include/svx/svdoashp.hxx             |    2 +-
 include/svx/svdobj.hxx               |    2 +-
 include/svx/svdomeas.hxx             |    2 +-
 include/svx/svdotable.hxx            |    2 +-
 include/svx/svdotext.hxx             |    2 +-
 oox/source/drawingml/shape.cxx       |   25 +++++++++++++++++++++++++
 sd/qa/unit/data/xml/n593612_0.xml    |    4 ++--
 sd/qa/unit/import-tests-smartart.cxx |    2 +-
 sd/qa/unit/import-tests2.cxx         |    8 ++++----
 sd/source/core/drawdoc4.cxx          |    2 +-
 svx/source/svdraw/svdoashp.cxx       |    4 ++--
 svx/source/svdraw/svdobj.cxx         |    2 +-
 svx/source/svdraw/svdomeas.cxx       |    4 ++--
 svx/source/svdraw/svdotext.cxx       |    4 ++--
 svx/source/table/svdotable.cxx       |    5 +++--
 15 files changed, 48 insertions(+), 22 deletions(-)

New commits:
commit ebf13e890766f4cadbba81444784cfe3c8e1bbc3
Author:     Balazs Varga <[email protected]>
AuthorDate: Thu Aug 8 10:18:24 2024 +0200
Commit:     Balazs Varga <[email protected]>
CommitDate: Mon Aug 12 13:24:48 2024 +0200

    tdf#156857: sd ooxml import: fix shape size if spAutofit is set
    
    and the size of the shape from ooxml file is different then the
    inew calculated by TextAutoGrowHeight.
    
    Furthermore, no need to check and resize the shape size during
    the spell checking.
    
    Change-Id: Iffd15e02579942d4f5f20db73f2194f8298c0838
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171621
    Tested-by: Jenkins
    Reviewed-by: Balazs Varga <[email protected]>
    Tested-by: Gabor Kelemen <[email protected]>

diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx
index 34f26acc33c1..a33fce0aca7a 100644
--- a/include/svx/svdoashp.hxx
+++ b/include/svx/svdoashp.hxx
@@ -218,7 +218,7 @@ public:
     virtual basegfx::B2DPolyPolygon TakeXorPoly() const override;
     virtual basegfx::B2DPolyPolygon TakeContour() const override;
 
-    virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
pTextObject) override;
+    virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
pTextObject, bool bAdjustTextFrameWidthAndHeight = true) override;
 
     virtual rtl::Reference<SdrObject> DoConvertToPolyObj(bool bBezier, bool 
bAddText) const override;
 
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 85446e9b35d0..d109c15f3ee3 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -633,7 +633,7 @@ public:
     // keep text in outliner's format
     // SetOutlinerParaObject: transfer ownership of *pTextObject!
     void SetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject);
-    virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
pTextObject);
+    virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
pTextObject, bool bAdjustTextFrameWidthAndHeight = true);
     virtual OutlinerParaObject* GetOutlinerParaObject() const;
     virtual void NbcReformatText();
 
diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx
index 775354020af0..dcef67aa2c4c 100644
--- a/include/svx/svdomeas.hxx
+++ b/include/svx/svdomeas.hxx
@@ -138,7 +138,7 @@ public:
     SAL_DLLPRIVATE virtual void TakeTextAnchorRect(tools::Rectangle& 
rAnchorRect) const override;
     SAL_DLLPRIVATE virtual void TakeTextEditArea(Size* pPaperMin, Size* 
pPaperMax, tools::Rectangle* pViewInit, tools::Rectangle* pViewMin) const 
override;
     SAL_DLLPRIVATE virtual EEAnchorMode GetOutlinerViewAnchorMode() const 
override;
-    SAL_DLLPRIVATE virtual void 
NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject) 
override;
+    SAL_DLLPRIVATE virtual void 
NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObject, bool 
bAdjustTextFrameWidthAndHeight = true) override;
     SAL_DLLPRIVATE virtual OutlinerParaObject* GetOutlinerParaObject() const 
