summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-12-09 23:14:47 +0100
committerEike Rathke <erack@redhat.com>2016-12-09 23:51:42 +0100
commitb579c928a8642bc5f455438c1fef01e8df7e195f (patch)
tree0da222b8a726bee9a26e1a17c6d7aac72ef14552
parent681c2c3f59863d1f2d0123a92ee63baf84e18dfc (diff)
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
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx24
-rw-r--r--sc/source/filter/xml/xmlexprt.hxx1
2 files changed, 17 insertions, 8 deletions
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index bd705fb1f174..aba30c22c950 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 33e926cdd338..fb14aa81530d 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;