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-10 02:35:41 +0000
commit1caf633196b43cb81c6f54ed85cf589acbbc89dc (patch)
tree4cca6ea214106cd379b4b2afa7138179aafa9d1c
parent3be163c72925824eeadf5e75f6e0cf6229d8ceab (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 (cherry picked from commit b579c928a8642bc5f455438c1fef01e8df7e195f) Reviewed-on: https://gerrit.libreoffice.org/31812 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins <ci@libreoffice.org>
-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 a3ec5b1b06fc..b1ea373f0433 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 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;