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 <utility>
41#include <vcl/svapp.hxx>
42#include <docsh.hxx>
43#include <swunohelper.hxx>
44
45#include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
46#include <com/sun/star/beans/GetPropertyTolerantResult.hpp>
47#include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
48#include <com/sun/star/beans/PropertyAttribute.hpp>
49#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
50#include <com/sun/star/text/WrapTextMode.hpp>
51#include <com/sun/star/text/TextContentAnchorType.hpp>
52
53#include <com/sun/star/drawing/BitmapMode.hpp>
55#include <editeng/unoipset.hxx>
56#include <svl/listener.hxx>
58#include <svx/xflbmtit.hxx>
59#include <svx/xflbstit.hxx>
60
61using namespace ::com::sun::star;
62
63namespace {
64
65class SwParaSelection
66{
67 SwCursor & m_rCursor;
68public:
69 explicit SwParaSelection(SwCursor & rCursor);
70 ~SwParaSelection();
71};
72
73}
74
75SwParaSelection::SwParaSelection(SwCursor & rCursor)
76 : m_rCursor(rCursor)
77{
78 if (m_rCursor.HasMark())
79 {
80 m_rCursor.DeleteMark();
81 }
82 // is it at the start?
83 if (m_rCursor.GetPoint()->GetContentIndex() != 0)
84 {
85 m_rCursor.MovePara(GoCurrPara, fnParaStart);
86 }
87 // or at the end already?
88 if (m_rCursor.GetPoint()->GetContentIndex() != m_rCursor.GetPointContentNode()->Len())
89 {
90 m_rCursor.SetMark();
91 m_rCursor.MovePara(GoCurrPara, fnParaEnd);
92 }
93}
94
95SwParaSelection::~SwParaSelection()
96{
97 if (m_rCursor.GetPoint()->GetContentIndex() != 0)
98 {
99 m_rCursor.DeleteMark();
100 m_rCursor.MovePara(GoCurrPara, fnParaStart);
101 }
102}
103
106static beans::PropertyState lcl_SwXParagraph_getPropertyState(
107 const SwTextNode& rTextNode,
108 const SwAttrSet** ppSet,
109 const SfxItemPropertyMapEntry& rEntry,
110 bool &rAttrSetFetched );
111
113 : public SvtListener
114{
115public:
118 std::mutex m_Mutex; // just for OInterfaceContainerHelper4
124 OUString m_sText;
125 uno::Reference<text::XText> m_xParentText;
127
129 SwTextNode* const pTextNode = nullptr, uno::Reference<text::XText> xParent = nullptr,
130 const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = -1)
131 : m_rThis(rThis)
133 , m_bIsDescriptor(nullptr == pTextNode)
134 , m_nSelectionStartPos(nSelStart)
135 , m_nSelectionEndPos(nSelEnd)
136 , m_xParentText(std::move(xParent))
137 , m_pTextNode(pTextNode)
138 {
139 m_pTextNode && StartListening(m_pTextNode->GetNotifier());
140 }
141
143 return m_pTextNode;
144 }
145
147 if (!m_pTextNode) {
148 throw uno::RuntimeException("SwXParagraph: disposed or invalid", nullptr);
149 }
150 return *m_pTextNode;
151 }
152
153 bool IsDescriptor() const { return m_bIsDescriptor; }
154
161 const uno::Sequence< OUString >& rPropertyNames,
162 const uno::Sequence< uno::Any >& rValues);
163
167 uno::Sequence< uno::Any >
169 const uno::Sequence< OUString >& rPropertyNames);
170
173 const SfxItemPropertyMapEntry& rEntry,
174 const SfxItemSet& rSet,
175 uno::Any& rAny ) const;
176
178 uno::Sequence< beans::GetDirectPropertyTolerantResult >
180 const uno::Sequence< OUString >& rPropertyNames,
181 bool bDirectValuesOnly);
182protected:
183 virtual void Notify(const SfxHint& rHint) override;
184
185};
186
188{
189 if(rHint.GetId() == SfxHintId::Dying)
190 {
191 m_pTextNode = nullptr;
192 std::unique_lock aGuard(m_Mutex);
193 if (m_EventListeners.getLength(aGuard) != 0)
194 {
195 // fdo#72695: if UNO object is already dead, don't revive it with event
196 // The specific pattern we are guarding against is this:
197 // [1] Thread1 takes the SolarMutex
198 // [2] Thread2 decrements the SwXParagraph reference count, and calls the
199 // SwXParagraph destructor, which tries to take the SolarMutex, and blocks
200 // [3] Thread1 destroys a SwTextNode, which calls this Notify event, which results
201 // in a double-free if we construct the xThis object.
202 uno::Reference<uno::XInterface> const xThis(m_wThis);
203 if (!xThis.is())
204 { // fdo#72695: if UNO object is already dead, don't revive it with event
205 return;
206 }
207 lang::EventObject const ev(xThis);
209 }
210 }
211}
212
214 : m_pImpl( new SwXParagraph::Impl(*this) )
215{
216}
217
219 uno::Reference< text::XText > const & xParent,
220 SwTextNode & rTextNode,
221 const sal_Int32 nSelStart, const sal_Int32 nSelEnd)
222 : m_pImpl(
223 new SwXParagraph::Impl(*this, &rTextNode, xParent, nSelStart, nSelEnd))
224{
225}
226
228{
229}
230
232{
233 return m_pImpl->GetTextNode();
234}
235
237{
238 return m_pImpl->IsDescriptor();
239}
240
243 uno::Reference< text::XText> const& i_xParent,
244 const sal_Int32 nSelStart, const sal_Int32 nSelEnd)
245{
246 // re-use existing SwXParagraph
247 // #i105557#: do not iterate over the registered clients: race condition
249 if (pTextNode && (-1 == nSelStart) && (-1 == nSelEnd))
250 { // only use cache if no selection!
251 xParagraph = pTextNode->GetXParagraph();
252 }
253 if (xParagraph.is())
254 {
255 return xParagraph;
256 }
257
258 // create new SwXParagraph
259 uno::Reference<text::XText> xParentText(i_xParent);
260 if (!xParentText.is() && pTextNode)
261 {
262 SwPosition Pos(*pTextNode);
263 xParentText.set(::sw::CreateParentXText( rDoc, Pos ));
264 }
265 SwXParagraph *const pXPara( pTextNode
266 ? new SwXParagraph(xParentText, *pTextNode, nSelStart, nSelEnd)
267 : new SwXParagraph);
268 // this is why the constructor is private: need to acquire pXPara here
269 xParagraph.set(pXPara);
270 // in order to initialize the weak pointer cache in the core object
271 if (pTextNode && (-1 == nSelStart) && (-1 == nSelEnd))
272 {
273 pTextNode->SetXParagraph(xParagraph);
274 }
275 // need a permanent Reference to initialize m_wThis
276 pXPara->m_pImpl->m_wThis = xParagraph.get();
277 return xParagraph;
278}
279
281{
282 SwTextNode const*const pTextNode( GetTextNode() );
283
284 if (!pTextNode)
285 {
286 return false;
287 }
288
289 rPaM.GetPoint()->Assign( *pTextNode );
290 // set selection to the whole paragraph
291 rPaM.SetMark();
292 rPaM.GetMark()->SetContent( pTextNode->GetText().getLength() );
293 return true;
294}
295
296const uno::Sequence< sal_Int8 > & SwXParagraph::getUnoTunnelId()
297{
298 static const comphelper::UnoIdInit theSwXParagraphUnoTunnelId;
299 return theSwXParagraphUnoTunnelId.getSeq();
300}
301
302sal_Int64 SAL_CALL
303SwXParagraph::getSomething(const uno::Sequence< sal_Int8 >& rId)
304{
305 return comphelper::getSomethingImpl<SwXParagraph>(rId, this);
306}
307
308OUString SAL_CALL
310{
311 return "SwXParagraph";
312}
313
314sal_Bool SAL_CALL
315SwXParagraph::supportsService(const OUString& rServiceName)
316{
317 return cppu::supportsService(this, rServiceName);
318}
319
320uno::Sequence< OUString > SAL_CALL
322{
323 return {
324 "com.sun.star.text.TextContent",
325 "com.sun.star.text.Paragraph",
326 "com.sun.star.style.CharacterProperties",
327 "com.sun.star.style.CharacterPropertiesAsian",
328 "com.sun.star.style.CharacterPropertiesComplex",
329 "com.sun.star.style.ParagraphProperties",
330 "com.sun.star.style.ParagraphPropertiesAsian",
331 "com.sun.star.style.ParagraphPropertiesComplex"
332 };
333}
334
335void
337{
338 OSL_ENSURE(m_pImpl->m_bIsDescriptor, "Paragraph is not a descriptor");
339 if (!m_pImpl->m_bIsDescriptor)
340 return;
341
342 m_pImpl->m_bIsDescriptor = false;
343 m_pImpl->EndListeningAll();
344 m_pImpl->StartListening(rTextNode.GetNotifier());
345 rTextNode.SetXParagraph(this);
346 m_pImpl->m_xParentText = &rParent;
347 if (!m_pImpl->m_sText.isEmpty())
348 {
349 try { setString(m_pImpl->m_sText); }
350 catch(...){}
351 m_pImpl->m_sText.clear();
352 }
353}
354
355uno::Reference< beans::XPropertySetInfo > SAL_CALL
357{
359
360 static uno::Reference< beans::XPropertySetInfo > xRef =
361 m_pImpl->m_rPropSet.getPropertySetInfo();
362 return xRef;
363}
364
365void SAL_CALL
366SwXParagraph::setPropertyValue(const OUString& rPropertyName,
367 const uno::Any& rValue)
368{
369 SolarMutexGuard aGuard;
370 m_pImpl->SetPropertyValues_Impl( { rPropertyName }, { rValue } );
371}
372
374SwXParagraph::getPropertyValue(const OUString& rPropertyName)
375{
376 SolarMutexGuard aGuard;
377 uno::Sequence<OUString> aPropertyNames { rPropertyName };
378 const uno::Sequence< uno::Any > aRet =
379 m_pImpl->GetPropertyValues_Impl(aPropertyNames);
380 return aRet.getConstArray()[0];
381}
382
384 const uno::Sequence< OUString >& rPropertyNames,
385 const uno::Sequence< uno::Any >& rValues )
386{
387 SwTextNode & rTextNode(GetTextNodeOrThrow());
388
389 SwPosition aPos( rTextNode );
390 SwCursor aCursor( aPos, nullptr );
391 const OUString* pPropertyNames = rPropertyNames.getConstArray();
392 const uno::Any* pValues = rValues.getConstArray();
394 SwParaSelection aParaSel( aCursor );
395
396 uno::Sequence< beans::PropertyValue > aValues( rPropertyNames.getLength() );
397 auto aValuesRange = asNonConstRange(aValues);
398 for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
399 {
400 SfxItemPropertyMapEntry const*const pEntry =
401 rMap.getByName( pPropertyNames[nProp] );
402 if (!pEntry)
403 {
404 throw beans::UnknownPropertyException(
405 "Unknown property: " + pPropertyNames[nProp],
406 static_cast< cppu::OWeakObject * >(&m_rThis));
407 }
408 if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
409 {
410 throw beans::PropertyVetoException(
411 "Property is read-only: " + pPropertyNames[nProp],
412 static_cast< cppu::OWeakObject * >(&m_rThis));
413 }
414 aValuesRange[nProp].Name = pPropertyNames[nProp];
415 aValuesRange[nProp].Value = pValues[nProp];
416 }
418}
419
421 const uno::Sequence< OUString >& rPropertyNames,
422 const uno::Sequence< uno::Any >& rValues )
423{
424 SolarMutexGuard aGuard;
425
426 // workaround for bad designed API
427 try
428 {
429 m_pImpl->SetPropertyValues_Impl( rPropertyNames, rValues );
430 }
431 catch (const beans::UnknownPropertyException &rException)
432 {
433 // wrap the original (here not allowed) exception in
434 // a lang::WrappedTargetException that gets thrown instead.
435 lang::WrappedTargetException aWExc;
436 aWExc.TargetException <<= rException;
437 throw aWExc;
438 }
439}
440
441// Support for DrawingLayer FillStyles for GetPropertyValue() usages
443 const SfxItemPropertyMapEntry& rEntry,
444 const SfxItemSet& rSet,
445 uno::Any& rAny ) const
446{
447 bool bDone(false);
448
449 switch(rEntry.nWID)
450 {
451 case RES_BACKGROUND:
452 {
453 const std::unique_ptr<SvxBrushItem> aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
454
455 if(!aOriginalBrushItem->QueryValue(rAny, rEntry.nMemberId))
456 {
457 OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
458 }
459
460 bDone = true;
461 break;
462 }
464 {
465 if (rSet.Get(XATTR_FILLBMP_TILE).GetValue())
466 {
467 rAny <<= drawing::BitmapMode_REPEAT;
468 }
469 else if (rSet.Get(XATTR_FILLBMP_STRETCH).GetValue())
470 {
471 rAny <<= drawing::BitmapMode_STRETCH;
472 }
473 else
474 {
475 rAny <<= drawing::BitmapMode_NO_REPEAT;
476 }
477
478 bDone = true;
479 break;
480 }
481 default: break;
482 }
483
484 if(bDone)
485 return;
486
487 // fallback to standard get value implementation used before this helper was created
488 m_rPropSet.getPropertyValue(rEntry, rSet, rAny);
489
490 if(rEntry.aType == cppu::UnoType<sal_Int16>::get() && rEntry.aType != rAny.getValueType())
491 {
492 // since the sfx uInt16 item now exports a sal_Int32, we may have to fix this here
493 sal_Int32 nValue(0);
494
495 if (rAny >>= nValue)
496 {
497 rAny <<= static_cast<sal_Int16>(nValue);
498 }
499 }
500
501 // check for needed metric translation
502 if(!(rEntry.nMoreFlags & PropertyMoreFlags::METRIC_ITEM))
503 return;
504
505 bool bDoIt(true);
506
507 if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
508 {
509 // exception: If these ItemTypes are used, do not convert when these are negative
510 // since this means they are intended as percent values
511 sal_Int32 nValue = 0;
512
513 if(rAny >>= nValue)
514 {
515 bDoIt = nValue > 0;
516 }
517 }
518
519 if(bDoIt)
520 {
521 const MapUnit eMapUnit(rSet.GetPool()->GetMetric(rEntry.nWID));
522
523 if(eMapUnit != MapUnit::Map100thMM)
524 {
525 SvxUnoConvertToMM(eMapUnit, rAny);
526 }
527 }
528}
529
531 const uno::Sequence< OUString > & rPropertyNames )
532{
533 SwTextNode & rTextNode(GetTextNodeOrThrow());
534
535 uno::Sequence< uno::Any > aValues(rPropertyNames.getLength());
536 SwPaM aPam( rTextNode );
537 uno::Any* pValues = aValues.getArray();
538 const OUString* pPropertyNames = rPropertyNames.getConstArray();
539 const SfxItemPropertyMap &rMap = m_rPropSet.getPropertyMap();
540 const SwAttrSet& rAttrSet( rTextNode.GetSwAttrSet() );
541 for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
542 {
543 SfxItemPropertyMapEntry const*const pEntry =
544 rMap.getByName( pPropertyNames[nProp] );
545 if (!pEntry)
546 {
547 throw beans::UnknownPropertyException(
548 "Unknown property: " + pPropertyNames[nProp],
549 static_cast< cppu::OWeakObject * >(&m_rThis));
550 }
552 pValues[nProp], pPropertyNames[nProp], pEntry->nWID))
553 {
554 beans::PropertyState eTemp;
556 *pEntry, aPam, &(pValues[nProp]), eTemp, &rTextNode );
557 if (!bDone)
558 {
559 GetSinglePropertyValue_Impl(*pEntry, rAttrSet, pValues[nProp]);
560 }
561 }
562 }
563 return aValues;
564}
565
566uno::Sequence< uno::Any > SAL_CALL
567SwXParagraph::getPropertyValues(const uno::Sequence< OUString >& rPropertyNames)
568{
569 SolarMutexGuard aGuard;
570 uno::Sequence< uno::Any > aValues;
571
572 // workaround for bad designed API
573 try
574 {
575 aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames );
576 }
577 catch (beans::UnknownPropertyException &)
578 {
579 css::uno::Any anyEx = cppu::getCaughtException();
580 throw css::lang::WrappedTargetRuntimeException("Unknown property exception caught",
581 static_cast < cppu::OWeakObject * > ( this ), anyEx );
582 }
583 catch (lang::WrappedTargetException &)
584 {
585 css::uno::Any anyEx = cppu::getCaughtException();
586 throw css::lang::WrappedTargetRuntimeException("WrappedTargetException caught",
587 static_cast < cppu::OWeakObject * > ( this ), anyEx );
588 }
589
590 return aValues;
591}
592
594 const uno::Sequence< OUString >& /*aPropertyNames*/,
595 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
596{
597 OSL_FAIL("SwXParagraph::addPropertiesChangeListener(): not implemented");
598}
599
601 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
602{
603 OSL_FAIL("SwXParagraph::removePropertiesChangeListener(): not implemented");
604}
605
607 const uno::Sequence< OUString >& /*aPropertyNames*/,
608 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
609{
610 OSL_FAIL("SwXParagraph::firePropertiesChangeEvent(): not implemented");
611}
612
613/* disabled for #i46921# */
614
615uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL
617 const uno::Sequence< OUString >& rPropertyNames,
618 const uno::Sequence< uno::Any >& rValues )
619{
620 SolarMutexGuard aGuard;
621
622 if (rPropertyNames.getLength() != rValues.getLength())
623 {
624 throw lang::IllegalArgumentException();
625 }
626
627 SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
628
629 //SwNode& rTextNode = pUnoCursor->GetPoint()->GetNode();
630 //const SwAttrSet& rAttrSet = static_cast<SwTextNode&>(rTextNode).GetSwAttrSet();
631 //sal_uInt16 nAttrCount = rAttrSet.Count();
632
633 const sal_Int32 nProps = rPropertyNames.getLength();
634 const OUString *pProp = rPropertyNames.getConstArray();
635
636 //sal_Int32 nVals = rValues.getLength();
637 const uno::Any *pValue = rValues.getConstArray();
638
639 sal_Int32 nFailed = 0;
640 uno::Sequence< beans::SetPropertyTolerantFailed > aFailed( nProps );
641 beans::SetPropertyTolerantFailed *pFailed = aFailed.getArray();
642
643 // get entry to start with
644 const SfxItemPropertyMap &rPropMap =
645 m_pImpl->m_rPropSet.getPropertyMap();
646
647 SwPosition aPos( rTextNode );
648 SwCursor aCursor( aPos, nullptr );
649 SwParaSelection aParaSel( aCursor );
650 for (sal_Int32 i = 0; i < nProps; ++i)
651 {
652 try
653 {
654 pFailed[ nFailed ].Name = pProp[i];
655
656 SfxItemPropertyMapEntry const*const pEntry =
657 rPropMap.getByName( pProp[i] );
658 if (!pEntry)
659 {
660 pFailed[ nFailed++ ].Result =
661 beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
662 }
663 else
664 {
665 // set property value
666 // (compare to SwXParagraph::setPropertyValues)
667 if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
668 {
669 pFailed[ nFailed++ ].Result =
670 beans::TolerantPropertySetResultType::PROPERTY_VETO;
671 }
672 else
673 {
675 aCursor, m_pImpl->m_rPropSet, pProp[i], pValue[i]);
676 }
677 }
678 }
679 catch (beans::UnknownPropertyException &)
680 {
681 // should not occur because property was searched for before
682 TOOLS_WARN_EXCEPTION( "sw", "unexpected exception caught" );
683 pFailed[ nFailed++ ].Result =
684 beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
685 }
686 catch (lang::IllegalArgumentException &)
687 {
688 pFailed[ nFailed++ ].Result =
689 beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
690 }
691 catch (beans::PropertyVetoException &)
692 {
693 pFailed[ nFailed++ ].Result =
694 beans::TolerantPropertySetResultType::PROPERTY_VETO;
695 }
696 catch (lang::WrappedTargetException &)
697 {
698 pFailed[ nFailed++ ].Result =
699 beans::TolerantPropertySetResultType::WRAPPED_TARGET;
700 }
701 }
702
703 aFailed.realloc( nFailed );
704 return aFailed;
705}
706
707uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL
709 const uno::Sequence< OUString >& rPropertyNames )
710{
711 SolarMutexGuard aGuard;
712
713 const uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes(
714 m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, false ) );
715
716 // copy temporary result to final result type
717 const sal_Int32 nLen = aTmpRes.getLength();
718 uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen );
719 std::copy(aTmpRes.begin(), aTmpRes.end(), aRes.getArray());
720 return aRes;
721}
722
723uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL
725 const uno::Sequence< OUString >& rPropertyNames )
726{
727 SolarMutexGuard aGuard;
728
729 return m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, true );
730}
731
732uno::Sequence< beans::GetDirectPropertyTolerantResult >
734 const uno::Sequence< OUString >& rPropertyNames,
735 bool bDirectValuesOnly )
736{
737 SolarMutexGuard aGuard;
738
739 SwTextNode & rTextNode(GetTextNodeOrThrow());
740
741 // #i46786# Use SwAttrSet pointer for determining the state.
742 // Use the value SwAttrSet (from the paragraph OR the style)
743 // for determining the actual value(s).
744 const SwAttrSet* pAttrSet = rTextNode.GetpSwAttrSet();
745 const SwAttrSet& rValueAttrSet = rTextNode.GetSwAttrSet();
746
747 sal_Int32 nProps = rPropertyNames.getLength();
748
749 uno::Sequence< beans::GetDirectPropertyTolerantResult > aResult( nProps );
750 beans::GetDirectPropertyTolerantResult *pResult = aResult.getArray();
751 sal_Int32 nIdx = 0;
752
753 // get entry to start with
754 const SfxItemPropertyMap &rPropMap = m_rPropSet.getPropertyMap();
755
756 for (const OUString& rProp : rPropertyNames)
757 {
758 OSL_ENSURE( nIdx < nProps, "index out of bounds" );
759 beans::GetDirectPropertyTolerantResult &rResult = pResult[nIdx];
760
761 try
762 {
763 rResult.Name = rProp;
764
765 SfxItemPropertyMapEntry const*const pEntry =
766 rPropMap.getByName( rProp );
767 if (!pEntry) // property available?
768 {
769 rResult.Result =
770 beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
771 }
772 else
773 {
774 // get property state
775 // (compare to SwXParagraph::getPropertyState)
776 bool bAttrSetFetched = true;
777 beans::PropertyState eState = lcl_SwXParagraph_getPropertyState(
778 rTextNode, &pAttrSet, *pEntry, bAttrSetFetched );
779 rResult.State = eState;
780
781 rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE;
782 if (!bDirectValuesOnly ||
783 (beans::PropertyState_DIRECT_VALUE == eState))
784 {
785 // get property value
786 // (compare to SwXParagraph::getPropertyValue(s))
787 uno::Any aValue;
789 aValue, rProp, pEntry->nWID ) )
790 {
791 SwPaM aPam( rTextNode );
792 // handle properties that are not part of the attribute
793 // and thus only pretended to be paragraph attributes
794 beans::PropertyState eTemp;
795 const bool bDone =
797 *pEntry, aPam, &aValue, eTemp, &rTextNode );
798
799 // if not found try the real paragraph attributes...
800 if (!bDone)
801 {
802 GetSinglePropertyValue_Impl(*pEntry, rValueAttrSet, aValue);
803 }
804 }
805
806 rResult.Value = aValue;
807 rResult.Result = beans::TolerantPropertySetResultType::SUCCESS;
808
809 nIdx++;
810 }
811 // this assertion should never occur!
812 OSL_ENSURE( nIdx < 1 || pResult[nIdx - 1].Result != beans::TolerantPropertySetResultType::UNKNOWN_FAILURE,
813 "unknown failure while retrieving property" );
814
815 }
816 }
817 catch (beans::UnknownPropertyException &)
818 {
819 // should not occur because property was searched for before
820 TOOLS_WARN_EXCEPTION( "sw", "unexpected exception caught" );
821 rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
822 }
823 catch (lang::IllegalArgumentException &)
824 {
825 rResult.Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
826 }
827 catch (beans::PropertyVetoException &)
828 {
829 rResult.Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
830 }
831 catch (lang::WrappedTargetException &)
832 {
833 rResult.Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET;
834 }
835 }
836
837 // resize to actually used size
838 aResult.realloc( nIdx );
839
840 return aResult;
841}
842
844 uno::Any& rAny, std::u16string_view rPropertyName, sal_uInt16 nWID)
845{
846 if(!nWID)
847 {
848 if(rPropertyName == u"" UNO_NAME_ANCHOR_TYPE)
849 nWID = FN_UNO_ANCHOR_TYPE;
850 else if(rPropertyName == u"" UNO_NAME_ANCHOR_TYPES)
851 nWID = FN_UNO_ANCHOR_TYPES;
852 else if(rPropertyName == u"" UNO_NAME_TEXT_WRAP)
853 nWID = FN_UNO_TEXT_WRAP;
854 else
855 return false;
856 }
857
858 switch(nWID)
859 {
860 case FN_UNO_TEXT_WRAP: rAny <<= text::WrapTextMode_NONE; break;
861 case FN_UNO_ANCHOR_TYPE: rAny <<= text::TextContentAnchorType_AT_PARAGRAPH; break;
863 { uno::Sequence<text::TextContentAnchorType> aTypes { text::TextContentAnchorType_AT_PARAGRAPH };
864 rAny <<= aTypes;
865 }
866 break;
867 default:
868 return false;
869 }
870 return true;
871}
872
873void SAL_CALL
875 const OUString& /*rPropertyName*/,
876 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
877{
878 OSL_FAIL("SwXParagraph::addPropertyChangeListener(): not implemented");
879}
880
881void SAL_CALL
883 const OUString& /*rPropertyName*/,
884 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
885{
886 OSL_FAIL("SwXParagraph::removePropertyChangeListener(): not implemented");
887}
888
889void SAL_CALL
891 const OUString& /*rPropertyName*/,
892 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
893{
894 OSL_FAIL("SwXParagraph::addVetoableChangeListener(): not implemented");
895}
896
897void SAL_CALL
899 const OUString& /*rPropertyName*/,
900 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
901{
902 OSL_FAIL("SwXParagraph::removeVetoableChangeListener(): not implemented");
903}
904
905static beans::PropertyState lcl_SwXParagraph_getPropertyState(
906 const SwTextNode& rTextNode,
907 const SwAttrSet** ppSet,
908 const SfxItemPropertyMapEntry& rEntry,
909 bool &rAttrSetFetched)
910{
911 beans::PropertyState eRet(beans::PropertyState_DEFAULT_VALUE);
912
913 if(!(*ppSet) && !rAttrSetFetched)
914 {
915 (*ppSet) = rTextNode.GetpSwAttrSet();
916 rAttrSetFetched = true;
917 }
918
919 SwPosition aPos(rTextNode);
920 SwPaM aPam(aPos);
921 bool bDone(false);
922
923 switch(rEntry.nWID)
924 {
925 case FN_UNO_NUM_RULES:
926 {
927 // if numbering is set, return it; else do nothing
929 bDone = true;
930 break;
931 }
932 case FN_UNO_LIST_ID:
933 {
934 SwNumRule* pNumRule = rTextNode.GetNumRule();
935 if (pNumRule && pNumRule->HasContinueList())
936 {
937 eRet = beans::PropertyState_DIRECT_VALUE;
938 }
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:763
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:493
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
Definition: swcrsr.cxx:2284
Definition: doc.hxx:194
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:321
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:1779
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1326
SwDocShell * GetDocShell()
Definition: doc.hxx:1359
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:111
SAL_DLLPRIVATE unotools::WeakReference< SwXParagraph > const & GetXParagraph() const
Definition: ndtxt.hxx:830
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
Definition: ndtxt.cxx:2907
const OUString & GetText() const
Definition: ndtxt.hxx:242
SAL_DLLPRIVATE void SetXParagraph(rtl::Reference< SwXParagraph > const &xParagraph)
Definition: ndtxt.cxx:5511
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 sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) 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
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
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
const css::uno::Sequence< sal_Int8 > & getSeq() const
css::uno::Type const & get()
std::pair< const_iterator, bool > insert(Value &&x)
#define FN_UNO_ANCHOR_TYPE
Definition: cmdid.h:583
#define FN_UNO_NUM_RULES
Definition: cmdid.h:540
#define FN_UNO_LIST_ID
Definition: cmdid.h:622
#define FN_UNO_PARA_CONDITIONAL_STYLE_NAME
Definition: cmdid.h:578
#define FN_UNO_PAGE_STYLE
Definition: cmdid.h:534
#define FN_UNO_ANCHOR_TYPES
Definition: cmdid.h:576
#define FN_UNO_PARA_STYLE
Definition: cmdid.h:533
#define FN_UNO_TEXT_WRAP
Definition: cmdid.h:582
#define TOOLS_WARN_EXCEPTION(area, stream)
sal_Int16 nValue
constexpr sal_uInt16 RES_FRMATR_END(133)
bool isATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:465
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(101)
constexpr sal_uInt16 RES_PARATR_BEGIN(RES_TXTATR_END)
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
#define SAL_WARN(area, stream)
MapUnit
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:615
void getNumberingProperty(SwPaM &rPam, PropertyState &eState, Any *pAny)
bool IsStartOfPara(SwPaM &rUnoCursor)
void SetString(SwCursor &rCursor, std::u16string_view aString)
Definition: unoobj2.cxx:1648
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
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:1228
bool GetDefaultTextContentValue(css::uno::Any &rAny, std::u16string_view rPropertyName, sal_uInt16 nWID=0)
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:1224
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:1717
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:315
#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)
#define UNO_NAME_ANCHOR_TYPES
Definition: unoprnms.hxx:232
#define UNO_NAME_TEXT_WRAP
Definition: unoprnms.hxx:319
#define UNO_NAME_ANCHOR_TYPE
Definition: unoprnms.hxx:231
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[]