summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-04-03 23:00:51 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-04-03 23:27:40 +0200
commit4290f249be1642c63a958e3f7873b56f47ae5a5b (patch)
treebb6169eeacfbc8cfc2140f77b9ded7831411507f /sfx2/source
parentf2e19cc800025a9361bbea7d6b435ff649b09528 (diff)
more clean-up around SfxContentHelper
Change-Id: I836a260d0e7c8b61cf4b6b6c378da854ca188a22
Diffstat (limited to 'sfx2/source')
-rw-r--r--sfx2/source/appl/newhelp.cxx74
-rw-r--r--sfx2/source/appl/sfxhelp.cxx6
-rw-r--r--sfx2/source/bastyp/helper.cxx26
-rw-r--r--sfx2/source/inc/helper.hxx10
4 files changed, 45 insertions, 71 deletions
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx
index 8f2378bf4a4f..052c7063a44d 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 7a8ec7840915..0517b65be3e9 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 6cc9c0f860f1..444dda9a9562 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 5e20e2245039..31b32a673e35 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