21 #include <osl/diagnose.h>
37 #include <section.hxx>
54 #include <strings.hrc>
88 OSL_FAIL(
"<lcl_IsInSameTableBox(..)> - no previous/next!" );
93 if ( aChkIdx < pTableNd->GetIndex() ||
117 for (
size_t n = 0;
n < rSortBoxes.
size(); ++
n)
153 std::tuple<SwTOXBase const*, sw::RedlineMode, sw::FieldmarkMode>
const*
const pTOXBaseAndMode,
154 SfxItemSet const*
const pAttr,
bool const bUpdate)
156 const SwNode* pPrvNd =
nullptr;
157 sal_uInt16 nRegionRet = 0;
161 if( 0 == nRegionRet )
165 SAL_INFO(
"sw.core" ,
"InsertSwSection: rRange overlaps other sections");
175 pEnd->nNode.GetNode().GetContentNode()->Len() ==
176 pEnd->nContent.GetIndex() )
181 pEnd->nNode.GetNode() );
189 pUndoInsSect =
new SwUndoInsSection(rRange, rNewData, pAttr, pTOXBaseAndMode);
201 SwTOXBase const*
const pTOXBase(pTOXBaseAndMode ? std::get<0>(*pTOXBaseAndMode) :
nullptr);
210 *pEndPos = const_cast<SwPosition*>(rRange.
End());
211 if( pPrvNd && 3 == nRegionRet )
213 OSL_ENSURE( pPrvNd,
"The SectionNode is missing" );
222 aStt, *pFormat, rNewData, pTOXBase, & aEnd);
228 if( !( pPrvNd && 1 == nRegionRet ) &&
239 if ( !( pPrvNd && 2 == nRegionRet ) )
243 if (pTNd && (pTNd->
GetText().getLength()
244 != pEndPos->nContent.GetIndex()))
251 if( pPrvNd && 1 == nRegionRet )
261 if( pPrvNd && 2 == nRegionRet )
263 pEndPos->nNode.Assign( *pPrvNd );
264 pEndPos->nContent.Assign( pEndPos->nNode.GetNode().GetContentNode(), 0 );
269 if( pCNd && pCNd->
Len() != pEndPos->nContent.GetIndex() )
288 nContent = pTNd ? pTNd->
GetText().getLength() : 0;
289 pEndPos->nContent.Assign( pTNd, nContent );
293 pSttPos->
nNode, *pFormat, rNewData, pTOXBase, &pEndPos->nNode);
303 pPos->
nNode, *pFormat, rNewData, pTOXBase,
nullptr);
308 pPos->
nNode, *pFormat, rNewData, pTOXBase,
nullptr,
false);
314 pUndoInsSect->
SaveSplitNode( const_cast<SwTextNode*>(static_cast<const SwTextNode*>(pCNd)),
true );
318 pPos->
nNode, *pFormat, rNewData, pTOXBase,
nullptr);
355 bool bUpdateFootnote =
false;
364 bUpdateFootnote =
true;
380 if( bUpdateFootnote )
403 if( pSectNd && pEndSectNd && pSectNd != pEndSectNd )
416 while(
nullptr != ( pPrvNd = (pNd = &aIdx.
GetNode())->GetSectionNode() ) &&
447 else if( !pSectNd && pEndSectNd )
473 else if( pSectNd && !pEndSectNd )
531 pFootnoteEndAtTextEnd =
nullptr;
543 if( pFootnoteEndAtTextEnd )
557 if( pFootnoteEndAtTextEnd )
586 if( nSttNd && pFootnoteEndAtTextEnd )
594 for( ; nCnt--; ++nSttNd )
610 SfxItemSet const*
const pAttr,
bool const bPreventLinkUpdate )
621 bool bOnlyAttrChg =
false;
622 if( pAttr && pAttr->
Count() )
708 if( !sSectName.isEmpty() )
729 bool bCalculatedCondHidden =
731 if ( bCalculatedCondHidden && !bOldCondHidden )
752 if( rFootnoteArr.
empty() )
760 while( nPos < rFootnoteArr.
size() &&
789 bool const bInsAtStart,
bool const bCreateFrames)
795 OSL_ENSURE(!pEnd || rNdIdx <= *pEnd,
796 "Section start and end in wrong order!");
815 ( pNd = &aInsPos.
GetNode())->IsEndNode() &&
844 *pRedline->
GetMark() = *aRedlineEnd.GetPoint();
857 if( aInsPos > pLastNode->
GetIndex() )
864 if( pStartNode->
GetIndex() > nMyIndex )
872 while( pStartNode->
GetIndex() > nMyIndex );
938 if( ULONG_MAX == nSkipIdx )
940 else if(
n >= nSkipIdx )
941 nSkipIdx = ULONG_MAX;
949 SetDerivedFrom( pSectFormat );
956 static_cast<SwTableNode*>(pNd)->DelFrames();
958 if( ULONG_MAX == nSkipIdx )
963 static_cast<SwContentNode*>(pNd)->DelFrames(
nullptr);
1012 , m_pSection( pTOXBase
1073 while(
nullptr != (pFrame = aNode2Layout.NextFrame()) )
1075 OSL_ENSURE( pFrame->IsSctFrame(),
"Depend of Section not a Section." );
1076 if (pFrame->getRootFrame()->HasMergedParas()
1100 bool bInitNewSect =
false;
1105 bInitNewSect =
true;
1107 while( pUp->
Lower() )
1121 if ( pViewShell && pViewShell->GetLayout() &&
1122 pViewShell->GetLayout()->IsAnyShellAccessible() )
1125 dynamic_cast<SwTextFrame*>(pNew->
FindNextCnt(
true )),
1126 dynamic_cast<SwTextFrame*>(pNew->
FindPrevCnt()) );
1135 pNew->
Paste( pFrame->GetUpper(), pFrame );
1138 pNew->
Paste( pFrame->GetUpper(), pFrame->GetNext() );
1147 if ( pViewShell && pViewShell->GetLayout() &&
1148 pViewShell->GetLayout()->IsAnyShellAccessible() )
1151 dynamic_cast<SwTextFrame*>(pNew->
FindNextCnt(
true )),
1152 dynamic_cast<SwTextFrame*>(pNew->
FindPrevCnt()) );
1165 OSL_ENSURE( pIdxBehind,
"no Index" );
1169 *pIdxBehind = *
this;
1229 std::unique_ptr<SwTOXBase> pTOXBase;
1232 OSL_ENSURE( dynamic_cast< const SwTOXBaseSection* >( &
GetSection() ) !=
nullptr ,
"no TOXBaseSection!" );
1234 dynamic_cast<SwTOXBaseSection const&>(
GetSection()));
1235 pTOXBase.reset(
new SwTOXBase(rTBS, &rDoc) );
1255 const OUString sSectionName(
GetSection().GetSectionName());
1272 rNds.
Copy_( aRg, aInsPos,
false );
1299 "That's simple: Hidden Section => Hidden Content" );
1302 while( aTmp < nEnd )
1304 if( aTmp.GetNode().IsSectionNode() )
1309 aTmp = *aTmp.GetNode().EndOfSectionNode();
1313 if( aTmp.GetNode().IsContentNode() || aTmp.GetNode().IsTableNode() )
1315 OSL_ENSURE( aTmp.GetNode().IsEndNode(),
"EndNode expected" );
1350 pSectNd = rNds[
n ]->GetSectionNode();
1351 if(
nullptr != pSectNd )
1361 OSL_ENSURE( pDoc == &
GetDoc(),
1362 "Moving to different Documents?" );
1386 OUString
newName =
"MailMergeSection"
1390 newName += *pChkStr;
1398 std::unique_ptr<sal_uInt8[]> pSetFlags(
new sal_uInt8[ nFlagSize ]);
1399 memset( pSetFlags.get(), 0, nFlagSize );
1404 if( pSectNd !=
nullptr )
1407 if (rNm.startsWith( aName ))
1410 nNum = rNm.copy( aName.getLength() ).
toInt32();
1411 if( nNum-- && nNum < mpSectionFormatTable->
size() )
1412 pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 ));
1414 if( pChkStr && *pChkStr==rNm )
1422 nNum = mpSectionFormatTable->size();
1425 auto nTmp = pSetFlags[
n ];
1442 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
sal_uLong GetIndex() const
SwStartNode * m_pStartOfSection
Marks a position in the document model.
void SetType(SectionType const eType)
bool IsSectionNode() const
sal_uLong StartOfSectionIndex() const
void SetHidden(bool const bFlag)
const OUString & GetText() const
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.
virtual void FieldsToCalc(SwCalc &rCalc, sal_uLong nLastNd, sal_Int32 nLastCnt)=0
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
sal_Int32 toInt32(OUString const &rStr)
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
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)
const SwSection & GetSection() const
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 &)
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)
sal_uLong GetIndex() const
SwFrame * MakeFrame(SwFrame *)
virtual bool IsUndoNodes(SwNodes const &rNodes) const =0
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
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
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
void sw_DeleteFootnote(SwSectionNode *pNd, sal_uLong nStt, sal_uLong nEnd)
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)
void SetSectNdPos(sal_uLong const nPos)
const SwFrame * Lower() const
SwContentFrame * FindNextCnt(const bool _bInSameFootnote=false)
bool IsHiddenFlag() const
SwContentNode * GetContentNode()
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
OUString SwResId(const char *pId)
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)
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 InvalidateAccessibleParaFlowRelation(const SwTextFrame *_pFromTextFrame, const SwTextFrame *_pToTextFrame)
invalidate CONTENT_FLOWS_FROM/_TO relation for paragraphs
void SetRefObject(SwServerObject *pObj)
std::unique_ptr< SwSectionFormats > mpSectionFormatTable
void RestoreUpperFrames(SwNodes &rNds, sal_uLong nStt, sal_uLong nEnd)
SwSbxValue Calculate(const OUString &rStr)
bool IsLayoutFrame() const
sal_uLong EndOfSectionIndex() 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
SectionType GetType() const
SwMoveFnCollection const & fnMoveBackward
SwTableNode * FindTableNode()
Search table node, in which it is.
-""- and with own number sequence
virtual sfx2::LinkManager & GetLinkManager()=0
virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart)=0
Split a node at rPos (implemented only for TextNode).
static SwNodePtr GetEndNode(SwOutlineNodes const *pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type *nOutl)
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
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
SwNode * FindPrvNxtFrameNode(SwNodeIndex &rFrameIdx, const SwNode *pEnd) const
Search previous / next content node or table node with frames.
constexpr TypedWhichId< SwFormatFootnoteAtTextEnd > RES_FTN_AT_TXTEND(117)
SwRootFrame * getRootFrame()
const SfxPoolItem * GetCurItem() const
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
void SetCondition(OUString const &rNew)
bool IsCreateFrameWhenHidingRedlines() const
SwNodeIndex & Assign(SwNodes const &rNds, sal_uLong)
Base class of the Writer document model elements.
SwTextFormatColl * GetTextColl() const