LCOV - code coverage report
Current view: top level - libreoffice/ucb/source/ucp/hierarchy - hierarchycontent.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 24 0.0 %
Date: 2012-12-27 Functions: 0 18 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 _HIERARCHYCONTENT_HXX
      21             : #define _HIERARCHYCONTENT_HXX
      22             : 
      23             : #include <list>
      24             : #include <rtl/ref.hxx>
      25             : #include <com/sun/star/ucb/XContentCreator.hpp>
      26             : #include <ucbhelper/contenthelper.hxx>
      27             : #include "hierarchydata.hxx"
      28             : #include "hierarchyprovider.hxx"
      29             : 
      30             : namespace com { namespace sun { namespace star { namespace beans {
      31             :     struct Property;
      32             :     struct PropertyValue;
      33             : } } } }
      34             : 
      35             : namespace com { namespace sun { namespace star { namespace sdbc {
      36             :     class XRow;
      37             : } } } }
      38             : 
      39             : namespace com { namespace sun { namespace star { namespace ucb {
      40             :     struct TransferInfo;
      41             : } } } }
      42             : 
      43             : namespace hierarchy_ucp
      44             : {
      45             : 
      46             : //=========================================================================
      47             : 
      48             : #define HIERARCHY_ROOT_FOLDER_CONTENT_SERVICE_NAME \
      49             :                             "com.sun.star.ucb.HierarchyRootFolderContent"
      50             : #define HIERARCHY_FOLDER_CONTENT_SERVICE_NAME \
      51             :                             "com.sun.star.ucb.HierarchyFolderContent"
      52             : #define HIERARCHY_LINK_CONTENT_SERVICE_NAME \
      53             :                             "com.sun.star.ucb.HierarchyLinkContent"
      54             : 
      55             : //=========================================================================
      56             : 
      57           0 : class HierarchyContentProperties
      58             : {
      59             : public:
      60           0 :     HierarchyContentProperties() {};
      61             : 
      62           0 :     HierarchyContentProperties( const HierarchyEntryData::Type & rType )
      63             :     : m_aData( rType ),
      64             :       m_aContentType( rType == HierarchyEntryData::FOLDER
      65             :         ? rtl::OUString( HIERARCHY_FOLDER_CONTENT_TYPE )
      66           0 :         : rtl::OUString( HIERARCHY_LINK_CONTENT_TYPE ) ) {}
      67             : 
      68           0 :     HierarchyContentProperties( const HierarchyEntryData & rData )
      69             :     : m_aData( rData ),
      70           0 :       m_aContentType( rData.getType() == HierarchyEntryData::FOLDER
      71             :         ? rtl::OUString( HIERARCHY_FOLDER_CONTENT_TYPE )
      72           0 :         : rtl::OUString( HIERARCHY_LINK_CONTENT_TYPE ) ) {}
      73             : 
      74           0 :     const rtl::OUString & getName() const { return m_aData.getName(); }
      75           0 :     void setName( const rtl::OUString & rName ) { m_aData.setName( rName ); };
      76             : 
      77           0 :     const rtl::OUString & getTitle() const { return m_aData.getTitle(); }
      78           0 :     void setTitle( const rtl::OUString & rTitle )
      79           0 :     { m_aData.setTitle( rTitle ); };
      80             : 
      81           0 :     const rtl::OUString & getTargetURL() const
      82           0 :     { return m_aData.getTargetURL(); }
      83           0 :     void setTargetURL( const rtl::OUString & rURL )
      84           0 :     { m_aData.setTargetURL( rURL ); };
      85             : 
      86           0 :     const rtl::OUString & getContentType() const { return m_aContentType; }
      87             : 
      88           0 :     sal_Bool getIsFolder() const
      89           0 :     { return m_aData.getType() == HierarchyEntryData::FOLDER; }
      90             : 
      91           0 :     sal_Bool getIsDocument() const { return !getIsFolder(); }
      92             : 
      93             :     com::sun::star::uno::Sequence< com::sun::star::ucb::ContentInfo >
      94             :     getCreatableContentsInfo() const;
      95             : 
      96           0 :     const HierarchyEntryData & getHierarchyEntryData() const { return m_aData; }
      97             : 
      98             : private:
      99             :     HierarchyEntryData m_aData;
     100             :     rtl::OUString m_aContentType;
     101             : };
     102             : 
     103             : //=========================================================================
     104             : 
     105             : class HierarchyContentProvider;
     106             : 
     107             : class HierarchyContent : public ::ucbhelper::ContentImplHelper,
     108             :                          public com::sun::star::ucb::XContentCreator
     109             : {
     110             :     enum ContentKind  { LINK, FOLDER, ROOT };
     111             :     enum ContentState { TRANSIENT,  // created via CreateNewContent,
     112             :                                         // but did not process "insert" yet
     113             :                         PERSISTENT, // processed "insert"
     114             :                         DEAD        // processed "delete"
     115             :                       };
     116             : 
     117             :     HierarchyContentProperties m_aProps;
     118             :     ContentKind                m_eKind;
     119             :     ContentState               m_eState;
     120             :     HierarchyContentProvider*  m_pProvider;
     121             :     bool                       m_bCheckedReadOnly;
     122             :     bool                       m_bIsReadOnly;
     123             : 
     124             : private:
     125             :     HierarchyContent(
     126             :             const com::sun::star::uno::Reference<
     127             :                 com::sun::star::uno::XComponentContext >& rxContext,
     128             :             HierarchyContentProvider* pProvider,
     129             :             const com::sun::star::uno::Reference<
     130             :                 com::sun::star::ucb::XContentIdentifier >& Identifier,
     131             :             const HierarchyContentProperties& rProps );
     132             :     HierarchyContent(
     133             :             const com::sun::star::uno::Reference<
     134             :                 com::sun::star::uno::XComponentContext >& rxContext,
     135             :             HierarchyContentProvider* pProvider,
     136             :             const com::sun::star::uno::Reference<
     137             :                 com::sun::star::ucb::XContentIdentifier >& Identifier,
     138             :             const com::sun::star::ucb::ContentInfo& Info );
     139             : 
     140             :     virtual com::sun::star::uno::Sequence< com::sun::star::beans::Property >
     141             :     getProperties( const com::sun::star::uno::Reference<
     142             :                     com::sun::star::ucb::XCommandEnvironment > & xEnv );
     143             :     virtual com::sun::star::uno::Sequence< com::sun::star::ucb::CommandInfo >
     144             :     getCommands( const com::sun::star::uno::Reference<
     145             :                     com::sun::star::ucb::XCommandEnvironment > & xEnv );
     146             :     virtual ::rtl::OUString getParentURL();
     147             : 
     148             :     static sal_Bool hasData(
     149             :             const com::sun::star::uno::Reference<
     150             :                 com::sun::star::uno::XComponentContext >& rxContext,
     151             :             HierarchyContentProvider* pProvider,
     152             :             const com::sun::star::uno::Reference<
     153             :                 com::sun::star::ucb::XContentIdentifier >& Identifier );
     154           0 :     sal_Bool hasData(
     155             :             const com::sun::star::uno::Reference<
     156             :                 com::sun::star::ucb::XContentIdentifier >& Identifier )
     157           0 :     { return hasData( m_xContext, m_pProvider, Identifier ); }
     158             :     static sal_Bool loadData(
     159             :             const com::sun::star::uno::Reference<
     160             :                 com::sun::star::uno::XComponentContext >& rxContext,
     161             :             HierarchyContentProvider* pProvider,
     162             :             const com::sun::star::uno::Reference<
     163             :                 com::sun::star::ucb::XContentIdentifier >& Identifier,
     164             :             HierarchyContentProperties& rProps );
     165             :     sal_Bool storeData();
     166             :     sal_Bool renameData( const com::sun::star::uno::Reference<
     167             :                             com::sun::star::ucb::XContentIdentifier >& xOldId,
     168             :                          const com::sun::star::uno::Reference<
     169             :                             com::sun::star::ucb::XContentIdentifier >& xNewId );
     170             :     sal_Bool removeData();
     171             : 
     172             :     void setKind( const com::sun::star::uno::Reference<
     173             :                     com::sun::star::ucb::XContentIdentifier >& Identifier );
     174             : 
     175             :     bool isReadOnly();
     176             : 
     177           0 :     sal_Bool isFolder() const { return ( m_eKind > LINK ); }
     178             : 
     179             :     ::com::sun::star::uno::Reference<
     180             :         ::com::sun::star::ucb::XContentIdentifier >
     181             :     makeNewIdentifier( const rtl::OUString& rTitle );
     182             : 
     183             :     typedef rtl::Reference< HierarchyContent > HierarchyContentRef;
     184             :     typedef std::list< HierarchyContentRef > HierarchyContentRefList;
     185             :     void queryChildren( HierarchyContentRefList& rChildren );
     186             : 
     187             :     sal_Bool exchangeIdentity(
     188             :                 const ::com::sun::star::uno::Reference<
     189             :                         ::com::sun::star::ucb::XContentIdentifier >& xNewId );
     190             : 
     191             :     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
     192             :     getPropertyValues( const ::com::sun::star::uno::Sequence<
     193             :                             ::com::sun::star::beans::Property >& rProperties );
     194             :     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
     195             :     setPropertyValues(
     196             :             const ::com::sun::star::uno::Sequence<
     197             :                     ::com::sun::star::beans::PropertyValue >& rValues,
     198             :             const ::com::sun::star::uno::Reference<
     199             :                     ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
     200             :         throw( ::com::sun::star::uno::Exception );
     201             : 
     202             :     void insert( sal_Int32 nNameClashResolve,
     203             :                  const ::com::sun::star::uno::Reference<
     204             :                     ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
     205             :         throw( ::com::sun::star::uno::Exception );
     206             : 
     207             :     void destroy( sal_Bool bDeletePhysical,
     208             :                   const ::com::sun::star::uno::Reference<
     209             :                     ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
     210             :         throw( ::com::sun::star::uno::Exception );
     211             : 
     212             :     void transfer( const ::com::sun::star::ucb::TransferInfo& rInfo,
     213             :                    const ::com::sun::star::uno::Reference<
     214             :                     ::com::sun::star::ucb::XCommandEnvironment > & xEnv )
     215             :         throw( ::com::sun::star::uno::Exception );
     216             : 
     217             : public:
     218             :     // Create existing content. Fail, if not already exists.
     219             :     static HierarchyContent* create(
     220             :             const com::sun::star::uno::Reference<
     221             :                 com::sun::star::uno::XComponentContext >& rxContext,
     222             :             HierarchyContentProvider* pProvider,
     223             :             const com::sun::star::uno::Reference<
     224             :                 com::sun::star::ucb::XContentIdentifier >& Identifier );
     225             : 
     226             :     // Create new content. Fail, if already exists.
     227             :     static HierarchyContent* create(
     228             :             const com::sun::star::uno::Reference<
     229             :                 com::sun::star::uno::XComponentContext >& rxContext,
     230             :             HierarchyContentProvider* pProvider,
     231             :             const com::sun::star::uno::Reference<
     232             :                 com::sun::star::ucb::XContentIdentifier >& Identifier,
     233             :             const com::sun::star::ucb::ContentInfo& Info );
     234             : 
     235             :     virtual ~HierarchyContent();
     236             : 
     237             :     // XInterface
     238             :     XINTERFACE_DECL()
     239             : 
     240             :     // XTypeProvider
     241             :     XTYPEPROVIDER_DECL()
     242             : 
     243             :     // XServiceInfo
     244             :     virtual ::rtl::OUString SAL_CALL
     245             :     getImplementationName()
     246             :         throw( ::com::sun::star::uno::RuntimeException );
     247             :     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
     248             :     getSupportedServiceNames()
     249             :         throw( ::com::sun::star::uno::RuntimeException );
     250             : 
     251             :     // XContent
     252             :     virtual rtl::OUString SAL_CALL
     253             :     getContentType()
     254             :         throw( com::sun::star::uno::RuntimeException );
     255             :     virtual com::sun::star::uno::Reference<
     256             :                 com::sun::star::ucb::XContentIdentifier > SAL_CALL
     257             :     getIdentifier()
     258             :         throw( com::sun::star::uno::RuntimeException );
     259             : 
     260             :     // XCommandProcessor
     261             :     virtual com::sun::star::uno::Any SAL_CALL
     262             :     execute( const com::sun::star::ucb::Command& aCommand,
     263             :              sal_Int32 CommandId,
     264             :              const com::sun::star::uno::Reference<
     265             :                 com::sun::star::ucb::XCommandEnvironment >& Environment )
     266             :         throw( com::sun::star::uno::Exception,
     267             :                com::sun::star::ucb::CommandAbortedException,
     268             :                com::sun::star::uno::RuntimeException );
     269             :     virtual void SAL_CALL
     270             :     abort( sal_Int32 CommandId )
     271             :         throw( com::sun::star::uno::RuntimeException );
     272             : 
     273             :     //////////////////////////////////////////////////////////////////////
     274             :     // Additional interfaces
     275             :     //////////////////////////////////////////////////////////////////////
     276             : 
     277             :     // XContentCreator
     278             :     virtual com::sun::star::uno::Sequence<
     279             :                 com::sun::star::ucb::ContentInfo > SAL_CALL
     280             :     queryCreatableContentsInfo()
     281             :         throw( com::sun::star::uno::RuntimeException );
     282             :     virtual com::sun::star::uno::Reference<
     283             :                 com::sun::star::ucb::XContent > SAL_CALL
     284             :     createNewContent( const com::sun::star::ucb::ContentInfo& Info )
     285             :         throw( com::sun::star::uno::RuntimeException );
     286             : 
     287             :     //////////////////////////////////////////////////////////////////////
     288             :     // Non-interface methods.
     289             :     //////////////////////////////////////////////////////////////////////
     290             : 
     291             :     static ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow >
     292             :     getPropertyValues( const ::com::sun::star::uno::Reference<
     293             :                         ::com::sun::star::uno::XComponentContext >& rxContext,
     294             :                        const ::com::sun::star::uno::Sequence<
     295             :                             ::com::sun::star::beans::Property >& rProperties,
     296             :                        const HierarchyContentProperties& rData,
     297             :                        HierarchyContentProvider* pProvider,
     298             :                        const ::rtl::OUString& rContentId );
     299             : };
     300             : 
     301             : } // namespace hierarchy_ucp
     302             : 
     303             : #endif /* !_HIERARCHYCONTENT_HXX */
     304             : 
     305             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10