Author: orw
Date: Tue Jan 14 13:10:51 2014
New Revision: 1558026

URL: http://svn.apache.org/r1558026
Log:
123457: improve ODF filter - suppress import and export of hyperlinks without 
an URL


Modified:
    openoffice/trunk/main/xmloff/inc/xmloff/txtparae.hxx
    openoffice/trunk/main/xmloff/inc/xmloff/xmlexp.hxx
    openoffice/trunk/main/xmloff/source/core/xmlexp.cxx
    openoffice/trunk/main/xmloff/source/text/txtimp.cxx
    openoffice/trunk/main/xmloff/source/text/txtparae.cxx
    openoffice/trunk/main/xmloff/source/text/txtparai.cxx

Modified: openoffice/trunk/main/xmloff/inc/xmloff/txtparae.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/xmloff/inc/xmloff/txtparae.hxx?rev=1558026&r1=1558025&r2=1558026&view=diff
==============================================================================
--- openoffice/trunk/main/xmloff/inc/xmloff/txtparae.hxx (original)
+++ openoffice/trunk/main/xmloff/inc/xmloff/txtparae.hxx Tue Jan 14 13:10:51 
2014
@@ -107,13 +107,21 @@ class XMLOFF_DLLPUBLIC XMLTextParagraphE
        ::rtl::OUString                         sOpenRubyCharStyle;
        sal_Bool                                        bOpenRuby;
 
-    // --> OD 2008-05-07 #refactorlists#
     XMLTextListsHelper* mpTextListsHelper;
     ::std::vector< XMLTextListsHelper* > maTextListsHelperStack;
-    // <--
 
        enum FrameType { FT_TEXT, FT_GRAPHIC, FT_EMBEDDED, FT_SHAPE };
 
+
+    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 ::rtl::OUString& sStyle,
+            sal_Bool& rPrevCharIsSpace );
+
 protected:
 
        const ::rtl::OUString sActualSize;

