LCOV - code coverage report
Current view: top level - ucb/source/ucp/tdoc - tdoc_docmgr.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 11 11 100.0 %
Date: 2014-11-03 Functions: 10 10 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_UCB_SOURCE_UCP_TDOC_TDOC_DOCMGR_HXX
      21             : #define INCLUDED_UCB_SOURCE_UCP_TDOC_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/XDocumentEventListener.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          96 :     class OfficeDocumentsEventListener
      39             :     {
      40             :     public:
      41             :         virtual void notifyDocumentOpened( const OUString & rDocId ) = 0;
      42             :         virtual void notifyDocumentClosed( const OUString & rDocId ) = 0;
      43             : 
      44             :     protected:
      45          92 :         ~OfficeDocumentsEventListener() {}
      46             :     };
      47             : 
      48             : 
      49             : 
      50        9122 :     struct StorageInfo
      51             :     {
      52             :         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        1418 :         StorageInfo() {}; // needed for STL map only.
      59             : 
      60        3853 :         StorageInfo(
      61             :             const 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        3853 :         : aTitle( rTitle ), xStorage( rxStorage ), xModel( rxModel ) {}
      67             :     };
      68             : 
      69             : 
      70             : 
      71             :     struct ltref
      72             :     {
      73        8684 :         bool operator()(
      74             :             const OUString & r1, const OUString & r2 ) const
      75             :         {
      76        8684 :             return r1 < r2;
      77             :         }
      78             :     };
      79             : 
      80             :     typedef std::map< OUString, StorageInfo, ltref > DocumentList;
      81             : 
      82             : 
      83             : 
      84             :     class OfficeDocumentsManager :
      85             :         public cppu::WeakImplHelper1< com::sun::star::document::XDocumentEventListener >
      86             :     {
      87         182 :         class OfficeDocumentsCloseListener :
      88             :            public cppu::WeakImplHelper1< com::sun::star::util::XCloseListener >
      89             : 
      90             :         {
      91             :         public:
      92          96 :             OfficeDocumentsCloseListener( OfficeDocumentsManager * pMgr )
      93          96 :             : 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, std::exception) SAL_OVERRIDE;
     101             : 
     102             :             virtual void SAL_CALL notifyClosing(
     103             :                     const ::com::sun::star::lang::EventObject& Source )
     104             :                 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     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, std::exception ) SAL_OVERRIDE;
     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::XDocumentEventListener
     124             :         virtual void SAL_CALL documentEventOccured(
     125             :                 const com::sun::star::document::DocumentEvent & Event )
     126             :             throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     127             : 
     128             :         // lang::XEventListener (base of document::XDocumentEventListener)
     129             :         virtual void SAL_CALL disposing(
     130             :                 const com::sun::star::lang::EventObject & Source )
     131             :             throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     132             : 
     133             :         // Non-interface
     134             :         com::sun::star::uno::Reference< com::sun::star::embed::XStorage >
     135             :         queryStorage( const OUString & rDocId );
     136             : 
     137             :         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 OUString & rDocId );
     144             : 
     145             :         com::sun::star::uno::Sequence< OUString >
     146             :         queryDocuments();
     147             : 
     148             :         OUString
     149             :         queryStorageTitle( const 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_UCB_SOURCE_UCP_TDOC_TDOC_DOCMGR_HXX
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10