summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver-Rainer Wittmann <orw@apache.org>2014-01-14 13:10:51 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-01-16 10:53:05 +0000
commit5f9d7ab963dbc1e13e4645fcef954cb8772cbb63 (patch)
tree01984712018833b5e0f4a742914717a3f9051289
parentd762c154178399a2ec1ab1d6aa9e8d5133f93d63 (diff)
Resolves: #i123457# suppress import and export of hyperlinks without an URL
(cherry picked from commit 71d322a8ce0f5f5cbfd66fd689ff10b3490c1ee4) Conflicts: include/xmloff/xmlexp.hxx xmloff/source/core/xmlexp.cxx xmloff/source/text/txtparae.cxx xmloff/source/text/txtparai.cxx Change-Id: Ie8291c93c86815cab68482b35a5e88a3bd9b731e
-rw-r--r--include/xmloff/txtparae.hxx11
-rw-r--r--include/xmloff/xmlexp.hxx18
-rw-r--r--xmloff/source/core/xmlexp.cxx154
-rw-r--r--xmloff/source/text/txtimp.cxx3
-rw-r--r--xmloff/source/text/txtparae.cxx137
-rw-r--r--xmloff/source/text/txtparai.cxx100
6 files changed, 237 insertions, 186 deletions
diff --git a/include/xmloff/txtparae.hxx b/include/xmloff/txtparae.hxx
index 585cc3f83bd7..87b32fc30ef5 100644
--- a/include/xmloff/txtparae.hxx
+++ b/include/xmloff/txtparae.hxx
@@ -105,6 +105,17 @@ public:
enum FieldmarkType { NONE, TEXT, CHECK }; // Used for simulating fieldmarks in OpenDocument 1.n Strict (for n <= 2). CHECK currently ignored.
+
+ void exportTextRangeSpan(
+ const ::com::sun::star::uno::Reference< com::sun::star::text::XTextRange > & rTextRange,
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & xPropSet,
+ ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > & xPropSetInfo,
+ const sal_Bool bIsUICharStyle,
+ const sal_Bool bHasAutoStyle,
+ const OUString& sStyle,
+ bool& rPrevCharIsSpace,
+ FieldmarkType& openFieldMark);
+
protected:
const OUString sActualSize;
diff --git a/include/xmloff/xmlexp.hxx b/include/xmloff/xmlexp.hxx
index b734777a3a33..2e77c5c00c06 100644
--- a/include/xmloff/xmlexp.hxx
+++ b/include/xmloff/xmlexp.hxx
@@ -654,14 +654,16 @@ inline void SvXMLExport::SetGraphicResolver(
// Helper class to export an element.
class XMLOFF_DLLPUBLIC SvXMLElementExport
{
- SvXMLExport& rExport;
- OUString aName;
- sal_Bool bIgnWS : 1;
- sal_Bool bDoSomething : 1;
-
- SAL_DLLPRIVATE void StartElement( SvXMLExport& rExp, sal_uInt16 nPrefix,
- const OUString& rName,
- sal_Bool bIgnWSOutside );
+ SvXMLExport& mrExport;
+ OUString maElementName;
+ const sal_Bool mbIgnoreWhitespaceInside :1;
+ const sal_Bool mbDoSomething :1;
+
+ SAL_DLLPRIVATE
+ void StartElement(
+ const sal_uInt16 nPrefix,
+ const OUString& rName,
+ const sal_Bool bIgnoreWhitespaceOutside );
public:
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index cd9d54f68428..0c9e3dcb851d 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -2531,83 +2531,95 @@ sal_Bool SvXMLExport::SetNullDateOnUnitConverter()
return mpImpl->mbNullDateInitialized;
}
-void SvXMLElementExport::StartElement( SvXMLExport& rExp,
- sal_uInt16 nPrefixKey,
- const OUString& rLName,
- sal_Bool bIWSOutside )
-{
- aName = rExp.GetNamespaceMap().GetQNameByKey(nPrefixKey, rLName);
- rExp.StartElement(aName, bIWSOutside);
-}
-
-SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
- sal_uInt16 nPrefixKey,
- const sal_Char *pLName,
- sal_Bool bIWSOutside,
- sal_Bool bIWSInside ) :
- rExport( rExp ),
- bIgnWS( bIWSInside ),
- bDoSomething( sal_True )
-{
- OUString sLName( OUString::createFromAscii(pLName) );
- StartElement( rExp, nPrefixKey, sLName, bIWSOutside );
-}
-
-SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
- sal_uInt16 nPrefixKey,
- const OUString& rLName,
- sal_Bool bIWSOutside,
- sal_Bool bIWSInside ) :
- rExport( rExp ),
- bIgnWS( bIWSInside ),
- bDoSomething( sal_True )
-{
- StartElement( rExp, nPrefixKey, rLName, bIWSOutside );
-}
-
-SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
- sal_uInt16 nPrefixKey,
- enum XMLTokenEnum eLName,
- sal_Bool bIWSOutside,
- sal_Bool bIWSInside ) :
- rExport( rExp ),
- bIgnWS( bIWSInside ),
- bDoSomething( sal_True )
-{
- StartElement( rExp, nPrefixKey, GetXMLToken(eLName), bIWSOutside );
-}
-
-SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
- sal_Bool bDoSth,
- sal_uInt16 nPrefixKey,
- enum XMLTokenEnum eLName,
- sal_Bool bIWSOutside,
- sal_Bool bIWSInside ) :
- rExport( rExp ),
- bIgnWS( bIWSInside ),
- bDoSomething( bDoSth )
-{
- if( bDoSomething )
- StartElement( rExport, nPrefixKey, GetXMLToken(eLName), bIWSOutside );
-}
-
-SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
- const OUString& rQName,
- sal_Bool bIWSOutside,
- sal_Bool bIWSInside ) :
- rExport( rExp ),
- bIgnWS( bIWSInside ),
- bDoSomething( sal_True )
-{
- aName = rQName;
+//=============================================================================
+
+void SvXMLElementExport::StartElement(
+ const sal_uInt16 nPrefixKey,
+ const OUString& rLName,
+ const sal_Bool bIgnoreWhitespaceOutside )
+{
+ maElementName = mrExport.GetNamespaceMap().GetQNameByKey(nPrefixKey, rLName);
+ mrExport.StartElement(maElementName, bIgnoreWhitespaceOutside);
+}
+
+SvXMLElementExport::SvXMLElementExport(
+ SvXMLExport& rExp,
+ sal_uInt16 nPrefixKey,
+ const sal_Char *pLName,
+ sal_Bool bIWSOutside,
+ sal_Bool bIWSInside )
+ : mrExport( rExp )
+ , maElementName()
+ , mbIgnoreWhitespaceInside( bIWSInside )
+ , mbDoSomething( sal_True )
+{
+ const OUString sLName( OUString::createFromAscii( pLName ) );
+ StartElement( nPrefixKey, sLName, bIWSOutside );
+}
+
+SvXMLElementExport::SvXMLElementExport(
+ SvXMLExport& rExp,
+ sal_uInt16 nPrefixKey,
+ const OUString& rLName,
+ sal_Bool bIWSOutside,
+ sal_Bool bIWSInside )
+ : mrExport( rExp )
+ , maElementName()
+ , mbIgnoreWhitespaceInside( bIWSInside )
+ , mbDoSomething( sal_True )
+{
+ StartElement( nPrefixKey, rLName, bIWSOutside );
+}
+
+SvXMLElementExport::SvXMLElementExport(
+ SvXMLExport& rExp,
+ sal_uInt16 nPrefixKey,
+ enum XMLTokenEnum eLName,
+ sal_Bool bIWSOutside,
+ sal_Bool bIWSInside )
+ : mrExport( rExp )
+ , maElementName()
+ , mbIgnoreWhitespaceInside( bIWSInside )
+ , mbDoSomething( sal_True )
+{
+ StartElement( nPrefixKey, GetXMLToken(eLName), bIWSOutside );
+}
+
+SvXMLElementExport::SvXMLElementExport(
+ SvXMLExport& rExp,
+ sal_Bool bDoSth,
+ sal_uInt16 nPrefixKey,
+ enum XMLTokenEnum eLName,
+ sal_Bool bIWSOutside,
+ sal_Bool bIWSInside )
+ : mrExport( rExp )
+ , maElementName()
+ , mbIgnoreWhitespaceInside( bIWSInside )
+ , mbDoSomething( bDoSth )
+{
+ if ( mbDoSomething )
+ StartElement( nPrefixKey, GetXMLToken( eLName ), bIWSOutside );
+}
+
+SvXMLElementExport::SvXMLElementExport(
+ SvXMLExport& rExp,
+ const OUString& rQName,
+ sal_Bool bIWSOutside,
+ sal_Bool bIWSInside )
+ : mrExport( rExp )
+ , maElementName()
+ , mbIgnoreWhitespaceInside( bIWSInside )
+ , mbDoSomething( sal_True )
+{
+ maElementName = rQName;
rExp.StartElement( rQName, bIWSOutside );
}
SvXMLElementExport::~SvXMLElementExport()
{
- if( bDoSomething )
+ if ( mbDoSomething )
{
- rExport.EndElement( aName, bIgnWS );
+ mrExport.EndElement( maElementName, mbIgnoreWhitespaceInside );
}
}
diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx
index 259633dee671..b122e6604578 100644
--- a/xmloff/source/text/txtimp.cxx
+++ b/xmloff/source/text/txtimp.cxx
@@ -1979,7 +1979,8 @@ void XMLTextImportHelper::SetOutlineStyles( sal_Bool bSetEmptyLevels )
{
if (!lcl_HasListStyle(
m_pImpl->m_pOutlineStylesCandidates[i][j],
- m_pImpl->m_xParaStyles, GetXMLImport(),
+ m_pImpl->m_xParaStyles,
+ GetXMLImport(),
s_NumberingStyleName,
sOutlineStyleName))
{
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 0dcdefce34bd..95f6f0ce599a 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -3220,9 +3220,9 @@ void XMLTextParagraphExport::setTextEmbeddedGraphicURL(
}
sal_Bool XMLTextParagraphExport::addHyperlinkAttributes(
- const Reference < XPropertySet > & rPropSet,
- const Reference < XPropertyState > & rPropState,
- const Reference < XPropertySetInfo > & rPropSetInfo )
+ const Reference< XPropertySet > & rPropSet,
+ const Reference< XPropertyState > & rPropState,
+ const Reference< XPropertySetInfo > & rPropSetInfo )
{
sal_Bool bExport = sal_False;
OUString sHRef, sName, sTargetFrame, sUStyleName, sVStyleName;
@@ -3238,52 +3238,59 @@ sal_Bool XMLTextParagraphExport::addHyperlinkAttributes(
bExport = sal_True;
}
- if( rPropSetInfo->hasPropertyByName( sHyperLinkName ) &&
- ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
- rPropState->getPropertyState( sHyperLinkName ) ) )
+ if ( sHRef.isEmpty() )
+ {
+ // hyperlink without an URL does not make sense
+ OSL_ENSURE( false, "hyperlink without an URL --> no export to ODF" );
+ return sal_False;
+ }
+
+ if ( rPropSetInfo->hasPropertyByName( sHyperLinkName )
+ && ( !rPropState.is()
+ || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sHyperLinkName ) ) )
{
rPropSet->getPropertyValue( sHyperLinkName ) >>= sName;
if( !sName.isEmpty() )
bExport = sal_True;
}
- if( rPropSetInfo->hasPropertyByName( sHyperLinkTarget ) &&
- ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
- rPropState->getPropertyState( sHyperLinkTarget ) ) )
+ if ( rPropSetInfo->hasPropertyByName( sHyperLinkTarget )
+ && ( !rPropState.is()
+ || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sHyperLinkTarget ) ) )
{
rPropSet->getPropertyValue( sHyperLinkTarget ) >>= sTargetFrame;
if( !sTargetFrame.isEmpty() )
bExport = sal_True;
}
- if( rPropSetInfo->hasPropertyByName( sServerMap ) &&
- ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
- rPropState->getPropertyState( sServerMap ) ) )
+ if ( rPropSetInfo->hasPropertyByName( sServerMap )
+ && ( !rPropState.is()
+ || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sServerMap ) ) )
{
- bServerMap = *(sal_Bool *)rPropSet->getPropertyValue( sServerMap ).getValue();
- if( bServerMap )
+ bServerMap = *(sal_Bool *) rPropSet->getPropertyValue( sServerMap ).getValue();
+ if ( bServerMap )
bExport = sal_True;
}
- if( rPropSetInfo->hasPropertyByName( sUnvisitedCharStyleName ) &&
- ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
- rPropState->getPropertyState( sUnvisitedCharStyleName ) ) )
+ if ( rPropSetInfo->hasPropertyByName( sUnvisitedCharStyleName )
+ && ( !rPropState.is()
+ || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sUnvisitedCharStyleName ) ) )
{
rPropSet->getPropertyValue( sUnvisitedCharStyleName ) >>= sUStyleName;
if( !sUStyleName.isEmpty() )
bExport = sal_True;
}
- if( rPropSetInfo->hasPropertyByName( sVisitedCharStyleName ) &&
- ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
- rPropState->getPropertyState( sVisitedCharStyleName ) ) )
+ if ( rPropSetInfo->hasPropertyByName( sVisitedCharStyleName )
+ && ( !rPropState.is()
+ || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( sVisitedCharStyleName ) ) )
{
rPropSet->getPropertyValue( sVisitedCharStyleName ) >>= sVStyleName;
if( !sVStyleName.isEmpty() )
bExport = sal_True;
}
- if( bExport )
+ if ( bExport )
{
GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
GetExport().AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, GetExport().GetRelativeReference( sHRef ) );
@@ -3315,14 +3322,46 @@ sal_Bool XMLTextParagraphExport::addHyperlinkAttributes(
return bExport;
}
+void XMLTextParagraphExport::exportTextRangeSpan(
+ const com::sun::star::uno::Reference< com::sun::star::text::XTextRange > & rTextRange,
+ Reference< XPropertySet > & xPropSet,
+ Reference < XPropertySetInfo > & xPropSetInfo,
+ const sal_Bool bIsUICharStyle,
+ const sal_Bool bHasAutoStyle,
+ const OUString& sStyle,
+ bool& rPrevCharIsSpace,
+ FieldmarkType& openFieldMark )
+{
+ XMLTextCharStyleNamesElementExport aCharStylesExport(
+ GetExport(),
+ bIsUICharStyle && aCharStyleNamesPropInfoCache.hasProperty( xPropSet, xPropSetInfo ),
+ bHasAutoStyle,
+ xPropSet,
+ sCharStyleNames );
+
+ if ( !sStyle.isEmpty() )
+ {
+ GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME, GetExport().EncodeStyleName( sStyle ) );
+ }
+ {
+ SvXMLElementExport aElement( GetExport(), !sStyle.isEmpty(), XML_NAMESPACE_TEXT, XML_SPAN, sal_False, sal_False );
+ const OUString aText( rTextRange->getString() );
+ SvXMLElementExport aElem2( GetExport(), TEXT == openFieldMark,
+ XML_NAMESPACE_TEXT, XML_TEXT_INPUT,
+ sal_False, sal_False );
+ exportText( aText, rPrevCharIsSpace );
+ openFieldMark = NONE;
+ }
+}
+
void XMLTextParagraphExport::exportTextRange(
- const Reference < XTextRange > & rTextRange,
+ const Reference< XTextRange > & rTextRange,
sal_Bool bAutoStyles,
bool& rPrevCharIsSpace,
FieldmarkType& openFieldMark )
{
- Reference < XPropertySet > xPropSet( rTextRange, UNO_QUERY );
- if( bAutoStyles )
+ Reference< XPropertySet > xPropSet( rTextRange, UNO_QUERY );
+ if ( bAutoStyles )
{
Add( XML_STYLE_FAMILY_TEXT_TEXT, xPropSet );
}
@@ -3331,54 +3370,36 @@ void XMLTextParagraphExport::exportTextRange(
sal_Bool bHyperlink = sal_False;
sal_Bool bIsUICharStyle = sal_False;
sal_Bool bHasAutoStyle = sal_False;
-
- OUString sStyle(FindTextStyleAndHyperlink( xPropSet, bHyperlink,
- bIsUICharStyle, bHasAutoStyle ));
+ const OUString sStyle(
+ FindTextStyleAndHyperlink( xPropSet, bHyperlink, bIsUICharStyle, bHasAutoStyle ) );
Reference < XPropertySetInfo > xPropSetInfo;
- if( bHyperlink )
+ sal_Bool bHyperlinkAttrsAdded = sal_False;
+ if ( bHyperlink )
{
Reference< XPropertyState > xPropState( xPropSet, UNO_QUERY );
- xPropSetInfo.set(xPropSet->getPropertySetInfo());
- bHyperlink = addHyperlinkAttributes( xPropSet, xPropState, xPropSetInfo );
+ xPropSetInfo.set( xPropSet->getPropertySetInfo() );
+ bHyperlinkAttrsAdded = addHyperlinkAttributes( xPropSet, xPropState, xPropSetInfo );
}
- SvXMLElementExport aElem( GetExport(), bHyperlink, XML_NAMESPACE_TEXT,
- XML_A, sal_False, sal_False );
- if( bHyperlink )
+
+ if ( bHyperlink && bHyperlinkAttrsAdded )
{
+ SvXMLElementExport aElem( GetExport(), sal_True, XML_NAMESPACE_TEXT, XML_A, sal_False, sal_False );
+
// export events (if supported)
OUString sHyperLinkEvents(
"HyperLinkEvents");
if (xPropSetInfo->hasPropertyByName(sHyperLinkEvents))
{
- Reference<XNameReplace> xName(xPropSet->getPropertyValue(sHyperLinkEvents), uno::UNO_QUERY);
- GetExport().GetEventExport().Export(xName, sal_False);
+ Reference< XNameReplace > xName( xPropSet->getPropertyValue( sHyperLinkEvents ), uno::UNO_QUERY );
+ GetExport().GetEventExport().Export( xName, sal_False );
}
- }
+ exportTextRangeSpan( rTextRange, xPropSet, xPropSetInfo, bIsUICharStyle, bHasAutoStyle, sStyle, rPrevCharIsSpace, openFieldMark );
+ }
+ else
{
- XMLTextCharStyleNamesElementExport aCharStylesExport(
- GetExport(), bIsUICharStyle &&
- aCharStyleNamesPropInfoCache.hasProperty(
- xPropSet, xPropSetInfo ), bHasAutoStyle,
- xPropSet, sCharStyleNames );
-
- OUString aText(rTextRange->getString());
- if( !sStyle.isEmpty() )
- GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_STYLE_NAME,
- GetExport().EncodeStyleName( sStyle ) );
- {
- // in a block to make sure it is destroyed before the text:a element
- SvXMLElementExport aElement( GetExport(), !sStyle.isEmpty(),
- XML_NAMESPACE_TEXT, XML_SPAN, sal_False,
- sal_False );
-
- SvXMLElementExport aElem2( GetExport(), TEXT == openFieldMark,
- XML_NAMESPACE_TEXT, XML_TEXT_INPUT,
- sal_False, sal_False );
- exportText( aText, rPrevCharIsSpace );
- openFieldMark = NONE;
- }
+ exportTextRangeSpan( rTextRange, xPropSet, xPropSetInfo, bIsUICharStyle, bHasAutoStyle, sStyle, rPrevCharIsSpace, openFieldMark );
}
}
}
diff --git a/xmloff/source/text/txtparai.cxx b/xmloff/source/text/txtparai.cxx
index 2867e5d8b4e4..75a856d91516 100644
--- a/xmloff/source/text/txtparai.cxx
+++ b/xmloff/source/text/txtparai.cxx
@@ -314,10 +314,10 @@ public:
class XMLImpHyperlinkContext_Impl : public SvXMLImportContext
{
- XMLHints_Impl& rHints;
- XMLHyperlinkHint_Impl *pHint;
+ XMLHints_Impl& mrHints;
+ XMLHyperlinkHint_Impl *mpHint;
- sal_Bool& rIgnoreLeadingSpace;
+ sal_Bool& mrbIgnoreLeadingSpace;
public:
@@ -343,71 +343,77 @@ public:
TYPEINIT1( XMLImpHyperlinkContext_Impl, SvXMLImportContext );
XMLImpHyperlinkContext_Impl::XMLImpHyperlinkContext_Impl(
- SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const OUString& rLName,
- const Reference< xml::sax::XAttributeList > & xAttrList,
- XMLHints_Impl& rHnts,
- sal_Bool& rIgnLeadSpace ) :
- SvXMLImportContext( rImport, nPrfx, rLName ),
- rHints( rHnts ),
- pHint( new XMLHyperlinkHint_Impl(
- GetImport().GetTextImport()->GetCursorAsRange()->getStart() ) ),
- rIgnoreLeadingSpace( rIgnLeadSpace )
+ SvXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const OUString& rLName,
+ const Reference< xml::sax::XAttributeList > & xAttrList,
+ XMLHints_Impl& rHnts,
+ sal_Bool& rIgnLeadSpace )
+ : SvXMLImportContext( rImport, nPrfx, rLName )
+ , mrHints( rHnts )
+ , mpHint( new XMLHyperlinkHint_Impl( GetImport().GetTextImport()->GetCursorAsRange()->getStart() ) )
+ , mrbIgnoreLeadingSpace( rIgnLeadSpace )
{
OUString sShow;
- const SvXMLTokenMap& rTokenMap =
- GetImport().GetTextImport()->GetTextHyperlinkAttrTokenMap();
+ const SvXMLTokenMap& rTokenMap = GetImport().GetTextImport()->GetTextHyperlinkAttrTokenMap();
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for( sal_Int16 i=0; i < nAttrCount; i++ )
+ for ( sal_Int16 i = 0; i < nAttrCount; i++ )
{
const OUString& rAttrName = xAttrList->getNameByIndex( i );
const OUString& rValue = xAttrList->getValueByIndex( i );
OUString aLocalName;
- sal_uInt16 nPrefix =
- GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
- &aLocalName );
- switch( rTokenMap.Get( nPrefix, aLocalName ) )
+ const sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName );
+ switch (rTokenMap.Get( nPrefix, aLocalName ))
{
case XML_TOK_TEXT_HYPERLINK_HREF:
- pHint->SetHRef( GetImport().GetAbsoluteReference( rValue ) );
+ mpHint->SetHRef( GetImport().GetAbsoluteReference( rValue ) );
break;
case XML_TOK_TEXT_HYPERLINK_NAME:
- pHint->SetName( rValue );
+ mpHint->SetName( rValue );
break;
case XML_TOK_TEXT_HYPERLINK_TARGET_FRAME:
- pHint->SetTargetFrameName( rValue );
+ mpHint->SetTargetFrameName( rValue );
break;
case XML_TOK_TEXT_HYPERLINK_SHOW:
sShow = rValue;
break;
case XML_TOK_TEXT_HYPERLINK_STYLE_NAME:
- pHint->SetStyleName( rValue );
+ mpHint->SetStyleName( rValue );
break;
case XML_TOK_TEXT_HYPERLINK_VIS_STYLE_NAME:
- pHint->SetVisitedStyleName( rValue );
+ mpHint->SetVisitedStyleName( rValue );
break;
}
}
- if( !sShow.isEmpty() && pHint->GetTargetFrameName().isEmpty() )
+ if( !sShow.isEmpty() && mpHint->GetTargetFrameName().isEmpty() )
{
if( IsXMLToken( sShow, XML_NEW ) )
- pHint->SetTargetFrameName(
+ mpHint->SetTargetFrameName(
OUString( "_blank" ) );
else if( IsXMLToken( sShow, XML_REPLACE ) )
- pHint->SetTargetFrameName(
+ mpHint->SetTargetFrameName(
OUString( "_self" ) );
}
- rHints.push_back( pHint );
+
+ if ( mpHint->GetHRef().isEmpty() )
+ {
+ // hyperlink without an URL is not imported.
+ delete mpHint;
+ mpHint = NULL;
+ }
+ else
+ {
+ mrHints.push_back( mpHint );
+ }
}
XMLImpHyperlinkContext_Impl::~XMLImpHyperlinkContext_Impl()
{
- if( pHint )
- pHint->SetEnd( GetImport().GetTextImport()
+ if( mpHint != NULL )
+ mpHint->SetEnd( GetImport().GetTextImport()
->GetCursorAsRange()->getStart() );
}
@@ -420,7 +426,7 @@ SvXMLImportContext *XMLImpHyperlinkContext_Impl::CreateChildContext(
{
XMLEventsImportContext* pCtxt = new XMLEventsImportContext(
GetImport(), nPrefix, rLocalName);
- pHint->SetEventsContext(pCtxt);
+ mpHint->SetEventsContext(pCtxt);
return pCtxt;
}
else
@@ -431,13 +437,13 @@ SvXMLImportContext *XMLImpHyperlinkContext_Impl::CreateChildContext(
return XMLImpSpanContext_Impl::CreateChildContext(
GetImport(), nPrefix, rLocalName, xAttrList,
- nToken, rHints, rIgnoreLeadingSpace );
+ nToken, mrHints, mrbIgnoreLeadingSpace );
}
}
void XMLImpHyperlinkContext_Impl::Characters( const OUString& rChars )
{
- GetImport().GetTextImport()->InsertString( rChars, rIgnoreLeadingSpace );
+ GetImport().GetTextImport()->InsertString( rChars, mrbIgnoreLeadingSpace );
}
class XMLImpRubyBaseContext_Impl : public SvXMLImportContext
@@ -1600,25 +1606,23 @@ SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext(
// test for HyperLinkURL property. If present, insert link as
// text property (StarWriter), else try to insert as text
// field (StarCalc, StarDraw, ...)
- Reference<beans::XPropertySet> xPropSet(
- rImport.GetTextImport()->GetCursor(),
- UNO_QUERY );
+ Reference< beans::XPropertySet > xPropSet( rImport.GetTextImport()->GetCursor(), UNO_QUERY );
- const OUString sHyperLinkURL(
- "HyperLinkURL");
+ const OUString sHyperLinkURL("HyperLinkURL");
- if (xPropSet->getPropertySetInfo()->hasPropertyByName(sHyperLinkURL))
+ if ( xPropSet->getPropertySetInfo()->hasPropertyByName( sHyperLinkURL ) )
{
- pContext = new XMLImpHyperlinkContext_Impl( rImport, nPrefix,
- rLocalName, xAttrList,
- rHints,
- rIgnoreLeadingSpace );
+ pContext = new XMLImpHyperlinkContext_Impl(
+ rImport,
+ nPrefix,
+ rLocalName,
+ xAttrList,
+ rHints,
+ rIgnoreLeadingSpace );
}
else
{
- pContext = new XMLUrlFieldImportContext( rImport,
- *rImport.GetTextImport().get(),
- nPrefix, rLocalName);
+ pContext = new XMLUrlFieldImportContext( rImport, *rImport.GetTextImport().get(), nPrefix, rLocalName );
//whitespace handling like other fields
rIgnoreLeadingSpace = sal_False;