diff options
author | tundet <tundeth@gmail.com> | 2019-04-12 10:21:42 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-04-17 10:17:47 +0200 |
commit | dc091e7fd952b0530db8583247c2f910d627700a (patch) | |
tree | b9f9e791329be94147fb932806a98ec897fa57b6 /sc/source/filter | |
parent | 185e01c015528cafbddcda5dfdabf816ce8be20e (diff) |
tdf#123645 XLSX export: fix hyperlink inserted to chart
Hyperlink inserted to chart lost after export.
chart_hyperlink.xlsx: Test file from Excel 2016.
Change-Id: Ideca10e544193ba43d7c2ef6e9dd8e393383edc1
Reviewed-on: https://gerrit.libreoffice.org/70648
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sc/source/filter')
-rw-r--r-- | sc/source/filter/excel/xeescher.cxx | 7 | ||||
-rw-r--r-- | sc/source/filter/inc/xcl97rec.hxx | 14 | ||||
-rw-r--r-- | sc/source/filter/inc/xeescher.hxx | 4 | ||||
-rw-r--r-- | sc/source/filter/xcl97/xcl97esc.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xcl97/xcl97rec.cxx | 35 |
5 files changed, 37 insertions, 25 deletions
diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index 1780e00efc9e..f1d41f7a7f7e 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -1059,9 +1059,10 @@ void XclExpTbxControlObj::WriteSbs( XclExpStream& rStrm ) //#endif -XclExpChartObj::XclExpChartObj( XclExpObjectManager& rObjMgr, Reference< XShape > const & xShape, const tools::Rectangle* pChildAnchor ) : +XclExpChartObj::XclExpChartObj( XclExpObjectManager& rObjMgr, Reference< XShape > const & xShape, const tools::Rectangle* pChildAnchor, ScDocument* pDoc ) : XclObj( rObjMgr, EXC_OBJTYPE_CHART ), - XclExpRoot( rObjMgr.GetRoot() ), mxShape( xShape ) + XclExpRoot( rObjMgr.GetRoot() ), mxShape( xShape ), + mpDoc(pDoc) { // create the MSODRAWING record contents for the chart object mrEscherEx.OpenContainer( ESCHER_SpContainer ); @@ -1128,6 +1129,8 @@ void XclExpChartObj::SaveXml( XclExpXmlStream& rStrm ) XclObjAny::WriteFromTo( rStrm, mxShape, GetTab() ); Reference< XModel > xModel( mxChartDoc, UNO_QUERY ); ChartExport aChartExport(XML_xdr, pDrawing, xModel, &rStrm, drawingml::DOCUMENT_XLSX); + std::shared_ptr<oox::drawingml::URLTransformer> pURLTransformer(new ScURLTransformer(*mpDoc)); + aChartExport.SetURLTranslator(pURLTransformer); static sal_Int32 nChartCount = 0; nChartCount++; sal_Int32 nID = rStrm.GetUniqueId(); diff --git a/sc/source/filter/inc/xcl97rec.hxx b/sc/source/filter/inc/xcl97rec.hxx index 1c8fa1903e33..0999f0ea3dd2 100644 --- a/sc/source/filter/inc/xcl97rec.hxx +++ b/sc/source/filter/inc/xcl97rec.hxx @@ -26,6 +26,7 @@ #include "xestring.hxx" #include <tabprotection.hxx> #include <svx/svdobj.hxx> +#include <oox/export/drawingml.hxx> class XclObj; class XclExpMsoDrawing; @@ -34,6 +35,19 @@ class SdrTextObj; class XclTxo; class XclEscherEx; +class ScURLTransformer : public oox::drawingml::URLTransformer +{ +public: + explicit ScURLTransformer(ScDocument& rDoc); + + virtual OUString getTransformedString(const OUString& rURL) const override; + + virtual bool isExternalURL(const OUString& rURL) const override; + +private: + ScDocument& mrDoc; +}; + class XclExpObjList : public ExcEmptyRec, protected XclExpRoot { public: diff --git a/sc/source/filter/inc/xeescher.hxx b/sc/source/filter/inc/xeescher.hxx index f45ebbf79bcf..05491a3b2127 100644 --- a/sc/source/filter/inc/xeescher.hxx +++ b/sc/source/filter/inc/xeescher.hxx @@ -294,7 +294,8 @@ public: explicit XclExpChartObj( XclExpObjectManager& rObjMgr, css::uno::Reference< css::drawing::XShape > const & xShape, - const tools::Rectangle* pChildAnchor ); + const tools::Rectangle* pChildAnchor, + ScDocument* pDoc ); virtual ~XclExpChartObj() override; /** Writes the OBJ record and the entire chart substream. */ @@ -308,6 +309,7 @@ private: XclExpChartRef mxChart; /// The chart itself (BOF/EOF substream data). css::uno::Reference< css::drawing::XShape > mxShape; css::uno::Reference< css::chart::XChartDocument > mxChartDoc; + ScDocument* mpDoc; }; /** Represents a NOTE record containing the relevant data of a cell note. diff --git a/sc/source/filter/xcl97/xcl97esc.cxx b/sc/source/filter/xcl97/xcl97esc.cxx index f987d336e1b4..9ca76ae49c58 100644 --- a/sc/source/filter/xcl97/xcl97esc.cxx +++ b/sc/source/filter/xcl97/xcl97esc.cxx @@ -215,7 +215,7 @@ EscherExHostAppData* XclEscherEx::StartShape( const Reference< XShape >& rxShape SvGlobalName aObjClsId( xObj->getClassID() ); if ( SotExchange::IsChart( aObjClsId ) ) { // yes, it's a chart diagram - mrObjMgr.AddObj( std::make_unique<XclExpChartObj>( mrObjMgr, rxShape, pChildAnchor ) ); + mrObjMgr.AddObj( std::make_unique<XclExpChartObj>( mrObjMgr, rxShape, pChildAnchor, &GetDocRef() ) ); pCurrXclObj = nullptr; // no metafile or whatsoever } else // metafile and OLE object diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx index 38fd9c27103e..4c55ed88ec03 100644 --- a/sc/source/filter/xcl97/xcl97rec.cxx +++ b/sc/source/filter/xcl97/xcl97rec.cxx @@ -1129,30 +1129,23 @@ void transformURL(const OUString& rOldURL, OUString& rNewURL, const ScDocument* rNewURL = rOldURL; } -class ScURLTransformer : public oox::drawingml::URLTransformer -{ -public: - explicit ScURLTransformer(ScDocument& rDoc) - : mrDoc(rDoc) - { - } - - virtual OUString getTransformedString(const OUString& rURL) const override - { - OUString aNewURL; - transformURL(rURL, aNewURL, &mrDoc); - return aNewURL; - } +} - virtual bool isExternalURL(const OUString& rURL) const override - { - return !rURL.startsWith("#"); - } +ScURLTransformer::ScURLTransformer(ScDocument& rDoc) + : mrDoc(rDoc) +{ +} -private: - ScDocument& mrDoc; -}; +OUString ScURLTransformer::getTransformedString(const OUString& rURL) const +{ + OUString aNewURL; + transformURL(rURL, aNewURL, &mrDoc); + return aNewURL; +} +bool ScURLTransformer::isExternalURL(const OUString& rURL) const +{ + return !rURL.startsWith("#"); } void XclObjAny::SaveXml( XclExpXmlStream& rStrm ) |