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

New commits:
commit 1caf633196b43cb81c6f54ed85cf589acbbc89dc
Author: Eike Rathke <er...@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
    (cherry picked from commit b579c928a8642bc5f455438c1fef01e8df7e195f)
    Reviewed-on: https://gerrit.libreoffice.org/31812
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins <c...@libreoffice.org>

diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index a3ec5b1..b1ea373 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1839,6 +1839,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;
@@ -1936,14 +1946,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)
     {
@@ -2099,6 +2102,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);
@@ -2268,6 +2273,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;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to