LibreOffice Module forms (master) 1
specialdispatchers.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#include <editeng/editeng.hxx>
22#include <editeng/editids.hrc>
23#include <editeng/editview.hxx>
25#include <osl/diagnose.h>
26
27
28namespace frm
29{
30
31
32 using namespace ::com::sun::star::uno;
33 using namespace ::com::sun::star::lang;
34 using namespace ::com::sun::star::util;
35 using namespace ::com::sun::star::frame;
36 using namespace ::com::sun::star::beans;
37
39 :ORichTextFeatureDispatcher( _rView, _rURL )
40 {
41 }
42
43
45 {
46 if ( !isDisposed() )
47 {
48 acquire();
49 dispose();
50 }
51 }
52
53
54 void SAL_CALL OSelectAllDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& /*_rArguments*/ )
55 {
56 ::osl::MutexGuard aGuard( m_aMutex );
57 OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OSelectAllDispatcher::dispatch: invalid URL!" );
58
60
61 EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : nullptr;
62 OSL_ENSURE( pEngine, "OSelectAllDispatcher::dispatch: no edit engine - but not yet disposed?" );
63 if ( !pEngine )
64 return;
65
66 sal_Int32 nParagraphs = pEngine->GetParagraphCount();
67 if ( nParagraphs )
68 {
69 sal_Int32 nLastParaNumber = nParagraphs - 1;
70 sal_Int32 nParaLen = pEngine->GetTextLen( nLastParaNumber );
71 getEditView()->SetSelection( ESelection( 0, 0, nLastParaNumber, nParaLen ) );
72 }
73 }
74
75
77 {
79 aEvent.IsEnabled = true;
80 return aEvent;
81 }
82
84 IMultiAttributeDispatcher* _pMasterDispatcher )
85 :OAttributeDispatcher( _rView, _nAttributeId, _rURL, _pMasterDispatcher )
86 {
87 }
88
89
91 {
93
94 EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : nullptr;
95 OSL_ENSURE( pEngine, "OParagraphDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
96 if ( pEngine && pEngine->IsEffectivelyVertical() )
97 aEvent.IsEnabled = false;
98
99 return aEvent;
100 }
101
103 :ORichTextFeatureDispatcher( _rView, _rURL )
104 {
105 }
106
107
108 void SAL_CALL OTextDirectionDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& /*_rArguments*/ )
109 {
110 ::osl::MutexGuard aGuard( m_aMutex );
111 OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OTextDirectionDispatcher::dispatch: invalid URL!" );
112
114
115 EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : nullptr;
116 OSL_ENSURE( pEngine, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
117 if ( !pEngine )
118 return;
119
120 pEngine->SetVertical( !pEngine->IsEffectivelyVertical() );
121 }
122
123
125 {
127
128 EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : nullptr;
129 OSL_ENSURE( pEngine, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
130
131 aEvent.IsEnabled = true;
132 aEvent.State <<= pEngine && pEngine->IsEffectivelyVertical();
133
134 return aEvent;
135 }
136
137 OAsianFontLayoutDispatcher::OAsianFontLayoutDispatcher( EditView& _rView, AttributeId _nAttributeId, const URL& _rURL, IMultiAttributeDispatcher* _pMasterDispatcher )
138 :OParametrizedAttributeDispatcher( _rView, _nAttributeId, _rURL, _pMasterDispatcher )
139 {
140 }
141
142
143 const SfxPoolItem* OAsianFontLayoutDispatcher::convertDispatchArgsToItem( const Sequence< PropertyValue >& _rArguments )
144 {
145 // look for the "Enable" parameter
146 const PropertyValue* pLookup = _rArguments.getConstArray();
147 const PropertyValue* pLookupEnd = _rArguments.getConstArray() + _rArguments.getLength();
148 while ( pLookup != pLookupEnd )
149 {
150 if ( pLookup->Name == "Enable" )
151 break;
152 ++pLookup;
153 }
154 if ( pLookup != pLookupEnd )
155 {
156 bool bEnable = true;
157 OSL_VERIFY( pLookup->Value >>= bEnable );
158 if ( m_nAttributeId == sal_uInt16(SID_ATTR_PARA_SCRIPTSPACE) )
159 return new SvxScriptSpaceItem( bEnable, static_cast<WhichId>(m_nAttributeId) );
160 return new SfxBoolItem( static_cast<WhichId>(m_nAttributeId), bEnable );
161 }
162
163 OSL_FAIL( "OAsianFontLayoutDispatcher::convertDispatchArgsToItem: did not find the one and only argument!" );
164 return nullptr;
165 }
166
167
168} // namespace frm
169
170
171/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
sal_Int32 GetParagraphCount() const
sal_Int32 GetTextLen() const
void SetVertical(bool bVertical)
bool IsEffectivelyVertical() const
void SetSelection(const ESelection &rNewSel)
EditEngine * GetEditEngine() const
mutable::osl::Mutex m_aMutex
virtual const SfxPoolItem * convertDispatchArgsToItem(const css::uno::Sequence< css::beans::PropertyValue > &_rArguments) override
convert the arguments as got in a XDispatch::dispatch call into an SfxPoolItem, which can be used wit...
OAsianFontLayoutDispatcher(EditView &_rView, AttributeId _nAttributeId, const css::util::URL &_rURL, IMultiAttributeDispatcher *_pMasterDispatcher)
virtual css::frame::FeatureStateEvent buildStatusEvent() const override
OParagraphDirectionDispatcher(EditView &_rView, AttributeId _nAttributeId, const css::util::URL &_rURL, IMultiAttributeDispatcher *_pMasterDispatcher)
virtual css::frame::FeatureStateEvent buildStatusEvent() const override
const css::util::URL & getFeatureURL() const
void dispose()
clean up resources associated with this instance
virtual css::frame::FeatureStateEvent buildStatusEvent() const
virtual ~OSelectAllDispatcher() override
virtual css::frame::FeatureStateEvent buildStatusEvent() const override
virtual void SAL_CALL dispatch(const css::util::URL &URL, const css::uno::Sequence< css::beans::PropertyValue > &Arguments) override
OSelectAllDispatcher(EditView &_rView, const css::util::URL &_rURL)
virtual css::frame::FeatureStateEvent buildStatusEvent() const override
virtual void SAL_CALL dispatch(const css::util::URL &URL, const css::uno::Sequence< css::beans::PropertyValue > &Arguments) override
OTextDirectionDispatcher(EditView &_rView, const css::util::URL &_rURL)
ListBox is a bit confusing / different from other form components, so here are a few notes:
Definition: BaseListBox.hxx:25
sal_uInt16 WhichId
the "which id" of an item in an SfxItemSet
sal_Int32 AttributeId
the id of an attribute