summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorKatarina Behrens <Katarina.Behrens@cib.de>2015-08-26 18:05:08 +0200
committerAndras Timar <andras.timar@collabora.com>2015-10-17 23:22:19 +0200
commitde6774e112006abc44f44211527f230bd2e74b04 (patch)
tree0c95059f5035cef19780ebc76b1de447a69606a0 /oox
parent778b4d0182768584f83bf83b3804e465bf35bbd2 (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: sd/qa/unit/export-tests.cxx Change-Id: I4317e4a2f6f2e6f15c30932adc80f1227e010af0 Reviewed-on: https://gerrit.libreoffice.org/18706 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> (cherry picked from commit e17187c323428b7edea425278ea33bca77db12b5)
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/drawingml.cxx40
1 files changed, 22 insertions, 18 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 878276a531ff..ecb66e365313 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1438,7 +1438,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
@@ -1461,11 +1461,10 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel
mpFS->endElementNS( XML_a, nElement );
}
-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 ) )
{
@@ -1479,7 +1478,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() )
{
@@ -1487,17 +1485,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 )
@@ -1546,14 +1546,19 @@ void DrawingML::WriteRun( Reference< XTextRange > rRun )
sal_Int16 nLevel = -1;
GET( nLevel, NumberingLevel );
- const char* sFieldType;
- bool bIsField = false;
+ bool bIsURLField = false;
+ OUString sFieldValue = GetFieldValue( rRun, bIsURLField );
+ bool bWriteField = !( sFieldValue.isEmpty() || bIsURLField );
+
OUString sText = rRun->getString();
//if there is no text following the bullet, add a space after the bullet
if (nLevel !=-1 && sText.isEmpty() )
sText=" ";
+ if ( bIsURLField )
+ sText = sFieldValue;
+
if( sText.isEmpty())
{
Reference< XPropertySet > xPropSet( rRun, UNO_QUERY );
@@ -1571,15 +1576,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
@@ -1588,13 +1592,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 );