summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/drawingml.cxx65
1 files changed, 57 insertions, 8 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index bfe44e32b098..b84a77f085a0 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -93,6 +93,10 @@
#include <com/sun/star/xml/dom/XNodeList.hpp>
#include <com/sun/star/xml/sax/Writer.hpp>
#include <com/sun/star/xml/sax/XSAXSerializable.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/drawing/XDrawPages.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/frame/XModel.hpp>
#include <comphelper/random.hxx>
#include <comphelper/seqstream.hxx>
@@ -156,9 +160,12 @@ OUString URLTransformer::getTransformedString(const OUString& rString) const
return rString;
}
-bool URLTransformer::isExternalURL(const OUString& /*rURL*/) const
+bool URLTransformer::isExternalURL(const OUString& rURL) const
{
- return true;
+ bool bExternal = true;
+ if (rURL.startsWith("#"))
+ bExternal = false;
+ return bExternal;
}
static css::uno::Any getLineDash( const css::uno::Reference<css::frame::XModel>& xModel, const OUString& rDashName )
@@ -1842,6 +1849,29 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa
bFlipHWrite, bFlipVWrite, ExportRotateClockwisify(nRotation + nCameraRotation), IsGroupShape( rXShape ));
}
+static OUString lcl_GetTarget(const css::uno::Reference<css::frame::XModel>& xModel, OUString& rURL)
+{
+ Reference<drawing::XDrawPagesSupplier> xDPS(xModel, uno::UNO_QUERY_THROW);
+ Reference<drawing::XDrawPages> xDrawPages(xDPS->getDrawPages(), uno::UNO_SET_THROW);
+ sal_uInt32 nPageCount = xDrawPages->getCount();
+ OUString sTarget;
+
+ for (sal_uInt32 i = 0; i < nPageCount; ++i)
+ {
+ Reference<XDrawPage> xDrawPage;
+ xDrawPages->getByIndex(i) >>= xDrawPage;
+ Reference<container::XNamed> xNamed(xDrawPage, UNO_QUERY_THROW);
+ OUString sSlideName = "#" + xNamed->getName();
+ if (rURL == sSlideName)
+ {
+ sTarget = "slide" + OUString::number(i + 1) + ".xml";
+ break;
+ }
+ }
+
+ return sTarget;
+}
+
void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool bIsField, sal_Int32 nElement,
bool bCheckDirect,bool& rbOverridingCharHeight, sal_Int32& rnCharHeight,
sal_Int16 nScriptType, const Reference< XPropertySet >& rXShapePropSet)
@@ -2177,15 +2207,34 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool
OUString sURL;
mAny >>= sURL;
- if( !sURL.isEmpty() ) {
- OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(),
- oox::getRelationship(Relationship::HYPERLINK),
- sURL, true );
+ if (!sURL.isEmpty())
+ {
+ if (!sURL.match("#action?jump="))
+ {
+ bool bExtURL = URLTransformer().isExternalURL(sURL);
+ sURL = bExtURL ? sURL : lcl_GetTarget(GetFB()->getModel(), sURL);
+
+ OUString sRelId
+ = mpFB->addRelation(mpFS->getOutputStream(),
+ bExtURL ? oox::getRelationship(Relationship::HYPERLINK)
+ : oox::getRelationship(Relationship::SLIDE),
+ sURL, bExtURL);
- mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), sRelId);
+ if (bExtURL)
+ mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), sRelId);
+ else
+ mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), sRelId,
+ XML_action, "ppaction://hlinksldjump");
+ }
+ else
+ {
+ sal_Int32 nIndex = sURL.indexOf('=');
+ OUString aDestination(sURL.copy(nIndex + 1));
+ mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), "", XML_action,
+ "ppaction://hlinkshowjump?jump=" + aDestination);
+ }
}
}
-
mpFS->endElementNS( XML_a, nElement );
}