summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-06-27 13:43:13 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-06-27 15:56:05 +0200
commit4f33a0961d69feba72806d105da65a4dc841ca5e (patch)
tree97c2818f1dc30874afeb53ad91acdcc05325a6b1 /svx
parentf2ad42f97b1f9534da9be96b5a07255434890187 (diff)
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
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdoashp.cxx74
1 files changed, 45 insertions, 29 deletions
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 8205121f854f..26c563c8d6f8 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -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
{
- 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 bHgtGrow=bHgt && IsAutoGrowHeight();
@@ -2353,41 +2361,49 @@ bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt,
if ( aSiz.Height() < 2 )
aSiz.Height() = 2; // minimum size=2
- if(pEdtOutl)
+ if (HasText())
{
- pEdtOutl->SetMaxAutoPaperSize( aSiz );
- if (bWdtGrow)
+ if(pEdtOutl)
{
- Size aSiz2(pEdtOutl->CalcTextSize());
- nWdt=aSiz2.Width()+1; // a little more tolerance
- if (bHgtGrow) nHgt=aSiz2.Height()+1; // a little more tolerance
- } else
+ pEdtOutl->SetMaxAutoPaperSize( aSiz );
+ if (bWdtGrow)
+ {
+ 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
{
- 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();
+ nHgt = m_aSuggestedTextFrameSize.Height();
+ nWdt = m_aSuggestedTextFrameSize.Width();
}
if ( nWdt < nMinWdt )
nWdt = nMinWdt;