LCOV - code coverage report
Current view: top level - framework/source/inc/accelerators - storageholder.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 4 100.0 %
Date: 2012-08-25 Functions: 2 3 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 4 25.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef __FRAMEWORK_ACCELERATORS_STORAGEHOLDER_HXX_
      30                 :            : #define __FRAMEWORK_ACCELERATORS_STORAGEHOLDER_HXX_
      31                 :            : 
      32                 :            : #include <accelerators/istoragelistener.hxx>
      33                 :            : #include <threadhelp/threadhelpbase.hxx>
      34                 :            : #include <general.h>
      35                 :            : #include <stdtypes.h>
      36                 :            : 
      37                 :            : #include <com/sun/star/embed/XStorage.hpp>
      38                 :            : 
      39                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      40                 :            : 
      41                 :            : 
      42                 :            : namespace css = ::com::sun::star;
      43                 :            : 
      44                 :            : namespace framework
      45                 :            : {
      46                 :            : 
      47                 :            : 
      48                 :            : //-----------------------------------------------
      49                 :            : /**
      50                 :            :     TODO document me
      51                 :            :  */
      52                 :            : class StorageHolder : private ThreadHelpBase // attention! Must be the first base class to guarentee right initialize lock ...
      53                 :            : {
      54                 :            :     //-------------------------------------------
      55                 :            :     // types
      56                 :            :     public:
      57                 :            : 
      58                 :            :         /** @short  TODO */
      59                 :            :         typedef ::std::vector< css::uno::Reference< css::embed::XStorage > > TStorageList;
      60                 :            : 
      61                 :            :         typedef ::std::vector< IStorageListener* > TStorageListenerList;
      62                 :            : 
      63         [ #  # ]:       2454 :         struct TStorageInfo
      64                 :            :         {
      65                 :            :             public:
      66                 :            :                 css::uno::Reference< css::embed::XStorage > Storage;
      67                 :            :                 sal_Int32 UseCount;
      68                 :            :                 TStorageListenerList Listener;
      69                 :            : 
      70                 :       2554 :                 TStorageInfo()
      71         [ +  - ]:       2554 :                     : UseCount(0)
      72                 :       2554 :                 {}
      73                 :            :         };
      74                 :            : 
      75                 :            :         /** @short  TODO */
      76                 :            :         typedef ::boost::unordered_map< ::rtl::OUString                    ,
      77                 :            :                                  TStorageInfo                       ,
      78                 :            :                                  ::rtl::OUStringHash                ,
      79                 :            :                                  ::std::equal_to< ::rtl::OUString > > TPath2StorageInfo;
      80                 :            : 
      81                 :            :     //-------------------------------------------
      82                 :            :     // member
      83                 :            :     private:
      84                 :            : 
      85                 :            :         /** @short  TODO */
      86                 :            :         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
      87                 :            : 
      88                 :            :         /** @short  TODO */
      89                 :            :         css::uno::Reference< css::embed::XStorage > m_xRoot;
      90                 :            : 
      91                 :            :         /** @short  TODO */
      92                 :            :         TPath2StorageInfo m_lStorages;
      93                 :            : 
      94                 :            :     //-------------------------------------------
      95                 :            :     // interface
      96                 :            :     public:
      97                 :            : 
      98                 :            :         //---------------------------------------
      99                 :            :         /** @short  TODO
     100                 :            :          */
     101                 :            :         StorageHolder();
     102                 :            : 
     103                 :            :         //---------------------------------------
     104                 :            :         /** @short  TODO
     105                 :            :          */
     106                 :            :         StorageHolder(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
     107                 :            : 
     108                 :            :         //---------------------------------------
     109                 :            :         /** @short  TODO
     110                 :            :          */
     111                 :            :         virtual ~StorageHolder();
     112                 :            : 
     113                 :            :         //---------------------------------------
     114                 :            :         /** @short  TODO
     115                 :            :          */
     116                 :            :         virtual void forgetCachedStorages();
     117                 :            : 
     118                 :            :         //---------------------------------------
     119                 :            :         /** @short  TODO
     120                 :            :          */
     121                 :            :         virtual void setRootStorage(const css::uno::Reference< css::embed::XStorage >& xRoot);
     122                 :            : 
     123                 :            :         //---------------------------------------
     124                 :            :         /** @short  TODO
     125                 :            :          */
     126                 :            :         virtual css::uno::Reference< css::embed::XStorage > getRootStorage() const;
     127                 :            : 
     128                 :            :         //---------------------------------------
     129                 :            :         /** @short  TODO
     130                 :            :                     open or get!
     131                 :            :          */
     132                 :            :         virtual css::uno::Reference< css::embed::XStorage > openPath(const ::rtl::OUString& sPath    ,
     133                 :            :                                                                            sal_Int32        nOpenMode);
     134                 :            : 
     135                 :            :         //---------------------------------------
     136                 :            :         /** @short  TODO
     137                 :            :          */
     138                 :            :         virtual StorageHolder::TStorageList getAllPathStorages(const ::rtl::OUString& sPath);
     139                 :            : 
     140                 :            :         //---------------------------------------
     141                 :            :         /** @short  TODO
     142                 :            :          */
     143                 :            :         virtual void commitPath(const ::rtl::OUString& sPath);
     144                 :            : 
     145                 :            :         //---------------------------------------
     146                 :            :         /** @short  TODO
     147                 :            :          */
     148                 :            :         virtual void closePath(const ::rtl::OUString& sPath);
     149                 :            : 
     150                 :            :         //---------------------------------------
     151                 :            :         /** @short  TODO
     152                 :            :          */
     153                 :            :         virtual void notifyPath(const ::rtl::OUString& sPath);
     154                 :            : 
     155                 :            :         //---------------------------------------
     156                 :            :         /** @short  TODO
     157                 :            :          */
     158                 :            :         virtual void addStorageListener(      IStorageListener* pListener,
     159                 :            :                                         const ::rtl::OUString&  sPath    );
     160                 :            : 
     161                 :            :         //---------------------------------------
     162                 :            :         /** @short  TODO
     163                 :            :          */
     164                 :            :         virtual void removeStorageListener(      IStorageListener* pListener,
     165                 :            :                                            const ::rtl::OUString&  sPath    );
     166                 :            : 
     167                 :            :         //---------------------------------------
     168                 :            :         /** @short  TODO
     169                 :            :          */
     170                 :            :         virtual ::rtl::OUString getPathOfStorage(const css::uno::Reference< css::embed::XStorage >& xStorage);
     171                 :            : 
     172                 :            :         //---------------------------------------
     173                 :            :         /** @short  TODO
     174                 :            :          */
     175                 :            :         virtual css::uno::Reference< css::embed::XStorage > getParentStorage(const css::uno::Reference< css::embed::XStorage >& xChild);
     176                 :            : 
     177                 :            :         //---------------------------------------
     178                 :            :         /** @short  TODO
     179                 :            :          */
     180                 :            :         virtual css::uno::Reference< css::embed::XStorage > getParentStorage(const ::rtl::OUString& sChildPath);
     181                 :            : 
     182                 :            :         //---------------------------------------
     183                 :            :         /** @short  TODO
     184                 :            :          */
     185                 :            :         void operator=(const StorageHolder& rCopy);
     186                 :            : 
     187                 :            :         //---------------------------------------
     188                 :            :         /** @short  opens a sub element of the specified base storage.
     189                 :            : 
     190                 :            :             @descr  First this method try to open the requested sub element
     191                 :            :                     using the given open mode. If it failed there is second step,
     192                 :            :                     which tries to do the same again ... but removing a might existing
     193                 :            :                     WRITE flag from the open mode. The user can supress this fallback
     194                 :            :                     handling by setting the parameter bAllowFallback to sal_False.
     195                 :            : 
     196                 :            :             @param  xBaseStorage
     197                 :            :                     the storage, where the sub element should be searched.
     198                 :            : 
     199                 :            :             @param  sSubElement
     200                 :            :                     the full name of the sub element.
     201                 :            :                     e.g. "default.xml"
     202                 :            : 
     203                 :            :             @param  eOpenMode
     204                 :            :                     a flag field, which set the open mode for this operation.
     205                 :            : 
     206                 :            :             @param  bAllowFallback
     207                 :            :                     if eOpenMode contains an ELEMENT_WRITE flag this parameter
     208                 :            :                     allow to remove it and try it with the rest of eOpenMode flags
     209                 :            :                     again.
     210                 :            :          */
     211                 :            :         static css::uno::Reference< css::embed::XStorage > openSubStorageWithFallback(const css::uno::Reference< css::embed::XStorage >& xBaseStorage  ,
     212                 :            :                                                                                       const ::rtl::OUString&                             sSubStorage   ,
     213                 :            :                                                                                             sal_Int32                                    eOpenMode     ,
     214                 :            :                                                                                             sal_Bool                                     bAllowFallback);
     215                 :            : 
     216                 :            :         static css::uno::Reference< css::io::XStream > openSubStreamWithFallback(const css::uno::Reference< css::embed::XStorage >& xBaseStorage  ,
     217                 :            :                                                                                  const ::rtl::OUString&                             sSubStream    ,
     218                 :            :                                                                                        sal_Int32                                    eOpenMode     ,
     219                 :            :                                                                                        sal_Bool                                     bAllowFallback);
     220                 :            : 
     221                 :            :         //---------------------------------------
     222                 :            :         // helper
     223                 :            :         private:
     224                 :            : 
     225                 :            :             //-----------------------------------
     226                 :            :             /** @short  TODO
     227                 :            :              */
     228                 :            :             static ::rtl::OUString impl_st_normPath(const ::rtl::OUString& sPath);
     229                 :            : 
     230                 :            :             //-----------------------------------
     231                 :            :             /** @short  TODO
     232                 :            :              */
     233                 :            :             static OUStringList impl_st_parsePath(const ::rtl::OUString& sPath);
     234                 :            : };
     235                 :            : 
     236                 :            : } // namespace framework
     237                 :            : 
     238                 :            : #endif // __FRAMEWORK_ACCELERATORS_STORAGEHOLDER_HXX_
     239                 :            : 
     240                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10