LCOV - code coverage report
Current view: top level - svx/source/mnuctrls - clipboardctl.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 62 0.0 %
Date: 2014-04-14 Functions: 0 9 0.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             : #include <sfx2/app.hxx>
      21             : #include <sfx2/tbxctrl.hxx>
      22             : #include <sfx2/bindings.hxx>
      23             : #include <sfx2/dispatch.hxx>
      24             : #include <svl/intitem.hxx>
      25             : #include <sot/exchange.hxx>
      26             : #include <svl/eitem.hxx>
      27             : #include <vcl/toolbox.hxx>
      28             : #include <svx/clipboardctl.hxx>
      29             : #include <svx/clipfmtitem.hxx>
      30             : 
      31             : #include <svtools/insdlg.hxx>
      32             : #include <svx/svxids.hrc>
      33             : 
      34             : using namespace ::com::sun::star::uno;
      35             : using namespace ::com::sun::star::beans;
      36             : 
      37             : 
      38             : 
      39           0 : SFX_IMPL_TOOLBOX_CONTROL( SvxClipBoardControl, SfxVoidItem /*SfxUInt16Item*/ );
      40             : 
      41             : 
      42           0 : SvxClipBoardControl::SvxClipBoardControl(
      43             :         sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) :
      44             : 
      45             :     SfxToolBoxControl( nSlotId, nId, rTbx ),
      46             :     pClipboardFmtItem( 0 ),
      47             :     pPopup( 0 ),
      48           0 :     bDisabled( false )
      49             : {
      50           0 :     addStatusListener( OUString( ".uno:ClipboardFormatItems" ));
      51           0 :     ToolBox& rBox = GetToolBox();
      52           0 :     rBox.SetItemBits( nId, TIB_DROPDOWN | rBox.GetItemBits( nId ) );
      53           0 :     rBox.Invalidate();
      54           0 : }
      55             : 
      56             : 
      57           0 : SvxClipBoardControl::~SvxClipBoardControl()
      58             : {
      59           0 :     DelPopup();
      60           0 :     delete pClipboardFmtItem;
      61           0 : }
      62             : 
      63             : 
      64           0 : SfxPopupWindow* SvxClipBoardControl::CreatePopupWindow()
      65             : {
      66           0 :     const SvxClipboardFmtItem* pFmtItem = PTR_CAST( SvxClipboardFmtItem, pClipboardFmtItem );
      67           0 :     if ( pFmtItem )
      68             :     {
      69           0 :         if (pPopup)
      70           0 :             pPopup->Clear();
      71             :         else
      72           0 :             pPopup = new PopupMenu;
      73             : 
      74           0 :         sal_uInt16 nCount = pFmtItem->Count();
      75           0 :         for (sal_uInt16 i = 0;  i < nCount;  ++i)
      76             :         {
      77           0 :             sal_uIntPtr nFmtID =  pFmtItem->GetClipbrdFormatId( i );
      78           0 :             OUString aFmtStr( pFmtItem->GetClipbrdFormatName( i ) );
      79           0 :             if (aFmtStr.isEmpty())
      80           0 :               aFmtStr = SvPasteObjectHelper::GetSotFormatUIName( nFmtID );
      81           0 :             pPopup->InsertItem( (sal_uInt16)nFmtID, aFmtStr );
      82           0 :         }
      83             : 
      84           0 :         ToolBox& rBox = GetToolBox();
      85           0 :         sal_uInt16 nId = GetId();
      86           0 :         rBox.SetItemDown( nId, true );
      87             : 
      88           0 :         pPopup->Execute( &rBox, rBox.GetItemRect( nId ),
      89           0 :             (rBox.GetAlign() == WINDOWALIGN_TOP || rBox.GetAlign() == WINDOWALIGN_BOTTOM) ?
      90           0 :                 POPUPMENU_EXECUTE_DOWN : POPUPMENU_EXECUTE_RIGHT );
      91             : 
      92           0 :         rBox.SetItemDown( nId, false );
      93             : 
      94           0 :         SfxUInt32Item aItem( SID_CLIPBOARD_FORMAT_ITEMS, pPopup->GetCurItemId() );
      95             : 
      96           0 :         Any a;
      97           0 :         Sequence< PropertyValue > aArgs( 1 );
      98           0 :         aArgs[0].Name = "SelectedFormat";
      99           0 :         aItem.QueryValue( a );
     100           0 :         aArgs[0].Value = a;
     101             :         Dispatch( OUString( ".uno:ClipboardFormatItems" ),
     102           0 :                   aArgs );
     103             :     }
     104             : 
     105           0 :     GetToolBox().EndSelection();
     106           0 :     DelPopup();
     107           0 :     return 0;
     108             : }
     109             : 
     110             : 
     111           0 : SfxPopupWindowType SvxClipBoardControl::GetPopupWindowType() const
     112             : {
     113           0 :     return SFX_POPUPWINDOW_ONTIMEOUT;
     114             : }
     115             : 
     116             : 
     117           0 : void SvxClipBoardControl::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
     118             : {
     119           0 :     if ( SID_CLIPBOARD_FORMAT_ITEMS == nSID )
     120             :     {
     121           0 :         DELETEZ( pClipboardFmtItem );
     122           0 :         if ( eState >= SFX_ITEM_AVAILABLE )
     123             :         {
     124           0 :             pClipboardFmtItem = pState->Clone();
     125           0 :             GetToolBox().SetItemBits( GetId(), GetToolBox().GetItemBits( GetId() ) | TIB_DROPDOWN );
     126             :         }
     127           0 :         else if ( !bDisabled )
     128           0 :             GetToolBox().SetItemBits( GetId(), GetToolBox().GetItemBits( GetId() ) & ~TIB_DROPDOWN );
     129           0 :         GetToolBox().Invalidate( GetToolBox().GetItemRect( GetId() ) );
     130             :     }
     131             :     else
     132             :     {
     133             :         // enable the item as a whole
     134           0 :         bDisabled = (GetItemState(pState) == SFX_ITEM_DISABLED);
     135           0 :         GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SFX_ITEM_DISABLED) );
     136             :     }
     137           0 : }
     138             : 
     139             : 
     140           0 : void SvxClipBoardControl::DelPopup()
     141             : {
     142           0 :     if(pPopup)
     143             :     {
     144           0 :         delete pPopup;
     145           0 :         pPopup = 0;
     146             :     }
     147           0 : }
     148             : 
     149             : 
     150             : 
     151             : 
     152             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10