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