summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx13
-rw-r--r--desktop/source/lib/init.cxx7
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h3
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx10
-rw-r--r--include/sfx2/lokhelper.hxx3
-rw-r--r--sfx2/source/view/lokhelper.cxx6
6 files changed, 42 insertions, 0 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index a08961403aac..d5616d566f6a 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 0973974fd0d3..95213017726f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -307,6 +307,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
{
@@ -330,6 +331,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;
}
@@ -447,6 +449,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 eae35374e032..b59d3f8c9f5d 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 1a8b002ecba6..32f190227719 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 d439bcedce19..bc3f43010c41 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 4f500e0388ef..1bb43d0ea02f 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: */