summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-09-28 10:41:07 +0200
committerMichael Stahl <mstahl@redhat.com>2016-09-28 11:04:19 +0200
commitbb069fe7b8b6a24f9ff4df4c7052961e17ea3a8c (patch)
tree2456f6b1d78a90284792eb91b79be1e46d5266b5
parent2bd8be10e231314e757f29a37177f529e6f1df47 (diff)
sw: remove defensive programming bullshit in lcl_AssureFieldMarksSet
In CppunitTest_sw_ooxmlfieldexport testFdo81492 a TextFieldmark is inserted at a position where already another TextFieldmark starts. The defensively programmed lcl_AssureFieldMarksSet notices there is aleady a dummy character at the start position, and does not insert another one, but then the dummy character for the end position is inserted, moving the start position index, which puts the start position behind another bookmark. So we end up with a field mark that has a end character but not a start character and an un-sorted m_vAllMarks. Change-Id: Icd15e83471e18f607eb41b2f7b0c2ce61c94ff9f
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx2
-rw-r--r--sw/source/core/crsr/bookmrk.cxx30
2 files changed, 10 insertions, 22 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index 9af064c457a3..39a227423d45 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -565,7 +565,7 @@ DECLARE_OOXMLEXPORT_TEST(testSdtDateDuplicate, "sdt-date-duplicate.docx")
DECLARE_OOXMLEXPORT_TEST(testFdo81492, "fdo81492.docx")
{
if (xmlDocPtr pXmlDoc = parseExport())
- assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[5]/w:instrText", "ADDIN EN.CITE.DATA");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[9]/w:instrText", "ADDIN EN.CITE.DATA");
}
DECLARE_OOXMLEXPORT_TEST(testEditTime, "fdo81341.docx")
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index b99edeb71c99..936e48f1bbb2 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -73,11 +73,7 @@ namespace
io_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_UI_REPLACE, nullptr);
SwPosition start = pField->GetMarkStart();
- SwTextNode const*const pStartTextNode = start.nNode.GetNode().GetTextNode();
- sal_Unicode ch_start = 0;
- if (pStartTextNode && (start.nContent.GetIndex() < pStartTextNode->GetText().getLength()))
- ch_start = pStartTextNode->GetText()[start.nContent.GetIndex()];
- if( ( ch_start != aStartMark ) && ( aEndMark != CH_TXT_ATR_FORMELEMENT ) )
+ if (aEndMark != CH_TXT_ATR_FORMELEMENT)
{
SwPaM aStartPaM(start);
io_pDoc->getIDocumentContentOperations().InsertString(aStartPaM, OUString(aStartMark));
@@ -88,14 +84,7 @@ namespace
}
SwPosition& rEnd = pField->GetMarkEnd();
- SwTextNode const*const pEndTextNode = rEnd.nNode.GetNode().GetTextNode();
- const sal_Int32 nEndPos = (rEnd == start || rEnd.nContent.GetIndex() == 0)
- ? rEnd.nContent.GetIndex()
- : rEnd.nContent.GetIndex() - 1;
- sal_Unicode ch_end = 0;
- if ( pEndTextNode && ( nEndPos < pEndTextNode->GetText().getLength() ) )
- ch_end = pEndTextNode->GetText()[nEndPos];
- if ( aEndMark && ( ch_end != aEndMark ) )
+ if (aEndMark)
{
SwPaM aEndPaM(rEnd);
io_pDoc->getIDocumentContentOperations().InsertString(aEndPaM, OUString(aEndMark));
@@ -118,8 +107,9 @@ namespace
if( pStartTextNode )
ch_start = pStartTextNode->GetText()[rStart.nContent.GetIndex()];
- if( ch_start == aStartMark )
+ if (aEndMark != CH_TXT_ATR_FORMELEMENT)
{
+ assert(ch_start == aStartMark);
SwPaM aStart(rStart, rStart);
++aStart.End()->nContent;
io_pDoc->getIDocumentContentOperations().DeleteRange(aStart);
@@ -133,13 +123,11 @@ namespace
sal_Unicode ch_end = 0;
if ( pEndTextNode )
ch_end = pEndTextNode->GetText()[nEndPos];
- if ( ch_end == aEndMark )
- {
- SwPaM aEnd(rEnd, rEnd);
- if (aEnd.Start()->nContent > 0)
- --aEnd.Start()->nContent;
- io_pDoc->getIDocumentContentOperations().DeleteRange(aEnd);
- }
+ assert(ch_end == aEndMark);
+ SwPaM aEnd(rEnd, rEnd);
+ if (aEnd.Start()->nContent > 0)
+ --aEnd.Start()->nContent;
+ io_pDoc->getIDocumentContentOperations().DeleteRange(aEnd);
io_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_UI_REPLACE, nullptr);
};