summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authortundet <tundeth@gmail.com>2019-04-12 10:21:42 +0200
committerLászló Németh <nemeth@numbertext.org>2019-04-17 10:17:47 +0200
commitdc091e7fd952b0530db8583247c2f910d627700a (patch)
treeb9f9e791329be94147fb932806a98ec897fa57b6 /oox
parent185e01c015528cafbddcda5dfdabf816ce8be20e (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 'oox')
-rw-r--r--oox/source/export/chartexport.cxx26
-rw-r--r--oox/source/export/drawingml.cxx14
-rw-r--r--oox/source/export/shapes.cxx24
3 files changed, 44 insertions, 20 deletions
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 15e9bca1c1c9..672ae2579d99 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -376,6 +376,7 @@ ChartExport::ChartExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, Reference< f
, mnXmlNamespace( nXmlNamespace )
, mnSeriesCount(0)
, mxChartModel( xModel )
+ , mpURLTransformer(new URLTransformer)
, mbHasCategoryLabels( false )
, mbHasZAxis( false )
, mbIs3DChart( false )
@@ -384,6 +385,11 @@ ChartExport::ChartExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, Reference< f
{
}
+void ChartExport::SetURLTranslator(const std::shared_ptr<URLTransformer>& pTransformer)
+{
+ mpURLTransformer = pTransformer;
+}
+
sal_Int32 ChartExport::getChartType( )
{
OUString sChartType = mxDiagram->getDiagramType();
@@ -445,6 +451,8 @@ void ChartExport::WriteChartObj( const Reference< XShape >& xShape, sal_Int32 nI
{
FSHelperPtr pFS = GetFS();
+ Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
+
pFS->startElementNS( mnXmlNamespace, XML_graphicFrame, FSEND );
pFS->startElementNS( mnXmlNamespace, XML_nvGraphicFramePr, FSEND );
@@ -455,11 +463,27 @@ void ChartExport::WriteChartObj( const Reference< XShape >& xShape, sal_Int32 nI
if (xNamed.is())
sName = xNamed->getName();
- pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
+ pFS->startElementNS( mnXmlNamespace, XML_cNvPr,
XML_id, I32S( nID ),
XML_name, sName.toUtf8(),
FSEND );
+ OUString sURL;
+ if ( GetProperty( xShapeProps, "URL" ) )
+ mAny >>= sURL;
+ if( !sURL.isEmpty() )
+ {
+ OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(),
+ oox::getRelationship(Relationship::HYPERLINK),
+ mpURLTransformer->getTransformedString(sURL),
+ mpURLTransformer->isExternalURL(sURL));
+
+ mpFS->singleElementNS( XML_a, XML_hlinkClick,
+ FSNS( XML_r,XML_id ), sRelId.toUtf8(),
+ FSEND );
+ }
+ pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
+
pFS->singleElementNS( mnXmlNamespace, XML_cNvGraphicFramePr,
FSEND );
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index a5e8f48f6dff..15eeda16f4c6 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -133,6 +133,20 @@ using ::sax_fastparser::FastSerializerHelper;
namespace oox {
namespace drawingml {
+URLTransformer::~URLTransformer()
+{
+}
+
+OUString URLTransformer::getTransformedString(const OUString& rString) const
+{
+ return rString;
+}
+
+bool URLTransformer::isExternalURL(const OUString& /*rURL*/) const
+{
+ return true;
+}
+
static css::uno::Any getLineDash( const css::uno::Reference<css::frame::XModel>& xModel, const OUString& rDashName )
{
css::uno::Reference<css::lang::XMultiServiceFactory> xFact(xModel, css::uno::UNO_QUERY);
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index ecc14705a75b..b89f1d966868 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -338,20 +338,6 @@ uno::Reference<io::XInputStream> GetOLEObjectStream(
namespace oox { namespace drawingml {
-URLTransformer::~URLTransformer()
-{
-}
-
-OUString URLTransformer::getTransformedString(const OUString& rString) const
-{
- return rString;
-}
-
-bool URLTransformer::isExternalURL(const OUString& /*rURL*/) const
-{
- return true;
-}
-
#define GETA(propName) \
GetProperty( rXPropSet, #propName)
@@ -1160,13 +1146,13 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape
if( !sURL.isEmpty() )
{
OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(),
- oox::getRelationship(Relationship::HYPERLINK),
- mpURLTransformer->getTransformedString(sURL),
- mpURLTransformer->isExternalURL(sURL));
+ oox::getRelationship(Relationship::HYPERLINK),
+ mpURLTransformer->getTransformedString(sURL),
+ mpURLTransformer->isExternalURL(sURL));
mpFS->singleElementNS( XML_a, XML_hlinkClick,
- FSNS( XML_r,XML_id ), sRelId.toUtf8(),
- FSEND );
+ FSNS( XML_r,XML_id ), sRelId.toUtf8(),
+ FSEND );
}
pFS->endElementNS(mnXmlNamespace, XML_cNvPr);