override;
 
     SAL_DLLPRIVATE virtual bool CalcFieldValue(const SvxFieldItem& rField, 
sal_Int32 nPara, sal_uInt16 nPos,
diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx
index 4a7e8ad792b6..9abacce2b9ff 100644
--- a/include/svx/svdotable.hxx
+++ b/include/svx/svdotable.hxx
@@ -239,7 +239,7 @@ public:
     void TakeTextEditArea(const sdr::table::CellPos& rPos, Size* pPaperMin, 
Size* pPaperMax, tools::Rectangle* pViewInit, tools::Rectangle* pViewMin) const;
     virtual EEAnchorMode GetOutlinerViewAnchorMode() const override;
 
-    virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
pTextObject) override;
+    virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
pTextObject, bool bAdjustTextFrameWidthAndHeight = true) override;
 
     virtual OutlinerParaObject* GetOutlinerParaObject() const override;
 
diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index c9184def420e..92d0cf0b9bf3 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -518,7 +518,7 @@ public:
     virtual void EndTextEdit(SdrOutliner& rOutl);
     virtual EEAnchorMode GetOutlinerViewAnchorMode() const;
 
-    virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
pTextObject) override;
+    virtual void NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
pTextObject, bool bAdjustTextFrameWidthAndHeight = true) override;
     // @param bAdjustTextFrameWidthAndHeight pass false if you know it is safe 
to avoid the cost of doing
     //              text layout right now.
     void NbcSetOutlinerParaObjectForText( std::optional<OutlinerParaObject> 
pTextObject, SdrText* pText, bool bAdjustTextFrameWidthAndHeight = true );
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 9d39849e4985..496714ec1e1a 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -2166,6 +2166,31 @@ Reference< XShape > const & Shape::createAndInsert(
             
rFilterBase.getMediaDescriptor()[utl::MediaDescriptor::PROP_DOCUMENTSERVICE] 
>>= sDocumentService;
             if (sDocumentService != u"com.sun.star.text.TextDocument")
                 mpTextBody->getTextProperties().readjustTextDistances(mxShape);
+
+            // tdf#156857: ooxml files can have shape size with spAutoFit=true 
and the first priority of
+            // shape size is the fix size even if TextAutoGrowHeight is true.
+            bool bAutoHeight = false;
+            Reference< XPropertySetInfo > xSetInfo(xSet->getPropertySetInfo());
+            const OUString& rPropName = 
PropertyMap::getPropertyName(PROP_TextAutoGrowHeight);
+            if (xSetInfo.is() && xSetInfo->hasPropertyByName(rPropName))
+            {
+                uno::Any aTextAutoGrowHeight = 
xSet->getPropertyValue(u"TextAutoGrowHeight"_ustr);
+                aTextAutoGrowHeight >>= bAutoHeight;
+            }
+
+            SdrObject* pShape = SdrObject::getSdrObjectFromXShape(mxShape);
+            if (pShape && bAutoHeight && bIsCustomShape)
+            {
+                tools::Rectangle aOrigSize(aShapeRectHmm.X, aShapeRectHmm.Y,
+                    aShapeRectHmm.X + aShapeRectHmm.Width, aShapeRectHmm.Y + 
aShapeRectHmm.Height);
+                tools::Rectangle aAdaptSize = pShape->GetLogicRect();
+                // a little tolerance same as in 
\svx\source\svdraw\svdoashp.cxx:AdjustTextFrameWidthAndHeight
+                if (std::abs(aOrigSize.GetHeight() - aAdaptSize.GetHeight()) > 
1)
+                {
+                    aAdaptSize.setHeight(aOrigSize.GetHeight());
+                    pShape->NbcSetLogicRect(aAdaptSize, false);
+                }
+            }
         }
     }
     return mxShape;
diff --git a/sd/qa/unit/data/xml/n593612_0.xml 
b/sd/qa/unit/data/xml/n593612_0.xml
index 0639294c5007..f278976b7d2a 100644
--- a/sd/qa/unit/data/xml/n593612_0.xml
+++ b/sd/qa/unit/data/xml/n593612_0.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <XShapes>
- <XShape positionX="11429" positionY="1324" sizeX="2259" sizeY="15124" 
type="com.sun.star.drawing.CustomShape" name="Rectangle 52" 
text="&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;"
 fontHeight="24.000000" fontColor="ffffffff" textAutoGrowHeight="true" 
textAutoGrowWidth="false" textContourFrame="false" textFitToSize="NONE" 
textHorizontalAdjust="CENTER" textVerticalAdjust="TOP" textLeftDistance="254" 
textRightDistance="254" textUpperDistance="127" textLowerDistance="127" 
textMaximumFrameHeight="0" textMaximumFrameWidth="0" textMinimumFrameHeight="0" 
textMinimumFrameWidth="0" textAnimationAmount="0" textAnimationCount="0" 
textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" 
textAnimationStartInside="false" textAnimationStopInside="false" 
textWritingMode="LR_TB" fillStyle="SOLID" fillColor="3c8c93" 
fillTransparence="0" fillTran
 sparenceGradientName="">
+ <XShape positionX="11429" positionY="1324" sizeX="2259" sizeY="15971" 
type="com.sun.star.drawing.CustomShape" name="Rectangle 52" 
text="&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;"
 fontHeight="24.000000" fontColor="ffffffff" textAutoGrowHeight="true" 
textAutoGrowWidth="false" textContourFrame="false" textFitToSize="NONE" 
textHorizontalAdjust="CENTER" textVerticalAdjust="TOP" textLeftDistance="254" 
textRightDistance="254" textUpperDistance="127" textLowerDistance="127" 
textMaximumFrameHeight="0" textMaximumFrameWidth="0" textMinimumFrameHeight="0" 
textMinimumFrameWidth="0" textAnimationAmount="0" textAnimationCount="0" 
textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" 
textAnimationStartInside="false" textAnimationStopInside="false" 
textWritingMode="LR_TB" fillStyle="SOLID" fillColor="3c8c93" 
fillTransparence="0" fillTran
 sparenceGradientName="">
   <FillTransparenceGradient style="LINEAR" startColor="000000" 
endColor="000000" angle="0" border="0" xOffset="50" yOffset="50" 
startIntensity="100" endIntensity="100" stepCount="0"/>
   <FillGradient style="LINEAR" startColor="3465a4" endColor="ffffff" angle="0" 
border="0" xOffset="50" yOffset="50" startIntensity="100" endIntensity="100" 
stepCount="0"/>
   <FillHatch style="SINGLE" color="3465a4" distance="20" angle="0"/>
@@ -10,7 +10,7 @@
   <LineEnd/>
   <Transformation>
    <Line1 column1="2260.000000" column2="0.000000" column3="11429.000000"/>
-   <Line2 column1="0.000000" column2="15125.000000" column3="1324.000000"/>
+   <Line2 column1="0.000000" column2="15972.000000" column3="1324.000000"/>
    <Line3 column1="0.000000" column2="0.000000" column3="1.000000"/>
   </Transformation>
   <CustomShapeGeometry>
diff --git a/sd/qa/unit/import-tests-smartart.cxx 
b/sd/qa/unit/import-tests-smartart.cxx
index ce947672cc93..be5a21aa482c 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -1032,7 +1032,7 @@ CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt, 
testPictureStrip)
     // Without the accompanying fix in place, this test would have failed with 
'Expected greater
     // than: 2873; Actual  : 2320', i.e. the title shape and the diagram 
overlapped.
     uno::Reference<drawing::XShape> xFirstPair = getChildShape(xGroup, 1);
-    CPPUNIT_ASSERT_GREATER(xTitle->getPosition().Y + xTitle->getSize().Height,
+    CPPUNIT_ASSERT_GREATER(xTitle->getPosition().Y + xTitle->getSize().Height 
- 1069,
                            xFirstPair->getPosition().Y);
 
     // Make sure that left margin is 60% of width (if you count width in 
points and margin in mms).
diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx
index 3f01a678ca5b..d66e12a52663 100644
--- a/sd/qa/unit/import-tests2.cxx
+++ b/sd/qa/unit/import-tests2.cxx
@@ -111,18 +111,18 @@ CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf160490)
     sal_Int32 nHeight1 = xShape1->getSize().Height;
 
     // Without the fix in place, this test would have failed with
-    // Expected: placeholder height: 2627
+    // Expected: placeholder height: 3728
     // Actual  : placeholder height: 3476
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(2627), nHeight1);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(3728), nHeight1);
 
     uno::Reference<drawing::XShape> xShape2(getShapeFromPage(0, 1), 
uno::UNO_QUERY);
     CPPUNIT_ASSERT(xShape2.is());
     sal_Int32 nHeight2 = xShape2->getSize().Height;
 
     // Without the fix in place, this test would have failed with
-    // Expected: placeholder height: 2373
+    // Expected: placeholder height: 3367
     // Actual  : placeholder height: 3116
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(2373), nHeight2);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(3367), nHeight2);
 }
 
 CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf157285)
diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx
index 5d4774b2ab0d..733d826123cd 100644
--- a/sd/source/core/drawdoc4.cxx
+++ b/sd/source/core/drawdoc4.cxx
@@ -896,7 +896,7 @@ void SdDrawDocument::SpellObject(SdrTextObj* pObj)
 
                     // taking text from the outliner
                     // use non-broadcasting version to avoid O(n^2)
-                    pObj->NbcSetOutlinerParaObject( std::move(pOPO) );
+                    pObj->NbcSetOutlinerParaObject( std::move(pOPO), false );
                 }
             }
         }
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 394cf7486155..fb9cf0a9923f 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -2800,9 +2800,9 @@ void SdrObjCustomShape::TakeTextRect( SdrOutliner& 
rOutliner, tools::Rectangle&
     rTextRect=tools::Rectangle(aTextPos,aTextSiz);
 }
 
-void 
SdrObjCustomShape::NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
pTextObject)
+void 
SdrObjCustomShape::NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
pTextObject, bool bAdjustTextFrameWidthAndHeight)
 {
-    SdrTextObj::NbcSetOutlinerParaObject( std::move(pTextObject) );
+    SdrTextObj::NbcSetOutlinerParaObject( std::move(pTextObject), 
bAdjustTextFrameWidthAndHeight );
     SetBoundRectDirty();
     SetBoundAndSnapRectsDirty(true);
     InvalidateRenderGeometry();
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index c28770ab2f7c..da43e65d0fb7 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -1853,7 +1853,7 @@ void 
SdrObject::SetOutlinerParaObject(std::optional<OutlinerParaObject> pTextObj
     }
 }
 
-void SdrObject::NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
/*pTextObject*/)
+void SdrObject::NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
/*pTextObject*/, bool /*bAdjustTextFrameWidthAndHeight = true*/)
 {
 }
 
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index 4e13258adaff..5647d0331539 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -1279,9 +1279,9 @@ OutlinerParaObject* 
SdrMeasureObj::GetOutlinerParaObject() const
     return SdrTextObj::GetOutlinerParaObject();
 }
 
-void SdrMeasureObj::NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
pTextObject)
+void SdrMeasureObj::NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
pTextObject, bool bAdjustTextFrameWidthAndHeight)
 {
-    SdrTextObj::NbcSetOutlinerParaObject(std::move(pTextObject));
+    SdrTextObj::NbcSetOutlinerParaObject(std::move(pTextObject), 
bAdjustTextFrameWidthAndHeight);
     if(SdrTextObj::GetOutlinerParaObject())
         SetTextDirty(); // recalculate text
 }
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 09fd8c945af3..3b4cf6ba72eb 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1321,9 +1321,9 @@ OutlinerParaObject* SdrTextObj::GetOutlinerParaObject() 
const
         return nullptr;
 }
 
-void SdrTextObj::NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
pTextObject)
+void SdrTextObj::NbcSetOutlinerParaObject(std::optional<OutlinerParaObject> 
pTextObject, bool bAdjustTextFrameWidthAndHeight)
 {
-    NbcSetOutlinerParaObjectForText( std::move(pTextObject), getActiveText() );
+    NbcSetOutlinerParaObjectForText( std::move(pTextObject), getActiveText(), 
bAdjustTextFrameWidthAndHeight );
 }
 
 namespace
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index a2b4ee89cfcb..43a4d7be5a0a 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -1869,7 +1869,7 @@ OutlinerParaObject* SdrTableObj::GetOutlinerParaObject() 
const
 }
 
 
-void SdrTableObj::NbcSetOutlinerParaObject( std::optional<OutlinerParaObject> 
pTextObject)
+void SdrTableObj::NbcSetOutlinerParaObject( std::optional<OutlinerParaObject> 
pTextObject, bool bAdjustTextFrameWidthAndHeight )
 {
     CellRef xCell( getActiveCell() );
     if( !xCell.is() )
@@ -1885,7 +1885,8 @@ void SdrTableObj::NbcSetOutlinerParaObject( 
std::optional<OutlinerParaObject> pT
 
     xCell->SetOutlinerParaObject( std::move(pTextObject) );
     SetTextSizeDirty();
-    NbcAdjustTextFrameWidthAndHeight();
+    if (bAdjustTextFrameWidthAndHeight)
+        NbcAdjustTextFrameWidthAndHeight();
 }
 
 

Reply via email to