sw/qa/extras/ooxmlexport/ooxmlexport10.cxx   |    6 ++-
 writerfilter/source/dmapper/DomainMapper.cxx |   52 +++++----------------------
 2 files changed, 14 insertions(+), 44 deletions(-)

New commits:
commit 875793d841165aaaaefa2c34b855e8f0f8a8c214
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Fri Oct 4 09:36:45 2019 +0300
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Oct 7 09:28:25 2019 +0200

    related tdf#99602 writerfilter TODO: subscript - use ParaStyle fontsize
    
    The existing code handled two situations:
    1.) if both position(escapement) and fontsize set via direct properties
    2.) if fontsize came from the document default properties.
    
    That misses both paragraph style fontsize (very common)
    and character style fontsize.  This patch adds checking for
    the paragraph style's fontsize.
    
    Change-Id: I25312cd4544cfd1be09b21c96a270cb05e4f5b8f
    Reviewed-on: https://gerrit.libreoffice.org/80179
    Reviewed-by: Justin Luth <justin_l...@sil.org>
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 911c343922eb..17b91ecb9180 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -213,8 +213,10 @@ DECLARE_OOXMLEXPORT_TEST(testFontEsc, 
"test_tdf120412.docx")
         return;
     // don't lose the run with superscript formatting
     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r", 2);
-    // raising is greater than 100%
-    assertXPath(pXmlDoc, 
"/w:document/w:body/w:p/w:r[2]/w:rPr/w:position","val", "24");
+    // Superscript should be raised by 100% (11pt). Was 110% (12pt)
+    // calculated using docDefault with fontsize 10pt (note only w:szCs 
defined as 11pt, not w:sz)
+    // instead of inherited normal paraStyle fontsize 11pt (related to 
tdf#99602)
+    assertXPath(pXmlDoc, 
"/w:document/w:body/w:p/w:r[2]/w:rPr/w:position","val", "22");
 }
 
 DECLARE_OOXMLEXPORT_TEST(testMceWpg, "mce-wpg.docx")
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index b461367fdec3..3d7216e62854 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1699,9 +1699,6 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
                         
xCharStyle->setPropertyValue(getPropertyName(PROP_CHAR_HEIGHT), aVal);
                 }
             }
-            // Make sure char sizes defined in the stylesheets don't affect 
char props from direct formatting.
-            if (!IsStyleSheetImport())
-                m_pImpl->deferCharacterProperty( nSprmId, uno::makeAny( 
nIntValue ));
             m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, (nSprmId == 
NS_ooxml::LN_EG_RPrBase_sz ? OUString("sz") : OUString("szCs")), 
OUString::number(nIntValue));
         }
         break;
@@ -2803,55 +2800,26 @@ void DomainMapper::processDeferredCharacterProperties( 
const std::map< sal_Int32
         rProp.second >>= sStringValue;
         switch( Id )
         {
-        case NS_ooxml::LN_EG_RPrBase_sz:
-        case NS_ooxml::LN_EG_RPrBase_szCs:
-        break; // only for use by other properties, ignore here
         case NS_ooxml::LN_EG_RPrBase_position:
         {
             double nEscapement = 0;
-            sal_Int8 nProp  = 100;
-            if(nIntValue == 0)
-                nProp = 0;
-            else
-            {
-                std::map< sal_Int32, uno::Any >::const_iterator font = 
deferredCharacterProperties.find( NS_ooxml::LN_EG_RPrBase_sz );
-                PropertyMapPtr pDefaultCharProps = 
m_pImpl->GetStyleSheetTable()->GetDefaultCharProps();
-                boost::optional<PropertyMap::Property> aDefaultFont = 
pDefaultCharProps->getProperty(PROP_CHAR_HEIGHT);
-                if( font != deferredCharacterProperties.end())
-                {
-                    double fontSize = 0;
-                    font->second >>= fontSize;
-                    if (fontSize != 0.0)
-                        nEscapement = nIntValue * 100 / fontSize;
-                }
-                // TODO if not direct formatting, check the style first, not 
directly the default char props.
-                else if (aDefaultFont)
-                {
-                    double fHeight = 0;
-                    aDefaultFont->second >>= fHeight;
-                    if (fHeight != 0.0)
-                    {
-                        // fHeight is in points, nIntValue is in half points, 
nEscapement is in percents.
-                        nEscapement = nIntValue * 100 / fHeight / 2;
-                    }
-                }
+            sal_Int8 nProp = 0;
+            if ( nIntValue )
+            {
+                nProp = 100;
+                double fFontSize = 0;
+                m_pImpl->GetAnyProperty(PROP_CHAR_HEIGHT, rContext) >>= 
fFontSize;
+                if ( fFontSize )
+                    // nIntValue is in half-points, fontsize is in points, 
escapement is a percentage.
+                    nEscapement = round( nIntValue/2.0 / fFontSize * 100 );
                 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
-                  // specific case somebody was trying to fix).
-                    nEscapement = ( nIntValue > 0 ) ? 58: -58;
-                }
+                    nEscapement = nIntValue > 0 ? DFLT_ESC_SUPER : 
DFLT_ESC_SUB;
             }
-
             // tdf#120412 up to 14400% (eg. 1584 pt with 11 pt letters)
             if ( nEscapement > MAX_ESC_POS )
-            {
                 nEscapement = MAX_ESC_POS;
-            }
             else if ( nEscapement < -MAX_ESC_POS )
-            {
                 nEscapement = -MAX_ESC_POS;
-            }
 
             rContext->Insert(PROP_CHAR_ESCAPEMENT,         uno::makeAny( 
sal_Int16(nEscapement) ) );
             rContext->Insert(PROP_CHAR_ESCAPEMENT_HEIGHT,  uno::makeAny( nProp 
) );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to