Blame SOURCES/0382-lokdocview-Use-an-array-to-install-properties.patch

135360
From 5a4d9a54a05efee6cb004b41207e53b6eadbd1a8 Mon Sep 17 00:00:00 2001
135360
From: Pranav Kant <pranavk@libreoffice.org>
135360
Date: Fri, 18 Dec 2015 21:51:23 +0530
135360
Subject: [PATCH 382/398] lokdocview: Use an array to install properties
135360
135360
This way we can directly reference any property by pointers to
135360
GParamSpec stored in a static array, rather than looking for
135360
property using property name. The former is a faster approach.
135360
135360
This will come in handy for functions, such as, g_object_notify
135360
which needs to access properties to notify the object of any
135360
property change in a faster way.
135360
135360
Change-Id: Ic4087bff3bdb63a3e8853d158c7af688e5e67811
135360
Reviewed-on: https://gerrit.libreoffice.org/20797
135360
Tested-by: Jenkins <ci@libreoffice.org>
135360
Reviewed-by: David Tardon <dtardon@redhat.com>
135360
Tested-by: David Tardon <dtardon@redhat.com>
135360
(cherry picked from commit 81f31f5151b54899ac5461c9c7c4021cdf31a9a6)
135360
Reviewed-on: https://gerrit.libreoffice.org/21272
135360
Reviewed-by: Pranav Kant <pranavk@gnome.org>
135360
(cherry picked from commit 09c73ad5b1462161b855bf3d43a3d86a3ee28659)
135360
---
135360
 libreofficekit/source/gtk/lokdocview.cxx | 187 +++++++++++++++----------------
135360
 1 file changed, 90 insertions(+), 97 deletions(-)
135360
135360
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
135360
index 4d2842005f37..07e5f993b79b 100644
135360
--- a/libreofficekit/source/gtk/lokdocview.cxx
135360
+++ b/libreofficekit/source/gtk/lokdocview.cxx
135360
@@ -206,10 +206,13 @@ enum
135360
     PROP_DOC_WIDTH,
135360
     PROP_DOC_HEIGHT,
135360
     PROP_CAN_ZOOM_IN,
135360
-    PROP_CAN_ZOOM_OUT
135360
+    PROP_CAN_ZOOM_OUT,
135360
+
135360
+    PROP_LAST
135360
 };
135360
 
135360
 static guint doc_view_signals[LAST_SIGNAL] = { 0 };
135360
+static GParamSpec *properties[PROP_LAST] = { nullptr };
135360
 
135360
 static void lok_doc_view_initable_iface_init (GInitableIface *iface);
135360
 static void callbackWorker (int nType, const char* pPayload, void* pData);
135360
@@ -2046,15 +2049,14 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
135360
      *
135360
      * The absolute path of the LibreOffice install.
135360
      */
135360
-    g_object_class_install_property (pGObjectClass,
135360
-          PROP_LO_PATH,
135360
-          g_param_spec_string("lopath",
135360
-                              "LO Path",
135360
-                              "LibreOffice Install Path",
135360
-                              nullptr,
135360
-                              static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
-                                                       G_PARAM_CONSTRUCT_ONLY |
135360
-                                                       G_PARAM_STATIC_STRINGS)));
135360
+    properties[PROP_LO_PATH] =
135360
+        g_param_spec_string("lopath",
135360
+                            "LO Path",
135360
+                            "LibreOffice Install Path",
135360
+                            nullptr,
135360
+                            static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
+                                                     G_PARAM_CONSTRUCT_ONLY |
135360
+                                                     G_PARAM_STATIC_STRINGS));
135360
 
135360
     /**
135360
      * LOKDocView:lopointer:
135360
@@ -2062,28 +2064,26 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
135360
      * A LibreOfficeKit* in case lok_init() is already called
135360
      * previously.
135360
      */
135360
-    g_object_class_install_property (pGObjectClass,
135360
-          PROP_LO_POINTER,
135360
-          g_param_spec_pointer("lopointer",
135360
-                               "LO Pointer",
135360
-                               "A LibreOfficeKit* from lok_init()",
135360
-                               static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
-                                                        G_PARAM_CONSTRUCT_ONLY |
135360
-                                                        G_PARAM_STATIC_STRINGS)));
135360
+    properties[PROP_LO_POINTER] =
135360
+        g_param_spec_pointer("lopointer",
135360
+                             "LO Pointer",
135360
+                             "A LibreOfficeKit* from lok_init()",
135360
+                             static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
+                                                      G_PARAM_CONSTRUCT_ONLY |
135360
+                                                      G_PARAM_STATIC_STRINGS));
135360
 
135360
     /**
135360
      * LOKDocView:docpath:
135360
      *
135360
      * The path of the document that is currently being viewed.
135360
      */
