[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 6 commits - desktop/qa desktop/source include/LibreOfficeKit include/sfx2 include/vcl libreofficekit/qa sfx2/Library_sfx.mk sfx2/source sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Sep 14 07:13:53 PDT 2015


 desktop/qa/desktop_lib/test_desktop_lib.cxx         |   23 ++++++++-----
 desktop/source/lib/init.cxx                         |   26 ++++++++++++++
 include/LibreOfficeKit/LibreOfficeKit.h             |    6 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx           |   20 +++++++++++
 include/sfx2/lokhelper.hxx                          |   24 +++++++++++++
 include/vcl/ITiledRenderable.hxx                    |   10 +++++
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |   24 +++++++++++++
 sfx2/Library_sfx.mk                                 |    1 
 sfx2/source/view/lokhelper.cxx                      |   35 ++++++++++++++++++++
 sw/inc/unotxdoc.hxx                                 |    2 +
 sw/source/uibase/uno/unotxdoc.cxx                   |    5 ++
 11 files changed, 168 insertions(+), 8 deletions(-)

New commits:
commit ba274cf01612d1c2355dbc1434ccfa76004d0056
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 14 15:56:34 2015 +0200

    CppunitTest_desktop_lib: fix reported name of failed test
    
    Change-Id: Iaa9effdcf6d6c6b2292e3fc7b666afdb3678694d

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d5616d5..8642f44 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -48,13 +48,14 @@ public:
     LibLODocument_Impl* loadDoc(const char* pName);
     void closeDoc();
 
-    void runAllTests();
     void testGetStyles();
     void testGetFonts();
     void testCreateView();
 
     CPPUNIT_TEST_SUITE(DesktopLOKTest);
-    CPPUNIT_TEST(runAllTests);
+    CPPUNIT_TEST(testGetStyles);
+    CPPUNIT_TEST(testGetFonts);
+    CPPUNIT_TEST(testCreateView);
     CPPUNIT_TEST_SUITE_END();
 
     uno::Reference<lang::XComponent> mxComponent;
@@ -81,13 +82,6 @@ void DesktopLOKTest::closeDoc()
     }
 }
 
-void DesktopLOKTest::runAllTests()
-{
-    testGetStyles();
-    testGetFonts();
-    testCreateView();
-}
-
 void DesktopLOKTest::testGetStyles()
 {
     LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
commit 7642889cdced365d1200ae88086e094c704e94cd
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 14 15:43:17 2015 +0200

    lok::Office: add getViews()
    
    Change-Id: Iabfb0f2a19106dc4a6bdae45f9e85d76c68a973e

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a089614..d5616d5 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -14,6 +14,7 @@
 #include <boost/property_tree/json_parser.hpp>
 #include <comphelper/processfactory.hxx>
 #include <sfx2/objsh.hxx>
+#include <sfx2/lokhelper.hxx>
 #include <test/unoapi_test.hxx>
 
 #include "../../inc/lib/init.hxx"
@@ -50,6 +51,7 @@ public:
     void runAllTests();
     void testGetStyles();
     void testGetFonts();
+    void testCreateView();
 
     CPPUNIT_TEST_SUITE(DesktopLOKTest);
     CPPUNIT_TEST(runAllTests);
@@ -83,6 +85,7 @@ void DesktopLOKTest::runAllTests()
 {
     testGetStyles();
     testGetFonts();
+    testCreateView();
 }
 
 void DesktopLOKTest::testGetStyles()
@@ -134,6 +137,16 @@ void DesktopLOKTest::testGetFonts()
     closeDoc();
 }
 
