LCOV - code coverage report
Current view: top level - ucb/source/ucp/package - pkgcontent.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 4 0.0 %
Date: 2014-04-14 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          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           0 : struct ContentProperties
      71             : {
      72             :     OUString  aTitle;                // Title
      73             :     OUString  aContentType;          // ContentType
      74             :     sal_Bool         bIsDocument;           // IsDocument
      75             :     sal_Bool         bIsFolder;             // IsFolder
      76             :     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           0 :     ContentProperties()
      85             :     : bIsDocument( sal_True ), bIsFolder( sal_False ), nSize( 0 ),
      86             :       bCompressed( sal_True ), bEncrypted( sal_False ),
      87           0 :       bHasEncryptedEntries( sal_False ) {}
      88             : 
      89             :     ContentProperties( const 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::uno::XComponentContext >& rxContext,
     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::uno::XComponentContext >& rxContext,
     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 ) SAL_OVERRIDE;
     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 ) SAL_OVERRIDE;
     142             :     virtual OUString getParentURL() SAL_OVERRIDE;
     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::uno::XComponentContext >& rxContext,
     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 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           0 :     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::uno::XComponentContext >& rxContext,
     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::uno::XComponentContext >& rxContext,
     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             :     virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
     259             :         throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     260             :     virtual void SAL_CALL acquire()
     261             :         throw() SAL_OVERRIDE;
     262             :     virtual void SAL_CALL release()
     263             :         throw() SAL_OVERRIDE;
     264             : 
     265             :     // XTypeProvider
     266             :     virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
     267             :         throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     268             :     virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
     269             :         throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     270             : 
     271             :     // XServiceInfo
     272             :     virtual OUString SAL_CALL
     273             :     getImplementationName()
     274             :         throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     275             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
     276             :     getSupportedServiceNames()
     277             :         throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     278             : 
     279             :     // XContent
     280             :     virtual OUString SAL_CALL
     281             :     getContentType()
     282             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     283             : 
     284             :     // XCommandProcessor
     285             :     virtual com::sun::star::uno::Any SAL_CALL
     286             :     execute( const com::sun::star::ucb::Command& aCommand,
     287             :              sal_Int32 CommandId,
     288             :              const com::sun::star::uno::Reference<
     289             :                 com::sun::star::ucb::XCommandEnvironment >& Environment )
     290             :         throw( com::sun::star::uno::Exception,
     291             :                com::sun::star::ucb::CommandAbortedException,
     292             :                com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     293             :     virtual void SAL_CALL
     294             :     abort( sal_Int32 CommandId )
     295             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     296             : 
     297             : 
     298             :     // Additional interfaces
     299             : 
     300             : 
     301             :     // XContentCreator
     302             :     virtual com::sun::star::uno::Sequence<
     303             :                 com::sun::star::ucb::ContentInfo > SAL_CALL
     304             :     queryCreatableContentsInfo()
     305             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     306             :     virtual com::sun::star::uno::Reference<
     307             :                 com::sun::star::ucb::XContent > SAL_CALL
     308             :     createNewContent( const com::sun::star::ucb::ContentInfo& Info )
     309             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     310             : 
     311             : 
     312             :     // Non-interface methods.
     313             : 
     314             : 
     315             :     // Called from resultset data supplier.
     316             :     static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
     317             :     getPropertyValues( const ::com::sun::star::uno::Reference<
     318             :                         ::com::sun::star::uno::XComponentContext >& rxContext,
     319             :                        const ::com::sun::star::uno::Sequence<
     320             :                             ::com::sun::star::beans::Property >& rProperties,
     321             :                        ContentProvider* pProvider,
     322             :                        const OUString& rContentId );
     323             : 
     324             :     // Called from resultset data supplier.
     325             :     ::com::sun::star::uno::Reference<
     326             :         ::com::sun::star::container::XEnumeration >
     327             :     getIterator();
     328             : 
     329             :     static OUString
     330             :     getContentType( const OUString& aScheme,  sal_Bool bFolder );
     331             : };
     332             : 
     333             : }
     334             : 
     335             : #endif
     336             : 
     337             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10