Modified: openoffice/trunk/main/xmloff/inc/xmloff/xmlexp.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/xmloff/inc/xmloff/xmlexp.hxx?rev=1558026&r1=1558025&r2=1558026&view=diff
==============================================================================
--- openoffice/trunk/main/xmloff/inc/xmloff/xmlexp.hxx (original)
+++ openoffice/trunk/main/xmloff/inc/xmloff/xmlexp.hxx Tue Jan 14 13:10:51 2014
@@ -684,14 +684,16 @@ inline void SvXMLExport::SetGraphicResol
 // Helper class to export an element.
 class XMLOFF_DLLPUBLIC SvXMLElementExport
 {
-       SvXMLExport& rExport;
-       ::rtl::OUString aName;
-       sal_Bool bIgnWS : 1;
-       sal_Bool bDoSomething : 1;
-
-       SAL_DLLPRIVATE void StartElement( SvXMLExport& rExp, sal_uInt16 nPrefix,
-                                          const ::rtl::OUString& rName,
-                                          sal_Bool bIgnWSOutside );
+    SvXMLExport& mrExport;
+    ::rtl::OUString maElementName;
+    const sal_Bool mbIgnoreWhitespaceInside :1;
+    const sal_Bool mbDoSomething :1;
+
+    SAL_DLLPRIVATE
+    void StartElement(
+        const sal_uInt16 nPrefix,
+        const ::rtl::OUString& rName,
+        const sal_Bool bIgnoreWhitespaceOutside );
 
 public:
 

Modified: openoffice/trunk/main/xmloff/source/core/xmlexp.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/xmloff/source/core/xmlexp.cxx?rev=1558026&r1=1558025&r2=1558026&view=diff
==============================================================================
--- openoffice/trunk/main/xmloff/source/core/xmlexp.cxx (original)
+++ openoffice/trunk/main/xmloff/source/core/xmlexp.cxx Tue Jan 14 13:10:51 2014
@@ -2627,12 +2627,10 @@ SvXMLExport::AddAttributesRDFa(
     mpImpl->mpRDFaHelper->AddRDFa(xMeta);
 }
 
-// --> OD 2008-11-26 #158694#
 sal_Bool SvXMLExport::exportTextNumberElement() const
 {
     return mpImpl->mbExportTextNumberElement;
 }
-// <--
 
 sal_Bool SvXMLExport::SetNullDateOnUnitConverter()
 {
@@ -2643,116 +2641,132 @@ sal_Bool SvXMLExport::SetNullDateOnUnitC
     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,
-                                                                               
const sal_Char *pLName,
-                                                                               
sal_Bool bIWSOutside,
-                                                                               
sal_Bool bIWSInside ) :
-       rExport( rExp ),
-       bIgnWS( bIWSInside ),
-       bDoSomething( bDoSth )
-{
-       if( bDoSomething )
-       {
-               OUString sLName( OUString::createFromAscii(pLName) );
-               StartElement( rExp, nPrefixKey, sLName, bIWSOutside );
-       }
-}
-
-SvXMLElementExport::SvXMLElementExport( SvXMLExport& rExp,
-                                                                               
sal_Bool bDoSth,
-                                                                               
sal_uInt16 nPrefixKey,
-                                                                               
const OUString& rLName,
-                                                                               
sal_Bool bIWSOutside,
-                                                                               
sal_Bool bIWSInside ) :
-       rExport( rExp ),
-       bIgnWS( bIWSInside ),
-       bDoSomething( bDoSth )
-{
-       if( bDoSomething )
-               StartElement( rExp, nPrefixKey, rLName, 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 )
+
+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,
+    const sal_Char *pLName,
+    sal_Bool bIWSOutside,
+    sal_Bool bIWSInside )
+    : mrExport( rExp )
+    , maElementName()
+    , mbIgnoreWhitespaceInside( bIWSInside )
+    , mbDoSomething( bDoSth )
+{
+    if ( mbDoSomething )
+    {
+        const OUString sLName( OUString::createFromAscii( pLName ) );
+        StartElement( nPrefixKey, sLName, bIWSOutside );
+    }
+}
+
+SvXMLElementExport::SvXMLElementExport(
+    SvXMLExport& rExp,
+    sal_Bool bDoSth,
+    sal_uInt16 nPrefixKey,
+    const OUString& rLName,
+    sal_Bool bIWSOutside,
+    sal_Bool bIWSInside )
+    : mrExport( rExp )
+    , maElementName()
+    , mbIgnoreWhitespaceInside( bIWSInside )
+    , mbDoSomething( bDoSth )
+{
+    if ( mbDoSomething )
+        StartElement( nPrefixKey, rLName, 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 )
 {
-    aName = rQName;
+    maElementName = rQName;
     rExp.StartElement( rQName, bIWSOutside );
 }
 
 SvXMLElementExport::~SvXMLElementExport()
 {
-       if( bDoSomething )
-       {
-        rExport.EndElement( aName, bIgnWS );
-       }
+    if ( mbDoSomething )
+    {
+        mrExport.EndElement( maElementName, mbIgnoreWhitespaceInside );
+    }
 }
 

Modified: openoffice/trunk/main/xmloff/source/text/txtimp.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/xmloff/source/text/txtimp.cxx?rev=1558026&r1=1558025&r2=1558026&view=diff
==============================================================================
--- openoffice/trunk/main/xmloff/source/text/txtimp.cxx (original)
+++ openoffice/trunk/main/xmloff/source/text/txtimp.cxx Tue Jan 14 13:10:51 2014
@@ -2125,7 +2125,8 @@ void XMLTextImportHelper::SetOutlineStyl
                         {
                             if (!lcl_HasListStyle(
                                     m_pImpl->m_pOutlineStylesCandidates[i][j],
-                                    m_pImpl->m_xParaStyles, GetXMLImport(),
+                                    m_pImpl->m_xParaStyles,
+                                    GetXMLImport(),
                                     s_NumberingStyleName,
                                     sOutlineStyleName))
                             {

Modified: openoffice/trunk/main/xmloff/source/text/txtparae.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/xmloff/source/text/txtparae.cxx?rev=1558026&r1=1558025&r2=1558026&view=diff
==============================================================================
--- openoffice/trunk/main/xmloff/source/text/txtparae.cxx (original)
+++ openoffice/trunk/main/xmloff/source/text/txtparae.cxx Tue Jan 14 13:10:51 
2014
@@ -3147,202 +3147,84 @@ void XMLTextParagraphExport::setTextEmbe
 }
 
 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;
-       sal_Bool bServerMap = sal_False;
+    sal_Bool bExport = sal_False;
+    OUString sHRef, sName, sTargetFrame, sUStyleName, sVStyleName;
+    sal_Bool bServerMap = sal_False;
 
-/*    bool bHyperLinkURL = false;
-    bool bHyperLinkName = false;
-    bool bHyperLinkTarget = false;
-    bool bServer = false;
-    bool bUnvisitedCharStyleName = false;
-    bool bVisitedCharStyleName = false;
-
-    const Reference< XMultiPropertySet > xMultiPropertySet( rPropSet, 
UNO_QUERY );
-    if ( xMultiPropertySet.is() )
-    {
-    sal_uInt32 nCount = 0;
-    Sequence< OUString > aPropertyNames( 6 );
-       OUString* pArray = aPropertyNames.getArray();
-
-    if ( rPropSetInfo->hasPropertyByName( sServerMap ) )
+    if ( rPropSetInfo->hasPropertyByName( sHyperLinkURL )
+         && ( !rPropState.is()
+              || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( 
sHyperLinkURL ) ) )
     {
-        bServer = true;
-        pArray[ nCount++ ] = sServerMap;
+        rPropSet->getPropertyValue( sHyperLinkURL ) >>= sHRef;
+        if ( !sHRef.isEmpty() )
+            bExport = sal_True;
     }
-    if ( rPropSetInfo->hasPropertyByName( sHyperLinkName ) )
+    if ( sHRef.isEmpty() )
     {
-        bHyperLinkName = true;
-        pArray[ nCount++ ] = sHyperLinkName;
+        // 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( sHyperLinkTarget ) )
+
+
+    if ( rPropSetInfo->hasPropertyByName( sHyperLinkName )
+         && ( !rPropState.is()
+              || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( 
sHyperLinkName ) ) )
     {
-        bHyperLinkTarget = true;
-        pArray[ nCount++ ] = sHyperLinkTarget;
+        rPropSet->getPropertyValue( sHyperLinkName ) >>= sName;
+        if ( !sName.isEmpty() )
+            bExport = sal_True;
     }
-    if ( rPropSetInfo->hasPropertyByName( sHyperLinkURL ) )
+
+    if ( rPropSetInfo->hasPropertyByName( sHyperLinkTarget )
+         && ( !rPropState.is()
+              || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( 
sHyperLinkTarget ) ) )
     {
-        bHyperLinkURL = true;
-        pArray[ nCount++ ] = sHyperLinkURL;
+        rPropSet->getPropertyValue( sHyperLinkTarget ) >>= sTargetFrame;
+        if ( !sTargetFrame.isEmpty() )
+            bExport = sal_True;
     }
-    if ( rPropSetInfo->hasPropertyByName( sUnvisitedCharStyleName ) )
+
+    if ( rPropSetInfo->hasPropertyByName( sServerMap )
+         && ( !rPropState.is()
+              || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( 
sServerMap ) ) )
     {
-        bUnvisitedCharStyleName = true;
-        pArray[ nCount++ ] = sUnvisitedCharStyleName;
+        bServerMap = *(sal_Bool *) rPropSet->getPropertyValue( sServerMap 
).getValue();
+        if ( bServerMap )
+            bExport = sal_True;
     }
-    if ( rPropSetInfo->hasPropertyByName( sVisitedCharStyleName ) )
+
+    if ( rPropSetInfo->hasPropertyByName( sUnvisitedCharStyleName )
+         && ( !rPropState.is()
+              || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( 
sUnvisitedCharStyleName ) ) )
     {
-        bVisitedCharStyleName = true;
-        pArray[ nCount++ ] = sVisitedCharStyleName;
+        rPropSet->getPropertyValue( sUnvisitedCharStyleName ) >>= sUStyleName;
+        if ( !sUStyleName.isEmpty() )
+            bExport = sal_True;
     }
 
-    aPropertyNames.realloc( nCount );
-
-    if ( nCount )
+    if ( rPropSetInfo->hasPropertyByName( sVisitedCharStyleName )
+         && ( !rPropState.is()
+              || PropertyState_DIRECT_VALUE == rPropState->getPropertyState( 
sVisitedCharStyleName ) ) )
     {
-        Sequence< PropertyState > aPropertyStates( nCount );
-       PropertyState* pStateArray = aPropertyStates.getArray();
-
-        if ( rPropState.is() )
-            aPropertyStates = rPropState->getPropertyStates( aPropertyNames );
-
-        Sequence< Any > aPropertyValues ( 
xMultiPropertySet->getPropertyValues( aPropertyNames ) );
-        Any* pValueArray = aPropertyValues.getArray();
-
-        sal_uInt32 nIdx = 0;
-
-        if ( bServer )
-        {
-            if ( !rPropState.is() || PropertyState_DIRECT_VALUE == 
pStateArray[ nIdx ] )
-            {
-                bServerMap = *(sal_Bool *)pValueArray[ nIdx ].getValue();
-                       if( bServerMap  )
-                               bExport = sal_True;
-            }
-            ++nIdx;
-        }
-        if ( bHyperLinkName )
-        {
-            if ( !rPropState.is() || PropertyState_DIRECT_VALUE == 
pStateArray[ nIdx ] )
-            {
-                pValueArray[ nIdx ] >>= sName;
-                       if( sName.getLength() > 0 )
-                               bExport = sal_True;
-            }
-            ++nIdx;
-        }
-        if ( bHyperLinkTarget )
-        {
-            if ( !rPropState.is() || PropertyState_DIRECT_VALUE == 
pStateArray[ nIdx ] )
-            {
-                pValueArray[ nIdx ] >>= sTargetFrame;
-                       if( sTargetFrame.getLength() )
-                               bExport = sal_True;
-            }
-            ++nIdx;
-        }
-        if ( bHyperLinkURL )
-        {
-            if ( !rPropState.is() || PropertyState_DIRECT_VALUE == 
pStateArray[ nIdx ] )
-            {
-                pValueArray[ nIdx ] >>= sHRef;
-                       if( sHRef.getLength() > 0 )
-                               bExport = sal_True;
-            }
-            ++nIdx;
-        }
-        if ( bUnvisitedCharStyleName )
-        {
-            if ( !rPropState.is() || PropertyState_DIRECT_VALUE == 
pStateArray[ nIdx ] )
-            {
-                pValueArray[ nIdx ] >>= sUStyleName;
-                       if( sUStyleName.getLength() )
-                               bExport = sal_True;
-            }
-            ++nIdx;
-        }
-        if ( bVisitedCharStyleName )
-        {
-            if ( !rPropState.is() || PropertyState_DIRECT_VALUE == 
pStateArray[ nIdx ] )
-            {
-                pValueArray[ nIdx ] >>= sVStyleName;
-                       if( sVStyleName.getLength() )
-                               bExport = sal_True;
-            }
-            ++nIdx;
-        }
-    }
+        rPropSet->getPropertyValue( sVisitedCharStyleName ) >>= sVStyleName;
+        if ( !sVStyleName.isEmpty() )
+            bExport = sal_True;
     }
-    else
-    {*/
-       if( rPropSetInfo->hasPropertyByName( sHyperLinkURL ) &&
-               ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
-                                       rPropState->getPropertyState( 
sHyperLinkURL ) ) )
-       {
-               rPropSet->getPropertyValue( sHyperLinkURL ) >>= sHRef;
-
-               if( sHRef.getLength() > 0 )
-                       bExport = sal_True;
-       }
-
-       if( rPropSetInfo->hasPropertyByName( sHyperLinkName ) &&
-               ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
-                                       rPropState->getPropertyState( 
sHyperLinkName ) ) )
-       {
-               rPropSet->getPropertyValue( sHyperLinkName ) >>= sName;
-               if( sName.getLength() > 0 )
-                       bExport = sal_True;
-       }
-
-       if( rPropSetInfo->hasPropertyByName( sHyperLinkTarget ) &&
-               ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
-                                       rPropState->getPropertyState( 
sHyperLinkTarget ) ) )
-       {
-               rPropSet->getPropertyValue( sHyperLinkTarget ) >>= sTargetFrame;
-               if( sTargetFrame.getLength() )
-                       bExport = sal_True;
-       }
-
-       if( rPropSetInfo->hasPropertyByName( sServerMap ) &&
-               ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
-                                       rPropState->getPropertyState( 
sServerMap ) ) )
-       {
-               bServerMap = *(sal_Bool *)rPropSet->getPropertyValue( 
sServerMap ).getValue();
-               if( bServerMap  )
-                       bExport = sal_True;
-       }
-
-       if( rPropSetInfo->hasPropertyByName( sUnvisitedCharStyleName ) &&
-               ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
-                       rPropState->getPropertyState( sUnvisitedCharStyleName ) 
) )
-       {
-               rPropSet->getPropertyValue( sUnvisitedCharStyleName ) >>= 
sUStyleName;
-               if( sUStyleName.getLength() )
-                       bExport = sal_True;
-       }
-
-       if( rPropSetInfo->hasPropertyByName( sVisitedCharStyleName ) &&
-               ( !rPropState.is() || PropertyState_DIRECT_VALUE ==
-                       rPropState->getPropertyState( sVisitedCharStyleName ) ) 
)
-       {
-               rPropSet->getPropertyValue( sVisitedCharStyleName ) >>= 
sVStyleName;
-               if( sVStyleName.getLength() )
-                       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 ) );
 