+void DesktopLOKTest::testCreateView()
+{
+    LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+    CPPUNIT_ASSERT_EQUAL(1, SfxLokHelper::getViews());
+
+    pDocument->m_pDocumentClass->createView(pDocument);
+    CPPUNIT_ASSERT_EQUAL(2, SfxLokHelper::getViews());
+    closeDoc();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 15a93cb..c35c6a4 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -305,6 +305,7 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions  (LibreOfficeKit* pThi
 static void                    lo_registerCallback (LibreOfficeKit* pThis,
                                                     LibreOfficeKitCallback pCallback,
                                                     void* pData);
+static int lo_getViews(LibreOfficeKit* pThis);
 
 struct LibLibreOffice_Impl : public _LibreOfficeKit
 {
@@ -328,6 +329,7 @@ struct LibLibreOffice_Impl : public _LibreOfficeKit
             m_pOfficeClass->getError = lo_getError;
             m_pOfficeClass->documentLoadWithOptions = lo_documentLoadWithOptions;
             m_pOfficeClass->registerCallback = lo_registerCallback;
+            m_pOfficeClass->getViews = lo_getViews;
 
             gOfficeClass = m_pOfficeClass;
         }
@@ -445,6 +447,11 @@ static void lo_registerCallback (LibreOfficeKit* pThis,
     pLib->mpCallbackData = pData;
 }
 
+static int lo_getViews(LibreOfficeKit* /*pThis*/)
+{
+    return SfxLokHelper::getViews();
+}
+
 static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const char* pFormat, const char* pFilterOptions)
 {
     LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index eae3537..b59d3f8 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -54,6 +54,9 @@ struct _LibreOfficeKitClass
     void (*registerCallback) (LibreOfficeKit* pThis,
                               LibreOfficeKitCallback pCallback,
                               void* pData);
+
+    /// @see lok::Office::getViews().
+    int (*getViews) (LibreOfficeKit* pThis);
 #endif
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 1a8b002..32f1902 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -313,6 +313,16 @@ public:
     {
         return mpThis->pClass->getError(mpThis);
     }
+
+#ifdef LOK_USE_UNSTABLE_API
+    /**
+     * Get number of total views.
+     */
+    inline int getViews()
+    {
+        return mpThis->pClass->getViews(mpThis);
+    }
+#endif
 };
 
 /// Factory method to create a lok::Office instance.
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index d439bce..bc3f430 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -16,6 +16,9 @@ class SFX2_DLLPUBLIC SfxLokHelper
 public:
     /// Create a new view shell for pViewShell's object shell.
     static int createView(SfxViewShell* pViewShell);
+
+    /// Total number of view shells.
+    static int getViews();
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 4f500e0..1bb43d0 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -26,4 +26,10 @@ int SfxLokHelper::createView(SfxViewShell* pViewShell)
     return rViewArr.size() - 1;
 }
 
+int SfxLokHelper::getViews()
+{
+    SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl();
+    return rViewArr.size();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 61b0018ac15ef4366e80d4e01191128d49fe54a4
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 14 15:10:22 2015 +0200

    gtktiledviewer: add button tooltips
    
    Change-Id: Ifad67adf80761118bbbfb110cbadd493214fee93

diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index dfc9b6d..6f10935 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -513,16 +513,19 @@ int main( int argc, char* argv[] )
 
     GtkToolItem* pZoomIn = gtk_tool_button_new( NULL, NULL );
     gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pZoomIn), "zoom-in-symbolic");
+    gtk_tool_item_set_tooltip_text(pZoomIn, "Zoom In");
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pZoomIn, 0);
     g_signal_connect( G_OBJECT(pZoomIn), "clicked", G_CALLBACK(changeZoom), NULL );
 
     GtkToolItem* pZoom1 = gtk_tool_button_new( NULL, NULL );
     gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pZoom1), "zoom-original-symbolic");
+    gtk_tool_item_set_tooltip_text(pZoom1, "Normal Size");
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pZoom1, -1);
     g_signal_connect( G_OBJECT(pZoom1), "clicked", G_CALLBACK(changeZoom), NULL );
 
     GtkToolItem* pZoomOut = gtk_tool_button_new( NULL, NULL );
     gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pZoomOut), "zoom-out-symbolic");
+    gtk_tool_item_set_tooltip_text(pZoomOut, "Zoom Out");
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), pZoomOut, -1);
     g_signal_connect( G_OBJECT(pZoomOut), "clicked", G_CALLBACK(changeZoom), NULL );
 
@@ -549,17 +552,20 @@ int main( int argc, char* argv[] )
     // Cut, copy & paste.
     GtkToolItem* pCopyButton = gtk_tool_button_new( NULL, NULL);
     gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(pCopyButton), "edit-copy-symbolic");
+    gtk_tool_item_set_tooltip_text(pCopyButton, "Copy");
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pCopyButton, -1);
     g_signal_connect(G_OBJECT(pCopyButton), "clicked", G_CALLBACK(doCopy), NULL);
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1);
 
     pEnableEditing = gtk_toggle_tool_button_new();
     gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pEnableEditing), "insert-text-symbolic");
+    gtk_tool_item_set_tooltip_text(pEnableEditing, "Edit");
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pEnableEditing, -1);
     g_signal_connect(G_OBJECT(pEnableEditing), "toggled", G_CALLBACK(toggleEditing), NULL);
 
     GtkToolItem* pFindButton = gtk_tool_button_new( NULL, NULL);
     gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pFindButton), "edit-find-symbolic");
+    gtk_tool_item_set_tooltip_text(pFindButton, "Find");
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pFindButton, -1);
     g_signal_connect(G_OBJECT(pFindButton), "clicked", G_CALLBACK(toggleFindbar), NULL);
 
@@ -573,24 +579,28 @@ int main( int argc, char* argv[] )
 
     pBold = gtk_toggle_tool_button_new();
     gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pBold), "format-text-bold-symbolic");
+    gtk_tool_item_set_tooltip_text(pBold, "Bold");
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pBold, -1);
     g_signal_connect(G_OBJECT(pBold), "toggled", G_CALLBACK(toggleToolItem), NULL);
     lcl_registerToolItem(pBold, ".uno:Bold");
 
     pItalic = gtk_toggle_tool_button_new();
     gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pItalic), "format-text-italic-symbolic");
+    gtk_tool_item_set_tooltip_text(pItalic, "Italic");
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pItalic, -1);
     g_signal_connect(G_OBJECT(pItalic), "toggled", G_CALLBACK(toggleToolItem), NULL);
     lcl_registerToolItem(pItalic, ".uno:Italic");
 
     pUnderline = gtk_toggle_tool_button_new();
     gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pUnderline), "format-text-underline-symbolic");
+    gtk_tool_item_set_tooltip_text(pUnderline, "Underline");
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pUnderline, -1);
     g_signal_connect(G_OBJECT(pUnderline), "toggled", G_CALLBACK(toggleToolItem), NULL);
     lcl_registerToolItem(pUnderline, ".uno:Underline");
 
     pStrikethrough = gtk_toggle_tool_button_new ();
     gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pStrikethrough), "format-text-strikethrough-symbolic");
+    gtk_tool_item_set_tooltip_text(pStrikethrough, "Strikethrough");
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pStrikethrough, -1);
     g_signal_connect(G_OBJECT(pStrikethrough), "toggled", G_CALLBACK(toggleToolItem), NULL);
     lcl_registerToolItem(pStrikethrough, ".uno:Strikeout");
commit 7d86b2e44b58f03f18b1417fadeedd01ad2eaebf
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 14 14:36:56 2015 +0200

    lok::Document: add createView()
    
    Change-Id: Ic871ec41992b611b10958799b2dc12375a91efe4

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index fb8ec3e..15a93cb 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -48,6 +48,7 @@
 #include <editeng/fontitem.hxx>
 #include <editeng/flstitem.hxx>
 #include <sfx2/objsh.hxx>
+#include <sfx2/lokhelper.hxx>
 #include <svx/svxids.hrc>
 #include <vcl/svapp.hxx>
 #include <vcl/svpforlokit.hxx>
@@ -244,6 +245,7 @@ static void doc_setGraphicSelection (LibreOfficeKitDocument* pThis,
 static void doc_resetSelection (LibreOfficeKitDocument* pThis);
 static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCommand);
 
+static int doc_createView(LibreOfficeKitDocument* pThis);
 
 LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) :
     mxComponent( xComponent )
@@ -275,6 +277,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->resetSelection = doc_resetSelection;
         m_pDocumentClass->getCommandValues = doc_getCommandValues;
 
+        m_pDocumentClass->createView = doc_createView;
+
         gDocumentClass = m_pDocumentClass;
     }
     pClass = m_pDocumentClass.get();
@@ -974,6 +978,21 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo
     }
 }
 
+static int doc_createView(LibreOfficeKitDocument* pThis)
+{
+    SolarMutexGuard aGuard;
+
+    ITiledRenderable* pDoc = getTiledRenderable(pThis);
+    if (!pDoc)
+    {
+        gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+        return -1;
+    }
+
+    SfxViewShell* pViewShell = pDoc->getCurrentViewShell();
+    return SfxLokHelper::createView(pViewShell);
+}
+
 static char* lo_getError (LibreOfficeKit *pThis)
 {
     LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 8060f0e..eae3537 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -162,6 +162,9 @@ struct _LibreOfficeKitDocumentClass
 
     /// @see lok::Document:getStyles
     char* (*getCommandValues) (LibreOfficeKitDocument* pThis, const char* pCommand);
+
+    /// @see lok::Document::createView().
+    int (*createView) (LibreOfficeKitDocument* pThis);
 #endif // LOK_USE_UNSTABLE_API
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 4459994..1a8b002 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -257,6 +257,16 @@ public:
     {
         return mpDoc->pClass->getCommandValues(mpDoc, pCommand);
     }
+
+    /**
+     * Create a new view for an existing document.
+     * By default a loaded document has 1 view.
+     * @return the ID of the new view.
+     */
+    int createView()
+    {
+        return mpDoc->pClass->createView(mpDoc);
+    }
 #endif // LOK_USE_UNSTABLE_API
 };
 
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 43afaf9..dfc9b6d 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -147,6 +147,14 @@ static void toggleFindbar(GtkWidget* /*pButton*/, gpointer /*pItem*/)
     }
 }
 
