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

Generated by: LCOV version 1.10