Author: alg
Date: Thu Sep 19 10:11:03 2013
New Revision: 1524675

URL: http://svn.apache.org/r1524675
Log:
i115391 better support for MinTextSize settings for TextShapes and CustomShapes

Modified:
    openoffice/trunk/main/svx/inc/svx/sdr/properties/customshapeproperties.hxx
    openoffice/trunk/main/svx/inc/svx/svdoashp.hxx
    openoffice/trunk/main/svx/inc/svx/svdotext.hxx
    openoffice/trunk/main/svx/source/sdr/properties/customshapeproperties.cxx
    openoffice/trunk/main/svx/source/svdraw/svdoashp.cxx
    openoffice/trunk/main/svx/source/svdraw/svdotext.cxx
    openoffice/trunk/main/svx/source/svdraw/svdotxdr.cxx
    openoffice/trunk/main/svx/source/svdraw/svdotxtr.cxx

Modified: 
openoffice/trunk/main/svx/inc/svx/sdr/properties/customshapeproperties.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/sdr/properties/customshapeproperties.hxx?rev=1524675&r1=1524674&r2=1524675&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/svx/sdr/properties/customshapeproperties.hxx 
(original)
+++ openoffice/trunk/main/svx/inc/svx/sdr/properties/customshapeproperties.hxx 
Thu Sep 19 10:11:03 2013
@@ -49,6 +49,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);
 

Modified: openoffice/trunk/main/svx/inc/svx/svdoashp.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/svdoashp.hxx?rev=1524675&r1=1524674&r2=1524675&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/svx/svdoashp.hxx (original)
+++ openoffice/trunk/main/svx/inc/svx/svdoashp.hxx Thu Sep 19 10:11:03 2013
@@ -131,6 +131,10 @@ public:
        static basegfx::B2DPolyPolygon GetLineGeometry( const 
SdrObjCustomShape* pCustomShape, const sal_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();
 
        String          aName;
 

Modified: openoffice/trunk/main/svx/inc/svx/svdotext.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/svdotext.hxx?rev=1524675&r1=1524674&r2=1524675&view=diff
==============================================================================
--- openoffice/trunk/main/svx/inc/svx/svdotext.hxx (original)
+++ openoffice/trunk/main/svx/inc/svx/svdotext.hxx Thu Sep 19 10:11:03 2013
@@ -289,13 +289,16 @@ protected:
        virtual void RestGeoData(const SdrObjGeoData& rGeo);
        FASTBOOL NbcSetEckenradius(long nRad);
        FASTBOOL NbcSetAutoGrowHeight(bool bAuto);
-       FASTBOOL NbcSetMinTextFrameHeight(long nHgt);
        FASTBOOL NbcSetMaxTextFrameHeight(long nHgt);
        FASTBOOL NbcSetAutoGrowWidth(bool bAuto);
-       FASTBOOL NbcSetMinTextFrameWidth(long nWdt);
        FASTBOOL NbcSetMaxTextFrameWidth(long nWdt);
        FASTBOOL 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();
        SdrTextObj(const Rectangle& rNewRect);

Modified: 
openoffice/trunk/main/svx/source/sdr/properties/customshapeproperties.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/sdr/properties/customshapeproperties.cxx?rev=1524675&r1=1524674&r2=1524675&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/sdr/properties/customshapeproperties.cxx 
(original)
+++ openoffice/trunk/main/svx/source/sdr/properties/customshapeproperties.cxx 
Thu Sep 19 10:11:03 2013
@@ -37,198 +37,202 @@
 
 namespace sdr
 {
-       namespace properties
-       {
-               void CustomShapeProperties::UpdateTextFrameStatus()
-               {
-                       SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
-                       SdrTextAutoGrowHeightItem& rAutoGrowHeightItem =
-                               (SdrTextAutoGrowHeightItem&)rObj.GetMergedItem( 
SDRATTR_TEXT_AUTOGROWHEIGHT );
-                       rObj.bTextFrame = rAutoGrowHeightItem.GetValue() != 0;
-
-                       if ( rObj.bTextFrame )
-                               rObj.NbcAdjustTextFrameWidthAndHeight();
-               }
-
-               SfxItemSet& 
CustomShapeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
-               {
-                       return *(new SfxItemSet(rPool,
-
-                               // ranges from SdrAttrObj
-                               SDRATTR_START, SDRATTR_SHADOW_LAST,
-                               SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
-                               SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
-
-                               // Graphic Attributes
-                               SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
-
-                               // 3d Properties
-                               SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
-
-                               // CustomShape properties
-                               SDRATTR_CUSTOMSHAPE_FIRST, 
SDRATTR_CUSTOMSHAPE_LAST,
-
-                               // range from SdrTextObj
-                               EE_ITEMS_START, EE_ITEMS_END,
-
-                               // end
-                               0, 0));
-               }
-               sal_Bool CustomShapeProperties::AllowItemChange(const 
sal_uInt16 nWhich, const SfxPoolItem* pNewItem ) const
-               {
-                       sal_Bool bAllowItemChange = sal_True;
-                       if ( !pNewItem )
-                       {
-                               if ( ( nWhich >= SDRATTR_CUSTOMSHAPE_FIRST ) && 
( nWhich <= SDRATTR_CUSTOMSHAPE_LAST ) )
-                                       bAllowItemChange = sal_False;
-                       }
-                       if ( bAllowItemChange )
-                               bAllowItemChange = 
TextProperties::AllowItemChange( nWhich, pNewItem );
-                       return bAllowItemChange;
-               }
-               void CustomShapeProperties::ClearObjectItem(const sal_uInt16 
nWhich)
-               {
-                       if ( !nWhich )
-                       {
-                               SfxWhichIter aIter( *mpItemSet );
-                               sal_uInt16 nWhich2 = aIter.FirstWhich();
-                               while( nWhich2 )
-                               {
-                                       TextProperties::ClearObjectItemDirect( 
nWhich2 );
-                                       nWhich2 = aIter.NextWhich();
-                               }
-                               SfxItemSet 
aSet((SfxItemPool&)(*GetSdrObject().GetObjectItemPool()));
-                               ItemSetChanged(aSet);
-                       }
-                       else
-                               TextProperties::ClearObjectItem( nWhich );
-               }
-               void CustomShapeProperties::ClearObjectItemDirect(const 
sal_uInt16 nWhich)
-               {
-                       if ( !nWhich )
-                       {
-                               SfxWhichIter aIter( *mpItemSet );
-                               sal_uInt16 nWhich2 = aIter.FirstWhich();
-                               while( nWhich2 )
-                               {
-                                       TextProperties::ClearObjectItemDirect( 
nWhich2 );
-                                       nWhich2 = aIter.NextWhich();
-                               }
-                       }
-                       else
-                               TextProperties::ClearObjectItemDirect( nWhich );
-               }
-               void CustomShapeProperties::ItemSetChanged(const SfxItemSet& 
rSet)
-               {
-                       SdrObjCustomShape& rObj = 
(SdrObjCustomShape&)GetSdrObject();
-
-                       if( SFX_ITEM_SET == rSet.GetItemState( 
SDRATTR_TEXT_AUTOGROWHEIGHT ) )
-                       {
-                               rObj.bTextFrame = 
((SdrTextAutoGrowHeightItem&)rSet.Get( SDRATTR_TEXT_AUTOGROWHEIGHT 
)).GetValue() != 0;
-                       }
-
-                       // call parent
-                       TextProperties::ItemSetChanged(rSet);
-
-                       // local changes, removing cached objects
-                       rObj.InvalidateRenderGeometry();
-               }
-               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() != 0;
-                       }
-                       // call parent
-                       TextProperties::ItemChange( nWhich, pNewItem );
-
-                       rObj.InvalidateRenderGeometry();
-               }
-               void CustomShapeProperties::SetStyleSheet(SfxStyleSheet* 
pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
-               {
-                       TextProperties::SetStyleSheet( pNewStyleSheet, 
bDontRemoveHardAttr );
-                       UpdateTextFrameStatus();
-               }
-               void CustomShapeProperties::ForceDefaultAttributes()
-               {
-                       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));
-                       }
-*/
-               }
-               CustomShapeProperties::CustomShapeProperties(SdrObject& rObj)
-               :       TextProperties(rObj)
-               {
-               }
-
-               CustomShapeProperties::CustomShapeProperties(const 
CustomShapeProperties& rProps, SdrObject& rObj)
-               :       TextProperties(rProps, rObj)
-               {
-               }
-
-               CustomShapeProperties::~CustomShapeProperties()
-               {
-               }
-
-               BaseProperties& CustomShapeProperties::Clone(SdrObject& rObj) 
const
-               {
-                       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() )
-                               {
-                                       case SFX_STYLESHEET_MODIFIED :
-                                       case SFX_STYLESHEET_CHANGED      :
-                                               bRemoveRenderGeometry = 
sal_True;
-                                       break;
-                               };
-                       }
-                       else if ( pSimpleHint && pSimpleHint->GetId() == 
SFX_HINT_DATACHANGED )
-                       {
-                               bRemoveRenderGeometry = sal_True;
-                       }
-                       if ( bRemoveRenderGeometry )
-                       {
-                               UpdateTextFrameStatus();
-
-                               // local changes, removing cached objects
-                               SdrObjCustomShape& rObj = 
(SdrObjCustomShape&)GetSdrObject();
-                               rObj.InvalidateRenderGeometry();
-                       }
-
-               }
-       } // end of namespace properties
+    namespace properties
+    {
+        void CustomShapeProperties::UpdateTextFrameStatus()
+        {
+            SdrObjCustomShape& rObj = static_cast< SdrObjCustomShape& 
>(GetSdrObject());
+            const bool bOld(rObj.bTextFrame);
+
+            rObj.bTextFrame = 0 != static_cast< const 
SdrTextAutoGrowHeightItem& 
>(GetObjectItemSet().Get(SDRATTR_TEXT_AUTOGROWHEIGHT)).GetValue();
+
+            if(rObj.bTextFrame != bOld)
+            {
+                rObj.InvalidateRenderGeometry();
+
+                // #115391# Potential recursuin, 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)
+        {
+            return *(new SfxItemSet(rPool,
+
+                // ranges from SdrAttrObj
+                SDRATTR_START, SDRATTR_SHADOW_LAST,
+                SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+                SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
+
+                // Graphic Attributes
+                SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
+
+                // 3d Properties
+                SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
+
+                // CustomShape properties
+                SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
+
+                // range from SdrTextObj
+                EE_ITEMS_START, EE_ITEMS_END,
+
+                // end
+                0, 0));
+        }
+
+        sal_Bool CustomShapeProperties::AllowItemChange(const sal_uInt16 
nWhich, const SfxPoolItem* pNewItem ) const
+        {
+            sal_Bool bAllowItemChange = sal_True;
+            if ( !pNewItem )
+            {
+                if ( ( nWhich >= SDRATTR_CUSTOMSHAPE_FIRST ) && ( nWhich <= 
SDRATTR_CUSTOMSHAPE_LAST ) )
+                    bAllowItemChange = sal_False;
+            }
+            if ( bAllowItemChange )
+                bAllowItemChange = TextProperties::AllowItemChange( nWhich, 
pNewItem );
+            return bAllowItemChange;
+        }
+
+        void CustomShapeProperties::ClearObjectItem(const sal_uInt16 nWhich)
+        {
+            if ( !nWhich )
+            {
+                SfxWhichIter aIter( *mpItemSet );
+                sal_uInt16 nWhich2 = aIter.FirstWhich();
+                while( nWhich2 )
+                {
+                    TextProperties::ClearObjectItemDirect( nWhich2 );
+                    nWhich2 = aIter.NextWhich();
+                }
+                SfxItemSet 
aSet((SfxItemPool&)(*GetSdrObject().GetObjectItemPool()));
+                ItemSetChanged(aSet);
+            }
+            else
+                TextProperties::ClearObjectItem( nWhich );
+        }
+
+        void CustomShapeProperties::ClearObjectItemDirect(const sal_uInt16 
nWhich)
+        {
+            if ( !nWhich )
+            {
+                SfxWhichIter aIter( *mpItemSet );
+                sal_uInt16 nWhich2 = aIter.FirstWhich();
+                while( nWhich2 )
+                {
+                    TextProperties::ClearObjectItemDirect( nWhich2 );
+                    nWhich2 = aIter.NextWhich();
+                }
+            }
+            else
+                TextProperties::ClearObjectItemDirect( nWhich );
+        }
+
+        void CustomShapeProperties::ItemSetChanged(const SfxItemSet& rSet)
+        {
+            // call parent
+            TextProperties::ItemSetChanged(rSet);
+
+            // update bTextFrame and RenderGeometry
+            UpdateTextFrameStatus();
+        }
+
+        void CustomShapeProperties::PostItemChange(const sal_uInt16 nWhich)
+        {
+            switch(nWhich)
+            {
+                case SDRATTR_TEXT_AUTOGROWHEIGHT:
+                {
+                    // #115391#  update bTextFrame and RenderGeometry using 
AdaptTextMinSize()
+                    UpdateTextFrameStatus();
+                    break;
+                }
+                default:
+                {
+                    break;
+                }
+            }
+
+            // call parent
+            TextProperties::PostItemChange(nWhich);
+        }
+
+        void CustomShapeProperties::ItemChange(const sal_uInt16 nWhich, const 
SfxPoolItem* pNewItem)
+        {
+            // call parent
+            TextProperties::ItemChange( nWhich, pNewItem );
+
+            // update bTextFrame and RenderGeometry
+            UpdateTextFrameStatus();
+        }
+
+        void CustomShapeProperties::SetStyleSheet(SfxStyleSheet* 
pNewStyleSheet, sal_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
+            // This means: Do *not* call parent here is by purpose...
+        }
+
+        CustomShapeProperties::CustomShapeProperties(SdrObject& rObj)
+        :   TextProperties(rObj)
+        {
+        }
+
+        CustomShapeProperties::CustomShapeProperties(const 
CustomShapeProperties& rProps, SdrObject& rObj)
+        :   TextProperties(rProps, rObj)
+        {
+        }
+
+        CustomShapeProperties::~CustomShapeProperties()
+        {
+        }
+
+        BaseProperties& CustomShapeProperties::Clone(SdrObject& rObj) const
+        {
+            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() )
+                {
+                    case SFX_STYLESHEET_MODIFIED :
+                    case SFX_STYLESHEET_CHANGED         :
+                        bRemoveRenderGeometry = sal_True;
+                    break;
+                };
+            }
+            else if ( pSimpleHint && pSimpleHint->GetId() == 
SFX_HINT_DATACHANGED )
+            {
+                bRemoveRenderGeometry = sal_True;
+            }
+
+            if ( bRemoveRenderGeometry )
+            {
+                // update bTextFrame and RenderGeometry
+                UpdateTextFrameStatus();
+            }
+        }
+    } // end of namespace properties
 } // end of namespace sdr
 
 //////////////////////////////////////////////////////////////////////////////

