[Libreoffice-commits] core.git: 9 commits - sw/inc sw/source

Matteo Casalin matteo.casalin at yahoo.com
Sat Oct 5 10:45:12 PDT 2013


 sw/inc/ndgrf.hxx                  |   11 ---
 sw/source/core/doc/docedt.cxx     |   53 +++++++-------
 sw/source/core/graphic/ndgrf.cxx  |  137 ++++++++++++++++++--------------------
 sw/source/filter/xml/xmltexte.cxx |    3 
 sw/source/ui/dochdl/swdtflvr.cxx  |    9 +-
 sw/source/ui/inc/wrtsh.hxx        |    2 
 sw/source/ui/wrtsh/wrtsh3.cxx     |    6 -
 7 files changed, 108 insertions(+), 113 deletions(-)

New commits:
commit 849352c724426c06dea98c9b3df10ef629f04942
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Oct 5 19:41:51 2013 +0200

    Correct prefix for OUString + constify
    
    Change-Id: I4662fa9c63717c57ccfb6bcee685c4d47c715eff

diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 1469568..e569613 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -472,28 +472,28 @@ struct StreamAndStorageNames
     OUString sStorage;
 };
 
-StreamAndStorageNames lcl_GetStreamStorageNames( OUString aUserData )
+StreamAndStorageNames lcl_GetStreamStorageNames( const OUString sUserData )
 {
     StreamAndStorageNames aNames;
-    if( aUserData.isEmpty() )
+    if( sUserData.isEmpty() )
         return aNames;
 
     const OUString aProt( "vnd.sun.star.Package:" );
-    if (aUserData.startsWith(aProt))
+    if (sUserData.startsWith(aProt))
     {
         // 6.0 (XML) Package
-        const sal_Int32 nPos = aUserData.indexOf('/');
+        const sal_Int32 nPos = sUserData.indexOf('/');
         if (nPos<0)
         {
-            aNames.sStream = aUserData.copy(aProt.getLength());
+            aNames.sStream = sUserData.copy(aProt.getLength());
         }
         else
         {
             sal_Int32 nPathStart = aProt.getLength();
-            if (aUserData.startsWith("./"))
+            if (sUserData.startsWith("./"))
                 nPathStart += 2;
-            aNames.sStorage = aUserData.copy( nPathStart, nPos-nPathStart );
-            aNames.sStream = aUserData.copy( nPos+1 );
+            aNames.sStorage = sUserData.copy( nPathStart, nPos-nPathStart );
+            aNames.sStream = sUserData.copy( nPos+1 );
         }
     }
     else
commit 7770eb9bd639312b166a575c2e64c6db5ac5d44b
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Oct 5 17:55:58 2013 +0200

    String to OUString + better names
    
    Change-Id: I811789b9fec38d7745ffffbcb57659aa5e3dc59f

diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index d99c1cd..d41364a 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -104,7 +104,7 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode
     */
     SvStream* _GetStreamForEmbedGrf(
             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _refPics,
-            const String& rStrmName ) const;
+            const OUString& rStreamName ) const;
 
     /** helper method to get a substorage of the document storage for readonly access.
 
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 439d992..1469568 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -870,37 +870,36 @@ uno::Reference< embed::XStorage > SwGrfNode::_GetDocSubstorageOrRoot( const Stri
 */
 SvStream* SwGrfNode::_GetStreamForEmbedGrf(
             const uno::Reference< embed::XStorage >& _refPics,
-            const String& rStrmName ) const
+            const OUString& rStreamName ) const
 {
     SvStream* pStrm( 0L );
 
-    if( _refPics.is() && rStrmName.Len() )
+    if( _refPics.is() && !rStreamName.isEmpty() )
     {
-        String _aStrmName(rStrmName);
+        OUString sStreamName(rStreamName);
         // If stream doesn't exist in the storage, try access the graphic file by
         // re-generating its name.
         // A save action can have changed the filename of the embedded graphic,
         // because a changed unique ID of the graphic is calculated.
         // --> recursive calls of <GetUniqueID()> have to be avoided.
         // Thus, use local static boolean to assure this.
-        if ( !_refPics->hasByName( _aStrmName ) ||
-               !_refPics->isStreamElement( _aStrmName ) )
+        if ( !_refPics->hasByName( sStreamName ) ||
+             !_refPics->isStreamElement( sStreamName ) )
         {
-            xub_StrLen nExtPos = _aStrmName.Search( '.' );
-            String aExtStr = _aStrmName.Copy( nExtPos );
             if ( GetGrfObj().GetType() != GRAPHIC_NONE )
             {
-                _aStrmName = OStringToOUString(GetGrfObj().GetUniqueID(),
-                    RTL_TEXTENCODING_ASCII_US);
-                _aStrmName += aExtStr;
+                const sal_Int32 nExtPos = sStreamName.indexOf('.');
+                const OUString aExtStr = (nExtPos>=0) ? sStreamName.copy( nExtPos ) : OUString();
+                sStreamName = OStringToOUString(GetGrfObj().GetUniqueID(),
+                    RTL_TEXTENCODING_ASCII_US) + aExtStr;
             }
         }
 
         // assure that graphic file exist in the storage.
-        if ( _refPics->hasByName( _aStrmName ) &&
-             _refPics->isStreamElement( _aStrmName ) )
+        if ( _refPics->hasByName( sStreamName ) &&
+             _refPics->isStreamElement( sStreamName ) )
         {
-            uno::Reference < io::XStream > refStrm = _refPics->openStreamElement( _aStrmName, embed::ElementModes::READ );
+            uno::Reference < io::XStream > refStrm = _refPics->openStreamElement( sStreamName, embed::ElementModes::READ );
             pStrm = utl::UcbStreamHelper::CreateStream( refStrm );
         }
         else
commit f37bb5d4426948cacc6928d501de01844adbc8f1
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Oct 5 16:58:37 2013 +0200

    String to OUString + use return instead of reference args
    
    Change-Id: I0c0857b4b4ac87586675e8540ef5135dbce82b5c

diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index c35d084..439d992 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -466,40 +466,42 @@ sal_Bool SwGrfNode::ImportGraphic( SvStream& rStrm )
 namespace
 {
 
-void lcl_GetStreamStorageNames( String aUserData,
-                                String& rStrmName,
-                                String& rStorName )
+struct StreamAndStorageNames
 {
-    rStorName.Erase();
-    rStrmName.Erase();
+    OUString sStream;
+    OUString sStorage;
+};
 
-    if( !aUserData.Len() )
-        return;
+StreamAndStorageNames lcl_GetStreamStorageNames( OUString aUserData )
+{
+    StreamAndStorageNames aNames;
+    if( aUserData.isEmpty() )
+        return aNames;
 
-    String aProt( "vnd.sun.star.Package:" );
-    if( 0 == aUserData.CompareTo( aProt, aProt.Len() ) )
+    const OUString aProt( "vnd.sun.star.Package:" );
+    if (aUserData.startsWith(aProt))
     {
         // 6.0 (XML) Package
-        xub_StrLen nPos = aUserData.Search( '/' );
-        if( STRING_NOTFOUND == nPos )
+        const sal_Int32 nPos = aUserData.indexOf('/');
+        if (nPos<0)
         {
-            rStrmName = aUserData.Copy( aProt.Len() );
+            aNames.sStream = aUserData.copy(aProt.getLength());
         }
         else
         {
-            xub_StrLen nPathStart = aProt.Len();
-            if( 0 == aUserData.CompareToAscii( "./", 2 ) )
+            sal_Int32 nPathStart = aProt.getLength();
+            if (aUserData.startsWith("./"))
                 nPathStart += 2;
-            rStorName = aUserData.Copy( nPathStart, nPos-nPathStart );
-            rStrmName = aUserData.Copy( nPos+1 );
+            aNames.sStorage = aUserData.copy( nPathStart, nPos-nPathStart );
+            aNames.sStream = aUserData.copy( nPos+1 );
         }
     }
     else
     {
         OSL_FAIL( "<lcl_GetStreamStorageNames(..)> - unknown graphic URL type. Code for handling 3.1 - 5.2 storages has been deleted by issue i53025." );
     }
-    OSL_ENSURE( STRING_NOTFOUND == rStrmName.Search( '/' ),
-            "invalid graphic stream name" );
+    OSL_ENSURE( aNames.sStream.indexOf('/')<0, "invalid graphic stream name" );
+    return aNames;
 }
 
 }
@@ -554,10 +556,9 @@ short SwGrfNode::SwapIn( sal_Bool bWaitForData )
         {
             try
             {
-                String aStrmName, aPicStgName;
-                lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName );
-                uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
-                SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
+                const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
+                uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aNames.sStorage );
+                SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aNames.sStream );
                 if ( pStrm )
                 {
                     if ( ImportGraphic( *pStrm ) )
@@ -816,12 +817,11 @@ void SwGrfNode::DelStreamName()
         {
             try
             {
-                String aPicStgName, aStrmName;
-                lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName );
+                const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
                 uno::Reference < embed::XStorage > refPics = xDocStg;
-                if ( aPicStgName.Len() )
-                    refPics = xDocStg->openStorageElement( aPicStgName, embed::ElementModes::READWRITE );
-                refPics->removeElement( aStrmName );
+                if ( !aNames.sStorage.isEmpty() )
+                    refPics = xDocStg->openStorageElement( aNames.sStorage, embed::ElementModes::READWRITE );
+                refPics->removeElement( aNames.sStream );
                 uno::Reference < embed::XTransactedObject > xTrans( refPics, uno::UNO_QUERY );
                 if ( xTrans.is() )
                     xTrans->commit();
@@ -923,10 +923,9 @@ SwCntntNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
     {
         try
         {
-            String aStrmName, aPicStgName;
-            lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName );
-            uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
-            SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
+            const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
+            uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aNames.sStorage );
+            SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aNames.sStream );
             if ( pStrm )
             {
                 const OUString aURL(maGrfObj.GetUserData());
@@ -1003,10 +1002,9 @@ IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj )
         {
             try
             {
-                String aStrmName, aPicStgName;
-                lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName );
-                uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
-                SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
+                const StreamAndStorageNames aNames = lcl_GetStreamStorageNames( maGrfObj.GetUserData() );
+                uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aNames.sStorage );
+                SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aNames.sStream );
                 if ( pStrm )
                 {
                     if( pGrfObj->IsInSwapOut() )
commit 74c7539c091a9b6781eae7d3f07d45546499d3b6
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Oct 5 16:45:34 2013 +0200

    This reference argument can be const
    
    Change-Id: I4d8d23d34aa72a0101bc18e98983ea8840806462

diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index 6d34a19..d99c1cd 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -95,7 +95,7 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode
         input parameter - reference to storage, which should contain the
         embedded graphic stream.
 
-        @param _aStrmName
+        @param rStrmName
         input parameter - proposed name of the embedded graphic stream.
 
         @return SvStream*
@@ -104,7 +104,7 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode
     */
     SvStream* _GetStreamForEmbedGrf(
             const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& _refPics,
-            String& _aStrmName ) const;
+            const String& rStrmName ) const;
 
     /** helper method to get a substorage of the document storage for readonly access.
 
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 8dc05fa..c35d084 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -870,12 +870,13 @@ uno::Reference< embed::XStorage > SwGrfNode::_GetDocSubstorageOrRoot( const Stri
 */
 SvStream* SwGrfNode::_GetStreamForEmbedGrf(
             const uno::Reference< embed::XStorage >& _refPics,
-            String& _aStrmName ) const
+            const String& rStrmName ) const
 {
     SvStream* pStrm( 0L );
 
-    if( _refPics.is() && _aStrmName.Len() )
+    if( _refPics.is() && rStrmName.Len() )
     {
+        String _aStrmName(rStrmName);
         // If stream doesn't exist in the storage, try access the graphic file by
         // re-generating its name.
         // A save action can have changed the filename of the embedded graphic,
commit c0afcc0f0777ec76c1c04611f528741271b58227
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Oct 5 15:14:07 2013 +0200

    This does not need to be a member function
    
    Change-Id: I4d008ac516c66243d436a3afe3322ba1b6c9ef22

diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index 5d01aaf..6d34a19 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -78,10 +78,6 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode
     /** adjust return type and rename method to
        indicate that its an private one. */
 
-    /** embedded graphic stream couldn't be inside a 3.1 - 5.2 storage any more.
-       Thus, return value isn't needed any more. */
-    void _GetStreamStorageNames( String& rStrmName, String& rStgName ) const;
-
     void DelStreamName();
     DECL_LINK( SwapGraphic, GraphicObject* );
 
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index e2df34b..8dc05fa 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -463,6 +463,47 @@ sal_Bool SwGrfNode::ImportGraphic( SvStream& rStrm )
     return sal_False;
 }
 
+namespace
+{
+
+void lcl_GetStreamStorageNames( String aUserData,
+                                String& rStrmName,
+                                String& rStorName )
+{
+    rStorName.Erase();
+    rStrmName.Erase();
+
+    if( !aUserData.Len() )
+        return;
+
+    String aProt( "vnd.sun.star.Package:" );
+    if( 0 == aUserData.CompareTo( aProt, aProt.Len() ) )
+    {
+        // 6.0 (XML) Package
+        xub_StrLen nPos = aUserData.Search( '/' );
+        if( STRING_NOTFOUND == nPos )
+        {
+            rStrmName = aUserData.Copy( aProt.Len() );
+        }
+        else
+        {
+            xub_StrLen nPathStart = aProt.Len();
+            if( 0 == aUserData.CompareToAscii( "./", 2 ) )
+                nPathStart += 2;
+            rStorName = aUserData.Copy( nPathStart, nPos-nPathStart );
+            rStrmName = aUserData.Copy( nPos+1 );
+        }
+    }
+    else
+    {
+        OSL_FAIL( "<lcl_GetStreamStorageNames(..)> - unknown graphic URL type. Code for handling 3.1 - 5.2 storages has been deleted by issue i53025." );
+    }
+    OSL_ENSURE( STRING_NOTFOUND == rStrmName.Search( '/' ),
+            "invalid graphic stream name" );
+}
+
+}
+
 /**
  * @return -1 if ReRead successful,
  *          1 if reading successful,
@@ -514,7 +555,7 @@ short SwGrfNode::SwapIn( sal_Bool bWaitForData )
             try
             {
                 String aStrmName, aPicStgName;
-                _GetStreamStorageNames( aStrmName, aPicStgName );
+                lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName );
                 uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
                 SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
                 if ( pStrm )
@@ -776,7 +817,7 @@ void SwGrfNode::DelStreamName()
             try
             {
                 String aPicStgName, aStrmName;
-                _GetStreamStorageNames( aStrmName, aPicStgName );
+                lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName );
                 uno::Reference < embed::XStorage > refPics = xDocStg;
                 if ( aPicStgName.Len() )
                     refPics = xDocStg->openStorageElement( aPicStgName, embed::ElementModes::READWRITE );
@@ -870,42 +911,6 @@ SvStream* SwGrfNode::_GetStreamForEmbedGrf(
     return pStrm;
 }
 
-void SwGrfNode::_GetStreamStorageNames( String& rStrmName,
-                                        String& rStorName ) const
-{
-    rStorName.Erase();
-    rStrmName.Erase();
-
-    String aUserData( maGrfObj.GetUserData() );
-    if( !aUserData.Len() )
-        return;
-
-    String aProt( "vnd.sun.star.Package:" );
-    if( 0 == aUserData.CompareTo( aProt, aProt.Len() ) )
-    {
-        // 6.0 (XML) Package
-        xub_StrLen nPos = aUserData.Search( '/' );
-        if( STRING_NOTFOUND == nPos )
-        {
-            rStrmName = aUserData.Copy( aProt.Len() );
-        }
-        else
-        {
-            xub_StrLen nPathStart = aProt.Len();
-            if( 0 == aUserData.CompareToAscii( "./", 2 ) )
-                nPathStart += 2;
-            rStorName = aUserData.Copy( nPathStart, nPos-nPathStart );
-            rStrmName = aUserData.Copy( nPos+1 );
-        }
-    }
-    else
-    {
-        OSL_FAIL( "<SwGrfNode::_GetStreamStorageNames(..)> - unknown graphic URL type. Code for handling 3.1 - 5.2 storages has been deleted by issue i53025." );
-    }
-    OSL_ENSURE( STRING_NOTFOUND == rStrmName.Search( '/' ),
-            "invalid graphic stream name" );
-}
-
 SwCntntNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
 {
     // copy formats into the other document
@@ -918,7 +923,7 @@ SwCntntNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
         try
         {
             String aStrmName, aPicStgName;
-            _GetStreamStorageNames( aStrmName, aPicStgName );
+            lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName );
             uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
             SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
             if ( pStrm )
@@ -998,7 +1003,7 @@ IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj )
             try
             {
                 String aStrmName, aPicStgName;
-                _GetStreamStorageNames( aStrmName, aPicStgName );
+                lcl_GetStreamStorageNames( maGrfObj.GetUserData(), aStrmName, aPicStgName );
                 uno::Reference < embed::XStorage > refPics = _GetDocSubstorageOrRoot( aPicStgName );
                 SvStream* pStrm = _GetStreamForEmbedGrf( refPics, aStrmName );
                 if ( pStrm )
commit 4106979a1d37c98b6ea93d134521fde9bb788956
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Oct 5 14:02:53 2013 +0200

    Unused data member and setter
    
    Change-Id: Ib11213ecad715948793f0b608ebb99d22fbc3152

diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index c839abb..5d01aaf 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -41,8 +41,6 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTxtNode
     GraphicObject *mpReplacementGraphic;
     ::sfx2::SvBaseLinkRef refLink;       ///< If graphics only as link then pointer is set.
     Size nGrfSize;
-    String aNewStrmName;                 /**< SW3/XML: new stream name (either SW3 stream
-                                         // name or package url) */
     String aLowResGrf;                   ///< HTML: LowRes graphics (substitute until regular HighRes graphics is loaded).
     sal_Bool bTransparentFlagValid  :1;
     sal_Bool bInSwapIn              :1;
@@ -181,7 +179,6 @@ public:
     short SwapOut();
     /// Access to storage stream-name.
     void SetStreamName( const String& r ) { maGrfObj.SetUserData( r ); }
-    void SetNewStreamName( const String& r ) { aNewStrmName = r; }
     /// Is this node selected by any shell?
     sal_Bool IsSelected() const;
 
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 67200ac..e2df34b 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -880,10 +880,6 @@ void SwGrfNode::_GetStreamStorageNames( String& rStrmName,
     if( !aUserData.Len() )
         return;
 
-    if (aNewStrmName.Len()>0) {
-        aUserData=aNewStrmName;
-    }
-
     String aProt( "vnd.sun.star.Package:" );
     if( 0 == aUserData.CompareTo( aProt, aProt.Len() ) )
     {
diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx
index fcc1373..e9aac07 100644
--- a/sw/source/filter/xml/xmltexte.cxx
+++ b/sw/source/filter/xml/xmltexte.cxx
@@ -208,9 +208,6 @@ void SwXMLTextParagraphExport::setTextEmbeddedGraphicURL(
         String aNewURL( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.Package:") );
         aNewURL += String(rURL);
 
-// This is nonsensical.
-//        pGrfNd->SetNewStreamName( aNewURL );
-
         // #i15411# save-as will swap all graphics in; we need to swap
         // them out again, to prevent excessive memory use
         pGrfNd->SwapOut();
commit b0caeafc1add0b52b3d7a9dc80f50080ba439f59
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Oct 5 12:31:55 2013 +0200

    Bail out early and minor optimizations
    
    Change-Id: Iec521a951e53386fc2bd780926d4a372e5fb05bc

diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index a082cb1..9175145 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -2124,7 +2124,6 @@ uno::Reference< XHyphenatedWord >  SwDoc::Hyphenate(
 
 static bool lcl_GetTokenToParaBreak( OUString& rStr, OUString& rRet, bool bRegExpRplc )
 {
-    bool bRet = false;
     if( bRegExpRplc )
     {
         sal_Int32 nPos = 0;
@@ -2139,24 +2138,23 @@ static bool lcl_GetTokenToParaBreak( OUString& rStr, OUString& rRet, bool bRegEx
             // Has this been escaped?
             if( nPos && '\\' == rStr[nPos-1])
             {
-                if( ++nPos >= rStr.getLength() )
+                nPos += sPara.getLength();
+                if( nPos >= rStr.getLength() )
+                {
                     break;
+                }
             }
             else
             {
                 rRet = rStr.copy( 0, nPos );
                 rStr = rStr.copy( nPos + sPara.getLength() );
-                bRet = true;
-                break;
+                return true;
             }
         }
     }
-    if( !bRet )
-    {
-        rRet = rStr;
-        rStr = OUString();
-    }
-    return bRet;
+    rRet = rStr;
+    rStr = OUString();
+    return false;
 }
 
 bool SwDoc::ReplaceRange( SwPaM& rPam, const OUString& rStr,
commit d72c7903d8748017955f8f3b0a19ab0f96532e53
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Oct 5 12:19:40 2013 +0200

    String to OUString
    
    Change-Id: Ib7f355f68fe79ebfebb83fb5d2b72f4070153610

diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index c8aaaad..a082cb1 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -2122,25 +2122,30 @@ uno::Reference< XHyphenatedWord >  SwDoc::Hyphenate(
     return aHyphArg.GetHyphWord();  // will be set by lcl_HyphenateNode
 }
 
-static bool lcl_GetTokenToParaBreak( String& rStr, String& rRet, bool bRegExpRplc )
+static bool lcl_GetTokenToParaBreak( OUString& rStr, OUString& rRet, bool bRegExpRplc )
 {
     bool bRet = false;
     if( bRegExpRplc )
     {
-        xub_StrLen nPos = 0;
-        OUString sPara("\\n");
-        while( STRING_NOTFOUND != ( nPos = rStr.Search( sPara, nPos )) )
+        sal_Int32 nPos = 0;
+        const OUString sPara("\\n");
+        for (;;)
         {
+            nPos = rStr.indexOf( sPara, nPos );
+            if (nPos<0)
+            {
+                break;
+            }
             // Has this been escaped?
-            if( nPos && '\\' == rStr.GetChar( nPos-1 ))
+            if( nPos && '\\' == rStr[nPos-1])
             {
-                if( ++nPos >= rStr.Len() )
+                if( ++nPos >= rStr.getLength() )
                     break;
             }
             else
             {
-                rRet = rStr.Copy( 0, nPos );
-                rStr.Erase( 0, nPos + sPara.getLength() );
+                rRet = rStr.copy( 0, nPos );
+                rStr = rStr.copy( nPos + sPara.getLength() );
                 bRet = true;
                 break;
             }
@@ -2149,7 +2154,7 @@ static bool lcl_GetTokenToParaBreak( String& rStr, String& rRet, bool bRegExpRpl
     if( !bRet )
     {
         rRet = rStr;
-        rStr.Erase();
+        rStr = OUString();
     }
     return bRet;
 }
@@ -2257,7 +2262,7 @@ bool SwDoc::ReplaceRangeImpl( SwPaM& rPam, const String& rStr,
         sal_Bool bOneNode = pStt->nNode == pEnd->nNode;
 
         // Own Undo?
-        String sRepl( rStr );
+        OUString sRepl( rStr );
         SwTxtNode* pTxtNd = pStt->nNode.GetNode().GetTxtNode();
         xub_StrLen nStt = pStt->nContent.GetIndex(),
                 nEnd = bOneNode ? pEnd->nContent.GetIndex()
@@ -2289,7 +2294,7 @@ bool SwDoc::ReplaceRangeImpl( SwPaM& rPam, const String& rStr,
                 nStt = pStt->nContent.GetIndex();
             }
 
-            if( sRepl.Len() )
+            if( !sRepl.isEmpty() )
             {
                 // Apply the first character's attributes to the ReplaceText
                 SfxItemSet aSet( GetAttrPool(),
@@ -2313,7 +2318,7 @@ bool SwDoc::ReplaceRangeImpl( SwPaM& rPam, const String& rStr,
                 xub_StrLen nPtCnt = aDelPam.GetPoint()->nContent.GetIndex();
 
                 bool bFirst = true;
-                String sIns;
+                OUString sIns;
                 while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) )
                 {
                     InsertString( aDelPam, sIns );
@@ -2333,7 +2338,7 @@ bool SwDoc::ReplaceRangeImpl( SwPaM& rPam, const String& rStr,
                     else
                         SplitNode( *aDelPam.GetPoint(), false );
                 }
-                if( sIns.Len() )
+                if( !sIns.isEmpty() )
                 {
                     InsertString( aDelPam, sIns );
                 }
@@ -2410,14 +2415,14 @@ SetRedlineMode( eOld );
                             : pTxtNd->GetTxt().getLength();
 
             bool bFirst = true;
-            String sIns;
+            OUString sIns;
             while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) )
             {
                 if (!bFirst || nStt == pTxtNd->GetTxt().getLength())
                 {
                     InsertString( aDelPam, sIns );
                 }
-                else if( nStt < nEnd || sIns.Len() )
+                else if( nStt < nEnd || !sIns.isEmpty() )
                 {
                     pTxtNd->ReplaceText( pStt->nContent, nEnd - nStt, sIns );
                 }
@@ -2425,13 +2430,13 @@ SetRedlineMode( eOld );
                 bFirst = false;
             }
 
-            if( bFirst || sIns.Len() )
+            if( bFirst || !sIns.isEmpty() )
             {
                 if (!bFirst || nStt == pTxtNd->GetTxt().getLength())
                 {
                     InsertString( aDelPam, sIns );
                 }
-                else if( nStt < nEnd || sIns.Len() )
+                else if( nStt < nEnd || !sIns.isEmpty() )
                 {
                     pTxtNd->ReplaceText( pStt->nContent, nEnd - nStt, sIns );
                 }
commit 2c5e78f90eb8f584a3bff15b5abc6bac099f156e
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Fri Oct 4 22:03:44 2013 +0200

    String to OUString
    
    Change-Id: I08064ad6f919b99ce5536eaef36b38523cf82610

diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx
index 4bcdfd6..fbb6d49 100644
--- a/sw/source/ui/dochdl/swdtflvr.cxx
+++ b/sw/source/ui/dochdl/swdtflvr.cxx
@@ -423,7 +423,8 @@ sal_Bool SwTransferable::GetData( const DataFlavor& rFlavor )
                 pOrigGrf = pClpBitmap;
 
             // is it an URL-Button ?
-            String sURL, sDesc;
+            OUString sURL;
+            OUString sDesc;
             if( pWrtShell->GetURLFromButton( sURL, sDesc ) )
             {
                 pBkmk = new INetBookmark( sURL, sDesc );
@@ -923,7 +924,8 @@ int SwTransferable::PrepareForCopy( sal_Bool bIsCut )
                 pOrigGrf = pClpBitmap;
 
             // is it an URL-Button ?
-            String sURL, sDesc;
+            OUString sURL;
+            OUString sDesc;
             if( pWrtShell->GetURLFromButton( sURL, sDesc ) )
             {
                 AddFormat( FORMAT_STRING );
@@ -3010,7 +3012,8 @@ void SwTransferable::SetDataForDragAndDrop( const Point& rSttPos )
                 pOrigGrf = pClpBitmap;
 
             // is it an URL-Button ?
-            String sURL, sDesc;
+            OUString sURL;
+            OUString sDesc;
             if( pWrtShell->GetURLFromButton( sURL, sDesc ) )
             {
                 AddFormat( FORMAT_STRING );
diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx
index ca6895e..d9d446a 100644
--- a/sw/source/ui/inc/wrtsh.hxx
+++ b/sw/source/ui/inc/wrtsh.hxx
@@ -428,7 +428,7 @@ typedef sal_Bool (SwWrtShell:: *FNSimpleMove)();
     inline bool IsInClickToEdit() const ;
 
     // if a URL-Button is selected, return its URL; otherwise an empty string
-    bool GetURLFromButton( String& rURL, String& rDescr ) const;
+    bool GetURLFromButton( OUString& rURL, OUString& rDescr ) const;
 
     void NavigatorPaste( const NaviContentBookmark& rBkmk,
                          const sal_uInt16 nAction );
diff --git a/sw/source/ui/wrtsh/wrtsh3.cxx b/sw/source/ui/wrtsh/wrtsh3.cxx
index d8b8bbf..eeb46b0 100644
--- a/sw/source/ui/wrtsh/wrtsh3.cxx
+++ b/sw/source/ui/wrtsh/wrtsh3.cxx
@@ -169,7 +169,7 @@ sal_uInt16 SwWrtShell::CallEvent( sal_uInt16 nEvent, const SwCallMouseEvent& rCa
 
     // If a util::URL-Button is selected, return its util::URL
     // otherwise an emtpy string.
-bool SwWrtShell::GetURLFromButton( String& rURL, String& rDescr ) const
+bool SwWrtShell::GetURLFromButton( OUString& rURL, OUString& rDescr ) const
 {
     bool bRet = false;
     const SdrView *pDView = GetDrawView();
@@ -207,14 +207,14 @@ bool SwWrtShell::GetURLFromButton( String& rURL, String& rDescr ) const
                         OUString uTmp;
                         if( (aTmp >>= uTmp) && !uTmp.isEmpty())
                         {
-                            rDescr = String(uTmp);
+                            rDescr = uTmp;
                         }
 
                         // util::URL
                         aTmp = xPropSet->getPropertyValue( "TargetURL" );
                         if( (aTmp >>= uTmp) && !uTmp.isEmpty())
                         {
-                            rURL = String(uTmp);
+                            rURL = uTmp;
                         }
                         bRet = true;
                     }


More information about the Libreoffice-commits mailing list