Line data Source code
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 "specialdispatchers.hxx"
21 : #include <editeng/editeng.hxx>
22 : #include <editeng/editview.hxx>
23 : #include <svx/svxids.hrc>
24 : #include <editeng/scriptspaceitem.hxx>
25 :
26 :
27 : namespace frm
28 : {
29 :
30 :
31 : using namespace ::com::sun::star::uno;
32 : using namespace ::com::sun::star::lang;
33 : using namespace ::com::sun::star::util;
34 : using namespace ::com::sun::star::frame;
35 : using namespace ::com::sun::star::beans;
36 :
37 :
38 : //= OSelectAllDispatcher
39 :
40 :
41 0 : OSelectAllDispatcher::OSelectAllDispatcher( EditView& _rView, const URL& _rURL )
42 0 : :ORichTextFeatureDispatcher( _rView, _rURL )
43 : {
44 0 : }
45 :
46 :
47 0 : OSelectAllDispatcher::~OSelectAllDispatcher( )
48 : {
49 0 : if ( !isDisposed() )
50 : {
51 0 : acquire();
52 0 : dispose();
53 : }
54 0 : }
55 :
56 :
57 0 : void SAL_CALL OSelectAllDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& /*_rArguments*/ )
58 : throw (RuntimeException,
59 : std::exception)
60 : {
61 0 : ::osl::MutexGuard aGuard( m_aMutex );
62 : OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OSelectAllDispatcher::dispatch: invalid URL!" );
63 : (void)_rURL;
64 :
65 0 : checkDisposed();
66 :
67 0 : EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
68 : OSL_ENSURE( pEngine, "OSelectAllDispatcher::dispatch: no edit engine - but not yet disposed?" );
69 0 : if ( !pEngine )
70 0 : return;
71 :
72 0 : sal_Int32 nParagraphs = pEngine->GetParagraphCount();
73 0 : if ( nParagraphs )
74 : {
75 0 : sal_Int32 nLastParaNumber = nParagraphs - 1;
76 0 : sal_Int32 nParaLen = pEngine->GetTextLen( nLastParaNumber );
77 0 : getEditView()->SetSelection( ESelection( 0, 0, nLastParaNumber, nParaLen ) );
78 0 : }
79 : }
80 :
81 :
82 0 : FeatureStateEvent OSelectAllDispatcher::buildStatusEvent() const
83 : {
84 0 : FeatureStateEvent aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
85 0 : aEvent.IsEnabled = sal_True;
86 0 : return aEvent;
87 : }
88 :
89 :
90 : //= OParagraphDirectionDispatcher
91 :
92 :
93 0 : OParagraphDirectionDispatcher::OParagraphDirectionDispatcher( EditView& _rView, AttributeId _nAttributeId, const URL& _rURL,
94 : IMultiAttributeDispatcher* _pMasterDispatcher )
95 0 : :OAttributeDispatcher( _rView, _nAttributeId, _rURL, _pMasterDispatcher )
96 : {
97 0 : }
98 :
99 :
100 0 : FeatureStateEvent OParagraphDirectionDispatcher::buildStatusEvent() const
101 : {
102 0 : FeatureStateEvent aEvent( OAttributeDispatcher::buildStatusEvent() );
103 :
104 0 : EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
105 : OSL_ENSURE( pEngine, "OParagraphDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
106 0 : if ( pEngine && pEngine->IsVertical() )
107 0 : aEvent.IsEnabled = sal_False;
108 :
109 0 : return aEvent;
110 : }
111 :
112 :
113 : //= OTextDirectionDispatcher
114 :
115 :
116 0 : OTextDirectionDispatcher::OTextDirectionDispatcher( EditView& _rView, const URL& _rURL )
117 0 : :ORichTextFeatureDispatcher( _rView, _rURL )
118 : {
119 0 : }
120 :
121 :
122 0 : void SAL_CALL OTextDirectionDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& /*_rArguments*/ ) throw (RuntimeException, std::exception)
123 : {
124 0 : ::osl::MutexGuard aGuard( m_aMutex );
125 : OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "OTextDirectionDispatcher::dispatch: invalid URL!" );
126 : (void)_rURL;
127 :
128 0 : checkDisposed();
129 :
130 0 : EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
131 : OSL_ENSURE( pEngine, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
132 0 : if ( !pEngine )
133 0 : return;
134 :
135 0 : pEngine->SetVertical( !pEngine->IsVertical() );
136 : }
137 :
138 :
139 0 : FeatureStateEvent OTextDirectionDispatcher::buildStatusEvent() const
140 : {
141 0 : FeatureStateEvent aEvent( ORichTextFeatureDispatcher::buildStatusEvent() );
142 :
143 0 : EditEngine* pEngine = getEditView() ? getEditView()->GetEditEngine() : NULL;
144 : OSL_ENSURE( pEngine, "OTextDirectionDispatcher::dispatch: no edit engine - but not yet disposed?" );
145 :
146 0 : aEvent.IsEnabled = sal_True;
147 0 : aEvent.State <<= (sal_Bool)( pEngine && pEngine->IsVertical() );
148 :
149 0 : return aEvent;
150 : }
151 :
152 :
153 : //= OAsianFontLayoutDispatcher
154 :
155 :
156 0 : OAsianFontLayoutDispatcher::OAsianFontLayoutDispatcher( EditView& _rView, AttributeId _nAttributeId, const URL& _rURL, IMultiAttributeDispatcher* _pMasterDispatcher )
157 0 : :OParametrizedAttributeDispatcher( _rView, _nAttributeId, _rURL, _pMasterDispatcher )
158 : {
159 0 : }
160 :
161 :
162 0 : const SfxPoolItem* OAsianFontLayoutDispatcher::convertDispatchArgsToItem( const Sequence< PropertyValue >& _rArguments )
163 : {
164 : // look for the "Enable" parameter
165 0 : const PropertyValue* pLookup = _rArguments.getConstArray();
166 0 : const PropertyValue* pLookupEnd = _rArguments.getConstArray() + _rArguments.getLength();
167 0 : while ( pLookup != pLookupEnd )
168 : {
169 0 : if ( pLookup->Name == "Enable" )
170 0 : break;
171 0 : ++pLookup;
172 : }
173 0 : if ( pLookup != pLookupEnd )
174 : {
175 0 : sal_Bool bEnable = sal_True;
176 0 : OSL_VERIFY( pLookup->Value >>= bEnable );
177 0 : if ( m_nAttributeId == SID_ATTR_PARA_SCRIPTSPACE )
178 0 : return new SvxScriptSpaceItem( bEnable, (WhichId)m_nAttributeId );
179 0 : return new SfxBoolItem( (WhichId)m_nAttributeId, bEnable );
180 : }
181 :
182 : OSL_FAIL( "OAsianFontLayoutDispatcher::convertDispatchArgsToItem: did not find the one and only argument!" );
183 0 : return NULL;
184 : }
185 :
186 :
187 : } // namespace frm
188 :
189 :
190 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|