LCOV - code coverage report
Current view: top level - ucb/source/ucp/tdoc - tdoc_content.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 19 0.0 %
Date: 2014-04-14 Functions: 0 13 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 INCLUDED_TDOC_CONTENT_HXX
      21             : #define INCLUDED_TDOC_CONTENT_HXX
      22             : 
      23             : #include <ucbhelper/contenthelper.hxx>
      24             : #include <com/sun/star/task/DocumentPasswordRequest.hpp>
      25             : #include <com/sun/star/ucb/XContentCreator.hpp>
      26             : #include <com/sun/star/ucb/CommandFailedException.hpp>
      27             : #include "tdoc_provider.hxx"
      28             : 
      29             : #define NO_STREAM_CREATION_WITHIN_DOCUMENT_ROOT 1
      30             : 
      31             : namespace com { namespace sun { namespace star {
      32             :     namespace sdbc  { class XRow; }
      33             :     namespace io    { class XInputStream; class XOutputStream; }
      34             :     namespace beans { struct PropertyValue; }
      35             :     namespace ucb   { struct OpenCommandArgument2; struct TransferInfo;
      36             :                       struct ContentInfo; }
      37             : } } }
      38             : 
      39             : namespace tdoc_ucp
      40             : {
      41             : 
      42             : 
      43             : 
      44             : #define TDOC_ROOT_CONTENT_SERVICE_NAME \
      45             :                 "com.sun.star.ucb.TransientDocumentsRootContent"
      46             : #define TDOC_DOCUMENT_CONTENT_SERVICE_NAME \
      47             :                 "com.sun.star.ucb.TransientDocumentsDocumentContent"
      48             : #define TDOC_FOLDER_CONTENT_SERVICE_NAME \
      49             :                 "com.sun.star.ucb.TransientDocumentsFolderContent"
      50             : #define TDOC_STREAM_CONTENT_SERVICE_NAME \
      51             :                 "com.sun.star.ucb.TransientDocumentsStreamContent"
      52             : 
      53             : 
      54             : 
      55             : enum ContentType { STREAM, FOLDER, DOCUMENT, ROOT };
      56             : 
      57           0 : class ContentProperties
      58             : {
      59             : public:
      60           0 :     ContentProperties()
      61           0 :     : m_eType( STREAM )
      62           0 :     {}
      63             : 
      64           0 :     ContentProperties( const ContentType & rType, const OUString & rTitle )
      65             :     : m_eType( rType ),
      66           0 :       m_aContentType( rType == STREAM
      67             :         ? OUString( TDOC_STREAM_CONTENT_TYPE )
      68           0 :         : rType == FOLDER
      69             :             ? OUString( TDOC_FOLDER_CONTENT_TYPE )
      70           0 :             : rType == DOCUMENT
      71             :                 ? OUString( TDOC_DOCUMENT_CONTENT_TYPE )
      72             :                 : OUString( TDOC_ROOT_CONTENT_TYPE ) ),
      73           0 :       m_aTitle( rTitle )
      74           0 :     {}
      75             : 
      76           0 :     ContentType getType() const { return m_eType; }
      77             : 
      78             :     // Properties
      79             : 
      80           0 :     const OUString & getContentType() const { return m_aContentType; }
      81             : 
      82           0 :     bool getIsFolder()   const { return m_eType > STREAM; }
      83           0 :     bool getIsDocument() const { return !getIsFolder(); }
      84             : 
      85           0 :     const OUString & getTitle() const { return m_aTitle; }
      86           0 :     void setTitle( const OUString & rTitle ) { m_aTitle = rTitle; }
      87             : 
      88             :     com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
      89             :     getCreatableContentsInfo() const;
      90             : 
      91             :     bool isContentCreator() const;
      92             : 
      93             : private:
      94             :     ContentType   m_eType;
      95             :     OUString m_aContentType;
      96             :     OUString m_aTitle;
      97             : };
      98             : 
      99             : 
     100             : 
     101             : class Content : public ::ucbhelper::ContentImplHelper,
     102             :                 public com::sun::star::ucb::XContentCreator
     103             : {
     104             :     enum ContentState { TRANSIENT,  // created via createNewContent,
     105             :                                         // but did not process "insert" yet
     106             :                         PERSISTENT, // processed "insert"
     107             :                         DEAD        // processed "delete" / document was closed
     108             :                       };
     109             : 
     110             :     ContentProperties m_aProps;
     111             :     ContentState      m_eState;
     112             :     ContentProvider*  m_pProvider;
     113             : 
     114             : private:
     115             :     Content( const com::sun::star::uno::Reference<
     116             :                 com::sun::star::uno::XComponentContext >& rxContext,
     117             :              ContentProvider* pProvider,
     118             :              const com::sun::star::uno::Reference<
     119             :                 com::sun::star::ucb::XContentIdentifier >& Identifier,
     120             :             const ContentProperties & rProps );
     121             :     Content( const com::sun::star::uno::Reference<
     122             :                 com::sun::star::uno::XComponentContext >& rxContext,
     123             :              ContentProvider* pProvider,
     124             :              const com::sun::star::uno::Reference<
     125             :                 com::sun::star::ucb::XContentIdentifier >& Identifier,
     126             :              const com::sun::star::ucb::ContentInfo& Info );
     127             : 
     128             :     virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
     129             :     getProperties( const com::sun::star::uno::Reference<
     130             :                     com::sun::star::ucb::XCommandEnvironment > & xEnv ) SAL_OVERRIDE;
     131             :     virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
     132             :     getCommands( const com::sun::star::uno::Reference<
     133             :                     com::sun::star::ucb::XCommandEnvironment > & xEnv ) SAL_OVERRIDE;
     134             :     virtual OUString getParentURL() SAL_OVERRIDE;
     135             : 
     136             :     static bool hasData( ContentProvider* pProvider, const Uri & rUri );
     137           0 :     bool hasData( const Uri & rUri ) { return hasData( m_pProvider, rUri ); }
     138             : 
     139             :     static bool loadData( ContentProvider* pProvider,
     140             :                           const Uri & rUri,
     141             :                           ContentProperties& rProps );
     142             :     bool storeData( const com::sun::star::uno::Reference<
     143             :                         com::sun::star::io::XInputStream >& xData,
     144             :                     const com::sun::star::uno::Reference<
     145             :                         com::sun::star::ucb::XCommandEnvironment >& xEnv )
     146             :         throw ( ::com::sun::star::ucb::CommandFailedException,
     147             :                 ::com::sun::star::task::DocumentPasswordRequest );
     148             :     bool renameData( const com::sun::star::uno::Reference<
     149             :                         com::sun::star::ucb::XContentIdentifier >& xOldId,
     150             :                      const com::sun::star::uno::Reference<
     151             :                         com::sun::star::ucb::XContentIdentifier >& xNewId );
     152             :     bool removeData();
     153             : 
     154             :     bool copyData( const Uri & rSourceUri, const OUString & rNewName );
     155             : 
     156             :     ::com::sun::star::uno::Reference<
     157             :         ::com::sun::star::ucb::XContentIdentifier >
     158             :     makeNewIdentifier( const OUString& rTitle );
     159             : 
     160             :     typedef rtl::Reference< Content > ContentRef;
     161             :     typedef std::list< ContentRef > ContentRefList;
     162             :     void queryChildren( ContentRefList& rChildren );
     163             : 
     164             :     sal_Bool exchangeIdentity(
     165             :                 const ::com::sun::star::uno::Reference<
     166             :                         ::com::sun::star::ucb::XContentIdentifier >& xNewId );
     167             : 
     168             :     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
     169             :     getPropertyValues( const ::com::sun::star::uno::Sequence<
     170             :                             ::com::sun::star::beans::Property >& rProperties );
     171             :     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
     172             :     setPropertyValues(
     173             :             const ::com::sun::star::uno::Sequence<
     174             :                     ::com::sun::star::beans::PropertyValue >& rValues,
     175             :             const ::com::sun::star::uno::Reference<
     176             :                     ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
     177             :         throw( ::com::sun::star::uno::Exception );
     178             : 
     179             :     com::sun::star::uno::Any
     180             :     open( const ::com::sun::star::ucb::OpenCommandArgument2& rArg,
     181             :           const ::com::sun::star::uno::Reference<
     182             :             ::com::sun::star::ucb::XCommandEnvironment >& xEnv )
     183             :         throw( ::com::sun::star::uno::Exception );
     184             : 
     185             :     void insert( const ::com::sun::star::uno::Reference<
     186             :                     ::com::sun::star::io::XInputStream >& xData,
     187             :                  sal_Int32 nNameClashResolve,
     188             :                  const ::com::sun::star::uno::Reference<
     189             :                     ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
     190             :         throw( ::com::sun::star::uno::Exception );
     191             : 
     192             :     void destroy( sal_Bool bDeletePhysical,
     193             :                   const ::com::sun::star::uno::Reference<
     194             :                     ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
     195             :         throw( ::com::sun::star::uno::Exception );
     196             : 
     197             :     void transfer( const ::com::sun::star::ucb::TransferInfo& rInfo,
     198             :                    const ::com::sun::star::uno::Reference<
     199             :                     ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
     200             :         throw( ::com::sun::star::uno::Exception );
     201             : 
     202             :     static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
     203             :     getPropertyValues( const ::com::sun::star::uno::Reference<
     204             :                         ::com::sun::star::uno::XComponentContext >& rxContext,
     205             :                        const ::com::sun::star::uno::Sequence<
     206             :                         ::com::sun::star::beans::Property >& rProperties,
     207             :                        const ContentProperties& rData,
     208             :                        ContentProvider* pProvider,
     209             :                        const OUString& rContentId );
     210             : 
     211             : 
     212             :     static bool commitStorage(
     213             :         const com::sun::star::uno::Reference<
     214             :             com::sun::star::embed::XStorage > & xStorage );
     215             : 
     216             :     static bool closeOutputStream(
     217             :         const com::sun::star::uno::Reference<
     218             :             com::sun::star::io::XOutputStream > & xOut );
     219             : 
     220             :     ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
     221             :     getInputStream( const ::com::sun::star::uno::Reference<
     222             :                         ::com::sun::star::ucb::XCommandEnvironment > &
     223             :                             xEnv )
     224             :         throw ( ::com::sun::star::ucb::CommandFailedException,
     225             :                 ::com::sun::star::task::DocumentPasswordRequest );
     226             : 
     227             :     ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
     228             :     getTruncatedOutputStream(
     229             :         const ::com::sun::star::uno::Reference<
     230             :             ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
     231             :         throw ( ::com::sun::star::ucb::CommandFailedException,
     232             :                 ::com::sun::star::task::DocumentPasswordRequest );
     233             : 
     234             :     ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent >
     235             :     queryChildContent( const OUString & rRelativeChildUri );
     236             : 
     237             :     ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >
     238             :     getStream( const ::com::sun::star::uno::Reference<
     239             :                     ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
     240             :         throw ( ::com::sun::star::ucb::CommandFailedException,
     241             :                 ::com::sun::star::task::DocumentPasswordRequest );
     242             : 
     243             : public:
     244             :     // Create existing content. Fail, if not already exists.
     245             :     static Content* create(
     246             :             const com::sun::star::uno::Reference<
     247             :                 com::sun::star::uno::XComponentContext >& rxContext,
     248             :             ContentProvider* pProvider,
     249             :             const com::sun::star::uno::Reference<
     250             :                 com::sun::star::ucb::XContentIdentifier >& Identifier );
     251             : 
     252             :     // Create new content. Fail, if already exists.
     253             :     static Content* create(
     254             :             const com::sun::star::uno::Reference<
     255             :                 com::sun::star::uno::XComponentContext >& rxContext,
     256             :             ContentProvider* pProvider,
     257             :             const com::sun::star::uno::Reference<
     258             :                 com::sun::star::ucb::XContentIdentifier >& Identifier,
     259             :             const com::sun::star::ucb::ContentInfo& Info );
     260             : 
     261             :     virtual ~Content();
     262             : 
     263             :     // XInterface
     264             :     virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
     265             :         throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     266             :     virtual void SAL_CALL acquire()
     267             :         throw() SAL_OVERRIDE;
     268             :     virtual void SAL_CALL release()
     269             :         throw() SAL_OVERRIDE;
     270             : 
     271             :     // XTypeProvider
     272             :     virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
     273             :         throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     274             :     virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
     275             :         throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     276             : 
     277             :     // XServiceInfo
     278             :     virtual OUString SAL_CALL
     279             :     getImplementationName()
     280             :         throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     281             :     virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
     282             :     getSupportedServiceNames()
     283             :         throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     284             : 
     285             :     // XContent
     286             :     virtual OUString SAL_CALL
     287             :     getContentType()
     288             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     289             :     virtual com::sun::star::uno::Reference<
     290             :                 com::sun::star::ucb::XContentIdentifier > SAL_CALL
     291             :     getIdentifier()
     292             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     293             : 
     294             :     // XCommandProcessor
     295             :     virtual com::sun::star::uno::Any SAL_CALL
     296             :     execute( const com::sun::star::ucb::Command& aCommand,
     297             :              sal_Int32 CommandId,
     298             :              const com::sun::star::uno::Reference<
     299             :                 com::sun::star::ucb::XCommandEnvironment >& Environment )
     300             :         throw( com::sun::star::uno::Exception,
     301             :                com::sun::star::ucb::CommandAbortedException,
     302             :                com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     303             :     virtual void SAL_CALL
     304             :     abort( sal_Int32 CommandId )
     305             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     306             : 
     307             : 
     308             :     // Additional interfaces
     309             : 
     310             : 
     311             :     // XContentCreator
     312             :     virtual com::sun::star::uno::Sequence<
     313             :                 com::sun::star::ucb::ContentInfo > SAL_CALL
     314             :     queryCreatableContentsInfo()
     315             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     316             :     virtual com::sun::star::uno::Reference<
     317             :                 com::sun::star::ucb::XContent > SAL_CALL
     318             :     createNewContent( const com::sun::star::ucb::ContentInfo& Info )
     319             :         throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     320             : 
     321             : 
     322             :     // Non-interface methods.
     323             : 
     324             : 
     325             :     static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
     326             :     getPropertyValues( const ::com::sun::star::uno::Reference<
     327             :                         ::com::sun::star::uno::XComponentContext >& rxContext,
     328             :                        const ::com::sun::star::uno::Sequence<
     329             :                         ::com::sun::star::beans::Property >& rProperties,
     330             :                        ContentProvider* pProvider,
     331             :                        const OUString& rContentId );
     332             : 
     333             :     void notifyDocumentClosed();
     334             :     void notifyChildRemoved( const OUString & rRelativeChildUri );
     335             :     void notifyChildInserted( const OUString & rRelativeChildUri );
     336             : 
     337           0 :     rtl::Reference< ContentProvider > getContentProvider() const
     338           0 :     { return rtl::Reference< ContentProvider >( m_pProvider ); }
     339             : };
     340             : 
     341             : } // namespace tdoc_ucp
     342             : 
     343             : #endif /* !INCLUDED_TDOC_CONTENT_HXX */
     344             : 
     345             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10