diff options
author | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-07-19 08:11:43 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-07-26 14:13:53 +0200 |
commit | a23b44fd9f0119f7ea3523e32875f55c1a07c1cd (patch) | |
tree | 2a9ffc63b7186fea9d0cfea8660d95d30a8f6684 /oox | |
parent | 3c3b9ad8886da916027f0fb940a2df822d63d4d7 (diff) |
tdf#123626 Allow adding hyperlinks to shapes
* Support hyperlinks on Shapes in Writer
* Add menu items
* Add context menu items
* ODF import/export + test
* OOXML import/export + test
Change-Id: I7269064c4cabd16fdb8259a48429c508184d3ccf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119164
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/export/vmlexport.cxx | 4 | ||||
-rw-r--r-- | oox/source/token/properties.txt | 1 | ||||
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 4 | ||||
-rw-r--r-- | oox/source/vml/vmlshapecontext.cxx | 6 |
4 files changed, 15 insertions, 0 deletions
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index 77d3e1686d16..5b267184a291 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -1389,6 +1389,10 @@ sal_Int32 VMLExport::StartShape() break; } + if (!m_pSdrObject->getHyperlink().isEmpty()) + m_pShapeAttrList->add( + XML_href, OUStringToOString(m_pSdrObject->getHyperlink(), RTL_TEXTENCODING_UTF8)); + m_pShapeAttrList->addNS(XML_o, XML_allowincell, m_IsFollowingTextFlow ? "t" : "f"); // add style diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 68b5e2d14af5..04b550e669ea 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -254,6 +254,7 @@ HoriOrientPosition HoriOrientRelation HorizontalSplitMode HorizontalSplitPositionTwips +Hyperlink IgnoreBlankCells IgnoreCase IgnoreLeadingSpaces diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 98481299e412..d1029173a1db 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -813,6 +813,10 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes if(!maTypeModel.maWrapStyle.isEmpty()) PropertySet(xShape).setAnyProperty(PROP_TextWordWrap, makeAny(maTypeModel.maWrapStyle == "square")); + // tdf#123626 + if (!maTypeModel.maHyperlink.isEmpty()) + PropertySet(xShape).setAnyProperty(PROP_Hyperlink, makeAny(maTypeModel.maHyperlink)); + PropertySet(xShape).setAnyProperty(PROP_TextAutoGrowHeight, makeAny(maTypeModel.mbAutoHeight)); diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index 0d0c00b61d8c..d53a924c278a 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -312,6 +312,7 @@ ShapeTypeContext::ShapeTypeContext(ContextHandler2Helper const & rParent, mrTypeModel.moCoordPos = lclDecodeInt32Pair( rAttribs, XML_coordorigin ); mrTypeModel.moCoordSize = lclDecodeInt32Pair( rAttribs, XML_coordsize ); setStyle( rAttribs.getString( XML_style, OUString() ) ); + setHyperlink( rAttribs.getString( XML_href, OUString() ) ); if( lclDecodeBool( rAttribs, O_TOKEN( hr )).get( false )) { // MSO's handling of o:hr width is nowhere near what the spec says: // - o:hrpct is not in % but in 0.1% @@ -469,6 +470,11 @@ void ShapeTypeContext::setStyle( const OUString& rStyle ) } } +void ShapeTypeContext::setHyperlink( const OUString& rHyperlink ) +{ + mrTypeModel.maHyperlink = rHyperlink; +} + ShapeContext::ShapeContext(ContextHandler2Helper const& rParent, const std::shared_ptr<ShapeBase>& pShape, const AttributeList& rAttribs) : ShapeTypeContext(rParent, pShape, rAttribs) |