desktop/qa/desktop_lib/test_desktop_lib.cxx | 12 +++++-- desktop/source/lib/init.cxx | 47 +++++++++++++++++----------- include/LibreOfficeKit/LibreOfficeKit.h | 9 +++-- include/LibreOfficeKit/LibreOfficeKit.hxx | 38 ++++++++++++++++------ include/sfx2/lokhelper.hxx | 13 ++++--- include/vcl/ITiledRenderable.hxx | 8 ---- libreofficekit/source/gtk/lokdocview.cxx | 21 +++++++----- sfx2/source/view/lokhelper.cxx | 41 ++++++++++++++++++++++-- sw/inc/unotxdoc.hxx | 2 - sw/source/uibase/uno/unotxdoc.cxx | 5 -- 10 files changed, 129 insertions(+), 67 deletions(-)
New commits: commit 711598801a3ccd7d7564929b1917cdb64754a942 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Sep 16 14:14:04 2015 +0200 LOK: make getViews() be a member function of Document Just to be consistent, as all other view-related member functions are there, too. No real impact, as only the unit test uses this so far, and it always works with a single document. Change-Id: I46f1ed8265ab95017986ab45c1b510e961192241 diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 7ad8127..0cd88ce 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 eba9c0b..4f17cb7 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -249,6 +249,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 ) @@ -284,6 +285,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; } @@ -311,8 +313,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; @@ -335,7 +335,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; } @@ -453,11 +452,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); @@ -1019,6 +1013,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 18f4b3e..fc025ae 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 f5821b7..45ace9d 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 5051622..99f2076 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 0beb06d..646715e 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: */ commit 3c01b6cdc3f52340a1a55cba6a33b01b5f5ee2c7 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Sep 16 12:30:25 2015 +0200 gtktiledviewer: use setView() before postKeyEvent() Also in SfxLokHelper::setView() set the current view shell directly, GetFocus() in VCL may be a NOP for hidden windows. With this, the Writer layout dump shows that two Gtk windows can have different cursor positions correctly. Change-Id: I81890c1d8ad7972f1194db3d5f2e9d8a39fc2f87 diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 271625f..25f1c48 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -106,6 +106,9 @@ struct _LOKDocViewPrivate /// If we are in the middle of a drag of a graphic selection handle. gboolean m_bInDragGraphicHandles[8]; ///@} + + /// View ID, returned by createView() or 0 by default. + int m_nViewId; }; enum @@ -240,6 +243,7 @@ postKeyEventInThread(gpointer data) LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView)); LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task)); + priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId); priv->m_pDocument->pClass->postKeyEvent(priv->m_pDocument, pLOEvent->m_nKeyEvent, pLOEvent->m_nCharCode, @@ -1847,18 +1851,19 @@ lok_doc_view_new (const gchar* pPath, GCancellable *cancellable, GError **error) return GTK_WIDGET (g_initable_new (LOK_TYPE_DOC_VIEW, cancellable, error, "lopath", pPath, NULL)); } -SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new_from_widget(LOKDocView* pLOKDocView) +SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new_from_widget(LOKDocView* pOldLOKDocView) { - LOKDocViewPrivate* priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private(pLOKDocView)); - GtkWidget* pDocView = GTK_WIDGET(g_initable_new(LOK_TYPE_DOC_VIEW, /*cancellable=*/0, /*error=*/0, - "lopath", priv->m_aLOPath, "lopointer", priv->m_pOffice, "docpointer", priv->m_pDocument, NULL)); + LOKDocViewPrivate* pOldPriv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private(pOldLOKDocView)); + GtkWidget* pNewDocView = GTK_WIDGET(g_initable_new(LOK_TYPE_DOC_VIEW, /*cancellable=*/0, /*error=*/0, + "lopath", pOldPriv->m_aLOPath, "lopointer", pOldPriv->m_pOffice, "docpointer", pOldPriv->m_pDocument, NULL)); // No documentLoad(), just a createView(). - LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(pDocView)); - pDocument->pClass->createView(pDocument); + LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(pNewDocView)); + LOKDocViewPrivate* pNewPriv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private(LOK_DOC_VIEW(pNewDocView))); + pNewPriv->m_nViewId = pDocument->pClass->createView(pDocument); - postDocumentLoad(pDocView); - return pDocView; + postDocumentLoad(pNewDocView); + return pNewDocView; } /** diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index f53d2b3..0beb06d 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -46,7 +46,7 @@ void SfxLokHelper::setView(size_t nId) SfxViewShell* pViewShell = rViewArr[nId]; if (SfxViewFrame* pViewFrame = pViewShell->GetViewFrame()) - pViewFrame->GetWindow().GrabFocus(); + pViewFrame->MakeActive_Impl(false); } size_t SfxLokHelper::getView() commit b18b49b529c4b97c7cc97438424ed33d6746e364 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Sep 16 10:32:34 2015 +0200 Use SfxViewFrame::Current() Allows getting rid of vcl::ITiledRenderable::getCurrentViewShell(), which would do the same, just not implemented outside Writer. Change-Id: Id26ceca560fb9002dc2d5c740c411b9c4a149523 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index a0f1110..eba9c0b 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -991,19 +991,11 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo } } -static int doc_createView(LibreOfficeKitDocument* pThis) +static int doc_createView(LibreOfficeKitDocument* /*pThis*/) { SolarMutexGuard aGuard; - ITiledRenderable* pDoc = getTiledRenderable(pThis); - if (!pDoc) - { - gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; - return -1; - } - - SfxViewShell* pViewShell = pDoc->getCurrentViewShell(); - return SfxLokHelper::createView(pViewShell); + return SfxLokHelper::createView(); } static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, int nId) diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index a05cd5d..5051622 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -17,8 +17,8 @@ class SfxViewShell; class SFX2_DLLPUBLIC SfxLokHelper { public: - /// Create a new view shell for pViewShell's object shell. - static int createView(SfxViewShell* pViewShell); + /// Create a new view shell from the current view frame. + static int createView(); /// Destroy a view shell from the global shell list. static void destroyView(size_t nId); /// Set a view shell as current one. diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx index a31d808..6639745 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -16,8 +16,6 @@ #include <tools/gen.hxx> #include <vcl/virdev.hxx> -class SfxViewShell; - namespace vcl { @@ -141,12 +139,6 @@ public: * @see lok::Document::resetSelection(). */ virtual void resetSelection() = 0; - - /// Get the currently active view shell of the document. - virtual SfxViewShell* getCurrentViewShell() - { - return 0; - } }; } // namespace vcl diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 0aea6db..f53d2b3 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -15,9 +15,9 @@ #include <shellimpl.hxx> -int SfxLokHelper::createView(SfxViewShell* pViewShell) +int SfxLokHelper::createView() { - SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); + SfxViewFrame* pViewFrame = SfxViewFrame::Current(); SfxRequest aRequest(pViewFrame, SID_NEWWINDOW); pViewFrame->ExecView_Impl(aRequest); diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 0ca6e5b..8306b83 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -428,8 +428,6 @@ public: virtual void setGraphicSelection(int nType, int nX, int nY) SAL_OVERRIDE; /// @see vcl::ITiledRenderable::resetSelection(). virtual void resetSelection() SAL_OVERRIDE; - /// @see vcl::ITiledRenderable::getCurrentViewShell(). - virtual SfxViewShell* getCurrentViewShell() SAL_OVERRIDE; // ::com::sun::star::tiledrendering::XTiledRenderable virtual void SAL_CALL paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) throw (::css::uno::RuntimeException, ::std::exception) SAL_OVERRIDE; diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index bd35606..fe75178 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3400,11 +3400,6 @@ void SwXTextDocument::resetSelection() pWrtShell->ResetSelect(0, false); } -SfxViewShell* SwXTextDocument::getCurrentViewShell() -{ - return pDocShell->GetView(); -} - void SAL_CALL SwXTextDocument::paintTile( const ::css::uno::Any& Parent, ::sal_Int32 nOutputWidth, ::sal_Int32 nOutputHeight, ::sal_Int32 nTilePosX, ::sal_Int32 nTilePosY, ::sal_Int32 nTileWidth, ::sal_Int32 nTileHeight ) throw (::css::uno::RuntimeException, ::std::exception) { SystemGraphicsData aData; commit 8fbfba74539d49fd9f17c3732b3c0f002c2b2b97 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Sep 16 09:30:41 2015 +0200 lok::Document: add get/setView() Change-Id: Ic3bce8f01d7e048e853c063c4bce1255845c60d0 diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 6baaa32..7ad8127 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -139,6 +139,12 @@ void DesktopLOKTest::testCreateView() int nId = pDocument->m_pDocumentClass->createView(pDocument); CPPUNIT_ASSERT_EQUAL(2, SfxLokHelper::getViews()); + // Make sure the created view is the active one, then switch to the old + // one. + CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getView(pDocument)); + pDocument->m_pDocumentClass->setView(pDocument, 0); + CPPUNIT_ASSERT_EQUAL(0, pDocument->m_pDocumentClass->getView(pDocument)); + 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 0d1e870..a0f1110 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -247,6 +247,8 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo 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); LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) : mxComponent( xComponent ) @@ -280,6 +282,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone m_pDocumentClass->createView = doc_createView; m_pDocumentClass->destroyView = doc_destroyView; + m_pDocumentClass->setView = doc_setView; + m_pDocumentClass->getView = doc_getView; gDocumentClass = m_pDocumentClass; } @@ -1009,6 +1013,20 @@ static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, int nId) SfxLokHelper::destroyView(nId); } +static void doc_setView(LibreOfficeKitDocument* /*pThis*/, int nId) +{ + SolarMutexGuard aGuard; + + SfxLokHelper::setView(nId); +} + +static int doc_getView(LibreOfficeKitDocument* /*pThis*/) +{ + SolarMutexGuard aGuard; + + return SfxLokHelper::getView(); +} + 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 7f41d13..18f4b3e 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -170,6 +170,10 @@ struct _LibreOfficeKitDocumentClass int (*createView) (LibreOfficeKitDocument* pThis); /// @see lok::Document::destroyView(). void (*destroyView) (LibreOfficeKitDocument* pThis, int nId); + /// @see lok::Document::setView(). + void (*setView) (LibreOfficeKitDocument* pThis, int nId); + /// @see lok::Document::getView(). + int (*getView) (LibreOfficeKitDocument* pThis); #endif // LOK_USE_UNSTABLE_API }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 3e1a0ac..f5821b7 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -269,13 +269,31 @@ public: } /** - * Destroy a view of an existring document. + * Destroy a view of an existing document. * @param nId a view ID, returned by createView(). */ void destroyView(int nId) { mpDoc->pClass->destroyView(mpDoc, nId); } + + /** + * Set an existing view of an existing document as current. + * @param nId a view ID, returned by createView(). + */ + void setView(int nId) + { + mpDoc->pClass->setView(mpDoc, nId); + } + + /** + * Get the current view. + * @return a view ID, previously returned by createView(). + */ + int getView() + { + return mpDoc->pClass->getView(mpDoc); + } #endif // LOK_USE_UNSTABLE_API }; diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index b57cb7d..a05cd5d 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -21,6 +21,10 @@ public: static int createView(SfxViewShell* pViewShell); /// Destroy a view shell from the global shell list. static void destroyView(size_t nId); + /// Set a view shell as current one. + static void setView(size_t nId); + /// Get the currently active view. + static size_t getView(); /// Total number of view shells. static int getViews(); diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 557478a..0aea6db 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -38,6 +38,30 @@ void SfxLokHelper::destroyView(size_t nId) pViewFrame->Exec_Impl(aRequest); } +void SfxLokHelper::setView(size_t nId) +{ + SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); + if (nId > rViewArr.size() - 1) + return; + + SfxViewShell* pViewShell = rViewArr[nId]; + if (SfxViewFrame* pViewFrame = pViewShell->GetViewFrame()) + pViewFrame->GetWindow().GrabFocus(); +} + +size_t SfxLokHelper::getView() +{ + SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); + SfxViewFrame* pViewFrame = SfxViewFrame::Current(); + for (size_t i = 0; i < rViewArr.size(); ++i) + { + if (rViewArr[i]->GetViewFrame() == pViewFrame) + return i; + } + assert(false); + return 0; +} + int SfxLokHelper::getViews() { SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits