20#include <config_wasm_strip.h>
21#include <libxml/xmlwriter.h>
23#include <osl/diagnose.h>
90 OSL_FAIL(
"<lcl_IsInSameTableBox(..)> - no previous/next!" );
95 if ( aChkIdx < pTableNd->GetIndex() ||
119 for (
size_t n = 0;
n < rSortBoxes.
size(); ++
n)
122 if ( pNd->
GetIndex() < nIdx && nIdx < pNd->EndOfSectionIndex() )
155 std::tuple<SwTOXBase const*, sw::RedlineMode, sw::FieldmarkMode, sw::ParagraphBreakMode>
const*
const pTOXBaseAndMode,
156 SfxItemSet const*
const pAttr,
bool const bUpdate)
158 const SwNode* pPrvNd =
nullptr;
159 sal_uInt16 nRegionRet = 0;
163 if( 0 == nRegionRet )
167 SAL_INFO(
"sw.core" ,
"InsertSwSection: rRange overlaps other sections");
175 auto [pStt, pEnd] = rRange.
StartEnd();
176 if( !pStt->GetContentIndex() &&
177 pEnd->GetNode().GetContentNode()->Len() ==
178 pEnd->GetContentIndex() )
191 pUndoInsSect =
new SwUndoInsSection(rRange, rNewData, pAttr, pTOXBaseAndMode);
203 SwTOXBase const*
const pTOXBase(pTOXBaseAndMode ? std::get<0>(*pTOXBaseAndMode) :
nullptr);
211 auto [pSttPos, pEndPos] =
const_cast<SwPaM&
>(rRange).StartEnd();
212 if( pPrvNd && 3 == nRegionRet )
214 OSL_ENSURE( pPrvNd,
"The SectionNode is missing" );
215 SwNodeIndex aStt( pSttPos->GetNode() ), aEnd( pEndPos->GetNode(), +1 );
223 aStt.GetNode(), *pFormat, rNewData, pTOXBase, & aEnd.
GetNode());
229 if( !( pPrvNd && 1 == nRegionRet ) &&
230 pSttPos->GetContentIndex() )
240 if ( !( pPrvNd && 2 == nRegionRet ) )
244 if (pTNd && (pTNd->
GetText().getLength()
245 != pEndPos->GetContentIndex()))
252 if( pPrvNd && 1 == nRegionRet )
254 pSttPos->Assign( *pPrvNd );
256 else if( pSttPos->GetContentIndex() )
261 if( pPrvNd && 2 == nRegionRet )
263 pEndPos->Assign( *pPrvNd );
268 if( pCNd && pCNd->
Len() != pEndPos->GetContentIndex() )
270 sal_Int32 nContent = pSttPos->GetContentIndex();
274 if( pEndPos->GetNodeIndex() == pSttPos->GetNodeIndex() )
279 pSttPos->SetContent( nContent );
287 nContent = pTNd ? pTNd->
GetText().getLength() : 0;
288 pEndPos->SetContent( nContent );
292 pSttPos->GetNode(), *pFormat, rNewData, pTOXBase, &pEndPos->GetNode());
302 pPos->
GetNode(), *pFormat, rNewData, pTOXBase,
nullptr);
307 pPos->
GetNode(), *pFormat, rNewData, pTOXBase,
nullptr,
false);
317 pPos->
GetNode(), *pFormat, rNewData, pTOXBase,
nullptr);
352 bool bUpdateFootnote =
false;
361 bUpdateFootnote =
true;
377 if( bUpdateFootnote )
393 auto [pStt, pEnd] = rRange.
StartEnd();
396 const SwNode* pNd = &pStt->GetNode();
399 if( pSectNd && pEndSectNd && pSectNd != pEndSectNd )
404 if( !pStt->GetContentIndex()
405 && pSectNd->
GetIndex() == pStt->GetNodeIndex() - 1
406 && pEnd->GetContentIndex() == pCNd->
Len() )
422 aIdx = pEnd->GetNodeIndex() + 1;
423 nCmp = pStt->GetNodeIndex();
443 else if( !pSectNd && pEndSectNd )
448 if( pEnd->GetContentIndex() == pCNd->
Len() )
469 else if( pSectNd && !pEndSectNd )
474 if( !pStt->GetContentIndex() )
524 if( !pFootnoteEndAtTextEnd )
537 if( pFootnoteEndAtTextEnd )
551 if( pFootnoteEndAtTextEnd )
579 if( nSttNd && pFootnoteEndAtTextEnd )
586 for( ; nCnt--; ++nSttNd )
601 SfxItemSet const*
const pAttr,
bool const bPreventLinkUpdate )
612 bool bOnlyAttrChg =
false;
613 if( pAttr && pAttr->
Count() )
699 if( !sSectName.isEmpty() )
720 bool bCalculatedCondHidden =
722 if ( bCalculatedCondHidden && !bOldCondHidden )
743 if( rFootnoteArr.
empty() )
751 while(
nPos < rFootnoteArr.
size() &&
779 SwNode const*
const pEndNd,
780 bool const bInsAtStart,
bool const bCreateFrames)
787 "Section start and end in wrong order!");
806 ( pNd = &aInsPos.
GetNode())->IsEndNode() &&
826 if ( RedlineType::Delete != pRedline->
GetType() ||
849 if( aInsPos > pLastNode->
GetIndex() )
856 if( pStartNode->
GetIndex() > nMyIndex )
864 while( pStartNode->
GetIndex() > nMyIndex );
912 std::optional<SwNode2LayoutSaveUpperFrames> oNode2Layout;
917 oNode2Layout.emplace(*pSectNd);
931 else if(
n >= nSkipIdx )
940 SetDerivedFrom( pSectFormat );
964 oNode2Layout->RestoreUpperFrames( pSectNd->
GetNodes(), nIdx, nIdx + 1 );
965 oNode2Layout.reset();
1003 , m_pSection( pTOXBase
1010 rFormat.LockModify();
1012 rFormat.UnlockModify();
1025 pFormat->LockModify();
1027 pFormat->UnlockModify();
1064 while(
nullptr != (pFrame = aNode2Layout.
NextFrame()) )
1066 OSL_ENSURE( pFrame->
IsSctFrame(),
"Depend of Section not a Section." );
1091 bool bInitNewSect =
false;
1096 bInitNewSect =
true;
1098 while( pUp->
Lower() )
1109#if !ENABLE_WASM_STRIP_ACCESSIBILITY
1113 if ( pViewShell && pViewShell->
GetLayout() &&
1119 pNext ? pNext->DynCastTextFrame() :
nullptr,
1120 pPrev ? pPrev->DynCastTextFrame() :
nullptr );
1139#if !ENABLE_WASM_STRIP_ACCESSIBILITY
1143 if ( pViewShell && pViewShell->
GetLayout() &&
1149 pNext ? pNext->DynCastTextFrame() :
nullptr,
1150 pPrev ? pPrev->DynCastTextFrame() :
nullptr );
1164 OSL_ENSURE( pIdxBehind,
"no Index" );
1168 *pIdxBehind = *
this;
1227 std::unique_ptr<SwTOXBase> pTOXBase;
1233 pTOXBase.reset(
new SwTOXBase(rTBS, &rDoc) );
1253 const OUString sSectionName(
GetSection().GetSectionName());
1298 "That's simple: Hidden Section => Hidden Content" );
1301 while( aTmp < nEnd )
1323 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"section"));
1324 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
1325 (void)xmlTextWriterWriteAttribute(
1326 pWriter, BAD_CAST(
"type"),
1328 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"index"),
1329 BAD_CAST(OString::number(sal_Int32(
GetIndex())).getStr()));
1353 pFormat->LockModify();
1355 pFormat->UnlockModify();
1367 pSectNd = rNds[
n ]->GetSectionNode();
1368 if(
nullptr != pSectNd )
1378 OSL_ENSURE( pDoc == &
GetDoc(),
1379 "Moving to different Documents?" );
1403 OUString
newName =
"MailMergeSection"
1415 std::unique_ptr<sal_uInt8[]> pSetFlags(
new sal_uInt8[ nFlagSize ]);
1416 memset( pSetFlags.get(), 0, nFlagSize );
1421 if( pSectNd !=
nullptr )
1424 if (rNm.startsWith(
aName ))
1428 if( nNum-- && nNum < mpSectionFormatTable->
size() )
1429 pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 ));
1431 if( pChkStr && *pChkStr==rNm )
1442 auto nTmp = pSetFlags[
n ];
1459 return aName + OUString::number( ++nNum );
std::unique_ptr< SwUndo > MakeUndoUpdateSection(SwSectionFormat const &, bool const)
std::unique_ptr< SwUndo > MakeUndoDelSection(SwSectionFormat const &)
virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart)=0
Split a node at rPos (implemented only for TextNode).
virtual void DeleteSection(SwNode *pNode)=0
Delete section containing the node.
virtual void FieldsToCalc(SwCalc &rCalc, SwNodeOffset nLastNd, sal_Int32 nLastCnt)=0
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
virtual sfx2::LinkManager & GetLinkManager()=0
virtual bool SplitRedline(const SwPaM &rPam)=0
virtual void SetRedlineFlags_intern(RedlineFlags eMode)=0
Set a new redline mode.
virtual const SwRedlineTable & GetRedlineTable() const =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 void SetModified()=0
Must be called manually at changes of format.
const SfxPoolItem * GetCurItem() const
const SfxPoolItem * NextItem()
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
SwSbxValue Calculate(const OUString &rStr)
void MakeFramesForAdjacentContentNode(SwContentNode &rNode)
Method creates all views of document for given node.
SwFormatColl * GetFormatColl() const
bool HasSwAttrSet() const
virtual SwContentFrame * MakeFrame(SwFrame *pSib)=0
MakeFrame will be called for a certain layout pSib is another SwFrame of the same layout (e....
void DelFrames(SwRootFrame const *pLayout)
Method deletes all views of document for the node.
void ChkCondColl(const SwTextFormatColl *pColl=nullptr)
virtual sal_Int32 Len() const
const SwAttrSet * GetpSwAttrSet() const
bool IsCopyIsMove() const
static SwSection * GetCurrSection(const SwPosition &rPos)
IDocumentState const & getIDocumentState() const
static sal_uInt16 IsInsRegionAvailable(const SwPaM &rRange, const SwNode **ppSttNd=nullptr)
SwSection * InsertSwSection(SwPaM const &rRange, SwSectionData &, std::tuple< SwTOXBase const *, sw::RedlineMode, sw::FieldmarkMode, sw::ParagraphBreakMode > const *pTOXBase, SfxItemSet const *const pAttr, bool const bUpdate=true)
IDocumentLinksAdministration const & getIDocumentLinksAdministration() const
IDocumentContentOperations const & getIDocumentContentOperations() const
IDocumentUndoRedo & GetIDocumentUndoRedo()
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
SwFootnoteIdxs & GetFootnoteIdxs()
void DelSectionFormat(SwSectionFormat *pFormat, bool bDelNodes=false)
OUString GetUniqueSectionName(const OUString *pChkStr=nullptr) const
void UpdateSection(size_t const nSect, SwSectionData &, SfxItemSet const *const =nullptr, bool const bPreventLinkUpdate=false)
std::unique_ptr< SwSectionFormats > mpSectionFormatTable
std::unique_ptr< SwFrameFormat > mpDfltFrameFormat
const SwFrameFormat * GetDfltFrameFormat() const
bool IsInMailMerge() const
SwSectionFormat * MakeSectionFormat()
Ends a section of nodes in the document model.
Content, content of frame (header, footer, fly).
const SwNodeIndex * GetContentIdx() const
Base class of the Writer layout elements.
SwContentFrame * FindPrevCnt()
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr)=0
SwLayoutFrame * GetUpper()
SwRootFrame * getRootFrame()
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
bool IsLayoutFrame() const
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame.
const SwFrame * Lower() const
Marks a node in the document model.
const SwNodes & GetNodes() const
SwNodeOffset GetIndex() const
Base class of the Writer document model elements.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwSectionNode * GetSectionNode()
SwNodeOffset GetIndex() const
bool IsProtect() const
Is node in something that is protected (range, frame, table cells ... including anchor in case of fra...
SwStartNode * m_pStartOfSection
SwNodes & GetNodes()
Node is in which nodes-array/doc?
bool IsContentNode() const
SwNodeOffset StartOfSectionIndex() const
bool IsSectionNode() const
SwTableNode * FindTableNode()
Search table node, in which it is.
SwSectionNode * FindSectionNode()
Search section node, in which it is.
const SwStartNode * StartOfSectionNode() const
SwNodeOffset EndOfSectionIndex() const
bool IsCreateFrameWhenHidingRedlines() const
SwContentNode * GetContentNode()
SwNodeType GetNodeType() const
const SwEndNode * EndOfSectionNode() const
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc....
SwSectionNode * InsertTextSection(SwNode &rNd, SwSectionFormat &rSectionFormat, SwSectionData const &, SwTOXBase const *const pTOXBase, SwNode const *pEndNd, bool const bInsAtStart=true, bool const bCreateFrames=true)
Insert a new SwSection.
void Copy_(const SwNodeRange &rRg, SwNode &rInsPos, bool bNewFrames=true) const
SwContentNode * GoNextSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true) const
Go to next content-node that is not protected or hidden (Both set FALSE ==> GoNext/GoPrevious!...
SwDoc & GetDoc()
Which Doc contains the nodes-array?
SwNode * FindPrvNxtFrameNode(const SwNode &rFrameNd, const SwNode *pEnd, SwRootFrame const *pLayout=nullptr) const
Search previous / next content node or table node with frames.
static SwContentNode * GoPrevSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true)
SwNodeOffset Count() const
PaM is Point and Mark: a selection of the document model.
const SwPosition * GetMark() const
std::pair< const SwPosition *, const SwPosition * > StartEnd() const
Because sometimes the cost of the operator<= can add up.
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
const SwPosition * GetPoint() const
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
RedlineType GetType(sal_uInt16 nPos=0) const
vector_type::size_type size_type
The root element of a Writer document layout.
SwViewShell * GetCurrShell() const
bool HasMergedParas() const
bool IsAnyShellAccessible() const
void SetHidden(bool const bFlag)
SectionType GetType() const
const OUString & GetCondition() const
const OUString & GetLinkFileName() const
const OUString & GetSectionName() const
A section node represents the start of a section on the UI, i.e.
bool IsContentHidden() const
Check for not hidden areas whether there is content that is not in a hidden sub-area.
SwFrame * MakeFrame(SwFrame *)
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Dumps the node structure to the given destination (file nodes.xml in the current directory by default...
std::unique_ptr< SwSection > const m_pSection
void NodesArrChgd()
Set pointer in format of section on itself.
SwSectionNode(const SwSectionNode &)=delete
const SwSection & GetSection() const
void DelFrames(SwRootFrame const *pLayout=nullptr, bool bForce=false)
Method deletes all views of document for the node.
void MakeFramesForAdjacentContentNode(const SwNodeIndex &rIdx)
Method creates all views of document for the previous node.
virtual ~SwSectionNode() override
void MakeOwnFrames(SwNodeIndex *pIdxBehind, SwNodeIndex *pEnd=nullptr)
Creates the frms for the SectionNode (i.e.
SwSectionNode * MakeCopy(SwDoc &, const SwNodeIndex &) const
OUString const & GetCondition() const
void SetLinkFileName(OUString const &rNew)
OUString const & GetLinkFileName() const
bool IsProtectFlag() const
bool IsHiddenFlag() const
void SetSectionData(SwSectionData const &rData)
void SetCondHidden(bool const bFlag)
const OUString & GetSectionName() const
SwSectionFormat * GetFormat()
void SetEditInReadonly(bool const bFlag=true)
void SetType(SectionType const eType)
const SwServerObject * GetObject() const
const ::sfx2::SvBaseLink & GetBaseLink() const
void SetHidden(bool const bFlag=true)
bool IsCondHidden() const
void SetCondition(OUString const &rNew)
bool IsEditInReadonlyFlag() const
void SetRefObject(SwServerObject *pObj)
bool DataEquals(SwSectionData const &rCmp) const
void SetProtect(bool const bFlag=true)
void SetSectionName(OUString const &rName)
void CreateLink(LinkCreateType eType)
Starts a section of nodes in the document model.
void CheckSectionCondColl() const
Call ChkCondcoll to all ContentNodes of section.
friend class SwEndNode
to set the theEndOfSection !!
const SwTable & GetTable() const
void DelFrames(SwRootFrame const *pLayout=nullptr)
Method deletes all views of document for the node.
SwTableSortBoxes & GetTabSortBoxes()
SwTextNode is a paragraph in the document model.
virtual bool SetAttr(const SfxPoolItem &) override
overriding to handle change of certain paragraph attributes
const OUString & GetText() const
SwTextFormatColl * GetTextColl() const
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0) override
void SetUpdateFootnoteFlag(bool const bFlag)
void SetSectNdPos(SwNodeOffset const nPos)
void SaveSplitNode(SwTextNode *const pTextNd, bool const bAtStart)
std::vector< SwSectionFormat * >::size_type size_type
std::vector< SwSectionFormat * >::iterator iterator
SwRootFrame * GetLayout() const
void InvalidateAccessibleParaFlowRelation(const SwTextFrame *_pFromTextFrame, const SwTextFrame *_pToTextFrame)
invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs
bool InsertServer(SvLinkSource *rObj)
void RemoveServer(SvLinkSource *rObj)
void Remove(SvBaseLink const *pLink)
TOOLS_DLLPUBLIC OString DateTimeToOString(const DateTime &rDateTime)
struct _xmlTextWriter * xmlTextWriterPtr
virtual OUString GetName() const override
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
constexpr OUStringLiteral IsHidden(u"IsHidden")
static SwContentNode * GetContentNode(SwDoc &rDoc, SwPosition &rPos, bool bNext)
@ FTNEND_ATTXTEND_OWNNUMANDFMT
-""- and with own numberformat
@ FTNEND_ATTXTEND_OWNNUMSEQ
-""- and with own number sequence
#define SwTextFootnote_GetIndex(pFIdx)
constexpr TypedWhichId< SwFormatEndAtTextEnd > RES_END_AT_TXTEND(124)
constexpr TypedWhichId< SwFormatFootnoteAtTextEnd > RES_FTN_AT_TXTEND(123)
constexpr TypedWhichId< SwConditionTextFormatColl > RES_CONDTXTFMTCOLL(166)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(99)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(100)
constexpr TypedWhichId< SwFormatContent > RES_CNTNT(101)
#define SAL_INFO(area, stream)
OUString newName(std::u16string_view aNewPrefix, std::u16string_view aOldPrefix, std::u16string_view old_Name)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
const sal_Unicode cTokenSeparator
static SwSectionFormat & lcl_initParent(SwSectionNode &rThis, SwSectionFormat &rFormat)
static bool lcl_IsTOXSection(SwSectionData const &rSectionData)
static void lcl_CheckEmptyLayFrame(SwNodes const &rNds, SwSectionData &rSectionData, const SwNode &rStt, const SwNode &rEnd)
void sw_DeleteFootnote(SwSectionNode *pNd, SwNodeOffset nStt, SwNodeOffset nEnd)
static bool lcl_IsInSameTableBox(SwNodes const &_rNds, const SwNode &_rNd, const bool _bPrev)
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
constexpr SwNodeOffset NODE_OFFSET_MAX(SAL_MAX_INT32)
SwContentNode * GetNode(SwPaM &rPam, bool &rbFirst, SwMoveFnCollection const &fnMove, bool const bInReadOnly, SwRootFrame const *const i_pLayout)
This function returns the next node in direction of search.
bool CheckNodesRange(const SwNode &rStt, const SwNode &rEnd, bool bChkSection)
Check if the given range is inside one of the defined top-level sections.
SwMoveFnCollection const & fnMoveBackward
Marks a position in the document model.
sal_Int32 GetContentIndex() const
OUString SwResId(TranslateId aId)