SdrObjCustomShape::AdjustTextFrameWidthAndHeight: allow external text
So that in Writer, in case we're using Writer TextFrames to handle the content of a shape, it's still possible to inform the custom shape about the automatic size of the text, just like when native editeng text is used. Change-Id: I2534b942a9b2d62d7aa009ffbfa8d76feb011f92
This commit is contained in:
@@ -136,6 +136,7 @@ protected:
|
|||||||
virtual void AdaptTextMinSize() SAL_OVERRIDE;
|
virtual void AdaptTextMinSize() SAL_OVERRIDE;
|
||||||
|
|
||||||
OUString aName;
|
OUString aName;
|
||||||
|
Size m_aSuggestedTextFrameSize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -212,6 +213,12 @@ public:
|
|||||||
virtual bool MovCreate(SdrDragStat& rStat) SAL_OVERRIDE; // #i37448#
|
virtual bool MovCreate(SdrDragStat& rStat) SAL_OVERRIDE; // #i37448#
|
||||||
virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) SAL_OVERRIDE;
|
virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) SAL_OVERRIDE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows suggesting the text frame size: in case the application has its
|
||||||
|
* own text associated to the shape, instead of using the shape's editeng
|
||||||
|
* text.
|
||||||
|
*/
|
||||||
|
void SuggestTextFrameSize(Size aSuggestedTextFrameSize);
|
||||||
virtual bool AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt = true, bool bWdt = true) const SAL_OVERRIDE;
|
virtual bool AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt = true, bool bWdt = true) const SAL_OVERRIDE;
|
||||||
virtual bool NbcAdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt = true) SAL_OVERRIDE;
|
virtual bool NbcAdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt = true) SAL_OVERRIDE;
|
||||||
virtual bool AdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt = true) SAL_OVERRIDE;
|
virtual bool AdjustTextFrameWidthAndHeight(bool bHgt = true, bool bWdt = true) SAL_OVERRIDE;
|
||||||
|
@@ -2312,9 +2312,17 @@ void SdrObjCustomShape::SetVerticalWriting( bool bVertical )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SdrObjCustomShape::SuggestTextFrameSize(Size aSuggestedTextFrameSize)
|
||||||
|
{
|
||||||
|
m_aSuggestedTextFrameSize = aSuggestedTextFrameSize;
|
||||||
|
}
|
||||||
|
|
||||||
bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt, bool bWdt) const
|
bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt, bool bWdt) const
|
||||||
{
|
{
|
||||||
if ( pModel && HasText() && !rR.IsEmpty() )
|
// Either we have text or the application has native text and suggested its size to us.
|
||||||
|
bool bHasText = HasText() || (m_aSuggestedTextFrameSize.Width() != 0 && m_aSuggestedTextFrameSize.Height() != 0);
|
||||||
|
if ( pModel && bHasText && !rR.IsEmpty() )
|
||||||
{
|
{
|
||||||
bool bWdtGrow=bWdt && IsAutoGrowWidth();
|
bool bWdtGrow=bWdt && IsAutoGrowWidth();
|
||||||
bool bHgtGrow=bHgt && IsAutoGrowHeight();
|
bool bHgtGrow=bHgt && IsAutoGrowHeight();
|
||||||
@@ -2353,6 +2361,8 @@ bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt,
|
|||||||
if ( aSiz.Height() < 2 )
|
if ( aSiz.Height() < 2 )
|
||||||
aSiz.Height() = 2; // minimum size=2
|
aSiz.Height() = 2; // minimum size=2
|
||||||
|
|
||||||
|
if (HasText())
|
||||||
|
{
|
||||||
if(pEdtOutl)
|
if(pEdtOutl)
|
||||||
{
|
{
|
||||||
pEdtOutl->SetMaxAutoPaperSize( aSiz );
|
pEdtOutl->SetMaxAutoPaperSize( aSiz );
|
||||||
@@ -2389,6 +2399,12 @@ bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt,
|
|||||||
nHgt = rOutliner.GetTextHeight()+1; // a little more tolerance
|
nHgt = rOutliner.GetTextHeight()+1; // a little more tolerance
|
||||||
rOutliner.Clear();
|
rOutliner.Clear();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nHgt = m_aSuggestedTextFrameSize.Height();
|
||||||
|
nWdt = m_aSuggestedTextFrameSize.Width();
|
||||||
|
}
|
||||||
if ( nWdt < nMinWdt )
|
if ( nWdt < nMinWdt )
|
||||||
nWdt = nMinWdt;
|
nWdt = nMinWdt;
|
||||||
if ( nWdt > nMaxWdt )
|
if ( nWdt > nMaxWdt )
|
||||||
|
Reference in New Issue
Block a user