From 89804c14ee99721d252e30468342384fbc8926b2 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Sat, 24 Sep 2016 20:41:52 +0200 Subject: implement prototype for more stable calc cell style names This should ensure that as long as the style does not change the cell style name is the same after an import export cycle. Each ScPatternAttr stores a unique ID and we store the ID to name mapping during import. During export if we find a ScPatternAttr that has a key that is also stored in the map we write back the style name from the map. To avoid name collisions we block the style names from the import for the export. The missing piece to make this completely awesome is now to make sure that styles are sorted by name during export. That way we can reduce the diff between import and export even more. Change-Id: Ie4fe2aa00f07efec27ea129e314ac0b6b7e0d8c0 Reviewed-on: https://gerrit.libreoffice.org/29255 Tested-by: Jenkins Reviewed-by: Markus Mohrhard --- xmloff/source/style/impastpl.cxx | 11 ++++++++++- xmloff/source/style/impastpl.hxx | 2 ++ xmloff/source/style/xmlaustp.cxx | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) (limited to 'xmloff') diff --git a/xmloff/source/style/impastpl.cxx b/xmloff/source/style/impastpl.cxx index f35b09862a76..7a4cbce8233f 100644 --- a/xmloff/source/style/impastpl.cxx +++ b/xmloff/source/style/impastpl.cxx @@ -244,7 +244,7 @@ XMLAutoStylePoolProperties::XMLAutoStylePoolProperties( XMLAutoStyleFamily& rFam sBuffer.append( OUString::number( rFamilyData.mnName ) ); msName = sBuffer.makeStringAndClear(); } - while (rFamilyData.maNameSet.find(msName) != rFamilyData.maNameSet.end()); + while (rFamilyData.maNameSet.find(msName) != rFamilyData.maNameSet.end() || rFamilyData.maReservedNameSet.find(msName) != rFamilyData.maReservedNameSet.end()); } #if OSL_DEBUG_LEVEL > 0 @@ -455,6 +455,15 @@ void SvXMLAutoStylePoolP_Impl::RegisterName( sal_Int32 nFamily, const OUString& (*iter)->maNameSet.insert(rName); } +// Adds a name to list +void SvXMLAutoStylePoolP_Impl::RegisterDefinedName( sal_Int32 nFamily, const OUString& rName ) +{ + std::unique_ptr pTemp(new XMLAutoStyleFamily(nFamily)); + auto const iter = m_FamilySet.find(pTemp); + assert(iter != m_FamilySet.end()); // family must be known + (*iter)->maReservedNameSet.insert(rName); +} + // Retrieve the list of registered names diff --git a/xmloff/source/style/impastpl.hxx b/xmloff/source/style/impastpl.hxx index c70c4da4d78f..45ea50995ffc 100644 --- a/xmloff/source/style/impastpl.hxx +++ b/xmloff/source/style/impastpl.hxx @@ -111,6 +111,7 @@ struct XMLAutoStyleFamily ParentSetType m_ParentSet; std::set maNameSet; + std::set maReservedNameSet; sal_uInt32 mnCount; sal_uInt32 mnName; OUString maStrPrefix; @@ -155,6 +156,7 @@ public: void SetFamilyPropSetMapper( sal_Int32 nFamily, const rtl::Reference < SvXMLExportPropertyMapper > & rMapper ); void RegisterName( sal_Int32 nFamily, const OUString& rName ); + void RegisterDefinedName( sal_Int32 nFamily, const OUString& rName ); void GetRegisteredNames( css::uno::Sequence& aFamilies, css::uno::Sequence& aNames ); diff --git a/xmloff/source/style/xmlaustp.cxx b/xmloff/source/style/xmlaustp.cxx index 493d46913733..adb678d2d358 100644 --- a/xmloff/source/style/xmlaustp.cxx +++ b/xmloff/source/style/xmlaustp.cxx @@ -309,6 +309,12 @@ void SvXMLAutoStylePoolP::RegisterName( sal_Int32 nFamily, pImpl->RegisterName( nFamily, rName ); } +void SvXMLAutoStylePoolP::RegisterDefinedName( sal_Int32 nFamily, + const OUString& rName ) +{ + pImpl->RegisterDefinedName( nFamily, rName ); +} + void SvXMLAutoStylePoolP::GetRegisteredNames( uno::Sequence& rFamilies, uno::Sequence& rNames ) -- cgit