Kaydet (Commit) 18b9b1b7 authored tarafından Miklos Vajna's avatar Miklos Vajna

lok::Office: add getViews()

Change-Id: Iabfb0f2a19106dc4a6bdae45f9e85d76c68a973e
(cherry picked from commit 2e523afe)
üst dc331776
......@@ -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();
......
......@@ -310,6 +310,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
{
......@@ -333,6 +334,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;
}
......@@ -450,6 +452,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);
......
......@@ -54,6 +54,9 @@ struct _LibreOfficeKitClass
void (*registerCallback) (LibreOfficeKit* pThis,
LibreOfficeKitCallback pCallback,
void* pData);
/// @see lok::Office::getViews().
int (*getViews) (LibreOfficeKit* pThis);
#endif
};
......
......@@ -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.
......
......@@ -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: */
......@@ -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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment