desktop/source/lib/init.cxx | 5 +++ include/vcl/ITiledRenderable.hxx | 10 +++++++ sd/inc/unomodel.hxx | 2 + sd/source/ui/inc/DrawViewShell.hxx | 4 ++ sd/source/ui/inc/ViewShell.hxx | 8 +++++ sd/source/ui/unoidl/unomodel.cxx | 12 ++++++++ sd/source/ui/view/drviews1.cxx | 51 ++++++++++++++++++++++++++++++++++--- sd/source/ui/view/drviews2.cxx | 6 +++- sd/source/ui/view/drviews3.cxx | 7 +++++ sd/source/ui/view/outlnvs2.cxx | 10 +++++-- sd/source/ui/view/viewshe2.cxx | 15 ++++++++++ 11 files changed, 124 insertions(+), 6 deletions(-)
New commits: commit 05ac5c1835cb064b85a2bb9d1093599ef896947c Author: Mohit Marathe <[email protected]> AuthorDate: Wed Nov 12 17:54:26 2025 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Mon Jan 12 19:37:07 2026 +0100 sd: remember last client visible area of canvas page and send that to the client Signed-off-by: Mohit Marathe <[email protected]> Change-Id: Ibd65498c980ebdb93f125904f80e5e78e0b6b172 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193862 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Stahl <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196701 diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx index abac2af1c3c2..dea836dd47c2 100644 --- a/sd/source/ui/inc/DrawViewShell.hxx +++ b/sd/source/ui/inc/DrawViewShell.hxx @@ -392,6 +392,8 @@ public: void destroyXSlideShowInstance(); + virtual void RememberCanvasPageVisArea(const ::tools::Rectangle &aRect) override; + protected: DECL_DLLPRIVATE_LINK( ClipboardChanged, TransferableDataHelper*, void ); DECL_DLLPRIVATE_LINK( TabSplitHdl, TabBar *, void ); @@ -512,6 +514,8 @@ private: std::vector<std::unique_ptr<SdrExternalToolEdit>> m_ExternalEdits; css::uno::Reference<css::presentation::XSlideShow> mxSlideShow; + + ::tools::Rectangle maCanvasPageVisArea; }; /// Merge the background properties together and deposit the result in rMergeAttr diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx index f4fd1f8f7fea..aae2e4d17a15 100644 --- a/sd/source/ui/inc/ViewShell.hxx +++ b/sd/source/ui/inc/ViewShell.hxx @@ -427,6 +427,8 @@ public: */ virtual void onGrabFocus(){}; + virtual void RememberCanvasPageVisArea(const ::tools::Rectangle & /*aRect*/) {}; + /// Allows adjusting the point or mark of the selection to a document coordinate. void SetCursorMm100Position(const Point& rPosition, bool bPoint, bool bClearMark); /// Gets the current selection diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 59f11028bd26..f2a59f83ea2c 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -4480,6 +4480,9 @@ void SdXImpressDocument::setClientVisibleArea(const ::tools::Rectangle& rRectang return; pViewShell->GetViewShellBase().setLOKVisibleArea(rRectangle); + + if (pViewShell->getCurrentPage()->IsCanvasPage()) + pViewShell->RememberCanvasPageVisArea(rRectangle); } void SdXImpressDocument::setClipboard(const uno::Reference<datatransfer::clipboard::XClipboard>& xClipboard) diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx index 66cb427a14e3..8ec1ecce86ea 100644 --- a/sd/source/ui/view/drviews1.cxx +++ b/sd/source/ui/view/drviews1.cxx @@ -1116,6 +1116,23 @@ bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage, bool bAllowChangeFocus, pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aPayload); } } + if (GetDoc()->HasCanvasPage() && getCurrentPage()->IsCanvasPage() && bAllowChangeFocus) + { + ::tools::JsonWriter aJsonWriter; + aJsonWriter.put("commandName", "CanvasPageVisArea"); + { + auto jsonState = aJsonWriter.startNode("state"); + aJsonWriter.put("x", maCanvasPageVisArea.Left()); + aJsonWriter.put("y", maCanvasPageVisArea.Top()); + aJsonWriter.put("width", maCanvasPageVisArea.GetWidth()); + aJsonWriter.put("height", maCanvasPageVisArea.GetHeight()); + } + OString aPayload = aJsonWriter.finishAndGetAsOString(); + if (SfxViewShell* pViewShell = GetViewShell()) + { + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aPayload); + } + } } else { diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx index ae6c27645807..e99fc993a32b 100644 --- a/sd/source/ui/view/drviews3.cxx +++ b/sd/source/ui/view/drviews3.cxx @@ -1136,6 +1136,13 @@ void DrawViewShell::GetSnapItemState( SfxItemSet &rSet ) } } +void DrawViewShell::RememberCanvasPageVisArea(const ::tools::Rectangle &aRect) +{ + if (!GetDoc()->HasCanvasPage()) + return; + maCanvasPageVisArea = aRect; +} + } // end of namespace sd /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit b4dee581619a2d8c9cfc9433f26dc4b858777b6f Author: Mohit Marathe <[email protected]> AuthorDate: Mon Nov 3 16:39:05 2025 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Mon Jan 12 19:36:53 2026 +0100 sd: remember canvas page zoom store zoom for canvas page & non-canvas page, and trigger zoom change when switching between them Signed-off-by: Mohit Marathe <[email protected]> Change-Id: I93310f09af3f2c2bbc87c4561ef5e0fc791d2ec3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193459 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196700 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 15b79c9bdbb9..a7acdc10905b 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -5927,7 +5927,12 @@ static void doc_setViewOption(LibreOfficeKitDocument* pThis, const char* pOption const int nZoom = getUString(pValue).toInt32(); if (nZoom) + { pDoc->setExportZoom(nZoom); + + // Remember the current page zoom in Impress + pDoc->setPageZoom(nZoom); + } } } diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx index f93e831a38ea..9e3f0a71c257 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -293,6 +293,16 @@ public: { } + /** + * Remember the zoom level as a percent for canvas page and + * non-canvas page + * + * @param nZoom - the zoom level as a percent + */ + virtual void setPageZoom(int /*nPageZoom*/) + { + } + /** * Show/Hide a single row/column header outline for Calc documents. * diff --git a/sd/inc/unomodel.hxx b/sd/inc/unomodel.hxx index af6107444c46..39b0e7cbb780 100644 --- a/sd/inc/unomodel.hxx +++ b/sd/inc/unomodel.hxx @@ -274,6 +274,8 @@ public: SD_DLLPUBLIC virtual void resetSelection() override; /// @see vcl::ITiledRenderable::setClientVisibleArea(). virtual void setClientVisibleArea(const tools::Rectangle& rRectangle) override; + /// @see vcl::ITiledRenderable::setPageZoom(). + virtual void setPageZoom(int nPageZoom) override; /// @see vcl::ITiledRenderable::setClipboard(). virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) override; /// @see vcl::ITiledRenderable::isMimeTypeSupported(). diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx index ae0ff4af609f..f4fd1f8f7fea 100644 --- a/sd/source/ui/inc/ViewShell.hxx +++ b/sd/source/ui/inc/ViewShell.hxx @@ -434,6 +434,9 @@ public: /// Allows starting or ending a graphic move or resize action. void SetGraphicMm100Position(bool bStart, const Point& rPosition); + sal_uInt16 GetPageZoom() const; + void RememberPageZoom(const sal_uInt16 nZoom); + class Implementation; protected: @@ -482,6 +485,9 @@ protected: sal_uInt16 mnPrintedHandoutPageNum; // Page number of the handout page that is to be printed. sal_uInt16 mnPrintedHandoutPageCount; // Page count of the handout pages that are to be printed. + sal_uInt16 mnCanvasPageZoom = 0; + sal_uInt16 mnNonCanvasPageZoom = 0; + //af bool bPrintDirectSelected; // Print only selected objects in direct print //afString sPageRange; // pagerange if selected objects in direct print diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 6d602e8b689f..59f11028bd26 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -4462,6 +4462,15 @@ void SdXImpressDocument::resetSelection() pSdrView->UnmarkAll(); } +void SdXImpressDocument::setPageZoom(int nPageZoom) +{ + SolarMutexGuard aGuard; + DrawViewShell* pViewShell = GetViewShell(); + if (!pViewShell) + return; + pViewShell->RememberPageZoom(nPageZoom); +} + void SdXImpressDocument::setClientVisibleArea(const ::tools::Rectangle& rRectangle) { SolarMutexGuard aGuard; diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx index 81f4765272e6..66cb427a14e3 100644 --- a/sd/source/ui/view/drviews1.cxx +++ b/sd/source/ui/view/drviews1.cxx @@ -35,6 +35,7 @@ #include <sfx2/module.hxx> #include <sfx2/notebookbar/SfxNotebookBar.hxx> #include <sfx2/lokhelper.hxx> +#include <sfx2/zoomitem.hxx> #include <svx/svdopage.hxx> #include <svx/fmshell.hxx> #include <tools/debug.hxx> @@ -1038,17 +1039,21 @@ bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage, bool bAllowChangeFocus, SdrPageView* pPV = mpDrawView->GetSdrPageView(); SdPage* pCurrentPage = pPV ? dynamic_cast<SdPage*>(pPV->GetPage()) : nullptr; + bool bChangeZoom = false; + if (pCurrentPage) { Size aCurrentPageSize = pCurrentPage->GetSize(); const ::tools::Long nCurrentWidth = aCurrentPageSize.Width(); const ::tools::Long nCurrentHeight = aCurrentPageSize.Height(); - SdPage* pNewPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind); - Size aNewPageSize = pNewPage->GetSize(); + SdPage* pSelectedPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind); + Size aNewPageSize = pSelectedPage->GetSize(); const ::tools::Long nNewWidth = aNewPageSize.Width(); const ::tools::Long nNewHeight = aNewPageSize.Height(); + bChangeZoom = pCurrentPage->IsCanvasPage() || pSelectedPage->IsCanvasPage(); + if ((nCurrentWidth != nNewWidth || nCurrentHeight != nNewHeight) && bAllowChangeFocus) { Point aPageOrg(nNewWidth, nNewHeight / 2); @@ -1058,7 +1063,7 @@ bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage, bool bAllowChangeFocus, InitWindows(aPageOrg, aViewSize, Point(-1, -1), true); - // pNewPage->SetBackgroundFullSize(true); + // pSelectedPage->SetBackgroundFullSize(true); UpdateScrollBars(); @@ -1099,6 +1104,29 @@ bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage, bool bAllowChangeFocus, mpDrawView->ShowSdrPage(mpActualPage); GetViewShellBase().GetDrawController()->FireSwitchCurrentPage(mpActualPage); + if (comphelper::LibreOfficeKit::isActive()) + { + if (bChangeZoom && bAllowChangeFocus) + { + sal_uInt16 nZoom = GetPageZoom(); + if (nZoom != 0) + { + OString aPayload = ".uno:PageZoomChange="_ostr + OString::number(nZoom); + if (SfxViewShell* pViewShell = GetViewShell()) + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aPayload); + } + } + } + else + { + const sal_uInt16 nZoom = GetPageZoom(); + if (nZoom) + { + const SvxZoomItem aZoomItem(SvxZoomType::PERCENT, nZoom, SID_ATTR_ZOOM); + GetViewFrame()->GetDispatcher()->ExecuteList(SID_ATTR_ZOOM, SfxCallMode::SLOT, {&aZoomItem}); + } + } + SdrPageView* pNewPageView = mpDrawView->GetSdrPageView(); if (pNewPageView) diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 7d5903b786c4..67bdb1c564c4 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -1651,7 +1651,11 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) switch( eZT ) { case SvxZoomType::PERCENT: - SetZoom( static_cast<::tools::Long>( pArgs->Get( SID_ATTR_ZOOM ).GetValue()) ); + { + sal_uInt16 nZoom = pArgs->Get( SID_ATTR_ZOOM ).GetValue(); + SetZoom( static_cast<::tools::Long>( nZoom ) ); + RememberPageZoom(nZoom); + } break; case SvxZoomType::OPTIMAL: diff --git a/sd/source/ui/view/outlnvs2.cxx b/sd/source/ui/view/outlnvs2.cxx index 13861cd3ddc6..6bfa2d9dc179 100644 --- a/sd/source/ui/view/outlnvs2.cxx +++ b/sd/source/ui/view/outlnvs2.cxx @@ -79,14 +79,20 @@ void OutlineViewShell::FuTemporary(SfxRequest &rReq) if ( pArgs ) { - SvxZoomType eZT = pArgs->Get( SID_ATTR_ZOOM ).GetType(); + SvxZoomItem aZoom = pArgs->Get( SID_ATTR_ZOOM ); + SvxZoomType eZT = aZoom.GetType(); switch( eZT ) { case SvxZoomType::PERCENT: + { SetZoom( static_cast<::tools::Long>( pArgs->Get( SID_ATTR_ZOOM ).GetValue()) ); Invalidate( SID_ATTR_ZOOM ); Invalidate( SID_ATTR_ZOOMSLIDER ); - break; + sal_uInt16 nZoom = aZoom.GetValue(); + RememberPageZoom(nZoom); + } + break; + default: break; } diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx index c7403d702f07..b264bb89121a 100644 --- a/sd/source/ui/view/viewshe2.cxx +++ b/sd/source/ui/view/viewshe2.cxx @@ -634,6 +634,21 @@ void ViewShell::SetZoomFactor(const Fraction& rZoomX, const Fraction&) SetZoom(nZoom); } +sal_uInt16 ViewShell::GetPageZoom() const +{ + if (getCurrentPage()->IsCanvasPage()) + return mnCanvasPageZoom; + return mnNonCanvasPageZoom; +} + +void ViewShell::RememberPageZoom(const sal_uInt16 nZoom) +{ + if (getCurrentPage()->IsCanvasPage()) + mnCanvasPageZoom = nZoom; + else + mnNonCanvasPageZoom = nZoom; +} + void ViewShell::SetActiveWindow (::sd::Window* pWin) { SfxViewShell* pViewShell = GetViewShell();
