summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-02-25 14:51:22 +0100
committerTomaž Vajngerl <quikee@gmail.com>2020-02-26 07:04:59 +0100
commitb90eaab5c51c2b0f2aba66da35a5b494c3211f1d (patch)
treef301added320a8f32af0bcfaea828e5b54fd10c2 /vcl
parent6d9cf22b2239611a6612a7855f8a701ed723cbd4 (diff)
vcl: use UCBContentHelper in instead of implement own functions
Change-Id: Iea617c8b5d3aa5f755b70ff2b6e00e8372057df0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89478 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/filter/graphicfilter.cxx56
1 files changed, 5 insertions, 51 deletions
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index c32015e7d222..9ae7e393c8b7 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -64,6 +64,7 @@
#include <rtl/instance.hxx>
#include <tools/svlibrary.h>
#include <comphelper/string.hxx>
+#include <unotools/ucbhelper.hxx>
#include <vector>
#include <memory>
@@ -103,54 +104,6 @@ public:
}
-static bool DirEntryExists( const INetURLObject& rObj )
-{
- bool bExists = false;
-
- try
- {
- ::ucbhelper::Content aCnt( rObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ),
- css::uno::Reference< css::ucb::XCommandEnvironment >(),
- comphelper::getProcessComponentContext() );
-
- bExists = aCnt.isDocument();
- }
- catch(const css::ucb::CommandAbortedException&)
- {
- SAL_WARN( "vcl.filter", "CommandAbortedException" );
- }
- catch(const css::ucb::ContentCreationException&)
- {
- SAL_WARN( "vcl.filter", "ContentCreationException" );
- }
- catch( ... )
- {
- SAL_WARN( "vcl.filter", "Any other exception" );
- }
- return bExists;
-}
-
-static void KillDirEntry( const OUString& rMainUrl )
-{
- try
- {
- ::ucbhelper::Content aCnt( rMainUrl,
- css::uno::Reference< css::ucb::XCommandEnvironment >(),
- comphelper::getProcessComponentContext() );
-
- aCnt.executeCommand( "delete",
- css::uno::makeAny( true ) );
- }
- catch(const css::ucb::CommandAbortedException&)
- {
- SAL_WARN( "vcl.filter", "CommandAbortedException" );
- }
- catch( ... )
- {
- SAL_WARN( "vcl.filter", "Any other exception" );
- }
-}
-
// Helper functions
sal_uInt8* ImplSearchEntry( sal_uInt8* pSource, sal_uInt8 const * pDest, sal_uLong nComp, sal_uLong nSize )
@@ -1881,9 +1834,10 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const INetURLObje
SAL_INFO( "vcl.filter", "GraphicFilter::ExportGraphic() (thb)" );
ErrCode nRetValue = ERRCODE_GRFILTER_FORMATERROR;
SAL_WARN_IF( rPath.GetProtocol() == INetProtocol::NotValid, "vcl.filter", "GraphicFilter::ExportGraphic() : ProtType == INetProtocol::NotValid" );
- bool bAlreadyExists = DirEntryExists( rPath );
- OUString aMainUrl( rPath.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
+ OUString aMainUrl(rPath.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+ bool bAlreadyExists = utl::UCBContentHelper::IsDocument(aMainUrl);
+
std::unique_ptr<SvStream> xStream(::utl::UcbStreamHelper::CreateStream( aMainUrl, StreamMode::WRITE | StreamMode::TRUNC ));
if (xStream)
{
@@ -1891,7 +1845,7 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const INetURLObje
xStream.reset();
if( ( ERRCODE_NONE != nRetValue ) && !bAlreadyExists )
- KillDirEntry( aMainUrl );
+ utl::UCBContentHelper::Kill(aMainUrl);
}
return nRetValue;
}