/src/libreoffice/editeng/source/uno/unotext.cxx
Line | Count | Source |
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 <vcl/svapp.hxx> |
21 | | #include <com/sun/star/text/ControlCharacter.hpp> |
22 | | #include <com/sun/star/text/XTextField.hpp> |
23 | | #include <com/sun/star/text/TextRangeSelection.hpp> |
24 | | #include <com/sun/star/lang/Locale.hpp> |
25 | | #include <com/sun/star/beans/Pair.hpp> |
26 | | #include <com/sun/star/beans/PropertyAttribute.hpp> |
27 | | #include <com/sun/star/container/XNameContainer.hpp> |
28 | | |
29 | | #include <svl/itemset.hxx> |
30 | | #include <svl/itempool.hxx> |
31 | | #include <svl/eitem.hxx> |
32 | | #include <tools/debug.hxx> |
33 | | |
34 | | #include <editeng/unoprnms.hxx> |
35 | | #include <editeng/unotext.hxx> |
36 | | #include <editeng/unoedsrc.hxx> |
37 | | #include <editeng/unonrule.hxx> |
38 | | #include <editeng/unofdesc.hxx> |
39 | | #include <editeng/unofield.hxx> |
40 | | #include <editeng/flditem.hxx> |
41 | | #include <editeng/numitem.hxx> |
42 | | #include <editeng/editeng.hxx> |
43 | | #include <editeng/outliner.hxx> |
44 | | #include <editeng/unoipset.hxx> |
45 | | #include <editeng/colritem.hxx> |
46 | | #include <comphelper/sequence.hxx> |
47 | | #include <comphelper/servicehelper.hxx> |
48 | | #include <cppuhelper/supportsservice.hxx> |
49 | | |
50 | | #include <editeng/unonames.hxx> |
51 | | |
52 | | #include <initializer_list> |
53 | | #include <memory> |
54 | | #include <string_view> |
55 | | |
56 | | using namespace ::cppu; |
57 | | using namespace ::com::sun::star; |
58 | | |
59 | | namespace { |
60 | | |
61 | | ESelection toESelection(const text::TextRangeSelection& rSel) |
62 | 39.7k | { |
63 | 39.7k | ESelection aESel; |
64 | 39.7k | aESel.start.nPara = rSel.Start.Paragraph; |
65 | 39.7k | aESel.start.nIndex = rSel.Start.PositionInParagraph; |
66 | 39.7k | aESel.end.nPara = rSel.End.Paragraph; |
67 | 39.7k | aESel.end.nIndex = rSel.End.PositionInParagraph; |
68 | 39.7k | return aESel; |
69 | 39.7k | } |
70 | | |
71 | | } |
72 | | |
73 | | #define QUERYINT( xint ) \ |
74 | 4.13M | if( rType == cppu::UnoType<xint>::get() ) \ |
75 | 4.13M | return uno::Any(uno::Reference< xint >(this)) |
76 | | |
77 | | const SvxItemPropertySet* ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() |
78 | 466k | { |
79 | 466k | static SvxItemPropertySet aTextCursorSvxPropertySet( ImplGetSvxUnoOutlinerTextCursorPropertyMap(), EditEngine::GetGlobalItemPool() ); |
80 | 466k | return &aTextCursorSvxPropertySet; |
81 | 466k | } |
82 | | |
83 | | std::span<const SfxItemPropertyMapEntry> ImplGetSvxTextPortionPropertyMap() |
84 | 3 | { |
85 | | // Propertymap for an Outliner Text |
86 | 3 | static const SfxItemPropertyMapEntry aSvxTextPortionPropertyMap[] = |
87 | 3 | { |
88 | 3 | SVX_UNOEDIT_CHAR_PROPERTIES, |
89 | 3 | SVX_UNOEDIT_FONT_PROPERTIES, |
90 | 3 | SVX_UNOEDIT_OUTLINER_PROPERTIES, |
91 | 3 | SVX_UNOEDIT_PARA_PROPERTIES, |
92 | 3 | { u"TextField"_ustr, EE_FEATURE_FIELD, cppu::UnoType<text::XTextField>::get(), beans::PropertyAttribute::READONLY, 0 }, |
93 | 3 | { u"TextPortionType"_ustr, WID_PORTIONTYPE, ::cppu::UnoType<OUString>::get(), beans::PropertyAttribute::READONLY, 0 }, |
94 | 3 | { u"TextUserDefinedAttributes"_ustr, EE_CHAR_XMLATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0}, |
95 | 3 | { u"ParaUserDefinedAttributes"_ustr, EE_PARA_XMLATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0}, |
96 | 3 | }; |
97 | 3 | return aSvxTextPortionPropertyMap; |
98 | 3 | } |
99 | | const SvxItemPropertySet* ImplGetSvxTextPortionSvxPropertySet() |
100 | 4.65k | { |
101 | 4.65k | static SvxItemPropertySet aSvxTextPortionPropertySet( ImplGetSvxTextPortionPropertyMap(), EditEngine::GetGlobalItemPool() ); |
102 | 4.65k | return &aSvxTextPortionPropertySet; |
103 | 4.65k | } |
104 | | |
105 | | static const SfxItemPropertySet* ImplGetSvxTextPortionSfxPropertySet() |
106 | 5.21k | { |
107 | 5.21k | static SfxItemPropertySet aSvxTextPortionSfxPropertySet( ImplGetSvxTextPortionPropertyMap() ); |
108 | 5.21k | return &aSvxTextPortionSfxPropertySet; |
109 | 5.21k | } |
110 | | |
111 | | std::span<const SfxItemPropertyMapEntry> ImplGetSvxUnoOutlinerTextCursorPropertyMap() |
112 | 12 | { |
113 | | // Propertymap for an Outliner Text |
114 | 12 | static const SfxItemPropertyMapEntry aSvxUnoOutlinerTextCursorPropertyMap[] = |
115 | 12 | { |
116 | 12 | SVX_UNOEDIT_CHAR_PROPERTIES, |
117 | 12 | SVX_UNOEDIT_FONT_PROPERTIES, |
118 | 12 | SVX_UNOEDIT_OUTLINER_PROPERTIES, |
119 | 12 | SVX_UNOEDIT_PARA_PROPERTIES, |
120 | 12 | { u"TextUserDefinedAttributes"_ustr, EE_CHAR_XMLATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0}, |
121 | 12 | { u"ParaUserDefinedAttributes"_ustr, EE_PARA_XMLATTRIBS, cppu::UnoType<css::container::XNameContainer>::get(), 0, 0}, |
122 | 12 | }; |
123 | | |
124 | 12 | return aSvxUnoOutlinerTextCursorPropertyMap; |
125 | 12 | } |
126 | | static const SfxItemPropertySet* ImplGetSvxUnoOutlinerTextCursorSfxPropertySet() |
127 | 1.27k | { |
128 | 1.27k | static SfxItemPropertySet aTextCursorSfxPropertySet( ImplGetSvxUnoOutlinerTextCursorPropertyMap() ); |
129 | 1.27k | return &aTextCursorSfxPropertySet; |
130 | 1.27k | } |
131 | | |
132 | | |
133 | | // helper for Item/Property conversion |
134 | | |
135 | | |
136 | | void GetSelection( struct ESelection& rSel, SvxTextForwarder const * pForwarder ) noexcept |
137 | 7.68M | { |
138 | 7.68M | DBG_ASSERT( pForwarder, "I need a valid SvxTextForwarder!" ); |
139 | 7.68M | if( pForwarder ) |
140 | 7.68M | { |
141 | 7.68M | sal_Int32 nParaCount = pForwarder->GetParagraphCount(); |
142 | 7.68M | if(nParaCount>0) |
143 | 7.68M | nParaCount--; |
144 | | |
145 | 7.68M | rSel = ESelection( 0,0, nParaCount, pForwarder->GetTextLen( nParaCount )); |
146 | 7.68M | } |
147 | 7.68M | } |
148 | | |
149 | | void CheckSelection( struct ESelection& rSel, SvxTextForwarder const * pForwarder ) noexcept |
150 | 7.29M | { |
151 | 7.29M | DBG_ASSERT( pForwarder, "I need a valid SvxTextForwarder!" ); |
152 | 7.29M | if( !pForwarder ) |
153 | 0 | return; |
154 | | |
155 | 7.29M | if (rSel.start.nPara == EE_PARA_MAX) |
156 | 14.2k | { |
157 | 14.2k | ::GetSelection( rSel, pForwarder ); |
158 | 14.2k | } |
159 | 7.28M | else |
160 | 7.28M | { |
161 | 7.28M | ESelection aMaxSelection; |
162 | 7.28M | GetSelection( aMaxSelection, pForwarder ); |
163 | | |
164 | | // check start position |
165 | 7.28M | if (rSel.start.nPara < aMaxSelection.start.nPara) |
166 | 0 | { |
167 | 0 | rSel.start = aMaxSelection.start; |
168 | 0 | } |
169 | 7.28M | else if (rSel.start.nPara > aMaxSelection.end.nPara) |
170 | 0 | { |
171 | 0 | rSel.start = aMaxSelection.end; |
172 | 0 | } |
173 | 7.28M | else if (rSel.start.nIndex > pForwarder->GetTextLen(rSel.start.nPara)) |
174 | 0 | { |
175 | 0 | rSel.start.nIndex = pForwarder->GetTextLen(rSel.start.nPara); |
176 | 0 | } |
177 | | |
178 | | // check end position |
179 | 7.28M | if (rSel.end.nPara < aMaxSelection.start.nPara) |
180 | 0 | { |
181 | 0 | rSel.end = aMaxSelection.start; |
182 | 0 | } |
183 | 7.28M | else if (rSel.end.nPara > aMaxSelection.end.nPara) |
184 | 14.4k | { |
185 | 14.4k | rSel.end = aMaxSelection.end; |
186 | 14.4k | } |
187 | 7.26M | else if (rSel.end.nIndex > pForwarder->GetTextLen(rSel.end.nPara)) |
188 | 25.5k | { |
189 | 25.5k | rSel.end.nIndex = pForwarder->GetTextLen(rSel.end.nPara); |
190 | 25.5k | } |
191 | 7.28M | } |
192 | 7.29M | } |
193 | | |
194 | | static void CheckSelection( struct ESelection& rSel, SvxEditSource *pEdit ) noexcept |
195 | 1.47M | { |
196 | 1.47M | if (!pEdit) |
197 | 3.75k | return; |
198 | 1.46M | CheckSelection( rSel, pEdit->GetTextForwarder() ); |
199 | 1.46M | } |
200 | | |
201 | | |
202 | | |
203 | | |
204 | | UNO3_GETIMPLEMENTATION_IMPL( SvxUnoTextRangeBase ); |
205 | | |
206 | | SvxUnoTextRangeBase::SvxUnoTextRangeBase(const SvxItemPropertySet* _pSet) |
207 | 466k | : mpPropSet(_pSet) |
208 | 466k | { |
209 | 466k | } |
210 | | |
211 | | SvxUnoTextRangeBase::SvxUnoTextRangeBase(const SvxEditSource* pSource, const SvxItemPropertySet* _pSet) |
212 | 186k | : mpPropSet(_pSet) |
213 | 186k | { |
214 | 186k | SolarMutexGuard aGuard; |
215 | | |
216 | 186k | assert(pSource && "SvxUnoTextRangeBase: I need a valid SvxEditSource!"); |
217 | | |
218 | 186k | mpEditSource = pSource->Clone(); |
219 | 186k | if (mpEditSource != nullptr) |
220 | 186k | { |
221 | 186k | ESelection aSelection; |
222 | 186k | ::GetSelection( aSelection, mpEditSource->GetTextForwarder() ); |
223 | 186k | SetSelection( aSelection ); |
224 | | |
225 | 186k | mpEditSource->addRange( this ); |
226 | 186k | } |
227 | 186k | } |
228 | | |
229 | | SvxUnoTextRangeBase::SvxUnoTextRangeBase(const SvxUnoTextRangeBase& rRange) |
230 | 184k | : text::XTextRange() |
231 | 184k | , beans::XPropertySet() |
232 | 184k | , beans::XMultiPropertySet() |
233 | 184k | , beans::XMultiPropertyStates() |
234 | 184k | , beans::XPropertyState() |
235 | 184k | , lang::XServiceInfo() |
236 | 184k | , text::XTextRangeCompare() |
237 | 184k | , lang::XUnoTunnel() |
238 | 184k | , osl::DebugBase<SvxUnoTextRangeBase>() |
239 | 184k | , mpPropSet(rRange.getPropertySet()) |
240 | 184k | { |
241 | 184k | SolarMutexGuard aGuard; |
242 | | |
243 | 184k | if (rRange.mpEditSource) |
244 | 183k | mpEditSource = rRange.mpEditSource->Clone(); |
245 | | |
246 | 184k | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
247 | 184k | if( pForwarder ) |
248 | 183k | { |
249 | 183k | maSelection = rRange.maSelection; |
250 | 183k | CheckSelection( maSelection, pForwarder ); |
251 | 183k | } |
252 | | |
253 | 184k | if( mpEditSource ) |
254 | 183k | mpEditSource->addRange( this ); |
255 | 184k | } |
256 | | |
257 | | SvxUnoTextRangeBase::~SvxUnoTextRangeBase() noexcept |
258 | 837k | { |
259 | 837k | if( mpEditSource ) |
260 | 835k | mpEditSource->removeRange( this ); |
261 | 837k | } |
262 | | |
263 | | void SvxUnoTextRangeBase::SetEditSource( SvxEditSource* pSource ) noexcept |
264 | 465k | { |
265 | 465k | DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!"); |
266 | 465k | DBG_ASSERT(mpEditSource==nullptr,"SvxUnoTextRangeBase::SetEditSource called while SvxEditSource already set" ); |
267 | | |
268 | 465k | mpEditSource.reset( pSource ); |
269 | | |
270 | 465k | maSelection.start.nPara = EE_PARA_MAX; |
271 | | |
272 | 465k | if( mpEditSource ) |
273 | 465k | mpEditSource->addRange( this ); |
274 | 465k | } |
275 | | |
276 | | /** puts a field item with a copy of the given FieldData into the itemset |
277 | | corresponding with this range */ |
278 | | void SvxUnoTextRangeBase::attachField( std::unique_ptr<SvxFieldData> pData ) noexcept |
279 | 14 | { |
280 | 14 | SolarMutexGuard aGuard; |
281 | | |
282 | 14 | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
283 | 14 | if( pForwarder ) |
284 | 14 | { |
285 | 14 | SvxFieldItem aField( std::move(pData), EE_FEATURE_FIELD ); |
286 | 14 | pForwarder->QuickInsertField( std::move(aField), maSelection ); |
287 | 14 | } |
288 | 14 | } |
289 | | |
290 | | void SvxUnoTextRangeBase::SetSelection( const ESelection& rSelection ) noexcept |
291 | 859k | { |
292 | 859k | SolarMutexGuard aGuard; |
293 | | |
294 | 859k | maSelection = rSelection; |
295 | 859k | CheckSelection( maSelection, mpEditSource.get() ); |
296 | 859k | } |
297 | | |
298 | | // Interface XTextRange ( XText ) |
299 | | |
300 | | uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getStart() |
301 | 159k | { |
302 | 159k | SolarMutexGuard aGuard; |
303 | | |
304 | 159k | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
305 | 159k | if( !pForwarder ) |
306 | 2.99k | return nullptr; |
307 | | |
308 | 156k | CheckSelection( maSelection, pForwarder ); |
309 | | |
310 | 156k | SvxUnoTextBase* pText = comphelper::getFromUnoTunnel<SvxUnoTextBase>( getText() ); |
311 | | |
312 | 156k | if(pText == nullptr) |
313 | 0 | throw uno::RuntimeException(u"Failed to retrieve a valid text base object from the Uno Tunnel"_ustr); |
314 | | |
315 | 156k | rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *pText ); |
316 | | |
317 | 156k | ESelection aNewSel = maSelection; |
318 | 156k | aNewSel.CollapseToStart(); |
319 | 156k | pRange->SetSelection( aNewSel ); |
320 | | |
321 | 156k | return pRange; |
322 | 156k | } |
323 | | |
324 | | uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextRangeBase::getEnd() |
325 | 13.2k | { |
326 | 13.2k | SolarMutexGuard aGuard; |
327 | | |
328 | 13.2k | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
329 | 13.2k | if( !pForwarder ) |
330 | 0 | return nullptr; |
331 | | |
332 | 13.2k | CheckSelection( maSelection, pForwarder ); |
333 | | |
334 | 13.2k | SvxUnoTextBase* pText = comphelper::getFromUnoTunnel<SvxUnoTextBase>( getText() ); |
335 | | |
336 | 13.2k | if(pText == nullptr) |
337 | 0 | throw uno::RuntimeException(u"Failed to retrieve a valid text base object from the Uno Tunnel"_ustr); |
338 | | |
339 | 13.2k | rtl::Reference<SvxUnoTextRange> pNew = new SvxUnoTextRange( *pText ); |
340 | | |
341 | 13.2k | ESelection aNewSel = maSelection; |
342 | 13.2k | aNewSel.CollapseToEnd(); |
343 | 13.2k | pNew->SetSelection( aNewSel ); |
344 | 13.2k | return pNew; |
345 | 13.2k | } |
346 | | |
347 | | OUString SAL_CALL SvxUnoTextRangeBase::getString() |
348 | 6.06k | { |
349 | 6.06k | SolarMutexGuard aGuard; |
350 | | |
351 | 6.06k | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
352 | 6.06k | if( pForwarder ) |
353 | 6.06k | { |
354 | 6.06k | CheckSelection( maSelection, pForwarder ); |
355 | | |
356 | 6.06k | return pForwarder->GetText( maSelection ); |
357 | 6.06k | } |
358 | 0 | else |
359 | 0 | { |
360 | 0 | return OUString(); |
361 | 0 | } |
362 | 6.06k | } |
363 | | |
364 | | void SAL_CALL SvxUnoTextRangeBase::setString(const OUString& aString) |
365 | 283k | { |
366 | 283k | SolarMutexGuard aGuard; |
367 | | |
368 | 283k | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
369 | 283k | if( !pForwarder ) |
370 | 1.87k | return; |
371 | | |
372 | 281k | CheckSelection( maSelection, pForwarder ); |
373 | | |
374 | 281k | OUString aConverted(convertLineEnd(aString, LINEEND_LF)); // Simply count the number of line endings |
375 | | |
376 | 281k | pForwarder->QuickInsertText( aConverted, maSelection ); |
377 | 281k | mpEditSource->UpdateData(); |
378 | | |
379 | | // Adapt selection |
380 | | //! It would be easier if the EditEngine would return the selection |
381 | | //! on QuickInsertText... |
382 | 281k | CollapseToStart(); |
383 | | |
384 | 281k | sal_Int32 nLen = aConverted.getLength(); |
385 | 281k | if (nLen) |
386 | 212k | GoRight( nLen, true ); |
387 | 281k | } |
388 | | |
389 | | // Interface beans::XPropertySet |
390 | | uno::Reference< beans::XPropertySetInfo > SAL_CALL SvxUnoTextRangeBase::getPropertySetInfo() |
391 | 339k | { |
392 | 339k | return mpPropSet->getPropertySetInfo(); |
393 | 339k | } |
394 | | |
395 | | void SAL_CALL SvxUnoTextRangeBase::setPropertyValue(const OUString& PropertyName, const uno::Any& aValue) |
396 | 710k | { |
397 | 710k | if (PropertyName == UNO_TR_PROP_SELECTION) |
398 | 19.8k | { |
399 | 19.8k | text::TextRangeSelection aSel = aValue.get<text::TextRangeSelection>(); |
400 | 19.8k | SetSelection(toESelection(aSel)); |
401 | | |
402 | 19.8k | return; |
403 | 19.8k | } |
404 | | |
405 | 691k | _setPropertyValue( PropertyName, aValue ); |
406 | 691k | } |
407 | | |
408 | | void SvxUnoTextRangeBase::_setPropertyValue( const OUString& PropertyName, const uno::Any& aValue, sal_Int32 nPara ) |
409 | 726k | { |
410 | 726k | SolarMutexGuard aGuard; |
411 | | |
412 | 726k | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
413 | 726k | if( pForwarder ) |
414 | 726k | { |
415 | 726k | CheckSelection( maSelection, pForwarder ); |
416 | | |
417 | 726k | const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName ); |
418 | 726k | if ( pMap ) |
419 | 726k | { |
420 | 726k | ESelection aSel( GetSelection() ); |
421 | 726k | bool bParaAttrib = (pMap->nWID >= EE_PARA_START) && ( pMap->nWID <= EE_PARA_END ); |
422 | | |
423 | 726k | if (pMap->nWID == WID_PARASTYLENAME) |
424 | 157 | { |
425 | 157 | OUString aStyle = aValue.get<OUString>(); |
426 | | |
427 | 157 | sal_Int32 nEndPara; |
428 | | |
429 | 157 | if( nPara == -1 ) |
430 | 157 | { |
431 | 157 | nPara = aSel.start.nPara; |
432 | 157 | nEndPara = aSel.end.nPara; |
433 | 157 | } |
434 | 0 | else |
435 | 0 | { |
436 | | // only one paragraph |
437 | 0 | nEndPara = nPara; |
438 | 0 | } |
439 | | |
440 | 314 | while( nPara <= nEndPara ) |
441 | 157 | { |
442 | 157 | pForwarder->SetStyleSheet(nPara, aStyle); |
443 | 157 | nPara++; |
444 | 157 | } |
445 | 157 | } |
446 | 726k | else if ( nPara == -1 && !bParaAttrib ) |
447 | 1.95k | { |
448 | 1.95k | SfxItemSet aOldSet( pForwarder->GetAttribs( aSel ) ); |
449 | | // we have a selection and no para attribute |
450 | 1.95k | SfxItemSet aNewSet( *aOldSet.GetPool(), aOldSet.GetRanges() ); |
451 | | |
452 | 1.95k | setPropertyValue( pMap, aValue, maSelection, aOldSet, aNewSet ); |
453 | | |
454 | | |
455 | 1.95k | pForwarder->QuickSetAttribs( aNewSet, GetSelection() ); |
456 | 1.95k | } |
457 | 724k | else |
458 | 724k | { |
459 | 724k | sal_Int32 nEndPara; |
460 | | |
461 | 724k | if( nPara == -1 ) |
462 | 688k | { |
463 | 688k | nPara = aSel.start.nPara; |
464 | 688k | nEndPara = aSel.end.nPara; |
465 | 688k | } |
466 | 35.3k | else |
467 | 35.3k | { |
468 | | // only one paragraph |
469 | 35.3k | nEndPara = nPara; |
470 | 35.3k | } |
471 | | |
472 | 1.44M | while( nPara <= nEndPara ) |
473 | 724k | { |
474 | | // we have a paragraph |
475 | 724k | SfxItemSet aSet( pForwarder->GetParaAttribs( nPara ) ); |
476 | 724k | setPropertyValue( pMap, aValue, maSelection, aSet, aSet ); |
477 | 724k | pForwarder->SetParaAttribs( nPara, aSet ); |
478 | 724k | nPara++; |
479 | 724k | } |
480 | 724k | } |
481 | | |
482 | 726k | GetEditSource()->UpdateData(); |
483 | 726k | return; |
484 | 726k | } |
485 | 726k | } |
486 | | |
487 | 0 | throw beans::UnknownPropertyException(PropertyName); |
488 | 726k | } |
489 | | |
490 | | void SvxUnoTextRangeBase::setPropertyValue( const SfxItemPropertyMapEntry* pMap, const uno::Any& rValue, const ESelection& rSelection, const SfxItemSet& rOldSet, SfxItemSet& rNewSet ) |
491 | 3.27M | { |
492 | 3.27M | if(!SetPropertyValueHelper( pMap, rValue, rNewSet, &rSelection, GetEditSource() )) |
493 | 3.18M | { |
494 | | // For parts of composite items with multiple properties (eg background) |
495 | | // must be taken from the document before the old item. |
496 | 3.18M | rNewSet.Put(rOldSet.Get(pMap->nWID)); // Old Item in new Set |
497 | 3.18M | SvxItemPropertySet::setPropertyValue(pMap, rValue, rNewSet, false ); |
498 | 3.18M | } |
499 | 3.27M | } |
500 | | |
501 | | bool SvxUnoTextRangeBase::SetPropertyValueHelper( const SfxItemPropertyMapEntry* pMap, const uno::Any& aValue, SfxItemSet& rNewSet, const ESelection* pSelection /* = NULL */, SvxEditSource* pEditSource /* = NULL*/ ) |
502 | 13.3M | { |
503 | 13.3M | switch( pMap->nWID ) |
504 | 13.3M | { |
505 | 0 | case WID_FONTDESC: |
506 | 0 | { |
507 | 0 | awt::FontDescriptor aDesc; |
508 | 0 | if(aValue >>= aDesc) |
509 | 0 | { |
510 | 0 | SvxUnoFontDescriptor::FillItemSet( aDesc, rNewSet ); |
511 | 0 | return true; |
512 | 0 | } |
513 | 0 | } |
514 | 0 | break; |
515 | | |
516 | 195k | case EE_PARA_NUMBULLET: |
517 | 195k | { |
518 | 195k | uno::Reference< container::XIndexReplace > xRule; |
519 | 195k | return !aValue.hasValue() || ((aValue >>= xRule) && !xRule.is()); |
520 | 0 | } |
521 | | |
522 | 161k | case EE_PARA_OUTLLEVEL: |
523 | 161k | { |
524 | 161k | SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : nullptr; |
525 | 161k | if(pForwarder && pSelection) |
526 | 161k | { |
527 | 161k | if (!pForwarder->SupportsOutlineDepth()) |
528 | 0 | return false; |
529 | | |
530 | 161k | sal_Int16 nLevel = sal_Int16(); |
531 | 161k | if( aValue >>= nLevel ) |
532 | 161k | { |
533 | | // #101004# Call interface method instead of unsafe cast |
534 | 161k | if (!pForwarder->SetDepth(pSelection->start.nPara, nLevel)) |
535 | 0 | throw lang::IllegalArgumentException(); |
536 | | |
537 | | // If valid, then not yet finished. Also needs to be added to paragraph props. |
538 | 161k | return nLevel < -1 || nLevel > 9; |
539 | 161k | } |
540 | 161k | } |
541 | 161k | } |
542 | 0 | break; |
543 | 0 | case WID_NUMBERINGSTARTVALUE: |
544 | 0 | { |
545 | 0 | SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : nullptr; |
546 | 0 | if(pForwarder && pSelection) |
547 | 0 | { |
548 | 0 | sal_Int16 nStartValue = -1; |
549 | 0 | if( aValue >>= nStartValue ) |
550 | 0 | { |
551 | 0 | pForwarder->SetNumberingStartValue(pSelection->start.nPara, nStartValue); |
552 | 0 | return true; |
553 | 0 | } |
554 | 0 | } |
555 | 0 | } |
556 | 0 | break; |
557 | 15 | case WID_PARAISNUMBERINGRESTART: |
558 | 15 | { |
559 | 15 | SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : nullptr; |
560 | 15 | if(pForwarder && pSelection) |
561 | 15 | { |
562 | 15 | bool bParaIsNumberingRestart = false; |
563 | 15 | if( aValue >>= bParaIsNumberingRestart ) |
564 | 15 | { |
565 | 15 | pForwarder->SetParaIsNumberingRestart( pSelection->start.nPara, bParaIsNumberingRestart ); |
566 | 15 | return true; |
567 | 15 | } |
568 | 15 | } |
569 | 15 | } |
570 | 0 | break; |
571 | 183k | case EE_PARA_BULLETSTATE: |
572 | 183k | { |
573 | 183k | bool bBullet = true; |
574 | 183k | if( aValue >>= bBullet ) |
575 | 183k | { |
576 | 183k | SfxBoolItem aItem( EE_PARA_BULLETSTATE, bBullet ); |
577 | 183k | rNewSet.Put(aItem); |
578 | 183k | return true; |
579 | 183k | } |
580 | 183k | } |
581 | 0 | break; |
582 | | |
583 | 12.8M | default: |
584 | 12.8M | return false; |
585 | 13.3M | } |
586 | | |
587 | 0 | throw lang::IllegalArgumentException(); |
588 | 13.3M | } |
589 | | |
590 | | uno::Any SAL_CALL SvxUnoTextRangeBase::getPropertyValue(const OUString& PropertyName) |
591 | 213k | { |
592 | 213k | if (PropertyName == UNO_TR_PROP_SELECTION) |
593 | 28.7k | { |
594 | 28.7k | const ESelection& rSel = GetSelection(); |
595 | 28.7k | text::TextRangeSelection aSel; |
596 | 28.7k | aSel.Start.Paragraph = rSel.start.nPara; |
597 | 28.7k | aSel.Start.PositionInParagraph = rSel.start.nIndex; |
598 | 28.7k | aSel.End.Paragraph = rSel.end.nPara; |
599 | 28.7k | aSel.End.PositionInParagraph = rSel.end.nIndex; |
600 | 28.7k | return uno::Any(aSel); |
601 | 28.7k | } |
602 | | |
603 | 184k | return _getPropertyValue( PropertyName ); |
604 | 213k | } |
605 | | |
606 | | uno::Any SvxUnoTextRangeBase::_getPropertyValue(const OUString& PropertyName, sal_Int32 nPara ) |
607 | 227k | { |
608 | 227k | SolarMutexGuard aGuard; |
609 | | |
610 | 227k | uno::Any aAny; |
611 | | |
612 | 227k | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
613 | 227k | if( pForwarder ) |
614 | 227k | { |
615 | 227k | const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName ); |
616 | 227k | if( pMap ) |
617 | 222k | { |
618 | 222k | std::optional<SfxItemSet> oAttribs; |
619 | 222k | if( nPara != -1 ) |
620 | 37.8k | oAttribs.emplace(pForwarder->GetParaAttribs( nPara )); |
621 | 184k | else |
622 | 184k | oAttribs.emplace(pForwarder->GetAttribs( GetSelection() )); |
623 | | |
624 | | // Replace Dontcare with Default, so that one always has a mirror |
625 | 222k | oAttribs->ClearInvalidItems(); |
626 | | |
627 | 222k | getPropertyValue( pMap, aAny, *oAttribs ); |
628 | | |
629 | 222k | return aAny; |
630 | 222k | } |
631 | 227k | } |
632 | | |
633 | 4.61k | throw beans::UnknownPropertyException(PropertyName); |
634 | 227k | } |
635 | | |
636 | | void SvxUnoTextRangeBase::getPropertyValue( const SfxItemPropertyMapEntry* pMap, uno::Any& rAny, const SfxItemSet& rSet ) |
637 | 288k | { |
638 | 288k | switch( pMap->nWID ) |
639 | 288k | { |
640 | 0 | case EE_FEATURE_FIELD: |
641 | 0 | { |
642 | 0 | const SvxFieldItem* pItem = nullptr; |
643 | 0 | if ( rSet.GetItemState( EE_FEATURE_FIELD, false, &pItem ) == SfxItemState::SET ) |
644 | 0 | { |
645 | 0 | const SvxFieldData* pData = pItem->GetField(); |
646 | 0 | uno::Reference< text::XTextRange > xAnchor( this ); |
647 | | |
648 | | // get presentation string for field |
649 | 0 | std::optional<Color> pTColor; |
650 | 0 | std::optional<Color> pFColor; |
651 | 0 | std::optional<FontLineStyle> pFldLineStyle; |
652 | |
|
653 | 0 | SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder(); |
654 | 0 | OUString aPresentation( pForwarder->CalcFieldValue( SvxFieldItem(*pData, EE_FEATURE_FIELD), maSelection.start.nPara, maSelection.start.nIndex, pTColor, pFColor, pFldLineStyle ) ); |
655 | |
|
656 | 0 | uno::Reference< text::XTextField > xField( new SvxUnoTextField( xAnchor, aPresentation, pData ) ); |
657 | 0 | rAny <<= xField; |
658 | 0 | } |
659 | 0 | break; |
660 | 0 | } |
661 | 6.86k | case WID_PORTIONTYPE: |
662 | 6.86k | if ( rSet.GetItemState( EE_FEATURE_FIELD, false ) == SfxItemState::SET ) |
663 | 0 | { |
664 | 0 | rAny <<= u"TextField"_ustr; |
665 | 0 | } |
666 | 6.86k | else |
667 | 6.86k | { |
668 | 6.86k | rAny <<= u"Text"_ustr; |
669 | 6.86k | } |
670 | 6.86k | break; |
671 | | |
672 | 0 | case WID_PARASTYLENAME: |
673 | 0 | { |
674 | 0 | rAny <<= GetEditSource()->GetTextForwarder()->GetStyleSheet(maSelection.start.nPara); |
675 | 0 | } |
676 | 0 | break; |
677 | | |
678 | 281k | default: |
679 | 281k | if(!GetPropertyValueHelper( *const_cast<SfxItemSet*>(&rSet), pMap, rAny, &maSelection, GetEditSource() )) |
680 | 106k | rAny = SvxItemPropertySet::getPropertyValue(pMap, rSet, true, false ); |
681 | 288k | } |
682 | 288k | } |
683 | | |
684 | | bool SvxUnoTextRangeBase::GetPropertyValueHelper( SfxItemSet const & rSet, const SfxItemPropertyMapEntry* pMap, uno::Any& aAny, const ESelection* pSelection /* = NULL */, SvxEditSource* pEditSource /* = NULL */ ) |
685 | 680k | { |
686 | 680k | switch( pMap->nWID ) |
687 | 680k | { |
688 | 0 | case WID_FONTDESC: |
689 | 0 | { |
690 | 0 | awt::FontDescriptor aDesc; |
691 | 0 | SvxUnoFontDescriptor::FillFromItemSet( rSet, aDesc ); |
692 | 0 | aAny <<= aDesc; |
693 | 0 | } |
694 | 0 | break; |
695 | | |
696 | 262k | case EE_PARA_NUMBULLET: |
697 | 262k | { |
698 | 262k | SfxItemState eState = rSet.GetItemState( EE_PARA_NUMBULLET ); |
699 | 262k | if( eState != SfxItemState::SET && eState != SfxItemState::DEFAULT) |
700 | 0 | throw uno::RuntimeException(u"Invalid item state for paragraph numbering/bullet. Expected SET or DEFAULT."_ustr); |
701 | | |
702 | 262k | const SvxNumBulletItem* pBulletItem = rSet.GetItem( EE_PARA_NUMBULLET ); |
703 | | |
704 | 262k | if( pBulletItem == nullptr ) |
705 | 0 | throw uno::RuntimeException(u"Unable to retrieve paragraph numbering/bullet item."_ustr); |
706 | | |
707 | 262k | aAny <<= SvxCreateNumRule( pBulletItem->GetNumRule() ); |
708 | 262k | } |
709 | 0 | break; |
710 | | |
711 | 2.29k | case EE_PARA_OUTLLEVEL: |
712 | 2.29k | { |
713 | 2.29k | SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : nullptr; |
714 | 2.29k | if(pForwarder && pSelection) |
715 | 2.29k | { |
716 | 2.29k | if (!pForwarder->SupportsOutlineDepth()) |
717 | 0 | return false; |
718 | | |
719 | 2.29k | sal_Int16 nLevel = pForwarder->GetDepth(pSelection->start.nPara); |
720 | 2.29k | if( nLevel >= 0 ) |
721 | 104 | aAny <<= nLevel; |
722 | 2.29k | } |
723 | 2.29k | } |
724 | 2.29k | break; |
725 | 2.29k | case WID_NUMBERINGSTARTVALUE: |
726 | 0 | { |
727 | 0 | SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : nullptr; |
728 | 0 | if(pForwarder && pSelection) |
729 | 0 | aAny <<= pForwarder->GetNumberingStartValue(pSelection->start.nPara); |
730 | 0 | } |
731 | 0 | break; |
732 | 0 | case WID_PARAISNUMBERINGRESTART: |
733 | 0 | { |
734 | 0 | SvxTextForwarder* pForwarder = pEditSource? pEditSource->GetTextForwarder() : nullptr; |
735 | 0 | if(pForwarder && pSelection) |
736 | 0 | aAny <<= pForwarder->IsParaIsNumberingRestart(pSelection->start.nPara); |
737 | 0 | } |
738 | 0 | break; |
739 | | |
740 | 0 | case EE_PARA_BULLETSTATE: |
741 | 0 | { |
742 | 0 | bool bState = false; |
743 | 0 | SfxItemState eState = rSet.GetItemState( EE_PARA_BULLETSTATE ); |
744 | 0 | if( eState == SfxItemState::SET || eState == SfxItemState::DEFAULT ) |
745 | 0 | { |
746 | 0 | const SfxBoolItem* pItem = rSet.GetItem<SfxBoolItem>( EE_PARA_BULLETSTATE ); |
747 | 0 | bState = pItem->GetValue(); |
748 | 0 | } |
749 | |
|
750 | 0 | aAny <<= bState; |
751 | 0 | } |
752 | 0 | break; |
753 | 416k | default: |
754 | | |
755 | 416k | return false; |
756 | 680k | } |
757 | | |
758 | 264k | return true; |
759 | 680k | } |
760 | | |
761 | | // is not (yet) supported |
762 | 0 | void SAL_CALL SvxUnoTextRangeBase::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) {} |
763 | 0 | void SAL_CALL SvxUnoTextRangeBase::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) {} |
764 | 0 | void SAL_CALL SvxUnoTextRangeBase::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) {} |
765 | 0 | void SAL_CALL SvxUnoTextRangeBase::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) {} |
766 | | |
767 | | // XMultiPropertySet |
768 | | void SAL_CALL SvxUnoTextRangeBase::setPropertyValues( const uno::Sequence< OUString >& aPropertyNames, const uno::Sequence< uno::Any >& aValues ) |
769 | 162k | { |
770 | 162k | _setPropertyValues( aPropertyNames, aValues ); |
771 | 162k | } |
772 | | |
773 | | void SvxUnoTextRangeBase::_setPropertyValues( const uno::Sequence< OUString >& aPropertyNames, const uno::Sequence< uno::Any >& aValues, sal_Int32 nPara ) |
774 | 162k | { |
775 | 162k | if (aPropertyNames.getLength() != aValues.getLength()) |
776 | 0 | throw lang::IllegalArgumentException(u"lengths do not match"_ustr, |
777 | 0 | static_cast<css::beans::XPropertySet*>(this), -1); |
778 | | |
779 | 162k | SolarMutexGuard aGuard; |
780 | | |
781 | 162k | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
782 | 162k | if( !pForwarder ) |
783 | 0 | return; |
784 | | |
785 | 162k | CheckSelection( maSelection, pForwarder ); |
786 | | |
787 | 162k | ESelection aSel( GetSelection() ); |
788 | | |
789 | 162k | const OUString* pPropertyNames = aPropertyNames.getConstArray(); |
790 | 162k | const uno::Any* pValues = aValues.getConstArray(); |
791 | 162k | sal_Int32 nCount = aPropertyNames.getLength(); |
792 | | |
793 | 162k | sal_Int32 nEndPara = nPara; |
794 | 162k | sal_Int32 nTempPara = nPara; |
795 | | |
796 | 162k | if( nTempPara == -1 ) |
797 | 162k | { |
798 | 162k | nTempPara = aSel.start.nPara; |
799 | 162k | nEndPara = aSel.end.nPara; |
800 | 162k | } |
801 | | |
802 | 162k | std::optional<SfxItemSet> pOldAttrSet; |
803 | 162k | std::optional<SfxItemSet> pNewAttrSet; |
804 | | |
805 | 162k | std::optional<SfxItemSet> pOldParaSet; |
806 | 162k | std::optional<SfxItemSet> pNewParaSet; |
807 | | |
808 | 162k | std::optional<OUString> aStyleName; |
809 | | |
810 | 2.73M | for( ; nCount; nCount--, pPropertyNames++, pValues++ ) |
811 | 2.57M | { |
812 | 2.57M | const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry( *pPropertyNames ); |
813 | | |
814 | 2.57M | if( pMap ) |
815 | 2.55M | { |
816 | 2.55M | bool bParaAttrib = (pMap->nWID >= EE_PARA_START) && ( pMap->nWID <= EE_PARA_END ); |
817 | | |
818 | 2.55M | if (pMap->nWID == WID_PARASTYLENAME) |
819 | 0 | { |
820 | 0 | aStyleName.emplace((*pValues).get<OUString>()); |
821 | 0 | } |
822 | 2.55M | else if( (nPara == -1) && !bParaAttrib ) |
823 | 2.27M | { |
824 | 2.27M | if( !pNewAttrSet ) |
825 | 107k | { |
826 | 107k | pOldAttrSet.emplace( pForwarder->GetAttribs( aSel ) ); |
827 | 107k | pNewAttrSet.emplace( *pOldAttrSet->GetPool(), pOldAttrSet->GetRanges() ); |
828 | 107k | } |
829 | | |
830 | 2.27M | setPropertyValue( pMap, *pValues, GetSelection(), *pOldAttrSet, *pNewAttrSet ); |
831 | | |
832 | 2.27M | if( pMap->nWID >= EE_ITEMS_START && pMap->nWID <= EE_ITEMS_END ) |
833 | 2.27M | { |
834 | 2.27M | const SfxPoolItem* pItem; |
835 | 2.27M | if( pNewAttrSet->GetItemState( pMap->nWID, true, &pItem ) == SfxItemState::SET ) |
836 | 2.27M | { |
837 | 2.27M | pOldAttrSet->Put( *pItem ); |
838 | 2.27M | } |
839 | 2.27M | } |
840 | 2.27M | } |
841 | 272k | else |
842 | 272k | { |
843 | 272k | if( !pNewParaSet ) |
844 | 50.4k | { |
845 | 50.4k | pOldParaSet.emplace( pForwarder->GetParaAttribs( nTempPara ) ); |
846 | 50.4k | pNewParaSet.emplace( *pOldParaSet->GetPool(), pOldParaSet->GetRanges() ); |
847 | 50.4k | } |
848 | | |
849 | 272k | setPropertyValue( pMap, *pValues, GetSelection(), *pOldParaSet, *pNewParaSet ); |
850 | | |
851 | 272k | if( pMap->nWID >= EE_ITEMS_START && pMap->nWID <= EE_ITEMS_END ) |
852 | 272k | { |
853 | 272k | const SfxPoolItem* pItem; |
854 | 272k | if( pNewParaSet->GetItemState( pMap->nWID, true, &pItem ) == SfxItemState::SET ) |
855 | 272k | { |
856 | 272k | pOldParaSet->Put( *pItem ); |
857 | 272k | } |
858 | 272k | } |
859 | | |
860 | 272k | } |
861 | 2.55M | } |
862 | 2.57M | } |
863 | | |
864 | 162k | bool bNeedsUpdate = false; |
865 | | |
866 | 162k | if( pNewParaSet || aStyleName ) |
867 | 50.4k | { |
868 | 50.4k | if( pNewParaSet->Count() ) |
869 | 50.4k | { |
870 | 100k | while( nTempPara <= nEndPara ) |
871 | 50.4k | { |
872 | 50.4k | SfxItemSet aSet( pForwarder->GetParaAttribs( nTempPara ) ); |
873 | 50.4k | aSet.Put( *pNewParaSet ); |
874 | 50.4k | pForwarder->SetParaAttribs( nTempPara, aSet ); |
875 | 50.4k | if (aStyleName) |
876 | 0 | pForwarder->SetStyleSheet(nTempPara, *aStyleName); |
877 | 50.4k | nTempPara++; |
878 | 50.4k | } |
879 | 50.4k | bNeedsUpdate = true; |
880 | 50.4k | } |
881 | | |
882 | 50.4k | pNewParaSet.reset(); |
883 | 50.4k | pOldParaSet.reset(); |
884 | 50.4k | } |
885 | | |
886 | 162k | if( pNewAttrSet ) |
887 | 107k | { |
888 | 107k | if( pNewAttrSet->Count() ) |
889 | 107k | { |
890 | 107k | pForwarder->QuickSetAttribs( *pNewAttrSet, GetSelection() ); |
891 | 107k | bNeedsUpdate = true; |
892 | 107k | } |
893 | 107k | pNewAttrSet.reset(); |
894 | 107k | pOldAttrSet.reset(); |
895 | 107k | } |
896 | | |
897 | 162k | if( bNeedsUpdate ) |
898 | 158k | GetEditSource()->UpdateData(); |
899 | 162k | } |
900 | | |
901 | | uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::getPropertyValues( const uno::Sequence< OUString >& aPropertyNames ) |
902 | 0 | { |
903 | 0 | return _getPropertyValues( aPropertyNames ); |
904 | 0 | } |
905 | | |
906 | | uno::Sequence< uno::Any > SvxUnoTextRangeBase::_getPropertyValues( const uno::Sequence< OUString >& aPropertyNames, sal_Int32 nPara ) |
907 | 4.32k | { |
908 | 4.32k | SolarMutexGuard aGuard; |
909 | | |
910 | 4.32k | sal_Int32 nCount = aPropertyNames.getLength(); |
911 | | |
912 | | |
913 | 4.32k | uno::Sequence< uno::Any > aValues( nCount ); |
914 | | |
915 | 4.32k | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
916 | 4.32k | if( pForwarder ) |
917 | 4.32k | { |
918 | 4.32k | std::optional<SfxItemSet> oAttribs; |
919 | 4.32k | if( nPara != -1 ) |
920 | 4.32k | oAttribs.emplace(pForwarder->GetParaAttribs( nPara )); |
921 | 0 | else |
922 | 0 | oAttribs.emplace(pForwarder->GetAttribs( GetSelection() )); |
923 | | |
924 | 4.32k | oAttribs->ClearInvalidItems(); |
925 | | |
926 | 4.32k | const OUString* pPropertyNames = aPropertyNames.getConstArray(); |
927 | 4.32k | uno::Any* pValues = aValues.getArray(); |
928 | | |
929 | 70.3k | for( ; nCount; nCount--, pPropertyNames++, pValues++ ) |
930 | 66.0k | { |
931 | 66.0k | const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry( *pPropertyNames ); |
932 | 66.0k | if( pMap ) |
933 | 66.0k | { |
934 | 66.0k | getPropertyValue( pMap, *pValues, *oAttribs ); |
935 | 66.0k | } |
936 | 66.0k | } |
937 | 4.32k | } |
938 | | |
939 | 4.32k | return aValues; |
940 | 4.32k | } |
941 | | |
942 | | void SAL_CALL SvxUnoTextRangeBase::addPropertiesChangeListener( const uno::Sequence< OUString >& , const uno::Reference< beans::XPropertiesChangeListener >& ) |
943 | 0 | { |
944 | 0 | } |
945 | | |
946 | | void SAL_CALL SvxUnoTextRangeBase::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& ) |
947 | 0 | { |
948 | 0 | } |
949 | | |
950 | | void SAL_CALL SvxUnoTextRangeBase::firePropertiesChangeEvent( const uno::Sequence< OUString >& , const uno::Reference< beans::XPropertiesChangeListener >& ) |
951 | 0 | { |
952 | 0 | } |
953 | | |
954 | | // beans::XPropertyState |
955 | | beans::PropertyState SAL_CALL SvxUnoTextRangeBase::getPropertyState( const OUString& PropertyName ) |
956 | 0 | { |
957 | 0 | return _getPropertyState( PropertyName ); |
958 | 0 | } |
959 | | |
960 | | const sal_uInt16 aSvxUnoFontDescriptorWhichMap[] = { EE_CHAR_FONTINFO, EE_CHAR_FONTHEIGHT, EE_CHAR_ITALIC, |
961 | | EE_CHAR_UNDERLINE, EE_CHAR_WEIGHT, EE_CHAR_STRIKEOUT, EE_CHAR_CASEMAP, |
962 | | EE_CHAR_WLM, 0 }; |
963 | | |
964 | | beans::PropertyState SvxUnoTextRangeBase::_getPropertyState(const SfxItemPropertyMapEntry* pMap, sal_Int32 nPara) |
965 | 0 | { |
966 | 0 | if ( pMap ) |
967 | 0 | { |
968 | 0 | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
969 | 0 | if( pForwarder ) |
970 | 0 | { |
971 | 0 | SfxItemState eItemState(SfxItemState::DEFAULT); |
972 | 0 | bool bItemStateSet(false); |
973 | |
|
974 | 0 | switch( pMap->nWID ) |
975 | 0 | { |
976 | 0 | case WID_FONTDESC: |
977 | 0 | { |
978 | 0 | const sal_uInt16* pWhichId = aSvxUnoFontDescriptorWhichMap; |
979 | 0 | while( *pWhichId ) |
980 | 0 | { |
981 | 0 | const SfxItemState eTempItemState(nPara != -1 |
982 | 0 | ? pForwarder->GetItemState( nPara, *pWhichId ) |
983 | 0 | : pForwarder->GetItemState( GetSelection(), *pWhichId )); |
984 | |
|
985 | 0 | switch( eTempItemState ) |
986 | 0 | { |
987 | 0 | case SfxItemState::DISABLED: |
988 | 0 | case SfxItemState::INVALID: |
989 | 0 | eItemState = SfxItemState::INVALID; |
990 | 0 | bItemStateSet = true; |
991 | 0 | break; |
992 | | |
993 | 0 | case SfxItemState::DEFAULT: |
994 | 0 | if( !bItemStateSet ) |
995 | 0 | { |
996 | 0 | eItemState = SfxItemState::DEFAULT; |
997 | 0 | bItemStateSet = true; |
998 | 0 | } |
999 | 0 | break; |
1000 | | |
1001 | 0 | case SfxItemState::SET: |
1002 | 0 | if( !bItemStateSet ) |
1003 | 0 | { |
1004 | 0 | eItemState = SfxItemState::SET; |
1005 | 0 | bItemStateSet = true; |
1006 | 0 | } |
1007 | 0 | break; |
1008 | 0 | default: |
1009 | 0 | throw beans::UnknownPropertyException(); |
1010 | 0 | } |
1011 | | |
1012 | 0 | pWhichId++; |
1013 | 0 | } |
1014 | 0 | } |
1015 | 0 | break; |
1016 | | |
1017 | 0 | case WID_NUMBERINGSTARTVALUE: |
1018 | 0 | case WID_PARAISNUMBERINGRESTART: |
1019 | 0 | case WID_PARASTYLENAME: |
1020 | 0 | eItemState = SfxItemState::SET; |
1021 | 0 | bItemStateSet = true; |
1022 | 0 | break; |
1023 | | |
1024 | 0 | default: |
1025 | 0 | if(0 != pMap->nWID) |
1026 | 0 | { |
1027 | 0 | if( nPara != -1 ) |
1028 | 0 | eItemState = pForwarder->GetItemState( nPara, pMap->nWID ); |
1029 | 0 | else |
1030 | 0 | eItemState = pForwarder->GetItemState( GetSelection(), pMap->nWID ); |
1031 | |
|
1032 | 0 | bItemStateSet = true; |
1033 | 0 | } |
1034 | 0 | break; |
1035 | 0 | } |
1036 | | |
1037 | 0 | if(bItemStateSet) |
1038 | 0 | { |
1039 | 0 | switch( eItemState ) |
1040 | 0 | { |
1041 | 0 | case SfxItemState::INVALID: |
1042 | 0 | case SfxItemState::DISABLED: |
1043 | 0 | return beans::PropertyState_AMBIGUOUS_VALUE; |
1044 | 0 | case SfxItemState::SET: |
1045 | 0 | return beans::PropertyState_DIRECT_VALUE; |
1046 | 0 | case SfxItemState::DEFAULT: |
1047 | 0 | return beans::PropertyState_DEFAULT_VALUE; |
1048 | 0 | default: break; |
1049 | 0 | } |
1050 | 0 | } |
1051 | 0 | } |
1052 | 0 | } |
1053 | 0 | throw beans::UnknownPropertyException(); |
1054 | 0 | } |
1055 | | |
1056 | | beans::PropertyState SvxUnoTextRangeBase::_getPropertyState(std::u16string_view PropertyName, sal_Int32 nPara /* = -1 */) |
1057 | 0 | { |
1058 | 0 | SolarMutexGuard aGuard; |
1059 | |
|
1060 | 0 | return _getPropertyState( mpPropSet->getPropertyMapEntry( PropertyName ), nPara); |
1061 | 0 | } |
1062 | | |
1063 | | uno::Sequence< beans::PropertyState > SAL_CALL SvxUnoTextRangeBase::getPropertyStates( const uno::Sequence< OUString >& aPropertyName ) |
1064 | 4.65k | { |
1065 | 4.65k | return _getPropertyStates( aPropertyName ); |
1066 | 4.65k | } |
1067 | | |
1068 | | uno::Sequence< beans::PropertyState > SvxUnoTextRangeBase::_getPropertyStates(const uno::Sequence< OUString >& PropertyName, sal_Int32 nPara /* = -1 */) |
1069 | 9.26k | { |
1070 | 9.26k | uno::Sequence< beans::PropertyState > aRet( PropertyName.getLength() ); |
1071 | | |
1072 | 9.26k | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
1073 | 9.26k | if( pForwarder ) |
1074 | 9.26k | { |
1075 | 9.26k | std::optional<SfxItemSet> pSet; |
1076 | 9.26k | if( nPara != -1 ) |
1077 | 4.61k | { |
1078 | 4.61k | pSet.emplace( pForwarder->GetParaAttribs( nPara ) ); |
1079 | 4.61k | } |
1080 | 4.65k | else |
1081 | 4.65k | { |
1082 | 4.65k | ESelection aSel( GetSelection() ); |
1083 | 4.65k | CheckSelection( aSel, pForwarder ); |
1084 | 4.65k | pSet.emplace( pForwarder->GetAttribs( aSel, EditEngineAttribs::OnlyHard ) ); |
1085 | 4.65k | } |
1086 | | |
1087 | 9.26k | beans::PropertyState* pState = aRet.getArray(); |
1088 | 9.26k | for( const OUString& rName : PropertyName ) |
1089 | 671k | { |
1090 | 671k | const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry( rName ); |
1091 | 671k | if( !_getOnePropertyStates(*pSet, pMap, *pState++) ) |
1092 | 0 | { |
1093 | 0 | throw beans::UnknownPropertyException(rName); |
1094 | 0 | } |
1095 | 671k | } |
1096 | 9.26k | } |
1097 | | |
1098 | 9.26k | return aRet; |
1099 | 9.26k | } |
1100 | | |
1101 | | bool SvxUnoTextRangeBase::_getOnePropertyStates(const SfxItemSet& rSet, const SfxItemPropertyMapEntry* pMap, beans::PropertyState& rState) |
1102 | 671k | { |
1103 | 671k | if (!pMap) |
1104 | 0 | return true; |
1105 | 671k | SfxItemState eItemState = SfxItemState::DEFAULT; |
1106 | 671k | bool bItemStateSet(false); |
1107 | | |
1108 | 671k | bool bUnknownPropertyFound = false; |
1109 | 671k | switch( pMap->nWID ) |
1110 | 671k | { |
1111 | 0 | case WID_FONTDESC: |
1112 | 0 | { |
1113 | 0 | const sal_uInt16* pWhichId = aSvxUnoFontDescriptorWhichMap; |
1114 | 0 | while( *pWhichId ) |
1115 | 0 | { |
1116 | 0 | const SfxItemState eTempItemState(rSet.GetItemState( *pWhichId )); |
1117 | |
|
1118 | 0 | switch( eTempItemState ) |
1119 | 0 | { |
1120 | 0 | case SfxItemState::DISABLED: |
1121 | 0 | case SfxItemState::INVALID: |
1122 | 0 | eItemState = SfxItemState::INVALID; |
1123 | 0 | bItemStateSet = true; |
1124 | 0 | break; |
1125 | | |
1126 | 0 | case SfxItemState::DEFAULT: |
1127 | 0 | if( !bItemStateSet ) |
1128 | 0 | { |
1129 | 0 | eItemState = SfxItemState::DEFAULT; |
1130 | 0 | bItemStateSet = true; |
1131 | 0 | } |
1132 | 0 | break; |
1133 | | |
1134 | 0 | case SfxItemState::SET: |
1135 | 0 | if( !bItemStateSet ) |
1136 | 0 | { |
1137 | 0 | eItemState = SfxItemState::SET; |
1138 | 0 | bItemStateSet = true; |
1139 | 0 | } |
1140 | 0 | break; |
1141 | 0 | default: |
1142 | 0 | bUnknownPropertyFound = true; |
1143 | 0 | break; |
1144 | 0 | } |
1145 | | |
1146 | 0 | pWhichId++; |
1147 | 0 | } |
1148 | 0 | } |
1149 | 0 | break; |
1150 | | |
1151 | 0 | case WID_NUMBERINGSTARTVALUE: |
1152 | 0 | case WID_PARAISNUMBERINGRESTART: |
1153 | 0 | case WID_PARASTYLENAME: |
1154 | 0 | eItemState = SfxItemState::SET; |
1155 | 0 | bItemStateSet = true; |
1156 | 0 | break; |
1157 | | |
1158 | 671k | default: |
1159 | 671k | if(0 != pMap->nWID) |
1160 | 671k | { |
1161 | 671k | eItemState = rSet.GetItemState( pMap->nWID, false ); |
1162 | 671k | bItemStateSet = true; |
1163 | 671k | } |
1164 | 671k | break; |
1165 | 671k | } |
1166 | | |
1167 | 671k | if( bUnknownPropertyFound ) |
1168 | 0 | return false; |
1169 | | |
1170 | 671k | if(bItemStateSet) |
1171 | 671k | { |
1172 | 671k | if (pMap->nWID == EE_CHAR_COLOR) |
1173 | 27.8k | { |
1174 | | // Theme & effects can be DEFAULT_VALUE, even if the same pool item has a color |
1175 | | // which is a DIRECT_VALUE. |
1176 | 27.8k | const SvxColorItem* pColor = rSet.GetItem<SvxColorItem>(EE_CHAR_COLOR); |
1177 | 27.8k | if (!pColor) |
1178 | 0 | { |
1179 | 0 | SAL_WARN("editeng", "Missing EE_CHAR_COLOR SvxColorItem"); |
1180 | 0 | return false; |
1181 | 0 | } |
1182 | 27.8k | switch (pMap->nMemberId) |
1183 | 27.8k | { |
1184 | 0 | case MID_COLOR_THEME_INDEX: |
1185 | 0 | if (!pColor->getComplexColor().isValidThemeType()) |
1186 | 0 | { |
1187 | 0 | eItemState = SfxItemState::DEFAULT; |
1188 | 0 | } |
1189 | 0 | break; |
1190 | 0 | case MID_COLOR_LUM_MOD: |
1191 | 0 | { |
1192 | 0 | sal_Int16 nLumMod = 10000; |
1193 | 0 | for (auto const& rTransform : pColor->getComplexColor().getTransformations()) |
1194 | 0 | { |
1195 | 0 | if (rTransform.meType == model::TransformationType::LumMod) |
1196 | 0 | nLumMod = rTransform.mnValue; |
1197 | 0 | } |
1198 | 0 | if (nLumMod == 10000) |
1199 | 0 | { |
1200 | 0 | eItemState = SfxItemState::DEFAULT; |
1201 | 0 | } |
1202 | 0 | break; |
1203 | 0 | } |
1204 | 0 | case MID_COLOR_LUM_OFF: |
1205 | 0 | { |
1206 | 0 | sal_Int16 nLumOff = 0; |
1207 | 0 | for (auto const& rTransform : pColor->getComplexColor().getTransformations()) |
1208 | 0 | { |
1209 | 0 | if (rTransform.meType == model::TransformationType::LumOff) |
1210 | 0 | nLumOff = rTransform.mnValue; |
1211 | 0 | } |
1212 | 0 | if (nLumOff == 0) |
1213 | 0 | { |
1214 | 0 | eItemState = SfxItemState::DEFAULT; |
1215 | 0 | } |
1216 | 0 | break; |
1217 | 0 | } |
1218 | 9.26k | case MID_COMPLEX_COLOR: |
1219 | 9.26k | if (pColor->getComplexColor().getType() == model::ColorType::Unused) |
1220 | 9.26k | { |
1221 | 9.26k | eItemState = SfxItemState::DEFAULT; |
1222 | 9.26k | } |
1223 | 9.26k | break; |
1224 | 27.8k | } |
1225 | 27.8k | } |
1226 | | |
1227 | 671k | switch( eItemState ) |
1228 | 671k | { |
1229 | 63.6k | case SfxItemState::SET: |
1230 | 63.6k | rState = beans::PropertyState_DIRECT_VALUE; |
1231 | 63.6k | break; |
1232 | 607k | case SfxItemState::DEFAULT: |
1233 | 607k | rState = beans::PropertyState_DEFAULT_VALUE; |
1234 | 607k | break; |
1235 | | // case SfxItemState::INVALID: |
1236 | | // case SfxItemState::DISABLED: |
1237 | 0 | default: |
1238 | 0 | rState = beans::PropertyState_AMBIGUOUS_VALUE; |
1239 | 671k | } |
1240 | 671k | } |
1241 | 0 | else |
1242 | 0 | { |
1243 | 0 | rState = beans::PropertyState_AMBIGUOUS_VALUE; |
1244 | 0 | } |
1245 | 671k | return true; |
1246 | 671k | } |
1247 | | |
1248 | | void SAL_CALL SvxUnoTextRangeBase::setPropertyToDefault( const OUString& PropertyName ) |
1249 | 0 | { |
1250 | 0 | _setPropertyToDefault( PropertyName ); |
1251 | 0 | } |
1252 | | |
1253 | | void SvxUnoTextRangeBase::_setPropertyToDefault(const OUString& PropertyName, sal_Int32 nPara /* = -1 */) |
1254 | 0 | { |
1255 | 0 | SolarMutexGuard aGuard; |
1256 | |
|
1257 | 0 | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
1258 | |
|
1259 | 0 | if( pForwarder ) |
1260 | 0 | { |
1261 | 0 | const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry( PropertyName ); |
1262 | 0 | if ( pMap ) |
1263 | 0 | { |
1264 | 0 | CheckSelection( maSelection, mpEditSource->GetTextForwarder() ); |
1265 | 0 | _setPropertyToDefault( pForwarder, pMap, nPara ); |
1266 | 0 | return; |
1267 | 0 | } |
1268 | 0 | } |
1269 | | |
1270 | 0 | throw beans::UnknownPropertyException(PropertyName); |
1271 | 0 | } |
1272 | | |
1273 | | void SvxUnoTextRangeBase::_setPropertyToDefault(SvxTextForwarder* pForwarder, const SfxItemPropertyMapEntry* pMap, sal_Int32 nPara ) |
1274 | 0 | { |
1275 | 0 | do |
1276 | 0 | { |
1277 | 0 | SfxItemSet aSet(*pForwarder->GetPool()); |
1278 | |
|
1279 | 0 | if( pMap->nWID == WID_FONTDESC ) |
1280 | 0 | { |
1281 | 0 | SvxUnoFontDescriptor::setPropertyToDefault( aSet ); |
1282 | 0 | } |
1283 | 0 | else if( pMap->nWID == WID_NUMBERINGSTARTVALUE ) |
1284 | 0 | { |
1285 | 0 | pForwarder->SetNumberingStartValue(maSelection.start.nPara, -1); |
1286 | 0 | } |
1287 | 0 | else if( pMap->nWID == WID_PARAISNUMBERINGRESTART ) |
1288 | 0 | { |
1289 | 0 | pForwarder->SetParaIsNumberingRestart(maSelection.start.nPara, false); |
1290 | 0 | } |
1291 | 0 | else |
1292 | 0 | { |
1293 | 0 | aSet.InvalidateItem( pMap->nWID ); |
1294 | 0 | } |
1295 | |
|
1296 | 0 | if(nPara != -1) |
1297 | 0 | pForwarder->SetParaAttribs( nPara, aSet ); |
1298 | 0 | else |
1299 | 0 | pForwarder->QuickSetAttribs( aSet, GetSelection() ); |
1300 | |
|
1301 | 0 | GetEditSource()->UpdateData(); |
1302 | |
|
1303 | 0 | return; |
1304 | 0 | } |
1305 | 0 | while(false); |
1306 | 0 | } |
1307 | | |
1308 | | uno::Any SAL_CALL SvxUnoTextRangeBase::getPropertyDefault( const OUString& aPropertyName ) |
1309 | 211k | { |
1310 | 211k | SolarMutexGuard aGuard; |
1311 | | |
1312 | 211k | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
1313 | 211k | if( pForwarder ) |
1314 | 211k | { |
1315 | 211k | const SfxItemPropertyMapEntry* pMap = mpPropSet->getPropertyMapEntry( aPropertyName ); |
1316 | 211k | if( pMap ) |
1317 | 211k | { |
1318 | 211k | SfxItemPool* pPool = pForwarder->GetPool(); |
1319 | | |
1320 | 211k | switch( pMap->nWID ) |
1321 | 211k | { |
1322 | 0 | case WID_FONTDESC: |
1323 | 0 | return SvxUnoFontDescriptor::getPropertyDefault( pPool ); |
1324 | | |
1325 | 0 | case EE_PARA_OUTLLEVEL: |
1326 | 0 | { |
1327 | 0 | uno::Any aAny; |
1328 | 0 | return aAny; |
1329 | 0 | } |
1330 | | |
1331 | 0 | case WID_NUMBERINGSTARTVALUE: |
1332 | 0 | return uno::Any( sal_Int16(-1) ); |
1333 | | |
1334 | 0 | case WID_PARAISNUMBERINGRESTART: |
1335 | 0 | return uno::Any( false ); |
1336 | | |
1337 | 211k | default: |
1338 | 211k | { |
1339 | | // Get Default from ItemPool |
1340 | 211k | if(SfxItemPool::IsWhich(pMap->nWID)) |
1341 | 211k | { |
1342 | 211k | SfxItemSet aSet( *pPool, pMap->nWID, pMap->nWID ); |
1343 | 211k | aSet.Put(pPool->GetUserOrPoolDefaultItem(pMap->nWID)); |
1344 | 211k | return SvxItemPropertySet::getPropertyValue(pMap, aSet, true, false ); |
1345 | 211k | } |
1346 | 211k | } |
1347 | 211k | } |
1348 | 211k | } |
1349 | 211k | } |
1350 | 0 | throw beans::UnknownPropertyException(aPropertyName); |
1351 | 211k | } |
1352 | | |
1353 | | // beans::XMultiPropertyStates |
1354 | | void SAL_CALL SvxUnoTextRangeBase::setAllPropertiesToDefault() |
1355 | 0 | { |
1356 | 0 | SolarMutexGuard aGuard; |
1357 | |
|
1358 | 0 | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
1359 | |
|
1360 | 0 | if( pForwarder ) |
1361 | 0 | { |
1362 | 0 | for (const SfxItemPropertyMapEntry* entry : mpPropSet->getPropertyMap().getPropertyEntries()) |
1363 | 0 | { |
1364 | 0 | _setPropertyToDefault( pForwarder, entry, -1 ); |
1365 | 0 | } |
1366 | 0 | } |
1367 | 0 | } |
1368 | | |
1369 | | void SAL_CALL SvxUnoTextRangeBase::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames ) |
1370 | 0 | { |
1371 | 0 | for( const OUString& rName : aPropertyNames ) |
1372 | 0 | { |
1373 | 0 | setPropertyToDefault( rName ); |
1374 | 0 | } |
1375 | 0 | } |
1376 | | |
1377 | | uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames ) |
1378 | 0 | { |
1379 | 0 | uno::Sequence< uno::Any > ret( aPropertyNames.getLength() ); |
1380 | 0 | uno::Any* pDefaults = ret.getArray(); |
1381 | |
|
1382 | 0 | for( const OUString& rName : aPropertyNames ) |
1383 | 0 | { |
1384 | 0 | *pDefaults++ = getPropertyDefault( rName ); |
1385 | 0 | } |
1386 | |
|
1387 | 0 | return ret; |
1388 | 0 | } |
1389 | | |
1390 | | // internal |
1391 | | void SvxUnoTextRangeBase::CollapseToStart() noexcept |
1392 | 281k | { |
1393 | 281k | CheckSelection( maSelection, mpEditSource.get() ); |
1394 | | |
1395 | 281k | maSelection.CollapseToStart(); |
1396 | 281k | } |
1397 | | |
1398 | | void SvxUnoTextRangeBase::CollapseToEnd() noexcept |
1399 | 224k | { |
1400 | 224k | CheckSelection( maSelection, mpEditSource.get() ); |
1401 | | |
1402 | 224k | maSelection.CollapseToEnd(); |
1403 | 224k | } |
1404 | | |
1405 | | bool SvxUnoTextRangeBase::IsCollapsed() noexcept |
1406 | 4.11k | { |
1407 | 4.11k | CheckSelection( maSelection, mpEditSource.get() ); |
1408 | | |
1409 | 4.11k | return !maSelection.HasRange(); |
1410 | 4.11k | } |
1411 | | |
1412 | | bool SvxUnoTextRangeBase::GoLeft(sal_Int32 nCount, bool Expand) noexcept |
1413 | 6.63k | { |
1414 | 6.63k | CheckSelection( maSelection, mpEditSource.get() ); |
1415 | | |
1416 | | // #75098# use end position, as in Writer (start is anchor, end is cursor) |
1417 | 6.63k | sal_Int32 nNewPos = maSelection.end.nIndex; |
1418 | 6.63k | sal_Int32 nNewPar = maSelection.end.nPara; |
1419 | | |
1420 | 6.63k | bool bOk = true; |
1421 | 6.63k | SvxTextForwarder* pForwarder = nullptr; |
1422 | 13.2k | while ( nCount > nNewPos && bOk ) |
1423 | 6.58k | { |
1424 | 6.58k | if ( nNewPar == 0 ) |
1425 | 1.77k | bOk = false; |
1426 | 4.81k | else |
1427 | 4.81k | { |
1428 | 4.81k | if ( !pForwarder ) |
1429 | 4.81k | pForwarder = mpEditSource->GetTextForwarder(); // first here, it is necessary... |
1430 | 4.81k | assert(pForwarder); |
1431 | 4.81k | --nNewPar; |
1432 | 4.81k | nCount -= nNewPos + 1; |
1433 | 4.81k | nNewPos = pForwarder->GetTextLen( nNewPar ); |
1434 | 4.81k | } |
1435 | 6.58k | } |
1436 | | |
1437 | 6.63k | if ( bOk ) |
1438 | 4.85k | { |
1439 | 4.85k | nNewPos = nNewPos - nCount; |
1440 | 4.85k | maSelection.start.nPara = nNewPar; |
1441 | 4.85k | maSelection.start.nIndex = nNewPos; |
1442 | 4.85k | } |
1443 | | |
1444 | 6.63k | if (!Expand) |
1445 | 10 | CollapseToStart(); |
1446 | | |
1447 | 6.63k | return bOk; |
1448 | 6.63k | } |
1449 | | |
1450 | | bool SvxUnoTextRangeBase::GoRight(sal_Int32 nCount, bool Expand) noexcept |
1451 | 212k | { |
1452 | 212k | if (!mpEditSource) |
1453 | 0 | return false; |
1454 | 212k | SvxTextForwarder* pForwarder = mpEditSource->GetTextForwarder(); |
1455 | 212k | if( !pForwarder ) |
1456 | 0 | return false; |
1457 | | |
1458 | 212k | CheckSelection( maSelection, pForwarder ); |
1459 | | |
1460 | 212k | sal_Int32 nNewPos = maSelection.end.nIndex + nCount; |
1461 | 212k | sal_Int32 nNewPar = maSelection.end.nPara; |
1462 | | |
1463 | 212k | bool bOk = true; |
1464 | 212k | sal_Int32 nParCount = pForwarder->GetParagraphCount(); |
1465 | 212k | sal_Int32 nThisLen = pForwarder->GetTextLen( nNewPar ); |
1466 | 317k | while ( nNewPos > nThisLen && bOk ) |
1467 | 104k | { |
1468 | 104k | if ( nNewPar + 1 >= nParCount ) |
1469 | 0 | bOk = false; |
1470 | 104k | else |
1471 | 104k | { |
1472 | 104k | nNewPos -= nThisLen+1; |
1473 | 104k | ++nNewPar; |
1474 | 104k | nThisLen = pForwarder->GetTextLen( nNewPar ); |
1475 | 104k | } |
1476 | 104k | } |
1477 | | |
1478 | 212k | if (bOk) |
1479 | 212k | { |
1480 | 212k | maSelection.end.nPara = nNewPar; |
1481 | 212k | maSelection.end.nIndex = nNewPos; |
1482 | 212k | } |
1483 | | |
1484 | 212k | if (!Expand) |
1485 | 0 | CollapseToEnd(); |
1486 | | |
1487 | 212k | return bOk; |
1488 | 212k | } |
1489 | | |
1490 | | void SvxUnoTextRangeBase::GotoStart(bool Expand) noexcept |
1491 | 2.92k | { |
1492 | 2.92k | maSelection.start.nPara = 0; |
1493 | 2.92k | maSelection.start.nIndex = 0; |
1494 | | |
1495 | 2.92k | if (!Expand) |
1496 | 0 | CollapseToStart(); |
1497 | 2.92k | } |
1498 | | |
1499 | | void SvxUnoTextRangeBase::GotoEnd(bool Expand) noexcept |
1500 | 97.9k | { |
1501 | 97.9k | CheckSelection( maSelection, mpEditSource.get() ); |
1502 | | |
1503 | 97.9k | SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr; |
1504 | 97.9k | if( !pForwarder ) |
1505 | 8 | return; |
1506 | | |
1507 | 97.9k | sal_Int32 nPar = pForwarder->GetParagraphCount(); |
1508 | 97.9k | if (nPar) |
1509 | 97.9k | --nPar; |
1510 | | |
1511 | 97.9k | maSelection.end.nPara = nPar; |
1512 | 97.9k | maSelection.end.nIndex = pForwarder->GetTextLen(nPar); |
1513 | | |
1514 | 97.9k | if (!Expand) |
1515 | 14.4k | CollapseToEnd(); |
1516 | 97.9k | } |
1517 | | |
1518 | | // lang::XServiceInfo |
1519 | | sal_Bool SAL_CALL SvxUnoTextRangeBase::supportsService( const OUString& ServiceName ) |
1520 | 4.61k | { |
1521 | 4.61k | return cppu::supportsService( this, ServiceName ); |
1522 | 4.61k | } |
1523 | | |
1524 | | uno::Sequence< OUString > SAL_CALL SvxUnoTextRangeBase::getSupportedServiceNames() |
1525 | 4.61k | { |
1526 | 4.61k | return getSupportedServiceNames_Static(); |
1527 | 4.61k | } |
1528 | | |
1529 | | uno::Sequence< OUString > SvxUnoTextRangeBase::getSupportedServiceNames_Static() |
1530 | 4.61k | { |
1531 | 4.61k | return { u"com.sun.star.style.CharacterProperties"_ustr, |
1532 | 4.61k | u"com.sun.star.style.CharacterPropertiesComplex"_ustr, |
1533 | 4.61k | u"com.sun.star.style.CharacterPropertiesAsian"_ustr }; |
1534 | 4.61k | } |
1535 | | |
1536 | | // XTextRangeCompare |
1537 | | sal_Int16 SAL_CALL SvxUnoTextRangeBase::compareRegionStarts( const uno::Reference< text::XTextRange >& xR1, const uno::Reference< text::XTextRange >& xR2 ) |
1538 | 4.81k | { |
1539 | 4.81k | SvxUnoTextRangeBase* pR1 = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( xR1 ); |
1540 | 4.81k | SvxUnoTextRangeBase* pR2 = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( xR2 ); |
1541 | | |
1542 | 4.81k | if( (pR1 == nullptr) || (pR2 == nullptr) ) |
1543 | 0 | throw lang::IllegalArgumentException(); |
1544 | | |
1545 | 4.81k | const ESelection& r1 = pR1->maSelection; |
1546 | 4.81k | const ESelection& r2 = pR2->maSelection; |
1547 | | |
1548 | 4.81k | return r1.start == r2.start ? 0 : r1.start < r2.start ? 1 : -1; |
1549 | 4.81k | } |
1550 | | |
1551 | | sal_Int16 SAL_CALL SvxUnoTextRangeBase::compareRegionEnds( const uno::Reference< text::XTextRange >& xR1, const uno::Reference< text::XTextRange >& xR2 ) |
1552 | 0 | { |
1553 | 0 | SvxUnoTextRangeBase* pR1 = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( xR1 ); |
1554 | 0 | SvxUnoTextRangeBase* pR2 = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( xR2 ); |
1555 | |
|
1556 | 0 | if( (pR1 == nullptr) || (pR2 == nullptr) ) |
1557 | 0 | throw lang::IllegalArgumentException(); |
1558 | | |
1559 | 0 | const ESelection& r1 = pR1->maSelection; |
1560 | 0 | const ESelection& r2 = pR2->maSelection; |
1561 | |
|
1562 | 0 | return r1.end == r2.end ? 0 : r1.end < r2.end ? 1 : -1; |
1563 | 0 | } |
1564 | | |
1565 | | SvxUnoTextRange::SvxUnoTextRange(const SvxUnoTextBase& rParent, bool bPortion /* = false */) |
1566 | 180k | :SvxUnoTextRangeBase( rParent.GetEditSource(), bPortion ? ImplGetSvxTextPortionSvxPropertySet() : rParent.getPropertySet() ), |
1567 | 180k | mbPortion( bPortion ) |
1568 | 180k | { |
1569 | 180k | xParentText = static_cast<text::XText*>(const_cast<SvxUnoTextBase *>(&rParent)); |
1570 | 180k | } |
1571 | | |
1572 | | SvxUnoTextRange::~SvxUnoTextRange() noexcept |
1573 | 180k | { |
1574 | 180k | } |
1575 | | |
1576 | | uno::Any SAL_CALL SvxUnoTextRange::queryAggregation( const uno::Type & rType ) |
1577 | 214k | { |
1578 | 214k | QUERYINT( text::XTextRange ); |
1579 | 210k | else if( rType == cppu::UnoType<beans::XMultiPropertyStates>::get()) |
1580 | 0 | return uno::Any(uno::Reference< beans::XMultiPropertyStates >(this)); |
1581 | 210k | else if( rType == cppu::UnoType<beans::XPropertySet>::get()) |
1582 | 23.6k | return uno::Any(uno::Reference< beans::XPropertySet >(this)); |
1583 | 186k | else QUERYINT( beans::XPropertyState ); |
1584 | 179k | else QUERYINT( text::XTextRangeCompare ); |
1585 | 179k | else if( rType == cppu::UnoType<beans::XMultiPropertySet>::get()) |
1586 | 17.5k | return uno::Any(uno::Reference< beans::XMultiPropertySet >(this)); |
1587 | 161k | else QUERYINT( lang::XServiceInfo ); |
1588 | 161k | else QUERYINT( lang::XTypeProvider ); |
1589 | 161k | else QUERYINT( lang::XUnoTunnel ); |
1590 | 5.06k | else |
1591 | 5.06k | return OWeakAggObject::queryAggregation( rType ); |
1592 | 214k | } |
1593 | | |
1594 | | uno::Any SAL_CALL SvxUnoTextRange::queryInterface( const uno::Type & rType ) |
1595 | 214k | { |
1596 | 214k | return OWeakAggObject::queryInterface(rType); |
1597 | 214k | } |
1598 | | |
1599 | | void SAL_CALL SvxUnoTextRange::acquire() |
1600 | | noexcept |
1601 | 842k | { |
1602 | 842k | OWeakAggObject::acquire(); |
1603 | 842k | } |
1604 | | |
1605 | | void SAL_CALL SvxUnoTextRange::release() |
1606 | | noexcept |
1607 | 842k | { |
1608 | 842k | OWeakAggObject::release(); |
1609 | 842k | } |
1610 | | |
1611 | | // XTypeProvider |
1612 | | |
1613 | | uno::Sequence< uno::Type > SAL_CALL SvxUnoTextRange::getTypes() |
1614 | 0 | { |
1615 | 0 | static const uno::Sequence< uno::Type > TYPES { |
1616 | 0 | cppu::UnoType<text::XTextRange>::get(), |
1617 | 0 | cppu::UnoType<beans::XPropertySet>::get(), |
1618 | 0 | cppu::UnoType<beans::XMultiPropertySet>::get(), |
1619 | 0 | cppu::UnoType<beans::XMultiPropertyStates>::get(), |
1620 | 0 | cppu::UnoType<beans::XPropertyState>::get(), |
1621 | 0 | cppu::UnoType<lang::XServiceInfo>::get(), |
1622 | 0 | cppu::UnoType<lang::XTypeProvider>::get(), |
1623 | 0 | cppu::UnoType<lang::XUnoTunnel>::get(), |
1624 | 0 | cppu::UnoType<text::XTextRangeCompare>::get() }; |
1625 | 0 | return TYPES; |
1626 | 0 | } |
1627 | | |
1628 | | uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextRange::getImplementationId() |
1629 | 0 | { |
1630 | 0 | return css::uno::Sequence<sal_Int8>(); |
1631 | 0 | } |
1632 | | |
1633 | | // XTextRange |
1634 | | uno::Reference< text::XText > SAL_CALL SvxUnoTextRange::getText() |
1635 | 1.07k | { |
1636 | 1.07k | return xParentText; |
1637 | 1.07k | } |
1638 | | |
1639 | | // lang::XServiceInfo |
1640 | | OUString SAL_CALL SvxUnoTextRange::getImplementationName() |
1641 | 0 | { |
1642 | 0 | return u"SvxUnoTextRange"_ustr; |
1643 | 0 | } |
1644 | | |
1645 | | |
1646 | | |
1647 | | |
1648 | | SvxUnoTextBase::SvxUnoTextBase(const SvxItemPropertySet* _pSet) |
1649 | 466k | : SvxUnoTextRangeBase(_pSet) |
1650 | 466k | { |
1651 | 466k | } |
1652 | | |
1653 | | SvxUnoTextBase::SvxUnoTextBase(const SvxEditSource* pSource, const SvxItemPropertySet* _pSet, uno::Reference < text::XText > const & xParent) |
1654 | 6.24k | : SvxUnoTextRangeBase(pSource, _pSet) |
1655 | 6.24k | { |
1656 | 6.24k | xParentText = xParent; |
1657 | 6.24k | ESelection aSelection; |
1658 | 6.24k | ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() ); |
1659 | 6.24k | SetSelection( aSelection ); |
1660 | 6.24k | } |
1661 | | |
1662 | | SvxUnoTextBase::SvxUnoTextBase(const SvxUnoTextBase& rText) |
1663 | 0 | : SvxUnoTextRangeBase( rText ) |
1664 | 0 | , text::XTextAppend() |
1665 | 0 | , text::XTextCopy() |
1666 | 0 | , container::XEnumerationAccess() |
1667 | 0 | , text::XTextRangeMover() |
1668 | 0 | , lang::XTypeProvider() |
1669 | 0 | { |
1670 | 0 | xParentText = rText.xParentText; |
1671 | 0 | } |
1672 | | |
1673 | | SvxUnoTextBase::~SvxUnoTextBase() noexcept |
1674 | 472k | { |
1675 | 472k | } |
1676 | | |
1677 | | // XInterface |
1678 | | uno::Any SAL_CALL SvxUnoTextBase::queryAggregation( const uno::Type & rType ) |
1679 | 315k | { |
1680 | 315k | QUERYINT( text::XText ); |
1681 | 238k | QUERYINT( text::XSimpleText ); |
1682 | 236k | if( rType == cppu::UnoType<text::XTextRange>::get()) |
1683 | 9.40k | return uno::Any(uno::Reference< text::XTextRange >(static_cast<text::XText*>(this))); |
1684 | 227k | QUERYINT(container::XEnumerationAccess ); |
1685 | 215k | QUERYINT( container::XElementAccess ); |
1686 | 215k | QUERYINT( beans::XMultiPropertyStates ); |
1687 | 215k | QUERYINT( beans::XPropertySet ); |
1688 | 179k | QUERYINT( beans::XMultiPropertySet ); |
1689 | 149k | QUERYINT( beans::XPropertyState ); |
1690 | 149k | QUERYINT( text::XTextRangeCompare ); |
1691 | 146k | QUERYINT( lang::XServiceInfo ); |
1692 | 146k | QUERYINT( text::XTextRangeMover ); |
1693 | 146k | QUERYINT( text::XTextCopy ); |
1694 | 146k | QUERYINT( text::XTextAppend ); |
1695 | 143k | QUERYINT( text::XParagraphAppend ); |
1696 | 143k | QUERYINT( text::XTextPortionAppend ); |
1697 | 143k | QUERYINT( lang::XTypeProvider ); |
1698 | 143k | QUERYINT( lang::XUnoTunnel ); |
1699 | | |
1700 | 142k | return uno::Any(); |
1701 | 143k | } |
1702 | | |
1703 | | // XTypeProvider |
1704 | | |
1705 | | uno::Sequence< uno::Type > SAL_CALL SvxUnoTextBase::getTypes() |
1706 | 0 | { |
1707 | 0 | static const uno::Sequence< uno::Type > TYPES { |
1708 | 0 | cppu::UnoType<text::XText>::get(), |
1709 | 0 | cppu::UnoType<container::XEnumerationAccess>::get(), |
1710 | 0 | cppu::UnoType<beans::XPropertySet>::get(), |
1711 | 0 | cppu::UnoType<beans::XMultiPropertySet>::get(), |
1712 | 0 | cppu::UnoType<beans::XMultiPropertyStates>::get(), |
1713 | 0 | cppu::UnoType<beans::XPropertyState>::get(), |
1714 | 0 | cppu::UnoType<text::XTextRangeMover>::get(), |
1715 | 0 | cppu::UnoType<text::XTextAppend>::get(), |
1716 | 0 | cppu::UnoType<text::XTextCopy>::get(), |
1717 | 0 | cppu::UnoType<text::XParagraphAppend>::get(), |
1718 | 0 | cppu::UnoType<text::XTextPortionAppend>::get(), |
1719 | 0 | cppu::UnoType<lang::XServiceInfo>::get(), |
1720 | 0 | cppu::UnoType<lang::XTypeProvider>::get(), |
1721 | 0 | cppu::UnoType<lang::XUnoTunnel>::get(), |
1722 | 0 | cppu::UnoType<text::XTextRangeCompare>::get() }; |
1723 | 0 | return TYPES; |
1724 | 0 | } |
1725 | | |
1726 | | uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextBase::getImplementationId() |
1727 | 0 | { |
1728 | 0 | return css::uno::Sequence<sal_Int8>(); |
1729 | 0 | } |
1730 | | |
1731 | | uno::Reference< text::XTextCursor > SvxUnoTextBase::createTextCursorBySelection( const ESelection& rSel ) |
1732 | 68.9k | { |
1733 | 68.9k | rtl::Reference<SvxUnoTextCursor> pCursor = new SvxUnoTextCursor( *this ); |
1734 | 68.9k | pCursor->SetSelection( rSel ); |
1735 | 68.9k | return pCursor; |
1736 | 68.9k | } |
1737 | | |
1738 | | // XSimpleText |
1739 | | |
1740 | | uno::Reference< text::XTextCursor > SAL_CALL SvxUnoTextBase::createTextCursor() |
1741 | 61.8k | { |
1742 | 61.8k | SolarMutexGuard aGuard; |
1743 | 61.8k | return new SvxUnoTextCursor( *this ); |
1744 | 61.8k | } |
1745 | | |
1746 | | uno::Reference< text::XTextCursor > SAL_CALL SvxUnoTextBase::createTextCursorByRange( const uno::Reference< text::XTextRange >& aTextPosition ) |
1747 | 69.3k | { |
1748 | 69.3k | SolarMutexGuard aGuard; |
1749 | | |
1750 | 69.3k | uno::Reference< text::XTextCursor > xCursor; |
1751 | | |
1752 | 69.3k | if( aTextPosition.is() ) |
1753 | 68.9k | { |
1754 | 68.9k | SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRangeBase>( aTextPosition ); |
1755 | 68.9k | if(pRange) |
1756 | 68.9k | xCursor = createTextCursorBySelection( pRange->GetSelection() ); |
1757 | 68.9k | } |
1758 | | |
1759 | 69.3k | return xCursor; |
1760 | 69.3k | } |
1761 | | |
1762 | | void SAL_CALL SvxUnoTextBase::insertString( const uno::Reference< text::XTextRange >& xRange, const OUString& aString, sal_Bool bAbsorb ) |
1763 | 104k | { |
1764 | 104k | SolarMutexGuard aGuard; |
1765 | | |
1766 | 104k | if( !xRange.is() ) |
1767 | 0 | return; |
1768 | | |
1769 | 104k | SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRange>( xRange ); |
1770 | 104k | if(!pRange) |
1771 | 0 | return; |
1772 | | |
1773 | | // setString on SvxUnoTextRangeBase instead of itself QuickInsertText |
1774 | | // and UpdateData, so that the selection will be adjusted to |
1775 | | // SvxUnoTextRangeBase. Actually all cursor objects of this Text must |
1776 | | // to be statement to be adapted! |
1777 | | |
1778 | 104k | if (!bAbsorb) // do not replace -> append on tail |
1779 | 104k | pRange->CollapseToEnd(); |
1780 | | |
1781 | 104k | pRange->setString( aString ); |
1782 | | |
1783 | 104k | pRange->CollapseToEnd(); |
1784 | | |
1785 | 104k | if (GetEditSource()) |
1786 | 102k | { |
1787 | | // Make the selection dynamic (whole text) instead of current text range |
1788 | 102k | maSelection = ESelection(EE_PARA_MAX, 0, 0, 0); |
1789 | 102k | } |
1790 | 104k | } |
1791 | | |
1792 | | void SAL_CALL SvxUnoTextBase::insertControlCharacter( const uno::Reference< text::XTextRange >& xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb ) |
1793 | 83.7k | { |
1794 | 83.7k | SolarMutexGuard aGuard; |
1795 | | |
1796 | 83.7k | SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : nullptr; |
1797 | | |
1798 | 83.7k | if( !pForwarder ) |
1799 | 319 | return; |
1800 | | |
1801 | 83.4k | ESelection aSelection; |
1802 | 83.4k | ::GetSelection( aSelection, pForwarder ); |
1803 | 83.4k | SetSelection( aSelection ); |
1804 | | |
1805 | 83.4k | switch( nControlCharacter ) |
1806 | 83.4k | { |
1807 | 0 | case text::ControlCharacter::PARAGRAPH_BREAK: |
1808 | 0 | { |
1809 | 0 | insertString( xRange, u"\x0D"_ustr, bAbsorb ); |
1810 | |
|
1811 | 0 | return; |
1812 | 0 | } |
1813 | 169 | case text::ControlCharacter::LINE_BREAK: |
1814 | 169 | { |
1815 | 169 | SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRange>( xRange ); |
1816 | 169 | if(pRange) |
1817 | 169 | { |
1818 | 169 | ESelection aRange = pRange->GetSelection(); |
1819 | | |
1820 | 169 | if( bAbsorb ) |
1821 | 0 | { |
1822 | 0 | pForwarder->QuickInsertText( u""_ustr, aRange ); |
1823 | |
|
1824 | 0 | aRange.CollapseToStart(); |
1825 | 0 | } |
1826 | 169 | else |
1827 | 169 | { |
1828 | 169 | aRange.CollapseToEnd(); |
1829 | 169 | } |
1830 | | |
1831 | 169 | pForwarder->QuickInsertLineBreak( aRange ); |
1832 | 169 | GetEditSource()->UpdateData(); |
1833 | | |
1834 | 169 | aRange.end.nIndex += 1; |
1835 | 169 | if( !bAbsorb ) |
1836 | 169 | aRange.start.nIndex += 1; |
1837 | | |
1838 | 169 | pRange->SetSelection( aRange ); |
1839 | 169 | } |
1840 | 169 | return; |
1841 | 0 | } |
1842 | 83.2k | case text::ControlCharacter::APPEND_PARAGRAPH: |
1843 | 83.2k | { |
1844 | 83.2k | SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRange>( xRange ); |
1845 | 83.2k | if(pRange) |
1846 | 83.2k | { |
1847 | 83.2k | ESelection aRange = pRange->GetSelection(); |
1848 | | // ESelection aOldSelection = aRange; |
1849 | | |
1850 | 83.2k | aRange.start.nIndex = pForwarder->GetTextLen( aRange.start.nPara ); |
1851 | | |
1852 | 83.2k | aRange.CollapseToStart(); |
1853 | | |
1854 | 83.2k | pRange->SetSelection( aRange ); |
1855 | 83.2k | static constexpr OUStringLiteral CR = u"\x0D"; |
1856 | 83.2k | pRange->setString( CR ); |
1857 | | |
1858 | 83.2k | aRange.start.nIndex = 0; |
1859 | 83.2k | aRange.start.nPara += 1; |
1860 | 83.2k | aRange.end.nIndex = 0; |
1861 | 83.2k | aRange.end.nPara += 1; |
1862 | | |
1863 | 83.2k | pRange->SetSelection( aRange ); |
1864 | | |
1865 | 83.2k | return; |
1866 | 83.2k | } |
1867 | 0 | [[fallthrough]]; |
1868 | 0 | } |
1869 | 0 | default: |
1870 | 0 | throw lang::IllegalArgumentException(); |
1871 | 83.4k | } |
1872 | 83.4k | } |
1873 | | |
1874 | | // XText |
1875 | | void SAL_CALL SvxUnoTextBase::insertTextContent( const uno::Reference< text::XTextRange >& xRange, const uno::Reference< text::XTextContent >& xContent, sal_Bool bAbsorb ) |
1876 | 29.3k | { |
1877 | 29.3k | SolarMutexGuard aGuard; |
1878 | | |
1879 | 29.3k | SvxTextForwarder* pForwarder = GetEditSource() ? GetEditSource()->GetTextForwarder() : nullptr; |
1880 | 29.3k | if (!pForwarder) |
1881 | 592 | return; |
1882 | | |
1883 | 28.7k | uno::Reference<beans::XPropertySet> xPropSet(xRange, uno::UNO_QUERY); |
1884 | 28.7k | if (!xPropSet.is()) |
1885 | 0 | throw lang::IllegalArgumentException(); |
1886 | | |
1887 | 28.7k | uno::Any aAny = xPropSet->getPropertyValue(UNO_TR_PROP_SELECTION); |
1888 | 28.7k | text::TextRangeSelection aSel = aAny.get<text::TextRangeSelection>(); |
1889 | 28.7k | if (!bAbsorb) |
1890 | 28.6k | aSel.Start = aSel.End; |
1891 | | |
1892 | 28.7k | std::unique_ptr<SvxFieldData> pFieldData(SvxFieldData::Create(xContent)); |
1893 | 28.7k | if (!pFieldData) |
1894 | 8.83k | throw lang::IllegalArgumentException(); |
1895 | | |
1896 | 19.8k | SvxFieldItem aField( *pFieldData, EE_FEATURE_FIELD ); |
1897 | 19.8k | pForwarder->QuickInsertField(aField, toESelection(aSel)); |
1898 | 19.8k | GetEditSource()->UpdateData(); |
1899 | | |
1900 | 19.8k | uno::Reference<beans::XPropertySet> xPropSetContent(xContent, uno::UNO_QUERY); |
1901 | 19.8k | if (!xPropSetContent.is()) |
1902 | 0 | throw lang::IllegalArgumentException(); |
1903 | | |
1904 | 19.8k | xPropSetContent->setPropertyValue(UNO_TC_PROP_ANCHOR, uno::Any(xRange)); |
1905 | | |
1906 | 19.8k | aSel.End.PositionInParagraph += 1; |
1907 | 19.8k | aSel.Start.PositionInParagraph = aSel.End.PositionInParagraph; |
1908 | 19.8k | xPropSet->setPropertyValue(UNO_TR_PROP_SELECTION, uno::Any(aSel)); |
1909 | 19.8k | } |
1910 | | |
1911 | | void SAL_CALL SvxUnoTextBase::removeTextContent( const uno::Reference< text::XTextContent >& ) |
1912 | 0 | { |
1913 | 0 | } |
1914 | | |
1915 | | // XTextRange |
1916 | | |
1917 | | uno::Reference< text::XText > SAL_CALL SvxUnoTextBase::getText() |
1918 | 20.7k | { |
1919 | 20.7k | SolarMutexGuard aGuard; |
1920 | | |
1921 | 20.7k | if (GetEditSource()) |
1922 | 20.7k | { |
1923 | 20.7k | ESelection aSelection; |
1924 | 20.7k | ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() ); |
1925 | 20.7k | SetSelection( aSelection ); |
1926 | 20.7k | } |
1927 | | |
1928 | 20.7k | return static_cast<text::XText*>(this); |
1929 | 20.7k | } |
1930 | | |
1931 | | uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::getStart() |
1932 | 0 | { |
1933 | 0 | return SvxUnoTextRangeBase::getStart(); |
1934 | 0 | } |
1935 | | |
1936 | | uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::getEnd() |
1937 | 13.2k | { |
1938 | 13.2k | return SvxUnoTextRangeBase::getEnd(); |
1939 | 13.2k | } |
1940 | | |
1941 | | OUString SAL_CALL SvxUnoTextBase::getString() |
1942 | 470 | { |
1943 | 470 | return SvxUnoTextRangeBase::getString(); |
1944 | 470 | } |
1945 | | |
1946 | | void SAL_CALL SvxUnoTextBase::setString( const OUString& aString ) |
1947 | 77.0k | { |
1948 | 77.0k | SvxUnoTextRangeBase::setString(aString); |
1949 | 77.0k | } |
1950 | | |
1951 | | |
1952 | | // XEnumerationAccess |
1953 | | uno::Reference< container::XEnumeration > SAL_CALL SvxUnoTextBase::createEnumeration() |
1954 | 9.95k | { |
1955 | 9.95k | SolarMutexGuard aGuard; |
1956 | | |
1957 | 9.95k | if (!GetEditSource()) |
1958 | 0 | return uno::Reference< container::XEnumeration >(); |
1959 | | |
1960 | 9.95k | if (maSelection == ESelection(0, 0, 0, 0) || maSelection == ESelection(EE_PARA_MAX, 0, 0, 0)) |
1961 | 3.05k | { |
1962 | 3.05k | ESelection aSelection; |
1963 | 3.05k | ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() ); |
1964 | 3.05k | return new SvxUnoTextContentEnumeration(*this, aSelection); |
1965 | 3.05k | } |
1966 | 6.89k | else |
1967 | 6.89k | { |
1968 | 6.89k | return new SvxUnoTextContentEnumeration(*this, maSelection); |
1969 | 6.89k | } |
1970 | 9.95k | } |
1971 | | |
1972 | | // XElementAccess ( container::XEnumerationAccess ) |
1973 | | uno::Type SAL_CALL SvxUnoTextBase::getElementType( ) |
1974 | 0 | { |
1975 | 0 | return cppu::UnoType<text::XTextRange>::get(); |
1976 | 0 | } |
1977 | | |
1978 | | sal_Bool SAL_CALL SvxUnoTextBase::hasElements( ) |
1979 | 2.11k | { |
1980 | 2.11k | SolarMutexGuard aGuard; |
1981 | | |
1982 | 2.11k | if(GetEditSource()) |
1983 | 2.11k | { |
1984 | 2.11k | SvxTextForwarder* pForwarder = GetEditSource()->GetTextForwarder(); |
1985 | 2.11k | if(pForwarder) |
1986 | 2.11k | return pForwarder->GetParagraphCount() != 0; |
1987 | 2.11k | } |
1988 | | |
1989 | 0 | return false; |
1990 | 2.11k | } |
1991 | | |
1992 | | // text::XTextRangeMover |
1993 | | void SAL_CALL SvxUnoTextBase::moveTextRange( const uno::Reference< text::XTextRange >&, sal_Int16 ) |
1994 | 0 | { |
1995 | 0 | } |
1996 | | |
1997 | | /// @throws lang::IllegalArgumentException |
1998 | | /// @throws beans::UnknownPropertyException |
1999 | | /// @throws uno::RuntimeException |
2000 | | static void SvxPropertyValuesToItemSet( |
2001 | | SfxItemSet &rItemSet, |
2002 | | const uno::Sequence< beans::PropertyValue >& rPropertyValues, |
2003 | | const SfxItemPropertySet *pPropSet, |
2004 | | SvxTextForwarder *pForwarder, |
2005 | | sal_Int32 nPara) |
2006 | 6.48k | { |
2007 | 6.48k | for (const beans::PropertyValue& rProp : rPropertyValues) |
2008 | 11.9k | { |
2009 | 11.9k | const SfxItemPropertyMapEntry *pEntry = pPropSet->getPropertyMap().getByName( rProp.Name ); |
2010 | 11.9k | if (!pEntry) |
2011 | 526 | throw beans::UnknownPropertyException( "Unknown property: " + rProp.Name ); |
2012 | | // Note: there is no need to take special care of the properties |
2013 | | // TextField (EE_FEATURE_FIELD) and |
2014 | | // TextPortionType (WID_PORTIONTYPE) |
2015 | | // since they are read-only and thus are already taken care of below. |
2016 | | |
2017 | 11.4k | if (pEntry->nFlags & beans::PropertyAttribute::READONLY) |
2018 | | // should be PropertyVetoException which is not yet defined for the new import API's functions |
2019 | 0 | throw uno::RuntimeException("Property is read-only: " + rProp.Name ); |
2020 | | //throw PropertyVetoException ("Property is read-only: " + rProp.Name ); |
2021 | | |
2022 | 11.4k | if (pEntry->nWID == WID_FONTDESC) |
2023 | 0 | { |
2024 | 0 | awt::FontDescriptor aDesc; |
2025 | 0 | if (rProp.Value >>= aDesc) |
2026 | 0 | SvxUnoFontDescriptor::FillItemSet( aDesc, rItemSet ); |
2027 | 0 | } |
2028 | 11.4k | else if (pEntry->nWID == WID_NUMBERINGSTARTVALUE ) |
2029 | 0 | { |
2030 | 0 | if( pForwarder ) |
2031 | 0 | { |
2032 | 0 | sal_Int16 nStartValue = -1; |
2033 | 0 | if( !(rProp.Value >>= nStartValue) ) |
2034 | 0 | throw lang::IllegalArgumentException(); |
2035 | | |
2036 | 0 | pForwarder->SetNumberingStartValue( nPara, nStartValue ); |
2037 | 0 | } |
2038 | 0 | } |
2039 | 11.4k | else if (pEntry->nWID == WID_PARAISNUMBERINGRESTART ) |
2040 | 0 | { |
2041 | 0 | if( pForwarder ) |
2042 | 0 | { |
2043 | 0 | bool bParaIsNumberingRestart = false; |
2044 | 0 | if( !(rProp.Value >>= bParaIsNumberingRestart) ) |
2045 | 0 | throw lang::IllegalArgumentException(); |
2046 | | |
2047 | 0 | pForwarder->SetParaIsNumberingRestart( nPara, bParaIsNumberingRestart ); |
2048 | 0 | } |
2049 | 0 | } |
2050 | 11.4k | else |
2051 | 11.4k | pPropSet->setPropertyValue( rProp.Name, rProp.Value, rItemSet ); |
2052 | 11.4k | } |
2053 | 6.48k | } |
2054 | | |
2055 | | uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::finishParagraphInsert( |
2056 | | const uno::Sequence< beans::PropertyValue >& /*rCharAndParaProps*/, |
2057 | | const uno::Reference< text::XTextRange >& /*rTextRange*/ ) |
2058 | 0 | { |
2059 | 0 | uno::Reference< text::XTextRange > xRet; |
2060 | 0 | return xRet; |
2061 | 0 | } |
2062 | | |
2063 | | uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::finishParagraph( |
2064 | | const uno::Sequence< beans::PropertyValue >& rCharAndParaProps ) |
2065 | 1.27k | { |
2066 | 1.27k | SolarMutexGuard aGuard; |
2067 | | |
2068 | 1.27k | SvxEditSource *pEditSource = GetEditSource(); |
2069 | 1.27k | SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : nullptr; |
2070 | 1.27k | if (!pTextForwarder) |
2071 | 0 | return nullptr; |
2072 | | |
2073 | 1.27k | sal_Int32 nParaCount = pTextForwarder->GetParagraphCount(); |
2074 | 1.27k | DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" ); |
2075 | 1.27k | pTextForwarder->AppendParagraph(); |
2076 | | |
2077 | | // set properties for the previously last paragraph |
2078 | 1.27k | sal_Int32 nPara = nParaCount - 1; |
2079 | 1.27k | ESelection aSel(nPara, 0); |
2080 | 1.27k | SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() ); |
2081 | 1.27k | SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps, |
2082 | 1.27k | ImplGetSvxUnoOutlinerTextCursorSfxPropertySet(), pTextForwarder, nPara ); |
2083 | 1.27k | pTextForwarder->QuickSetAttribs( aItemSet, aSel ); |
2084 | 1.27k | pEditSource->UpdateData(); |
2085 | 1.27k | rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *this ); |
2086 | 1.27k | pRange->SetSelection( aSel ); |
2087 | 1.27k | return pRange; |
2088 | 1.27k | } |
2089 | | |
2090 | | uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::insertTextPortion( |
2091 | | const OUString& rText, |
2092 | | const uno::Sequence< beans::PropertyValue >& rCharAndParaProps, |
2093 | | const uno::Reference< text::XTextRange>& rTextRange ) |
2094 | 0 | { |
2095 | 0 | SolarMutexGuard aGuard; |
2096 | |
|
2097 | 0 | if (!rTextRange.is()) |
2098 | 0 | return nullptr; |
2099 | | |
2100 | 0 | SvxUnoTextRangeBase* pRange = comphelper::getFromUnoTunnel<SvxUnoTextRange>(rTextRange); |
2101 | 0 | if (!pRange) |
2102 | 0 | return nullptr; |
2103 | | |
2104 | 0 | SvxEditSource *pEditSource = GetEditSource(); |
2105 | 0 | SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : nullptr; |
2106 | |
|
2107 | 0 | if (!pTextForwarder) |
2108 | 0 | return nullptr; |
2109 | | |
2110 | 0 | pRange->setString(rText); |
2111 | |
|
2112 | 0 | ESelection aSelection(pRange->GetSelection()); |
2113 | |
|
2114 | 0 | pTextForwarder->RemoveAttribs(aSelection); |
2115 | 0 | pEditSource->UpdateData(); |
2116 | |
|
2117 | 0 | SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() ); |
2118 | 0 | SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps, |
2119 | 0 | ImplGetSvxTextPortionSfxPropertySet(), pTextForwarder, aSelection.start.nPara ); |
2120 | 0 | pTextForwarder->QuickSetAttribs( aItemSet, aSelection); |
2121 | 0 | rtl::Reference<SvxUnoTextRange> pNewRange = new SvxUnoTextRange( *this ); |
2122 | 0 | pNewRange->SetSelection(aSelection); |
2123 | 0 | for( const beans::PropertyValue& rProp : rCharAndParaProps ) |
2124 | 0 | pNewRange->setPropertyValue( rProp.Name, rProp.Value ); |
2125 | 0 | return pNewRange; |
2126 | 0 | } |
2127 | | |
2128 | | // css::text::XTextPortionAppend (new import API) |
2129 | | uno::Reference< text::XTextRange > SAL_CALL SvxUnoTextBase::appendTextPortion( |
2130 | | const OUString& rText, |
2131 | | const uno::Sequence< beans::PropertyValue >& rCharAndParaProps ) |
2132 | 5.21k | { |
2133 | 5.21k | SolarMutexGuard aGuard; |
2134 | | |
2135 | 5.21k | SvxEditSource *pEditSource = GetEditSource(); |
2136 | 5.21k | SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : nullptr; |
2137 | 5.21k | if (!pTextForwarder) |
2138 | 0 | return nullptr; |
2139 | | |
2140 | 5.21k | sal_Int32 nParaCount = pTextForwarder->GetParagraphCount(); |
2141 | 5.21k | DBG_ASSERT( nParaCount > 0, "paragraph count is 0 or negative" ); |
2142 | 5.21k | sal_Int32 nPara = nParaCount - 1; |
2143 | 5.21k | SfxItemSet aSet( pTextForwarder->GetParaAttribs( nPara ) ); |
2144 | 5.21k | sal_Int32 nStart = pTextForwarder->AppendTextPortion( nPara, rText, aSet ); |
2145 | 5.21k | pEditSource->UpdateData(); |
2146 | 5.21k | sal_Int32 nEnd = pTextForwarder->GetTextLen( nPara ); |
2147 | | |
2148 | | // set properties for the new text portion |
2149 | 5.21k | ESelection aSel( nPara, nStart, nPara, nEnd ); |
2150 | 5.21k | pTextForwarder->RemoveAttribs( aSel ); |
2151 | 5.21k | pEditSource->UpdateData(); |
2152 | | |
2153 | 5.21k | SfxItemSet aItemSet( *pTextForwarder->GetEmptyItemSetPtr() ); |
2154 | 5.21k | SvxPropertyValuesToItemSet( aItemSet, rCharAndParaProps, |
2155 | 5.21k | ImplGetSvxTextPortionSfxPropertySet(), pTextForwarder, nPara ); |
2156 | 5.21k | pTextForwarder->QuickSetAttribs( aItemSet, aSel ); |
2157 | | |
2158 | 5.21k | rtl::Reference<SvxUnoTextRange> pRange = new SvxUnoTextRange( *this ); |
2159 | 5.21k | pRange->SetSelection( aSel ); |
2160 | 5.21k | uno::Sequence<OUString> aPropNames(rCharAndParaProps.getLength()); |
2161 | 5.21k | uno::Sequence<uno::Any> aPropVals(rCharAndParaProps.getLength()); |
2162 | 5.21k | int i = 0; |
2163 | 5.21k | for( const beans::PropertyValue& rProp : rCharAndParaProps ) |
2164 | 8.98k | { |
2165 | 8.98k | aPropNames.getArray()[i] = rProp.Name; |
2166 | 8.98k | aPropVals.getArray()[i] = rProp.Value; |
2167 | 8.98k | ++i; |
2168 | 8.98k | } |
2169 | 5.21k | pRange->setPropertyValues( aPropNames, aPropVals ); |
2170 | 5.21k | return pRange; |
2171 | 5.21k | } |
2172 | | |
2173 | | void SvxUnoTextBase::copyText( |
2174 | | const uno::Reference< text::XTextCopy >& xSource ) |
2175 | 0 | { |
2176 | 0 | SolarMutexGuard aGuard; |
2177 | 0 | uno::Reference< lang::XUnoTunnel > xUT( xSource, uno::UNO_QUERY ); |
2178 | 0 | SvxEditSource *pEditSource = GetEditSource(); |
2179 | 0 | SvxTextForwarder *pTextForwarder = pEditSource ? pEditSource->GetTextForwarder() : nullptr; |
2180 | 0 | if( !pTextForwarder ) |
2181 | 0 | return; |
2182 | 0 | if (auto pSource = comphelper::getFromUnoTunnel<SvxUnoTextBase>(xUT)) |
2183 | 0 | { |
2184 | 0 | SvxEditSource *pSourceEditSource = pSource->GetEditSource(); |
2185 | 0 | SvxTextForwarder *pSourceTextForwarder = pSourceEditSource ? pSourceEditSource->GetTextForwarder() : nullptr; |
2186 | 0 | if( pSourceTextForwarder ) |
2187 | 0 | { |
2188 | 0 | pTextForwarder->CopyText( *pSourceTextForwarder ); |
2189 | 0 | pEditSource->UpdateData(); |
2190 | 0 | SetSelection(pSource->GetSelection()); |
2191 | 0 | } |
2192 | 0 | } |
2193 | 0 | else |
2194 | 0 | { |
2195 | 0 | uno::Reference< text::XText > xSourceText( xSource, uno::UNO_QUERY ); |
2196 | 0 | if( xSourceText.is() ) |
2197 | 0 | { |
2198 | 0 | setString( xSourceText->getString() ); |
2199 | 0 | } |
2200 | 0 | } |
2201 | 0 | } |
2202 | | |
2203 | | // lang::XServiceInfo |
2204 | | OUString SAL_CALL SvxUnoTextBase::getImplementationName() |
2205 | 0 | { |
2206 | 0 | return u"SvxUnoTextBase"_ustr; |
2207 | 0 | } |
2208 | | |
2209 | | uno::Sequence< OUString > SAL_CALL SvxUnoTextBase::getSupportedServiceNames( ) |
2210 | 0 | { |
2211 | 0 | return getSupportedServiceNames_Static(); |
2212 | 0 | } |
2213 | | |
2214 | | uno::Sequence< OUString > SAL_CALL SvxUnoTextBase::getSupportedServiceNames_Static( ) |
2215 | 0 | { |
2216 | 0 | return comphelper::concatSequences( |
2217 | 0 | SvxUnoTextRangeBase::getSupportedServiceNames_Static(), |
2218 | 0 | std::initializer_list<OUString>{ u"com.sun.star.text.Text"_ustr }); |
2219 | 0 | } |
2220 | | |
2221 | | const uno::Sequence< sal_Int8 > & SvxUnoTextBase::getUnoTunnelId() noexcept |
2222 | 400k | { |
2223 | 400k | static const comphelper::UnoIdInit theSvxUnoTextBaseUnoTunnelId; |
2224 | 400k | return theSvxUnoTextBaseUnoTunnelId.getSeq(); |
2225 | 400k | } |
2226 | | |
2227 | | sal_Int64 SAL_CALL SvxUnoTextBase::getSomething( const uno::Sequence< sal_Int8 >& rId ) |
2228 | 204k | { |
2229 | 204k | return comphelper::getSomethingImpl( |
2230 | 204k | rId, this, comphelper::FallbackToGetSomethingOf<SvxUnoTextRangeBase>{}); |
2231 | 204k | } |
2232 | | |
2233 | | SvxUnoText::SvxUnoText( const SvxItemPropertySet* _pSet ) noexcept |
2234 | 0 | : SvxUnoTextBase( _pSet ) |
2235 | 0 | { |
2236 | 0 | } |
2237 | | |
2238 | | SvxUnoText::SvxUnoText( const SvxEditSource* pSource, const SvxItemPropertySet* _pSet, uno::Reference < text::XText > const & xParent ) noexcept |
2239 | 6.24k | : SvxUnoTextBase( pSource, _pSet, xParent ) |
2240 | 6.24k | { |
2241 | 6.24k | } |
2242 | | |
2243 | | SvxUnoText::SvxUnoText( const SvxUnoText& rText ) noexcept |
2244 | 0 | : SvxUnoTextBase( rText ) |
2245 | 0 | , cppu::OWeakAggObject() |
2246 | 0 | { |
2247 | 0 | } |
2248 | | |
2249 | | SvxUnoText::~SvxUnoText() noexcept |
2250 | 6.24k | { |
2251 | 6.24k | } |
2252 | | |
2253 | | // uno::XInterface |
2254 | | uno::Any SAL_CALL SvxUnoText::queryAggregation( const uno::Type & rType ) |
2255 | 1.61k | { |
2256 | 1.61k | uno::Any aAny( SvxUnoTextBase::queryAggregation( rType ) ); |
2257 | 1.61k | if( !aAny.hasValue() ) |
2258 | 0 | aAny = OWeakAggObject::queryAggregation( rType ); |
2259 | | |
2260 | 1.61k | return aAny; |
2261 | 1.61k | } |
2262 | | |
2263 | | uno::Any SAL_CALL SvxUnoText::queryInterface( const uno::Type & rType ) |
2264 | 1.61k | { |
2265 | 1.61k | return OWeakAggObject::queryInterface( rType ); |
2266 | 1.61k | } |
2267 | | |
2268 | | void SAL_CALL SvxUnoText::acquire() noexcept |
2269 | 42.2k | { |
2270 | 42.2k | OWeakAggObject::acquire(); |
2271 | 42.2k | } |
2272 | | |
2273 | | void SAL_CALL SvxUnoText::release() noexcept |
2274 | 42.2k | { |
2275 | 42.2k | OWeakAggObject::release(); |
2276 | 42.2k | } |
2277 | | |
2278 | | // lang::XTypeProvider |
2279 | | uno::Sequence< uno::Type > SAL_CALL SvxUnoText::getTypes( ) |
2280 | 0 | { |
2281 | 0 | return SvxUnoTextBase::getTypes(); |
2282 | 0 | } |
2283 | | |
2284 | | uno::Sequence< sal_Int8 > SAL_CALL SvxUnoText::getImplementationId( ) |
2285 | 0 | { |
2286 | 0 | return css::uno::Sequence<sal_Int8>(); |
2287 | 0 | } |
2288 | | |
2289 | | const uno::Sequence< sal_Int8 > & SvxUnoText::getUnoTunnelId() noexcept |
2290 | 879 | { |
2291 | 879 | static const comphelper::UnoIdInit theSvxUnoTextUnoTunnelId; |
2292 | 879 | return theSvxUnoTextUnoTunnelId.getSeq(); |
2293 | 879 | } |
2294 | | |
2295 | | sal_Int64 SAL_CALL SvxUnoText::getSomething( const uno::Sequence< sal_Int8 >& rId ) |
2296 | 879 | { |
2297 | 879 | return comphelper::getSomethingImpl(rId, this, |
2298 | 879 | comphelper::FallbackToGetSomethingOf<SvxUnoTextBase>{}); |
2299 | 879 | } |
2300 | | |
2301 | | |
2302 | | SvxDummyTextSource::~SvxDummyTextSource() |
2303 | 0 | { |
2304 | 0 | }; |
2305 | | |
2306 | | std::unique_ptr<SvxEditSource> SvxDummyTextSource::Clone() const |
2307 | 0 | { |
2308 | 0 | return std::unique_ptr<SvxEditSource>(new SvxDummyTextSource); |
2309 | 0 | } |
2310 | | |
2311 | | SvxTextForwarder* SvxDummyTextSource::GetTextForwarder() |
2312 | 0 | { |
2313 | 0 | return this; |
2314 | 0 | } |
2315 | | |
2316 | | void SvxDummyTextSource::UpdateData() |
2317 | 0 | { |
2318 | 0 | } |
2319 | | |
2320 | | sal_Int32 SvxDummyTextSource::GetParagraphCount() const |
2321 | 0 | { |
2322 | 0 | return 0; |
2323 | 0 | } |
2324 | | |
2325 | | sal_Int32 SvxDummyTextSource::GetTextLen( sal_Int32 ) const |
2326 | 0 | { |
2327 | 0 | return 0; |
2328 | 0 | } |
2329 | | |
2330 | | OUString SvxDummyTextSource::GetText( const ESelection& ) const |
2331 | 0 | { |
2332 | 0 | return OUString(); |
2333 | 0 | } |
2334 | | |
2335 | | SfxItemSet SvxDummyTextSource::GetAttribs( const ESelection&, EditEngineAttribs ) const |
2336 | 0 | { |
2337 | | // Very dangerous: The former implementation used a SfxItemPool created on the |
2338 | | // fly which of course was deleted again ASAP. Thus, the returned SfxItemSet was using |
2339 | | // a deleted Pool by design. |
2340 | 0 | return SfxItemSet(EditEngine::GetGlobalItemPool()); |
2341 | 0 | } |
2342 | | |
2343 | | SfxItemSet SvxDummyTextSource::GetParaAttribs( sal_Int32 ) const |
2344 | 0 | { |
2345 | 0 | return GetAttribs(ESelection()); |
2346 | 0 | } |
2347 | | |
2348 | | void SvxDummyTextSource::SetParaAttribs( sal_Int32, const SfxItemSet& ) |
2349 | 0 | { |
2350 | 0 | } |
2351 | | |
2352 | | void SvxDummyTextSource::RemoveAttribs( const ESelection& ) |
2353 | 0 | { |
2354 | 0 | } |
2355 | | |
2356 | | void SvxDummyTextSource::GetPortions( sal_Int32, std::vector<sal_Int32>& ) const |
2357 | 0 | { |
2358 | 0 | } |
2359 | | |
2360 | | OUString SvxDummyTextSource::GetStyleSheet(sal_Int32) const |
2361 | 0 | { |
2362 | 0 | return OUString(); |
2363 | 0 | } |
2364 | | |
2365 | | void SvxDummyTextSource::SetStyleSheet(sal_Int32, const OUString&) |
2366 | 0 | { |
2367 | 0 | } |
2368 | | |
2369 | | SfxItemState SvxDummyTextSource::GetItemState( const ESelection&, sal_uInt16 ) const |
2370 | 0 | { |
2371 | 0 | return SfxItemState::UNKNOWN; |
2372 | 0 | } |
2373 | | |
2374 | | SfxItemState SvxDummyTextSource::GetItemState( sal_Int32, sal_uInt16 ) const |
2375 | 0 | { |
2376 | 0 | return SfxItemState::UNKNOWN; |
2377 | 0 | } |
2378 | | |
2379 | | SfxItemPool* SvxDummyTextSource::GetPool() const |
2380 | 0 | { |
2381 | 0 | return nullptr; |
2382 | 0 | } |
2383 | | |
2384 | | void SvxDummyTextSource::QuickInsertText( const OUString&, const ESelection& ) |
2385 | 0 | { |
2386 | 0 | } |
2387 | | |
2388 | | void SvxDummyTextSource::QuickInsertField( const SvxFieldItem&, const ESelection& ) |
2389 | 0 | { |
2390 | 0 | } |
2391 | | |
2392 | | void SvxDummyTextSource::QuickSetAttribs( const SfxItemSet&, const ESelection& ) |
2393 | 0 | { |
2394 | 0 | } |
2395 | | |
2396 | | void SvxDummyTextSource::QuickInsertLineBreak( const ESelection& ) |
2397 | 0 | { |
2398 | 0 | }; |
2399 | | |
2400 | | OUString SvxDummyTextSource::CalcFieldValue( const SvxFieldItem&, sal_Int32, sal_Int32, std::optional<Color>&, std::optional<Color>&, std::optional<FontLineStyle>& ) |
2401 | 0 | { |
2402 | 0 | return OUString(); |
2403 | 0 | } |
2404 | | |
2405 | | void SvxDummyTextSource::FieldClicked( const SvxFieldItem& ) |
2406 | 0 | { |
2407 | 0 | } |
2408 | | |
2409 | | bool SvxDummyTextSource::IsValid() const |
2410 | 0 | { |
2411 | 0 | return false; |
2412 | 0 | } |
2413 | | |
2414 | | LanguageType SvxDummyTextSource::GetLanguage( sal_Int32, sal_Int32 ) const |
2415 | 0 | { |
2416 | 0 | return LANGUAGE_DONTKNOW; |
2417 | 0 | } |
2418 | | |
2419 | | std::vector<EFieldInfo> SvxDummyTextSource::GetFieldInfo( sal_Int32 ) const |
2420 | 0 | { |
2421 | 0 | return {}; |
2422 | 0 | } |
2423 | | |
2424 | | EBulletInfo SvxDummyTextSource::GetBulletInfo( sal_Int32 ) const |
2425 | 0 | { |
2426 | 0 | return EBulletInfo(); |
2427 | 0 | } |
2428 | | |
2429 | | tools::Rectangle SvxDummyTextSource::GetCharBounds( sal_Int32, sal_Int32 ) const |
2430 | 0 | { |
2431 | 0 | return tools::Rectangle(); |
2432 | 0 | } |
2433 | | |
2434 | | tools::Rectangle SvxDummyTextSource::GetParaBounds( sal_Int32 ) const |
2435 | 0 | { |
2436 | 0 | return tools::Rectangle(); |
2437 | 0 | } |
2438 | | |
2439 | | MapMode SvxDummyTextSource::GetMapMode() const |
2440 | 0 | { |
2441 | 0 | return MapMode(); |
2442 | 0 | } |
2443 | | |
2444 | | OutputDevice* SvxDummyTextSource::GetRefDevice() const |
2445 | 0 | { |
2446 | 0 | return nullptr; |
2447 | 0 | } |
2448 | | |
2449 | | bool SvxDummyTextSource::GetIndexAtPoint( const Point&, sal_Int32&, sal_Int32& ) const |
2450 | 0 | { |
2451 | 0 | return false; |
2452 | 0 | } |
2453 | | |
2454 | | bool SvxDummyTextSource::GetWordIndices( sal_Int32, sal_Int32, sal_Int32&, sal_Int32& ) const |
2455 | 0 | { |
2456 | 0 | return false; |
2457 | 0 | } |
2458 | | |
2459 | | bool SvxDummyTextSource::GetAttributeRun( sal_Int32&, sal_Int32&, sal_Int32, sal_Int32, bool ) const |
2460 | 0 | { |
2461 | 0 | return false; |
2462 | 0 | } |
2463 | | |
2464 | | sal_Int32 SvxDummyTextSource::GetLineCount( sal_Int32 ) const |
2465 | 0 | { |
2466 | 0 | return 0; |
2467 | 0 | } |
2468 | | |
2469 | | sal_Int32 SvxDummyTextSource::GetLineLen( sal_Int32, sal_Int32 ) const |
2470 | 0 | { |
2471 | 0 | return 0; |
2472 | 0 | } |
2473 | | |
2474 | | void SvxDummyTextSource::GetLineBoundaries( /*out*/sal_Int32 &rStart, /*out*/sal_Int32 &rEnd, sal_Int32 /*nParagraph*/, sal_Int32 /*nLine*/ ) const |
2475 | 0 | { |
2476 | 0 | rStart = rEnd = 0; |
2477 | 0 | } |
2478 | | |
2479 | | sal_Int32 SvxDummyTextSource::GetLineNumberAtIndex( sal_Int32 /*nPara*/, sal_Int32 /*nIndex*/ ) const |
2480 | 0 | { |
2481 | 0 | return 0; |
2482 | 0 | } |
2483 | | |
2484 | | bool SvxDummyTextSource::QuickFormatDoc( bool ) |
2485 | 0 | { |
2486 | 0 | return false; |
2487 | 0 | } |
2488 | | |
2489 | | bool SvxDummyTextSource::SupportsOutlineDepth() const |
2490 | 0 | { |
2491 | 0 | return false; |
2492 | 0 | } |
2493 | | |
2494 | | sal_Int16 SvxDummyTextSource::GetDepth( sal_Int32 ) const |
2495 | 0 | { |
2496 | 0 | return -1; |
2497 | 0 | } |
2498 | | |
2499 | | bool SvxDummyTextSource::SetDepth( sal_Int32, sal_Int16 nNewDepth ) |
2500 | 0 | { |
2501 | 0 | return nNewDepth == 0; |
2502 | 0 | } |
2503 | | |
2504 | | bool SvxDummyTextSource::Delete( const ESelection& ) |
2505 | 0 | { |
2506 | 0 | return false; |
2507 | 0 | } |
2508 | | |
2509 | | bool SvxDummyTextSource::InsertText( const OUString&, const ESelection& ) |
2510 | 0 | { |
2511 | 0 | return false; |
2512 | 0 | } |
2513 | | |
2514 | | const SfxItemSet * SvxDummyTextSource::GetEmptyItemSetPtr() |
2515 | 0 | { |
2516 | 0 | return nullptr; |
2517 | 0 | } |
2518 | | |
2519 | | void SvxDummyTextSource::AppendParagraph() |
2520 | 0 | { |
2521 | 0 | } |
2522 | | |
2523 | | sal_Int32 SvxDummyTextSource::AppendTextPortion( sal_Int32, const OUString &, const SfxItemSet & ) |
2524 | 0 | { |
2525 | 0 | return 0; |
2526 | 0 | } |
2527 | | |
2528 | | void SvxDummyTextSource::CopyText(const SvxTextForwarder& ) |
2529 | 0 | { |
2530 | 0 | } |
2531 | | |
2532 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |