diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-05-10 16:41:54 +0200 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2021-05-18 15:25:17 +0200 |
commit | ad5ebd2bcf6d80d46b59849fb85aa3ee226b52a3 (patch) | |
tree | 38269794a4f112df338d58fbe4b845ce2ae7a0f3 | |
parent | f18b902062c8753a19847f866cd7f51432106e60 (diff) |
tdf#138209 ODF export: work around forms problem in LO < 7.0
LO without commit 519d96fd8b83ef4c61576d87b58f97b7e6e6e3c6 makes a mess
when storing form documents it has loaded from ODF 1.3 documents: the
XML parts are stored as ODF 1.2, but the storage (and therefore manifest
entry) keeps version 1.3.
To avoid this, store form documents as ODF 1.2 extended by default.
Unfortunately a bunch of ODF export code accesses the global
SvtSaveOptions variable; with this version override, only
SvXMLExport::getSaneDefaultVersion() must be used.
Change-Id: I5fa8e286f5103c578ed0d93da07a8a6cbe2f0ddd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115357
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit 16de54a5c47fbc4691ee099c1f7bb559a8fe11ac)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115390
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
24 files changed, 199 insertions, 103 deletions
diff --git a/dbaccess/source/filter/xml/xmlExport.cxx b/dbaccess/source/filter/xml/xmlExport.cxx index 61800a5ab194..7964dbe4e131 100644 --- a/dbaccess/source/filter/xml/xmlExport.cxx +++ b/dbaccess/source/filter/xml/xmlExport.cxx @@ -1076,7 +1076,7 @@ void ODBExport::exportAutoStyle(XPropertySet* _xProp) std::vector< XMLPropertyState > aPropertyStates; for (const auto & i : pExportHelper) { - aPropertyStates = i.first->Filter(_xProp); + aPropertyStates = i.first->Filter(*this, _xProp); if ( !aPropertyStates.empty() ) i.second.first->emplace( _xProp,GetAutoStylePool()->Add( i.second.second, aPropertyStates ) ); } @@ -1090,7 +1090,7 @@ void ODBExport::exportAutoStyle(XPropertySet* _xProp) GetFontAutoStylePool()->Add(aFont.Name,aFont.StyleName,static_cast<FontFamily>(aFont.Family), static_cast<FontPitch>(aFont.Pitch),aFont.CharSet ); - m_aCurrentPropertyStates = m_xCellExportHelper->Filter(_xProp); + m_aCurrentPropertyStates = m_xCellExportHelper->Filter(*this, _xProp); if ( !m_aCurrentPropertyStates.empty() && !xCollection->hasElements() ) { Reference< XDataDescriptorFactory> xFac(xCollection,UNO_QUERY); @@ -1121,7 +1121,7 @@ void ODBExport::exportAutoStyle(XPropertySet* _xProp) }; for (const auto & i : pExportHelper) { - std::vector< XMLPropertyState > aPropStates = i.first->Filter( _xProp ); + std::vector< XMLPropertyState > aPropStates = i.first->Filter(*this, _xProp); if ( !aPropStates.empty() ) { const rtl::Reference < XMLPropertySetMapper >& pStyle = i.first->getPropertySetMapper(); diff --git a/include/xmloff/xmlexppr.hxx b/include/xmloff/xmlexppr.hxx index f2f1e6adf72e..5e47201a5234 100644 --- a/include/xmloff/xmlexppr.hxx +++ b/include/xmloff/xmlexppr.hxx @@ -64,6 +64,7 @@ protected: After this process It'll called 'Contextfilter' for application-specific filter-processes. */ std::vector<XMLPropertyState> Filter_( + SvXMLExport const& rExport, const css::uno::Reference<css::beans::XPropertySet>& rPropSet, bool bDefault, bool bDisableFoFontFamily ) const; @@ -114,6 +115,7 @@ public: After this process It'll called 'Contextfilter' for application-specific filter-processes. */ std::vector<XMLPropertyState> Filter( + SvXMLExport const& rExport, const css::uno::Reference<css::beans::XPropertySet>& rPropSet, bool bEnableFoFontFamily = false ) const; /** Like Filter(), except that: @@ -122,6 +124,7 @@ public: * - instead of the property's value, its default value is exported. */ std::vector<XMLPropertyState> FilterDefaults( + SvXMLExport const& rExport, const css::uno::Reference<css::beans::XPropertySet>& rPropSet ) const; /** Provides a partial ordering over two arrays of XMLPropertyState, diff --git a/include/xmloff/xmluconv.hxx b/include/xmloff/xmluconv.hxx index 647472d2b7b5..b9800b02a805 100644 --- a/include/xmloff/xmluconv.hxx +++ b/include/xmloff/xmluconv.hxx @@ -30,6 +30,8 @@ #include <rtl/ustrbuf.hxx> #include <xmloff/xmltoken.hxx> +#include <unotools/saveopt.hxx> + #include <tools/fldunit.hxx> namespace com::sun::star { @@ -90,7 +92,8 @@ public: SvXMLUnitConverter( const css::uno::Reference< css::uno::XComponentContext >& xContext, sal_Int16 eCoreMeasureUnit /*css::util::MeasureUnit*/, - sal_Int16 eXMLMeasureUnit /*css::util::MeasureUnit*/); + sal_Int16 eXMLMeasureUnit /*css::util::MeasureUnit*/, + SvtSaveOptions::ODFSaneDefaultVersion const nODFVersion); ~SvXMLUnitConverter(); @@ -105,6 +108,10 @@ public: /** gets the default unit for textual measures */ sal_Int16 GetXMLMeasureUnit() const; + /// ODF version, only when exporting + SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const; + void overrideSaneDefaultVersion(SvtSaveOptions::ODFSaneDefaultVersion const); + /** gets XNumberingTypeInfo */ const css::uno::Reference< css::text::XNumberingTypeInfo >& getNumTypeInfo() const; diff --git a/reportdesign/source/filter/xml/xmlExport.cxx b/reportdesign/source/filter/xml/xmlExport.cxx index e81e78375ad0..e6e517b52ed1 100644 --- a/reportdesign/source/filter/xml/xmlExport.cxx +++ b/reportdesign/source/filter/xml/xmlExport.cxx @@ -1112,11 +1112,11 @@ void ORptExport::exportAutoStyle(XPropertySet* _xProp,const Reference<XFormatted const uno::Reference< report::XShape> xShape(_xProp,uno::UNO_QUERY); if ( xShape.is() ) { - ::std::vector< XMLPropertyState > aPropertyStates( m_xParaPropMapper->Filter(_xProp) ); + ::std::vector<XMLPropertyState> aPropertyStates(m_xParaPropMapper->Filter(*this, _xProp)); if ( !aPropertyStates.empty() ) m_aAutoStyleNames.emplace( _xProp,GetAutoStylePool()->Add( XmlStyleFamily::TEXT_PARAGRAPH, aPropertyStates )); } - ::std::vector< XMLPropertyState > aPropertyStates( m_xCellStylesExportPropertySetMapper->Filter(_xProp) ); + ::std::vector<XMLPropertyState> aPropertyStates(m_xCellStylesExportPropertySetMapper->Filter(*this, _xProp)); Reference<XFixedLine> xFixedLine(_xProp,uno::UNO_QUERY); if ( xFixedLine.is() ) { @@ -1178,7 +1178,7 @@ void ORptExport::exportAutoStyle(XPropertySet* _xProp,const Reference<XFormatted xBorderProp->setPropertyValue(it, aEmpty); } - ::std::vector< XMLPropertyState > aBorderStates(m_xCellStylesExportPropertySetMapper->Filter(xBorderProp)); + ::std::vector<XMLPropertyState> aBorderStates(m_xCellStylesExportPropertySetMapper->Filter(*this, xBorderProp)); aPropertyStates.insert( aPropertyStates.end(), aBorderStates.begin(), aBorderStates.end() ); } else @@ -1219,7 +1219,7 @@ void ORptExport::exportAutoStyle(XPropertySet* _xProp,const Reference<XFormatted void ORptExport::exportAutoStyle(const Reference<XSection>& _xProp) { - ::std::vector< XMLPropertyState > aPropertyStates( m_xTableStylesExportPropertySetMapper->Filter(_xProp.get()) ); + ::std::vector<XMLPropertyState> aPropertyStates(m_xTableStylesExportPropertySetMapper->Filter(*this, _xProp.get())); if ( !aPropertyStates.empty() ) m_aAutoStyleNames.emplace( _xProp.get(),GetAutoStylePool()->Add( XmlStyleFamily::TABLE_TABLE, aPropertyStates )); } diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 4fbdb0c1356a..6e6f60d72d6d 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -2001,7 +2001,7 @@ void ScXMLExport::AddStyleFromCells(const uno::Reference<beans::XPropertySet>& x OUString sStyleName; sal_Int32 nNumberFormat(-1); sal_Int32 nValidationIndex(-1); - std::vector< XMLPropertyState > aPropStates(xCellStylesExportPropertySetMapper->Filter( xProperties )); + std::vector<XMLPropertyState> aPropStates(xCellStylesExportPropertySetMapper->Filter(*this, xProperties)); std::vector< XMLPropertyState >::iterator aItr(aPropStates.begin()); std::vector< XMLPropertyState >::iterator aEndItr(aPropStates.end()); sal_Int32 nCount(0); @@ -2135,7 +2135,7 @@ void ScXMLExport::AddStyleFromCells(const uno::Reference<beans::XPropertySet>& x void ScXMLExport::AddStyleFromColumn(const uno::Reference<beans::XPropertySet>& xColumnProperties, const OUString* pOldName, sal_Int32& rIndex, bool& rIsVisible) { - std::vector<XMLPropertyState> aPropStates(xColumnStylesExportPropertySetMapper->Filter(xColumnProperties)); + std::vector<XMLPropertyState> aPropStates(xColumnStylesExportPropertySetMapper->Filter(*this, xColumnProperties)); if(aPropStates.empty()) return; @@ -2172,7 +2172,7 @@ void ScXMLExport::AddStyleFromColumn(const uno::Reference<beans::XPropertySet>& void ScXMLExport::AddStyleFromRow(const uno::Reference<beans::XPropertySet>& xRowProperties, const OUString* pOldName, sal_Int32& rIndex) { - std::vector<XMLPropertyState> aPropStates(xRowStylesExportPropertySetMapper->Filter(xRowProperties)); + std::vector<XMLPropertyState> aPropStates(xRowStylesExportPropertySetMapper->Filter(*this, xRowProperties)); if(aPropStates.empty()) return; @@ -2320,7 +2320,7 @@ void ScXMLExport::collectAutoStyles() uno::Reference<beans::XPropertySet> xTableProperties(xIndex->getByIndex(nTable), uno::UNO_QUERY); if (xTableProperties.is()) { - std::vector<XMLPropertyState> aPropStates(xTableStylesExportPropertySetMapper->Filter(xTableProperties)); + std::vector<XMLPropertyState> aPropStates(xTableStylesExportPropertySetMapper->Filter(*this, xTableProperties)); OUString sName( rTableEntry.maName ); GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TABLE_TABLE, OUString(), aPropStates); GetAutoStylePool()->RegisterName(XmlStyleFamily::TABLE_TABLE, sName); @@ -2354,7 +2354,7 @@ void ScXMLExport::collectAutoStyles() { if ( !rNoteEntry.maStyleName.isEmpty() ) { - std::vector<XMLPropertyState> aPropStates(xShapeMapper->Filter(xShapeProperties)); + std::vector<XMLPropertyState> aPropStates(xShapeMapper->Filter(*this, xShapeProperties)); OUString sName( rNoteEntry.maStyleName ); GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::SD_GRAPHICS_ID, OUString(), aPropStates); GetAutoStylePool()->RegisterName(XmlStyleFamily::SD_GRAPHICS_ID, sName); @@ -2362,7 +2362,7 @@ void ScXMLExport::collectAutoStyles() if ( !rNoteEntry.maTextStyle.isEmpty() ) { std::vector<XMLPropertyState> aPropStates( - GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter(xShapeProperties)); + GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter(*this, xShapeProperties)); OUString sName( rNoteEntry.maTextStyle ); GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TEXT_PARAGRAPH, OUString(), aPropStates); GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_PARAGRAPH, sName); @@ -2394,7 +2394,7 @@ void ScXMLExport::collectAutoStyles() lcl_GetEnumerated( xCellText, rNoteParaEntry.maSelection.nStartPara ), uno::UNO_QUERY ); if ( xParaProp.is() ) { - std::vector<XMLPropertyState> aPropStates(xParaPropMapper->Filter(xParaProp)); + std::vector<XMLPropertyState> aPropStates(xParaPropMapper->Filter(*this, xParaProp)); OUString sName( rNoteParaEntry.maName ); GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TEXT_PARAGRAPH, OUString(), aPropStates); GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_PARAGRAPH, sName); @@ -2427,7 +2427,7 @@ void ScXMLExport::collectAutoStyles() { pCursor->SetSelection( rNoteTextEntry.maSelection ); - std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(xCursorProp)); + std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(*this, xCursorProp)); OUString sName( rNoteTextEntry.maName ); GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TEXT_TEXT, OUString(), aPropStates); GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_TEXT, sName); @@ -2468,7 +2468,7 @@ void ScXMLExport::collectAutoStyles() continue; pCursor->SetSelection( rTextEntry.maSelection ); - std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(xCursorProp)); + std::vector<XMLPropertyState> aPropStates(xTextPropMapper->Filter(*this, xCursorProp)); OUString sName( rTextEntry.maName ); GetAutoStylePool()->AddNamed(sName, XmlStyleFamily::TEXT_TEXT, OUString(), aPropStates); GetAutoStylePool()->RegisterName(XmlStyleFamily::TEXT_TEXT, sName); @@ -2498,7 +2498,7 @@ void ScXMLExport::collectAutoStyles() uno::Reference<beans::XPropertySet> xTableProperties(xTable, uno::UNO_QUERY); if (xTableProperties.is()) { - std::vector<XMLPropertyState> aPropStates(xTableStylesExportPropertySetMapper->Filter(xTableProperties)); + std::vector<XMLPropertyState> aPropStates(xTableStylesExportPropertySetMapper->Filter(*this, xTableProperties)); if(!aPropStates.empty()) { OUString sName; diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 4188ec2a7ef2..29ca6d9a0fed 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -29,6 +29,7 @@ #include <svl/intitem.hxx> #include <com/sun/star/frame/theGlobalEventBroadcaster.hpp> #include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/frame/XModule.hpp> #include <com/sun/star/document/XFilter.hpp> #include <com/sun/star/document/XImporter.hpp> #include <com/sun/star/document/XExporter.hpp> @@ -335,7 +336,11 @@ void SfxObjectShell::SetupStorage( const uno::Reference< embed::XStorage >& xSto try { // older versions can not have this property set, it exists only starting from ODF1.2 - if (SvtSaveOptions::ODFSVER_013 <= nDefVersion) + uno::Reference<frame::XModule> const xModule(GetModel(), uno::UNO_QUERY); + bool const isBaseForm(xModule.is() && + xModule->getIdentifier() == "com.sun.star.sdb.FormDesign"); + SAL_INFO_IF(isBaseForm, "sfx.doc", "tdf#138209 force form export to ODF 1.2"); + if (!isBaseForm && SvtSaveOptions::ODFSVER_013 <= nDefVersion) { xProps->setPropertyValue("Version", uno::makeAny<OUString>(ODFVER_013_TEXT)); } @@ -981,7 +986,11 @@ bool SfxObjectShell::DoSave() { try // tdf#134582 set Version on embedded objects as they { // could have been loaded with a different/old version - if (SvtSaveOptions::ODFSVER_013 <= nDefVersion) + uno::Reference<frame::XModule> const xModule(GetModel(), uno::UNO_QUERY); + bool const isBaseForm(xModule.is() && + xModule->getIdentifier() == "com.sun.star.sdb.FormDesign"); + SAL_INFO_IF(isBaseForm, "sfx.doc", "tdf#138209 force form export to ODF 1.2"); + if (!isBaseForm && SvtSaveOptions::ODFSVER_013 <= nDefVersion) { xProps->setPropertyValue("Version", uno::makeAny<OUString>(ODFVER_013_TEXT)); } diff --git a/sw/source/filter/xml/xmliteme.cxx b/sw/source/filter/xml/xmliteme.cxx index ca590f6ddef6..eb5f74ced41d 100644 --- a/sw/source/filter/xml/xmliteme.cxx +++ b/sw/source/filter/xml/xmliteme.cxx @@ -196,7 +196,8 @@ inline void SwXMLTableItemMapper_Impl::SetAbsWidth( sal_uInt32 nAbs ) void SwXMLExport::InitItemExport() { m_pTwipUnitConverter.reset(new SvXMLUnitConverter(getComponentContext(), - util::MeasureUnit::TWIP, GetMM100UnitConverter().GetXMLMeasureUnit())); + util::MeasureUnit::TWIP, GetMM100UnitConverter().GetXMLMeasureUnit(), + getSaneDefaultVersion())); m_xTableItemMap = new SvXMLItemMapEntries( aXMLTableItemMap ); m_xTableRowItemMap = new SvXMLItemMapEntries( aXMLTableRowItemMap ); diff --git a/sw/source/filter/xml/xmlitemi.cxx b/sw/source/filter/xml/xmlitemi.cxx index 54eed769a945..f58407655681 100644 --- a/sw/source/filter/xml/xmlitemi.cxx +++ b/sw/source/filter/xml/xmlitemi.cxx @@ -227,7 +227,8 @@ void SwXMLImportTableItemMapper_Impl::finished( void SwXMLImport::InitItemImport() { m_pTwipUnitConv.reset( new SvXMLUnitConverter( GetComponentContext(), - util::MeasureUnit::TWIP, util::MeasureUnit::TWIP ) ); + util::MeasureUnit::TWIP, util::MeasureUnit::TWIP, + SvtSaveOptions::ODFSVER_LATEST_EXTENDED) ); m_xTableItemMap = new SvXMLItemMapEntries( aXMLTableItemMap ); m_xTableColItemMap = new SvXMLItemMapEntries( aXMLTableColItemMap ); diff --git a/xmloff/source/chart/PropertyMaps.cxx b/xmloff/source/chart/PropertyMaps.cxx index 6ce23fb54c68..19cfe8cf6765 100644 --- a/xmloff/source/chart/PropertyMaps.cxx +++ b/xmloff/source/chart/PropertyMaps.cxx @@ -436,7 +436,8 @@ void XMLChartExportPropertyMapper::handleSpecialItem( { if( ( nValue & chart::ChartDataCaption::PERCENT ) == chart::ChartDataCaption::PERCENT ) { - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFSaneDefaultVersion() ); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion( + mrExport.getSaneDefaultVersion()); if (nCurrentVersion < SvtSaveOptions::ODFSVER_012) sValueBuffer.append( GetXMLToken( XML_PERCENTAGE )); else @@ -488,7 +489,8 @@ void XMLChartExportPropertyMapper::handleSpecialItem( break; case XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE: { - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFSaneDefaultVersion() ); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion( + mrExport.getSaneDefaultVersion()); OUString aServiceName; rProperty.maValue >>= aServiceName; diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index b33ebb1ac054..0ee68425c6fc 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -282,7 +282,8 @@ public: namespace { -CustomLabelSeq lcl_getCustomLabelField(sal_Int32 nDataPointIndex, +CustomLabelSeq lcl_getCustomLabelField(SvXMLExport const& rExport, + sal_Int32 nDataPointIndex, const uno::Reference< chart2::XDataSeries >& rSeries) { if (!rSeries.is()) @@ -291,7 +292,7 @@ CustomLabelSeq lcl_getCustomLabelField(sal_Int32 nDataPointIndex, // Custom data label text will be written to the <text:p> child element of a // <chart:data-label> element. That exists only since ODF 1.2. const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( - SvtSaveOptions().GetODFSaneDefaultVersion()); + rExport.getSaneDefaultVersion()); if (nCurrentODFVersion < SvtSaveOptions::ODFSVER_012) return CustomLabelSeq(); @@ -307,13 +308,17 @@ CustomLabelSeq lcl_getCustomLabelField(sal_Int32 nDataPointIndex, return CustomLabelSeq(); } -css::chart2::RelativePosition lcl_getCustomLabelPosition(sal_Int32 nDataPointIndex, +css::chart2::RelativePosition lcl_getCustomLabelPosition( + SvXMLExport const& rExport, + sal_Int32 const nDataPointIndex, const uno::Reference< chart2::XDataSeries >& rSeries) { if (!rSeries.is()) return chart2::RelativePosition(); - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( + rExport.getSaneDefaultVersion()); + if ((nCurrentODFVersion & SvtSaveOptions::ODFSVER_EXTENDED) == 0) // do not export to ODF 1.3 or older return chart2::RelativePosition(); @@ -1182,13 +1187,15 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument > { Reference< beans::XPropertySet > xPropSet = rChartDoc->getArea(); if( xPropSet.is()) - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); + aPropertyStates = mxExpPropMapper->Filter(mrExport, xPropSet); } if( bExportContent ) { //export data provider in xlink:href attribute - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( + mrExport.getSaneDefaultVersion()); + if (nCurrentODFVersion >= SvtSaveOptions::ODFSVER_012) { OUString aDataProviderURL( ".." ); @@ -1272,7 +1279,7 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument > { Reference< beans::XPropertySet > xPropSet( rChartDoc->getTitle(), uno::UNO_QUERY ); if( xPropSet.is()) - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); + aPropertyStates = mxExpPropMapper->Filter(mrExport, xPropSet); } if( bExportContent ) { @@ -1312,7 +1319,7 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument > { Reference< beans::XPropertySet > xPropSet( rChartDoc->getSubTitle(), uno::UNO_QUERY ); if( xPropSet.is()) - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); + aPropertyStates = mxExpPropMapper->Filter(mrExport, xPropSet); } if( bExportContent ) @@ -1353,7 +1360,7 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument > { Reference< beans::XPropertySet > xPropSet( rChartDoc->getLegend(), uno::UNO_QUERY ); if( xPropSet.is()) - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); + aPropertyStates = mxExpPropMapper->Filter(mrExport, xPropSet); } if( bExportContent ) @@ -1361,7 +1368,8 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument > Reference< beans::XPropertySet > xProp( rChartDoc->getLegend(), uno::UNO_QUERY ); if( xProp.is()) { - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( + mrExport.getSaneDefaultVersion()); // export legend anchor position try @@ -1864,7 +1872,7 @@ void SchXMLExportHelper_Impl::exportPlotArea( if( xPropSet.is()) { if( mxExpPropMapper.is()) - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); + aPropertyStates = mxExpPropMapper->Filter(mrExport, xPropSet); } if( bExportContent ) { @@ -1983,7 +1991,7 @@ void SchXMLExportHelper_Impl::exportPlotArea( if( xStockPropSet.is()) { aPropertyStates.clear(); - aPropertyStates = mxExpPropMapper->Filter( xStockPropSet ); + aPropertyStates = mxExpPropMapper->Filter(mrExport, xStockPropSet); if( !aPropertyStates.empty() ) { @@ -2005,7 +2013,7 @@ void SchXMLExportHelper_Impl::exportPlotArea( if( xStockPropSet.is()) { aPropertyStates.clear(); - aPropertyStates = mxExpPropMapper->Filter( xStockPropSet ); + aPropertyStates = mxExpPropMapper->Filter(mrExport, xStockPropSet); if( !aPropertyStates.empty() ) { @@ -2027,7 +2035,7 @@ void SchXMLExportHelper_Impl::exportPlotArea( if( xStockPropSet.is()) { aPropertyStates.clear(); - aPropertyStates = mxExpPropMapper->Filter( xStockPropSet ); + aPropertyStates = mxExpPropMapper->Filter(mrExport, xStockPropSet); if( !aPropertyStates.empty() ) { @@ -2058,7 +2066,7 @@ void SchXMLExportHelper_Impl::exportPlotArea( Reference< beans::XPropertySet > xWallPropSet = xWallFloorSupplier->getWall(); if( xWallPropSet.is()) { - aPropertyStates = mxExpPropMapper->Filter( xWallPropSet ); + aPropertyStates = mxExpPropMapper->Filter(mrExport, xWallPropSet); if( !aPropertyStates.empty() ) { @@ -2085,7 +2093,7 @@ void SchXMLExportHelper_Impl::exportPlotArea( if( !xFloorPropSet.is()) return; - aPropertyStates = mxExpPropMapper->Filter( xFloorPropSet ); + aPropertyStates = mxExpPropMapper->Filter(mrExport, xFloorPropSet); if( aPropertyStates.empty() ) return; @@ -2106,7 +2114,8 @@ void SchXMLExportHelper_Impl::exportPlotArea( void SchXMLExportHelper_Impl::exportCoordinateRegion( const uno::Reference< chart::XDiagram >& xDiagram ) { - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( + mrExport.getSaneDefaultVersion()); if (nCurrentODFVersion <= SvtSaveOptions::ODFSVER_012) //do not export to ODF 1.2 or older return; @@ -2177,7 +2186,7 @@ void SchXMLExportHelper_Impl::exportAxisTitle( const Reference< beans::XProperty { if( !rTitleProps.is() ) return; - std::vector< XMLPropertyState > aPropertyStates = mxExpPropMapper->Filter( rTitleProps ); + std::vector<XMLPropertyState> aPropertyStates = mxExpPropMapper->Filter(mrExport, rTitleProps); if( bExportContent ) { OUString aText; @@ -2205,7 +2214,7 @@ void SchXMLExportHelper_Impl::exportGrid( const Reference< beans::XPropertySet > { if( !rGridProperties.is() ) return; - std::vector< XMLPropertyState > aPropertyStates = mxExpPropMapper->Filter( rGridProperties ); + std::vector<XMLPropertyState> aPropertyStates = mxExpPropMapper->Filter(mrExport, rGridProperties); if( bExportContent ) { AddAutoStyleAttribute( aPropertyStates ); @@ -2229,7 +2238,8 @@ bool lcl_exportAxisType( const Reference< chart2::XAxis >& rChart2Axis, SvXMLExp if( !rChart2Axis.is() ) return bExportDateScale; - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( + rExport.getSaneDefaultVersion()); if ((nCurrentODFVersion & SvtSaveOptions::ODFSVER_EXTENDED) == 0) //do not export to ODF 1.3 or older return bExportDateScale; @@ -2302,7 +2312,8 @@ void SchXMLExportHelper_Impl::exportAxis( // get property states for autostyles if( rAxisProps.is() && mxExpPropMapper.is() ) { - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( + mrExport.getSaneDefaultVersion()); if (nCurrentODFVersion & SvtSaveOptions::ODFSVER_EXTENDED && eDimension == XML_X) { @@ -2318,7 +2329,7 @@ void SchXMLExportHelper_Impl::exportAxis( } lcl_exportNumberFormat( "NumberFormat", rAxisProps, mrExport ); - aPropertyStates = mxExpPropMapper->Filter( rAxisProps ); + aPropertyStates = mxExpPropMapper->Filter(mrExport, rAxisProps); if (!maSrcShellID.isEmpty() && !maDestShellID.isEmpty() && maSrcShellID != maDestShellID) { @@ -2727,7 +2738,8 @@ void SchXMLExportHelper_Impl::exportSeries( TOOLS_INFO_EXCEPTION("xmloff.chart", "Required property not found in DataRowProperties" ); } - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( + mrExport.getSaneDefaultVersion()); if (nCurrentODFVersion >= SvtSaveOptions::ODFSVER_012) { lcl_exportNumberFormat( "NumberFormat", xPropSet, mrExport ); @@ -2735,7 +2747,7 @@ void SchXMLExportHelper_Impl::exportSeries( } if( mxExpPropMapper.is()) - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); + aPropertyStates = mxExpPropMapper->Filter(mrExport, xPropSet); } if( bExportContent ) @@ -2760,7 +2772,8 @@ void SchXMLExportHelper_Impl::exportSeries( // #i75297# allow empty series, export empty range to have all ranges on import mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, OUString()); - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( + mrExport.getSaneDefaultVersion()); if (nCurrentODFVersion & SvtSaveOptions::ODFSVER_EXTENDED) // do not export to ODF 1.3 or older { if (xPropSet.is()) @@ -2898,7 +2911,7 @@ void SchXMLExportHelper_Impl::exportSeries( if( xStatProp.is() ) { - aPropertyStates = mxExpPropMapper->Filter( xStatProp ); + aPropertyStates = mxExpPropMapper->Filter(mrExport, xStatProp); if( !aPropertyStates.empty() ) { @@ -2931,7 +2944,8 @@ void SchXMLExportHelper_Impl::exportSeries( uno::Reference< beans::XPropertySet >( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ), nSeriesLength, xNewDiagram, bExportContent ); - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( + mrExport.getSaneDefaultVersion()); // create <chart:data-label> child element if needed. if (xPropSet.is() && mxExpPropMapper.is()) @@ -3042,7 +3056,7 @@ void SchXMLExportHelper_Impl::exportRegressionCurve( OUString aService = xServiceName->getServiceName(); - std::vector< XMLPropertyState > aPropertyStates = mxExpPropMapper->Filter( xProperties ); + std::vector<XMLPropertyState> aPropertyStates = mxExpPropMapper->Filter(mrExport, xProperties); // Add service name (which is regression type) sal_Int32 nIndex = GetPropertySetMapper()->FindEntryIndex(XML_SCH_CONTEXT_SPECIAL_REGRESSION_TYPE); @@ -3057,7 +3071,8 @@ void SchXMLExportHelper_Impl::exportRegressionCurve( xEquationProperties->getPropertyValue( "ShowCorrelationCoefficient") >>= bShowRSquared; bExportEquation = ( bShowEquation || bShowRSquared ); - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion( + mrExport.getSaneDefaultVersion()); if (nCurrentVersion < SvtSaveOptions::ODFSVER_012) { bExportEquation=false; @@ -3071,7 +3086,7 @@ void SchXMLExportHelper_Impl::exportRegressionCurve( { mrExport.addDataStyle( nNumberFormat ); } - aEquationPropertyStates = mxExpPropMapper->Filter( xEquationProperties ); + aEquationPropertyStates = mxExpPropMapper->Filter(mrExport, xEquationProperties); } } @@ -3132,7 +3147,8 @@ void SchXMLExportHelper_Impl::exportErrorBar( const Reference<beans::XPropertySe { assert(mxExpPropMapper.is()); - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion( + mrExport.getSaneDefaultVersion()); /// Don't export X ErrorBars for older ODF versions. if (!bYError && nCurrentVersion < SvtSaveOptions::ODFSVER_012) @@ -3182,7 +3198,7 @@ void SchXMLExportHelper_Impl::exportErrorBar( const Reference<beans::XPropertySe } } - std::vector< XMLPropertyState > aPropertyStates = mxExpPropMapper->Filter( xErrorBarProp ); + std::vector<XMLPropertyState> aPropertyStates = mxExpPropMapper->Filter(mrExport, xErrorBarProp); if( aPropertyStates.empty() ) return; @@ -3347,7 +3363,8 @@ void SchXMLExportHelper_Impl::exportDataPoints( xSeriesProperties->getPropertyValue("AttributedDataPoints") >>= aDataPointSeq; xSeriesProperties->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint; - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( + mrExport.getSaneDefaultVersion()); if (nCurrentODFVersion & SvtSaveOptions::ODFSVER_EXTENDED) // do not export to ODF 1.3 or older xSeriesProperties->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntriesSeq; } @@ -3401,7 +3418,8 @@ void SchXMLExportHelper_Impl::exportDataPoints( SAL_WARN_IF( !xPropSet.is(), "xmloff.chart", "Pie Segments should have properties" ); if( xPropSet.is()) { - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( + mrExport.getSaneDefaultVersion()); if (nCurrentODFVersion >= SvtSaveOptions::ODFSVER_012 && bExportNumFmt) { lcl_exportNumberFormat( "NumberFormat", xPropSet, mrExport ); @@ -3426,7 +3444,7 @@ void SchXMLExportHelper_Impl::exportDataPoints( } } - aPropertyStates = mxExpPropMapper->Filter(xPropSet); + aPropertyStates = mxExpPropMapper->Filter(mrExport, xPropSet); if (!aPropertyStates.empty() || !aDataLabelPropertyStates.empty()) { if (bExportContent) @@ -3448,8 +3466,8 @@ void SchXMLExportHelper_Impl::exportDataPoints( maAutoStyleNameQueue.pop(); } if(bExportNumFmt) - aPoint.mCustomLabelText = lcl_getCustomLabelField(nElement, xSeries); - aPoint.mCustomLabelPos = lcl_getCustomLabelPosition(nElement, xSeries); + aPoint.mCustomLabelText = lcl_getCustomLabelField(mrExport, nElement, xSeries); + aPoint.mCustomLabelPos = lcl_getCustomLabelPosition(mrExport, nElement, xSeries); aDataPointVector.push_back( aPoint ); } @@ -3497,7 +3515,8 @@ void SchXMLExportHelper_Impl::exportDataPoints( } if( xPropSet.is()) { - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( + mrExport.getSaneDefaultVersion()); if (nCurrentODFVersion >= SvtSaveOptions::ODFSVER_012) { lcl_exportNumberFormat( "NumberFormat", xPropSet, mrExport ); @@ -3511,7 +3530,7 @@ void SchXMLExportHelper_Impl::exportDataPoints( mxExpPropMapper); } - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); + aPropertyStates = mxExpPropMapper->Filter(mrExport, xPropSet); if (!aPropertyStates.empty() || !aDataLabelPropertyStates.empty()) { @@ -3526,8 +3545,8 @@ void SchXMLExportHelper_Impl::exportDataPoints( aPoint.maStyleName = maAutoStyleNameQueue.front(); maAutoStyleNameQueue.pop(); } - aPoint.mCustomLabelText = lcl_getCustomLabelField(nCurrIndex, xSeries); - aPoint.mCustomLabelPos = lcl_getCustomLabelPosition(nCurrIndex, xSeries); + aPoint.mCustomLabelText = lcl_getCustomLabelField(mrExport, nCurrIndex, xSeries); + aPoint.mCustomLabelPos = lcl_getCustomLabelPosition(mrExport, nCurrIndex, xSeries); if (!aDataLabelPropertyStates.empty()) { SAL_WARN_IF(maAutoStyleNameQueue.empty(), "xmloff.chart", diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx index 6ac7475a1afd..80f9481ced18 100644 --- a/xmloff/source/chart/SchXMLTools.cxx +++ b/xmloff/source/chart/SchXMLTools.cxx @@ -609,7 +609,8 @@ void exportRangeToSomewhere( SvXMLExport& rExport, const OUString& rValue ) //#i113950# first the range was exported to attribute text:id, but that attribute does not allow arbitrary strings anymore within ODF 1.2 //as an alternative the range info is now saved into the description at an empty group element (not very nice, but ODF conform) - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( + rExport.getSaneDefaultVersion()); if (nCurrentODFVersion == SvtSaveOptions::ODFSVER_010 || nCurrentODFVersion == SvtSaveOptions::ODFSVER_011) return;//svg:desc is not allowed at draw:g in ODF1.0; but as the ranges for error bars are anyhow not allowed within ODF1.0 nor ODF1.1 we do not need the information diff --git a/xmloff/source/chart/XMLErrorBarStylePropertyHdl.cxx b/xmloff/source/chart/XMLErrorBarStylePropertyHdl.cxx index 0a14b506352a..c50450740db3 100644 --- a/xmloff/source/chart/XMLErrorBarStylePropertyHdl.cxx +++ b/xmloff/source/chart/XMLErrorBarStylePropertyHdl.cxx @@ -18,6 +18,8 @@ */ #include "XMLErrorBarStylePropertyHdl.hxx" + +#include <xmloff/xmluconv.hxx> #include <unotools/saveopt.hxx> #include <com/sun/star/chart/ErrorBarStyle.hpp> @@ -35,10 +37,10 @@ XMLErrorBarStylePropertyHdl::~XMLErrorBarStylePropertyHdl() } bool XMLErrorBarStylePropertyHdl::exportXML( OUString& rStrExpValue, - const uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const + const uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter) const { uno::Any aValue(rValue); - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion(rUnitConverter.getSaneDefaultVersion()); if (nCurrentVersion < SvtSaveOptions::ODFSVER_012) { sal_Int32 nValue = 0; diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index a6b22c178729..732ea6a453fb 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -22,6 +22,7 @@ #include <sal/log.hxx> #include <stack> +#include <optional> #include <xmloff/unointerfacetouniqueidentifiermapper.hxx> #include <osl/mutex.hxx> @@ -58,6 +59,7 @@ #include <com/sun/star/document/XEventsSupplier.hpp> #include <com/sun/star/document/XViewDataSupplier.hpp> #include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/frame/XModule.hpp> #include <xmloff/GradientStyle.hxx> #include <xmloff/HatchStyle.hxx> #include <xmloff/ImageStyle.hxx> @@ -260,6 +262,7 @@ public: uno::Reference< embed::XStorage > mxTargetStorage; SvtSaveOptions maSaveOptions; + std::optional<SvtSaveOptions::ODFSaneDefaultVersion> m_oOverrideODFVersion; /// name of stream in package, e.g., "content.xml" OUString mStreamName; @@ -418,6 +421,32 @@ void SvXMLExport::DetermineModelType_() if ( mxModel.is() ) { meModelType = SvtModuleOptions::ClassifyFactoryByModel( mxModel ); + + // note: MATH documents will throw NotInitializedException; maybe unit test problem + if (meModelType == SvtModuleOptions::EFactory::WRITER) + { + uno::Reference<frame::XModule> const xModule(mxModel, uno::UNO_QUERY); + bool const isBaseForm(xModule.is() && + xModule->getIdentifier() == "com.sun.star.sdb.FormDesign"); + if (isBaseForm) + { + switch (mpImpl->maSaveOptions.GetODFSaneDefaultVersion()) + { + case SvtSaveOptions::ODFSVER_013_EXTENDED: + SAL_INFO("xmloff.core", "tdf#138209 force form export to ODF 1.2"); + mpImpl->m_oOverrideODFVersion = SvtSaveOptions::ODFSVER_012_EXTENDED; + maUnitConv.overrideSaneDefaultVersion(SvtSaveOptions::ODFSVER_012_EXTENDED); + break; + case SvtSaveOptions::ODFSVER_013: + SAL_INFO("xmloff.core", "tdf#138209 force form export to ODF 1.2"); + mpImpl->m_oOverrideODFVersion = SvtSaveOptions::ODFSVER_012; + maUnitConv.overrideSaneDefaultVersion(SvtSaveOptions::ODFSVER_012); + break; + default: + break; + } + } + } } } @@ -430,7 +459,7 @@ SvXMLExport::SvXMLExport( m_xContext(xContext), m_implementationName(implementationName), mxAttrList( new SvXMLAttributeList ), mpNamespaceMap( new SvXMLNamespaceMap ), - maUnitConv( xContext, util::MeasureUnit::MM_100TH, eDefaultMeasureUnit ), + maUnitConv(xContext, util::MeasureUnit::MM_100TH, eDefaultMeasureUnit, getSaneDefaultVersion()), meClass( eClass ), mnExportFlags( nExportFlags ), mnErrorFlags( SvXMLErrorFlags::NO ), @@ -455,7 +484,7 @@ SvXMLExport::SvXMLExport( mxAttrList( new SvXMLAttributeList ), msOrigFileName( rFileName ), mpNamespaceMap( new SvXMLNamespaceMap ), - maUnitConv( xContext, util::MeasureUnit::MM_100TH, eDefaultMeasureUnit ), + maUnitConv(xContext, util::MeasureUnit::MM_100TH, eDefaultMeasureUnit, getSaneDefaultVersion()), meClass( XML_TOKEN_INVALID ), mnExportFlags( SvXMLExportFlags::NONE ), mnErrorFlags( SvXMLErrorFlags::NO ), @@ -490,7 +519,8 @@ SvXMLExport::SvXMLExport( mpNamespaceMap( new SvXMLNamespaceMap ), maUnitConv( xContext, util::MeasureUnit::MM_100TH, - SvXMLUnitConverter::GetMeasureUnit(eDefaultFieldUnit) ), + SvXMLUnitConverter::GetMeasureUnit(eDefaultFieldUnit), + getSaneDefaultVersion()), meClass( XML_TOKEN_INVALID ), mnExportFlags( nExportFlag ), mnErrorFlags( SvXMLErrorFlags::NO ), @@ -2296,11 +2326,11 @@ uno::Reference< embed::XStorage > const & SvXMLExport::GetTargetStorage() const SvtSaveOptions::ODFSaneDefaultVersion SvXMLExport::getSaneDefaultVersion() const { - if( mpImpl ) - return mpImpl->maSaveOptions.GetODFSaneDefaultVersion(); - - // fatal error, use current version as default - return SvtSaveOptions::ODFSVER_LATEST; + if (mpImpl->m_oOverrideODFVersion) + { + return *mpImpl->m_oOverrideODFVersion; + } + return mpImpl->maSaveOptions.GetODFSaneDefaultVersion(); } void diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index c66ab63f4479..bc977309b169 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -402,7 +402,8 @@ SvXMLImport::SvXMLImport( mpNamespaceMap( new SvXMLNamespaceMap ), mpUnitConv( new SvXMLUnitConverter( xContext, - util::MeasureUnit::MM_100TH, util::MeasureUnit::MM_100TH) ), + util::MeasureUnit::MM_100TH, util::MeasureUnit::MM_100TH, + SvtSaveOptions::ODFSVER_LATEST_EXTENDED) ), mnImportFlags( nImportFlags ), maNamespaceHandler( new SvXMLImportFastNamespaceHandler() ), diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx index b18972ba29f2..9e74d00e214e 100644 --- a/xmloff/source/core/xmluconv.cxx +++ b/xmloff/source/core/xmluconv.cxx @@ -66,6 +66,7 @@ struct SvXMLUnitConverter::Impl { sal_Int16 m_eCoreMeasureUnit; /*css::util::MeasureUnit*/ sal_Int16 m_eXMLMeasureUnit; /*css::util::MeasureUnit*/ + SvtSaveOptions::ODFSaneDefaultVersion m_eODFVersion; util::Date m_aNullDate; mutable uno::Reference< text::XNumberingTypeInfo > m_xNumTypeInfo; mutable uno::Reference< i18n::XCharacterClassification > m_xCharClass; @@ -73,9 +74,11 @@ struct SvXMLUnitConverter::Impl Impl(uno::Reference<uno::XComponentContext> const& xContext, sal_Int16 const eCoreMeasureUnit, - sal_Int16 const eXMLMeasureUnit) + sal_Int16 const eXMLMeasureUnit, + SvtSaveOptions::ODFSaneDefaultVersion const nODFVersion) : m_eCoreMeasureUnit(eCoreMeasureUnit) , m_eXMLMeasureUnit(eXMLMeasureUnit) + , m_eODFVersion(nODFVersion) , m_aNullDate(30, 12, 1899) , m_xContext(xContext) { @@ -117,6 +120,17 @@ sal_Int16 SvXMLUnitConverter::GetXMLMeasureUnit() const return m_pImpl->m_eXMLMeasureUnit; } +SvtSaveOptions::ODFSaneDefaultVersion SvXMLUnitConverter::getSaneDefaultVersion() const +{ + return m_pImpl->m_eODFVersion; +} + +void SvXMLUnitConverter::overrideSaneDefaultVersion( + SvtSaveOptions::ODFSaneDefaultVersion const nODFVersion) +{ + m_pImpl->m_eODFVersion = nODFVersion; +} + /** constructs a SvXMLUnitConverter. The core measure unit is the default unit for numerical measures, the XML measure unit is the default unit for textual measures @@ -125,8 +139,9 @@ sal_Int16 SvXMLUnitConverter::GetXMLMeasureUnit() const SvXMLUnitConverter::SvXMLUnitConverter( const uno::Reference<uno::XComponentContext>& xContext, sal_Int16 const eCoreMeasureUnit, - sal_Int16 const eXMLMeasureUnit) -: m_pImpl(new Impl(xContext, eCoreMeasureUnit, eXMLMeasureUnit)) + sal_Int16 const eXMLMeasureUnit, + SvtSaveOptions::ODFSaneDefaultVersion const nODFVersion) +: m_pImpl(new Impl(xContext, eCoreMeasureUnit, eXMLMeasureUnit, nODFVersion)) { } diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index f7c4410659ed..4fcfed5bb731 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -1524,7 +1524,7 @@ OUString SdXMLExport::ImpCreatePresPageStyleName( const Reference<XDrawPage>& xD const rtl::Reference< SvXMLExportPropertyMapper > aMapperRef( GetPresPagePropsMapper() ); - std::vector< XMLPropertyState > aPropStates( aMapperRef->Filter( xPropSet ) ); + std::vector<XMLPropertyState> aPropStates(aMapperRef->Filter(*this, xPropSet)); if( !aPropStates.empty() ) { diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index 32cf74b8a799..22e7db685f99 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -391,7 +391,7 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap sal_Int32 nCount = 0; if( !bIsEmptyPresObj || (aShapeInfo.meShapeType != XmlShapeTypePresPageShape) ) { - aPropStates = GetPropertySetMapper()->Filter( xPropSet ); + aPropStates = GetPropertySetMapper()->Filter(mrExport, xPropSet); if (XmlShapeTypeDrawControlShape == aShapeInfo.meShapeType) { @@ -442,7 +442,7 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap // optionally generate auto style for text attributes if( (!bIsEmptyPresObj || (aShapeInfo.meShapeType != XmlShapeTypePresPageShape)) && bObjSupportsText ) { - aPropStates = GetExport().GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter( xPropSet ); + aPropStates = GetExport().GetTextParagraphExport()->GetParagraphPropertyMapper()->Filter(mrExport, xPropSet); // yet more additionally, we need to care for the ParaAdjust property if ( XmlShapeTypeDrawControlShape == aShapeInfo.meShapeType ) diff --git a/xmloff/source/forms/layerexport.cxx b/xmloff/source/forms/layerexport.cxx index d2beff0d3786..fb5567fa5ef5 100644 --- a/xmloff/source/forms/layerexport.cxx +++ b/xmloff/source/forms/layerexport.cxx @@ -569,7 +569,7 @@ namespace xmloff // determine a number style, if needed xColumnPropertiesMeta = xColumnProperties->getPropertySetInfo(); // get the styles of the column - ::std::vector< XMLPropertyState > aPropertyStates = m_xStyleExportMapper->Filter( xColumnProperties ); + ::std::vector<XMLPropertyState> aPropertyStates = m_xStyleExportMapper->Filter(m_rContext, xColumnProperties); // care for the number format, additionally OUString sColumnNumberStyle; diff --git a/xmloff/source/style/XMLPageExport.cxx b/xmloff/source/style/XMLPageExport.cxx index 640e11b7094d..3c3fd16e8413 100644 --- a/xmloff/source/style/XMLPageExport.cxx +++ b/xmloff/source/style/XMLPageExport.cxx @@ -71,7 +71,7 @@ void XMLPageExport::collectPageMasterAutoStyle( SAL_WARN_IF( !xPageMasterPropSetMapper.is(), "xmloff", "page master family/XMLPageMasterPropSetMapper not found" ); if( xPageMasterPropSetMapper.is() ) { - ::std::vector<XMLPropertyState> aPropStates = xPageMasterExportPropMapper->Filter( rPropSet ); + ::std::vector<XMLPropertyState> aPropStates = xPageMasterExportPropMapper->Filter(rExport, rPropSet); if( !aPropStates.empty()) { OUString sParent; @@ -84,7 +84,7 @@ void XMLPageExport::collectPageMasterAutoStyle( } assert(m_xPageMasterDrawingPageExportPropMapper.is()); ::std::vector<XMLPropertyState> const aPropStates( - m_xPageMasterDrawingPageExportPropMapper->Filter(rPropSet)); + m_xPageMasterDrawingPageExportPropMapper->Filter(rExport, rPropSet)); if (!aPropStates.empty()) { OUString sParent; @@ -267,7 +267,7 @@ void XMLPageExport::exportDefaultStyle() GetExport().CheckAttrList(); ::std::vector< XMLPropertyState > aPropStates = - xPageMasterExportPropMapper->FilterDefaults( xPropSet ); + xPageMasterExportPropMapper->FilterDefaults(rExport, xPropSet); bool bExport = false; rtl::Reference < XMLPropertySetMapper > aPropMapper(xPageMasterExportPropMapper->getPropertySetMapper()); diff --git a/xmloff/source/style/chrlohdl.cxx b/xmloff/source/style/chrlohdl.cxx index 2834e519d122..4b6b1aebbf1d 100644 --- a/xmloff/source/style/chrlohdl.cxx +++ b/xmloff/source/style/chrlohdl.cxx @@ -218,7 +218,8 @@ bool XMLCharScriptHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue return true; } -bool XMLCharScriptHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const +bool XMLCharScriptHdl::exportXML(OUString& rStrExpValue, + const uno::Any& rValue, const SvXMLUnitConverter& rUnitConv) const { lang::Locale aLocale; if(!(rValue >>= aLocale)) @@ -233,7 +234,7 @@ bool XMLCharScriptHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue if (!aLanguageTag.hasScript()) return false; - if (SvtSaveOptions().GetODFSaneDefaultVersion() < SvtSaveOptions::ODFSVER_012) + if (rUnitConv.getSaneDefaultVersion() < SvtSaveOptions::ODFSVER_012) return false; OUString aLanguage, aCountry; @@ -346,7 +347,8 @@ bool XMLCharRfcLanguageTagHdl::importXML( const OUString& rStrImpValue, uno::Any return true; } -bool XMLCharRfcLanguageTagHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const +bool XMLCharRfcLanguageTagHdl::exportXML(OUString& rStrExpValue, + const uno::Any& rValue, const SvXMLUnitConverter& rUnitConv) const { lang::Locale aLocale; if(!(rValue >>= aLocale)) @@ -356,7 +358,7 @@ bool XMLCharRfcLanguageTagHdl::exportXML( OUString& rStrExpValue, const uno::Any if (aLocale.Variant.isEmpty()) return false; - if (SvtSaveOptions().GetODFSaneDefaultVersion() < SvtSaveOptions::ODFSVER_012) + if (rUnitConv.getSaneDefaultVersion() < SvtSaveOptions::ODFSVER_012) return false; rStrExpValue = aLocale.Variant; diff --git a/xmloff/source/style/styleexp.cxx b/xmloff/source/style/styleexp.cxx index 734318a0ab13..8b4256a3d043 100644 --- a/xmloff/source/style/styleexp.cxx +++ b/xmloff/source/style/styleexp.cxx @@ -361,7 +361,7 @@ bool XMLStyleExport::exportStyle( // <style:properties> ::std::vector< XMLPropertyState > aPropStates = - rPropMapper->Filter( xPropSet, true ); + rPropMapper->Filter(GetExport(), xPropSet, true); bool const bUseExtensionNamespaceForGraphicProperties( rXMLFamily != "drawing-page" && rXMLFamily != "graphic" && @@ -401,7 +401,7 @@ void XMLStyleExport::exportDefaultStyle( true, true ); // <style:properties> ::std::vector< XMLPropertyState > aPropStates = - rPropMapper->FilterDefaults( xPropSet ); + rPropMapper->FilterDefaults(GetExport(), xPropSet); rPropMapper->exportXML( GetExport(), aPropStates, SvXmlExportFlags::IGN_WS ); } diff --git a/xmloff/source/style/xmlexppr.cxx b/xmloff/source/style/xmlexppr.cxx index 893e0fb36ee4..f252822c6314 100644 --- a/xmloff/source/style/xmlexppr.cxx +++ b/xmloff/source/style/xmlexppr.cxx @@ -520,18 +520,21 @@ void SvXMLExportPropertyMapper::ChainExportMapper( } std::vector<XMLPropertyState> SvXMLExportPropertyMapper::Filter( + SvXMLExport const& rExport, const uno::Reference<beans::XPropertySet>& rPropSet, bool bEnableFoFontFamily ) const { - return Filter_(rPropSet, false, bEnableFoFontFamily); + return Filter_(rExport, rPropSet, false, bEnableFoFontFamily); } std::vector<XMLPropertyState> SvXMLExportPropertyMapper::FilterDefaults( + SvXMLExport const& rExport, const uno::Reference<beans::XPropertySet>& rPropSet ) const { - return Filter_(rPropSet, true, false/*bEnableFoFontFamily*/); + return Filter_(rExport, rPropSet, true, false/*bEnableFoFontFamily*/); } vector<XMLPropertyState> SvXMLExportPropertyMapper::Filter_( + SvXMLExport const& rExport, const Reference<XPropertySet>& xPropSet, bool bDefault, bool bEnableFoFontFamily ) const { vector< XMLPropertyState > aPropStateArray; @@ -553,7 +556,7 @@ vector<XMLPropertyState> SvXMLExportPropertyMapper::Filter_( if( !pFilterInfo ) { assert(SvtSaveOptions().GetODFDefaultVersion() != SvtSaveOptions::ODFVER_UNKNOWN); - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion(SvtSaveOptions().GetODFSaneDefaultVersion()); + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentVersion(rExport.getSaneDefaultVersion()); pFilterInfo = new FilterPropertiesInfo_Impl; for( sal_Int32 i=0; i < nProps; i++ ) { diff --git a/xmloff/source/table/XMLTableExport.cxx b/xmloff/source/table/XMLTableExport.cxx index 194f8e7121a1..65295d41dc3f 100644 --- a/xmloff/source/table/XMLTableExport.cxx +++ b/xmloff/source/table/XMLTableExport.cxx @@ -235,7 +235,7 @@ static bool has_states( const std::vector< XMLPropertyState >& xPropStates ) for( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn ) try { Reference< XPropertySet > xPropSet( xIndexAccessCols->getByIndex(nColumn) , UNO_QUERY_THROW ); - std::vector< XMLPropertyState > aPropStates( mxColumnExportPropertySetMapper->Filter( xPropSet ) ); + std::vector<XMLPropertyState> aPropStates(mxColumnExportPropertySetMapper->Filter(mrExport, xPropSet)); if( has_states( aPropStates ) ) { @@ -259,7 +259,7 @@ static bool has_states( const std::vector< XMLPropertyState >& xPropStates ) try { Reference< XPropertySet > xPropSet( xIndexAccessRows->getByIndex(nRow) , UNO_QUERY_THROW ); - std::vector< XMLPropertyState > aRowPropStates( mxRowExportPropertySetMapper->Filter( xPropSet ) ); + std::vector<XMLPropertyState> aRowPropStates(mxRowExportPropertySetMapper->Filter(mrExport, xPropSet)); if( has_states( aRowPropStates ) ) { @@ -287,7 +287,7 @@ static bool has_states( const std::vector< XMLPropertyState >& xPropStates ) // create auto style, if needed OUString sStyleName; - std::vector< XMLPropertyState > aCellPropStates( mxCellExportPropertySetMapper->Filter( xCellSet ) ); + std::vector<XMLPropertyState> aCellPropStates(mxCellExportPropertySetMapper->Filter(mrExport, xCellSet)); if( has_states( aCellPropStates ) ) sStyleName = mrExport.GetAutoStylePool()->Add(XmlStyleFamily::TABLE_CELL, aCellPropStates); else diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx index d787537e26f0..1b4e15b21e61 100644 --- a/xmloff/source/text/txtparae.cxx +++ b/xmloff/source/text/txtparae.cxx @@ -535,7 +535,7 @@ void XMLTextParagraphExport::Add( XmlStyleFamily nFamily, SAL_WARN_IF( !xPropMapper.is(), "xmloff", "There is the property mapper?" ); vector< XMLPropertyState > aPropStates = - xPropMapper->Filter( rPropSet ); + xPropMapper->Filter(GetExport(), rPropSet); if( ppAddStates ) { @@ -667,7 +667,7 @@ void XMLTextParagraphExport::Add( XmlStyleFamily nFamily, } SAL_WARN_IF( !xPropMapper.is(), "xmloff", "There is the property mapper?" ); - vector< XMLPropertyState > aPropStates(xPropMapper->Filter( rPropSet )); + vector<XMLPropertyState> aPropStates(xPropMapper->Filter(GetExport(), rPropSet)); if( rPropSetHelper.hasProperty( NUMBERING_RULES_AUTO ) ) { @@ -764,7 +764,7 @@ OUString XMLTextParagraphExport::Find( SAL_WARN_IF( !xPropMapper.is(), "xmloff", "There is the property mapper?" ); if( !xPropMapper.is() ) return sName; - vector< XMLPropertyState > aPropStates(xPropMapper->Filter( rPropSet )); + vector<XMLPropertyState> aPropStates(xPropMapper->Filter(GetExport(), rPropSet)); if( ppAddStates ) { while( *ppAddStates ) @@ -787,7 +787,7 @@ OUString XMLTextParagraphExport::FindTextStyleAndHyperlink( const XMLPropertyState** ppAddStates ) const { rtl::Reference < SvXMLExportPropertyMapper > xPropMapper(GetTextPropMapper()); - vector< XMLPropertyState > aPropStates(xPropMapper->Filter( rPropSet )); + vector<XMLPropertyState> aPropStates(xPropMapper->Filter(GetExport(), rPropSet)); // Get parent and remove hyperlinks (they aren't of interest) OUString sName; |