diff options
author | Michael Brauer <mib@openoffice.org> | 2002-10-31 09:26:33 +0000 |
---|---|---|
committer | Michael Brauer <mib@openoffice.org> | 2002-10-31 09:26:33 +0000 |
commit | 7e8a4211664bcc4325135456d071783330e0f15b (patch) | |
tree | 541cc58eee8cebb0f895e06fa802692cf3ba952b /xmloff | |
parent | 0c24dc84e7fbb94677b4fef487e9880b645911e5 (diff) |
#96627# hyperlinks and contore for embedded objects in flat files
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/text/XMLTextFrameContext.cxx | 120 | ||||
-rw-r--r-- | xmloff/source/text/XMLTextFrameContext.hxx | 11 |
2 files changed, 102 insertions, 29 deletions
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx index 22fe44a2ca82..9be263c9e010 100644 --- a/xmloff/source/text/XMLTextFrameContext.cxx +++ b/xmloff/source/text/XMLTextFrameContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLTextFrameContext.cxx,v $ * - * $Revision: 1.52 $ + * $Revision: 1.53 $ * - * last change: $Author: mib $ $Date: 2001-11-26 11:45:54 $ + * last change: $Author: mib $ $Date: 2002-10-31 10:26:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -173,6 +173,36 @@ using namespace ::com::sun::star::document; using namespace ::xmloff::token; using ::com::sun::star::document::XEventsSupplier; +class XMLTextFrameContextHyperlink_Impl +{ + OUString sHRef; + OUString sName; + OUString sTargetFrameName; + sal_Bool bMap; + +public: + + inline XMLTextFrameContextHyperlink_Impl( const OUString& rHRef, + const OUString& rName, + const OUString& rTargetFrameName, + sal_Bool bMap ); + + const OUString& GetHRef() const { return sHRef; } + const OUString& GetName() const { return sName; } + const OUString& GetTargetFrameName() const { return sTargetFrameName; } + sal_Bool GetMap() const { return bMap; } +}; + +inline XMLTextFrameContextHyperlink_Impl::XMLTextFrameContextHyperlink_Impl( + const OUString& rHRef, const OUString& rName, + const OUString& rTargetFrameName, sal_Bool bM ) : + sHRef( rHRef ), + sName( rName ), + sTargetFrameName( rTargetFrameName ), + bMap( bM ) +{ +} + class XMLTextFrameDescContext_Impl : public SvXMLImportContext { OUString& rDesc; @@ -486,7 +516,10 @@ void XMLTextFrameContext::Create( sal_Bool bHRefOrBase64 ) } if( !xPropSet.is() ) + { + bCreateFailed = sal_True; return; + } Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); @@ -677,6 +710,29 @@ void XMLTextFrameContext::Create( sal_Bool bHRefOrBase64 ) xTxtImport->SetListItem( NULL ); } + if( pHyperlink ) + { + SetHyperlink( pHyperlink->GetHRef(), pHyperlink->GetName(), + pHyperlink->GetTargetFrameName(), pHyperlink->GetMap() ); + delete pHyperlink; + pHyperlink = 0; + } + +} + +sal_Bool XMLTextFrameContext::CreateIfNotThere() +{ + if( !xPropSet.is() && + ( XML_TEXT_FRAME_OBJECT_OLE == nType || + XML_TEXT_FRAME_GRAPHIC == nType ) && + xBase64Stream.is() && !bCreateFailed ) + { + if( bOwnBase64Stream ) + xBase64Stream->closeOutput(); + Create( sal_True ); + } + + return xPropSet.is(); } XMLTextFrameContext::XMLTextFrameContext( @@ -708,7 +764,8 @@ XMLTextFrameContext::XMLTextFrameContext( sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName")), sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation")), sTextBoxServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame")), - sGraphicServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GraphicObject")) + sGraphicServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GraphicObject")), + pHyperlink( 0 ) { nX = 0; nY = 0; @@ -724,7 +781,7 @@ XMLTextFrameContext::XMLTextFrameContext( bMinHeight = sal_False; bSyncWidth = sal_False; bSyncHeight = sal_False; - bCreateBase64StreamFailed = sal_False; + bCreateFailed = sal_False; bOwnBase64Stream = sal_False; UniReference < XMLTextImportHelper > xTxtImport = @@ -926,18 +983,14 @@ XMLTextFrameContext::XMLTextFrameContext( XMLTextFrameContext::~XMLTextFrameContext() { + delete pHyperlink; // should be 0, but might exist not only because of + // a filter bug but also because of an improper XML + // file, so an OSL_ENSURE is not correct either. } void XMLTextFrameContext::EndElement() { - if( ( XML_TEXT_FRAME_OBJECT_OLE == nType || - XML_TEXT_FRAME_GRAPHIC == nType ) - && !xPropSet.is() && xBase64Stream.is() ) - { - if( bOwnBase64Stream ) - xBase64Stream->closeOutput(); - Create( sal_True ); - } + CreateIfNotThere(); // alternative text if( sDesc.getLength() ) @@ -997,22 +1050,31 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext( nPrefix, rLocalName, xAttrList, nType, aParamMap ); } - else if( xPropSet.is() ) + else { if( IsXMLToken( rLocalName, XML_CONTOUR_POLYGON ) ) - pContext = new XMLTextFrameContourContext_Impl( GetImport(), - nPrefix, rLocalName, - xAttrList, xPropSet, sal_False ); + { + if( CreateIfNotThere() ) + pContext = new XMLTextFrameContourContext_Impl( GetImport(), + nPrefix, rLocalName, + xAttrList, xPropSet, sal_False ); + } else if( IsXMLToken( rLocalName, XML_CONTOUR_PATH ) ) - pContext = new XMLTextFrameContourContext_Impl( GetImport(), - nPrefix, rLocalName, - xAttrList, xPropSet, sal_True ); + { + if( CreateIfNotThere() ) + pContext = new XMLTextFrameContourContext_Impl( GetImport(), + nPrefix, rLocalName, + xAttrList, xPropSet, sal_True ); + } else if ( IsXMLToken( rLocalName, XML_IMAGE_MAP ) && ( nType == XML_TEXT_FRAME_TEXTBOX || nType == XML_TEXT_FRAME_GRAPHIC || nType == XML_TEXT_FRAME_OBJECT_OLE ) ) - pContext = new XMLImageMapContext( GetImport(), nPrefix, - rLocalName, xPropSet ); + { + if( CreateIfNotThere() ) + pContext = new XMLImageMapContext( GetImport(), nPrefix, + rLocalName, xPropSet ); + } } } else if( (XML_NAMESPACE_OFFICE == nPrefix) ) @@ -1020,7 +1082,7 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext( if( IsXMLToken( rLocalName, XML_EVENTS ) ) { // do we still have the frame object? - if (xPropSet.is()) + if( CreateIfNotThere() ) { // is it an event supplier? Reference<XEventsSupplier> xEventsSupplier(xPropSet, UNO_QUERY); @@ -1037,7 +1099,7 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext( else if( xmloff::token::IsXMLToken( rLocalName, xmloff::token::XML_BINARY_DATA ) ) { - if( !xPropSet.is() && !xBase64Stream.is() ) + if( !xPropSet.is() && !xBase64Stream.is() && !bCreateFailed ) { switch( nType ) { @@ -1064,7 +1126,7 @@ SvXMLImportContext *XMLTextFrameContext::CreateChildContext( (XML_NAMESPACE_MATH == nPrefix && IsXMLToken(rLocalName, XML_MATH) ) ) ) { - if( !xPropSet.is() ) + if( !xPropSet.is() && !bCreateFailed ) { XMLEmbeddedObjectImportContext *pEContext = new XMLEmbeddedObjectImportContext( GetImport(), nPrefix, @@ -1101,12 +1163,12 @@ void XMLTextFrameContext::Characters( const OUString& rChars ) { if( ( XML_TEXT_FRAME_OBJECT_OLE == nType || XML_TEXT_FRAME_GRAPHIC == nType) && - !xPropSet.is() ) + !xPropSet.is() && !bCreateFailed ) { OUString sTrimmedChars( rChars. trim() ); if( sTrimmedChars.getLength() ) { - if( !xBase64Stream.is() && !bCreateBase64StreamFailed ) + if( !xBase64Stream.is() ) { if( XML_TEXT_FRAME_GRAPHIC == nType ) { @@ -1152,7 +1214,13 @@ void XMLTextFrameContext::SetHyperlink( const OUString& rHRef, sal_Bool bMap ) { if( !xPropSet.is() ) + { + OSL_ENSURE( !pHyperlink, "recursive SetHyperlink call" ); + delete pHyperlink; + pHyperlink = new XMLTextFrameContextHyperlink_Impl( + rHRef, rName, rTargetFrameName, bMap ); return; + } UniReference< XMLTextImportHelper > xTxtImp = GetImport().GetTextImport(); Reference < XPropertySetInfo > xPropSetInfo = diff --git a/xmloff/source/text/XMLTextFrameContext.hxx b/xmloff/source/text/XMLTextFrameContext.hxx index 9b32984b21bb..c54e35e65137 100644 --- a/xmloff/source/text/XMLTextFrameContext.hxx +++ b/xmloff/source/text/XMLTextFrameContext.hxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLTextFrameContext.hxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: mib $ $Date: 2001-10-16 10:56:37 $ + * last change: $Author: mib $ $Date: 2002-10-31 10:25:03 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -105,6 +105,8 @@ typedef ::std::map < const ::rtl::OUString, ::rtl::OUString, ::comphelper::UStri typedef ::std::map < const ::rtl::OUString, ::rtl::OUString, less_functor> ParamMap; #endif +class XMLTextFrameContextHyperlink_Impl; + class XMLTextFrameContext : public SvXMLImportContext { ::com::sun::star::uno::Reference < @@ -158,6 +160,8 @@ class XMLTextFrameContext : public SvXMLImportContext ParamMap aParamMap; + XMLTextFrameContextHyperlink_Impl *pHyperlink; + sal_Int32 nX; sal_Int32 nY; sal_Int32 nWidth; @@ -175,10 +179,11 @@ class XMLTextFrameContext : public SvXMLImportContext sal_Bool bMinHeight : 1; sal_Bool bSyncWidth : 1; sal_Bool bSyncHeight : 1; - sal_Bool bCreateBase64StreamFailed : 1; + sal_Bool bCreateFailed : 1; sal_Bool bOwnBase64Stream : 1; void Create( sal_Bool bHRefOrBase64 ); + sal_Bool CreateIfNotThere(); public: |