bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / tbxctrls / formatpaintbrushctrl.cxx
blob63eb13c4de405bc5e18d075e84c8c08c9a2beeb6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "svx/formatpaintbrushctrl.hxx"
23 // header for class SfxBoolItem
24 #include <svl/eitem.hxx>
26 // header for define SFX_APP
27 #include <sfx2/app.hxx>
29 // header for class ToolBox
30 #include <vcl/toolbox.hxx>
32 //.............................................................................
33 namespace svx
35 //.............................................................................
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::beans;
40 SFX_IMPL_TOOLBOX_CONTROL( FormatPaintBrushToolBoxControl, SfxBoolItem );
42 FormatPaintBrushToolBoxControl::FormatPaintBrushToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
43 : SfxToolBoxControl( nSlotId, nId, rTbx )
44 , m_bPersistentCopy(false)
45 , m_aDoubleClickTimer()
47 sal_uIntPtr nDblClkTime = rTbx.GetSettings().GetMouseSettings().GetDoubleClickTime();
49 m_aDoubleClickTimer.SetTimeoutHdl( LINK(this, FormatPaintBrushToolBoxControl, WaitDoubleClickHdl) );
50 m_aDoubleClickTimer.SetTimeout(nDblClkTime);
53 // -----------------------------------------------------------------------
55 FormatPaintBrushToolBoxControl::~FormatPaintBrushToolBoxControl()
57 m_aDoubleClickTimer.Stop();
60 // -----------------------------------------------------------------------
61 void FormatPaintBrushToolBoxControl::impl_executePaintBrush()
63 Sequence< PropertyValue > aArgs( 1 );
64 aArgs[0].Name = OUString( "PersistentCopy" );
65 aArgs[0].Value = makeAny( static_cast<sal_Bool>(m_bPersistentCopy) );
66 Dispatch( OUString( ".uno:FormatPaintbrush" )
67 , aArgs );
70 // -----------------------------------------------------------------------
71 void FormatPaintBrushToolBoxControl::DoubleClick()
73 m_aDoubleClickTimer.Stop();
75 m_bPersistentCopy = true;
76 this->impl_executePaintBrush();
79 // -----------------------------------------------------------------------
80 void FormatPaintBrushToolBoxControl::Click()
82 m_bPersistentCopy = false;
83 m_aDoubleClickTimer.Start();
86 // -----------------------------------------------------------------------
87 IMPL_LINK_NOARG(FormatPaintBrushToolBoxControl, WaitDoubleClickHdl)
89 //there was no second click during waiting
90 this->impl_executePaintBrush();
91 return 0;
94 // -----------------------------------------------------------------------
95 void FormatPaintBrushToolBoxControl::Select( sal_Bool )
99 // -----------------------------------------------------------------------
100 void FormatPaintBrushToolBoxControl::StateChanged( sal_uInt16 nSID, SfxItemState eState,
101 const SfxPoolItem* pState )
103 if( ( eState & SFX_ITEM_SET ) == 0 )
104 m_bPersistentCopy = false;
105 SfxToolBoxControl::StateChanged( nSID, eState, pState );
108 //.............................................................................
109 } //namespace svx
110 //.............................................................................
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */