sw/qa/extras/ooxmlexport/data/table-style-rPr-sz.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 24 ++++++++++++++++++ writerfilter/inc/dmapper/DomainMapper.hxx | 1 writerfilter/source/dmapper/DomainMapper.cxx | 6 +++- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 3 +- writerfilter/source/dmapper/DomainMapper_Impl.hxx | 3 ++ writerfilter/source/dmapper/StyleSheetTable.cxx | 5 +++ 7 files changed, 40 insertions(+), 2 deletions(-)
New commits: commit ba660eb85665b1893c86217daf1dad78d68ba192 Author: Pierre-Eric Pelloux-Prayer <pierre-e...@lanedo.com> Date: Thu Dec 20 17:09:24 2012 +0100 docx import: table styles and rPr/pPr tags unit test When importing table style from docx, ignore sz tag when not inside a tblStylePr element. I did not find any reason for this in WordProcessingML documentation, but Office seems to be doing so. This change includes the unit test. Change-Id: I2a6c27e458e02eb6cd39defe65a415792adc6393 diff --git a/sw/qa/extras/ooxmlexport/data/table-style-rPr-sz.docx b/sw/qa/extras/ooxmlexport/data/table-style-rPr-sz.docx new file mode 100755 index 0000000..6b6f694 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/table-style-rPr-sz.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 433160f..c95a99f 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -39,6 +39,9 @@ #include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/table/ShadowFormat.hpp> #include <com/sun/star/text/XPageCursor.hpp> +#include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/awt/FontUnderline.hpp> +#include <com/sun/star/awt/FontSlant.hpp> #include <unotools/tempfile.hxx> #include <unotools/ucbstreamhelper.hxx> @@ -80,6 +83,7 @@ public: void testTextFrameBorders(); void testTextframeGradient(); void testCellBtlr(); + void testTableStylerPrSz(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -123,6 +127,7 @@ void Test::run() {"textframe-borders.docx", &Test::testTextFrameBorders}, {"textframe-gradient.docx", &Test::testTextframeGradient}, {"cell-btlr.docx", &Test::testCellBtlr}, + {"table-style-rPr-sz.docx", &Test::testTableStylerPrSz}, }; // Don't test the first import of these, for some reason those tests fail const char* aBlacklist[] = { @@ -626,6 +631,25 @@ void Test::testCellBtlr() CPPUNIT_ASSERT_EQUAL(OUString("btLr"), aValue); } +void Test::testTableStylerPrSz() +{ + // Verify that font size inside the table is 20pt, despite the sz attribute in the table size. + // Also check that other rPr attribute are used: italic, bold, underline + // Office has the same behavior + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); + uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); + + CPPUNIT_ASSERT_EQUAL(20.f, getProperty<float>(getRun(xPara, 1), "CharHeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::SINGLE, getProperty<short>(getRun(xPara, 1), "CharUnderline")); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(xPara, 1), "CharWeight")); + CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, getProperty<awt::FontSlant>(getRun(xPara, 1), "CharPosture")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); commit 23b67c536537c91020cf5a45ab5cb36d7316ed89 Author: Miklos Vajna <vmik...@suse.cz> Date: Mon Mar 4 13:08:28 2013 +0100 DOCX import: fix import of font size in table styles Change-Id: I2c7ea83fb910b57d78fda620bc42b90e55de3719 diff --git a/writerfilter/inc/dmapper/DomainMapper.hxx b/writerfilter/inc/dmapper/DomainMapper.hxx index 26654d72..519367b 100644 --- a/writerfilter/inc/dmapper/DomainMapper.hxx +++ b/writerfilter/inc/dmapper/DomainMapper.hxx @@ -117,6 +117,7 @@ public: */ void processDeferredCharacterProperties( const std::map< sal_Int32, com::sun::star::uno::Any >& deferredCharacterProperties ); + void setInTableStyleRunProps(bool bInTableStyleRunProps); private: // Stream diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 6892f82..a4d1e03 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -2136,7 +2136,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType { rContext->Insert( PROP_CHAR_HEIGHT_COMPLEX, true, aVal ); } - else + else if (!m_pImpl->m_bInTableStyleRunProps) { //Asian get the same value as Western rContext->Insert( PROP_CHAR_HEIGHT, true, aVal ); @@ -3294,6 +3294,10 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType } } +void DomainMapper::setInTableStyleRunProps(bool bInTableStyleRunProps) +{ + m_pImpl->m_bInTableStyleRunProps = bInTableStyleRunProps; +} void DomainMapper::processDeferredCharacterProperties( const std::map< sal_Int32, uno::Any >& deferredCharacterProperties ) { diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 28ad154..383681d 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -186,7 +186,8 @@ DomainMapper_Impl::DomainMapper_Impl( m_bUsingEnhancedFields( false ), m_bSdt(false), m_xInsertTextRange(xInsertTextRange), - m_bIsNewDoc(bIsNewDoc) + m_bIsNewDoc(bIsNewDoc), + m_bInTableStyleRunProps(false) { appendTableManager( ); GetBodyText(); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index c8860f6..d59ffd9 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -670,6 +670,9 @@ public: /// If we're importing into a new document, or just pasting to an existing one. bool IsNewDoc(); + + /// If we're inside <w:rPr>, inside <w:style w:type="table"> + bool m_bInTableStyleRunProps; }; } //namespace dmapper } //namespace writerfilter diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index b5413b8..6e38673 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -594,7 +594,12 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm) m_pImpl->m_rDMapper.PushStyleSheetProperties( m_pImpl->m_pCurrentEntry->pProperties ); PropertyMapPtr pProps(new PropertyMap()); + bool bTableStyleRunProps = m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_TABLE && nSprmId == NS_ooxml::LN_CT_Style_rPr; + if (bTableStyleRunProps) + m_pImpl->m_rDMapper.setInTableStyleRunProps(true); m_pImpl->m_rDMapper.sprmWithProps( rSprm, pProps ); + if (bTableStyleRunProps) + m_pImpl->m_rDMapper.setInTableStyleRunProps(false); m_pImpl->m_pCurrentEntry->pProperties->InsertProps(pProps); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits