diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2008-08-18 09:48:38 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2008-08-18 09:48:38 +0000 |
commit | 262443cd2fdea157744c9fd4acbb6b1e87c05ae2 (patch) | |
tree | b950ac898b0dc18e6e8ff968c97a3a57c4915e02 /vcl/aqua/source/gdi/salatslayout.cxx | |
parent | 1d01a0e981d41d5f2397e91961f132672459acd5 (diff) |
INTEGRATION: CWS vcl30stop3 (1.10.44); FILE MERGED
2008/08/04 10:44:18 hdu 1.10.44.3: #i92342# adjust the comments in GetTextBreak()
2008/08/04 09:07:44 hdu 1.10.44.2: #i92342# faster emulation of ATSUI based naive GetTextBreak()
2008/08/04 08:45:52 hdu 1.10.44.1: #i92342# emulate naive GetTextBreak() using ATSUI
Diffstat (limited to 'vcl/aqua/source/gdi/salatslayout.cxx')
-rwxr-xr-x | vcl/aqua/source/gdi/salatslayout.cxx | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/vcl/aqua/source/gdi/salatslayout.cxx b/vcl/aqua/source/gdi/salatslayout.cxx index 988be2f3a7e0..ed46c05dce9e 100755 --- a/vcl/aqua/source/gdi/salatslayout.cxx +++ b/vcl/aqua/source/gdi/salatslayout.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: salatslayout.cxx,v $ - * $Revision: 1.10 $ + * $Revision: 1.11 $ * * This file is part of OpenOffice.org. * @@ -80,7 +80,7 @@ private: int Fixed2Vcl( Fixed ) const; // convert ATSU-Fixed units to VCL units int AtsuPix2Vcl( int ) const; // convert ATSU-Pixel units to VCL units - Fixed Vcl2Fixed( int ) const; // convert VCL units to ATSU-Fixed units + Fixed Vcl2Fixed( int ) const; // convert VCL units to ATSU-Fixed units // cached details about the resulting layout // mutable members since these details are all lazy initialized @@ -298,7 +298,7 @@ void ATSLayout::AdjustLayout( ImplLayoutArgs& rArgs ) Fixed nFixedWidth = Vcl2Fixed( nPixelWidth ); mnCachedWidth = nFixedWidth; Fract nFractFactor = kATSUFullJustification; - ATSLineLayoutOptions nLineLayoutOptions = kATSLineHasNoHangers | kATSLineHasNoOpticalAlignment; + ATSLineLayoutOptions nLineLayoutOptions = kATSLineHasNoHangers | kATSLineHasNoOpticalAlignment | kATSLineBreakToNearestCharacter; nTags[0] = kATSULineWidthTag; nVals[0] = &nFixedWidth; @@ -618,11 +618,6 @@ int ATSLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) cons { const long nPixelWidth = (nMaxWidth - (nCharExtra * mnCharCount)) / nFactor; - // TODO: ATSUBreakLine needs to be dumbed down to treat spaces as normal - // codepoints, to ignore word/syllable boundaries and so on: - // OOo's SW+SVX+I18N handle "logical line breaking" with the value - // returned from VCL's GetTextBreak(). Returning anything else than the - // "stupid visual line break" results in subtle problems in the app layers UniCharArrayOffset nBreakPos = mnMinCharPos; const ATSUTextMeasurement nATSUMaxWidth = Vcl2Fixed( nPixelWidth ); OSStatus nStatus = ATSUBreakLine( maATSULayout, mnMinCharPos, @@ -631,11 +626,32 @@ int ATSLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) cons if( (nStatus != noErr) && (nStatus != kATSULineBreakInWord) ) return STRING_LEN; + // the result from ATSUBreakLine() doesn't match the semantics expected by its + // application layer callers from SW+SVX+I18N. Adjust the results to the expectations: + // ATSU reports that everything fits even when trailing spaces would break the line // #i89789# OOo's application layers expect STRING_LEN if everything fits - if( (sal_Int32)nBreakPos >= mnEndCharPos ) - nBreakPos = STRING_LEN; - return nBreakPos; + if( nBreakPos >= static_cast<UniCharArrayOffset>(mnEndCharPos) ) + return STRING_LEN; + + // GetTextBreak()'s callers expect it to return the "stupid visual line break". + // Returning anything else result.s in subtle problems in the application layers. + static const bool bInWord = true; // TODO: add as argument to GetTextBreak() method + if( !bInWord ) + return nBreakPos; + + // emulate stupid visual line breaking by line breaking for the remaining width + ATSUTextMeasurement nLeft, nRight, nDummy; + nStatus = ATSUGetUnjustifiedBounds( maATSULayout, mnMinCharPos, nBreakPos-mnMinCharPos, + &nLeft, &nRight, &nDummy, &nDummy ); + if( nStatus != noErr ) + return nBreakPos; + const ATSUTextMeasurement nATSURemWidth = nATSUMaxWidth - (nRight - nLeft); + if( nATSURemWidth <= 0 ) + return nBreakPos; + UniCharArrayOffset nBreakPosInWord = nBreakPos; + nStatus = ATSUBreakLine( maATSULayout, nBreakPos, nATSURemWidth, false, &nBreakPosInWord ); + return nBreakPosInWord; } // ----------------------------------------------------------------------- |