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