summaryrefslogtreecommitdiff
path: root/xmloff/source/draw
diff options
context:
space:
mode:
authorChristian Lippka <christian.lippka@sun.com>2010-02-22 18:27:09 +0100
committerChristian Lippka <christian.lippka@sun.com>2010-02-22 18:27:09 +0100
commit8f8ff2eed656838de34d32db09c685a5b73ce0ce (patch)
tree3371e08ac00c514f1dc323305562146926bba756 /xmloff/source/draw
parent57684db80b31ec34e3d6c0c59a8bb28ff708a330 (diff)
#i106339# preserve hyperlinks at shapes in draw documents
Diffstat (limited to 'xmloff/source/draw')
-rw-r--r--xmloff/source/draw/shapeexport.cxx38
-rw-r--r--xmloff/source/draw/ximpshap.cxx51
2 files changed, 71 insertions, 18 deletions
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index 3a0e01631f28..740b0c71bc02 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -30,7 +30,11 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_xmloff.hxx"
+
+#include <memory>
+
#include "unointerfacetouniqueidentifiermapper.hxx"
+#include <com/sun/star/presentation/ClickAction.hpp>
#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/text/XText.hpp>
@@ -541,6 +545,38 @@ void XMLShapeExport::exportShape(const uno::Reference< drawing::XShape >& xShape
}
sal_Int32 nZIndex = 0;
uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY );
+
+
+ ::std::auto_ptr< SvXMLElementExport > mpHyperlinkElement;
+
+ // export hyperlinks with <a><shape/></a>. Currently only in draw since draw
+ // does not support document events
+ if( xSet.is() && (GetExport().GetModelType() == SvtModuleOptions::E_DRAW) ) try
+ {
+ presentation::ClickAction eAction = presentation::ClickAction_NONE;
+ xSet->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("OnClick"))) >>= eAction;
+
+ if( (eAction == presentation::ClickAction_DOCUMENT) ||
+ (eAction == presentation::ClickAction_BOOKMARK) )
+ {
+ OUString sURL;
+ xSet->getPropertyValue(msBookmark) >>= sURL;
+
+ if( sURL.getLength() )
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sURL );
+ mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
+ mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
+ mpHyperlinkElement.reset( new SvXMLElementExport(mrExport, XML_NAMESPACE_DRAW, XML_A, sal_True, sal_True) );
+ }
+ }
+ }
+ catch( uno::Exception& )
+ {
+ DBG_ERROR("XMLShapeExport::exportShape(): exception during hyperlink export");
+ }
+
+
if( xSet.is() )
xSet->getPropertyValue(msZIndex) >>= nZIndex;
@@ -848,6 +884,8 @@ void XMLShapeExport::exportShape(const uno::Reference< drawing::XShape >& xShape
}
}
+ mpHyperlinkElement.reset();
+
// #97489# #97111#
// if there was an error and no element for the shape was exported
// we need to clear the attribute list or the attributes will be
diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx
index 07c6f8f62152..3ddf0020774c 100644
--- a/xmloff/source/draw/ximpshap.cxx
+++ b/xmloff/source/draw/ximpshap.cxx
@@ -375,31 +375,46 @@ void SdXMLShapeContext::EndElement()
if( msHyperlink.getLength() != 0 ) try
{
- Reference< XEventsSupplier > xEventsSupplier( mxShape, UNO_QUERY_THROW );
- Reference< XNameReplace > xEvents( xEventsSupplier->getEvents(), UNO_QUERY_THROW );
+ const OUString sBookmark( RTL_CONSTASCII_USTRINGPARAM( "Bookmark" ) );
- uno::Sequence< beans::PropertyValue > aProperties( 3 );
- aProperties[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "EventType" ) );
- aProperties[0].Handle = -1;
- aProperties[0].Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM("Presentation") );
- aProperties[0].State = beans::PropertyState_DIRECT_VALUE;
+ Reference< XEventsSupplier > xEventsSupplier( mxShape, UNO_QUERY );
+ if( xEventsSupplier.is() )
+ {
+ const OUString sEventType( RTL_CONSTASCII_USTRINGPARAM( "EventType" ) );
+ const OUString sClickAction( RTL_CONSTASCII_USTRINGPARAM( "ClickAction" ) );
+
+ Reference< XNameReplace > xEvents( xEventsSupplier->getEvents(), UNO_QUERY_THROW );
- aProperties[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "ClickAction" ) );
- aProperties[1].Handle = -1;
- aProperties[1].Value <<= ::com::sun::star::presentation::ClickAction_DOCUMENT;
- aProperties[1].State = beans::PropertyState_DIRECT_VALUE;
+ uno::Sequence< beans::PropertyValue > aProperties( 3 );
+ aProperties[0].Name = sEventType;
+ aProperties[0].Handle = -1;
+ aProperties[0].Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM("Presentation") );
+ aProperties[0].State = beans::PropertyState_DIRECT_VALUE;
- aProperties[2].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Bookmark" ) );
- aProperties[2].Handle = -1;
- aProperties[2].Value <<= msHyperlink;
- aProperties[2].State = beans::PropertyState_DIRECT_VALUE;
+ aProperties[1].Name = sClickAction;
+ aProperties[1].Handle = -1;
+ aProperties[1].Value <<= ::com::sun::star::presentation::ClickAction_DOCUMENT;
+ aProperties[1].State = beans::PropertyState_DIRECT_VALUE;
- const OUString sAPIEventName( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) );
- xEvents->replaceByName( sAPIEventName, Any( aProperties ) );
+ aProperties[2].Name = sBookmark;
+ aProperties[2].Handle = -1;
+ aProperties[2].Value <<= msHyperlink;
+ aProperties[2].State = beans::PropertyState_DIRECT_VALUE;
+
+ const OUString sAPIEventName( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) );
+ xEvents->replaceByName( sAPIEventName, Any( aProperties ) );
+ }
+ else
+ {
+ // in draw use the Bookmark property
+ Reference< beans::XPropertySet > xSet( mxShape, UNO_QUERY_THROW );
+ xSet->setPropertyValue( sBookmark, Any( msHyperlink ) );
+ xSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) ), Any( ::com::sun::star::presentation::ClickAction_DOCUMENT ) );
+ }
}
catch( Exception& )
{
- DBG_ERROR("xmloff::SdXMLShapeContext::EndElement(), exception caught!");
+ DBG_ERROR("xmloff::SdXMLShapeContext::EndElement(), exception caught while setting hyperlink!");
}
if( mxLockable.is() )