[Libreoffice-commits] core.git: Branch 'feature/gsoc-tiled-rendering' - 7 commits - include/LibreOfficeKit libreofficekit/qa libreofficekit/source
Pranav Kant
pranavk at gnome.org
Fri Jun 5 14:47:58 PDT 2015
include/LibreOfficeKit/LibreOfficeKitGtk.h | 73 +++----
libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 52 ++---
libreofficekit/source/gtk/lokdocview.cxx | 196 +++++++++-----------
3 files changed, 162 insertions(+), 159 deletions(-)
New commits:
commit f5795aa66eef527a658cedb758cfba715b596655
Author: Pranav Kant <pranavk at gnome.org>
Date: Sat Jun 6 03:10:31 2015 +0530
lokdocview: Modernise LOKDocView as GObject
Change-Id: I3bbd07ce8163890f9b88567966622dd4fbe9d94d
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index 069c565..747e45e 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -18,9 +18,13 @@
G_BEGIN_DECLS
-#define LOK_DOC_VIEW(obj) GTK_CHECK_CAST (obj, lok_doc_view_get_type(), LOKDocView)
-#define LOK_DOC_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, lok_doc_view_get_type(), LOKDocViewClass)
-#define IS_LOK_DOC_VIEW(obj) GTK_CHECK_TYPE (obj, lok_doc_view_get_type())
+#define LOK_TYPE_DOC_VIEW (lok_doc_view_get_type())
+#define LOK_DOC_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LOK_TYPE_DOC_VIEW, LOKDocView))
+#define LOK_IS_DOC_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LOK_TYPE_DOC_VIEW))
+#define LOK_DOC_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LOK_TYPE_DOC_VIEW, LOKDocViewClass))
+#define LOK_IS_DOC_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), LOK_TYPE_DOC_VIEW))
+#define LOK_DOC_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), LOK_TYPE_DOC_VIEW, LOKDocViewClass))
+
typedef struct _LOKDocView LOKDocView;
typedef struct _LOKDocViewClass LOKDocViewClass;
@@ -40,40 +44,45 @@ struct _LOKDocViewClass
void (* part_changed) (LOKDocView* pView, int new_part);
};
-guint lok_doc_view_get_type (void);
-GtkWidget* lok_doc_view_new ( LibreOfficeKit* pOffice );
-gboolean lok_doc_view_open_document (LOKDocView* pDocView,
- char* pPath);
+GType lok_doc_view_get_type (void);
+GtkWidget* lok_doc_view_new (LibreOfficeKit* pOffice );
+gboolean lok_doc_view_open_document (LOKDocView* pDocView,
+ char* pPath);
/// Gets the document the viewer displays.
-LibreOfficeKitDocument* lok_doc_view_get_document(LOKDocView* pDocView);
-
-void lok_doc_view_set_zoom (LOKDocView* pDocView,
- float fZoom);
-float lok_doc_view_get_zoom (LOKDocView* pDocView);
-
-int lok_doc_view_get_parts (LOKDocView* pDocView);
-int lok_doc_view_get_part (LOKDocView* pDocView);
-void lok_doc_view_set_part (LOKDocView* pDocView,
- int nPart);
-char* lok_doc_view_get_part_name (LOKDocView* pDocView,
- int nPart);
-void lok_doc_view_set_partmode (LOKDocView* pDocView,
- int nPartMode);
+LibreOfficeKitDocument* lok_doc_view_get_document (LOKDocView* pDocView);
+
+void lok_doc_view_set_zoom (LOKDocView* pDocView,
+ float fZoom);
+float lok_doc_view_get_zoom (LOKDocView* pDocView);
+
+int lok_doc_view_get_parts (LOKDocView* pDocView);
+int lok_doc_view_get_part (LOKDocView* pDocView);
+void lok_doc_view_set_part (LOKDocView* pDocView,
+ int nPart);
+char* lok_doc_view_get_part_name (LOKDocView* pDocView,
+ int nPart);
+void lok_doc_view_set_partmode (LOKDocView* pDocView,
+ int nPartMode);
/// Sets if the viewer is actually an editor or not.
-void lok_doc_view_set_edit (LOKDocView* pDocView,
- gboolean bEdit);
+void lok_doc_view_set_edit (LOKDocView* pDocView,
+ gboolean bEdit);
/// Gets if the viewer is actually an editor or not.
-gboolean lok_doc_view_get_edit (LOKDocView* pDocView);
+gboolean lok_doc_view_get_edit (LOKDocView* pDocView);
/// Posts the .uno: command to the LibreOfficeKit.
-void lok_doc_view_post_command (LOKDocView* pDocView, const char* pCommand, const char* pArguments);
+void lok_doc_view_post_command (LOKDocView* pDocView,
+ const char* pCommand,
+ const char* pArguments);
/// Posts a keyboard event to LibreOfficeKit.
-void lok_doc_view_post_key (GtkWidget* pWidget, GdkEventKey* pEvent, gpointer pData);
+void lok_doc_view_post_key (GtkWidget* pWidget,
+ GdkEventKey* pEvent,
+ gpointer pData);
/// Get the visible area of the document (in twips).
-void lok_doc_view_get_visarea(LOKDocView* pThis, GdkRectangle* pArea);
+void lok_doc_view_get_visarea (LOKDocView* pThis,
+ GdkRectangle* pArea);
G_END_DECLS
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index d34488a..b6c529f 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -37,26 +37,6 @@
// Number of handles around a graphic selection.
#define GRAPHIC_HANDLE_COUNT 8
-namespace {
-
-/// Sets rWidth and rHeight from a "width, height" string.
-void payloadToSize(const char* pPayload, long& rWidth, long& rHeight)
-{
- rWidth = rHeight = 0;
- gchar** ppCoordinates = g_strsplit(pPayload, ", ", 2);
- gchar** ppCoordinate = ppCoordinates;
- if (!*ppCoordinate)
- return;
- rWidth = atoi(*ppCoordinate);
- ++ppCoordinate;
- if (!*ppCoordinate)
- return;
- rHeight = atoi(*ppCoordinate);
- g_strfreev(ppCoordinates);
-}
-
-}
-
/// Holds data used by LOKDocView only.
struct LOKDocView_Impl
{
@@ -216,6 +196,44 @@ struct LOKDocView_Impl
void setTilesInvalid(const GdkRectangle& rRectangle);
};
+enum
+{
+ EDIT_CHANGED,
+ COMMAND_CHANGED,
+ SEARCH_NOT_FOUND,
+ PART_CHANGED,
+ LAST_SIGNAL
+};
+
+
+static guint doc_view_signals[LAST_SIGNAL] = { 0 };
+
+
+G_DEFINE_TYPE(LOKDocView, lok_doc_view, GTK_TYPE_SCROLLED_WINDOW)
+
+
+namespace {
+
+/// Sets rWidth and rHeight from a "width, height" string.
+void payloadToSize(const char* pPayload, long& rWidth, long& rHeight)
+{
+ rWidth = rHeight = 0;
+ gchar** ppCoordinates = g_strsplit(pPayload, ", ", 2);
+ gchar** ppCoordinate = ppCoordinates;
+ if (!*ppCoordinate)
+ return;
+ rWidth = atoi(*ppCoordinate);
+ ++ppCoordinate;
+ if (!*ppCoordinate)
+ return;
+ rHeight = atoi(*ppCoordinate);
+ g_strfreev(ppCoordinates);
+}
+
+}
+
+
+
namespace {
/// Implementation of the global callback handler, invoked by globalCallback();
@@ -1073,16 +1091,7 @@ void LOKDocView_Impl::globalCallbackWorkerImpl(int nType, const char* pPayload)
#endif
}
-enum
-{
- EDIT_CHANGED,
- COMMAND_CHANGED,
- SEARCH_NOT_FOUND,
- PART_CHANGED,
- LAST_SIGNAL
-};
-static guint doc_view_signals[LAST_SIGNAL] = { 0 };
void LOKDocView_Impl::commandChanged(const std::string& rString)
{
@@ -1100,9 +1109,8 @@ void LOKDocView_Impl::setPart(const std::string& rString)
renderDocument(0);
}
-static void lok_doc_view_class_init( gpointer ptr )
+static void lok_doc_view_class_init (LOKDocViewClass* pClass)
{
- LOKDocViewClass* pClass = static_cast<LOKDocViewClass *>(ptr);
GObjectClass *gobject_class = G_OBJECT_CLASS(pClass);
pClass->edit_changed = NULL;
doc_view_signals[EDIT_CHANGED] =
@@ -1146,9 +1154,8 @@ static void lok_doc_view_class_init( gpointer ptr )
G_TYPE_INT);
}
-static void lok_doc_view_init( GTypeInstance* pInstance, gpointer )
+static void lok_doc_view_init (LOKDocView* pDocView)
{
- LOKDocView* pDocView = reinterpret_cast<LOKDocView *>(pInstance);
// Gtk ScrolledWindow is apparently not fully initialised yet, we specifically
// have to set the [hv]adjustment to prevent GTK assertions from firing, see
// https://bugzilla.gnome.org/show_bug.cgi?id=438114 for more info.
@@ -1183,29 +1190,7 @@ static void lok_doc_view_init( GTypeInstance* pInstance, gpointer )
g_signal_connect(G_OBJECT(pDocView), "destroy", G_CALLBACK(LOKDocView_Impl::destroy), 0);
}
-SAL_DLLPUBLIC_EXPORT guint lok_doc_view_get_type()
-{
- static guint lok_doc_view_type = 0;
-
- if (!lok_doc_view_type)
- {
- char pName[] = "LokDocView";
- GtkTypeInfo lok_doc_view_info =
- {
- pName,
- sizeof( LOKDocView ),
- sizeof( LOKDocViewClass ),
- lok_doc_view_class_init,
- lok_doc_view_init,
- NULL,
- NULL,
- (GtkClassInitFunc) NULL
- };
-
- lok_doc_view_type = gtk_type_unique( gtk_scrolled_window_get_type(), &lok_doc_view_info );
- }
- return lok_doc_view_type;
-}
+SAL_DLLPUBLIC_EXPORT GType lok_doc_view_get_type();
SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new( LibreOfficeKit* pOffice )
{
commit 2e54caf962561b0b304bdffbaa7f070eca91cf23
Author: Pranav Kant <pranavk at gnome.org>
Date: Sat Jun 6 02:32:54 2015 +0530
lokdocview: Lets follow the GObject naming convention
If we are mentioning this type as DocView, we should break it at each
capital letter.
Change-Id: I76c7eea455281e541b2196a03778018aa127cebe
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index 9668904..069c565 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -18,9 +18,9 @@
G_BEGIN_DECLS
-#define LOK_DOCVIEW(obj) GTK_CHECK_CAST (obj, lok_docview_get_type(), LOKDocView)
-#define LOK_DOCVIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, lok_docview_get_type(), LOKDocViewClass)
-#define IS_LOK_DOCVIEW(obj) GTK_CHECK_TYPE (obj, lok_docview_get_type())
+#define LOK_DOC_VIEW(obj) GTK_CHECK_CAST (obj, lok_doc_view_get_type(), LOKDocView)
+#define LOK_DOC_VIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, lok_doc_view_get_type(), LOKDocViewClass)
+#define IS_LOK_DOC_VIEW(obj) GTK_CHECK_TYPE (obj, lok_doc_view_get_type())
typedef struct _LOKDocView LOKDocView;
typedef struct _LOKDocViewClass LOKDocViewClass;
@@ -40,40 +40,40 @@ struct _LOKDocViewClass
void (* part_changed) (LOKDocView* pView, int new_part);
};
-guint lok_docview_get_type (void);
-GtkWidget* lok_docview_new ( LibreOfficeKit* pOffice );
-gboolean lok_docview_open_document (LOKDocView* pDocView,
+guint lok_doc_view_get_type (void);
+GtkWidget* lok_doc_view_new ( LibreOfficeKit* pOffice );
+gboolean lok_doc_view_open_document (LOKDocView* pDocView,
char* pPath);
/// Gets the document the viewer displays.
-LibreOfficeKitDocument* lok_docview_get_document(LOKDocView* pDocView);
+LibreOfficeKitDocument* lok_doc_view_get_document(LOKDocView* pDocView);
-void lok_docview_set_zoom (LOKDocView* pDocView,
+void lok_doc_view_set_zoom (LOKDocView* pDocView,
float fZoom);
-float lok_docview_get_zoom (LOKDocView* pDocView);
+float lok_doc_view_get_zoom (LOKDocView* pDocView);
-int lok_docview_get_parts (LOKDocView* pDocView);
-int lok_docview_get_part (LOKDocView* pDocView);
-void lok_docview_set_part (LOKDocView* pDocView,
+int lok_doc_view_get_parts (LOKDocView* pDocView);
+int lok_doc_view_get_part (LOKDocView* pDocView);
+void lok_doc_view_set_part (LOKDocView* pDocView,
int nPart);
-char* lok_docview_get_part_name (LOKDocView* pDocView,
+char* lok_doc_view_get_part_name (LOKDocView* pDocView,
int nPart);
-void lok_docview_set_partmode (LOKDocView* pDocView,
+void lok_doc_view_set_partmode (LOKDocView* pDocView,
int nPartMode);
/// Sets if the viewer is actually an editor or not.
-void lok_docview_set_edit (LOKDocView* pDocView,
+void lok_doc_view_set_edit (LOKDocView* pDocView,
gboolean bEdit);
/// Gets if the viewer is actually an editor or not.
-gboolean lok_docview_get_edit (LOKDocView* pDocView);
+gboolean lok_doc_view_get_edit (LOKDocView* pDocView);
/// Posts the .uno: command to the LibreOfficeKit.
-void lok_docview_post_command (LOKDocView* pDocView, const char* pCommand, const char* pArguments);
+void lok_doc_view_post_command (LOKDocView* pDocView, const char* pCommand, const char* pArguments);
/// Posts a keyboard event to LibreOfficeKit.
-void lok_docview_post_key (GtkWidget* pWidget, GdkEventKey* pEvent, gpointer pData);
+void lok_doc_view_post_key (GtkWidget* pWidget, GdkEventKey* pEvent, gpointer pData);
/// Get the visible area of the document (in twips).
-void lok_docview_get_visarea(LOKDocView* pThis, GdkRectangle* pArea);
+void lok_doc_view_get_visarea(LOKDocView* pThis, GdkRectangle* pArea);
G_END_DECLS
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index d20f43d..38b29ee 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -71,7 +71,7 @@ static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ )
if ( pDocView )
{
- fCurrentZoom = lok_docview_get_zoom( LOK_DOCVIEW(pDocView) );
+ fCurrentZoom = lok_doc_view_get_zoom( LOK_DOC_VIEW(pDocView) );
}
if ( strcmp(sName, "gtk-zoom-in") == 0)
@@ -104,7 +104,7 @@ static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ )
{
if ( pDocView )
{
- lok_docview_set_zoom( LOK_DOCVIEW(pDocView), fZoom );
+ lok_doc_view_set_zoom( LOK_DOC_VIEW(pDocView), fZoom );
}
}
}
@@ -112,10 +112,10 @@ static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ )
/// User clicked on the button -> inform LOKDocView.
static void toggleEditing(GtkWidget* /*pButton*/, gpointer /*pItem*/)
{
- LOKDocView* pLOKDocView = LOK_DOCVIEW(pDocView);
+ LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView);
bool bActive = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(pEnableEditing));
- if (bool(lok_docview_get_edit(pLOKDocView)) != bActive)
- lok_docview_set_edit(pLOKDocView, bActive);
+ if (bool(lok_doc_view_get_edit(pLOKDocView)) != bActive)
+ lok_doc_view_set_edit(pLOKDocView, bActive);
}
/// Toggle the visibility of the findbar.
@@ -137,11 +137,11 @@ static void toggleFindbar(GtkWidget* /*pButton*/, gpointer /*pItem*/)
/// Handles the key-press-event of the window.
static gboolean signalKey(GtkWidget* pWidget, GdkEventKey* pEvent, gpointer pData)
{
- LOKDocView* pLOKDocView = LOK_DOCVIEW(pDocView);
+ LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView);
#if GTK_CHECK_VERSION(2,18,0) // we need gtk_widget_get_visible()
- if (!gtk_widget_get_visible(pFindbar) && bool(lok_docview_get_edit(pLOKDocView)))
+ if (!gtk_widget_get_visible(pFindbar) && bool(lok_doc_view_get_edit(pLOKDocView)))
{
- lok_docview_post_key(pWidget, pEvent, pData);
+ lok_doc_view_post_key(pWidget, pEvent, pData);
return TRUE;
}
#endif
@@ -159,9 +159,9 @@ static void doSearch(bool bBackwards)
aTree.put(boost::property_tree::ptree::path_type("SearchItem.Backward/type", '/'), "boolean");
aTree.put(boost::property_tree::ptree::path_type("SearchItem.Backward/value", '/'), bBackwards);
- LOKDocView* pLOKDocView = LOK_DOCVIEW(pDocView);
+ LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView);
GdkRectangle aArea;
- lok_docview_get_visarea(pLOKDocView, &aArea);
+ lok_doc_view_get_visarea(pLOKDocView, &aArea);
aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchStartPointX/type", '/'), "long");
aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchStartPointX/value", '/'), aArea.x);
aTree.put(boost::property_tree::ptree::path_type("SearchItem.SearchStartPointY/type", '/'), "long");
@@ -170,7 +170,7 @@ static void doSearch(bool bBackwards)
std::stringstream aStream;
boost::property_tree::write_json(aStream, aTree);
- lok_docview_post_command(pLOKDocView, ".uno:ExecuteSearch", aStream.str().c_str());
+ lok_doc_view_post_command(pLOKDocView, ".uno:ExecuteSearch", aStream.str().c_str());
}
/// Click handler for the search next button.
@@ -210,8 +210,8 @@ static gboolean signalFindbar(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpoin
/// LOKDocView changed edit state -> inform the tool button.
static void signalEdit(LOKDocView* pLOKDocView, gboolean bWasEdit, gpointer /*pData*/)
{
- gboolean bEdit = lok_docview_get_edit(pLOKDocView);
- g_info("signalEdit: %d -> %d", bWasEdit, lok_docview_get_edit(pLOKDocView));
+ gboolean bEdit = lok_doc_view_get_edit(pLOKDocView);
+ g_info("signalEdit: %d -> %d", bWasEdit, lok_doc_view_get_edit(pLOKDocView));
if (gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(pEnableEditing)) != bEdit)
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(pEnableEditing), bEdit);
}
@@ -233,7 +233,7 @@ static void signalCommand(LOKDocView* /*pLOKDocView*/, char* pPayload, gpointer
gboolean bEdit = aValue == "true";
if (gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(pItem)) != bEdit)
{
- // Avoid invoking lok_docview_post_command().
+ // Avoid invoking lok_doc_view_post_command().
g_bToolItemBroadcast = false;
gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(pItem), bEdit);
g_bToolItemBroadcast = true;
@@ -262,11 +262,11 @@ static void toggleToolItem(GtkWidget* pWidget, gpointer /*pData*/)
{
if (g_bToolItemBroadcast)
{
- LOKDocView* pLOKDocView = LOK_DOCVIEW(pDocView);
+ LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView);
GtkToolItem* pItem = GTK_TOOL_ITEM(pWidget);
const std::string& rString = g_aToolItemCommandNames[pItem];
- g_info("toggleToolItem: lok_docview_post_command('%s')", rString.c_str());
- lok_docview_post_command(pLOKDocView, rString.c_str(), 0);
+ g_info("toggleToolItem: lok_doc_view_post_command('%s')", rString.c_str());
+ lok_doc_view_post_command(pLOKDocView, rString.c_str(), 0);
}
}
@@ -286,10 +286,10 @@ static void populatePartSelector()
const int nMaxLength = 50;
char sText[nMaxLength];
- int nParts = lok_docview_get_parts( LOK_DOCVIEW(pDocView) );
+ int nParts = lok_doc_view_get_parts( LOK_DOC_VIEW(pDocView) );
for ( int i = 0; i < nParts; i++ )
{
- char* pName = lok_docview_get_part_name( LOK_DOCVIEW(pDocView), i );
+ char* pName = lok_doc_view_get_part_name( LOK_DOC_VIEW(pDocView), i );
assert( pName );
snprintf( sText, nMaxLength, "%i (%s)", i+1, pName );
free( pName );
@@ -297,7 +297,7 @@ static void populatePartSelector()
gtk_combo_box_text_append_text( pPartSelector, sText );
}
gtk_combo_box_set_active( GTK_COMBO_BOX(pPartSelector),
- lok_docview_get_part( LOK_DOCVIEW(pDocView) ) );
+ lok_doc_view_get_part( LOK_DOC_VIEW(pDocView) ) );
}
static void changePart( GtkWidget* pSelector, gpointer /* pItem */ )
@@ -306,7 +306,7 @@ static void changePart( GtkWidget* pSelector, gpointer /* pItem */ )
if (g_bPartSelectorBroadcast && pDocView)
{
- lok_docview_set_part( LOK_DOCVIEW(pDocView), nPart );
+ lok_doc_view_set_part( LOK_DOC_VIEW(pDocView), nPart );
}
}
@@ -326,7 +326,7 @@ static void changePartMode( GtkWidget* pSelector, gpointer /* pItem */ )
if ( pDocView )
{
- lok_docview_set_partmode( LOK_DOCVIEW(pDocView), ePartMode );
+ lok_doc_view_set_partmode( LOK_DOC_VIEW(pDocView), ePartMode );
}
}
#endif
@@ -451,7 +451,7 @@ int main( int argc, char* argv[] )
gtk_box_pack_end(GTK_BOX(pVBox), pFindbar, FALSE, FALSE, 0);
// Docview
- pDocView = lok_docview_new( pOffice );
+ pDocView = lok_doc_view_new( pOffice );
g_signal_connect(pDocView, "edit-changed", G_CALLBACK(signalEdit), NULL);
g_signal_connect(pDocView, "command-changed", G_CALLBACK(signalCommand), NULL);
g_signal_connect(pDocView, "search-not-found", G_CALLBACK(signalSearch), NULL);
@@ -467,10 +467,10 @@ int main( int argc, char* argv[] )
// Hide the findbar by default.
gtk_widget_hide(pFindbar);
- int bOpened = lok_docview_open_document( LOK_DOCVIEW(pDocView), argv[2] );
+ int bOpened = lok_doc_view_open_document( LOK_DOC_VIEW(pDocView), argv[2] );
if (!bOpened)
- g_error("main: lok_docview_open_document() failed with '%s'", pOffice->pClass->getError(pOffice));
- assert(lok_docview_get_document(LOK_DOCVIEW(pDocView)));
+ g_error("main: lok_doc_view_open_document() failed with '%s'", pOffice->pClass->getError(pOffice));
+ assert(lok_doc_view_get_document(LOK_DOC_VIEW(pDocView)));
// GtkComboBox requires gtk 2.24 or later
#if ( GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 24 ) || GTK_MAJOR_VERSION > 2
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 53dff28..d34488a 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -123,7 +123,7 @@ struct LOKDocView_Impl
bool m_bInDragGraphicHandles[8];
///@}
- /// Callback data, allocated in lok_docview_callback_worker(), released in lok_docview_callback().
+ /// Callback data, allocated in lok_doc_view_callback_worker(), released in lok_doc_view_callback().
struct CallbackData
{
int m_nType;
@@ -305,7 +305,7 @@ void LOKDocView_Impl::destroy(LOKDocView* pDocView, gpointer /*pData*/)
void LOKDocView_Impl::on_exposed(GtkWidget* /*widget*/, GdkEvent* /*event*/, gpointer userdata)
{
- LOKDocView *pDocView = LOK_DOCVIEW (userdata);
+ LOKDocView *pDocView = LOK_DOC_VIEW (userdata);
pDocView->m_pImpl->renderDocument(0);
}
@@ -461,7 +461,7 @@ gboolean LOKDocView_Impl::signalButtonImpl(GdkEventButton* pEvent)
}
if (!m_bEdit)
- lok_docview_set_edit(m_pDocView, TRUE);
+ lok_doc_view_set_edit(m_pDocView, TRUE);
switch (pEvent->type)
{
@@ -782,7 +782,7 @@ gboolean LOKDocView_Impl::handleTimeoutImpl()
void LOKDocView_Impl::renderDocument(GdkRectangle* pPartial)
{
GdkRectangle visibleArea;
- lok_docview_get_visarea (m_pDocView, &visibleArea);
+ lok_doc_view_get_visarea (m_pDocView, &visibleArea);
long nDocumentWidthPixels = twipToPixel(m_nDocumentWidthTwips, m_fZoom);
long nDocumentHeightPixels = twipToPixel(m_nDocumentHeightTwips, m_fZoom);
@@ -1058,7 +1058,7 @@ void LOKDocView_Impl::globalCallbackWorker(int nType, const char* pPayload, void
void LOKDocView_Impl::callbackWorkerImpl(int nType, const char* pPayload)
{
LOKDocView_Impl::CallbackData* pCallback = new LOKDocView_Impl::CallbackData(nType, pPayload ? pPayload : "(nil)", m_pDocView);
- g_info("lok_docview_callback_worker: %s, '%s'", LOKDocView_Impl::callbackTypeToString(nType), pPayload);
+ g_info("lok_doc_view_callback_worker: %s, '%s'", LOKDocView_Impl::callbackTypeToString(nType), pPayload);
#if GTK_CHECK_VERSION(2,12,0)
gdk_threads_add_idle(LOKDocView_Impl::callback, pCallback);
#endif
@@ -1082,30 +1082,30 @@ enum
LAST_SIGNAL
};
-static guint docview_signals[LAST_SIGNAL] = { 0 };
+static guint doc_view_signals[LAST_SIGNAL] = { 0 };
void LOKDocView_Impl::commandChanged(const std::string& rString)
{
- g_signal_emit(m_pDocView, docview_signals[COMMAND_CHANGED], 0, rString.c_str());
+ g_signal_emit(m_pDocView, doc_view_signals[COMMAND_CHANGED], 0, rString.c_str());
}
void LOKDocView_Impl::searchNotFound(const std::string& rString)
{
- g_signal_emit(m_pDocView, docview_signals[SEARCH_NOT_FOUND], 0, rString.c_str());
+ g_signal_emit(m_pDocView, doc_view_signals[SEARCH_NOT_FOUND], 0, rString.c_str());
}
void LOKDocView_Impl::setPart(const std::string& rString)
{
- g_signal_emit(m_pDocView, docview_signals[PART_CHANGED], 0, std::stoi(rString));
+ g_signal_emit(m_pDocView, doc_view_signals[PART_CHANGED], 0, std::stoi(rString));
renderDocument(0);
}
-static void lok_docview_class_init( gpointer ptr )
+static void lok_doc_view_class_init( gpointer ptr )
{
LOKDocViewClass* pClass = static_cast<LOKDocViewClass *>(ptr);
GObjectClass *gobject_class = G_OBJECT_CLASS(pClass);
pClass->edit_changed = NULL;
- docview_signals[EDIT_CHANGED] =
+ doc_view_signals[EDIT_CHANGED] =
g_signal_new("edit-changed",
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST,
@@ -1115,7 +1115,7 @@ static void lok_docview_class_init( gpointer ptr )
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
pClass->command_changed = NULL;
- docview_signals[COMMAND_CHANGED] =
+ doc_view_signals[COMMAND_CHANGED] =
g_signal_new("command-changed",
G_TYPE_FROM_CLASS(gobject_class),
G_SIGNAL_RUN_FIRST,
@@ -1125,7 +1125,7 @@ static void lok_docview_class_init( gpointer ptr )
G_TYPE_NONE, 1,
G_TYPE_STRING);
pClass->search_not_found = 0;
- docview_signals[SEARCH_NOT_FOUND] =
+ doc_view_signals[SEARCH_NOT_FOUND] =
g_signal_new("search-not-found",
G_TYPE_FROM_CLASS(gobject_class),
G_SIGNAL_RUN_FIRST,
@@ -1135,7 +1135,7 @@ static void lok_docview_class_init( gpointer ptr )
G_TYPE_NONE, 1,
G_TYPE_STRING);
pClass->part_changed = 0;
- docview_signals[PART_CHANGED] =
+ doc_view_signals[PART_CHANGED] =
g_signal_new("part-changed",
G_TYPE_FROM_CLASS(gobject_class),
G_SIGNAL_RUN_FIRST,
@@ -1146,7 +1146,7 @@ static void lok_docview_class_init( gpointer ptr )
G_TYPE_INT);
}
-static void lok_docview_init( GTypeInstance* pInstance, gpointer )
+static void lok_doc_view_init( GTypeInstance* pInstance, gpointer )
{
LOKDocView* pDocView = reinterpret_cast<LOKDocView *>(pInstance);
// Gtk ScrolledWindow is apparently not fully initialised yet, we specifically
@@ -1183,38 +1183,38 @@ static void lok_docview_init( GTypeInstance* pInstance, gpointer )
g_signal_connect(G_OBJECT(pDocView), "destroy", G_CALLBACK(LOKDocView_Impl::destroy), 0);
}
-SAL_DLLPUBLIC_EXPORT guint lok_docview_get_type()
+SAL_DLLPUBLIC_EXPORT guint lok_doc_view_get_type()
{
- static guint lok_docview_type = 0;
+ static guint lok_doc_view_type = 0;
- if (!lok_docview_type)
+ if (!lok_doc_view_type)
{
char pName[] = "LokDocView";
- GtkTypeInfo lok_docview_info =
+ GtkTypeInfo lok_doc_view_info =
{
pName,
sizeof( LOKDocView ),
sizeof( LOKDocViewClass ),
- lok_docview_class_init,
- lok_docview_init,
+ lok_doc_view_class_init,
+ lok_doc_view_init,
NULL,
NULL,
(GtkClassInitFunc) NULL
};
- lok_docview_type = gtk_type_unique( gtk_scrolled_window_get_type(), &lok_docview_info );
+ lok_doc_view_type = gtk_type_unique( gtk_scrolled_window_get_type(), &lok_doc_view_info );
}
- return lok_docview_type;
+ return lok_doc_view_type;
}
-SAL_DLLPUBLIC_EXPORT GtkWidget* lok_docview_new( LibreOfficeKit* pOffice )
+SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new( LibreOfficeKit* pOffice )
{
- LOKDocView* pDocView = LOK_DOCVIEW(gtk_type_new(lok_docview_get_type()));
+ LOKDocView* pDocView = LOK_DOC_VIEW(gtk_type_new(lok_doc_view_get_type()));
pDocView->m_pImpl->m_pOffice = pOffice;
return GTK_WIDGET( pDocView );
}
-SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, char* pPath )
+SAL_DLLPUBLIC_EXPORT gboolean lok_doc_view_open_document( LOKDocView* pDocView, char* pPath )
{
if ( pDocView->m_pImpl->m_pDocument )
{
@@ -1260,12 +1260,12 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, c
return TRUE;
}
-SAL_DLLPUBLIC_EXPORT LibreOfficeKitDocument* lok_docview_get_document(LOKDocView* pDocView)
+SAL_DLLPUBLIC_EXPORT LibreOfficeKitDocument* lok_doc_view_get_document(LOKDocView* pDocView)
{
return pDocView->m_pImpl->m_pDocument;
}
-SAL_DLLPUBLIC_EXPORT void lok_docview_set_zoom ( LOKDocView* pDocView, float fZoom )
+SAL_DLLPUBLIC_EXPORT void lok_doc_view_set_zoom ( LOKDocView* pDocView, float fZoom )
{
pDocView->m_pImpl->m_fZoom = fZoom;
long nDocumentWidthPixels = twipToPixel(pDocView->m_pImpl->m_nDocumentWidthTwips, fZoom);
@@ -1283,72 +1283,72 @@ SAL_DLLPUBLIC_EXPORT void lok_docview_set_zoom ( LOKDocView* pDocView, float fZo
pDocView->m_pImpl->renderDocument(0);
}
-SAL_DLLPUBLIC_EXPORT float lok_docview_get_zoom ( LOKDocView* pDocView )
+SAL_DLLPUBLIC_EXPORT float lok_doc_view_get_zoom ( LOKDocView* pDocView )
{
return pDocView->m_pImpl->m_fZoom;
}
-SAL_DLLPUBLIC_EXPORT int lok_docview_get_parts( LOKDocView* pDocView )
+SAL_DLLPUBLIC_EXPORT int lok_doc_view_get_parts( LOKDocView* pDocView )
{
return pDocView->m_pImpl->m_pDocument->pClass->getParts( pDocView->m_pImpl->m_pDocument );
}
-SAL_DLLPUBLIC_EXPORT int lok_docview_get_part( LOKDocView* pDocView )
+SAL_DLLPUBLIC_EXPORT int lok_doc_view_get_part( LOKDocView* pDocView )
{
return pDocView->m_pImpl->m_pDocument->pClass->getPart( pDocView->m_pImpl->m_pDocument );
}
-SAL_DLLPUBLIC_EXPORT void lok_docview_set_part( LOKDocView* pDocView, int nPart)
+SAL_DLLPUBLIC_EXPORT void lok_doc_view_set_part( LOKDocView* pDocView, int nPart)
{
pDocView->m_pImpl->m_pDocument->pClass->setPart( pDocView->m_pImpl->m_pDocument, nPart );
}
-SAL_DLLPUBLIC_EXPORT char* lok_docview_get_part_name( LOKDocView* pDocView, int nPart )
+SAL_DLLPUBLIC_EXPORT char* lok_doc_view_get_part_name( LOKDocView* pDocView, int nPart )
{
return pDocView->m_pImpl->m_pDocument->pClass->getPartName( pDocView->m_pImpl->m_pDocument, nPart );
}
-SAL_DLLPUBLIC_EXPORT void lok_docview_set_partmode( LOKDocView* pDocView,
+SAL_DLLPUBLIC_EXPORT void lok_doc_view_set_partmode( LOKDocView* pDocView,
int nPartMode )
{
pDocView->m_pImpl->m_pDocument->pClass->setPartMode( pDocView->m_pImpl->m_pDocument, nPartMode );
pDocView->m_pImpl->renderDocument(0);
}
-SAL_DLLPUBLIC_EXPORT void lok_docview_set_edit( LOKDocView* pDocView,
+SAL_DLLPUBLIC_EXPORT void lok_doc_view_set_edit( LOKDocView* pDocView,
gboolean bEdit )
{
gboolean bWasEdit = pDocView->m_pImpl->m_bEdit;
if (!pDocView->m_pImpl->m_bEdit && bEdit)
- g_info("lok_docview_set_edit: entering edit mode");
+ g_info("lok_doc_view_set_edit: entering edit mode");
else if (pDocView->m_pImpl->m_bEdit && !bEdit)
{
- g_info("lok_docview_set_edit: leaving edit mode");
+ g_info("lok_doc_view_set_edit: leaving edit mode");
pDocView->m_pImpl->m_pDocument->pClass->resetSelection(pDocView->m_pImpl->m_pDocument);
}
pDocView->m_pImpl->m_bEdit = bEdit;
- g_signal_emit(pDocView, docview_signals[EDIT_CHANGED], 0, bWasEdit);
+ g_signal_emit(pDocView, doc_view_signals[EDIT_CHANGED], 0, bWasEdit);
gtk_widget_queue_draw(GTK_WIDGET(pDocView->m_pImpl->m_pDrawingArea));
}
-SAL_DLLPUBLIC_EXPORT gboolean lok_docview_get_edit(LOKDocView* pDocView)
+SAL_DLLPUBLIC_EXPORT gboolean lok_doc_view_get_edit(LOKDocView* pDocView)
{
return pDocView->m_pImpl->m_bEdit;
}
-SAL_DLLPUBLIC_EXPORT void lok_docview_post_command(LOKDocView* pDocView, const char* pCommand, const char* pArguments)
+SAL_DLLPUBLIC_EXPORT void lok_doc_view_post_command(LOKDocView* pDocView, const char* pCommand, const char* pArguments)
{
pDocView->m_pImpl->m_pDocument->pClass->postUnoCommand(pDocView->m_pImpl->m_pDocument, pCommand, pArguments);
}
-SAL_DLLPUBLIC_EXPORT void lok_docview_post_key(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer pData)
+SAL_DLLPUBLIC_EXPORT void lok_doc_view_post_key(GtkWidget* /*pWidget*/, GdkEventKey* pEvent, gpointer pData)
{
LOKDocView* pDocView = static_cast<LOKDocView *>(pData);
pDocView->m_pImpl->signalKey(pEvent);
}
-SAL_DLLPUBLIC_EXPORT void lok_docview_get_visarea(LOKDocView* pThis, GdkRectangle* pArea)
+SAL_DLLPUBLIC_EXPORT void lok_doc_view_get_visarea(LOKDocView* pThis, GdkRectangle* pArea)
{
float zoom = pThis->m_pImpl->m_fZoom;
GtkAdjustment* pHAdjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(pThis));
commit 08f5b55132565f604b5705f19066cecb3e4de9f8
Author: Pranav Kant <pranavk at gnome.org>
Date: Sat Jun 6 02:07:31 2015 +0530
lokdocview: Let G_BEGIN/END_DECLS handle the compiler check
Change-Id: I8c60c9ba13516fc2b3a926c19b41ee19805d74a5
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index b3e50d3..9668904 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -16,10 +16,7 @@
#define LOK_USE_UNSTABLE_API
#include <LibreOfficeKit/LibreOfficeKit.h>
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+G_BEGIN_DECLS
#define LOK_DOCVIEW(obj) GTK_CHECK_CAST (obj, lok_docview_get_type(), LOKDocView)
#define LOK_DOCVIEW_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, lok_docview_get_type(), LOKDocViewClass)
@@ -77,9 +74,8 @@ void lok_docview_post_key (GtkWidget* pWidget, GdkEventKey* pEvent
/// Get the visible area of the document (in twips).
void lok_docview_get_visarea(LOKDocView* pThis, GdkRectangle* pArea);
-#ifdef __cplusplus
-}
-#endif
+
+G_END_DECLS
#endif // INCLUDED_LIBREOFFICEKIT_LIBREOFFICEKITGTK_H
commit f18cfaa028c11d0a59b8adabdc1e4174e73cfedf
Author: Pranav Kant <pranavk at gnome.org>
Date: Sat Jun 6 00:36:54 2015 +0530
lokdocview: fix render calls after LOK callbacks
Change-Id: Ib33f0e1dcf257350be1e2cf6c49cd92494472a55
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 137eb0e..53dff28 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -949,21 +949,18 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback)
{
GdkRectangle aRectangle = LOKDocView_Impl::payloadToRectangle(pCallback->m_aPayload.c_str());
setTilesInvalid(aRectangle);
- renderDocument(0);
}
else
- {
m_pTileBuffer->resetAllTiles();
- renderDocument(0);
- }
+
+ gtk_widget_queue_draw(m_pDrawingArea);
}
break;
case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
{
m_aVisibleCursor = LOKDocView_Impl::payloadToRectangle(pCallback->m_aPayload.c_str());
m_bCursorOverlayVisible = true;
- setTilesInvalid(m_aVisibleCursor);
- renderDocument(0);
+ gtk_widget_queue_draw(m_pDrawingArea);
}
break;
case LOK_CALLBACK_TEXT_SELECTION:
@@ -1030,7 +1027,6 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback)
gtk_widget_set_size_request(m_pDrawingArea,
twipToPixel(m_nDocumentWidthTwips, m_fZoom),
twipToPixel(m_nDocumentHeightTwips, m_fZoom));
- m_pTileBuffer->resetAllTiles();
}
break;
case LOK_CALLBACK_SET_PART:
commit 89b388fccddc1cd4496d70959153fbd5d4954a7d
Author: Pranav Kant <pranavk at gnome.org>
Date: Fri Jun 5 20:38:55 2015 +0530
lokdocview: move GtkDrawingArea size request out of renderDocument()
... and place it at places only where the widget can change its size.
Change-Id: I4a4b28b35eba06a6faab434677d4d70d2a33339a
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index b70335a..137eb0e 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -790,7 +790,6 @@ void LOKDocView_Impl::renderDocument(GdkRectangle* pPartial)
guint nRows = ceil((double)nDocumentHeightPixels / nTileSizePixels);
guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
- gtk_widget_set_size_request(m_pDrawingArea, nDocumentWidthPixels, nDocumentHeightPixels);
cairo_t *pcairo = gdk_cairo_create(m_pDrawingArea->window);
// Render the tiles.
@@ -826,7 +825,7 @@ void LOKDocView_Impl::renderDocument(GdkRectangle* pPartial)
if (bPaint)
{
- g_info("tile_buffer_get_tile (%d, %d)", nRow, nColumn);
+ //g_info("tile_buffer_get_tile (%d, %d)", nRow, nColumn);
Tile& currentTile = m_pTileBuffer->getTile(nRow, nColumn);
GdkPixbuf* pPixBuf = currentTile.getBuffer();
@@ -1028,6 +1027,10 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback)
case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
{
payloadToSize(pCallback->m_aPayload.c_str(), m_nDocumentWidthTwips, m_nDocumentHeightTwips);
+ gtk_widget_set_size_request(m_pDrawingArea,
+ twipToPixel(m_nDocumentWidthTwips, m_fZoom),
+ twipToPixel(m_nDocumentHeightTwips, m_fZoom));
+ m_pTileBuffer->resetAllTiles();
}
break;
case LOK_CALLBACK_SET_PART:
@@ -1252,6 +1255,9 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, c
nTileSizePixels,
nRows,
nColumns);
+ gtk_widget_set_size_request(pDocView->m_pImpl->m_pDrawingArea,
+ nDocumentWidthPixels,
+ nDocumentHeightPixels);
pDocView->m_pImpl->renderDocument(0);
}
@@ -1273,6 +1279,9 @@ SAL_DLLPUBLIC_EXPORT void lok_docview_set_zoom ( LOKDocView* pDocView, float fZo
guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
pDocView->m_pImpl->m_pTileBuffer->setZoom(fZoom, nRows, nColumns);
+ gtk_widget_set_size_request(pDocView->m_pImpl->m_pDrawingArea,
+ nDocumentWidthPixels,
+ nDocumentHeightPixels);
if ( pDocView->m_pImpl->m_pDocument )
pDocView->m_pImpl->renderDocument(0);
commit 3f668f0656f40a995d0713932dbb3c4b774a108b
Author: Pranav Kant <pranavk at gnome.org>
Date: Fri Jun 5 17:06:54 2015 +0530
lokdocview: check payload for inconsistencies before using it
Lets follow the old advice: "Be liberal in what you accept, be strict in
what you produce".
This is after noticing negative values for x, y in
the payload in some situation, such as, hitting a backspace key when the
cursor is at the start of a line
Change-Id: I11939b981f75969b88214baee66b4c69c5e41906
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index d538bb6..b70335a 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -187,9 +187,9 @@ struct LOKDocView_Impl
*/
void renderDocument(GdkRectangle* pPartial);
/// Returns the GdkRectangle of a x,y,width,height string.
- static GdkRectangle payloadToRectangle(const char* pPayload);
+ GdkRectangle payloadToRectangle(const char* pPayload);
/// Returns the GdkRectangles of a x1,y1,w1,h1;x2,y2,w2,h2;... string.
- static std::vector<GdkRectangle> payloadToRectangles(const char* pPayload);
+ std::vector<GdkRectangle> payloadToRectangles(const char* pPayload);
/// Returns the string representation of a LibreOfficeKitCallbackType enumeration element.
static const char* callbackTypeToString(int nType);
/// Invoked on the main thread if callbackWorker() requests so.
@@ -853,18 +853,26 @@ GdkRectangle LOKDocView_Impl::payloadToRectangle(const char* pPayload)
if (!*ppCoordinate)
return aRet;
aRet.x = atoi(*ppCoordinate);
+ if (aRet.x < 0)
+ aRet.x = 0;
++ppCoordinate;
if (!*ppCoordinate)
return aRet;
aRet.y = atoi(*ppCoordinate);
+ if (aRet.y < 0)
+ aRet.y = 0;
++ppCoordinate;
if (!*ppCoordinate)
return aRet;
aRet.width = atoi(*ppCoordinate);
+ if (aRet.x + aRet.width > m_nDocumentWidthTwips)
+ aRet.width = m_nDocumentWidthTwips - aRet.x;
++ppCoordinate;
if (!*ppCoordinate)
return aRet;
aRet.height = atoi(*ppCoordinate);
+ if (aRet.y + aRet.height > m_nDocumentHeightTwips)
+ aRet.height = m_nDocumentHeightTwips - aRet.y;
g_strfreev(ppCoordinates);
return aRet;
}
commit 73d580f7575c4e0795911f8e19e418003339db62
Author: Pranav Kant <pranavk at gnome.org>
Date: Fri Jun 5 17:05:28 2015 +0530
lokdocview: fixed rectangle format in documentation/comments
Change-Id: Iaf4a5fba5c4c34d03b91ca9ca4dd4eff1dbf39f6
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 5e90ca9..d538bb6 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -186,9 +186,9 @@ struct LOKDocView_Impl
* the tiles that intersect with pPartial.
*/
void renderDocument(GdkRectangle* pPartial);
- /// Returns the GdkRectangle of a width,height,x,y string.
+ /// Returns the GdkRectangle of a x,y,width,height string.
static GdkRectangle payloadToRectangle(const char* pPayload);
- /// Returns the GdkRectangles of a w,h,x,y;w2,h2,x2,y2;... string.
+ /// Returns the GdkRectangles of a x1,y1,w1,h1;x2,y2,w2,h2;... string.
static std::vector<GdkRectangle> payloadToRectangles(const char* pPayload);
/// Returns the string representation of a LibreOfficeKitCallbackType enumeration element.
static const char* callbackTypeToString(int nType);
More information about the Libreoffice-commits
mailing list