include/svx/svdpage.hxx         |    2 --
 sd/inc/sdpage.hxx               |    2 +-
 sd/source/core/drawdoc3.cxx     |    7 +++----
 sd/source/core/stlfamily.cxx    |   11 +++++------
 sd/source/ui/unoidl/unopage.cxx |    7 ++++++-
 sd/source/ui/view/drviewsb.cxx  |    3 ++-
 sd/source/ui/view/outlnvsh.cxx  |    2 +-
 svx/source/svdraw/svdpage.cxx   |    5 -----
 8 files changed, 18 insertions(+), 21 deletions(-)

New commits:
commit efaceac76b91cb114c9f87d56872f085143cabab
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu Mar 6 11:21:57 2025 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Mar 6 22:56:37 2025 +0100

    Revert "tdf#165504 restore SdrPage::GetLayoutName virtual"
    
    This reverts commit 5137fcc47f8e40dcba991db1f57dc1b395bbf970.
    
    The commit I bisected in
    https://bugs.documentfoundation.org/show_bug.cgi?id=165504#c3
    was actually the same as tdf#164463 which got fixed in
    960db01dbfe2f916b91782da03532fae1f836445 "Resolves: tdf#164463 we need
    to pass a copy of the LayoutName"
    So this revert is not necessary.
    I'm really sorry for all the inconveniences caused.
    
    Change-Id: Ice96b06220decf8078658b61ca721638cc8d2254
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182578
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index 2eeb30059b31..0ad088889206 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -526,8 +526,6 @@ public:
     const SdrLayerAdmin& GetLayerAdmin() const;
     SdrLayerAdmin& GetLayerAdmin();
 
-    virtual OUString GetLayoutName() const;
-
     /// for snap-to-grid in Writer, also for AlignObjects if 1 object is marked
     /// if pRect != null, then the pages that are intersected by this Rect,
     /// otherwise the visible pages
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index c93121922950..a1121b68b18b 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -252,7 +252,7 @@ public:
                          const ::tools::Rectangle& rOldBoundRect) override;
 
     void             SetLayoutName(const OUString& aName);
-    virtual OUString GetLayoutName() const override       { return 
maLayoutName; }
+    const OUString& GetLayoutName() const { return maLayoutName; }
 
     void            SetFileName(const OUString& aName) { maFileName = aName; }
     const OUString& GetFileName() const       { return maFileName; }
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index 21b3c05ffb34..3e8c088e1067 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -106,10 +106,9 @@ void 
InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc
             // about this
             if( bRenameDuplicates && aTest != SdResId( STR_LAYOUT_DEFAULT_NAME 
) && !(pTestPage->Equals(*pBMMPage)) )
             {
-                pBookmarkDoc->RenameLayoutTemplate(
-                    pBMMPage->GetLayoutName(), pBMMPage->GetName() + "_");
+                OUString aOldPageLayoutName = pBMMPage->GetLayoutName();
+                pBookmarkDoc->RenameLayoutTemplate(aOldPageLayoutName, 
pBMMPage->GetName() + "_");
                 aLayout = pBMMPage->GetName();
-
                 break;
             }
             else
