[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - desktop/qa desktop/source include/LibreOfficeKit include/sfx2 sfx2/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Sep 15 00:33:01 PDT 2015


 desktop/qa/desktop_lib/test_desktop_lib.cxx |    5 ++++-
 desktop/source/lib/init.cxx                 |    9 +++++++++
 include/LibreOfficeKit/LibreOfficeKit.h     |    2 ++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |    9 +++++++++
 include/sfx2/lokhelper.hxx                  |    2 ++
 sfx2/source/view/lokhelper.cxx              |   12 ++++++++++++
 6 files changed, 38 insertions(+), 1 deletion(-)

New commits:
commit fd7d12fbcecacb059145db5ce9360d3b9e3b9e85
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 15 09:31:49 2015 +0200

    lok::Document: add destroyView()
    
    Change-Id: Id9e92593217541b4123e95279019cec3c958056c

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 8642f44..6baaa32 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -136,8 +136,11 @@ void DesktopLOKTest::testCreateView()
     LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
     CPPUNIT_ASSERT_EQUAL(1, SfxLokHelper::getViews());
 
-    pDocument->m_pDocumentClass->createView(pDocument);
+    int nId = pDocument->m_pDocumentClass->createView(pDocument);
     CPPUNIT_ASSERT_EQUAL(2, SfxLokHelper::getViews());
+
+    pDocument->m_pDocumentClass->destroyView(pDocument, nId);
+    CPPUNIT_ASSERT_EQUAL(1, SfxLokHelper::getViews());
     closeDoc();
 }
 
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index c35c6a4..0d1e870 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -246,6 +246,7 @@ static void doc_resetSelection (LibreOfficeKitDocument* pThis);
 static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCommand);
 
 static int doc_createView(LibreOfficeKitDocument* pThis);
+static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId);
 
 LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) :
     mxComponent( xComponent )
@@ -278,6 +279,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->getCommandValues = doc_getCommandValues;
 
         m_pDocumentClass->createView = doc_createView;
+        m_pDocumentClass->destroyView = doc_destroyView;
 
         gDocumentClass = m_pDocumentClass;
     }
@@ -1000,6 +1002,13 @@ static int doc_createView(LibreOfficeKitDocument* pThis)
     return SfxLokHelper::createView(pViewShell);
 }
 
+static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, int nId)
+{
+    SolarMutexGuard aGuard;
+
+    SfxLokHelper::destroyView(nId);
+}
+
 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 b59d3f8..7f41d13 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -168,6 +168,8 @@ struct _LibreOfficeKitDocumentClass
 
     /// @see lok::Document::createView().
     int (*createView) (LibreOfficeKitDocument* pThis);
+    /// @see lok::Document::destroyView().
+    void (*destroyView) (LibreOfficeKitDocument* pThis, int nId);
 #endif // LOK_USE_UNSTABLE_API
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 32f1902..3e1a0ac 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -267,6 +267,15 @@ public:
     {
         return mpDoc->pClass->createView(mpDoc);
     }
+
+    /**
+     * Destroy a view of an existring document.
+     * @param nId a view ID, returned by createView().
+     */
+    void destroyView(int nId)
+    {
+        mpDoc->pClass->destroyView(mpDoc, nId);
+    }
 #endif // LOK_USE_UNSTABLE_API
 };
 
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index bc3f430..9430cd5 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -16,6 +16,8 @@ class SFX2_DLLPUBLIC SfxLokHelper
 public:
     /// Create a new view shell for pViewShell's object shell.
     static int createView(SfxViewShell* pViewShell);
+    /// Destroy a view shell from the global shell list.
+    static void destroyView(size_t nId);
 
     /// Total number of view shells.
     static int getViews();
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 1bb43d0..557478a 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -26,6 +26,18 @@ int SfxLokHelper::createView(SfxViewShell* pViewShell)
     return rViewArr.size() - 1;
 }
 
+void SfxLokHelper::destroyView(size_t nId)
+{
+    SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl();
+    if (nId > rViewArr.size() - 1)
+        return;
+
+    SfxViewShell* pViewShell = rViewArr[nId];
+    SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
+    SfxRequest aRequest(pViewFrame, SID_CLOSEWIN);
+    pViewFrame->Exec_Impl(aRequest);
+}
+
 int SfxLokHelper::getViews()
 {
     SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl();


More information about the Libreoffice-commits mailing list