LCOV - code coverage report
Current view: top level - ucb/source/ucp/package - pkgcontent.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 4 100.0 %
Date: 2012-08-25 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 6 50.0 %

           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                 :            : #ifndef _PKGCONTENT_HXX
      21                 :            : #define _PKGCONTENT_HXX
      22                 :            : 
      23                 :            : #include <list>
      24                 :            : #include <rtl/ref.hxx>
      25                 :            : 
      26                 :            : #include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp>
      27                 :            : #include <com/sun/star/ucb/XContentCreator.hpp>
      28                 :            : #include <ucbhelper/contenthelper.hxx>
      29                 :            : #include "pkguri.hxx"
      30                 :            : 
      31                 :            : namespace com { namespace sun { namespace star {
      32                 :            :     namespace beans
      33                 :            :     {
      34                 :            :         struct Property;
      35                 :            :         struct PropertyValue;
      36                 :            :     }
      37                 :            :     namespace container
      38                 :            :     {
      39                 :            :         class XHierarchicalNameAccess;
      40                 :            :         class XEnumeration;
      41                 :            :     }
      42                 :            :     namespace io
      43                 :            :     {
      44                 :            :         class XInputStream;
      45                 :            :     }
      46                 :            :     namespace sdbc
      47                 :            :     {
      48                 :            :         class XRow;
      49                 :            :     }
      50                 :            :     namespace ucb
      51                 :            :     {
      52                 :            :         struct OpenCommandArgument2;
      53                 :            :         struct TransferInfo;
      54                 :            :     }
      55                 :            : } } }
      56                 :            : 
      57                 :            : namespace package_ucp
      58                 :            : {
      59                 :            : 
      60                 :            : //=========================================================================
      61                 :            : 
      62                 :            : // UNO service name for the content.
      63                 :            : #define PACKAGE_FOLDER_CONTENT_SERVICE_NAME \
      64                 :            :                             "com.sun.star.ucb.PackageFolderContent"
      65                 :            : #define PACKAGE_STREAM_CONTENT_SERVICE_NAME \
      66                 :            :                             "com.sun.star.ucb.PackageStreamContent"
      67                 :            : 
      68                 :            : //=========================================================================
      69                 :            : 
      70 [ +  - ][ +  - ]:        487 : struct ContentProperties
      71                 :            : {
      72                 :            :     ::rtl::OUString  aTitle;                // Title
      73                 :            :     ::rtl::OUString  aContentType;          // ContentType
      74                 :            :     sal_Bool         bIsDocument;           // IsDocument
      75                 :            :     sal_Bool         bIsFolder;             // IsFolder
      76                 :            :     ::rtl::OUString  aMediaType;            // MediaType
      77                 :            :     com::sun::star::uno::Sequence <
      78                 :            :         sal_Int8 >   aEncryptionKey;        // EncryptionKey
      79                 :            :     sal_Int64        nSize;                 // Size
      80                 :            :     sal_Bool         bCompressed;           // Compressed
      81                 :            :     sal_Bool         bEncrypted;            // Encrypted
      82                 :            :     sal_Bool         bHasEncryptedEntries;  // HasEncryptedEntries
      83                 :            : 
      84                 :        129 :     ContentProperties()
      85                 :            :     : bIsDocument( sal_True ), bIsFolder( sal_False ), nSize( 0 ),
      86                 :            :       bCompressed( sal_True ), bEncrypted( sal_False ),
      87         [ +  - ]:        129 :       bHasEncryptedEntries( sal_False ) {}
      88                 :            : 
      89                 :            :     ContentProperties( const ::rtl::OUString& rContentType );
      90                 :            : 
      91                 :            :     com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
      92                 :            :     getCreatableContentsInfo( PackageUri const & rUri ) const;
      93                 :            : };
      94                 :            : 
      95                 :            : //=========================================================================
      96                 :            : 
      97                 :            : class ContentProvider;
      98                 :            : 
      99                 :            : class Content : public ::ucbhelper::ContentImplHelper,
     100                 :            :                 public com::sun::star::ucb::XContentCreator
     101                 :            : {
     102                 :            :     enum ContentState { TRANSIENT,  // created via CreateNewContent,
     103                 :            :                                         // but did not process "insert" yet
     104                 :            :                         PERSISTENT, // processed "insert"
     105                 :            :                         DEAD        // processed "delete"
     106                 :            :                       };
     107                 :            : 
     108                 :            :     PackageUri              m_aUri;
     109                 :            :     ContentProperties       m_aProps;
     110                 :            :     ContentState            m_eState;
     111                 :            :     com::sun::star::uno::Reference<
     112                 :            :         com::sun::star::container::XHierarchicalNameAccess > m_xPackage;
     113                 :            :     ContentProvider*        m_pProvider;
     114                 :            :     sal_uInt32              m_nModifiedProps;
     115                 :            : 
     116                 :            : private:
     117                 :            :     Content( const com::sun::star::uno::Reference<
     118                 :            :                 com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
     119                 :            :              ContentProvider* pProvider,
     120                 :            :              const com::sun::star::uno::Reference<
     121                 :            :                 com::sun::star::ucb::XContentIdentifier >& Identifier,
     122                 :            :              const ::com::sun::star::uno::Reference<
     123                 :            :                 com::sun::star::container::XHierarchicalNameAccess >& Package,
     124                 :            :              const PackageUri& rUri,
     125                 :            :              const ContentProperties& rProps );
     126                 :            :     Content( const com::sun::star::uno::Reference<
     127                 :            :                 com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
     128                 :            :              ContentProvider* pProvider,
     129                 :            :              const com::sun::star::uno::Reference<
     130                 :            :                 com::sun::star::ucb::XContentIdentifier >& Identifier,
     131                 :            :              const com::sun::star::uno::Reference<
     132                 :            :                 com::sun::star::container::XHierarchicalNameAccess >& Package,
     133                 :            :              const PackageUri& rUri,
     134                 :            :              const com::sun::star::ucb::ContentInfo& Info );
     135                 :            : 
     136                 :            :     virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
     137                 :            :     getProperties( const com::sun::star::uno::Reference<
     138                 :            :                     com::sun::star::ucb::XCommandEnvironment > & xEnv );
     139                 :            :     virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
     140                 :            :     getCommands( const com::sun::star::uno::Reference<
     141                 :            :                     com::sun::star::ucb::XCommandEnvironment > & xEnv );
     142                 :            :     virtual ::rtl::OUString getParentURL();
     143                 :            : 
     144                 :            :     static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
     145                 :            :     getPropertyValues( const ::com::sun::star::uno::Reference<
     146                 :            :                         ::com::sun::star::lang::XMultiServiceFactory >& rSMgr,
     147                 :            :                        const ::com::sun::star::uno::Sequence<
     148                 :            :                             ::com::sun::star::beans::Property >& rProperties,
     149                 :            :                        const ContentProperties& rData,
     150                 :            :                        const rtl::Reference<
     151                 :            :                             ::ucbhelper::ContentProviderImplHelper >& rProvider,
     152                 :            :                        const ::rtl::OUString& rContentId );
     153                 :            : 
     154                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
     155                 :            :     getPropertyValues( const ::com::sun::star::uno::Sequence<
     156                 :            :                         ::com::sun::star::beans::Property >& rProperties );
     157                 :            :     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
     158                 :            :     setPropertyValues( const ::com::sun::star::uno::Sequence<
     159                 :            :                         ::com::sun::star::beans::PropertyValue >& rValues,
     160                 :            :                        const ::com::sun::star::uno::Reference<
     161                 :            :                         ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
     162                 :            :         throw( ::com::sun::star::uno::Exception );
     163                 :            : 
     164                 :            :     com::sun::star::uno::Reference<
     165                 :            :         com::sun::star::container::XHierarchicalNameAccess >
     166                 :            :     getPackage( const PackageUri& rURI );
     167                 :            :     com::sun::star::uno::Reference<
     168                 :            :         com::sun::star::container::XHierarchicalNameAccess >
     169                 :            :     getPackage();
     170                 :            : 
     171                 :            :     static sal_Bool
     172                 :            :     loadData( ContentProvider* pProvider,
     173                 :            :               const PackageUri& rURI,
     174                 :            :               ContentProperties& rProps,
     175                 :            :               com::sun::star::uno::Reference<
     176                 :            :                 com::sun::star::container::XHierarchicalNameAccess > &
     177                 :            :                     rxPackage );
     178                 :            :     static sal_Bool
     179                 :            :     hasData( ContentProvider* pProvider,
     180                 :            :              const PackageUri& rURI,
     181                 :            :              com::sun::star::uno::Reference<
     182                 :            :                 com::sun::star::container::XHierarchicalNameAccess > &
     183                 :            :                     rxPackage );
     184                 :            : 
     185                 :            :     sal_Bool
     186                 :            :     hasData( const PackageUri& rURI );
     187                 :            :     sal_Bool
     188                 :            :     renameData( const com::sun::star::uno::Reference<
     189                 :            :                     com::sun::star::ucb::XContentIdentifier >& xOldId,
     190                 :            :                 const com::sun::star::uno::Reference<
     191                 :            :                     com::sun::star::ucb::XContentIdentifier >& xNewId );
     192                 :            :     sal_Bool
     193                 :            :     storeData( const com::sun::star::uno::Reference<
     194                 :            :                     com::sun::star::io::XInputStream >& xStream );
     195                 :            :     sal_Bool
     196                 :            :     removeData();
     197                 :            : 
     198                 :            :     sal_Bool
     199                 :            :     flushData();
     200                 :            : 
     201                 :            :     typedef rtl::Reference< Content > ContentRef;
     202                 :            :     typedef std::list< ContentRef > ContentRefList;
     203                 :            :     void queryChildren( ContentRefList& rChildren );
     204                 :            : 
     205                 :            :     sal_Bool
     206                 :            :     exchangeIdentity( const ::com::sun::star::uno::Reference<
     207                 :            :                         ::com::sun::star::ucb::XContentIdentifier >& xNewId );
     208                 :            : 
     209                 :            :     ::com::sun::star::uno::Any
     210                 :            :     open( const ::com::sun::star::ucb::OpenCommandArgument2& rArg,
     211                 :            :           const ::com::sun::star::uno::Reference<
     212                 :            :                     ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
     213                 :            :         throw( ::com::sun::star::uno::Exception );
     214                 :            : 
     215                 :            :     void insert( const ::com::sun::star::uno::Reference<
     216                 :            :                         ::com::sun::star::io::XInputStream >& xStream,
     217                 :            :                  sal_Int32 nNameClashResolve,
     218                 :            :                  const ::com::sun::star::uno::Reference<
     219                 :            :                     ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
     220                 :            :         throw( ::com::sun::star::uno::Exception );
     221                 :            : 
     222                 :            :     void destroy( sal_Bool bDeletePhysical,
     223                 :            :                   const ::com::sun::star::uno::Reference<
     224                 :            :                     ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
     225                 :            :         throw( ::com::sun::star::uno::Exception );
     226                 :            : 
     227                 :            :     void transfer( const ::com::sun::star::ucb::TransferInfo& rInfo,
     228                 :            :                    const ::com::sun::star::uno::Reference<
     229                 :            :                     ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
     230                 :            :         throw( ::com::sun::star::uno::Exception );
     231                 :            : 
     232                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
     233                 :            :     getInputStream();
     234                 :            : 
     235                 :       2418 :     sal_Bool isFolder() const { return m_aProps.bIsFolder; }
     236                 :            : 
     237                 :            : public:
     238                 :            :     // Create existing content. Fail, if not already exists.
     239                 :            :     static Content* create(
     240                 :            :             const com::sun::star::uno::Reference<
     241                 :            :                 com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
     242                 :            :             ContentProvider* pProvider,
     243                 :            :             const com::sun::star::uno::Reference<
     244                 :            :                 com::sun::star::ucb::XContentIdentifier >& Identifier );
     245                 :            : 
     246                 :            :     // Create new content. Fail, if already exists.
     247                 :            :     static Content* create(
     248                 :            :             const com::sun::star::uno::Reference<
     249                 :            :                 com::sun::star::lang::XMultiServiceFactory >& rxSMgr,
     250                 :            :             ContentProvider* pProvider,
     251                 :            :             const com::sun::star::uno::Reference<
     252                 :            :                 com::sun::star::ucb::XContentIdentifier >& Identifier,
     253                 :            :             const com::sun::star::ucb::ContentInfo& Info );
     254                 :            : 
     255                 :            :     virtual ~Content();
     256                 :            : 
     257                 :            :     // XInterface
     258                 :            :     XINTERFACE_DECL()
     259                 :            : 
     260                 :            :     // XTypeProvider
     261                 :            :     XTYPEPROVIDER_DECL()
     262                 :            : 
     263                 :            :     // XServiceInfo
     264                 :            :     virtual ::rtl::OUString SAL_CALL
     265                 :            :     getImplementationName()
     266                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     267                 :            :     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
     268                 :            :     getSupportedServiceNames()
     269                 :            :         throw( ::com::sun::star::uno::RuntimeException );
     270                 :            : 
     271                 :            :     // XContent
     272                 :            :     virtual rtl::OUString SAL_CALL
     273                 :            :     getContentType()
     274                 :            :         throw( com::sun::star::uno::RuntimeException );
     275                 :            : 
     276                 :            :     // XCommandProcessor
     277                 :            :     virtual com::sun::star::uno::Any SAL_CALL
     278                 :            :     execute( const com::sun::star::ucb::Command& aCommand,
     279                 :            :              sal_Int32 CommandId,
     280                 :            :              const com::sun::star::uno::Reference<
     281                 :            :                 com::sun::star::ucb::XCommandEnvironment >& Environment )
     282                 :            :         throw( com::sun::star::uno::Exception,
     283                 :            :                com::sun::star::ucb::CommandAbortedException,
     284                 :            :                com::sun::star::uno::RuntimeException );
     285                 :            :     virtual void SAL_CALL
     286                 :            :     abort( sal_Int32 CommandId )
     287                 :            :         throw( com::sun::star::uno::RuntimeException );
     288                 :            : 
     289                 :            :     //////////////////////////////////////////////////////////////////////
     290                 :            :     // Additional interfaces
     291                 :            :     //////////////////////////////////////////////////////////////////////
     292                 :            : 
     293                 :            :     // XContentCreator
     294                 :            :     virtual com::sun::star::uno::Sequence<
     295                 :            :                 com::sun::star::ucb::ContentInfo > SAL_CALL
     296                 :            :     queryCreatableContentsInfo()
     297                 :            :         throw( com::sun::star::uno::RuntimeException );
     298                 :            :     virtual com::sun::star::uno::Reference<
     299                 :            :                 com::sun::star::ucb::XContent > SAL_CALL
     300                 :            :     createNewContent( const com::sun::star::ucb::ContentInfo& Info )
     301                 :            :         throw( com::sun::star::uno::RuntimeException );
     302                 :            : 
     303                 :            :     //////////////////////////////////////////////////////////////////////
     304                 :            :     // Non-interface methods.
     305                 :            :     //////////////////////////////////////////////////////////////////////
     306                 :            : 
     307                 :            :     // Called from resultset data supplier.
     308                 :            :     static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
     309                 :            :     getPropertyValues( const ::com::sun::star::uno::Reference<
     310                 :            :                         ::com::sun::star::lang::XMultiServiceFactory >& rSMgr,
     311                 :            :                        const ::com::sun::star::uno::Sequence<
     312                 :            :                             ::com::sun::star::beans::Property >& rProperties,
     313                 :            :                        ContentProvider* pProvider,
     314                 :            :                        const ::rtl::OUString& rContentId );
     315                 :            : 
     316                 :            :     // Called from resultset data supplier.
     317                 :            :     ::com::sun::star::uno::Reference<
     318                 :            :         ::com::sun::star::container::XEnumeration >
     319                 :            :     getIterator();
     320                 :            : 
     321                 :            :     static ::rtl::OUString
     322                 :            :     getContentType( const ::rtl::OUString& aScheme,  sal_Bool bFolder );
     323                 :            : };
     324                 :            : 
     325                 :            : }
     326                 :            : 
     327                 :            : #endif
     328                 :            : 
     329                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10