20#include <config_wasm_strip.h>
21#include <libxml/xmlwriter.h>
23#include <osl/diagnose.h>
89 OSL_FAIL(
"<lcl_IsInSameTableBox(..)> - no previous/next!" );
93 if ( aChkIdx < pTableNd->GetIndex() ||
113 for (
size_t n = 0;
n < rSortBoxes.
size(); ++
n)
116 if ( pNd->
GetIndex() < nIdx && nIdx < pNd->EndOfSectionIndex() )
149 std::tuple<SwTOXBase const*, sw::RedlineMode, sw::FieldmarkMode, sw::ParagraphBreakMode>
const*
const pTOXBaseAndMode,
150 SfxItemSet const*
const pAttr,
bool const bUpdate)
152 const SwNode* pPrvNd =
nullptr;
153 sal_uInt16 nRegionRet = 0;
157 if( 0 == nRegionRet )
161 SAL_INFO(
"sw.core" ,
"InsertSwSection: rRange overlaps other sections");
169 auto [pStt, pEnd] = rRange.
StartEnd();
170 if( !pStt->GetContentIndex() &&
171 pEnd->GetNode().GetContentNode()->Len() ==
172 pEnd->GetContentIndex() )
185 pUndoInsSect =
new SwUndoInsSection(rRange, rNewData, pAttr, pTOXBaseAndMode);
197 SwTOXBase const*
const pTOXBase(pTOXBaseAndMode ? std::get<0>(*pTOXBaseAndMode) :
nullptr);
205 auto [pSttPos, pEndPos] =
const_cast<SwPaM&
>(rRange).StartEnd();
206 if( pPrvNd && 3 == nRegionRet )
208 OSL_ENSURE( pPrvNd,
"The SectionNode is missing" );
209 SwNodeIndex aStt( pSttPos->GetNode() ), aEnd( pEndPos->GetNode(), +1 );
217 aStt.GetNode(), *pFormat, rNewData, pTOXBase, & aEnd.
GetNode());
223 if( !( pPrvNd && 1 == nRegionRet ) &&
224 pSttPos->GetContentIndex() )
234 if ( !( pPrvNd && 2 == nRegionRet ) )
238 if (pTNd && (pTNd->
GetText().getLength()
239 != pEndPos->GetContentIndex()))
246 if( pPrvNd && 1 == nRegionRet )
248 pSttPos->Assign( *pPrvNd );
250 else if( pSttPos->GetContentIndex() )
255 if( pPrvNd && 2 == nRegionRet )
257 pEndPos->Assign( *pPrvNd );
262 if( pCNd && pCNd->
Len() != pEndPos->GetContentIndex() )
264 sal_Int32 nContent = pSttPos->GetContentIndex();
268 if( pEndPos->GetNodeIndex() == pSttPos->GetNodeIndex() )
273 pSttPos->SetContent( nContent );
281 nContent = pTNd ? pTNd->
GetText().getLength() : 0;
282 pEndPos->SetContent( nContent );
286 pSttPos->GetNode(), *pFormat, rNewData, pTOXBase, &pEndPos->GetNode());
296 pPos->
GetNode(), *pFormat, rNewData, pTOXBase,
nullptr);
301 pPos->
GetNode(), *pFormat, rNewData, pTOXBase,
nullptr,
false);
311 pPos->
GetNode(), *pFormat, rNewData, pTOXBase,
nullptr);
346 bool bUpdateFootnote =
false;
355 bUpdateFootnote =
true;
371 if( bUpdateFootnote )
387 auto [pStt, pEnd] = rRange.
StartEnd();
390 const SwNode* pNd = &pStt->GetNode();
393 if( pSectNd && pEndSectNd && pSectNd != pEndSectNd )
398 if( !pStt->GetContentIndex()
399 && pSectNd->
GetIndex() == pStt->GetNodeIndex() - 1
400 && pEnd->GetContentIndex() == pCNd->
Len() )
416 aIdx = pEnd->GetNodeIndex() + 1;
417 nCmp = pStt->GetNodeIndex();
437 else if( !pSectNd && pEndSectNd )
442 if( pEnd->GetContentIndex() == pCNd->
Len() )
463 else if( pSectNd && !pEndSectNd )
468 if( !pStt->GetContentIndex() )
518 if( !pFootnoteEndAtTextEnd )
531 if( pFootnoteEndAtTextEnd )
545 if( pFootnoteEndAtTextEnd )
573 if( nSttNd && pFootnoteEndAtTextEnd )
580 for( ; nCnt--; ++nSttNd )
595 SfxItemSet const*
const pAttr,
bool const bPreventLinkUpdate )
606 bool bOnlyAttrChg =
false;
607 if( pAttr && pAttr->
Count() )
693 if( !sSectName.isEmpty() )
714 bool bCalculatedCondHidden =
716 if ( bCalculatedCondHidden && !bOldCondHidden )
737 if( rFootnoteArr.
empty() )
745 while(
nPos < rFootnoteArr.
size() &&
773 SwNode const*
const pEndNd,
774 bool const bInsAtStart,
bool const bCreateFrames)
781 "Section start and end in wrong order!");
800 ( pNd = &aInsPos.
GetNode())->IsEndNode() &&
820 if ( RedlineType::Delete != pRedline->
GetType() ||
843 if( aInsPos > pLastNode->
GetIndex() )
850 if( pStartNode->
GetIndex() > nMyIndex )
858 while( pStartNode->
GetIndex() > nMyIndex );
906 std::optional<SwNode2LayoutSaveUpperFrames> oNode2Layout;
911 oNode2Layout.emplace(*pSectNd);
925 else if(
n >= nSkipIdx )
934 SetDerivedFrom( pSectFormat );
958 oNode2Layout->RestoreUpperFrames( pSectNd->
GetNodes(), nIdx, nIdx + 1 );
959 oNode2Layout.reset();
997 , m_pSection( pTOXBase
1004 rFormat.LockModify();
1006 rFormat.UnlockModify();
1019 pFormat->LockModify();
1021 pFormat->UnlockModify();
1058 while(
nullptr != (pFrame = aNode2Layout.
NextFrame()) )
1060 OSL_ENSURE( pFrame->
IsSctFrame(),
"Depend of Section not a Section." );
1085 bool bInitNewSect =
false;
1090 bInitNewSect =
true;
1092 while( pUp->
Lower() )
1103#if !ENABLE_WASM_STRIP_ACCESSIBILITY
1107 if ( pViewShell && pViewShell->
GetLayout() &&
1113 pNext ? pNext->DynCastTextFrame() :
nullptr,
1114 pPrev ? pPrev->DynCastTextFrame() :
nullptr );
1133#if !ENABLE_WASM_STRIP_ACCESSIBILITY
1137 if ( pViewShell && pViewShell->
GetLayout() &&
1143 pNext ? pNext->DynCastTextFrame() :
nullptr,
1144 pPrev ? pPrev->DynCastTextFrame() :
nullptr );
1158 OSL_ENSURE( pIdxBehind,
"no Index" );
1162 *pIdxBehind = *
this;
1221 std::unique_ptr<SwTOXBase> pTOXBase;
1227 pTOXBase.reset(
new SwTOXBase(rTBS, &rDoc) );
1247 const OUString sSectionName(
GetSection().GetSectionName());
1292 "That's simple: Hidden Section => Hidden Content" );
1295 while( aTmp < nEnd )
1317 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"section"));
1318 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
1319 (void)xmlTextWriterWriteAttribute(
1320 pWriter, BAD_CAST(
"type"),
1322 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"index"),
1323 BAD_CAST(OString::number(sal_Int32(
GetIndex())).getStr()));
1347 pFormat->LockModify();
1349 pFormat->UnlockModify();
1361 pSectNd = rNds[
n ]->GetSectionNode();
1362 if(
nullptr != pSectNd )
1372 OSL_ENSURE( pDoc == &
GetDoc(),
1373 "Moving to different Documents?" );
1397 OUString
newName =
"MailMergeSection"
1409 std::unique_ptr<sal_uInt8[]> pSetFlags(
new sal_uInt8[ nFlagSize ]);
1410 memset( pSetFlags.get(), 0, nFlagSize );
1415 if( pSectNd !=
nullptr )
1418 if (rNm.startsWith(
aName ))
1422 if( nNum-- && nNum < mpSectionFormatTable->
size() )
1423 pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 ));
1425 if( pChkStr && *pChkStr==rNm )
1436 auto nTmp = pSetFlags[
n ];
1453 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)