sw/qa/extras/ooxmlimport/data/n782061.docx |binary sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 12 ++++++++++++ writerfilter/source/dmapper/DomainMapper.cxx | 14 +++++++++++++- writerfilter/source/dmapper/StyleSheetTable.cxx | 4 ++++ writerfilter/source/dmapper/StyleSheetTable.hxx | 3 +++ 5 files changed, 32 insertions(+), 1 deletion(-)
New commits: commit 7a3a8a254363801bf6893b23d67f86a7461f8f3b Author: Miklos Vajna <vmik...@suse.cz> Date: Fri Sep 28 09:52:29 2012 +0100 n#782061 testcase Change-Id: I6aa95063ac8fe825b47decc68b08a35d81e4d59d diff --git a/sw/qa/extras/ooxmlimport/data/n782061.docx b/sw/qa/extras/ooxmlimport/data/n782061.docx new file mode 100644 index 0000000..9d8218b Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/n782061.docx differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 1cefa39..a83a398 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -96,6 +96,7 @@ public: void testN780853(); void testN780843(); void testShadow(); + void testN782061(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -138,6 +139,7 @@ public: CPPUNIT_TEST(testN780853); CPPUNIT_TEST(testN780843); CPPUNIT_TEST(testShadow); + CPPUNIT_TEST(testN782061); #endif CPPUNIT_TEST_SUITE_END(); @@ -981,6 +983,16 @@ void Test::testShadow() CPPUNIT_ASSERT_EQUAL(sal_Int32(273), sal_Int32(aShadow.ShadowWidth)); } +void Test::testN782061() +{ + /* + * The problem was that the character escapement in the second run was -58. + */ + load("n782061.docx"); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(-9), getProperty<sal_Int32>(getRun(getParagraph(1), 2), "CharEscapement")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); commit 0c8017a364efb0e8a1cab57b22257e9b319fa0a1 Author: Miklos Vajna <vmik...@suse.cz> Date: Fri Sep 28 09:51:42 2012 +0100 n#782061 DOCX import: w:position should respect w:sz in w:rPrDefault Subscript relative font size (w:position) is in percents in Writer, but is in half points in Word. When checking for the default font size to count the percent value, the mapper should search font size (w:sz) not only in direct character properties, but also in default character properties (w:rPrDefault). Change-Id: I9286d44c6498c765ddfee795d50921ef58b80071 diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 52d8c1a..cfd8dad 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -2132,7 +2132,9 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType if (xCharStyle.is()) xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_HEIGHT), aVal); } - m_pImpl->deferCharacterProperty( nSprmId, uno::makeAny( nIntValue )); + // Make sure char sizes defined in the stylesheets don't affect char props from direct formatting. + if (!m_pImpl->IsStyleSheetImport()) + m_pImpl->deferCharacterProperty( nSprmId, uno::makeAny( nIntValue )); } break; case NS_sprm::LN_CHpsInc: @@ -3300,12 +3302,22 @@ void DomainMapper::processDeferredCharacterProperties( const std::map< sal_Int32 else { std::map< sal_Int32, uno::Any >::const_iterator font = deferredCharacterProperties.find( NS_sprm::LN_CHps ); + PropertyMapPtr pDefaultCharProps = m_pImpl->GetStyleSheetTable()->GetDefaultCharProps(); + PropertyMap::iterator aDefaultFont = pDefaultCharProps->find(PropertyDefinition( PROP_CHAR_HEIGHT, false )); if( font != deferredCharacterProperties.end()) { double fontSize = 0; font->second >>= fontSize; nEscapement = nIntValue * 100 / fontSize; } + // TODO if not direct formatting, check the style first, not directly the default char props. + else if (aDefaultFont != pDefaultCharProps->end()) + { + double fHeight = 0; + aDefaultFont->second >>= fHeight; + // fHeight is in points, nIntValue is in half points, nEscapement is in percents. + nEscapement = nIntValue * 100 / fHeight / 2; + } else { // TODO: Find out the font size. The 58/-58 values were here previous, but I have // no idea what they are (they are probably some random guess that did fit whatever diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index be06d59..044b53c 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -360,6 +360,10 @@ StyleSheetTable::~StyleSheetTable() delete m_pImpl; } +PropertyMapPtr StyleSheetTable::GetDefaultCharProps() +{ + return m_pImpl->m_pDefaultCharProps; +} void StyleSheetTable::lcl_attribute(Id Name, Value & val) { diff --git a/writerfilter/source/dmapper/StyleSheetTable.hxx b/writerfilter/source/dmapper/StyleSheetTable.hxx index c0ee6de..d668989 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.hxx +++ b/writerfilter/source/dmapper/StyleSheetTable.hxx @@ -96,6 +96,9 @@ public: OUString getOrCreateCharStyle( PropertyValueVector_t& rCharProperties ); + /// Returns the default character properties. + PropertyMapPtr GetDefaultCharProps(); + private: // Properties virtual void lcl_attribute(Id Name, Value & val); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits