20 #include <config_wasm_strip.h>
22 #include <libxml/xmlwriter.h>
25 #include <osl/diagnose.h>
41 #include <section.hxx>
58 #include <strings.hrc>
92 OSL_FAIL(
"<lcl_IsInSameTableBox(..)> - no previous/next!" );
97 if ( aChkIdx < pTableNd->GetIndex() ||
121 for (
size_t n = 0;
n < rSortBoxes.
size(); ++
n)
157 std::tuple<SwTOXBase const*, sw::RedlineMode, sw::FieldmarkMode>
const*
const pTOXBaseAndMode,
158 SfxItemSet const*
const pAttr,
bool const bUpdate)
160 const SwNode* pPrvNd =
nullptr;
161 sal_uInt16 nRegionRet = 0;
165 if( 0 == nRegionRet )
169 SAL_INFO(
"sw.core" ,
"InsertSwSection: rRange overlaps other sections");
179 pEnd->nNode.GetNode().GetContentNode()->Len() ==
180 pEnd->nContent.GetIndex() )
185 pEnd->nNode.GetNode() );
193 pUndoInsSect =
new SwUndoInsSection(rRange, rNewData, pAttr, pTOXBaseAndMode);
205 SwTOXBase const*
const pTOXBase(pTOXBaseAndMode ? std::get<0>(*pTOXBaseAndMode) :
nullptr);
214 *pEndPos = const_cast<SwPosition*>(rRange.
End());
215 if( pPrvNd && 3 == nRegionRet )
217 OSL_ENSURE( pPrvNd,
"The SectionNode is missing" );
226 aStt, *pFormat, rNewData, pTOXBase, & aEnd);
232 if( !( pPrvNd && 1 == nRegionRet ) &&
243 if ( !( pPrvNd && 2 == nRegionRet ) )
247 if (pTNd && (pTNd->
GetText().getLength()
248 != pEndPos->nContent.GetIndex()))
255 if( pPrvNd && 1 == nRegionRet )
265 if( pPrvNd && 2 == nRegionRet )
267 pEndPos->nNode.Assign( *pPrvNd );
268 pEndPos->nContent.Assign( pEndPos->nNode.GetNode().GetContentNode(), 0 );
273 if( pCNd && pCNd->
Len() != pEndPos->nContent.GetIndex() )
292 nContent = pTNd ? pTNd->
GetText().getLength() : 0;
293 pEndPos->nContent.Assign( pTNd, nContent );
297 pSttPos->
nNode, *pFormat, rNewData, pTOXBase, &pEndPos->nNode);
307 pPos->
nNode, *pFormat, rNewData, pTOXBase,
nullptr);
312 pPos->
nNode, *pFormat, rNewData, pTOXBase,
nullptr,
false);
318 pUndoInsSect->
SaveSplitNode( const_cast<SwTextNode*>(static_cast<const SwTextNode*>(pCNd)),
true );
322 pPos->
nNode, *pFormat, rNewData, pTOXBase,
nullptr);
359 bool bUpdateFootnote =
false;
368 bUpdateFootnote =
true;
384 if( bUpdateFootnote )
407 if( pSectNd && pEndSectNd && pSectNd != pEndSectNd )
420 while(
nullptr != ( pPrvNd = (pNd = &aIdx.
GetNode())->GetSectionNode() ) &&
451 else if( !pSectNd && pEndSectNd )
477 else if( pSectNd && !pEndSectNd )
532 if( !pFootnoteEndAtTextEnd )
545 if( pFootnoteEndAtTextEnd )
559 if( pFootnoteEndAtTextEnd )
588 if( nSttNd && pFootnoteEndAtTextEnd )
596 for( ; nCnt--; ++nSttNd )
612 SfxItemSet const*
const pAttr,
bool const bPreventLinkUpdate )
623 bool bOnlyAttrChg =
false;
624 if( pAttr && pAttr->
Count() )
710 if( !sSectName.isEmpty() )
731 bool bCalculatedCondHidden =
733 if ( bCalculatedCondHidden && !bOldCondHidden )
754 if( rFootnoteArr.
empty() )
762 while( nPos < rFootnoteArr.
size() &&
791 bool const bInsAtStart,
bool const bCreateFrames)
797 OSL_ENSURE(!pEnd || rNdIdx <= *pEnd,
798 "Section start and end in wrong order!");
817 ( pNd = &aInsPos.
GetNode())->IsEndNode() &&
846 *pRedline->
GetMark() = *aRedlineEnd.GetPoint();
859 if( aInsPos > pLastNode->
GetIndex() )
866 if( pStartNode->
GetIndex() > nMyIndex )
874 while( pStartNode->
GetIndex() > nMyIndex );
942 else if(
n >= nSkipIdx )
951 SetDerivedFrom( pSectFormat );
958 static_cast<SwTableNode*>(pNd)->DelFrames();
965 static_cast<SwContentNode*>(pNd)->DelFrames(
nullptr);
1014 , m_pSection( pTOXBase
1075 while(
nullptr != (pFrame = aNode2Layout.NextFrame()) )
1077 OSL_ENSURE( pFrame->IsSctFrame(),
"Depend of Section not a Section." );
1078 if (pFrame->getRootFrame()->HasMergedParas()
1102 bool bInitNewSect =
false;
1107 bInitNewSect =
true;
1109 while( pUp->
Lower() )
1120 #if !ENABLE_WASM_STRIP_ACCESSIBILITY
1124 if ( pViewShell && pViewShell->GetLayout() &&
1125 pViewShell->GetLayout()->IsAnyShellAccessible() )
1129 pViewShell->InvalidateAccessibleParaFlowRelation(
1130 pNext ? pNext->DynCastTextFrame() :
nullptr,
1131 pPrev ? pPrev->DynCastTextFrame() : nullptr );
1141 pNew->
Paste( pFrame->GetUpper(), pFrame );
1144 pNew->
Paste( pFrame->GetUpper(), pFrame->GetNext() );
1150 #if !ENABLE_WASM_STRIP_ACCESSIBILITY
1154 if ( pViewShell && pViewShell->GetLayout() &&
1155 pViewShell->GetLayout()->IsAnyShellAccessible() )
1159 pViewShell->InvalidateAccessibleParaFlowRelation(
1160 pNext ? pNext->DynCastTextFrame() :
nullptr,
1161 pPrev ? pPrev->DynCastTextFrame() : nullptr );
1175 OSL_ENSURE( pIdxBehind,
"no Index" );
1179 *pIdxBehind = *
this;
1239 std::unique_ptr<SwTOXBase> pTOXBase;
1242 assert( dynamic_cast< const SwTOXBaseSection* >( &
GetSection() ) &&
"no TOXBaseSection!" );
1244 dynamic_cast<SwTOXBaseSection const&>(
GetSection()));
1245 pTOXBase.reset(
new SwTOXBase(rTBS, &rDoc) );
1265 const OUString sSectionName(
GetSection().GetSectionName());
1282 rNds.
Copy_( aRg, aInsPos,
false );
1309 "That's simple: Hidden Section => Hidden Content" );
1312 while( aTmp < nEnd )
1314 if( aTmp.GetNode().IsSectionNode() )
1319 aTmp = *aTmp.GetNode().EndOfSectionNode();
1323 if( aTmp.GetNode().IsContentNode() || aTmp.GetNode().IsTableNode() )
1325 OSL_ENSURE( aTmp.GetNode().IsEndNode(),
"EndNode expected" );
1334 (
void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"section"));
1335 (
void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
1336 (
void)xmlTextWriterWriteAttribute(
1337 pWriter, BAD_CAST(
"type"),
1338 BAD_CAST(OString::number(static_cast<sal_uInt8>(
GetNodeType())).getStr()));
1339 (
void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"index"),
1340 BAD_CAST(OString::number(sal_Int32(
GetIndex())).getStr()));
1378 pSectNd = rNds[
n ]->GetSectionNode();
1379 if(
nullptr != pSectNd )
1389 OSL_ENSURE( pDoc == &
GetDoc(),
1390 "Moving to different Documents?" );
1414 OUString
newName =
"MailMergeSection"
1418 newName += *pChkStr;
1426 std::unique_ptr<sal_uInt8[]> pSetFlags(
new sal_uInt8[ nFlagSize ]);
1427 memset( pSetFlags.get(), 0, nFlagSize );
1432 if( pSectNd !=
nullptr )
1435 if (rNm.startsWith( aName ))
1439 if( nNum-- && nNum < mpSectionFormatTable->
size() )
1440 pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 ));
1442 if( pChkStr && *pChkStr==rNm )
1450 nNum = mpSectionFormatTable->size();
1453 auto nTmp = pSetFlags[
n ];
1470 return aName + OUString::number( ++nNum );
SwSectionNode * FindSectionNode()
Search section node, in which it is.
const SwEndNode * EndOfSectionNode() const
Starts a section of nodes in the document model.
Base class of the Writer layout elements.
virtual sal_Int32 Len() const
constexpr TypedWhichId< SwFormatEndAtTextEnd > RES_END_AT_TXTEND(118)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
bool IsInMailMerge() const
SwStartNode * m_pStartOfSection
SwNodeOffset EndOfSectionIndex() const
Marks a position in the document model.
void SetType(SectionType const eType)
bool IsSectionNode() const
virtual void FieldsToCalc(SwCalc &rCalc, SwNodeOffset nLastNd, sal_Int32 nLastCnt)=0
void SetHidden(bool const bFlag)
const OUString & GetText() const
constexpr SwNodeOffset NODE_OFFSET_MAX(SAL_MAX_INT32)
static SwSectionFormat & lcl_initParent(SwSectionNode &rThis, SwSectionFormat &rFormat)
virtual bool SetAttr(const SfxPoolItem &) override
overriding to handle change of certain paragraph attributes
static SwContentNode * GetContentNode(SwDoc &rDoc, SwNodeIndex &rIdx, bool bNext)
virtual AppendResult AppendRedline(SwRangeRedline *pNewRedl, bool bCallDelete)=0
Append a new redline.
void DelSectionFormat(SwSectionFormat *pFormat, bool bDelNodes=false)
virtual void SetRedlineFlags_intern(RedlineFlags eMode)=0
Set a new redline mode.
SwNodeOffset StartOfSectionIndex() const
SwDoc & GetDoc()
Which Doc contains the nodes-array?
const OUString & GetCondition() const
static bool lcl_IsTOXSection(SwSectionData const &rSectionData)
void SetSectionName(OUString const &rName)
virtual void SetModified()=0
Must be called manually at changes of format.
-""- and with own numberformat
void CreateLink(LinkCreateType eType)
bool IsEditInReadonlyFlag() const
const SwPosition * GetMark() const
const sal_Unicode cTokenSeparator
bool IsContentHidden() const
Check for not hidden areas whether there is content that is not in a hidden sub-area.
virtual SwContentFrame * MakeFrame(SwFrame *pSib)=0
MakeFrame will be called for a certain layout pSib is another SwFrame of the same layout (e...
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
static SwContentNode * GoPrevSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true)
void SetEditInReadonly(bool const bFlag=true)
OUString GetUniqueSectionName(const OUString *pChkStr=nullptr) const
IDocumentLinksAdministration const & getIDocumentLinksAdministration() const
const SwServerObject * GetObject() const
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
OUString newName(std::u16string_view aNewPrefix, const OUString &aOldPrefix, std::u16string_view old_Name)
void NodesArrChgd()
Set pointer in format of section on itself.
bool InsertServer(SvLinkSource *rObj)
Content, content of frame (header, footer, fly).
SwSectionFormat * GetFormat()
constexpr TypedWhichId< SwConditionTextFormatColl > RES_CONDTXTFMTCOLL(160)
IDocumentUndoRedo & GetIDocumentUndoRedo()
void CheckSectionCondColl() const
Call ChkCondcoll to all ContentNodes of section.
OUString const & GetLinkFileName() const
IDocumentContentOperations const & getIDocumentContentOperations() const
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Dumps the node structure to the given destination (file nodes.xml in the current directory by default...
The root element of a Writer document layout.
void Copy_(const SwNodeRange &rRg, const SwNodeIndex &rInsPos, bool bNewFrames=true) const
static SwSection * GetCurrSection(const SwPosition &rPos)
bool IsCondHidden() const
OUString const & GetCondition() const
void SaveSplitNode(SwTextNode *const pTextNd, bool const bAtStart)
void SetSectNdPos(SwNodeOffset const nPos)
const SwSection & GetSection() const
OUString SwResId(TranslateId aId)
void MakeFramesForAdjacentContentNode(SwContentNode &rNode)
Method creates all views of document for given node.
SwSectionNode * MakeCopy(SwDoc &, const SwNodeIndex &) const
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
const SfxPoolItem * NextItem()
const ::sfx2::SvBaseLink & GetBaseLink() const
std::unique_ptr< SwUndo > MakeUndoDelSection(SwSectionFormat const &)
SwNodeType GetNodeType() const
void MakeOwnFrames(SwNodeIndex *pIdxBehind, SwNodeIndex *pEnd=nullptr)
Creates the frms for the SectionNode (i.e.
static bool IsRedlineOn(const RedlineFlags eM)
void RemoveServer(SvLinkSource *rObj)
SwFrame * MakeFrame(SwFrame *)
virtual bool IsUndoNodes(SwNodes const &rNodes) const =0
SwNode * FindPrvNxtFrameNode(SwNodeIndex &rFrameIdx, const SwNode *pEnd, SwRootFrame const *pLayout=nullptr) const
Search previous / next content node or table node with frames.
virtual void DoUndo(bool const bDoUndo)=0
Enable/Disable Undo.
bool CheckNodesRange(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, bool bChkSection)
Check if the given range is inside one of the defined top-level sections.
const SwTable & GetTable() const
virtual void DeleteSection(SwNode *pNode)=0
Delete section containing the node.
bool IsProtectFlag() const
SwNodeOffset GetIndex() const
virtual OUString GetName() const override
const OUString & GetSectionName() const
void ChkCondColl(const SwTextFormatColl *pColl=nullptr)
SwSectionFormat * MakeSectionFormat()
virtual bool DoesUndo() const =0
Is Undo enabled?
virtual void Paste(SwFrame *pParent, SwFrame *pSibling=nullptr)=0
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
SwTableSortBoxes & GetTabSortBoxes()
bool IsContentNode() const
PaM is Point and Mark: a selection of the document model.
const SwAttrSet * GetpSwAttrSet() const
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
virtual void AppendUndo(std::unique_ptr< SwUndo > pUndo)=0
Add new Undo action.
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
virtual ~SwSectionNode() override
SwNodeIndex & Assign(SwNodes const &rNds, SwNodeOffset)
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SwStartNode * StartOfSectionNode() const
const OUString & GetSectionName() const
const SwPosition * GetPoint() const
std::vector< SwSectionFormat * >::size_type size_type
void SetCondHidden(bool const bFlag)
void Remove(SvBaseLink const *pLink)
SwIndex & Assign(SwIndexReg *, sal_Int32)
void SetProtect(bool const bFlag=true)
const SwFrame * Lower() const
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
bool IsHiddenFlag() const
SwContentNode * GetContentNode()
SwNodeOffset GetIndex() const
vector_type::size_type size_type
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
IDocumentState const & getIDocumentState() const
void SetHidden(bool const bFlag=true)
std::vector< SwSectionFormat * >::iterator iterator
Marks a node in the document model.
SwNodes & GetNodes()
Node is in which nodes-array/doc?
#define SwTextFootnote_GetIndex(pFIdx)
bool HasSwAttrSet() const
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
bool IsEditInReadonly() const
SwSectionNode * InsertTextSection(SwNodeIndex const &rNdIdx, SwSectionFormat &rSectionFormat, SwSectionData const &, SwTOXBase const *const pTOXBase, SwNodeIndex const *const pEnd, bool const bInsAtStart=true, bool const bCreateFrames=true)
Insert a new SwSection.
std::unique_ptr< SwSection > const m_pSection
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
void SetLinkFileName(OUString const &rNew)
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
const SwPosition * Start() const
constexpr TypedWhichId< SwFormatContent > RES_CNTNT(95)
const SwNodeIndex * GetContentIdx() const
const SwFrameFormat * GetDfltFrameFormat() const
static bool lcl_IsInSameTableBox(SwNodes const &_rNds, const SwNode &_rNd, const bool _bPrev)
void SetRefObject(SwServerObject *pObj)
std::unique_ptr< SwSectionFormats > mpSectionFormatTable
SwSbxValue Calculate(const OUString &rStr)
bool IsLayoutFrame() const
SwTextNode is a paragraph in the document model.
virtual bool SplitRedline(const SwPaM &rPam)=0
const OUString & GetLinkFileName() const
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
void SetUpdateFootnoteFlag(bool const bFlag)
void UpdateSection(size_t const nSect, SwSectionData &, SfxItemSet const *const =nullptr, bool const bPreventLinkUpdate=false)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
const SwNodes & GetNodes() const
bool IsCopyIsMove() const
#define SAL_INFO(area, stream)
sal_Int32 GetIndex() const
OString DateTimeToOString(const DateTime &rDateTime)
bool DataEquals(SwSectionData const &rCmp) const
friend class SwEndNode
to set the theEndOfSection !!
static sal_uInt16 IsInsRegionAvailable(const SwPaM &rRange, const SwNode **ppSttNd=nullptr)
const SwPosition * End() const
void DelFrames(SwRootFrame const *pLayout=nullptr, bool bForce=false)
Method deletes all views of document for the node.
SwSectionNode(const SwSectionNode &)=delete
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
SectionType GetType() const
SwMoveFnCollection const & fnMoveBackward
SwTableNode * FindTableNode()
Search table node, in which it is.
-""- and with own number sequence
SwNodeOffset Count() const
virtual sfx2::LinkManager & GetLinkManager()=0
virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart)=0
Split a node at rPos (implemented only for TextNode).
static SwNode * GetEndNode(SwOutlineNodes const *pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type *nOutl)
void sw_DeleteFootnote(SwSectionNode *pNd, SwNodeOffset nStt, SwNodeOffset nEnd)
std::unique_ptr< SwUndo > MakeUndoUpdateSection(SwSectionFormat const &, bool const)
SwFootnoteIdxs & GetFootnoteIdxs()
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
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!!!).
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc...
std::unique_ptr< SwFrameFormat > mpDfltFrameFormat
struct _xmlTextWriter * xmlTextWriterPtr
SwFormatColl * GetFormatColl() const
SwContentFrame * FindPrevCnt()
void SetSectionData(SwSectionData const &rData)
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
SwSectionNode * GetSectionNode()
Ends a section of nodes in the document model.
virtual const SwRedlineTable & GetRedlineTable() const =0
void MakeFramesForAdjacentContentNode(const SwNodeIndex &rIdx)
Method creates all views of document for the previous node.
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0) override
static void lcl_CheckEmptyLayFrame(SwNodes const &rNds, SwSectionData &rSectionData, const SwNode &rStt, const SwNode &rEnd)
SwSection * InsertSwSection(SwPaM const &rRange, SwSectionData &, std::tuple< SwTOXBase const *, sw::RedlineMode, sw::FieldmarkMode > const *pTOXBase, SfxItemSet const *const pAttr, bool const bUpdate=true)
SwViewShell * GetCurrShell() const
constexpr TypedWhichId< SwFormatFootnoteAtTextEnd > RES_FTN_AT_TXTEND(117)
SwRootFrame * getRootFrame()
void RestoreUpperFrames(SwNodes &rNds, SwNodeOffset nStt, SwNodeOffset nEnd)
const SfxPoolItem * GetCurItem() const
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
void SetCondition(OUString const &rNew)
bool IsCreateFrameWhenHidingRedlines() const
Base class of the Writer document model elements.
SwTextFormatColl * GetTextColl() const