bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / tbxctrls / formatpaintbrushctrl.cxx
blob410398432d8b088a06c0ce4ceaae970280f12608
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 #include <svl/eitem.hxx>
24 #include <sfx2/app.hxx>
25 #include <vcl/toolbox.hxx>
26 #include <vcl/settings.hxx>
29 namespace svx
33 using namespace ::com::sun::star::uno;
34 using namespace ::com::sun::star::beans;
36 SFX_IMPL_TOOLBOX_CONTROL( FormatPaintBrushToolBoxControl, SfxBoolItem );
38 FormatPaintBrushToolBoxControl::FormatPaintBrushToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
39 : SfxToolBoxControl( nSlotId, nId, rTbx )
40 , m_bPersistentCopy(false)
41 , m_aDoubleClickTimer()
43 sal_uInt64 nDblClkTime = rTbx.GetSettings().GetMouseSettings().GetDoubleClickTime();
45 m_aDoubleClickTimer.SetTimeoutHdl( LINK(this, FormatPaintBrushToolBoxControl, WaitDoubleClickHdl) );
46 m_aDoubleClickTimer.SetTimeout(nDblClkTime);
51 FormatPaintBrushToolBoxControl::~FormatPaintBrushToolBoxControl()
53 m_aDoubleClickTimer.Stop();
57 void FormatPaintBrushToolBoxControl::impl_executePaintBrush()
59 Sequence< PropertyValue > aArgs( 1 );
60 aArgs[0].Name = "PersistentCopy";
61 aArgs[0].Value = makeAny( m_bPersistentCopy );
62 Dispatch( OUString( ".uno:FormatPaintbrush" )
63 , aArgs );
67 void FormatPaintBrushToolBoxControl::DoubleClick()
69 m_aDoubleClickTimer.Stop();
71 m_bPersistentCopy = true;
72 this->impl_executePaintBrush();
76 void FormatPaintBrushToolBoxControl::Click()
78 m_bPersistentCopy = false;
79 m_aDoubleClickTimer.Start();
83 IMPL_LINK_NOARG_TYPED(FormatPaintBrushToolBoxControl, WaitDoubleClickHdl, Timer *, void)
85 //there was no second click during waiting
86 this->impl_executePaintBrush();
90 void FormatPaintBrushToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/)
95 void FormatPaintBrushToolBoxControl::StateChanged( sal_uInt16 nSID, SfxItemState eState,
96 const SfxPoolItem* pState )
98 if( eState != SfxItemState::DEFAULT && eState != SfxItemState::SET )
99 m_bPersistentCopy = false;
100 SfxToolBoxControl::StateChanged( nSID, eState, pState );
104 } //namespace svx
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */