Cleaned up utl::UCBContentHelper.

This commit is contained in:
Stephan Bergmann 2011-11-28 10:09:57 +01:00
parent ab5b77536b
commit 2af9040d38
7 changed files with 488 additions and 677 deletions

View file

@ -32,6 +32,7 @@
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <ucbhelper/content.hxx>
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/ucb/NameClash.hpp>
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <unotools/tempfile.hxx>
#include <unotools/ucbstreamhelper.hxx>

View file

@ -29,6 +29,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/ucb/NameClash.hpp>
#include <com/sun/star/ucb/XProgressHandler.hpp>
#include <com/sun/star/ucb/XContentAccess.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>

View file

@ -236,10 +236,9 @@ void ODocumentInfoPreview::fill(
// size
if ( i_rURL.Len() > 0 )
{
sal_uLong nDocSize = ::utl::UCBContentHelper::GetSize( i_rURL );
m_pEditWin->InsertEntry(
m_pInfoTable->GetString( DI_SIZE ),
CreateExactSizeText_Impl( nDocSize ) );
CreateExactSizeText_Impl( utl::UCBContentHelper::GetSize( i_rURL ) ) );
}
// MIMEType
@ -749,8 +748,8 @@ sal_Bool SvtFileViewWindow_Impl::HasPreviousLevel( String& rURL ) const
String SvtFileViewWindow_Impl::GetFolderTitle() const
{
String aTitle;
::utl::UCBContentHelper::GetTitle( aFolderURL, aTitle );
rtl::OUString aTitle;
::utl::UCBContentHelper::GetTitle( aFolderURL, &aTitle );
return aTitle;
}

View file

