diff options
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 2 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper_Impl.cxx | 35 |
2 files changed, 30 insertions, 7 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index e269a3bfba6e..3996c634ab8f 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -537,7 +537,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[9]/w:instrText", "ADDIN EN.CITE.DATA"); + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[7]/w:instrText", "ADDIN EN.CITE.DATA"); } DECLARE_OOXMLEXPORT_TEST(testEditTime, "fdo81341.docx") diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index b9c053700574..b2cb490f221a 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1779,7 +1779,10 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, const Proper m_bTextInserted = true; xTOCTextCursor->gotoRange(xTextRange->getEnd(), true); mxTOCTextCursor = xTOCTextCursor; - m_aTextAppendStack.push(TextAppendContext(xTextAppend, xTOCTextCursor)); + if (!m_bStartGenericField) + { + m_aTextAppendStack.push(TextAppendContext(xTextAppend, xTOCTextCursor)); + } } } else @@ -5029,12 +5032,27 @@ void DomainMapper_Impl::CloseFieldCommand() const uno::Reference<text::XTextContent> xTextContent(xFieldInterface, uno::UNO_QUERY_THROW); uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend; uno::Reference< text::XTextCursor > xCrsr = xTextAppend->createTextCursorByRange(pContext->GetStartRange()); - if (xTextContent.is()) + if (m_aTextAppendStack.top().xInsertPosition.is()) + { + xCrsr->gotoRange(m_aTextAppendStack.top().xInsertPosition, true); + } + else { - xTextAppend->insertTextContent(xCrsr,xTextContent, true); + xCrsr->gotoEnd(true); } - uno::Reference<uno::XInterface> xContent(xTextContent); - uno::Reference< text::XFormField> xFormField(xContent, uno::UNO_QUERY); + xTextAppend->insertTextContent(xCrsr, xTextContent, true); + // problem: the fieldmark must be inserted here, because + // attach() takes 2 positions, not 3! + // FAIL: AppendTextNode() ignores the content index! + // plan B: insert a spurious paragraph break now and join + // it in PopFieldContext()! + xCrsr->gotoRange(xTextContent->getAnchor()->getEnd(), false); + xCrsr->goLeft(1, false); // skip CH_TXT_ATR_FIELDEND + xTextAppend->insertControlCharacter(xCrsr, text::ControlCharacter::PARAGRAPH_BREAK, false); + xCrsr->goLeft(1, false); // back to previous paragraph + m_aTextAppendStack.push(TextAppendContext(xTextAppend, xCrsr)); + + uno::Reference<text::XFormField> xFormField(xTextContent, uno::UNO_QUERY); xFormField->setFieldType(aCode); m_bStartGenericField = true; pContext->SetFormField( xFormField ); @@ -5396,9 +5414,14 @@ void DomainMapper_Impl::PopFieldContext() else if(m_bStartGenericField) { m_bStartGenericField = false; + xCrsr->gotoRange(m_aTextAppendStack.top().xInsertPosition, false); + xCrsr->goRight(1, true); + xCrsr->setString(OUString()); // undo SplitNode from CloseFieldCommand() + // note: paragraph properties will be overwritten + // by finishParagraph() anyway so ignore here + m_aTextAppendStack.pop(); if(m_bTextInserted) { - m_aTextAppendStack.pop(); m_bTextInserted = false; } } |