[Libreoffice-commits] core.git: 11 commits - sfx2/source

Markus Mohrhard markus.mohrhard at googlemail.com
Wed Apr 3 14:28:42 PDT 2013


 sfx2/source/appl/newhelp.cxx   |   74 ++++++++++++++-------------------
 sfx2/source/appl/sfxhelp.cxx   |   40 +++++-------------
 sfx2/source/bastyp/helper.cxx  |   91 +++++++++--------------------------------
 sfx2/source/dialog/dinfdlg.cxx |   26 ++++-------
 sfx2/source/inc/helper.hxx     |   16 +++----
 5 files changed, 83 insertions(+), 164 deletions(-)

New commits:
commit e9516eb4335ec9db3cee6ce2468c880403386f08
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 3 23:26:15 2013 +0200

    limit scope of the variable
    
    Change-Id: Ic6001ca66e85cdeb4c797aaab1138c27b9e17c67

diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 87d62cf..297e356 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -683,7 +683,6 @@ sal_Bool SfxHelp::Start_Impl(const OUString& rURL, const Window* pWindow, const
     OUString aHelpURL;
     INetURLObject aParser( rURL );
     INetProtocol nProtocol = aParser.GetProtocol();
-    OUString aHelpModuleName( GetHelpModuleName_Impl() );
 
     switch ( nProtocol )
     {
@@ -693,6 +692,7 @@ sal_Bool SfxHelp::Start_Impl(const OUString& rURL, const Window* pWindow, const
             break;
         default:
         {
+            OUString aHelpModuleName( GetHelpModuleName_Impl() );
             // no URL, just a HelpID (maybe empty in case of keyword search)
             aHelpURL = CreateHelpURL_Impl( rURL, aHelpModuleName );
 
commit 5a7dbd4d8bcc4ac86ef6e6ca4534b279e81a4355
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 3 23:12:24 2013 +0200

    maybe a bit over-engineered
    
    Change-Id: Ia7a491241ad78cafc542e63b3796b7c32fa5300c

diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index a2a7445..87d62cf 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -216,18 +216,9 @@ public:
 
 static Sequence< OUString > GetPropertyNames()
 {
-    static const char* aPropNames[] =
-    {
-        "HelpAgentStarterList",
-    };
-
-    const int nCount = sizeof( aPropNames ) / sizeof( const char* );
-    Sequence< OUString > aNames( nCount );
+    Sequence< OUString > aNames( 1 );
     OUString* pNames = aNames.getArray();
-    OUString* pEnd   = pNames + aNames.getLength();
-    int i = 0;
-    for ( ; pNames != pEnd; ++pNames )
-        *pNames = OUString::createFromAscii( aPropNames[i++] );
+    pNames[0] = OUString( "HelpAgentStarterList" );
 
     return aNames;
 }
commit 8948dfdb693c7565a02f3fe1f235fb6c7d3ddc44
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 3 23:08:58 2013 +0200

    screen space is a valuable good, don't waste it
    
    Change-Id: I67d47ef4030ce60d1cbc160a52cad7cc3c417b34

diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 4538ce4..a2a7445 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -206,12 +206,12 @@ private:
     std::set < OString > m_aIds;
 
 public:
-                    SfxHelpOptions_Impl();
-                    ~SfxHelpOptions_Impl();
+    SfxHelpOptions_Impl();
+    ~SfxHelpOptions_Impl();
 
-    bool            HasId( const OString& rId ) { return m_aIds.size() ? m_aIds.find( rId ) != m_aIds.end() : false; }
-    virtual void            Notify( const com::sun::star::uno::Sequence< OUString >& aPropertyNames );
-    virtual void            Commit();
+    bool HasId( const OString& rId ) { return m_aIds.size() ? m_aIds.find( rId ) != m_aIds.end() : false; }
+    virtual void Notify( const com::sun::star::uno::Sequence< OUString >& aPropertyNames );
+    virtual void Commit();
 };
 
 static Sequence< OUString > GetPropertyNames()
@@ -298,7 +298,7 @@ void SfxHelpOptions_Impl::Commit()
 class SfxHelp_Impl
 {
 private:
-    SfxHelpOptions_Impl*                m_pOpt;         // the options
+    SfxHelpOptions_Impl* m_pOpt; // the options
 
 public:
     SfxHelp_Impl();
@@ -309,9 +309,7 @@ public:
 };
 
 SfxHelp_Impl::SfxHelp_Impl() :
-
-    m_pOpt          ( NULL )
-
+    m_pOpt ( NULL )
 {
 }
 
@@ -342,10 +340,8 @@ SfxHelpOptions_Impl* SfxHelp_Impl::GetOptions()
 }
 
 SfxHelp::SfxHelp() :
-
     bIsDebug( sal_False ),
     pImp    ( NULL )
-
 {
     // read the environment variable "HELP_DEBUG"
     // if it's set, you will see debug output on active help
commit 677b125ae3f14d823ebdddf04d22cf879a3cfd4f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 3 23:04:39 2013 +0200

    this variable was unused
    
    Change-Id: I7ea23acbaebb02def5d7875bc07fb7c10b2af883

diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 0517b65b..4538ce4 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -299,7 +299,6 @@ class SfxHelp_Impl
 {
 private:
     SfxHelpOptions_Impl*                m_pOpt;         // the options
-    ::std::vector< OUString >    m_aModulesList; // list of all installed modules
 
 public:
     SfxHelp_Impl();
commit 4290f249be1642c63a958e3f7873b56f47ae5a5b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 3 23:00:51 2013 +0200

    more clean-up around SfxContentHelper
    
    Change-Id: I836a260d0e7c8b61cf4b6b6c378da854ca188a22

diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index 8f2378b..052c706 100644
--- a/sfx2/source/appl/newhelp.cxx
+++ b/sfx2/source/appl/newhelp.cxx
@@ -104,6 +104,8 @@
 #include <sfx2/objsh.hxx>
 #include <sfx2/docfac.hxx>
 
+#include <vector>
+
 using namespace ::ucbhelper;
 using namespace ::com::sun::star::ucb;
 
@@ -309,21 +311,18 @@ ContentListBox_Impl::~ContentListBox_Impl()
 
 void ContentListBox_Impl::InitRoot()
 {
-    String aHelpTreeviewURL( "vnd.sun.star.hier://com.sun.star.help.TreeView/" );
-    ::com::sun::star::uno::Sequence< ::rtl::OUString > aList =
+    OUString aHelpTreeviewURL( "vnd.sun.star.hier://com.sun.star.help.TreeView/" );
+    std::vector< OUString > aList =
         SfxContentHelper::GetHelpTreeViewContents( aHelpTreeviewURL );
 
-    const ::rtl::OUString* pEntries  = aList.getConstArray();
-    sal_uInt32 i, nCount = aList.getLength();
-    for ( i = 0; i < nCount; ++i )
+    for(size_t i = 0, n = aList.size(); i < n; ++i )
     {
-        String aRow( pEntries[i] );
-        String aTitle, aURL;
+        const OUString& aRow = aList[i];
         sal_Int32 nIdx = 0;
-        aTitle = aRow.GetToken( 0, '\t', nIdx );
-        aURL = aRow.GetToken( 0, '\t', nIdx );
-        sal_Unicode cFolder = aRow.GetToken( 0, '\t', nIdx ).GetChar(0);
-        sal_Bool bIsFolder = ( '1' == cFolder );
+        OUString aTitle = aRow.getToken( 0, '\t', nIdx );
+        OUString aURL = aRow.getToken( 0, '\t', nIdx );
+        sal_Unicode cFolder = aRow.getToken( 0, '\t', nIdx )[0];
+        bool bIsFolder = ( '1' == cFolder );
         SvTreeListEntry* pEntry = InsertEntry( aTitle, aOpenBookImage, aClosedBookImage, NULL, sal_True );
         if ( bIsFolder )
             pEntry->SetUserData( new ContentEntry_Impl( aURL, sal_True ) );
@@ -354,20 +353,17 @@ void ContentListBox_Impl::RequestingChildren( SvTreeListEntry* pParent )
             if ( pParent->GetUserData() )
             {
                 String aTmpURL( ( (ContentEntry_Impl*)pParent->GetUserData()  )->aURL );
-                ::com::sun::star::uno::Sequence< ::rtl::OUString > aList =
+                std::vector<OUString > aList =
                     SfxContentHelper::GetHelpTreeViewContents( aTmpURL );
 
-                const ::rtl::OUString* pEntries  = aList.getConstArray();
-                sal_uInt32 i, nCount = aList.getLength();
-                for ( i = 0; i < nCount; ++i )
+                for (size_t i = 0,n = aList.size(); i < n; ++i )
                 {
-                    String aRow( pEntries[i] );
-                    String aTitle, aURL;
+                    const OUString& aRow = aList[i];
                     sal_Int32 nIdx = 0;
-                    aTitle = aRow.GetToken( 0, '\t', nIdx );
-                    aURL = aRow.GetToken( 0, '\t', nIdx );
-                    sal_Unicode cFolder = aRow.GetToken( 0, '\t', nIdx ).GetChar(0);
-                    sal_Bool bIsFolder = ( '1' == cFolder );
+                    OUString aTitle = aRow.getToken( 0, '\t', nIdx );
+                    OUString aURL = aRow.getToken( 0, '\t', nIdx );
+                    sal_Unicode cFolder = aRow.getToken( 0, '\t', nIdx )[0];
+                    bool bIsFolder = ( '1' == cFolder );
                     SvTreeListEntry* pEntry = NULL;
                     if ( bIsFolder )
                     {
@@ -379,7 +375,7 @@ void ContentListBox_Impl::RequestingChildren( SvTreeListEntry* pParent )
                         pEntry = InsertEntry( aTitle, aDocumentImage, aDocumentImage, pParent );
                         Any aAny( ::utl::UCBContentHelper::GetProperty( aURL, String("TargetURL"  ) ) );
                         rtl::OUString aTargetURL;
-                        if ( aAny >>=  aTargetURL )
+                        if ( aAny >>= aTargetURL )
                             pEntry->SetUserData( new ContentEntry_Impl( aTargetURL, sal_False ) );
                     }
                 }
@@ -1074,23 +1070,20 @@ IMPL_LINK_NOARG(SearchTabPage_Impl, SearchHdl)
         AppendConfigToken(aSearchURL, sal_False);
         if ( aScopeCB.IsChecked() )
             aSearchURL.append("&Scope=Heading");
-        Sequence< OUString > aFactories = SfxContentHelper::GetResultSet(aSearchURL.makeStringAndClear());
-        const OUString* pFacs  = aFactories.getConstArray();
-        sal_uInt32 i, nCount = aFactories.getLength();
-        for ( i = 0; i < nCount; ++i )
+        std::vector< OUString > aFactories = SfxContentHelper::GetResultSet(aSearchURL.makeStringAndClear());
+        for (size_t i = 0, n = aFactories.size(); i < n; ++i )
         {
-            String aRow( pFacs[i] );
-            String aTitle, aType;
+            const OUString& rRow = aFactories[i];
             sal_Int32 nIdx = 0;
-            aTitle = aRow.GetToken( 0, '\t', nIdx );
-            aType = aRow.GetToken( 0, '\t', nIdx );
-            String* pURL = new String( aRow.GetToken( 0, '\t', nIdx ) );
+            OUString aTitle = rRow.getToken( 0, '\t', nIdx );
+            nIdx = 0;
+            String* pURL = new String( rRow.getToken( 2, '\t', nIdx ) );
             sal_uInt16 nPos = aResultsLB.InsertEntry( aTitle );
             aResultsLB.SetEntryData( nPos, (void*)(sal_uIntPtr)pURL );
         }
         LeaveWait();
 
-        if ( !nCount )
+        if ( aFactories.empty() )
         {
             InfoBox aBox( this, SfxResId( RID_INFO_NOSEARCHRESULTS ) );
             aBox.SetText( SfxResId( STR_HELP_WINDOW_TITLE ).toString() );
@@ -1593,23 +1586,20 @@ void SfxHelpIndexWindow_Impl::Initialize()
 {
     OUStringBuffer aHelpURL(HELP_URL);
     AppendConfigToken(aHelpURL, sal_True);
-    Sequence< ::rtl::OUString > aFactories = SfxContentHelper::GetResultSet(aHelpURL.makeStringAndClear());
-    const ::rtl::OUString* pFacs  = aFactories.getConstArray();
-    sal_uInt32 i, nCount = aFactories.getLength();
-    for ( i = 0; i < nCount; ++i )
+    std::vector<OUString> aFactories = SfxContentHelper::GetResultSet(aHelpURL.makeStringAndClear());
+    for (size_t i = 0, n = aFactories.size(); i < n; ++i )
     {
-        String aRow( pFacs[i] );
-        String aTitle, aType, aURL;
+        const OUString& rRow = aFactories[i];
         sal_Int32 nIdx = 0;
-        aTitle = aRow.GetToken( 0, '\t', nIdx );
-        aType = aRow.GetToken( 0, '\t', nIdx );
-        aURL = aRow.GetToken( 0, '\t', nIdx );
+        OUString aTitle = rRow.getToken( 0, '\t', nIdx );
+        nIdx = 0;
+        OUString aURL = rRow.getToken( 2, '\t', nIdx );
         String* pFactory = new String( INetURLObject( aURL ).GetHost() );
         sal_uInt16 nPos = aActiveLB.InsertEntry( aTitle );
         aActiveLB.SetEntryData( nPos, (void*)(sal_uIntPtr)pFactory );
     }
 
-    aActiveLB.SetDropDownLineCount( (sal_uInt16)nCount );
+    aActiveLB.SetDropDownLineCount( (sal_uInt16)aFactories.size() );
     if ( aActiveLB.GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND )
         SetActiveFactory();
 }
diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index 7a8ec78..0517b65b 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -639,9 +639,9 @@ static bool impl_hasHelpInstalled( const OUString &rLang = OUString() )
 {
     OUStringBuffer aHelpRootURL("vnd.sun.star.help://");
     AppendConfigToken(aHelpRootURL, sal_True, rLang);
-    Sequence< OUString > aFactories = SfxContentHelper::GetResultSet(aHelpRootURL.makeStringAndClear());
+    std::vector< OUString > aFactories = SfxContentHelper::GetResultSet(aHelpRootURL.makeStringAndClear());
 
-    return ( aFactories.getLength() != 0   );
+    return !aFactories.empty();
 }
 
 sal_Bool SfxHelp::SearchKeyword( const OUString& rKeyword )
@@ -681,7 +681,7 @@ sal_Bool SfxHelp::Start_Impl(const OUString& rURL, const Window* pWindow, const
 {
     OUStringBuffer aHelpRootURL("vnd.sun.star.help://");
     AppendConfigToken(aHelpRootURL, sal_True);
-    Sequence< OUString > aFactories = SfxContentHelper::GetResultSet(aHelpRootURL.makeStringAndClear());
+    SfxContentHelper::GetResultSet(aHelpRootURL.makeStringAndClear());
 
     /* rURL may be
         - a "real" URL
diff --git a/sfx2/source/bastyp/helper.cxx b/sfx2/source/bastyp/helper.cxx
index 6cc9c0f..444dda9 100644
--- a/sfx2/source/bastyp/helper.cxx
+++ b/sfx2/source/bastyp/helper.cxx
@@ -54,8 +54,6 @@ using namespace osl;
 
 using ::std::vector;
 
-using ::rtl::OUString;
-using ::rtl::OStringBuffer;
 using ::rtl::OStringToOUString;
 
 namespace {
@@ -70,7 +68,7 @@ DateTime convertDateTime( const util::DateTime& rUnoDT )
 
 // -----------------------------------------------------------------------
 
-uno::Sequence < OUString > SfxContentHelper::GetResultSet( const String& rURL )
+std::vector<OUString> SfxContentHelper::GetResultSet( const OUString& rURL )
 {
     vector<OUString> aList;
     try
@@ -134,19 +132,12 @@ uno::Sequence < OUString > SfxContentHelper::GetResultSet( const String& rURL )
         SAL_WARN( "sfx2.bastyp", "GetResultSet: Any other exception: " << e.Message );
     }
 
-    size_t nCount = aList.size();
-    uno::Sequence < OUString > aRet( nCount );
-    OUString* pRet = aRet.getArray();
-    for ( size_t i = 0; i < nCount; ++i )
-    {
-        pRet[i] = aList[0];
-    }
-    return aRet;
+    return aList;
 }
 
 // -----------------------------------------------------------------------
 
-uno::Sequence< OUString > SfxContentHelper::GetHelpTreeViewContents( const String& rURL )
+std::vector< OUString > SfxContentHelper::GetHelpTreeViewContents( const OUString& rURL )
 {
     vector< OUString > aProperties;
     try
@@ -207,14 +198,7 @@ uno::Sequence< OUString > SfxContentHelper::GetHelpTreeViewContents( const Strin
     {
     }
 
-    size_t nCount = aProperties.size();
-    uno::Sequence < OUString > aRet( nCount );
-    OUString* pRet = aRet.getArray();
-    for(size_t i = 0; i < nCount; ++i)
-    {
-        pRet[i] = aProperties[i];
-    }
-    return aRet;
+    return aProperties;
 }
 
 // -----------------------------------------------------------------------
@@ -273,7 +257,7 @@ bool SfxContentHelper::IsHelpErrorDocument( const OUString& rURL )
 
 // -----------------------------------------------------------------------
 
-sal_Int64 SfxContentHelper::GetSize( const String& rContent )
+sal_Int64 SfxContentHelper::GetSize( const OUString& rContent )
 {
     sal_Int64 nSize = 0;
     INetURLObject aObj( rContent );
diff --git a/sfx2/source/inc/helper.hxx b/sfx2/source/inc/helper.hxx
index 5e20e22..31b32a6 100644
--- a/sfx2/source/inc/helper.hxx
+++ b/sfx2/source/inc/helper.hxx
@@ -25,19 +25,19 @@
 #include <tools/string.hxx>
 #include <tools/errcode.hxx>
 
+#include <vector>
+
 // class SfxContentHelper ------------------------------------------------
 
 class SfxContentHelper
 {
 public:
-    static ::com::sun::star::uno::Sequence< ::rtl::OUString >
-                                GetResultSet( const String& rURL );
-    static ::com::sun::star::uno::Sequence< ::rtl::OUString >
-                                GetHelpTreeViewContents( const String& rURL );
+    static std::vector< OUString > GetResultSet( const OUString& rURL );
+    static std::vector< OUString > GetHelpTreeViewContents( const OUString& rURL );
     static OUString GetActiveHelpString( const OUString& rURL );
     static bool IsHelpErrorDocument( const OUString& rURL );
 
-    static sal_Int64 GetSize( const String& rContent );
+    static sal_Int64 GetSize( const OUString& rContent );
 };
 
 #endif // #ifndef _SFX_HELPER_HXX
commit f2e19cc800025a9361bbea7d6b435ff649b09528
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 3 22:16:17 2013 +0200

    sal_Bool -> bool
    
    Change-Id: I1225c972d806301ef5bd295b2b42145a8b2e7145

diff --git a/sfx2/source/bastyp/helper.cxx b/sfx2/source/bastyp/helper.cxx
index 4ee9d44..6cc9c0f 100644
--- a/sfx2/source/bastyp/helper.cxx
+++ b/sfx2/source/bastyp/helper.cxx
@@ -251,9 +251,9 @@ OUString SfxContentHelper::GetActiveHelpString( const OUString& rURL )
 
 // -----------------------------------------------------------------------
 
-sal_Bool SfxContentHelper::IsHelpErrorDocument( const OUString& rURL )
+bool SfxContentHelper::IsHelpErrorDocument( const OUString& rURL )
 {
-    sal_Bool bRet = sal_False;
+    bool bRet = false;
     try
     {
         ::ucbhelper::Content aCnt( INetURLObject( rURL ).GetMainURL( INetURLObject::NO_DECODE ),
diff --git a/sfx2/source/inc/helper.hxx b/sfx2/source/inc/helper.hxx
index a228f2c..5e20e22 100644
--- a/sfx2/source/inc/helper.hxx
+++ b/sfx2/source/inc/helper.hxx
@@ -35,7 +35,7 @@ public:
     static ::com::sun::star::uno::Sequence< ::rtl::OUString >
                                 GetHelpTreeViewContents( const String& rURL );
     static OUString GetActiveHelpString( const OUString& rURL );
-    static sal_Bool IsHelpErrorDocument( const OUString& rURL );
+    static bool IsHelpErrorDocument( const OUString& rURL );
 
     static sal_Int64 GetSize( const String& rContent );
 };
commit 9db1c9e1915ca21b05d1c38f44984716f0d6a8cf
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 3 22:08:19 2013 +0200

    this method is actually unused
    
    Change-Id: I1808ada7c012f4dfacc7ace93478a4acab50f6eb

diff --git a/sfx2/source/bastyp/helper.cxx b/sfx2/source/bastyp/helper.cxx
index caa1506..4ee9d44 100644
--- a/sfx2/source/bastyp/helper.cxx
+++ b/sfx2/source/bastyp/helper.cxx
@@ -68,16 +68,6 @@ DateTime convertDateTime( const util::DateTime& rUnoDT )
 
 }
 
-void AppendDateTime_Impl( const util::DateTime rDT,
-                          String& rRow, const LocaleDataWrapper& rWrapper )
-{
-    DateTime aDT = convertDateTime(rDT);
-    String aDateStr = rWrapper.getDate( aDT );
-    aDateStr += rtl::OUString(", ");
-    aDateStr += rWrapper.getTime( aDT );
-    rRow += aDateStr;
-}
-
 // -----------------------------------------------------------------------
 
 uno::Sequence < OUString > SfxContentHelper::GetResultSet( const String& rURL )
commit baa6a3b90d7d888cc294c960f5b184718673b1dd
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 3 22:00:25 2013 +0200

    prevent some unnecessary casting
    
    Change-Id: I56b324cc8431347c25472f7ef3ac5871b226f5b1

diff --git a/sfx2/source/bastyp/helper.cxx b/sfx2/source/bastyp/helper.cxx
index cc439db..caa1506 100644
--- a/sfx2/source/bastyp/helper.cxx
+++ b/sfx2/source/bastyp/helper.cxx
@@ -283,16 +283,15 @@ sal_Bool SfxContentHelper::IsHelpErrorDocument( const OUString& rURL )
 
 // -----------------------------------------------------------------------
 
-sal_uIntPtr SfxContentHelper::GetSize( const String& rContent )
+sal_Int64 SfxContentHelper::GetSize( const String& rContent )
 {
-    sal_uIntPtr nSize = 0;
-    sal_Int64 nTemp = 0;
+    sal_Int64 nSize = 0;
     INetURLObject aObj( rContent );
     DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" );
     try
     {
         ::ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() );
-        aCnt.getPropertyValue( "Size" ) >>= nTemp;
+        aCnt.getPropertyValue( "Size" ) >>= nSize;
     }
     catch( const ucb::CommandAbortedException& )
     {
@@ -302,7 +301,6 @@ sal_uIntPtr SfxContentHelper::GetSize( const String& rContent )
     {
         SAL_WARN( "sfx2.bastyp", "Any other exception" );
     }
-    nSize = (sal_uInt32)nTemp;
     return nSize;
 }
 
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index b16b3f1..8646146 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -113,18 +113,18 @@ const sal_uInt16 HI_ACTION = 4;
 static const char DOCUMENT_SIGNATURE_MENU_CMD[] = "Signature";
 
 //------------------------------------------------------------------------
-String CreateSizeText( sal_uIntPtr nSize, sal_Bool bExtraBytes = sal_True, sal_Bool bSmartExtraBytes = sal_False );
-String CreateSizeText( sal_uIntPtr nSize, sal_Bool bExtraBytes, sal_Bool bSmartExtraBytes )
+namespace {
+
+String CreateSizeText( sal_Int64 nSize )
 {
     String aUnitStr = rtl::OUString(' ');
     aUnitStr += SfxResId(STR_BYTES).toString();
-    sal_uIntPtr nSize1 = nSize;
-    sal_uIntPtr nSize2 = nSize1;
-    sal_uIntPtr nMega = 1024 * 1024;
-    sal_uIntPtr nGiga = nMega * 1024;
+    sal_Int64 nSize1 = nSize;
+    sal_Int64 nSize2 = nSize1;
+    sal_Int64 nMega = 1024 * 1024;
+    sal_Int64 nGiga = nMega * 1024;
     double fSize = nSize;
     int nDec = 0;
-    sal_Bool bGB = sal_False;
 
     if ( nSize1 >= 10000 && nSize1 < nMega )
     {
@@ -147,7 +147,6 @@ String CreateSizeText( sal_uIntPtr nSize, sal_Bool bExtraBytes, sal_Bool bSmartE
         nSize1 /= nGiga;
         aUnitStr = ' ';
         aUnitStr += SfxResId(STR_GB).toString();
-        bGB = sal_True;
         fSize /= nGiga;
         nDec = 3;
     }
@@ -155,7 +154,7 @@ String CreateSizeText( sal_uIntPtr nSize, sal_Bool bExtraBytes, sal_Bool bSmartE
     const LocaleDataWrapper& rLocaleWrapper = aSysLocale.GetLocaleData();
     String aSizeStr( rLocaleWrapper.getNum( nSize1, 0 ) );
     aSizeStr += aUnitStr;
-    if ( bExtraBytes && ( nSize1 < nSize2 ) )
+    if ( nSize1 < nSize2 )
     {
         aSizeStr = ::rtl::math::doubleToUString( fSize,
                 rtl_math_StringFormat_F, nDec,
@@ -168,14 +167,6 @@ String CreateSizeText( sal_uIntPtr nSize, sal_Bool bExtraBytes, sal_Bool bSmartE
         aSizeStr += SfxResId(STR_BYTES).toString();
         aSizeStr += ')';
     }
-    else if ( bGB && bSmartExtraBytes )
-    {
-        nSize1 = nSize / nMega;
-        aSizeStr = " (";
-        aSizeStr += rLocaleWrapper.getNum( nSize1, 0 );
-        aSizeStr += aUnitStr;
-        aSizeStr += ')';
-    }
     return aSizeStr;
 }
 
@@ -197,6 +188,7 @@ String ConvertDateTime_Impl( const String& rName,
      return aStr;
 }
 
+}
 //------------------------------------------------------------------------
 
 SfxDocumentInfoItem::SfxDocumentInfoItem()
diff --git a/sfx2/source/inc/helper.hxx b/sfx2/source/inc/helper.hxx
index 6c008d4..a228f2c 100644
--- a/sfx2/source/inc/helper.hxx
+++ b/sfx2/source/inc/helper.hxx
@@ -34,10 +34,10 @@ public:
                                 GetResultSet( const String& rURL );
     static ::com::sun::star::uno::Sequence< ::rtl::OUString >
                                 GetHelpTreeViewContents( const String& rURL );
-    static OUString             GetActiveHelpString( const OUString& rURL );
-    static sal_Bool             IsHelpErrorDocument( const OUString& rURL );
+    static OUString GetActiveHelpString( const OUString& rURL );
+    static sal_Bool IsHelpErrorDocument( const OUString& rURL );
 
-    static sal_uIntPtr              GetSize( const String& rContent );
+    static sal_Int64 GetSize( const String& rContent );
 };
 
 #endif // #ifndef _SFX_HELPER_HXX
commit 56f0144b0a40048505de4bac81e25f2454e43704
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 3 20:37:38 2013 +0200

    we don't need a macro here
    
    Change-Id: I7b063f54f354ade05dd0f2c4b10b161a44895076

diff --git a/sfx2/source/bastyp/helper.cxx b/sfx2/source/bastyp/helper.cxx
index 7c02635..cc439db 100644
--- a/sfx2/source/bastyp/helper.cxx
+++ b/sfx2/source/bastyp/helper.cxx
@@ -58,15 +58,20 @@ using ::rtl::OUString;
 using ::rtl::OStringBuffer;
 using ::rtl::OStringToOUString;
 
-#define CONVERT_DATETIME( aUnoDT, aToolsDT ) \
-    aToolsDT = DateTime( Date( aUnoDT.Day, aUnoDT.Month, aUnoDT.Year ), \
-                         Time( aUnoDT.Hours, aUnoDT.Minutes, aUnoDT.Seconds, aUnoDT.HundredthSeconds ) );
+namespace {
+
+DateTime convertDateTime( const util::DateTime& rUnoDT )
+{
+    return DateTime( Date( rUnoDT.Day, rUnoDT.Month, rUnoDT.Year ),
+                         Time( rUnoDT.Hours, rUnoDT.Minutes, rUnoDT.Seconds, rUnoDT.HundredthSeconds ) );
+}
+
+}
 
 void AppendDateTime_Impl( const util::DateTime rDT,
                           String& rRow, const LocaleDataWrapper& rWrapper )
 {
-    DateTime aDT( DateTime::EMPTY );
-    CONVERT_DATETIME( rDT, aDT );
+    DateTime aDT = convertDateTime(rDT);
     String aDateStr = rWrapper.getDate( aDT );
     aDateStr += rtl::OUString(", ");
     aDateStr += rWrapper.getTime( aDT );
commit 0ae1a6248434d60f2530fbf948cc302c987de1a5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 3 20:26:50 2013 +0200

    no need for pointers here
    
    Change-Id: I0eca0d07d251949f99ebed44ef3267fa6dfb4c80

diff --git a/sfx2/source/bastyp/helper.cxx b/sfx2/source/bastyp/helper.cxx
index 4a6a39c..7c02635 100644
--- a/sfx2/source/bastyp/helper.cxx
+++ b/sfx2/source/bastyp/helper.cxx
@@ -58,8 +58,6 @@ using ::rtl::OUString;
 using ::rtl::OStringBuffer;
 using ::rtl::OStringToOUString;
 
-typedef vector< OUString* > StringList_Impl;
-
 #define CONVERT_DATETIME( aUnoDT, aToolsDT ) \
     aToolsDT = DateTime( Date( aUnoDT.Day, aUnoDT.Month, aUnoDT.Year ), \
                          Time( aUnoDT.Hours, aUnoDT.Minutes, aUnoDT.Seconds, aUnoDT.HundredthSeconds ) );
@@ -79,7 +77,7 @@ void AppendDateTime_Impl( const util::DateTime rDT,
 
 uno::Sequence < OUString > SfxContentHelper::GetResultSet( const String& rURL )
 {
-    StringList_Impl* pList = NULL;
+    vector<OUString> aList;
     try
     {
         ::ucbhelper::Content aCnt( rURL, uno::Reference< ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() );
@@ -109,7 +107,6 @@ uno::Sequence < OUString > SfxContentHelper::GetResultSet( const String& rURL )
 
         if ( xResultSet.is() )
         {
-            pList = new StringList_Impl();
             uno::Reference< sdbc::XRow > xRow( xResultSet, uno::UNO_QUERY );
             uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
 
@@ -124,8 +121,7 @@ uno::Sequence < OUString > SfxContentHelper::GetResultSet( const String& rURL )
                     aRow += aType;
                     aRow += '\t';
                     aRow += String( xContentAccess->queryContentIdentifierString() );
-                    OUString* pRow = new OUString( aRow );
-                    pList->push_back( pRow );
+                    aList.push_back( OUString( aRow ) );
                 }
             }
             catch( const ucb::CommandAbortedException& )
@@ -143,30 +139,21 @@ uno::Sequence < OUString > SfxContentHelper::GetResultSet( const String& rURL )
         SAL_WARN( "sfx2.bastyp", "GetResultSet: Any other exception: " << e.Message );
     }
 
-    if ( pList )
+    size_t nCount = aList.size();
+    uno::Sequence < OUString > aRet( nCount );
+    OUString* pRet = aRet.getArray();
+    for ( size_t i = 0; i < nCount; ++i )
     {
-        size_t nCount = pList->size();
-        uno::Sequence < OUString > aRet( nCount );
-        OUString* pRet = aRet.getArray();
-        for ( size_t i = 0; i < nCount; ++i )
-        {
-            OUString* pEntry = pList->at(i);
-            pRet[i] = *( pEntry );
-            delete pEntry;
-        }
-        pList->clear();
-        delete pList;
-        return aRet;
+        pRet[i] = aList[0];
     }
-    else
-        return uno::Sequence < OUString > ();
+    return aRet;
 }
 
 // -----------------------------------------------------------------------
 
 uno::Sequence< OUString > SfxContentHelper::GetHelpTreeViewContents( const String& rURL )
 {
-    StringList_Impl* pProperties = NULL;
+    vector< OUString > aProperties;
     try
     {
         uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
@@ -196,7 +183,6 @@ uno::Sequence< OUString > SfxContentHelper::GetHelpTreeViewContents( const Strin
 
         if ( xResultSet.is() )
         {
-            pProperties = new StringList_Impl();
             uno::Reference< sdbc::XRow > xRow( xResultSet, uno::UNO_QUERY );
             uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
 
@@ -211,8 +197,7 @@ uno::Sequence< OUString > SfxContentHelper::GetHelpTreeViewContents( const Strin
                     aRow += String( xContentAccess->queryContentIdentifierString() );
                     aRow += '\t';
                     aRow += bFolder ? '1' : '0';
-                    OUString* pRow = new OUString( aRow );
-                    pProperties->push_back( pRow );
+                    aProperties.push_back( OUString( aRow ) );
                 }
             }
             catch( const ucb::CommandAbortedException& )
@@ -227,23 +212,14 @@ uno::Sequence< OUString > SfxContentHelper::GetHelpTreeViewContents( const Strin
     {
     }
 
-    if ( pProperties )
+    size_t nCount = aProperties.size();
+    uno::Sequence < OUString > aRet( nCount );
+    OUString* pRet = aRet.getArray();
+    for(size_t i = 0; i < nCount; ++i)
     {
-        size_t nCount = pProperties->size();
-        uno::Sequence < OUString > aRet( nCount );
-        OUString* pRet = aRet.getArray();
-        for ( size_t i = 0; i < nCount; ++i )
-        {
-            OUString* pProperty = pProperties->at(i);
-            pRet[i] = *( pProperty );
-            delete pProperty;
-        }
-        pProperties->clear();
-        delete pProperties;
-        return aRet;
+        pRet[i] = aProperties[i];
     }
-    else
-        return uno::Sequence < OUString > ();
+    return aRet;
 }
 
 // -----------------------------------------------------------------------
commit 9c22cf54a942311f554d5e9c82e93b5cec7edc2c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 3 04:41:37 2013 +0200

    simplify this a bit
    
    Change-Id: I4deaf117c64f4646e36da98c498188022b2c32f0

diff --git a/sfx2/source/bastyp/helper.cxx b/sfx2/source/bastyp/helper.cxx
index 5e96afc..4a6a39c 100644
--- a/sfx2/source/bastyp/helper.cxx
+++ b/sfx2/source/bastyp/helper.cxx
@@ -264,10 +264,8 @@ OUString SfxContentHelper::GetActiveHelpString( const OUString& rURL )
         sal_Int32 nRead = xStream->readBytes( lData, 1024 );
         while ( nRead > 0 )
         {
-            OStringBuffer sBuffer( nRead );
-            for( sal_Int32 i = 0; i < nRead; ++i )
-                sBuffer.append( (sal_Char)lData[i] );
-            OUString sString = OStringToOUString( sBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
+            OString sOldString( (sal_Char*)lData.getConstArray(), nRead );
+            OUString sString = OStringToOUString( sOldString, RTL_TEXTENCODING_UTF8 );
             aRet.append( sString );
 
             nRead = xStream->readBytes( lData, 1024 );


More information about the Libreoffice-commits mailing list