135360
-    g_object_class_install_property (pGObjectClass,
135360
-          PROP_DOC_PATH,
135360
-          g_param_spec_string("docpath",
135360
-                              "Document Path",
135360
-                              "The URI of the document to open",
135360
-                              nullptr,
135360
-                              static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
-                                                       G_PARAM_STATIC_STRINGS)));
135360
+    properties[PROP_DOC_PATH] =
135360
+        g_param_spec_string("docpath",
135360
+                            "Document Path",
135360
+                            "The URI of the document to open",
135360
+                            nullptr,
135360
+                            static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
+                                                     G_PARAM_STATIC_STRINGS));
135360
 
135360
     /**
135360
      * LOKDocView:docpointer:
135360
@@ -2091,27 +2091,25 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
135360
      * A LibreOfficeKitDocument* in case documentLoad() is already called
135360
      * previously.
135360
      */
135360
-    g_object_class_install_property (pGObjectClass,
135360
-          PROP_DOC_POINTER,
135360
-          g_param_spec_pointer("docpointer",
135360
-                               "Document Pointer",
135360
-                               "A LibreOfficeKitDocument* from documentLoad()",
135360
-                               static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
-                                                        G_PARAM_STATIC_STRINGS)));
135360
+    properties[PROP_DOC_POINTER] =
135360
+        g_param_spec_pointer("docpointer",
135360
+                             "Document Pointer",
135360
+                             "A LibreOfficeKitDocument* from documentLoad()",
135360
+                             static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
+                                                      G_PARAM_STATIC_STRINGS));
135360
 
135360
     /**
135360
      * LOKDocView:editable:
135360
      *
135360
      * Whether the document loaded inside of #LOKDocView is editable or not.
135360
      */
135360
-    g_object_class_install_property (pGObjectClass,
135360
-          PROP_EDITABLE,
135360
-          g_param_spec_boolean("editable",
135360
-                               "Editable",
135360
-                               "Whether the content is in edit mode or not",
135360
-                               FALSE,
135360
-                               static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
-                                                        G_PARAM_STATIC_STRINGS)));
135360
+    properties[PROP_EDITABLE] =
135360
+        g_param_spec_boolean("editable",
135360
+                             "Editable",
135360
+                             "Whether the content is in edit mode or not",
135360
+                             FALSE,
135360
+                             static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
+                                                      G_PARAM_STATIC_STRINGS));
135360
 
135360
     /**
135360
      * LOKDocView:load-progress:
135360
@@ -2121,14 +2119,13 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
135360
      * very accurate progress indicator, and its value might reset it couple of
135360
      * times to 0 and start again. You should not rely on its numbers.
135360
      */
135360
-    g_object_class_install_property (pGObjectClass,
135360
-          PROP_LOAD_PROGRESS,
135360
-          g_param_spec_double("load-progress",
135360
-                              "Estimated Load Progress",
135360
-                              "Shows the progress of the document load operation",
135360
-                              0.0, 1.0, 0.0,
135360
-                              static_cast<GParamFlags>(G_PARAM_READABLE |
135360
-                                                       G_PARAM_STATIC_STRINGS)));
135360
+    properties[PROP_LOAD_PROGRESS] =
135360
+        g_param_spec_double("load-progress",
135360
+                            "Estimated Load Progress",
135360
+                            "Shows the progress of the document load operation",
135360
+                            0.0, 1.0, 0.0,
135360
+                            static_cast<GParamFlags>(G_PARAM_READABLE |
135360
+                                                     G_PARAM_STATIC_STRINGS));
135360
 
135360
     /**
135360
      * LOKDocView:zoom-level:
135360
@@ -2136,14 +2133,13 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
135360
      * The current zoom level of the document loaded inside #LOKDocView. The
135360
      * default value is 1.0.
135360
      */
135360
-    g_object_class_install_property (pGObjectClass,
135360
-          PROP_ZOOM,
135360
-          g_param_spec_float("zoom-level",
135360
-                             "Zoom Level",
135360
-                             "The current zoom level of the content",
135360
-                             0, 5.0, 1.0,
135360
-                             static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
-                                                      G_PARAM_STATIC_STRINGS)));
135360
+    properties[PROP_ZOOM] =
135360
+        g_param_spec_float("zoom-level",
135360
+                           "Zoom Level",
135360
+                           "The current zoom level of the content",
135360
+                           0, 5.0, 1.0,
135360
+                           static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
+                                                    G_PARAM_STATIC_STRINGS));
135360
 
135360
     /**
135360
      * LOKDocView:is-loading:
135360
@@ -2151,70 +2147,67 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
135360
      * Whether the requested document is being loaded or not. %TRUE if it is
135360
      * being loaded, otherwise %FALSE.
135360
      */
