Kaydet (Commit) 2af9040d authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Cleaned up utl::UCBContentHelper.

üst ab5b7753
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <ucbhelper/content.hxx> #include <ucbhelper/content.hxx>
#include <com/sun/star/uno/Reference.h> #include <com/sun/star/uno/Reference.h>
#include <com/sun/star/ucb/NameClash.hpp>
#include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <unotools/tempfile.hxx> #include <unotools/tempfile.hxx>
#include <unotools/ucbstreamhelper.hxx> #include <unotools/ucbstreamhelper.hxx>
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/embed/XTransactedObject.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/XProgressHandler.hpp>
#include <com/sun/star/ucb/XContentAccess.hpp> #include <com/sun/star/ucb/XContentAccess.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp> #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
......
...@@ -236,10 +236,9 @@ void ODocumentInfoPreview::fill( ...@@ -236,10 +236,9 @@ void ODocumentInfoPreview::fill(
// size // size
if ( i_rURL.Len() > 0 ) if ( i_rURL.Len() > 0 )
{ {
sal_uLong nDocSize = ::utl::UCBContentHelper::GetSize( i_rURL );
m_pEditWin->InsertEntry( m_pEditWin->InsertEntry(
m_pInfoTable->GetString( DI_SIZE ), m_pInfoTable->GetString( DI_SIZE ),
CreateExactSizeText_Impl( nDocSize ) ); CreateExactSizeText_Impl( utl::UCBContentHelper::GetSize( i_rURL ) ) );
} }
// MIMEType // MIMEType
...@@ -749,8 +748,8 @@ sal_Bool SvtFileViewWindow_Impl::HasPreviousLevel( String& rURL ) const ...@@ -749,8 +748,8 @@ sal_Bool SvtFileViewWindow_Impl::HasPreviousLevel( String& rURL ) const
String SvtFileViewWindow_Impl::GetFolderTitle() const String SvtFileViewWindow_Impl::GetFolderTitle() const
{ {
String aTitle; rtl::OUString aTitle;
::utl::UCBContentHelper::GetTitle( aFolderURL, aTitle ); ::utl::UCBContentHelper::GetTitle( aFolderURL, &aTitle );
return aTitle; return aTitle;
} }
......
...@@ -1200,7 +1200,7 @@ String SvtURLBox::GetURL() ...@@ -1200,7 +1200,7 @@ String SvtURLBox::GetURL()
Any aAny = Any aAny =
UCBContentHelper::GetProperty(aURL,aPropName); UCBContentHelper::GetProperty(aURL,aPropName);
sal_Bool success = (aAny >>= aFileURL); sal_Bool success = (aAny >>= aFileURL);
String aTitle; rtl::OUString aTitle;
if(success) if(success)
aTitle = String( aTitle = String(
INetURLObject(aFileURL).getName( INetURLObject(aFileURL).getName(
...@@ -1209,12 +1209,11 @@ String SvtURLBox::GetURL() ...@@ -1209,12 +1209,11 @@ String SvtURLBox::GetURL()
INetURLObject::DECODE_WITH_CHARSET )); INetURLObject::DECODE_WITH_CHARSET ));
else else
success = success =
UCBContentHelper::GetTitle(aURL,aTitle); UCBContentHelper::GetTitle(aURL,&aTitle);
if( success && if( success &&
( aTitle.Len() > 1 || !(aTitle.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("/"))
(aTitle.CompareToAscii("/") != 0 && || aTitle.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("."))) )
aTitle.CompareToAscii(".") != 0) ) )
{ {
aObj.SetName( aTitle ); aObj.SetName( aTitle );
if ( bSlash ) if ( bSlash )
......
...@@ -25,55 +25,58 @@ ...@@ -25,55 +25,58 @@
* for a copy of the LGPLv3 License. * for a copy of the LGPLv3 License.
* *
************************************************************************/ ************************************************************************/
#include "unotools/unotoolsdllapi.h"
#ifndef _UNOTOOLS_UCBHELPER_HXX #ifndef _UNOTOOLS_UCBHELPER_HXX
#define _UNOTOOLS_UCBHELPER_HXX #define _UNOTOOLS_UCBHELPER_HXX
// include --------------------------------------------------------------- #include "sal/config.h"
#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 <tools/string.hxx>
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 );
static ::com::sun::star::uno::Any GetProperty( const String& rURL, const ::rtl::OUString& rName );
static ::com::sun::star::uno::Sequence< ::rtl::OUString >
GetFolderContents( const String& rFolder, sal_Bool bFolder, sal_Bool bSorted = sal_False );
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 );
static sal_uLong GetSize( const String& rContent );
static sal_Bool IsYounger( const String& rIsYoung, const String& rIsOlder );
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 );
};
}
#endif #include "com/sun/star/uno/Sequence.hxx"
#include "sal/types.h"
#include "unotools/unotoolsdllapi.h"
namespace com { namespace sun { namespace star { namespace uno {
class Any;
} } } }
namespace rtl { class OUString; }
namespace ucbhelper { class Content; }
namespace utl { namespace UCBContentHelper {
UNOTOOLS_DLLPUBLIC bool IsDocument(rtl::OUString const & url);
UNOTOOLS_DLLPUBLIC bool IsFolder(rtl::OUString const & url);
UNOTOOLS_DLLPUBLIC bool GetTitle(
rtl::OUString const & url, rtl::OUString * title);
UNOTOOLS_DLLPUBLIC bool Kill(rtl::OUString const & url);
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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include <com/sun/star/embed/XTransactedObject.hpp> #include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/ucb/XContent.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/XContentIdentifierFactory.hpp>
#include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <com/sun/star/ucb/XCommandProcessor.hpp> #include <com/sun/star/ucb/XCommandProcessor.hpp>
...@@ -52,7 +51,6 @@ ...@@ -52,7 +51,6 @@
#include <unotools/securityoptions.hxx> #include <unotools/securityoptions.hxx>
#include <com/sun/star/security/CertificateValidity.hpp> #include <com/sun/star/security/CertificateValidity.hpp>
#include <com/sun/star/security/SerialNumberAdapter.hpp> #include <com/sun/star/security/SerialNumberAdapter.hpp>
#include <ucbhelper/contentbroker.hxx>
#include <unotools/ucbhelper.hxx> #include <unotools/ucbhelper.hxx>
#include <comphelper/componentcontext.hxx> #include <comphelper/componentcontext.hxx>
#include "comphelper/documentconstants.hxx" #include "comphelper/documentconstants.hxx"
...@@ -434,22 +432,11 @@ void DocumentDigitalSignatures::showCertificate( ...@@ -434,22 +432,11 @@ void DocumentDigitalSignatures::showCertificate(
INetURLObject aLocObj( Location ); INetURLObject aLocObj( Location );
INetURLObject aLocObjLowCase( Location.toAsciiLowerCase() ); // will be used for case insensitive comparing 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(); Sequence< ::rtl::OUString > aSecURLs = SvtSecurityOptions().GetSecureURLs();
const ::rtl::OUString* pSecURLs = aSecURLs.getConstArray(); const ::rtl::OUString* pSecURLs = aSecURLs.getConstArray();
const ::rtl::OUString* pSecURLsEnd = pSecURLs + aSecURLs.getLength(); const ::rtl::OUString* pSecURLsEnd = pSecURLs + aSecURLs.getLength();
for ( ; pSecURLs != pSecURLsEnd && !bFound; ++pSecURLs ) for ( ; pSecURLs != pSecURLsEnd && !bFound; ++pSecURLs )
bFound = ::utl::UCBContentHelper::IsSubPath( *pSecURLs, Location, xContentProvider ); bFound = ::utl::UCBContentHelper::IsSubPath( *pSecURLs, Location );
return bFound; return bFound;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment