Blame SOURCES/0242-lokdocview-ensure-private-structure-is-allocated-wit.patch

135360
From 1c92d1b2e1ac5b48a3c010c8fcaffc88f80e13da Mon Sep 17 00:00:00 2001
135360
From: Miklos Vajna <vmiklos@collabora.co.uk>
135360
Date: Fri, 30 Oct 2015 08:31:43 +0100
135360
Subject: [PATCH 242/398] lokdocview: ensure private structure is allocated
135360
 with operator new
135360
135360
It's undesirable to malloc a struct that has a TileBuffer member, while
135360
TileBuffer doesn't have a default ctor.
135360
135360
Change-Id: I72dfacc0088f238ee101d84838bd7eea51ced82a
135360
(cherry picked from commit bd0ec1e68dcbc344cbaa50e35608bab95925fcaf)
135360
---
135360
 libreofficekit/source/gtk/lokdocview.cxx | 152 +++++++++++++++++++++----------
135360
 libreofficekit/source/gtk/tilebuffer.hxx |   4 +-
135360
 2 files changed, 108 insertions(+), 48 deletions(-)
135360
135360
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
135360
index bbb87115fa4f..29b028c7b5d0 100644
135360
--- a/libreofficekit/source/gtk/lokdocview.cxx
135360
+++ b/libreofficekit/source/gtk/lokdocview.cxx
135360
@@ -39,7 +39,7 @@
135360
 #define GRAPHIC_HANDLE_COUNT 8
135360
 
135360
 /// Private struct used by this GObject type
135360
-struct _LOKDocViewPrivate
135360
+struct LOKDocViewPrivateImpl
135360
 {
135360
     const gchar* m_aLOPath;
135360
     const gchar* m_aDocPath;
135360
@@ -115,6 +115,58 @@ struct _LOKDocViewPrivate
135360
 
135360
     /// View ID, returned by createView() or 0 by default.
135360
     int m_nViewId;
135360
+
135360
+    LOKDocViewPrivateImpl()
135360
+        : m_aLOPath(0),
135360
+        m_aDocPath(0),
135360
+        m_nLoadProgress(0),
135360
+        m_bIsLoading(false),
135360
+        m_bCanZoomIn(false),
135360
+        m_bCanZoomOut(false),
135360
+        m_pOffice(0),
135360
+        m_pDocument(0),
135360
+        lokThreadPool(0),
135360
+        m_fZoom(0),
135360
+        m_nDocumentWidthTwips(0),
135360
+        m_nDocumentHeightTwips(0),
135360
+        m_bEdit(FALSE),
135360
+        m_aVisibleCursor({0, 0, 0, 0}),
135360
+        m_bCursorOverlayVisible(false),
135360
+        m_bCursorVisible(true),
135360
+        m_nLastButtonPressTime(0),
135360
+        m_nLastButtonReleaseTime(0),
135360
+        m_nLastButtonPressed(0),
135360
+        m_nKeyModifier(0),
135360
+        m_aTextSelectionStart({0, 0, 0, 0}),
135360
+        m_aTextSelectionEnd({0, 0, 0, 0}),
135360
+        m_aGraphicSelection({0, 0, 0, 0}),
135360
+        m_bInDragGraphicSelection(false),
135360
+        m_pHandleStart(0),
135360
+        m_aHandleStartRect({0, 0, 0, 0}),
135360
+        m_bInDragStartHandle(0),
135360
+        m_pHandleMiddle(0),
135360
+        m_aHandleMiddleRect({0, 0, 0, 0}),
135360
+        m_bInDragMiddleHandle(false),
135360
+        m_pHandleEnd(0),
135360
+        m_aHandleEndRect({0, 0, 0, 0}),
135360
+        m_bInDragEndHandle(false),
135360
+        m_pGraphicHandle(0),
135360
+        m_nViewId(0)
135360
+    {
135360
+        memset(&m_aGraphicHandleRects, 0, sizeof(m_aGraphicHandleRects));
135360
+        memset(&m_bInDragGraphicHandles, 0, sizeof(m_bInDragGraphicHandles));
135360
+    }
135360
+};
135360
+
135360
+/// Wrapper around LOKDocViewPrivateImpl, managed by malloc/memset/free.
135360
+struct _LOKDocViewPrivate
135360
+{
135360
+    LOKDocViewPrivateImpl* m_pImpl;
135360
+
135360
+    LOKDocViewPrivateImpl* operator->()
135360
+    {
135360
+        return m_pImpl;
135360
+    }
135360
 };
