writerfilter/source/dmapper/DomainMapper_Impl.cxx |   92 ++++++++--------------
 1 file changed, 37 insertions(+), 55 deletions(-)

New commits:
commit af8f05f859a1fb61d88dfe558d1bc7a8282c792a
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Mon Mar 13 09:47:29 2023 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Wed Mar 15 09:46:45 2023 +0000

    tdf#154129 writerfilter framePr: deduplicate w:h
    
    This is not quite a No Functional Change commit.
    In the previous code, a zero value for H was not added as a property
    if there was no parent style.
    
    However, it seems that pretty much only RTF
    fails to typically have styles defined,
    since even an unspecified "Normal" style is checked.
    (fdo77890.docx also followed the "else" path
     because it basically had an empty styles.xml file.)
    
    That means that in all but the most bizarre cases,
    the "no style" case would never be reached anyway.
    That really eliminates any worries about the deduplication going bad.
    
    In any case, it makes it the same as width (and most DOCX files)
    which had been doing this in the first place.
    
    For consistency and code simplicity I'll go ahead with the change.
    
    Change-Id: I65eed50ba83397284f21bb20ef3bbf10e02cce04
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148805
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index eee409798ce1..910fe366fa93 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -1647,6 +1647,43 @@ void 
DomainMapper_Impl::CheckUnregisteredFrameConversion( )
             comphelper::makePropertyValue(getPropertyName(PROP_WIDTH_TYPE),
                                           bAutoWidth ? text::SizeType::MIN : 
text::SizeType::FIX));
 
+        bool bValidH = false;
+        sal_Int32 nHeight = DEFAULT_FRAME_MIN_HEIGHT;
+        for (const auto pProp : vProps)
+        {
+            if (pProp->Geth() < 0)
+                continue;
+            nHeight = pProp->Geth();
+            bValidH = true;
+            break;
+        }
+        aFrameProperties.push_back(
+            comphelper::makePropertyValue(getPropertyName(PROP_HEIGHT), 
nHeight));
+
+        sal_Int16 nhRule = -1;
+        for (const auto pProp : vProps)
+        {
+            if (pProp->GethRule() < 0)
+                continue;
+            nhRule = pProp->GethRule();
+            break;
+        }
+        if (nhRule < 0)
+        {
+            if (bValidH)
+            {
+                // [MS-OE376] Word uses a default value of "atLeast" for
+                // this attribute when the value of the h attribute is not 0.
+                nhRule = text::SizeType::MIN;
+            }
+            else
+            {
+                nhRule = text::SizeType::VARIABLE;
+            }
+        }
+        aFrameProperties.push_back(
+            comphelper::makePropertyValue(getPropertyName(PROP_SIZE_TYPE), 
nhRule));
+
         sal_Int16 nHoriOrient = text::HoriOrientation::NONE;
         for (const auto pProp : vProps)
         {
@@ -1671,42 +1708,6 @@ void 
DomainMapper_Impl::CheckUnregisteredFrameConversion( )
 
         if (vProps.size() > 1)
         {
-            bool bValidH = false;
-            sal_Int32 nHeight = DEFAULT_FRAME_MIN_HEIGHT;
-            for (const auto pProp : vProps)
-            {
-                if (pProp->Geth() < 0)
-                    continue;
-                nHeight = pProp->Geth();
-                bValidH = true;
-                break;
-            }
-            aFrameProperties.push_back(
-                comphelper::makePropertyValue(getPropertyName(PROP_HEIGHT), 
nHeight));
-
-            sal_Int16 nhRule = -1;
-            for (const auto pProp : vProps)
-            {
-                if (pProp->GethRule() < 0)
-                    continue;
-                nhRule = pProp->GethRule();
-                break;
-            }
-            if ( nhRule < 0 )
-            {
-                if (bValidH)
-                {
-                    // [MS-OE376] Word uses a default value of "atLeast" for
-                    // this attribute when the value of the h attribute is not 
0.
-                    nhRule = text::SizeType::MIN;
-                }
-                else
-                {
-                    nhRule = text::SizeType::VARIABLE;
-                }
-            }
-            
aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_SIZE_TYPE),
 nhRule));
-
             if (const std::optional<sal_Int16> nDirection = 
PopFrameDirection())
             {
                 
aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_FRM_DIRECTION),
 *nDirection));
@@ -1826,22 +1827,6 @@ void 
DomainMapper_Impl::CheckUnregisteredFrameConversion( )
         }
         else
         {
-            sal_Int16 nhRule = 
sal_Int16(rAppendContext.pLastParagraphProperties->GethRule());
-            if ( nhRule < 0 )
-            {
-                if ( rAppendContext.pLastParagraphProperties->Geth() >= 0 )
-                {
-                    // [MS-OE376] Word uses a default value of atLeast for
-                    // this attribute when the value of the h attribute is not 
0.
-                    nhRule = text::SizeType::MIN;
-                }
-                else
-                {
-                    nhRule = text::SizeType::VARIABLE;
-                }
-            }
-            
aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_SIZE_TYPE),
 nhRule));
-
             sal_Int32 nVertDist = 
rAppendContext.pLastParagraphProperties->GethSpace();
             if( nVertDist < 0 )
                 nVertDist = 0;
@@ -1854,9 +1839,6 @@ void DomainMapper_Impl::CheckUnregisteredFrameConversion( 
)
             
aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_TOP_MARGIN),
 nHoriOrient == text::HoriOrientation::LEFT ? 0 : nHoriDist));
             
aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_BOTTOM_MARGIN),
 nHoriOrient == text::HoriOrientation::RIGHT ? 0 : nHoriDist));
 
-            if( rAppendContext.pLastParagraphProperties->Geth() > 0 )
-                
aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_HEIGHT),
 rAppendContext.pLastParagraphProperties->Geth()));
-
             if( rAppendContext.pLastParagraphProperties->IsxValid() )
                 
aFrameProperties.push_back(comphelper::makePropertyValue(getPropertyName(PROP_HORI_ORIENT_POSITION),
 rAppendContext.pLastParagraphProperties->Getx()));
 

Reply via email to