-               if( sName.getLength() > 0 )
+               if( !sName.isEmpty() )
                        GetExport().AddAttribute( XML_NAMESPACE_OFFICE, 
XML_NAME, sName );
 
-               if( sTargetFrame.getLength() )
+               if( !sTargetFrame.isEmpty() )
                {
                        GetExport().AddAttribute( XML_NAMESPACE_OFFICE,
                                                                          
XML_TARGET_FRAME_NAME, sTargetFrame );
@@ -3356,11 +3238,11 @@ sal_Bool XMLTextParagraphExport::addHype
                        GetExport().AddAttribute( XML_NAMESPACE_OFFICE,
                                       XML_SERVER_MAP, XML_TRUE );
 
-               if( sUStyleName.getLength() )
+               if( !sUStyleName.isEmpty() )
                        GetExport().AddAttribute( XML_NAMESPACE_TEXT,
                          XML_STYLE_NAME, GetExport().EncodeStyleName( 
sUStyleName ) );
 
-               if( sVStyleName.getLength() )
+               if( !sVStyleName.isEmpty() )
                        GetExport().AddAttribute( XML_NAMESPACE_TEXT,
                          XML_VISITED_STYLE_NAME, GetExport().EncodeStyleName( 
sVStyleName ) );
        }
@@ -3368,66 +3250,79 @@ sal_Bool XMLTextParagraphExport::addHype
        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,
