summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-03-01 12:25:48 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-03-01 21:24:13 +0100
commit4f35958c64d5e63c30e67434936c3a0352f57698 (patch)
treec8ce567433390e8da0d582bab8d27982c522d313 /sw
parentebceee31d92f04b58e795d02a26f62b717c47737 (diff)
merge sw::hack::Position and SwFltPosition
because they both attempt the same thing Change-Id: Ica0201fc114dd6251f05aa94c685258e322f7314 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111749 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/basflt/fltshell.cxx2
-rw-r--r--sw/source/filter/inc/fltshell.hxx12
-rw-r--r--sw/source/filter/ww8/ww8par.cxx15
-rw-r--r--sw/source/filter/ww8/ww8par.hxx20
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx10
5 files changed, 17 insertions, 42 deletions
diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx
index 153ccf42a37b..9514f2534095 100644
--- a/sw/source/filter/basflt/fltshell.cxx
+++ b/sw/source/filter/basflt/fltshell.cxx
@@ -101,7 +101,7 @@ void SwFltStackEntry::SetEndPos(const SwPosition& rEndPos)
// the cursor position moves the attribute's range
// That's not the desired behavior!
bOpen = false; // release and remember END
- m_aPtPos.SetPos(rEndPos);
+ m_aPtPos.FromSwPosition(rEndPos);
}
bool SwFltStackEntry::MakeRegion(SwDoc& rDoc, SwPaM& rRegion, RegionMode const eCheck,
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index e6e74e111e0d..4019c2c0ff9c 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -60,6 +60,7 @@ public:
m_nNode = rNode;
m_nContent = nIdx;
}
+
//operators with SwPosition, where the node is hacked to the previous one,
//and the offset to content is de-dynamic-ified
SwFltPosition(const SwPosition &rPos)
@@ -67,11 +68,20 @@ public:
, m_nContent(rPos.nContent.GetIndex())
{
}
- void SetPos(const SwPosition &rPos)
+
+ void FromSwPosition(const SwPosition &rPos)
{
m_nNode = rPos.nNode.GetIndex()-1;
m_nContent = rPos.nContent.GetIndex();
}
+
+ SwPosition ToSwPosition() const
+ {
+ SwNodeIndex m_nCorrectNode(m_nNode, +1);
+ SwPosition aRet(m_nCorrectNode);
+ aRet.nContent.Assign(m_nCorrectNode.GetNode().GetContentNode(), m_nContent);
+ return aRet;
+ }
};
// Stack entry for the attributes. It is always pointers to new attributes that are passed.
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index abab8b7d91c4..68069d83a7a1 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -6651,21 +6651,6 @@ bool SwWW8ImplReader::InEqualApo(int nLvl) const
return m_aApos[nLvl];
}
-namespace sw::hack
-{
- Position::Position(const SwPosition &rPos)
- : maPtNode(rPos.nNode), mnPtContent(rPos.nContent.GetIndex())
- {
- }
-
- Position::operator SwPosition() const
- {
- SwPosition aRet(maPtNode);
- aRet.nContent.Assign(maPtNode.GetNode().GetContentNode(), mnPtContent);
- return aRet;
- }
-}
-
SwMacroInfo::SwMacroInfo()
: SdrObjUserData( SdrInventor::ScOrSwDraw, SW_UD_IMAPDATA )
, mnShapeId(-1)
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index c4c60f30f586..21975f20fac8 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -543,21 +543,6 @@ struct HyperLinksTable
namespace sw
{
- namespace hack
- {
- class Position
- {
- private:
- SwNodeIndex maPtNode;
- sal_Int32 mnPtContent;
- public:
- explicit Position(const SwPosition &rPos);
- operator SwPosition() const;
- const SwNodeIndex& GetPtNode() const { return maPtNode; };
- sal_Int32 GetPtContent() const { return mnPtContent; };
- };
- }
-
auto FilterControlChars(OUString const& rString) -> OUString;
}
@@ -570,7 +555,7 @@ class WW8FieldEntry
::sw::mark::IFieldmark::parameter_map_t maParams;
public:
- sw::hack::Position maStartPos;
+ SwFltPosition maStartPos;
sal_uInt16 mnFieldId;
sal_uLong mnObjLocFc;
WW8FieldEntry(SwPosition const &rPos, sal_uInt16 nFieldId) throw();
@@ -578,9 +563,6 @@ class WW8FieldEntry
WW8FieldEntry &operator=(const WW8FieldEntry &rOther) throw();
void Swap(WW8FieldEntry &rOther) throw();
- SwNodeIndex GetPtNode() const { return maStartPos.GetPtNode(); };
- sal_Int32 GetPtContent() const { return maStartPos.GetPtContent(); };
-
const OUString& GetBookmarkName() const { return msBookmarkName;}
const OUString& GetBookmarkCode() const { return msMarkCode;}
void SetBookmarkName(const OUString& bookmarkName);
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 88b952099e6a..202f9a2d629f 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -220,7 +220,7 @@ tools::Long SwWW8ImplReader::Read_Book(WW8PLCFManResult*)
if (!m_aFieldStack.empty())
{
const WW8FieldEntry &rTest = m_aFieldStack.back();
- aStart = rTest.maStartPos;
+ aStart = rTest.maStartPos.ToSwPosition();
}
const OUString sOrigName = BookmarkToWriter(*pName);
@@ -522,7 +522,7 @@ sal_uInt16 SwWW8ImplReader::End_Field()
case ww::eFORMTEXT:
if (bUseEnhFields && m_pPaM!=nullptr && m_pPaM->GetPoint()!=nullptr) {
SwPosition aEndPos = *m_pPaM->GetPoint();
- SwPaM aFieldPam( m_aFieldStack.back().GetPtNode(), m_aFieldStack.back().GetPtContent(), aEndPos.nNode, aEndPos.nContent.GetIndex());
+ SwPaM aFieldPam(m_aFieldStack.back().maStartPos.ToSwPosition(), aEndPos);
IDocumentMarkAccess* pMarksAccess = m_rDoc.getIDocumentMarkAccess( );
IFieldmark *pFieldmark = pMarksAccess->makeFieldBookmark(
aFieldPam, m_aFieldStack.back().GetBookmarkName(), ODF_FORMTEXT,
@@ -584,7 +584,7 @@ sal_uInt16 SwWW8ImplReader::End_Field()
case ww::eMERGEINC:
case ww::eINCLUDETEXT:
//Move outside the section associated with this type of field
- *m_pPaM->GetPoint() = m_aFieldStack.back().maStartPos;
+ *m_pPaM->GetPoint() = m_aFieldStack.back().maStartPos.ToSwPosition();
break;
case ww::eIF: // IF-field
{
@@ -616,9 +616,7 @@ sal_uInt16 SwWW8ImplReader::End_Field()
{
// Unhandled field with stored code
SwPosition aEndPos = *m_pPaM->GetPoint();
- SwPaM aFieldPam(
- m_aFieldStack.back().GetPtNode(), m_aFieldStack.back().GetPtContent(),
- aEndPos.nNode, aEndPos.nContent.GetIndex());
+ SwPaM aFieldPam(m_aFieldStack.back().maStartPos.ToSwPosition(), aEndPos);
IDocumentMarkAccess* pMarksAccess = m_rDoc.getIDocumentMarkAccess( );