include/svx/sdr/properties/customshapeproperties.hxx | 7 - include/svx/svdoashp.hxx | 4 include/svx/svdotext.hxx | 12 + sd/qa/unit/data/xml/shapes-test_page2.xml | 2 svx/source/sdr/properties/customshapeproperties.cxx | 120 ++++++++++--------- svx/source/svdraw/svdoashp.cxx | 105 +++++++++------- svx/source/svdraw/svdotext.cxx | 109 +++++++++++++---- svx/source/svdraw/svdotxdr.cxx | 20 --- svx/source/svdraw/svdotxtr.cxx | 31 +++- 9 files changed, 258 insertions(+), 152 deletions(-)
New commits: commit 1a67b7cc3d5dc3dcd0de0e247f638c33d57dea1b Author: David Tardon <[email protected]> Date: Sat Mar 22 15:44:47 2014 +0100 init only required items Change-Id: Iccbdea89fe2b5142bdd5213bb90e7656fc7eda8a diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index 6ced8d6..b86e76c 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -1451,7 +1451,11 @@ void SdrObjCustomShape::AdaptTextMinSize() if(!pModel || !pModel->IsPasteResize()) { const bool bResizeShapeToFitText(0 != static_cast< const SdrTextAutoGrowHeightItem& >(GetObjectItem(SDRATTR_TEXT_AUTOGROWHEIGHT)).GetValue()); - SfxItemSet aSet(GetObjectItemSet()); + SfxItemSet aSet( + *GetObjectItemSet().GetPool(), + SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT, + SDRATTR_TEXT_MINFRAMEWIDTH, SDRATTR_TEXT_AUTOGROWWIDTH, // contains SDRATTR_TEXT_MAXFRAMEWIDTH + 0, 0); bool bChanged(false); if(bResizeShapeToFitText) commit 363119a9f2f0710a55530909330efb343d5a8bae Author: David Tardon <[email protected]> Date: Sun Mar 9 12:48:48 2014 +0100 avoid infinite loop when setting vert. text dir. Change-Id: I8ff1d61af9ff383f00062894ad10efca534318bd diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 02a91d3..170c5ec 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -1617,15 +1617,17 @@ void SdrTextObj::SetVerticalWriting(bool bVertical) case SDRTEXTHORZADJUST_BLOCK: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK)); break; } - SetObjectItemSet(aNewSet); - pOutlinerParaObject = GetOutlinerParaObject(); if( pOutlinerParaObject ) { - // set ParaObject orientation accordingly + // Set ParaObject orientation accordingly. This _must_ be + // done before applying the updated item set, otherwise we + // get stuck in a loop leading to eventual stack overflow. pOutlinerParaObject->SetVertical(bVertical); } + SetObjectItemSet(aNewSet); + // restore object size SetSnapRect(aObjectRect); } commit 33c310b6ff9feb277c001ce61db96864baedc3bc Author: Armin Le Grand <[email protected]> Date: Mon Jan 27 21:14:39 2014 +0000 i123932 Init only needed items in diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 3a4c9ab..02a91d3 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -573,7 +573,11 @@ void SdrTextObj::AdaptTextMinSize() if(bW || bH) { - SfxItemSet aSet(GetObjectItemSet()); + SfxItemSet aSet( + *GetObjectItemSet().GetPool(), + SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT, + SDRATTR_TEXT_MINFRAMEWIDTH, SDRATTR_TEXT_AUTOGROWWIDTH, // contains SDRATTR_TEXT_MAXFRAMEWIDTH + 0, 0); if(bW) { commit 872b5642f9c81f7e09b5fe592d9f92b9367d337c Author: Armin Le Grand <[email protected]> Date: Thu Oct 31 11:53:29 2013 +0000 i123573 corrected reaction on ItemChanges for CustomShapes Conflicts: svx/source/sdr/properties/customshapeproperties.cxx Change-Id: I9f37893bab72b2d9b9f8874f6827ca6bee5dfbe1 diff --git a/include/svx/sdr/properties/customshapeproperties.hxx b/include/svx/sdr/properties/customshapeproperties.hxx index d92db87..f28c90f 100644 --- a/include/svx/sdr/properties/customshapeproperties.hxx +++ b/include/svx/sdr/properties/customshapeproperties.hxx @@ -30,7 +30,8 @@ namespace sdr { class CustomShapeProperties : public TextProperties { - void UpdateTextFrameStatus(); + private: + void UpdateTextFrameStatus(bool bInvalidateRenderGeometry); protected: // create a new itemset diff --git a/svx/source/sdr/properties/customshapeproperties.cxx b/svx/source/sdr/properties/customshapeproperties.cxx index 35b4d07..729709e 100644 --- a/svx/source/sdr/properties/customshapeproperties.cxx +++ b/svx/source/sdr/properties/customshapeproperties.cxx @@ -32,21 +32,32 @@ namespace sdr { namespace properties { - void CustomShapeProperties::UpdateTextFrameStatus() + void CustomShapeProperties::UpdateTextFrameStatus(bool bInvalidateRenderGeometry) { SdrObjCustomShape& rObj = static_cast< SdrObjCustomShape& >(GetSdrObject()); const bool bOld(rObj.bTextFrame); + // change TextFrame flag when bResizeShapeToFitText changes (which is mapped + // on the item SDRATTR_TEXT_AUTOGROWHEIGHT for custom shapes, argh) rObj.bTextFrame = 0 != static_cast< const SdrTextAutoGrowHeightItem& >(GetObjectItemSet().Get(SDRATTR_TEXT_AUTOGROWHEIGHT)).GetValue(); + // check if it did change if(rObj.bTextFrame != bOld) { - rObj.InvalidateRenderGeometry(); + // on change also invalidate render geometry + bInvalidateRenderGeometry = true; // #115391# Potential recursion, since it calls SetObjectItemSet again, but rObj.bTextFrame - // will not change again, thus it will be only one level and terminate + // will not change again. Thus it will be only one level and terminate safely rObj.AdaptTextMinSize(); } + + if(bInvalidateRenderGeometry) + { + // if asked for or bResizeShapeToFitText changed, make sure that + // the render geometry is reconstructed using changed parameters + rObj.InvalidateRenderGeometry(); + } } SfxItemSet& CustomShapeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) @@ -127,7 +138,7 @@ namespace sdr TextProperties::ItemSetChanged(rSet); // update bTextFrame and RenderGeometry - UpdateTextFrameStatus(); + UpdateTextFrameStatus(true); } void CustomShapeProperties::PostItemChange(const sal_uInt16 nWhich) @@ -137,7 +148,7 @@ namespace sdr case SDRATTR_TEXT_AUTOGROWHEIGHT: { // #115391# update bTextFrame and RenderGeometry using AdaptTextMinSize() - UpdateTextFrameStatus(); + UpdateTextFrameStatus(false); break; } default: @@ -156,7 +167,7 @@ namespace sdr TextProperties::ItemChange( nWhich, pNewItem ); // update bTextFrame and RenderGeometry - UpdateTextFrameStatus(); + UpdateTextFrameStatus(true); } void CustomShapeProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) @@ -165,13 +176,13 @@ namespace sdr TextProperties::SetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr ); // update bTextFrame and RenderGeometry - UpdateTextFrameStatus(); + UpdateTextFrameStatus(true); } void CustomShapeProperties::ForceDefaultAttributes() { // update bTextFrame and RenderGeometry - UpdateTextFrameStatus(); + UpdateTextFrameStatus(true); // SJ: Following is no good if creating customshapes, leading to objects that are white after loading via xml // This means: Do *not* call parent here is by purpose... @@ -219,11 +230,8 @@ namespace sdr bRemoveRenderGeometry = sal_True; } - if ( bRemoveRenderGeometry ) - { // update bTextFrame and RenderGeometry - UpdateTextFrameStatus(); - } + UpdateTextFrameStatus(bRemoveRenderGeometry); } } // end of namespace properties } // end of namespace sdr commit d74fc692a9ee403851b29bb93b252a79404ba007 Author: Armin Le Grand <[email protected]> Date: Thu Sep 19 11:21:03 2013 +0000 i115391 corected from SetObejctItem to usage of local SfxItemSet diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 5c24ec0..3a4c9ab 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -599,7 +599,7 @@ void SdrTextObj::AdaptTextMinSize() if(IsVerticalWriting() && bDisableAutoWidthOnDragging) { bDisableAutoWidthOnDragging = false; - SetObjectItem(SdrTextAutoGrowHeightItem(false)); + aSet.Put(SdrTextAutoGrowHeightItem(false)); } } commit acd03d705029ac4a4bbdbfae4403697d27367979 Author: David Tardon <[email protected]> Date: Sun Mar 9 13:04:10 2014 +0100 fix unit test diff --git a/sd/qa/unit/data/xml/shapes-test_page2.xml b/sd/qa/unit/data/xml/shapes-test_page2.xml index f7ecaa6..fb81de6 100644 --- a/sd/qa/unit/data/xml/shapes-test_page2.xml +++ b/sd/qa/unit/data/xml/shapes-test_page2.xml @@ -577,7 +577,7 @@ <PropertyValue name="Handles" handle="0" propertyState="DIRECT_VALUE"/> </CustomShapeGeometry> </XShape> - <XShape positionX="23400" positionY="1400" sizeX="2800" sizeY="2600" type="com.sun.star.drawing.CustomShape" fontHeight="18.000000" fontColor="ffffffff" textAutoGrowHeight="true" textAutoGrowWidth="false" textContourFrame="false" textFitToSize="NONE" textHorizontalAdjust="BLOCK" textVerticalAdjust="TOP" textLeftDistance="250" textRightDistance="250" textUpperDistance="125" textLowerDistance="125" textMaximumFrameHeight="0" textMaximumFrameWidth="0" textMinimumFrameHeight="666" textMinimumFrameWidth="486" textAnimationAmount="0" textAnimationCount="0" textAnimationDelay="0" textAnimationDirection="LEFT" textAnimationKind="NONE" textAnimationStartInside="false" textAnimationStopInside="false" textWritingMode="LR_TB" fillStyle="SOLID" fillColor="cfe7f5" fillTransparence="0" fillTransparenceGradientName=""> + <XShape positionX="23400" positionY="1400" sizeX="2800" sizeY="2600" type="com.sun.star.drawing.CustomShape" fontHeight="18.000000" fontColor="ffffffff" textAutoGrowHeight="true" textAutoGrowWidth="false" textContourFrame="false" textFitToSize="NONE" textHorizontalAdjust="BLOCK" textVerticalAdjust="TOP" textLeftDistance="250" textRightDistance="250" textUpperDistance="125" textLowerDistance="125" 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="cfe7f5" fillTransparence="0" fillTransparenceGradientName=""> <FillTransparenceGradient style="LINEAR" startColor="000000" endColor="ffffff" 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"/> commit 120e469d176026ceb59abbf74d2ad255323cbc9a Author: Armin Le Grand <[email protected]> Date: Thu Sep 19 10:11:03 2013 +0000 i#115391 better support for MinTextSize settings ... for TextShapes and CustomShapes Conflicts: include/svx/svdotext.hxx svx/source/sdr/properties/customshapeproperties.cxx svx/source/svdraw/svdoashp.cxx svx/source/svdraw/svdotext.cxx svx/source/svdraw/svdotxdr.cxx svx/source/svdraw/svdotxtr.cxx Change-Id: Ie6f490801b6887568135ed5f83c8bbe7ab6daa08 diff --git a/include/svx/sdr/properties/customshapeproperties.hxx b/include/svx/sdr/properties/customshapeproperties.hxx index 23a0181..d92db87 100644 --- a/include/svx/sdr/properties/customshapeproperties.hxx +++ b/include/svx/sdr/properties/customshapeproperties.hxx @@ -45,6 +45,10 @@ namespace sdr // react on Item change virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem); + // Called after ItemChange() is done for all items. Allows local reactions on + // specific item changes + virtual void PostItemChange(const sal_uInt16 nWhich); + // clear single item virtual void ClearObjectItem(const sal_uInt16 nWhich = 0); diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx index be3c7a7..00b4afe 100644 --- a/include/svx/svdoashp.hxx +++ b/include/svx/svdoashp.hxx @@ -130,6 +130,10 @@ public: static basegfx::B2DPolyPolygon GetLineGeometry( const SdrObjCustomShape* pCustomShape, const bool bBezierAllowed ); protected: + // #115391# new method for SdrObjCustomShape and SdrTextObj to correctly handle and set + // SdrTextMinFrameWidthItem and SdrTextMinFrameHeightItem based on all settings, necessities + // and object sizes + virtual void AdaptTextMinSize(); OUString aName; diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index 91a935c..8e184c3 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -290,8 +290,16 @@ protected: virtual void SaveGeoData(SdrObjGeoData& rGeo) const; virtual void RestGeoData(const SdrObjGeoData& rGeo); bool NbcSetEckenradius(long nRad); - bool NbcSetMinTextFrameHeight(long nHgt); - bool NbcSetMinTextFrameWidth(long nWdt); + bool NbcSetAutoGrowHeight(bool bAuto); + bool NbcSetMaxTextFrameHeight(long nHgt); + bool NbcSetAutoGrowWidth(bool bAuto); + bool NbcSetMaxTextFrameWidth(long nWdt); + bool NbcSetFitToSize(SdrFitToSizeType eFit); + + // #115391# new method for SdrObjCustomShape and SdrTextObj to correctly handle and set + // SdrTextMinFrameWidthItem and SdrTextMinFrameHeightItem based on all settings, necessities + // and object sizes + virtual void AdaptTextMinSize(); // Konstruktoren fuer beschriftete Zeichenobjekte SdrTextObj(); diff --git a/svx/source/sdr/properties/customshapeproperties.cxx b/svx/source/sdr/properties/customshapeproperties.cxx index 13f167c..35b4d07 100644 --- a/svx/source/sdr/properties/customshapeproperties.cxx +++ b/svx/source/sdr/properties/customshapeproperties.cxx @@ -34,13 +34,19 @@ namespace sdr { void CustomShapeProperties::UpdateTextFrameStatus() { - SdrTextObj& rObj = (SdrTextObj&)GetSdrObject(); - SdrTextAutoGrowHeightItem& rAutoGrowHeightItem = - (SdrTextAutoGrowHeightItem&)rObj.GetMergedItem( SDRATTR_TEXT_AUTOGROWHEIGHT ); - rObj.bTextFrame = rAutoGrowHeightItem.GetValue(); + SdrObjCustomShape& rObj = static_cast< SdrObjCustomShape& >(GetSdrObject()); + const bool bOld(rObj.bTextFrame); - if ( rObj.bTextFrame ) - rObj.NbcAdjustTextFrameWidthAndHeight(); + rObj.bTextFrame = 0 != static_cast< const SdrTextAutoGrowHeightItem& >(GetObjectItemSet().Get(SDRATTR_TEXT_AUTOGROWHEIGHT)).GetValue(); + + if(rObj.bTextFrame != bOld) + { + rObj.InvalidateRenderGeometry(); + + // #115391# Potential recursion, since it calls SetObjectItemSet again, but rObj.bTextFrame + // will not change again, thus it will be only one level and terminate + rObj.AdaptTextMinSize(); + } } SfxItemSet& CustomShapeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) @@ -67,6 +73,7 @@ namespace sdr // end 0, 0)); } + bool CustomShapeProperties::AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem ) const { sal_Bool bAllowItemChange = sal_True; @@ -79,6 +86,7 @@ namespace sdr bAllowItemChange = TextProperties::AllowItemChange( nWhich, pNewItem ); return bAllowItemChange; } + void CustomShapeProperties::ClearObjectItem(const sal_uInt16 nWhich) { if ( !nWhich ) @@ -96,6 +104,7 @@ namespace sdr else TextProperties::ClearObjectItem( nWhich ); } + void CustomShapeProperties::ClearObjectItemDirect(const sal_uInt16 nWhich) { if ( !nWhich ) @@ -111,66 +120,63 @@ namespace sdr else TextProperties::ClearObjectItemDirect( nWhich ); } + void CustomShapeProperties::ItemSetChanged(const SfxItemSet& rSet) { - SdrObjCustomShape& rObj = (SdrObjCustomShape&)GetSdrObject(); + // call parent + TextProperties::ItemSetChanged(rSet); + + // update bTextFrame and RenderGeometry + UpdateTextFrameStatus(); + } - if( SFX_ITEM_SET == rSet.GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) ) + void CustomShapeProperties::PostItemChange(const sal_uInt16 nWhich) + { + switch(nWhich) { - rObj.bTextFrame = ((SdrTextAutoGrowHeightItem&)rSet.Get( SDRATTR_TEXT_AUTOGROWHEIGHT )).GetValue(); + case SDRATTR_TEXT_AUTOGROWHEIGHT: + { + // #115391# update bTextFrame and RenderGeometry using AdaptTextMinSize() + UpdateTextFrameStatus(); + break; + } + default: + { + break; + } } // call parent - TextProperties::ItemSetChanged(rSet); - - // local changes, removing cached objects - rObj.InvalidateRenderGeometry(); + TextProperties::PostItemChange(nWhich); } + void CustomShapeProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem) { - SdrObjCustomShape& rObj = (SdrObjCustomShape&)GetSdrObject(); - //OutlinerParaObject* pParaObj = rObj.GetOutlinerParaObject(); - - if( pNewItem && ( SDRATTR_TEXT_AUTOGROWHEIGHT == nWhich ) ) - { - rObj.bTextFrame = ((SdrTextAutoGrowHeightItem*)pNewItem)->GetValue(); - } // call parent TextProperties::ItemChange( nWhich, pNewItem ); - rObj.InvalidateRenderGeometry(); + // update bTextFrame and RenderGeometry + UpdateTextFrameStatus(); } + void CustomShapeProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr) { + // call parent TextProperties::SetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr ); + + // update bTextFrame and RenderGeometry UpdateTextFrameStatus(); } + void CustomShapeProperties::ForceDefaultAttributes() { + // update bTextFrame and RenderGeometry UpdateTextFrameStatus(); -/* SJ: Following is no good if creating customshapes, leading to objects that are white after loading via xml - - SdrTextObj& rObj = (SdrTextObj&)GetSdrObject(); - sal_Bool bTextFrame(rObj.IsTextFrame()); - - // force ItemSet - GetObjectItemSet(); - - if(bTextFrame) - { - mpItemSet->Put(XLineStyleItem(XLINE_NONE)); - mpItemSet->Put(XFillColorItem(String(), Color(COL_WHITE))); - mpItemSet->Put(XFillStyleItem(XFILL_NONE)); - } - else - { - mpItemSet->Put(SvxAdjustItem(SVX_ADJUST_CENTER)); - mpItemSet->Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER)); - mpItemSet->Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); - } -*/ + // SJ: Following is no good if creating customshapes, leading to objects that are white after loading via xml + // This means: Do *not* call parent here is by purpose... } + CustomShapeProperties::CustomShapeProperties(SdrObject& rObj) : TextProperties(rObj) { @@ -189,14 +195,15 @@ namespace sdr { return *(new CustomShapeProperties(*this, rObj)); } + void CustomShapeProperties::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { TextProperties::Notify( rBC, rHint ); sal_Bool bRemoveRenderGeometry = sal_False; - const SfxStyleSheetHint *pStyleHint = PTR_CAST( SfxStyleSheetHint, &rHint ); const SfxSimpleHint *pSimpleHint = PTR_CAST( SfxSimpleHint, &rHint ); + if ( pStyleHint && pStyleHint->GetStyleSheet() == GetStyleSheet() ) { switch( pStyleHint->GetHint() ) @@ -211,15 +218,12 @@ namespace sdr { bRemoveRenderGeometry = sal_True; } + if ( bRemoveRenderGeometry ) { + // update bTextFrame and RenderGeometry UpdateTextFrameStatus(); - - // local changes, removing cached objects - SdrObjCustomShape& rObj = (SdrObjCustomShape&)GetSdrObject(); - rObj.InvalidateRenderGeometry(); } - } } // end of namespace properties } // end of namespace sdr diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index dee5960..6ced8d6 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -1443,27 +1443,60 @@ const Rectangle& SdrObjCustomShape::GetLogicRect() const { return SdrTextObj::GetLogicRect(); } -void SdrObjCustomShape::NbcSetSnapRect( const Rectangle& rRect ) + +// #115391# This implementation is based on the TextFrame size of the CustomShape and the +// state of the ResizeShapeToFitText flag to correctly set TextMinFrameWidth/Height +void SdrObjCustomShape::AdaptTextMinSize() { - aRect=rRect; - ImpJustifyRect(aRect); - InvalidateRenderGeometry(); - Rectangle aTextBound( aRect ); - if ( GetTextBounds( aTextBound ) ) + if(!pModel || !pModel->IsPasteResize()) { - if ( pModel==NULL || !pModel->IsPasteResize() ) + const bool bResizeShapeToFitText(0 != static_cast< const SdrTextAutoGrowHeightItem& >(GetObjectItem(SDRATTR_TEXT_AUTOGROWHEIGHT)).GetValue()); + SfxItemSet aSet(GetObjectItemSet()); + bool bChanged(false); + + if(bResizeShapeToFitText) { - long nHDist=GetTextLeftDistance()+GetTextRightDistance(); - long nVDist=GetTextUpperDistance()+GetTextLowerDistance(); - long nTWdt=aTextBound.GetWidth ()-1-nHDist; if (nTWdt<0) nTWdt=0; - long nTHgt=aTextBound.GetHeight()-1-nVDist; if (nTHgt<0) nTHgt=0; - if ( IsAutoGrowWidth() ) - NbcSetMinTextFrameWidth( nTWdt ); - if ( IsAutoGrowHeight() ) - NbcSetMinTextFrameHeight( nTHgt ); + // always reset MinWidthHeight to zero to only rely on text size and frame size + // to allow resizing being completely dependent on text size only + aSet.Put(SdrTextMinFrameWidthItem(0)); + aSet.Put(SdrTextMinFrameHeightItem(0)); + bChanged = true; + } + else + { + // recreate from CustomShape-specific TextBounds + Rectangle aTextBound(aRect); + + if(GetTextBounds(aTextBound)) + { + const long nHDist(GetTextLeftDistance() + GetTextRightDistance()); + const long nVDist(GetTextUpperDistance() + GetTextLowerDistance()); + const long nTWdt(std::max(long(0), (long)(aTextBound.GetWidth() - 1 - nHDist))); + const long nTHgt(std::max(long(0), (long)(aTextBound.GetHeight() - 1 - nVDist))); + + aSet.Put(SdrTextMinFrameWidthItem(nTWdt)); + aSet.Put(SdrTextMinFrameHeightItem(nTHgt)); + bChanged = true; + } + } + + if(bChanged) + { + SetObjectItemSet(aSet); NbcAdjustTextFrameWidthAndHeight(); } } +} + +void SdrObjCustomShape::NbcSetSnapRect( const Rectangle& rRect ) +{ + aRect=rRect; + ImpJustifyRect(aRect); + InvalidateRenderGeometry(); + + // #115391# + AdaptTextMinSize(); + ImpCheckShear(); SetRectsDirty(); SetChanged(); @@ -1482,20 +1515,10 @@ void SdrObjCustomShape::NbcSetLogicRect( const Rectangle& rRect ) aRect = rRect; ImpJustifyRect( aRect ); InvalidateRenderGeometry(); - Rectangle aTextBound( aRect ); - if ( GetTextBounds( aTextBound ) ) - { - long nHDist=GetTextLeftDistance()+GetTextRightDistance(); - long nVDist=GetTextUpperDistance()+GetTextLowerDistance(); - long nTWdt=aTextBound.GetWidth()-1-nHDist; if (nTWdt<0) nTWdt=0; - long nTHgt=aTextBound.GetHeight()-1-nVDist; if (nTHgt<0) nTHgt=0; - if ( IsAutoGrowWidth() ) - NbcSetMinTextFrameWidth( nTWdt ); - if ( IsAutoGrowHeight() ) - NbcSetMinTextFrameHeight( nTHgt ); - NbcAdjustTextFrameWidthAndHeight(); - } + // #115391# + AdaptTextMinSize(); + SetRectsDirty(); SetChanged(); } @@ -2197,25 +2220,9 @@ bool SdrObjCustomShape::EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd ) { DragCreateObject( rStat ); - if ( bTextFrame ) - { - if ( IsAutoGrowHeight() ) - { - // MinTextHeight - long nHgt=aRect.GetHeight()-1; - if (nHgt==1) nHgt=0; - NbcSetMinTextFrameHeight( nHgt ); - } - if ( IsAutoGrowWidth() ) - { - // MinTextWidth - long nWdt=aRect.GetWidth()-1; - if (nWdt==1) nWdt=0; - NbcSetMinTextFrameWidth( nWdt ); - } - // re-calculate text frame - NbcAdjustTextFrameWidthAndHeight(); - } + // #115391# + AdaptTextMinSize(); + SetRectsDirty(); return ( eCmd == SDRCREATE_FORCEEND || rStat.GetPointAnz() >= 2 ); } diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 214f22a..5c24ec0 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -542,39 +542,98 @@ bool SdrTextObj::NbcSetEckenradius(long nRad) return true; } -bool SdrTextObj::NbcSetMinTextFrameHeight(long nHgt) +bool SdrTextObj::NbcSetAutoGrowHeight(bool bAuto) { - if( bTextFrame && ( !pModel || !pModel->isLocked() ) ) // #i44922# + if(bTextFrame) { - SetObjectItem(SdrTextMinFrameHeightItem(nHgt)); - - // use bDisableAutoWidthOnDragging as - // bDisableAutoHeightOnDragging if vertical. - if(IsVerticalWriting() && bDisableAutoWidthOnDragging) - { - bDisableAutoWidthOnDragging = false; - SetObjectItem(SdrTextAutoGrowHeightItem(false)); - } + SetObjectItem(SdrTextAutoGrowHeightItem(bAuto)); + return true; + } + return false; +} +bool SdrTextObj::NbcSetMaxTextFrameHeight(long nHgt) +{ + if(bTextFrame) + { + SetObjectItem(SdrTextMaxFrameHeightItem(nHgt)); return true; } return false; } -bool SdrTextObj::NbcSetMinTextFrameWidth(long nWdt) +// #115391# This implementation is based on the object size (aRect) and the +// states of IsAutoGrowWidth/Height to correctly set TextMinFrameWidth/Height +void SdrTextObj::AdaptTextMinSize() { - if( bTextFrame && ( !pModel || !pModel->isLocked() ) ) // #i44922# + if(bTextFrame && (!pModel || !pModel->isLocked())) { - SetObjectItem(SdrTextMinFrameWidthItem(nWdt)); + const bool bW(IsAutoGrowWidth()); + const bool bH(IsAutoGrowHeight()); - // use bDisableAutoWidthOnDragging only - // when not vertical. - if(!IsVerticalWriting() && bDisableAutoWidthOnDragging) + if(bW || bH) { - bDisableAutoWidthOnDragging = false; - SetObjectItem(SdrTextAutoGrowWidthItem(false)); + SfxItemSet aSet(GetObjectItemSet()); + + if(bW) + { + const long nDist(GetTextLeftDistance() + GetTextRightDistance()); + const long nW(std::max(long(0), (long)(aRect.GetWidth() - 1 - nDist))); + + aSet.Put(SdrTextMinFrameWidthItem(nW)); + + if(!IsVerticalWriting() && bDisableAutoWidthOnDragging) + { + bDisableAutoWidthOnDragging = true; + aSet.Put(SdrTextAutoGrowWidthItem(false)); + } + } + + if(bH) + { + const long nDist(GetTextUpperDistance() + GetTextLowerDistance()); + const long nH(std::max(long(0), (long)(aRect.GetHeight() - 1 - nDist))); + + aSet.Put(SdrTextMinFrameHeightItem(nH)); + + if(IsVerticalWriting() && bDisableAutoWidthOnDragging) + { + bDisableAutoWidthOnDragging = false; + SetObjectItem(SdrTextAutoGrowHeightItem(false)); + } + } + + SetObjectItemSet(aSet); + NbcAdjustTextFrameWidthAndHeight(); } + } +} +bool SdrTextObj::NbcSetAutoGrowWidth(bool bAuto) +{ + if(bTextFrame) + { + SetObjectItem(SdrTextAutoGrowWidthItem(bAuto)); + return true; + } + return false; +} + +bool SdrTextObj::NbcSetMaxTextFrameWidth(long nWdt) +{ + if(bTextFrame) + { + SetObjectItem(SdrTextMaxFrameWidthItem(nWdt)); + return true; + } + return false; +} + +bool SdrTextObj::NbcSetFitToSize(SdrFitToSizeType eFit) +{ + if(bTextFrame) + { + SetObjectItem(SdrTextFitToSizeTypeItem(eFit)); return true; } return false; diff --git a/svx/source/svdraw/svdotxdr.cxx b/svx/source/svdraw/svdotxdr.cxx index 7e81766..cd98685 100644 --- a/svx/source/svdraw/svdotxdr.cxx +++ b/svx/source/svdraw/svdotxdr.cxx @@ -210,22 +210,10 @@ bool SdrTextObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) { rStat.TakeCreateRect(aRect); ImpJustifyRect(aRect); - if (bTextFrame) { - if (IsAutoGrowHeight()) { - // MinTextHeight - long nHgt=aRect.GetHeight()-1; - if (nHgt==1) nHgt=0; - NbcSetMinTextFrameHeight(nHgt); - } - if (IsAutoGrowWidth()) { - // MinTextWidth - long nWdt=aRect.GetWidth()-1; - if (nWdt==1) nWdt=0; - NbcSetMinTextFrameWidth(nWdt); - } - // re-calculate text frame - NbcAdjustTextFrameWidthAndHeight(); - } + + // #115391# + AdaptTextMinSize(); + SetRectsDirty(); if (HAS_BASE(SdrRectObj,this)) { ((SdrRectObj*)this)->SetXPolyDirty(); diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx index 409af9f..a0267dd 100644 --- a/svx/source/svdraw/svdotxtr.cxx +++ b/svx/source/svdraw/svdotxtr.cxx @@ -58,11 +58,15 @@ void SdrTextObj::NbcSetSnapRect(const Rectangle& rRect) long nTHgt1=rRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0; aRect=rRect; ImpJustifyRect(aRect); - if (bTextFrame && (pModel==NULL || !pModel->IsPasteResize())) { - if (nTWdt0!=nTWdt1 && IsAutoGrowWidth() ) NbcSetMinTextFrameWidth(nTWdt1); - if (nTHgt0!=nTHgt1 && IsAutoGrowHeight()) NbcSetMinTextFrameHeight(nTHgt1); + + // #115391# + AdaptTextMinSize(); + + if (bTextFrame && (pModel==NULL || !pModel->IsPasteResize())) + { NbcAdjustTextFrameWidthAndHeight(); } + ImpCheckShear(); SetRectsDirty(); } @@ -83,11 +87,15 @@ void SdrTextObj::NbcSetLogicRect(const Rectangle& rRect) long nTHgt1=rRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0; aRect=rRect; ImpJustifyRect(aRect); - if (bTextFrame) { - if (nTWdt0!=nTWdt1 && IsAutoGrowWidth() ) NbcSetMinTextFrameWidth(nTWdt1); - if (nTHgt0!=nTHgt1 && IsAutoGrowHeight()) NbcSetMinTextFrameHeight(nTHgt1); + + // #115391# + AdaptTextMinSize(); + + if(bTextFrame) + { NbcAdjustTextFrameWidthAndHeight(); } + SetRectsDirty(); } @@ -185,13 +193,18 @@ void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract } ImpJustifyRect(aRect); + long nTWdt1=aRect.GetWidth ()-1-nHDist; if (nTWdt1<0) nTWdt1=0; long nTHgt1=aRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0; - if (bTextFrame && (pModel==NULL || !pModel->IsPasteResize())) { - if (nTWdt0!=nTWdt1 && IsAutoGrowWidth() ) NbcSetMinTextFrameWidth(nTWdt1); - if (nTHgt0!=nTHgt1 && IsAutoGrowHeight()) NbcSetMinTextFrameHeight(nTHgt1); + + // #115391# + AdaptTextMinSize(); + + if(bTextFrame && (!pModel || !pModel->IsPasteResize())) + { NbcAdjustTextFrameWidthAndHeight(); } + ImpCheckShear(); SetRectsDirty(); } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
