summaryrefslogtreecommitdiff
path: root/sdext
diff options
context:
space:
mode:
authorGábor Stefanik <netrolller.3d@gmail.com>2012-05-11 06:23:32 +0200
committerAndras Timar <atimar@suse.com>2012-05-12 17:48:40 +0200
commit5c379de9589ab819da852768a9663455dbb4a835 (patch)
tree2a6b85331dde99fa91ec6a50787a43e5a207f272 /sdext
parentf941184568634e578ce0421908b9000a20eab54a (diff)
fdo#46223: Fix Presenter Console help screen layout
Change-Id: I18d2fda46d3a6427b1691c1ff7838097bb25d0ec
Diffstat (limited to 'sdext')
-rw-r--r--sdext/source/presenter/PresenterHelpView.cxx66
1 files changed, 51 insertions, 15 deletions
diff --git a/sdext/source/presenter/PresenterHelpView.cxx b/sdext/source/presenter/PresenterHelpView.cxx
index b314dcc7194f..21f67326f362 100644
--- a/sdext/source/presenter/PresenterHelpView.cxx
+++ b/sdext/source/presenter/PresenterHelpView.cxx
@@ -385,10 +385,6 @@ void PresenterHelpView::CheckFontSize (void)
if (mpFont.get() == NULL)
return;
- const awt::Rectangle aWindowBox (mxWindow->getPosSize());
- if (aWindowBox.Width<=0 || aWindowBox.Height<=0)
- return;
-
sal_Int32 nBestSize (6);
// Scaling down and then reformatting can cause the text to be too large
@@ -396,7 +392,7 @@ void PresenterHelpView::CheckFontSize (void)
// small enough. Restrict the number of loops.
for (int nLoopCount=0; nLoopCount<5; ++nLoopCount)
{
- double nY (gnVerticalBorder);
+ double nY (0.0);
TextContainer::iterator iBlock (mpTextContainer->begin());
TextContainer::const_iterator iBlockEnd (mpTextContainer->end());
for ( ; iBlock!=iBlockEnd; ++iBlock)
@@ -404,7 +400,7 @@ void PresenterHelpView::CheckFontSize (void)
(*iBlock)->maLeft.GetHeight(),
(*iBlock)->maRight.GetHeight());
- const double nHeightDifference (nY - (aWindowBox.Height-gnVerticalBorder));
+ const double nHeightDifference (nY - (mnSeparatorY-gnVerticalBorder));
if (nHeightDifference <= 0 && nHeightDifference > -50)
{
// We have found a good font size that is large and leaves not
@@ -412,16 +408,14 @@ void PresenterHelpView::CheckFontSize (void)
return;
}
- // Font is too large. Make it smaller.
-
// Use a simple linear transformation to calculate initial guess of
// a size that lets all help text be shown inside the window.
- const double nScale (double(aWindowBox.Height-gnVerticalBorder) / nY);
- if (nScale > 0.95 && nScale <1.05)
+ const double nScale (double(mnSeparatorY-gnVerticalBorder) / nY);
+ if (nScale > 1.0 && nScale < 1.05)
break;
- sal_Int32 nFontSizeGuess (::std::max(sal_Int32(1),sal_Int32(mpFont->mnSize * nScale)));
- if (nHeightDifference<0 && mpFont->mnSize>nBestSize)
+ sal_Int32 nFontSizeGuess (sal_Int32(mpFont->mnSize * nScale));
+ if (nHeightDifference<=0 && mpFont->mnSize>nBestSize)
nBestSize = mpFont->mnSize;
mpFont->mnSize = nFontSizeGuess;
mpFont->mxFont = NULL;
@@ -673,12 +667,53 @@ void LineDescriptorList::FormatText (
vector<OUString>::const_iterator iPart (rTextParts.begin());
vector<OUString>::const_iterator iEnd (rTextParts.end());
- for ( ; iPart!=iEnd; ++iPart)
+ while (iPart!=iEnd)
{
if (aLineDescriptor.IsEmpty())
{
// Avoid empty lines.
- aLineDescriptor.AddPart(*iPart, rxFont);
+ if (PresenterCanvasHelper::GetTextSize(
+ rxFont, *iPart).Width > nMaximalWidth)
+ {
+ const sal_Char cSpace (' ');
+
+ sal_Int32 nIndex (0);
+ sal_Int32 nStart (0);
+ sal_Int32 nLength (iPart->getLength());
+ while (nIndex < nLength)
+ {
+ sal_Int32 nSpaceIndex (iPart->indexOf(cSpace, nIndex));
+ while (nSpaceIndex >= 0 && PresenterCanvasHelper::GetTextSize(
+ rxFont, iPart->copy(nStart, nSpaceIndex-nStart)).Width <= nMaximalWidth)
+ {
+ nIndex = nSpaceIndex;
+ nSpaceIndex = iPart->indexOf(cSpace, nIndex+1);
+ }
+
+ if (nSpaceIndex < 0 && PresenterCanvasHelper::GetTextSize(
+ rxFont, iPart->copy(nStart, nLength-nStart)).Width <= nMaximalWidth)
+ {
+ nIndex = nLength;
+ }
+
+ if (nIndex == nStart)
+ {
+ nIndex = nLength;
+ }
+
+ aLineDescriptor.AddPart(iPart->copy(nStart, nIndex-nStart), rxFont);
+ if (nIndex != nLength)
+ {
+ mpLineDescriptors->push_back(aLineDescriptor);
+ aLineDescriptor = LineDescriptor();
+ }
+ nStart = nIndex;
+ }
+ }
+ else
+ {
+ aLineDescriptor.AddPart(*iPart, rxFont);
+ }
}
else if (PresenterCanvasHelper::GetTextSize(
rxFont, aLineDescriptor.msLine+A2S(", ")+*iPart).Width > nMaximalWidth)
@@ -686,12 +721,13 @@ void LineDescriptorList::FormatText (
aLineDescriptor.AddPart(A2S(","), rxFont);
mpLineDescriptors->push_back(aLineDescriptor);
aLineDescriptor = LineDescriptor();
- aLineDescriptor.AddPart(*iPart, rxFont);
+ continue;
}
else
{
aLineDescriptor.AddPart(A2S(", ")+*iPart, rxFont);
}
+ ++iPart;
}
if ( ! aLineDescriptor.IsEmpty())
{