diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2015-08-26 18:05:08 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-09-29 10:57:22 +0000 |
commit | 7e2c726fc1ca98d2a21bd75b8669e41e461ed85f (patch) | |
tree | 489e3a9a30b242bde482bbc4591b128d6d2bf041 | |
parent | 67b846d8e2a2078740cfb55a305ac671fbf13215 (diff) |
tdf#91293: Preserve hyperlink on URL field OOXML export
The fix is twofold:
1.Get URL property from the underlying text field, not from the
text run -- put text field properties into rXPropSet (that's
what GETA macro later queries), not into rRun
6a043e9c0acff20e1618ca8ec15c21d5d0fd0d37 does s/rXPropSet/rRun/
afaics for no good reason
2. Retrieve string content from URL field early, so that the test
for empty text content doesn't fire
Reviewed-on: https://gerrit.libreoffice.org/18031
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Conflicts:
oox/source/export/drawingml.cxx
sd/qa/unit/export-tests.cxx
Change-Id: I4317e4a2f6f2e6f15c30932adc80f1227e010af0
Reviewed-on: https://gerrit.libreoffice.org/18709
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | include/oox/export/drawingml.hxx | 2 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 40 |
2 files changed, 23 insertions, 19 deletions
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index 246960c22fda..255f493ba158 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -107,7 +107,7 @@ protected: bool GetPropertyAndState( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState > rXPropState, const OUString& aName, ::com::sun::star::beans::PropertyState& eState ); - const char* GetFieldType( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > rRun, bool& bIsField ); + OUString GetFieldValue( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > rRun, bool& bIsURLField ); /// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 66dfb1ffcbf4..efe632390ad6 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1409,7 +1409,7 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel Reference< XTextField > rXTextField; GET( rXTextField, TextField ); if( rXTextField.is() ) - rRun.set( rXTextField, UNO_QUERY ); + rXPropSet.set( rXTextField, UNO_QUERY ); } // field properties starts here @@ -1432,11 +1432,10 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel mpFS->endElementNS( XML_a, XML_rPr ); } -const char* DrawingML::GetFieldType( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > rRun, bool& bIsField ) +OUString DrawingML::GetFieldValue( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > rRun, bool& bIsURLField ) { - const char* sType = NULL; Reference< XPropertySet > rXPropSet( rRun, UNO_QUERY ); - OUString aFieldType; + OUString aFieldType, aFieldValue; if( GETA( TextPortionType ) ) { @@ -1450,7 +1449,6 @@ const char* DrawingML::GetFieldType( ::com::sun::star::uno::Reference< ::com::su GET( rXTextField, TextField ); if( rXTextField.is() ) { - bIsField = true; rXPropSet.set( rXTextField, UNO_QUERY ); if( rXPropSet.is() ) { @@ -1458,17 +1456,19 @@ const char* DrawingML::GetFieldType( ::com::sun::star::uno::Reference< ::com::su DBG(fprintf (stderr, "field kind: %s\n", USS(aFieldKind) )); if( aFieldKind == "Page" ) { - return "slidenum"; + aFieldValue = OUString("slidenum"); + } + else if( aFieldKind == "URL" ) + { + bIsURLField = true; + GET( aFieldValue, Representation) + } - // else if( aFieldKind == "URL" ) { - // do not return here - // and make URL field text run with hyperlink property later - // } } } } - return sType; + return aFieldValue; } void DrawingML::GetUUID( OStringBuffer& rBuffer ) @@ -1513,10 +1513,15 @@ void DrawingML::GetUUID( OStringBuffer& rBuffer ) void DrawingML::WriteRun( Reference< XTextRange > rRun ) { - const char* sFieldType; - bool bIsField = false; + bool bIsURLField = false; + OUString sFieldValue = GetFieldValue( rRun, bIsURLField ); + bool bWriteField = !( sFieldValue.isEmpty() || bIsURLField ); + OUString sText = rRun->getString(); + if ( bIsURLField ) + sText = sFieldValue; + if( sText.isEmpty()) { Reference< XPropertySet > xPropSet( rRun, UNO_QUERY ); @@ -1534,15 +1539,14 @@ void DrawingML::WriteRun( Reference< XTextRange > rRun ) } } - sFieldType = GetFieldType( rRun, bIsField ); - if( ( sFieldType != NULL ) ) + if( ( bWriteField ) ) { OStringBuffer sUUID(39); GetUUID( sUUID ); mpFS->startElementNS( XML_a, XML_fld, XML_id, sUUID.getStr(), - XML_type, sFieldType, + XML_type, OUStringToOString( sFieldValue, RTL_TEXTENCODING_UTF8 ).getStr(), FSEND ); } else @@ -1551,13 +1555,13 @@ void DrawingML::WriteRun( Reference< XTextRange > rRun ) } Reference< XPropertySet > xPropSet( rRun, uno::UNO_QUERY ); - WriteRunProperties( xPropSet, bIsField ); + WriteRunProperties( xPropSet, bIsURLField ); mpFS->startElementNS( XML_a, XML_t, FSEND ); mpFS->writeEscaped( sText ); mpFS->endElementNS( XML_a, XML_t ); - if( sFieldType ) + if( bWriteField ) mpFS->endElementNS( XML_a, XML_fld ); else mpFS->endElementNS( XML_a, XML_r ); |