1*24acc546SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*24acc546SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*24acc546SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*24acc546SAndrew Rist * distributed with this work for additional information 6*24acc546SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*24acc546SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*24acc546SAndrew Rist * "License"); you may not use this file except in compliance 9*24acc546SAndrew Rist * with the License. You may obtain a copy of the License at 10*24acc546SAndrew Rist * 11*24acc546SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*24acc546SAndrew Rist * 13*24acc546SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*24acc546SAndrew Rist * software distributed under the License is distributed on an 15*24acc546SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*24acc546SAndrew Rist * KIND, either express or implied. See the License for the 17*24acc546SAndrew Rist * specific language governing permissions and limitations 18*24acc546SAndrew Rist * under the License. 19*24acc546SAndrew Rist * 20*24acc546SAndrew Rist *************************************************************/ 21*24acc546SAndrew Rist 22*24acc546SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_forms.hxx" 26cdf0e10cSrcweir #include "attributedispatcher.hxx" 27cdf0e10cSrcweir 28cdf0e10cSrcweir /** === begin UNO includes === **/ 29cdf0e10cSrcweir /** === end UNO includes === **/ 30cdf0e10cSrcweir #include <editeng/editview.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir //........................................................................ 33cdf0e10cSrcweir namespace frm 34cdf0e10cSrcweir { 35cdf0e10cSrcweir //........................................................................ 36cdf0e10cSrcweir 37cdf0e10cSrcweir using namespace ::com::sun::star::uno; 38cdf0e10cSrcweir using namespace ::com::sun::star::frame; 39cdf0e10cSrcweir using namespace ::com::sun::star::lang; 40cdf0e10cSrcweir using namespace ::com::sun::star::util; 41cdf0e10cSrcweir using namespace ::com::sun::star::beans; 42cdf0e10cSrcweir 43cdf0e10cSrcweir //==================================================================== 44cdf0e10cSrcweir //= OAttributeDispatcher 45cdf0e10cSrcweir //==================================================================== 46cdf0e10cSrcweir //-------------------------------------------------------------------- OAttributeDispatcher(EditView & _rView,AttributeId _nAttributeId,const URL & _rURL,IMultiAttributeDispatcher * _pMasterDispatcher)47cdf0e10cSrcweir OAttributeDispatcher::OAttributeDispatcher( EditView& _rView, AttributeId _nAttributeId, const URL& _rURL, 48cdf0e10cSrcweir IMultiAttributeDispatcher* _pMasterDispatcher ) 49cdf0e10cSrcweir :ORichTextFeatureDispatcher( _rView, _rURL ) 50cdf0e10cSrcweir ,m_pMasterDispatcher( _pMasterDispatcher ) 51cdf0e10cSrcweir ,m_nAttributeId( _nAttributeId ) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir OSL_ENSURE( m_pMasterDispatcher, "OAttributeDispatcher::OAttributeDispatcher: invalid master dispatcher!" ); 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir //-------------------------------------------------------------------- ~OAttributeDispatcher()57cdf0e10cSrcweir OAttributeDispatcher::~OAttributeDispatcher( ) 58cdf0e10cSrcweir { 59cdf0e10cSrcweir acquire(); 60cdf0e10cSrcweir dispose(); 61cdf0e10cSrcweir } 62cdf0e10cSrcweir 63cdf0e10cSrcweir //-------------------------------------------------------------------- disposing(::osl::ClearableMutexGuard & _rClearBeforeNotify)64cdf0e10cSrcweir void OAttributeDispatcher::disposing( ::osl::ClearableMutexGuard& _rClearBeforeNotify ) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir m_pMasterDispatcher = NULL; 67cdf0e10cSrcweir ORichTextFeatureDispatcher::disposing( _rClearBeforeNotify ); 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir //-------------------------------------------------------------------- fillFeatureEventFromAttributeState(FeatureStateEvent & _rEvent,const AttributeState & _rState) const71cdf0e10cSrcweir void OAttributeDispatcher::fillFeatureEventFromAttributeState( FeatureStateEvent& _rEvent, const AttributeState& _rState ) const 72cdf0e10cSrcweir { 73cdf0e10cSrcweir if ( _rState.eSimpleState == eChecked ) 74cdf0e10cSrcweir _rEvent.State <<= (sal_Bool)sal_True; 75cdf0e10cSrcweir else if ( _rState.eSimpleState == eUnchecked ) 76cdf0e10cSrcweir _rEvent.State <<= (sal_Bool)sal_False; 77cdf0e10cSrcweir } 78cdf0e10cSrcweir 79cdf0e10cSrcweir //-------------------------------------------------------------------- buildStatusEvent() const80cdf0e10cSrcweir FeatureStateEvent OAttributeDispatcher::buildStatusEvent() const 81cdf0e10cSrcweir { 82cdf0e10cSrcweir FeatureStateEvent aEvent( ORichTextFeatureDispatcher::buildStatusEvent() ); 83cdf0e10cSrcweir aEvent.IsEnabled = getEditView() ? !getEditView()->IsReadOnly() : sal_False; 84cdf0e10cSrcweir 85cdf0e10cSrcweir AttributeState aState; 86cdf0e10cSrcweir if ( m_pMasterDispatcher ) 87cdf0e10cSrcweir aState = m_pMasterDispatcher->getState( m_nAttributeId ); 88cdf0e10cSrcweir 89cdf0e10cSrcweir fillFeatureEventFromAttributeState( aEvent, aState ); 90cdf0e10cSrcweir 91cdf0e10cSrcweir return aEvent; 92cdf0e10cSrcweir } 93cdf0e10cSrcweir 94cdf0e10cSrcweir //-------------------------------------------------------------------- dispatch(const URL & _rURL,const Sequence<PropertyValue> & _rArguments)95cdf0e10cSrcweir void SAL_CALL OAttributeDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArguments ) throw (RuntimeException) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 98cdf0e10cSrcweir 99cdf0e10cSrcweir checkDisposed(); 100cdf0e10cSrcweir 101cdf0e10cSrcweir (void)_rURL; 102cdf0e10cSrcweir (void)_rArguments; 103cdf0e10cSrcweir 104cdf0e10cSrcweir OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OAttributeDispatcher::dispatch: invalid URL!" ); 105cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 106cdf0e10cSrcweir if ( _rArguments.getLength() ) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir ::rtl::OString sMessage( "OAttributeDispatcher::dispatch: found arguments, but can't handle arguments at all" ); 109cdf0e10cSrcweir sMessage += "\n (URL: "; 110cdf0e10cSrcweir sMessage += ::rtl::OString( _rURL.Complete.getStr(), _rURL.Complete.getLength(), RTL_TEXTENCODING_ASCII_US ); 111cdf0e10cSrcweir sMessage += ")"; 112cdf0e10cSrcweir DBG_ERROR( sMessage.getStr() ); 113cdf0e10cSrcweir } 114cdf0e10cSrcweir #endif 115cdf0e10cSrcweir 116cdf0e10cSrcweir if ( m_pMasterDispatcher ) 117cdf0e10cSrcweir m_pMasterDispatcher->executeAttribute( m_nAttributeId, NULL ); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir //-------------------------------------------------------------------- onAttributeStateChanged(AttributeId _nAttributeId,const AttributeState &)121cdf0e10cSrcweir void OAttributeDispatcher::onAttributeStateChanged( AttributeId _nAttributeId, const AttributeState& /*_rState*/ ) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir OSL_ENSURE( _nAttributeId == m_nAttributeId, "OAttributeDispatcher::onAttributeStateChanged: wrong attribute!" ); 124cdf0e10cSrcweir (void)_nAttributeId; 125cdf0e10cSrcweir 126cdf0e10cSrcweir FeatureStateEvent aEvent( buildStatusEvent() ); 127cdf0e10cSrcweir ::cppu::OInterfaceIteratorHelper aIter( getStatusListeners() ); 128cdf0e10cSrcweir while ( aIter.hasMoreElements() ) 129cdf0e10cSrcweir doNotify( static_cast< XStatusListener* >( aIter.next() ), aEvent ); 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132cdf0e10cSrcweir //........................................................................ 133cdf0e10cSrcweir } // namespace frm 134cdf0e10cSrcweir //........................................................................ 135