LCOV - code coverage report
Current view: top level - fileaccess/source - FileAccess.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 152 322 47.2 %
Date: 2012-08-25 Functions: 26 43 60.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 171 708 24.2 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #include <osl/mutex.hxx>
      21                 :            : #include <osl/diagnose.h>
      22                 :            : 
      23                 :            : #include <uno/mapping.hxx>
      24                 :            : 
      25                 :            : #include <cppuhelper/factory.hxx>
      26                 :            : #include <cppuhelper/implbase1.hxx>
      27                 :            : 
      28                 :            : #include <tools/urlobj.hxx>
      29                 :            : #include <ucbhelper/content.hxx>
      30                 :            : #include <unotools/streamwrap.hxx>
      31                 :            : #include <tools/stream.hxx>
      32                 :            : 
      33                 :            : #include <com/sun/star/beans/Property.hpp>
      34                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      35                 :            : #include <com/sun/star/container/XChild.hpp>
      36                 :            : #include <com/sun/star/io/XActiveDataSink.hpp>
      37                 :            : #include <com/sun/star/io/XActiveDataSource.hpp>
      38                 :            : #include <com/sun/star/io/XActiveDataStreamer.hpp>
      39                 :            : #include <com/sun/star/sdbc/XResultSet.hpp>
      40                 :            : #include <com/sun/star/ucb/CommandFailedException.hpp>
      41                 :            : #include <com/sun/star/ucb/ContentInfo.hpp>
      42                 :            : #include <com/sun/star/ucb/ContentInfoAttribute.hpp>
      43                 :            : #include <com/sun/star/ucb/InsertCommandArgument.hpp>
      44                 :            : #include <com/sun/star/ucb/InteractiveIOException.hpp>
      45                 :            : #include <com/sun/star/ucb/NameClash.hpp>
      46                 :            : #include <com/sun/star/ucb/NameClashException.hpp>
      47                 :            : #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
      48                 :            : #include <com/sun/star/ucb/OpenMode.hpp>
      49                 :            : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
      50                 :            : #include <com/sun/star/ucb/XContent.hpp>
      51                 :            : #include <com/sun/star/ucb/XContentAccess.hpp>
      52                 :            : #include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
      53                 :            : #include <com/sun/star/util/XMacroExpander.hpp>
      54                 :            : 
      55                 :            : #include <vector>
      56                 :            : 
      57                 :            : #define IMPLEMENTATION_NAME "com.sun.star.comp.ucb.SimpleFileAccess"
      58                 :            : #define SERVICE_NAME "com.sun.star.ucb.SimpleFileAccess"
      59                 :            : 
      60                 :            : using namespace ::com::sun::star::uno;
      61                 :            : using namespace ::com::sun::star::lang;
      62                 :            : using namespace ::com::sun::star::io;
      63                 :            : using namespace ::com::sun::star::ucb;
      64                 :            : using namespace ::com::sun::star::sdbc;
      65                 :            : using namespace ::com::sun::star::task;
      66                 :            : using namespace ::com::sun::star::util;
      67                 :            : using namespace ::com::sun::star::beans;
      68                 :            : using namespace ::com::sun::star::registry;
      69                 :            : using namespace ::com::sun::star::container;
      70                 :            : 
      71                 :            : using ::std::vector;
      72                 :            : 
      73                 :            : namespace
      74                 :            : {
      75                 :            : 
      76                 :            : 
      77                 :            : //===========================================================================
      78                 :            : // Implementation XSimpleFileAccess
      79                 :            : 
      80                 :            : typedef cppu::WeakImplHelper1< XSimpleFileAccess3 > FileAccessHelper;
      81                 :            : class OCommandEnvironment;
      82                 :            : 
      83         [ -  + ]:       7870 : class OFileAccess : public FileAccessHelper
      84                 :            : {
      85                 :            :     Reference< XMultiServiceFactory > mxSMgr;
      86                 :            :     Reference< XCommandEnvironment > mxEnvironment;
      87                 :            :     OCommandEnvironment* mpEnvironment;
      88                 :            : 
      89                 :            :     void transferImpl( const rtl::OUString& rSource, const rtl::OUString& rDest, sal_Bool bMoveData )
      90                 :            :         throw(CommandAbortedException, Exception, RuntimeException);
      91                 :            :     bool createNewFile( const rtl::OUString & rParentURL,
      92                 :            :                         const rtl::OUString & rTitle,
      93                 :            :                         const Reference< XInputStream >& data )
      94                 :            :         throw ( Exception );
      95                 :            : 
      96                 :            : public:
      97                 :       4081 :     OFileAccess( const Reference< XMultiServiceFactory > & xSMgr )
      98                 :       4081 :         : mxSMgr( xSMgr), mpEnvironment( NULL ) {}
      99                 :            : 
     100                 :            :     // Methods
     101                 :            :     virtual void SAL_CALL copy( const ::rtl::OUString& SourceURL, const ::rtl::OUString& DestURL ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     102                 :            :     virtual void SAL_CALL move( const ::rtl::OUString& SourceURL, const ::rtl::OUString& DestURL ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     103                 :            :     virtual void SAL_CALL kill( const ::rtl::OUString& FileURL ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     104                 :            :     virtual sal_Bool SAL_CALL isFolder( const ::rtl::OUString& FileURL ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     105                 :            :     virtual sal_Bool SAL_CALL isReadOnly( const ::rtl::OUString& FileURL ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     106                 :            :     virtual void SAL_CALL setReadOnly( const ::rtl::OUString& FileURL, sal_Bool bReadOnly ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     107                 :            :     virtual void SAL_CALL createFolder( const ::rtl::OUString& NewFolderURL ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     108                 :            :     virtual sal_Int32 SAL_CALL getSize( const ::rtl::OUString& FileURL ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     109                 :            :     virtual ::rtl::OUString SAL_CALL getContentType( const ::rtl::OUString& FileURL ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     110                 :            :     virtual ::com::sun::star::util::DateTime SAL_CALL getDateTimeModified( const ::rtl::OUString& FileURL ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     111                 :            :     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFolderContents( const ::rtl::OUString& FolderURL, sal_Bool bIncludeFolders ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     112                 :            :     virtual sal_Bool SAL_CALL exists( const ::rtl::OUString& FileURL ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     113                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL openFileRead( const ::rtl::OUString& FileURL ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     114                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL openFileWrite( const ::rtl::OUString& FileURL ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     115                 :            :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > SAL_CALL openFileReadWrite( const ::rtl::OUString& FileURL ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     116                 :            :     virtual void SAL_CALL setInteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& Handler ) throw(::com::sun::star::uno::RuntimeException);
     117                 :            :     virtual void SAL_CALL writeFile( const ::rtl::OUString& FileURL, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& data ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     118                 :            :     virtual sal_Bool SAL_CALL isHidden( const ::rtl::OUString& FileURL ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     119                 :            :     virtual void SAL_CALL setHidden( const ::rtl::OUString& FileURL, sal_Bool bHidden ) throw(::com::sun::star::ucb::CommandAbortedException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
     120                 :            : };
     121                 :            : 
     122                 :            : 
     123                 :            : //===========================================================================
     124                 :            : // Implementation XActiveDataSink
     125                 :            : 
     126                 :            : typedef cppu::WeakImplHelper1< XActiveDataSink > ActiveDataSinkHelper;
     127                 :            : 
     128         [ -  + ]:       8271 : class OActiveDataSink : public ActiveDataSinkHelper
     129                 :            : {
     130                 :            :     Reference< XInputStream > mxStream;
     131                 :            : 
     132                 :            : public:
     133                 :            : 
     134                 :            :     // Methods
     135                 :            :     virtual void SAL_CALL setInputStream( const Reference< XInputStream >& aStream )
     136                 :            :         throw(RuntimeException);
     137                 :            :     virtual Reference< XInputStream > SAL_CALL getInputStream(  )
     138                 :            :         throw(RuntimeException);
     139                 :            : };
     140                 :            : 
     141                 :       2435 : void OActiveDataSink::setInputStream( const Reference< XInputStream >& aStream )
     142                 :            :     throw(RuntimeException)
     143                 :            : {
     144                 :       2435 :     mxStream = aStream;
     145                 :       2435 : }
     146                 :            : 
     147                 :       2435 : Reference< XInputStream > OActiveDataSink::getInputStream()
     148                 :            :     throw(RuntimeException)
     149                 :            : {
     150                 :       2435 :     return mxStream;
     151                 :            : }
     152                 :            : 
     153                 :            : 
     154                 :            : //===========================================================================
     155                 :            : // Implementation XActiveDataStreamer
     156                 :            : 
     157                 :            : typedef cppu::WeakImplHelper1< XActiveDataStreamer > ActiveDataStreamerHelper;
     158                 :            : 
     159         [ -  + ]:       3816 : class OActiveDataStreamer : public ActiveDataStreamerHelper
     160                 :            : {
     161                 :            :     Reference< XStream > mxStream;
     162                 :            : 
     163                 :            : public:
     164                 :            : 
     165                 :            :     // Methods
     166                 :            :     virtual void SAL_CALL setStream( const Reference< XStream >& aStream )
     167                 :            :         throw(RuntimeException);
     168                 :            :     virtual Reference< XStream > SAL_CALL getStream()
     169                 :            :         throw(RuntimeException);
     170                 :            : };
     171                 :            : 
     172                 :       1272 : void OActiveDataStreamer::setStream( const Reference< XStream >& aStream )
     173                 :            :     throw(RuntimeException)
     174                 :            : {
     175                 :       1272 :     mxStream = aStream;
     176                 :       1272 : }
     177                 :            : 
     178                 :        969 : Reference< XStream > OActiveDataStreamer::getStream()
     179                 :            :     throw(RuntimeException)
     180                 :            : {
     181                 :        969 :     return mxStream;
     182                 :            : }
     183                 :            : 
     184                 :            : 
     185                 :            : 
     186                 :            : //===========================================================================
     187                 :            : // Implementation XCommandEnvironment
     188                 :            : 
     189                 :            : typedef cppu::WeakImplHelper1< XCommandEnvironment > CommandEnvironmentHelper;
     190                 :            : 
     191         [ #  # ]:          0 : class OCommandEnvironment : public CommandEnvironmentHelper
     192                 :            : {
     193                 :            :     Reference< XInteractionHandler > mxInteraction;
     194                 :            : 
     195                 :            : public:
     196                 :          0 :     void setHandler( Reference< XInteractionHandler > xInteraction_ )
     197                 :            :     {
     198                 :          0 :         mxInteraction = xInteraction_;
     199                 :          0 :     }
     200                 :            : 
     201                 :            :     // Methods
     202                 :            :     virtual Reference< XInteractionHandler > SAL_CALL getInteractionHandler()
     203                 :            :         throw(RuntimeException);
     204                 :            :     virtual Reference< XProgressHandler > SAL_CALL getProgressHandler()
     205                 :            :         throw(RuntimeException);
     206                 :            : };
     207                 :            : 
     208                 :          0 : Reference< XInteractionHandler > OCommandEnvironment::getInteractionHandler()
     209                 :            :     throw(RuntimeException)
     210                 :            : {
     211                 :          0 :     return mxInteraction;
     212                 :            : }
     213                 :            : 
     214                 :          0 : Reference< XProgressHandler > OCommandEnvironment::getProgressHandler()
     215                 :            :     throw(RuntimeException)
     216                 :            : {
     217                 :          0 :     Reference< XProgressHandler > xRet;
     218                 :          0 :     return xRet;
     219                 :            : }
     220                 :            : 
     221                 :            : //===========================================================================
     222                 :            : 
     223                 :         82 : void OFileAccess::transferImpl( const rtl::OUString& rSource,
     224                 :            :                                 const rtl::OUString& rDest,
     225                 :            :                                 sal_Bool bMoveData )
     226                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     227                 :            : {
     228                 :            :     // SfxContentHelper::Transfer_Impl
     229         [ +  - ]:         82 :     INetURLObject aSourceObj( rSource, INET_PROT_FILE );
     230         [ +  - ]:         82 :     INetURLObject aDestObj( rDest, INET_PROT_FILE );
     231                 :            :     String aName = aDestObj.getName(
     232 [ +  - ][ +  - ]:         82 :         INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
     233         [ +  - ]:         82 :     String aDestURL;
     234 [ +  - ][ +  - ]:         82 :     String aSourceURL = aSourceObj.GetMainURL( INetURLObject::NO_DECODE );
     235 [ +  - ][ +  - ]:         82 :     if ( aDestObj.removeSegment() )
     236                 :            :     {
     237                 :            :         // hierarchical URL.
     238                 :            : 
     239         [ +  - ]:         82 :         aDestObj.setFinalSlash();
     240 [ +  - ][ +  - ]:         82 :         aDestURL = aDestObj.GetMainURL( INetURLObject::NO_DECODE );
     241                 :            :     }
     242                 :            :     else
     243                 :            :     {
     244                 :            :         // non-hierachical URL
     245                 :            : 
     246                 :            :         // #i29648#
     247                 :            :         //
     248                 :            : 
     249         [ #  # ]:          0 :         if ( aDestObj.GetProtocol() == INET_PROT_VND_SUN_STAR_EXPAND )
     250                 :            :         {
     251                 :            :             // Hack: Expand destination URL using Macro Expander and try again
     252                 :            :             //       with the hopefully hierarchical expanded URL...
     253                 :            : 
     254                 :            :             try
     255                 :            :             {
     256                 :          0 :                 Reference< XComponentContext > xCtx;
     257         [ #  # ]:          0 :                 Reference< XPropertySet > xPropSet( mxSMgr, UNO_QUERY_THROW );
     258         [ #  # ]:          0 :                 if ( xPropSet.is() )
     259                 :            :                 {
     260         [ #  # ]:          0 :                     xPropSet->getPropertyValue(
     261                 :            :                         rtl::OUString(
     262                 :          0 :                             "DefaultContext"  ) )
     263 [ #  # ][ #  # ]:          0 :                                 >>= xCtx;
     264                 :            :                 }
     265                 :            : 
     266                 :          0 :                 Reference< XMacroExpander > xExpander;
     267                 :            : 
     268         [ #  # ]:          0 :                 xCtx->getValueByName(
     269                 :          0 :                     rtl::OUString( "/singletons/com.sun.star.util.theMacroExpander"  ) )
     270 [ #  # ][ #  # ]:          0 :                             >>= xExpander;
     271                 :            : 
     272                 :            :                 OSL_ENSURE( xExpander.is(),
     273                 :            :                             "Unable to obtain macro expander singleton!" );
     274                 :            : 
     275         [ #  # ]:          0 :                 aDestURL = xExpander->expandMacros(
     276 [ #  # ][ #  # ]:          0 :                     aDestObj.GetURLPath( INetURLObject::DECODE_WITH_CHARSET ) );
                 [ #  # ]
     277                 :            :             }
     278         [ #  # ]:          0 :             catch ( Exception const & )
     279                 :            :             {
     280                 :            :                 throw RuntimeException(
     281                 :            :                     rtl::OUString( "OFileAccess::transferrImpl - Unable to obtain "
     282                 :            :                             "destination folder URL!"  ),
     283   [ #  #  #  # ]:          0 :                     static_cast< cppu::OWeakObject * >( this ) );
     284                 :            :             }
     285                 :            : 
     286 [ #  # ][ #  # ]:          0 :             transferImpl( rSource, aDestURL, bMoveData );
     287                 :         82 :             return;
     288                 :            :         }
     289                 :            : 
     290                 :            :         throw RuntimeException(
     291                 :            :             rtl::OUString( "OFileAccess::transferrImpl - Unable to obtain "
     292                 :            :                     "destination folder URL!"  ),
     293 [ #  # ][ #  # ]:          0 :                 static_cast< cppu::OWeakObject * >( this ) );
     294                 :            : 
     295                 :            :     }
     296                 :            : 
     297 [ +  - ][ +  - ]:         82 :     ucbhelper::Content aDestPath( aDestURL,   mxEnvironment );
     298 [ +  - ][ +  - ]:         82 :     ucbhelper::Content aSrc     ( aSourceURL, mxEnvironment );
     299                 :            : 
     300                 :            :     try
     301                 :            :     {
     302                 :            :         aDestPath.transferContent( aSrc,
     303                 :            :                                    bMoveData
     304                 :            :                                     ? ucbhelper::InsertOperation_MOVE
     305                 :            :                                     : ucbhelper::InsertOperation_COPY,
     306                 :            :                                    aName,
     307 [ -  + ][ +  - ]:         82 :                                    ::com::sun::star::ucb::NameClash::OVERWRITE );
         [ #  # ][ +  - ]
     308                 :            :     }
     309         [ #  # ]:          0 :     catch ( ::com::sun::star::ucb::CommandFailedException const & )
     310                 :            :     {
     311                 :            :         // Interaction Handler already handled the error that has occurred...
     312 [ +  - ][ +  - ]:         82 :     }
         [ +  - ][ -  + ]
         [ +  - ][ -  + ]
         [ +  - ][ -  + ]
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
     313                 :            : }
     314                 :            : 
     315                 :         82 : void OFileAccess::copy( const rtl::OUString& SourceURL, const rtl::OUString& DestURL )
     316                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     317                 :            : {
     318                 :         82 :     transferImpl( SourceURL, DestURL, sal_False );
     319                 :         82 : }
     320                 :            : 
     321                 :          0 : void OFileAccess::move( const rtl::OUString& SourceURL, const rtl::OUString& DestURL )
     322                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     323                 :            : {
     324                 :          0 :     transferImpl( SourceURL, DestURL, sal_True );
     325                 :          0 : }
     326                 :            : 
     327                 :        225 : void OFileAccess::kill( const rtl::OUString& FileURL )
     328                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     329                 :            : {
     330                 :            :     // SfxContentHelper::Kill
     331         [ +  - ]:        225 :     INetURLObject aDeleteObj( FileURL, INET_PROT_FILE );
     332 [ +  - ][ +  - ]:        225 :     ucbhelper::Content aCnt( aDeleteObj.GetMainURL( INetURLObject::NO_DECODE ), mxEnvironment );
     333                 :            :     try
     334                 :            :     {
     335 [ +  + ][ +  - ]:        225 :         aCnt.executeCommand( rtl::OUString("delete" ), makeAny( sal_Bool( sal_True ) ) );
                 [ +  - ]
     336                 :            :     }
     337         [ #  # ]:          0 :     catch ( ::com::sun::star::ucb::CommandFailedException const & )
     338                 :            :     {
     339                 :            :         // Interaction Handler already handled the error that has occurred...
     340 [ +  - ][ +  - ]:        225 :     }
     341                 :        211 : }
     342                 :            : 
     343                 :       6144 : sal_Bool OFileAccess::isFolder( const rtl::OUString& FileURL )
     344                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     345                 :            : {
     346                 :       6144 :     sal_Bool bRet = sal_False;
     347                 :            :     try
     348                 :            :     {
     349         [ +  - ]:       6144 :         INetURLObject aURLObj( FileURL, INET_PROT_FILE );
     350 [ +  - ][ +  + ]:       6144 :         ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::NO_DECODE ), mxEnvironment );
     351 [ +  - ][ +  - ]:       6144 :         bRet = aCnt.isFolder();
         [ -  + ][ +  + ]
     352                 :            :     }
     353                 :       3382 :     catch (const Exception &) {}
     354                 :       6144 :     return bRet;
     355                 :            : }
     356                 :            : 
     357                 :          0 : sal_Bool OFileAccess::isReadOnly( const rtl::OUString& FileURL )
     358                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     359                 :            : {
     360         [ #  # ]:          0 :     INetURLObject aURLObj( FileURL, INET_PROT_FILE );
     361 [ #  # ][ #  # ]:          0 :     ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::NO_DECODE ), mxEnvironment );
     362         [ #  # ]:          0 :     Any aRetAny = aCnt.getPropertyValue( rtl::OUString( "IsReadOnly"  ) );
     363                 :          0 :     sal_Bool bRet = sal_False;
     364                 :          0 :     aRetAny >>= bRet;
     365 [ #  # ][ #  # ]:          0 :     return bRet;
     366                 :            : }
     367                 :            : 
     368                 :          0 : void OFileAccess::setReadOnly( const rtl::OUString& FileURL, sal_Bool bReadOnly )
     369                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     370                 :            : {
     371         [ #  # ]:          0 :     INetURLObject aURLObj( FileURL, INET_PROT_FILE );
     372 [ #  # ][ #  # ]:          0 :     ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::NO_DECODE ), mxEnvironment );
     373                 :          0 :     Any aAny;
     374         [ #  # ]:          0 :     aAny <<= bReadOnly;
     375 [ #  # ][ #  # ]:          0 :     aCnt.setPropertyValue( rtl::OUString( "IsReadOnly"  ), aAny );
                 [ #  # ]
     376                 :          0 : }
     377                 :            : 
     378                 :          0 : void OFileAccess::createFolder( const rtl::OUString& NewFolderURL )
     379                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     380                 :            : {
     381                 :            :     // Does the folder already exist?
     382 [ #  # ][ #  # ]:          0 :     if( NewFolderURL.isEmpty() || isFolder( NewFolderURL ) )
         [ #  # ][ #  # ]
     383                 :            :         return;
     384                 :            : 
     385                 :            :     // SfxContentHelper::MakeFolder
     386         [ #  # ]:          0 :     INetURLObject aURL( NewFolderURL, INET_PROT_FILE );
     387 [ #  # ][ #  # ]:          0 :     String aNewFolderURLStr = aURL.GetMainURL( INetURLObject::NO_DECODE );
     388 [ #  # ][ #  # ]:          0 :     String aTitle = aURL.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
     389         [ #  # ]:          0 :     if ( aTitle.Len() )
     390                 :            :     {
     391         [ #  # ]:          0 :         aURL.removeSegment();
     392                 :            : 
     393                 :            :         // Does the base folder exist? Otherwise create it first
     394 [ #  # ][ #  # ]:          0 :         String aBaseFolderURLStr = aURL.GetMainURL( INetURLObject::NO_DECODE );
     395 [ #  # ][ #  # ]:          0 :         if( !isFolder( aBaseFolderURLStr ) )
                 [ #  # ]
     396                 :            :         {
     397 [ #  # ][ #  # ]:          0 :             createFolder( aBaseFolderURLStr );
     398         [ #  # ]:          0 :         }
     399                 :            :     }
     400                 :            : 
     401 [ #  # ][ #  # ]:          0 :     ucbhelper::Content aCnt( aURL.GetMainURL( INetURLObject::NO_DECODE ), mxEnvironment );
     402                 :            : 
     403         [ #  # ]:          0 :     Sequence< ContentInfo > aInfo = aCnt.queryCreatableContentsInfo();
     404                 :          0 :     sal_Int32 nCount = aInfo.getLength();
     405         [ #  # ]:          0 :     if ( nCount == 0 )
     406                 :            :         return;
     407                 :            : 
     408         [ #  # ]:          0 :     for ( sal_Int32 i = 0; i < nCount; ++i )
     409                 :            :     {
     410                 :            :         // Simply look for the first KIND_FOLDER...
     411         [ #  # ]:          0 :         const ContentInfo & rCurr = aInfo[i];
     412         [ #  # ]:          0 :         if ( rCurr.Attributes & ContentInfoAttribute::KIND_FOLDER )
     413                 :            :         {
     414                 :            :             // Make sure the only required bootstrap property is "Title",
     415                 :          0 :             const Sequence< Property > & rProps = rCurr.Properties;
     416         [ #  # ]:          0 :             if ( rProps.getLength() != 1 )
     417                 :          0 :                 continue;
     418                 :            : 
     419         [ #  # ]:          0 :             if ( rProps[ 0 ].Name != "Title" )
     420                 :          0 :                 continue;
     421                 :            : 
     422         [ #  # ]:          0 :             Sequence<rtl::OUString> aNames(1);
     423         [ #  # ]:          0 :             rtl::OUString* pNames = aNames.getArray();
     424                 :          0 :             pNames[0] = rtl::OUString( "Title"  );
     425         [ #  # ]:          0 :             Sequence< Any > aValues(1);
     426         [ #  # ]:          0 :             Any* pValues = aValues.getArray();
     427 [ #  # ][ #  # ]:          0 :             pValues[0] = makeAny( rtl::OUString( aTitle ) );
                 [ #  # ]
     428                 :            : 
     429         [ #  # ]:          0 :             ucbhelper::Content aNew;
     430                 :            :             try
     431                 :            :             {
     432 [ #  # ][ #  # ]:          0 :                 if ( !aCnt.insertNewContent( rCurr.Type, aNames, aValues, aNew ) )
     433                 :          0 :                     continue;
     434                 :            : 
     435                 :            :                 // Success. We're done.
     436         [ #  # ]:          0 :                 return;
     437                 :            :             }
     438         [ #  # ]:          0 :             catch ( ::com::sun::star::ucb::CommandFailedException const & )
     439                 :            :             {
     440                 :            :                 // Interaction Handler already handled the error that has occurred...
     441                 :          0 :                 continue;
     442 [ #  # ][ #  # ]:          0 :             }
         [ #  # ][ #  # ]
                 [ #  # ]
     443                 :            :         }
     444 [ #  # ][ #  # ]:          0 :     }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     445                 :            : }
     446                 :            : 
     447                 :         12 : sal_Int32 OFileAccess::getSize( const rtl::OUString& FileURL )
     448                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     449                 :            : {
     450                 :            :     // SfxContentHelper::GetSize
     451                 :         12 :     sal_Int32 nSize = 0;
     452                 :         12 :     sal_Int64 nTemp = 0;
     453         [ +  - ]:         12 :     INetURLObject aObj( FileURL, INET_PROT_FILE );
     454 [ +  - ][ +  - ]:         12 :     ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), mxEnvironment );
     455         [ +  - ]:         12 :     aCnt.getPropertyValue( rtl::OUString("Size" ) ) >>= nTemp;
     456                 :         12 :     nSize = (sal_Int32)nTemp;
     457 [ +  - ][ +  - ]:         12 :     return nSize;
     458                 :            : }
     459                 :            : 
     460                 :          0 : rtl::OUString OFileAccess::getContentType( const rtl::OUString& FileURL )
     461                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     462                 :            : {
     463         [ #  # ]:          0 :     INetURLObject aObj( FileURL, INET_PROT_FILE );
     464 [ #  # ][ #  # ]:          0 :     ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), mxEnvironment );
     465                 :            : 
     466         [ #  # ]:          0 :     Reference< XContent > xContent = aCnt.get();
     467 [ #  # ][ #  # ]:          0 :     rtl::OUString aTypeStr = xContent->getContentType();
     468 [ #  # ][ #  # ]:          0 :     return aTypeStr;
     469                 :            : }
     470                 :            : 
     471                 :          0 : DateTime OFileAccess::getDateTimeModified( const rtl::OUString& FileURL )
     472                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     473                 :            : {
     474         [ #  # ]:          0 :     INetURLObject aFileObj( FileURL, INET_PROT_FILE );
     475                 :          0 :     DateTime aDateTime;
     476                 :            : 
     477                 :          0 :     Reference< XCommandEnvironment > aCmdEnv;
     478 [ #  # ][ #  # ]:          0 :     ucbhelper::Content aYoung( aFileObj.GetMainURL( INetURLObject::NO_DECODE ), aCmdEnv );
     479 [ #  # ][ #  # ]:          0 :     aYoung.getPropertyValue( rtl::OUString("DateModified" ) ) >>= aDateTime;
     480 [ #  # ][ #  # ]:          0 :     return aDateTime;
     481                 :            : }
     482                 :            : 
     483                 :            : typedef vector< rtl::OUString* > StringList_Impl;
     484                 :            : 
     485                 :        334 : Sequence< rtl::OUString > OFileAccess::getFolderContents( const rtl::OUString& FolderURL, sal_Bool bIncludeFolders )
     486                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     487                 :            : {
     488                 :            :     // SfxContentHelper::GetFolderContents
     489                 :            : 
     490                 :        334 :     StringList_Impl* pFiles = NULL;
     491         [ +  - ]:        334 :     INetURLObject aFolderObj( FolderURL, INET_PROT_FILE );
     492                 :            : 
     493 [ +  - ][ +  - ]:        334 :     ucbhelper::Content aCnt( aFolderObj.GetMainURL( INetURLObject::NO_DECODE ), mxEnvironment );
     494                 :        334 :     Reference< XResultSet > xResultSet;
     495         [ +  - ]:        334 :     Sequence< rtl::OUString > aProps(0);
     496                 :            : 
     497         [ +  - ]:        334 :     ucbhelper::ResultSetInclude eInclude = bIncludeFolders ? ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS : ucbhelper::INCLUDE_DOCUMENTS_ONLY;
     498                 :            : 
     499                 :            :     try
     500                 :            :     {
     501 [ +  - ][ +  - ]:        334 :         xResultSet = aCnt.createCursor( aProps, eInclude );
                 [ #  # ]
     502                 :            :     }
     503         [ #  # ]:          0 :     catch ( ::com::sun::star::ucb::CommandFailedException const & )
     504                 :            :     {
     505                 :            :         // Interaction Handler already handled the error that has occurred...
     506                 :            :     }
     507                 :            : 
     508         [ +  - ]:        334 :     if ( xResultSet.is() )
     509                 :            :     {
     510 [ +  - ][ +  - ]:        334 :         pFiles = new StringList_Impl();
     511         [ +  - ]:        334 :         Reference< com::sun::star::ucb::XContentAccess > xContentAccess( xResultSet, UNO_QUERY );
     512                 :            : 
     513 [ +  - ][ +  - ]:        820 :         while ( xResultSet->next() )
                 [ +  + ]
     514                 :            :         {
     515 [ +  - ][ +  - ]:        486 :             rtl::OUString aId = xContentAccess->queryContentIdentifierString();
     516         [ +  - ]:        486 :             INetURLObject aURL( aId, INET_PROT_FILE );
     517 [ +  - ][ +  - ]:        486 :             rtl::OUString* pFile = new rtl::OUString( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
     518         [ +  - ]:        486 :             pFiles->push_back( pFile );
     519         [ +  - ]:        820 :         }
     520                 :            :     }
     521                 :            : 
     522         [ +  - ]:        334 :     if ( pFiles )
     523                 :            :     {
     524                 :        334 :         size_t nCount = pFiles->size();
     525         [ +  - ]:        334 :         Sequence < rtl::OUString > aRet( nCount );
     526         [ +  - ]:        334 :         rtl::OUString* pRet = aRet.getArray();
     527         [ +  + ]:        820 :         for ( size_t i = 0; i < nCount; ++i )
     528                 :            :         {
     529         [ +  - ]:        486 :             rtl::OUString* pFile = pFiles->at( i );
     530                 :        486 :             pRet[i] = *( pFile );
     531         [ +  - ]:        486 :             delete pFile;
     532                 :            :         }
     533                 :        334 :         pFiles->clear();
     534         [ +  - ]:        334 :         delete pFiles;
     535 [ +  - ][ +  - ]:        334 :         return aRet;
     536                 :            :     }
     537                 :            :     else
     538 [ #  # ][ +  - ]:        334 :         return Sequence < rtl::OUString > ();
         [ +  - ][ +  - ]
     539                 :            : }
     540                 :            : 
     541                 :        410 : sal_Bool OFileAccess::exists( const rtl::OUString& FileURL )
     542                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     543                 :            : {
     544                 :        410 :     sal_Bool bRet = sal_False;
     545                 :            :     try
     546                 :            :     {
     547         [ +  - ]:        410 :         bRet = isFolder( FileURL );
     548         [ +  - ]:        410 :         if( !bRet )
     549                 :            :         {
     550         [ +  + ]:        410 :             Reference< XInputStream > xStream = openFileRead( FileURL );
     551                 :        292 :             bRet = xStream.is();
     552         [ +  - ]:        292 :             if( bRet )
     553 [ +  - ][ +  - ]:        410 :                 xStream->closeInput();
                 [ -  + ]
     554                 :            :         }
     555                 :            :     }
     556                 :        118 :     catch (const Exception &) {}
     557                 :        410 :     return bRet;
     558                 :            : }
     559                 :            : 
     560                 :       2859 : Reference< XInputStream > OFileAccess::openFileRead( const rtl::OUString& FileURL )
     561                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     562                 :            : {
     563                 :       2859 :     Reference< XInputStream > xRet;
     564         [ +  - ]:       2859 :     INetURLObject aObj( FileURL, INET_PROT_FILE );
     565 [ +  - ][ +  + ]:       2859 :     ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::NO_DECODE ), mxEnvironment );
     566                 :            : 
     567 [ +  - ][ +  - ]:       2757 :     Reference< XActiveDataSink > xSink = (XActiveDataSink*)(new OActiveDataSink());
                 [ +  - ]
     568                 :            : 
     569                 :            :     try
     570                 :            :     {
     571         [ +  + ]:       2757 :         sal_Bool bRet = aCnt.openStream( xSink );
     572         [ +  - ]:       2435 :         if( bRet )
     573 [ +  - ][ +  - ]:       2757 :             xRet = xSink->getInputStream();
         [ +  - ][ +  - ]
     574                 :            :     }
     575         [ #  # ]:          0 :     catch ( ::com::sun::star::ucb::CommandFailedException const & )
     576                 :            :     {
     577                 :            :         // Interaction Handler already handled the error that has occurred...
     578                 :            :     }
     579                 :            : 
     580 [ +  - ][ +  - ]:       2859 :     return xRet;
     581                 :            : }
     582                 :            : 
     583                 :        519 : Reference< XOutputStream > OFileAccess::openFileWrite( const rtl::OUString& FileURL )
     584                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     585                 :            : {
     586                 :        519 :     Reference< XOutputStream > xRet;
     587         [ +  - ]:        519 :     Reference< XStream > xStream = OFileAccess::openFileReadWrite( FileURL );
     588         [ +  - ]:        519 :     if( xStream.is() )
     589 [ +  - ][ +  - ]:        519 :         xRet = xStream->getOutputStream();
                 [ +  - ]
     590                 :        519 :     return xRet;
     591                 :            : }
     592                 :            : 
     593                 :       1272 : Reference< XStream > OFileAccess::openFileReadWrite( const rtl::OUString& FileURL )
     594                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     595                 :            : {
     596 [ +  - ][ +  - ]:       1272 :     Reference< XActiveDataStreamer > xSink = (XActiveDataStreamer*)new OActiveDataStreamer();
                 [ +  - ]
     597         [ +  - ]:       1272 :     Reference< XInterface > xSinkIface = Reference< XInterface >::query( xSink );
     598                 :            : 
     599         [ +  - ]:       1272 :     OpenCommandArgument2 aArg;
     600                 :       1272 :     aArg.Mode       = OpenMode::DOCUMENT;
     601                 :       1272 :     aArg.Priority   = 0; // unused
     602         [ +  - ]:       1272 :     aArg.Sink       = xSink;
     603 [ +  - ][ +  - ]:       1272 :     aArg.Properties = Sequence< Property >( 0 ); // unused
                 [ +  - ]
     604                 :            : 
     605                 :       1272 :     Any aCmdArg;
     606         [ +  - ]:       1272 :     aCmdArg <<= aArg;
     607                 :            : 
     608         [ +  - ]:       1272 :     INetURLObject aFileObj( FileURL, INET_PROT_FILE );
     609 [ +  - ][ +  - ]:       1272 :     ucbhelper::Content aCnt( aFileObj.GetMainURL( INetURLObject::NO_DECODE ), mxEnvironment );
     610                 :            : 
     611                 :            :     // Be silent...
     612                 :       1272 :     Reference< XInteractionHandler > xIH;
     613         [ -  + ]:       1272 :     if ( mpEnvironment )
     614                 :            :     {
     615 [ #  # ][ #  # ]:          0 :         xIH = mpEnvironment->getInteractionHandler();
     616 [ #  # ][ #  # ]:          0 :         mpEnvironment->setHandler( 0 );
     617                 :            :     }
     618                 :            : 
     619                 :            :     try
     620                 :            :     {
     621         [ +  + ]:       1272 :         aCnt.executeCommand( rtl::OUString("open" ), aCmdArg );
     622                 :            :     }
     623 [ -  + ][ +  - ]:        606 :     catch ( InteractiveIOException const & e )
     624                 :            :     {
     625         [ -  + ]:        303 :         if ( xIH.is() )
     626         [ #  # ]:          0 :             mpEnvironment->setHandler( xIH );
     627                 :            : 
     628         [ +  - ]:        303 :         if ( e.Code == IOErrorCode_NOT_EXISTING )
     629                 :            :         {
     630                 :            :             // Create file...
     631         [ -  + ]:        303 :             SvMemoryStream aStream(0,0);
     632         [ -  + ]:        303 :             ::utl::OInputStreamWrapper* pInput = new ::utl::OInputStreamWrapper( aStream );
     633 [ +  - ][ -  + ]:        303 :             Reference< XInputStream > xInput( pInput );
     634         [ -  + ]:        303 :             InsertCommandArgument aInsertArg;
     635         [ -  + ]:        303 :             aInsertArg.Data = xInput;
     636                 :        303 :             aInsertArg.ReplaceExisting = sal_False;
     637                 :            : 
     638         [ -  + ]:        303 :             aCmdArg <<= aInsertArg;
     639         [ -  + ]:        303 :             aCnt.executeCommand( rtl::OUString("insert" ), aCmdArg );
     640                 :            : 
     641                 :            :             // Retry...
     642 [ -  + ][ -  + ]:        303 :             return openFileReadWrite( FileURL );
                 [ -  + ]
     643                 :            :         }
     644                 :            : 
     645                 :          0 :         throw;
     646                 :            :     }
     647                 :            : 
     648         [ -  + ]:        969 :     if ( xIH.is() )
     649         [ #  # ]:          0 :         mpEnvironment->setHandler( xIH );
     650                 :            : 
     651 [ +  - ][ +  - ]:        969 :     Reference< XStream > xRet = xSink->getStream();
     652 [ +  - ][ +  - ]:       1272 :     return xRet;
                 [ +  - ]
     653                 :            : }
     654                 :            : 
     655                 :          0 : void OFileAccess::setInteractionHandler( const Reference< XInteractionHandler >& Handler )
     656                 :            :     throw(RuntimeException)
     657                 :            : {
     658         [ #  # ]:          0 :     if( !mpEnvironment )
     659                 :            :     {
     660         [ #  # ]:          0 :         mpEnvironment = new OCommandEnvironment();
     661         [ #  # ]:          0 :         mxEnvironment = (XCommandEnvironment*)mpEnvironment;
     662                 :            :     }
     663         [ #  # ]:          0 :     mpEnvironment->setHandler( Handler );
     664                 :          0 : }
     665                 :            : 
     666                 :          0 : bool OFileAccess::createNewFile( const rtl::OUString & rParentURL,
     667                 :            :                                  const rtl::OUString & rTitle,
     668                 :            :                                  const Reference< XInputStream >& data )
     669                 :            :     throw ( Exception )
     670                 :            : {
     671         [ #  # ]:          0 :     ucbhelper::Content aParentCnt( rParentURL, mxEnvironment );
     672                 :            : 
     673         [ #  # ]:          0 :     Sequence< ContentInfo > aInfo = aParentCnt.queryCreatableContentsInfo();
     674                 :          0 :     sal_Int32 nCount = aInfo.getLength();
     675         [ #  # ]:          0 :     if ( nCount == 0 )
     676                 :          0 :         return false;
     677                 :            : 
     678         [ #  # ]:          0 :     for ( sal_Int32 i = 0; i < nCount; ++i )
     679                 :            :     {
     680         [ #  # ]:          0 :         const ContentInfo & rCurr = aInfo[i];
     681 [ #  # ][ #  # ]:          0 :         if ( ( rCurr.Attributes
     682                 :            :                & ContentInfoAttribute::KIND_DOCUMENT ) &&
     683                 :            :              ( rCurr.Attributes
     684                 :            :                & ContentInfoAttribute::INSERT_WITH_INPUTSTREAM ) )
     685                 :            :         {
     686                 :            :             // Make sure the only required bootstrap property is
     687                 :            :             // "Title",
     688                 :          0 :             const Sequence< Property > & rProps = rCurr.Properties;
     689         [ #  # ]:          0 :             if ( rProps.getLength() != 1 )
     690                 :          0 :                 continue;
     691                 :            : 
     692         [ #  # ]:          0 :             if ( rProps[ 0 ].Name != "Title" )
     693                 :          0 :                 continue;
     694                 :            : 
     695         [ #  # ]:          0 :             Sequence<rtl::OUString> aNames(1);
     696         [ #  # ]:          0 :             rtl::OUString* pNames = aNames.getArray();
     697                 :            :             pNames[0] = rtl::OUString(
     698                 :          0 :                             "Title"  );
     699         [ #  # ]:          0 :             Sequence< Any > aValues(1);
     700         [ #  # ]:          0 :             Any* pValues = aValues.getArray();
     701         [ #  # ]:          0 :             pValues[0] = makeAny( rtl::OUString( rTitle ) );
     702                 :            : 
     703                 :            :             try
     704                 :            :             {
     705         [ #  # ]:          0 :                 ucbhelper::Content aNew;
     706         [ #  # ]:          0 :                 if ( aParentCnt.insertNewContent(
     707         [ #  # ]:          0 :                          rCurr.Type, aNames, aValues, data, aNew ) )
     708                 :          0 :                     return true; // success.
     709                 :            :                 else
     710 [ #  # ][ #  # ]:          0 :                     continue;
                 [ #  # ]
     711                 :            :             }
     712         [ #  # ]:          0 :             catch ( CommandFailedException const & )
     713                 :            :             {
     714                 :            :                 // Interaction Handler already handled the
     715                 :            :                 // error that has occurred...
     716                 :          0 :                 continue;
     717 [ #  # ][ #  # ]:          0 :             }
         [ #  # ][ #  # ]
     718                 :            :         }
     719                 :            :     }
     720                 :            : 
     721 [ #  # ][ #  # ]:          0 :     return false;
     722                 :            : }
     723                 :            : 
     724                 :          0 : void SAL_CALL OFileAccess::writeFile( const rtl::OUString& FileURL,
     725                 :            :                                       const Reference< XInputStream >& data )
     726                 :            :     throw ( Exception, RuntimeException )
     727                 :            : {
     728         [ #  # ]:          0 :     INetURLObject aURL( FileURL, INET_PROT_FILE );
     729                 :            :     try
     730                 :            :     {
     731                 :            :         ucbhelper::Content aCnt(
     732 [ #  # ][ #  # ]:          0 :             aURL.GetMainURL( INetURLObject::NO_DECODE ), mxEnvironment );
                 [ #  # ]
     733                 :            : 
     734                 :            :         try
     735                 :            :         {
     736         [ #  # ]:          0 :             aCnt.writeStream( data, sal_True /* bReplaceExisting */ );
     737                 :            :         }
     738         [ #  # ]:          0 :         catch ( CommandFailedException const & )
     739                 :            :         {
     740                 :            :             // Interaction Handler already handled the error that has occurred...
     741         [ #  # ]:          0 :         }
     742                 :            :     }
     743   [ #  #  #  # ]:          0 :     catch ( ContentCreationException const & e )
     744                 :            :     {
     745                 :            :         // Most probably file does not exist. Try to create.
     746         [ #  # ]:          0 :         if ( e.eError == ContentCreationError_CONTENT_CREATION_FAILED )
     747                 :            :         {
     748         [ #  # ]:          0 :             INetURLObject aParentURLObj( aURL );
     749   [ #  #  #  # ]:          0 :             if ( aParentURLObj.removeSegment() )
     750                 :            :             {
     751                 :            :                 String aParentURL
     752   [ #  #  #  # ]:          0 :                     = aParentURLObj.GetMainURL( INetURLObject::NO_DECODE );
     753                 :            : 
     754                 :            :                 // ensure all parent folders exist.
     755   [ #  #  #  # ]:          0 :                 createFolder( aParentURL );
     756                 :            : 
     757                 :            :                 // create the new file...
     758                 :            :                 String aTitle
     759                 :            :                     = aURL.getName( INetURLObject::LAST_SEGMENT,
     760                 :            :                                     true,
     761   [ #  #  #  # ]:          0 :                                     INetURLObject::DECODE_WITH_CHARSET );
     762   [ #  #  #  #  :          0 :                 if ( createNewFile( aParentURL, aTitle, data ) )
             #  #  #  # ]
     763                 :            :                 {
     764                 :            :                     // success
     765                 :          0 :                     return;
     766   [ #  #  #  #  :          0 :                 }
             #  #  #  # ]
     767   [ #  #  #  # ]:          0 :             }
     768                 :            :         }
     769                 :            : 
     770                 :          0 :         throw;
     771 [ #  # ][ #  # ]:          0 :     }
     772                 :            : }
     773                 :            : 
     774                 :          0 : sal_Bool OFileAccess::isHidden( const ::rtl::OUString& FileURL )
     775                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     776                 :            : {
     777         [ #  # ]:          0 :     INetURLObject aURLObj( FileURL, INET_PROT_FILE );
     778 [ #  # ][ #  # ]:          0 :     ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::NO_DECODE ), mxEnvironment );
     779         [ #  # ]:          0 :     Any aRetAny = aCnt.getPropertyValue( rtl::OUString( "IsHidden"  ) );
     780                 :          0 :     sal_Bool bRet = sal_False;
     781                 :          0 :     aRetAny >>= bRet;
     782 [ #  # ][ #  # ]:          0 :     return bRet;
     783                 :            : }
     784                 :            : 
     785                 :          0 : void OFileAccess::setHidden( const ::rtl::OUString& FileURL, sal_Bool bHidden )
     786                 :            :     throw(CommandAbortedException, Exception, RuntimeException)
     787                 :            : {
     788         [ #  # ]:          0 :     INetURLObject aURLObj( FileURL, INET_PROT_FILE );
     789 [ #  # ][ #  # ]:          0 :     ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::NO_DECODE ), mxEnvironment );
     790                 :          0 :     Any aAny;
     791         [ #  # ]:          0 :     aAny <<= bHidden;
     792 [ #  # ][ #  # ]:          0 :     aCnt.setPropertyValue( rtl::OUString( "IsHidden"  ), aAny );
                 [ #  # ]
     793                 :          0 : }
     794                 :            : 
     795                 :            : //==================================================================================================
     796                 :            : //==================================================================================================
     797                 :            : //==================================================================================================
     798                 :            : 
     799                 :       4081 : Reference< XInterface > SAL_CALL FileAccess_CreateInstance( const Reference< XMultiServiceFactory > & xSMgr )
     800                 :            : {
     801         [ +  - ]:       4081 :     return Reference < XInterface >( ( cppu::OWeakObject * ) new OFileAccess( xSMgr ) );
     802                 :            : }
     803                 :            : 
     804                 :            : 
     805                 :        202 : Sequence< rtl::OUString > FileAccess_getSupportedServiceNames()
     806                 :            : {
     807                 :        202 :     Sequence< rtl::OUString > seqNames(1);
     808         [ +  - ]:        202 :     seqNames.getArray()[0] = rtl::OUString(SERVICE_NAME );
     809                 :        202 :     return seqNames;
     810                 :            : }
     811                 :            : 
     812                 :            : 
     813                 :            : }
     814                 :            : 
     815                 :            : //==================================================================================================
     816                 :            : // Component exports
     817                 :            : 
     818                 :            : extern "C"
     819                 :            : {
     820                 :        202 : SAL_DLLPUBLIC_EXPORT void * SAL_CALL fileacc_component_getFactory(
     821                 :            :     const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
     822                 :            : {
     823                 :        202 :     void * pRet = 0;
     824                 :            : 
     825 [ +  - ][ +  - ]:        202 :     if (pServiceManager && rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0)
                 [ +  - ]
     826                 :            :     {
     827                 :            :         Reference< XSingleServiceFactory > xFactory( cppu::createSingleFactory(
     828                 :            :             reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
     829                 :            :             rtl::OUString::createFromAscii( pImplName ),
     830                 :            :             FileAccess_CreateInstance,
     831 [ +  - ][ +  - ]:        202 :             FileAccess_getSupportedServiceNames() ) );
         [ +  - ][ +  - ]
     832                 :            : 
     833         [ +  - ]:        202 :         if (xFactory.is())
     834                 :            :         {
     835         [ +  - ]:        202 :             xFactory->acquire();
     836         [ +  - ]:        202 :             pRet = xFactory.get();
     837                 :        202 :         }
     838                 :            :     }
     839                 :            : 
     840                 :        202 :     return pRet;
     841                 :            : }
     842                 :            : }
     843                 :            : 
     844                 :            : 
     845                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10