diff options
Diffstat (limited to 'oox/source/drawingml')
-rw-r--r-- | oox/source/drawingml/hyperlinkcontext.cxx | 103 | ||||
-rw-r--r-- | oox/source/drawingml/shape.cxx | 16 | ||||
-rw-r--r-- | oox/source/drawingml/textrun.cxx | 11 |
3 files changed, 112 insertions, 18 deletions
diff --git a/oox/source/drawingml/hyperlinkcontext.cxx b/oox/source/drawingml/hyperlinkcontext.cxx index 2c83aedeff82..f1c87d2507dc 100644 --- a/oox/source/drawingml/hyperlinkcontext.cxx +++ b/oox/source/drawingml/hyperlinkcontext.cxx @@ -55,33 +55,106 @@ HyperLinkContext::HyperLinkContext( ContextHandler& rParent, : ContextHandler( rParent ) , maProperties(aProperties) { + OUString sURL, sHref; OUString aRelId = xAttributes->getOptionalValue( NMSP_RELATIONSHIPS|XML_id ); - OSL_TRACE("OOX: URI rId %s", ::rtl::OUStringToOString (aRelId, RTL_TEXTENCODING_UTF8).pData->buffer); - const OUString& sHref = getRelations().getExternalTargetFromRelId( aRelId ); - if( sHref.getLength() > 0 ) + if ( aRelId.getLength() ) { - OSL_TRACE("OOX: URI href %s", ::rtl::OUStringToOString (sHref, RTL_TEXTENCODING_UTF8).pData->buffer); - maProperties[ PROP_URL ] <<= getFilter().getAbsoluteUrl( sHref ); - OUString sTooltip = xAttributes->getOptionalValue( NMSP_RELATIONSHIPS|XML_tooltip ); + OSL_TRACE("OOX: URI rId %s", ::rtl::OUStringToOString (aRelId, RTL_TEXTENCODING_UTF8).pData->buffer); + sHref = getRelations().getTargetFromRelId( aRelId ); + if( sHref.getLength() > 0 ) + { + OSL_TRACE("OOX: URI href %s", ::rtl::OUStringToOString (sHref, RTL_TEXTENCODING_UTF8).pData->buffer); + sURL = getFilter().getAbsoluteUrl( sHref ); + } + } + OUString sTooltip = xAttributes->getOptionalValue( NMSP_RELATIONSHIPS|XML_tooltip ); + if ( sTooltip.getLength() ) maProperties[ PROP_Representation ] <<= sTooltip; + OUString sFrame = xAttributes->getOptionalValue( NMSP_RELATIONSHIPS|XML_tgtFrame ); + if( sFrame.getLength() ) + maProperties[ PROP_TargetFrame ] <<= sFrame; + OUString aAction = xAttributes->getOptionalValue( XML_action ); + if ( aAction.getLength() ) + { + // reserved values of the unrestricted string aAction: + // ppaction://customshow?id=SHOW_ID // custom presentation + // ppaction://hlinkfile // external file via r:id + // ppaction://hlinkpres?slideindex=SLIDE_NUM // external presentation via r:id + // ppaction://hlinkshowjump?jump=endshow + // ppaction://hlinkshowjump?jump=firstslide + // ppaction://hlinkshowjump?jump=lastslide + // ppaction://hlinkshowjump?jump=lastslideviewed + // ppaction://hlinkshowjump?jump=nextslide + // ppaction://hlinkshowjump?jump=previousslide + // ppaction://hlinksldjump + // ppaction://macro?name=MACRO_NAME + // ppaction://program - OUString sFrame = xAttributes->getOptionalValue( NMSP_RELATIONSHIPS|XML_tgtFrame ); - if( sFrame.getLength() ) - maProperties[ PROP_TargetFrame ] <<= sFrame; + const OUString sPPAction( CREATE_OUSTRING( "ppaction://" ) ); + if ( aAction.matchIgnoreAsciiCase( sPPAction, 0 ) ) + { + OUString aPPAct( aAction.copy( sPPAction.getLength() ) ); + sal_Int32 nIndex = aPPAct.indexOf( '?', 0 ); + OUString aPPAction( nIndex > 0 ? aPPAct.copy( 0, nIndex ) : aPPAct ); -// sValue = OUString( RTL_CONSTASCII_USTRINGPARAM( "" ) ); -// const rtl::OUString sUnvisitedCharStyleName( CREATE_OUSTRING( "UnvisitedCharStyleName" ) ); -// maProperties[ sUnvisitedCharStyleName ] <<= sValue; -// const rtl::OUString sVisitedCharStyleName( CREATE_OUSTRING( "VisitedCharStyleName" ) ); -// maProperties[ sVisitedCharStyleName ] <<= sValue; + const OUString sHlinkshowjump( CREATE_OUSTRING( "hlinkshowjump" ) ); + const OUString sHlinksldjump( CREATE_OUSTRING( "hlinksldjump" ) ); + if ( aPPAction.match( sHlinkshowjump ) ) + { + const OUString sJump( CREATE_OUSTRING( "jump=" ) ); + if ( aPPAct.match( sJump, nIndex + 1 ) ) + { + OUString aDestination( aPPAct.copy( nIndex + 1 + sJump.getLength() ) ); + sURL = sURL.concat( CREATE_OUSTRING( "#action?jump=" ) ); + sURL = sURL.concat( aDestination ); + } + } + else if ( aPPAction.match( sHlinksldjump ) ) + { + sURL = OUString(); + sal_Int32 nIndex2 = 0; + while ( nIndex2 < sHref.getLength() ) + { + sal_Unicode nChar = sHref[ nIndex2 ]; + if ( ( nChar >= '0' ) && ( nChar <= '9' ) ) + break; + nIndex2++; + } + if ( nIndex2 && ( nIndex2 != sHref.getLength() ) ) + { + sal_Int32 nLength = 1; + while( ( nIndex2 + nLength ) < sHref.getLength() ) + { + sal_Unicode nChar = sHref[ nIndex2 + nLength ]; + if ( ( nChar < '0' ) || ( nChar > '9' ) ) + break; + nLength++; + } + sal_Int32 nPageNumber = sHref.copy( nIndex2, nLength ).toInt32(); + if ( nPageNumber ) + { + const OUString sSlide( CREATE_OUSTRING( "slide" ) ); + const OUString sNotesSlide( CREATE_OUSTRING( "notesSlide" ) ); + const OUString aSlideType( sHref.copy( 0, nIndex2 ) ); + if ( aSlideType.match( sSlide ) ) + sURL = CREATE_OUSTRING( "#Slide " ).concat( rtl::OUString::valueOf( nPageNumber ) ); + else if ( aSlideType.match( sNotesSlide ) ) + sURL = CREATE_OUSTRING( "#Notes " ).concat( rtl::OUString::valueOf( nPageNumber ) ); +// else: todo for other types such as notesMaster or slideMaster as they can't be referenced easily + } + } + } + } } + if ( sURL.getLength() ) + maProperties[ PROP_URL ] <<= sURL; + // TODO unhandled // XML_invalidUrl // XML_history // XML_highlightClick // XML_endSnd - // XML_action } HyperLinkContext::~HyperLinkContext() diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 08f6d63f0ee5..329aa6b36226 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -148,7 +148,7 @@ void Shape::addShape( rtl::OUString sServiceName( msServiceName ); if( sServiceName.getLength() ) { - Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, rxTheme, rxShapes, pShapeRect ) ); + Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, rxTheme, rxShapes, pShapeRect, sal_False ) ); if( pShapeMap && msId.getLength() ) { @@ -247,7 +247,8 @@ Reference< XShape > Shape::createAndInsert( const rtl::OUString& rServiceName, const ThemePtr& rxTheme, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, - const awt::Rectangle* pShapeRect ) + const awt::Rectangle* pShapeRect, + sal_Bool bClearText ) { awt::Size aSize( pShapeRect ? awt::Size( pShapeRect->Width, pShapeRect->Height ) : maSize ); awt::Point aPosition( pShapeRect ? awt::Point( pShapeRect->X, pShapeRect->Y ) : maPosition ); @@ -367,6 +368,17 @@ Reference< XShape > Shape::createAndInsert( } rxShapes->add( mxShape ); + // sj: removing default text of placeholder objects such as SlideNumberShape or HeaderShape + if ( bClearText ) + { + uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY ); + if ( xText.is() ) + { + OUString aEmpty; + xText->setString( aEmpty ); + } + } + LineProperties aLineProperties; aLineProperties.maLineFill.moFillType = XML_noFill; sal_Int32 nLinePhClr = -1; diff --git a/oox/source/drawingml/textrun.cxx b/oox/source/drawingml/textrun.cxx index 2d8422b2f018..04dcb68c053f 100644 --- a/oox/source/drawingml/textrun.cxx +++ b/oox/source/drawingml/textrun.cxx @@ -91,12 +91,21 @@ void TextRun::insertAt( Reference< XTextField > xField( xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.text.TextField.URL" ) ), UNO_QUERY ); if( xField.is() ) { + Reference< XTextCursor > xTextFieldCursor = xText->createTextCursor(); + xTextFieldCursor->gotoEnd( sal_False ); + PropertySet aFieldProps( xField ); aFieldProps.setProperties( maTextCharacterProperties.maHyperlinkPropertyMap ); aFieldProps.setProperty( PROP_Representation, getText() ); - Reference< XTextContent > xContent( xField, UNO_QUERY); xText->insertTextContent( xStart, xContent, sal_False ); + + xTextFieldCursor->gotoEnd( sal_True ); + oox::core::TextField aTextField; + aTextField.xText = xText; + aTextField.xTextCursor = xTextFieldCursor; + aTextField.xTextField = xField; + rFilterBase.getTextFieldStack().push_back( aTextField ); } else { |