[Libreoffice-commits] core.git: sc/source

Eike Rathke erack at redhat.com
Fri Dec 9 22:52:16 UTC 2016


 sc/source/filter/xml/xmlexprt.cxx |   24 ++++++++++++++++--------
 sc/source/filter/xml/xmlexprt.hxx |    1 +
 2 files changed, 17 insertions(+), 8 deletions(-)

New commits:
commit b579c928a8642bc5f455438c1fef01e8df7e195f
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Dec 9 23:14:47 2016 +0100

    Resolves: tdf#104097 register reserved cell style names for auto styles
    
    SvXMLAutoStylePoolP_Impl re-starts with a clean
    XMLAutoStyleFamily::maReservedNameSet, so reserving the names in
    ScXMLExport::ExportStyles_() is not enough and needs to be redone in
    ScXMLExport::ExportAutoStyles_()
    
    In the bug scenario that lead to cell styles with duplicated names for
    different styles of which when reloading only the first was taken.
    
    Additionally, a style must be registered after SvXMLAutoStylePoolP::AddNamed()
    to prevent duplicated styles with different names.
    
    Change-Id: If3491eb89ab1741887d9a36ecf904a216fb1368e

diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index bd705fb..aba30c2 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1834,6 +1834,16 @@ const ScXMLEditAttributeMap& ScXMLExport::GetEditAttributeMap() const
     return *mpEditAttrMap;
 }
 
+void ScXMLExport::RegisterDefinedNames( uno::Reference< css::sheet::XSpreadsheetDocument > & xSpreadDoc )
+{
+    ScFormatSaveData* pFormatData = ScModelObj::getImplementation(xSpreadDoc)->GetFormatSaveData();
+    auto xAutoStylePool = GetAutoStylePool();
+    for (const auto& rFormatInfo : pFormatData->maIDToName)
+    {
+        xAutoStylePool->RegisterDefinedName(XML_STYLE_FAMILY_TABLE_CELL, rFormatInfo.second);
+    }
+}
+
 void ScXMLExport::ExportContent_()
 {
     nCurrentTable = 0;
@@ -1931,14 +1941,7 @@ void ScXMLExport::ExportStyles_( bool bUsed )
 {
     Reference <sheet::XSpreadsheetDocument> xSpreadDoc( GetModel(), uno::UNO_QUERY );
     if (xSpreadDoc.is())
-    {
-        ScFormatSaveData* pFormatData = ScModelObj::getImplementation(xSpreadDoc)->GetFormatSaveData();
-        auto aAutoStylePool = GetAutoStylePool();
-        for (const auto& rFormatInfo : pFormatData->maIDToName)
-        {
-            aAutoStylePool->RegisterDefinedName(XML_STYLE_FAMILY_TABLE_CELL, rFormatInfo.second);
-        }
-    }
+        RegisterDefinedNames( xSpreadDoc);
 
     if (!pSharedData)
     {
@@ -2094,6 +2097,8 @@ void ScXMLExport::AddStyleFromCells(const uno::Reference<beans::XPropertySet>& x
                     {
                         sName = itr->second;
                         bAdded = GetAutoStylePool()->AddNamed(sName, XML_STYLE_FAMILY_TABLE_CELL, sStyleName, aPropStates);
+                        if (bAdded)
+                            GetAutoStylePool()->RegisterName(XML_STYLE_FAMILY_TABLE_CELL, sName);
                     }
                 }
                 bool bIsAutoStyle(true);
@@ -2263,6 +2268,9 @@ void ScXMLExport::ExportAutoStyles_()
 
     if (getExportFlags() & SvXMLExportFlags::CONTENT)
     {
+        // Reserve the loaded cell style names.
+        RegisterDefinedNames( xSpreadDoc);
+
         //  re-create automatic styles with old names from stored data
         ScSheetSaveData* pSheetData = ScModelObj::getImplementation(xSpreadDoc)->GetSheetSaveData();
         if (pSheetData && pDoc)
diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx
index 33e926c..fb14aa8 100644
--- a/sc/source/filter/xml/xmlexprt.hxx
+++ b/sc/source/filter/xml/xmlexprt.hxx
@@ -131,6 +131,7 @@ class ScXMLExport : public SvXMLExport
     sal_Int32       GetNumberFormatStyleIndex(sal_Int32 nNumFmt) const;
     void            CollectSharedData(SCTAB& nTableCount, sal_Int32& nShapesCount);
     void            CollectShapesAutoStyles(SCTAB nTableCount);
+    void            RegisterDefinedNames( css::uno::Reference< css::sheet::XSpreadsheetDocument > & xSpreadDoc );
     virtual void ExportFontDecls_() override;
     virtual void ExportStyles_( bool bUsed ) override;
     virtual void ExportAutoStyles_() override;


More information about the Libreoffice-commits mailing list