+/// Calls lok::Document::createView().
+static void createView(GtkWidget* /*pButton*/, gpointer /*pItem*/)
+{
+    LOKDocView* pLOKDocView = LOK_DOC_VIEW(pDocView);
+    LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(pLOKDocView);
+    pDocument->pClass->createView(pDocument);
+}
+
 /// Our GtkClipboardGetFunc implementation for HTML.
 static void htmlGetFunc(GtkClipboard* /*pClipboard*/, GtkSelectionData* pSelectionData, guint /*info*/, gpointer pUserData)
 {
@@ -555,6 +563,12 @@ int main( int argc, char* argv[] )
     gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pFindButton, -1);
     g_signal_connect(G_OBJECT(pFindButton), "clicked", G_CALLBACK(toggleFindbar), NULL);
 
+    GtkToolItem* pNewViewButton = gtk_tool_button_new( NULL, NULL);
+    gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON (pNewViewButton), "view-continuous-symbolic");
+    gtk_tool_item_set_tooltip_text(pNewViewButton, "New View");
+    gtk_toolbar_insert(GTK_TOOLBAR(pToolbar), pNewViewButton, -1);
+    g_signal_connect(G_OBJECT(pNewViewButton), "clicked", G_CALLBACK(createView), NULL);
+
     gtk_toolbar_insert( GTK_TOOLBAR(pToolbar), gtk_separator_tool_item_new(), -1);
 
     pBold = gtk_toggle_tool_button_new();
commit 2fc69762a43f97df4f790a641b23f2d556c069b3
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 14 14:36:38 2015 +0200

    sfx2: add SfxLokHelper
    
    This is meant to be a class that is visible outside sfx2 (so e.g.
    desktop can use it later), but has access to various sfx2 internals.
    
    Change-Id: I83204963492b11c1c4a621e86528a64fba27acf3

diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
new file mode 100644
index 0000000..d439bce
--- /dev/null
+++ b/include/sfx2/lokhelper.hxx
@@ -0,0 +1,21 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sfx2/dllapi.h>
+
+class SfxViewShell;
+
+class SFX2_DLLPUBLIC SfxLokHelper
+{
+public:
+    /// Create a new view shell for pViewShell's object shell.
+    static int createView(SfxViewShell* pViewShell);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index faba426..9f0bb3d 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -297,6 +297,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
     sfx2/source/view/frame2 \
     sfx2/source/view/frmload \
     sfx2/source/view/ipclient \
+    sfx2/source/view/lokhelper \
     sfx2/source/view/printer \
     sfx2/source/view/sfxbasecontroller \
     sfx2/source/view/userinputinterception \
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
new file mode 100644
index 0000000..4f500e0
--- /dev/null
+++ b/sfx2/source/view/lokhelper.cxx
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sfx2/lokhelper.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <sfx2/viewfrm.hxx>
+
+#include <shellimpl.hxx>
+
+int SfxLokHelper::createView(SfxViewShell* pViewShell)
+{
+    SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
+    SfxRequest aRequest(pViewFrame, SID_NEWWINDOW);
+    pViewFrame->ExecView_Impl(aRequest);
+
+    // The SfxViewShell ctor always puts the view shell to the end of the vector.
+    SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl();
+    return rViewArr.size() - 1;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit f0f082fa3a6f3bf2396b477a2c5e810b532b7ab8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 14 12:50:48 2015 +0200

    vcl::ITiledRenderable: add getCurrentViewShell() and implement it for Writer
    
    Change-Id: Ic936746f3d473e15f5a1589cba35173778b442c6

diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index 8824361..a31d808 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -16,6 +16,8 @@
 #include <tools/gen.hxx>
 #include <vcl/virdev.hxx>
 
+class SfxViewShell;
+
 namespace vcl
 {
 
@@ -139,8 +141,16 @@ public:
      * @see lok::Document::resetSelection().
      */
     virtual void resetSelection() = 0;
+
+    /// Get the currently active view shell of the document.
+    virtual SfxViewShell* getCurrentViewShell()
+    {
+        return 0;
+    }
 };
 
 } // namespace vcl
 
 #endif // INCLUDED_VCL_ITILEDRENDERABLE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 8306b83..0ca6e5b 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -428,6 +428,8 @@ public:
     virtual void setGraphicSelection(int nType, int nX, int nY) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::resetSelection().
     virtual void resetSelection() SAL_OVERRIDE;
+    /// @see vcl::ITiledRenderable::getCurrentViewShell().
+    virtual SfxViewShell* getCurrentViewShell() SAL_OVERRIDE;
 
     // ::com::sun::star::tiledrendering::XTiledRenderable
     virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) throw (::css::uno::RuntimeException, ::std::exception) SAL_OVERRIDE;
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index fe75178..bd35606 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3400,6 +3400,11 @@ void SwXTextDocument::resetSelection()
     pWrtShell->ResetSelect(0, false);
 }
 
+SfxViewShell* SwXTextDocument::getCurrentViewShell()
+{
+    return pDocShell->GetView();
+}
+
 void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) throw (::css::uno::RuntimeException, ::std::exception)
 {
     SystemGraphicsData aData;


More information about the Libreoffice-commits mailing list