nss: upgrade to release 3.73
[LibreOffice.git] / forms / source / richtext / attributedispatcher.cxx
blob0cabb526c75fb9ebb056bd4bd9cd682ac62f6dbd
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 .
20 #include "attributedispatcher.hxx"
22 #include <editeng/editview.hxx>
23 #include <sal/log.hxx>
24 #include <osl/diagnose.h>
27 namespace frm
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::frame;
33 using namespace ::com::sun::star::lang;
34 using namespace ::com::sun::star::util;
35 using namespace ::com::sun::star::beans;
37 OAttributeDispatcher::OAttributeDispatcher( EditView& _rView, AttributeId _nAttributeId, const URL& _rURL,
38 IMultiAttributeDispatcher* _pMasterDispatcher )
39 :ORichTextFeatureDispatcher( _rView, _rURL )
40 ,m_pMasterDispatcher( _pMasterDispatcher )
41 ,m_nAttributeId( _nAttributeId )
43 OSL_ENSURE( m_pMasterDispatcher, "OAttributeDispatcher::OAttributeDispatcher: invalid master dispatcher!" );
47 OAttributeDispatcher::~OAttributeDispatcher( )
49 acquire();
50 dispose();
54 void OAttributeDispatcher::disposing( ::osl::ClearableMutexGuard& _rClearBeforeNotify )
56 m_pMasterDispatcher = nullptr;
57 ORichTextFeatureDispatcher::disposing( _rClearBeforeNotify );
61 void OAttributeDispatcher::fillFeatureEventFromAttributeState( FeatureStateEvent& _rEvent, const AttributeState& _rState ) const
63 if ( _rState.eSimpleState == eChecked )
64 _rEvent.State <<= true;
65 else if ( _rState.eSimpleState == eUnchecked )
66 _rEvent.State <<= false;
70 FeatureStateEvent OAttributeDispatcher::buildStatusEvent() const
72 FeatureStateEvent aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
73 aEvent.IsEnabled = getEditView() && !getEditView()->IsReadOnly();
75 AttributeState aState;
76 if ( m_pMasterDispatcher )
77 aState = m_pMasterDispatcher->getState( m_nAttributeId );
79 fillFeatureEventFromAttributeState( aEvent, aState );
81 return aEvent;
85 void SAL_CALL OAttributeDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArguments )
87 ::osl::MutexGuard aGuard( m_aMutex );
89 checkDisposed();
91 OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OAttributeDispatcher::dispatch: invalid URL!" );
92 SAL_WARN_IF( _rArguments.hasElements(), "forms.richtext",
93 "OAttributeDispatcher::dispatch: found arguments, but can't handle arguments at all"
94 " (URL: " << _rURL.Complete << ")");
96 if ( m_pMasterDispatcher )
97 m_pMasterDispatcher->executeAttribute( m_nAttributeId, nullptr );
101 void OAttributeDispatcher::onAttributeStateChanged( AttributeId _nAttributeId )
103 OSL_ENSURE( _nAttributeId == m_nAttributeId, "OAttributeDispatcher::onAttributeStateChanged: wrong attribute!" );
105 FeatureStateEvent aEvent( buildStatusEvent() );
106 ::comphelper::OInterfaceIteratorHelper2 aIter( getStatusListeners() );
107 while ( aIter.hasMoreElements() )
108 doNotify( static_cast< XStatusListener* >( aIter.next() ), aEvent );
112 } // namespace frm
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */