[Libreoffice-commits] core.git: Branch 'private/kohei/chart-bugs' - 2 commits - chart2/source embeddedobj/source include/xmloff sc/source svtools/source xmloff/source
Kohei Yoshida
kohei.yoshida at collabora.com
Mon Jun 16 16:39:34 PDT 2014
chart2/source/model/filter/XMLFilter.cxx | 5 --
chart2/source/model/inc/XMLFilter.hxx | 3 +
embeddedobj/source/commonembedding/persistence.cxx | 52 ++++++++++++++++-----
embeddedobj/source/inc/commonembobj.hxx | 12 ++--
include/xmloff/SchXMLExportHelper.hxx | 3 +
include/xmloff/xmlexp.hxx | 3 +
sc/source/ui/docshell/externalrefmgr.cxx | 16 ++++--
svtools/source/misc/embedtransfer.cxx | 7 ++
xmloff/source/chart/SchXMLExport.cxx | 50 ++++++++++++++++++++
xmloff/source/core/xmlexp.cxx | 36 +++++++++++++-
10 files changed, 160 insertions(+), 27 deletions(-)
New commits:
commit 1105bb1cf8ba9a24285d8ca46c9cf1e61bb21e30
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Mon Jun 16 19:38:39 2014 -0400
Pass source and destination shell IDs through myriad of abstraction layers.
Change-Id: I92e4507857ca64ff6bff31947f2604a4b7c29119
diff --git a/chart2/source/model/filter/XMLFilter.cxx b/chart2/source/model/filter/XMLFilter.cxx
index bc5f494..a5984ede 100644
--- a/chart2/source/model/filter/XMLFilter.cxx
+++ b/chart2/source/model/filter/XMLFilter.cxx
@@ -541,6 +541,7 @@ sal_Int32 XMLFilter::impl_Export(
const Reference< lang::XComponent > & xDocumentComp,
const Sequence< beans::PropertyValue > & rMediaDescriptor )
{
+ m_aMediaDescriptor = rMediaDescriptor;
//save
sal_Int32 nWarning = 0;
@@ -744,9 +745,7 @@ sal_Int32 XMLFilter::impl_ExportStream(
if ( !xFilter.is() )
return ERRCODE_SFX_GENERAL;
- uno::Sequence < beans::PropertyValue > aMediaDesc(0);
- //@todo? filter properties? ... url? ...
- xFilter->filter( aMediaDesc );
+ xFilter->filter(m_aMediaDescriptor);
}
catch (const uno::Exception& rEx)
{
diff --git a/chart2/source/model/inc/XMLFilter.hxx b/chart2/source/model/inc/XMLFilter.hxx
index ad316d0..4c2c8a1 100644
--- a/chart2/source/model/inc/XMLFilter.hxx
+++ b/chart2/source/model/inc/XMLFilter.hxx
@@ -151,6 +151,9 @@ private:
::com::sun::star::lang::XComponent > m_xTargetDoc;
::com::sun::star::uno::Reference<
::com::sun::star::lang::XComponent > m_xSourceDoc;
+
+ css::uno::Sequence<css::beans::PropertyValue> m_aMediaDescriptor;
+
OUString m_sDocumentHandler; // when set it will be set as doc handler
volatile bool m_bCancelOperation;
diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx
index 4a057f8..cbba532 100644
--- a/embeddedobj/source/commonembedding/persistence.cxx
+++ b/embeddedobj/source/commonembedding/persistence.cxx
@@ -723,12 +723,33 @@ void OCommonEmbeddedObject::SwitchDocToStorage_Impl( const uno::Reference< docum
m_xRecoveryStorage.clear();
}
+namespace {
-void OCommonEmbeddedObject::StoreDocToStorage_Impl( const uno::Reference< embed::XStorage >& xStorage,
- sal_Int32 nStorageFormat,
- const OUString& aBaseURL,
- const OUString& aHierarchName,
- bool bAttachToTheStorage )
+OUString getStringPropertyValue( const uno::Sequence<beans::PropertyValue>& rProps, const OUString& rName )
+{
+ OUString aStr;
+
+ for (sal_Int32 i = 0; i < rProps.getLength(); ++i)
+ {
+ if (rProps[i].Name == rName)
+ {
+ rProps[i].Value >>= aStr;
+ break;
+ }
+ }
+
+ return aStr;
+}
+
+}
+
+void OCommonEmbeddedObject::StoreDocToStorage_Impl(
+ const uno::Reference<embed::XStorage>& xStorage,
+ const uno::Sequence<beans::PropertyValue>& rMediaArgs,
+ const uno::Sequence<beans::PropertyValue>& rObjArgs,
+ sal_Int32 nStorageFormat,
+ const OUString& aHierarchName,
+ bool bAttachToTheStorage )
{
SAL_WARN_IF( !xStorage.is(), "embeddedobj.common", "No storage is provided for storing!" );
@@ -742,6 +763,8 @@ void OCommonEmbeddedObject::StoreDocToStorage_Impl( const uno::Reference< embed:
xDoc = uno::Reference< document::XStorageBasedDocument >( m_pDocHolder->GetComponent(), uno::UNO_QUERY );
}
+ OUString aBaseURL = GetBaseURLFrom_Impl(rMediaArgs, rObjArgs);
+
if ( xDoc.is() )
{
OUString aFilterName = GetFilterName( nStorageFormat );
@@ -750,13 +773,17 @@ void OCommonEmbeddedObject::StoreDocToStorage_Impl( const uno::Reference< embed:
if ( aFilterName.isEmpty() )
throw io::IOException(); // TODO:
- uno::Sequence< beans::PropertyValue > aArgs( 3 );
+ uno::Sequence<beans::PropertyValue> aArgs(5);
aArgs[0].Name = "FilterName";
aArgs[0].Value <<= aFilterName;
- aArgs[2].Name = "DocumentBaseURL";
- aArgs[2].Value <<= aBaseURL;
aArgs[1].Name = "HierarchicalDocumentName";
aArgs[1].Value <<= aHierarchName;
+ aArgs[2].Name = "DocumentBaseURL";
+ aArgs[2].Value <<= aBaseURL;
+ aArgs[3].Name = "SourceShellID";
+ aArgs[3].Value <<= getStringPropertyValue(rObjArgs, "SourceShellID");
+ aArgs[4].Name = "DestinationShellID";
+ aArgs[4].Value <<= getStringPropertyValue(rObjArgs, "DestinationShellID");
xDoc->storeToStorage( xStorage, aArgs );
if ( bAttachToTheStorage )
@@ -1237,7 +1264,8 @@ void SAL_CALL OCommonEmbeddedObject::storeToEntry( const uno::Reference< embed::
aGuard.clear();
// TODO/LATER: support hierarchical name for embedded objects in embedded objects
- StoreDocToStorage_Impl( xSubStorage, nTargetStorageFormat, GetBaseURLFrom_Impl( lArguments, lObjArgs ), sEntName, false );
+ StoreDocToStorage_Impl(
+ xSubStorage, lArguments, lObjArgs, nTargetStorageFormat, sEntName, false );
aGuard.reset();
if ( bSwitchBackToLoaded )
@@ -1374,7 +1402,8 @@ void SAL_CALL OCommonEmbeddedObject::storeAsEntry( const uno::Reference< embed::
{
aGuard.clear();
// TODO/LATER: support hierarchical name for embedded objects in embedded objects
- StoreDocToStorage_Impl( xSubStorage, nTargetStorageFormat, GetBaseURLFrom_Impl( lArguments, lObjArgs ), sEntName, false );
+ StoreDocToStorage_Impl(
+ xSubStorage, lArguments, lObjArgs, nTargetStorageFormat, sEntName, false );
aGuard.reset();
if ( bSwitchBackToLoaded )
@@ -1599,7 +1628,8 @@ void SAL_CALL OCommonEmbeddedObject::storeOwn()
}
aGuard.clear();
- StoreDocToStorage_Impl( m_xObjectStorage, nStorageFormat, GetBaseURL_Impl(), m_aEntryName, true );
+ uno::Sequence<beans::PropertyValue> aEmpty;
+ StoreDocToStorage_Impl( m_xObjectStorage, aEmpty, aEmpty, nStorageFormat, m_aEntryName, true );
aGuard.reset();
}
diff --git a/embeddedobj/source/inc/commonembobj.hxx b/embeddedobj/source/inc/commonembobj.hxx
index 98354f3..ceba61e 100644
--- a/embeddedobj/source/inc/commonembobj.hxx
+++ b/embeddedobj/source/inc/commonembobj.hxx
@@ -195,11 +195,13 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > InitNewDocument_Impl();
- void StoreDocToStorage_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
- sal_Int32 nStorageVersion,
- const OUString& aBaseURL,
- const OUString& aHierarchName,
- bool bAttachToStorage );
+ void StoreDocToStorage_Impl(
+ const css::uno::Reference<css::embed::XStorage>& xStorage,
+ const css::uno::Sequence<css::beans::PropertyValue>& rMediaArgs,
+ const css::uno::Sequence<css::beans::PropertyValue>& rObjArgs,
+ sal_Int32 nStorageVersion,
+ const OUString& aHierarchName,
+ bool bAttachToStorage );
void SwitchDocToStorage_Impl(
const ::com::sun::star::uno::Reference< ::com::sun::star::document::XStorageBasedDocument >& xDoc,
diff --git a/include/xmloff/SchXMLExportHelper.hxx b/include/xmloff/SchXMLExportHelper.hxx
index d46663f..af866be 100644
--- a/include/xmloff/SchXMLExportHelper.hxx
+++ b/include/xmloff/SchXMLExportHelper.hxx
@@ -52,6 +52,9 @@ public:
/// returns the string corresponding to the current FileFormat CLSID for Chart
const OUString& getChartCLSID();
+ void SetSourceShellID( const OUString& rShellID );
+ void SetDestinationShellID( const OUString& rShellID );
+
private:
SchXMLExportHelper(); // not defined
SchXMLExportHelper(SchXMLExportHelper &); // not defined
diff --git a/include/xmloff/xmlexp.hxx b/include/xmloff/xmlexp.hxx
index b45ed39..989eba3 100644
--- a/include/xmloff/xmlexp.hxx
+++ b/include/xmloff/xmlexp.hxx
@@ -210,6 +210,9 @@ protected:
// This method must be overloaded to export the content of <office:body>.
virtual void _ExportContent() = 0;
+ OUString GetSourceShellID() const;
+ OUString GetDestinationShellID() const;
+
void SetExtended( bool bSet=true ) { mbExtended = bSet; }
// save linked sections? (may be false in global documents)
diff --git a/svtools/source/misc/embedtransfer.cxx b/svtools/source/misc/embedtransfer.cxx
index 4341c85..7792f84 100644
--- a/svtools/source/misc/embedtransfer.cxx
+++ b/svtools/source/misc/embedtransfer.cxx
@@ -113,7 +113,12 @@ bool SvEmbedTransferHelper::GetData( const css::datatransfer::DataFlavor& rFlavo
SvStream* pStream = NULL;
bool bDeleteStream = false;
uno::Sequence < beans::PropertyValue > aEmpty;
- xPers->storeToEntry( xStg, aName, aEmpty, aEmpty );
+ uno::Sequence<beans::PropertyValue> aObjArgs(2);
+ aObjArgs[0].Name = "SourceShellID";
+ aObjArgs[0].Value <<= maParentShellID;
+ aObjArgs[1].Name = "DestinationShellID";
+ aObjArgs[1].Value <<= rDestDoc;
+ xPers->storeToEntry(xStg, aName, aEmpty, aObjArgs);
if ( xStg->isStreamElement( aName ) )
{
uno::Reference < io::XStream > xStm = xStg->cloneStreamElement( aName );
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 08b6c15..26d626b 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;
@@ -2284,8 +2297,42 @@ void SchXMLExportHelper_Impl::exportAxis(
// get property states for autostyles
if( xAxisProps.is() && mxExpPropMapper.is() )
{
+ bool bIgnoreLinkedNumFmt = maSrcShellID != maDestShellID;
lcl_exportNumberFormat( sNumFormat, xAxisProps, mrExport );
aPropertyStates = mxExpPropMapper->Filter( xAxisProps );
+
+ fprintf(stdout, "SchXMLExportHelper_Impl::exportAxis: src shell = '%s' dest shell = '%s'\n",
+ rtl::OUStringToOString(maSrcShellID, RTL_TEXTENCODING_UTF8).getStr(),
+ rtl::OUStringToOString(maDestShellID, RTL_TEXTENCODING_UTF8).getStr());
+
+ if (bIgnoreLinkedNumFmt && false)
+ {
+ bool bFound = false;
+ const UniReference<XMLPropertySetMapper>& rMapper = mxExpPropMapper->getPropertySetMapper();
+ for (size_t i = 0; i < aPropertyStates.size(); ++i)
+ {
+ XMLPropertyState& rState = aPropertyStates[i];
+ if (rState.mnIndex < 0 || rMapper->GetEntryCount() <= rState.mnIndex)
+ continue;
+
+ OUString aAPIName = rMapper->GetEntryAPIName(rState.mnIndex);
+ OUString aXMLName = rMapper->GetEntryXMLName(rState.mnIndex);
+
+ if (aAPIName != "LinkNumberFormatToSource")
+ continue;
+
+ rState.maValue <<= false;
+ bFound = true;
+ }
+
+ if (!bFound)
+ {
+ sal_Int32 nIndex = rMapper->GetEntryIndex(XML_NAMESPACE_CHART, "link-data-style-to-source", 0);
+ XMLPropertyState aState(nIndex);
+ aState.maValue <<= false;
+ aPropertyStates.push_back(aState);
+ }
+ }
}
bool bExportDateScale = false;
@@ -3562,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 7730c88..6546983 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,14 +800,15 @@ sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue
try
{
+ const sal_Int32 nPropCount = aDescriptor.getLength();
+ const beans::PropertyValue* pProps = aDescriptor.getConstArray();
+
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();
for( sal_Int32 nIndex = 0; nIndex < nPropCount; nIndex++, pProps++ )
{
@@ -824,6 +828,24 @@ sal_Bool SAL_CALL SvXMLExport::filter( const uno::Sequence< beans::PropertyValue
}
}
+ 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 +1532,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() );
commit 36b340e75377d6bee6e54abe5d3755fdc5b81d2c
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Mon Jun 16 10:43:08 2014 -0400
Cache table entry may be null. Let's not assume it's always non-null.
This is done intentionally because we do need correct table index when
resolving external reference. This requires we do need to allocate array
with the same sheet size as the remote document. But we don't allocate
Table instances for remote sheets that we don't reference, to save
memory.
Change-Id: I27fb6228f0e4558327aa4a04a6bccce8d2f1085f
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index a4d03f2..ab9a7b9 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1118,15 +1118,18 @@ void ScExternalRefCache::getAllCachedDataSpans( sal_uInt16 nFileId, sc::ColumnSp
const std::vector<TableTypeRef>& rTables = pDocItem->maTables;
for (size_t nTab = 0, nTabCount = rTables.size(); nTab < nTabCount; ++nTab)
{
- const Table& rTable = *rTables[nTab];
+ TableTypeRef pTab = rTables[nTab];
+ if (!pTab)
+ continue;
+
std::vector<SCROW> aRows;
- rTable.getAllRows(aRows);
+ pTab->getAllRows(aRows);
std::vector<SCROW>::const_iterator itRow = aRows.begin(), itRowEnd = aRows.end();
for (; itRow != itRowEnd; ++itRow)
{
SCROW nRow = *itRow;
std::vector<SCCOL> aCols;
- rTable.getAllCols(nRow, aCols);
+ pTab->getAllCols(nRow, aCols);
std::vector<SCCOL>::const_iterator itCol = aCols.begin(), itColEnd = aCols.end();
for (; itCol != itColEnd; ++itCol)
{
@@ -1242,8 +1245,11 @@ void ScExternalRefCache::clearCacheTables(sal_uInt16 nFileId)
std::vector<TableTypeRef>& rTabs = pDocItem->maTables;
for (size_t i = 0, n = rTabs.size(); i < n; ++i)
{
- Table& rTab = *rTabs[i];
- rTab.clear();
+ TableTypeRef pTab = rTabs[i];
+ if (!pTab)
+ continue;
+
+ pTab->clear();
}
// Clear the external range name caches.
More information about the Libreoffice-commits
mailing list