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