LCOV - code coverage report
Current view: top level - sfx2/source/appl - appchild.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 41 46 89.1 %
Date: 2014-11-03 Functions: 6 6 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             : 
      21             : #include <svl/whiter.hxx>
      22             : #include <svl/eitem.hxx>
      23             : 
      24             : #include <sfx2/app.hxx>
      25             : #include "appdata.hxx"
      26             : #include "workwin.hxx"
      27             : #include <sfx2/childwin.hxx>
      28             : #include <sfx2/templdlg.hxx>
      29             : #include <sfx2/request.hxx>
      30             : #include <sfx2/bindings.hxx>
      31             : #include <sfx2/dispatch.hxx>
      32             : #include "sfxtypes.hxx"
      33             : #include <sfx2/module.hxx>
      34             : #include <sfx2/sfxsids.hrc>
      35             : 
      36             : 
      37             : 
      38             : 
      39       10216 : void SfxApplication::RegisterChildWindow_Impl( SfxModule *pMod, SfxChildWinFactory *pFact )
      40             : {
      41       10216 :     if ( pMod )
      42             :     {
      43        5052 :         pMod->RegisterChildWindow( pFact );
      44       15268 :         return;
      45             :     }
      46             : 
      47        5164 :     if (!pAppData_Impl->pFactArr)
      48         303 :         pAppData_Impl->pFactArr = new SfxChildWinFactArr_Impl;
      49             : 
      50       47717 :     for (sal_uInt16 nFactory=0; nFactory<pAppData_Impl->pFactArr->size(); ++nFactory)
      51             :     {
      52       42553 :         if (pFact->nId ==  (*pAppData_Impl->pFactArr)[nFactory].nId)
      53             :         {
      54           0 :             pAppData_Impl->pFactArr->erase( pAppData_Impl->pFactArr->begin() + nFactory );
      55             :         }
      56             :     }
      57             : 
      58        5164 :     pAppData_Impl->pFactArr->push_back( pFact );
      59             : }
      60             : 
      61         236 : void SfxApplication::RegisterChildWindowContext_Impl( SfxModule *pMod, sal_uInt16 nId,
      62             :         SfxChildWinContextFactory *pFact)
      63             : {
      64             :     SfxChildWinFactArr_Impl *pFactories;
      65         236 :     SfxChildWinFactory *pF = NULL;
      66         236 :     if ( pMod )
      67             :     {
      68             :         // Abandon Module, search there for ChildwindowFactory
      69         236 :         pFactories = pMod->GetChildWinFactories_Impl();
      70         236 :         if ( pFactories )
      71             :         {
      72         236 :             sal_uInt16 nCount = pFactories->size();
      73        1152 :             for (sal_uInt16 nFactory=0; nFactory<nCount; ++nFactory)
      74             :             {
      75         952 :                 SfxChildWinFactory *pFac = &(*pFactories)[nFactory];
      76         952 :                 if ( nId == pFac->nId )
      77             :                 {
      78             :                     // Factory found, registrer Context here.
      79          36 :                     pF = pFac;
      80          36 :                     break;
      81             :                 }
      82             :             }
      83             :         }
      84             :     }
      85             : 
      86         236 :     if ( !pF )
      87             :     {
      88             :         // Search for Factory in the Application
      89             :         DBG_ASSERT( pAppData_Impl, "No AppData!" );
      90             :         DBG_ASSERT( pAppData_Impl->pFactArr, "No Factories!" );
      91             : 
      92         200 :         pFactories = pAppData_Impl->pFactArr;
      93         200 :         sal_uInt16 nCount = pFactories->size();
      94         400 :         for (sal_uInt16 nFactory=0; nFactory<nCount; ++nFactory)
      95             :         {
      96         400 :             SfxChildWinFactory *pFac = &(*pFactories)[nFactory];
      97         400 :             if ( nId == pFac->nId )
      98             :             {
      99         200 :                 if ( pMod )
     100             :                 {
     101             :                     // If the context of a module has been registered, then the
     102             :                     // ChildWindowFactory must also be available there,
     103             :                     // else the ContextFactory would have be unsubscribed on
     104             :                     // DLL-exit
     105             :                     pF = new SfxChildWinFactory( pFac->pCtor, pFac->nId,
     106         200 :                             pFac->nPos );
     107         200 :                     pMod->RegisterChildWindow( pF );
     108             :                 }
     109             :                 else
     110           0 :                     pF = pFac;
     111         200 :                 break;
     112             :             }
     113             :         }
     114             :     }
     115             : 
     116         236 :     if ( pF )
     117             :     {
     118         236 :         if ( !pF->pArr )
     119         200 :             pF->pArr = new SfxChildWinContextArr_Impl;
     120         236 :         pF->pArr->push_back( pFact );
     121         236 :         return;
     122             :     }
     123             : 
     124             :     OSL_FAIL( "No ChildWindow for this Context!" );
     125             : }
     126             : 
     127             : 
     128             : 
     129      184507 : SfxChildWinFactArr_Impl& SfxApplication::GetChildWinFactories_Impl() const
     130             : {
     131      184507 :     return ( *(pAppData_Impl->pFactArr));
     132             : }
     133             : 
     134             : 
     135         638 : SfxWorkWindow* SfxApplication::GetWorkWindow_Impl(const SfxViewFrame *pFrame) const
     136             : {
     137         638 :     if ( pFrame )
     138         638 :         return pFrame->GetFrame().GetWorkWindow_Impl();
     139           0 :     else if ( pAppData_Impl->pViewFrame )
     140           0 :         return pAppData_Impl->pViewFrame->GetFrame().GetWorkWindow_Impl();
     141             :     else
     142           0 :         return NULL;
     143         951 : }
     144             : 
     145             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10