diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-06-13 11:12:50 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-06-19 14:46:56 -0400 |
commit | 1d38cb365543924f9c50014e6b2227e77de1d0c9 (patch) | |
tree | 1e77d0d2f82330f16c09cda60864824397d132c4 /xmloff | |
parent | Use define constant to keep track of all NumberFormat property usage. (diff) | |
download | core-1d38cb365543924f9c50014e6b2227e77de1d0c9.tar.gz core-1d38cb365543924f9c50014e6b2227e77de1d0c9.zip |
fdo#71076, fdo#71767: Preserve number formats when charts are copied.
Change-Id: If5ae8852152012483237e7602e56a0c46ea8748a
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/chart/SchXMLExport.cxx | 56 | ||||
-rw-r--r-- | xmloff/source/core/xmlexp.cxx | 37 |
2 files changed, 90 insertions, 3 deletions
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 5691a5b9ce75..5bda8cc55707 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -154,7 +154,7 @@ public: com::sun::star::chart::XChartDocument > rChartDoc, bool bIncludeTable ); - UniReference< XMLPropertySetMapper > GetPropertySetMapper() const { return mxPropertySetMapper;} + UniReference<XMLPropertySetMapper> GetPropertySetMapper() const; void SetChartRangeAddress( const OUString& rAddress ) { msChartAddress = rAddress; } @@ -269,6 +269,9 @@ public: OUString msCLSID; + OUString maSrcShellID; + OUString maDestShellID; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > mxAdditionalShapes; tDataSequenceCont m_aDataSequencesToExport; @@ -1010,6 +1013,20 @@ const OUString& SchXMLExportHelper::getChartCLSID() return m_pImpl->msCLSID; } +void SchXMLExportHelper::SetSourceShellID( const OUString& rShellID ) +{ + m_pImpl->maSrcShellID = rShellID; +} + +void SchXMLExportHelper::SetDestinationShellID( const OUString& rShellID ) +{ + m_pImpl->maDestShellID = rShellID; +} + +UniReference< XMLPropertySetMapper > SchXMLExportHelper_Impl::GetPropertySetMapper() const +{ + return mxPropertySetMapper; +} void SchXMLExportHelper_Impl::exportAutoStyles() { @@ -2262,6 +2279,32 @@ bool lcl_exportAxisType( const Reference< chart2::XAxis > xChart2Axis, SvXMLExpo return bExportDateScale; } +void disableLinkedNumberFormat( + std::vector<XMLPropertyState>& rPropStates, const UniReference<XMLPropertySetMapper>& rMapper ) +{ + for (size_t i = 0; i < rPropStates.size(); ++i) + { + XMLPropertyState& rState = rPropStates[i]; + if (rState.mnIndex < 0 || rMapper->GetEntryCount() <= rState.mnIndex) + continue; + + OUString aXMLName = rMapper->GetEntryXMLName(rState.mnIndex); + + if (aXMLName != "link-data-style-to-source") + continue; + + // Entry found. Set the value to false and bail out. + rState.maValue <<= false; + return; + } + + // Entry not found. Insert a new entry for this. + sal_Int32 nIndex = rMapper->GetEntryIndex(XML_NAMESPACE_CHART, "link-data-style-to-source", 0); + XMLPropertyState aState(nIndex); + aState.maValue <<= false; + rPropStates.push_back(aState); +} + } void SchXMLExportHelper_Impl::exportAxis( @@ -2282,6 +2325,14 @@ void SchXMLExportHelper_Impl::exportAxis( { lcl_exportNumberFormat( sNumFormat, xAxisProps, mrExport ); aPropertyStates = mxExpPropMapper->Filter( xAxisProps ); + + if (!maSrcShellID.isEmpty() && !maDestShellID.isEmpty() && maSrcShellID != maDestShellID) + { + // Disable link to source number format property when pasting to + // a different doc shell. These shell ID's should be both empty + // during real ODF export. + disableLinkedNumberFormat(aPropertyStates, mxExpPropMapper->getPropertySetMapper()); + } } bool bExportDateScale = false; @@ -3558,6 +3609,9 @@ SchXMLExport::~SchXMLExport() sal_uInt32 SchXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass ) { + maExportHelper.SetSourceShellID(GetSourceShellID()); + maExportHelper.SetDestinationShellID(GetDestinationShellID()); + Reference< chart2::XChartDocument > xChartDoc( GetModel(), uno::UNO_QUERY ); maExportHelper.m_pImpl->InitRangeSegmentationProperties( xChartDoc ); return SvXMLExport::exportDoc( eClass ); diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index 2086d2a7b5b2..5e6571319d18 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -259,6 +259,9 @@ public: /// name of stream in package, e.g., "content.xml" OUString mStreamName; + OUString maSrcShellID; + OUString maDestShellID; + /// stack of backed up namespace maps /// long: depth at which namespace map has been backed up into the stack ::std::stack< ::std::pair< SvXMLNamespaceMap *, long > > mNamespaceMaps; @@ -797,15 +800,16 @@ sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue try { + const sal_Int32 nPropCount = aDescriptor.getLength(); + const sal_uInt32 nTest = EXPORT_META|EXPORT_STYLES|EXPORT_CONTENT|EXPORT_SETTINGS; if( (mnExportFlags & nTest) == nTest && msOrigFileName.isEmpty() ) { // evaluate descriptor only for flat files and if a base URI // has not been provided already - const sal_Int32 nPropCount = aDescriptor.getLength(); - const beans::PropertyValue* pProps = aDescriptor.getConstArray(); + const beans::PropertyValue* pProps = aDescriptor.getConstArray(); for( sal_Int32 nIndex = 0; nIndex < nPropCount; nIndex++, pProps++ ) { const OUString& rPropName = pProps->Name; @@ -824,6 +828,25 @@ sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue } } + const beans::PropertyValue* pProps = aDescriptor.getConstArray(); + for (sal_Int32 nIndex = 0; nIndex < nPropCount; ++nIndex, ++pProps) + { + const OUString& rPropName = pProps->Name; + const Any& rValue = pProps->Value; + + if (rPropName == "SourceShellID") + { + if (!(rValue >>= mpImpl->maSrcShellID)) + return false; + } + else if (rPropName == "DestinationShellID") + { + if (!(rValue >>= mpImpl->maDestShellID)) + return false; + } + } + + exportDoc( meClass ); } catch(const uno::Exception& e) @@ -1510,6 +1533,16 @@ void SvXMLExport::ResetNamespaceMap() delete mpNamespaceMap; mpNamespaceMap = new SvXMLNamespaceMap; } +OUString SvXMLExport::GetSourceShellID() const +{ + return mpImpl->maSrcShellID; +} + +OUString SvXMLExport::GetDestinationShellID() const +{ + return mpImpl->maDestShellID; +} + void SvXMLExport::_ExportMeta() { OUString generator( ::utl::DocInfoHelper::GetGeneratorString() ); |