diff options
author | Gábor Stefanik <netrolller.3d@gmail.com> | 2012-05-11 06:23:32 +0200 |
---|---|---|
committer | Andras Timar <atimar@suse.com> | 2012-05-12 17:41:49 +0200 |
commit | cf90a279a4ba18e73067b7a978af5ef1f1b98e27 (patch) | |
tree | c8e5d0920605a691701e809047c92410a69cf605 | |
parent | dd8f905389056acbcd35db1cb027f816df1a429e (diff) |
fdo#46223: Fix Presenter Console help screen layout
Change-Id: I18d2fda46d3a6427b1691c1ff7838097bb25d0ec
Signed-off-by: Andras Timar <atimar@suse.com>
-rw-r--r-- | sdext/source/presenter/PresenterHelpView.cxx | 66 |
1 files changed, 51 insertions, 15 deletions
diff --git a/sdext/source/presenter/PresenterHelpView.cxx b/sdext/source/presenter/PresenterHelpView.cxx index 45a365b34db3..e2ec90ffa37d 100644 --- a/sdext/source/presenter/PresenterHelpView.cxx +++ b/sdext/source/presenter/PresenterHelpView.cxx @@ -426,10 +426,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 @@ -437,7 +433,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) @@ -445,7 +441,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 @@ -453,16 +449,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; @@ -759,12 +753,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) @@ -772,12 +807,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()) { |