Modified: openoffice/trunk/main/svx/source/svdraw/svdoashp.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/svdraw/svdoashp.cxx?rev=1524675&r1=1524674&r2=1524675&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/svdraw/svdoashp.cxx (original)
+++ openoffice/trunk/main/svx/source/svdraw/svdoashp.cxx Thu Sep 19 10:11:03 
2013
@@ -1719,27 +1719,61 @@ const Rectangle& SdrObjCustomShape::GetL
 {
        return SdrTextObj::GetLogicRect();
 }
+
+// #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()
+{
+    if(!pModel || !pModel->IsPasteResize())
+    {
+        const bool bResizeShapeToFitText(0 != static_cast< const 
SdrTextAutoGrowHeightItem& 
>(GetObjectItem(SDRATTR_TEXT_AUTOGROWHEIGHT)).GetValue());
+        SfxItemSet aSet(GetObjectItemSet());
+        bool bChanged(false);
+
+        if(bResizeShapeToFitText)
+        {
+            // 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)));
+                SfxItemSet aSet(GetObjectItemSet());
+
+                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();
-       Rectangle aTextBound( aRect );
-       if ( GetTextBounds( aTextBound ) )
-       {
-               if ( pModel==NULL || !pModel->IsPasteResize() )
-               {
-                       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();
+
        ImpCheckShear();
        SetRectsDirty();
        SetChanged();
@@ -1758,20 +1792,10 @@ void SdrObjCustomShape::NbcSetLogicRect(
        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();
 }
@@ -2485,29 +2509,13 @@ FASTBOOL SdrObjCustomShape::MovCreate(Sd
 
 FASTBOOL SdrObjCustomShape::EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd )
 {
-       DragCreateObject( rStat );
+    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 );
-               }
-               // Textrahmen neu berechnen
-               NbcAdjustTextFrameWidthAndHeight();
-       }
-       SetRectsDirty();
-       return ( eCmd == SDRCREATE_FORCEEND || rStat.GetPointAnz() >= 2 );
+    // #115391#
+    AdaptTextMinSize();
+
+    SetRectsDirty();
+    return ( eCmd == SDRCREATE_FORCEEND || rStat.GetPointAnz() >= 2 );
 }
 
 basegfx::B2DPolyPolygon SdrObjCustomShape::TakeCreatePoly(const SdrDragStat& 
/*rDrag*/) const

Modified: openoffice/trunk/main/svx/source/svdraw/svdotext.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/svdraw/svdotext.cxx?rev=1524675&r1=1524674&r2=1524675&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/svdraw/svdotext.cxx (original)
+++ openoffice/trunk/main/svx/source/svdraw/svdotext.cxx Thu Sep 19 10:11:03 
2013
@@ -644,23 +644,51 @@ FASTBOOL SdrTextObj::NbcSetAutoGrowHeigh
        return sal_False;
 }
 
-FASTBOOL SdrTextObj::NbcSetMinTextFrameHeight(long nHgt)
+// #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() ) )                  
// SJ: #i44922#
-       {
-               SetObjectItem(SdrTextMinFrameHeightItem(nHgt));
+    if(bTextFrame && (!pModel || !pModel->isLocked())) 
+    {
+        const bool bW(IsAutoGrowWidth());
+        const bool bH(IsAutoGrowHeight());
 
-               // #84974# use bDisableAutoWidthOnDragging as
-               // bDisableAutoHeightOnDragging if vertical.
-               if(IsVerticalWriting() && bDisableAutoWidthOnDragging)
-               {
-                       bDisableAutoWidthOnDragging = sal_False;
-                       SetObjectItem(SdrTextAutoGrowHeightItem(sal_False));
-               }
+        if(bW || bH)
+        {
+            SfxItemSet aSet(GetObjectItemSet());
 
-               return sal_True;
-       }
-       return sal_False;
+            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();
+        }
+    }
 }
 
 FASTBOOL SdrTextObj::NbcSetMaxTextFrameHeight(long nHgt)
