diff options
-rw-r--r-- | sw/inc/ndarr.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/docnode/ndnum.cxx | 12 | ||||
-rw-r--r-- | sw/source/uibase/app/docst.cxx | 13 |
3 files changed, 19 insertions, 8 deletions
diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx index 5c423e11378c..fdf0eec7849b 100644 --- a/sw/inc/ndarr.hxx +++ b/sw/inc/ndarr.hxx @@ -81,7 +81,7 @@ public: static constexpr auto npos = std::numeric_limits<size_type>::max(); bool Seek_Entry(const SwNode* rP, size_type* pnPos) const; - static const SwNode* GetRootNode(const SwNode* pNode); + static const SwNode* GetRootNode(const SwNode* pNode, bool bCheckInlineHeading = true); }; struct CompareSwOutlineNodesInline diff --git a/sw/source/core/docnode/ndnum.cxx b/sw/source/core/docnode/ndnum.cxx index 89e8cc186311..095bfaa60b56 100644 --- a/sw/source/core/docnode/ndnum.cxx +++ b/sw/source/core/docnode/ndnum.cxx @@ -27,18 +27,20 @@ #include <fmtanchr.hxx> #include <poolfmt.hxx> -static const SwNode* getNodeOrAnchorNode(const SwNode* pNode) +static const SwNode* getNodeOrAnchorNode(const SwNode* pNode, bool bCheckInlineHeading = true) { // if pNode is an inline heading in an Inline Heading // text frame, return its anchor node instead of pNode + // if bCheckInlineHeading == false, it's enough to be in an + // arbitrary text frame to return its anchor node if (const auto pFlyFormat = pNode->GetFlyFormat()) { SwFormatAnchor const*const pAnchor = &pFlyFormat->GetAnchor(); SwNode const*const pAnchorNode = pAnchor->GetAnchorNode(); const SwFormat* pParent = pFlyFormat->DerivedFrom(); - if ( pAnchorNode && pParent && + if ( pAnchorNode && pParent && ( !bCheckInlineHeading || ( RndStdIds::FLY_AS_CHAR == pAnchor->GetAnchorId() && - pParent->GetPoolFormatId() == RES_POOLFRM_INLINE_HEADING ) + pParent->GetPoolFormatId() == RES_POOLFRM_INLINE_HEADING ) ) ) { return pAnchorNode; } @@ -58,9 +60,9 @@ bool SwOutlineNodes::Seek_Entry(const SwNode* rP, size_type* pnPos) const return it != end() && rP->GetIndex() == (*it)->GetIndex(); } -const SwNode* SwOutlineNodes::GetRootNode(const SwNode* pNode) +const SwNode* SwOutlineNodes::GetRootNode(const SwNode* pNode, bool bCheckInlineHeading) { - return getNodeOrAnchorNode(pNode); + return getNodeOrAnchorNode(pNode, bCheckInlineHeading); } bool CompareSwOutlineNodesInline::operator()(const SwNode* lhs, const SwNode* rhs) const diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx index ecdb14726e37..c9b9a74d730c 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -1174,7 +1174,7 @@ void SwDocShell::Hide(const OUString &rName, SfxStyleFamily nFamily, bool bHidde } } -#define MAX_CHAR_IN_INLINE_HEADING 75 +#define MAX_CHAR_IN_INLINE_HEADING 120 bool SwDocShell::MakeInlineHeading(SwWrtShell *pSh, SwTextFormatColl* pColl, const sal_uInt16 nMode) { // insert an inline heading frame, if only MAX_CHAR_IN_INLINE_HEADING or less @@ -1185,6 +1185,15 @@ bool SwDocShell::MakeInlineHeading(SwWrtShell *pSh, SwTextFormatColl* pColl, con 0 < GetView()->GetSelectionText().getLength() ) { SwTextFormatColl *pLocal = pColl? pColl: (*GetDoc()->GetTextFormatColls())[0]; + // don't put inline heading in a frame (it would be enough to limit for inline heading + // frames, but the recent FN_INSERT_FRAME cannot handle the insertion inside a frame + // correctly) + // TODO: allow to insert inline headings in a (not an Inline Heading) text frame + if ( pSh->GetCursor()->GetPointNode() != + *SwOutlineNodes::GetRootNode( &pSh->GetCursor()->GetPointNode(), /*bInlineHeading=*/false ) ) + { + return false; + } // put inside a single Undo SwRewriter aRewriter; @@ -1271,7 +1280,7 @@ SfxStyleFamily SwDocShell::ApplyStyles(const OUString &rName, SfxStyleFamily nFa // outline node's content is folded. MakeAllOutlineContentTemporarilyVisible a(GetDoc()); - // if the first 75 or less characters are selected, but not the full paragraph, + // if the first 120 or less characters are selected, but not the full paragraph, // create an inline heading from the selected text SwTextFormatColl* pColl = pStyle->GetCollection(); if ( MakeInlineHeading( pSh, pColl, nMode ) ) |