1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: formatpaintbrushctrl.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include "formatpaintbrushctrl.hxx"
36 // header for class SfxBoolItem
37 #include <svtools/eitem.hxx>
39 // header for define SFX_APP
40 #include <sfx2/app.hxx>
42 // header for class ToolBox
43 #include <vcl/toolbox.hxx>
45 //.............................................................................
48 //.............................................................................
50 using namespace ::com::sun::star::uno
;
51 using namespace ::com::sun::star::beans
;
53 SFX_IMPL_TOOLBOX_CONTROL( FormatPaintBrushToolBoxControl
, SfxBoolItem
);
55 FormatPaintBrushToolBoxControl::FormatPaintBrushToolBoxControl( USHORT nSlotId
, USHORT nId
, ToolBox
& rTbx
)
56 : SfxToolBoxControl( nSlotId
, nId
, rTbx
)
57 , m_bPersistentCopy(false)
58 , m_aDoubleClickTimer()
60 ULONG nDblClkTime
= rTbx
.GetSettings().GetMouseSettings().GetDoubleClickTime();
62 m_aDoubleClickTimer
.SetTimeoutHdl( LINK(this, FormatPaintBrushToolBoxControl
, WaitDoubleClickHdl
) );
63 m_aDoubleClickTimer
.SetTimeout(nDblClkTime
);
66 // -----------------------------------------------------------------------
68 FormatPaintBrushToolBoxControl::~FormatPaintBrushToolBoxControl()
70 m_aDoubleClickTimer
.Stop();
73 // -----------------------------------------------------------------------
74 void FormatPaintBrushToolBoxControl::impl_executePaintBrush()
76 Sequence
< PropertyValue
> aArgs( 1 );
77 aArgs
[0].Name
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PersistentCopy" ));
78 aArgs
[0].Value
= makeAny( static_cast<sal_Bool
>(m_bPersistentCopy
) );
79 Dispatch( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormatPaintbrush" ))
83 // -----------------------------------------------------------------------
84 void FormatPaintBrushToolBoxControl::DoubleClick()
86 m_aDoubleClickTimer
.Stop();
88 m_bPersistentCopy
= true;
89 this->impl_executePaintBrush();
92 // -----------------------------------------------------------------------
93 void FormatPaintBrushToolBoxControl::Click()
95 m_bPersistentCopy
= false;
96 m_aDoubleClickTimer
.Start();
99 // -----------------------------------------------------------------------
100 IMPL_LINK(FormatPaintBrushToolBoxControl
, WaitDoubleClickHdl
, void*, EMPTYARG
)
102 //there was no second click during waiting
103 this->impl_executePaintBrush();
107 // -----------------------------------------------------------------------
108 void FormatPaintBrushToolBoxControl::Select( BOOL
)
112 // -----------------------------------------------------------------------
113 void FormatPaintBrushToolBoxControl::StateChanged( USHORT nSID
, SfxItemState eState
,
114 const SfxPoolItem
* pState
)
116 if( ( eState
& SFX_ITEM_SET
) == 0 )
117 m_bPersistentCopy
= false;
118 SfxToolBoxControl::StateChanged( nSID
, eState
, pState
);
121 //.............................................................................
123 //.............................................................................