@@ -683,25 +711,6 @@ FASTBOOL SdrTextObj::NbcSetAutoGrowWidth
        return sal_False;
 }
 
-FASTBOOL SdrTextObj::NbcSetMinTextFrameWidth(long nWdt)
-{
-       if( bTextFrame && ( !pModel || !pModel->isLocked() ) )                  
// SJ: #i44922#
-       {
-               SetObjectItem(SdrTextMinFrameWidthItem(nWdt));
-
-               // #84974# use bDisableAutoWidthOnDragging only
-               // when not vertical.
-               if(!IsVerticalWriting() && bDisableAutoWidthOnDragging)
-               {
-                       bDisableAutoWidthOnDragging = sal_False;
-                       SetObjectItem(SdrTextAutoGrowWidthItem(sal_False));
-               }
-
-               return sal_True;
-       }
-       return sal_False;
-}
-
 FASTBOOL SdrTextObj::NbcSetMaxTextFrameWidth(long nWdt)
 {
        if(bTextFrame)

Modified: openoffice/trunk/main/svx/source/svdraw/svdotxdr.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/svdraw/svdotxdr.cxx?rev=1524675&r1=1524674&r2=1524675&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/svdraw/svdotxdr.cxx (original)
+++ openoffice/trunk/main/svx/source/svdraw/svdotxdr.cxx Thu Sep 19 10:11:03 
2013
@@ -227,24 +227,12 @@ FASTBOOL SdrTextObj::MovCreate(SdrDragSt
 
 FASTBOOL 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);
-               }
-               // Textrahmen neu berechnen
-               NbcAdjustTextFrameWidthAndHeight();
-       }
+    rStat.TakeCreateRect(aRect);
+    ImpJustifyRect(aRect);
+
+    // #115391#
+    AdaptTextMinSize();
+
        SetRectsDirty();
        if (HAS_BASE(SdrRectObj,this)) {
                ((SdrRectObj*)this)->SetXPolyDirty();

Modified: openoffice/trunk/main/svx/source/svdraw/svdotxtr.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/svdraw/svdotxtr.cxx?rev=1524675&r1=1524674&r2=1524675&view=diff
==============================================================================
--- openoffice/trunk/main/svx/source/svdraw/svdotxtr.cxx (original)
+++ openoffice/trunk/main/svx/source/svdraw/svdotxtr.cxx Thu Sep 19 10:11:03 
2013
@@ -77,17 +77,23 @@ void SdrTextObj::NbcSetSnapRect(const Re
                long nTHgt1=rRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0;
                aRect=rRect;
                ImpJustifyRect(aRect);
-               if (bTextFrame && (pModel==NULL || !pModel->IsPasteResize())) { 
// #51139#
-                       if (nTWdt0!=nTWdt1 && IsAutoGrowWidth() ) 
NbcSetMinTextFrameWidth(nTWdt1);
-                       if (nTHgt0!=nTHgt1 && IsAutoGrowHeight()) 
NbcSetMinTextFrameHeight(nTHgt1);
-                       if (GetFitToSize()==SDRTEXTFIT_RESIZEATTR) {
-                               
NbcResizeTextAttributes(Fraction(nTWdt1,nTWdt0),Fraction(nTHgt1,nTHgt0));
-                       }
-                       NbcAdjustTextFrameWidthAndHeight();
-               }
-               ImpCheckShear();
-               SetRectsDirty();
-       }
+
+        // #115391#
+        AdaptTextMinSize();
+
+        if (bTextFrame && (pModel==NULL || !pModel->IsPasteResize())) 
+        { 
+            if(SDRTEXTFIT_RESIZEATTR == GetFitToSize()) 
+            {
+                
NbcResizeTextAttributes(Fraction(nTWdt1,nTWdt0),Fraction(nTHgt1,nTHgt0));
+            }
+
+            NbcAdjustTextFrameWidthAndHeight();
+        }
+
+        ImpCheckShear();
+        SetRectsDirty();
+    }
 }
 
 const Rectangle& SdrTextObj::GetLogicRect() const
@@ -105,15 +111,21 @@ void SdrTextObj::NbcSetLogicRect(const R
        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);
-               if (GetFitToSize()==SDRTEXTFIT_RESIZEATTR) {
-                       
NbcResizeTextAttributes(Fraction(nTWdt1,nTWdt0),Fraction(nTHgt1,nTHgt0));
-               }
-               NbcAdjustTextFrameWidthAndHeight();
-       }
-       SetRectsDirty();
+
+    // #115391#
+    AdaptTextMinSize();
+
+    if(bTextFrame) 
+    {
+        if(SDRTEXTFIT_RESIZEATTR == GetFitToSize()) 
+        {
+            
NbcResizeTextAttributes(Fraction(nTWdt1,nTWdt0),Fraction(nTHgt1,nTHgt0));
+        }
+
+        NbcAdjustTextFrameWidthAndHeight();
+    }
+
+    SetRectsDirty();
 }
 
 long SdrTextObj::GetRotateAngle() const
@@ -218,19 +230,26 @@ void SdrTextObj::NbcResize(const Point& 
                }
        }
 
-       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())) { // 
#51139#
-               if (nTWdt0!=nTWdt1 && IsAutoGrowWidth() ) 
NbcSetMinTextFrameWidth(nTWdt1);
-               if (nTHgt0!=nTHgt1 && IsAutoGrowHeight()) 
NbcSetMinTextFrameHeight(nTHgt1);
-               if (GetFitToSize()==SDRTEXTFIT_RESIZEATTR) {
-                       
NbcResizeTextAttributes(Fraction(nTWdt1,nTWdt0),Fraction(nTHgt1,nTHgt0));
-               }
-               NbcAdjustTextFrameWidthAndHeight();
-       }
-       ImpCheckShear();
-       SetRectsDirty();
+    ImpJustifyRect(aRect);
+
+    long nTWdt1=aRect.GetWidth ()-1-nHDist; if (nTWdt1<0) nTWdt1=0;
+    long nTHgt1=aRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0;
+
+    // #115391#
+    AdaptTextMinSize();
+
+    if(bTextFrame && (!pModel || !pModel->IsPasteResize())) 
+    { 
+        if(SDRTEXTFIT_RESIZEATTR == GetFitToSize()) 
+        {
+            
NbcResizeTextAttributes(Fraction(nTWdt1,nTWdt0),Fraction(nTHgt1,nTHgt0));
+        }
+
+        NbcAdjustTextFrameWidthAndHeight();
+    }
+
+    ImpCheckShear();
+    SetRectsDirty();
 }
 
 void SdrTextObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)


Reply via email to