summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-06-13 11:12:50 -0400
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-06-23 15:02:14 +0000
commit22cd19eeeb476c40b68bb1ff040fce6103fdeba4 (patch)
treec4550dfcfbc10ebb75e3b6130ca44d44a28484ec /xmloff
parenta28256553dcc29d67c530b29727bfbf3ba6aa81a (diff)
fdo#71076, fdo#71767: Preserve number formats when charts are copied.
(cherry picked from commit 1d38cb365543924f9c50014e6b2227e77de1d0c9) Conflicts: sd/source/ui/view/sdview3.cxx xmloff/source/chart/SchXMLExport.cxx Change-Id: If5ae8852152012483237e7602e56a0c46ea8748a Reviewed-on: https://gerrit.libreoffice.org/9836 Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/chart/SchXMLExport.cxx50
-rw-r--r--xmloff/source/core/xmlexp.cxx37
2 files changed, 85 insertions, 2 deletions
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 0c5147feeb9e..d31b1ce8d7d9 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -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,16 @@ 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;
@@ -2273,6 +2286,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(
@@ -2293,6 +2332,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;
@@ -3569,6 +3616,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 5f4d9b9622fe..5379cf4c451b 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() );