Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <hintids.hxx>
30 : :
31 : : #include <editeng/tstpitem.hxx>
32 : : #include <editeng/lrspitem.hxx>
33 : : #include <editeng/scripttypeitem.hxx>
34 : : #include <com/sun/star/i18n/ScriptType.hpp>
35 : : #include <txatbase.hxx>
36 : : #include <txtftn.hxx>
37 : : #include <fmtftn.hxx>
38 : : #include <editsh.hxx>
39 : : #include <edimp.hxx> // fuer MACROS
40 : : #include <doc.hxx>
41 : : #include <swundo.hxx> // fuer UNDO-Ids
42 : : #include <ndtxt.hxx>
43 : : #include <ftnidx.hxx>
44 : : #include <expfld.hxx>
45 : : #include <rootfrm.hxx>
46 : : #include <cntfrm.hxx>
47 : : #include <breakit.hxx>
48 : : #include <txtfld.hxx>
49 : : #include <fmtfld.hxx>
50 : : #include <crsskip.hxx>
51 : : #include <txtfrm.hxx> // SwTxtFrm
52 : : #include <scriptinfo.hxx>
53 : : #include <svl/ctloptions.hxx>
54 : : #include <charfmt.hxx> // #i27615#
55 : : #include <numrule.hxx>
56 : :
57 : : #include <algorithm>
58 : :
59 : : /*************************************
60 : : * harte Formatierung (Attribute)
61 : : *************************************/
62 : :
63 : : // wenn Selektion groesser Max Nodes oder mehr als Max Selektionen
64 : : // => keine Attribute
65 : 62112 : const sal_uInt16& getMaxLookup()
66 : : {
67 : : static const sal_uInt16 nMaxLookup = 1000;
68 : 62112 : return nMaxLookup;
69 : : }
70 : :
71 : 27390 : sal_Bool SwEditShell::GetPaMAttr( SwPaM* pPaM, SfxItemSet& rSet,
72 : : const bool bMergeIndentValuesOfNumRule ) const
73 : : {
74 : : // ??? pPaM can be different from the Cursor ???
75 [ + - ][ - + ]: 27390 : if( GetCrsrCnt() > getMaxLookup() )
76 : : {
77 [ # # ]: 0 : rSet.InvalidateAllItems();
78 : 0 : return sal_False;
79 : : }
80 : :
81 [ + - ]: 27390 : SfxItemSet aSet( *rSet.GetPool(), rSet.GetRanges() );
82 : 27390 : SfxItemSet *pSet = &rSet;
83 : :
84 : 27390 : SwPaM* pStartPaM = pPaM;
85 [ + + ]: 27498 : do {
86 : : // #i27615# if the cursor is in front of the numbering label
87 : : // the attributes to get are those from the numbering format.
88 [ - + ]: 27498 : if (pPaM->IsInFrontOfLabel())
89 : : {
90 : 0 : SwTxtNode * pTxtNd = pPaM->GetPoint()->nNode.GetNode().GetTxtNode();
91 : :
92 [ # # ]: 0 : if (pTxtNd)
93 : : {
94 [ # # ]: 0 : SwNumRule * pNumRule = pTxtNd->GetNumRule();
95 : :
96 [ # # ]: 0 : if (pNumRule)
97 : : {
98 : : const String & aCharFmtName =
99 [ # # ][ # # ]: 0 : pNumRule->Get(static_cast<sal_uInt16>(pTxtNd->GetActualListLevel())).GetCharFmtName();
[ # # ]
100 : : SwCharFmt * pCharFmt =
101 [ # # ]: 0 : GetDoc()->FindCharFmtByName(aCharFmtName);
102 : :
103 [ # # ]: 0 : if (pCharFmt)
104 [ # # ]: 0 : rSet.Put(pCharFmt->GetAttrSet());
105 : : }
106 : : }
107 : :
108 : 0 : continue;
109 : : }
110 : :
111 : 27498 : sal_uLong nSttNd = pPaM->GetMark()->nNode.GetIndex(),
112 : 27498 : nEndNd = pPaM->GetPoint()->nNode.GetIndex();
113 : 27498 : xub_StrLen nSttCnt = pPaM->GetMark()->nContent.GetIndex(),
114 : 27498 : nEndCnt = pPaM->GetPoint()->nContent.GetIndex();
115 : :
116 [ + - ][ + + ]: 27498 : if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt ))
[ + - ]
117 : : {
118 : 23 : std::swap(nSttNd, nEndNd);
119 : 23 : std::swap(nSttCnt, nEndCnt);
120 : : }
121 : :
122 [ - + ]: 27498 : if( nEndNd - nSttNd >= getMaxLookup() )
123 : : {
124 [ # # ]: 0 : rSet.ClearItem();
125 [ # # ]: 0 : rSet.InvalidateAllItems();
126 : 0 : return sal_False;
127 : : }
128 : :
129 : : // beim 1.Node traegt der Node die Werte in den GetSet ein (Initial)
130 : : // alle weiteren Nodes werden zum GetSet zu gemergt
131 [ + + ]: 54996 : for( sal_uLong n = nSttNd; n <= nEndNd; ++n )
132 : : {
133 [ + - ][ + - ]: 27498 : SwNode* pNd = GetDoc()->GetNodes()[ n ];
134 [ + - - ]: 27498 : switch( pNd->GetNodeType() )
135 : : {
136 : : case ND_TEXTNODE:
137 : : {
138 [ + - ]: 27498 : xub_StrLen nStt = n == nSttNd ? nSttCnt : 0,
139 : : nEnd = n == nEndNd ? nEndCnt
140 [ - + ][ # # ]: 27498 : : ((SwTxtNode*)pNd)->GetTxt().Len();
141 : :
142 : : ((SwTxtNode*)pNd)->GetAttr( *pSet, nStt, nEnd,
143 : : sal_False, sal_True,
144 [ + - ][ + - ]: 27498 : bMergeIndentValuesOfNumRule );
145 : : }
146 : 27498 : break;
147 : : case ND_GRFNODE:
148 : : case ND_OLENODE:
149 [ # # ][ # # ]: 0 : ((SwCntntNode*)pNd)->GetAttr( *pSet );
150 : 0 : break;
151 : :
152 : : default:
153 : 0 : pNd = 0;
154 : : }
155 : :
156 [ + - ]: 27498 : if( pNd )
157 : : {
158 [ + + ]: 27498 : if( pSet != &rSet )
159 [ + - ]: 108 : rSet.MergeValues( aSet );
160 : :
161 [ + + ]: 27498 : if( aSet.Count() )
162 [ + - ]: 16 : aSet.ClearItem();
163 : : }
164 : 27498 : pSet = &aSet;
165 : : }
166 : :
167 : 27498 : } while ( ( pPaM = (SwPaM*)pPaM->GetNext() ) != pStartPaM );
168 : :
169 [ + - ]: 27390 : return sal_True;
170 : : }
171 : :
172 : 27390 : sal_Bool SwEditShell::GetCurAttr( SfxItemSet& rSet,
173 : : const bool bMergeIndentValuesOfNumRule ) const
174 : : {
175 : 27390 : return GetPaMAttr( GetCrsr(), rSet, bMergeIndentValuesOfNumRule );
176 : : }
177 : :
178 : 0 : sal_Bool SwEditShell::GetCurParAttr( SfxItemSet& rSet) const
179 : : {
180 : 0 : return GetPaMParAttr( GetCrsr(), rSet );
181 : : }
182 : :
183 : 0 : sal_Bool SwEditShell::GetPaMParAttr( SwPaM* pPaM, SfxItemSet& rSet ) const
184 : : {
185 : : // number of nodes the function has explored so far
186 : 0 : sal_uInt16 numberOfLookup = 0;
187 : :
188 [ # # ]: 0 : SfxItemSet aSet( *rSet.GetPool(), rSet.GetRanges() );
189 : 0 : SfxItemSet* pSet = &rSet;
190 : :
191 : 0 : SwPaM* pStartPaM = pPaM;
192 [ # # ]: 0 : do { // for all the point and mark (selections)
193 : :
194 : : // get the start and the end node of the current selection
195 : 0 : sal_uLong nSttNd = pPaM->GetMark()->nNode.GetIndex(),
196 : 0 : nEndNd = pPaM->GetPoint()->nNode.GetIndex();
197 : :
198 : : // reverse start and end if there number aren't sorted correctly
199 [ # # ]: 0 : if( nSttNd > nEndNd )
200 : 0 : std::swap(nSttNd, nEndNd);
201 : :
202 : : // for all the nodes in the current selection
203 : : // get the node (paragraph) attributes
204 : : // and merge them in rSet
205 [ # # ]: 0 : for( sal_uLong n = nSttNd; n <= nEndNd; ++n )
206 : : {
207 : : // get the node
208 [ # # ][ # # ]: 0 : SwNode* pNd = GetDoc()->GetNodes()[ n ];
209 : :
210 [ # # ]: 0 : if( pNd->IsTxtNode() )
211 : : {
212 : : // get the node (paragraph) attributes
213 [ # # ][ # # ]: 0 : static_cast<SwCntntNode*>(pNd)->GetAttr(*pSet);
214 : :
215 [ # # ][ # # ]: 0 : if( pSet != &rSet && aSet.Count() )
[ # # ]
216 : : {
217 [ # # ]: 0 : rSet.MergeValues( aSet );
218 [ # # ]: 0 : aSet.ClearItem();
219 : : }
220 : :
221 : 0 : pSet = &aSet;
222 : : }
223 : :
224 : 0 : ++numberOfLookup;
225 : :
226 : : // if the maximum number of node that can be inspected has been reached
227 [ # # ]: 0 : if (numberOfLookup >= getMaxLookup())
228 : 0 : return sal_False;
229 : : }
230 : 0 : } while ( ( pPaM = static_cast<SwPaM*>(pPaM->GetNext()) ) != pStartPaM );
231 : :
232 [ # # ]: 0 : return sal_True;
233 : : }
234 : :
235 : 7224 : SwTxtFmtColl* SwEditShell::GetCurTxtFmtColl( ) const
236 : : {
237 : 7224 : return GetPaMTxtFmtColl( GetCrsr() );
238 : : }
239 : :
240 : 7224 : SwTxtFmtColl* SwEditShell::GetPaMTxtFmtColl( SwPaM* pPaM ) const
241 : : {
242 : : // number of nodes the function have explored so far
243 : 7224 : sal_uInt16 numberOfLookup = 0;
244 : :
245 : 7224 : SwPaM* pStartPaM = pPaM;
246 [ # # ]: 7224 : do { // for all the point and mark (selections)
247 : :
248 : : // get the start and the end node of the current selection
249 : 7224 : sal_uLong nSttNd = pPaM->GetMark()->nNode.GetIndex(),
250 : 7224 : nEndNd = pPaM->GetPoint()->nNode.GetIndex();
251 : :
252 : : // reverse start and end if they aren't sorted correctly
253 [ - + ]: 7224 : if( nSttNd > nEndNd )
254 : 0 : std::swap(nSttNd, nEndNd);
255 : :
256 : : // for all the nodes in the current Point and Mark
257 [ + - ]: 7224 : for( sal_uLong n = nSttNd; n <= nEndNd; ++n )
258 : : {
259 : : // get the node
260 [ + - ][ + - ]: 7224 : SwNode* pNd = GetDoc()->GetNodes()[ n ];
261 : :
262 : 7224 : ++numberOfLookup;
263 : :
264 : : // if the maximum number of node that can be inspected has been reached
265 [ - + ]: 7224 : if (numberOfLookup >= getMaxLookup())
266 : 0 : return NULL;
267 : :
268 [ + - ]: 7224 : if( pNd->IsTxtNode() )
269 : : {
270 : : // if it's a text node get its named paragraph format
271 [ + - ]: 7224 : SwTxtFmtColl* pFmt = static_cast<SwTxtNode*>(pNd)->GetTxtColl();
272 : :
273 : : // if the paragraph format exist stop here and return it
274 [ + - ]: 7224 : if( pFmt != NULL )
275 : 7224 : return pFmt;
276 : : }
277 : : }
278 : 0 : } while ( ( pPaM = static_cast<SwPaM*>(pPaM->GetNext()) ) != pStartPaM );
279 : :
280 : : // if none of the selected node contain a named paragraph format
281 : 7224 : return NULL;
282 : : }
283 : :
284 : :
285 : :
286 : 14 : sal_Bool SwEditShell::GetCurFtn( SwFmtFtn* pFillFtn )
287 : : {
288 : : // der Cursor muss auf dem akt. Fussnoten-Anker stehen:
289 : 14 : SwPaM* pCrsr = GetCrsr();
290 : 14 : SwTxtNode* pTxtNd = pCrsr->GetNode()->GetTxtNode();
291 [ - + ]: 14 : if( !pTxtNd )
292 : 0 : return sal_False;
293 : :
294 : : SwTxtAttr *const pFtn = pTxtNd->GetTxtAttrForCharAt(
295 : 14 : pCrsr->GetPoint()->nContent.GetIndex(), RES_TXTATR_FTN);
296 [ # # ][ - + ]: 14 : if( pFtn && pFillFtn )
297 : : {
298 : : // Daten vom Attribut uebertragen
299 : 0 : const SwFmtFtn &rFtn = ((SwTxtFtn*)pFtn)->GetFtn();
300 : 0 : pFillFtn->SetNumber( rFtn );
301 : 0 : pFillFtn->SetEndNote( rFtn.IsEndNote() );
302 : : }
303 : 14 : return 0 != pFtn;
304 : : }
305 : :
306 : :
307 : 0 : bool SwEditShell::SetCurFtn( const SwFmtFtn& rFillFtn )
308 : : {
309 : 0 : bool bChgd = false;
310 : 0 : StartAllAction();
311 : :
312 : 0 : SwPaM* pCrsr = GetCrsr(), *pFirst = pCrsr;
313 [ # # ]: 0 : do {
314 : 0 : bChgd |= pDoc->SetCurFtn( *pCrsr, rFillFtn.GetNumStr(),
315 : 0 : rFillFtn.GetNumber(),
316 : 0 : rFillFtn.IsEndNote() );
317 : :
318 : 0 : } while( pFirst != ( pCrsr = (SwPaM*)pCrsr->GetNext() ));
319 : :
320 : 0 : EndAllAction();
321 : 0 : return bChgd;
322 : : }
323 : :
324 : :
325 : 0 : bool SwEditShell::HasFtns( bool bEndNotes ) const
326 : : {
327 : 0 : const SwFtnIdxs &rIdxs = pDoc->GetFtnIdxs();
328 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < rIdxs.size(); ++i )
329 : : {
330 : 0 : const SwFmtFtn &rFtn = rIdxs[i]->GetFtn();
331 [ # # ]: 0 : if ( bEndNotes == rFtn.IsEndNote() )
332 : 0 : return sal_True;
333 : : }
334 : 0 : return sal_False;
335 : : }
336 : :
337 : :
338 : : // gebe Liste aller Fussnoten und deren Anfangstexte
339 : 0 : sal_uInt16 SwEditShell::GetSeqFtnList( SwSeqFldList& rList, bool bEndNotes )
340 : : {
341 : 0 : rList.Clear();
342 : :
343 : 0 : sal_uInt16 n, nFtnCnt = pDoc->GetFtnIdxs().size();
344 : : SwTxtFtn* pTxtFtn;
345 [ # # ]: 0 : for( n = 0; n < nFtnCnt; ++n )
346 : : {
347 : 0 : pTxtFtn = pDoc->GetFtnIdxs()[ n ];
348 : 0 : const SwFmtFtn& rFtn = pTxtFtn->GetFtn();
349 [ # # ]: 0 : if ( rFtn.IsEndNote() != bEndNotes )
350 : 0 : continue;
351 : :
352 : 0 : SwNodeIndex* pIdx = pTxtFtn->GetStartNode();
353 [ # # ]: 0 : if( pIdx )
354 : : {
355 [ # # ]: 0 : SwNodeIndex aIdx( *pIdx, 1 );
356 : 0 : SwTxtNode* pTxtNd = aIdx.GetNode().GetTxtNode();
357 [ # # ]: 0 : if( !pTxtNd )
358 [ # # ][ # # ]: 0 : pTxtNd = (SwTxtNode*)pDoc->GetNodes().GoNext( &aIdx );
359 : :
360 [ # # ]: 0 : if( pTxtNd )
361 : : {
362 [ # # ]: 0 : String sTxt( rFtn.GetViewNumStr( *pDoc ));
363 [ # # ]: 0 : if( sTxt.Len() )
364 [ # # ]: 0 : sTxt += ' ';
365 [ # # ][ # # ]: 0 : sTxt += pTxtNd->GetExpandTxt( 0, USHRT_MAX );
[ # # ]
366 : :
367 : : _SeqFldLstElem* pNew = new _SeqFldLstElem( sTxt,
368 [ # # ][ # # ]: 0 : pTxtFtn->GetSeqRefNo() );
369 [ # # ][ # # ]: 0 : while( rList.InsertSort( pNew ) )
370 [ # # ][ # # ]: 0 : pNew->sDlgEntry += ' ';
371 [ # # ]: 0 : }
372 : : }
373 : : }
374 : :
375 : 0 : return rList.Count();
376 : : }
377 : :
378 : :
379 : : // Adjust left margin via object bar (similar to adjustment of numerations).
380 : 2686 : sal_Bool SwEditShell::IsMoveLeftMargin( sal_Bool bRight, sal_Bool bModulus ) const
381 : : {
382 : 2686 : sal_Bool bRet = sal_True;
383 : :
384 : : const SvxTabStopItem& rTabItem = (SvxTabStopItem&)GetDoc()->
385 : 2686 : GetDefault( RES_PARATR_TABSTOP );
386 [ + - ]: 2686 : sal_uInt16 nDefDist = static_cast<sal_uInt16>(rTabItem.Count() ? rTabItem[0].GetTabPos() : 1134);
387 [ - + ]: 2686 : if( !nDefDist )
388 : 0 : return sal_False;
389 : :
390 [ + + ]: 5420 : FOREACHPAM_START(this)
391 : :
392 : 2734 : sal_uLong nSttNd = PCURCRSR->GetMark()->nNode.GetIndex(),
393 : 2734 : nEndNd = PCURCRSR->GetPoint()->nNode.GetIndex();
394 : :
395 [ - + ]: 2734 : if( nSttNd > nEndNd )
396 : 0 : std::swap(nSttNd, nEndNd);
397 : :
398 : : SwCntntNode* pCNd;
399 [ + + ][ + + ]: 5468 : for( sal_uLong n = nSttNd; bRet && n <= nEndNd; ++n )
[ + + ]
400 [ + - ][ + - ]: 2734 : if( 0 != ( pCNd = GetDoc()->GetNodes()[ n ]->GetTxtNode() ))
[ + - ]
401 : : {
402 : : const SvxLRSpaceItem& rLS = (SvxLRSpaceItem&)
403 [ + - ]: 2734 : pCNd->GetAttr( RES_LR_SPACE );
404 [ + + ]: 2734 : if( bRight )
405 : : {
406 : 1367 : long nNext = rLS.GetTxtLeft() + nDefDist;
407 [ + - ]: 1367 : if( bModulus )
408 : 1367 : nNext = ( nNext / nDefDist ) * nDefDist;
409 [ + - ][ + - ]: 1367 : SwFrm* pFrm = pCNd->getLayoutFrm( GetLayout() );
410 [ + - ]: 1367 : if ( pFrm )
411 : : {
412 [ + - ]: 1367 : const sal_uInt16 nFrmWidth = static_cast<sal_uInt16>( pFrm->IsVertical() ?
413 : 0 : pFrm->Frm().Height() :
414 [ - + ]: 1367 : pFrm->Frm().Width() );
415 : 1367 : bRet = nFrmWidth > ( nNext + MM50 );
416 : : }
417 : : else
418 : 0 : bRet = sal_False;
419 : : }
420 : : }
421 : :
422 [ + + ]: 2734 : if( !bRet )
423 : : break;
424 : :
425 : 2728 : FOREACHPAM_END()
426 : 2686 : return bRet;
427 : : }
428 : :
429 : 0 : void SwEditShell::MoveLeftMargin( sal_Bool bRight, sal_Bool bModulus )
430 : : {
431 : 0 : StartAllAction();
432 : 0 : StartUndo( UNDO_START );
433 : :
434 : 0 : SwPaM* pCrsr = GetCrsr();
435 [ # # ]: 0 : if( pCrsr->GetNext() != pCrsr ) // Mehrfachselektion ?
436 : : {
437 [ # # ]: 0 : SwPamRanges aRangeArr( *pCrsr );
438 [ # # ]: 0 : SwPaM aPam( *pCrsr->GetPoint() );
439 [ # # ]: 0 : for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n )
440 [ # # ]: 0 : GetDoc()->MoveLeftMargin( aRangeArr.SetPam( n, aPam ),
441 [ # # ][ # # ]: 0 : bRight, bModulus );
442 : : }
443 : : else
444 : 0 : GetDoc()->MoveLeftMargin( *pCrsr, bRight, bModulus );
445 : :
446 : 0 : EndUndo( UNDO_END );
447 : 0 : EndAllAction();
448 : 0 : }
449 : :
450 : :
451 : 6350 : inline sal_uInt16 lcl_SetScriptFlags( sal_uInt16 nType )
452 : : {
453 : : sal_uInt16 nRet;
454 [ + - - + ]: 6350 : switch( nType )
455 : : {
456 : 6344 : case ::com::sun::star::i18n::ScriptType::LATIN: nRet = SCRIPTTYPE_LATIN; break;
457 : 0 : case ::com::sun::star::i18n::ScriptType::ASIAN: nRet = SCRIPTTYPE_ASIAN; break;
458 : 0 : case ::com::sun::star::i18n::ScriptType::COMPLEX: nRet = SCRIPTTYPE_COMPLEX; break;
459 : 6 : default: nRet = 0;
460 : : }
461 : 6350 : return nRet;
462 : : }
463 : :
464 : 8261 : sal_Bool lcl_IsNoEndTxtAttrAtPos( const SwTxtNode& rTNd, xub_StrLen nPos,
465 : : sal_uInt16 &rScrpt, sal_Bool bInSelection, sal_Bool bNum )
466 : : {
467 : 8261 : sal_Bool bRet = sal_False;
468 : 8261 : const String& rTxt = rTNd.GetTxt();
469 [ + - ]: 8261 : String sExp;
470 : :
471 : : // consider numbering
472 [ - + ]: 8261 : if ( bNum )
473 : : {
474 : 0 : bRet = sal_False;
475 : :
476 [ # # ][ # # ]: 0 : if ( rTNd.IsInList() )
477 : : {
478 : : OSL_ENSURE( rTNd.GetNumRule(),
479 : : "<lcl_IsNoEndTxtAttrAtPos(..)> - no list style found at text node. Serious defect -> please inform OD." );
480 [ # # ]: 0 : const SwNumRule* pNumRule = rTNd.GetNumRule();
481 [ # # ]: 0 : if(pNumRule)
482 : : {
483 [ # # ][ # # ]: 0 : const SwNumFmt &rNumFmt = pNumRule->Get( static_cast<sal_uInt16>(rTNd.GetActualListLevel()) );
484 [ # # ]: 0 : if( SVX_NUM_BITMAP != rNumFmt.GetNumberingType() )
485 : : {
486 [ # # ]: 0 : if ( SVX_NUM_CHAR_SPECIAL == rNumFmt.GetNumberingType() )
487 [ # # ]: 0 : sExp = rNumFmt.GetBulletChar();
488 : : else
489 [ # # ][ # # ]: 0 : sExp = rTNd.GetNumString();
[ # # ]
490 : : }
491 : : }
492 : : }
493 : : }
494 : :
495 : : // and fields
496 [ + + ]: 8261 : if ( CH_TXTATR_BREAKWORD == rTxt.GetChar( nPos ) )
497 : : {
498 [ + - ]: 1926 : const SwTxtAttr* const pAttr = rTNd.GetTxtAttrForCharAt( nPos );
499 [ + - ]: 1926 : if (pAttr)
500 : : {
501 : 1926 : bRet = sal_True; // all other than fields can be
502 : : // defined as weak-script ?
503 [ + - ][ + + ]: 1926 : if ( RES_TXTATR_FIELD == pAttr->Which() )
504 : : {
505 : 39 : const SwField* const pFld = pAttr->GetFld().GetFld();
506 [ + - ]: 39 : if (pFld)
507 : : {
508 [ + - ][ + - ]: 39 : sExp += pFld->ExpandField(true);
[ + - ]
509 : : }
510 : : }
511 : : }
512 : : }
513 : :
514 : 8261 : xub_StrLen nEnd = sExp.Len();
515 [ + + ]: 8261 : if ( nEnd )
516 : : {
517 : : xub_StrLen n;
518 [ - + ]: 15 : if( bInSelection )
519 : : {
520 : : sal_uInt16 nScript;
521 [ # # ]: 0 : for( n = 0; n < nEnd; n = (xub_StrLen)
522 [ # # ][ # # ]: 0 : pBreakIt->GetBreakIter()->endOfScript( sExp, n, nScript ))
[ # # ][ # # ]
523 : : {
524 [ # # ][ # # ]: 0 : nScript = pBreakIt->GetBreakIter()->getScriptType( sExp, n );
[ # # ][ # # ]
525 : 0 : rScrpt |= lcl_SetScriptFlags( nScript );
526 : : }
527 : : }
528 : : else
529 [ + - ][ + - ]: 30 : rScrpt |= lcl_SetScriptFlags( pBreakIt->GetBreakIter()->
530 [ + - ][ + - ]: 15 : getScriptType( sExp, nEnd-1 ));
531 : : }
532 : :
533 [ + - ]: 8261 : return bRet;
534 : : }
535 : :
536 : :
537 : : // returns the scripttpye of the selection
538 : 8177 : sal_uInt16 SwEditShell::GetScriptType() const
539 : : {
540 : 8177 : sal_uInt16 nRet = 0;
541 : :
542 : : {
543 [ + - ][ + + ]: 16438 : FOREACHPAM_START(this)
544 : :
545 [ + - ]: 8261 : const SwPosition *pStt = PCURCRSR->Start(),
546 : 8261 : *pEnd = pStt == PCURCRSR->GetMark()
547 : : ? PCURCRSR->GetPoint()
548 [ + + ]: 8261 : : PCURCRSR->GetMark();
549 [ + + ][ + - ]: 8261 : if( pStt == pEnd || *pStt == *pEnd )
[ + - ][ + - ]
550 : : {
551 : 8261 : const SwTxtNode* pTNd = pStt->nNode.GetNode().GetTxtNode();
552 [ + - ]: 8261 : if( pTNd )
553 : : {
554 : : // try to get SwScriptInfo
555 [ + - ]: 8261 : const SwScriptInfo* pScriptInfo = SwScriptInfo::GetScriptInfo( *pTNd );
556 : :
557 : 8261 : xub_StrLen nPos = pStt->nContent.GetIndex();
558 : : //Task 90448: we need the scripttype of the previous
559 : : // position, if no selection exist!
560 [ + + ]: 8261 : if( nPos )
561 : : {
562 [ + - ]: 2733 : SwIndex aIdx( pStt->nContent );
563 [ + - ][ + - ]: 2733 : if( pTNd->GoPrevious( &aIdx, CRSR_SKIP_CHARS ) )
564 [ + - ]: 2733 : nPos = aIdx.GetIndex();
565 : : }
566 : :
567 : : sal_uInt16 nScript;
568 : :
569 [ + + ]: 8261 : if ( pTNd->GetTxt().Len() )
570 : : {
571 : : nScript = pScriptInfo ?
572 [ + - ]: 2795 : pScriptInfo->ScriptType( nPos ) :
573 [ + + ][ + - ]: 5614 : pBreakIt->GetBreakIter()->getScriptType( pTNd->GetTxt(), nPos );
[ + - ][ + - ]
[ + - ][ + + ]
[ + + ]
[ # # # # ]
574 : : }
575 : : else
576 [ + - ][ + - ]: 5442 : nScript = GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() );
577 : :
578 [ + - ][ + + ]: 8261 : if( !lcl_IsNoEndTxtAttrAtPos( *pTNd, nPos, nRet, sal_False, sal_False ))
579 : 6335 : nRet |= lcl_SetScriptFlags( nScript );
580 : : }
581 : : }
582 [ # # ][ # # ]: 0 : else if ( pBreakIt->GetBreakIter().is() )
583 : : {
584 : 0 : sal_uLong nEndIdx = pEnd->nNode.GetIndex();
585 [ # # ]: 0 : SwNodeIndex aIdx( pStt->nNode );
586 [ # # ][ # # ]: 0 : for( ; aIdx.GetIndex() <= nEndIdx; aIdx++ )
587 [ # # ]: 0 : if( aIdx.GetNode().IsTxtNode() )
588 : : {
589 : 0 : const SwTxtNode* pTNd = aIdx.GetNode().GetTxtNode();
590 : 0 : const String& rTxt = pTNd->GetTxt();
591 : :
592 : : // try to get SwScriptInfo
593 [ # # ]: 0 : const SwScriptInfo* pScriptInfo = SwScriptInfo::GetScriptInfo( *pTNd );
594 : :
595 : 0 : xub_StrLen nChg = aIdx == pStt->nNode
596 : 0 : ? pStt->nContent.GetIndex()
597 [ # # ]: 0 : : 0,
598 : 0 : nEndPos = aIdx == nEndIdx
599 : 0 : ? pEnd->nContent.GetIndex()
600 [ # # ]: 0 : : rTxt.Len();
601 : :
602 : : OSL_ENSURE( nEndPos <= rTxt.Len(), "Index outside the range - endless loop!" );
603 [ # # ]: 0 : if( nEndPos > rTxt.Len() )
604 : 0 : nEndPos = rTxt.Len();
605 : :
606 : : sal_uInt16 nScript;
607 [ # # ]: 0 : while( nChg < nEndPos )
608 : : {
609 : : nScript = pScriptInfo ?
610 [ # # ]: 0 : pScriptInfo->ScriptType( nChg ) :
611 [ # # ][ # # ]: 0 : pBreakIt->GetBreakIter()->getScriptType(
[ # # ][ # # ]
612 [ # # ][ # # ]: 0 : rTxt, nChg );
[ # # ][ # # ]
[ # # ]
613 : :
614 [ # # ]: 0 : if( !lcl_IsNoEndTxtAttrAtPos( *pTNd, nChg, nRet, sal_True,
615 [ # # ][ # # ]: 0 : 0 == nChg && rTxt.Len() == nEndPos ) )
[ # # ]
616 : 0 : nRet |= lcl_SetScriptFlags( nScript );
617 : :
618 [ # # ]: 0 : if( (SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN |
619 : : SCRIPTTYPE_COMPLEX) == nRet )
620 : 0 : break;
621 : :
622 : 0 : xub_StrLen nFldPos = nChg+1;
623 : :
624 : : nChg = pScriptInfo ?
625 : 0 : pScriptInfo->NextScriptChg( nChg ) :
626 [ # # ][ # # ]: 0 : (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript(
[ # # ][ # # ]
627 [ # # ][ # # ]: 0 : rTxt, nChg, nScript );
[ # # ][ # # ]
[ # # ][ # # ]
628 : :
629 : : nFldPos = rTxt.Search(
630 [ # # ]: 0 : CH_TXTATR_BREAKWORD, nFldPos );
631 [ # # ]: 0 : if( nFldPos < nChg )
632 : 0 : nChg = nFldPos;
633 : : }
634 [ # # ]: 0 : if( (SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN |
635 : : SCRIPTTYPE_COMPLEX) == nRet )
636 : 0 : break;
637 [ # # ]: 0 : }
638 : : }
639 [ - + ]: 8261 : if( (SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN |
640 : : SCRIPTTYPE_COMPLEX) == nRet )
641 : 0 : break;
642 : :
643 : 8261 : FOREACHPAM_END()
644 : : }
645 [ + + ]: 8177 : if( !nRet )
646 [ + - ]: 1917 : nRet = SvtLanguageOptions::GetScriptTypeOfLanguage( LANGUAGE_SYSTEM );
647 : 8177 : return nRet;
648 : : }
649 : :
650 : :
651 : 0 : sal_uInt16 SwEditShell::GetCurLang() const
652 : : {
653 : 0 : const SwPaM* pCrsr = GetCrsr();
654 : 0 : const SwPosition& rPos = *pCrsr->GetPoint();
655 : 0 : const SwTxtNode* pTNd = rPos.nNode.GetNode().GetTxtNode();
656 : : sal_uInt16 nLang;
657 [ # # ]: 0 : if( pTNd )
658 : : {
659 : : //JP 24.9.2001: if exist no selection, then get the language before
660 : : // the current character!
661 : 0 : xub_StrLen nPos = rPos.nContent.GetIndex();
662 [ # # ][ # # ]: 0 : if( nPos && !pCrsr->HasMark() )
[ # # ]
663 : 0 : --nPos;
664 : 0 : nLang = pTNd->GetLang( nPos );
665 : : }
666 : : else
667 : 0 : nLang = LANGUAGE_DONTKNOW;
668 : 0 : return nLang;
669 : : }
670 : :
671 : 0 : sal_uInt16 SwEditShell::GetScalingOfSelectedText() const
672 : : {
673 : 0 : const SwPaM* pCrsr = GetCrsr();
674 : 0 : const SwPosition* pStt = pCrsr->Start();
675 : 0 : const SwTxtNode* pTNd = pStt->nNode.GetNode().GetTxtNode();
676 : : OSL_ENSURE( pTNd, "no textnode available" );
677 : :
678 : : sal_uInt16 nScaleWidth;
679 [ # # ]: 0 : if( pTNd )
680 : : {
681 : 0 : xub_StrLen nStt = pStt->nContent.GetIndex(), nEnd;
682 : 0 : const SwPosition* pEnd = pStt == pCrsr->GetPoint()
683 : : ? pCrsr->GetMark()
684 [ # # ]: 0 : : pCrsr->GetPoint();
685 [ # # ]: 0 : if( pStt->nNode == pEnd->nNode )
686 : 0 : nEnd = pEnd->nContent.GetIndex();
687 : : else
688 : 0 : nEnd = pTNd->GetTxt().Len();
689 : 0 : nScaleWidth = pTNd->GetScalingOfSelectedText( nStt, nEnd );
690 : : }
691 : : else
692 : 0 : nScaleWidth = 100; // default are no scaling -> 100%
693 : 0 : return nScaleWidth;
694 : : }
695 : :
696 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|