Lines 30-35
Link Here
|
30 |
|
30 |
|
31 |
// MARKER(update_precomp.py): autogen include statement, do not remove |
31 |
// MARKER(update_precomp.py): autogen include statement, do not remove |
32 |
#include "precompiled_sw.hxx" |
32 |
#include "precompiled_sw.hxx" |
|
|
33 |
#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ |
34 |
#include <com/sun/star/i18n/ScriptType.hdl> |
35 |
#endif |
36 |
|
33 |
#include <vcl/outdev.hxx> |
37 |
#include <vcl/outdev.hxx> |
34 |
#include <IDocumentSettingAccess.hxx> |
38 |
#include <IDocumentSettingAccess.hxx> |
35 |
|
39 |
|
Lines 46-51
Link Here
|
46 |
|
50 |
|
47 |
#define MIN_TAB_WIDTH 60 |
51 |
#define MIN_TAB_WIDTH 60 |
48 |
|
52 |
|
|
|
53 |
using namespace ::com::sun::star; |
54 |
|
49 |
/************************************************************************* |
55 |
/************************************************************************* |
50 |
* SwTxtAdjuster::FormatBlock() |
56 |
* SwTxtAdjuster::FormatBlock() |
51 |
*************************************************************************/ |
57 |
*************************************************************************/ |
Lines 133-139
Link Here
|
133 |
*************************************************************************/ |
139 |
*************************************************************************/ |
134 |
|
140 |
|
135 |
void SwTxtAdjuster::CalcNewBlock( SwLineLayout *pCurrent, |
141 |
void SwTxtAdjuster::CalcNewBlock( SwLineLayout *pCurrent, |
136 |
const SwLinePortion *pStopAt, SwTwips nReal ) |
142 |
const SwLinePortion *pStopAt, SwTwips nReal, bool bSkipKashida ) |
137 |
{ |
143 |
{ |
138 |
ASSERT( GetInfo().IsMulti() || SVX_ADJUST_BLOCK == GetAdjust(), |
144 |
ASSERT( GetInfo().IsMulti() || SVX_ADJUST_BLOCK == GetAdjust(), |
139 |
"CalcNewBlock: Why?" ); |
145 |
"CalcNewBlock: Why?" ); |
Lines 153-164
Link Here
|
153 |
{ |
159 |
{ |
154 |
while (aItr.GetCurr() != pCurrent && aItr.GetNext()) |
160 |
while (aItr.GetCurr() != pCurrent && aItr.GetNext()) |
155 |
aItr.Next(); |
161 |
aItr.Next(); |
156 |
rSI.ClearKashidaInvalid ( aItr.GetStart(), aItr.GetLength() ); |
162 |
|
|
|
163 |
if( bSkipKashida ) |
164 |
{ |
165 |
rSI.SetNoKashidaLine ( aItr.GetStart(), aItr.GetLength()); |
166 |
} |
167 |
else |
168 |
{ |
169 |
rSI.ClearKashidaInvalid ( aItr.GetStart(), aItr.GetLength() ); |
170 |
rSI.ClearNoKashidaLine( aItr.GetStart(), aItr.GetLength() ); |
171 |
} |
157 |
} |
172 |
} |
158 |
|
173 |
|
159 |
// Nicht vergessen: |
174 |
// Nicht vergessen: |
160 |
// CalcRightMargin() setzt pCurrent->Width() auf die Zeilenbreite ! |
175 |
// CalcRightMargin() setzt pCurrent->Width() auf die Zeilenbreite ! |
161 |
CalcRightMargin( pCurrent, nReal ); |
176 |
if (!bSkipKashida) |
|
|
177 |
CalcRightMargin( pCurrent, nReal ); |
162 |
|
178 |
|
163 |
// --> FME 2005-06-08 #i49277# |
179 |
// --> FME 2005-06-08 #i49277# |
164 |
const sal_Bool bDoNotJustifyLinesWithManualBreak = |
180 |
const sal_Bool bDoNotJustifyLinesWithManualBreak = |
Lines 209-269
Link Here
|
209 |
|
225 |
|
210 |
const long nGluePortionWidth = static_cast<SwGluePortion*>(pPos)->GetPrtGlue() * |
226 |
const long nGluePortionWidth = static_cast<SwGluePortion*>(pPos)->GetPrtGlue() * |
211 |
SPACING_PRECISION_FACTOR; |
227 |
SPACING_PRECISION_FACTOR; |
212 |
|
228 |
xub_StrLen nKashidas = 0; |
|
|
229 |
if( nGluePortion && rSI.CountKashida() && !bSkipKashida ) |
230 |
{ |
231 |
// kashida positions found in SwScriptInfo are not necessarily valid in every font |
232 |
// if two characters are replaced by a ligature glyph, there will be no place for a kashida |
233 |
if ( !CheckKashidaPositions ( rSI, aInf, aItr, nKashidas, nGluePortion )) |
234 |
{ |
235 |
// all kashida positions are invalid |
236 |
// do regular blank justification |
237 |
pCurrent->FinishSpaceAdd(); |
238 |
GetInfo().SetIdx( nStart ); |
239 |
CalcNewBlock( pCurrent, pStopAt, nReal, true ); |
240 |
return; |
241 |
} |
242 |
} |
213 |
if( nGluePortion ) |
243 |
if( nGluePortion ) |
214 |
{ |
244 |
{ |
215 |
// i60594 |
245 |
long nSpaceAdd = nGluePortionWidth / nGluePortion; |
216 |
long nSpaceAdd = nGluePortionWidth / nGluePortion; |
246 |
|
217 |
|
247 |
if( rSI.CountKashida() && !bSkipKashida ) |
218 |
// validate or recalculate for Kashida justification |
248 |
{ |
219 |
if ( rSI.CountKashida() ) |
249 |
if( !CheckKashidaWidth( rSI, aInf, aItr, nKashidas, nGluePortion, nGluePortionWidth, nSpaceAdd )) |
220 |
{ |
250 |
{ |
221 |
xub_StrLen nIdx = aItr.GetStart(); |
251 |
// no kashidas left |
222 |
xub_StrLen nEnd = aItr.GetEnd(); |
252 |
// do regular blank justification |
223 |
|
253 |
pCurrent->FinishSpaceAdd(); |
224 |
|
254 |
GetInfo().SetIdx( nStart ); |
225 |
// Note on calling KashidaJustify(): |
255 |
CalcNewBlock( pCurrent, pStopAt, nReal, true ); |
226 |
// Kashida positions may be marked as invalid. Therefore KashidaJustify may return the clean |
256 |
return; |
227 |
// total number of kashida positions, or the number of kashida positions after some positions |
257 |
} |
228 |
// have been dropped. |
258 |
} |
229 |
// Here we want the clean total, which is OK: We have called ClearKashidaInvalid() before. |
259 |
|
230 |
xub_StrLen nKashidas = rSI.KashidaJustify ( 0, 0, aItr.GetStart(), aItr.GetLength(), 0 ); |
|
|
231 |
|
232 |
bool bAddSpaceChanged; |
233 |
while ( nKashidas ) |
234 |
{ |
235 |
bAddSpaceChanged = false; |
236 |
nIdx = aItr.GetStart(); |
237 |
aItr.SeekAndChgAttrIter( nIdx, aInf.GetOut() ); |
238 |
|
239 |
while ( nIdx < nEnd ) |
240 |
{ |
241 |
long nFontMinKashida = aInf.GetOut()->GetMinKashida(); |
242 |
if ( nFontMinKashida ) |
243 |
{ |
244 |
while ( nKashidas && nGluePortion > 1 && |
245 |
nSpaceAdd / SPACING_PRECISION_FACTOR < nFontMinKashida ) |
246 |
{ |
247 |
if ( rSI.MarkKashidaInvalid(aItr.GetStart(), aItr.GetLength()) ) |
248 |
{ |
249 |
--nGluePortion; |
250 |
--nKashidas; |
251 |
nSpaceAdd = nGluePortionWidth / nGluePortion; |
252 |
bAddSpaceChanged = true; |
253 |
} |
254 |
} |
255 |
} |
256 |
if ( bAddSpaceChanged ) |
257 |
break; // start all over again |
258 |
nIdx = aItr.GetNextAttr(); |
259 |
if ( nIdx != STRING_LEN ) |
260 |
aItr.SeekAndChgAttrIter( nIdx, aInf.GetOut() ); |
261 |
} |
262 |
if ( !bAddSpaceChanged ) |
263 |
break; // everything was OK |
264 |
} |
265 |
} |
266 |
|
267 |
pCurrent->SetLLSpaceAdd( nSpaceAdd , nSpaceIdx ); |
260 |
pCurrent->SetLLSpaceAdd( nSpaceAdd , nSpaceIdx ); |
268 |
pPos->Width( ( (SwGluePortion*)pPos )->GetFixWidth() ); |
261 |
pPos->Width( ( (SwGluePortion*)pPos )->GetFixWidth() ); |
269 |
} |
262 |
} |
Lines 292-297
Link Here
|
292 |
} |
285 |
} |
293 |
|
286 |
|
294 |
/************************************************************************* |
287 |
/************************************************************************* |
|
|
288 |
* SwTxtAdjuster::CheckKashidaPositions() |
289 |
*************************************************************************/ |
290 |
bool SwTxtAdjuster::CheckKashidaPositions( SwScriptInfo& rSI, SwTxtSizeInfo& rInf, SwTxtIter& rItr, |
291 |
xub_StrLen& nKashidas, xub_StrLen& nGluePortion ) |
292 |
{ |
293 |
// i60594 validate Kashida justification |
294 |
xub_StrLen nIdx = rItr.GetStart(); |
295 |
xub_StrLen nEnd = rItr.GetEnd(); |
296 |
|
297 |
// Note on calling KashidaJustify(): |
298 |
// Kashida positions may be marked as invalid. Therefore KashidaJustify may return the clean |
299 |
// total number of kashida positions, or the number of kashida positions after some positions |
300 |
// have been dropped. |
301 |
// Here we want the clean total, which is OK: We have called ClearKashidaInvalid() before. |
302 |
nKashidas = rSI.KashidaJustify ( 0, 0, rItr.GetStart(), rItr.GetLength(), 0 ); |
303 |
|
304 |
if (!nKashidas) // nothing to do |
305 |
return true; |
306 |
|
307 |
// kashida positions found in SwScriptInfo are not necessarily valid in every font |
308 |
// if two characters are replaced by a ligature glyph, there will be no place for a kashida |
309 |
xub_StrLen* pKashidaPos = new xub_StrLen [ nKashidas ]; |
310 |
xub_StrLen* pKashidaPosDropped = new xub_StrLen [ nKashidas ]; |
311 |
rSI.GetKashidaPositions ( nIdx, rItr.GetLength(), pKashidaPos ); |
312 |
xub_StrLen nKashidaIdx = 0; |
313 |
while ( nKashidas && nIdx < nEnd ) |
314 |
{ |
315 |
rItr.SeekAndChgAttrIter( nIdx, rInf.GetOut() ); |
316 |
xub_StrLen nNext = rItr.GetNextAttr(); |
317 |
|
318 |
// is there also a script change before? |
319 |
// if there is, nNext should point to the script change |
320 |
xub_StrLen nNextScript = rSI.NextScriptChg( nIdx ); |
321 |
if( nNextScript < nNext ) |
322 |
nNext = nNextScript; |
323 |
|
324 |
if ( nNext == STRING_LEN || nNext > nEnd ) |
325 |
nNext = nEnd; |
326 |
xub_StrLen nKashidasInAttr = rSI.KashidaJustify ( 0, 0, nIdx, nNext - nIdx ); |
327 |
if ( nKashidasInAttr ) |
328 |
{ |
329 |
xub_StrLen nKashidasDropped = 0; |
330 |
LanguageType aLang = GetTxtFrm()->GetTxtNode()-> |
331 |
GetLang ( nIdx, 1, i18n::ScriptType::COMPLEX ); |
332 |
if ( !SwScriptInfo::IsArabicLanguage( aLang ) ) |
333 |
{ |
334 |
nKashidasDropped = nKashidasInAttr; |
335 |
nKashidas -= nKashidasDropped; |
336 |
} |
337 |
else |
338 |
{ |
339 |
ULONG nOldLayout = rInf.GetOut()->GetLayoutMode(); |
340 |
rInf.GetOut()->SetLayoutMode ( nOldLayout | TEXT_LAYOUT_BIDI_RTL ); |
341 |
nKashidasDropped = rInf.GetOut()->ValidateKashidas ( rInf.GetTxt(), nIdx, nNext - nIdx, |
342 |
nKashidasInAttr, pKashidaPos + nKashidaIdx, |
343 |
pKashidaPosDropped ); |
344 |
rInf.GetOut()->SetLayoutMode ( nOldLayout ); |
345 |
if ( nKashidasDropped ) |
346 |
{ |
347 |
rSI.MarkKashidasInvalid ( nKashidasDropped, pKashidaPosDropped ); |
348 |
nKashidas -= nKashidasDropped; |
349 |
nGluePortion -= nKashidasDropped; |
350 |
} |
351 |
} |
352 |
nKashidaIdx += nKashidasInAttr; |
353 |
} |
354 |
nIdx = nNext; |
355 |
} |
356 |
delete[] pKashidaPos; |
357 |
delete[] pKashidaPosDropped; |
358 |
|
359 |
// return false if all kashidas have been eliminated |
360 |
return (nKashidas > 0); |
361 |
} |
362 |
|
363 |
|
364 |
/************************************************************************* |
365 |
* SwTxtAdjuster::CheckKashidaWidth() |
366 |
*************************************************************************/ |
367 |
bool SwTxtAdjuster::CheckKashidaWidth ( SwScriptInfo& rSI, SwTxtSizeInfo& rInf, SwTxtIter& rItr, xub_StrLen& nKashidas, |
368 |
xub_StrLen& nGluePortion, const long nGluePortionWidth, long& nSpaceAdd ) |
369 |
{ |
370 |
// check kashida width |
371 |
// if width is smaller than minimal kashida width allowed by fonts in the current line |
372 |
// drop one kashida after the other until kashida width is OK |
373 |
bool bAddSpaceChanged; |
374 |
while ( nKashidas ) |
375 |
{ |
376 |
bAddSpaceChanged = false; |
377 |
xub_StrLen nIdx = rItr.GetStart(); |
378 |
xub_StrLen nEnd = rItr.GetEnd(); |
379 |
while ( nIdx < nEnd ) |
380 |
{ |
381 |
rItr.SeekAndChgAttrIter( nIdx, rInf.GetOut() ); |
382 |
xub_StrLen nNext = rItr.GetNextAttr(); |
383 |
|
384 |
// is there also a script change before? |
385 |
// if there is, nNext should point to the script change |
386 |
xub_StrLen nNextScript = rSI.NextScriptChg( nIdx ); |
387 |
if( nNextScript < nNext ) |
388 |
nNext = nNextScript; |
389 |
|
390 |
if ( nNext == STRING_LEN || nNext > nEnd ) |
391 |
nNext = nEnd; |
392 |
xub_StrLen nKashidasInAttr = rSI.KashidaJustify ( 0, 0, nIdx, nNext - nIdx ); |
393 |
|
394 |
long nFontMinKashida = rInf.GetOut()->GetMinKashida(); |
395 |
LanguageType aLang = GetTxtFrm()->GetTxtNode()-> |
396 |
GetLang ( nIdx, 1, i18n::ScriptType::COMPLEX ); |
397 |
if ( nFontMinKashida && nKashidasInAttr && SwScriptInfo::IsArabicLanguage( aLang )) |
398 |
{ |
399 |
xub_StrLen nKashidasDropped = 0; |
400 |
while ( nKashidas && nGluePortion && nKashidasInAttr && |
401 |
nSpaceAdd / SPACING_PRECISION_FACTOR < nFontMinKashida ) |
402 |
{ |
403 |
--nGluePortion; |
404 |
--nKashidas; |
405 |
--nKashidasInAttr; |
406 |
++nKashidasDropped; |
407 |
if( !nKashidas || !nGluePortion ) // nothing left, return false to |
408 |
return false; // do regular blank justification |
409 |
|
410 |
nSpaceAdd = nGluePortionWidth / nGluePortion; |
411 |
bAddSpaceChanged = true; |
412 |
} |
413 |
if( nKashidasDropped ) |
414 |
rSI.MarkKashidasInvalid( nKashidasDropped, nIdx, nNext - nIdx ); |
415 |
} |
416 |
if ( bAddSpaceChanged ) |
417 |
break; // start all over again |
418 |
nIdx = nNext; |
419 |
} |
420 |
if ( !bAddSpaceChanged ) |
421 |
break; // everything was OK |
422 |
} |
423 |
return true; |
424 |
} |
425 |
|
426 |
/************************************************************************* |
295 |
* SwTxtAdjuster::CalcKanaAdj() |
427 |
* SwTxtAdjuster::CalcKanaAdj() |
296 |
*************************************************************************/ |
428 |
*************************************************************************/ |
297 |
|
429 |
|