+    sal_Bool& rPrevCharIsSpace )
+{
+    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() );
+        exportText( aText, rPrevCharIsSpace );
+    }
+}
+
 void XMLTextParagraphExport::exportTextRange(
-               const Reference < XTextRange > & rTextRange,
-               sal_Bool bAutoStyles,
-               sal_Bool& rPrevCharIsSpace )
+        const Reference< XTextRange > & rTextRange,
+        sal_Bool bAutoStyles,
+        sal_Bool& rPrevCharIsSpace )
 {
-       Reference < XPropertySet > xPropSet( rTextRange, UNO_QUERY );
-       if( bAutoStyles )
-       {
-               Add( XML_STYLE_FAMILY_TEXT_TEXT, xPropSet );
-       }
-       else
-       {
-               sal_Bool bHyperlink = sal_False;
+    Reference< XPropertySet > xPropSet( rTextRange, UNO_QUERY );
+    if ( bAutoStyles )
+    {
+        Add( XML_STYLE_FAMILY_TEXT_TEXT, xPropSet );
+    }
+    else
+    {
+        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 )
-               {
-                       Reference< XPropertyState > xPropState( xPropSet, 
UNO_QUERY );
-                       xPropSetInfo.set(xPropSet->getPropertySetInfo());
-                       bHyperlink = addHyperlinkAttributes( xPropSet, 
xPropState, xPropSetInfo );
-               }
-               SvXMLElementExport aElem( GetExport(), bHyperlink, 
XML_NAMESPACE_TEXT,
-                                                                 XML_A, 
sal_False, sal_False );
-               if( bHyperlink )
-               {
-                       // export events (if supported)
-                       OUString sHyperLinkEvents(RTL_CONSTASCII_USTRINGPARAM(
-                               "HyperLinkEvents"));
-                       if (xPropSetInfo->hasPropertyByName(sHyperLinkEvents))
-                       {
-                Reference<XNameReplace> 
xName(xPropSet->getPropertyValue(sHyperLinkEvents), uno::UNO_QUERY);
-                               GetExport().GetEventExport().Export(xName, 
sal_False);
-                       }
-               }
+        sal_Bool bHyperlinkAttrsAdded = sal_False;
+        if ( bHyperlink )
+        {
+            Reference< XPropertyState > xPropState( xPropSet, UNO_QUERY );
+            xPropSetInfo.set( xPropSet->getPropertySetInfo() );
+            bHyperlinkAttrsAdded = addHyperlinkAttributes( xPropSet, 
xPropState, xPropSetInfo );
+        }
 
-               {
-                       XMLTextCharStyleNamesElementExport aCharStylesExport(
-                               GetExport(), bIsUICharStyle &&
-                                                        
aCharStyleNamesPropInfoCache.hasProperty(
-                                                    xPropSet, xPropSetInfo ), 
bHasAutoStyle,
-                               xPropSet, sCharStyleNames );
-
-                       OUString aText(rTextRange->getString());
-                       if( sStyle.getLength() )
-                               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.getLength() > 0,
-                                                                               
  XML_NAMESPACE_TEXT, XML_SPAN, sal_False,
-                                                                               
  sal_False );
-                               exportText( aText, rPrevCharIsSpace );
-                       }
-               }
-       }
+        if ( bHyperlink && bHyperlinkAttrsAdded )
+        {
+            SvXMLElementExport aElem( GetExport(), sal_True, 
XML_NAMESPACE_TEXT, XML_A, sal_False, sal_False );
+
+            // export events (if supported)
+            static const OUString sHyperLinkEvents( 
RTL_CONSTASCII_USTRINGPARAM( "HyperLinkEvents" ) );
+            if ( xPropSetInfo->hasPropertyByName( sHyperLinkEvents ) )
+            {
+                Reference< XNameReplace > xName( xPropSet->getPropertyValue( 
sHyperLinkEvents ), uno::UNO_QUERY );
+                GetExport().GetEventExport().Export( xName, sal_False );
+            }
+
+            exportTextRangeSpan( rTextRange, xPropSet, xPropSetInfo, 
bIsUICharStyle, bHasAutoStyle, sStyle, rPrevCharIsSpace );
+        }
+        else
+        {
+            exportTextRangeSpan( rTextRange, xPropSet, xPropSetInfo, 
bIsUICharStyle, bHasAutoStyle, sStyle, rPrevCharIsSpace );
+        }
+    }
 }
 
 void XMLTextParagraphExport::exportText( const OUString& rText,

Modified: openoffice/trunk/main/xmloff/source/text/txtparai.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/xmloff/source/text/txtparai.cxx?rev=1558026&r1=1558025&r2=1558026&view=diff
==============================================================================
--- openoffice/trunk/main/xmloff/source/text/txtparai.cxx (original)
+++ openoffice/trunk/main/xmloff/source/text/txtparai.cxx Tue Jan 14 13:10:51 
2014
@@ -338,10 +338,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:
 
@@ -367,71 +367,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();
+    OUString sShow;
+    const SvXMLTokenMap& rTokenMap = 
GetImport().GetTextImport()->GetTextHyperlinkAttrTokenMap();
 
-       sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
-       for( sal_Int16 i=0; i < nAttrCount; i++ )
-       {
-               const OUString& rAttrName = xAttrList->getNameByIndex( i );
-               const OUString& rValue = xAttrList->getValueByIndex( i );
+    sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+    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 ) )
-               {
-               case XML_TOK_TEXT_HYPERLINK_HREF:
-                       pHint->SetHRef( GetImport().GetAbsoluteReference( 
rValue ) );
-                       break;
-               case XML_TOK_TEXT_HYPERLINK_NAME:
-                       pHint->SetName( rValue );
-                       break;
-               case XML_TOK_TEXT_HYPERLINK_TARGET_FRAME:
-                       pHint->SetTargetFrameName( rValue );
-                       break;
-               case XML_TOK_TEXT_HYPERLINK_SHOW:
-                       sShow = rValue;
-                       break;
-               case XML_TOK_TEXT_HYPERLINK_STYLE_NAME:
-                       pHint->SetStyleName( rValue );
-                       break;
-               case XML_TOK_TEXT_HYPERLINK_VIS_STYLE_NAME:
-                       pHint->SetVisitedStyleName( rValue );
-                       break;
-               }
-       }
+        OUString aLocalName;
+        const sal_uInt16 nPrefix = 
GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName );
+        switch (rTokenMap.Get( nPrefix, aLocalName ))
+        {
+        case XML_TOK_TEXT_HYPERLINK_HREF:
+            mpHint->SetHRef( GetImport().GetAbsoluteReference( rValue ) );
+            break;
+        case XML_TOK_TEXT_HYPERLINK_NAME:
+            mpHint->SetName( rValue );
+            break;
+        case XML_TOK_TEXT_HYPERLINK_TARGET_FRAME:
+            mpHint->SetTargetFrameName( rValue );
+            break;
+        case XML_TOK_TEXT_HYPERLINK_SHOW:
+            sShow = rValue;
+            break;
+        case XML_TOK_TEXT_HYPERLINK_STYLE_NAME:
+            mpHint->SetStyleName( rValue );
+            break;
+        case XML_TOK_TEXT_HYPERLINK_VIS_STYLE_NAME:
+            mpHint->SetVisitedStyleName( rValue );
+            break;
+        }
+    }
 
