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,6 +2132,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
if (xCharStyle.is())
xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_HEIGHT), aVal);
}
// 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;
......@@ -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
......
......@@ -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)
{
......
......@@ -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);
......
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