LibreOffice Module svx (master)  1
fmtextcontrolfeature.cxx
Go to the documentation of this file.
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 #include <fmtextcontrolfeature.hxx>
21 #include <fmtextcontrolshell.hxx>
22 
23 #include <osl/diagnose.h>
24 #include <tools/diagnose_ex.h>
25 
26 namespace svx
27 {
28 
29 
30  using namespace ::com::sun::star::uno;
31  using namespace ::com::sun::star::frame;
32  using namespace ::com::sun::star::lang;
33  using namespace ::com::sun::star::beans;
34  using namespace ::com::sun::star::util;
35 
36  FmTextControlFeature::FmTextControlFeature( const Reference< XDispatch >& _rxDispatcher, const URL& _rFeatureURL, SfxSlotId _nSlotId, FmTextControlShell* _pInvalidator )
37  :m_xDispatcher ( _rxDispatcher )
38  ,m_aFeatureURL ( _rFeatureURL )
39  ,m_nSlotId ( _nSlotId )
40  ,m_pInvalidator ( _pInvalidator )
41  ,m_bFeatureEnabled( false )
42  {
43  OSL_ENSURE( _rxDispatcher.is(), "FmTextControlFeature::FmTextControlFeature: invalid dispatcher!" );
44  OSL_ENSURE( m_nSlotId, "FmTextControlFeature::FmTextControlFeature: invalid slot id!" );
45  OSL_ENSURE( m_pInvalidator, "FmTextControlFeature::FmTextControlFeature: invalid invalidator!" );
46 
47  osl_atomic_increment( &m_refCount );
48  try
49  {
50  m_xDispatcher->addStatusListener( this, m_aFeatureURL );
51  }
52  catch( const Exception& )
53  {
54  TOOLS_WARN_EXCEPTION( "svx", "FmTextControlFeature::FmTextControlFeature" );
55  }
56  osl_atomic_decrement( &m_refCount );
57  }
58 
59 
61  {
62  }
63 
64 
66  {
67  dispatch( Sequence< PropertyValue >( ) );
68  }
69 
70 
71  void FmTextControlFeature::dispatch( const Sequence< PropertyValue >& _rArgs ) const
72  {
73  try
74  {
75  if ( m_xDispatcher.is() )
76  m_xDispatcher->dispatch( m_aFeatureURL, _rArgs );
77  }
78  catch( const Exception& )
79  {
80  TOOLS_WARN_EXCEPTION( "svx", "FmTextControlFeature::dispatch" );
81  }
82  }
83 
84 
85  void SAL_CALL FmTextControlFeature::statusChanged( const FeatureStateEvent& _rState )
86  {
87  m_aFeatureState = _rState.State;
88  m_bFeatureEnabled = _rState.IsEnabled;
89 
90  if ( m_pInvalidator )
92  }
93 
94 
95  void SAL_CALL FmTextControlFeature::disposing( const EventObject& /*Source*/ )
96  {
97  // nothing to do
98  }
99 
100 
102  {
103  try
104  {
105  m_xDispatcher->removeStatusListener( this, m_aFeatureURL );
106  m_xDispatcher.clear();
107  }
108  catch( const Exception& )
109  {
110  TOOLS_WARN_EXCEPTION( "svx", "FmTextControlFeature::dispose" );
111  }
112  }
113 
114 
115 }
116 
117 
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ULONG m_refCount
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
sal_uInt16 SfxSlotId
virtual ~FmTextControlFeature() override
FmTextControlShell * m_pInvalidator
void dispatch() const
dispatches the feature URL to the dispatcher
#define TOOLS_WARN_EXCEPTION(area, stream)
FmTextControlFeature(const css::uno::Reference< css::frame::XDispatch > &_rxDispatcher, const css::util::URL &_rFeatureURL, SfxSlotId _nId, FmTextControlShell *_pInvalidator)
constructs a FmTextControlFeature object
void dispose()
releases any resources associated with this instance
virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &State) override
css::uno::Reference< css::frame::XDispatch > m_xDispatcher
void Invalidate(SfxSlotId _nSlot)