summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2020-02-21 02:35:55 +0200
committerMichael Stahl <michael.stahl@cib.de>2020-02-27 19:04:33 +0100
commit59ace23c367f83491a37e844d16f7d716eff6346 (patch)
treeaf47d9b808037e3af045678b60b73e47b6f1121f /sc
parent5352d45dd4a04f8f02cf7f6ad4169126d3b3586a (diff)
tdf#101710 Fix invalid style:data-style-name attribute
There were two problems with this attribute: 1. It was written in style:table-cell-properties instead of in style:style. 2. It was referencing a number format id, instead of a style name. Moreover, the data style wasn't even exported as part of office:styles (if at all). Both import and export were affected. For export, it was easily possible to reuse some related stuff from Calc, so that stuff was moved into xmloff and used from there (there are no logic changes for Calc). For import, loading of the invalid attribute was kept for compat reasons. Although it's only useful for automatic number formats, as the data styles weren't exported properly anyway (e.g. see the document attached in bugzilla). Change-Id: I8b70ad205972fada6f3845837d6ed5928d7d6406 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89551 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx27
-rw-r--r--sc/source/filter/xml/xmlstyle.cxx38
-rw-r--r--sc/source/filter/xml/xmlstyle.hxx14
3 files changed, 3 insertions, 76 deletions
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 59e8088d4acf..b626eb3b72f3 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -101,6 +101,7 @@
#include <xmloff/XMLEventExport.hxx>
#include <xmloff/xmlprmap.hxx>
#include <xmloff/ProgressBarHelper.hxx>
+#include <xmloff/table/XMLTableExport.hxx>
#include <sax/tools/converter.hxx>
#include <tools/fldunit.hxx>
@@ -1957,7 +1958,7 @@ void ScXMLExport::ExportStyles_( bool bUsed )
sal_Int32 nShapesCount(0);
CollectSharedData(nTableCount, nShapesCount);
}
- rtl::Reference<ScXMLStyleExport> aStylesExp(new ScXMLStyleExport(*this, GetAutoStylePool().get()));
+ rtl::Reference<XMLCellStyleExport> aStylesExp(new XMLCellStyleExport(*this, GetAutoStylePool().get()));
if (GetModel().is())
{
uno::Reference <lang::XMultiServiceFactory> xMultiServiceFactory(GetModel(), uno::UNO_QUERY);
@@ -1971,29 +1972,7 @@ void ScXMLExport::ExportStyles_( bool bUsed )
GetShapeExport()->ExportGraphicDefaults();
}
}
- uno::Reference <style::XStyleFamiliesSupplier> xStyleFamiliesSupplier (GetModel(), uno::UNO_QUERY);
- if (xStyleFamiliesSupplier.is())
- {
- uno::Reference <container::XNameAccess> xStylesFamilies(xStyleFamiliesSupplier->getStyleFamilies());
- if (xStylesFamilies.is())
- {
- uno::Reference <container::XIndexAccess> xCellStyles(xStylesFamilies->getByName("CellStyles"), uno::UNO_QUERY);
- if (xCellStyles.is())
- {
- sal_Int32 nCount(xCellStyles->getCount());
- for (sal_Int32 i = 0; i < nCount; ++i)
- {
- uno::Reference <beans::XPropertySet> xCellProperties(xCellStyles->getByIndex(i), uno::UNO_QUERY);
- if (xCellProperties.is())
- {
- sal_Int32 nNumberFormat = 0;
- if (xCellProperties->getPropertyValue(SC_UNONAME_NUMFMT) >>= nNumberFormat)
- addDataStyle(nNumberFormat);
- }
- }
- }
- }
- }
+ collectDataStyles(false);
}
exportDataStyles();
diff --git a/sc/source/filter/xml/xmlstyle.cxx b/sc/source/filter/xml/xmlstyle.cxx
index 5283b97f24a7..1dbd6ca451a7 100644
--- a/sc/source/filter/xml/xmlstyle.cxx
+++ b/sc/source/filter/xml/xmlstyle.cxx
@@ -792,44 +792,6 @@ ScXMLAutoStylePoolP::~ScXMLAutoStylePoolP()
{
}
-void ScXMLStyleExport::exportStyleAttributes(
- const css::uno::Reference< css::style::XStyle > & rStyle )
-{
- uno::Reference< beans::XPropertySet > xPropSet( rStyle, uno::UNO_QUERY );
- if (xPropSet.is())
- {
- uno::Reference< beans::XPropertySetInfo > xPropSetInfo(xPropSet->getPropertySetInfo());
- OUString sNumberFormat("NumberFormat");
- if( xPropSetInfo->hasPropertyByName( sNumberFormat ) )
- {
- uno::Reference< beans::XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
- if( xPropState.is() && (beans::PropertyState_DIRECT_VALUE ==
- xPropState->getPropertyState( sNumberFormat )) )
- {
- sal_Int32 nNumberFormat = 0;
- if (xPropSet->getPropertyValue( sNumberFormat ) >>= nNumberFormat)
- GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME,
- GetExport().getDataStyleName(nNumberFormat) );
- }
- }
- }
-}
-
-void ScXMLStyleExport::exportStyleContent( const css::uno::Reference<css::style::XStyle > & /* rStyle */ )
-{
-}
-
-ScXMLStyleExport::ScXMLStyleExport(
- SvXMLExport& rExp,
- SvXMLAutoStylePoolP *pAutoStyleP )
- : XMLStyleExport(rExp, pAutoStyleP)
-{
-}
-
-ScXMLStyleExport::~ScXMLStyleExport()
-{
-}
-
XMLScPropHdlFactory::XMLScPropHdlFactory()
: XMLPropertyHandlerFactory()
{
diff --git a/sc/source/filter/xml/xmlstyle.hxx b/sc/source/filter/xml/xmlstyle.hxx
index 3ddb5e9c215a..bff6767bf51a 100644
--- a/sc/source/filter/xml/xmlstyle.hxx
+++ b/sc/source/filter/xml/xmlstyle.hxx
@@ -24,7 +24,6 @@
#include <xmloff/xmlaustp.hxx>
#include <xmloff/xmltypes.hxx>
#include <xmloff/prhdlfac.hxx>
-#include <xmloff/styleexp.hxx>
#include <xmloff/xmlexppr.hxx>
#include <xmloff/contextid.hxx>
#include <xmloff/xmlprhdl.hxx>
@@ -206,19 +205,6 @@ public:
virtual ~ScXMLAutoStylePoolP() override;
};
-class ScXMLStyleExport : public XMLStyleExport
-{
- virtual void exportStyleAttributes(
- const css::uno::Reference< css::style::XStyle > & rStyle ) override;
- virtual void exportStyleContent(
- const css::uno::Reference< css::style::XStyle > & rStyle ) override;
-public:
- ScXMLStyleExport(
- SvXMLExport& rExp,
- SvXMLAutoStylePoolP *pAutoStyleP );
- virtual ~ScXMLStyleExport() override;
-};
-
class XMLScPropHdlFactory : public XMLPropertyHandlerFactory
{
public: