sw/qa/extras/rtfimport/data/landscape.rtf | 13 ++++ sw/qa/extras/rtfimport/data/lndscpsxn.rtf | 17 +++++ sw/qa/extras/rtfimport/rtfimport.cxx | 73 +++++++++++++++++++++++++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 9 ++- 4 files changed, 111 insertions(+), 1 deletion(-)
New commits: commit cbc0c1b64bff517b27104c6335d45fb59a884931 Author: Guillaume Smaha <[email protected]> Date: Wed Nov 25 10:18:51 2015 +0100 RTF import, fix landscape flag & implement lndscpsxn Change-Id: Id2e8e9c1a9686fd674d712498acb7374a81077d7 Reviewed-on: https://gerrit.libreoffice.org/20163 Tested-by: Jenkins <[email protected]> Reviewed-by: Mark Hung <[email protected]> Tested-by: Mark Hung <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/sw/qa/extras/rtfimport/data/landscape.rtf b/sw/qa/extras/rtfimport/data/landscape.rtf new file mode 100644 index 0000000..9bbc3f7 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/landscape.rtf @@ -0,0 +1,13 @@ +{\rtf1 \ansi \landscape \paperw16837 \paperh11905 +{\sectd +Test +\par +\sect} +{\sectd +TEST +\par +\sect} +{\sectd +Test +\par} +} diff --git a/sw/qa/extras/rtfimport/data/lndscpsxn.rtf b/sw/qa/extras/rtfimport/data/lndscpsxn.rtf new file mode 100644 index 0000000..d904a54 --- /dev/null +++ b/sw/qa/extras/rtfimport/data/lndscpsxn.rtf @@ -0,0 +1,17 @@ +{\rtf1 \ansi +{\sectd \paperw16837 \paperh11905 \lndscpsxn +Test +\par +\sect} +{\sectd \paperw11905 \paperh16837 +TEST +\par +\sect} +{\sectd \paperw16837 \paperh11905 \lndscpsxn +Test +\par +\sect} +{\sectd \paperw11905 \paperh16837 +TEST +\par} +} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 43d0fcb..c3edad9 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -2400,6 +2400,79 @@ DECLARE_RTFIMPORT_TEST(testTdf96308Tabpos, "tdf96308-tabpos.rtf") CPPUNIT_ASSERT(!aTabStops.hasElements()); } +DECLARE_RTFIMPORT_TEST(testLndscpsxn, "lndscpsxn.rtf") +{ + // Check landscape flag. + CPPUNIT_ASSERT_EQUAL(4, getPages()); + + uno::Reference<container::XNameAccess> pageStyles = getStyles("PageStyles"); + + // get a page cursor + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier( + xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XPageCursor> xCursor( + xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + + // check that the first page has landscape flag + xCursor->jumpToFirstPage(); + OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + uno::Reference<style::XStyle> xStylePage(pageStyles->getByName(pageStyleName), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_True, getProperty<sal_Bool>(xStylePage, "IsLandscape")); + + // check that the second page has no landscape flag + xCursor->jumpToPage(2); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xStylePage.set(pageStyles->getByName(pageStyleName), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_False, getProperty<sal_Bool>(xStylePage, "IsLandscape")); + + // check that the third page has landscape flag + xCursor->jumpToPage(3); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xStylePage.set(pageStyles->getByName(pageStyleName), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_True, getProperty<sal_Bool>(xStylePage, "IsLandscape")); + + // check that the last page has no landscape flag + xCursor->jumpToLastPage(); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xStylePage.set(pageStyles->getByName(pageStyleName), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_False, getProperty<sal_Bool>(xStylePage, "IsLandscape")); +} + +DECLARE_RTFIMPORT_TEST(testLandscape, "landscape.rtf") +{ + // Check landscape flag. + CPPUNIT_ASSERT_EQUAL(3, getPages()); + + // All pages should have flag orientiation + uno::Reference<container::XNameAccess> pageStyles = getStyles("PageStyles"); + + // get a page cursor + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier( + xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XPageCursor> xCursor( + xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + + // check that the first page has landscape flag + xCursor->jumpToFirstPage(); + OUString pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + uno::Reference<style::XStyle> xStylePage(pageStyles->getByName(pageStyleName), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_True, getProperty<sal_Bool>(xStylePage, "IsLandscape")); + + // check that the second page has landscape flag + xCursor->jumpToPage(2); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xStylePage.set(pageStyles->getByName(pageStyleName), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_True, getProperty<sal_Bool>(xStylePage, "IsLandscape")); + + // check that the last page has landscape flag + xCursor->jumpToLastPage(); + pageStyleName = getProperty<OUString>(xCursor, "PageStyleName"); + xStylePage.set(pageStyles->getByName(pageStyleName), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_True, getProperty<sal_Bool>(xStylePage, "IsLandscape")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 8ee4bc7..92ba692 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -3497,7 +3497,14 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword) case RTF_LANDSCAPE: { auto pValue = std::make_shared<RTFValue>(NS_ooxml::LN_Value_ST_PageOrientation_landscape); - lcl_putNestedAttribute(m_aStates.top().aSectionSprms, NS_ooxml::LN_EG_SectPrContents_pgSz, NS_ooxml::LN_CT_PageSz_orient, pValue); + lcl_putNestedAttribute(m_aDefaultState.aSectionSprms, + NS_ooxml::LN_EG_SectPrContents_pgSz, NS_ooxml::LN_CT_PageSz_orient, pValue); + } + case RTF_LNDSCPSXN: + { + auto pValue = std::make_shared<RTFValue>(NS_ooxml::LN_Value_ST_PageOrientation_landscape); + lcl_putNestedAttribute(m_aStates.top().aSectionSprms, + NS_ooxml::LN_EG_SectPrContents_pgSz, NS_ooxml::LN_CT_PageSz_orient, pValue); } break; case RTF_SHPBXPAGE: _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
