diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2022-08-29 09:34:53 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2022-11-19 18:16:16 +0100 |
commit | 931e3d204e59ccb2e9c479477e6e66b2c098924f (patch) | |
tree | e6c71fef4881bb4c4f26a8e25bfa135c85ebcb22 /desktop | |
parent | 553cfbfc9e74a03fe02a58e9aa6076fc1dddeb7b (diff) |
lok: masterpage: Introduce mode property to tile rendering
This is needed for Impress which can have slides in
two Edit Modes: Master Page and Page.
Change-Id: I3eca0f51ba7970e793026d1ac6aa09b19b7a904b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137869
Reviewed-by: Ashod Nakashian <ash@collabora.com>
Tested-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142969
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 5 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 113 |
2 files changed, 88 insertions, 30 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index dd84323f6c9b..e7762753775f 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -2275,7 +2275,7 @@ void DesktopLOKTest::testPaintPartTile() // Call paintPartTile() to paint the second part (in whichever view it finds suitable for this). unsigned char pPixels[256 * 256 * 4]; - pDocument->m_pDocumentClass->paintPartTile(pDocument, pPixels, 1, 256, 256, 0, 0, 256, 256); + pDocument->m_pDocumentClass->paintPartTile(pDocument, pPixels, 1, 0, 256, 256, 0, 0, 256, 256); // Type again. Scheduler::ProcessEventsToIdle(); @@ -3624,10 +3624,11 @@ void DesktopLOKTest::testABI() offsetof(struct _LibreOfficeKitDocumentClass, sendContentControlEvent)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(65), offsetof(struct _LibreOfficeKitDocumentClass, getSelectionTypeAndText)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(66), offsetof(struct _LibreOfficeKitDocumentClass, getDataArea)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(67), offsetof(struct _LibreOfficeKitDocumentClass, getEditMode)); // Extending is fine, update this, and add new assert for the offsetof the // new method - CPPUNIT_ASSERT_EQUAL(documentClassOffset(67), sizeof(struct _LibreOfficeKitDocumentClass)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(68), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 1163ef2a638f..766248ef00ef 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -998,6 +998,7 @@ static void doc_selectPart(LibreOfficeKitDocument* pThis, int nPart, int nSelect static void doc_moveSelectedParts(LibreOfficeKitDocument* pThis, int nPosition, bool bDuplicate); static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart); static void doc_setPartMode(LibreOfficeKitDocument* pThis, int nPartMode); +static int doc_getEditMode(LibreOfficeKitDocument* pThis); static void doc_paintTile(LibreOfficeKitDocument* pThis, unsigned char* pBuffer, const int nCanvasWidth, const int nCanvasHeight, @@ -1013,6 +1014,7 @@ static void doc_paintTileToCGContext(LibreOfficeKitDocument* pThis, static void doc_paintPartTile(LibreOfficeKitDocument* pThis, unsigned char* pBuffer, const int nPart, + const int nMode, const int nCanvasWidth, const int nCanvasHeight, const int nTilePosX, const int nTilePosY, const int nTileWidth, const int nTileHeight); @@ -1269,6 +1271,7 @@ LibLODocument_Impl::LibLODocument_Impl(uno::Reference <css::lang::XComponent> xC m_pDocumentClass->moveSelectedParts = doc_moveSelectedParts; m_pDocumentClass->getPartName = doc_getPartName; m_pDocumentClass->setPartMode = doc_setPartMode; + m_pDocumentClass->getEditMode = doc_getEditMode; m_pDocumentClass->paintTile = doc_paintTile; #ifdef IOS m_pDocumentClass->paintTileToCGContext = doc_paintTileToCGContext; @@ -3641,6 +3644,23 @@ static void doc_setPartMode(LibreOfficeKitDocument* pThis, } } +static int doc_getEditMode(LibreOfficeKitDocument* pThis) +{ + comphelper::ProfileZone aZone("doc_getEditMode"); + + SolarMutexGuard aGuard; + SetLastExceptionMsg(); + + ITiledRenderable* pDoc = getTiledRenderable(pThis); + if (!pDoc) + { + SetLastExceptionMsg("Document doesn't support tiled rendering"); + return 0; + } + + return pDoc->getEditMode(); +} + static void doc_paintTile(LibreOfficeKitDocument* pThis, unsigned char* pBuffer, const int nCanvasWidth, const int nCanvasHeight, @@ -3770,6 +3790,7 @@ static void doc_paintTileToCGContext(LibreOfficeKitDocument* pThis, static void doc_paintPartTile(LibreOfficeKitDocument* pThis, unsigned char* pBuffer, const int nPart, + const int nMode, const int nCanvasWidth, const int nCanvasHeight, const int nTilePosX, const int nTilePosY, const int nTileWidth, const int nTileHeight) @@ -3779,7 +3800,7 @@ static void doc_paintPartTile(LibreOfficeKitDocument* pThis, SolarMutexGuard aGuard; SetLastExceptionMsg(); - SAL_INFO( "lok.tiledrendering", "paintPartTile: painting @ " << nPart << " [" + SAL_INFO( "lok.tiledrendering", "paintPartTile: painting @ " << nPart << " : " << nMode << " [" << nTileWidth << "x" << nTileHeight << "]@(" << nTilePosX << ", " << nTilePosY << ") to [" << nCanvasWidth << "x" << nCanvasHeight << "]px" ); @@ -3787,6 +3808,13 @@ static void doc_paintPartTile(LibreOfficeKitDocument* pThis, LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); int nOrigViewId = doc_getView(pThis); + ITiledRenderable* pDoc = getTiledRenderable(pThis); + if (!pDoc) + { + SetLastExceptionMsg("Document doesn't support tiled rendering"); + return; + } + if (nOrigViewId < 0) { // tile painting always needs a SfxViewShell::Current(), but actually @@ -3819,13 +3847,17 @@ static void doc_paintPartTile(LibreOfficeKitDocument* pThis, int nOrigPart = 0; const int aType = doc_getDocumentType(pThis); const bool isText = (aType == LOK_DOCTYPE_TEXT); + const bool isCalc = (aType == LOK_DOCTYPE_SPREADSHEET); + int nOrigEditMode = 0; + bool bPaintTextEdit = true; int nViewId = nOrigViewId; - int nLastNonEditorView = nViewId; + int nLastNonEditorView = -1; + int nViewMatchingMode = -1; if (!isText) { // Check if just switching to another view is enough, that has // less side-effects. - if (nPart != doc_getPart(pThis)) + if (nPart != doc_getPart(pThis) || nMode != pDoc->getEditMode()) { SfxViewShell* pViewShell = SfxViewShell::GetFirst(); while (pViewShell) @@ -3835,23 +3867,40 @@ static void doc_paintPartTile(LibreOfficeKitDocument* pThis, if (!bIsInEdit) nLastNonEditorView = pViewShell->GetViewShellId().get(); - if (pViewShell->getPart() == nPart && !bIsInEdit) + if (pViewShell->getPart() == nPart && + pViewShell->getEditMode() == nMode && + !bIsInEdit) { nViewId = pViewShell->GetViewShellId().get(); + nViewMatchingMode = nViewId; nLastNonEditorView = nViewId; doc_setView(pThis, nViewId); break; } + else if (pViewShell->getEditMode() == nMode && !bIsInEdit) + { + nViewMatchingMode = pViewShell->GetViewShellId().get(); + } + pViewShell = SfxViewShell::GetNext(*pViewShell); } } - // if not found view with correct part - at least avoid rendering active textbox + // if not found view with correct part + // - at least avoid rendering active textbox, This is for Impress. + // - prefer view with the same mode SfxViewShell* pCurrentViewShell = SfxViewShell::Current(); - if (pCurrentViewShell && pCurrentViewShell->GetDrawView() && + if (nViewMatchingMode >= 0 && nViewMatchingMode != nViewId) + { + nViewId = nViewMatchingMode; + doc_setView(pThis, nViewId); + } + else if (!isCalc && nLastNonEditorView >= 0 && nLastNonEditorView != nViewId && + pCurrentViewShell && pCurrentViewShell->GetDrawView() && pCurrentViewShell->GetDrawView()->GetTextEditOutliner()) { - doc_setView(pThis, nLastNonEditorView); + nViewId = nLastNonEditorView; + doc_setView(pThis, nViewId); } // Disable callbacks while we are painting - after setting the view @@ -3867,36 +3916,44 @@ static void doc_paintPartTile(LibreOfficeKitDocument* pThis, { doc_setPartImpl(pThis, nPart, false); } - } - ITiledRenderable* pDoc = getTiledRenderable(pThis); - if (!pDoc) - { - SetLastExceptionMsg("Document doesn't support tiled rendering"); - return; - } + nOrigEditMode = pDoc->getEditMode(); + if (nOrigEditMode != nMode) + { + SfxLokHelper::setEditMode(nMode, pDoc); + } - bool bPaintTextEdit = nPart == nOrigPart; - pDoc->setPaintTextEdit( bPaintTextEdit ); + bPaintTextEdit = (nPart == nOrigPart && nMode == nOrigEditMode); + pDoc->setPaintTextEdit(bPaintTextEdit); + } doc_paintTile(pThis, pBuffer, nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); - pDoc->setPaintTextEdit( true ); - - if (!isText && nPart != nOrigPart) - { - doc_setPartImpl(pThis, nOrigPart, false); - } - if (!isText && nViewId != nOrigViewId) + if (!isText) { - if (nViewId >= 0) + pDoc->setPaintTextEdit(true); + + if (nMode != nOrigEditMode) { - const auto handlerIt = pDocument->mpCallbackFlushHandlers.find(nViewId); - if (handlerIt != pDocument->mpCallbackFlushHandlers.end()) - handlerIt->second->enableCallbacks(); + SfxLokHelper::setEditMode(nOrigEditMode, pDoc); } - doc_setView(pThis, nOrigViewId); + if (nPart != nOrigPart) + { + doc_setPartImpl(pThis, nOrigPart, false); + } + + if (nViewId != nOrigViewId) + { + if (nViewId >= 0) + { + const auto handlerIt = pDocument->mpCallbackFlushHandlers.find(nViewId); + if (handlerIt != pDocument->mpCallbackFlushHandlers.end()) + handlerIt->second->enableCallbacks(); + } + + doc_setView(pThis, nOrigViewId); + } } } catch (const std::exception&) |