sax/source/tools/fastserializer.cxx | 25 -------- sw/qa/extras/ooxmlexport/data/nonbmpchar.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 9 +++ 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 ++- 7 files changed, 122 insertions(+), 24 deletions(-)
New commits: commit adef474252f8b5ad97c1ee004783d8223c4bde11 Author: Guillaume Smaha <[email protected]> Date: Wed Nov 25 10:18:51 2015 +0100 RTF import, fix landscape flag & implement lndscpsxn 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]> (cherry picked from commit cbc0c1b64bff517b27104c6335d45fb59a884931) Change-Id: Id2e8e9c1a9686fd674d712498acb7374a81077d7 Signed-off-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 36eaf03..f7e16fc 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -2373,6 +2373,79 @@ DECLARE_RTFIMPORT_TEST(testTdf59454, "tdf59454.rtf") CPPUNIT_ASSERT_EQUAL(2, getPages()); } +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 2c32453..9748fe6 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -3487,7 +3487,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: commit e99f22bbc499ab0566621ee0bb01e4a7747efe76 Author: Mark Hung <[email protected]> Date: Sun Jan 10 00:28:14 2016 +0800 Fix FastSaxSerializer::write() for non-BMP unicode characters. Reviewed-on: https://gerrit.libreoffice.org/21293 Tested-by: Jenkins <[email protected]> Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit 7ec5ba47783ac8b2d0141109d0efe6b20b363ced) Signed-off-by: Michael Stahl <[email protected]> Change-Id: I6ee9d028813c970b9ac5b9f0574af932e73111bd diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index 37ed847..8437ff0 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -94,29 +94,8 @@ namespace sax_fastparser { void FastSaxSerializer::write( const OUString& sOutput, bool bEscape ) { - const sal_Int32 nLength = sOutput.getLength(); - for (sal_Int32 i = 0; i < nLength; ++i) - { - const sal_Unicode cUnicode = sOutput[ i ]; - const char cChar = cUnicode; - if (cUnicode & 0xff80) - { - write( OString(&cUnicode, 1, RTL_TEXTENCODING_UTF8) ); - } - else if(bEscape) switch( cChar ) - { - case '<': writeBytes( "<", 4 ); break; - case '>': writeBytes( ">", 4 ); break; - case '&': writeBytes( "&", 5 ); break; - case '\'': writeBytes( "'", 6 ); break; - case '"': writeBytes( """, 6 ); break; - case '\n': writeBytes( " ", 5 ); break; - case '\r': writeBytes( " ", 5 ); break; - default: writeBytes( &cChar, 1 ); break; - } - else - writeBytes( &cChar, 1 ); - } + write( sOutput.toUtf8(), bEscape ); + } void FastSaxSerializer::write( const OString& sOutput, bool bEscape ) diff --git a/sw/qa/extras/ooxmlexport/data/nonbmpchar.docx b/sw/qa/extras/ooxmlexport/data/nonbmpchar.docx new file mode 100644 index 0000000..a6b5d41 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/nonbmpchar.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index 3626d57..f66aeca 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -970,6 +970,15 @@ DECLARE_OOXMLEXPORT_TEST(testOO106020, "ooo106020-1.odt") assertXPath(pXmlDoc, "//w:tbl", 1); } +DECLARE_OOXMLEXPORT_TEST(testNonBMPChar, "nonbmpchar.docx") +{ + sal_uInt32 nCh = 0x24b62; + OUString aExpected( &nCh, 1); + // Assert that UTF8 encoded non-BMP Unicode character is correct + uno::Reference<text::XTextRange> xTextRange1 = getRun(getParagraph(1), 1); + CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange1->getString()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
