LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/framework/source/inc/accelerators - storageholder.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 4 100.0 %
Date: 2013-07-09 Functions: 2 3 66.7 %
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 __FRAMEWORK_ACCELERATORS_STORAGEHOLDER_HXX_
      21             : #define __FRAMEWORK_ACCELERATORS_STORAGEHOLDER_HXX_
      22             : 
      23             : #include <accelerators/istoragelistener.hxx>
      24             : #include <threadhelp/threadhelpbase.hxx>
      25             : #include <general.h>
      26             : #include <stdtypes.h>
      27             : 
      28             : #include <com/sun/star/embed/XStorage.hpp>
      29             : 
      30             : 
      31             : namespace framework
      32             : {
      33             : 
      34             : 
      35             : //-----------------------------------------------
      36             : /**
      37             :     TODO document me
      38             :  */
      39             : class StorageHolder : private ThreadHelpBase // attention! Must be the first base class to guarentee right initialize lock ...
      40             : {
      41             :     //-------------------------------------------
      42             :     // types
      43             :     public:
      44             : 
      45             :         /** @short  TODO */
      46             :         typedef ::std::vector< css::uno::Reference< css::embed::XStorage > > TStorageList;
      47             : 
      48             :         typedef ::std::vector< IStorageListener* > TStorageListenerList;
      49             : 
      50        1319 :         struct TStorageInfo
      51             :         {
      52             :             public:
      53             :                 css::uno::Reference< css::embed::XStorage > Storage;
      54             :                 sal_Int32 UseCount;
      55             :                 TStorageListenerList Listener;
      56             : 
      57        1344 :                 TStorageInfo()
      58        1344 :                     : UseCount(0)
      59        1344 :                 {}
      60             :         };
      61             : 
      62             :         /** @short  TODO */
      63             :         typedef ::boost::unordered_map< OUString                    ,
      64             :                                  TStorageInfo                       ,
      65             :                                  OUStringHash                ,
      66             :                                  ::std::equal_to< OUString > > TPath2StorageInfo;
      67             : 
      68             :     //-------------------------------------------
      69             :     // member
      70             :     private:
      71             : 
      72             :         /** @short  TODO */
      73             :         css::uno::Reference< css::embed::XStorage > m_xRoot;
      74             : 
      75             :         /** @short  TODO */
      76             :         TPath2StorageInfo m_lStorages;
      77             : 
      78             :     //-------------------------------------------
      79             :     // interface
      80             :     public:
      81             : 
      82             :         //---------------------------------------
      83             :         /** @short  TODO
      84             :          */
      85             :         StorageHolder();
      86             : 
      87             :         //---------------------------------------
      88             :         /** @short  TODO
      89             :          */
      90             :         virtual ~StorageHolder();
      91             : 
      92             :         //---------------------------------------
      93             :         /** @short  TODO
      94             :          */
      95             :         virtual void forgetCachedStorages();
      96             : 
      97             :         //---------------------------------------
      98             :         /** @short  TODO
      99             :          */
     100             :         virtual void setRootStorage(const css::uno::Reference< css::embed::XStorage >& xRoot);
     101             : 
     102             :         //---------------------------------------
     103             :         /** @short  TODO
     104             :          */
     105             :         virtual css::uno::Reference< css::embed::XStorage > getRootStorage() const;
     106             : 
     107             :         //---------------------------------------
     108             :         /** @short  TODO
     109             :                     open or get!
     110             :          */
     111             :         virtual css::uno::Reference< css::embed::XStorage > openPath(const OUString& sPath    ,
     112             :                                                                            sal_Int32        nOpenMode);
     113             : 
     114             :         //---------------------------------------
     115             :         /** @short  TODO
     116             :          */
     117             :         virtual StorageHolder::TStorageList getAllPathStorages(const OUString& sPath);
     118             : 
     119             :         //---------------------------------------
     120             :         /** @short  TODO
     121             :          */
     122             :         virtual void commitPath(const OUString& sPath);
     123             : 
     124             :         //---------------------------------------
     125             :         /** @short  TODO
     126             :          */
     127             :         virtual void closePath(const OUString& sPath);
     128             : 
     129             :         //---------------------------------------
     130             :         /** @short  TODO
     131             :          */
     132             :         virtual void notifyPath(const OUString& sPath);
     133             : 
     134             :         //---------------------------------------
     135             :         /** @short  TODO
     136             :          */
     137             :         virtual void addStorageListener(      IStorageListener* pListener,
     138             :                                         const OUString&  sPath    );
     139             : 
     140             :         //---------------------------------------
     141             :         /** @short  TODO
     142             :          */
     143             :         virtual void removeStorageListener(      IStorageListener* pListener,
     144             :                                            const OUString&  sPath    );
     145             : 
     146             :         //---------------------------------------
     147             :         /** @short  TODO
     148             :          */
     149             :         virtual OUString getPathOfStorage(const css::uno::Reference< css::embed::XStorage >& xStorage);
     150             : 
     151             :         //---------------------------------------
     152             :         /** @short  TODO
     153             :          */
     154             :         virtual css::uno::Reference< css::embed::XStorage > getParentStorage(const css::uno::Reference< css::embed::XStorage >& xChild);
     155             : 
     156             :         //---------------------------------------
     157             :         /** @short  TODO
     158             :          */
     159             :         virtual css::uno::Reference< css::embed::XStorage > getParentStorage(const OUString& sChildPath);
     160             : 
     161             :         //---------------------------------------
     162             :         /** @short  TODO
     163             :          */
     164             :         void operator=(const StorageHolder& rCopy);
     165             : 
     166             :         //---------------------------------------
     167             :         /** @short  opens a sub element of the specified base storage.
     168             : 
     169             :             @descr  First this method try to open the requested sub element
     170             :                     using the given open mode. If it failed there is second step,
     171             :                     which tries to do the same again ... but removing a might existing
     172             :                     WRITE flag from the open mode. The user can supress this fallback
     173             :                     handling by setting the parameter bAllowFallback to sal_False.
     174             : 
     175             :             @param  xBaseStorage
     176             :                     the storage, where the sub element should be searched.
     177             : 
     178             :             @param  sSubElement
     179             :                     the full name of the sub element.
     180             :                     e.g. "default.xml"
     181             : 
     182             :             @param  eOpenMode
     183             :                     a flag field, which set the open mode for this operation.
     184             : 
     185             :             @param  bAllowFallback
     186             :                     if eOpenMode contains an ELEMENT_WRITE flag this parameter
     187             :                     allow to remove it and try it with the rest of eOpenMode flags
     188             :                     again.
     189             :          */
     190             :         static css::uno::Reference< css::embed::XStorage > openSubStorageWithFallback(const css::uno::Reference< css::embed::XStorage >& xBaseStorage  ,
     191             :                                                                                       const OUString&                             sSubStorage   ,
     192             :                                                                                             sal_Int32                                    eOpenMode     ,
     193             :                                                                                             sal_Bool                                     bAllowFallback);
     194             : 
     195             :         static css::uno::Reference< css::io::XStream > openSubStreamWithFallback(const css::uno::Reference< css::embed::XStorage >& xBaseStorage  ,
     196             :                                                                                  const OUString&                             sSubStream    ,
     197             :                                                                                        sal_Int32                                    eOpenMode     ,
     198             :                                                                                        sal_Bool                                     bAllowFallback);
     199             : 
     200             :         //---------------------------------------
     201             :         // helper
     202             :         private:
     203             : 
     204             :             //-----------------------------------
     205             :             /** @short  TODO
     206             :              */
     207             :             static OUString impl_st_normPath(const OUString& sPath);
     208             : 
     209             :             //-----------------------------------
     210             :             /** @short  TODO
     211             :              */
     212             :             static OUStringList impl_st_parsePath(const OUString& sPath);
     213             : };
     214             : 
     215             : } // namespace framework
     216             : 
     217             : #endif // __FRAMEWORK_ACCELERATORS_STORAGEHOLDER_HXX_
     218             : 
     219             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10