LCOV - code coverage report
Current view: top level - sfx2/source/appl - appchild.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 41 50 82.0 %
Date: 2012-08-25 Functions: 4 5 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 26 46 56.5 %

           Branch data     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 "arrdecl.hxx"
      29                 :            : #include <sfx2/templdlg.hxx>
      30                 :            : #include <sfx2/request.hxx>
      31                 :            : #include <sfx2/bindings.hxx>
      32                 :            : #include <sfx2/dispatch.hxx>
      33                 :            : #include "sfxtypes.hxx"
      34                 :            : #include <sfx2/module.hxx>
      35                 :            : #include <sfx2/sfxsids.hrc>
      36                 :            : 
      37                 :            : //=========================================================================
      38                 :            : 
      39                 :            : 
      40                 :       7055 : void SfxApplication::RegisterChildWindow_Impl( SfxModule *pMod, SfxChildWinFactory *pFact )
      41                 :            : {
      42         [ +  + ]:       7055 :     if ( pMod )
      43                 :            :     {
      44                 :       3098 :         pMod->RegisterChildWindow( pFact );
      45                 :       7055 :         return;
      46                 :            :     }
      47                 :            : 
      48         [ +  + ]:       3957 :     if (!pAppData_Impl->pFactArr)
      49         [ +  - ]:        233 :         pAppData_Impl->pFactArr = new SfxChildWinFactArr_Impl;
      50                 :            : 
      51         [ +  + ]:      36330 :     for (sal_uInt16 nFactory=0; nFactory<pAppData_Impl->pFactArr->size(); ++nFactory)
      52                 :            :     {
      53         [ -  + ]:      32373 :         if (pFact->nId ==  (*pAppData_Impl->pFactArr)[nFactory]->nId)
      54                 :            :         {
      55 [ #  # ][ #  # ]:          0 :             pAppData_Impl->pFactArr->erase( pAppData_Impl->pFactArr->begin() + nFactory );
      56                 :            :         }
      57                 :            :     }
      58                 :            : 
      59                 :       3957 :     pAppData_Impl->pFactArr->push_back( pFact );
      60                 :            : }
      61                 :            : 
      62                 :        174 : void SfxApplication::RegisterChildWindowContext_Impl( SfxModule *pMod, sal_uInt16 nId,
      63                 :            :         SfxChildWinContextFactory *pFact)
      64                 :            : {
      65                 :            :     SfxChildWinFactArr_Impl *pFactories;
      66                 :        174 :     SfxChildWinFactory *pF = NULL;
      67         [ +  - ]:        174 :     if ( pMod )
      68                 :            :     {
      69                 :            :         // Abandon Module, search there for ChildwindowFactory
      70                 :        174 :         pFactories = pMod->GetChildWinFactories_Impl();
      71         [ +  - ]:        174 :         if ( pFactories )
      72                 :            :         {
      73                 :        174 :             sal_uInt16 nCount = pFactories->size();
      74         [ +  + ]:        862 :             for (sal_uInt16 nFactory=0; nFactory<nCount; ++nFactory)
      75                 :            :             {
      76                 :        688 :                 SfxChildWinFactory *pFac = (*pFactories)[nFactory];
      77         [ +  + ]:        688 :                 if ( nId == pFac->nId )
      78                 :            :                 {
      79                 :            :                     // Factory found, registrer Context here.
      80                 :         25 :                     pF = pFac;
      81                 :         25 :                     break;
      82                 :            :                 }
      83                 :            :             }
      84                 :            :         }
      85                 :            :     }
      86                 :            : 
      87         [ +  + ]:        174 :     if ( !pF )
      88                 :            :     {
      89                 :            :         // Search for Factory in the Application
      90                 :            :         DBG_ASSERT( pAppData_Impl, "No AppData!" );
      91                 :            :         DBG_ASSERT( pAppData_Impl->pFactArr, "No Factories!" );
      92                 :            : 
      93                 :        149 :         pFactories = pAppData_Impl->pFactArr;
      94                 :        149 :         sal_uInt16 nCount = pFactories->size();
      95         [ +  - ]:        447 :         for (sal_uInt16 nFactory=0; nFactory<nCount; ++nFactory)
      96                 :            :         {
      97                 :        298 :             SfxChildWinFactory *pFac = (*pFactories)[nFactory];
      98         [ +  + ]:        298 :             if ( nId == pFac->nId )
      99                 :            :             {
     100         [ +  - ]:        149 :                 if ( pMod )
     101                 :            :                 {
     102                 :            :                     // If the context of a module has been registered, then the
     103                 :            :                     // ChildWindowFactory must also be available there,
     104                 :            :                     // else the ContextFactory would have be unsubscribed on
     105                 :            :                     // DLL-exit
     106                 :            :                     pF = new SfxChildWinFactory( pFac->pCtor, pFac->nId,
     107         [ +  - ]:        149 :                             pFac->nPos );
     108                 :        149 :                     pMod->RegisterChildWindow( pF );
     109                 :            :                 }
     110                 :            :                 else
     111                 :          0 :                     pF = pFac;
     112                 :        149 :                 break;
     113                 :            :             }
     114                 :            :         }
     115                 :            :     }
     116                 :            : 
     117         [ +  - ]:        174 :     if ( pF )
     118                 :            :     {
     119         [ +  + ]:        174 :         if ( !pF->pArr )
     120         [ +  - ]:        149 :             pF->pArr = new SfxChildWinContextArr_Impl;
     121                 :        174 :         pF->pArr->push_back( pFact );
     122                 :        174 :         return;
     123                 :            :     }
     124                 :            : 
     125                 :            :     OSL_FAIL( "No ChildWindow for this Context!" );
     126                 :            : }
     127                 :            : 
     128                 :            : //--------------------------------------------------------------------
     129                 :            : 
     130                 :      56121 : SfxChildWinFactArr_Impl& SfxApplication::GetChildWinFactories_Impl() const
     131                 :            : {
     132                 :      56121 :     return ( *(pAppData_Impl->pFactArr));
     133                 :            : }
     134                 :            : 
     135                 :            : //--------------------------------------------------------------------
     136                 :            : 
     137                 :          0 : SfxTemplateDialog* SfxApplication::GetTemplateDialog()
     138                 :            : {
     139         [ #  # ]:          0 :     if ( pAppData_Impl->pViewFrame )
     140                 :            :     {
     141                 :          0 :         SfxChildWindow *pChild = pAppData_Impl->pViewFrame->GetChildWindow(SfxTemplateDialogWrapper::GetChildWindowId());
     142         [ #  # ]:          0 :         return pChild ? (SfxTemplateDialog*) pChild->GetWindow() : 0;
     143                 :            :     }
     144                 :            : 
     145                 :          0 :     return NULL;
     146                 :            : }
     147                 :            : 
     148                 :            : //--------------------------------------------------------------------
     149                 :            : 
     150                 :         43 : SfxWorkWindow* SfxApplication::GetWorkWindow_Impl(const SfxViewFrame *pFrame) const
     151                 :            : {
     152         [ +  - ]:         43 :     if ( pFrame )
     153                 :         43 :         return pFrame->GetFrame().GetWorkWindow_Impl();
     154         [ #  # ]:          0 :     else if ( pAppData_Impl->pViewFrame )
     155                 :          0 :         return pAppData_Impl->pViewFrame->GetFrame().GetWorkWindow_Impl();
     156                 :            :     else
     157                 :         43 :         return NULL;
     158                 :            : }
     159                 :            : 
     160                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10