[Libreoffice-commits] core.git: Branch 'private/mst/sw_redlinehide_2' - 7 commits - sw/inc sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Sep 13 18:51:49 UTC 2018
sw/inc/crsrsh.hxx | 11 -
sw/inc/ndtxt.hxx | 3
sw/source/core/crsr/crsrsh.cxx | 133 ++++++++++++++++++---
sw/source/core/doc/DocumentOutlineNodesManager.cxx | 4
sw/source/core/fields/chpfld.cxx | 2
sw/source/core/fields/reffld.cxx | 4
sw/source/core/text/txtfrm.cxx | 7 -
sw/source/core/tox/txmsrt.cxx | 2
sw/source/core/txtnode/ndtxt.cxx | 6
sw/source/ui/dbui/mmlayoutpage.cxx | 2
10 files changed, 129 insertions(+), 45 deletions(-)
New commits:
commit f7a851833bd93b76146ddd7f86f3704d9170ad9e
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Sep 13 20:42:03 2018 +0200
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Thu Sep 13 20:42:03 2018 +0200
sw_redlinehide_2: fix FrameContainsNode() to use pLastNode
Change-Id: Iaa67b9a0134971917c18c9d6f678f6d2913db666
diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx
index 56bbc10111f2..b61c1341d222 100644
--- a/sw/source/core/text/txtfrm.cxx
+++ b/sw/source/core/text/txtfrm.cxx
@@ -291,12 +291,7 @@ namespace sw {
if (sw::MergedPara const*const pMerged = rTextFrame.GetMergedPara())
{
sal_uLong const nFirst(pMerged->pFirstNode->GetIndex());
- sal_uLong nLast(nFirst);
- // FIXME is this actually the last one? what about delete RL that dels last node until end, what happens to its anchored objs?
- if (!pMerged->extents.empty())
- {
- nLast = pMerged->extents.back().pNode->GetIndex();
- }
+ sal_uLong const nLast(pMerged->pLastNode->GetIndex());
return (nFirst <= nNodeIndex && nNodeIndex <= nLast);
}
else
commit c952365081babc8e6bb1c599fe7eb8fe174110a7
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Sep 13 20:40:24 2018 +0200
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Thu Sep 13 20:41:24 2018 +0200
sw_redlinehide_2: view cursor: adapt SwCursorShell::GetSelText()
Pass in ExpandMode::HideDeletions to get the same effect (hopefully)
from the model code as from the merged text frame.
Change-Id: I546f51388bc7bd0d1740167062ef9171a37d1797
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 07e298842e25..b6d662b372db 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2394,6 +2394,40 @@ void SwCursorShell::CallChgLnk()
OUString SwCursorShell::GetSelText() const
{
OUString aText;
+ if (GetLayout()->IsHideRedlines())
+ {
+ SwContentFrame const*const pFrame(GetCurrFrame(false));
+ if (FrameContainsNode(*pFrame, m_pCurrentCursor->GetMark()->nNode.GetIndex()))
+ {
+ OUStringBuffer buf;
+ SwPosition const*const pStart(m_pCurrentCursor->Start());
+ SwPosition const*const pEnd(m_pCurrentCursor->End());
+ for (sal_uLong i = pStart->nNode.GetIndex(); i <= pEnd->nNode.GetIndex(); ++i)
+ {
+ SwNode const& rNode(*pStart->nNode.GetNodes()[i]);
+ assert(!rNode.IsEndNode());
+ if (rNode.IsStartNode())
+ {
+ i = rNode.EndOfSectionIndex();
+ }
+ else if (rNode.IsTextNode())
+ {
+ sal_Int32 const nStart(i == pStart->nNode.GetIndex()
+ ? pStart->nContent.GetIndex()
+ : 0);
+ sal_Int32 const nEnd(i == pEnd->nNode.GetIndex()
+ ? pEnd->nContent.GetIndex()
+ : pEnd->nNode.GetNode().GetTextNode()->Len());
+ buf.append(rNode.GetTextNode()->GetExpandText(
+ nStart, nEnd - nStart, false, false, false,
+ ExpandMode::HideDeletions));
+
+ }
+ }
+ aText = buf.makeStringAndClear();
+ }
+ }
+ else
if( m_pCurrentCursor->GetPoint()->nNode.GetIndex() ==
m_pCurrentCursor->GetMark()->nNode.GetIndex() )
{
commit 70a70276b9f471937e4a2b3b7b1784e7374ca1a5
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Sep 13 20:38:36 2018 +0200
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Thu Sep 13 20:38:36 2018 +0200
sw_redlinehide_2: remove one bool from SwTextNode::ExpandText()
... to make call sites both more readable and more flexible.
Change-Id: I28932290799cb3c354cdcaad8e426050bcfede50
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 2a5e48145cd8..0f2c5c6347ee 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -61,6 +61,7 @@ class SwWrongList;
class SwGrammarMarkUp;
struct SwDocStat;
struct SwParaIdleData_Impl;
+enum class ExpandMode;
namespace sw { namespace mark { enum class RestoreMode; } }
@@ -686,7 +687,7 @@ public:
const bool bWithNum = false,
const bool bAddSpaceAfterListLabelStr = false,
const bool bWithSpacesForLevel = false,
- const bool bWithFootnote = true ) const;
+ const ExpandMode eAdditionalMode = ExpandMode(0)) const;
bool GetExpandText( SwTextNode& rDestNd, const SwIndex* pDestIdx,
sal_Int32 nIdx, sal_Int32 nLen,
bool bWithNum = false, bool bWithFootnote = true,
diff --git a/sw/source/core/doc/DocumentOutlineNodesManager.cxx b/sw/source/core/doc/DocumentOutlineNodesManager.cxx
index c129887b7f68..db448ec4f609 100644
--- a/sw/source/core/doc/DocumentOutlineNodesManager.cxx
+++ b/sw/source/core/doc/DocumentOutlineNodesManager.cxx
@@ -19,6 +19,7 @@
#include <DocumentOutlineNodesManager.hxx>
#include <doc.hxx>
#include <ndtxt.hxx>
+#include <modeltoviewhelper.hxx>
namespace sw
{
@@ -45,7 +46,8 @@ OUString DocumentOutlineNodesManager::getOutlineText( const tSortedOutlineNodeLi
{
return m_rDoc.GetNodes().GetOutLineNds()[ nIdx ]->
GetTextNode()->GetExpandText( 0, -1, bWithNumber,
- bWithNumber, bWithSpacesForLevel, bWithFootnote );
+ bWithNumber, bWithSpacesForLevel,
+ bWithFootnote ? ExpandMode::ExpandFootnote : ExpandMode(0));
}
SwTextNode* DocumentOutlineNodesManager::getOutlineNode( const tSortedOutlineNodeList::size_type nIdx ) const
diff --git a/sw/source/core/fields/chpfld.cxx b/sw/source/core/fields/chpfld.cxx
index 68b2749cedc6..7093e940764a 100644
--- a/sw/source/core/fields/chpfld.cxx
+++ b/sw/source/core/fields/chpfld.cxx
@@ -187,7 +187,7 @@ void SwChapterField::ChangeExpansion(const SwTextNode &rTextNd, bool bSrchNum)
sNumber = "??";
}
- sTitle = removeControlChars(pTextNd->GetExpandText(0, -1, false, false, false, false));
+ sTitle = removeControlChars(pTextNd->GetExpandText(0, -1, false, false, false));
}
}
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index b7ad1cb81f33..e1ca14410486 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -396,7 +396,7 @@ OUString SwGetRefField::GetExpandedTextOfReferencedTextNode() const
{
const SwTextNode* pReferencedTextNode( GetReferencedTextNode() );
return pReferencedTextNode
- ? pReferencedTextNode->GetExpandText( 0, -1, true, true, false, false )
+ ? pReferencedTextNode->GetExpandText(0, -1, true, true, false)
: OUString();
}
@@ -538,7 +538,7 @@ void SwGetRefField::UpdateField( const SwTextField* pFieldTextAttr )
if( nStart != nEnd ) // a section?
{
- m_sText = pTextNd->GetExpandText( nStart, nEnd - nStart, false, false, false, false );
+ m_sText = pTextNd->GetExpandText(nStart, nEnd - nStart, false, false, false);
// remove all special characters (replace them with blanks)
if( !m_sText.isEmpty() )
diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx
index a5dbd956b0c5..801c7679d26d 100644
--- a/sw/source/core/tox/txmsrt.cxx
+++ b/sw/source/core/tox/txmsrt.cxx
@@ -502,7 +502,7 @@ TextAndReading SwTOXPara::GetText_Impl() const
return TextAndReading(static_cast<const SwTextNode*>(pNd)->GetExpandText(
nStartIndex,
nEndIndex == -1 ? -1 : nEndIndex - nStartIndex,
- false, false, false, false),
+ false, false, false),
OUString());
}
break;
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 7302a168c840..6414f900887b 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -3396,12 +3396,10 @@ OUString SwTextNode::GetExpandText( const sal_Int32 nIdx,
const bool bWithNum,
const bool bAddSpaceAfterListLabelStr,
const bool bWithSpacesForLevel,
- const bool bWithFootnote ) const
+ const ExpandMode eAdditionalMode) const
{
- ExpandMode eMode = ExpandMode::ExpandFields;
- if (bWithFootnote)
- eMode |= ExpandMode::ExpandFootnote;
+ ExpandMode eMode = ExpandMode::ExpandFields | eAdditionalMode;
ModelToViewHelper aConversionMap(*this, eMode);
const OUString aExpandText = aConversionMap.getViewText();
commit b5f2fd2dfa84b53fcb888791909e89519cb5f4cf
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Sep 13 20:30:06 2018 +0200
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Thu Sep 13 20:35:19 2018 +0200
sw_redlinehide_2: view cursor: IsSelOnePara(),IsStartPara(),IsEndPara()
Change-Id: Idb7bdc139e501dfbd7e7d3b2d4598d211fa11591
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 12337a2da62c..327674e3c547 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -502,7 +502,7 @@ public:
bool ShouldWait() const;
// Check if selection is within one paragraph.
- inline bool IsSelOnePara() const;
+ bool IsSelOnePara() const;
/*
* Returns SRectangle, at which the cursor is located.
@@ -870,12 +870,6 @@ inline bool SwCursorShell::IsMultiSelection() const
return m_pCurrentCursor->GetNext() != m_pCurrentCursor;
}
-inline bool SwCursorShell::IsSelOnePara() const
-{
- return !m_pCurrentCursor->IsMultiSelection() &&
- m_pCurrentCursor->GetPoint()->nNode == m_pCurrentCursor->GetMark()->nNode;
-}
-
inline const SwTableNode* SwCursorShell::IsCursorInTable() const
{
return m_pCurrentCursor->GetNode().FindTableNode();
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 25d7be2305fb..07e298842e25 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -1052,11 +1052,62 @@ int SwCursorShell::CompareCursorStackMkCurrPt() const
return nRet;
}
+bool SwCursorShell::IsSelOnePara() const
+{
+ if (m_pCurrentCursor->IsMultiSelection())
+ {
+ return false;
+ }
+ if (m_pCurrentCursor->GetPoint()->nNode == m_pCurrentCursor->GetMark()->nNode)
+ {
+ return true;
+ }
+ if (GetLayout()->IsHideRedlines())
+ {
+ SwContentFrame const*const pFrame(GetCurrFrame(false));
+ auto const n(m_pCurrentCursor->GetPoint()->nNode.GetIndex());
+ return FrameContainsNode(*pFrame, n);
+ }
+ return false;
+}
+
bool SwCursorShell::IsSttPara() const
-{ return m_pCurrentCursor->GetPoint()->nContent == 0; }
+{
+ if (GetLayout()->IsHideRedlines())
+ {
+ SwTextNode const*const pNode(m_pCurrentCursor->GetPoint()->nNode.GetNode().GetTextNode());
+ if (pNode)
+ {
+ SwTextFrame const*const pFrame(static_cast<SwTextFrame*>(
+ pNode->getLayoutFrame(GetLayout())));
+ if (pFrame)
+ {
+ return pFrame->MapModelToViewPos(*m_pCurrentCursor->GetPoint())
+ == TextFrameIndex(0);
+ }
+ }
+ }
+ return m_pCurrentCursor->GetPoint()->nContent == 0;
+}
bool SwCursorShell::IsEndPara() const
-{ return m_pCurrentCursor->GetPoint()->nContent == m_pCurrentCursor->GetContentNode()->Len(); }
+{
+ if (GetLayout()->IsHideRedlines())
+ {
+ SwTextNode const*const pNode(m_pCurrentCursor->GetPoint()->nNode.GetNode().GetTextNode());
+ if (pNode)
+ {
+ SwTextFrame const*const pFrame(static_cast<SwTextFrame*>(
+ pNode->getLayoutFrame(GetLayout())));
+ if (pFrame)
+ {
+ return pFrame->MapModelToViewPos(*m_pCurrentCursor->GetPoint())
+ == TextFrameIndex(pFrame->GetText().getLength());
+ }
+ }
+ }
+ return m_pCurrentCursor->GetPoint()->nContent == m_pCurrentCursor->GetContentNode()->Len();
+}
bool SwCursorShell::IsEndOfTable() const
{
commit 5763b6f1b2731589ec7b75d37abf24ee1210b4c9
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Sep 13 20:09:49 2018 +0200
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Thu Sep 13 20:09:49 2018 +0200
sw_redlinehide_2: remove GetTextUntilEndOfNode()
This is pretty silly, the only caller is actually interested in the
position of the cursor, not any text at all.
Change-Id: Ibf016d5526e18775c0e6e365b9823723267e76d5
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index ca221d5b6b35..12337a2da62c 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -566,9 +566,6 @@ public:
// get the selected text at the current cursor. it will be filled with
// fields etc.
OUString GetSelText() const;
- // return only the text starting from the current cursor position (to the
- // end of the node)
- OUString GetTextUntilEndOfNode() const;
// Check of SPoint or Mark of current cursor are placed within a table.
inline const SwTableNode* IsCursorInTable() const;
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 68e83859adab..25d7be2305fb 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2357,21 +2357,6 @@ OUString SwCursorShell::GetSelText() const
return aText;
}
-/// get text only from current cursor position (until end of node)
-OUString SwCursorShell::GetTextUntilEndOfNode() const
-{
- OUString aText;
- if( m_pCurrentCursor->GetPoint()->nNode.GetIndex() ==
- m_pCurrentCursor->GetMark()->nNode.GetIndex() )
- {
- SwTextNode* pTextNd = m_pCurrentCursor->GetNode().GetTextNode();
- if( pTextNd )
- aText = pTextNd->GetText().copy(
- m_pCurrentCursor->GetPoint()->nContent.GetIndex() );
- }
- return aText;
-}
-
/** get the nth character of the current SSelection
@param bEnd Start counting from the end? From start otherwise.
diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx
index 1a6e8ba28547..fecbff79b026 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -454,7 +454,7 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig
//we may end up inside of a paragraph if the left margin is not at DEFAULT_LEFT_DISTANCE
rShell.MovePara(GoCurrPara, fnParaStart);
}
- bool bSplitNode = !rShell.GetTextUntilEndOfNode().isEmpty();
+ bool bSplitNode = !rShell.IsEndPara();
sal_Int32 nMoves = rConfigItem.GetGreetingMoves();
if( !bExample && 0 != nMoves )
{
commit 64a4af77cd7643f74783e7b4d29be593852d3e9f
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Sep 13 19:21:46 2018 +0200
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Thu Sep 13 19:22:51 2018 +0200
sw_redlinehide_2: rename SwCursorShell::GetText()
It's really not obvious *what* you can get here.
Change-Id: I1f14b851a127847206f8eb5fd2da778d0acece9b
diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx
index 8b736656dec9..ca221d5b6b35 100644
--- a/sw/inc/crsrsh.hxx
+++ b/sw/inc/crsrsh.hxx
@@ -568,7 +568,7 @@ public:
OUString GetSelText() const;
// return only the text starting from the current cursor position (to the
// end of the node)
- OUString GetText() const;
+ OUString GetTextUntilEndOfNode() const;
// Check of SPoint or Mark of current cursor are placed within a table.
inline const SwTableNode* IsCursorInTable() const;
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 1cbcd78e7297..68e83859adab 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2358,7 +2358,7 @@ OUString SwCursorShell::GetSelText() const
}
/// get text only from current cursor position (until end of node)
-OUString SwCursorShell::GetText() const
+OUString SwCursorShell::GetTextUntilEndOfNode() const
{
OUString aText;
if( m_pCurrentCursor->GetPoint()->nNode.GetIndex() ==
diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx
index 23e6d7b845a2..1a6e8ba28547 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -454,7 +454,7 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig
//we may end up inside of a paragraph if the left margin is not at DEFAULT_LEFT_DISTANCE
rShell.MovePara(GoCurrPara, fnParaStart);
}
- bool bSplitNode = !rShell.GetText().isEmpty();
+ bool bSplitNode = !rShell.GetTextUntilEndOfNode().isEmpty();
sal_Int32 nMoves = rConfigItem.GetGreetingMoves();
if( !bExample && 0 != nMoves )
{
commit 07171a2ec706d22bfe0be0b64625e123375d5f7c
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Thu Sep 13 12:18:48 2018 +0200
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Thu Sep 13 12:18:48 2018 +0200
sw_redlinehide_2: view cursor movement, prev/next/start/end paragraph
This is used by Ctrl+Up/Down.
Just iterate movement in SwCursorShell::MovePara() until the point
is at the start (or end) of a frame.
Change-Id: I8abab57f1b549a3d585a385181cf734d73a0286a
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index f29462b9b268..1cbcd78e7297 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -651,6 +651,32 @@ bool SwCursorShell::isInHiddenTextFrame(SwShellCursor* pShellCursor)
return !pFrame || (pFrame->IsTextFrame() && static_cast<SwTextFrame*>(pFrame)->IsHiddenNow());
}
+// sw_redlinehide: this should work for all cases: GoCurrPara, GoNextPara, GoPrevPara
+static bool IsAtStartOrEndOfFrame(SwCursorShell const*const pShell,
+ SwShellCursor const*const pShellCursor, SwMoveFnCollection const& fnPosPara)
+{
+ SwContentNode *const pCNode = pShellCursor->GetContentNode();
+ assert(pCNode); // surely can't have moved otherwise?
+ SwContentFrame const*const pFrame = pCNode->getLayoutFrame(
+ pShell->GetLayout(), &pShellCursor->GetPtPos(),
+ pShellCursor->GetPoint(), false);
+ if (!pFrame || !pFrame->IsTextFrame())
+ {
+ return false;
+ }
+ SwTextFrame const& rTextFrame(static_cast<SwTextFrame const&>(*pFrame));
+ TextFrameIndex const ix(rTextFrame.MapModelToViewPos(*pShellCursor->GetPoint()));
+ if (&fnParaStart == &fnPosPara)
+ {
+ return ix == TextFrameIndex(0);
+ }
+ else
+ {
+ assert(&fnParaEnd == &fnPosPara);
+ return ix == TextFrameIndex(rTextFrame.GetText().getLength());
+ }
+}
+
bool SwCursorShell::MovePara(SwWhichPara fnWhichPara, SwMoveFnCollection const & fnPosPara )
{
SwCallLink aLk( *this ); // watch Cursor-Moves; call Link if needed
@@ -663,7 +689,8 @@ bool SwCursorShell::MovePara(SwWhichPara fnWhichPara, SwMoveFnCollection const &
//which is what SwCursorShell::UpdateCursorPos will reset
//the position to if we pass it a position in an
//invisible hidden paragraph field
- while (isInHiddenTextFrame(pTmpCursor))
+ while (isInHiddenTextFrame(pTmpCursor)
+ || !IsAtStartOrEndOfFrame(this, pTmpCursor, fnPosPara))
{
if (!pTmpCursor->MovePara(fnWhichPara, fnPosPara))
break;
More information about the Libreoffice-commits
mailing list