sc/source/filter/excel/xicontent.cxx  |    2 +-
 sc/source/filter/ftools/ftools.cxx    |    9 ++-------
 sc/source/filter/inc/ftools.hxx       |    7 ++++---
 sc/source/filter/oox/stylesbuffer.cxx |    4 ++--
 4 files changed, 9 insertions(+), 13 deletions(-)

New commits:
commit 5cc3d3a4433f538394c4c65b1a80a9ea7e4d7ce6
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu May 9 12:44:13 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu May 9 17:58:53 2024 +0200

    Revert "tdf#160706 speed up loading conditional formatting rule in XLS (3)"
    
    This reverts commit e1268721d4266ed1254da99581a7c2c3dfb72ba6.
    
    caolanm:
    
    With the old "bForceName" of true then previously if the style name existed 
it was renamed to something else and then a fresh style with the requested name 
created. While now we just reuse it.
    
    I'm not very clued in to what calc does, but in writer we might do 
something like this if we are inserting into an existing document and don't 
want to clobber existing styles. Except here we sort of did clobber existing 
styles by renaming them. So I'm unsure of what on earth the original idea was.
    
    So I wonder about a "insert into existing calc document" scenario?
    
    noelg:
    
    Caolan, I was operating under the assumption that this comment here is the 
desired behaviour.
    But now that I read it again, I am not so sure.
    This commit should probably be backed out.
    
    Change-Id: If503efa9fa1a7886eb57bb62d1327f81e4410981
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167318
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/sc/source/filter/excel/xicontent.cxx 
b/sc/source/filter/excel/xicontent.cxx
index 8701b3c69204..a2862f7b6988 100644
--- a/sc/source/filter/excel/xicontent.cxx
+++ b/sc/source/filter/excel/xicontent.cxx
@@ -576,7 +576,7 @@ void XclImpCondFormat::ReadCF( XclImpStream& rStrm )
     // *** create style sheet ***
 
     OUString aStyleName( XclTools::GetCondFormatStyleName( GetCurrScTab(), 
mnFormatIndex, mnCondIndex ) );
-    SfxItemSet& rStyleItemSet = ScfTools::MakeCellStyleSheet( 
GetStyleSheetPool(), aStyleName ).GetItemSet();
+    SfxItemSet& rStyleItemSet = ScfTools::MakeCellStyleSheet( 
GetStyleSheetPool(), aStyleName, true ).GetItemSet();
 
     const XclImpPalette& rPalette = GetPalette();
 
diff --git a/sc/source/filter/ftools/ftools.cxx 
b/sc/source/filter/ftools/ftools.cxx
index 1ce82e5dd1d8..bf2b784a994b 100644
--- a/sc/source/filter/ftools/ftools.cxx
+++ b/sc/source/filter/ftools/ftools.cxx
@@ -254,14 +254,9 @@ ScStyleSheet& lclMakeStyleSheet( ScStyleSheetPool& rPool, 
const OUString& rStyle
 
 } // namespace
 
-ScStyleSheet& ScfTools::MakeCellStyleSheet( ScStyleSheetPool& rPool, const 
OUString& rStyleName )
+ScStyleSheet& ScfTools::MakeCellStyleSheet( ScStyleSheetPool& rPool, const 
OUString& rStyleName, bool bForceName )
 {
-    SfxStyleSheetBase* pOldStyleSheet = rPool.Find( rStyleName, 
SfxStyleFamily::Para );
-    if( pOldStyleSheet )
-        return static_cast< ScStyleSheet& >(*pOldStyleSheet);
-
-    // create new style sheet
-    return static_cast< ScStyleSheet& >( rPool.Make( rStyleName, 
SfxStyleFamily::Para, SfxStyleSearchBits::UserDefined ) );
+    return lclMakeStyleSheet( rPool, rStyleName, SfxStyleFamily::Para, 
bForceName );
 }
 
 ScStyleSheet& ScfTools::MakePageStyleSheet( ScStyleSheetPool& rPool, const 
OUString& rStyleName, bool bForceName )
diff --git a/sc/source/filter/inc/ftools.hxx b/sc/source/filter/inc/ftools.hxx
index 0fdb90cc26ae..7e8a07bce8c8 100644
--- a/sc/source/filter/inc/ftools.hxx
+++ b/sc/source/filter/inc/ftools.hxx
@@ -193,11 +193,12 @@ public:
 // *** style sheet handling *** -----------------------------------------------
 
     /** Creates and returns a cell style sheet and inserts it into the pool.
-        @descr  If the style sheet is already in the pool, return the existing 
style.
-    */
+        @descr  If the style sheet is already in the pool, another unused 
style name is used.
+        @param bForceName  Controls behaviour, if the style already exists:
+        true = Old existing style will be renamed; false = New style gets 
another name. */
     static ScStyleSheet& MakeCellStyleSheet(
                             ScStyleSheetPool& rPool,
-                            const OUString& rStyleName );
+                            const OUString& rStyleName, bool bForceName );
     /** Creates and returns a page style sheet and inserts it into the pool.
         @descr  If the style sheet is already in the pool, another unused 
style name is used.
         @param bForceName  Controls behaviour, if the style already exists:
diff --git a/sc/source/filter/oox/stylesbuffer.cxx 
b/sc/source/filter/oox/stylesbuffer.cxx
index 76245a6980a3..234d0365bdec 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -3005,7 +3005,7 @@ OUString StylesBuffer::createDxfStyle( sal_Int32 nDxfId ) 
const
         // Create a cell style. This may overwrite an existing style if
         // one with the same name exists.
         ScStyleSheet& rStyleSheet = ScfTools::MakeCellStyleSheet(
-                *getScDocument().GetStyleSheetPool(), rStyleName);
+                *getScDocument().GetStyleSheetPool(), rStyleName, true);
 
         rStyleSheet.ResetParent();
         SfxItemSet& rStyleItemSet =
@@ -3033,7 +3033,7 @@ OUString StylesBuffer::createExtDxfStyle( sal_Int32 
nDxfId ) const
         // Create a cell style. This may overwrite an existing style if
         // one with the same name exists.
         ScStyleSheet& rStyleSheet = ScfTools::MakeCellStyleSheet(
-                *getScDocument().GetStyleSheetPool(), rStyleName);
+                *getScDocument().GetStyleSheetPool(), rStyleName, true);
 
         rStyleSheet.ResetParent();
         SfxItemSet& rStyleItemSet =

Reply via email to