135360
-    g_object_class_install_property (pGObjectClass,
135360
-          PROP_IS_LOADING,
135360
-          g_param_spec_boolean("is-loading",
135360
-                               "Is Loading",
135360
-                               "Whether the view is loading a document",
135360
-                               FALSE,
135360
-                               static_cast<GParamFlags>(G_PARAM_READABLE |
135360
-                                                        G_PARAM_STATIC_STRINGS)));
135360
+    properties[PROP_IS_LOADING] =
135360
+        g_param_spec_boolean("is-loading",
135360
+                             "Is Loading",
135360
+                             "Whether the view is loading a document",
135360
+                             FALSE,
135360
+                             static_cast<GParamFlags>(G_PARAM_READABLE |
135360
+                                                      G_PARAM_STATIC_STRINGS));
135360
 
135360
     /**
135360
      * LOKDocView:doc-width:
135360
      *
135360
      * The width of the currently loaded document in #LOKDocView in twips.
135360
      */
135360
-    g_object_class_install_property (pGObjectClass,
135360
-          PROP_DOC_WIDTH,
135360
-          g_param_spec_long("doc-width",
135360
-                            "Document Width",
135360
-                            "Width of the document in twips",
135360
-                            0, G_MAXLONG, 0,
135360
-                            static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
-                                                     G_PARAM_STATIC_STRINGS)));
135360
+    properties[PROP_DOC_WIDTH] =
135360
+        g_param_spec_long("doc-width",
135360
+                          "Document Width",
135360
+                          "Width of the document in twips",
135360
+                          0, G_MAXLONG, 0,
135360
+                          static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
+                                                   G_PARAM_STATIC_STRINGS));
135360
 
135360
     /**
135360
      * LOKDocView:doc-height:
135360
      *
135360
      * The height of the currently loaded document in #LOKDocView in twips.
135360
      */
135360
-    g_object_class_install_property (pGObjectClass,
135360
-          PROP_DOC_HEIGHT,
135360
-          g_param_spec_long("doc-height",
135360
-                            "Document Height",
135360
-                            "Height of the document in twips",
135360
-                            0, G_MAXLONG, 0,
135360
-                            static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
-                                                     G_PARAM_STATIC_STRINGS)));
135360
+    properties[PROP_DOC_HEIGHT] =
135360
+        g_param_spec_long("doc-height",
135360
+                          "Document Height",
135360
+                          "Height of the document in twips",
135360
+                          0, G_MAXLONG, 0,
135360
+                          static_cast<GParamFlags>(G_PARAM_READWRITE |
135360
+                                                   G_PARAM_STATIC_STRINGS));
135360
 
135360
     /**
135360
      * LOKDocView:can-zoom-in:
135360
      *
135360
      * It tells whether the view can further be zoomed in or not.
135360
      */
135360
-    g_object_class_install_property (pGObjectClass,
135360
-          PROP_CAN_ZOOM_IN,
135360
-          g_param_spec_boolean("can-zoom-in",
135360
-                               "Can Zoom In",
135360
-                               "Whether the view can be zoomed in further",
135360
-                               TRUE,
135360
-                               static_cast<GParamFlags>(G_PARAM_READABLE
135360
-                                                       | G_PARAM_STATIC_STRINGS)));
135360
+    properties[PROP_CAN_ZOOM_IN] =
135360
+        g_param_spec_boolean("can-zoom-in",
135360
+                             "Can Zoom In",
135360
+                             "Whether the view can be zoomed in further",
135360
+                             TRUE,
135360
+                             static_cast<GParamFlags>(G_PARAM_READABLE
135360
+                                                      | G_PARAM_STATIC_STRINGS));
135360
 
135360
     /**
135360
      * LOKDocView:can-zoom-out:
135360
      *
135360
      * It tells whether the view can further be zoomed out or not.
135360
      */
135360
-    g_object_class_install_property (pGObjectClass,
135360
-          PROP_CAN_ZOOM_OUT,
135360
-          g_param_spec_boolean("can-zoom-out",
135360
-                               "Can Zoom Out",
135360
-                               "Whether the view can be zoomed out further",
135360
-                               TRUE,
135360
-                               static_cast<GParamFlags>(G_PARAM_READABLE
135360
-                                                       | G_PARAM_STATIC_STRINGS)));
135360
+    properties[PROP_CAN_ZOOM_OUT] =
135360
+        g_param_spec_boolean("can-zoom-out",
135360
+                             "Can Zoom Out",
135360
+                             "Whether the view can be zoomed out further",
135360
+                             TRUE,
135360
+                             static_cast<GParamFlags>(G_PARAM_READABLE
135360
+                                                      | G_PARAM_STATIC_STRINGS));
135360
+
135360
+    g_object_class_install_properties(pGObjectClass, PROP_LAST, properties);
135360
 
135360
     /**
135360
      * LOKDocView::load-changed:
135360
-- 
135360
2.12.0
135360