LCOV - code coverage report
Current view: top level - sw/source/ui/utlui - tmplctrl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 53 22.6 %
Date: 2012-08-25 Functions: 6 13 46.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 86 9.3 %

           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/style.hxx>
      22                 :            : #include <vcl/menu.hxx>
      23                 :            : #include <svl/stritem.hxx>
      24                 :            : #include <sfx2/dispatch.hxx>
      25                 :            : #include <vcl/status.hxx>
      26                 :            : 
      27                 :            : #include "wrtsh.hxx"
      28                 :            : #include "view.hxx"
      29                 :            : #include "swmodule.hxx"
      30                 :            : #include "cmdid.h"
      31                 :            : #include "docsh.hxx"
      32                 :            : #include "tmplctrl.hxx"
      33                 :            : 
      34                 :            : 
      35                 :            : // STATIC DATA -----------------------------------------------------------
      36                 :            : 
      37         [ +  - ]:        837 : SFX_IMPL_STATUSBAR_CONTROL( SwTemplateControl, SfxStringItem );
      38                 :            : 
      39                 :            : // class TemplatePopup_Impl --------------------------------------------------
      40                 :            : 
      41         [ #  # ]:          0 : class TemplatePopup_Impl : public PopupMenu
      42                 :            : {
      43                 :            : public:
      44                 :            :     TemplatePopup_Impl();
      45                 :            : 
      46                 :          0 :     sal_uInt16          GetCurId() const { return nCurId; }
      47                 :            : 
      48                 :            : private:
      49                 :            :     sal_uInt16          nCurId;
      50                 :            : 
      51                 :            :     virtual void    Select();
      52                 :            : };
      53                 :            : 
      54                 :          0 : TemplatePopup_Impl::TemplatePopup_Impl() :
      55                 :            :     PopupMenu(),
      56                 :          0 :     nCurId(USHRT_MAX)
      57                 :            : {
      58                 :          0 : }
      59                 :            : 
      60                 :          0 : void TemplatePopup_Impl::Select()
      61                 :            : {
      62                 :          0 :     nCurId = GetCurItemId();
      63                 :          0 : }
      64                 :            : 
      65                 :            : // class SvxZoomStatusBarControl ------------------------------------------
      66                 :            : 
      67                 :        764 : SwTemplateControl::SwTemplateControl( sal_uInt16 _nSlotId,
      68                 :            :                                       sal_uInt16 _nId,
      69                 :            :                                       StatusBar& rStb ) :
      70         [ +  - ]:        764 :     SfxStatusBarControl( _nSlotId, _nId, rStb )
      71                 :            : {
      72                 :        764 : }
      73                 :            : 
      74         [ +  - ]:        764 : SwTemplateControl::~SwTemplateControl()
      75                 :            : {
      76         [ -  + ]:       1528 : }
      77                 :            : 
      78                 :       1242 : void SwTemplateControl::StateChanged(
      79                 :            :     sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
      80                 :            : {
      81 [ +  - ][ -  + ]:       1242 :     if( eState != SFX_ITEM_AVAILABLE || pState->ISA( SfxVoidItem ) )
                 [ -  + ]
      82         [ #  # ]:          0 :         GetStatusBar().SetItemText( GetId(), String() );
      83         [ +  - ]:       1242 :     else if ( pState->ISA( SfxStringItem ) )
      84                 :            :     {
      85                 :       1242 :         sTemplate = ((SfxStringItem*)pState)->GetValue();
      86                 :       1242 :         GetStatusBar().SetItemText( GetId(), sTemplate );
      87                 :            :     }
      88                 :       1242 : }
      89                 :            : 
      90                 :          0 : void SwTemplateControl::Paint( const UserDrawEvent&  )
      91                 :            : {
      92                 :          0 :     GetStatusBar().SetItemText( GetId(), sTemplate );
      93                 :          0 : }
      94                 :            : 
      95                 :          0 : void SwTemplateControl::Command( const CommandEvent& rCEvt )
      96                 :            : {
      97   [ #  #  #  # ]:          0 :     if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU &&
                 [ #  # ]
      98                 :          0 :             GetStatusBar().GetItemText( GetId() ).Len() )
      99                 :            :     {
     100         [ #  # ]:          0 :         CaptureMouse();
     101         [ #  # ]:          0 :         TemplatePopup_Impl aPop;
     102                 :            :         {
     103         [ #  # ]:          0 :             SwView* pView = ::GetActiveView();
     104                 :            :             SwWrtShell* pWrtShell;
     105 [ #  # ][ #  # ]:          0 :             if( pView && 0 != (pWrtShell = pView->GetWrtShellPtr()) &&
           [ #  #  #  # ]
         [ #  # ][ #  # ]
     106         [ #  # ]:          0 :                 !pWrtShell->SwCrsrShell::HasSelection()&&
     107                 :          0 :                 !pWrtShell->IsSelFrmMode() &&
     108         [ #  # ]:          0 :                 !pWrtShell->IsObjSelected())
     109                 :            :             {
     110         [ #  # ]:          0 :                 SfxStyleSheetBasePool* pPool = pView->GetDocShell()->
     111         [ #  # ]:          0 :                                                             GetStyleSheetPool();
     112         [ #  # ]:          0 :                 pPool->SetSearchMask(SFX_STYLE_FAMILY_PAGE, SFXSTYLEBIT_ALL);
     113 [ #  # ][ #  # ]:          0 :                 if( pPool->Count() > 1 )
     114                 :            :                 {
     115                 :          0 :                     sal_uInt16 nCount = 0;
     116         [ #  # ]:          0 :                     SfxStyleSheetBase* pStyle = pPool->First();
     117         [ #  # ]:          0 :                     while( pStyle )
     118                 :            :                     {
     119                 :          0 :                         nCount++;
     120 [ #  # ][ #  # ]:          0 :                         aPop.InsertItem( nCount, pStyle->GetName() );
     121         [ #  # ]:          0 :                         pStyle = pPool->Next();
     122                 :            :                     }
     123                 :            : 
     124         [ #  # ]:          0 :                     aPop.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel());
     125                 :          0 :                     sal_uInt16 nCurrId = aPop.GetCurId();
     126         [ #  # ]:          0 :                     if( nCurrId != USHRT_MAX)
     127                 :            :                     {
     128                 :            :                         // sieht etwas umstaendlich aus, anders geht's aber nicht
     129         [ #  # ]:          0 :                         pStyle = pPool->operator[]( nCurrId - 1 );
     130 [ #  # ][ #  # ]:          0 :                         SfxStringItem aStyle( FN_SET_PAGE_STYLE, pStyle->GetName() );
     131                 :          0 :                         pWrtShell->GetView().GetViewFrame()->GetDispatcher()->Execute(
     132                 :            :                                     FN_SET_PAGE_STYLE,
     133                 :            :                                     SFX_CALLMODE_SLOT|SFX_CALLMODE_RECORD,
     134 [ #  # ][ #  # ]:          0 :                                     &aStyle, 0L );
     135                 :            :                     }
     136                 :            :                 }
     137                 :            :             }
     138                 :            :         }
     139 [ #  # ][ #  # ]:          0 :         ReleaseMouse();
     140                 :            :     }
     141                 :          0 : }
     142                 :            : 
     143                 :            : 
     144                 :            : 
     145                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10