summaryrefslogtreecommitdiff
path: root/svx/source/svdraw
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source/svdraw')
-rw-r--r--svx/source/svdraw/svdoashp.cxx101
-rw-r--r--svx/source/svdraw/svdotext.cxx97
-rw-r--r--svx/source/svdraw/svdotxdr.cxx20
-rw-r--r--svx/source/svdraw/svdotxtr.cxx31
4 files changed, 158 insertions, 91 deletions
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index dee596023efa..6ced8d646ac1 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 214f22af597f..5c24ec0848ea 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 7e81766c2e90..cd9868553c09 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 409af9f24c07..a0267ddae4ca 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();
}