sw/qa/extras/odfexport/odfexport.cxx | 34 ++++++++++++++++++++++++++++++++++ sw/source/core/layout/fly.cxx | 5 +++++ sw/source/core/text/xmldump.cxx | 15 +++++++++++++++ 3 files changed, 54 insertions(+)
New commits: commit 8a26e4b26f0153fb8ca5da880ee4aa44748ee4df Author: Miklos Vajna <[email protected]> AuthorDate: Thu May 9 21:13:50 2019 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Fri May 10 08:30:53 2019 +0200 sw btlr writing mode: implement layout for fly frames The case when a fly frame was first constructed with one direction then switched to btlr was already working. The case when the direction is already set before the SwFlyFrame is constructed was not, as SvxFrameDirection::Vertical_LR_BT was unhandled. Change-Id: I97d15b3fc15ee116181718144dc9bccf8f31529f Reviewed-on: https://gerrit.libreoffice.org/72077 Tested-by: Jenkins Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 4ef1128d3118..eeb16f2d9ef7 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -37,6 +37,8 @@ #include <svl/PasswordHelper.hxx> #include <docufld.hxx> // for SwHiddenTextField::ParseIfFieldDefinition() method call #include <unoprnms.hxx> +#include <sortedobjs.hxx> +#include <flyfrm.hxx> class Test : public SwModelTestBase { @@ -1419,6 +1421,38 @@ DECLARE_ODFEXPORT_TEST(testBtlrFrame, "btlr-frame.odt") auto nActual = getProperty<sal_Int16>(xTextFrame, "WritingMode"); CPPUNIT_ASSERT_EQUAL(text::WritingMode2::BT_LR, nActual); + + // Without the accompanying fix in place, this test would have failed, as the fly frame had + // mbVertical==true, but mbVertLRBT==false, even if the writing direction in the doc model was + // btlr. + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc(); + CPPUNIT_ASSERT(pDoc); + + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + CPPUNIT_ASSERT(pLayout); + + SwFrame* pPageFrame = pLayout->GetLower(); + CPPUNIT_ASSERT(pPageFrame); + CPPUNIT_ASSERT(pPageFrame->IsPageFrame()); + + SwFrame* pBodyFrame = pPageFrame->GetLower(); + CPPUNIT_ASSERT(pBodyFrame); + CPPUNIT_ASSERT(pBodyFrame->IsBodyFrame()); + + SwFrame* pBodyTextFrame = pBodyFrame->GetLower(); + CPPUNIT_ASSERT(pBodyTextFrame); + CPPUNIT_ASSERT(pBodyTextFrame->IsTextFrame()); + + CPPUNIT_ASSERT(pBodyTextFrame->GetDrawObjs()); + const SwSortedObjs& rAnchored = *pBodyTextFrame->GetDrawObjs(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rAnchored.size()); + + auto* pFlyFrame = dynamic_cast<SwFlyFrame*>(rAnchored[0]); + CPPUNIT_ASSERT(pFlyFrame); + CPPUNIT_ASSERT(pFlyFrame->IsVertLRBT()); } DECLARE_ODFEXPORT_TEST(testFdo86963, "fdo86963.odt") diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index d364ccf655b8..c701c9db56b9 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -129,6 +129,11 @@ SwFlyFrame::SwFlyFrame( SwFlyFrameFormat *pFormat, SwFrame* pSib, SwFrame *pAnch if ( SvxFrameDirection::Vertical_LR_TB == nDir ) mbVertLR = true; + else if (nDir == SvxFrameDirection::Vertical_LR_BT) + { + mbVertLR = true; + mbVertLRBT = true; + } else mbVertLR = false; } diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx index 5a25baaeb264..b99645bed539 100644 --- a/sw/source/core/text/xmldump.cxx +++ b/sw/source/core/text/xmldump.cxx @@ -467,6 +467,21 @@ void SwFrame::dumpAsXmlAttributes( xmlTextWriterPtr writer ) const const SwTextFrame *pTextFrame = static_cast<const SwTextFrame *>(this); const SwTextNode *pTextNode = pTextFrame->GetTextNodeFirst(); xmlTextWriterWriteFormatAttribute( writer, BAD_CAST( "txtNodeIndex" ), TMP_FORMAT, pTextNode->GetIndex() ); + + OString aMode = "Horizontal"; + if (IsVertLRBT()) + { + aMode = "VertBTLR"; + } + else if (IsVertLR()) + { + aMode = "VertLR"; + } + else if (IsVertical()) + { + aMode = "Vertical"; + } + xmlTextWriterWriteAttribute(writer, BAD_CAST("WritingMode"), BAD_CAST(aMode.getStr())); } if (IsHeaderFrame() || IsFooterFrame()) { _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
