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 : :
30 : : #include "svx/formatpaintbrushctrl.hxx"
31 : :
32 : : // header for class SfxBoolItem
33 : : #include <svl/eitem.hxx>
34 : :
35 : : // header for define SFX_APP
36 : : #include <sfx2/app.hxx>
37 : :
38 : : // header for class ToolBox
39 : : #include <vcl/toolbox.hxx>
40 : :
41 : : //.............................................................................
42 : : namespace svx
43 : : {
44 : : //.............................................................................
45 : :
46 : : using namespace ::com::sun::star::uno;
47 : : using namespace ::com::sun::star::beans;
48 : :
49 [ + - ]: 1258 : SFX_IMPL_TOOLBOX_CONTROL( FormatPaintBrushToolBoxControl, SfxBoolItem );
50 : :
51 : 1109 : FormatPaintBrushToolBoxControl::FormatPaintBrushToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
52 : : : SfxToolBoxControl( nSlotId, nId, rTbx )
53 : : , m_bPersistentCopy(false)
54 [ + - ]: 1109 : , m_aDoubleClickTimer()
55 : : {
56 : 1109 : sal_uIntPtr nDblClkTime = rTbx.GetSettings().GetMouseSettings().GetDoubleClickTime();
57 : :
58 [ + - ]: 1109 : m_aDoubleClickTimer.SetTimeoutHdl( LINK(this, FormatPaintBrushToolBoxControl, WaitDoubleClickHdl) );
59 [ + - ]: 1109 : m_aDoubleClickTimer.SetTimeout(nDblClkTime);
60 : 1109 : }
61 : :
62 : : // -----------------------------------------------------------------------
63 : :
64 [ + - ]: 1109 : FormatPaintBrushToolBoxControl::~FormatPaintBrushToolBoxControl()
65 : : {
66 [ + - ]: 1109 : m_aDoubleClickTimer.Stop();
67 [ - + ]: 2218 : }
68 : :
69 : : // -----------------------------------------------------------------------
70 : 0 : void FormatPaintBrushToolBoxControl::impl_executePaintBrush()
71 : : {
72 [ # # ]: 0 : Sequence< PropertyValue > aArgs( 1 );
73 [ # # ][ # # ]: 0 : aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PersistentCopy" ));
74 [ # # ][ # # ]: 0 : aArgs[0].Value = makeAny( static_cast<sal_Bool>(m_bPersistentCopy) );
75 : : Dispatch( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormatPaintbrush" ))
76 [ # # ][ # # ]: 0 : , aArgs );
[ # # ]
77 : 0 : }
78 : :
79 : : // -----------------------------------------------------------------------
80 : 0 : void FormatPaintBrushToolBoxControl::DoubleClick()
81 : : {
82 : 0 : m_aDoubleClickTimer.Stop();
83 : :
84 : 0 : m_bPersistentCopy = true;
85 : 0 : this->impl_executePaintBrush();
86 : 0 : }
87 : :
88 : : // -----------------------------------------------------------------------
89 : 0 : void FormatPaintBrushToolBoxControl::Click()
90 : : {
91 : 0 : m_bPersistentCopy = false;
92 : 0 : m_aDoubleClickTimer.Start();
93 : 0 : }
94 : :
95 : : // -----------------------------------------------------------------------
96 : 0 : IMPL_LINK_NOARG(FormatPaintBrushToolBoxControl, WaitDoubleClickHdl)
97 : : {
98 : : //there was no second click during waiting
99 : 0 : this->impl_executePaintBrush();
100 : 0 : return 0;
101 : : }
102 : :
103 : : // -----------------------------------------------------------------------
104 : 0 : void FormatPaintBrushToolBoxControl::Select( sal_Bool )
105 : : {
106 : 0 : }
107 : :
108 : : // -----------------------------------------------------------------------
109 : 1713 : void FormatPaintBrushToolBoxControl::StateChanged( sal_uInt16 nSID, SfxItemState eState,
110 : : const SfxPoolItem* pState )
111 : : {
112 [ + + ]: 1713 : if( ( eState & SFX_ITEM_SET ) == 0 )
113 : 231 : m_bPersistentCopy = false;
114 : 1713 : SfxToolBoxControl::StateChanged( nSID, eState, pState );
115 : 1713 : }
116 : :
117 : : //.............................................................................
118 : : } //namespace svx
119 : : //.............................................................................
120 : :
121 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|