1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 #include "svx/formatpaintbrushctrl.hxx" 32 33 // header for class SfxBoolItem 34 #include <svl/eitem.hxx> 35 36 // header for define SFX_APP 37 #include <sfx2/app.hxx> 38 39 // header for class ToolBox 40 #include <vcl/toolbox.hxx> 41 42 //............................................................................. 43 namespace svx 44 { 45 //............................................................................. 46 47 using namespace ::com::sun::star::uno; 48 using namespace ::com::sun::star::beans; 49 50 SFX_IMPL_TOOLBOX_CONTROL( FormatPaintBrushToolBoxControl, SfxBoolItem ); 51 52 FormatPaintBrushToolBoxControl::FormatPaintBrushToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) 53 : SfxToolBoxControl( nSlotId, nId, rTbx ) 54 , m_bPersistentCopy(false) 55 , m_aDoubleClickTimer() 56 { 57 sal_uIntPtr nDblClkTime = rTbx.GetSettings().GetMouseSettings().GetDoubleClickTime(); 58 59 m_aDoubleClickTimer.SetTimeoutHdl( LINK(this, FormatPaintBrushToolBoxControl, WaitDoubleClickHdl) ); 60 m_aDoubleClickTimer.SetTimeout(nDblClkTime); 61 } 62 63 // ----------------------------------------------------------------------- 64 65 FormatPaintBrushToolBoxControl::~FormatPaintBrushToolBoxControl() 66 { 67 m_aDoubleClickTimer.Stop(); 68 } 69 70 // ----------------------------------------------------------------------- 71 void FormatPaintBrushToolBoxControl::impl_executePaintBrush() 72 { 73 Sequence< PropertyValue > aArgs( 1 ); 74 aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PersistentCopy" )); 75 aArgs[0].Value = makeAny( static_cast<sal_Bool>(m_bPersistentCopy) ); 76 Dispatch( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormatPaintbrush" )) 77 , aArgs ); 78 } 79 80 // ----------------------------------------------------------------------- 81 void FormatPaintBrushToolBoxControl::DoubleClick() 82 { 83 m_aDoubleClickTimer.Stop(); 84 85 m_bPersistentCopy = true; 86 this->impl_executePaintBrush(); 87 } 88 89 // ----------------------------------------------------------------------- 90 void FormatPaintBrushToolBoxControl::Click() 91 { 92 m_bPersistentCopy = false; 93 m_aDoubleClickTimer.Start(); 94 } 95 96 // ----------------------------------------------------------------------- 97 IMPL_LINK(FormatPaintBrushToolBoxControl, WaitDoubleClickHdl, void*, EMPTYARG ) 98 { 99 //there was no second click during waiting 100 this->impl_executePaintBrush(); 101 return 0; 102 } 103 104 // ----------------------------------------------------------------------- 105 void FormatPaintBrushToolBoxControl::Select( sal_Bool ) 106 { 107 } 108 109 // ----------------------------------------------------------------------- 110 void FormatPaintBrushToolBoxControl::StateChanged( sal_uInt16 nSID, SfxItemState eState, 111 const SfxPoolItem* pState ) 112 { 113 if( ( eState & SFX_ITEM_SET ) == 0 ) 114 m_bPersistentCopy = false; 115 SfxToolBoxControl::StateChanged( nSID, eState, pState ); 116 } 117 118 //............................................................................. 119 } //namespace svx 120 //............................................................................. 121