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,41 +2361,49 @@ 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(pEdtOutl)
|
if (HasText())
|
||||||
{
|
{
|
||||||
pEdtOutl->SetMaxAutoPaperSize( aSiz );
|
if(pEdtOutl)
|
||||||
if (bWdtGrow)
|
|
||||||
{
|
{
|
||||||
Size aSiz2(pEdtOutl->CalcTextSize());
|
pEdtOutl->SetMaxAutoPaperSize( aSiz );
|
||||||
nWdt=aSiz2.Width()+1; // a little more tolerance
|
if (bWdtGrow)
|
||||||
if (bHgtGrow) nHgt=aSiz2.Height()+1; // a little more tolerance
|
{
|
||||||
} else
|
Size aSiz2(pEdtOutl->CalcTextSize());
|
||||||
|
nWdt=aSiz2.Width()+1; // a little more tolerance
|
||||||
|
if (bHgtGrow) nHgt=aSiz2.Height()+1; // a little more tolerance
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
nHgt=pEdtOutl->GetTextHeight()+1; // a little more tolerance
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
nHgt=pEdtOutl->GetTextHeight()+1; // a little more tolerance
|
Outliner& rOutliner=ImpGetDrawOutliner();
|
||||||
|
rOutliner.SetPaperSize(aSiz);
|
||||||
|
rOutliner.SetUpdateMode(true);
|
||||||
|
// TODO: add the optimization with bPortionInfoChecked again.
|
||||||
|
OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
|
||||||
|
if( pOutlinerParaObject != NULL )
|
||||||
|
{
|
||||||
|
rOutliner.SetText(*pOutlinerParaObject);
|
||||||
|
rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
|
||||||
|
}
|
||||||
|
if ( bWdtGrow )
|
||||||
|
{
|
||||||
|
Size aSiz2(rOutliner.CalcTextSize());
|
||||||
|
nWdt=aSiz2.Width()+1; // a little more tolerance
|
||||||
|
if ( bHgtGrow )
|
||||||
|
nHgt=aSiz2.Height()+1; // a little more tolerance
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nHgt = rOutliner.GetTextHeight()+1; // a little more tolerance
|
||||||
|
rOutliner.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Outliner& rOutliner=ImpGetDrawOutliner();
|
nHgt = m_aSuggestedTextFrameSize.Height();
|
||||||
rOutliner.SetPaperSize(aSiz);
|
nWdt = m_aSuggestedTextFrameSize.Width();
|
||||||
rOutliner.SetUpdateMode(true);
|
|
||||||
// TODO: add the optimization with bPortionInfoChecked again.
|
|
||||||
OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
|
|
||||||
if( pOutlinerParaObject != NULL )
|
|
||||||
{
|
|
||||||
rOutliner.SetText(*pOutlinerParaObject);
|
|
||||||
rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
|
|
||||||
}
|
|
||||||
if ( bWdtGrow )
|
|
||||||
{
|
|
||||||
Size aSiz2(rOutliner.CalcTextSize());
|
|
||||||
nWdt=aSiz2.Width()+1; // a little more tolerance
|
|
||||||
if ( bHgtGrow )
|
|
||||||
nHgt=aSiz2.Height()+1; // a little more tolerance
|
|
||||||
}
|
|
||||||
else
|
|
||||||
nHgt = rOutliner.GetTextHeight()+1; // a little more tolerance
|
|
||||||
rOutliner.Clear();
|
|
||||||
}
|
}
|
||||||
if ( nWdt < nMinWdt )
|
if ( nWdt < nMinWdt )
|
||||||
nWdt = nMinWdt;
|
nWdt = nMinWdt;
|
||||||
|
Reference in New Issue
Block a user