diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/unocore/unotext.cxx | 36 |
2 files changed, 46 insertions, 2 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index 5c36cf7421d3..d389f3cd890a 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -572,7 +572,17 @@ DECLARE_OOXMLEXPORT_TEST(testN780843, "n780843.docx") { uno::Reference< text::XTextRange > xPara = getParagraph(1); OUString aStyleName = getProperty<OUString>(xPara, "PageStyleName"); - CPPUNIT_ASSERT_EQUAL(OUString("First Page"), aStyleName); + // what happens on export here is that the "Default Style" isn't actually + // used on page 2, because of the hard page break with style "Converted2" + // and therefore SwPageDesc::IsFollowNextPageOfNode() returns false and + // "w:titlepg" element is not written + // (the export result is wrong with or without w:titlepg, because the footer + // on the 2nd page should be the text "shown footer") + if (mbExported) + CPPUNIT_ASSERT_EQUAL(OUString("Standard"), aStyleName); + else + CPPUNIT_ASSERT_EQUAL(OUString("First Page"), aStyleName); + //tdf64372 this document should only have one page break (2 pages, not 3) uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 0657f7bc361d..2a84d8655a46 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -2218,6 +2218,12 @@ SwXText::copyText( { SolarMutexGuard aGuard; + uno::Reference<lang::XUnoTunnel> const xSourceTunnel(xSource, + uno::UNO_QUERY); + SwXText const*const pSource( xSourceTunnel.is() + ? ::sw::UnoTunnelGetImplementation<SwXText>(xSourceTunnel) + : nullptr); + uno::Reference< text::XText > const xText(xSource, uno::UNO_QUERY_THROW); uno::Reference< text::XTextCursor > const xCursor = xText->createTextCursor(); @@ -2235,7 +2241,35 @@ SwXText::copyText( SwNodeIndex rNdIndex( *GetStartNode( ), 1 ); SwPosition rPos( rNdIndex ); - m_pImpl->m_pDoc->getIDocumentContentOperations().CopyRange( *pCursor->GetPaM(), rPos, /*bCopyAll=*/false, /*bCheckPos=*/true ); + // tdf#112202 need SwXText because cursor cannot select table at the start + if (pSource) + { + SwTextNode * pFirstNode; + { + SwPaM temp(*pSource->GetStartNode(), *pSource->GetStartNode()->EndOfSectionNode(), +1, -1); + pFirstNode = temp.GetMark()->nNode.GetNode().GetTextNode(); + if (pFirstNode) + { + pFirstNode->MakeStartIndex(&temp.GetMark()->nContent); + } + if (SwTextNode *const pNode = temp.GetPoint()->nNode.GetNode().GetTextNode()) + { + pNode->MakeEndIndex(&temp.GetPoint()->nContent); + } + m_pImpl->m_pDoc->getIDocumentContentOperations().CopyRange(temp, rPos, /*bCopyAll=*/false, /*bCheckPos=*/true); + } + if (!pFirstNode) + { // the node at rPos was split; get rid of the first empty one so + // that the pasted table is first + auto pDelCursor(m_pImpl->m_pDoc->CreateUnoCursor(SwPosition(SwNodeIndex(*GetStartNode(), 1)))); + m_pImpl->m_pDoc->getIDocumentContentOperations().DelFullPara(*pDelCursor); + } + } + else + { + m_pImpl->m_pDoc->getIDocumentContentOperations().CopyRange(*pCursor->GetPaM(), rPos, /*bCopyAll=*/false, /*bCheckPos=*/true); + } + } SwXBodyText::SwXBodyText(SwDoc *const pDoc) |