summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-11-26 15:56:30 +0100
committerMichael Stahl <michael.stahl@cib.de>2019-11-26 19:18:07 +0100
commit10d72337640677e2d49b522a734728646c9b8e96 (patch)
tree456a03f93b91d500dc68c2477a77202f449bc831
parent87156783e5bc89709a1933efbbde82817715d5dc (diff)
sw: WW8 import: fix again asserts on fdo45983-1.doc export to ODT
The problem is that we now insert 2 dummy characters at the start of a fieldmark instead of 1, so the checks in RedlineStack::MoveAttrs() were off by 1 and we get the same invalid redline containing the start but not the end of a fieldmark. (regression from 7f2e61f884949ab27bcb7e1a02ece9a5cb4354b9) Change-Id: I9752ca4c3a281539e37ddac4fe811e2f9d7374a6 Reviewed-on: https://gerrit.libreoffice.org/83783 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
-rw-r--r--sw/source/filter/inc/msfilter.hxx3
-rw-r--r--sw/source/filter/ww8/writerhelper.cxx13
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx6
3 files changed, 14 insertions, 8 deletions
diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx
index b5fbfdb2e737..f05283e46c51 100644
--- a/sw/source/filter/inc/msfilter.hxx
+++ b/sw/source/filter/inc/msfilter.hxx
@@ -299,7 +299,8 @@ namespace sw
public:
explicit RedlineStack(SwDoc &rDoc) : mrDoc(rDoc) {}
- void MoveAttrs(const SwPosition& rPos);
+ enum class MoveAttrsMode { Default, FieldmarkInserted };
+ void MoveAttrs(const SwPosition& rPos, MoveAttrsMode eMode = MoveAttrsMode::Default);
void open(const SwPosition& rPos, const SfxPoolItem& rAttr);
bool close(const SwPosition& rPos, RedlineType eType);
void close(const SwPosition& rPos, RedlineType eType,
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index cf2a051bd237..512812faf361 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -742,11 +742,14 @@ namespace sw
std::for_each(maStack.begin(), maStack.end(), SetEndIfOpen(rPos));
}
- void RedlineStack::MoveAttrs( const SwPosition& rPos )
+ void RedlineStack::MoveAttrs(const SwPosition& rPos, MoveAttrsMode const eMode)
{
size_t nCnt = maStack.size();
+ sal_Int32 const nInserted = eMode == MoveAttrsMode::FieldmarkInserted
+ ? 2 // CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDSEP
+ : 1;
sal_uLong nPosNd = rPos.nNode.GetIndex();
- sal_Int32 nPosCt = rPos.nContent.GetIndex() - 1;
+ sal_Int32 nPosCt = rPos.nContent.GetIndex() - nInserted;
for (size_t i=0; i < nCnt; ++i)
{
@@ -755,12 +758,12 @@ namespace sw
if ((rEntry.m_aMkPos.m_nNode.GetIndex()+1 == nPosNd) &&
(nPosCt <= rEntry.m_aMkPos.m_nContent))
{
- rEntry.m_aMkPos.m_nContent++;
+ rEntry.m_aMkPos.m_nContent += nInserted;
SAL_WARN_IF(rEntry.m_aMkPos.m_nContent > rPos.nNode.GetNodes()[nPosNd]->GetContentNode()->Len(),
"sw.ww8", "redline ends after end of line");
if (isPoint) // sigh ... important special case...
{
- rEntry.m_aPtPos.m_nContent++;
+ rEntry.m_aPtPos.m_nContent += nInserted;
continue;
}
}
@@ -769,7 +772,7 @@ namespace sw
if ((rEntry.m_aPtPos.m_nNode.GetIndex()+1 == nPosNd) &&
(nPosCt < rEntry.m_aPtPos.m_nContent))
{
- rEntry.m_aPtPos.m_nContent++;
+ rEntry.m_aPtPos.m_nContent += nInserted;
SAL_WARN_IF(rEntry.m_aPtPos.m_nContent > rPos.nNode.GetNodes()[nPosNd]->GetContentNode()->Len(),
"sw.ww8", "redline ends after end of line");
}
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index e6f31bb0736a..ea0a435371a3 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -542,7 +542,8 @@ sal_uInt16 SwWW8ImplReader::End_Field()
if (pFieldmark!=nullptr) {
// adapt redline positions to inserted field mark start
// dummy char (assume not necessary for end dummy char)
- m_xRedlineStack->MoveAttrs(*aFieldPam.Start());
+ m_xRedlineStack->MoveAttrs(*aFieldPam.Start(),
+ RedlineStack::MoveAttrsMode::FieldmarkInserted);
const IFieldmark::parameter_map_t& rParametersToAdd = m_aFieldStack.back().getParameters();
pFieldmark->GetParameters()->insert(rParametersToAdd.begin(), rParametersToAdd.end());
}
@@ -642,7 +643,8 @@ sal_uInt16 SwWW8ImplReader::End_Field()
{
// adapt redline positions to inserted field mark start
// dummy char (assume not necessary for end dummy char)
- m_xRedlineStack->MoveAttrs(*aFieldPam.Start());
+ m_xRedlineStack->MoveAttrs(*aFieldPam.Start(),
+ RedlineStack::MoveAttrsMode::FieldmarkInserted);
const IFieldmark::parameter_map_t& rParametersToAdd = m_aFieldStack.back().getParameters();
pFieldmark->GetParameters()->insert(rParametersToAdd.begin(), rParametersToAdd.end());
OUString sFieldId = OUString::number( m_aFieldStack.back().mnFieldId );