-       if( sShow.getLength() && !pHint->GetTargetFrameName().getLength() )
+       if( sShow.getLength() && !mpHint->GetTargetFrameName().getLength() )
        {
                if( IsXMLToken( sShow, XML_NEW ) )
-                       pHint->SetTargetFrameName(
+                       mpHint->SetTargetFrameName(
                                        OUString( 
RTL_CONSTASCII_USTRINGPARAM("_blank" ) ) );
                else if( IsXMLToken( sShow, XML_REPLACE ) )
-                       pHint->SetTargetFrameName(
+                       mpHint->SetTargetFrameName(
                                        OUString( 
RTL_CONSTASCII_USTRINGPARAM("_self" ) ) );
        }
-       rHints.Insert( pHint, rHints.Count() );
+
+    if ( mpHint->GetHRef().isEmpty() )
+    {
+        // hyperlink without an URL is not imported.
+        delete mpHint;
+        mpHint = NULL;
+    }
+    else
+    {
+        mrHints.Insert( mpHint, mrHints.Count() );
+    }
 }
 
 XMLImpHyperlinkContext_Impl::~XMLImpHyperlinkContext_Impl()
 {
-       if( pHint )
-               pHint->SetEnd( GetImport().GetTextImport()
+       if( mpHint != NULL )
+               mpHint->SetEnd( GetImport().GetTextImport()
                                                        
->GetCursorAsRange()->getStart() );
 }
 
@@ -444,7 +450,7 @@ SvXMLImportContext *XMLImpHyperlinkConte
        {
                XMLEventsImportContext* pCtxt = new XMLEventsImportContext(
                        GetImport(), nPrefix, rLocalName);
-               pHint->SetEventsContext(pCtxt);
+               mpHint->SetEventsContext(pCtxt);
                return pCtxt;
        }
        else
@@ -455,13 +461,13 @@ SvXMLImportContext *XMLImpHyperlinkConte
 
                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 );
 }
 
 // ---------------------------------------------------------------------
