Enable gtktiledviewer on Windows

A new configure argument is introduced:

  --with-gtk3-build=<absolute path to GTK3 build>

When provided, libreofficekit_selectionhandles package, libreofficekitgtk
library and gtktiledviewer executable would be built on Windows using the
GTK3 libraries in the passed directory, that must contain lib/pkgconfig
subdirectory with correct pkg-config data.

Change-Id: I6504af6eec0fc73cceb26a1ce923337abe14b5c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141624
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski 2022-10-20 12:55:41 +03:00
parent ffb9dcce39
commit d8c751008a
9 changed files with 114 additions and 43 deletions

View file

@ -82,6 +82,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \
visualbackendtest \
listfonts \
$(if $(and $(ENABLE_GTK3), $(filter LINUX %BSD SOLARIS,$(OS))), gtktiledviewer) \
$(if $(and $(ENABLE_GTKTILEDVIEWER), $(filter WNT,$(OS))), gtktiledviewer) \
$(if $(filter EMSCRIPTEN,$(OS)),wasm-qt5-mandelbrot) \
))
@ -655,6 +656,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,PLAINLIBS_OOO,ooo, \
$(if $(ENABLE_JAVA),hsqldb) \
i18nutil \
$(if $(and $(ENABLE_GTK3), $(filter LINUX %BSD SOLARIS,$(OS))), libreofficekitgtk) \
$(if $(and $(ENABLE_GTKTILEDVIEWER), $(filter WNT,$(OS))), libreofficekitgtk) \
$(if $(ENABLE_JAVA), \
$(if $(filter $(OS),MACOSX),,officebean) \
) \
@ -872,6 +874,7 @@ $(eval $(call gb_Helper_register_packages_for_install,calc,\
$(eval $(call gb_Helper_register_packages_for_install,libreofficekit,\
$(if $(filter LINUX %BSD SOLARIS, $(OS)),libreofficekit_selectionhandles) \
$(if $(and $(ENABLE_GTKTILEDVIEWER), $(filter WNT,$(OS))), libreofficekit_selectionhandles) \
))
$(eval $(call gb_Helper_register_packages_for_install,ure,\

View file

@ -167,6 +167,7 @@ export ENABLE_GPGMEPP=@ENABLE_GPGMEPP@
export ENABLE_GSTREAMER_1_0=@ENABLE_GSTREAMER_1_0@
export ENABLE_GTK3=@ENABLE_GTK3@
export ENABLE_GTK4=@ENABLE_GTK4@
export ENABLE_GTKTILEDVIEWER=@ENABLE_GTKTILEDVIEWER@
export DISABLE_GUI=@DISABLE_GUI@
export ENABLE_HEADLESS=@ENABLE_HEADLESS@
export ENABLE_HTMLHELP=@ENABLE_HTMLHELP@

View file

@ -46,6 +46,17 @@ FilterLibs()
# Return value: $filteredlibs
filteredlibs=
if test "$COM" = "MSC"; then
for f in $1; do
if test "x$f" != "x${f#-L}"; then
filteredlibs="$filteredlibs -LIBPATH:${f:2}"
elif test "x$f" != "x${f#-l}"; then
filteredlibs="$filteredlibs ${f:2}.lib"
else
filteredlibs="$filteredlibs $f"
fi
done
else
for f in $1; do
case "$f" in
# let's start with Fedora's paths for now
@ -59,6 +70,7 @@ FilterLibs()
;;
esac
done
fi
}
PathFormat()
@ -2681,6 +2693,11 @@ libo_FUZZ_ARG_WITH(latest-c++,
published standard.]),,
[with_latest_c__=no])
AC_ARG_WITH(gtk3-build,
AS_HELP_STRING([--with-gtk3-build=<absolute path to GTK3 build>],
[(Windows-only) In order to build GtkTiledViewer on Windows, pass the path
to a GTK3 build, like '--with-gtk3-build=C:/gtk-build/gtk/x64/release'.]))
dnl ===================================================================
dnl Branding
dnl ===================================================================
@ -11748,6 +11765,7 @@ dnl ===================================================================
GTK3_CFLAGS=""
GTK3_LIBS=""
ENABLE_GTKTILEDVIEWER=""
if test "$test_gtk3" = yes -a "x$enable_gtk3" = "xyes" -o "x$enable_gtk3_kde5" = "xyes"; then
if test "$with_system_cairo" = no; then
add_warning 'Non-system cairo combined with gtk3 is assumed to cause trouble; proceed at your own risk.'
@ -11765,9 +11783,23 @@ if test "$test_gtk3" = yes -a "x$enable_gtk3" = "xyes" -o "x$enable_gtk3_kde5" =
AC_CHECK_HEADER(EGL/eglplatform.h, [],
[AC_MSG_ERROR(EGL headers not found. install mesa-libEGL-devel)], [])
fi
elif test -n "$with_gtk3_build" -a "$OS" = "WNT"; then
PathFormat "${with_gtk3_build}/lib/pkgconfig"
if test "$build_os" = "cygwin"; then
dnl cygwin's pkg-config does not recognize "C:/..."-style paths, only "/cygdrive/c/..."
formatted_path_unix=`cygpath -au "$formatted_path_unix"`
fi
PKG_CONFIG_PATH="$formatted_path_unix"; export PKG_CONFIG_PATH
PKG_CHECK_MODULES(GTK3, cairo gdk-3.0 gio-2.0 glib-2.0 gobject-2.0 gtk+-3.0)
GTK3_CFLAGS="$GTK3_CFLAGS -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
FilterLibs "${GTK3_LIBS}"
GTK3_LIBS="${filteredlibs}"
ENABLE_GTKTILEDVIEWER="yes"
fi
AC_SUBST(GTK3_LIBS)
AC_SUBST(GTK3_CFLAGS)
AC_SUBST(ENABLE_GTKTILEDVIEWER)
GTK4_CFLAGS=""
GTK4_LIBS=""

View file

@ -15,6 +15,13 @@
#include <LibreOfficeKit/LibreOfficeKit.h>
// Avoid "error C2375: 'foo': redefinition; different linkage" on MSVC
#if defined LOK_DOC_VIEW_IMPLEMENTATION
#define LOK_DOC_VIEW_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
#else
#define LOK_DOC_VIEW_DLLPUBLIC
#endif
G_BEGIN_DECLS
#define LOK_TYPE_DOC_VIEW (lok_doc_view_get_type())
@ -38,7 +45,7 @@ struct _LOKDocViewClass
GtkDrawingAreaClass parent_class;
};
GType lok_doc_view_get_type (void) G_GNUC_CONST;
LOK_DOC_VIEW_DLLPUBLIC GType lok_doc_view_get_type (void) G_GNUC_CONST;
/**
* lok_doc_view_new:
@ -50,7 +57,7 @@ GType lok_doc_view_get_type (void) G_GNUC
*
* Returns: (transfer none): The #LOKDocView widget instance.
*/
GtkWidget* lok_doc_view_new (const gchar* pPath,
LOK_DOC_VIEW_DLLPUBLIC GtkWidget* lok_doc_view_new (const gchar* pPath,
GCancellable *cancellable,
GError **error);
@ -67,7 +74,7 @@ GtkWidget* lok_doc_view_new (const gchar*
*
* Returns: (transfer none): The #LOKDocView widget instance.
*/
GtkWidget* lok_doc_view_new_from_user_profile (const gchar* pPath,
LOK_DOC_VIEW_DLLPUBLIC GtkWidget* lok_doc_view_new_from_user_profile (const gchar* pPath,
const gchar* pUserProfile,
GCancellable *cancellable,
GError **error);
@ -79,7 +86,7 @@ GtkWidget* lok_doc_view_new_from_user_profile (const gchar*
*
* Returns: (transfer none): The #LOKDocView widget instance.
*/
GtkWidget* lok_doc_view_new_from_widget (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC GtkWidget* lok_doc_view_new_from_widget (LOKDocView* pDocView,
const gchar* pRenderingArguments);
/**
@ -91,7 +98,7 @@ GtkWidget* lok_doc_view_new_from_widget (LOKDocView*
* @callback:
* @userdata:
*/
void lok_doc_view_open_document (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC void lok_doc_view_open_document (LOKDocView* pDocView,
const gchar* pPath,
const gchar* pRenderingArguments,
GCancellable* cancellable,
@ -106,7 +113,7 @@ void lok_doc_view_open_document (LOKDocView*
*
* Returns: %TRUE if the document is loaded successfully, %FALSE otherwise
*/
gboolean lok_doc_view_open_document_finish (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC gboolean lok_doc_view_open_document_finish (LOKDocView* pDocView,
GAsyncResult* res,
GError** error);
@ -118,7 +125,7 @@ gboolean lok_doc_view_open_document_finish (LOKDocView*
*
* Returns: The #LibreOfficeKitDocument instance the widget is currently showing
*/
LibreOfficeKitDocument* lok_doc_view_get_document (LOKDocView* pDocView);
LOK_DOC_VIEW_DLLPUBLIC LibreOfficeKitDocument* lok_doc_view_get_document (LOKDocView* pDocView);
/**
* lok_doc_view_set_zoom:
@ -129,7 +136,7 @@ LibreOfficeKitDocument* lok_doc_view_get_document (LOKDocView*
* existing zoom level. Values outside the range [0.25, 5.0] are clamped into
* the nearest allowed value in the interval.
*/
void lok_doc_view_set_zoom (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC void lok_doc_view_set_zoom (LOKDocView* pDocView,
float fZoom);
/**
* lok_doc_view_set_visible_area:
@ -140,7 +147,7 @@ void lok_doc_view_set_zoom (LOKDocView*
* to jump the correct length, which depends on the amount of visible height of
* the document.
*/
void lok_doc_view_set_visible_area (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC void lok_doc_view_set_visible_area (LOKDocView* pDocView,
GdkRectangle* pVisibleArea);
/**
@ -149,7 +156,7 @@ void lok_doc_view_set_visible_area (LOKDocView*
*
* Returns: The current zoom factor value in float for pDocView
*/
gfloat lok_doc_view_get_zoom (LOKDocView* pDocView);
LOK_DOC_VIEW_DLLPUBLIC gfloat lok_doc_view_get_zoom (LOKDocView* pDocView);
/**
* lok_doc_view_get_parts:
@ -158,7 +165,7 @@ gfloat lok_doc_view_get_zoom (LOKDocView*
* Returns: Part refers to either individual sheets in a Calc, or slides in Impress,
* and has no relevance for Writer. Returns -1 if no document is set currently.
*/
gint lok_doc_view_get_parts (LOKDocView* pDocView);
LOK_DOC_VIEW_DLLPUBLIC gint lok_doc_view_get_parts (LOKDocView* pDocView);
/**
* lok_doc_view_get_part:
@ -166,14 +173,14 @@ gint lok_doc_view_get_parts (LOKDocView*
*
* Returns: Current part number of the document. Returns -1 if no document is set currently.
*/
gint lok_doc_view_get_part (LOKDocView* pDocView);
LOK_DOC_VIEW_DLLPUBLIC gint lok_doc_view_get_part (LOKDocView* pDocView);
/**
* lok_doc_view_set_part:
* @pDocView: The #LOKDocView instance
* @nPart:
*/
void lok_doc_view_set_part (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC void lok_doc_view_set_part (LOKDocView* pDocView,
int nPart);
/**
@ -184,7 +191,7 @@ void lok_doc_view_set_part (LOKDocView*
* Returns: Get current part name of loaded document. Returns null if no
* document is set, or document has been destroyed using lok_doc_view_destroy_document.
*/
gchar* lok_doc_view_get_part_name (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC gchar* lok_doc_view_get_part_name (LOKDocView* pDocView,
int nPart);
/**
@ -192,14 +199,14 @@ gchar* lok_doc_view_get_part_name (LOKDocView*
* @pDocView: The #LOKDocView instance
* @nPartMode:
*/
void lok_doc_view_set_partmode (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC void lok_doc_view_set_partmode (LOKDocView* pDocView,
int nPartMode);
/**
* lok_doc_view_reset_view:
* @pDocView: The #LOKDocView instance
*/
void lok_doc_view_reset_view (LOKDocView* pDocView);
LOK_DOC_VIEW_DLLPUBLIC void lok_doc_view_reset_view (LOKDocView* pDocView);
/**
* lok_doc_view_set_edit:
@ -208,7 +215,7 @@ void lok_doc_view_reset_view (LOKDocView*
*
* Sets if the viewer is actually an editor or not.
*/
void lok_doc_view_set_edit (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC void lok_doc_view_set_edit (LOKDocView* pDocView,
gboolean bEdit);
/**
@ -219,7 +226,7 @@ void lok_doc_view_set_edit (LOKDocView*
*
* Returns: %TRUE if the given pDocView is in edit mode.
*/
gboolean lok_doc_view_get_edit (LOKDocView* pDocView);
LOK_DOC_VIEW_DLLPUBLIC gboolean lok_doc_view_get_edit (LOKDocView* pDocView);
/**
* lok_doc_view_post_command:
@ -230,7 +237,7 @@ gboolean lok_doc_view_get_edit (LOKDocView*
*
* Posts the .uno: command to the LibreOfficeKit.
*/
void lok_doc_view_post_command (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC void lok_doc_view_post_command (LOKDocView* pDocView,
const gchar* pCommand,
const gchar* pArguments,
gboolean bNotifyWhenFinished);
@ -245,7 +252,7 @@ void lok_doc_view_post_command (LOKDocView*
*
* Returns: A json mapping of the possible values for the given command
*/
gchar * lok_doc_view_get_command_values (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC gchar * lok_doc_view_get_command_values (LOKDocView* pDocView,
const gchar* pCommand);
/**
@ -257,7 +264,7 @@ gchar * lok_doc_view_get_command_values (LOKDocView*
* Highlights the next matching text in the view. `search-not-found` signal will
* be emitted when no search is found
*/
void lok_doc_view_find_next (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC void lok_doc_view_find_next (LOKDocView* pDocView,
const gchar* pText,
gboolean bHighlightAll);
@ -270,7 +277,7 @@ void lok_doc_view_find_next (LOKDocView*
* Highlights the previous matching text in the view. `search-not-found` signal
* will be emitted when no search is found
*/
void lok_doc_view_find_prev (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC void lok_doc_view_find_prev (LOKDocView* pDocView,
const gchar* pText,
gboolean bHighlightAll);
@ -282,7 +289,7 @@ void lok_doc_view_find_prev (LOKDocView*
* Highlights all matching texts in the view. `search-not-found` signal
* will be emitted when no search is found
*/
void lok_doc_view_highlight_all (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC void lok_doc_view_highlight_all (LOKDocView* pDocView,
const gchar* pText);
/**
@ -295,7 +302,7 @@ void lok_doc_view_highlight_all (LOKDocView*
* Returns: Selected text. The caller must free the returned buffer after
* use. Returns null if no document is set.
*/
gchar* lok_doc_view_copy_selection (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC gchar* lok_doc_view_copy_selection (LOKDocView* pDocView,
const gchar* pMimeType,
gchar** pUsedMimeType);
@ -310,7 +317,7 @@ gchar* lok_doc_view_copy_selection (LOKDocView*
*
* Returns: if pData was pasted successfully.
*/
gboolean lok_doc_view_paste (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC gboolean lok_doc_view_paste (LOKDocView* pDocView,
const gchar* pMimeType,
const gchar* pData,
gsize nSize);
@ -323,7 +330,7 @@ gboolean lok_doc_view_paste (LOKDocView*
*
* Set the password for password protected documents
*/
void lok_doc_view_set_document_password (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC void lok_doc_view_set_document_password (LOKDocView* pDocView,
const gchar* pURL,
const gchar* pPassword);
@ -341,7 +348,7 @@ void lok_doc_view_set_document_password (LOKDocView*
* "ProductExtension": ".0.0.alpha0",
* "BuildId": "<full 40 char git hash>"}
*/
gchar* lok_doc_view_get_version_info (LOKDocView* pDocView);
LOK_DOC_VIEW_DLLPUBLIC gchar* lok_doc_view_get_version_info (LOKDocView* pDocView);
/**
* lok_doc_view_pixel_to_twip:
@ -352,7 +359,7 @@ gchar* lok_doc_view_get_version_info (LOKDocView*
*
* Returns: The corresponding value in twips
*/
gfloat lok_doc_view_pixel_to_twip (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC gfloat lok_doc_view_pixel_to_twip (LOKDocView* pDocView,
float fInput);
/**
@ -364,7 +371,7 @@ gfloat lok_doc_view_pixel_to_twip (LOKDocView*
*
* Returns: The corresponding value in pixels
*/
gfloat lok_doc_view_twip_to_pixel (LOKDocView* pDocView,
LOK_DOC_VIEW_DLLPUBLIC gfloat lok_doc_view_twip_to_pixel (LOKDocView* pDocView,
float fInput);
/**
@ -372,7 +379,7 @@ gfloat lok_doc_view_twip_to_pixel (LOKDocView*
* @pDocView: The #LOKDocView instance
* @pArguments: (nullable) (allow-none): see lok::Document::sendContentControlEvent() for the details.
*/
void lok_doc_view_send_content_control_event(LOKDocView* pDocView, const gchar* pArguments);
LOK_DOC_VIEW_DLLPUBLIC void lok_doc_view_send_content_control_event(LOKDocView* pDocView, const gchar* pArguments);
G_END_DECLS

View file

@ -29,12 +29,17 @@ $(eval $(call gb_Executable_add_cxxflags,gtktiledviewer,\
$(eval $(call gb_Executable_add_libs,gtktiledviewer,\
$(GTK3_LIBS) \
))
ifneq ($(OS), WNT)
$(eval $(call gb_Executable_add_libs,gtktiledviewer,\
-lX11 \
-lXext \
-lXrender \
-lSM \
-lICE \
))
endif
$(eval $(call gb_Executable_use_libraries,gtktiledviewer,\
libreofficekitgtk \

View file

@ -31,6 +31,7 @@ $(eval $(call gb_Library_add_libs,libreofficekitgtk,\
$(eval $(call gb_Library_add_defs,libreofficekitgtk,\
-DLOK_PATH="\"$(LIBDIR)/libreoffice/$(LIBO_LIB_FOLDER)\"" \
-DLOK_DOC_VIEW_IMPLEMENTATION \
))
ifeq ($(OS),$(filter LINUX %BSD SOLARIS, $(OS)))

View file

@ -33,6 +33,16 @@ $(eval $(call gb_Module_add_targets,libreofficekit,\
UIConfig_libreofficekit \
))
else ifeq ($(OS),WNT)
ifneq ($(ENABLE_GTKTILEDVIEWER),)
$(eval $(call gb_Module_add_targets,libreofficekit,\
Library_libreofficekitgtk \
Executable_gtktiledviewer \
Package_selectionhandles \
))
endif
endif
# vim: set ts=4 sw=4 et:

View file

@ -97,6 +97,19 @@ To debug with `gdb`:
before `bin/run`, this will run gtktiledviewer in the debugger instead.
### Building and running gtktiledviewer on Windows
A pre-requisite is pre-built GTK3 libraries. See [official GTK documentation](https://www.gtk.org/docs/installations/windows/).
Building of gtktiledviewer on Windows is enabled by passing
--with-gtk3-build=<path/to/GTK3/build/directory>
to configure.
Running the compiled executable requires GTK's bin in PATH:
PATH=${PATH}:/cygdrive/c/gtk-build/gtk/x64/release/bin bin/run gtktiledviewer --lo-path=$(cygpath -am $PWD/instdir/program) ../test.odt
## LibreOfficeKitGtk
Currently consists of only a very basic GTK document viewer widget.

View file

@ -338,7 +338,6 @@ static void lok_doc_view_initable_iface_init (GInitableIface *iface);
static void callbackWorker (int nType, const char* pPayload, void* pData);
static void updateClientZoom (LOKDocView *pDocView);
SAL_DLLPUBLIC_EXPORT GType lok_doc_view_get_type();
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"