[Libreoffice-commits] core.git: vcl/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 26 06:05:34 UTC 2020


 vcl/source/filter/graphicfilter.cxx |   56 +++---------------------------------
 1 file changed, 5 insertions(+), 51 deletions(-)

New commits:
commit b90eaab5c51c2b0f2aba66da35a5b494c3211f1d
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue Feb 25 14:51:22 2020 +0100
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Feb 26 07:04:59 2020 +0100

    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 at gmail.com>

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;
 }


More information about the Libreoffice-commits mailing list