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: */
...@@ -26,657 +26,478 @@ ...@@ -26,657 +26,478 @@
* *
************************************************************************/ ************************************************************************/
#include "sal/config.h"
#include "unotools/ucbhelper.hxx" #include <cassert>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
#include <com/sun/star/ucb/XCommandProcessor.hpp>
#include <com/sun/star/ucb/CommandAbortedException.hpp>
#include <com/sun/star/ucb/IllegalIdentifierException.hpp>
#include <com/sun/star/ucb/NameClashException.hpp>
#include <com/sun/star/ucb/NameClash.hpp>
#include <com/sun/star/ucb/NumberedSortingInfo.hpp>
#include <com/sun/star/ucb/TransferInfo.hpp>
#include <com/sun/star/ucb/XAnyCompareFactory.hpp>
#include <com/sun/star/ucb/XCommandInfo.hpp>
#include <com/sun/star/ucb/XContentAccess.hpp>
#include <com/sun/star/ucb/ContentInfo.hpp>
#include <com/sun/star/ucb/ContentInfoAttribute.hpp>
#include <com/sun/star/ucb/XDynamicResultSet.hpp>
#include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
#include <com/sun/star/util/DateTime.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/ucb/InteractiveIOException.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp>
#include <ucbhelper/commandenvironment.hxx>
#include <ucbhelper/content.hxx>
#include <comphelper/processfactory.hxx>
#include <osl/file.hxx>
#include <tools/wldcrd.hxx>
#include <tools/ref.hxx>
#include <tools/debug.hxx>
#include <tools/urlobj.hxx>
#include <tools/datetime.hxx>
#include <ucbhelper/contentbroker.hxx>
#include "unotools/localfilehelper.hxx"
#include <vector> #include <vector>
using namespace ucbhelper; #include "com/sun/star/lang/XMultiServiceFactory.hpp"
using namespace com::sun::star; #include "com/sun/star/sdbc/XResultSet.hpp"
using namespace com::sun::star::beans; #include "com/sun/star/task/XInteractionHandler.hpp"
using namespace com::sun::star::container; #include "com/sun/star/ucb/CommandAbortedException.hpp"
using namespace com::sun::star::lang; #include "com/sun/star/ucb/ContentInfo.hpp"
using namespace com::sun::star::sdbc; #include "com/sun/star/ucb/ContentInfoAttribute.hpp"
using namespace com::sun::star::task; #include "com/sun/star/ucb/IOErrorCode.hpp"
using namespace com::sun::star::uno; #include "com/sun/star/ucb/InteractiveIOException.hpp"
using namespace com::sun::star::ucb; #include "com/sun/star/ucb/NameClashException.hpp"
using namespace comphelper; #include "com/sun/star/ucb/XCommandEnvironment.hpp"
using namespace osl; #include "com/sun/star/ucb/XContentAccess.hpp"
#include "com/sun/star/ucb/XContentIdentifier.hpp"
#include "com/sun/star/ucb/XContentIdentifierFactory.hpp"
#include "com/sun/star/ucb/XProgressHandler.hpp"
#include "com/sun/star/uno/Any.hxx"
#include "com/sun/star/uno/Exception.hpp"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/RuntimeException.hpp"
#include "com/sun/star/uno/Sequence.hxx"
#include "com/sun/star/util/DateTime.hpp"
#include "comphelper/processfactory.hxx"
#include "cppuhelper/exc_hlp.hxx"
#include "osl/file.hxx"
#include "rtl/oustringostreaminserter.hxx"
#include "rtl/string.h"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/log.hxx"
#include "sal/types.h"
#include "tools/datetime.hxx"
#include "tools/urlobj.hxx"
#include "ucbhelper/commandenvironment.hxx"
#include "ucbhelper/content.hxx"
#include "ucbhelper/contentbroker.hxx"
#include "unotools/localfilehelper.hxx"
#include "unotools/ucbhelper.hxx"
using ::rtl::OUString; namespace {
typedef ::std::vector< OUString* > StringList_Impl; namespace css = com::sun::star;
#define CONVERT_DATETIME( aUnoDT, aToolsDT ) \ rtl::OUString canonic(rtl::OUString const & url) {
aToolsDT = DateTime( Date( aUnoDT.Day, aUnoDT.Month, aUnoDT.Year ), \ INetURLObject o(url);
Time( aUnoDT.Hours, aUnoDT.Minutes, aUnoDT.Seconds, aUnoDT.HundredthSeconds ) ); SAL_WARN_IF(o.HasError(), "unotools", "Invalid URL \"" << url << '"');
return o.GetMainURL(INetURLObject::NO_DECODE);
}
namespace utl ucbhelper::Content content(rtl::OUString const & url) {
{ return ucbhelper::Content(
canonic(url),
css::uno::Reference<css::ucb::XCommandEnvironment>());
}
sal_Bool UCBContentHelper::IsDocument( const String& rContent ) ucbhelper::Content content(INetURLObject const & url) {
{ return ucbhelper::Content(
sal_Bool bRet = sal_False; url.GetMainURL(INetURLObject::NO_DECODE),
INetURLObject aObj( rContent ); css::uno::Reference<css::ucb::XCommandEnvironment>());
DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); }
try std::vector<rtl::OUString> getContents(rtl::OUString const & url) {
{ try {
Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () ); std::vector<rtl::OUString> cs;
bRet = aCnt.isDocument(); ucbhelper::Content c(content(url));
} css::uno::Sequence<rtl::OUString> args(1);
catch( ::com::sun::star::ucb::CommandAbortedException& ) args[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title"));
{ css::uno::Reference<css::sdbc::XResultSet> res(
DBG_WARNING( "CommandAbortedException" ); c.createCursor(args, ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS),
} css::uno::UNO_SET_THROW);
catch( ::com::sun::star::ucb::IllegalIdentifierException& ) css::uno::Reference<com::sun::star::ucb::XContentAccess> acc(
{ res, css::uno::UNO_QUERY_THROW);
DBG_WARNING( "IllegalIdentifierException" ); while (res->next()) {
} cs.push_back(acc->queryContentIdentifierString());
catch( ContentCreationException& ) }
{ return cs;
DBG_WARNING( "IllegalIdentifierException" ); } catch (css::uno::RuntimeException const &) {
} throw;
catch( ::com::sun::star::uno::Exception& ) } catch (css::ucb::CommandAbortedException const &) {
{ assert(false); // this cannot happen
DBG_WARNING( "Any other exception" ); throw;
} catch (css::uno::Exception const &) {
css::uno::Any e(cppu::getCaughtException());
SAL_INFO(
"unotools",
"getContents(" << url << ") " << e.getValueType().getTypeName()
<< " \"" << e.get<css::uno::Exception>().Message << '"');
return std::vector<rtl::OUString>();
} }
return bRet;
} }
// ----------------------------------------------------------------------- rtl::OUString getCasePreservingUrl(INetURLObject url) {
return
content(url).executeCommand(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("getCasePreservingURL")),
css::uno::Any()).
get<rtl::OUString>();
}
Any UCBContentHelper::GetProperty( const String& rContent, const ::rtl::OUString& rName ) DateTime convert(css::util::DateTime const & dt) {
{ return DateTime(
INetURLObject aObj( rContent ); Date(dt.Day, dt.Month, dt.Year),
DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); Time(dt.Hours, dt.Minutes, dt.Seconds, dt.HundredthSeconds));
try }
{
Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
return aCnt.getPropertyValue( rName );
}
catch( ::com::sun::star::ucb::CommandAbortedException& )
{
DBG_WARNING( "CommandAbortedException" );
}
catch( ::com::sun::star::ucb::IllegalIdentifierException& )
{
DBG_WARNING( "IllegalIdentifierException" );
}
catch( ContentCreationException& )
{
DBG_WARNING( "IllegalIdentifierException" );
}
catch( ::com::sun::star::uno::Exception& )
{
DBG_WARNING( "Any other exception" );
}
return Any();
} }
sal_Bool UCBContentHelper::IsFolder( const String& rContent ) bool utl::UCBContentHelper::IsDocument(rtl::OUString const & url) {
{ try {
sal_Bool bRet = sal_False; return content(url).isDocument();
INetURLObject aObj( rContent ); } catch (css::uno::RuntimeException const &) {
DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); throw;
try } catch (css::ucb::CommandAbortedException const &) {
{ assert(false); // this cannot happen
Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () ); throw;
bRet = aCnt.isFolder(); } catch (css::uno::Exception const &) {
} css::uno::Any e(cppu::getCaughtException());
catch( ::com::sun::star::ucb::CommandAbortedException& ) SAL_INFO(
{ "unotools",
DBG_WARNING( "CommandAbortedException" ); "UCBContentHelper::IsDocument(" << url << ") "
} << e.getValueType().getTypeName() << " \""
catch( ::com::sun::star::ucb::IllegalIdentifierException& ) << e.get<css::uno::Exception>().Message << '"');
{ return false;
DBG_WARNING( "IllegalIdentifierException" );
}
catch( ContentCreationException& )
{
DBG_WARNING( "IllegalIdentifierException" );
}
catch( ::com::sun::star::uno::Exception& )
{
DBG_WARNING( "Any other exception" );
} }
return bRet;
} }
// ----------------------------------------------------------------------- css::uno::Any utl::UCBContentHelper::GetProperty(
rtl::OUString const & url, rtl::OUString const & property)
sal_Bool UCBContentHelper::GetTitle( const String& rContent, String& rTitle )
{ {
sal_Bool bRet = sal_False; try {
INetURLObject aObj( rContent ); return content(url).getPropertyValue(property);
DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); } catch (css::uno::RuntimeException const &) {
try throw;
{ } catch (css::ucb::CommandAbortedException const &) {
Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () ); assert(false); // this cannot happen
OUString aTemp; throw;
if ( aCnt.getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Title")) ) >>= aTemp ) } catch (css::uno::Exception const &) {
{ css::uno::Any e(cppu::getCaughtException());
rTitle = String( aTemp ); SAL_INFO(
bRet = sal_True; "unotools",
} "UCBContentHelper::GetProperty(" << url << ", " << property << ") "
} << e.getValueType().getTypeName() << " \""
catch( ::com::sun::star::ucb::CommandAbortedException& ) << e.get<css::uno::Exception>().Message << '"');
{ return css::uno::Any();
} }
catch( ::com::sun::star::uno::Exception& )
{
}
return bRet;
} }
// ----------------------------------------------------------------------- bool utl::UCBContentHelper::IsFolder(rtl::OUString const & url) {
try {
sal_Bool UCBContentHelper::Kill( const String& rContent ) return content(url).isFolder();
{ } catch (css::uno::RuntimeException const &) {
sal_Bool bRet = sal_True; throw;
INetURLObject aDeleteObj( rContent ); } catch (css::ucb::CommandAbortedException const &) {
DBG_ASSERT( aDeleteObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); assert(false); // this cannot happen
throw;
try } catch (css::uno::Exception const &) {
{ css::uno::Any e(cppu::getCaughtException());
Content aCnt( aDeleteObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () ); SAL_INFO(
aCnt.executeCommand( OUString(RTL_CONSTASCII_USTRINGPARAM("delete")), makeAny( sal_Bool( sal_True ) ) ); "unotools",
"UCBContentHelper::IsFolder(" << url << ") "
<< e.getValueType().getTypeName() << " \""
<< e.get<css::uno::Exception>().Message << '"');
return false;
} }
catch( ::com::sun::star::ucb::CommandAbortedException& )
{
DBG_WARNING( "CommandAbortedException" );
bRet = sal_False;
}
catch( ::com::sun::star::uno::Exception& )
{
DBG_WARNING( "Any other exception" );
bRet = sal_False;
}
return bRet;
} }
// ----------------------------------------------------------------------- bool utl::UCBContentHelper::GetTitle(
rtl::OUString const & url, rtl::OUString * title)
Sequence < OUString > UCBContentHelper::GetFolderContents( const String& rFolder, sal_Bool bFolder, sal_Bool bSorted )
{ {
StringList_Impl* pFiles = NULL; assert(title != 0);
INetURLObject aFolderObj( rFolder ); try {
DBG_ASSERT( aFolderObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); *title = content(url).
try getPropertyValue(
{ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title"))).
Content aCnt( aFolderObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () ); get<rtl::OUString>();
uno::Reference< XResultSet > xResultSet; return true;
Sequence< OUString > aProps( bSorted ? 2 : 1 ); } catch (css::uno::RuntimeException const &) {
OUString* pProps = aProps.getArray(); throw;
pProps[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("Title")); } catch (css::ucb::CommandAbortedException const &) {
if ( bSorted ) assert(false); // this cannot happen
pProps[1] = OUString(RTL_CONSTASCII_USTRINGPARAM("IsFolder")); throw;
} catch (css::uno::Exception const &) {
try css::uno::Any e(cppu::getCaughtException());
{ SAL_INFO(
ResultSetInclude eInclude = bFolder ? INCLUDE_FOLDERS_AND_DOCUMENTS : INCLUDE_DOCUMENTS_ONLY; "unotools",
if ( !bSorted ) "UCBContentHelper::GetTitle(" << url << ") "
{ << e.getValueType().getTypeName() << " \""
xResultSet = aCnt.createCursor( aProps, eInclude ); << e.get<css::uno::Exception>().Message << '"');
} return false;
else
{
uno::Reference< com::sun::star::ucb::XDynamicResultSet > xDynResultSet;
xDynResultSet = aCnt.createDynamicCursor( aProps, eInclude );
uno::Reference < com::sun::star::ucb::XAnyCompareFactory > xFactory;
uno::Reference < XMultiServiceFactory > xMgr = getProcessServiceFactory();
uno::Reference < com::sun::star::ucb::XSortedDynamicResultSetFactory > xSRSFac(
xMgr->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SortedDynamicResultSetFactory")) ), UNO_QUERY );
Sequence< com::sun::star::ucb::NumberedSortingInfo > aSortInfo( 2 );
com::sun::star::ucb::NumberedSortingInfo* pInfo = aSortInfo.getArray();
pInfo[ 0 ].ColumnIndex = 2;
pInfo[ 0 ].Ascending = sal_False;
pInfo[ 1 ].ColumnIndex = 1;
pInfo[ 1 ].Ascending = sal_True;
uno::Reference< com::sun::star::ucb::XDynamicResultSet > xDynamicResultSet;
xDynamicResultSet =
xSRSFac->createSortedDynamicResultSet( xDynResultSet, aSortInfo, xFactory );
if ( xDynamicResultSet.is() )
{
xResultSet = xDynamicResultSet->getStaticResultSet();
}
}
}
catch( ::com::sun::star::ucb::CommandAbortedException& )
{
// folder not exists?
}
catch( ::com::sun::star::uno::Exception& )
{
}
if ( xResultSet.is() )
{
pFiles = new StringList_Impl;
uno::Reference< com::sun::star::ucb::XContentAccess > xContentAccess( xResultSet, UNO_QUERY );
try
{
while ( xResultSet->next() )
{
OUString aId = xContentAccess->queryContentIdentifierString();
OUString* pFile = new OUString( aId );
pFiles->push_back( pFile );
}
}
catch( ::com::sun::star::ucb::CommandAbortedException& )
{
}
catch( ::com::sun::star::uno::Exception& )
{
}
}
}
catch( ::com::sun::star::uno::Exception& )
{
} }
}
if ( pFiles ) bool utl::UCBContentHelper::Kill(rtl::OUString const & url) {
{ try {
size_t nCount = pFiles->size(); content(url).executeCommand(
Sequence < OUString > aRet( nCount ); rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("delete")),
OUString* pRet = aRet.getArray(); css::uno::makeAny(true));
for ( size_t i = 0; i < nCount; ++i ) return true;
{ } catch (css::uno::RuntimeException const &) {
OUString* pFile = (*pFiles)[ i ]; throw;
pRet[i] = *( pFile ); } catch (css::ucb::CommandAbortedException const &) {
delete pFile; assert(false); // this cannot happen
} throw;
delete pFiles; } catch (css::uno::Exception const &) {
return aRet; css::uno::Any e(cppu::getCaughtException());
SAL_INFO(
"unotools",
"UCBContentHelper::Kill(" << url << ") "
<< e.getValueType().getTypeName() << " \""
<< e.get<css::uno::Exception>().Message << '"');
return false;
} }
else
return Sequence < OUString > ();
} }
// ----------------------------------------------------------------------- bool utl::UCBContentHelper::MakeFolder(
rtl::OUString const & url, bool exclusive)
sal_Bool UCBContentHelper::MakeFolder( const String& rFolder, sal_Bool bNewOnly )
{ {
INetURLObject aURL( rFolder ); INetURLObject o(url);
DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); SAL_WARN_IF(o.HasError(), "unotools", "Invalid URL \"" << url << '"');
String aTitle = aURL.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ); rtl::OUString title(
aURL.removeSegment(); o.getName(
Content aCnt; INetURLObject::LAST_SEGMENT, true,
Content aNew; INetURLObject::DECODE_WITH_CHARSET));
uno::Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); o.removeSegment();
uno::Reference< XInteractionHandler > xInteractionHandler = uno::Reference< XInteractionHandler > ( ucbhelper::Content parent;
xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uui.InteractionHandler") ) ), UNO_QUERY ); ucbhelper::Content res;
if ( Content::create( aURL.GetMainURL( INetURLObject::NO_DECODE ), new CommandEnvironment( xInteractionHandler, uno::Reference< XProgressHandler >() ), aCnt ) ) return
return MakeFolder( aCnt, aTitle, aNew, bNewOnly ); ucbhelper::Content::create(
else o.GetMainURL(INetURLObject::NO_DECODE),
return sal_False; new ucbhelper::CommandEnvironment(
css::uno::Reference<css::task::XInteractionHandler>(
(css::uno::Reference<css::lang::XMultiServiceFactory>(
comphelper::getProcessServiceFactory(),
css::uno::UNO_SET_THROW)->
createInstance(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.uui.InteractionHandler")))),
css::uno::UNO_QUERY_THROW),
css::uno::Reference<css::ucb::XProgressHandler>()),
parent)
&& MakeFolder(parent, title, res, exclusive);
} }
sal_Bool UCBContentHelper::MakeFolder( Content& aCnt, const String& aTitle, Content& rNew, sal_Bool bNewOnly ) bool utl::UCBContentHelper::MakeFolder(
ucbhelper::Content & parent, rtl::OUString const & title,
ucbhelper::Content & result, bool exclusive)
{ {
sal_Bool bAlreadyExists = sal_False; bool exists = false;
try {
try css::uno::Sequence<css::ucb::ContentInfo> info(
{ parent.queryCreatableContentsInfo());
Sequence< ContentInfo > aInfo = aCnt.queryCreatableContentsInfo(); for (sal_Int32 i = 0; i < info.getLength(); ++i) {
sal_Int32 nCount = aInfo.getLength(); // Simply look for the first KIND_FOLDER:
if ( nCount == 0 ) if ((info[i].Attributes
return sal_False; & css::ucb::ContentInfoAttribute::KIND_FOLDER)
!= 0)
for ( sal_Int32 i = 0; i < nCount; ++i )
{
// Simply look for the first KIND_FOLDER...
const ContentInfo & rCurr = aInfo[i];
if ( rCurr.Attributes & ContentInfoAttribute::KIND_FOLDER )
{ {
// Make sure the only required bootstrap property is "Title", // Make sure the only required bootstrap property is "Title":
const Sequence< Property > & rProps = rCurr.Properties; if (info[i].Properties.getLength() != 1
if ( rProps.getLength() != 1 ) || !info[i].Properties[0].Name.equalsAsciiL(
continue; RTL_CONSTASCII_STRINGPARAM("Title")))
{
if ( !rProps[ 0 ].Name.equalsAsciiL(
RTL_CONSTASCII_STRINGPARAM( "Title" ) ) )
continue;
Sequence<OUString> aNames(1);
OUString* pNames = aNames.getArray();
pNames[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) );
Sequence<Any> aValues(1);
Any* pValues = aValues.getArray();
pValues[0] = makeAny( OUString( aTitle ) );
if ( !aCnt.insertNewContent( rCurr.Type, aNames, aValues, rNew ) )
continue; continue;
}
return sal_True; css::uno::Sequence<rtl::OUString> keys(1);
keys[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title"));
css::uno::Sequence<css::uno::Any> values(1);
values[0] <<= title;
if (parent.insertNewContent(info[i].Type, keys, values, result))
{
return true;
}
} }
} }
} } catch (css::ucb::InteractiveIOException const & e) {
catch ( InteractiveIOException& r ) if (e.Code == css::ucb::IOErrorCode_ALREADY_EXISTING) {
{ exists = true;
if ( r.Code == IOErrorCode_ALREADY_EXISTING ) } else {
{ SAL_INFO(
bAlreadyExists = sal_True; "unotools",
"UCBContentHelper::MakeFolder(" << title
<< ") InteractiveIOException \"" << e.Message
<< "\", code " << +e.Code);
} }
} catch (css::ucb::NameClashException const &) {
exists = true;
} catch (css::uno::RuntimeException const &) {
throw;
} catch (css::ucb::CommandAbortedException const &) {
assert(false); // this cannot happen
throw;
} catch (css::uno::Exception const &) {
css::uno::Any e(cppu::getCaughtException());
SAL_INFO(
"unotools",
"UCBContentHelper::MakeFolder(" << title << ") "
<< e.getValueType().getTypeName() << " \""
<< e.get<css::uno::Exception>().Message << '"');
}
if (exists && !exclusive) {
INetURLObject o(parent.getURL());
o.Append(title);
result = content(o);
return true;
} else {
return false;
} }
catch ( NameClashException& )
{
bAlreadyExists = sal_True;
}
catch( ::com::sun::star::ucb::CommandAbortedException& )
{
}
catch( RuntimeException& )
{
}
catch( Exception& )
{
}
if( bAlreadyExists && !bNewOnly )
{
INetURLObject aObj( aCnt.getURL() );
aObj.Append( aTitle );
rNew = Content( aObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference < XCommandEnvironment >() );
return sal_True;
}
return sal_False;
} }
// ----------------------------------------------------------------------- sal_Int64 utl::UCBContentHelper::GetSize(rtl::OUString const & url) {
try {
sal_uLong UCBContentHelper::GetSize( const String& rContent ) return
{ content(url).getPropertyValue(
sal_uLong nSize = 0; rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Size"))).
sal_Int64 nTemp = 0; get<sal_Int64>();
INetURLObject aObj( rContent ); } catch (css::uno::RuntimeException const &) {
DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); throw;
try } catch (css::ucb::CommandAbortedException const &) {
{ assert(false); // this cannot happen
Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () ); throw;
aCnt.getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Size")) ) >>= nTemp; } catch (css::uno::Exception const &) {
} css::uno::Any e(cppu::getCaughtException());
catch( ::com::sun::star::ucb::CommandAbortedException& ) SAL_INFO(
{ "unotools",
"UCBContentHelper::GetSize(" << url << ") "
<< e.getValueType().getTypeName() << " \""
<< e.get<css::uno::Exception>().Message << '"');
return 0;
} }
catch( ::com::sun::star::uno::Exception& )
{
}
nSize = (sal_uInt32)nTemp;
return nSize;
} }
// ----------------------------------------------------------------------- bool utl::UCBContentHelper::IsYounger(
rtl::OUString const & younger, rtl::OUString const & older)
sal_Bool UCBContentHelper::IsYounger( const String& rIsYoung, const String& rIsOlder )
{ {
DateTime aYoungDate, aOlderDate; try {
INetURLObject aYoungObj( rIsYoung ); return
DBG_ASSERT( aYoungObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); convert(
INetURLObject aOlderObj( rIsOlder ); content(younger).getPropertyValue(
DBG_ASSERT( aOlderObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DateModified"))).
try get<css::util::DateTime>())
{ > convert(
uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > aCmdEnv; content(older).getPropertyValue(
Content aYoung( aYoungObj.GetMainURL( INetURLObject::NO_DECODE ), aCmdEnv ); rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DateModified"))).
::com::sun::star::util::DateTime aTempYoungDate; get<css::util::DateTime>());
aYoung.getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DateModified")) ) >>= aTempYoungDate; } catch (css::uno::RuntimeException const &) {
CONVERT_DATETIME( aTempYoungDate, aYoungDate ); throw;
Content aOlder( aOlderObj.GetMainURL( INetURLObject::NO_DECODE ), aCmdEnv ); } catch (css::ucb::CommandAbortedException const &) {
::com::sun::star::util::DateTime aTempOlderDate; assert(false); // this cannot happen
aOlder.getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DateModified")) ) >>= aTempOlderDate; throw;
CONVERT_DATETIME( aTempOlderDate, aOlderDate ); } catch (css::uno::Exception const &) {
css::uno::Any e(cppu::getCaughtException());
SAL_INFO(
"unotools",
"UCBContentHelper::IsYounger(" << younger << ", " << older << ") "
<< e.getValueType().getTypeName() << " \""
<< e.get<css::uno::Exception>().Message << '"');
return false;
} }
catch( ::com::sun::star::ucb::CommandAbortedException& )
{
}
catch( ::com::sun::star::uno::Exception& )
{
}
return ( aYoungDate > aOlderDate );
} }
// ----------------------------------------------------------------------- bool utl::UCBContentHelper::Exists(rtl::OUString const & url) {
sal_Bool UCBContentHelper::Exists( const String& rURL ) rtl::OUString pathname;
{ if (utl::LocalFileHelper::ConvertURLToPhysicalName(url, pathname)) {
// Try to create a directory entry for the given URL:
String sObjectPhysicalName; rtl::OUString url2;
sal_Bool bIsLocalFile = ::utl::LocalFileHelper::ConvertURLToPhysicalName( rURL, sObjectPhysicalName ); if (osl::FileBase::getFileURLFromSystemPath(pathname, url2)
// try to create a directory entry for the URL given == osl::FileBase::E_None)
if ( bIsLocalFile )
{
::rtl::OUString sIn( sObjectPhysicalName ), sOut;
if ( osl_File_E_None == osl_getFileURLFromSystemPath( sIn.pData, &sOut.pData ) )
{ {
// #106526 osl_getDirectoryItem is an existence check // #106526 osl_getDirectoryItem is an existence check, no further
// no further osl_getFileStatus call necessary // osl_getFileStatus call necessary:
DirectoryItem aItem; osl::DirectoryItem item;
return (FileBase::E_None == DirectoryItem::get(sOut, aItem)); return osl::DirectoryItem::get(url2, item) == osl::FileBase::E_None;
} else {
return false;
} }
return sal_False; } else {
} // Divide URL into folder and name part:
INetURLObject o(url);
// divide URL into folder and name part rtl::OUString name(
sal_Bool bRet = sal_False; o.getName(
INetURLObject aObj( rURL ); INetURLObject::LAST_SEGMENT, true,
::rtl::OUString aFileName = aObj.getName( INetURLObject::DECODE_WITH_CHARSET));
INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ).toAsciiLowerCase(); o.removeSegment();
aObj.removeSegment(); o.removeFinalSlash();
aObj.removeFinalSlash(); std::vector<rtl::OUString> cs(
getContents(o.GetMainURL(INetURLObject::NO_DECODE)));
// get a list of URLs for all children of rFolder for (std::vector<rtl::OUString>::iterator i(cs.begin()); i != cs.end();
Sequence< ::rtl::OUString > aFiles = GetFolderContents( aObj.GetMainURL( INetURLObject::NO_DECODE ), sal_True, sal_False ); ++i)
const ::rtl::OUString* pFiles = aFiles.getConstArray();
sal_uInt32 i, nCount = aFiles.getLength();
for ( i = 0; i < nCount; ++i )
{
// get the last name of the URLs and compare it with rName
INetURLObject aFileObject( pFiles[i] );
::rtl::OUString aFile = aFileObject.getName(
INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ).toAsciiLowerCase();
if ( aFile == aFileName )
{ {
// names match if (INetURLObject(*i).getName(
bRet = sal_True; INetURLObject::LAST_SEGMENT, true,
break; INetURLObject::DECODE_WITH_CHARSET).
} equalsIgnoreAsciiCase(name))
}
return bRet;
}
// -----------------------------------------------------------------------
sal_Bool UCBContentHelper::IsSubPath( const ::rtl::OUString& rPath, const ::rtl::OUString& rSubfolderCandidate, const uno::Reference< ::com::sun::star::ucb::XContentProvider >& xProv )
{
sal_Bool bResult = sal_False;
uno::Reference< ::com::sun::star::ucb::XContentProvider > xContentProvider = xProv;
// the comparing is done in the following way:
// - first compare in case sensitive way
// - if name are different try a fallback comparing inf case insensitive way
// - if the last comparing succeeded get casepreserving normalized names for the files and compare them
// ( the second step is required because retrieving of the normalized names might be very expensive in some cases )
INetURLObject aCandidate( rSubfolderCandidate );
INetURLObject aCandidateLowCase( rSubfolderCandidate.toAsciiLowerCase() ); // will be used for case insensitive comparing
INetURLObject aParentFolder( rPath );
INetURLObject aParentFolderLowCase( rPath.toAsciiLowerCase() ); // will be used for case insensitive comparing
if ( aCandidate.GetProtocol() == aParentFolder.GetProtocol() )
{
if ( !xContentProvider.is() )
{
::ucbhelper::ContentBroker* pBroker = NULL;
if ( aCandidate.GetProtocol() == INET_PROT_FILE )
{ {
pBroker = ::ucbhelper::ContentBroker::get(); return true;
if ( pBroker )
xContentProvider = pBroker->getContentProviderInterface();
} }
} }
return false;
INetURLObject aLastTmpObj;
do
{
if ( aParentFolder == aCandidate )
{
// if case sensitive comparing succeeded there is no need for additional checks
bResult = sal_True;
}
else if ( xContentProvider.is() && aParentFolderLowCase == aCandidateLowCase )
{
// the comparing was done using caseinsensitive way
// the case sensitive comparing have failed already
// the normalized urls must be retrieved
try
{
uno::Reference< ::com::sun::star::ucb::XContent > xSecCont =
xContentProvider->queryContent(
uno::Reference< ::com::sun::star::ucb::XContentIdentifierFactory >(
xContentProvider, ::com::sun::star::uno::UNO_QUERY_THROW )->createContentIdentifier(
aParentFolder.GetMainURL( INetURLObject::NO_DECODE ) ) );
uno::Reference< ::com::sun::star::ucb::XContent > xLocCont =
xContentProvider->queryContent(
uno::Reference< ::com::sun::star::ucb::XContentIdentifierFactory >(
xContentProvider, ::com::sun::star::uno::UNO_QUERY_THROW )->createContentIdentifier(
aCandidate.GetMainURL( INetURLObject::NO_DECODE ) ) );
if ( !xSecCont.is() || !xLocCont.is() )
throw ::com::sun::star::uno::RuntimeException();
::rtl::OUString aSecNormStr;
::rtl::OUString aLocNormStr;
bResult =
( ( uno::Reference< ::com::sun::star::ucb::XCommandProcessor >(
xSecCont, ::com::sun::star::uno::UNO_QUERY_THROW )->execute(
::com::sun::star::ucb::Command(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getCasePreservingURL" ) ),
-1,
::com::sun::star::uno::Any() ),
0,
uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() )
>>= aSecNormStr )
&& ( uno::Reference< ::com::sun::star::ucb::XCommandProcessor >(
xLocCont, ::com::sun::star::uno::UNO_QUERY_THROW )->execute(
::com::sun::star::ucb::Command(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getCasePreservingURL" ) ),
-1,
::com::sun::star::uno::Any() ),
0,
uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() )
>>= aLocNormStr )
&& aLocNormStr.equals( aSecNormStr ) );
}
catch( ::com::sun::star::uno::Exception& )
{}
}
// INetURLObject::removeSegment sometimes return true without exchanging URL,
// for example in case of "file:///"
aLastTmpObj = aCandidate;
} while( aCandidate.removeSegment() && aCandidateLowCase.removeSegment() && aCandidate != aLastTmpObj && !bResult );
} }
return bResult;
} }
// ----------------------------------------------------------------------- bool utl::UCBContentHelper::IsSubPath(
sal_Bool UCBContentHelper::EqualURLs( const ::rtl::OUString& aFirstURL, const ::rtl::OUString& aSecondURL ) rtl::OUString const & parent, rtl::OUString const & child)
{ {
sal_Bool bResult = sal_False; // The comparison is done in the following way:
// - First, compare case sensitively
if ( aFirstURL.getLength() && aSecondURL.getLength() ) // - If names are different, try a fallback comparing case insensitively
{ // - If the last comparison succeeded, get case preserving normalized names
INetURLObject aFirst( aFirstURL ); // for the files and compare them
INetURLObject aSecond( aSecondURL ); // (The second step is required because retrieving the normalized names
// might be very expensive in some cases.)
if ( aFirst.GetProtocol() != INET_PROT_NOT_VALID && aSecond.GetProtocol() != INET_PROT_NOT_VALID ) INetURLObject candidate(child);
{ INetURLObject folder(parent);
try if (candidate.GetProtocol() != folder.GetProtocol()) {
return false;
}
INetURLObject candidateLower(child.toAsciiLowerCase());
INetURLObject folderLower(parent.toAsciiLowerCase());
try {
INetURLObject tmp;
do {
if (candidate == folder
|| (candidate.GetProtocol() == INET_PROT_FILE
&& candidateLower == folderLower
&& (getCasePreservingUrl(candidate)
== getCasePreservingUrl(folder))))
{ {
::ucbhelper::ContentBroker* pBroker = ::ucbhelper::ContentBroker::get(); return true;
if ( !pBroker )
throw uno::RuntimeException();
uno::Reference< ::com::sun::star::ucb::XContentIdentifierFactory > xIdFac
= pBroker->getContentIdentifierFactoryInterface();
if ( !xIdFac.is() )
throw uno::RuntimeException();
uno::Reference< ::com::sun::star::ucb::XContentIdentifier > xIdFirst
= xIdFac->createContentIdentifier( aFirst.GetMainURL( INetURLObject::NO_DECODE ) );
uno::Reference< ::com::sun::star::ucb::XContentIdentifier > xIdSecond
= xIdFac->createContentIdentifier( aSecond.GetMainURL( INetURLObject::NO_DECODE ) );
if ( xIdFirst.is() && xIdSecond.is() )
{
uno::Reference< ::com::sun::star::ucb::XContentProvider > xProvider =
pBroker->getContentProviderInterface();
if ( !xProvider.is() )
throw uno::RuntimeException();
bResult = !xProvider->compareContentIds( xIdFirst, xIdSecond );
}
} }
catch( uno::Exception& ) tmp = candidate;
{ } while (candidate.removeSegment() && candidateLower.removeSegment()
OSL_FAIL( "Can't compare URL's, treat as different!\n" ); && candidate != tmp);
} // INetURLObject::removeSegment sometimes returns true without
} // modifying the URL, e.g., in case of "file:///"
} } catch (css::uno::RuntimeException const &) {
throw;
return bResult; } catch (css::ucb::CommandAbortedException const &) {
assert(false); // this cannot happen
throw;
} catch (css::uno::Exception const &) {
css::uno::Any e(cppu::getCaughtException());
SAL_INFO(
"unotools",
"UCBContentHelper::IsSubPath(" << parent << ", " << child << ") "
<< e.getValueType().getTypeName() << " \""
<< e.get<css::uno::Exception>().Message << '"');
}
return false;
} }
bool utl::UCBContentHelper::EqualURLs(
rtl::OUString const & url1, rtl::OUString const & url2)
} // namespace utl {
if (url1.isEmpty() || url2.isEmpty()) {
return false;
}
ucbhelper::ContentBroker * broker = ucbhelper::ContentBroker::get();
if (broker == 0) {
throw css::uno::RuntimeException(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("no ucbhelper::ContentBroker")),
css::uno::Reference<css::uno::XInterface>());
}
return broker->getContentProviderInterface()->compareContentIds(
(broker->getContentIdentifierFactoryInterface()->
createContentIdentifier(canonic(url1))),
(broker->getContentIdentifierFactoryInterface()->
createContentIdentifier(canonic(url2))));
}
/* 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