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 
23 #include <cppuhelper/exc_hlp.hxx>
25 #include <osl/diagnose.h>
26 
27 #include <cmdid.h>
28 #include <unomid.h>
29 #include <unoparaframeenum.hxx>
30 #include <unotext.hxx>
31 #include <unotextrange.hxx>
32 #include <unoport.hxx>
33 #include <unomap.hxx>
34 #include <unocrsr.hxx>
35 #include <unoprnms.hxx>
36 #include <unocrsrhelper.hxx>
37 #include <doc.hxx>
38 #include <ndtxt.hxx>
39 #include <osl/mutex.hxx>
40 #include <vcl/svapp.hxx>
41 #include <docsh.hxx>
42 #include <swunohelper.hxx>
43 
44 #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
45 #include <com/sun/star/beans/GetPropertyTolerantResult.hpp>
46 #include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
47 #include <com/sun/star/beans/PropertyAttribute.hpp>
48 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
49 #include <com/sun/star/text/WrapTextMode.hpp>
50 #include <com/sun/star/text/TextContentAnchorType.hpp>
51 
52 #include <com/sun/star/drawing/BitmapMode.hpp>
54 #include <editeng/unoipset.hxx>
55 #include <svl/listener.hxx>
57 #include <svx/xflbmtit.hxx>
58 #include <svx/xflbstit.hxx>
59 
60 using namespace ::com::sun::star;
61 
62 
64 {
66 public:
67  explicit SwParaSelection(SwCursor & rCursor);
69 };
70 
72  : m_rCursor(rCursor)
73 {
74  if (m_rCursor.HasMark())
75  {
77  }
78  // is it at the start?
79  if (m_rCursor.GetPoint()->nContent != 0)
80  {
82  }
83  // or at the end already?
85  {
88  }
89 }
90 
92 {
93  if (m_rCursor.GetPoint()->nContent != 0)
94  {
97  }
98 }
99 
102 static beans::PropertyState lcl_SwXParagraph_getPropertyState(
103  const SwTextNode& rTextNode,
104  const SwAttrSet** ppSet,
105  const SfxItemPropertySimpleEntry& rEntry,
106  bool &rAttrSetFetched );
107 
109  : public SvtListener
110 {
111 private:
112  ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
113 
114 public:
116  uno::WeakReference<uno::XInterface> m_wThis;
120  sal_Int32 const m_nSelectionStartPos;
121  sal_Int32 const m_nSelectionEndPos;
122  OUString m_sText;
123  uno::Reference<text::XText> m_xParentText;
125 
127  SwTextNode* const pTextNode = nullptr, uno::Reference<text::XText> const& xParent = nullptr,
128  const sal_Int32 nSelStart = -1, const sal_Int32 nSelEnd = -1)
129  : m_rThis(rThis)
130  , m_EventListeners(m_Mutex)
131  , m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARAGRAPH))
132  , m_bIsDescriptor(nullptr == pTextNode)
133  , m_nSelectionStartPos(nSelStart)
134  , m_nSelectionEndPos(nSelEnd)
135  , m_xParentText(xParent)
136  , m_pTextNode(pTextNode)
137  {
138  m_pTextNode && StartListening(m_pTextNode->GetNotifier());
139  }
140 
142  return m_pTextNode;
143  }
144 
146  if (!m_pTextNode) {
147  throw uno::RuntimeException("SwXParagraph: disposed or invalid", nullptr);
148  }
149  return *m_pTextNode;
150  }
151 
152  bool IsDescriptor() const { return m_bIsDescriptor; }
153 
160  const uno::Sequence< OUString >& rPropertyNames,
161  const uno::Sequence< uno::Any >& rValues);
162 
166  uno::Sequence< uno::Any >
168  const uno::Sequence< OUString >& rPropertyNames);
169 
172  const SfxItemPropertySimpleEntry& rEntry,
173  const SfxItemSet& rSet,
174  uno::Any& rAny ) const;
175 
177  uno::Sequence< beans::GetDirectPropertyTolerantResult >
179  const uno::Sequence< OUString >& rPropertyNames,
180  bool bDirectValuesOnly);
181 protected:
182  virtual void Notify(const SfxHint& rHint) override;
183 
184 };
185 
187 {
188  if(rHint.GetId() == SfxHintId::Dying)
189  {
190  m_pTextNode = nullptr;
191  uno::Reference<uno::XInterface> const xThis(m_wThis);
192  if (!xThis.is())
193  { // fdo#72695: if UNO object is already dead, don't revive it with event
194  return;
195  }
196  lang::EventObject const ev(xThis);
198  }
199 }
200 
202  : m_pImpl( new SwXParagraph::Impl(*this) )
203 {
204 }
205 
207  uno::Reference< text::XText > const & xParent,
208  SwTextNode & rTextNode,
209  const sal_Int32 nSelStart, const sal_Int32 nSelEnd)
210  : m_pImpl(
211  new SwXParagraph::Impl(*this, &rTextNode, xParent, nSelStart, nSelEnd))
212 {
213 }
214 
216 {
217 }
218 
220 {
221  return m_pImpl->GetTextNode();
222 }
223 
225 {
226  return m_pImpl->IsDescriptor();
227 }
228 
229 uno::Reference<text::XTextContent>
231  uno::Reference< text::XText> const& i_xParent,
232  const sal_Int32 nSelStart, const sal_Int32 nSelEnd)
233 {
234  // re-use existing SwXParagraph
235  // #i105557#: do not iterate over the registered clients: race condition
236  uno::Reference<text::XTextContent> xParagraph;
237  if (pTextNode && (-1 == nSelStart) && (-1 == nSelEnd))
238  { // only use cache if no selection!
239  xParagraph.set(pTextNode->GetXParagraph());
240  }
241  if (xParagraph.is())
242  {
243  return xParagraph;
244  }
245 
246  // create new SwXParagraph
247  uno::Reference<text::XText> xParentText(i_xParent);
248  if (!xParentText.is() && pTextNode)
249  {
250  SwPosition Pos(*pTextNode);
251  xParentText.set(::sw::CreateParentXText( rDoc, Pos ));
252  }
253  SwXParagraph *const pXPara( pTextNode
254  ? new SwXParagraph(xParentText, *pTextNode, nSelStart, nSelEnd)
255  : new SwXParagraph);
256  // this is why the constructor is private: need to acquire pXPara here
257  xParagraph.set(pXPara);
258  // in order to initialize the weak pointer cache in the core object
259  if (pTextNode && (-1 == nSelStart) && (-1 == nSelEnd))
260  {
261  pTextNode->SetXParagraph(xParagraph);
262  }
263  // need a permanent Reference to initialize m_wThis
264  pXPara->m_pImpl->m_wThis = xParagraph;
265  return xParagraph;
266 }
267 
269 {
270  SwTextNode const*const pTextNode( GetTextNode() );
271 
272  if (!pTextNode)
273  {
274  return false;
275  }
276 
277  *rPaM.GetPoint() = SwPosition( *pTextNode );
278  // set selection to the whole paragraph
279  rPaM.SetMark();
280  rPaM.GetMark()->nContent = pTextNode->GetText().getLength();
281  return true;
282 }
283 
284 namespace
285 {
286  class theSwXParagraphUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXParagraphUnoTunnelId > {};
287 }
288 
289 const uno::Sequence< sal_Int8 > & SwXParagraph::getUnoTunnelId()
290 {
291  return theSwXParagraphUnoTunnelId::get().getSeq();
292 }
293 
294 sal_Int64 SAL_CALL
295 SwXParagraph::getSomething(const uno::Sequence< sal_Int8 >& rId)
296 {
297  return ::sw::UnoTunnelImpl<SwXParagraph>(rId, this);
298 }
299 
300 OUString SAL_CALL
302 {
303  return OUString("SwXParagraph");
304 }
305 
306 static char const*const g_ServicesParagraph[] =
307 {
308  "com.sun.star.text.TextContent",
309  "com.sun.star.text.Paragraph",
310  "com.sun.star.style.CharacterProperties",
311  "com.sun.star.style.CharacterPropertiesAsian",
312  "com.sun.star.style.CharacterPropertiesComplex",
313  "com.sun.star.style.ParagraphProperties",
314  "com.sun.star.style.ParagraphPropertiesAsian",
315  "com.sun.star.style.ParagraphPropertiesComplex",
316 };
317 
319 
320 sal_Bool SAL_CALL
321 SwXParagraph::supportsService(const OUString& rServiceName)
322 {
323  return cppu::supportsService(this, rServiceName);
324 }
325 
326 uno::Sequence< OUString > SAL_CALL
328 {
331 }
332 
333 void
335 {
336  OSL_ENSURE(m_pImpl->m_bIsDescriptor, "Paragraph is not a descriptor");
337  if (m_pImpl->m_bIsDescriptor)
338  {
339  m_pImpl->m_bIsDescriptor = false;
340  m_pImpl->EndListeningAll();
341  m_pImpl->StartListening(rTextNode.GetNotifier());
342  rTextNode.SetXParagraph(uno::Reference<text::XTextContent>(this));
343  m_pImpl->m_xParentText = &rParent;
344  if (!m_pImpl->m_sText.isEmpty())
345  {
346  try { setString(m_pImpl->m_sText); }
347  catch(...){}
348  m_pImpl->m_sText.clear();
349  }
350  }
351 }
352 
353 uno::Reference< beans::XPropertySetInfo > SAL_CALL
355 {
356  SolarMutexGuard g;
357 
358  static uno::Reference< beans::XPropertySetInfo > xRef =
359  m_pImpl->m_rPropSet.getPropertySetInfo();
360  return xRef;
361 }
362 
363 void SAL_CALL
364 SwXParagraph::setPropertyValue(const OUString& rPropertyName,
365  const uno::Any& rValue)
366 {
367  SolarMutexGuard aGuard;
368  uno::Sequence<OUString> aPropertyNames { rPropertyName };
369  uno::Sequence<uno::Any> aValues(1);
370  aValues.getArray()[0] = rValue;
371  m_pImpl->SetPropertyValues_Impl( aPropertyNames, aValues );
372 }
373 
374 uno::Any
375 SwXParagraph::getPropertyValue(const OUString& rPropertyName)
376 {
377  SolarMutexGuard aGuard;
378  uno::Sequence<OUString> aPropertyNames { rPropertyName };
379  const uno::Sequence< uno::Any > aRet =
380  m_pImpl->GetPropertyValues_Impl(aPropertyNames);
381  return aRet.getConstArray()[0];
382 }
383 
385  const uno::Sequence< OUString >& rPropertyNames,
386  const uno::Sequence< uno::Any >& rValues )
387 {
388  SwTextNode & rTextNode(GetTextNodeOrThrow());
389 
390  SwPosition aPos( rTextNode );
391  SwCursor aCursor( aPos, nullptr );
392  const OUString* pPropertyNames = rPropertyNames.getConstArray();
393  const uno::Any* pValues = rValues.getConstArray();
395  SwParaSelection aParaSel( aCursor );
396 
397  uno::Sequence< beans::PropertyValue > aValues( rPropertyNames.getLength() );
398  for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
399  {
400  SfxItemPropertySimpleEntry 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  aValues[nProp].Name = pPropertyNames[nProp];
415  aValues[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 SfxItemPropertySimpleEntry& 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::shared_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  {
486  // fallback to standard get value implementation used before this helper was created
487  m_rPropSet.getPropertyValue(rEntry, rSet, rAny);
488 
489  if(rEntry.aType == cppu::UnoType<sal_Int16>::get() && rEntry.aType != rAny.getValueType())
490  {
491  // since the sfx uInt16 item now exports a sal_Int32, we may have to fix this here
492  sal_Int32 nValue(0);
493 
494  if (rAny >>= nValue)
495  {
496  rAny <<= static_cast<sal_Int16>(nValue);
497  }
498  }
499 
500  // check for needed metric translation
501  if(rEntry.nMoreFlags & PropertyMoreFlags::METRIC_ITEM)
502  {
503  bool bDoIt(true);
504 
505  if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
506  {
507  // exception: If these ItemTypes are used, do not convert when these are negative
508  // since this means they are intended as percent values
509  sal_Int32 nValue = 0;
510 
511  if(rAny >>= nValue)
512  {
513  bDoIt = nValue > 0;
514  }
515  }
516 
517  if(bDoIt)
518  {
519  const MapUnit eMapUnit(rSet.GetPool()->GetMetric(rEntry.nWID));
520 
521  if(eMapUnit != MapUnit::Map100thMM)
522  {
523  SvxUnoConvertToMM(eMapUnit, rAny);
524  }
525  }
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  SwPosition aPos( rTextNode );
537  SwPaM aPam( aPos );
538  uno::Any* pValues = aValues.getArray();
539  const OUString* pPropertyNames = rPropertyNames.getConstArray();
540  const SfxItemPropertyMap &rMap = m_rPropSet.getPropertyMap();
541  const SwAttrSet& rAttrSet( rTextNode.GetSwAttrSet() );
542  for (sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
543  {
544  SfxItemPropertySimpleEntry const*const pEntry =
545  rMap.getByName( pPropertyNames[nProp] );
546  if (!pEntry)
547  {
548  throw beans::UnknownPropertyException(
549  "Unknown property: " + pPropertyNames[nProp],
550  static_cast< cppu::OWeakObject * >(&m_rThis));
551  }
553  pValues[nProp], pPropertyNames[nProp], pEntry->nWID))
554  {
555  beans::PropertyState eTemp;
557  *pEntry, aPam, &(pValues[nProp]), eTemp, &rTextNode );
558  if (!bDone)
559  {
560  GetSinglePropertyValue_Impl(*pEntry, rAttrSet, pValues[nProp]);
561  }
562  }
563  }
564  return aValues;
565 }
566 
567 uno::Sequence< uno::Any > SAL_CALL
568 SwXParagraph::getPropertyValues(const uno::Sequence< OUString >& rPropertyNames)
569 {
570  SolarMutexGuard aGuard;
571  uno::Sequence< uno::Any > aValues;
572 
573  // workaround for bad designed API
574  try
575  {
576  aValues = m_pImpl->GetPropertyValues_Impl( rPropertyNames );
577  }
578  catch (beans::UnknownPropertyException &)
579  {
580  css::uno::Any anyEx = cppu::getCaughtException();
581  throw css::lang::WrappedTargetRuntimeException("Unknown property exception caught",
582  static_cast < cppu::OWeakObject * > ( this ), anyEx );
583  }
584  catch (lang::WrappedTargetException &)
585  {
586  css::uno::Any anyEx = cppu::getCaughtException();
587  throw css::lang::WrappedTargetRuntimeException("WrappedTargetException caught",
588  static_cast < cppu::OWeakObject * > ( this ), anyEx );
589  }
590 
591  return aValues;
592 }
593 
595  const uno::Sequence< OUString >& /*aPropertyNames*/,
596  const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
597 {
598  OSL_FAIL("SwXParagraph::addPropertiesChangeListener(): not implemented");
599 }
600 
602  const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
603 {
604  OSL_FAIL("SwXParagraph::removePropertiesChangeListener(): not implemented");
605 }
606 
608  const uno::Sequence< OUString >& /*aPropertyNames*/,
609  const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
610 {
611  OSL_FAIL("SwXParagraph::firePropertiesChangeEvent(): not implemented");
612 }
613 
614 /* disabled for #i46921# */
615 
616 uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL
618  const uno::Sequence< OUString >& rPropertyNames,
619  const uno::Sequence< uno::Any >& rValues )
620 {
621  SolarMutexGuard aGuard;
622 
623  if (rPropertyNames.getLength() != rValues.getLength())
624  {
625  throw lang::IllegalArgumentException();
626  }
627 
628  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
629 
630  //SwNode& rTextNode = pUnoCursor->GetPoint()->nNode.GetNode();
631  //const SwAttrSet& rAttrSet = static_cast<SwTextNode&>(rTextNode).GetSwAttrSet();
632  //sal_uInt16 nAttrCount = rAttrSet.Count();
633 
634  const sal_Int32 nProps = rPropertyNames.getLength();
635  const OUString *pProp = rPropertyNames.getConstArray();
636 
637  //sal_Int32 nVals = rValues.getLength();
638  const uno::Any *pValue = rValues.getConstArray();
639 
640  sal_Int32 nFailed = 0;
641  uno::Sequence< beans::SetPropertyTolerantFailed > aFailed( nProps );
642  beans::SetPropertyTolerantFailed *pFailed = aFailed.getArray();
643 
644  // get entry to start with
645  const SfxItemPropertyMap &rPropMap =
646  m_pImpl->m_rPropSet.getPropertyMap();
647 
648  SwPosition aPos( rTextNode );
649  SwCursor aCursor( aPos, nullptr );
650  SwParaSelection aParaSel( aCursor );
651  for (sal_Int32 i = 0; i < nProps; ++i)
652  {
653  try
654  {
655  pFailed[ nFailed ].Name = pProp[i];
656 
657  SfxItemPropertySimpleEntry const*const pEntry =
658  rPropMap.getByName( pProp[i] );
659  if (!pEntry)
660  {
661  pFailed[ nFailed++ ].Result =
662  beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
663  }
664  else
665  {
666  // set property value
667  // (compare to SwXParagraph::setPropertyValues)
668  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
669  {
670  pFailed[ nFailed++ ].Result =
671  beans::TolerantPropertySetResultType::PROPERTY_VETO;
672  }
673  else
674  {
676  aCursor, m_pImpl->m_rPropSet, pProp[i], pValue[i]);
677  }
678  }
679  }
680  catch (beans::UnknownPropertyException &)
681  {
682  // should not occur because property was searched for before
683  OSL_FAIL( "unexpected exception caught" );
684  pFailed[ nFailed++ ].Result =
685  beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
686  }
687  catch (lang::IllegalArgumentException &)
688  {
689  pFailed[ nFailed++ ].Result =
690  beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
691  }
692  catch (beans::PropertyVetoException &)
693  {
694  pFailed[ nFailed++ ].Result =
695  beans::TolerantPropertySetResultType::PROPERTY_VETO;
696  }
697  catch (lang::WrappedTargetException &)
698  {
699  pFailed[ nFailed++ ].Result =
700  beans::TolerantPropertySetResultType::WRAPPED_TARGET;
701  }
702  }
703 
704  aFailed.realloc( nFailed );
705  return aFailed;
706 }
707 
708 uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL
710  const uno::Sequence< OUString >& rPropertyNames )
711 {
712  SolarMutexGuard aGuard;
713 
714  uno::Sequence< beans::GetDirectPropertyTolerantResult > aTmpRes(
715  m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, false ) );
716  const beans::GetDirectPropertyTolerantResult *pTmpRes =
717  aTmpRes.getConstArray();
718 
719  // copy temporary result to final result type
720  const sal_Int32 nLen = aTmpRes.getLength();
721  uno::Sequence< beans::GetPropertyTolerantResult > aRes( nLen );
722  beans::GetPropertyTolerantResult *pRes = aRes.getArray();
723  for (sal_Int32 i = 0; i < nLen; i++)
724  {
725  *pRes++ = *pTmpRes++;
726  }
727  return aRes;
728 }
729 
730 uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL
732  const uno::Sequence< OUString >& rPropertyNames )
733 {
734  SolarMutexGuard aGuard;
735 
736  return m_pImpl->GetPropertyValuesTolerant_Impl( rPropertyNames, true );
737 }
738 
739 uno::Sequence< beans::GetDirectPropertyTolerantResult >
741  const uno::Sequence< OUString >& rPropertyNames,
742  bool bDirectValuesOnly )
743 {
744  SolarMutexGuard aGuard;
745 
746  SwTextNode & rTextNode(GetTextNodeOrThrow());
747 
748  // #i46786# Use SwAttrSet pointer for determining the state.
749  // Use the value SwAttrSet (from the paragraph OR the style)
750  // for determining the actual value(s).
751  const SwAttrSet* pAttrSet = rTextNode.GetpSwAttrSet();
752  const SwAttrSet& rValueAttrSet = rTextNode.GetSwAttrSet();
753 
754  sal_Int32 nProps = rPropertyNames.getLength();
755  const OUString *pProp = rPropertyNames.getConstArray();
756 
757  uno::Sequence< beans::GetDirectPropertyTolerantResult > aResult( nProps );
758  beans::GetDirectPropertyTolerantResult *pResult = aResult.getArray();
759  sal_Int32 nIdx = 0;
760 
761  // get entry to start with
762  const SfxItemPropertyMap &rPropMap = m_rPropSet.getPropertyMap();
763 
764  for (sal_Int32 i = 0; i < nProps; ++i)
765  {
766  OSL_ENSURE( nIdx < nProps, "index out ouf bounds" );
767  beans::GetDirectPropertyTolerantResult &rResult = pResult[nIdx];
768 
769  try
770  {
771  rResult.Name = pProp[i];
772 
773  SfxItemPropertySimpleEntry const*const pEntry =
774  rPropMap.getByName( pProp[i] );
775  if (!pEntry) // property available?
776  {
777  rResult.Result =
778  beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
779  }
780  else
781  {
782  // get property state
783  // (compare to SwXParagraph::getPropertyState)
784  bool bAttrSetFetched = true;
785  beans::PropertyState eState = lcl_SwXParagraph_getPropertyState(
786  rTextNode, &pAttrSet, *pEntry, bAttrSetFetched );
787  rResult.State = eState;
788 
789  rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE;
790  if (!bDirectValuesOnly ||
791  (beans::PropertyState_DIRECT_VALUE == eState))
792  {
793  // get property value
794  // (compare to SwXParagraph::getPropertyValue(s))
795  uno::Any aValue;
797  aValue, pProp[i], pEntry->nWID ) )
798  {
799  SwPosition aPos( rTextNode );
800  SwPaM aPam( aPos );
801  // handle properties that are not part of the attribute
802  // and thus only pretended to be paragraph attributes
803  beans::PropertyState eTemp;
804  const bool bDone =
806  *pEntry, aPam, &aValue, eTemp, &rTextNode );
807 
808  // if not found try the real paragraph attributes...
809  if (!bDone)
810  {
811  GetSinglePropertyValue_Impl(*pEntry, rValueAttrSet, aValue);
812  }
813  }
814 
815  rResult.Value = aValue;
816  rResult.Result = beans::TolerantPropertySetResultType::SUCCESS;
817 
818  nIdx++;
819  }
820  // this assertion should never occur!
821  OSL_ENSURE( nIdx < 1 || pResult[nIdx - 1].Result != beans::TolerantPropertySetResultType::UNKNOWN_FAILURE,
822  "unknown failure while retrieving property" );
823 
824  }
825  }
826  catch (beans::UnknownPropertyException &)
827  {
828  // should not occur because property was searched for before
829  OSL_FAIL( "unexpected exception caught" );
830  rResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
831  }
832  catch (lang::IllegalArgumentException &)
833  {
834  rResult.Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
835  }
836  catch (beans::PropertyVetoException &)
837  {
838  rResult.Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
839  }
840  catch (lang::WrappedTargetException &)
841  {
842  rResult.Result = beans::TolerantPropertySetResultType::WRAPPED_TARGET;
843  }
844  }
845 
846  // resize to actually used size
847  aResult.realloc( nIdx );
848 
849  return aResult;
850 }
851 
853  uno::Any& rAny, const OUString& rPropertyName, sal_uInt16 nWID)
854 {
855  if(!nWID)
856  {
857  if(rPropertyName == UNO_NAME_ANCHOR_TYPE)
858  nWID = FN_UNO_ANCHOR_TYPE;
859  else if(rPropertyName == UNO_NAME_ANCHOR_TYPES)
860  nWID = FN_UNO_ANCHOR_TYPES;
861  else if(rPropertyName == UNO_NAME_TEXT_WRAP)
862  nWID = FN_UNO_TEXT_WRAP;
863  else
864  return false;
865  }
866 
867  switch(nWID)
868  {
869  case FN_UNO_TEXT_WRAP: rAny <<= text::WrapTextMode_NONE; break;
870  case FN_UNO_ANCHOR_TYPE: rAny <<= text::TextContentAnchorType_AT_PARAGRAPH; break;
871  case FN_UNO_ANCHOR_TYPES:
872  { uno::Sequence<text::TextContentAnchorType> aTypes(1);
873  text::TextContentAnchorType* pArray = aTypes.getArray();
874  pArray[0] = text::TextContentAnchorType_AT_PARAGRAPH;
875  rAny <<= aTypes;
876  }
877  break;
878  default:
879  return false;
880  }
881  return true;
882 }
883 
884 void SAL_CALL
886  const OUString& /*rPropertyName*/,
887  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
888 {
889  OSL_FAIL("SwXParagraph::addPropertyChangeListener(): not implemented");
890 }
891 
892 void SAL_CALL
894  const OUString& /*rPropertyName*/,
895  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
896 {
897  OSL_FAIL("SwXParagraph::removePropertyChangeListener(): not implemented");
898 }
899 
900 void SAL_CALL
902  const OUString& /*rPropertyName*/,
903  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
904 {
905  OSL_FAIL("SwXParagraph::addVetoableChangeListener(): not implemented");
906 }
907 
908 void SAL_CALL
910  const OUString& /*rPropertyName*/,
911  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
912 {
913  OSL_FAIL("SwXParagraph::removeVetoableChangeListener(): not implemented");
914 }
915 
916 static beans::PropertyState lcl_SwXParagraph_getPropertyState(
917  const SwTextNode& rTextNode,
918  const SwAttrSet** ppSet,
919  const SfxItemPropertySimpleEntry& rEntry,
920  bool &rAttrSetFetched)
921 {
922  beans::PropertyState eRet(beans::PropertyState_DEFAULT_VALUE);
923 
924  if(!(*ppSet) && !rAttrSetFetched)
925  {
926  (*ppSet) = rTextNode.GetpSwAttrSet();
927  rAttrSetFetched = true;
928  }
929 
930  SwPosition aPos(rTextNode);
931  SwPaM aPam(aPos);
932  bool bDone(false);
933 
934  switch(rEntry.nWID)
935  {
936  case FN_UNO_NUM_RULES:
937  {
938  // if numbering is set, return it; else do nothing
939  SwUnoCursorHelper::getNumberingProperty(aPam,eRet,nullptr);
940  bDone = true;
941  break;
942  }
943  case FN_UNO_ANCHOR_TYPES:
944  {
945  bDone = true;
946  break;
947  }
948  case RES_ANCHOR:
949  {
950  bDone = (MID_SURROUND_SURROUNDTYPE == rEntry.nMemberId);
951  break;
952  }
953  case RES_SURROUND:
954  {
955  bDone = (MID_ANCHOR_ANCHORTYPE == rEntry.nMemberId);
956  break;
957  }
958  case FN_UNO_PARA_STYLE:
960  {
962  eRet = pFormat ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE;
963  bDone = true;
964  break;
965  }
966  case FN_UNO_PAGE_STYLE:
967  {
968  OUString sVal;
970  eRet = !sVal.isEmpty() ? beans::PropertyState_DIRECT_VALUE
971  : beans::PropertyState_AMBIGUOUS_VALUE;
972  bDone = true;
973  break;
974  }
975 
976  // DrawingLayer PropertyStyle support
978  {
979  if(*ppSet)
980  {
981  if(SfxItemState::SET == (*ppSet)->GetItemState(XATTR_FILLBMP_STRETCH, false)
982  || SfxItemState::SET == (*ppSet)->GetItemState(XATTR_FILLBMP_TILE, false))
983  {
984  eRet = beans::PropertyState_DIRECT_VALUE;
985  }
986  else
987  {
988  eRet = beans::PropertyState_AMBIGUOUS_VALUE;
989  }
990 
991  bDone = true;
992  }
993  break;
994  }
995  case RES_BACKGROUND:
996  {
997  if(*ppSet)
998  {
1000  rEntry.nMemberId))
1001  {
1002  eRet = beans::PropertyState_DIRECT_VALUE;
1003  }
1004  bDone = true;
1005  }
1006  break;
1007  }
1008  }
1009 
1010  if(!bDone)
1011  {
1012  if((*ppSet) && SfxItemState::SET == (*ppSet)->GetItemState(rEntry.nWID, false))
1013  {
1014  eRet = beans::PropertyState_DIRECT_VALUE;
1015  }
1016  }
1017 
1018  return eRet;
1019 }
1020 
1021 beans::PropertyState SAL_CALL
1022 SwXParagraph::getPropertyState(const OUString& rPropertyName)
1023 {
1024  SolarMutexGuard aGuard;
1025 
1026  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1027 
1028  const SwAttrSet* pSet = nullptr;
1029  SfxItemPropertySimpleEntry const*const pEntry =
1030  m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
1031  if (!pEntry)
1032  {
1033  throw beans::UnknownPropertyException(
1034  "Unknown property: " + rPropertyName,
1035  static_cast<cppu::OWeakObject *>(this));
1036  }
1037  bool bDummy = false;
1038  const beans::PropertyState eRet =
1039  lcl_SwXParagraph_getPropertyState(rTextNode, &pSet, *pEntry, bDummy);
1040  return eRet;
1041 }
1042 
1043 uno::Sequence< beans::PropertyState > SAL_CALL
1045  const uno::Sequence< OUString >& PropertyNames)
1046 {
1047  SolarMutexGuard aGuard;
1048 
1049  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1050 
1051  const OUString* pNames = PropertyNames.getConstArray();
1052  uno::Sequence< beans::PropertyState > aRet(PropertyNames.getLength());
1053  beans::PropertyState* pStates = aRet.getArray();
1054  const SfxItemPropertyMap &rMap = m_pImpl->m_rPropSet.getPropertyMap();
1055  const SwAttrSet* pSet = nullptr;
1056  bool bAttrSetFetched = false;
1057 
1058  for (sal_Int32 i = 0, nEnd = PropertyNames.getLength(); i < nEnd;
1059  ++i, ++pStates, ++pNames)
1060  {
1061  SfxItemPropertySimpleEntry const*const pEntry =
1062  rMap.getByName( *pNames );
1063  if (!pEntry)
1064  {
1065  throw beans::UnknownPropertyException(
1066  "Unknown property: " + *pNames,
1067  static_cast<cppu::OWeakObject *>(this));
1068  }
1069 
1070  if (bAttrSetFetched && !pSet && isATR(pEntry->nWID))
1071  {
1072  *pStates = beans::PropertyState_DEFAULT_VALUE;
1073  }
1074  else
1075  {
1077  rTextNode, &pSet, *pEntry, bAttrSetFetched );
1078  }
1079  }
1080 
1081  return aRet;
1082 }
1083 
1084 void SAL_CALL
1085 SwXParagraph::setPropertyToDefault(const OUString& rPropertyName)
1086 {
1087  SolarMutexGuard aGuard;
1088 
1089  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1090 
1091  SwPosition aPos( rTextNode );
1092  SwCursor aCursor( aPos, nullptr );
1093  if (rPropertyName == UNO_NAME_ANCHOR_TYPE ||
1094  rPropertyName == UNO_NAME_ANCHOR_TYPES ||
1095  rPropertyName == UNO_NAME_TEXT_WRAP)
1096  {
1097  return;
1098  }
1099 
1100  // select paragraph
1101  SwParaSelection aParaSel( aCursor );
1102  SfxItemPropertySimpleEntry const*const pEntry =
1103  m_pImpl->m_rPropSet.getPropertyMap().getByName( rPropertyName );
1104  if (!pEntry)
1105  {
1106  throw beans::UnknownPropertyException(
1107  "Unknown property: " + rPropertyName,
1108  static_cast<cppu::OWeakObject *>(this));
1109  }
1110 
1111  if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
1112  {
1113  throw uno::RuntimeException(
1114  "Property is read-only: " + rPropertyName,
1115  static_cast<cppu::OWeakObject *>(this));
1116  }
1117 
1118  const bool bBelowFrameAtrEnd(pEntry->nWID < RES_FRMATR_END);
1119  const bool bDrawingLayerRange(XATTR_FILL_FIRST <= pEntry->nWID && XATTR_FILL_LAST >= pEntry->nWID);
1120 
1121  if(bBelowFrameAtrEnd || bDrawingLayerRange)
1122  {
1123  std::set<sal_uInt16> aWhichIds;
1124 
1125  // For FillBitmapMode two IDs have to be reset (!)
1126  if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
1127  {
1128  aWhichIds.insert(XATTR_FILLBMP_STRETCH);
1129  aWhichIds.insert(XATTR_FILLBMP_TILE);
1130  }
1131  else
1132  {
1133  aWhichIds.insert(pEntry->nWID);
1134  }
1135 
1136  if (pEntry->nWID < RES_PARATR_BEGIN)
1137  {
1138  aCursor.GetDoc()->ResetAttrs(aCursor, true, aWhichIds);
1139  }
1140  else
1141  {
1142  // for paragraph attributes the selection must be extended
1143  // to paragraph boundaries
1144  SwPosition aStart( *aCursor.Start() );
1145  SwPosition aEnd ( *aCursor.End() );
1146  auto pTemp( aCursor.GetDoc()->CreateUnoCursor(aStart) );
1148  {
1149  pTemp->MovePara(GoCurrPara, fnParaStart);
1150  }
1151 
1152  pTemp->SetMark();
1153  *pTemp->GetPoint() = aEnd;
1154 
1155  SwUnoCursorHelper::SelectPam(*pTemp, true);
1156 
1157  if (!SwUnoCursorHelper::IsEndOfPara(*pTemp))
1158  {
1159  pTemp->MovePara(GoCurrPara, fnParaEnd);
1160  }
1161 
1162 
1163  pTemp->GetDoc()->ResetAttrs(*pTemp, true, aWhichIds);
1164  }
1165  }
1166  else
1167  {
1169  }
1170 }
1171 
1172 uno::Any SAL_CALL
1173 SwXParagraph::getPropertyDefault(const OUString& rPropertyName)
1174 {
1175  SolarMutexGuard g;
1176 
1177  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1178 
1179  uno::Any aRet;
1180  if (::sw::GetDefaultTextContentValue(aRet, rPropertyName))
1181  {
1182  return aRet;
1183  }
1184 
1185  SfxItemPropertySimpleEntry const*const pEntry =
1186  m_pImpl->m_rPropSet.getPropertyMap().getByName(rPropertyName);
1187  if (!pEntry)
1188  {
1189  throw beans::UnknownPropertyException(
1190  "Unknown property: " + rPropertyName,
1191  static_cast<cppu::OWeakObject *>(this));
1192  }
1193 
1194  const bool bBelowFrameAtrEnd(pEntry->nWID < RES_FRMATR_END);
1195  const bool bDrawingLayerRange(XATTR_FILL_FIRST <= pEntry->nWID && XATTR_FILL_LAST >= pEntry->nWID);
1196 
1197  if(bBelowFrameAtrEnd || bDrawingLayerRange)
1198  {
1199  const SfxPoolItem& rDefItem = rTextNode.GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID);
1200 
1201  rDefItem.QueryValue(aRet, pEntry->nMemberId);
1202  }
1203 
1204  return aRet;
1205 }
1206 
1207 void SAL_CALL
1208 SwXParagraph::attach(const uno::Reference< text::XTextRange > & /*xTextRange*/)
1209 {
1210  SolarMutexGuard aGuard;
1211  // SwXParagraph will only created in order to be inserted by
1212  // 'insertTextContentBefore' or 'insertTextContentAfter' therefore
1213  // they cannot be attached
1214  throw uno::RuntimeException();
1215 }
1216 
1217 uno::Reference< text::XTextRange > SAL_CALL
1219 {
1220  SolarMutexGuard aGuard;
1221 
1222  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1223 
1224  SwPosition aPos( rTextNode );
1225  SwCursor aCursor( aPos, nullptr );
1226  // select paragraph
1227  SwParaSelection aParaSel( aCursor );
1228  const uno::Reference< text::XTextRange > xRet =
1229  new SwXTextRange(aCursor, m_pImpl->m_xParentText);
1230  return xRet;
1231 }
1232 
1233 void SAL_CALL SwXParagraph::dispose()
1234 {
1235  SolarMutexGuard aGuard;
1236 
1237  SwTextNode *const pTextNode( m_pImpl->GetTextNode() );
1238  if (pTextNode)
1239  {
1240  SwCursor aCursor( SwPosition( *pTextNode ), nullptr );
1241  pTextNode->GetDoc()->getIDocumentContentOperations().DelFullPara(aCursor);
1242  lang::EventObject const ev(static_cast< ::cppu::OWeakObject&>(*this));
1243  m_pImpl->m_EventListeners.disposeAndClear(ev);
1244  }
1245 }
1246 
1248  const uno::Reference< lang::XEventListener > & xListener)
1249 {
1250  // no need to lock here as m_pImpl is const and container threadsafe
1251  m_pImpl->m_EventListeners.addInterface(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  m_pImpl->m_EventListeners.removeInterface(xListener);
1259 }
1260 
1261 uno::Reference< container::XEnumeration > SAL_CALL
1263 {
1264  SolarMutexGuard aGuard;
1265 
1266  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1267 
1268  SwPosition aPos( rTextNode );
1269  SwPaM aPam ( aPos );
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 
1277 {
1279 }
1280 
1282 {
1283  SolarMutexGuard aGuard;
1284  return GetTextNode() != nullptr;
1285 }
1286 
1287 uno::Reference< text::XText > SAL_CALL
1289 {
1290  SolarMutexGuard g;
1291 
1292  return m_pImpl->m_xParentText;
1293 }
1294 
1295 uno::Reference< text::XTextRange > SAL_CALL
1297 {
1298  SolarMutexGuard aGuard;
1299 
1300  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1301 
1302  SwPosition aPos( rTextNode );
1303  SwCursor aCursor( aPos, nullptr );
1304  SwParaSelection aParaSel( aCursor );
1305  SwPaM aPam( *aCursor.Start() );
1306  uno::Reference< text::XText > xParent = getText();
1307  const uno::Reference< text::XTextRange > xRet =
1308  new SwXTextRange(aPam, xParent);
1309  return xRet;
1310 }
1311 
1312 uno::Reference< text::XTextRange > SAL_CALL
1314 {
1315  SolarMutexGuard aGuard;
1316 
1317  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1318 
1319  SwPosition aPos( rTextNode );
1320  SwCursor aCursor( aPos, nullptr );
1321  SwParaSelection aParaSel( aCursor );
1322  SwPaM aPam( *aCursor.End() );
1323  uno::Reference< text::XText > xParent = getText();
1324  const uno::Reference< text::XTextRange > xRet =
1325  new SwXTextRange(aPam, xParent);
1326  return xRet;
1327 }
1328 
1329 OUString SAL_CALL SwXParagraph::getString()
1330 {
1331  SolarMutexGuard aGuard;
1332  OUString aRet;
1333  SwTextNode const*const pTextNode( GetTextNode() );
1334  if (pTextNode)
1335  {
1336  SwPosition aPos( *pTextNode );
1337  SwCursor aCursor( aPos, nullptr );
1338  SwParaSelection aParaSel( aCursor );
1339  SwUnoCursorHelper::GetTextFromPam(aCursor, aRet);
1340  }
1341  else if (m_pImpl->IsDescriptor())
1342  {
1343  aRet = m_pImpl->m_sText;
1344  }
1345  else
1346  {
1347  // Seems object is being disposed or some other problem occurs.
1348  // Anyway from user point of view object still exist, so on that level this is not an error
1349  SAL_WARN("sw.uno", "getString() for invalid paragraph called. Returning empty string.");
1350  }
1351  return aRet;
1352 }
1353 
1354 void SAL_CALL SwXParagraph::setString(const OUString& aString)
1355 {
1356  SolarMutexGuard aGuard;
1357 
1358  SwTextNode const*const pTextNode( GetTextNode() );
1359  if (pTextNode)
1360  {
1361  SwPosition aPos( *pTextNode );
1362  SwCursor aCursor( aPos, nullptr );
1363  if (!SwUnoCursorHelper::IsStartOfPara(aCursor)) {
1364  aCursor.MovePara(GoCurrPara, fnParaStart);
1365  }
1366  SwUnoCursorHelper::SelectPam(aCursor, true);
1367  if (pTextNode->GetText().getLength()) {
1368  aCursor.MovePara(GoCurrPara, fnParaEnd);
1369  }
1370  SwUnoCursorHelper::SetString(aCursor, aString);
1371  SwUnoCursorHelper::SelectPam(aCursor, false);
1372  }
1373  else if (m_pImpl->IsDescriptor())
1374  {
1375  m_pImpl->m_sText = aString;
1376  }
1377  else
1378  {
1379  throw uno::RuntimeException();
1380  }
1381 }
1382 
1383 uno::Reference< container::XEnumeration > SAL_CALL
1384 SwXParagraph::createContentEnumeration(const OUString& rServiceName)
1385 {
1386  SolarMutexGuard g;
1387 
1388  if ( rServiceName != "com.sun.star.text.TextContent" )
1389  {
1390  throw uno::RuntimeException();
1391  }
1392 
1393  SwTextNode & rTextNode(m_pImpl->GetTextNodeOrThrow());
1394 
1395  SwPosition aPos( rTextNode );
1396  SwPaM aPam( aPos );
1397  uno::Reference< container::XEnumeration > xRet =
1399  return xRet;
1400 }
1401 
1402 uno::Sequence< OUString > SAL_CALL
1404 {
1405  uno::Sequence<OUString> aRet { "com.sun.star.text.TextContent" };
1406  return aRet;
1407 }
1408 
1409 // MetadatableMixin
1411 {
1412  SwTextNode *const pTextNode( m_pImpl->GetTextNode() );
1413  return pTextNode;
1414 }
1415 
1416 uno::Reference<frame::XModel> SwXParagraph::GetModel()
1417 {
1418  SwTextNode *const pTextNode( m_pImpl->GetTextNode() );
1419  if (pTextNode)
1420  {
1421  SwDocShell const*const pShell( pTextNode->GetDoc()->GetDocShell() );
1422  return pShell ? pShell->GetModel() : nullptr;
1423  }
1424  return nullptr;
1425 }
1426 
1427 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
Definition: swcrsr.cxx:2197
void ResetAttrs(const SwPaM &rRg, bool bTextAttr=true, const std::set< sal_uInt16 > &rAttrs=std::set< sal_uInt16 >(), const bool bSendDataChangedEvents=true, SwRootFrame const *pLayout=nullptr)
Reset attributes.
Definition: docfmt.cxx:256
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1785
virtual sal_Int32 Len() const
Definition: node.cxx:1183
void DeleteMark()
Definition: pam.hxx:177
SwMoveFnCollection const & fnParaEnd
Definition: paminit.cxx:47
#define MID_SURROUND_SURROUNDTYPE
Definition: unomid.h:29
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &rPropertyNames) override
Marks a position in the document model.
Definition: pam.hxx:35
Result
void attachToText(SwXText &rParent, SwTextNode &rTextNode)
for SwXText
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
const OUString & GetText() const
Definition: ndtxt.hxx:211
uno::Sequence< OUString > GetSupportedServiceNamesImpl(size_t const nServices, char const *const pServices[])
Definition: unoobj2.cxx:121
bool GoCurrPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:949
Impl(SwXParagraph &rThis, SwTextNode *const pTextNode=nullptr, uno::Reference< text::XText > const &xParent=nullptr, const sal_Int32 nSelStart=-1, const sal_Int32 nSelEnd=-1)
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
static css::uno::Reference< css::text::XTextContent > 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::GetPropertyTolerantResult > SAL_CALL getPropertyValuesTolerant(const css::uno::Sequence< OUString > &rPropertyNames) override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString &rServiceName) override
const SwPosition * GetMark() const
Definition: pam.hxx:209
#define RES_SURROUND
Definition: hintids.hxx:206
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
std::shared_ptr< SvxBrushItem > getSvxBrushItemFromSourceSet(const SfxItemSet &rSourceSet, sal_uInt16 nBackgroundID, bool bSearchInParents, bool bXMLImportHack)
uno::WeakReference< uno::XInterface > m_wThis
#define RES_FRMATR_END
Definition: hintids.hxx:236
void getNumberingProperty(SwPaM &rPam, PropertyState &eState, Any *pAny)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
bool isATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:338
Definition: doc.hxx:185
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:46
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &rPropertyName) override
void resetCursorPropertyValue(const SfxItemPropertySimpleEntry &rEntry, SwPaM &rPam)
void disposeAndClear(const css::lang::EventObject &rEvt)
bool getCursorPropertyValue(const SfxItemPropertySimpleEntry &rEntry, SwPaM &rPam, Any *pAny, PropertyState &eState, const SwTextNode *pNode)
virtual css::uno::Sequence< css::beans::GetDirectPropertyTolerantResult > SAL_CALL getDirectPropertyValuesTolerant(const css::uno::Sequence< OUString > &rPropertyNames) override
virtual sal_Bool SAL_CALL hasElements() override
void SetPropertyValues(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const css::uno::Sequence< css::beans::PropertyValue > &rPropertyValues, const SetAttrMode nAttrMode=SetAttrMode::DEFAULT)
SAL_DLLPRIVATE css::uno::WeakReference< css::text::XTextContent > const & GetXParagraph() const
Definition: ndtxt.hxx:779
css::uno::Reference< css::frame::XModel > GetModel() const
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
SfxHintId GetId() const
#define UNO_NAME_TEXT_WRAP
Definition: unoprnms.hxx:317
#define XATTR_FILLBMP_STRETCH
static const size_t g_nServicesParagraph(SAL_N_ELEMENTS(g_ServicesParagraph))
void SetString(SwCursor &rCursor, const OUString &rString)
Definition: unoobj2.cxx:1566
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:229
::comphelper::OInterfaceContainerHelper2 m_EventListeners
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
virtual css::uno::Reference< css::frame::XModel > GetModel() override
virtual OUString SAL_CALL getString() override
SwParaSelection(SwCursor &rCursor)
SwTextNode * m_pTextNode
bool GetDefaultTextContentValue(css::uno::Any &rAny, const OUString &rPropertyName, sal_uInt16 nWID=0)
#define XATTR_FILL_LAST
SwIndex nContent
Definition: pam.hxx:38
Any SAL_CALL getCaughtException()
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
#define FN_UNO_TEXT_WRAP
Definition: cmdid.h:542
SwXParagraph & m_rThis
static SwXParaFrameEnumeration * Create(const SwPaM &rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat *const pFormat=nullptr)
Definition: unoobj2.cxx:1632
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual ::sfx2::Metadatable * GetCoreObject() override
::sw::UnoImplPtr< Impl > m_pImpl
void GetTextFromPam(SwPaM &rPam, OUString &rBuffer, SwRootFrame const *pLayout=nullptr)
Definition: unoobj.cxx:165
#define RES_PARATR_BEGIN
Definition: hintids.hxx:160
#define FN_UNO_PARA_CONDITIONAL_STYLE_NAME
Definition: cmdid.h:538
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) 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 css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor() override
void SelectPam(SwPaM &rPam, const bool bExpand)
Definition: unoobj.cxx:150
#define SAL_N_ELEMENTS(arr)
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
#define RES_BACKGROUND
Definition: hintids.hxx:210
uno::Sequence< uno::Any > GetPropertyValues_Impl(const uno::Sequence< OUString > &rPropertyNames)
#define FN_UNO_PAGE_STYLE
Definition: cmdid.h:496
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:443
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
bool IsEndOfPara(SwPaM &rUnoCursor)
#define MID_ANCHOR_ANCHORTYPE
Definition: unomid.h:43
void GetSinglePropertyValue_Impl(const SfxItemPropertySimpleEntry &rEntry, const SfxItemSet &rSet, uno::Any &rAny) const
#define RES_ANCHOR
Definition: hintids.hxx:209
virtual void Notify(const SfxHint &rHint) override
const SwPosition * GetPoint() const
Definition: pam.hxx:207
static char const *const g_ServicesParagraph[]
virtual void SAL_CALL setString(const OUString &rString) override
int i
SwTextNode * GetTextNode()
bool IsDescriptor() const
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
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...
#define XATTR_FILLBMP_SIZEX
::osl::Mutex m_Mutex
SwDoc * GetDoc() const
Definition: pam.hxx:243
virtual ~SwXParagraph() override
bool IsStartOfPara(SwPaM &rUnoCursor)
SwCursor & m_rCursor
unsigned char sal_Bool
const SfxItemPropertyMap & getPropertyMap() const
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Sequence< css::uno::Any > &rValues) override
virtual OUString SAL_CALL getImplementationName() override
css::uno::Type const & get()
bool StartListening(SvtBroadcaster &rBroadcaster)
SfxItemPool * GetPool() const
const SfxItemPropertySimpleEntry * getByName(const OUString &rName) const
virtual void SAL_CALL dispose() override
const SwPosition * Start() const
Definition: pam.hxx:212
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
SwXParagraph()
descriptor
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:93
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
uno::Sequence< beans::GetDirectPropertyTolerantResult > GetPropertyValuesTolerant_Impl(const uno::Sequence< OUString > &rPropertyNames, bool bDirectValuesOnly)
#define XATTR_FILLBMP_SIZEY
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
#define XATTR_FILLBMP_TILE
#define PROPERTY_MAP_PARAGRAPH
Definition: unomap.hxx:64
#define OWN_ATTR_FILLBMP_MODE
Definition: unomap.hxx:324
void SetPropertyValues_Impl(const uno::Sequence< OUString > &rPropertyNames, const uno::Sequence< uno::Any > &rValues)
#define FN_UNO_NUM_RULES
Definition: cmdid.h:501
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
#define UNO_NAME_ANCHOR_TYPE
Definition: unoprnms.hxx:228
virtual css::uno::Type SAL_CALL getElementType() override
#define FN_UNO_ANCHOR_TYPE
Definition: cmdid.h:543
sal_Int32 const m_nSelectionEndPos
SwTextNode & GetTextNodeOrThrow()
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
void SetPropertyValue(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName, const css::uno::Any &rValue, const SetAttrMode nAttrMode=SetAttrMode::DEFAULT)
const SwPosition * End() const
Definition: pam.hxx:217
bool IsDescriptor() const
const SwTextNode * GetTextNode() const
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
sal_Int32 const m_nSelectionStartPos
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:130
void SvxUnoConvertToMM(const MapUnit eSourceMapUnit, uno::Any &rMetric)
#define FN_UNO_ANCHOR_TYPES
Definition: cmdid.h:536
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:723
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
SwFormatColl * GetCurTextFormatColl(SwPaM &rPam, const bool bConditional)
Definition: unoobj.cxx:612
void GetCurPageStyle(SwPaM const &rPaM, OUString &rString)
SfxItemPropertySet const & m_rPropSet
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &rPropertyNames) override
virtual void SAL_CALL setPropertyToDefault(const OUString &rPropertyName) override
#define UNO_NAME_ANCHOR_TYPES
Definition: unoprnms.hxx:229
MapUnit
#define SAL_WARN(area, stream)
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:457
static beans::PropertyState lcl_SwXParagraph_getPropertyState(const SwTextNode &rTextNode, const SwAttrSet **ppSet, const SfxItemPropertySimpleEntry &rEntry, bool &rAttrSetFetched)
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &rPropertyName) override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
SAL_DLLPRIVATE void SetXParagraph(css::uno::Reference< css::text::XTextContent > const &xParagraph)
Definition: ndtxt.hxx:781
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
uno::Reference< text::XText > CreateParentXText(SwDoc &rDoc, const SwPosition &rPos)
Definition: unoobj2.cxx:1156
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
#define FN_UNO_PARA_STYLE
Definition: cmdid.h:495
uno::Reference< text::XText > m_xParentText
PropertyMoreFlags nMoreFlags