LCOV - code coverage report
Current view: top level - fpicker/source/office - fpsmartcontent.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 10 0.0 %
Date: 2014-04-14 Functions: 0 8 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 SVTOOLS_SOURCE_FILEPICKER_FPSMARTCONTENT_HXX
      21             : #define SVTOOLS_SOURCE_FILEPICKER_FPSMARTCONTENT_HXX
      22             : 
      23             : #include "fpinteraction.hxx"
      24             : 
      25             : #include <com/sun/star/ucb/XCommandEnvironment.hpp>
      26             : #include <com/sun/star/task/XInteractionHandler.hpp>
      27             : #include <ucbhelper/content.hxx>
      28             : 
      29             : 
      30             : namespace svt
      31             : {
      32             : 
      33             : 
      34             : 
      35             :     //= SmartContent
      36             : 
      37             :     /** a "smart content" which basically wraps an UCB content, but caches some information
      38             :         so that repeatedly recreating it may be faster
      39             :     */
      40             :     class SmartContent
      41             :     {
      42             :     public:
      43             :         enum State
      44             :         {
      45             :             NOT_BOUND,  // never bound
      46             :             UNKNOWN,    // bound, but validity is unknown
      47             :             VALID,      // bound to an URL, and valid
      48             :             INVALID     // bound to an URL, and invalid
      49             :         };
      50             : 
      51             :     private:
      52             :         OUString                                                                  m_sURL;
      53             :         ::ucbhelper::Content*                                                            m_pContent;
      54             :         State                                                                            m_eState;
      55             :         ::com::sun::star::uno::Reference < ::com::sun::star::ucb::XCommandEnvironment >  m_xCmdEnv;
      56             :         ::com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionHandler > m_xOwnInteraction;
      57             :         ::svt::OFilePickerInteractionHandler*                                            m_pOwnInteraction;
      58             : 
      59             :     private:
      60             :         enum Type { Folder, Document };
      61             :         /// checks if the currently bound content is a folder or document
      62             :         sal_Bool implIs( const OUString& _rURL, Type _eType );
      63             : 
      64             :         SmartContent( const SmartContent& _rSource );               // never implemented
      65             :         SmartContent& operator=( const SmartContent& _rSource );    // never implemented
      66             : 
      67             :     public:
      68             :         SmartContent();
      69             :         SmartContent( const OUString& _rInitialURL );
      70             :         ~SmartContent();
      71             : 
      72             :     public:
      73             : 
      74             :         /** create and set a specialized interaction handler at the internal used command environment.
      75             : 
      76             :             @param eInterceptions
      77             :                     will be directly forwarded to OFilePickerInteractionHandler::enableInterceptions()
      78             :         */
      79             :         void enableOwnInteractionHandler(::svt::OFilePickerInteractionHandler::EInterceptedInteractions eInterceptions);
      80             : 
      81             :         /** disable the specialized interaction handler and use the global UI interaction handler only.
      82             :         */
      83             :         void enableDefaultInteractionHandler();
      84             : 
      85             :         /** return the internal used interaction handler object ...
      86             :             Because this pointer will be valid only, if the uno object is hold
      87             :             alive by its uno reference (and this reference is set on the
      88             :             command environment) we must return NULL, in case this environment does
      89             :             not exist!
      90             :         */
      91             :         ::svt::OFilePickerInteractionHandler* getOwnInteractionHandler() const;
      92             : 
      93             :         /** describes different types of interaction handlers
      94             :          */
      95             :         enum InteractionHandlerType
      96             :         {
      97             :             IHT_NONE,
      98             :             IHT_OWN,
      99             :             IHT_DEFAULT
     100             :         };
     101             : 
     102             :         /** return the type of the internal used interaction handler object ...
     103             : 
     104             :             @seealso InteractionHandlerType
     105             :         */
     106             :         InteractionHandlerType queryCurrentInteractionHandler() const;
     107             : 
     108             :         /** disable internal used interaction handler object ...
     109             :          */
     110             :         void disableInteractionHandler();
     111             : 
     112             :         /** returns the current state of the content
     113             : 
     114             :             @seealso State
     115             :         */
     116           0 :         inline  State       getState( ) const { return m_eState; }
     117             : 
     118             :         /** checks if the content is valid
     119             :             <p>Note that "not (is valid)" is not the same as "is invalid"</p>
     120             :         */
     121           0 :         inline  sal_Bool    isValid( ) const { return VALID == getState(); }
     122             : 
     123             :         /** checks if the content is valid
     124             :             <p>Note that "not (is invalid)" is not the same as "is valid"</p>
     125             :         */
     126           0 :         inline  sal_Bool    isInvalid( ) const { return INVALID == getState(); }
     127             : 
     128             :         /** checks if the content is bound
     129             :         */
     130           0 :         inline  sal_Bool    isBound( ) const { return NOT_BOUND != getState(); }
     131             : 
     132             :         /** returns the URL of the content
     133             :         */
     134           0 :         inline OUString  getURL() const { return m_pContent ? m_pContent->getURL() : m_sURL; }
     135             : 
     136             :         /** (re)creates the content for the given URL
     137             : 
     138             :             <p>Note that getState will return either UNKNOWN or INVALID after the call returns,
     139             :             but never VALID. The reason is that there are content providers which allow to construct
     140             :             content objects, even if the respective contents are not accessible. They tell about this
     141             :             only upon working with the content object (e.g. when asking for the IsFolder).</p>
     142             : 
     143             :             @postcond
     144             :                 <member>getState</member> does not return NOT_BOUND after the call returns
     145             :         */
     146             :         void    bindTo( const OUString& _rURL );
     147             : 
     148             :         /** retrieves the title of the content
     149             :             @precond
     150             :                 the content is bound and not invalid
     151             :         */
     152             :         void    getTitle( OUString& /* [out] */ _rTitle );
     153             : 
     154             :         /** checks if the content has a parent folder
     155             :             @precond
     156             :                 the content is bound and not invalid
     157             :         */
     158             :         sal_Bool    hasParentFolder( );
     159             : 
     160             :         /** checks if sub folders below the content can be created
     161             :             @precond
     162             :                 the content is bound and not invalid
     163             :         */
     164             :         sal_Bool    canCreateFolder( );
     165             : 
     166             :         /** creates a new folder with the given title and return the corresponding URL.
     167             : 
     168             :             @return
     169             :                 the URL of the created folder or an empty string
     170             :           */
     171             :         OUString    createFolder( const OUString& _rTitle );
     172             : 
     173             :         /** binds to the given URL, checks whether or not it refers to a folder
     174             : 
     175             :             @postcond
     176             :                 the content is not in the state UNKNOWN
     177             :         */
     178           0 :         inline  sal_Bool    isFolder( const OUString& _rURL )
     179             :         {
     180           0 :             return implIs( _rURL, Folder );
     181             :         }
     182             : 
     183             :         /** binds to the given URL, checks whether or not it refers to a document
     184             : 
     185             :             @postcond
     186             :                 the content is not in the state UNKNOWN
     187             :         */
     188             :         inline  sal_Bool    isDocument(  const OUString& _rURL )
     189             :         {
     190             :             return implIs( _rURL, Document );
     191             :         }
     192             : 
     193             :         /** checks if the content is existent (it is if and only if it is a document or a folder)
     194             :         */
     195           0 :         inline  sal_Bool    is( const OUString& _rURL )
     196             :         {
     197           0 :             return  implIs( _rURL, Folder ) || implIs( _rURL, Document );
     198             :         }
     199             : 
     200           0 :         inline  sal_Bool    isFolder( )     { return isFolder( getURL() ); }
     201             :         inline  sal_Bool    isDocument( )   { return isDocument( getURL() ); }
     202             :         inline  sal_Bool    is( )           { return is( getURL() ); }
     203             :     };
     204             : 
     205             : 
     206             : } // namespace svt
     207             : 
     208             : 
     209             : #endif // SVTOOLS_SOURCE_FILEPICKER_FPSMARTCONTENT_HXX
     210             : 
     211             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10