135360
 
135360
 enum
135360
@@ -167,6 +219,12 @@ G_DEFINE_TYPE_WITH_CODE (LOKDocView, lok_doc_view, GTK_TYPE_DRAWING_AREA,
135360
 #pragma GCC diagnostic pop
135360
 #endif
135360
 
135360
+static LOKDocViewPrivate& getPrivate(LOKDocView* pDocView)
135360
+{
135360
+    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private(pDocView));
135360
+    return *priv;
135360
+}
135360
+
135360
 /// Helper struct used to pass the data from soffice thread -> main thread.
135360
 struct CallbackData
135360
 {
135360
@@ -249,7 +307,7 @@ postKeyEventInThread(gpointer data)
135360
 {
135360
     GTask* task = G_TASK(data);
135360
     LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
135360
 
135360
     priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
135360
@@ -263,7 +321,7 @@ static gboolean
135360
 signalKey (GtkWidget* pWidget, GdkEventKey* pEvent)
135360
 {
135360
     LOKDocView* pDocView = LOK_DOC_VIEW(pWidget);
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     int nCharCode = 0;
135360
     int nKeyCode = 0;
135360
     GError* error = NULL;
135360
@@ -372,7 +430,7 @@ static gboolean
135360
 handleTimeout (gpointer pData)
135360
 {
135360
     LOKDocView* pDocView = LOK_DOC_VIEW (pData);
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
 
135360
     if (priv->m_bEdit)
135360
     {
135360
@@ -429,7 +487,7 @@ static gboolean queueDraw(gpointer pData)
135360
 static gboolean postDocumentLoad(gpointer pData)
135360
 {
135360
     LOKDocView* pLOKDocView = static_cast<LOKDocView*>(pData);
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private(pLOKDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pLOKDocView);
135360
 
135360
     priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
135360
     priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument);
135360
@@ -462,7 +520,7 @@ static gboolean
135360
 globalCallback (gpointer pData)
135360
 {
135360
     CallbackData* pCallback = static_cast<CallbackData*>(pData);
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pCallback->m_pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pCallback->m_pDocView);
135360
 
135360
     switch (pCallback->m_nType)
135360
     {
135360
@@ -506,7 +564,7 @@ globalCallbackWorker(int nType, const char* pPayload, void* pData)
135360
 static GdkRectangle
135360
 payloadToRectangle (LOKDocView* pDocView, const char* pPayload)
135360
 {
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     GdkRectangle aRet;
135360
     gchar** ppCoordinates = g_strsplit(pPayload, ", ", 4);
135360
     gchar** ppCoordinate = ppCoordinates;
135360
@@ -558,7 +616,7 @@ payloadToRectangles(LOKDocView* pDocView, const char* pPayload)
135360
 static void
135360
 setTilesInvalid (LOKDocView* pDocView, const GdkRectangle& rRectangle)
135360
 {
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     GdkRectangle aRectanglePixels;
135360
     GdkPoint aStart, aEnd;
135360
 
135360
@@ -587,7 +645,7 @@ callback (gpointer pData)
135360
 {
135360
     CallbackData* pCallback = static_cast<CallbackData*>(pData);
135360
     LOKDocView* pDocView = LOK_DOC_VIEW (pCallback->m_pDocView);
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
 
135360
     switch (pCallback->m_nType)
135360
     {
135360
@@ -720,7 +778,7 @@ renderHandle(LOKDocView* pDocView,
135360
              cairo_surface_t* pHandle,
135360
              GdkRectangle& rRectangle)
135360
 {
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     GdkPoint aCursorBottom;
135360
     int nHandleWidth, nHandleHeight;
135360
     double fHandleScale;
135360
@@ -753,7 +811,7 @@ renderGraphicHandle(LOKDocView* pDocView,
135360
                     const GdkRectangle& rSelection,
135360
                     cairo_surface_t* pHandle)
135360
 {
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     int nHandleWidth, nHandleHeight;
135360
     GdkRectangle aSelection;
135360
 
135360
@@ -819,7 +877,7 @@ renderGraphicHandle(LOKDocView* pDocView,
135360
 static gboolean
135360
 renderDocument(LOKDocView* pDocView, cairo_t* pCairo)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     GdkRectangle aVisibleArea;
135360
     long nDocumentWidthPixels = twipToPixel(priv->m_nDocumentWidthTwips, priv->m_fZoom);
135360
     long nDocumentHeightPixels = twipToPixel(priv->m_nDocumentHeightTwips, priv->m_fZoom);
135360
@@ -882,7 +940,7 @@ renderDocument(LOKDocView* pDocView, cairo_t* pCairo)
135360
 static gboolean
135360
 renderOverlay(LOKDocView* pDocView, cairo_t* pCairo)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
 
135360
     if (priv->m_bEdit && priv->m_bCursorVisible && priv->m_bCursorOverlayVisible && !isEmptyRectangle(priv->m_aVisibleCursor))
135360
     {
135360
@@ -960,7 +1018,7 @@ static gboolean
135360
 lok_doc_view_signal_button(GtkWidget* pWidget, GdkEventButton* pEvent)
135360
 {
135360
     LOKDocView* pDocView = LOK_DOC_VIEW (pWidget);
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     GError* error = NULL;
135360
 
135360
     g_info("LOKDocView_Impl::signalButton: %d, %d (in twips: %d, %d)",
135360
@@ -1203,7 +1261,7 @@ static gboolean
135360
 lok_doc_view_signal_motion (GtkWidget* pWidget, GdkEventMotion* pEvent)
135360
 {
135360
     LOKDocView* pDocView = LOK_DOC_VIEW (pWidget);
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     GdkPoint aPoint;
135360
     GError* error = NULL;
135360
 
135360
@@ -1300,7 +1358,7 @@ setGraphicSelectionInThread(gpointer data)
135360
 {
135360
     GTask* task = G_TASK(data);
135360
     LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
135360
 
135360
     priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
135360
@@ -1315,7 +1373,7 @@ postMouseEventInThread(gpointer data)
135360
 {
135360
     GTask* task = G_TASK(data);
135360
     LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
135360
 
135360
     priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
135360
@@ -1333,7 +1391,7 @@ openDocumentInThread (gpointer data)
135360
 {
135360
     GTask* task = G_TASK(data);
135360
     LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
 
135360
     if ( priv->m_pDocument )
135360
     {
135360
@@ -1360,7 +1418,7 @@ setPartInThread(gpointer data)
135360
 {
135360
     GTask* task = G_TASK(data);
135360
     LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
135360
     int nPart = pLOEvent->m_nPart;
135360
 
135360
@@ -1373,7 +1431,7 @@ setPartmodeInThread(gpointer data)
135360
 {
135360
     GTask* task = G_TASK(data);
135360
     LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
135360
     int nPartMode = pLOEvent->m_nPartMode;
135360
 
135360
@@ -1386,7 +1444,7 @@ setEditInThread(gpointer data)
135360
 {
135360
     GTask* task = G_TASK(data);
135360
     LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
135360
     gboolean bWasEdit = priv->m_bEdit;
135360
     gboolean bEdit = pLOEvent->m_bEdit;
135360
@@ -1410,7 +1468,7 @@ postCommandInThread (gpointer data)
135360
     GTask* task = G_TASK(data);
135360
     LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
     LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
 
135360
     priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
135360
     std::stringstream ss;
135360
@@ -1424,7 +1482,7 @@ paintTileInThread (gpointer data)
135360
 {
135360
     GTask* task = G_TASK(data);
135360
     LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
135360
     TileBuffer& buffer = priv->m_aTileBuffer;
135360
     int index = pLOEvent->m_nPaintTileX * buffer.m_nWidth + pLOEvent->m_nPaintTileY;
135360
@@ -1508,8 +1566,8 @@ lokThreadFunc(gpointer data, gpointer /*user_data*/)
135360
 
135360
 static void lok_doc_view_init (LOKDocView* pDocView)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
-    priv->m_bCursorVisible = true;
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
+    priv.m_pImpl = new LOKDocViewPrivateImpl();
135360
 
135360
     gtk_widget_add_events(GTK_WIDGET(pDocView),
135360
                           GDK_BUTTON_PRESS_MASK
135360
@@ -1528,7 +1586,7 @@ static void lok_doc_view_init (LOKDocView* pDocView)
135360
 static void lok_doc_view_set_property (GObject* object, guint propId, const GValue *value, GParamSpec *pspec)
135360
 {
135360
     LOKDocView* pDocView = LOK_DOC_VIEW (object);
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
 
135360
     switch (propId)
135360
     {
135360
@@ -1564,7 +1622,7 @@ static void lok_doc_view_set_property (GObject* object, guint propId, const GVal
135360
 static void lok_doc_view_get_property (GObject* object, guint propId, GValue *value, GParamSpec *pspec)
135360
 {
135360
     LOKDocView* pDocView = LOK_DOC_VIEW (object);
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
 
135360
     switch (propId)
135360
     {
135360
@@ -1622,12 +1680,14 @@ static gboolean lok_doc_view_draw (GtkWidget* pWidget, cairo_t* pCairo)
135360
 static void lok_doc_view_finalize (GObject* object)
135360
 {
135360
     LOKDocView* pDocView = LOK_DOC_VIEW (object);
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
 
135360
     if (priv->m_pDocument)
135360
         priv->m_pDocument->pClass->destroy (priv->m_pDocument);
135360
     if (priv->m_pOffice)
135360
         priv->m_pOffice->pClass->destroy (priv->m_pOffice);
135360
+    delete priv.m_pImpl;
135360
+    priv.m_pImpl = 0;
135360
 
135360
     G_OBJECT_CLASS (lok_doc_view_parent_class)->finalize (object);
135360
 }
135360
@@ -1635,7 +1695,7 @@ static void lok_doc_view_finalize (GObject* object)
135360
 static gboolean lok_doc_view_initable_init (GInitable *initable, GCancellable* /*cancellable*/, GError **error)
135360
 {
135360
     LOKDocView *pDocView = LOK_DOC_VIEW (initable);
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
 
135360
     if (priv->m_pOffice != NULL)
135360
         return TRUE;
135360
@@ -1999,13 +2059,13 @@ lok_doc_view_new (const gchar* pPath, GCancellable *cancellable, GError **error)
135360
 
135360
 SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new_from_widget(LOKDocView* pOldLOKDocView)
135360
 {
135360
-    LOKDocViewPrivate* pOldPriv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private(pOldLOKDocView));
135360
+    LOKDocViewPrivate& pOldPriv = getPrivate(pOldLOKDocView);
135360
     GtkWidget* pNewDocView = GTK_WIDGET(g_initable_new(LOK_TYPE_DOC_VIEW, /*cancellable=*/0, /*error=*/0,
135360
                                                        "lopath", pOldPriv->m_aLOPath, "lopointer", pOldPriv->m_pOffice, "docpointer", pOldPriv->m_pDocument, NULL));
135360
 
135360
     // No documentLoad(), just a createView().
135360
     LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(pNewDocView));
135360
-    LOKDocViewPrivate* pNewPriv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private(LOK_DOC_VIEW(pNewDocView)));
135360
+    LOKDocViewPrivate& pNewPriv = getPrivate(LOK_DOC_VIEW(pNewDocView));
135360
     pNewPriv->m_nViewId = pDocument->pClass->createView(pDocument);
135360
 
135360
     postDocumentLoad(pNewDocView);
135360
@@ -2033,7 +2093,7 @@ lok_doc_view_open_document (LOKDocView* pDocView,
135360
                             gpointer userdata)
135360
 {
135360
     GTask* task = g_task_new(pDocView, cancellable, callback, userdata);
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     GError* error = NULL;
135360
 
135360
     LOEvent* pLOEvent = new LOEvent(LOK_LOAD_DOC);
135360
@@ -2054,14 +2114,14 @@ lok_doc_view_open_document (LOKDocView* pDocView,
135360
 SAL_DLLPUBLIC_EXPORT LibreOfficeKitDocument*
135360
 lok_doc_view_get_document (LOKDocView* pDocView)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     return priv->m_pDocument;
135360
 }
135360
 
135360
 SAL_DLLPUBLIC_EXPORT void
135360
 lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
 
135360
     priv->m_fZoom = fZoom;
135360
     long nDocumentWidthPixels = twipToPixel(priv->m_nDocumentWidthTwips, fZoom);
135360
@@ -2079,14 +2139,14 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
135360
 SAL_DLLPUBLIC_EXPORT float
135360
 lok_doc_view_get_zoom (LOKDocView* pDocView)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     return priv->m_fZoom;
135360
 }
135360
 
135360
 SAL_DLLPUBLIC_EXPORT int
135360
 lok_doc_view_get_parts (LOKDocView* pDocView)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
135360
     return priv->m_pDocument->pClass->getParts( priv->m_pDocument );
135360
 }
135360
@@ -2094,7 +2154,7 @@ lok_doc_view_get_parts (LOKDocView* pDocView)
135360
 SAL_DLLPUBLIC_EXPORT int
135360
 lok_doc_view_get_part (LOKDocView* pDocView)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
135360
     return priv->m_pDocument->pClass->getPart( priv->m_pDocument );
135360
 }
135360
@@ -2102,7 +2162,7 @@ lok_doc_view_get_part (LOKDocView* pDocView)
135360
 SAL_DLLPUBLIC_EXPORT void
135360
 lok_doc_view_set_part (LOKDocView* pDocView, int nPart)
135360
 {
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
135360
     LOEvent* pLOEvent = new LOEvent(LOK_SET_PART);
135360
     GError* error = NULL;
135360
@@ -2122,7 +2182,7 @@ lok_doc_view_set_part (LOKDocView* pDocView, int nPart)
135360
 SAL_DLLPUBLIC_EXPORT char*
135360
 lok_doc_view_get_part_name (LOKDocView* pDocView, int nPart)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId);
135360
     return priv->m_pDocument->pClass->getPartName( priv->m_pDocument, nPart );
135360
 }
135360
@@ -2131,7 +2191,7 @@ SAL_DLLPUBLIC_EXPORT void
135360
 lok_doc_view_set_partmode(LOKDocView* pDocView,
135360
                           int nPartMode)
135360
 {
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
135360
     LOEvent* pLOEvent = new LOEvent(LOK_SET_PARTMODE);
135360
     GError* error = NULL;
135360
@@ -2150,7 +2210,7 @@ lok_doc_view_set_partmode(LOKDocView* pDocView,
135360
 SAL_DLLPUBLIC_EXPORT void
135360
 lok_doc_view_reset_view(LOKDocView* pDocView)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     priv->m_aTileBuffer.resetAllTiles();
135360
     priv->m_nLoadProgress = 0.0;
135360
 
135360
@@ -2196,7 +2256,7 @@ SAL_DLLPUBLIC_EXPORT void
135360
 lok_doc_view_set_edit(LOKDocView* pDocView,
135360
                       gboolean bEdit)
135360
 {
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
135360
     LOEvent* pLOEvent = new LOEvent(LOK_SET_EDIT);
135360
     GError* error = NULL;
135360
@@ -2215,7 +2275,7 @@ lok_doc_view_set_edit(LOKDocView* pDocView,
135360
 SAL_DLLPUBLIC_EXPORT gboolean
135360
 lok_doc_view_get_edit (LOKDocView* pDocView)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     return priv->m_bEdit;
135360
 }
135360
 
135360
@@ -2225,7 +2285,7 @@ lok_doc_view_post_command (LOKDocView* pDocView,
135360
                            const gchar* pCommand,
135360
                            const gchar* pArguments)
135360
 {
135360
-    LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
135360
     LOEvent* pLOEvent = new LOEvent(LOK_POST_COMMAND);
135360
     GError* error = NULL;
135360
@@ -2245,14 +2305,14 @@ lok_doc_view_post_command (LOKDocView* pDocView,
135360
 SAL_DLLPUBLIC_EXPORT float
135360
 lok_doc_view_pixel_to_twip (LOKDocView* pDocView, float fInput)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     return pixelToTwip(fInput, priv->m_fZoom);
135360
 }
135360
 
135360
 SAL_DLLPUBLIC_EXPORT float
135360
 lok_doc_view_twip_to_pixel (LOKDocView* pDocView, float fInput)
135360
 {
135360
-    LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
135360
     return twipToPixel(fInput, priv->m_fZoom);
135360
 }
135360
 
135360
diff --git a/libreofficekit/source/gtk/tilebuffer.hxx b/libreofficekit/source/gtk/tilebuffer.hxx
135360
index 34b9001e8bc5..9361a622fb7c 100644
135360
--- a/libreofficekit/source/gtk/tilebuffer.hxx
135360
+++ b/libreofficekit/source/gtk/tilebuffer.hxx
135360
@@ -82,8 +82,8 @@ private:
135360
 class TileBuffer
135360
 {
135360
  public:
135360
- TileBuffer(LibreOfficeKitDocument *document,
135360
-            int columns)
135360
+ TileBuffer(LibreOfficeKitDocument *document = 0,
135360
+            int columns = 0)
135360
      : m_pLOKDocument(document)
135360
         , m_nWidth(columns)
135360
     {
135360
-- 
135360
2.12.0
135360