LCOV - code coverage report
Current view: top level - svx/source/mnuctrls - fntctl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 43 2.3 %
Date: 2012-08-25 Functions: 1 11 9.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 68 0.0 %

           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 <string>
      22                 :            : #include <svtools/stdmenu.hxx>
      23                 :            : #include <sfx2/app.hxx>
      24                 :            : #include <sfx2/objsh.hxx>
      25                 :            : #include <sfx2/dispatch.hxx>
      26                 :            : 
      27                 :            : #include <svx/fntctl.hxx>
      28                 :            : #include <svx/svxids.hrc>
      29                 :            : #include "editeng/flstitem.hxx"
      30                 :            : #include "editeng/fontitem.hxx"
      31                 :            : 
      32                 :            : // STATIC DATA -----------------------------------------------------------
      33                 :            : 
      34         [ #  # ]:        149 : SFX_IMPL_MENU_CONTROL(SvxFontMenuControl, SvxFontItem);
      35                 :            : 
      36                 :            : //--------------------------------------------------------------------
      37                 :            : 
      38                 :            : /*  [Beschreibung]
      39                 :            : 
      40                 :            :     Ctor; setzt den Select-Handler am Men"u und tr"agt das Men"u
      41                 :            :     in seinen Parent ein.
      42                 :            : */
      43                 :            : 
      44                 :          0 : SvxFontMenuControl::SvxFontMenuControl
      45                 :            : (
      46                 :            :     sal_uInt16          _nId,
      47                 :            :     Menu&           rMenu,
      48                 :            :     SfxBindings&    rBindings
      49                 :            : ) :
      50         [ #  # ]:          0 :     pMenu   ( new FontNameMenu ),
      51 [ #  # ][ #  # ]:          0 :     rParent ( rMenu )
      52                 :            : {
      53         [ #  # ]:          0 :     rMenu.SetPopupMenu( _nId, pMenu );
      54         [ #  # ]:          0 :     pMenu->SetSelectHdl( LINK( this, SvxFontMenuControl, MenuSelect ) );
      55         [ #  # ]:          0 :     StartListening( rBindings );
      56         [ #  # ]:          0 :     FillMenu();
      57                 :          0 : }
      58                 :            : 
      59                 :            : //--------------------------------------------------------------------
      60                 :            : 
      61                 :            : /*  [Beschreibung]
      62                 :            : 
      63                 :            :     F"ullt das Men"u mit den aktuellen Fonts aus der Fontlist
      64                 :            :     der DocumentShell.
      65                 :            : */
      66                 :            : 
      67                 :          0 : void SvxFontMenuControl::FillMenu()
      68                 :            : {
      69                 :          0 :     SfxObjectShell *pDoc = SfxObjectShell::Current();
      70                 :            : 
      71         [ #  # ]:          0 :     if ( pDoc )
      72                 :            :     {
      73                 :            :         const SvxFontListItem* pFonts =
      74                 :          0 :             (const SvxFontListItem*)pDoc->GetItem( SID_ATTR_CHAR_FONTLIST );
      75         [ #  # ]:          0 :         const FontList* pList = pFonts ? pFonts->GetFontList(): 0;
      76                 :            :         DBG_ASSERT( pList, "Kein Fonts gefunden" );
      77                 :          0 :         pMenu->Fill( pList );
      78                 :            :     }
      79                 :          0 : }
      80                 :            : 
      81                 :            : //--------------------------------------------------------------------
      82                 :            : 
      83                 :            : /*  [Beschreibung]
      84                 :            : 
      85                 :            :     Statusbenachrichtigung;
      86                 :            :     f"ullt ggf. das Men"u mit den aktuellen Fonts aus der Fontlist
      87                 :            :     der DocumentShell.
      88                 :            :     Ist die Funktionalit"at disabled, wird der entsprechende
      89                 :            :     Men"ueintrag im Parentmen"u disabled, andernfalls wird er enabled.
      90                 :            :     Der aktuelle Font wird mit einer Checkmark versehen.
      91                 :            : */
      92                 :            : 
      93                 :          0 : void SvxFontMenuControl::StateChanged(
      94                 :            : 
      95                 :            :     sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )
      96                 :            : 
      97                 :            : {
      98                 :          0 :     rParent.EnableItem( GetId(), SFX_ITEM_DISABLED != eState );
      99                 :            : 
     100         [ #  # ]:          0 :     if ( SFX_ITEM_AVAILABLE == eState )
     101                 :            :     {
     102 [ #  # ][ #  # ]:          0 :         if ( !pMenu->GetItemCount() )
     103         [ #  # ]:          0 :             FillMenu();
     104 [ #  # ][ #  # ]:          0 :         const SvxFontItem* pFontItem = PTR_CAST( SvxFontItem, pState );
         [ #  # ][ #  # ]
     105         [ #  # ]:          0 :         String aFont;
     106                 :            : 
     107         [ #  # ]:          0 :         if ( pFontItem )
     108         [ #  # ]:          0 :             aFont = pFontItem->GetFamilyName();
     109 [ #  # ][ #  # ]:          0 :         pMenu->SetCurName( aFont );
     110                 :            :     }
     111                 :          0 : }
     112                 :            : 
     113                 :            : //--------------------------------------------------------------------
     114                 :            : 
     115                 :            : /*  [Beschreibung]
     116                 :            : 
     117                 :            :     Statusbenachrichtigung "uber Bindings;  bei DOCCHANGED
     118                 :            :     wird das Men"u mit den aktuellen Fonts aus der Fontlist
     119                 :            :     der DocumentShell gef"ullt.
     120                 :            : */
     121                 :            : 
     122                 :          0 : void SvxFontMenuControl::Notify( SfxBroadcaster&, const SfxHint& rHint )
     123                 :            : {
     124   [ #  #  #  # ]:          0 :     if ( rHint.Type() != TYPE(SfxSimpleHint) &&
                 [ #  # ]
     125                 :          0 :          ( (SfxSimpleHint&)rHint ).GetId() == SFX_HINT_DOCCHANGED )
     126                 :          0 :         FillMenu();
     127                 :          0 : }
     128                 :            : 
     129                 :            : //--------------------------------------------------------------------
     130                 :            : 
     131                 :            : /*  [Beschreibung]
     132                 :            : 
     133                 :            :     Select-Handler des Men"us; der Name des selektierten Fonts
     134                 :            :     wird in einem SvxFontItem verschickt. Das F"ullen mit den
     135                 :            :     weiteren Fontinformationen mu\s durch die Applikation geschehen.
     136                 :            : */
     137                 :            : 
     138                 :          0 : IMPL_LINK_INLINE_START( SvxFontMenuControl, MenuSelect, FontNameMenu *, pMen )
     139                 :            : {
     140         [ #  # ]:          0 :     SvxFontItem aItem( GetId() );
     141         [ #  # ]:          0 :     aItem.SetFamilyName(pMen->GetCurName());
     142         [ #  # ]:          0 :     GetBindings().GetDispatcher()->Execute( GetId(), SFX_CALLMODE_RECORD, &aItem, 0L );
     143         [ #  # ]:          0 :     return 0;
     144                 :            : }
     145                 :          0 : IMPL_LINK_INLINE_END( SvxFontMenuControl, MenuSelect, FontNameMenu *, pMen )
     146                 :            : 
     147                 :            : //--------------------------------------------------------------------
     148                 :            : 
     149                 :            : /*  [Beschreibung]
     150                 :            : 
     151                 :            :     Dtor; gibt das Men"u frei.
     152                 :            : */
     153                 :            : 
     154         [ #  # ]:          0 : SvxFontMenuControl::~SvxFontMenuControl()
     155                 :            : {
     156 [ #  # ][ #  # ]:          0 :     delete pMenu;
     157         [ #  # ]:          0 : }
     158                 :            : 
     159                 :            : //--------------------------------------------------------------------
     160                 :            : 
     161                 :            : /*  [Beschreibung]
     162                 :            : 
     163                 :            :     Gibt das Men"u zur"uck
     164                 :            : */
     165                 :            : 
     166                 :          0 : PopupMenu* SvxFontMenuControl::GetPopup() const
     167                 :            : {
     168                 :          0 :     return pMenu;
     169                 :            : }
     170                 :            : 
     171                 :            : 
     172                 :            : 
     173                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10