@ -1200,7 +1200,7 @@ String SvtURLBox::GetURL()
Any aAny =
UCBContentHelper::GetProperty(aURL,aPropName);
sal_Bool success = (aAny >>= aFileURL);
String aTitle;
rtl::OUString aTitle;
if(success)
aTitle = String(
INetURLObject(aFileURL).getName(
@ -1209,12 +1209,11 @@ String SvtURLBox::GetURL()
INetURLObject::DECODE_WITH_CHARSET ));
else
success =
UCBContentHelper::GetTitle(aURL,aTitle);
UCBContentHelper::GetTitle(aURL,&aTitle);
if( success &&
( aTitle.Len() > 1 ||
(aTitle.CompareToAscii("/") != 0 &&
aTitle.CompareToAscii(".") != 0) ) )
!(aTitle.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("/"))
|| aTitle.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("."))) )
{
aObj.SetName( aTitle );
if ( bSlash )

View file

@ -25,55 +25,58 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "unotools/unotoolsdllapi.h"
#ifndef _UNOTOOLS_UCBHELPER_HXX
#define _UNOTOOLS_UCBHELPER_HXX
// include ---------------------------------------------------------------
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/ucb/NameClash.hpp>
#include <com/sun/star/ucb/XContentProvider.hpp>
#include "sal/config.h"
#include <tools/string.hxx>
#include "com/sun/star/uno/Sequence.hxx"
#include "sal/types.h"
#include "unotools/unotoolsdllapi.h"
namespace ucbhelper
{
class Content;
}
namespace com { namespace sun { namespace star { namespace uno {
class Any;
} } } }
namespace rtl { class OUString; }
namespace ucbhelper { class Content; }
namespace utl
{
class UNOTOOLS_DLLPUBLIC UCBContentHelper
{
public:
static sal_Bool IsDocument( const String& rContent );
static sal_Bool IsFolder( const String& rContent );
static sal_Bool GetTitle( const String& rContent, String& rTitle );
static sal_Bool Kill( const String& rContent );
namespace utl { namespace UCBContentHelper {
static ::com::sun::star::uno::Any GetProperty( const String& rURL, const ::rtl::OUString& rName );
UNOTOOLS_DLLPUBLIC bool IsDocument(rtl::OUString const & url);
static ::com::sun::star::uno::Sequence< ::rtl::OUString >
GetFolderContents( const String& rFolder, sal_Bool bFolder, sal_Bool bSorted = sal_False );
UNOTOOLS_DLLPUBLIC bool IsFolder(rtl::OUString const & url);
static sal_Bool MakeFolder( const String& rFolder, sal_Bool bNewOnly = sal_False );
static sal_Bool MakeFolder( ::ucbhelper::Content& rParent,
const String& rTitle,
::ucbhelper::Content& rNewFolder,
sal_Bool bNewOnly = sal_False );
UNOTOOLS_DLLPUBLIC bool GetTitle(
rtl::OUString const & url, rtl::OUString * title);
static sal_uLong GetSize( const String& rContent );
static sal_Bool IsYounger( const String& rIsYoung, const String& rIsOlder );
UNOTOOLS_DLLPUBLIC bool Kill(rtl::OUString const & url);
static sal_Bool Exists( const String& rContent );
static sal_Bool IsSubPath( const ::rtl::OUString& rPath, const ::rtl::OUString& rChildCandidate, const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentProvider >& xContentProvider = ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentProvider >() );
static sal_Bool EqualURLs( const ::rtl::OUString& aFirstURL, const ::rtl::OUString& aSecondURL );
};
}
UNOTOOLS_DLLPUBLIC com::sun::star::uno::Any GetProperty(
rtl::OUString const & url, rtl::OUString const & property);
UNOTOOLS_DLLPUBLIC bool MakeFolder(
rtl::OUString const & url, bool exclusive = false);
UNOTOOLS_DLLPUBLIC bool MakeFolder(
ucbhelper::Content & parent, rtl::OUString const & title,
ucbhelper::Content & result, bool exclusive = false);
UNOTOOLS_DLLPUBLIC sal_Int64 GetSize(rtl::OUString const & url);
UNOTOOLS_DLLPUBLIC bool IsYounger(
rtl::OUString const & younger, rtl::OUString const & older);
UNOTOOLS_DLLPUBLIC bool Exists(rtl::OUString const & url);
UNOTOOLS_DLLPUBLIC bool IsSubPath(
rtl::OUString const & parent, rtl::OUString const & child);
UNOTOOLS_DLLPUBLIC bool EqualURLs(
rtl::OUString const & url1, rtl::OUString const & url2);
} }
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

File diff suppressed because it is too large Load diff

View file

@ -42,7 +42,6 @@
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/ucb/XContent.hpp>
#include <com/sun/star/ucb/XContentProvider.hpp>
#include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <com/sun/star/ucb/XCommandProcessor.hpp>
@ -52,7 +51,6 @@
#include <unotools/securityoptions.hxx>
#include <com/sun/star/security/CertificateValidity.hpp>
#include <com/sun/star/security/SerialNumberAdapter.hpp>
#include <ucbhelper/contentbroker.hxx>
#include <unotools/ucbhelper.hxx>
#include <comphelper/componentcontext.hxx>
#include "comphelper/documentconstants.hxx"
@ -434,22 +432,11 @@ void DocumentDigitalSignatures::showCertificate(
INetURLObject aLocObj( Location );
INetURLObject aLocObjLowCase( Location.toAsciiLowerCase() ); // will be used for case insensitive comparing
::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContentProvider > xContentProvider;
::ucbhelper::ContentBroker* pBroker = NULL;
//warning free code
if ( aLocObj.GetProtocol() == INET_PROT_FILE)
{
pBroker = ::ucbhelper::ContentBroker::get();
if (pBroker)
xContentProvider = pBroker->getContentProviderInterface();
}
Sequence< ::rtl::OUString > aSecURLs = SvtSecurityOptions().GetSecureURLs();
const ::rtl::OUString* pSecURLs = aSecURLs.getConstArray();
const ::rtl::OUString* pSecURLsEnd = pSecURLs + aSecURLs.getLength();
for ( ; pSecURLs != pSecURLsEnd && !bFound; ++pSecURLs )
bFound = ::utl::UCBContentHelper::IsSubPath( *pSecURLs, Location, xContentProvider );
bFound = ::utl::UCBContentHelper::IsSubPath( *pSecURLs, Location );
return bFound;
}