@@ -1651,36 +1657,34 @@ SvXMLImportContext *XMLImpSpanContext_Im
                                                                                
           0x0020, sal_True );
                break;
 
-       case XML_TOK_TEXT_HYPERLINK:
-       {
-               // 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 );
-
-               const OUString sHyperLinkURL(
-                       RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL"));
-
-               if 
(xPropSet->getPropertySetInfo()->hasPropertyByName(sHyperLinkURL))
-               {
-                       pContext = new XMLImpHyperlinkContext_Impl( rImport, 
nPrefix,
-                                                                               
                                rLocalName, xAttrList,
-                                                                               
                                rHints,
-                                                                               
                                rIgnoreLeadingSpace );
-               }
-               else
-               {
-                       pContext = new XMLUrlFieldImportContext( rImport,
-                                                                               
          *rImport.GetTextImport().get(),
-                                                                               
                         nPrefix, rLocalName);
-                       //whitespace handling like other fields
-                       rIgnoreLeadingSpace = sal_False;
+    case XML_TOK_TEXT_HYPERLINK:
+    {
+        // 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 );
 
-               }
-               break;
-       }
+        static const OUString sHyperLinkURL( RTL_CONSTASCII_USTRINGPARAM( 
"HyperLinkURL" ) );
+
+        if ( xPropSet->getPropertySetInfo()->hasPropertyByName( sHyperLinkURL 
) )
+        {
+            pContext = new XMLImpHyperlinkContext_Impl(
+                    rImport,
+                    nPrefix,
+                    rLocalName,
+                    xAttrList,
+                    rHints,
+                    rIgnoreLeadingSpace );
+        }
+        else
+        {
+            pContext = new XMLUrlFieldImportContext( rImport, 
*rImport.GetTextImport().get(), nPrefix, rLocalName );
+            //whitespace handling like other fields
+            rIgnoreLeadingSpace = sal_False;
+
+        }
+        break;
+    }
 
        case XML_TOK_TEXT_RUBY:
                pContext = new XMLImpRubyContext_Impl( rImport, nPrefix,


Reply via email to