diff options
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 11 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 16 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.h | 8 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.hxx | 8 | ||||
-rw-r--r-- | include/sfx2/lokhelper.hxx | 12 | ||||
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 21 | ||||
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 68 |
7 files changed, 80 insertions, 64 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index cabeb874cd57..f59370b57dd0 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -294,16 +294,17 @@ void DesktopLOKTest::testCreateView() LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViews(pDocument)); - int nId = pDocument->m_pDocumentClass->createView(pDocument); + std::uintptr_t nId0 = pDocument->m_pDocumentClass->getView(pDocument); + std::uintptr_t nId1 = pDocument->m_pDocumentClass->createView(pDocument); CPPUNIT_ASSERT_EQUAL(2, pDocument->m_pDocumentClass->getViews(pDocument)); // 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)); + CPPUNIT_ASSERT_EQUAL(nId1, pDocument->m_pDocumentClass->getView(pDocument)); + pDocument->m_pDocumentClass->setView(pDocument, nId0); + CPPUNIT_ASSERT_EQUAL(nId0, pDocument->m_pDocumentClass->getView(pDocument)); - pDocument->m_pDocumentClass->destroyView(pDocument, nId); + pDocument->m_pDocumentClass->destroyView(pDocument, nId1); CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViews(pDocument)); } diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 48db0ec73d7a..a03f6644c7ef 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -392,10 +392,10 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis, int nTileTwipWidth, int nTileTwipHeight); static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight); -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 uintptr_t doc_createView(LibreOfficeKitDocument* pThis); +static void doc_destroyView(LibreOfficeKitDocument* pThis, uintptr_t nId); +static void doc_setView(LibreOfficeKitDocument* pThis, uintptr_t nId); +static uintptr_t doc_getView(LibreOfficeKitDocument* pThis); static int doc_getViews(LibreOfficeKitDocument* pThis); static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis, const char *pFontName, @@ -1937,28 +1937,28 @@ static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int pDoc->setClientVisibleArea(aRectangle); } -static int doc_createView(LibreOfficeKitDocument* /*pThis*/) +static uintptr_t doc_createView(LibreOfficeKitDocument* /*pThis*/) { SolarMutexGuard aGuard; return SfxLokHelper::createView(); } -static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, int nId) +static void doc_destroyView(LibreOfficeKitDocument* /*pThis*/, uintptr_t nId) { SolarMutexGuard aGuard; SfxLokHelper::destroyView(nId); } -static void doc_setView(LibreOfficeKitDocument* /*pThis*/, int nId) +static void doc_setView(LibreOfficeKitDocument* /*pThis*/, uintptr_t nId) { SolarMutexGuard aGuard; SfxLokHelper::setView(nId); } -static int doc_getView(LibreOfficeKitDocument* /*pThis*/) +static uintptr_t doc_getView(LibreOfficeKitDocument* /*pThis*/) { SolarMutexGuard aGuard; diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 81d65c1ace38..559d28ae24c7 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -212,13 +212,13 @@ struct _LibreOfficeKitDocumentClass void (*setClientVisibleArea) (LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight); /// @see lok::Document::createView(). - int (*createView) (LibreOfficeKitDocument* pThis); + uintptr_t (*createView) (LibreOfficeKitDocument* pThis); /// @see lok::Document::destroyView(). - void (*destroyView) (LibreOfficeKitDocument* pThis, int nId); + void (*destroyView) (LibreOfficeKitDocument* pThis, uintptr_t nId); /// @see lok::Document::setView(). - void (*setView) (LibreOfficeKitDocument* pThis, int nId); + void (*setView) (LibreOfficeKitDocument* pThis, uintptr_t nId); /// @see lok::Document::getView(). - int (*getView) (LibreOfficeKitDocument* pThis); + uintptr_t (*getView) (LibreOfficeKitDocument* pThis); /// @see lok::Document::getViews(). int (*getViews) (LibreOfficeKitDocument* pThis); diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 36114ab6ff84..aae5f3806a64 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -363,7 +363,7 @@ public: * By default a loaded document has 1 view. * @return the ID of the new view. */ - int createView() + uintptr_t createView() { return mpDoc->pClass->createView(mpDoc); } @@ -372,7 +372,7 @@ public: * Destroy a view of an existing document. * @param nId a view ID, returned by createView(). */ - void destroyView(int nId) + void destroyView(uintptr_t nId) { mpDoc->pClass->destroyView(mpDoc, nId); } @@ -381,7 +381,7 @@ public: * Set an existing view of an existing document as current. * @param nId a view ID, returned by createView(). */ - void setView(int nId) + void setView(uintptr_t nId) { mpDoc->pClass->setView(mpDoc, nId); } @@ -390,7 +390,7 @@ public: * Get the current view. * @return a view ID, previously returned by createView(). */ - int getView() + uintptr_t getView() { return mpDoc->pClass->getView(mpDoc); } diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index 99f2076eeea1..2a691f65759c 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -11,6 +11,8 @@ #define INCLUDED_SFX2_LOKHELPER_HXX #include <sfx2/dllapi.h> +#include <cstddef> +#include <cstdint> class SfxViewShell; @@ -18,15 +20,15 @@ class SFX2_DLLPUBLIC SfxLokHelper { public: /// Create a new view shell from the current view frame. - static int createView(); + static std::uintptr_t createView(); /// Destroy a view shell from the global shell list. - static void destroyView(size_t nId); + static void destroyView(std::uintptr_t nId); /// Set a view shell as current one. - static void setView(size_t nId); + static void setView(std::uintptr_t nId); /// Get the currently active view. - static size_t getView(); + static std::uintptr_t getView(); /// Get the number of views of the current object shell. - static size_t getViews(); + static std::size_t getViews(); }; #endif diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 7989c1321c4b..964b2858c748 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -127,7 +127,7 @@ struct LOKDocViewPrivateImpl ///@} /// View ID, returned by createView() or 0 by default. - int m_nViewId; + std::uintptr_t m_nViewId; /** * Contains a freshly set zoom level: logic size of a tile. @@ -831,6 +831,7 @@ static gboolean postDocumentLoad(gpointer pData) g_info("%s", ss.str().c_str()); priv->m_pDocument->pClass->setView(priv->m_pDocument, priv->m_nViewId); priv->m_pDocument->pClass->initializeForRendering(priv->m_pDocument, priv->m_aRenderingArguments.c_str()); + priv->m_nViewId = priv->m_pDocument->pClass->getView(priv->m_pDocument); priv->m_pDocument->pClass->registerCallback(priv->m_pDocument, callbackWorker, pLOKDocView); priv->m_pDocument->pClass->getDocumentSize(priv->m_pDocument, &priv->m_nDocumentWidthTwips, &priv->m_nDocumentHeightTwips); priv->m_nParts = priv->m_pDocument->pClass->getParts(priv->m_pDocument); @@ -2685,7 +2686,10 @@ SAL_DLLPUBLIC_EXPORT GtkWidget* lok_doc_view_new_from_widget(LOKDocView* pOldLOK // No documentLoad(), just a createView(). LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(LOK_DOC_VIEW(pNewDocView)); LOKDocViewPrivate& pNewPriv = getPrivate(LOK_DOC_VIEW(pNewDocView)); - pNewPriv->m_nViewId = pDocument->pClass->createView(pDocument); + // Store the view id only later in postDocumentLoad(), as + // initializeForRendering() changes the id in Impress. + pDocument->pClass->createView(pDocument); + pNewPriv->m_aRenderingArguments = pOldPriv->m_aRenderingArguments; postDocumentLoad(pNewDocView); return pNewDocView; @@ -2784,12 +2788,12 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom) // set properties to indicate if view can be further zoomed in/out bool bCanZoomIn = priv->m_fZoom < MAX_ZOOM; bool bCanZoomOut = priv->m_fZoom > MIN_ZOOM; - if (bCanZoomIn != priv->m_bCanZoomIn) + if (bCanZoomIn != bool(priv->m_bCanZoomIn)) { priv->m_bCanZoomIn = bCanZoomIn; g_object_notify_by_pspec(G_OBJECT(pDocView), properties[PROP_CAN_ZOOM_IN]); } - if (bCanZoomOut != priv->m_bCanZoomOut) + if (bCanZoomOut != bool(priv->m_bCanZoomOut)) { priv->m_bCanZoomOut = bCanZoomOut; g_object_notify_by_pspec(G_OBJECT(pDocView), properties[PROP_CAN_ZOOM_OUT]); @@ -3041,6 +3045,10 @@ lok_doc_view_copy_selection (LOKDocView* pDocView, LibreOfficeKitDocument* pDocument = lok_doc_view_get_document(pDocView); if (!pDocument) return nullptr; + + std::stringstream ss; + ss << "lok::Document::getTextSelection('" << pMimeType << "')"; + g_info("%s", ss.str().c_str()); return pDocument->pClass->getTextSelection(pDocument, pMimeType, pUsedMimeType); } @@ -3064,7 +3072,12 @@ lok_doc_view_paste (LOKDocView* pDocView, } if (pData) + { + std::stringstream ss; + ss << "lok::Document::paste('" << pMimeType << "', '" << std::string(pData, nSize) << ", "<<nSize<<"')"; + g_info("%s", ss.str().c_str()); ret = pDocument->pClass->paste(pDocument, pMimeType, pData, nSize); + } return ret; } diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index f3731e799ec3..3a306cfbe362 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -10,70 +10,70 @@ #include <sfx2/lokhelper.hxx> #include <sfx2/viewsh.hxx> #include <sfx2/request.hxx> -#include <sfx2/sfxsids.hrc> #include <sfx2/viewfrm.hxx> #include <shellimpl.hxx> -int SfxLokHelper::createView() +std::uintptr_t SfxLokHelper::createView() { SfxViewFrame* pViewFrame = SfxViewFrame::Current(); SfxRequest aRequest(pViewFrame, SID_NEWWINDOW); pViewFrame->ExecView_Impl(aRequest); - // The SfxViewShell ctor always puts the view shell to the end of the vector. - SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); - return rViewArr.size() - 1; + return reinterpret_cast<std::uintptr_t>(SfxViewShell::Current()); } -void SfxLokHelper::destroyView(size_t nId) +void SfxLokHelper::destroyView(std::uintptr_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); + for (std::size_t i = 0; i < rViewArr.size(); ++i) + { + SfxViewShell* pViewShell = rViewArr[i]; + if (reinterpret_cast<std::uintptr_t>(pViewShell) == nId) + { + SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); + SfxRequest aRequest(pViewFrame, SID_CLOSEWIN); + pViewFrame->Exec_Impl(aRequest); + break; + } + } } -void SfxLokHelper::setView(size_t nId) +void SfxLokHelper::setView(std::uintptr_t nId) { SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); - if (nId > rViewArr.size() - 1) - return; - SfxViewShell* pViewShell = rViewArr[nId]; - if (pViewShell->GetViewFrame() == SfxViewFrame::Current()) - return; + for (std::size_t i = 0; i < rViewArr.size(); ++i) + { + SfxViewShell* pViewShell = rViewArr[i]; + if (reinterpret_cast<std::uintptr_t>(pViewShell) == nId) + { + if (pViewShell == SfxViewShell::Current()) + return; + + SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); + pViewFrame->MakeActive_Impl(false); + return; + } + } - if (SfxViewFrame* pViewFrame = pViewShell->GetViewFrame()) - pViewFrame->MakeActive_Impl(false); } -size_t SfxLokHelper::getView() +std::uintptr_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; + return reinterpret_cast<std::uintptr_t>(SfxViewShell::Current()); } -size_t SfxLokHelper::getViews() +std::size_t SfxLokHelper::getViews() { - size_t nRet = 0; + std::size_t nRet = 0; SfxObjectShell* pObjectShell = SfxViewFrame::Current()->GetObjectShell(); SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); - for (size_t i = 0; i < rViewArr.size(); ++i) + for (SfxViewShell* i : rViewArr) { - if (rViewArr[i]->GetObjectShell() == pObjectShell) + if (i->GetObjectShell() == pObjectShell) ++nRet; } |