Kaydet (Commit) 0c8017a3 authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst 2f31023a
...@@ -2132,7 +2132,9 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType ...@@ -2132,7 +2132,9 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
if (xCharStyle.is()) if (xCharStyle.is())
xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_HEIGHT), aVal); 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; break;
case NS_sprm::LN_CHpsInc: case NS_sprm::LN_CHpsInc:
...@@ -3300,12 +3302,22 @@ void DomainMapper::processDeferredCharacterProperties( const std::map< sal_Int32 ...@@ -3300,12 +3302,22 @@ void DomainMapper::processDeferredCharacterProperties( const std::map< sal_Int32
else else
{ {
std::map< sal_Int32, uno::Any >::const_iterator font = deferredCharacterProperties.find( NS_sprm::LN_CHps ); 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()) if( font != deferredCharacterProperties.end())
{ {
double fontSize = 0; double fontSize = 0;
font->second >>= fontSize; font->second >>= fontSize;
nEscapement = nIntValue * 100 / 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 else
{ // TODO: Find out the font size. The 58/-58 values were here previous, but I have { // 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 // no idea what they are (they are probably some random guess that did fit whatever
......
...@@ -360,6 +360,10 @@ StyleSheetTable::~StyleSheetTable() ...@@ -360,6 +360,10 @@ StyleSheetTable::~StyleSheetTable()
delete m_pImpl; delete m_pImpl;
} }
PropertyMapPtr StyleSheetTable::GetDefaultCharProps()
{
return m_pImpl->m_pDefaultCharProps;
}
void StyleSheetTable::lcl_attribute(Id Name, Value & val) void StyleSheetTable::lcl_attribute(Id Name, Value & val)
{ {
......
...@@ -96,6 +96,9 @@ public: ...@@ -96,6 +96,9 @@ public:
OUString getOrCreateCharStyle( PropertyValueVector_t& rCharProperties ); OUString getOrCreateCharStyle( PropertyValueVector_t& rCharProperties );
/// Returns the default character properties.
PropertyMapPtr GetDefaultCharProps();
private: private:
// Properties // Properties
virtual void lcl_attribute(Id Name, Value & val); virtual void lcl_attribute(Id Name, Value & val);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment