sw/qa/extras/rtfexport/data/tbrl-frame.odt |binary sw/qa/extras/rtfexport/rtfexport3.cxx | 16 ++++++++ sw/qa/extras/unowriter/data/view-cursor-page-style.fodt | 23 ++++++++++++ sw/qa/extras/unowriter/unowriter.cxx | 29 ++++++++++++++++ sw/source/core/unocore/unocrsrhelper.cxx | 5 ++ sw/source/filter/ww8/rtfattributeoutput.cxx | 10 +++++ writerfilter/source/rtftok/rtfsdrimport.cxx | 9 +++- 7 files changed, 89 insertions(+), 3 deletions(-)
New commits: commit 73ba97ad4f12bdfc12f9cbd5ac223980f14af3ab Author: Miklos Vajna <[email protected]> AuthorDate: Wed Aug 7 17:43:50 2019 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Aug 9 16:19:24 2019 +0200 sw: fix ViewCursor.PageStyleName for multi-page paragraphs In case the text frames of a text node span over multiple pages and the first page has a page style which has a follow page style, the page style under the cursor depends on not only the text node index, but also on the context index. Without this, the page style under the cursor will expose the first page's style name via the API, even if it's already on a follow page. Change-Id: I922e153750755317bda87441a88e9f53a6f348b7 Reviewed-on: https://gerrit.libreoffice.org/77128 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins (cherry picked from commit 9a66b452ede70a25cd6fc8a72772a71b0ee7957a) Reviewed-on: https://gerrit.libreoffice.org/77201 Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sw/qa/extras/unowriter/data/view-cursor-page-style.fodt b/sw/qa/extras/unowriter/data/view-cursor-page-style.fodt new file mode 100644 index 000000000000..c386e72c949e --- /dev/null +++ b/sw/qa/extras/unowriter/data/view-cursor-page-style.fodt @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1. 0" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ooo="http://openoffice.org/2004/office" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:rpt="http://op enoffice.org/2005/report" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:styles> + <style:default-style style:family="paragraph"/> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + </office:styles> + <office:automatic-styles> + <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard" style:master-page-name="First_20_Page"/> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="9.7cm" style:print-orientation="landscape" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm"> + </style:page-layout-properties> + </style:page-layout> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1"/> + <style:master-page style:name="First_20_Page" style:display-name="First Page" style:page-layout-name="pm1" style:next-style-name="Standard"/> + </office:master-styles> + <office:body> + <office:text> + <text:p text:style-name="P1">01<text:line-break/>02<text:line-break/>03<text:line-break/>04<text:line-break/>05<text:line-break/>06<text:line-break/>07<text:line-break/>08<text:line-break/>09<text:line-break/>10<text:line-break/>11<text:line-break/>12<text:line-break/>13<text:line-break/>14<text:line-break/>15<text:line-break/>16</text:p> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx index 72b2fced0d3c..a3b28218acd4 100644 --- a/sw/qa/extras/unowriter/unowriter.cxx +++ b/sw/qa/extras/unowriter/unowriter.cxx @@ -415,6 +415,35 @@ DECLARE_UNOAPI_TEST(testImageCommentAtChar) } } +CPPUNIT_TEST_FIXTURE(SwUnoWriter, testViewCursorPageStyle) +{ + // Load a document with 2 pages, but a single paragraph. + load(mpTestDocumentPath, "view-cursor-page-style.fodt"); + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + CPPUNIT_ASSERT(xModel.is()); + uno::Reference<text::XTextViewCursorSupplier> xController(xModel->getCurrentController(), + uno::UNO_QUERY); + CPPUNIT_ASSERT(xController.is()); + uno::Reference<text::XPageCursor> xViewCursor(xController->getViewCursor(), uno::UNO_QUERY); + CPPUNIT_ASSERT(xViewCursor.is()); + + // Go to the first page, which has an explicit page style. + xViewCursor->jumpToPage(1); + OUString aActualPageStyleName = getProperty<OUString>(xViewCursor, "PageStyleName"); + CPPUNIT_ASSERT_EQUAL(OUString("First Page"), aActualPageStyleName); + + // Go to the second page, which is still the first paragraph, but the page style is different, + // as the explicit 'First Page' page style has a next style defined (Standard). + xViewCursor->jumpToPage(2); + aActualPageStyleName = getProperty<OUString>(xViewCursor, "PageStyleName"); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: Standard + // - Actual : First Page + // i.e. the cursor position was determined only based on the node index, ignoring the content + // index. + CPPUNIT_ASSERT_EQUAL(OUString("Standard"), aActualPageStyleName); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index da1facfad0ab..c19cdeea537f 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -913,7 +913,10 @@ void GetCurPageStyle(SwPaM const & rPaM, OUString &rString) { if (!rPaM.GetContentNode()) return; // TODO: is there an easy way to get it for tables/sections? - SwContentFrame* pFrame = rPaM.GetContentNode()->getLayoutFrame(rPaM.GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout()); + SwRootFrame* pLayout = rPaM.GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout(); + // Consider the position inside the content node, since the node may span over multiple pages + // with different page styles. + SwContentFrame* pFrame = rPaM.GetContentNode()->getLayoutFrame(pLayout, rPaM.GetPoint()); if(pFrame) { const SwPageFrame* pPage = pFrame->FindPageFrame(); commit 3ac0003eb2cfb35f2892625c6c1d47b79f1ed6b0 Author: Miklos Vajna <[email protected]> AuthorDate: Thu Aug 1 19:28:07 2019 +0200 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Aug 9 16:19:12 2019 +0200 sw btlr writing mode: RTF filter of Writer tbrl textframes Fix both import and export. Values 1 and 3 seems to be the same. Accept both on import, but write 3, as DOCX only has a single value and Word uses 3 when doing DOCX->RTF conversion. Reviewed-on: https://gerrit.libreoffice.org/76823 Tested-by: Jenkins Reviewed-by: Miklos Vajna <[email protected]> (cherry picked from commit 8f36d40426fa83bf7923a818377cc50048199dfd) Conflicts: sw/qa/extras/rtfexport/rtfexport4.cxx Change-Id: Ic5420091ffee9eb20c6aaac61a127e93289aa9fe Reviewed-on: https://gerrit.libreoffice.org/77200 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/qa/extras/rtfexport/data/tbrl-frame.odt b/sw/qa/extras/rtfexport/data/tbrl-frame.odt new file mode 100644 index 000000000000..3cc79deb66e5 Binary files /dev/null and b/sw/qa/extras/rtfexport/data/tbrl-frame.odt differ diff --git a/sw/qa/extras/rtfexport/rtfexport3.cxx b/sw/qa/extras/rtfexport/rtfexport3.cxx index a254fa618bfe..12b1e84d77c6 100644 --- a/sw/qa/extras/rtfexport/rtfexport3.cxx +++ b/sw/qa/extras/rtfexport/rtfexport3.cxx @@ -250,6 +250,22 @@ DECLARE_RTFEXPORT_TEST(testBtlrCell, "btlr-cell.rtf") CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, getProperty<sal_Int16>(xC1, "WritingMode")); } +DECLARE_RTFEXPORT_TEST(testTbrlFrame, "tbrl-frame.odt") +{ + if (!mbExported) + { + return; + } + + uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY); + auto nActual = getProperty<sal_Int16>(xShape, "WritingMode"); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2 + // - Actual : 0 + // i.e. custom wrting mode was lost. + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL, nActual); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 44958af03f25..24be7b8904af 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -3484,6 +3484,16 @@ void RtfAttributeOutput::FormatLineNumbering(const SwFormatLineNumber& rNumberin void RtfAttributeOutput::FormatFrameDirection(const SvxFrameDirectionItem& rDirection) { + if (m_rExport.m_bRTFFlySyntax) + { + if (rDirection.GetValue() == SvxFrameDirection::Vertical_RL_TB) + { + // Top to bottom non-ASCII font + m_aFlyProperties.push_back(std::make_pair<OString, OString>("txflTextFlow", "3")); + } + return; + } + if (!m_rExport.m_bOutPageDescs) { if (rDirection.GetValue() == SvxFrameDirection::Horizontal_RL_TB) diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 9a7b980ba09d..35addd606640 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -446,8 +446,13 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap ; // Ignore: complementer of lineColor else if (rProperty.first == "txflTextFlow" && xPropertySet.is()) { - if (rProperty.second.toInt32() == 1) - eWritingMode = text::WritingMode_TB_RL; + switch (rProperty.second.toInt32()) + { + case 1: // Top to bottom ASCII font + case 3: // Top to bottom non-ASCII font + eWritingMode = text::WritingMode_TB_RL; + break; + } } else if (rProperty.first == "fLine" && xPropertySet.is()) resolveFLine(xPropertySet, rProperty.second.toInt32()); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
