summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/sallayout.cxx
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2006-08-11 14:51:43 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2006-08-11 14:51:43 +0000
commita0095bb26dddd982608655d5d55aaa9b2bc4b4a4 (patch)
tree5d7d4bbdde0e8d3c0cfe79fd4604c96b643595e2 /vcl/source/gdi/sallayout.cxx
parentf61547c5b88de9b8891a22e232c842ccec184686 (diff)
INTEGRATION: CWS swqbf82 (1.80.88); FILE MERGED
2006/08/09 14:33:52 hdu 1.80.88.1: #i24517# move OutputDevice::Stretchtext fix to CWS swqbf82
Diffstat (limited to 'vcl/source/gdi/sallayout.cxx')
-rwxr-xr-xvcl/source/gdi/sallayout.cxx67
1 files changed, 46 insertions, 21 deletions
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 074a8c16c366..dfa0ab6c1213 100755
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: sallayout.cxx,v $
*
- * $Revision: 1.80 $
+ * $Revision: 1.81 $
*
- * last change: $Author: hr $ $Date: 2006-06-19 19:31:39 $
+ * last change: $Author: hr $ $Date: 2006-08-11 15:51:43 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -1143,36 +1143,61 @@ void GenericSalLayout::Justify( long nNewWidth )
// find rightmost glyph, it won't get stretched
GlyphItem* pGRight = mpGlyphItems + mnGlyphCount - 1;
- // move rightmost glyph to requested position, correct adjustment widths
- nOldWidth -= pGRight->mnOrigWidth;
- nNewWidth -= pGRight->mnOrigWidth;
- if( (nOldWidth < 0) || (nNewWidth < 0) )
- return;
- const long nBasePos = maBasePoint.X();
- pGRight->maLinearPos.X() = nBasePos + nNewWidth;
-
// count stretchable glyphs
GlyphItem* pG;
int nStretchable = 0;
+ int nMaxGlyphWidth = 0;
for( pG = mpGlyphItems; pG < pGRight; ++pG )
+ {
if( pG->mnOrigWidth > 0 )
++nStretchable;
+ if( nMaxGlyphWidth < pG->mnOrigWidth)
+ nMaxGlyphWidth = pG->mnOrigWidth;
+ }
+
+ // move rightmost glyph to requested position
+ nOldWidth -= pGRight->mnOrigWidth;
+ if( nOldWidth <= 0)
+ return;
+ if( nNewWidth < nMaxGlyphWidth)
+ nNewWidth = nMaxGlyphWidth;
+ nNewWidth -= pGRight->mnOrigWidth;
+ pGRight->maLinearPos.X() = maBasePoint.X() + nNewWidth;
- // interpolate inbetween glyph positions
+ // justify glyph widths and positions
int nDiffWidth = nNewWidth - nOldWidth;
- int nDeltaSum = 0;
- for( pG = mpGlyphItems; (pG < pGRight) && (nStretchable > 0); ++pG )
+ if( nDiffWidth >= 0) // expanded case
{
- if( pG->mnOrigWidth <= 0 )
- continue;
+ // expand width by distributing space between glyphs evenly
+ int nDeltaSum = 0;
+ for( pG = mpGlyphItems; pG < pGRight; ++pG )
+ {
+ // move glyph to justified position
+ pG->maLinearPos.X() += nDeltaSum;
- int nDeltaWidth = nDiffWidth / nStretchable;
- nDiffWidth -= nDeltaWidth;
- --nStretchable;
+ // do not stretch non-stretchable glyphs
+ if( (pG->mnOrigWidth <= 0) || (nStretchable <= 0) )
+ continue;
- pG->mnNewWidth += nDeltaWidth;
- pG->maLinearPos.X() += nDeltaSum;
- nDeltaSum += nDeltaWidth;
+ // distribute extra space equally to stretchable glyphs
+ int nDeltaWidth = nDiffWidth / nStretchable--;
+ nDiffWidth -= nDeltaWidth;
+ pG->mnNewWidth += nDeltaWidth;
+ nDeltaSum += nDeltaWidth;
+ }
+ }
+ else // condensed case
+ {
+ // squeeze width by moving glyphs proportionally
+ for( pG = mpGlyphItems; ++pG < pGRight;)
+ {
+ int nX = pG->maLinearPos.X() - maBasePoint.X();
+ nX = nX * nNewWidth / nOldWidth;
+ pG->maLinearPos.X() = nX + maBasePoint.X();
+ }
+ // adjust glyph widths to new positions
+ for( pG = mpGlyphItems; pG < pGRight; ++pG )
+ pG->mnNewWidth = pG[1].maLinearPos.X() - pG[0].maLinearPos.X();
}
}