LibreOffice Module sw (master)  1
unocrsrhelper.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 <unocrsrhelper.hxx>
21 
22 #include <map>
23 #include <algorithm>
24 #include <memory>
25 
26 #include <com/sun/star/beans/NamedValue.hpp>
27 #include <com/sun/star/beans/PropertyAttribute.hpp>
28 #include <com/sun/star/beans/PropertyState.hpp>
29 #include <com/sun/star/embed/ElementModes.hpp>
30 #include <com/sun/star/embed/XStorage.hpp>
31 #include <com/sun/star/io/IOException.hpp>
32 #include <com/sun/star/text/XTextSection.hpp>
33 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
34 
35 #include <svx/unoshape.hxx>
36 
37 #include <cmdid.h>
38 #include <hintids.hxx>
39 #include <unotextrange.hxx>
40 #include <unodraw.hxx>
41 #include <unofootnote.hxx>
42 #include <unobookmark.hxx>
43 #include <unomap.hxx>
44 #include <unorefmark.hxx>
45 #include <unoidx.hxx>
46 #include <unofield.hxx>
47 #include <unotbl.hxx>
48 #include <unosett.hxx>
49 #include <unoframe.hxx>
50 #include <unocrsr.hxx>
51 #include <doc.hxx>
52 #include <IDocumentUndoRedo.hxx>
55 #include <fmtftn.hxx>
56 #include <charfmt.hxx>
57 #include <pagedesc.hxx>
58 #include <docstyle.hxx>
59 #include <ndtxt.hxx>
60 #include <docsh.hxx>
61 #include <section.hxx>
62 #include <shellio.hxx>
63 #include <edimp.hxx>
64 #include <swundo.hxx>
65 #include <cntfrm.hxx>
66 #include <pagefrm.hxx>
67 #include <svl/eitem.hxx>
68 #include <svl/lngmisc.hxx>
69 #include <docary.hxx>
70 #include <swtable.hxx>
71 #include <tox.hxx>
72 #include <doctxm.hxx>
73 #include <fchrfmt.hxx>
74 #include <editeng/editids.hrc>
75 #include <editeng/flstitem.hxx>
76 #include <editeng/prntitem.hxx>
77 #include <vcl/metric.hxx>
78 #include <svtools/ctrltool.hxx>
79 #include <sfx2/docfilt.hxx>
80 #include <sfx2/docfile.hxx>
81 #include <sfx2/fcontnr.hxx>
82 #include <svl/stritem.hxx>
83 #include <SwStyleNameMapper.hxx>
84 #include <redline.hxx>
85 #include <numrule.hxx>
89 #include <SwNodeNum.hxx>
90 #include <fmtmeta.hxx>
91 #include <txtfld.hxx>
92 #include <unoparagraph.hxx>
93 #include <poolfmt.hxx>
94 #include <paratr.hxx>
95 #include <sal/log.hxx>
96 
97 using namespace ::com::sun::star;
98 using namespace ::com::sun::star::uno;
99 using namespace ::com::sun::star::beans;
100 using namespace ::com::sun::star::text;
101 using namespace ::com::sun::star::table;
102 using namespace ::com::sun::star::container;
103 using namespace ::com::sun::star::lang;
104 
106 {
107 
108 static SwPaM* lcl_createPamCopy(const SwPaM& rPam)
109 {
110  SwPaM *const pRet = new SwPaM(*rPam.GetPoint());
111  ::sw::DeepCopyPaM(rPam, *pRet);
112  return pRet;
113 }
114 
115 void GetSelectableFromAny(uno::Reference<uno::XInterface> const& xIfc,
116  SwDoc & rTargetDoc,
117  SwPaM *& o_rpPaM, std::pair<OUString, FlyCntType> & o_rFrame,
118  OUString & o_rTableName, SwUnoTableCursor const*& o_rpTableCursor,
119  ::sw::mark::IMark const*& o_rpMark,
120  std::vector<SdrObject *> & o_rSdrObjects)
121 {
122  uno::Reference<drawing::XShapes> const xShapes(xIfc, UNO_QUERY);
123  if (xShapes.is())
124  {
125  sal_Int32 nShapes(xShapes->getCount());
126  for (sal_Int32 i = 0; i < nShapes; ++i)
127  {
128  uno::Reference<lang::XUnoTunnel> xShape;
129  xShapes->getByIndex(i) >>= xShape;
130  if (xShape.is())
131  {
132  SvxShape *const pSvxShape(
133  comphelper::getFromUnoTunnel<SvxShape>(xShape));
134  if (pSvxShape)
135  {
136  SdrObject *const pSdrObject = pSvxShape->GetSdrObject();
137  if (pSdrObject)
138  { // hmm... needs view to verify it's in right doc...
139  o_rSdrObjects.push_back(pSdrObject);
140  }
141  }
142  }
143  }
144  return;
145  }
146 
147  uno::Reference<lang::XUnoTunnel> const xTunnel(xIfc, UNO_QUERY);
148  if (!xTunnel.is()) // everything below needs tunnel
149  {
150  return;
151  }
152 
153  SwXShape *const pShape(comphelper::getFromUnoTunnel<SwXShape>(xTunnel));
154  if (pShape)
155  {
156  uno::Reference<uno::XAggregation> const xAgg(
157  pShape->GetAggregationInterface());
158  if (xAgg.is())
159  {
160  SvxShape *const pSvxShape(
161  comphelper::getFromUnoTunnel<SvxShape>(xTunnel));
162  if (pSvxShape)
163  {
164  SdrObject *const pSdrObject = pSvxShape->GetSdrObject();
165  if (pSdrObject)
166  { // hmm... needs view to verify it's in right doc...
167  o_rSdrObjects.push_back(pSdrObject);
168  }
169  }
170  }
171  return;
172  }
173 
174  OTextCursorHelper *const pCursor(
175  comphelper::getFromUnoTunnel<OTextCursorHelper>(xTunnel));
176  if (pCursor)
177  {
178  if (pCursor->GetDoc() == &rTargetDoc)
179  {
180  o_rpPaM = lcl_createPamCopy(*pCursor->GetPaM());
181  }
182  return;
183  }
184 
185  SwXTextRanges* const pRanges(
186  comphelper::getFromUnoTunnel<SwXTextRanges>(xTunnel));
187  if (pRanges)
188  {
189  SwUnoCursor const* pUnoCursor = pRanges->GetCursor();
190  if (pUnoCursor && &pUnoCursor->GetDoc() == &rTargetDoc)
191  {
192  o_rpPaM = lcl_createPamCopy(*pUnoCursor);
193  }
194  return;
195  }
196 
197  // check these before Range to prevent misinterpretation of text frames
198  // and cells also implement XTextRange
199  SwXFrame *const pFrame(
200  comphelper::getFromUnoTunnel<SwXFrame>(xTunnel));
201  if (pFrame)
202  {
203  const SwFrameFormat *const pFrameFormat(pFrame->GetFrameFormat());
204  if (pFrameFormat && pFrameFormat->GetDoc() == &rTargetDoc)
205  {
206  o_rFrame = std::make_pair(pFrameFormat->GetName(), pFrame->GetFlyCntType());
207  }
208  return;
209  }
210 
211  SwXTextTable *const pTextTable(
212  comphelper::getFromUnoTunnel<SwXTextTable>(xTunnel));
213  if (pTextTable)
214  {
215  SwFrameFormat *const pFrameFormat(pTextTable->GetFrameFormat());
216  if (pFrameFormat && pFrameFormat->GetDoc() == &rTargetDoc)
217  {
218  o_rTableName = pFrameFormat->GetName();
219  }
220  return;
221  }
222 
223  SwXCell *const pCell(
224  comphelper::getFromUnoTunnel<SwXCell>(xTunnel));
225  if (pCell)
226  {
227  SwFrameFormat *const pFrameFormat(pCell->GetFrameFormat());
228  if (pFrameFormat && pFrameFormat->GetDoc() == &rTargetDoc)
229  {
230  SwTableBox * pBox = pCell->GetTableBox();
231  SwTable *const pTable = SwTable::FindTable(pFrameFormat);
232  // ??? what's the benefit of setting pBox in this convoluted way?
233  pBox = pCell->FindBox(pTable, pBox);
234  if (pBox)
235  {
236  SwPosition const aPos(*pBox->GetSttNd());
237  SwPaM aPam(aPos);
238  aPam.Move(fnMoveForward, GoInNode);
239  o_rpPaM = lcl_createPamCopy(aPam);
240  }
241  }
242  return;
243  }
244 
245  uno::Reference<text::XTextRange> const xTextRange(xTunnel, UNO_QUERY);
246  if (xTextRange.is())
247  {
248  SwUnoInternalPaM aPam(rTargetDoc);
249  if (::sw::XTextRangeToSwPaM(aPam, xTextRange))
250  {
251  o_rpPaM = lcl_createPamCopy(aPam);
252  }
253  return;
254  }
255 
256  SwXCellRange *const pCellRange(
257  comphelper::getFromUnoTunnel<SwXCellRange>(xTunnel));
258  if (pCellRange)
259  {
260  SwUnoCursor const*const pUnoCursor(pCellRange->GetTableCursor());
261  if (pUnoCursor && &pUnoCursor->GetDoc() == &rTargetDoc)
262  {
263  // probably can't copy it to o_rpPaM for this since it's
264  // a SwTableCursor
265  o_rpTableCursor = dynamic_cast<SwUnoTableCursor const*>(pUnoCursor);
266  }
267  return;
268  }
269 
270  ::sw::mark::IMark const*const pMark(
271  SwXBookmark::GetBookmarkInDoc(& rTargetDoc, xTunnel));
272  if (pMark)
273  {
274  o_rpMark = pMark;
275  return;
276  }
277 }
278 
279 uno::Reference<text::XTextContent>
280 GetNestedTextContent(SwTextNode const & rTextNode, sal_Int32 const nIndex,
281  bool const bParent)
282 {
283  // these should be unambiguous because of the dummy character
284  SwTextNode::GetTextAttrMode const eMode( bParent
286  SwTextAttr *const pMetaTextAttr =
287  rTextNode.GetTextAttrAt(nIndex, RES_TXTATR_META, eMode);
288  SwTextAttr *const pMetaFieldTextAttr =
289  rTextNode.GetTextAttrAt(nIndex, RES_TXTATR_METAFIELD, eMode);
290  // which is innermost?
291  SwTextAttr *const pTextAttr = pMetaTextAttr
292  ? (pMetaFieldTextAttr
293  ? ((pMetaFieldTextAttr->GetStart() >
294  pMetaTextAttr->GetStart())
295  ? pMetaFieldTextAttr : pMetaTextAttr)
296  : pMetaTextAttr)
297  : pMetaFieldTextAttr;
298  uno::Reference<XTextContent> xRet;
299  if (pTextAttr)
300  {
301  ::sw::Meta *const pMeta(
302  static_cast<SwFormatMeta &>(pTextAttr->GetAttr()).GetMeta());
303  assert(pMeta);
304  xRet.set(pMeta->MakeUnoObject(), uno::UNO_QUERY);
305  }
306  return xRet;
307 }
308 
310 {
311  SwFormatAutoFormat const*const pFormat(
313  if (!pFormat)
314  {
315  return uno::Any();
316  }
317  const auto pSet(pFormat->GetStyleHandle());
318  if (!pSet)
319  return {};
321  SfxItemPropertyMap const& rMap(rPropSet.getPropertyMap());
322  std::vector<beans::NamedValue> props;
323  // have to iterate the map, not the item set?
324  for (auto const pEntry : rMap.getPropertyEntries())
325  {
326  if (rPropSet.getPropertyState(*pEntry, *pSet) == PropertyState_DIRECT_VALUE)
327  {
328  Any value;
329  rPropSet.getPropertyValue(*pEntry, *pSet, value);
330  props.emplace_back(pEntry->aName, value);
331  }
332  }
333  return uno::makeAny(comphelper::containerToSequence(props));
334 }
335 
336 // Read the special properties of the cursor
338  , SwPaM& rPam
339  , Any *pAny
340  , PropertyState& eState
341  , const SwTextNode* pNode )
342 {
343  PropertyState eNewState = PropertyState_DIRECT_VALUE;
344  bool bDone = true;
345  switch(rEntry.nWID)
346  {
348  if (pAny)
349  {
350  const SwTextNode * pTmpNode = pNode;
351 
352  if (!pTmpNode)
353  pTmpNode = rPam.GetNode().GetTextNode();
354 
355  bool bRet = false;
356 
357  if ( pTmpNode &&
358  pTmpNode->GetNum() &&
359  pTmpNode->GetNum()->IsContinueingPreviousSubTree() )
360  {
361  bRet = true;
362  }
363 
364  *pAny <<= bRet;
365  }
366  break;
368  if (pAny)
369  {
370  const SwTextNode * pTmpNode = pNode;
371 
372  if (!pTmpNode)
373  pTmpNode = rPam.GetNode().GetTextNode();
374 
375  OUString sRet;
376  if ( pTmpNode && pTmpNode->GetNum() )
377  {
378  sRet = pTmpNode->GetNumString();
379  }
380 
381  *pAny <<= sRet;
382  }
383  break;
385  if (pAny)
386  {
387  const SwTextNode * pTmpNode = pNode;
388 
389  if (!pTmpNode)
390  pTmpNode = rPam.GetNode().GetTextNode();
391 
392  sal_Int16 nRet = -1;
393  if ( pTmpNode )
394  nRet = sal::static_int_cast< sal_Int16 >( pTmpNode->GetAttrOutlineLevel() );
395 
396  *pAny <<= nRet;
397  }
398  break;
400  case FN_UNO_PARA_STYLE :
401  {
402  SwFormatColl* pFormat = nullptr;
403  if(pNode)
404  pFormat = FN_UNO_PARA_CONDITIONAL_STYLE_NAME == rEntry.nWID
405  ? pNode->GetFormatColl() : &pNode->GetAnyFormatColl();
406  else
407  {
410  }
411  if(pFormat)
412  {
413  if( pAny )
414  {
415  OUString sVal;
417  *pAny <<= sVal;
418  }
419  }
420  else
421  eNewState = PropertyState_AMBIGUOUS_VALUE;
422  }
423  break;
424  case FN_UNO_PAGE_STYLE :
425  {
426  OUString sVal;
427  GetCurPageStyle(rPam, sVal);
428  if( pAny )
429  *pAny <<= sVal;
430  if(sVal.isEmpty())
431  eNewState = PropertyState_AMBIGUOUS_VALUE;
432  }
433  break;
435  if( pAny )
436  {
437  sal_Int16 nValue = IsNodeNumStart(rPam, eNewState);
438  *pAny <<= nValue;
439  }
440  break;
441  case FN_UNO_NUM_LEVEL :
442  case FN_UNO_IS_NUMBER :
443  // #i91601#
444  case FN_UNO_LIST_ID:
445  case FN_NUMBER_NEWSTART:
447  {
448  if (!pAny)
449  {
450  break;
451  }
452  // a multi selection is not considered
453  const SwTextNode* pTextNd = rPam.GetNode().GetTextNode();
454  if ( pTextNd && pTextNd->IsInList() )
455  {
456  switch (rEntry.nWID)
457  {
458  case FN_UNO_NUM_LEVEL:
459  {
460  *pAny <<= static_cast<sal_Int16>(pTextNd->GetActualListLevel());
461  break;
462  }
463  case FN_UNO_IS_NUMBER:
464  {
465  *pAny <<= pTextNd->IsCountedInList();
466  break;
467  }
468  // #i91601#
469  case FN_UNO_LIST_ID:
470  {
471  *pAny <<= pTextNd->GetListId();
472  break;
473  }
474  case FN_NUMBER_NEWSTART:
475  {
476  *pAny <<= pTextNd->IsListRestart();
477  break;
478  }
480  {
481  *pAny = GetParaListAutoFormat(*pTextNd);
482  break;
483  }
484  default:
485  assert(false);
486  }
487  }
488  else
489  {
490  eNewState = PropertyState_DEFAULT_VALUE;
491 
492  // #i30838# set default values for default properties
493  switch (rEntry.nWID)
494  {
495  case FN_UNO_NUM_LEVEL:
496  {
497  *pAny <<= static_cast<sal_Int16>( 0 );
498  break;
499  }
500  case FN_UNO_IS_NUMBER:
501  {
502  *pAny <<= false;
503  break;
504  }
505  // #i91601#
506  case FN_UNO_LIST_ID:
507  {
508  *pAny <<= OUString();
509  break;
510  }
511  case FN_NUMBER_NEWSTART:
512  {
513  *pAny <<= false;
514  break;
515  }
517  {
518  break; // void
519  }
520  default:
521  assert(false);
522  }
523  }
524  //PROPERTY_MAYBEVOID!
525  }
526  break;
527  case FN_UNO_NUM_RULES :
528  if( pAny )
529  getNumberingProperty(rPam, eNewState, pAny);
530  else
531  {
532  if( !SwDoc::GetNumRuleAtPos( *rPam.GetPoint() ) )
533  eNewState = PropertyState_DEFAULT_VALUE;
534  }
535  break;
537  {
538  std::vector<SwTextAttr *> marks;
539  if (rPam.GetNode().IsTextNode())
540  {
541  marks = rPam.GetNode().GetTextNode()->GetTextAttrsAt(
543  }
544  if (!marks.empty())
545  {
546  if( pAny )
547  { // hmm... can only return 1 here
548  SwTOXMark & rMark =
549  static_cast<SwTOXMark &>((*marks.begin())->GetAttr());
550  const uno::Reference< text::XDocumentIndexMark > xRef =
552  rPam.GetDoc(), &rMark);
553  (*pAny) <<= xRef;
554  }
555  }
556  else
557  //also here - indistinguishable
558  eNewState = PropertyState_DEFAULT_VALUE;
559  }
560  break;
562  {
563  SwTOXBase* pBase = SwDoc::GetCurTOX(
564  *rPam.Start() );
565  if( pBase )
566  {
567  if( pAny )
568  {
569  const uno::Reference< text::XDocumentIndex > xRef =
571  static_cast<SwTOXBaseSection *>(pBase));
572  (*pAny) <<= xRef;
573  }
574  }
575  else
576  eNewState = PropertyState_DEFAULT_VALUE;
577  }
578  break;
579  case FN_UNO_TEXT_FIELD:
580  {
581  const SwPosition *pPos = rPam.Start();
582  const SwTextNode *pTextNd =
583  rPam.GetDoc().GetNodes()[pPos->nNode.GetIndex()]->GetTextNode();
584  const SwTextAttr* pTextAttr = pTextNd
585  ? pTextNd->GetFieldTextAttrAt( pPos->nContent.GetIndex(), true )
586  : nullptr;
587  if ( pTextAttr != nullptr )
588  {
589  if( pAny )
590  {
591  uno::Reference<text::XTextField> const xField(
593  &pTextAttr->GetFormatField()));
594  *pAny <<= xField;
595  }
596  }
597  else
598  eNewState = PropertyState_DEFAULT_VALUE;
599  }
600  break;
601  case FN_UNO_TEXT_TABLE:
602  case FN_UNO_CELL:
603  {
604  SwStartNode* pSttNode = rPam.GetNode().StartOfSectionNode();
605  SwStartNodeType eType = pSttNode->GetStartNodeType();
606  if(SwTableBoxStartNode == eType)
607  {
608  if( pAny )
609  {
610  const SwTableNode* pTableNode = pSttNode->FindTableNode();
611  SwFrameFormat* pTableFormat = pTableNode->GetTable().GetFrameFormat();
612  //SwTable& rTable = static_cast<SwTableNode*>(pSttNode)->GetTable();
613  if(FN_UNO_TEXT_TABLE == rEntry.nWID)
614  {
615  uno::Reference< XTextTable > xTable = SwXTextTables::GetObject(*pTableFormat);
616  *pAny <<= xTable;
617  }
618  else
619  {
620  SwTableBox* pBox = pSttNode->GetTableBox();
621  uno::Reference< XCell > xCell = SwXCell::CreateXCell(pTableFormat, pBox);
622  *pAny <<= xCell;
623  }
624  }
625  }
626  else
627  eNewState = PropertyState_DEFAULT_VALUE;
628  }
629  break;
630  case FN_UNO_TEXT_FRAME:
631  {
632  SwStartNode* pSttNode = rPam.GetNode().StartOfSectionNode();
633  SwStartNodeType eType = pSttNode->GetStartNodeType();
634 
635  SwFrameFormat* pFormat;
636  if(eType == SwFlyStartNode && nullptr != (pFormat = pSttNode->GetFlyFormat()))
637  {
638  // Create a wrapper only for text frames, not for graphic or OLE nodes.
639  if (pAny && !rPam.GetNode().IsNoTextNode())
640  {
641  uno::Reference<XTextFrame> const xFrame(
642  SwXTextFrame::CreateXTextFrame(*pFormat->GetDoc(), pFormat));
643  (*pAny) <<= xFrame;
644  }
645  }
646  else
647  eNewState = PropertyState_DEFAULT_VALUE;
648  }
649  break;
650  case FN_UNO_TEXT_SECTION:
651  {
652  SwSection* pSect = SwDoc::GetCurrSection(*rPam.GetPoint());
653  if(pSect)
654  {
655  if( pAny )
656  {
657  uno::Reference< XTextSection > xSect = SwXTextSections::GetObject( *pSect->GetFormat() );
658  *pAny <<= xSect;
659  }
660  }
661  else
662  eNewState = PropertyState_DEFAULT_VALUE;
663  }
664  break;
666  {
667  SwTextNode* pTextNode = rPam.GetPoint()->nNode.GetNode().GetTextNode();
668  if (pTextNode)
669  {
670  if (pAny)
671  {
672  uno::Reference<text::XTextContent> xParagraph = SwXParagraph::CreateXParagraph(pTextNode->GetDoc(), pTextNode);
673  *pAny <<= xParagraph;
674  }
675  }
676  else
677  eNewState = PropertyState_DEFAULT_VALUE;
678  }
679  break;
680  case FN_UNO_ENDNOTE:
681  case FN_UNO_FOOTNOTE:
682  {
683  SwTextAttr *const pTextAttr = rPam.GetNode().IsTextNode() ?
685  rPam.GetPoint()->nContent.GetIndex(), RES_TXTATR_FTN) : nullptr;
686  if(pTextAttr)
687  {
688  const SwFormatFootnote& rFootnote = pTextAttr->GetFootnote();
689  if(rFootnote.IsEndNote() == (FN_UNO_ENDNOTE == rEntry.nWID))
690  {
691  if( pAny )
692  {
693  const uno::Reference< text::XFootnote > xFootnote =
695  &const_cast<SwFormatFootnote&>(rFootnote));
696  *pAny <<= xFootnote;
697  }
698  }
699  else
700  eNewState = PropertyState_DEFAULT_VALUE;
701  }
702  else
703  eNewState = PropertyState_DEFAULT_VALUE;
704  }
705  break;
707  {
708  std::vector<SwTextAttr *> marks;
709  if (rPam.GetNode().IsTextNode())
710  {
711  marks = rPam.GetNode().GetTextNode()->GetTextAttrsAt(
713  }
714  if (!marks.empty())
715  {
716  if( pAny )
717  { // hmm... can only return 1 here
718  const SwFormatRefMark& rRef = (*marks.begin())->GetRefMark();
719  uno::Reference<XTextContent> const xRef =
721  const_cast<SwFormatRefMark*>(&rRef));
722  *pAny <<= xRef;
723  }
724  }
725  else
726  eNewState = PropertyState_DEFAULT_VALUE;
727  }
728  break;
730  {
731  uno::Reference<XTextContent> const xRet(rPam.GetNode().IsTextNode()
733  rPam.GetPoint()->nContent.GetIndex(), false)
734  : nullptr);
735  if (xRet.is())
736  {
737  if (pAny)
738  {
739  (*pAny) <<= xRet;
740  }
741  }
742  else
743  {
744  eNewState = PropertyState_DEFAULT_VALUE;
745  }
746  }
747  break;
749  {
750 
751  SwTextNode *const pTextNode = rPam.GetNode().GetTextNode();
752  if (&rPam.GetNode() == &rPam.GetNode(false)
753  && pTextNode && pTextNode->GetpSwpHints())
754  {
755  sal_Int32 nPaMStart = rPam.GetPoint()->nContent.GetIndex();
756  sal_Int32 nPaMEnd = rPam.GetMark() ? rPam.GetMark()->nContent.GetIndex() : nPaMStart;
757  if(nPaMStart > nPaMEnd)
758  {
759  std::swap(nPaMStart, nPaMEnd);
760  }
761  Sequence< OUString> aCharStyles;
762  SwpHints* pHints = pTextNode->GetpSwpHints();
763  for( size_t nAttr = 0; nAttr < pHints->Count(); ++nAttr )
764  {
765  SwTextAttr* pAttr = pHints->Get( nAttr );
766  if(pAttr->Which() != RES_TXTATR_CHARFMT)
767  continue;
768  const sal_Int32 nAttrStart = pAttr->GetStart();
769  const sal_Int32 nAttrEnd = *pAttr->GetEnd();
770  //check if the attribute touches the selection
771  if( ( nAttrEnd > nPaMStart && nAttrStart < nPaMEnd ) ||
772  ( !nAttrStart && !nAttrEnd && !nPaMStart && !nPaMEnd ) )
773  {
774  //check for overlapping
775  if(nAttrStart > nPaMStart ||
776  nAttrEnd < nPaMEnd)
777  {
778  aCharStyles.realloc(0);
779  break;
780  }
781  else
782  {
783  //now the attribute should start before or at the selection
784  //and it should end at the end of the selection or behind
785  OSL_ENSURE(nAttrStart <= nPaMStart && nAttrEnd >=nPaMEnd,
786  "attribute overlaps or is outside");
787  //now the name of the style has to be added to the sequence
788  aCharStyles.realloc(aCharStyles.getLength() + 1);
789  OSL_ENSURE(pAttr->GetCharFormat().GetCharFormat(), "no character format set");
790  aCharStyles.getArray()[aCharStyles.getLength() - 1] =
793  }
794  }
795 
796  }
797  eNewState =
798  aCharStyles.hasElements() ?
799  PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;
800  if(pAny)
801  (*pAny) <<= aCharStyles;
802  }
803  else
804  eNewState = PropertyState_DEFAULT_VALUE;
805  }
806  break;
807  case RES_TXTATR_CHARFMT:
808  // no break here!
809  default: bDone = false;
810  }
811  if( bDone )
812  eState = eNewState;
813  return bDone;
814 };
815 
816 sal_Int16 IsNodeNumStart(SwPaM const & rPam, PropertyState& eState)
817 {
818  const SwTextNode* pTextNd = rPam.GetNode().GetTextNode();
819  // correction: check, if restart value is set at the text node and use
820  // new method <SwTextNode::GetAttrListRestartValue()> to retrieve the value
821  if ( pTextNd && pTextNd->GetNumRule() && pTextNd->IsListRestart() &&
822  pTextNd->HasAttrListRestartValue() )
823  {
824  eState = PropertyState_DIRECT_VALUE;
825  sal_Int16 nTmp = sal::static_int_cast< sal_Int16 >(pTextNd->GetAttrListRestartValue());
826  return nTmp;
827  }
828  eState = PropertyState_DEFAULT_VALUE;
829  return -1;
830 }
831 
832 void setNumberingProperty(const Any& rValue, SwPaM& rPam)
833 {
834  uno::Reference<XIndexReplace> xIndexReplace;
835  if(rValue >>= xIndexReplace)
836  {
837  auto pSwNum = comphelper::getFromUnoTunnel<SwXNumberingRules>(xIndexReplace);
838  if(pSwNum)
839  {
840  SwDoc& rDoc = rPam.GetDoc();
841  if(pSwNum->GetNumRule())
842  {
843  SwNumRule aRule(*pSwNum->GetNumRule());
844  const OUString* pNewCharStyles = pSwNum->GetNewCharStyleNames();
845  const OUString* pBulletFontNames = pSwNum->GetBulletFontNames();
846  for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
847  {
848  SwNumFormat aFormat(aRule.Get( i ));
849  if (!pNewCharStyles[i].isEmpty() &&
850  !SwXNumberingRules::isInvalidStyle(pNewCharStyles[i]) &&
851  (!aFormat.GetCharFormat() || pNewCharStyles[i] != aFormat.GetCharFormat()->GetName()))
852  {
853  if (pNewCharStyles[i].isEmpty())
854  {
855  // FIXME
856  // Is something missing/wrong here?
857  // if condition is always false due to outer check!
858  aFormat.SetCharFormat(nullptr);
859  }
860  else
861  {
862 
863  // get CharStyle and set the rule
864  const size_t nChCount = rDoc.GetCharFormats()->size();
865  SwCharFormat* pCharFormat = nullptr;
866  for(size_t nCharFormat = 0; nCharFormat < nChCount; ++nCharFormat)
867  {
868  SwCharFormat& rChFormat = *((*(rDoc.GetCharFormats()))[nCharFormat]);
869  if(rChFormat.GetName() == pNewCharStyles[i])
870  {
871  pCharFormat = &rChFormat;
872  break;
873  }
874  }
875 
876  if(!pCharFormat)
877  {
879  SfxStyleSheetBase* pBase;
880  pBase = pPool->Find(pNewCharStyles[i], SfxStyleFamily::Char);
881  // shall it really be created?
882  if(!pBase)
883  pBase = &pPool->Make(pNewCharStyles[i], SfxStyleFamily::Page);
884  pCharFormat = static_cast<SwDocStyleSheet*>(pBase)->GetCharFormat();
885  }
886  if(pCharFormat)
887  aFormat.SetCharFormat(pCharFormat);
888  }
889  }
890  //Now again for fonts
891  if(
892  !pBulletFontNames[i].isEmpty() &&
893  !SwXNumberingRules::isInvalidStyle(pBulletFontNames[i]) &&
894  (!aFormat.GetBulletFont() || aFormat.GetBulletFont()->GetFamilyName() != pBulletFontNames[i])
895  )
896  {
897  const SvxFontListItem* pFontListItem =
898  static_cast<const SvxFontListItem* >(rDoc.GetDocShell()
899  ->GetItem( SID_ATTR_CHAR_FONTLIST ));
900  const FontList* pList = pFontListItem->GetFontList();
901 
902  FontMetric aFontMetric = pList->Get(
903  pBulletFontNames[i],WEIGHT_NORMAL, ITALIC_NONE);
904  vcl::Font aFont(aFontMetric);
905  aFormat.SetBulletFont(&aFont);
906  }
907  aRule.Set( i, aFormat );
908  }
909  UnoActionContext aAction(&rDoc);
910 
911  if( rPam.GetNext() != &rPam ) // Multiple selection?
912  {
914  SwPamRanges aRangeArr( rPam );
915  SwPaM aPam( *rPam.GetPoint() );
916  for ( size_t n = 0; n < aRangeArr.Count(); ++n )
917  {
918  // no start of a new list
919  rDoc.SetNumRule( aRangeArr.SetPam( n, aPam ), aRule, false );
920  }
921  rDoc.GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
922  }
923  else
924  {
925  // no start of a new list
926  rDoc.SetNumRule( rPam, aRule, false );
927  }
928 
929  }
930  else if(!pSwNum->GetCreatedNumRuleName().isEmpty())
931  {
932  UnoActionContext aAction( &rDoc );
933  SwNumRule* pRule = rDoc.FindNumRulePtr( pSwNum->GetCreatedNumRuleName() );
934  if ( !pRule )
935  throw RuntimeException();
936  // no start of a new list
937  rDoc.SetNumRule( rPam, *pRule, false );
938  }
939  else
940  {
941  // #i103817#
942  // outline numbering
943  UnoActionContext aAction(&rDoc);
944  SwNumRule* pRule = rDoc.GetOutlineNumRule();
945  if(!pRule)
946  throw RuntimeException();
947  rDoc.SetNumRule( rPam, *pRule, false );
948  }
949  }
950  }
951  else if ( rValue.getValueType() == cppu::UnoType<void>::get() )
952  {
953  rPam.GetDoc().DelNumRules(rPam);
954  }
955 }
956 
957 void getNumberingProperty(SwPaM& rPam, PropertyState& eState, Any * pAny )
958 {
959  const SwNumRule* pNumRule = SwDoc::GetNumRuleAtPos( *rPam.GetPoint() );
960  if(pNumRule)
961  {
962  uno::Reference< XIndexReplace > xNum = new SwXNumberingRules(*pNumRule);
963  if ( pAny )
964  *pAny <<= xNum;
965  eState = PropertyState_DIRECT_VALUE;
966  }
967  else
968  eState = PropertyState_DEFAULT_VALUE;
969 }
970 
971 void GetCurPageStyle(SwPaM const & rPaM, OUString &rString)
972 {
973  if (!rPaM.GetContentNode())
974  return; // TODO: is there an easy way to get it for tables/sections?
976  // Consider the position inside the content node, since the node may span over multiple pages
977  // with different page styles.
978  SwContentFrame* pFrame = rPaM.GetContentNode()->getLayoutFrame(pLayout, rPaM.GetPoint());
979  if(pFrame)
980  {
981  const SwPageFrame* pPage = pFrame->FindPageFrame();
982  if(pPage)
983  {
986  }
987  }
988 }
989 
990 // reset special properties of the cursor
992 {
993  SwDoc& rDoc = rPam.GetDoc();
994  switch(rEntry.nWID)
995  {
996  case FN_UNO_PARA_STYLE :
997  break;
998  case FN_UNO_PAGE_STYLE :
999  break;
1000  case FN_UNO_NUM_START_VALUE :
1001  {
1002  UnoActionContext aAction(&rDoc);
1003 
1004  if( rPam.GetNext() != &rPam ) // Multiple selection?
1005  {
1006  rDoc.GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr );
1007  SwPamRanges aRangeArr( rPam );
1008  SwPaM aPam( *rPam.GetPoint() );
1009  for( size_t n = 0; n < aRangeArr.Count(); ++n )
1010  rDoc.SetNodeNumStart( *aRangeArr.SetPam( n, aPam ).GetPoint(), 1 );
1011  rDoc.GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
1012  }
1013  else
1014  rDoc.SetNodeNumStart( *rPam.GetPoint(), 0 );
1015  }
1016 
1017  break;
1018  case FN_UNO_NUM_LEVEL :
1019  break;
1020  case FN_UNO_NUM_RULES:
1021  break;
1023  {
1024  rDoc.ResetAttrs(rPam, true, { RES_TXTATR_CHARFMT });
1025  }
1026  break;
1027  }
1028 }
1029 
1030 void InsertFile(SwUnoCursor* pUnoCursor, const OUString& rURL,
1031  const uno::Sequence< beans::PropertyValue >& rOptions)
1032 {
1033  std::unique_ptr<SfxMedium> pMed;
1034  SwDoc& rDoc = pUnoCursor->GetDoc();
1035  SwDocShell* pDocSh = rDoc.GetDocShell();
1036  utl::MediaDescriptor aMediaDescriptor( rOptions );
1037  OUString sFileName = rURL;
1038  OUString sFilterName, sFilterOptions, sPassword, sBaseURL;
1039  uno::Reference < io::XStream > xStream;
1040  uno::Reference < io::XInputStream > xInputStream;
1041 
1042  if( sFileName.isEmpty() )
1043  aMediaDescriptor[utl::MediaDescriptor::PROP_URL()] >>= sFileName;
1044  if( sFileName.isEmpty() )
1045  aMediaDescriptor[utl::MediaDescriptor::PROP_FILENAME()] >>= sFileName;
1046  aMediaDescriptor[utl::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream;
1047  aMediaDescriptor[utl::MediaDescriptor::PROP_STREAM()] >>= xStream;
1048  aMediaDescriptor[utl::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream;
1049  aMediaDescriptor[utl::MediaDescriptor::PROP_FILTERNAME()] >>= sFilterName;
1050  aMediaDescriptor[utl::MediaDescriptor::PROP_FILTEROPTIONS()] >>= sFilterOptions;
1051  aMediaDescriptor[utl::MediaDescriptor::PROP_PASSWORD()] >>= sPassword;
1052  aMediaDescriptor[utl::MediaDescriptor::PROP_DOCUMENTBASEURL() ] >>= sBaseURL;
1053  if ( !xInputStream.is() && xStream.is() )
1054  xInputStream = xStream->getInputStream();
1055 
1056  if(!pDocSh || (sFileName.isEmpty() && !xInputStream.is()))
1057  return;
1058 
1059  SfxObjectFactory& rFact = pDocSh->GetFactory();
1060  std::shared_ptr<const SfxFilter> pFilter = rFact.GetFilterContainer()->GetFilter4FilterName( sFilterName );
1061  uno::Reference < embed::XStorage > xReadStorage;
1062  if( xInputStream.is() )
1063  {
1064  uno::Sequence< uno::Any > aArgs( 2 );
1065  aArgs[0] <<= xInputStream;
1066  aArgs[1] <<= embed::ElementModes::READ;
1067  try
1068  {
1069  xReadStorage.set( ::comphelper::OStorageHelper::GetStorageFactory()->createInstanceWithArguments( aArgs ),
1070  uno::UNO_QUERY );
1071  }
1072  catch( const io::IOException&) {}
1073  }
1074  if ( !pFilter )
1075  {
1076  if( xInputStream.is() && !xReadStorage.is())
1077  {
1078  pMed.reset(new SfxMedium);
1079  pMed->setStreamToLoadFrom(xInputStream, true );
1080  }
1081  else
1082  pMed.reset(xReadStorage.is() ?
1083  new SfxMedium(xReadStorage, sBaseURL ) :
1084  new SfxMedium(sFileName, StreamMode::READ ));
1085  if( !sBaseURL.isEmpty() )
1086  pMed->GetItemSet()->Put( SfxStringItem( SID_DOC_BASEURL, sBaseURL ) );
1087 
1088  SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() );
1089  ErrCode nErr = aMatcher.GuessFilter(*pMed, pFilter, SfxFilterFlags::NONE);
1090  if ( nErr || !pFilter)
1091  return;
1092  pMed->SetFilter( pFilter );
1093  }
1094  else
1095  {
1096  if( xInputStream.is() && !xReadStorage.is())
1097  {
1098  pMed.reset(new SfxMedium);
1099  pMed->setStreamToLoadFrom(xInputStream, true );
1100  pMed->SetFilter( pFilter );
1101  }
1102  else
1103  {
1104  if( xReadStorage.is() )
1105  {
1106  pMed.reset(new SfxMedium(xReadStorage, sBaseURL ));
1107  pMed->SetFilter( pFilter );
1108  }
1109  else
1110  pMed.reset(new SfxMedium(sFileName, StreamMode::READ, pFilter, nullptr));
1111  }
1112  if(!sFilterOptions.isEmpty())
1113  pMed->GetItemSet()->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, sFilterOptions ) );
1114  if(!sBaseURL.isEmpty())
1115  pMed->GetItemSet()->Put( SfxStringItem( SID_DOC_BASEURL, sBaseURL ) );
1116  }
1117 
1118  // this sourcecode is not responsible for the lifetime of the shell, SfxObjectShellLock should not be used
1119  SfxObjectShellRef aRef( pDocSh );
1120 
1121  pMed->Download(); // if necessary: start the download
1122  if( !(aRef.is() && 1 < aRef->GetRefCount()) ) // Ref still valid?
1123  return;
1124 
1125  SwReaderPtr pRdr;
1126  SfxItemSet* pSet = pMed->GetItemSet();
1127  pSet->Put(SfxBoolItem(FN_API_CALL, true));
1128  if(!sPassword.isEmpty())
1129  pSet->Put(SfxStringItem(SID_PASSWORD, sPassword));
1130  Reader *pRead = pDocSh->StartConvertFrom( *pMed, pRdr, nullptr, pUnoCursor);
1131  if( !pRead )
1132  return;
1133 
1134  UnoActionContext aContext(&rDoc);
1135 
1136  if(pUnoCursor->HasMark())
1137  rDoc.getIDocumentContentOperations().DeleteAndJoin(*pUnoCursor);
1138 
1139  SwNodeIndex aSave( pUnoCursor->GetPoint()->nNode, -1 );
1140  sal_Int32 nContent = pUnoCursor->GetPoint()->nContent.GetIndex();
1141 
1142  ErrCode nErrno = pRdr->Read( *pRead ); // and paste the document
1143 
1144  if(!nErrno)
1145  {
1146  ++aSave;
1147  pUnoCursor->SetMark();
1148  pUnoCursor->GetMark()->nNode = aSave;
1149 
1150  SwContentNode* pCntNode = aSave.GetNode().GetContentNode();
1151  if( !pCntNode )
1152  nContent = 0;
1153  pUnoCursor->GetMark()->nContent.Assign( pCntNode, nContent );
1154  }
1155 }
1156 
1157 // insert text and scan for CR characters in order to insert
1158 // paragraph breaks at those positions by calling SplitNode
1160  SwDoc &rDoc,
1161  const SwPaM &rNewCursor,
1162  const OUString &rText,
1163  const bool bForceExpandHints )
1164 {
1165  bool bOK = true;
1166 
1167  for (sal_Int32 i = 0; i < rText.getLength(); ++i)
1168  {
1169  sal_Unicode const ch(rText[i]);
1171  && ch != '\r' && ch != '\n' && ch != '\t')
1172  {
1173  SAL_WARN("sw.uno", "DocInsertStringSplitCR: refusing to insert control character " << int(ch));
1174  return false;
1175  }
1176  }
1177 
1178  const SwInsertFlags nInsertFlags =
1179  bForceExpandHints
1182 
1183  // grouping done in InsertString is intended for typing, not API calls
1184  ::sw::GroupUndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
1185  SwTextNode* const pTextNd =
1186  rNewCursor.GetPoint()->nNode.GetNode().GetTextNode();
1187  if (!pTextNd)
1188  {
1189  SAL_INFO("sw.uno", "DocInsertStringSplitCR: need a text node");
1190  return false;
1191  }
1192  OUString aText;
1193  sal_Int32 nStartIdx = 0;
1194  const sal_Int32 nMaxLength = COMPLETE_STRING - pTextNd->GetText().getLength();
1195 
1196  sal_Int32 nIdx = rText.indexOf( '\r', nStartIdx );
1197  if( ( nIdx == -1 && nMaxLength < rText.getLength() ) ||
1198  ( nIdx != -1 && nMaxLength < nIdx ) )
1199  {
1200  nIdx = nMaxLength;
1201  }
1202  while (nIdx != -1 )
1203  {
1204  OSL_ENSURE( nIdx - nStartIdx >= 0, "index negative!" );
1205  aText = rText.copy( nStartIdx, nIdx - nStartIdx );
1206  if (!aText.isEmpty() &&
1207  !rDoc.getIDocumentContentOperations().InsertString( rNewCursor, aText, nInsertFlags ))
1208  {
1209  OSL_FAIL( "Doc->Insert(Str) failed." );
1210  bOK = false;
1211  }
1212  if (!rDoc.getIDocumentContentOperations().SplitNode( *rNewCursor.GetPoint(), false ) )
1213  {
1214  OSL_FAIL( "SplitNode failed" );
1215  bOK = false;
1216  }
1217  nStartIdx = nIdx + 1;
1218  nIdx = rText.indexOf( '\r', nStartIdx );
1219  }
1220  aText = rText.copy( nStartIdx );
1221  if (!aText.isEmpty() &&
1222  !rDoc.getIDocumentContentOperations().InsertString( rNewCursor, aText, nInsertFlags ))
1223  {
1224  OSL_FAIL( "Doc->Insert(Str) failed." );
1225  bOK = false;
1226  }
1227 
1228  return bOK;
1229 }
1230 
1231 void makeRedline( SwPaM const & rPaM,
1232  std::u16string_view rRedlineType,
1233  const uno::Sequence< beans::PropertyValue >& rRedlineProperties )
1234 {
1235  IDocumentRedlineAccess& rRedlineAccess = rPaM.GetDoc().getIDocumentRedlineAccess();
1236 
1238  if ( rRedlineType == u"Insert" )
1239  eType = RedlineType::Insert;
1240  else if ( rRedlineType == u"Delete" )
1241  eType = RedlineType::Delete;
1242  else if ( rRedlineType == u"Format" )
1243  eType = RedlineType::Format;
1244  else if ( rRedlineType == u"TextTable" )
1245  eType = RedlineType::Table;
1246  else if ( rRedlineType == u"ParagraphFormat" )
1247  eType = RedlineType::ParagraphFormat;
1248  else
1249  throw lang::IllegalArgumentException();
1250 
1251  //todo: what about REDLINE_FMTCOLL?
1252  comphelper::SequenceAsHashMap aPropMap( rRedlineProperties );
1253  std::size_t nAuthor = 0;
1254  OUString sAuthor;
1255  if( aPropMap.getValue("RedlineAuthor") >>= sAuthor )
1256  nAuthor = rRedlineAccess.InsertRedlineAuthor(sAuthor);
1257 
1258  OUString sComment;
1259  SwRedlineData aRedlineData( eType, nAuthor );
1260  if( aPropMap.getValue("RedlineComment") >>= sComment )
1261  aRedlineData.SetComment( sComment );
1262 
1263  ::util::DateTime aStamp;
1264  if( aPropMap.getValue("RedlineDateTime") >>= aStamp )
1265  {
1266  aRedlineData.SetTimeStamp( DateTime( aStamp));
1267  }
1268 
1269  std::unique_ptr<SwRedlineExtraData_FormatColl> xRedlineExtraData;
1270 
1271  // Read the 'Redline Revert Properties' from the parameters
1272  uno::Sequence< beans::PropertyValue > aRevertProperties;
1273  // Check if the value exists
1274  if ( aPropMap.getValue("RedlineRevertProperties") >>= aRevertProperties )
1275  {
1276  int nMap = 0;
1277  // Make sure that paragraph format gets its own map, otherwise e.g. fill attributes are not preserved.
1278  if (eType == RedlineType::ParagraphFormat)
1279  {
1280  nMap = PROPERTY_MAP_PARAGRAPH;
1281  if (!aRevertProperties.hasElements())
1282  {
1283  // to reject the paragraph style change, use standard style
1284  xRedlineExtraData.reset(new SwRedlineExtraData_FormatColl( "", RES_POOLCOLL_STANDARD, nullptr ));
1285  }
1286  }
1287  else
1289  SfxItemPropertySet const& rPropSet = *aSwMapProvider.GetPropertySet(nMap);
1290 
1291  // Check if there are any properties
1292  if (aRevertProperties.hasElements())
1293  {
1294  SwDoc& rDoc = rPaM.GetDoc();
1295 
1296  // Build set of attributes we want to fetch
1297  WhichRangesContainer aWhichPairs;
1298  std::vector<SfxItemPropertyMapEntry const*> aEntries;
1299  std::vector<uno::Any> aValues;
1300  aEntries.reserve(aRevertProperties.getLength());
1301  sal_uInt16 nStyleId = USHRT_MAX;
1302  sal_uInt16 nNumId = USHRT_MAX;
1303  for (const auto& rRevertProperty : std::as_const(aRevertProperties))
1304  {
1305  const OUString &rPropertyName = rRevertProperty.Name;
1306  SfxItemPropertyMapEntry const* pEntry = rPropSet.getPropertyMap().getByName(rPropertyName);
1307 
1308  if (!pEntry)
1309  {
1310  // unknown property
1311  break;
1312  }
1313  else if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
1314  {
1315  break;
1316  }
1317  else if (rPropertyName == "NumberingRules")
1318  {
1319  aWhichPairs = aWhichPairs.MergeRange(RES_PARATR_NUMRULE, RES_PARATR_NUMRULE);
1320  nNumId = aEntries.size();
1321  }
1322  else
1323  {
1324  aWhichPairs = aWhichPairs.MergeRange(pEntry->nWID, pEntry->nWID);
1325  if (rPropertyName == "ParaStyleName")
1326  nStyleId = aEntries.size();
1327  }
1328  aEntries.push_back(pEntry);
1329  aValues.push_back(rRevertProperty.Value);
1330  }
1331 
1332  if (!aWhichPairs.empty())
1333  {
1334  sal_uInt16 nStylePoolId = USHRT_MAX;
1335  OUString sParaStyleName;
1336  SfxItemSet aItemSet(rDoc.GetAttrPool(), aWhichPairs);
1337 
1338  for (size_t i = 0; i < aEntries.size(); ++i)
1339  {
1340  const uno::Any &rValue = aValues[i];
1341  if (i == nNumId)
1342  {
1343  uno::Reference<container::XNamed> xNumberingRules;
1344  rValue >>= xNumberingRules;
1345  if (xNumberingRules.is())
1346  {
1347  aItemSet.Put( SwNumRuleItem( xNumberingRules->getName() ));
1348  // keep it during export
1349  SwNumRule* pRule = rDoc.FindNumRulePtr(
1350  xNumberingRules->getName());
1351  if (pRule)
1352  pRule->SetUsedByRedline(true);
1353  }
1354  }
1355  else
1356  {
1357  SfxItemPropertyMapEntry const*const pEntry = aEntries[i];
1358  rPropSet.setPropertyValue(*pEntry, rValue, aItemSet);
1359  if (i == nStyleId)
1360  rValue >>= sParaStyleName;
1361  }
1362  }
1363 
1364  if (eType == RedlineType::ParagraphFormat && sParaStyleName.isEmpty())
1365  nStylePoolId = RES_POOLCOLL_STANDARD;
1366 
1367  xRedlineExtraData.reset(new SwRedlineExtraData_FormatColl( sParaStyleName, nStylePoolId, &aItemSet ));
1368  }
1369  else if (eType == RedlineType::ParagraphFormat)
1370  xRedlineExtraData.reset(new SwRedlineExtraData_FormatColl( "", RES_POOLCOLL_STANDARD, nullptr ));
1371  }
1372  }
1373 
1374  SwRangeRedline* pRedline = new SwRangeRedline( aRedlineData, rPaM );
1375  RedlineFlags nPrevMode = rRedlineAccess.GetRedlineFlags( );
1376  // xRedlineExtraData is copied here
1377  pRedline->SetExtraData( xRedlineExtraData.get() );
1378 
1379  rRedlineAccess.SetRedlineFlags_intern(RedlineFlags::On);
1380  auto const result(rRedlineAccess.AppendRedline(pRedline, false));
1381  rRedlineAccess.SetRedlineFlags_intern( nPrevMode );
1383  throw lang::IllegalArgumentException();
1384 }
1385 
1387  std::u16string_view rRedlineType,
1388  const uno::Sequence< beans::PropertyValue >& rRedlineProperties )
1389 {
1390  SwDoc* pDoc = rTableLine.GetFrameFormat()->GetDoc();
1391  IDocumentRedlineAccess* pRedlineAccess = &pDoc->getIDocumentRedlineAccess();
1392 
1394  if ( rRedlineType == u"TableRowInsert" )
1395  {
1396  eType = RedlineType::TableRowInsert;
1397  }
1398  else if ( rRedlineType == u"TableRowDelete" )
1399  {
1400  eType = RedlineType::TableRowDelete;
1401  }
1402  else
1403  {
1404  throw lang::IllegalArgumentException();
1405  }
1406 
1407  // set table row property "HasTextChangesOnly" to false
1408  // to handle tracked deletion or insertion of the table row on the UI
1409  const SvxPrintItem *pHasTextChangesOnlyProp =
1411  if ( !pHasTextChangesOnlyProp || pHasTextChangesOnlyProp->GetValue() )
1412  {
1413  SvxPrintItem aSetTracking(RES_PRINT, false);
1414  SwNodeIndex aInsPos( *(rTableLine.GetTabBoxes()[0]->GetSttNd()), 1 );
1415  // as a workaround for the rows without text content,
1416  // add a redline with invisible text CH_TXT_TRACKED_DUMMY_CHAR
1417  if ( rTableLine.IsEmpty() )
1418  {
1419  SwPaM aPaM(aInsPos);
1421  OUStringChar(CH_TXT_TRACKED_DUMMY_CHAR) );
1422  aPaM.SetMark();
1423  aPaM.GetMark()->nContent.Assign(aPaM.GetContentNode(), 0);
1424  makeRedline(aPaM, RedlineType::TableRowInsert == eType
1425  ? u"Insert"
1426  : u"Delete", rRedlineProperties);
1427  }
1428  SwCursor aCursor( SwPosition(aInsPos), nullptr );
1429  pDoc->SetRowNotTracked( aCursor, aSetTracking );
1430  }
1431 
1432  comphelper::SequenceAsHashMap aPropMap( rRedlineProperties );
1433  std::size_t nAuthor = 0;
1434  OUString sAuthor;
1435  if( aPropMap.getValue("RedlineAuthor") >>= sAuthor )
1436  nAuthor = pRedlineAccess->InsertRedlineAuthor(sAuthor);
1437 
1438  OUString sComment;
1439  SwRedlineData aRedlineData( eType, nAuthor );
1440  if( aPropMap.getValue("RedlineComment") >>= sComment )
1441  aRedlineData.SetComment( sComment );
1442 
1443  ::util::DateTime aStamp;
1444  if( aPropMap.getValue("RedlineDateTime") >>= aStamp )
1445  {
1446  aRedlineData.SetTimeStamp(
1447  DateTime( Date( aStamp.Day, aStamp.Month, aStamp.Year ), tools::Time( aStamp.Hours, aStamp.Minutes, aStamp.Seconds ) ) );
1448  }
1449 
1450  SwTableRowRedline* pRedline = new SwTableRowRedline( aRedlineData, rTableLine );
1451  RedlineFlags nPrevMode = pRedlineAccess->GetRedlineFlags( );
1452  pRedline->SetExtraData( nullptr );
1453 
1454  pRedlineAccess->SetRedlineFlags_intern(RedlineFlags::On);
1455  bool bRet = pRedlineAccess->AppendTableRowRedline( pRedline );
1456  pRedlineAccess->SetRedlineFlags_intern( nPrevMode );
1457  if( !bRet )
1458  throw lang::IllegalArgumentException();
1459 }
1460 
1462  std::u16string_view rRedlineType,
1463  const uno::Sequence< beans::PropertyValue >& rRedlineProperties )
1464 {
1465  IDocumentRedlineAccess* pRedlineAccess = &rTableBox.GetFrameFormat()->GetDoc()->getIDocumentRedlineAccess();
1466 
1468  if ( rRedlineType == u"TableCellInsert" )
1469  {
1470  eType = RedlineType::TableCellInsert;
1471  }
1472  else if ( rRedlineType == u"TableCellDelete" )
1473  {
1474  eType = RedlineType::TableCellDelete;
1475  }
1476  else
1477  {
1478  throw lang::IllegalArgumentException();
1479  }
1480 
1481  comphelper::SequenceAsHashMap aPropMap( rRedlineProperties );
1482  std::size_t nAuthor = 0;
1483  OUString sAuthor;
1484  if( aPropMap.getValue("RedlineAuthor") >>= sAuthor )
1485  nAuthor = pRedlineAccess->InsertRedlineAuthor(sAuthor);
1486 
1487  OUString sComment;
1488  SwRedlineData aRedlineData( eType, nAuthor );
1489  if( aPropMap.getValue("RedlineComment") >>= sComment )
1490  aRedlineData.SetComment( sComment );
1491 
1492  ::util::DateTime aStamp;
1493  if( aPropMap.getValue("RedlineDateTime") >>= aStamp )
1494  {
1495  aRedlineData.SetTimeStamp(
1496  DateTime( Date( aStamp.Day, aStamp.Month, aStamp.Year ), tools::Time( aStamp.Hours, aStamp.Minutes, aStamp.Seconds ) ) );
1497  }
1498 
1499  SwTableCellRedline* pRedline = new SwTableCellRedline( aRedlineData, rTableBox );
1500  RedlineFlags nPrevMode = pRedlineAccess->GetRedlineFlags( );
1501  pRedline->SetExtraData( nullptr );
1502 
1503  pRedlineAccess->SetRedlineFlags_intern(RedlineFlags::On);
1504  bool bRet = pRedlineAccess->AppendTableCellRedline( pRedline );
1505  pRedlineAccess->SetRedlineFlags_intern( nPrevMode );
1506  if( !bRet )
1507  throw lang::IllegalArgumentException();
1508 }
1509 
1510 void SwAnyMapHelper::SetValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& rAny )
1511 {
1512  sal_uInt32 nKey = (nWhichId << 16) + nMemberId;
1513  m_Map[nKey] = rAny;
1514 }
1515 
1516 bool SwAnyMapHelper::FillValue( sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& pAny )
1517 {
1518  bool bRet = false;
1519  sal_uInt32 nKey = (nWhichId << 16) + nMemberId;
1520  auto aIt = m_Map.find( nKey );
1521  if (aIt != m_Map.end())
1522  {
1523  pAny = & aIt->second;
1524  bRet = true;
1525  }
1526  return bRet;
1527 }
1528 
1529 }//namespace SwUnoCursorHelper
1530 
1531 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool is() const
Starts a section of nodes in the document model.
Definition: node.hxx:312
static const OUString & PROP_DOCUMENTBASEURL()
#define FN_API_CALL
Definition: cmdid.h:552
static const OUString & PROP_PASSWORD()
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
virtual SfxObjectFactory & GetFactory() const =0
static uno::Any GetParaListAutoFormat(SwTextNode const &rNode)
virtual const SwDoc * GetDoc() const =0
static const OUString & PROP_FILENAME()
Marks a position in the document model.
Definition: pam.hxx:35
void setPropertyValue(const SfxItemPropertyMapEntry &rEntry, const css::uno::Any &aVal, SfxItemSet &rSet) const
#define FN_UNO_DOCUMENT_INDEX_MARK
Definition: cmdid.h:524
#define FN_UNO_CELL
Definition: cmdid.h:528
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:313
const SwNodeNum * GetNum(SwRootFrame const *pLayout=nullptr) const
Definition: ndtxt.cxx:3918
constexpr TypedWhichId< SvxPrintItem > RES_PRINT(98)
bool getCursorPropertyValue(const SfxItemPropertyMapEntry &rEntry, SwPaM &rPam, Any *pAny, PropertyState &eState, const SwTextNode *pNode)
SwTableBox * GetTableBox() const
If node is in a table return the respective table box.
Definition: node.cxx:754
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_METAFIELD(49)
virtual const SwRootFrame * GetCurrentLayout() const =0
static rtl::Reference< SwXCell > CreateXCell(SwFrameFormat *pTableFormat, SwTableBox *pBox, SwTable *pTable=nullptr)
Definition: unotbl.cxx:1129
SwDocShell * GetDocShell()
Definition: doc.hxx:1352
SwpHints * GetpSwpHints()
Definition: ndtxt.hxx:226
virtual AppendResult AppendRedline(SwRangeRedline *pNewRedl, bool bCallDelete)=0
Append a new redline.
void SetTimeStamp(const DateTime &rDT)
Definition: redline.hxx:132
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_META(48)
virtual void SetRedlineFlags_intern(RedlineFlags eMode)=0
Set a new redline mode.
static SwTOXBase * GetCurTOX(const SwPosition &rPos)
Get current table of contents.
Definition: doctxm.cxx:447
SwNodeIndex nNode
Definition: pam.hxx:37
static const OUString & PROP_FILTEROPTIONS()
static SwPaM * lcl_createPamCopy(const SwPaM &rPam)
virtual const sal_Int32 * GetEnd() const
end position
Definition: txatbase.cxx:48
const SwFrameFormat * GetFrameFormat() const
Definition: unoframe.hxx:152
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)
constexpr TypedWhichId< SwNumRuleItem > RES_PARATR_NUMRULE(72)
Reference< XFrame > xFrame
const SwPosition * GetMark() const
Definition: pam.hxx:209
#define FN_UNO_PARA_CONT_PREV_SUBTREE
Definition: cmdid.h:608
void getNumberingProperty(SwPaM &rPam, PropertyState &eState, Any *pAny)
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1213
SwTableBox * GetTableBox() const
Definition: unotbl.hxx:143
sal_Int64 n
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
OUString GetListId() const
Definition: ndtxt.cxx:4339
static const OUString & PROP_FILTERNAME()
const SfxItemPropertySet * GetPropertySet(sal_uInt16 PropertyId)
Definition: unomap1.cxx:1062
Definition: doc.hxx:188
constexpr sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:93
SwTableLine is one table row in the document model.
Definition: swtable.hxx:357
SwNode & GetNode() const
Definition: ndindex.hxx:119
#define FN_UNO_TEXT_PARAGRAPH
Definition: cmdid.h:548
const std::shared_ptr< SfxItemSet > & GetStyleHandle() const
Definition: fmtautofmt.hxx:49
SwSectionFormat * GetFormat()
Definition: section.hxx:336
bool IsEndNote() const
Definition: fmtftn.hxx:71
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
void resetCursorPropertyValue(const SfxItemPropertyMapEntry &rEntry, SwPaM &rPam)
void GetSelectableFromAny(uno::Reference< uno::XInterface > const &xIfc, SwDoc &rTargetDoc, SwPaM *&o_rpPaM, std::pair< OUString, FlyCntType > &o_rFrame, OUString &o_rTableName, SwUnoTableCursor const *&o_rpTableCursor,::sw::mark::IMark const *&o_rpMark, std::vector< SdrObject * > &o_rSdrObjects)
sal_uInt16 Which() const
Definition: txatbase.hxx:114
static css::uno::Reference< css::text::XTextField > CreateXTextField(SwDoc *pDoc, SwFormatField const *pFormat, SwServiceType nServiceId=SwServiceType::Invalid)
Definition: unofield.cxx:1219
virtual bool DeleteAndJoin(SwPaM &, const bool bForceJoinNext=false)=0
complete delete of a given PaM
SwTextAttr * GetTextAttrAt(sal_Int32 const nIndex, sal_uInt16 const nWhich, enum GetTextAttrMode const eMode=DEFAULT) const
get the innermost text attribute covering position nIndex.
Definition: ndtxt.cxx:1691
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:315
void makeTableCellRedline(SwTableBox &rTableBox, std::u16string_view rRedlineType, const uno::Sequence< beans::PropertyValue > &rRedlineProperties)
bool IsListRestart() const
Definition: ndtxt.cxx:4086
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
static SwSection * GetCurrSection(const SwPosition &rPos)
Definition: ndsect.cxx:502
int GetActualListLevel() const
Returns the actual list level of this text node, when it is a list item.
Definition: ndtxt.cxx:4063
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:204
int GetAttrOutlineLevel() const
Returns outline level of this text node.
Definition: ndtxt.cxx:3983
static css::uno::Reference< css::lang::XSingleServiceFactory > GetStorageFactory(const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >())
const OUString & GetName() const
Definition: pagedesc.hxx:196
const SfxItemPropertyMapEntry * getByName(std::u16string_view rName) const
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:229
SwTextAttr * GetTextAttrForCharAt(const sal_Int32 nIndex, const sal_uInt16 nWhich=RES_TXTATR_END) const
get the text attribute at position nIndex which owns the dummy character CH_TXTATR_* at that position...
Definition: ndtxt.cxx:3012
sal_uInt16 sal_Unicode
#define PROPERTY_MAP_CHAR_AUTO_STYLE
Definition: unomap.hxx:119
#define FN_UNO_PARA_NUM_AUTO_FORMAT
Definition: cmdid.h:519
#define FN_UNO_ENDNOTE
Definition: cmdid.h:533
#define FN_UNO_LIST_ID
Definition: cmdid.h:605
Reference< XInputStream > xStream
SwIndex nContent
Definition: pam.hxx:38
#define FN_UNO_DOCUMENT_INDEX
Definition: cmdid.h:525
static SwNumRule * GetNumRuleAtPos(SwPosition &rPos, SwRootFrame const *pLayout=nullptr)
Definition: docnum.cxx:2387
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:242
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:41
void SetComment(const OUString &rS)
Definition: redline.hxx:131
const OUString & GetName() const
Definition: format.hxx:115
constexpr TypedWhichId< SfxUInt16Item > RES_PARATR_OUTLINELEVEL(79)
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
sal_Int32 GetStart() const
Definition: txatbase.hxx:86
FontMetric Get(const OUString &rName, const OUString &rStyleName) const
void SetValue(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const css::uno::Any &rAny)
const css::uno::Reference< css::uno::XAggregation > & GetAggregationInterface() const
Definition: unodraw.hxx:259
Mode eMode
const SwTable & GetTable() const
Definition: node.hxx:499
constexpr TypedWhichId< SwFormatCharFormat > RES_TXTATR_CHARFMT(52)
const SwFormatField & GetFormatField() const
Definition: txatbase.hxx:195
#define FN_UNO_PARA_CONDITIONAL_STYLE_NAME
Definition: cmdid.h:561
RedlineFlags on.
static const OUString & PROP_STREAM()
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(58)
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:213
SwPaM * GetNext()
Definition: pam.hxx:264
Redline that holds information about a table-cell that had some change.
Definition: redline.hxx:301
virtual bool AppendTableCellRedline(SwTableCellRedline *pPtr)=0
SwPaM & SetPam(size_t nArrPos, SwPaM &rPam)
Definition: ednumber.cxx:101
#define FN_UNO_IS_NUMBER
Definition: cmdid.h:564
SwFormatColl & GetAnyFormatColl() const
Definition: node.hxx:708
std::unique_ptr< SwReader, o3tl::default_delete< SwReader > > SwReaderPtr
Definition: docsh.hxx:44
DocumentType eType
void DelNumRules(const SwPaM &, SwRootFrame const *pLayout=nullptr)
Definition: docnum.cxx:1322
void SetNodeNumStart(const SwPosition &rPos, sal_uInt16 nStt)
Definition: docnum.cxx:1038
FlyCntType GetFlyCntType() const
Definition: unoframe.hxx:157
#define FN_UNO_PAGE_STYLE
Definition: cmdid.h:517
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
size_t Count() const
Definition: edimp.hxx:49
SwNumRule * FindNumRulePtr(const OUString &rName) const
Definition: docnum.cxx:2416
static SwTable * FindTable(SwFrameFormat const *const pFormat)
Definition: swtable.cxx:1966
virtual bool InsertString(const SwPaM &rRg, const OUString &, const SwInsertFlags nInsertMode=SwInsertFlags::EMPTYEXPAND)=0
Insert string into existing text node at position rRg.Point().
#define CH_TXT_TRACKED_DUMMY_CHAR
Definition: hintids.hxx:187
Style of a layout element.
Definition: frmfmt.hxx:59
size_t Count() const
Definition: ndhints.hxx:142
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
SwTextAttr * Get(size_t nPos) const
Definition: ndhints.hxx:144
int i
bool GoInNode(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:961
static const OUString & PROP_URL()
SwTableBox * FindBox(SwTable *pTable, SwTableBox *pBox)
search if a box exists in a table
Definition: unotbl.cxx:1150
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:132
SwDoc & GetDoc()
Definition: node.hxx:212
const SwPosition * GetPoint() const
Definition: pam.hxx:207
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
#define FN_UNO_NESTED_TEXT_CONTENT
Definition: cmdid.h:612
virtual SfxStyleSheetBase & Make(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits nMask=SfxStyleSearchBits::All)
SwPageFrame * FindPageFrame()
Definition: frame.hxx:681
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:143
SwContentNode * GetContentNode()
Definition: node.hxx:616
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
css::uno::Any getValue(const OUString &sKey) const
virtual SfxStyleSheetBasePool * GetStyleSheetPool() override
For Style PI.
Definition: docsh.cxx:1142
WEIGHT_NORMAL
float u
static css::uno::Reference< css::text::XDocumentIndexMark > CreateXDocumentIndexMark(SwDoc &rDoc, SwTOXMark *pMark, TOXTypes eType=TOX_INDEX)
Definition: unoidx.cxx:1614
const SfxItemPropertyMap & getPropertyMap() const
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
Definition: ndtxt.cxx:2777
dictionary props
static css::uno::Reference< css::text::XDocumentIndex > CreateXDocumentIndex(SwDoc &rDoc, SwTOXBaseSection *pSection, TOXTypes eTypes=TOX_INDEX)
Definition: unoidx.cxx:401
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:379
bool IsNoTextNode() const
Definition: node.hxx:649
Marks a node in the document model.
Definition: ndindex.hxx:31
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:444
css::uno::Type const & get()
static css::uno::Reference< css::text::XTextTable > GetObject(SwFrameFormat &rFormat)
Definition: unocoll.cxx:980
SwTextField * GetFieldTextAttrAt(const sal_Int32 nIndex, const bool bIncludeInputFieldAtStart=false) const
Definition: ndtxt.cxx:1735
Reader * StartConvertFrom(SfxMedium &rMedium, SwReaderPtr &rpRdr, SwCursorShell const *pCursorSh=nullptr, SwPaM *pPaM=nullptr)
For inserting document.
Definition: docsh.cxx:139
SwStartNodeType GetStartNodeType() const
Definition: node.hxx:329
ITALIC_NONE
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:123
virtual std::size_t InsertRedlineAuthor(const OUString &rAuthor)=0
#define FN_UNO_NUM_START_VALUE
Definition: cmdid.h:521
void InsertFile(SwUnoCursor *pUnoCursor, const OUString &rURL, const uno::Sequence< beans::PropertyValue > &rOptions)
static css::uno::Reference< css::text::XTextContent > CreateXReferenceMark(SwDoc &rDoc, SwFormatRefMark *pMarkFormat)
Definition: unorefmk.cxx:129
Represents the style of a text portion.
Definition: charfmt.hxx:26
A page of the document layout.
Definition: pagefrm.hxx:57
bool FillValue(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const css::uno::Any *&pAny)
const SwFormatFootnote & GetFootnote() const
Definition: txatbase.hxx:204
Redline that holds information about a table-row that had some change.
Definition: redline.hxx:280
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
#define FN_UNO_TEXT_SECTION
Definition: cmdid.h:531
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:112
const SwPosition * Start() const
Definition: pam.hxx:212
SAL_WARN_UNUSED_RESULT WhichRangesContainer MergeRange(sal_uInt16 nFrom, sal_uInt16 nTo) const
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange,::sw::TextRangeMode const eMode)
Definition: unoobj2.cxx:1107
EXPAND : (Start < nIndex <= End)
Definition: ndtxt.hxx:371
size_t size() const
Definition: charformats.hxx:71
bool IsControlChar(sal_Unicode cChar)
DEFAULT: (Start <= nIndex < End)
Definition: ndtxt.hxx:370
virtual const SwPaM * GetPaM() const =0
#define FN_UNO_TEXT_FIELD
Definition: cmdid.h:526
std::map< sal_uInt32, css::uno::Any > m_Map
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
uno::Reference< text::XTextContent > GetNestedTextContent(SwTextNode const &rTextNode, sal_Int32 const nIndex, bool const bParent)
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
virtual bool AppendTableRowRedline(SwTableRowRedline *pPtr)=0
SwTableBoxes & GetTabBoxes()
Definition: swtable.hxx:367
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:292
#define PROPERTY_MAP_PARAGRAPH
Definition: unomap.hxx:61
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
SwCharFormat * GetCharFormat() const
Definition: fchrfmt.hxx:70
void SetCharFormat(SwCharFormat *)
Definition: number.cxx:273
const SwStartNode * GetSttNd() const
Definition: swtable.hxx:458
An SwTextAttr container, stores all directly formatted text portions for a text node.
Definition: ndhints.hxx:67
#define FN_UNO_NUM_RULES
Definition: cmdid.h:523
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:740
#define FN_NUMBER_NEWSTART
Definition: cmdid.h:456
SwNumberTree::tSwNumTreeNumber GetAttrListRestartValue() const
Definition: ndtxt.cxx:4140
#define FN_UNO_CHARFMT_SEQUENCE
Definition: cmdid.h:589
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
std::shared_ptr< const SfxFilter > GetFilter4FilterName(const OUString &rName, SfxFilterFlags nMust=SfxFilterFlags::NONE, SfxFilterFlags nDont=SFX_FILTER_NOTINSTALLED) const
#define FN_UNO_REFERENCE_MARK
Definition: cmdid.h:530
#define SAL_INFO(area, stream)
sal_Int32 GetIndex() const
Definition: index.hxx:91
bool IsCountedInList() const
Definition: ndtxt.cxx:4201
static void FillProgName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
SwNodes & GetNodes()
Definition: doc.hxx:409
void SetRowNotTracked(const SwCursor &rCursor, const SvxPrintItem &rNotTracked, bool bAll=false)
rNotTracked = false means that the row was deleted or inserted with its tracked cell content bAll: de...
Definition: ndtbl1.cxx:543
SdrObject * GetSdrObject() const
static SW_DLLPUBLIC css::uno::Reference< css::text::XTextFrame > CreateXTextFrame(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
Definition: unoframe.cxx:3177
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:405
const SwUnoCursor * GetTableCursor() const
Definition: unotbl.cxx:3812
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:87
#define FN_UNO_TEXT_FRAME
Definition: cmdid.h:529
::sw::mark::IMark const * GetBookmarkInDoc(SwDoc const *const pDoc, const css::uno::Reference< css::lang::XUnoTunnel > &xUT)
Definition: unobkm.cxx:187
constexpr TypedWhichId< SwTOXMark > RES_TXTATR_TOXMARK(47)
void makeRedline(SwPaM const &rPaM, std::u16string_view rRedlineType, const uno::Sequence< beans::PropertyValue > &rRedlineProperties)
Any value
bool IsContinueingPreviousSubTree() const
static css::uno::Reference< css::text::XFootnote > CreateXFootnote(SwDoc &rDoc, SwFormatFootnote *pFootnoteFormat, bool isEndnote=false)
Definition: unoftn.cxx:144
SwStartNodeType
Definition: ndtyp.hxx:50
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:715
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:357
void makeTableRowRedline(SwTableLine &rTableLine, std::u16string_view rRedlineType, const uno::Sequence< beans::PropertyValue > &rRedlineProperties)
constexpr sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:58
SwFormatColl * GetCurTextFormatColl(SwPaM &rPam, const bool bConditional)
Definition: unoobj.cxx:616
virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart)=0
Split a node at rPos (implemented only for TextNode).
OUString GetNumString(const bool _bInclPrefixAndSuffixStrings=true, const unsigned int _nRestrictToThisLevel=MAXLEVEL, SwRootFrame const *pLayout=nullptr) const
Returns outline of numbering string.
Definition: ndtxt.cxx:3083
const SfxPoolItem & GetAttr() const
Definition: txatbase.hxx:163
void GetCurPageStyle(SwPaM const &rPaM, OUString &rString)
void setNumberingProperty(const Any &rValue, SwPaM &rPam)
std::vector< SwTextAttr * > GetTextAttrsAt(sal_Int32 const nIndex, sal_uInt16 const nWhich) const
get the innermost text attributes covering position nIndex.
Definition: ndtxt.cxx:1682
sal_Int32 size() const noexcept
ScXMLEditAttributeMap::Entry const aEntries[]
constexpr TypedWhichId< SwFormatAutoFormat > RES_PARATR_LIST_AUTOFMT(87)
Any result
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
#define SAL_WARN(area, stream)
SwFormatColl * GetFormatColl() const
Definition: node.hxx:454
bool IsInList() const
Definition: ndtxt.cxx:4305
SwDoc & GetDoc() const
Definition: pam.hxx:243
bool DocInsertStringSplitCR(SwDoc &rDoc, const SwPaM &rNewCursor, const OUString &rText, const bool bForceExpandHints)
void SetUsedByRedline(bool bUsed)
Definition: numrule.hxx:248
RedlineType
virtual SwUnoCursor * GetCursor()=0
#define FN_UNO_TEXT_TABLE
Definition: cmdid.h:527
bool empty() const noexcept
#define FN_UNO_NUM_LEVEL
Definition: cmdid.h:522
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:478
constexpr TypedWhichId< SwFormatRefMark > RES_TXTATR_REFMARK(RES_TXTATR_WITHEND_BEGIN)
const FontList * GetFontList() const
static bool isInvalidStyle(std::u16string_view rName)
Definition: unosett.cxx:1012
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:120
static css::uno::Reference< css::text::XTextSection > GetObject(SwSectionFormat &rFormat)
Definition: unocoll.cxx:1523
SfxFilterContainer * GetFilterContainer() const
const SwFormatCharFormat & GetCharFormat() const
Definition: txatbase.hxx:183
static const OUString & PROP_INPUTSTREAM()
OUString SetNumRule(const SwPaM &, const SwNumRule &, bool bCreateNewList, SwRootFrame const *pLayout=nullptr, const OUString &sContinuedListId=OUString(), bool bSetItem=true, const bool bResetIndentAttrs=false)
Accept changes of outline styles for OutlineRule.
Definition: docnum.cxx:868
bool HasAttrListRestartValue() const
Definition: ndtxt.cxx:4135
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All)
void DeepCopyPaM(SwPaM const &rSource, SwPaM &rTarget)
Definition: unoobj2.cxx:78
#define FN_UNO_FOOTNOTE
Definition: cmdid.h:532
bool IsTextNode() const
Definition: node.hxx:637
OUString const & GetName() const
sal_Int16 IsNodeNumStart(SwPaM const &rPam, PropertyState &eState)
#define FN_UNO_PARA_NUM_STRING
Definition: cmdid.h:609
SwFrameFormat * GetFlyFormat() const
If node is in a fly return the respective format.
Definition: node.cxx:719
#define PROPERTY_MAP_TEXTPORTION_EXTENSIONS
Definition: unomap.hxx:59
#define FN_UNO_PARA_STYLE
Definition: cmdid.h:516
GetTextAttrMode
Definition: ndtxt.hxx:368
bool IsEmpty() const
Definition: swtable.cxx:1555
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1319
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:856
SwFrameFormat * GetFrameFormat() const
Definition: unotbl.hxx:146
sal_Int16 nValue
SwNumRule * GetOutlineNumRule() const
Definition: doc.hxx:1024
static const OUString & GetProgName(const OUString &rName, SwGetPoolIdFromName)
SW_DLLPUBLIC SwFrameFormat * GetFrameFormat()
Definition: unotbl.cxx:2014