summaryrefslogtreecommitdiffstats
path: root/oox
diff options
context:
space:
mode:
authorKatarina Behrens <Katarina.Behrens@cib.de>2015-08-26 18:05:08 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-09-14 16:52:47 +0000
commit2b2a812b89d0d1df08c5d771bfe9bc5eaa3a040c (patch)
tree5c8640a85135e446cf887510b8b8a913b87fd8f5 /oox
parentResolves: tdf#93895 broadcast cell changes when multi-selection was pasted (diff)
downloadcore-2b2a812b89d0d1df08c5d771bfe9bc5eaa3a040c.tar.gz
core-2b2a812b89d0d1df08c5d771bfe9bc5eaa3a040c.zip
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 Change-Id: I4317e4a2f6f2e6f15c30932adc80f1227e010af0 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>
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 83fd6f065b0f..4cb85307af52 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1439,7 +1439,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
@@ -1462,11 +1462,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 ) )
{
@@ -1480,7 +1479,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() )
{
@@ -1488,17 +1486,19 @@ const char* DrawingML::GetFieldType( ::com::sun::star::uno::Reference< ::com::su
SAL_INFO("oox.shape", "field kind: " << 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;
}
OString DrawingML::GetUUID()
@@ -1523,14 +1523,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 );
@@ -1548,13 +1553,12 @@ void DrawingML::WriteRun( Reference< XTextRange > rRun )
}
}
- sFieldType = GetFieldType( rRun, bIsField );
- if( ( sFieldType != NULL ) )
+ if( ( bWriteField ) )
{
OString sUUID(GetUUID());
mpFS->startElementNS( XML_a, XML_fld,
XML_id, sUUID.getStr(),
- XML_type, sFieldType,
+ XML_type, OUStringToOString( sFieldValue, RTL_TEXTENCODING_UTF8 ).getStr(),
FSEND );
}
else
@@ -1563,13 +1567,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 );