LCOV - code coverage report
Current view: top level - libreoffice/ucb/source/ucp/tdoc - tdoc_docmgr.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 11 11 100.0 %
Date: 2012-12-27 Functions: 11 11 100.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 INCLUDED_TDOC_DOCMGR_HXX
      21             : #define INCLUDED_TDOC_DOCMGR_HXX
      22             : 
      23             : #include <map>
      24             : 
      25             : #include "osl/mutex.hxx"
      26             : 
      27             : #include "cppuhelper/implbase1.hxx"
      28             : 
      29             : #include "com/sun/star/document/XEventListener.hpp"
      30             : #include "com/sun/star/embed/XStorage.hpp"
      31             : #include "com/sun/star/frame/XModel.hpp"
      32             : #include "com/sun/star/frame/XModuleManager2.hpp"
      33             : #include "com/sun/star/frame/XGlobalEventBroadcaster.hpp"
      34             : #include "com/sun/star/util/XCloseListener.hpp"
      35             : 
      36             : namespace tdoc_ucp {
      37             : 
      38           7 :     class OfficeDocumentsEventListener
      39             :     {
      40             :     public:
      41             :         virtual void notifyDocumentOpened( const rtl::OUString & rDocId ) = 0;
      42             :         virtual void notifyDocumentClosed( const rtl::OUString & rDocId ) = 0;
      43             : 
      44             :     protected:
      45           7 :         ~OfficeDocumentsEventListener() {}
      46             :     };
      47             : 
      48             :     //=======================================================================
      49             : 
      50         716 :     struct StorageInfo
      51             :     {
      52             :         rtl::OUString aTitle;
      53             :         com::sun::star::uno::Reference<
      54             :             com::sun::star::embed::XStorage > xStorage;
      55             :         com::sun::star::uno::Reference<
      56             :             com::sun::star::frame::XModel >   xModel;
      57             : 
      58          80 :         StorageInfo() {}; // needed for STL map only.
      59             : 
      60         158 :         StorageInfo(
      61             :             const rtl::OUString & rTitle,
      62             :             const com::sun::star::uno::Reference<
      63             :                 com::sun::star::embed::XStorage > & rxStorage,
      64             :             const com::sun::star::uno::Reference<
      65             :                 com::sun::star::frame::XModel > & rxModel )
      66         158 :         : aTitle( rTitle ), xStorage( rxStorage ), xModel( rxModel ) {}
      67             :     };
      68             : 
      69             :     //=======================================================================
      70             : 
      71             :     struct ltref
      72             :     {
      73         315 :         bool operator()(
      74             :             const rtl::OUString & r1, const rtl::OUString & r2 ) const
      75             :         {
      76         315 :             return r1 < r2;
      77             :         }
      78             :     };
      79             : 
      80             :     typedef std::map< rtl::OUString, StorageInfo, ltref > DocumentList;
      81             : 
      82             :     //=======================================================================
      83             : 
      84             :     class OfficeDocumentsManager :
      85             :         public cppu::WeakImplHelper1< com::sun::star::document::XEventListener >
      86             :     {
      87           6 :         class OfficeDocumentsCloseListener :
      88             :            public cppu::WeakImplHelper1< com::sun::star::util::XCloseListener >
      89             : 
      90             :         {
      91             :         public:
      92           7 :             OfficeDocumentsCloseListener( OfficeDocumentsManager * pMgr )
      93           7 :             : m_pManager( pMgr ) {};
      94             : 
      95             :             // util::XCloseListener
      96             :             virtual void SAL_CALL queryClosing(
      97             :                     const ::com::sun::star::lang::EventObject& Source,
      98             :                     ::sal_Bool GetsOwnership )
      99             :                 throw (::com::sun::star::util::CloseVetoException,
     100             :                        ::com::sun::star::uno::RuntimeException);
     101             : 
     102             :             virtual void SAL_CALL notifyClosing(
     103             :                     const ::com::sun::star::lang::EventObject& Source )
     104             :                 throw (::com::sun::star::uno::RuntimeException);
     105             : 
     106             :             // lang::XEventListener (base of util::XCloseListener)
     107             :             virtual void SAL_CALL disposing(
     108             :                     const com::sun::star::lang::EventObject & Source )
     109             :                 throw ( com::sun::star::uno::RuntimeException );
     110             :         private:
     111             :             OfficeDocumentsManager * m_pManager;
     112             :         };
     113             : 
     114             :     public:
     115             :         OfficeDocumentsManager(
     116             :             const com::sun::star::uno::Reference<
     117             :                 com::sun::star::uno::XComponentContext > & rxContext,
     118             :             OfficeDocumentsEventListener * pDocEventListener );
     119             :         virtual ~OfficeDocumentsManager();
     120             : 
     121             :         void destroy();
     122             : 
     123             :         // document::XEventListener
     124             :         virtual void SAL_CALL notifyEvent(
     125             :                 const com::sun::star::document::EventObject & Event )
     126             :             throw ( com::sun::star::uno::RuntimeException );
     127             : 
     128             :         // lang::XEventListener (base of document::XEventListener)
     129             :         virtual void SAL_CALL disposing(
     130             :                 const com::sun::star::lang::EventObject & Source )
     131             :             throw ( com::sun::star::uno::RuntimeException );
     132             : 
     133             :         // Non-interface
     134             :         com::sun::star::uno::Reference< com::sun::star::embed::XStorage >
     135             :         queryStorage( const rtl::OUString & rDocId );
     136             : 
     137             :         rtl::OUString
     138             :         queryDocumentId(
     139             :             const com::sun::star::uno::Reference<
     140             :                 com::sun::star::frame::XModel > & xModel );
     141             : 
     142             :         com::sun::star::uno::Reference< com::sun::star::frame::XModel >
     143             :         queryDocumentModel( const rtl::OUString & rDocId );
     144             : 
     145             :         com::sun::star::uno::Sequence< rtl::OUString >
     146             :         queryDocuments();
     147             : 
     148             :         rtl::OUString
     149             :         queryStorageTitle( const rtl::OUString & rDocId );
     150             : 
     151             :     private:
     152             :         void buildDocumentsList();
     153             : 
     154             :         bool
     155             :         isOfficeDocument(
     156             :             const com::sun::star::uno::Reference<
     157             :                 com::sun::star::uno::XInterface > & xDoc );
     158             : 
     159             :         bool
     160             :         isDocumentPreview(
     161             :             const com::sun::star::uno::Reference<
     162             :                 com::sun::star::frame::XModel > & xModel );
     163             : 
     164             :         bool
     165             :         isWithoutOrInTopLevelFrame(
     166             :             const com::sun::star::uno::Reference<
     167             :                 com::sun::star::frame::XModel > & xModel );
     168             : 
     169             :         bool
     170             :         isBasicIDE(
     171             :             const com::sun::star::uno::Reference<
     172             :                 com::sun::star::frame::XModel > & xModel );
     173             : 
     174             :         bool
     175             :         isHelpDocument(
     176             :             const com::sun::star::uno::Reference<
     177             :                 com::sun::star::frame::XModel > & xModel );
     178             : 
     179             :         osl::Mutex                                          m_aMtx;
     180             :         com::sun::star::uno::Reference<
     181             :             com::sun::star::uno::XComponentContext >        m_xContext;
     182             :         com::sun::star::uno::Reference<
     183             :             com::sun::star::frame::XGlobalEventBroadcaster > m_xDocEvtNotifier;
     184             :         com::sun::star::uno::Reference<
     185             :             com::sun::star::frame::XModuleManager2 >        m_xModuleMgr;
     186             :         DocumentList                                        m_aDocs;
     187             :         OfficeDocumentsEventListener *                      m_pDocEventListener;
     188             :         com::sun::star::uno::Reference<
     189             :             com::sun::star::util::XCloseListener >          m_xDocCloseListener;
     190             :     };
     191             : 
     192             : } // namespace tdoc_ucp
     193             : 
     194             : #endif /* !INCLUDED_TDOC_DOCMGR_HXX */
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10