summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-09-15 09:31:49 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-09-21 07:30:14 +0200
commit10a0cad9d6990abac507899a34fbcdeb466187f7 (patch)
treefc7e4aacd8d98ba29e80bc31498126165a87df64
parent4f62c14748c0e62ad0212e831d606ac32e694eca (diff)
lok::Document: add destroyView()
Change-Id: Id9e92593217541b4123e95279019cec3c958056c
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx5
-rw-r--r--desktop/source/lib/init.cxx9
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h2
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx9
-rw-r--r--include/sfx2/lokhelper.hxx2
-rw-r--r--sfx2/source/view/lokhelper.cxx12
6 files changed, 38 insertions, 1 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 8642f4491f9f..6baaa32239c9 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 95213017726f..15ab2e7ffa50 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -248,6 +248,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 )
@@ -280,6 +281,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;
}
@@ -1055,6 +1057,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 b59d3f8c9f5d..7f41d13ff393 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 32f190227719..3e1a0ac20b07 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 bc3f43010c41..9430cd5665d8 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 1bb43d0ea02f..557478a78ae6 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();