summaryrefslogtreecommitdiff
path: root/sfx2/source/bastyp/helper.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source/bastyp/helper.cxx')
-rw-r--r--sfx2/source/bastyp/helper.cxx113
1 files changed, 62 insertions, 51 deletions
diff --git a/sfx2/source/bastyp/helper.cxx b/sfx2/source/bastyp/helper.cxx
index 0b698070da..d4ce417f53 100644
--- a/sfx2/source/bastyp/helper.cxx
+++ b/sfx2/source/bastyp/helper.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -56,13 +57,16 @@
#include <ucbhelper/commandenvironment.hxx>
#include <comphelper/processfactory.hxx>
#include <osl/file.hxx>
+#include <vector>
using namespace com::sun::star;
using namespace rtl;
using namespace comphelper;
using namespace osl;
-DECLARE_LIST( StringList_Impl, OUString* )
+using ::std::vector;
+
+typedef vector< OUString* > StringList_Impl;
#define CONVERT_DATETIME( aUnoDT, aToolsDT ) \
aToolsDT = DateTime( Date( aUnoDT.Day, aUnoDT.Month, aUnoDT.Year ), \
@@ -102,7 +106,7 @@ sal_Bool SfxContentHelper::Transfer_Impl( const String& rSource, const String& r
{
::ucbhelper::Content aDestPath( aDestObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment > () );
uno::Reference< ucb::XCommandInfo > xInfo = aDestPath.getCommands();
- OUString aTransferName = OUString::createFromAscii( "transfer" );
+ OUString aTransferName(RTL_CONSTASCII_USTRINGPARAM("transfer"));
if ( xInfo->hasCommandByName( aTransferName ) )
{
aDestPath.executeCommand( aTransferName, uno::makeAny(
@@ -205,7 +209,7 @@ sal_Bool SfxContentHelper::GetTitle( const String& rContent, String& rTitle )
{
::ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment > () );
OUString aTemp;
- aCnt.getPropertyValue( OUString::createFromAscii( "Title" ) ) >>= aTemp;
+ aCnt.getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Title")) ) >>= aTemp;
rTitle = String( aTemp );
bRet = sal_True;
}
@@ -231,7 +235,7 @@ sal_Bool SfxContentHelper::Kill( const String& rContent )
try
{
::ucbhelper::Content aCnt( aDeleteObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment > () );
- aCnt.executeCommand( OUString::createFromAscii( "delete" ), uno::makeAny( sal_Bool( sal_True ) ) );
+ aCnt.executeCommand( OUString(RTL_CONSTASCII_USTRINGPARAM("delete")), uno::makeAny( sal_Bool( sal_True ) ) );
}
catch( ucb::CommandAbortedException& )
{
@@ -260,8 +264,8 @@ uno::Sequence < OUString > SfxContentHelper::GetFolderContents( const String& rF
uno::Reference< sdbc::XResultSet > xResultSet;
uno::Sequence< OUString > aProps(2);
OUString* pProps = aProps.getArray();
- pProps[0] = OUString::createFromAscii( "Title" );
- pProps[1] = OUString::createFromAscii( "IsFolder" );
+ pProps[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("Title"));
+ pProps[1] = OUString(RTL_CONSTASCII_USTRINGPARAM("IsFolder"));
try
{
@@ -278,7 +282,7 @@ uno::Sequence < OUString > SfxContentHelper::GetFolderContents( const String& rF
uno::Reference < ucb::XAnyCompareFactory > xFactory;
uno::Reference < lang::XMultiServiceFactory > xMgr = getProcessServiceFactory();
uno::Reference < ucb::XSortedDynamicResultSetFactory > xSRSFac(
- xMgr->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.ucb.SortedDynamicResultSetFactory") ), uno::UNO_QUERY );
+ xMgr->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SortedDynamicResultSetFactory")) ), uno::UNO_QUERY );
uno::Sequence< ucb::NumberedSortingInfo > aSortInfo( 2 );
ucb::NumberedSortingInfo* pInfo = aSortInfo.getArray();
@@ -307,7 +311,7 @@ uno::Sequence < OUString > SfxContentHelper::GetFolderContents( const String& rF
if ( xResultSet.is() )
{
- pFiles = new StringList_Impl;
+ pFiles = new StringList_Impl();
uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
try
{
@@ -315,7 +319,7 @@ uno::Sequence < OUString > SfxContentHelper::GetFolderContents( const String& rF
{
OUString aId = xContentAccess->queryContentIdentifierString();
OUString* pFile = new OUString( aId );
- pFiles->Insert( pFile, LIST_APPEND );
+ pFiles->push_back( pFile );
}
}
catch( ucb::CommandAbortedException& )
@@ -335,15 +339,16 @@ uno::Sequence < OUString > SfxContentHelper::GetFolderContents( const String& rF
if ( pFiles )
{
- ULONG nCount = pFiles->Count();
+ size_t nCount = pFiles->size();
uno::Sequence < OUString > aRet( nCount );
OUString* pRet = aRet.getArray();
- for ( ULONG i = 0; i < nCount; ++i )
+ for ( size_t i = 0; i < nCount; ++i )
{
- OUString* pFile = pFiles->GetObject(i);
+ OUString* pFile = pFiles->at( i );
pRet[i] = *( pFile );
delete pFile;
}
+ pFiles->clear();
delete pFiles;
return aRet;
}
@@ -368,11 +373,11 @@ uno::Sequence < OUString > SfxContentHelper::GetFolderContentProperties( const S
uno::Reference< sdbc::XResultSet > xResultSet;
uno::Sequence< OUString > aProps(5);
OUString* pProps = aProps.getArray();
- pProps[0] = OUString::createFromAscii( "Title" );
- pProps[1] = OUString::createFromAscii( "ContentType" );
- pProps[2] = OUString::createFromAscii( "Size" );
- pProps[3] = OUString::createFromAscii( "DateModified" );
- pProps[4] = OUString::createFromAscii( "IsFolder" );
+ pProps[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("Title"));
+ pProps[1] = OUString(RTL_CONSTASCII_USTRINGPARAM("ContentType"));
+ pProps[2] = OUString(RTL_CONSTASCII_USTRINGPARAM("Size"));
+ pProps[3] = OUString(RTL_CONSTASCII_USTRINGPARAM("DateModified"));
+ pProps[4] = OUString(RTL_CONSTASCII_USTRINGPARAM("IsFolder"));
try
{
@@ -383,7 +388,7 @@ uno::Sequence < OUString > SfxContentHelper::GetFolderContentProperties( const S
uno::Reference < ucb::XAnyCompareFactory > xCmpFactory;
uno::Reference < lang::XMultiServiceFactory > xMgr = getProcessServiceFactory();
uno::Reference < ucb::XSortedDynamicResultSetFactory > xSRSFac(
- xMgr->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.ucb.SortedDynamicResultSetFactory") ), uno::UNO_QUERY );
+ xMgr->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SortedDynamicResultSetFactory")) ), uno::UNO_QUERY );
uno::Sequence< ucb::NumberedSortingInfo > aSortInfo( 2 );
ucb::NumberedSortingInfo* pInfo = aSortInfo.getArray();
@@ -399,9 +404,6 @@ uno::Sequence < OUString > SfxContentHelper::GetFolderContentProperties( const S
{
xResultSet = xDynamicResultSet->getStaticResultSet();
}
-
-// if ( xDynResultSet.is() )
-// xResultSet = xDynResultSet->getStaticResultSet();
}
catch( ucb::CommandAbortedException& )
{
@@ -415,10 +417,10 @@ uno::Sequence < OUString > SfxContentHelper::GetFolderContentProperties( const S
if ( xResultSet.is() )
{
LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
- pProperties = new StringList_Impl;
+ pProperties = new StringList_Impl();
uno::Reference< sdbc::XRow > xRow( xResultSet, uno::UNO_QUERY );
uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
- ULONG nFolderPos = LIST_APPEND;
+ size_t nFolderPos = size_t(-1);
try
{
@@ -428,12 +430,10 @@ uno::Sequence < OUString > SfxContentHelper::GetFolderContentProperties( const S
String aType( xRow->getString(2) );
sal_Int64 nSize = xRow->getLong(3);
util::DateTime aDT = xRow->getTimestamp(4);
- sal_Bool bFolder = xRow->getBoolean(5);
+ sal_Bool bFolder = xRow->getBoolean(5); // true = directory, else file
String aRow = aTitle;
aRow += '\t';
-//! aRow += aType;
-//! aRow += '\t';
aRow += String::CreateFromInt64( nSize );
aRow += '\t';
AppendDateTime_Impl( aDT, aRow, aLocaleWrapper );
@@ -442,16 +442,23 @@ uno::Sequence < OUString > SfxContentHelper::GetFolderContentProperties( const S
aRow += '\t';
aRow += bFolder ? '1' : '0';
OUString* pRow = new OUString( aRow );
- ULONG nPos = LIST_APPEND;
- if ( bFolder )
+ size_t nPos = size_t(-1);
+ if ( bFolder ) // place the directories at the top of the listing
{
- if ( LIST_APPEND == nFolderPos )
+ if ( nFolderPos == size_t(-1) )
nFolderPos = 0;
else
nFolderPos++;
nPos = nFolderPos;
}
- pProperties->Insert( pRow, nPos );
+ if ( nPos >= pProperties->size() )
+ pProperties->push_back( pRow );
+ else
+ {
+ StringList_Impl::iterator it = pProperties->begin();
+ ::std::advance( it, nPos );
+ it = pProperties->insert( it, pRow );
+ }
}
}
catch( ucb::CommandAbortedException& )
@@ -471,15 +478,16 @@ uno::Sequence < OUString > SfxContentHelper::GetFolderContentProperties( const S
if ( pProperties )
{
- ULONG nCount = pProperties->Count();
+ size_t nCount = pProperties->size();
uno::Sequence < OUString > aRet( nCount );
OUString* pRet = aRet.getArray();
- for ( ULONG i = 0; i < nCount; ++i )
+ for ( size_t i = 0; i < nCount; ++i )
{
- OUString* pProperty = pProperties->GetObject(i);
+ OUString* pProperty = pProperties->at(i);
pRet[i] = *( pProperty );
delete pProperty;
}
+ pProperties->clear();
delete pProperties;
return aRet;
}
@@ -499,9 +507,9 @@ uno::Sequence < OUString > SfxContentHelper::GetResultSet( const String& rURL )
uno::Reference< ucb::XDynamicResultSet > xDynResultSet;
uno::Sequence< OUString > aProps(3);
OUString* pProps = aProps.getArray();
- pProps[0] = OUString::createFromAscii( "Title" );
- pProps[1] = OUString::createFromAscii( "ContentType" );
- pProps[2] = OUString::createFromAscii( "IsFolder" );
+ pProps[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("Title"));
+ pProps[1] = OUString(RTL_CONSTASCII_USTRINGPARAM("ContentType"));
+ pProps[2] = OUString(RTL_CONSTASCII_USTRINGPARAM("IsFolder"));
try
{
@@ -520,7 +528,7 @@ uno::Sequence < OUString > SfxContentHelper::GetResultSet( const String& rURL )
if ( xResultSet.is() )
{
- pList = new StringList_Impl;
+ pList = new StringList_Impl();
uno::Reference< sdbc::XRow > xRow( xResultSet, uno::UNO_QUERY );
uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
@@ -536,7 +544,7 @@ uno::Sequence < OUString > SfxContentHelper::GetResultSet( const String& rURL )
aRow += '\t';
aRow += String( xContentAccess->queryContentIdentifierString() );
OUString* pRow = new OUString( aRow );
- pList->Insert( pRow, LIST_APPEND );
+ pList->push_back( pRow );
}
}
catch( ucb::CommandAbortedException& )
@@ -564,15 +572,16 @@ uno::Sequence < OUString > SfxContentHelper::GetResultSet( const String& rURL )
if ( pList )
{
- ULONG nCount = pList->Count();
+ size_t nCount = pList->size();
uno::Sequence < OUString > aRet( nCount );
OUString* pRet = aRet.getArray();
- for ( ULONG i = 0; i < nCount; ++i )
+ for ( size_t i = 0; i < nCount; ++i )
{
- OUString* pEntry = pList->GetObject(i);
+ OUString* pEntry = pList->at(i);
pRet[i] = *( pEntry );
delete pEntry;
}
+ pList->clear();
delete pList;
return aRet;
}
@@ -595,8 +604,8 @@ uno::Sequence< OUString > SfxContentHelper::GetHelpTreeViewContents( const Strin
uno::Reference< sdbc::XResultSet > xResultSet;
uno::Sequence< OUString > aProps(2);
OUString* pProps = aProps.getArray();
- pProps[0] = OUString::createFromAscii( "Title" );
- pProps[1] = OUString::createFromAscii( "IsFolder" );
+ pProps[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("Title"));
+ pProps[1] = OUString(RTL_CONSTASCII_USTRINGPARAM("IsFolder"));
try
{
@@ -614,7 +623,7 @@ uno::Sequence< OUString > SfxContentHelper::GetHelpTreeViewContents( const Strin
if ( xResultSet.is() )
{
- pProperties = new StringList_Impl;
+ pProperties = new StringList_Impl();
uno::Reference< sdbc::XRow > xRow( xResultSet, uno::UNO_QUERY );
uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
@@ -630,7 +639,7 @@ uno::Sequence< OUString > SfxContentHelper::GetHelpTreeViewContents( const Strin
aRow += '\t';
aRow += bFolder ? '1' : '0';
OUString* pRow = new OUString( aRow );
- pProperties->Insert( pRow, LIST_APPEND );
+ pProperties->push_back( pRow );
}
}
catch( ucb::CommandAbortedException& )
@@ -647,15 +656,16 @@ uno::Sequence< OUString > SfxContentHelper::GetHelpTreeViewContents( const Strin
if ( pProperties )
{
- ULONG nCount = pProperties->Count();
+ size_t nCount = pProperties->size();
uno::Sequence < OUString > aRet( nCount );
OUString* pRet = aRet.getArray();
- for ( ULONG i = 0; i < nCount; ++i )
+ for ( size_t i = 0; i < nCount; ++i )
{
- OUString* pProperty = pProperties->GetObject(i);
+ OUString* pProperty = pProperties->at(i);
pRet[i] = *( pProperty );
delete pProperty;
}
+ pProperties->clear();
delete pProperties;
return aRet;
}
@@ -706,7 +716,7 @@ sal_Bool SfxContentHelper::IsHelpErrorDocument( const String& rURL )
{
::ucbhelper::Content aCnt( INetURLObject( rURL ).GetMainURL( INetURLObject::NO_DECODE ),
uno::Reference< ucb::XCommandEnvironment > () );
- if ( !( aCnt.getPropertyValue( OUString::createFromAscii( "IsErrorDocument" ) ) >>= bRet ) )
+ if ( !( aCnt.getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsErrorDocument")) ) >>= bRet ) )
{
DBG_ERRORFILE( "Property 'IsErrorDocument' is missing" );
}
@@ -784,7 +794,7 @@ ErrCode SfxContentHelper::QueryDiskSpace( const String& rPath, sal_Int64& rFreeB
try
{
::ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment > () );
- aCnt.getPropertyValue( OUString::createFromAscii( "FreeSpace" ) ) >>= rFreeBytes;
+ aCnt.getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("FreeSpace")) ) >>= rFreeBytes;
}
catch( ucb::CommandAbortedException& )
{
@@ -810,7 +820,7 @@ ULONG SfxContentHelper::GetSize( const String& rContent )
try
{
::ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment > () );
- aCnt.getPropertyValue( OUString::createFromAscii( "Size" ) ) >>= nTemp;
+ aCnt.getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Size")) ) >>= nTemp;
}
catch( ucb::CommandAbortedException& )
{
@@ -877,3 +887,4 @@ sal_Bool SfxContentHelper::Find( const String& rFolder, const String& rName, Str
}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */