LCOV - code coverage report
Current view: top level - sw/source/ui/ribbar - tbxanchr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 50 2.0 %
Date: 2012-08-25 Functions: 1 8 12.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 88 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <string>
      30                 :            : #include <vcl/timer.hxx>
      31                 :            : #include <sfx2/app.hxx>
      32                 :            : #include <svx/htmlmode.hxx>
      33                 :            : #include <svl/intitem.hxx>
      34                 :            : #include <sfx2/dispatch.hxx>
      35                 :            : #include <vcl/toolbox.hxx>
      36                 :            : #include <sfx2/mnumgr.hxx>
      37                 :            : 
      38                 :            : 
      39                 :            : #include "cmdid.h"
      40                 :            : #include "docsh.hxx"
      41                 :            : #include "swtypes.hxx"
      42                 :            : #include "swmodule.hxx"
      43                 :            : #include "wrtsh.hxx"
      44                 :            : #include "view.hxx"
      45                 :            : #include "viewopt.hxx"
      46                 :            : #include "ribbar.hrc"
      47                 :            : #include "tbxanchr.hxx"
      48                 :            : 
      49                 :            : 
      50                 :            : 
      51         [ #  # ]:         73 : SFX_IMPL_TOOLBOX_CONTROL(SwTbxAnchor, SfxUInt16Item);
      52                 :            : 
      53                 :          0 : SwTbxAnchor::SwTbxAnchor( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
      54                 :            :     SfxToolBoxControl( nSlotId, nId, rTbx ),
      55                 :          0 :     nActAnchorId(0)
      56                 :            : {
      57 [ #  # ][ #  # ]:          0 :     rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
      58                 :          0 : }
      59                 :            : 
      60                 :          0 :  SwTbxAnchor::~SwTbxAnchor()
      61                 :            : {
      62         [ #  # ]:          0 : }
      63                 :            : 
      64                 :          0 : void  SwTbxAnchor::StateChanged( sal_uInt16 /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
      65                 :            : {
      66                 :          0 :     GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SFX_ITEM_DISABLED) );
      67                 :            : 
      68         [ #  # ]:          0 :     if( eState == SFX_ITEM_AVAILABLE )
      69                 :            :     {
      70 [ #  # ][ #  # ]:          0 :         const SfxUInt16Item* pItem = PTR_CAST( SfxUInt16Item, pState );
      71         [ #  # ]:          0 :         if(pItem)
      72                 :          0 :             nActAnchorId = pItem->GetValue();
      73                 :            :     }
      74                 :            : 
      75                 :          0 : }
      76                 :            : 
      77                 :          0 : SfxPopupWindow* SwTbxAnchor::CreatePopupWindow()
      78                 :            : {
      79                 :          0 :     SwTbxAnchor::Click();
      80                 :          0 :     return 0;
      81                 :            : }
      82                 :            : 
      83                 :          0 : void  SwTbxAnchor::Click()
      84                 :            : {
      85         [ #  # ]:          0 :     PopupMenu aPopMenu(SW_RES(MN_ANCHOR_POPUP));
      86                 :            : 
      87                 :          0 :     SfxViewFrame*   pViewFrame( 0 );
      88                 :          0 :     SfxDispatcher*  pDispatch( 0 );
      89         [ #  # ]:          0 :     SfxViewShell*   pCurSh( SfxViewShell::Current() );
      90                 :            : 
      91         [ #  # ]:          0 :     if ( pCurSh )
      92                 :            :     {
      93                 :          0 :         pViewFrame = pCurSh->GetViewFrame();
      94         [ #  # ]:          0 :         if ( pViewFrame )
      95                 :          0 :             pDispatch = pViewFrame->GetDispatcher();
      96                 :            :     }
      97                 :            : 
      98                 :          0 :     SwView* pActiveView = 0;
      99         [ #  # ]:          0 :     if(pViewFrame)
     100                 :            :     {
     101         [ #  # ]:          0 :         const TypeId aTypeId = TYPE(SwView);
     102         [ #  # ]:          0 :         SwView* pView = (SwView*)SfxViewShell::GetFirst(&aTypeId);
     103         [ #  # ]:          0 :         while( pView )
     104                 :            :         {
     105         [ #  # ]:          0 :             if(pView->GetViewFrame() == pViewFrame)
     106                 :            :             {
     107                 :          0 :                 pActiveView = pView;
     108                 :          0 :                 break;
     109                 :            :             }
     110         [ #  # ]:          0 :             pView = (SwView*)SfxViewShell::GetNext(*pView, &aTypeId);
     111                 :            :         }
     112                 :            :     }
     113         [ #  # ]:          0 :     if(!pActiveView)
     114                 :            :     {
     115                 :            :         OSL_FAIL("No active view found");
     116                 :          0 :         return;
     117                 :            :     }
     118                 :          0 :     SwWrtShell* pWrtShell = pActiveView->GetWrtShellPtr();
     119 [ #  # ][ #  # ]:          0 :     aPopMenu.EnableItem( FN_TOOL_ANCHOR_FRAME, 0 != pWrtShell->IsFlyInFly() );
     120                 :            : 
     121 [ #  # ][ #  # ]:          0 :     Rectangle aRect(GetToolBox().GetItemRect(GetId()));
                 [ #  # ]
     122 [ #  # ][ #  # ]:          0 :     sal_uInt16 nHtmlMode = ::GetHtmlMode((SwDocShell*)SfxObjectShell::Current());
     123 [ #  # ][ #  # ]:          0 :     sal_Bool bHtmlModeNoAnchor = ( nHtmlMode & HTMLMODE_ON) && 0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS);
     124                 :            : 
     125 [ #  # ][ #  # ]:          0 :     if (bHtmlModeNoAnchor || pWrtShell->IsInHeaderFooter())
         [ #  # ][ #  # ]
     126 [ #  # ][ #  # ]:          0 :         aPopMenu.RemoveItem(aPopMenu.GetItemPos(FN_TOOL_ANCHOR_PAGE));
     127                 :            : 
     128         [ #  # ]:          0 :     if (nActAnchorId)
     129         [ #  # ]:          0 :         aPopMenu.CheckItem(nActAnchorId);
     130                 :            : 
     131                 :            : 
     132 [ #  # ][ #  # ]:          0 :     sal_uInt16 nSlotId = aPopMenu.Execute(&GetToolBox(), aRect);
     133 [ #  # ][ #  # ]:          0 :     GetToolBox().EndSelection();
     134                 :            : 
     135         [ #  # ]:          0 :     if (nSlotId)
     136 [ #  # ][ #  # ]:          0 :         pDispatch->Execute(nSlotId, SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD);
                 [ #  # ]
     137                 :            : }
     138                 :            : 
     139                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10