sd/source/core/drawdoc2.cxx | 32 ++++++++++------ sd/source/filter/eppt/pptx-epptbase.cxx | 3 + sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx | 32 +++++++--------- sd/source/ui/view/ViewClipboard.cxx | 4 +- 4 files changed, 41 insertions(+), 30 deletions(-)
New commits: commit 29c1aa929d329d2ac587ec2293f3944f9fe3edd2 Author: Mohit Marathe <[email protected]> AuthorDate: Fri Nov 28 17:03:59 2025 +0530 Commit: Mohit Marathe <[email protected]> CommitDate: Tue Jan 13 08:54:13 2026 +0100 sd: make sure canvas page remains as the first page also reverts 7f5c359ab120ec89af04e2f9cbaee387c30662fb Signed-off-by: Mohit Marathe <[email protected]> Change-Id: I61a3b9baa5e592a662e137b56afeaebc0c855c4d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194773 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Stahl <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196707 diff --git a/sd/source/core/drawdoc2.cxx b/sd/source/core/drawdoc2.cxx index e1ceca8573fd..a675aab3cf2a 100644 --- a/sd/source/core/drawdoc2.cxx +++ b/sd/source/core/drawdoc2.cxx @@ -433,6 +433,13 @@ void SdDrawDocument::UpdatePageRelativeURLs(SdPage const * pPage, sal_uInt16 nPo // Move page void SdDrawDocument::MovePage(sal_uInt16 nPgNum, sal_uInt16 nNewPos) { + if (HasCanvasPage()) + { + if (nPgNum == 1) + return; + if (nNewPos == 1) + nNewPos = 3; + } FmFormModel::MovePage(nPgNum, nNewPos); sal_uInt16 nMin = std::min(nPgNum, nNewPos); @@ -1494,10 +1501,8 @@ bool SdDrawDocument::ValidateCanvasPage(const SdPage* pPage) const void SdDrawDocument::ImportCanvasPage() { - sal_uInt16 nStdPageCnt = GetSdPageCount(PageKind::Standard); - - // what if canvas page is not the last page? - SdPage* pPage = GetSdPage(nStdPageCnt - 1, PageKind::Standard); + // what if canvas page is not the first page? + SdPage* pPage = GetSdPage(0, PageKind::Standard); bool bIsCanvasPageValid = ValidateCanvasPage(pPage); pPage->SetCanvasPage(); mpCanvasPage = pPage; @@ -1582,7 +1587,7 @@ void SdDrawDocument::ReshufflePages() { SdPage* pPage = static_cast<SdPage*>(aPageOrder[i]->GetReferencedPage()); sal_uInt16 nCurrentPageNum = pPage->GetPageNum(); - sal_uInt16 nTargetPageNum = 2 * i + 1; + sal_uInt16 nTargetPageNum = 2 * (i + 1) + 1; MovePage(nCurrentPageNum, nTargetPageNum); // Standard page MovePage(nCurrentPageNum + 1, nTargetPageNum + 1); // Notes page } @@ -1597,15 +1602,20 @@ sal_uInt16 SdDrawDocument::GetOrInsertCanvasPage() sal_uInt16 nLastPageNum = GetSdPageCount(PageKind::Standard); SdPage* pLastStandardPage = GetSdPage(nLastPageNum - 1, PageKind::Standard); - sal_uInt16 nCanvasPageNum = CreatePage(pLastStandardPage, PageKind::Standard, + sal_uInt16 nCanvasPageIndex = CreatePage(pLastStandardPage, PageKind::Standard, u"Canvas Page"_ustr, u"Canvas notes page"_ustr, AutoLayout::AUTOLAYOUT_NONE, AutoLayout::AUTOLAYOUT_NONE, false, false, pLastStandardPage->GetPageNum() + 2); - SdPage* pCanvasPage = GetSdPage(nCanvasPageNum, PageKind::Standard); + SdPage* pCanvasPage = GetSdPage(nCanvasPageIndex, PageKind::Standard); if (!pCanvasPage) return 0xffff; + // move the canvas page to the top + sal_uInt16 nCanvasPageNum = 2 * nCanvasPageIndex + 1; + MovePage(nCanvasPageNum, 1); // Canvas page + MovePage(nCanvasPageNum + 1, 2); // Canvas notes page + const Size aCanvasSize(500000, 500000); ResizeCurrentPage(pCanvasPage, aCanvasSize, PageKind::Standard); @@ -1641,9 +1651,9 @@ static int calculateGridColumns(const sal_uInt16 nCnt) void SdDrawDocument::populatePagePreviewsGrid() { - sal_uInt16 nPageCnt = GetSdPageCount(PageKind::Standard) - 1; // don't count the canvas page - sal_uInt16 nTotalCol = static_cast<sal_uInt16>(calculateGridColumns(nPageCnt)); - sal_uInt16 nTotalRow = nPageCnt / nTotalCol + (nPageCnt % nTotalCol ? 1 : 0); + sal_uInt16 nPageCnt = GetSdPageCount(PageKind::Standard); + sal_uInt16 nTotalCol = static_cast<sal_uInt16>(calculateGridColumns(nPageCnt - 1)); + sal_uInt16 nTotalRow = (nPageCnt - 1) / nTotalCol + ((nPageCnt - 1) % nTotalCol ? 1 : 0); // width and height of a standard 16:9 page sal_uInt16 nWidth = 28000; @@ -1679,7 +1689,7 @@ void SdDrawDocument::populatePagePreviewsGrid() ::tools::Long nX = (mpCanvasPage->GetWidth() - nTotalGridWidth) / 2; for (sal_uInt16 nCol = 0; nCol < nTotalCol; nCol++) { - sal_uInt16 nCurrentPageIndex = nTotalCol * nRow + nCol; + sal_uInt16 nCurrentPageIndex = nTotalCol * nRow + nCol + 1; if (nCurrentPageIndex == nPageCnt) return; SdPage* pPage = GetSdPage(nCurrentPageIndex, PageKind::Standard); diff --git a/sd/source/filter/eppt/pptx-epptbase.cxx b/sd/source/filter/eppt/pptx-epptbase.cxx index 44289dec8356..642394419882 100644 --- a/sd/source/filter/eppt/pptx-epptbase.cxx +++ b/sd/source/filter/eppt/pptx-epptbase.cxx @@ -234,9 +234,6 @@ bool PPTWriterBase::InitSOIface() if ( !GetPageByIndex( 0, NORMAL ) ) break; - SdDrawDocument* pDoc = mXModel->GetDoc(); - if (pDoc && pDoc->HasCanvasPage()) - mnPages--; return true; } return false; diff --git a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx index 14cb5f9b88c0..6e18425586c8 100644 --- a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx +++ b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx @@ -760,7 +760,10 @@ void SlideSorterViewShell::ExecMovePageFirst (SfxRequest& /*rReq*/) SyncPageSelectionToDocument(xSelection); // Moves selected pages after page -1 - GetDoc()->MoveSelectedPages( sal_uInt16(-1) ); + if (!GetDoc()->HasCanvasPage()) + GetDoc()->MoveSelectedPages( sal_uInt16(-1) ); + else + GetDoc()->MoveSelectedPages(1); PostMoveSlidesActions(xSelection); } @@ -794,11 +797,18 @@ void SlideSorterViewShell::GetStateMovePageFirst (SfxItemSet& rSet) } if (GetDoc()->HasCanvasPage()) - if (firstSelectedPageNo == GetDoc()->GetSdPageCount(PageKind::Standard) - 1) + { + if (firstSelectedPageNo == 0) + { + rSet.DisableItem( SID_MOVE_PAGE_LAST ); + rSet.DisableItem( SID_MOVE_PAGE_DOWN ); + } + if (firstSelectedPageNo == 1) { rSet.DisableItem( SID_MOVE_PAGE_FIRST ); rSet.DisableItem( SID_MOVE_PAGE_UP ); } + } } void SlideSorterViewShell::ExecMovePageUp (SfxRequest& /*rReq*/) @@ -820,9 +830,8 @@ void SlideSorterViewShell::ExecMovePageUp (SfxRequest& /*rReq*/) if (firstSelectedPageNo == 0) return; - if (GetDoc()->HasCanvasPage()) - if (firstSelectedPageNo == GetDoc()->GetSdPageCount(PageKind::Standard) - 1) + if (firstSelectedPageNo == 1) return; // Move pages before firstSelectedPageNo - 1 (so after firstSelectedPageNo - 2), @@ -855,7 +864,7 @@ void SlideSorterViewShell::ExecMovePageDown (SfxRequest& /*rReq*/) if (lastSelectedPageNo == nNoOfPages - 1) return; if (GetDoc()->HasCanvasPage()) - if (lastSelectedPageNo == nNoOfPages - 2) + if (lastSelectedPageNo == 0) return; // Move to position after lastSelectedPageNo @@ -883,10 +892,7 @@ void SlideSorterViewShell::ExecMovePageLast (SfxRequest& /*rReq*/) sal_uInt16 nNoOfPages = GetDoc()->GetSdPageCount(PageKind::Standard); // Move to position after last page No (=Number of pages - 1) - if (!GetDoc()->HasCanvasPage()) - GetDoc()->MoveSelectedPages( nNoOfPages - 1 ); - else - GetDoc()->MoveSelectedPages( nNoOfPages - 2 ); + GetDoc()->MoveSelectedPages( nNoOfPages - 1 ); PostMoveSlidesActions(xSelection); } @@ -918,14 +924,6 @@ void SlideSorterViewShell::GetStateMovePageLast (SfxItemSet& rSet) rSet.DisableItem( SID_MOVE_PAGE_LAST ); rSet.DisableItem( SID_MOVE_PAGE_DOWN ); } - if (GetDoc()->HasCanvasPage()) - { - if (lastSelectedPageNo == nNoOfPages - 2) - { - rSet.DisableItem( SID_MOVE_PAGE_LAST ); - rSet.DisableItem( SID_MOVE_PAGE_DOWN ); - } - } } void SlideSorterViewShell::PostMoveSlidesActions(const std::shared_ptr<SlideSorterViewShell::PageSelection> &rpSelection) diff --git a/sd/source/ui/view/ViewClipboard.cxx b/sd/source/ui/view/ViewClipboard.cxx index 25d1c572ff84..2c64f883c012 100644 --- a/sd/source/ui/view/ViewClipboard.cxx +++ b/sd/source/ui/view/ViewClipboard.cxx @@ -174,8 +174,8 @@ sal_uInt16 ViewClipboard::DetermineInsertPosition () } if (rDoc.HasCanvasPage()) { - if (nInsertPos == rDoc.GetPageCount()) - nInsertPos = rDoc.GetPageCount() - 2; + if (nInsertPos == 1) + nInsertPos = 3; } return nInsertPos; commit ddfd9549d2dc036836c3b22ddefe6367652aa41d Author: Mohit Marathe <[email protected]> AuthorDate: Tue Nov 25 15:52:53 2025 +0530 Commit: Mohit Marathe <[email protected]> CommitDate: Tue Jan 13 08:54:01 2026 +0100 sd: do not export canvas slide to pptx by decreasing the page count by 1. As the canvas page and its notes page is always at the end, `PPTWriterBase::CreateSlide` and `PPTWriterBase::CreateNotes` won't be called for them. The same cannot be done for the master canvas page as its not necessarily the last master page. Since that master page will be unused, it is safe to export that. Signed-off-by: Mohit Marathe <[email protected]> Change-Id: Ie24f594d45c08a99548363cc1e20cfff977ce519 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194521 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Stahl <[email protected]> Code-Style: Michael Stahl <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196706 diff --git a/sd/source/filter/eppt/pptx-epptbase.cxx b/sd/source/filter/eppt/pptx-epptbase.cxx index b1eb2675b944..44289dec8356 100644 --- a/sd/source/filter/eppt/pptx-epptbase.cxx +++ b/sd/source/filter/eppt/pptx-epptbase.cxx @@ -17,9 +17,12 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <comphelper/servicehelper.hxx> +#include <drawdoc.hxx> #include "epptbase.hxx" #include "epptdef.hxx" #include "../ppt/pptanimations.hxx" +#include <unomodel.hxx> #include <o3tl/any.hxx> #include <vcl/outdev.hxx> @@ -231,6 +234,9 @@ bool PPTWriterBase::InitSOIface() if ( !GetPageByIndex( 0, NORMAL ) ) break; + SdDrawDocument* pDoc = mXModel->GetDoc(); + if (pDoc && pDoc->HasCanvasPage()) + mnPages--; return true; } return false;