@@ -1390,7 +1389,7 @@ static bool isMasterPageLayoutNameUnique(const 
SdDrawDocument& rDoc, std::u16str
 
     for(sal_uInt16 a(0); a < nPageCount; a++)
     {
-        const SdrPage* pCandidate = rDoc.GetMasterPage(a);
+        const SdPage* pCandidate = static_cast<const 
SdPage*>(rDoc.GetMasterPage(a));
         OUString aPageLayoutName(pCandidate->GetLayoutName());
         sal_Int32 nIndex = aPageLayoutName.indexOf(SD_LT_SEPARATOR);
         if( nIndex != -1 )
diff --git a/sd/source/core/stlfamily.cxx b/sd/source/core/stlfamily.cxx
index 9696668dc326..2262ef1203d2 100644
--- a/sd/source/core/stlfamily.cxx
+++ b/sd/source/core/stlfamily.cxx
@@ -192,12 +192,11 @@ OUString SAL_CALL SdStyleFamily::getName()
         if( pPage == nullptr )
             throw DisposedException();
 
-        OUString aLayoutName( pPage->GetLayoutName() );
-        sal_Int32 nIndex = aLayoutName.indexOf(SD_LT_SEPARATOR);
-        if( nIndex != -1 )
-            aLayoutName = aLayoutName.copy(0, nIndex);
-
-        return aLayoutName;
+        const OUString& rLayoutName = pPage->GetLayoutName();
+        sal_Int32 nIndex = rLayoutName.indexOf(SD_LT_SEPARATOR);
+        if (nIndex != -1)
+            return rLayoutName.copy(0, nIndex);
+        return rLayoutName;
     }
     else
     {
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index 9b8450d085b8..8279858b20df 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -2983,7 +2983,12 @@ void SAL_CALL SdMasterPage::setName( const OUString& 
rName )
     GetPage()->SetName( rName );
 
     if( pDoc )
-        pDoc->RenameLayoutTemplate( GetPage()->GetLayoutName(), rName );
+    {
+        // tdf#164463 we need to pass a copy of the LayoutName here, a
+        // reference means it can get updated to rName during the function.
+        OUString aOldPageLayoutName = GetPage()->GetLayoutName();
+        pDoc->RenameLayoutTemplate(aOldPageLayoutName, rName);
+    }
 
     // fake a mode change to repaint the page tab bar
     ::sd::DrawDocShell* pDocSh = GetModel()->GetDocShell();
diff --git a/sd/source/ui/view/drviewsb.cxx b/sd/source/ui/view/drviewsb.cxx
index b585185c09d0..0f6d46460153 100644
--- a/sd/source/ui/view/drviewsb.cxx
+++ b/sd/source/ui/view/drviewsb.cxx
@@ -83,7 +83,8 @@ bool DrawViewShell::RenameSlide( sal_uInt16 nPageId, const 
OUString & rName  )
     {
         // rename MasterPage -> rename LayoutTemplate
         pPageToRename = GetDoc()->GetMasterSdPage( 
maTabControl->GetPagePos(nPageId), ePageKind );
-        GetDoc()->RenameLayoutTemplate( pPageToRename->GetLayoutName(), rName 
);
+        OUString aOldPageLayoutName = pPageToRename->GetLayoutName();
+        GetDoc()->RenameLayoutTemplate(aOldPageLayoutName, rName);
     }
 
     bool bSuccess = (rName == pPageToRename->GetName());
diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx
index a8131c653f21..87782fc5603d 100644
--- a/sd/source/ui/view/outlnvsh.cxx
+++ b/sd/source/ui/view/outlnvsh.cxx
@@ -1318,7 +1318,7 @@ void OutlineViewShell::GetStatusBarState(SfxItemSet& rSet)
         if( nPos >= GetDoc()->GetSdPageCount( PageKind::Standard ) )
             nPos = 0;
 
-        SdrPage* pPage = GetDoc()->GetSdPage( static_cast<sal_uInt16>(nPos), 
PageKind::Standard );
+        SdPage* pPage = GetDoc()->GetSdPage( static_cast<sal_uInt16>(nPos), 
PageKind::Standard );
 
         if (GetDoc()->GetDocumentType() == DocumentType::Draw)
             aPageStr = SdResId(STR_SD_PAGE_COUNT_DRAW);
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
index 8400b0e2a1c0..3dc8464b6f21 100644
--- a/svx/source/svdraw/svdpage.cxx
+++ b/svx/source/svdraw/svdpage.cxx
@@ -1743,11 +1743,6 @@ SdrLayerAdmin& SdrPage::GetLayerAdmin()
     return *mpLayerAdmin;
 }
 
-OUString SdrPage::GetLayoutName() const
-{
-    return OUString();
-}
-
 void SdrPage::SetInserted( bool bIns )
 {
     if( mbInserted == bIns )

Reply via email to