[Libreoffice-commits] core.git: libreofficekit/qa libreofficekit/source

Pranav Kant pranavk at collabora.co.uk
Fri Jan 27 16:13:53 UTC 2017


 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |   23 +++++++++++------
 libreofficekit/source/gtk/lokdocview.cxx            |   27 +++++++++++++++++++-
 2 files changed, 42 insertions(+), 8 deletions(-)

New commits:
commit 3616f875b014b7d58f81cd871ff7bbf9fd6c78d5
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Jan 24 17:41:54 2017 +0530

    lokdocview: Separate gobject property for turning off comments
    
    Pass --enable-tiled-annotations to gtktiledviewer on command line
    to turn comments on again, by default they are turned off now.
    
    Change-Id: I40e93ab683ec9538e088ae9aa83cda2eaaf9939e
    Reviewed-on: https://gerrit.libreoffice.org/33622
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index cb32cd6..c2faacd 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -288,7 +288,11 @@ gboolean CommentsSidebar::docConfigureEvent(GtkWidget* pDocView, GdkEventConfigu
     TiledWindow& rWindow = lcl_getTiledWindow(pDocView);
     LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(pDocView));
 
-    if (pDocument && pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_TEXT)
+    // whether tield rendering is turned on
+    gboolean bTiledAnnotations;
+    g_object_get(G_OBJECT(pDocView), "tiled-annotations", &bTiledAnnotations, nullptr);
+
+    if (!bTiledAnnotations && pDocument && pDocument->pClass->getDocumentType(pDocument) == LOK_DOCTYPE_TEXT)
     {
         if (!rWindow.m_pCommentsSidebar)
         {
@@ -933,19 +937,20 @@ static void toggleFindbar(GtkWidget* pButton, gpointer /*pItem*/)
 }
 
 static void
-setLOKFeatures (GtkWidget* pDocView)
+setLOKFeatures (GtkWidget* pDocView, gboolean bTiledAnnotations)
 {
     g_object_set(G_OBJECT(pDocView),
                  "doc-password", TRUE,
                  "doc-password-to-modify", TRUE,
+                 "tiled-annotations", bTiledAnnotations,
                  nullptr);
 }
 
 /// Common initialization, regardless if it's just a new view or a full init.
-static TiledWindow& setupWidgetAndCreateWindow(GtkWidget* pDocView)
+static TiledWindow& setupWidgetAndCreateWindow(GtkWidget* pDocView, gboolean bTiledAnnotations)
 {
     setupDocView(pDocView);
-    setLOKFeatures(pDocView);
+    setLOKFeatures(pDocView, bTiledAnnotations);
     TiledWindow aWindow;
     aWindow.m_pDocView = pDocView;
     GtkWidget* pWindow = createWindow(aWindow);
@@ -974,8 +979,9 @@ static void createView(GtkWidget* pButton, gpointer /*pItem*/)
     std::string aArguments = aStream.str();
 
     GtkWidget* pDocView = lok_doc_view_new_from_widget(LOK_DOC_VIEW(rWindow.m_pDocView), aArguments.c_str());
-
-    TiledWindow& rNewWindow = setupWidgetAndCreateWindow(pDocView);
+    gboolean bTiledAnnotations;
+    g_object_get(G_OBJECT(rWindow.m_pDocView), "tiled-annotations", &bTiledAnnotations, nullptr);
+    TiledWindow& rNewWindow = setupWidgetAndCreateWindow(pDocView, bTiledAnnotations);
     // Hide the unused progress bar.
     gtk_widget_show_all(rNewWindow.m_pStatusBar);
     gtk_widget_hide(rNewWindow.m_pProgressBar);
@@ -988,17 +994,20 @@ static void createView(GtkWidget* pButton, gpointer /*pItem*/)
 static void createModelAndView(const char* pLOPath, const char* pDocPath, const std::vector<std::string>& rArguments)
 {
     std::string aUserProfile;
+    gboolean bTiledAnnotations = FALSE;
     for (size_t i = 0; i < rArguments.size(); ++i)
     {
         const std::string& rArgument = rArguments[i];
         if (rArgument == "--user-profile" && i + 1 < rArguments.size())
             aUserProfile = std::string("vnd.sun.star.pathname:")
                 + rArguments[i + 1].c_str();
+        else if (rArgument == "--enable-tiled-annotations")
+            bTiledAnnotations = TRUE;
     }
     const gchar* pUserProfile = aUserProfile.empty() ? nullptr : aUserProfile.c_str();
     GtkWidget* pDocView = lok_doc_view_new_from_user_profile(pLOPath, pUserProfile, nullptr, nullptr);
 
-    TiledWindow& rWindow = setupWidgetAndCreateWindow(pDocView);
+    TiledWindow& rWindow = setupWidgetAndCreateWindow(pDocView, bTiledAnnotations);
 
     boost::property_tree::ptree aTree;
     for (size_t i = 0; i < rArguments.size(); ++i)
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 1cd2c05..80d40f5 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -299,6 +299,7 @@ enum
     PROP_CAN_ZOOM_OUT,
     PROP_DOC_PASSWORD,
     PROP_DOC_PASSWORD_TO_MODIFY,
+    PROP_TILED_ANNOTATIONS,
 
     PROP_LAST
 };
@@ -2465,6 +2466,7 @@ static void lok_doc_view_set_property (GObject* object, guint propId, const GVal
     LOKDocViewPrivate& priv = getPrivate(pDocView);
     gboolean bDocPasswordEnabled = priv->m_nLOKFeatures & LOK_FEATURE_DOCUMENT_PASSWORD;
     gboolean bDocPasswordToModifyEnabled = priv->m_nLOKFeatures & LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY;
+    gboolean bTiledAnnotationsEnabled = !(priv->m_nLOKFeatures & LOK_FEATURE_NO_TILED_ANNOTATIONS);
 
     switch (propId)
     {
@@ -2510,6 +2512,13 @@ static void lok_doc_view_set_property (GObject* object, guint propId, const GVal
             priv->m_pOffice->pClass->setOptionalFeatures(priv->m_pOffice, priv->m_nLOKFeatures);
         }
         break;
+    case PROP_TILED_ANNOTATIONS:
+        if ( g_value_get_boolean (value) != bTiledAnnotationsEnabled)
+        {
+            priv->m_nLOKFeatures = priv->m_nLOKFeatures ^ LOK_FEATURE_NO_TILED_ANNOTATIONS;
+            priv->m_pOffice->pClass->setOptionalFeatures(priv->m_pOffice, priv->m_nLOKFeatures);
+        }
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propId, pspec);
     }
@@ -2567,6 +2576,9 @@ static void lok_doc_view_get_property (GObject* object, guint propId, GValue *va
     case PROP_DOC_PASSWORD_TO_MODIFY:
         g_value_set_boolean (value, priv->m_nLOKFeatures & LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY);
         break;
+    case PROP_TILED_ANNOTATIONS:
+        g_value_set_boolean (value, !(priv->m_nLOKFeatures & LOK_FEATURE_NO_TILED_ANNOTATIONS));
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propId, pspec);
     }
@@ -2632,7 +2644,6 @@ static gboolean lok_doc_view_initable_init (GInitable *initable, GCancellable* /
         return FALSE;
     }
     priv->m_nLOKFeatures |= LOK_FEATURE_PART_IN_INVALIDATION_CALLBACK;
-    priv->m_nLOKFeatures |= LOK_FEATURE_NO_TILED_ANNOTATIONS;
     priv->m_pOffice->pClass->setOptionalFeatures(priv->m_pOffice, priv->m_nLOKFeatures);
 
     return TRUE;
@@ -2863,6 +2874,20 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
                              static_cast<GParamFlags>(G_PARAM_READWRITE
                                                       | G_PARAM_STATIC_STRINGS));
 
+    /**
+     * LOKDocView:tiled-annotations-rendering:
+     *
+     * Set it to false if client does not want LO to render comments in tiles and
+     * instead interested in using comments API to access comments
+     */
+    properties[PROP_TILED_ANNOTATIONS] =
+        g_param_spec_boolean("tiled-annotations",
+                             "Render comments in tiles",
+                             "Whether the client wants in tile comment rendering",
+                             TRUE,
+                             static_cast<GParamFlags>(G_PARAM_READWRITE
+                                                      | G_PARAM_STATIC_STRINGS));
+
     g_object_class_install_properties(pGObjectClass, PROP_LAST, properties);
 
     /**


More information about the Libreoffice-commits mailing list