diff options
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 6 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 17 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.h | 5 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.hxx | 18 | ||||
-rw-r--r-- | include/sfx2/lokhelper.hxx | 5 | ||||
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 13 |
6 files changed, 35 insertions, 29 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 7ad81278d64a..0cd88cefffa0 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -134,10 +134,10 @@ void DesktopLOKTest::testGetFonts() void DesktopLOKTest::testCreateView() { LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); - CPPUNIT_ASSERT_EQUAL(1, SfxLokHelper::getViews()); + CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViews(pDocument)); int nId = pDocument->m_pDocumentClass->createView(pDocument); - CPPUNIT_ASSERT_EQUAL(2, SfxLokHelper::getViews()); + CPPUNIT_ASSERT_EQUAL(2, pDocument->m_pDocumentClass->getViews(pDocument)); // Make sure the created view is the active one, then switch to the old // one. @@ -146,7 +146,7 @@ void DesktopLOKTest::testCreateView() CPPUNIT_ASSERT_EQUAL(0, pDocument->m_pDocumentClass->getView(pDocument)); pDocument->m_pDocumentClass->destroyView(pDocument, nId); - CPPUNIT_ASSERT_EQUAL(1, SfxLokHelper::getViews()); + CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViews(pDocument)); closeDoc(); } diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 0548ea3329ef..c4301fd7695e 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -251,6 +251,7 @@ static int doc_createView(LibreOfficeKitDocument* pThis); static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId); static void doc_setView(LibreOfficeKitDocument* pThis, int nId); static int doc_getView(LibreOfficeKitDocument* pThis); +static int doc_getViews(LibreOfficeKitDocument* pThis); LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) : mxComponent( xComponent ) @@ -286,6 +287,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone m_pDocumentClass->destroyView = doc_destroyView; m_pDocumentClass->setView = doc_setView; m_pDocumentClass->getView = doc_getView; + m_pDocumentClass->getViews = doc_getViews; gDocumentClass = m_pDocumentClass; } @@ -313,8 +315,6 @@ 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 { OUString maLastExceptionMsg; @@ -337,7 +337,6 @@ 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; } @@ -455,11 +454,6 @@ 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); @@ -1074,6 +1068,13 @@ static int doc_getView(LibreOfficeKitDocument* /*pThis*/) return SfxLokHelper::getView(); } +static int doc_getViews(LibreOfficeKitDocument* /*pThis*/) +{ + SolarMutexGuard aGuard; + + return SfxLokHelper::getViews(); +} + 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 18f4b3edc624..fc025aed5b15 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -54,9 +54,6 @@ struct _LibreOfficeKitClass void (*registerCallback) (LibreOfficeKit* pThis, LibreOfficeKitCallback pCallback, void* pData); - - /// @see lok::Office::getViews(). - int (*getViews) (LibreOfficeKit* pThis); #endif }; @@ -174,6 +171,8 @@ struct _LibreOfficeKitDocumentClass void (*setView) (LibreOfficeKitDocument* pThis, int nId); /// @see lok::Document::getView(). int (*getView) (LibreOfficeKitDocument* pThis); + /// @see lok::Document::getViews(). + int (*getViews) (LibreOfficeKitDocument* pThis); #endif // LOK_USE_UNSTABLE_API }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index f5821b71191a..45ace9dfff04 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -294,6 +294,14 @@ public: { return mpDoc->pClass->getView(mpDoc); } + + /** + * Get number of views of this document. + */ + inline int getViews() + { + return mpDoc->pClass->getViews(mpDoc); + } #endif // LOK_USE_UNSTABLE_API }; @@ -340,16 +348,6 @@ 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 50516227e992..99f2076eeea1 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -25,9 +25,8 @@ public: static void setView(size_t nId); /// Get the currently active view. static size_t getView(); - - /// Total number of view shells. - static int getViews(); + /// Get the number of views of the current object shell. + static size_t getViews(); }; #endif diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 0beb06ddd956..646715ef226f 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -62,10 +62,19 @@ size_t SfxLokHelper::getView() return 0; } -int SfxLokHelper::getViews() +size_t SfxLokHelper::getViews() { + size_t nRet = 0; + + SfxObjectShell* pObjectShell = SfxViewFrame::Current()->GetObjectShell(); SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); - return rViewArr.size(); + for (size_t i = 0; i < rViewArr.size(); ++i) + { + if (rViewArr[i]->GetObjectShell() == pObjectShell) + ++nRet; + } + + return nRet; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |