LibreOffice Module forms (master) 1
attributedispatcher.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
21
22#include <editeng/editview.hxx>
23#include <sal/log.hxx>
24#include <osl/diagnose.h>
25
26
27namespace frm
28{
29
30
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;
36
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 )
42 {
43 OSL_ENSURE( m_pMasterDispatcher, "OAttributeDispatcher::OAttributeDispatcher: invalid master dispatcher!" );
44 }
45
46
48 {
49 acquire();
50 dispose();
51 }
52
53
54 void OAttributeDispatcher::disposing( ::osl::ClearableMutexGuard& _rClearBeforeNotify )
55 {
56 m_pMasterDispatcher = nullptr;
57 ORichTextFeatureDispatcher::disposing( _rClearBeforeNotify );
58 }
59
60
61 void OAttributeDispatcher::fillFeatureEventFromAttributeState( FeatureStateEvent& _rEvent, const AttributeState& _rState ) const
62 {
63 if ( _rState.eSimpleState == eChecked )
64 _rEvent.State <<= true;
65 else if ( _rState.eSimpleState == eUnchecked )
66 _rEvent.State <<= false;
67 }
68
69
71 {
73 aEvent.IsEnabled = getEditView() && !getEditView()->IsReadOnly();
74
75 AttributeState aState;
78
80
81 return aEvent;
82 }
83
84
85 void SAL_CALL OAttributeDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArguments )
86 {
87 ::osl::MutexGuard aGuard( m_aMutex );
88
90
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 << ")");
95
98 }
99
100
102 {
103 OSL_ENSURE( _nAttributeId == m_nAttributeId, "OAttributeDispatcher::onAttributeStateChanged: wrong attribute!" );
104
105 FeatureStateEvent aEvent( buildStatusEvent() );
107 while ( aIter.hasMoreElements() )
108 doNotify( aIter.next(), aEvent );
109 }
110
111
112} // namespace frm
113
114
115/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
bool IsReadOnly() const
css::uno::Reference< ListenerT > const & next()
mutable::osl::Mutex m_aMutex
virtual void executeAttribute(AttributeId _nAttributeId, const SfxPoolItem *_pArgument)=0
virtual AttributeState getState(AttributeId _nAttributeId) const =0
virtual void onAttributeStateChanged(AttributeId _nAttributeId) override
virtual void fillFeatureEventFromAttributeState(css::frame::FeatureStateEvent &_rEvent, const AttributeState &_rState) const
OAttributeDispatcher(EditView &_rView, AttributeId _nAttributeId, const css::util::URL &_rURL, IMultiAttributeDispatcher *_pMasterDispatcher)
ctor
IMultiAttributeDispatcher * m_pMasterDispatcher
virtual css::frame::FeatureStateEvent buildStatusEvent() const override
virtual ~OAttributeDispatcher() override
virtual void SAL_CALL dispatch(const css::util::URL &URL, const css::uno::Sequence< css::beans::PropertyValue > &Arguments) override
virtual void disposing(::osl::ClearableMutexGuard &_rClearBeforeNotify) override
const css::util::URL & getFeatureURL() const
void dispose()
clean up resources associated with this instance
static void doNotify(const css::uno::Reference< css::frame::XStatusListener > &_rxListener, const css::frame::FeatureStateEvent &_rEvent)
virtual css::frame::FeatureStateEvent buildStatusEvent() const
::comphelper::OInterfaceContainerHelper3< css::frame::XStatusListener > & getStatusListeners()
virtual void disposing(::osl::ClearableMutexGuard &_rClearBeforeNotify)
#define SAL_WARN_IF(condition, area, stream)
ListBox is a bit confusing / different from other form components, so here are a few notes:
Definition: BaseListBox.hxx:25
@ eUnchecked
@ eChecked
sal_Int32 AttributeId
the id of an attribute
AttributeCheckState eSimpleState