LCOV - code coverage report
Current view: top level - svx/source/tbxctrls - formatpaintbrushctrl.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 16 36 44.4 %
Date: 2014-11-03 Functions: 8 14 57.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      21             : #include "svx/formatpaintbrushctrl.hxx"
      22             : 
      23             : #include <svl/eitem.hxx>
      24             : #include <sfx2/app.hxx>
      25             : #include <vcl/toolbox.hxx>
      26             : #include <vcl/settings.hxx>
      27             : 
      28             : 
      29             : namespace svx
      30             : {
      31             : 
      32             : 
      33             : using namespace ::com::sun::star::uno;
      34             : using namespace ::com::sun::star::beans;
      35             : 
      36        1630 : SFX_IMPL_TOOLBOX_CONTROL( FormatPaintBrushToolBoxControl, SfxBoolItem );
      37             : 
      38        1430 : FormatPaintBrushToolBoxControl::FormatPaintBrushToolBoxControl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx )
      39             :     : SfxToolBoxControl( nSlotId, nId, rTbx )
      40             :     , m_bPersistentCopy(false)
      41        1430 :     , m_aDoubleClickTimer()
      42             : {
      43        1430 :     sal_uIntPtr nDblClkTime = rTbx.GetSettings().GetMouseSettings().GetDoubleClickTime();
      44             : 
      45        1430 :     m_aDoubleClickTimer.SetTimeoutHdl( LINK(this, FormatPaintBrushToolBoxControl, WaitDoubleClickHdl) );
      46        1430 :     m_aDoubleClickTimer.SetTimeout(nDblClkTime);
      47        1430 : }
      48             : 
      49             : 
      50             : 
      51        4290 : FormatPaintBrushToolBoxControl::~FormatPaintBrushToolBoxControl()
      52             : {
      53        1430 :     m_aDoubleClickTimer.Stop();
      54        2860 : }
      55             : 
      56             : 
      57           0 : void FormatPaintBrushToolBoxControl::impl_executePaintBrush()
      58             : {
      59           0 :     Sequence< PropertyValue > aArgs( 1 );
      60           0 :     aArgs[0].Name  = "PersistentCopy";
      61           0 :     aArgs[0].Value = makeAny( m_bPersistentCopy );
      62             :     Dispatch( OUString( ".uno:FormatPaintbrush" )
      63           0 :         , aArgs );
      64           0 : }
      65             : 
      66             : 
      67           0 : void FormatPaintBrushToolBoxControl::DoubleClick()
      68             : {
      69           0 :     m_aDoubleClickTimer.Stop();
      70             : 
      71           0 :     m_bPersistentCopy = true;
      72           0 :     this->impl_executePaintBrush();
      73           0 : }
      74             : 
      75             : 
      76           0 : void FormatPaintBrushToolBoxControl::Click()
      77             : {
      78           0 :     m_bPersistentCopy = false;
      79           0 :     m_aDoubleClickTimer.Start();
      80           0 : }
      81             : 
      82             : 
      83           0 : IMPL_LINK_NOARG(FormatPaintBrushToolBoxControl, WaitDoubleClickHdl)
      84             : {
      85             :     //there was no second click during waiting
      86           0 :     this->impl_executePaintBrush();
      87           0 :     return 0;
      88             : }
      89             : 
      90             : 
      91           0 : void FormatPaintBrushToolBoxControl::Select(sal_uInt16 /*nSelectModifier*/)
      92             : {
      93           0 : }
      94             : 
      95             : 
      96        1290 : void FormatPaintBrushToolBoxControl::StateChanged( sal_uInt16 nSID, SfxItemState eState,
      97             :                 const SfxPoolItem* pState )
      98             : {
      99        1290 :     if( eState != SfxItemState::DEFAULT && eState != SfxItemState::SET )
     100         150 :         m_bPersistentCopy = false;
     101        1290 :     SfxToolBoxControl::StateChanged( nSID, eState, pState );
     102        1290 : }
     103             : 
     104             : 
     105         594 : } //namespace svx
     106             : 
     107             : 
     108             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10