LibreOffice Module sw (master) 1
unoparagraph.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <unoparagraph.hxx>
21
25#include <osl/diagnose.h>
27
28#include <cmdid.h>
29#include <unomid.h>
30#include <unoparaframeenum.hxx>
31#include <unotext.hxx>
32#include <unotextrange.hxx>
33#include <unoport.hxx>
34#include <unomap.hxx>
35#include <unocrsr.hxx>
36#include <unoprnms.hxx>
37#include <unocrsrhelper.hxx>
38#include <doc.hxx>
39#include <ndtxt.hxx>
40#include <algorithm>
41#include <utility>
42#include <vcl/svapp.hxx>
43#include <docsh.hxx>
44#include <swunohelper.hxx>
45
46#include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
47#include <com/sun/star/beans/GetPropertyTolerantResult.hpp>
48#include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
49#include <com/sun/star/beans/PropertyAttribute.hpp>
50#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
51#include <com/sun/star/text/WrapTextMode.hpp>
52#include <com/sun/star/text/TextContentAnchorType.hpp>
53
54#include <com/sun/star/drawing/BitmapMode.hpp>
57#include <editeng/unoipset.hxx>
58#include <svl/listener.hxx>
60#include <svx/xflbmtit.hxx>
61#include <svx/xflbstit.hxx>
62
63using namespace ::com::sun::star;
64
65namespace {
66
67class SwParaSelection
68{
69 SwCursor & m_rCursor;
70public:
71 explicit SwParaSelection(SwCursor & rCursor);
72 ~SwParaSelection();
73};
74
75}
76
77SwParaSelection::SwParaSelection(SwCursor & rCursor)
78 : m_rCursor(rCursor)
79{
80 if (m_rCursor.HasMark())
81 {
82 m_rCursor.DeleteMark();
83 }
84 // is it at the start?
85 if (m_rCursor.GetPoint()->GetContentIndex() != 0)
86 {
87 m_rCursor.MovePara(GoCurrPara, fnParaStart);
88 }
89 // or at the end already?
90 if (m_rCursor.GetPoint()->GetContentIndex() != m_rCursor.GetPointContentNode()->Len())
91 {
92 m_rCursor.SetMark();
93 m_rCursor.MovePara(GoCurrPara, fnParaEnd);
94 }
95}
96
97SwParaSelection::~SwParaSelection()
98{
99 if (m_rCursor.GetPoint()->GetContentIndex() != 0)
100 {
101 m_rCursor.DeleteMark();
102 m_rCursor.MovePara(GoCurrPara, fnParaStart);
103 }
104}
105
108static beans::PropertyState lcl_SwXParagraph_getPropertyState(
109 const SwTextNode& rTextNode,
110 const SwAttrSet** ppSet,
111 const SfxItemPropertyMapEntry& rEntry,
112 bool &rAttrSetFetched );
113
115 : public SvtListener
116{
117public:
120 std::mutex m_Mutex; // just for OInterfaceContainerHelper4
126 OUString m_sText;
127 uno::Reference<text::XText> m_xParentText;
129
131 SwTextNode* const pTextNode = nullptr, uno::Reference<text::XText> xParent = nullptr,
132 const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = -1)
133 : m_rThis(rThis)
135 , m_bIsDescriptor(nullptr == pTextNode)
136 , m_nSelectionStartPos(nSelStart)
137 , m_nSelectionEndPos(nSelEnd)
138 , m_xParentText(std::move(xParent))
139 , m_pTextNode(pTextNode)
140 {
141 m_pTextNode && StartListening(m_pTextNode->GetNotifier());
142 }
143
145 return m_pTextNode;
146 }
147
149 if (!m_pTextNode) {
150 throw uno::RuntimeException("SwXParagraph: disposed or invalid", nullptr);
151 }
152 return *m_pTextNode;
153 }
154
155 bool IsDescriptor() const { return m_bIsDescriptor; }
156
163 const uno::Sequence< OUString >& rPropertyNames,
164 const uno::Sequence< uno::Any >& rValues);
165
169 uno::Sequence< uno::Any >
171 const uno::Sequence< OUString >& rPropertyNames);
172
175 const SfxItemPropertyMapEntry& rEntry,
176 const SfxItemSet& rSet,
177 uno::Any& rAny ) const;
178
180 uno::Sequence< beans::GetDirectPropertyTolerantResult >
182 const uno::Sequence< OUString >& rPropertyNames,
183 bool bDirectValuesOnly);
184protected:
185 virtual void Notify(const SfxHint& rHint) override;
186
187};
188
190{
191 if(rHint.GetId() == SfxHintId::Dying)
192 {
193 m_pTextNode = nullptr;
194 std::unique_lock aGuard(m_Mutex);
195 if (m_EventListeners.getLength(aGuard) != 0)
196 {
197 // fdo#72695: if UNO object is already dead, don't revive it with event
198 // The specific pattern we are guarding against is this:
199 // [1] Thread1 takes the SolarMutex
200 // [2] Thread2 decrements the SwXParagraph reference count, and calls the
201 // SwXParagraph destructor, which tries to take the SolarMutex, and blocks
202 // [3] Thread1 destroys a SwTextNode, which calls this Notify event, which results
203 // in a double-free if we construct the xThis object.
204 uno::Reference<uno::XInterface> const xThis(m_wThis);
205 if (!xThis.is())
206 { // fdo#72695: if UNO object is already dead, don't revive it with event
207 return;
208 }
209 lang::EventObject const ev(xThis);
211 }
212 }
213}
214
216 : m_pImpl( new SwXParagraph::Impl(*this) )
217{
218}
219
221 uno::Reference< text::XText > const & xParent,
222 SwTextNode & rTextNode,
223 const sal_Int32 nSelStart, const sal_Int32 nSelEnd)
224 : m_pImpl(
225 new SwXParagraph::Impl(*this, &rTextNode, xParent, nSelStart, nSelEnd))
226{
227}
228
230{
231}
232
234{
235 return m_pImpl->GetTextNode();
236}
237
239{
240 return m_pImpl->IsDescriptor();
241}
242
245 uno::Reference< text::XText> const& i_xParent,
246 const sal_Int32 nSelStart, const sal_Int32 nSelEnd)
247{
248 // re-use existing SwXParagraph
249 // #i105557#: do not iterate over the registered clients: race condition
251 if (pTextNode && (-1 == nSelStart) && (-1 == nSelEnd))
252 { // only use cache if no selection!
253 xParagraph = pTextNode->GetXParagraph();
254 }
255 if (xParagraph.is())
256 {
257 return xParagraph;
258 }
259
260 // create new SwXParagraph
261 uno::Reference<text::XText> xParentText(i_xParent);
262 if (!xParentText.is() && pTextNode)
263 {
264 SwPosition Pos(*pTextNode);
265 xParentText.set(::sw::CreateParentXText( rDoc, Pos ));
266 }
267 SwXParagraph *const pXPara( pTextNode
268 ? new SwXParagraph(xParentText, *pTextNode, nSelStart, nSelEnd)
269 : new SwXParagraph);
270 // this is why the constructor is private: need to acquire pXPara here
271 xParagraph.set(pXPara);
272 // in order to initialize the weak pointer cache in the core object
273 if (pTextNode && (-1 == nSelStart) && (-1 == nSelEnd))
274 {
275 pTextNode->SetXParagraph(xParagraph);
276 }
277 // need a permanent Reference to initialize m_wThis
278 pXPara->m_pImpl->m_wThis = xParagraph.get();
279 return xParagraph;
280}
281
283{
284 SwTextNode const*const pTextNode( GetTextNode() );
285
286 if (!pTextNode)
287 {
288 return false;
289 }
290
291 rPaM.GetPoint()->Assign( *pTextNode );
292 // set selection to the whole paragraph
293 rPaM.SetMark();
294 rPaM.GetMark()->SetContent( pTextNode->GetText().getLength() );
295 return true;
296}
297
298OUString SAL_CALL
300{
301 return "SwXParagraph";
302}
303
304sal_Bool SAL_CALL
305SwXParagraph::supportsService(const OUString& rServiceName)
306{
307 return cppu::supportsService(this, rServiceName);
308}
309
310uno::Sequence< OUString > SAL_CALL
312{
313 return {
314 "com.sun.star.text.TextContent",
315 "com.sun.star.text.Paragraph",
316 "com.sun.star.style.CharacterProperties",
317 "com.sun.star.style.CharacterPropertiesAsian",
318 "com.sun.star.style.CharacterPropertiesComplex",
319 "com.sun.star.style.ParagraphProperties",
320 "com.sun.star.style.ParagraphPropertiesAsian",
321 "com.sun.star.style.ParagraphPropertiesComplex"
322 };
323}
324
325void
327{
328 OSL_ENSURE(m_pImpl->m_bIsDescriptor, "Paragraph is not a descriptor");
329 if (!m_pImpl->m_bIsDescriptor)
330 return;
331
332 m_pImpl->m_bIsDescriptor = false;
333 m_pImpl->EndListeningAll();
334 m_pImpl->StartListening(rTextNode.GetNotifier());
335 rTextNode.SetXParagraph(this);
336 m_pImpl->m_xParentText = &rParent;
337 if (!m_pImpl->m_sText.isEmpty())
338 {
339 try { setString(m_pImpl->m_sText); }
340 catch(...){}
341 m_pImpl->m_sText.clear();
342 }
343}
344
345uno::Reference< beans::XPropertySetInfo > SAL_CALL
347{
349
350 static uno::Reference< beans::XPropertySetInfo > xRef =
351 m_pImpl->m_rPropSet.getPropertySetInfo();
352 return xRef;
353}
354
355void SAL_CALL
356SwXParagraph::setPropertyValue(const OUString& rPropertyName,
357 const uno::Any& rValue)
358{
359 SolarMutexGuard aGuard;
360 m_pImpl->SetPropertyValues_Impl( { rPropertyName }, { rValue } );
361}
362
364SwXParagraph::getPropertyValue(const OUString& rPropertyName)
365{
366 SolarMutexGuard aGuard;
367 uno::Sequence<OUString> aPropertyNames { rPropertyName };
368 const uno::Sequence< uno::Any > aRet =
369 m_pImpl->GetPropertyValues_Impl(aPropertyNames);
370 return aRet.getConstArray()[0];
371}
372
374 const uno::Sequence< OUString >& rPropertyNames,
375 const uno::Sequence< uno::Any >& rValues )
376{
377 SwTextNode & rTextNode(GetTextNodeOrThrow());
378
379 SwPosition aPos( rTextNode );
380 SwCursor aCursor( aPos, nullptr );
381 SwParaSelection aParaSel( aCursor );
382
383 uno::Sequence< beans::PropertyValue > aValues( rPropertyNames.getLength() );
384 std::transform(
385 rPropertyNames.begin(), rPropertyNames.end(), rValues.begin(), aValues.getArray(),
386 [&rMap = m_rPropSet.getPropertyMap(), this](const OUString& name, const uno::Any& value)
387 {
388 if (SfxItemPropertyMapEntry const* const pEntry = rMap.getByName(name); !pEntry)
389 {
390 throw beans::UnknownPropertyException("Unknown property: " + name,
391 static_cast<cppu::OWeakObject*>(&m_rThis));
392 }
393 else if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
394 {
395 throw beans::PropertyVetoException("Property is read-only: " + name,
396 static_cast<cppu::OWeakObject*>(&m_rThis));
397 }
399 });
400 SwUnoCursorHelper::SetPropertyValues(aCursor, m_rPropSet, aValues);
401}
402
404 const uno::Sequence< OUString >& rPropertyNames,
405 const uno::Sequence< uno::Any >& rValues )
406{
407 if (rPropertyNames.getLength() != rValues.getLength())
408 throw lang::IllegalArgumentException("lengths do not match",
409 static_cast<cppu::OWeakObject*>(this), -1);
410
411 SolarMutexGuard aGuard;
412
413 // workaround for bad designed API
414 try
415 {
416 m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues );
417 }
418 catch (const beans::UnknownPropertyException &rException)
419 {
420 // wrap the original (here not allowed) exception in
421 // a lang::WrappedTargetException that gets thrown instead.
422 lang::WrappedTargetException aWExc;
423 aWExc.TargetException <<= rException;
424 throw aWExc;
425 }
426}
427
428// Support for DrawingLayer FillStyles for GetPropertyValue() usages
430 const SfxItemPropertyMapEntry& rEntry,
431 const SfxItemSet& rSet,
432 uno::Any& rAny ) const
433{
434 bool bDone(false);
435
436 switch(rEntry.nWID)
437 {
438 case RES_BACKGROUND:
439 {
440 const std::unique_ptr<SvxBrushItem> aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
441
442 if(!aOriginalBrushItem->QueryValue(rAny, rEntry.nMemberId))
443 {
444 OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
445 }
446
447 bDone = true;
448 break;
449 }
451 {
452 if (rSet.Get(XATTR_FILLBMP_TILE).GetValue())
453 {
454 rAny <<= drawing::BitmapMode_REPEAT;
455 }
456 else if (rSet.Get(XATTR_FILLBMP_STRETCH).GetValue())
457 {
458 rAny <<= drawing::BitmapMode_STRETCH;
459 }
460 else
461 {
462 rAny <<= drawing::BitmapMode_NO_REPEAT;
463 }
464
465 bDone = true;
466 break;
467 }
468 default: break;
469 }
470
471 if(bDone)
472 return;
473
474 // fallback to standard get value implementation used before this helper was created
475 m_rPropSet.getPropertyValue(rEntry, rSet, rAny);
476
477 if(rEntry.aType == cppu::UnoType<sal_Int16>::get() && rEntry.aType != rAny.getValueType())
478 {
479 // since the sfx uInt16 item now exports a sal_Int32, we may have to fix this here
480 sal_Int32 nValue(0);
481
482 if (rAny >>= nValue)
483 {
484 rAny <<= static_cast<sal_Int16>(nValue);
485 }
486 }
487
488 // check for needed metric translation
489 if(!(rEntry.nMoreFlags & PropertyMoreFlags::METRIC_ITEM))
490 return;
491
492 bool bDoIt(true);
493
494 if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
495 {
496 // exception: If these ItemTypes are used, do not convert when these are negative
497 // since this means they are intended as percent values
498 sal_Int32 nValue = 0;
499
500 if(rAny >>= nValue)
501 {
502 bDoIt = nValue > 0;
503 }
504 }
505
506 if(bDoIt)
507 {
508 const MapUnit eMapUnit(rSet.GetPool()->GetMetric(rEntry.nWID));
509
510 if(eMapUnit != MapUnit::Map100thMM)
511 {
512 SvxUnoConvertToMM(eMapUnit, rAny);
513 }
514 }
515}
516
518 const uno::Sequence< OUString > & rPropertyNames )
519{
520 SwTextNode & rTextNode(GetTextNodeOrThrow());
521
522 uno::Sequence< uno::Any > aValues(rPropertyNames.getLength());
523 SwPaM aPam( rTextNode );
524 uno::Any* pValues = aValues.getArray();
525 const OUString* pPropertyNames = rPropertyNames.getConstArray();
526 const SfxItemPropertyMap &rMap = m_rPropSet.getPropertyMap();
527 const SwAttrSet& rAttrSet( rTextNode.GetSwAttrSet() );
528 for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
529 {
530 SfxItemPropertyMapEntry const*const pEntry =
531 rMap.getByName( pPropertyNames[nProp] );
532 if (!pEntry)
533 {
534 throw beans::UnknownPropertyException(
535 "Unknown property: " + pPropertyNames[nProp],
536 static_cast< cppu::OWeakObject * >(&m_rThis));
537 }
539 pValues[nProp], pPropertyNames[nProp], pEntry->nWID))
540 {
541 beans::PropertyState eTemp;
543 *pEntry, aPam, &(pValues[nProp]), eTemp, &rTextNode );
544 if (!bDone)
545 {
546 GetSinglePropertyValue_Impl(*pEntry, rAttrSet, pValues[nProp]);
547 }
548 }
549 }
550 return aValues;
551}
552
553uno::Sequence< uno::Any > SAL_CALL
554SwXParagraph::getPropertyValues(const uno::Sequence< OUString >& rPropertyNames)
555{
556 SolarMutexGuard aGuard;
557 uno::Sequence< uno::Any > aValues;
558
559 // workaround for bad designed API
560 try
561 {
562 aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames );
563 }
564 catch (beans::UnknownPropertyException &)
565 {
566 css::uno::Any anyEx = cppu::getCaughtException();
567 throw css::lang::WrappedTargetRuntimeException("Unknown property exception caught",
568 static_cast < cppu::OWeakObject * > ( this ), anyEx );
569 }
570 catch (lang::WrappedTargetException &)
571 {
572 css::uno::Any anyEx = cppu::getCaughtException();
573 throw css::lang::WrappedTargetRuntimeException("WrappedTargetException caught",
574 static_cast < cppu::OWeakObject * > ( this ), anyEx );
575 }
576
577 return aValues;
578}
579
581 const uno::Sequence< OUString >& /*aPropertyNames*/,
582 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
583{
584 OSL_FAIL("SwXParagraph::addPropertiesChangeListener(): not implemented");
585}
586
588 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
589{
590 OSL_FAIL("SwXParagraph::removePropertiesChangeListener(): not implemented");
591}
592
594 const uno::Sequence< OUString >& /*aPropertyNames*/,
595 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
596{
597 OSL_FAIL("SwXParagraph::firePropertiesChangeEvent(): not implemented");
598}
599
600/* disabled for #i46921# */
601
602uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL
604 const uno::Sequence< OUString >& rPropertyNames,
605 const uno::Sequence< uno::Any >& rValues )
606{
607 SolarMutexGuard aGuard;
608
609 if (rPropertyNames.getLength() != rValues.getLength())
610 {
611 throw lang::IllegalArgumentException();
612 }
613
614 SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
615
616 //SwNode& rTextNode = pUnoCursor->GetPoint()->GetNode();
617 //const SwAttrSet& rAttrSet = static_cast<SwTextNode&>(rTextNode).GetSwAttrSet();
618 //sal_uInt16 nAttrCount = rAttrSet.Count();
619
620 const sal_Int32 nProps = rPropertyNames.getLength();
621 const OUString *pProp = rPropertyNames.getConstArray();
622
623 //sal_Int32 nVals = rValues.getLength();
624 const uno::Any *pValue = rValues.getConstArray();
625
626 sal_Int32 nFailed = 0;
627 uno::Sequence< beans::SetPropertyTolerantFailed > aFailed( nProps );
628 beans::SetPropertyTolerantFailed *pFailed = aFailed.getArray();
629
630 // get entry to start with
631 const SfxItemPropertyMap &rPropMap =
632 m_pImpl->m_rPropSet.getPropertyMap();
633
634 SwPosition aPos( rTextNode );
635 SwCursor aCursor( aPos, nullptr );
636 SwParaSelection aParaSel( aCursor );
637 for (sal_Int32 i = 0; i < nProps; ++i)
638 {
639 try
640 {
641 pFailed[ nFailed ].Name = pProp[i];
642
643 SfxItemPropertyMapEntry const*const pEntry =
644 rPropMap.getByName( pProp[i] );
645 if (!pEntry)
646 {
647 pFailed[ nFailed++ ].Result =
648 beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
649 }
650 else
651 {
652 // set property value
653 // (compare to SwXParagraph::setPropertyValues)
654 if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
655 {
656 pFailed[ nFailed++ ].Result =
657 beans::TolerantPropertySetResultType::PROPERTY_VETO;
658 }
659 else
660 {
662 aCursor, m_pImpl->m_rPropSet, pProp[i], pValue[i]);
663 }
664 }
665 }
666 catch (beans::UnknownPropertyException &)
667 {
668 // should not occur because property was searched for before
669 TOOLS_WARN_EXCEPTION( "sw", "unexpected exception caught" );
670 pFailed[ nFailed++ ].Result =
671 beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
672 }
673 catch (lang::IllegalArgumentException &)
674 {
675 pFailed[ nFailed++ ].Result =
676 beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
677 }
678 catch (beans::PropertyVetoException &)
679 {
680 pFailed[ nFailed++ ].Result =
681 beans::TolerantPropertySetResultType::PROPERTY_VETO;
682 }
683 catch (lang::WrappedTargetException &)
684 {
685 pFailed[ nFailed++ ].Result =
686 beans::TolerantPropertySetResultType::WRAPPED_TARGET;
687 }
688 }
689
690 aFailed.realloc( nFailed );
691 return aFailed;
692}
693
694uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL
696 const uno::Sequence< OUString >& rPropertyNames )
697{
698 SolarMutexGuard aGuard;
699
700 const uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes(
701 m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, false ) );
702
703 // copy temporary result to final result type
704 const sal_Int32 nLen = aTmpRes.getLength();
705 uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen );
706 std::copy(aTmpRes.begin(), aTmpRes.end(), aRes.getArray());
707 return aRes;
708}
709
710uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL
712 const uno::Sequence< OUString >& rPropertyNames )
713{
714 SolarMutexGuard aGuard;
715
716 return m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, true );
717}
718
719uno::Sequence< beans::GetDirectPropertyTolerantResult >
721 const uno::Sequence< OUString >& rPropertyNames,
722 bool bDirectValuesOnly )
723{
724 SolarMutexGuard aGuard;
725
726 SwTextNode & rTextNode(GetTextNodeOrThrow());
727
728 // #i46786# Use SwAttrSet pointer for determining the state.
729 // Use the value SwAttrSet (from the paragraph OR the style)
730 // for determining the actual value(s).
731 const SwAttrSet* pAttrSet = rTextNode.GetpSwAttrSet();
732 const SwAttrSet& rValueAttrSet = rTextNode.GetSwAttrSet();
733
734 sal_Int32 nProps = rPropertyNames.getLength();
735
736 uno::Sequence< beans::GetDirectPropertyTolerantResult > aResult( nProps );
737 beans::GetDirectPropertyTolerantResult *pResult = aResult.getArray();
738 sal_Int32 nIdx = 0;
739
740 // get entry to start with
741 const SfxItemPropertyMap &rPropMap = m_rPropSet.getPropertyMap();
742
743 for (const OUString& rProp : rPropertyNames)
744 {
745 OSL_ENSURE( nIdx < nProps, "index out of bounds" );
746 beans::GetDirectPropertyTolerantResult &rResult = pResult[nIdx];
747
748 try
749 {
750 rResult.Name = rProp;
751
752 SfxItemPropertyMapEntry const*const pEntry =
753 rPropMap.getByName( rProp );
754 if (!pEntry) // property available?
755 {
756 rResult.Result =
757 beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
758 }
759 else
760 {
761 // get property state
762 // (compare to SwXParagraph::getPropertyState)
763 bool bAttrSetFetched = true;
764 beans::PropertyState eState = lcl_SwXParagraph_getPropertyState(
765 rTextNode, &pAttrSet, *pEntry, bAttrSetFetched );
766 rResult.State = eState;
767
768 rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE;
769 if (!bDirectValuesOnly ||
770 (beans::PropertyState_DIRECT_VALUE == eState))
771 {
772 // get property value
773 // (compare to SwXParagraph::getPropertyValue(s))
774 uno::Any aValue;
776 aValue, rProp, pEntry->nWID ) )
777 {
778 SwPaM aPam( rTextNode );
779 // handle properties that are not part of the attribute
780 // and thus only pretended to be paragraph attributes
781 beans::PropertyState eTemp;
782 const bool bDone =
784 *pEntry, aPam, &aValue, eTemp, &rTextNode );
785
786 // if not found try the real paragraph attributes...
787 if (!bDone)
788 {
789 GetSinglePropertyValue_Impl(*pEntry, rValueAttrSet, aValue);
790 }
791 }
792
793 rResult.Value = aValue;
794 rResult.Result = beans::TolerantPropertySetResultType::SUCCESS;
795
796 nIdx++;
797 }
798 // this assertion should never occur!
799 OSL_ENSURE( nIdx < 1 || pResult[nIdx - 1].Result != beans::TolerantPropertySetResultType::UNKNOWN_FAILURE,
800 "unknown failure while retrieving property" );
801
802 }
803 }
804 catch (beans::UnknownPropertyException &)
805 {
806 // should not occur because property was searched for before
807 TOOLS_WARN_EXCEPTION( "sw", "unexpected exception caught" );
808 rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
809 }
810 catch (lang::IllegalArgumentException &)
811 {
812 rResult.Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
813 }
814 catch (beans::PropertyVetoException &)
815 {
816 rResult.Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
817 }
818 catch (lang::WrappedTargetException &)
819 {
820 rResult.Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET;
821 }
822 }
823
824 // resize to actually used size
825 aResult.realloc( nIdx );
826
827 return aResult;
828}
829
831 uno::Any& rAny, std::u16string_view rPropertyName, sal_uInt16 nWID)
832{
833 if(!nWID)
834 {
835 if(rPropertyName == UNO_NAME_ANCHOR_TYPE)
836 nWID = FN_UNO_ANCHOR_TYPE;
837 else if(rPropertyName == UNO_NAME_ANCHOR_TYPES)
838 nWID = FN_UNO_ANCHOR_TYPES;
839 else if(rPropertyName == UNO_NAME_TEXT_WRAP)
840 nWID = FN_UNO_TEXT_WRAP;
841 else
842 return false;
843 }
844
845 switch(nWID)
846 {
847 case FN_UNO_TEXT_WRAP: rAny <<= text::WrapTextMode_NONE; break;
848 case FN_UNO_ANCHOR_TYPE: rAny <<= text::TextContentAnchorType_AT_PARAGRAPH; break;
850 { uno::Sequence<text::TextContentAnchorType> aTypes { text::TextContentAnchorType_AT_PARAGRAPH };
851 rAny <<= aTypes;
852 }
853 break;
854 default:
855 return false;
856 }
857 return true;
858}
859
860void SAL_CALL
862 const OUString& /*rPropertyName*/,
863 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
864{
865 OSL_FAIL("SwXParagraph::addPropertyChangeListener(): not implemented");
866}
867
868void SAL_CALL
870 const OUString& /*rPropertyName*/,
871 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
872{
873 OSL_FAIL("SwXParagraph::removePropertyChangeListener(): not implemented");
874}
875
876void SAL_CALL
878 const OUString& /*rPropertyName*/,
879 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
880{
881 OSL_FAIL("SwXParagraph::addVetoableChangeListener(): not implemented");
882}
883
884void SAL_CALL
886 const OUString& /*rPropertyName*/,
887 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
888{
889 OSL_FAIL("SwXParagraph::removeVetoableChangeListener(): not implemented");
890}
891
892static beans::PropertyState lcl_SwXParagraph_getPropertyState(
893 const SwTextNode& rTextNode,
894 const SwAttrSet** ppSet,
895 const SfxItemPropertyMapEntry& rEntry,
896 bool &rAttrSetFetched)
897{
898 beans::PropertyState eRet(beans::PropertyState_DEFAULT_VALUE);
899
900 if(!(*ppSet) && !rAttrSetFetched)
901 {
902 (*ppSet) = rTextNode.GetpSwAttrSet();
903 rAttrSetFetched = true;
904 }
905
906 SwPosition aPos(rTextNode);
907 SwPaM aPam(aPos);
908 bool bDone(false);
909
910 switch(rEntry.nWID)
911 {
912 case FN_UNO_NUM_RULES:
913 {
914 // if numbering is set, return it; else do nothing
916 bDone = true;
917 break;
918 }
919 case FN_UNO_LIST_ID:
920 {
921 SwNumRule* pNumRule = rTextNode.GetNumRule();
922 if (pNumRule && pNumRule->HasContinueList())
923 {
924 eRet = beans::PropertyState_DIRECT_VALUE;
925 }
926 bDone = true;
927 break;
928 }
930 {
931 bDone = true;
932 break;
933 }
934 case RES_ANCHOR:
935 {
936 bDone = (MID_SURROUND_SURROUNDTYPE == rEntry.nMemberId);
937 break;
938 }
939 case RES_SURROUND:
940 {
941 bDone = (MID_ANCHOR_ANCHORTYPE == rEntry.nMemberId);
942 break;
943 }
946 {
948 eRet = pFormat ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE;
949 bDone = true;
950 break;
951 }
953 {
954 OUString sVal;
956 eRet = !sVal.isEmpty() ? beans::PropertyState_DIRECT_VALUE
957 : beans::PropertyState_AMBIGUOUS_VALUE;
958 bDone = true;
959 break;
960 }
961
962 // DrawingLayer PropertyStyle support
964 {
965 if(*ppSet)
966 {
967 if(SfxItemState::SET == (*ppSet)->GetItemState(XATTR_FILLBMP_STRETCH, false)
968 || SfxItemState::SET == (*ppSet)->GetItemState(XATTR_FILLBMP_TILE, false))
969 {
970 eRet = beans::PropertyState_DIRECT_VALUE;
971 }
972 else
973 {
974 eRet = beans::PropertyState_AMBIGUOUS_VALUE;
975 }
976
977 bDone = true;
978 }
979 break;
980 }
981 case RES_BACKGROUND:
982 {
983 if(*ppSet)
984 {
986 rEntry.nMemberId))
987 {
988 eRet = beans::PropertyState_DIRECT_VALUE;
989 }
990 bDone = true;
991 }
992 break;
993 }
994 }
995
996 if(!bDone)
997 {
998 if((*ppSet) && SfxItemState::SET == (*ppSet)->GetItemState(rEntry.nWID, false))
999 {
1000 eRet = beans::PropertyState_DIRECT_VALUE;
1001 }
1002 }
1003
1004 return eRet;
1005}
1006
1007beans::PropertyState SAL_CALL
1008SwXParagraph::getPropertyState(const OUString& rPropertyName)
1009{
1010 SolarMutexGuard aGuard;
1011
1012 SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1013
1014 const SwAttrSet* pSet = nullptr;
1015 SfxItemPropertyMapEntry const*const pEntry =
1016 m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
1017 if (!pEntry)
1018 {
1019 throw beans::UnknownPropertyException(
1020 "Unknown property: " + rPropertyName,
1021 static_cast<cppu::OWeakObject *>(this));
1022 }
1023 bool bDummy = false;
1024 const beans::PropertyState eRet =
1025 lcl_SwXParagraph_getPropertyState(rTextNode, &pSet, *pEntry, bDummy);
1026 return eRet;
1027}
1028
1029uno::Sequence< beans::PropertyState > SAL_CALL
1031 const uno::Sequence< OUString >& PropertyNames)
1032{
1033 SolarMutexGuard aGuard;
1034
1035 SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1036
1037 const OUString* pNames = PropertyNames.getConstArray();
1038 uno::Sequence< beans::PropertyState > aRet(PropertyNames.getLength());
1039 beans::PropertyState* pStates = aRet.getArray();
1040 const SfxItemPropertyMap &rMap = m_pImpl->m_rPropSet.getPropertyMap();
1041 const SwAttrSet* pSet = nullptr;
1042 bool bAttrSetFetched = false;
1043
1044 for (sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd;
1045 ++i, ++pStates, ++pNames)
1046 {
1047 SfxItemPropertyMapEntry const*const pEntry =
1048 rMap.getByName( *pNames );
1049 if (!pEntry)
1050 {
1051 throw beans::UnknownPropertyException(
1052 "Unknown property: " + *pNames,
1053 static_cast<cppu::OWeakObject *>(this));
1054 }
1055
1056 if (bAttrSetFetched && !pSet && isATR(pEntry->nWID))
1057 {
1058 *pStates = beans::PropertyState_DEFAULT_VALUE;
1059 }
1060 else
1061 {
1063 rTextNode, &pSet, *pEntry, bAttrSetFetched );
1064 }
1065 }
1066
1067 return aRet;
1068}
1069
1070void SAL_CALL
1071SwXParagraph::setPropertyToDefault(const OUString& rPropertyName)
1072{
1073 SolarMutexGuard aGuard;
1074
1075 SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1076
1077 SwPosition aPos( rTextNode );
1078 SwCursor aCursor( aPos, nullptr );
1079 if (rPropertyName == UNO_NAME_ANCHOR_TYPE ||
1080 rPropertyName == UNO_NAME_ANCHOR_TYPES ||
1081 rPropertyName == UNO_NAME_TEXT_WRAP)
1082 {
1083 return;
1084 }
1085
1086 // select paragraph
1087 SwParaSelection aParaSel( aCursor );
1088 SfxItemPropertyMapEntry const*const pEntry =
1089 m_pImpl->m_rPropSet.getPropertyMap().getByName( rPropertyName );
1090 if (!pEntry)
1091 {
1092 throw beans::UnknownPropertyException(
1093 "Unknown property: " + rPropertyName,
1094 static_cast<cppu::OWeakObject *>(this));
1095 }
1096
1097 if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
1098 {
1099 throw uno::RuntimeException(
1100 "Property is read-only: " + rPropertyName,
1101 static_cast<cppu::OWeakObject *>(this));
1102 }
1103
1104 const bool bBelowFrameAtrEnd(pEntry->nWID < RES_FRMATR_END);
1105 const bool bDrawingLayerRange(XATTR_FILL_FIRST <= pEntry->nWID && XATTR_FILL_LAST >= pEntry->nWID);
1106
1107 if(bBelowFrameAtrEnd || bDrawingLayerRange)
1108 {
1110
1111 // For FillBitmapMode two IDs have to be reset (!)
1112 if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
1113 {
1114 aWhichIds.insert(XATTR_FILLBMP_STRETCH);
1115 aWhichIds.insert(XATTR_FILLBMP_TILE);
1116 }
1117 else
1118 {
1119 aWhichIds.insert(pEntry->nWID);
1120 }
1121
1122 if (pEntry->nWID < RES_PARATR_BEGIN)
1123 {
1124 aCursor.GetDoc().ResetAttrs(aCursor, true, aWhichIds);
1125 }
1126 else
1127 {
1128 // for paragraph attributes the selection must be extended
1129 // to paragraph boundaries
1130 SwPosition aStart( *aCursor.Start() );
1131 SwPosition aEnd ( *aCursor.End() );
1132 auto pTemp( aCursor.GetDoc().CreateUnoCursor(aStart) );
1134 {
1135 pTemp->MovePara(GoCurrPara, fnParaStart);
1136 }
1137
1138 pTemp->SetMark();
1139 *pTemp->GetPoint() = aEnd;
1140
1141 SwUnoCursorHelper::SelectPam(*pTemp, true);
1142
1143 if (!SwUnoCursorHelper::IsEndOfPara(*pTemp))
1144 {
1145 pTemp->MovePara(GoCurrPara, fnParaEnd);
1146 }
1147
1148
1149 pTemp->GetDoc().ResetAttrs(*pTemp, true, aWhichIds);
1150 }
1151 }
1152 else
1153 {
1155 }
1156}
1157
1158uno::Any SAL_CALL
1159SwXParagraph::getPropertyDefault(const OUString& rPropertyName)
1160{
1162
1163 SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1164
1165 uno::Any aRet;
1166 if (::sw::GetDefaultTextContentValue(aRet, rPropertyName))
1167 {
1168 return aRet;
1169 }
1170
1171 SfxItemPropertyMapEntry const*const pEntry =
1172 m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
1173 if (!pEntry)
1174 {
1175 throw beans::UnknownPropertyException(
1176 "Unknown property: " + rPropertyName,
1177 static_cast<cppu::OWeakObject *>(this));
1178 }
1179
1180 const bool bBelowFrameAtrEnd(pEntry->nWID < RES_FRMATR_END);
1181 const bool bDrawingLayerRange(XATTR_FILL_FIRST <= pEntry->nWID && XATTR_FILL_LAST >= pEntry->nWID);
1182
1183 if(bBelowFrameAtrEnd || bDrawingLayerRange)
1184 {
1185 const SfxPoolItem& rDefItem = rTextNode.GetDoc().GetAttrPool().GetDefaultItem(pEntry->nWID);
1186
1187 rDefItem.QueryValue(aRet, pEntry->nMemberId);
1188 }
1189
1190 return aRet;
1191}
1192
1193void SAL_CALL
1194SwXParagraph::attach(const uno::Reference< text::XTextRange > & /*xTextRange*/)
1195{
1196 // SwXParagraph will only created in order to be inserted by
1197 // 'insertTextContentBefore' or 'insertTextContentAfter' therefore
1198 // they cannot be attached
1199 throw uno::RuntimeException();
1200}
1201
1202uno::Reference< text::XTextRange > SAL_CALL
1204{
1205 SolarMutexGuard aGuard;
1206
1207 SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1208
1209 SwPosition aPos( rTextNode );
1210 SwCursor aCursor( aPos, nullptr );
1211 // select paragraph
1212 SwParaSelection aParaSel( aCursor );
1213 const uno::Reference< text::XTextRange > xRet =
1214 new SwXTextRange(aCursor, m_pImpl->m_xParentText);
1215 return xRet;
1216}
1217
1219{
1220 SolarMutexGuard aGuard;
1221
1222 SwTextNode *const pTextNode( m_pImpl->GetTextNode() );
1223 if (pTextNode)
1224 {
1225 SwCursor aCursor( SwPosition( *pTextNode ), nullptr );
1226 pTextNode->GetDoc().getIDocumentContentOperations().DelFullPara(aCursor);
1227 lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
1228 std::unique_lock aGuard2(m_pImpl->m_Mutex);
1229 m_pImpl->m_EventListeners.disposeAndClear(aGuard2, ev);
1230 }
1231}
1232
1234 const uno::Reference< lang::XEventListener > & xListener)
1235{
1236 // no need to lock here as m_pImpl is const and container threadsafe
1237 std::unique_lock aGuard(m_pImpl->m_Mutex);
1238 m_pImpl->m_EventListeners.addInterface(aGuard, xListener);
1239}
1240
1242 const uno::Reference< lang::XEventListener > & xListener)
1243{
1244 // no need to lock here as m_pImpl is const and container threadsafe
1245 std::unique_lock aGuard(m_pImpl->m_Mutex);
1246 m_pImpl->m_EventListeners.removeInterface(aGuard, xListener);
1247}
1248
1249uno::Reference< container::XEnumeration > SAL_CALL
1251{
1252 SolarMutexGuard aGuard;
1253
1254 SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1255
1256 SwPaM aPam ( rTextNode );
1257 const uno::Reference< container::XEnumeration > xRef =
1258 new SwXTextPortionEnumeration(aPam, m_pImpl->m_xParentText,
1259 m_pImpl->m_nSelectionStartPos, m_pImpl->m_nSelectionEndPos);
1260 return xRef;
1261}
1262
1266{
1267 SolarMutexGuard aGuard;
1268
1269 SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1270 SwPaM aPam ( rTextNode );
1271
1272 return new SwXTextPortionEnumeration(aPam, m_pImpl->m_xParentText,
1273 m_pImpl->m_nSelectionStartPos, m_pImpl->m_nSelectionEndPos, /*bOnlyTextFields*/true);
1274}
1275
1277{
1279}
1280
1282{
1283 SolarMutexGuard aGuard;
1284 return GetTextNode() != nullptr;
1285}
1286
1287uno::Reference< text::XText > SAL_CALL
1289{
1291
1292 return m_pImpl->m_xParentText;
1293}
1294
1295uno::Reference< text::XTextRange > SAL_CALL
1297{
1298 SolarMutexGuard aGuard;
1299
1300 SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1301
1302 SwPosition aPos( rTextNode );
1303 SwCursor aCursor( aPos, nullptr );
1304 SwParaSelection aParaSel( aCursor );
1305 SwPaM aPam( *aCursor.Start() );
1306 uno::Reference< text::XText > xParent = getText();
1307 const uno::Reference< text::XTextRange > xRet =
1308 new SwXTextRange(aPam, xParent);
1309 return xRet;
1310}
1311
1312uno::Reference< text::XTextRange > SAL_CALL
1314{
1315 SolarMutexGuard aGuard;
1316
1317 SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1318
1319 SwPosition aPos( rTextNode );
1320 SwCursor aCursor( aPos, nullptr );
1321 SwParaSelection aParaSel( aCursor );
1322 SwPaM aPam( *aCursor.End() );
1323 uno::Reference< text::XText > xParent = getText();
1324 const uno::Reference< text::XTextRange > xRet =
1325 new SwXTextRange(aPam, xParent);
1326 return xRet;
1327}
1328
1329OUString SAL_CALL SwXParagraph::getString()
1330{
1331 SolarMutexGuard aGuard;
1332 OUString aRet;
1333 SwTextNode const*const pTextNode( GetTextNode() );
1334 if (pTextNode)
1335 {
1336 SwPosition aPos( *pTextNode );
1337 SwCursor aCursor( aPos, nullptr );
1338 SwParaSelection aParaSel( aCursor );
1339 SwUnoCursorHelper::GetTextFromPam(aCursor, aRet);
1340 }
1341 else if (m_pImpl->IsDescriptor())
1342 {
1343 aRet = m_pImpl->m_sText;
1344 }
1345 else
1346 {
1347 // Seems object is being disposed or some other problem occurs.
1348 // Anyway from user point of view object still exist, so on that level this is not an error
1349 SAL_WARN("sw.uno", "getString() for invalid paragraph called. Returning empty string.");
1350 }
1351 return aRet;
1352}
1353
1354void SAL_CALL SwXParagraph::setString(const OUString& aString)
1355{
1356 SolarMutexGuard aGuard;
1357
1358 SwTextNode const*const pTextNode( GetTextNode() );
1359 if (pTextNode)
1360 {
1361 SwPosition aPos( *pTextNode );
1362 SwCursor aCursor( aPos, nullptr );
1363 if (!SwUnoCursorHelper::IsStartOfPara(aCursor)) {
1365 }
1366 SwUnoCursorHelper::SelectPam(aCursor, true);
1367 if (pTextNode->GetText().getLength()) {
1368 aCursor.MovePara(GoCurrPara, fnParaEnd);
1369 }
1370 SwUnoCursorHelper::SetString(aCursor, aString);
1371 SwUnoCursorHelper::SelectPam(aCursor, false);
1372 }
1373 else if (m_pImpl->IsDescriptor())
1374 {
1375 m_pImpl->m_sText = aString;
1376 }
1377 else
1378 {
1379 throw uno::RuntimeException();
1380 }
1381}
1382
1383uno::Reference< container::XEnumeration > SAL_CALL
1384SwXParagraph::createContentEnumeration(const OUString& rServiceName)
1385{
1387
1388 if ( rServiceName != "com.sun.star.text.TextContent" )
1389 {
1390 throw uno::RuntimeException();
1391 }
1392
1393 SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1394
1395 SwPaM aPam( rTextNode );
1396 uno::Reference< container::XEnumeration > xRet =
1398 return xRet;
1399}
1400
1401uno::Sequence< OUString > SAL_CALL
1403{
1404 uno::Sequence<OUString> aRet { "com.sun.star.text.TextContent" };
1405 return aRet;
1406}
1407
1408// MetadatableMixin
1409::sfx2::Metadatable* SwXParagraph::GetCoreObject()
1410{
1411 SwTextNode *const pTextNode( m_pImpl->GetTextNode() );
1412 return pTextNode;
1413}
1414
1415uno::Reference<frame::XModel> SwXParagraph::GetModel()
1416{
1417 SwTextNode *const pTextNode( m_pImpl->GetTextNode() );
1418 if (pTextNode)
1419 {
1420 SwDocShell const*const pShell( pTextNode->GetDoc().GetDocShell() );
1421 return pShell ? pShell->GetModel() : nullptr;
1422 }
1423 return nullptr;
1424}
1425
1426/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
virtual bool DelFullPara(SwPaM &)=0
Delete full paragraphs.
SfxHintId GetId() const
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
const SfxItemPropertyMapEntry * getByName(std::u16string_view rName) const
const SfxItemPropertyMap & getPropertyMap() const
SfxItemPool * GetPool() const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
css::uno::Reference< css::frame::XModel3 > GetModel() const
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
bool StartListening(SvtBroadcaster &rBroadcaster)
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:765
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:493
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
Definition: swcrsr.cxx:2292
Definition: doc.hxx:195
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:323
void ResetAttrs(const SwPaM &rRg, bool bTextAttr=true, const o3tl::sorted_vector< sal_uInt16 > &rAttrs=o3tl::sorted_vector< sal_uInt16 >(), const bool bSendDataChangedEvents=true, SwRootFrame const *pLayout=nullptr)
Reset attributes.
Definition: docfmt.cxx:243
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1803
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1331
SwDocShell * GetDocShell()
Definition: doc.hxx:1364
SwFormatColl is just an SwFormat subclass that defaults to m_bAutoFormat=false, expressing that this ...
Definition: fmtcol.hxx:38
SwDoc & GetDoc()
Definition: node.hxx:233
bool HasContinueList() const
Is it possible that this numbering has multiple lists?
Definition: number.cxx:1156
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
const SwPosition * GetMark() const
Definition: pam.hxx:263
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:642
const SwPosition * End() const
Definition: pam.hxx:271
SwDoc & GetDoc() const
Definition: pam.hxx:299
const SwPosition * GetPoint() const
Definition: pam.hxx:261
const SwPosition * Start() const
Definition: pam.hxx:266
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
SAL_DLLPRIVATE unotools::WeakReference< SwXParagraph > const & GetXParagraph() const
Definition: ndtxt.hxx:836
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
Definition: ndtxt.cxx:2919
const OUString & GetText() const
Definition: ndtxt.hxx:244
SAL_DLLPRIVATE void SetXParagraph(rtl::Reference< SwXParagraph > const &xParagraph)
Definition: ndtxt.cxx:5573
Impl(SwXParagraph &rThis, SwTextNode *const pTextNode=nullptr, uno::Reference< text::XText > xParent=nullptr, const sal_Int32 nSelStart=-1, const sal_Int32 nSelEnd=-1)
unotools::WeakReference< SwXParagraph > m_wThis
::comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_EventListeners
SwTextNode & GetTextNodeOrThrow()
uno::Reference< text::XText > m_xParentText
SwXParagraph & m_rThis
SwTextNode * m_pTextNode
void GetSinglePropertyValue_Impl(const SfxItemPropertyMapEntry &rEntry, const SfxItemSet &rSet, uno::Any &rAny) const
SwTextNode * GetTextNode()
bool IsDescriptor() const
sal_Int32 m_nSelectionEndPos
virtual void Notify(const SfxHint &rHint) override
void SetPropertyValues_Impl(const uno::Sequence< OUString > &rPropertyNames, const uno::Sequence< uno::Any > &rValues)
SfxItemPropertySet const & m_rPropSet
uno::Sequence< uno::Any > GetPropertyValues_Impl(const uno::Sequence< OUString > &rPropertyNames)
uno::Sequence< beans::GetDirectPropertyTolerantResult > GetPropertyValuesTolerant_Impl(const uno::Sequence< OUString > &rPropertyNames, bool bDirectValuesOnly)
sal_Int32 m_nSelectionStartPos
virtual css::uno::Reference< css::frame::XModel > GetModel() override
virtual void SAL_CALL setString(const OUString &rString) override
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &rPropertyNames) override
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
virtual css::uno::Type SAL_CALL getElementType() override
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
virtual ~SwXParagraph() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL setPropertyToDefault(const OUString &rPropertyName) override
void attachToText(SwXText &rParent, SwTextNode &rTextNode)
for SwXText
virtual OUString SAL_CALL getString() override
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
virtual void SAL_CALL dispose() override
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
bool SelectPaM(SwPaM &rPaM)
make rPaM select the paragraph
virtual ::sfx2::Metadatable * GetCoreObject() override
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
::sw::UnoImplPtr< Impl > m_pImpl
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString &rServiceName) override
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
SwXParagraph()
descriptor
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &rPropertyNames) override
virtual css::uno::Sequence< css::beans::GetPropertyTolerantResult > SAL_CALL getPropertyValuesTolerant(const css::uno::Sequence< OUString > &rPropertyNames) override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
const SwTextNode * GetTextNode() const
virtual sal_Bool SAL_CALL hasElements() override
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &rPropertyName) override
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
bool IsDescriptor() const
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual css::uno::Sequence< css::beans::SetPropertyTolerantFailed > SAL_CALL setPropertyValuesTolerant(const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Sequence< css::uno::Any > &rValues) override
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &rPropertyName) override
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
static rtl::Reference< SwXParagraph > CreateXParagraph(SwDoc &rDoc, SwTextNode *pTextNode, css::uno::Reference< css::text::XText > const &xParentText=nullptr, const sal_Int32 nSelStart=-1, const sal_Int32 nSelEnd=- 1)
virtual css::uno::Sequence< css::beans::GetDirectPropertyTolerantResult > SAL_CALL getDirectPropertyValuesTolerant(const css::uno::Sequence< OUString > &rPropertyNames) override
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Sequence< css::uno::Any > &rValues) override
rtl::Reference< SwXTextPortionEnumeration > createTextFieldsEnumeration()
tries to return less data, but may return more than just text fields
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
void disposeAndClear(::std::unique_lock<::std::mutex > &rGuard, const css::lang::EventObject &rEvt)
sal_Int32 getLength(std::unique_lock< std::mutex > &rGuard) const
css::uno::Type const & get()
std::pair< const_iterator, bool > insert(Value &&x)
#define FN_UNO_ANCHOR_TYPE
Definition: cmdid.h:597
#define FN_UNO_NUM_RULES
Definition: cmdid.h:553
#define FN_UNO_LIST_ID
Definition: cmdid.h:636
#define FN_UNO_PARA_CONDITIONAL_STYLE_NAME
Definition: cmdid.h:592
#define FN_UNO_PAGE_STYLE
Definition: cmdid.h:547
#define FN_UNO_ANCHOR_TYPES
Definition: cmdid.h:590
#define FN_UNO_PARA_STYLE
Definition: cmdid.h:546
#define FN_UNO_TEXT_WRAP
Definition: cmdid.h:596
Any value
#define TOOLS_WARN_EXCEPTION(area, stream)
sal_Int16 nValue
bool isATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:470
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
constexpr sal_uInt16 RES_FRMATR_END(141)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(111)
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(110)
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(107)
const char * name
#define SAL_WARN(area, stream)
MapUnit
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
bool needToMapFillItemsToSvxBrushItemTypes(const SfxItemSet &rSet, sal_uInt16 const nMID)
helper to check if fill style is set to color or bitmap and thus formerly used SvxBrushItem parts nee...
void GetCurPageStyle(SwPaM const &rPaM, OUString &rString)
void SetPropertyValue(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName, const css::uno::Any &rValue, const SetAttrMode nAttrMode=SetAttrMode::DEFAULT)
void SetPropertyValues(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const css::uno::Sequence< css::beans::PropertyValue > &rPropertyValues, const SetAttrMode nAttrMode=SetAttrMode::DEFAULT)
SwFormatColl * GetCurTextFormatColl(SwPaM &rPam, const bool bConditional)
Definition: unoobj.cxx:674
void getNumberingProperty(SwPaM &rPam, PropertyState &eState, Any *pAny)
bool IsStartOfPara(SwPaM &rUnoCursor)
void SetString(SwCursor &rCursor, std::u16string_view aString)
Definition: unoobj2.cxx:1623
bool getCursorPropertyValue(const SfxItemPropertyMapEntry &rEntry, SwPaM &rPam, Any *pAny, PropertyState &eState, const SwTextNode *pNode)
void GetTextFromPam(SwPaM &rPam, OUString &rBuffer, SwRootFrame const *pLayout=nullptr)
Definition: unoobj.cxx:131
bool IsEndOfPara(SwPaM &rUnoCursor)
void resetCursorPropertyValue(const SfxItemPropertyMapEntry &rEntry, SwPaM &rPam)
void SelectPam(SwPaM &rPam, const bool bExpand)
Definition: unoobj.cxx:116
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Any SAL_CALL getCaughtException()
int i
uno::Reference< text::XText > CreateParentXText(SwDoc &rDoc, const SwPosition &rPos)
Definition: unoobj2.cxx:1218
bool GetDefaultTextContentValue(css::uno::Any &rAny, std::u16string_view rPropertyName, sal_uInt16 nWID=0)
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:1225
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:48
SwMoveFnCollection const & fnParaEnd
Definition: paminit.cxx:49
static SfxItemSet & rSet
PropertyMoreFlags nMoreFlags
css::uno::Type aType
Marks a position in the document model.
Definition: pam.hxx:37
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
Definition: pam.cxx:230
void SetContent(sal_Int32 nContentIndex)
Set content index, only valid to call this if the position points to a SwContentNode subclass.
Definition: pam.cxx:266
static rtl::Reference< SwXParaFrameEnumeration > Create(const SwPaM &rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat *const pFormat=nullptr)
Definition: unoobj2.cxx:1692
unsigned char sal_Bool
SVXCORE_DLLPUBLIC std::unique_ptr< SvxBrushItem > getSvxBrushItemFromSourceSet(const SfxItemSet &rSourceSet, sal_uInt16 nBackgroundID, bool bSearchInParents=true, bool bXMLImportHack=false)
void SvxUnoConvertToMM(const MapUnit eSourceMapUnit, uno::Any &rMetric) noexcept
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:87
#define OWN_ATTR_FILLBMP_MODE
Definition: unomap.hxx:332
#define PROPERTY_MAP_PARAGRAPH
Definition: unomap.hxx:62
#define MID_SURROUND_SURROUNDTYPE
Definition: unomid.h:29
#define MID_ANCHOR_ANCHORTYPE
Definition: unomid.h:43
@ PARAFRAME_PORTION_PARAGRAPH
static beans::PropertyState lcl_SwXParagraph_getPropertyState(const SwTextNode &rTextNode, const SwAttrSet **ppSet, const SfxItemPropertyMapEntry &rEntry, bool &rAttrSetFetched)
constexpr OUStringLiteral UNO_NAME_ANCHOR_TYPE
Definition: unoprnms.hxx:243
constexpr OUStringLiteral UNO_NAME_TEXT_WRAP
Definition: unoprnms.hxx:331
constexpr OUStringLiteral UNO_NAME_ANCHOR_TYPES
Definition: unoprnms.hxx:244
constexpr TypedWhichId< SfxMetricItem > XATTR_FILLBMP_SIZEX(XATTR_FILL_FIRST+9)
constexpr TypedWhichId< XFillBmpSizeYItem > XATTR_FILLBMP_SIZEY(XATTR_FILL_FIRST+10)
constexpr TypedWhichId< XFillBmpStretchItem > XATTR_FILLBMP_STRETCH(XATTR_FILL_FIRST+16)
constexpr sal_uInt16 XATTR_FILL_LAST(XATTR_FILLUSESLIDEBACKGROUND)
constexpr TypedWhichId< XFillBmpTileItem > XATTR_FILLBMP_TILE(XATTR_FILL_FIRST+7)
const SvXMLTokenMapEntry aTypes[]