From 103f744637e772e3be590f6b054dcf1dbcac1c3f Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Tue, 24 Jan 2017 17:41:54 +0530 Subject: 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 Tested-by: pranavk (cherry picked from commit 3616f875b014b7d58f81cd871ff7bbf9fd6c78d5) --- .../qa/gtktiledviewer/gtktiledviewer.cxx | 23 ++++++++++++------ libreofficekit/source/gtk/lokdocview.cxx | 27 +++++++++++++++++++++- 2 files changed, 42 insertions(+), 8 deletions(-) (limited to 'libreofficekit') diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx index cb32cd638114..c2faacd6a00a 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& 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 646fc844a014..1f00fdb5200c 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(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(G_PARAM_READWRITE + | G_PARAM_STATIC_STRINGS)); + g_object_class_install_properties(pGObjectClass, PROP_LAST, properties); /** -- cgit