diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2013-11-22 16:14:11 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2013-12-02 11:13:43 +0100 |
commit | 97fa39975f592cb2d46db95b9a323ff753497fbd (patch) | |
tree | 60eb84fc5d3ade7d3c88081b9fc01f66b7625717 /sc/source/filter | |
parent | 7acc91eb72bc4873367c264109321abc34d7db77 (diff) |
export data streams; pretend to be an area link
Fix ScXMLExport::GetAreaLinks to not use UNO, so we can hack DataStreams
into ScMyAreaLinksContainer.
We need to connect them to cells for export / import - that does not make
sense for DataStream without any attached range. We use an arbitrary one.
But you might remove it, if you create another ScAreaLink / DataStream
with the same range, without knowing about it.
Maybe it wouldn't be that bad to let DataStream inherit from ScAreaLink.
Change-Id: I5b85a9329ba1ca46fb2893b54fe5161d2fb22f47
Diffstat (limited to 'sc/source/filter')
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 55 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.hxx | 2 |
2 files changed, 29 insertions, 28 deletions
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 5ed08dfa70f6..8fbeb8ab22ff 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -60,6 +60,8 @@ #include "stylehelper.hxx" #include "edittextiterator.hxx" #include "editattributemap.hxx" +#include <arealink.hxx> +#include <datastream.hxx> #include <xmloff/xmltoken.hxx> #include <xmloff/xmlnmspe.hxx> @@ -147,6 +149,7 @@ #include "XMLCodeNameProvider.hxx" +#include <sfx2/linkmgr.hxx> #include <sfx2/objsh.hxx> #include <vector> @@ -814,37 +817,35 @@ table::CellRangeAddress ScXMLExport::GetEndAddress(const uno::Reference<sheet::X return aCellAddress; } -void ScXMLExport::GetAreaLinks( uno::Reference< sheet::XSpreadsheetDocument>& xSpreadDoc, - ScMyAreaLinksContainer& rAreaLinks ) +void ScXMLExport::GetAreaLinks( ScMyAreaLinksContainer& rAreaLinks ) { - uno::Reference< beans::XPropertySet > xPropSet( xSpreadDoc, uno::UNO_QUERY ); - if( !xPropSet.is() ) return; - - uno::Reference< container::XIndexAccess > xLinksIAccess( xPropSet->getPropertyValue( OUString( SC_UNO_AREALINKS ) ), uno::UNO_QUERY); - if( xLinksIAccess.is() ) + if (pDoc->GetLinkManager()) { - const OUString sFilter( SC_UNONAME_FILTER ); - const OUString sFilterOpt( SC_UNONAME_FILTOPT ); - const OUString sURL( SC_UNONAME_LINKURL ); - const OUString sRefresh( SC_UNONAME_REFDELAY ); - - sal_Int32 nCount(xLinksIAccess->getCount()); - for( sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex ) + const sfx2::SvBaseLinks& rLinks = pDoc->GetLinkManager()->GetLinks(); + for (size_t i = 0; i < rLinks.size(); i++) { - uno::Reference< sheet::XAreaLink > xAreaLink(xLinksIAccess->getByIndex( nIndex ), uno::UNO_QUERY); - if( xAreaLink.is() ) + ScAreaLink *pLink = dynamic_cast<ScAreaLink*>(&(*(*rLinks[i]))); + if (pLink) { ScMyAreaLink aAreaLink; - aAreaLink.aDestRange = xAreaLink->getDestArea(); - aAreaLink.sSourceStr = xAreaLink->getSourceArea(); - uno::Reference< beans::XPropertySet > xLinkProp( xAreaLink, uno::UNO_QUERY ); - if( xLinkProp.is() ) - { - xLinkProp->getPropertyValue( sFilter ) >>= aAreaLink.sFilter; - xLinkProp->getPropertyValue( sFilterOpt ) >>= aAreaLink.sFilterOptions; - xLinkProp->getPropertyValue( sURL ) >>= aAreaLink.sURL; - xLinkProp->getPropertyValue( sRefresh ) >>= aAreaLink.nRefresh; - } + ScUnoConversion::FillApiRange( aAreaLink.aDestRange, pLink->GetDestArea() ); + aAreaLink.sSourceStr = pLink->GetSource(); + aAreaLink.sFilter = pLink->GetFilter(); + aAreaLink.sFilterOptions = pLink->GetOptions(); + aAreaLink.sURL = pLink->GetFile(); + aAreaLink.nRefresh = pLink->GetTimeout(); + rAreaLinks.AddNewAreaLink( aAreaLink ); + } + DataStream *pStream = dynamic_cast<DataStream*>(&(*(*rLinks[i]))); + if (pStream) + { + ScMyAreaLink aAreaLink; + ScUnoConversion::FillApiRange( aAreaLink.aDestRange, pStream->GetRange() ); + aAreaLink.sSourceStr = pStream->GetMove(); + aAreaLink.sFilter = OUString::number(pStream->GetLimit()); + aAreaLink.sFilterOptions = "DataStream"; + aAreaLink.sURL = pStream->GetURL(); + aAreaLink.nRefresh = pStream->GetSettings(); rAreaLinks.AddNewAreaLink( aAreaLink ); } } @@ -1904,7 +1905,7 @@ void ScXMLExport::_ExportContent() WriteCalculationSettings(xSpreadDoc); sal_Int32 nTableCount(xIndex->getCount()); ScMyAreaLinksContainer aAreaLinks; - GetAreaLinks( xSpreadDoc, aAreaLinks ); + GetAreaLinks( aAreaLinks ); ScMyEmptyDatabaseRangesContainer aEmptyRanges(aExportDatabaseRanges.GetEmptyDatabaseRanges()); ScMyDetectiveOpContainer aDetectiveOpContainer; GetDetectiveOpList( aDetectiveOpContainer ); diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx index cc649bd3df72..4ece1d5bb9ff 100644 --- a/sc/source/filter/xml/xmlexprt.hxx +++ b/sc/source/filter/xml/xmlexprt.hxx @@ -144,7 +144,7 @@ class ScXMLExport : public SvXMLExport com::sun::star::table::CellRangeAddress GetEndAddress(const com::sun::star::uno::Reference<com::sun::star::sheet::XSpreadsheet>& xTable, const sal_Int32 nTable); // ScMyEmptyDatabaseRangesContainer GetEmptyDatabaseRanges(); - void GetAreaLinks( com::sun::star::uno::Reference< com::sun::star::sheet::XSpreadsheetDocument>& xSpreadDoc, ScMyAreaLinksContainer& rAreaLinks ); + void GetAreaLinks( ScMyAreaLinksContainer& rAreaLinks ); void GetDetectiveOpList( ScMyDetectiveOpContainer& rDetOp ); void WriteSingleColumn(const sal_Int32 nRepeatColumns, const sal_Int32 nStyleIndex, const sal_Int32 nIndex, const bool bIsAutoStyle, const bool bIsVisible); |