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 : :
30 : : #include <ctype.h>
31 : : #include <hintids.hxx>
32 : :
33 : : #include <unotools/charclass.hxx>
34 : :
35 : : #include <vcl/msgbox.hxx>
36 : :
37 : : #include <editeng/boxitem.hxx>
38 : : #include <editeng/lrspitem.hxx>
39 : : #include <editeng/brkitem.hxx>
40 : : #include <editeng/adjitem.hxx>
41 : : #include <editeng/tstpitem.hxx>
42 : : #include <editeng/fontitem.hxx>
43 : : #include <editeng/langitem.hxx>
44 : : #include <editeng/cscoitem.hxx>
45 : : #include <editeng/unolingu.hxx>
46 : : #include <editeng/acorrcfg.hxx>
47 : :
48 : : #include <swwait.hxx>
49 : : #include <fmtpdsc.hxx>
50 : : #include <fmtanchr.hxx>
51 : : #include <doc.hxx>
52 : : #include <IDocumentUndoRedo.hxx>
53 : : #include <docary.hxx>
54 : : #include <editsh.hxx>
55 : : #include <index.hxx>
56 : : #include <pam.hxx>
57 : : #include <edimp.hxx>
58 : : #include <fesh.hxx>
59 : : #include <swundo.hxx> // for the UndoId's
60 : : #include <poolfmt.hxx>
61 : : #include <ndtxt.hxx>
62 : : #include <txtfrm.hxx>
63 : : #include <frminf.hxx>
64 : : #include <pagedesc.hxx>
65 : : #include <paratr.hxx>
66 : : #include <swtable.hxx>
67 : : #include <acorrect.hxx>
68 : : #include <shellres.hxx>
69 : : #include <section.hxx>
70 : : #include <frmatr.hxx>
71 : : #include <charatr.hxx>
72 : : #include <mdiexp.hxx>
73 : : #include <statstr.hrc>
74 : : #include <comcore.hrc>
75 : : #include <numrule.hxx>
76 : :
77 : : using namespace ::com::sun::star;
78 : :
79 : : //-------------------------------------------------------------------
80 : :
81 : : //JP 16.12.99: definition:
82 : : // from pos cPosEnDash to cPosEmDash all chars changed to endashes,
83 : : // from pos cPosEmDash to cPosEnd all chars changed to emdashes
84 : : // all other chars are changed to the user configuration
85 : :
86 : : const sal_Unicode pBulletChar[6] = { '+', '*', '-', 0x2013, 0x2014, 0 };
87 : : const int cnPosEnDash = 2, cnPosEmDash = 4, cnPosEnd = 5;
88 : :
89 : : const sal_Unicode cStarSymbolEnDash = 0x2013;
90 : : const sal_Unicode cStarSymbolEmDash = 0x2014;
91 : :
92 : :
93 : : SvxSwAutoFmtFlags* SwEditShell::pAutoFmtFlags = 0;
94 : :
95 : : // Number of num-/bullet-paragraph templates. MAXLEVEL will soon be raised
96 : : // to x, but not the number of templates. (Artifact from <= 4.0)
97 : : const sal_uInt16 cnNumBullColls = 4;
98 : :
99 : : class SwAutoFormat
100 : : {
101 : : SvxSwAutoFmtFlags aFlags;
102 : : SwPaM aDelPam; // a Pam that can be used
103 : : SwNodeIndex aNdIdx; // the index on the current TextNode
104 : : SwNodeIndex aEndNdIdx; // index on the end of the area
105 : :
106 : : SwEditShell* pEditShell;
107 : : SwDoc* pDoc;
108 : : SwTxtNode* pAktTxtNd; // the current TextNode
109 : : SwTxtFrm* pAktTxtFrm; // frame of the current TextNode
110 : : CharClass* pCharClass; // Character classification
111 : : sal_uLong nEndNdIdx; // for the percentage-display
112 : : LanguageType eCharClassLang;
113 : :
114 : : sal_uInt16 nLastHeadLvl, nLastCalcHeadLvl;
115 : : sal_uInt16 nLastEnumLvl, nLastCalcEnumLvl;
116 : : sal_uInt16 nRedlAutoFmtSeqId;
117 : :
118 : : enum
119 : : {
120 : : NONE = 0,
121 : : DELIM = 1,
122 : : DIGIT = 2,
123 : : CHG = 4,
124 : : LOWER_ALPHA = 8,
125 : : UPPER_ALPHA = 16,
126 : : LOWER_ROMAN = 32,
127 : : UPPER_ROMAN = 64,
128 : : NO_DELIM = (DIGIT|LOWER_ALPHA|UPPER_ALPHA|LOWER_ROMAN|UPPER_ROMAN)
129 : : };
130 : :
131 : : enum Format_Status
132 : : {
133 : : READ_NEXT_PARA,
134 : : TST_EMPTY_LINE,
135 : : TST_ALPHA_LINE,
136 : : GET_ALL_INFO,
137 : : IS_ONE_LINE,
138 : : TST_ENUMERIC,
139 : : TST_IDENT,
140 : : TST_NEG_IDENT,
141 : : TST_TXT_BODY,
142 : : HAS_FMTCOLL,
143 : : IS_ENDE
144 : : } eStat;
145 : :
146 : : sal_Bool bEnde : 1;
147 : : sal_Bool bEmptyLine : 1;
148 : : sal_Bool bMoreLines : 1;
149 : :
150 : : static sal_Bool m_bAskForCancelUndoWhileBufferOverflow;
151 : : static short m_nActionWhileAutoformatUndoBufferOverflow;
152 : :
153 : :
154 : : // ------------- private methods -----------------------------
155 : : void _GetCharClass( LanguageType eLang );
156 : 0 : CharClass& GetCharClass( LanguageType eLang ) const
157 : : {
158 [ # # ][ # # ]: 0 : if( !pCharClass || eLang != eCharClassLang )
159 : : {
160 : 0 : SwAutoFormat* pThis = (SwAutoFormat*)this;
161 : 0 : pThis->_GetCharClass( eLang );
162 : : }
163 : 0 : return *pCharClass;
164 : : }
165 : :
166 : :
167 : 0 : sal_Bool IsSpace( const sal_Unicode c ) const
168 [ # # ][ # # ]: 0 : { return (' ' == c || '\t' == c || 0x0a == c|| 0x3000 == c /* Jap. space */) ? sal_True : sal_False; }
[ # # ][ # # ]
169 : :
170 : : void SetColl( sal_uInt16 nId, sal_Bool bHdLineOrText = sal_False );
171 : : String GoNextPara();
172 : : sal_Bool HasObjects( const SwNode& rNd );
173 : :
174 : : // TxtNode methods
175 : : const SwTxtNode* GetNextNode() const;
176 : 0 : sal_Bool IsEmptyLine( const SwTxtNode& rNd ) const
177 : 0 : { return 0 == rNd.GetTxt().Len() ||
178 [ # # ][ # # ]: 0 : rNd.GetTxt().Len() == GetLeadingBlanks( rNd.GetTxt() ); }
179 : :
180 : : sal_Bool IsOneLine( const SwTxtNode& ) const;
181 : : sal_Bool IsFastFullLine( const SwTxtNode& ) const;
182 : : sal_Bool IsNoAlphaLine( const SwTxtNode&) const;
183 : : sal_Bool IsEnumericChar( const SwTxtNode&) const;
184 : : sal_Bool IsBlanksInString( const SwTxtNode&) const;
185 : : sal_uInt16 CalcLevel( const SwTxtNode&, sal_uInt16 *pDigitLvl = 0 ) const;
186 : : xub_StrLen GetBigIndent( xub_StrLen& rAktSpacePos ) const;
187 : :
188 : : String& DelLeadingBlanks( String& rStr ) const;
189 : : String& DelTrailingBlanks( String& rStr ) const;
190 : : xub_StrLen GetLeadingBlanks( const String& rStr ) const;
191 : : xub_StrLen GetTrailingBlanks( const String& rStr ) const;
192 : :
193 : : sal_Bool IsFirstCharCapital( const SwTxtNode& rNd ) const;
194 : : sal_uInt16 GetDigitLevel( const SwTxtNode& rTxtNd, xub_StrLen& rPos,
195 : : String* pPreFix = 0, String* pPostFix = 0,
196 : : String* pNumTypes = 0 ) const;
197 : : // get the FORMATED TextFrame
198 : : SwTxtFrm* GetFrm( const SwTxtNode& rTxtNd ) const;
199 : :
200 : : void BuildIndent();
201 : : void BuildText();
202 : : void BuildTextIndent();
203 : : void BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel );
204 : : void BuildNegIndent( SwTwips nSpaces );
205 : : void BuildHeadLine( sal_uInt16 nLvl );
206 : :
207 : : sal_Bool HasSelBlanks( SwPaM& rPam ) const;
208 : : sal_Bool HasBreakAttr( const SwTxtNode& ) const;
209 : : void DeleteSel( SwPaM& rPam );
210 : : sal_Bool DeleteAktNxtPara( const String& rNxtPara );
211 : : // delete in the node start and/or end
212 : : void DeleteAktPara( sal_Bool bStart = sal_True, sal_Bool nEnd = sal_True );
213 : : void DelEmptyLine( sal_Bool bTstNextPara = sal_True );
214 : : // when using multiline paragraphs delete the "left" and/or
215 : : // "right" margins
216 : : void DelMoreLinesBlanks( sal_Bool bWithLineBreaks = sal_False );
217 : : // delete the previous paragraph
218 : : void DelPrevPara();
219 : : // execute AutoCorrect on current TextNode
220 : : void AutoCorrect( xub_StrLen nSttPos = 0 );
221 : :
222 : 0 : sal_Bool CanJoin( const SwTxtNode* pTxtNd ) const
223 : : {
224 : 0 : return !bEnde && pTxtNd &&
225 : 0 : !IsEmptyLine( *pTxtNd ) &&
226 : 0 : !IsNoAlphaLine( *pTxtNd) &&
227 : 0 : !IsEnumericChar( *pTxtNd ) &&
228 : 0 : ((STRING_MAXLEN - 50 - pTxtNd->GetTxt().Len()) >
229 : 0 : pAktTxtNd->GetTxt().Len()) &&
230 [ # # ][ # # : 0 : !HasBreakAttr( *pTxtNd );
# # # # #
# # # ]
[ # # ]
231 : : }
232 : :
233 : : // is a dot at the end ??
234 : : sal_Bool IsSentenceAtEnd( const SwTxtNode& rTxtNd ) const;
235 : :
236 : : sal_Bool DoUnderline();
237 : : sal_Bool DoTable();
238 : :
239 : : void _SetRedlineTxt( sal_uInt16 nId );
240 : 0 : sal_Bool SetRedlineTxt( sal_uInt16 nId )
241 [ # # ]: 0 : { if( aFlags.bWithRedlining ) _SetRedlineTxt( nId ); return sal_True; }
242 : 0 : sal_Bool ClearRedlineTxt()
243 [ # # ]: 0 : { if( aFlags.bWithRedlining ) pDoc->SetAutoFmtRedlineComment(0); return sal_True; }
244 : :
245 : : public:
246 : : SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFmtFlags& rFlags,
247 : : SwNodeIndex* pSttNd = 0, SwNodeIndex* pEndNd = 0 );
248 [ # # ][ # # ]: 0 : ~SwAutoFormat() {
[ # # ]
249 [ # # ][ # # ]: 0 : delete pCharClass;
250 : 0 : }
251 : : };
252 : :
253 : : sal_Bool SwAutoFormat::m_bAskForCancelUndoWhileBufferOverflow = sal_True;
254 : : short SwAutoFormat::m_nActionWhileAutoformatUndoBufferOverflow = RET_YES;
255 : :
256 : 0 : const sal_Unicode* StrChr( const sal_Unicode* pSrc, sal_Unicode c )
257 : : {
258 [ # # ][ # # ]: 0 : while( *pSrc && *pSrc != c )
[ # # ]
259 : 0 : ++pSrc;
260 [ # # ]: 0 : return *pSrc ? pSrc : 0;
261 : : }
262 : :
263 : 0 : SwTxtFrm* SwAutoFormat::GetFrm( const SwTxtNode& rTxtNd ) const
264 : : {
265 : : // get the Frame
266 : 0 : const SwCntntFrm *pFrm = rTxtNd.getLayoutFrm( pEditShell->GetLayout() );
267 : : OSL_ENSURE( pFrm, "zum Autoformat muss das Layout vorhanden sein" );
268 [ # # ][ # # ]: 0 : if( aFlags.bAFmtByInput && !pFrm->IsValid() )
[ # # ]
269 : : {
270 : 0 : SwRect aTmpFrm( pFrm->Frm() );
271 : 0 : SwRect aTmpPrt( pFrm->Prt() );
272 [ # # ]: 0 : pFrm->Calc();
273 [ # # ][ # # : 0 : if( pFrm->Frm() != aTmpFrm || pFrm->Prt() != aTmpPrt ||
# # # # ]
[ # # ]
274 [ # # ][ # # ]: 0 : ( pFrm->IsTxtFrm() && !((SwTxtFrm*)pFrm)->Paint().IsEmpty() ) )
[ # # ]
275 : 0 : pFrm->SetCompletePaint();
276 : : }
277 : 0 : return ((SwTxtFrm*)pFrm)->GetFormatted();
278 : : }
279 : :
280 : 0 : void SwAutoFormat::_GetCharClass( LanguageType eLang )
281 : : {
282 [ # # ]: 0 : delete pCharClass;
283 [ # # ][ # # ]: 0 : pCharClass = new CharClass( SvxCreateLocale( eLang ));
284 : 0 : eCharClassLang = eLang;
285 : 0 : }
286 : :
287 : 0 : void SwAutoFormat::_SetRedlineTxt( sal_uInt16 nActionId )
288 : : {
289 [ # # ]: 0 : String sTxt;
290 : 0 : sal_uInt16 nSeqNo = 0;
291 [ # # ]: 0 : if( STR_AUTOFMTREDL_END > nActionId )
292 : : {
293 [ # # ][ # # ]: 0 : sTxt = ViewShell::GetShellRes()->GetAutoFmtNameLst()[ nActionId ];
[ # # ][ # # ]
294 [ # # ]: 0 : switch( nActionId )
295 : : {
296 : : case STR_AUTOFMTREDL_SET_NUMBULET:
297 : : case STR_AUTOFMTREDL_DEL_MORELINES:
298 : :
299 : : // AutoCorrect-Actions
300 : : case STR_AUTOFMTREDL_USE_REPLACE:
301 : : case STR_AUTOFMTREDL_CPTL_STT_WORD:
302 : : case STR_AUTOFMTREDL_CPTL_STT_SENT:
303 : : case STR_AUTOFMTREDL_TYPO:
304 : : case STR_AUTOFMTREDL_UNDER:
305 : : case STR_AUTOFMTREDL_BOLD:
306 : : case STR_AUTOFMTREDL_FRACTION:
307 : : case STR_AUTOFMTREDL_DASH:
308 : : case STR_AUTOFMTREDL_ORDINAL:
309 : : case STR_AUTOFMTREDL_NON_BREAK_SPACE:
310 : 0 : nSeqNo = ++nRedlAutoFmtSeqId;
311 : 0 : break;
312 : : }
313 : : }
314 : : #if OSL_DEBUG_LEVEL > 0
315 : : else
316 : : sTxt = rtl::OUString("Action-Text fehlt");
317 : : #endif
318 : :
319 [ # # ][ # # ]: 0 : pDoc->SetAutoFmtRedlineComment( &sTxt, nSeqNo );
320 : 0 : }
321 : :
322 : 0 : String SwAutoFormat::GoNextPara()
323 : : {
324 : 0 : SwNode* pNewNd = 0;
325 [ # # ]: 0 : do {
326 : : //has to be checed twice before and after incrementation
327 [ # # ]: 0 : if( aNdIdx.GetIndex() >= aEndNdIdx.GetIndex() )
328 : : {
329 : 0 : bEnde = sal_True;
330 : 0 : return aEmptyStr;
331 : : }
332 : :
333 : 0 : aNdIdx++;
334 [ # # ]: 0 : if( aNdIdx.GetIndex() >= aEndNdIdx.GetIndex() )
335 : : {
336 : 0 : bEnde = sal_True;
337 : 0 : return aEmptyStr;
338 : : }
339 : : else
340 : 0 : pNewNd = &aNdIdx.GetNode();
341 : :
342 : : // not a TextNode ->
343 : : // TableNode : skip table
344 : : // NoTxtNode : skip nodes
345 : : // EndNode : at the end, terminate
346 [ # # ]: 0 : if( pNewNd->IsEndNode() )
347 : : {
348 : 0 : bEnde = sal_True;
349 : 0 : return aEmptyStr;
350 : : }
351 [ # # ]: 0 : else if( pNewNd->IsTableNode() )
352 : 0 : aNdIdx = *pNewNd->EndOfSectionNode();
353 [ # # ]: 0 : else if( pNewNd->IsSectionNode() )
354 : : {
355 : 0 : const SwSection& rSect = pNewNd->GetSectionNode()->GetSection();
356 [ # # ][ # # ]: 0 : if( rSect.IsHiddenFlag() || rSect.IsProtectFlag() )
[ # # ]
357 : 0 : aNdIdx = *pNewNd->EndOfSectionNode();
358 : : }
359 : 0 : } while( !pNewNd->IsTxtNode() );
360 : :
361 [ # # ]: 0 : if( !aFlags.bAFmtByInput )
362 : 0 : ::SetProgressState( aNdIdx.GetIndex() + nEndNdIdx - aEndNdIdx.GetIndex(),
363 : 0 : pDoc->GetDocShell() );
364 : :
365 [ # # ]: 0 : pAktTxtNd = (SwTxtNode*)pNewNd;
366 : 0 : pAktTxtFrm = GetFrm( *pAktTxtNd );
367 : 0 : return pAktTxtNd->GetTxt();
368 : : }
369 : :
370 : 0 : sal_Bool SwAutoFormat::HasObjects( const SwNode& rNd )
371 : : {
372 : : // Is there something bound to the paragraph in the paragraph
373 : : // like borders, DrawObjects, ...
374 : 0 : sal_Bool bRet = sal_False;
375 : 0 : const SwFrmFmts& rFmts = *pDoc->GetSpzFrmFmts();
376 [ # # ]: 0 : for( sal_uInt16 n = 0; n < rFmts.size(); ++n )
377 : : {
378 : 0 : const SwFmtAnchor& rAnchor = rFmts[ n ]->GetAnchor();
379 [ # # ][ # # : 0 : if ((FLY_AT_PAGE != rAnchor.GetAnchorId()) &&
# # # # ]
380 : 0 : rAnchor.GetCntntAnchor() &&
381 : 0 : &rAnchor.GetCntntAnchor()->nNode.GetNode() == &rNd )
382 : : {
383 : 0 : bRet = sal_True;
384 : 0 : break;
385 : : }
386 : : }
387 : 0 : return bRet;
388 : : }
389 : :
390 : 0 : const SwTxtNode* SwAutoFormat::GetNextNode() const
391 : : {
392 [ # # ]: 0 : if( aNdIdx.GetIndex()+1 >= aEndNdIdx.GetIndex() )
393 : 0 : return 0;
394 : 0 : return pDoc->GetNodes()[ aNdIdx.GetIndex() + 1 ]->GetTxtNode();
395 : : }
396 : :
397 : :
398 : 0 : sal_Bool SwAutoFormat::IsOneLine( const SwTxtNode& rNd ) const
399 : : {
400 [ # # ]: 0 : SwTxtFrmInfo aFInfo( GetFrm( rNd ) );
401 [ # # ]: 0 : return aFInfo.IsOneLine();
402 : : }
403 : :
404 : :
405 : 0 : sal_Bool SwAutoFormat::IsFastFullLine( const SwTxtNode& rNd ) const
406 : : {
407 : 0 : sal_Bool bRet = aFlags.bRightMargin;
408 [ # # ]: 0 : if( bRet )
409 : : {
410 [ # # ]: 0 : SwTxtFrmInfo aFInfo( GetFrm( rNd ) );
411 [ # # ]: 0 : bRet = aFInfo.IsFilled( aFlags.nRightMargin );
412 : : }
413 : 0 : return bRet;
414 : : }
415 : :
416 : :
417 : 0 : sal_Bool SwAutoFormat::IsEnumericChar( const SwTxtNode& rNd ) const
418 : : {
419 : 0 : const String& rTxt = rNd.GetTxt();
420 [ # # ]: 0 : String sTmp( rTxt );
421 : 0 : xub_StrLen nBlnks = GetLeadingBlanks( sTmp );
422 : 0 : xub_StrLen nLen = rTxt.Len() - nBlnks;
423 [ # # ]: 0 : if( !nLen )
424 : 0 : return sal_False;
425 : :
426 : : // -, +, * separated by blank ??
427 [ # # ][ # # ]: 0 : if( 2 < nLen && IsSpace( rTxt.GetChar( nBlnks + 1 ) ) )
[ # # ]
428 : : {
429 [ # # ]: 0 : if( StrChr( pBulletChar, rTxt.GetChar( nBlnks ) ) )
430 : 0 : return sal_True;
431 : : // Should there be a symbol font at the position?
432 [ # # ]: 0 : SwTxtFrmInfo aFInfo( GetFrm( rNd ) );
433 [ # # ][ # # ]: 0 : if( aFInfo.IsBullet( nBlnks ))
434 : 0 : return sal_True;
435 : : }
436 : :
437 : : // 1.) / 1. / 1.1.1 / (1). / (1) / ....
438 [ # # ][ # # ]: 0 : return USHRT_MAX != GetDigitLevel( rNd, nBlnks );
439 : : }
440 : :
441 : :
442 : 0 : sal_Bool SwAutoFormat::IsBlanksInString( const SwTxtNode& rNd ) const
443 : : {
444 : : // Search more that 5 blanks/tabs in the string.
445 [ # # ]: 0 : String sTmp( rNd.GetTxt() );
446 [ # # ][ # # ]: 0 : DelTrailingBlanks( DelLeadingBlanks( sTmp ));
447 : 0 : const sal_Unicode* pTmp = sTmp.GetBuffer();
448 [ # # ]: 0 : while( *pTmp )
449 : : {
450 [ # # ]: 0 : if( IsSpace( *pTmp ) )
451 : : {
452 [ # # ]: 0 : if( IsSpace( *++pTmp )) // 2 spaces after each other
453 : : {
454 : 0 : const sal_Unicode* pStt = pTmp;
455 [ # # ][ # # ]: 0 : while( *pTmp && IsSpace( *++pTmp ))
[ # # ]
456 : : ;
457 [ # # ]: 0 : if( 5 <= pTmp - pStt )
458 : 0 : return sal_True;
459 : : }
460 : : else
461 : 0 : ++pTmp;
462 : : }
463 : : else
464 : 0 : ++pTmp;
465 : : }
466 [ # # ]: 0 : return sal_False;
467 : : }
468 : :
469 : :
470 : 0 : sal_uInt16 SwAutoFormat::CalcLevel( const SwTxtNode& rNd, sal_uInt16 *pDigitLvl ) const
471 : : {
472 : 0 : sal_uInt16 nLvl = 0, nBlnk = 0;
473 : 0 : const String& rTxt = rNd.GetTxt();
474 [ # # ]: 0 : if( pDigitLvl )
475 : 0 : *pDigitLvl = USHRT_MAX;
476 : :
477 [ # # ]: 0 : if( RES_POOLCOLL_TEXT_MOVE == rNd.GetTxtColl()->GetPoolFmtId() )
478 : : {
479 [ # # ]: 0 : if( aFlags.bAFmtByInput )
480 : : {
481 : 0 : nLvl = rNd.GetAutoFmtLvl();
482 : 0 : ((SwTxtNode&)rNd).SetAutoFmtLvl( 0 );
483 [ # # ]: 0 : if( nLvl )
484 : 0 : return nLvl;
485 : : }
486 : 0 : ++nLvl;
487 : : }
488 : :
489 : :
490 [ # # ]: 0 : for( xub_StrLen n = 0, nEnd = rTxt.Len(); n < nEnd; ++n )
491 : : {
492 [ # # # ]: 0 : switch( rTxt.GetChar( n ) )
493 : : {
494 [ # # ]: 0 : case ' ': if( 3 == ++nBlnk )
495 : 0 : ++nLvl, nBlnk = 0;
496 : 0 : break;
497 : 0 : case '\t': ++nLvl, nBlnk = 0;
498 : 0 : break;
499 : : default:
500 [ # # ]: 0 : if( pDigitLvl )
501 : : // test 1.) / 1. / 1.1.1 / (1). / (1) / ....
502 [ # # ]: 0 : *pDigitLvl = GetDigitLevel( rNd, n );
503 : 0 : return nLvl;
504 : : }
505 : : }
506 : 0 : return nLvl;
507 : : }
508 : :
509 : :
510 : :
511 : 0 : xub_StrLen SwAutoFormat::GetBigIndent( xub_StrLen& rAktSpacePos ) const
512 : : {
513 [ # # ]: 0 : SwTxtFrmInfo aFInfo( GetFrm( *pAktTxtNd ) );
514 : 0 : const SwTxtFrm* pNxtFrm = 0;
515 : :
516 [ # # ]: 0 : if( !bMoreLines )
517 : : {
518 [ # # ]: 0 : const SwTxtNode* pNxtNd = GetNextNode();
519 [ # # ][ # # ]: 0 : if( !CanJoin( pNxtNd ) || !IsOneLine( *pNxtNd ) )
[ # # ][ # # ]
[ # # ]
520 : 0 : return 0;
521 : :
522 [ # # ]: 0 : pNxtFrm = GetFrm( *pNxtNd );
523 : : }
524 : :
525 [ # # ]: 0 : return aFInfo.GetBigIndent( rAktSpacePos, pNxtFrm );
526 : : }
527 : :
528 : :
529 : 0 : sal_Bool SwAutoFormat::IsNoAlphaLine( const SwTxtNode& rNd ) const
530 : : {
531 : 0 : const String& rStr = rNd.GetTxt();
532 [ # # ]: 0 : if( !rStr.Len() )
533 : 0 : return sal_False;
534 : : // oder besser: ueber die Anzahl von Alpha/Num- und !AN-Zeichen
535 : : // bestimmen.
536 : 0 : xub_StrLen nANChar = 0, nBlnk = 0;
537 : :
538 : 0 : CharClass& rCC = GetCharClass( rNd.GetSwAttrSet().GetLanguage().GetLanguage() );
539 [ # # ]: 0 : for( xub_StrLen n = 0, nEnd = rStr.Len(); n < nEnd; ++n )
540 [ # # ]: 0 : if( IsSpace( rStr.GetChar( n ) ) )
541 : 0 : ++nBlnk;
542 [ # # ]: 0 : else if( rCC.isLetterNumeric( rStr, n ))
543 : 0 : ++nANChar;
544 : :
545 : : // sind zu 75% keine Alpha-Nummerische-Zeichen, dann sal_True
546 : 0 : sal_uLong nLen = rStr.Len() - nBlnk;
547 : 0 : nLen = ( nLen * 3 ) / 4; // long overflow, if the strlen > sal_uInt16
548 : 0 : return xub_StrLen(nLen) < (rStr.Len() - nANChar - nBlnk);
549 : : }
550 : :
551 : :
552 : :
553 : 0 : sal_Bool SwAutoFormat::DoUnderline()
554 : : {
555 [ # # ]: 0 : if( !aFlags.bSetBorder )
556 : 0 : return sal_False;
557 : :
558 : 0 : const sal_Unicode* pStr = pAktTxtNd->GetTxt().GetBuffer();
559 : 0 : int eState = 0;
560 : 0 : xub_StrLen nCnt = 0;
561 [ # # ]: 0 : while( *pStr )
562 : : {
563 : 0 : int eTmp = 0;
564 [ # # # # : 0 : switch( *pStr )
# # # ]
565 : : {
566 : 0 : case '-': eTmp = 1; break;
567 : 0 : case '_': eTmp = 2; break;
568 : 0 : case '=': eTmp = 3; break;
569 : 0 : case '*': eTmp = 4; break;
570 : 0 : case '~': eTmp = 5; break;
571 : 0 : case '#': eTmp = 6; break;
572 : : default:
573 : 0 : return sal_False;
574 : : }
575 [ # # ]: 0 : if( 0 == eState )
576 : 0 : eState = eTmp;
577 [ # # ]: 0 : else if( eState != eTmp )
578 : 0 : return sal_False;
579 : 0 : ++nCnt;
580 : :
581 : 0 : ++pStr;
582 : : }
583 : :
584 [ # # ]: 0 : if( 2 < nCnt )
585 : : {
586 : : // dann unterstreiche mal den vorherigen Absatz, wenn es diesen gibt!
587 [ # # ]: 0 : DelEmptyLine( sal_False );
588 [ # # ]: 0 : aDelPam.SetMark();
589 [ # # ]: 0 : aDelPam.GetMark()->nContent = 0;
590 : :
591 [ # # ]: 0 : editeng::SvxBorderLine aLine;
592 [ # # # # : 0 : switch( eState )
# # # ]
593 : : {
594 : : case 1: // single, 0,05 pt
595 [ # # ]: 0 : aLine.SetBorderLineStyle(table::BorderLineStyle::SOLID);
596 : 0 : aLine.SetWidth( DEF_LINE_WIDTH_0 );
597 : 0 : break;
598 : : case 2: // single, 1,0 pt
599 [ # # ]: 0 : aLine.SetBorderLineStyle(table::BorderLineStyle::SOLID);
600 : 0 : aLine.SetWidth( DEF_LINE_WIDTH_1 );
601 : 0 : break;
602 : : case 3: // double, 1,1 pt
603 [ # # ]: 0 : aLine.SetBorderLineStyle(table::BorderLineStyle::DOUBLE);
604 : 0 : aLine.SetWidth( DEF_LINE_WIDTH_0 );
605 : 0 : break;
606 : : case 4: // double, 4,5 pt
607 [ # # ]: 0 : aLine.SetBorderLineStyle(table::BorderLineStyle::THICKTHIN_SMALLGAP);
608 : 0 : aLine.SetWidth( DEF_LINE_WIDTH_1 );
609 : 0 : break;
610 : : case 5: // double, 6,0 pt
611 [ # # ]: 0 : aLine.SetBorderLineStyle(table::BorderLineStyle::THINTHICK_SMALLGAP);
612 : 0 : aLine.SetWidth( DEF_LINE_WIDTH_2 );
613 : 0 : break;
614 : : case 6: // double, 9,0 pt
615 [ # # ]: 0 : aLine.SetBorderLineStyle(table::BorderLineStyle::DOUBLE);
616 : 0 : aLine.SetWidth( DEF_LINE_WIDTH_2 );
617 : 0 : break;
618 : : }
619 : 0 : SfxItemSet aSet(pDoc->GetAttrPool(),
620 : : RES_PARATR_CONNECT_BORDER, RES_PARATR_CONNECT_BORDER,
621 : : RES_BOX, RES_BOX,
622 [ # # ]: 0 : 0);
623 [ # # ][ # # ]: 0 : aSet.Put( SwParaConnectBorderItem( sal_False ) );
[ # # ]
624 [ # # ]: 0 : SvxBoxItem aBox( RES_BOX );
625 [ # # ]: 0 : aBox.SetLine( &aLine, BOX_LINE_BOTTOM );
626 : 0 : aBox.SetDistance( 42 ); // ~0,75 mm
627 [ # # ]: 0 : aSet.Put(aBox);
628 [ # # ]: 0 : pDoc->InsertItemSet( aDelPam, aSet, 0 );
629 : :
630 [ # # ][ # # ]: 0 : aDelPam.DeleteMark();
[ # # ]
631 : : }
632 : 0 : return 2 < nCnt;
633 : : }
634 : :
635 : :
636 : 0 : sal_Bool SwAutoFormat::DoTable()
637 : : {
638 [ # # ][ # # ]: 0 : if( !aFlags.bCreateTable || !aFlags.bAFmtByInput ||
[ # # ][ # # ]
639 [ # # ]: 0 : pAktTxtNd->FindTableNode() )
640 : 0 : return sal_False;
641 : :
642 : 0 : const String& rTmp = pAktTxtNd->GetTxt();
643 : 0 : xub_StrLen nSttPlus = GetLeadingBlanks( rTmp );
644 : 0 : xub_StrLen nEndPlus = GetTrailingBlanks( rTmp );
645 : : sal_Unicode cChar;
646 : :
647 [ # # ][ # # ]: 0 : if( 2 > nEndPlus - nSttPlus ||
[ # # ][ # # ]
[ # # ][ # # ]
648 : 0 : ( '+' != ( cChar = rTmp.GetChar( nSttPlus )) && '|' != cChar ) ||
649 : 0 : ( '+' != ( cChar = rTmp.GetChar( nEndPlus - 1)) && '|' != cChar ))
650 : 0 : return sal_False;
651 : :
652 : 0 : SwTxtFrmInfo aInfo( pAktTxtFrm );
653 : :
654 : 0 : xub_StrLen n = nSttPlus;
655 : 0 : const sal_Unicode* pStr = rTmp.GetBuffer() + n;
656 [ # # ]: 0 : std::vector<sal_uInt16> aPosArr;
657 : :
658 [ # # ]: 0 : while( *pStr )
659 : : {
660 [ # # # ]: 0 : switch( *pStr )
661 : : {
662 : : case '-':
663 : : case '_':
664 : : case '=':
665 : : case ' ':
666 : : case '\t':
667 : 0 : break;
668 : :
669 : : case '+':
670 : : case '|':
671 [ # # ][ # # ]: 0 : aPosArr.push_back( static_cast<sal_uInt16>(aInfo.GetCharPos(n)) );
672 : 0 : break;
673 : :
674 : : default:
675 : 0 : return sal_False;
676 : : }
677 [ # # ]: 0 : if( ++n == nEndPlus )
678 : 0 : break;
679 : :
680 : 0 : ++pStr;
681 : : }
682 : :
683 [ # # ]: 0 : if( 1 < aPosArr.size() )
684 : : {
685 : : // Ausrichtung vom Textnode besorgen:
686 : 0 : sal_uInt16 nColCnt = aPosArr.size() - 1;
687 [ # # ]: 0 : SwTwips nSttPos = aPosArr[ 0 ];
688 : : sal_Int16 eHori;
689 [ # # ][ # # ]: 0 : switch( pAktTxtNd->GetSwAttrSet().GetAdjust().GetAdjust() )
[ # # # ]
690 : : {
691 : 0 : case SVX_ADJUST_CENTER: eHori = text::HoriOrientation::CENTER; break;
692 : 0 : case SVX_ADJUST_RIGHT: eHori = text::HoriOrientation::RIGHT; break;
693 : :
694 : : default:
695 [ # # ]: 0 : if( nSttPos )
696 : : {
697 : 0 : eHori = text::HoriOrientation::NONE;
698 : : // dann muss als letztes noch die akt. FrameBreite
699 : : // ins Array
700 [ # # ]: 0 : aPosArr.push_back( static_cast<sal_uInt16>(pAktTxtFrm->Frm().Width()) );
701 : : }
702 : : else
703 : 0 : eHori = text::HoriOrientation::LEFT;
704 : 0 : break;
705 : : }
706 : :
707 : : // dann erzeuge eine Tabelle, die den Zeichen entspricht
708 [ # # ]: 0 : DelEmptyLine();
709 [ # # ]: 0 : SwNodeIndex aIdx( aDelPam.GetPoint()->nNode );
710 [ # # ]: 0 : aDelPam.Move( fnMoveForward );
711 : : pDoc->InsertTable( SwInsertTableOptions( tabopts::ALL_TBL_INS_ATTR , 1 ),
712 : 0 : *aDelPam.GetPoint(), 1, nColCnt, eHori,
713 [ # # ]: 0 : 0, &aPosArr );
714 [ # # ][ # # ]: 0 : aDelPam.GetPoint()->nNode = aIdx;
715 : : }
716 : 0 : return 1 < aPosArr.size();
717 : : }
718 : :
719 : :
720 : 0 : String& SwAutoFormat::DelLeadingBlanks( String& rStr ) const
721 : : {
722 : : xub_StrLen nL;
723 : : xub_StrLen n;
724 : :
725 [ # # ][ # # ]: 0 : for( nL = rStr.Len(), n = 0; n < nL && IsSpace( rStr.GetChar(n) ); ++n )
[ # # ]
726 : : ;
727 [ # # ]: 0 : if( n ) // keine Spaces
728 : 0 : rStr.Erase( 0, n );
729 : 0 : return rStr;
730 : : }
731 : :
732 : :
733 : 0 : String& SwAutoFormat::DelTrailingBlanks( String& rStr ) const
734 : : {
735 : 0 : xub_StrLen nL = rStr.Len(), n = nL;
736 [ # # ]: 0 : if( !nL )
737 : 0 : return rStr;
738 : :
739 [ # # ][ # # ]: 0 : while( --n && IsSpace( rStr.GetChar( n ) ) )
[ # # ]
740 : : ;
741 [ # # ]: 0 : if( n+1 != nL ) // keine Spaces
742 : 0 : rStr.Erase( n+1 );
743 : 0 : return rStr;
744 : : }
745 : :
746 : :
747 : 0 : xub_StrLen SwAutoFormat::GetLeadingBlanks( const String& rStr ) const
748 : : {
749 : : xub_StrLen nL;
750 : : xub_StrLen n;
751 : :
752 [ # # ][ # # ]: 0 : for( nL = rStr.Len(), n = 0; n < nL && IsSpace( rStr.GetChar( n ) ); ++n )
[ # # ]
753 : : ;
754 : 0 : return n;
755 : : }
756 : :
757 : :
758 : 0 : xub_StrLen SwAutoFormat::GetTrailingBlanks( const String& rStr ) const
759 : : {
760 : 0 : xub_StrLen nL = rStr.Len(), n = nL;
761 [ # # ]: 0 : if( !nL )
762 : 0 : return 0;
763 : :
764 [ # # ][ # # ]: 0 : while( --n && IsSpace( rStr.GetChar( n ) ) )
[ # # ]
765 : : ;
766 : 0 : return ++n;
767 : : }
768 : :
769 : :
770 : 0 : sal_Bool SwAutoFormat::IsFirstCharCapital( const SwTxtNode& rNd ) const
771 : : {
772 : 0 : const String& rTxt = rNd.GetTxt();
773 [ # # ]: 0 : for( xub_StrLen n = 0, nEnd = rTxt.Len(); n < nEnd; ++n )
774 [ # # ]: 0 : if( !IsSpace( rTxt.GetChar( n ) ) )
775 : : {
776 : 0 : CharClass& rCC = GetCharClass( rNd.GetSwAttrSet().
777 : 0 : GetLanguage().GetLanguage() );
778 : 0 : sal_Int32 nCharType = rCC.getCharacterType( rTxt, n );
779 : 0 : return CharClass::isLetterType( nCharType ) &&
780 : : 0 != ( i18n::KCharacterType::UPPER &
781 [ # # ][ # # ]: 0 : nCharType );
782 : : }
783 : 0 : return sal_False;
784 : : }
785 : :
786 : :
787 : 0 : sal_uInt16 SwAutoFormat::GetDigitLevel( const SwTxtNode& rNd, xub_StrLen& rPos,
788 : : String* pPreFix, String* pPostFix, String* pNumTypes ) const
789 : : {
790 : : // Teste auf 1.) / 1. / 1.1.1 / (1). / (1) / ....
791 : 0 : const String& rTxt = rNd.GetTxt();
792 : 0 : xub_StrLen nPos = rPos;
793 : 0 : int eScan = NONE;
794 : :
795 : 0 : sal_uInt16 nStart = 0;
796 : 0 : sal_uInt8 nDigitLvl = 0, nDigitCnt = 0;
797 : : //count number of parenthesis to assure a sensible order is found
798 : 0 : sal_uInt16 nOpeningParentheses = 0;
799 : 0 : sal_uInt16 nClosingParentheses = 0;
800 : :
801 : 0 : CharClass& rCC = GetCharClass( rNd.GetSwAttrSet().GetLanguage().GetLanguage() );
802 : :
803 [ # # ][ # # ]: 0 : while( nPos < rTxt.Len() && nDigitLvl < MAXLEVEL - 1)
[ # # ]
804 : : {
805 : 0 : const sal_Unicode cCurrentChar = rTxt.GetChar( nPos );
806 [ # # ][ # # ]: 0 : if( ('0' <= cCurrentChar && '9' >= cCurrentChar) ||
[ # # ][ # # ]
807 : : (0xff10 <= cCurrentChar && 0xff19 >= cCurrentChar) )
808 : : {
809 [ # # ]: 0 : if( eScan & DELIM )
810 : : {
811 [ # # ]: 0 : if( eScan & CHG ) // nicht wenns mit einer Zahl beginnt
812 : : {
813 : 0 : ++nDigitLvl;
814 [ # # ]: 0 : if( pPostFix )
815 : 0 : *pPostFix += (sal_Unicode)1;
816 : : }
817 : :
818 [ # # ]: 0 : if( pNumTypes )
819 : 0 : *pNumTypes += (sal_Unicode)('0' + SVX_NUM_ARABIC);
820 : :
821 : 0 : eScan = eScan | CHG;
822 : : }
823 [ # # ][ # # ]: 0 : else if( pNumTypes && !(eScan & DIGIT) )
824 : 0 : *pNumTypes += (sal_Unicode)('0' + SVX_NUM_ARABIC);
825 : :
826 : 0 : eScan &= ~DELIM; // Delim raus
827 [ # # ][ # # ]: 0 : if( 0 != (eScan & ~CHG) && DIGIT != (eScan & ~CHG))
828 : 0 : return USHRT_MAX;
829 : :
830 : 0 : eScan |= DIGIT; // Digit rein
831 [ # # ]: 0 : if( 3 == ++nDigitCnt ) // mehr als 2 Nummern sind kein Enum mehr
832 : 0 : return USHRT_MAX;
833 : :
834 : 0 : nStart *= 10;
835 [ # # ]: 0 : nStart += cCurrentChar <= '9' ? cCurrentChar - '0' : cCurrentChar - 0xff10;
836 : : }
837 [ # # ]: 0 : else if( rCC.isAlpha( rTxt, nPos ) )
838 : : {
839 : : sal_Bool bIsUpper =
840 : : 0 != ( i18n::KCharacterType::UPPER &
841 : 0 : rCC.getCharacterType( rTxt, nPos ));
842 [ # # ]: 0 : sal_Unicode cLow = rCC.lowercase(rTxt, nPos, 1)[0], cNumTyp;
843 : : int eTmpScan;
844 : :
845 : : // roemische Zeichen sind "mdclxvi". Da man aber eher mal eine
846 : : // Numerierung mit c oder d anfangen will, werden diese erstmal
847 : : // zu chars und spaeter ggfs. zu romischen Zeichen!
848 : : #ifdef WITH_ALPHANUM_AS_NUMFMT
849 : : //detection of 'c' and 'd' a ROMAN numbering should not be done here
850 : : if( 256 > cLow &&( (eScan & (LOWER_ROMAN|UPPER_ROMAN))
851 : : ? strchr( "mdclxvi", cLow )
852 : : : strchr( "mlxvi", cLow ) ))
853 : : #else
854 [ # # ][ # # ]: 0 : if( 256 > cLow && ( strchr( "mdclxvi", cLow ) ))
855 : : #endif
856 : : {
857 [ # # ]: 0 : if( bIsUpper )
858 : 0 : cNumTyp = '0' + SVX_NUM_ROMAN_UPPER, eTmpScan = UPPER_ROMAN;
859 : : else
860 : 0 : cNumTyp = '0' + SVX_NUM_ROMAN_LOWER, eTmpScan = LOWER_ROMAN;
861 : : }
862 [ # # ]: 0 : else if( bIsUpper )
863 : 0 : cNumTyp = '0' + SVX_NUM_CHARS_UPPER_LETTER, eTmpScan = UPPER_ALPHA;
864 : : else
865 : 0 : cNumTyp = '0' + SVX_NUM_CHARS_LOWER_LETTER, eTmpScan = LOWER_ALPHA;
866 : :
867 : :
868 : : //ggfs. auf roemische Zeichen umschalten (nur bei c/d!)?
869 [ # # ][ # # ]: 0 : if( 1 == nDigitCnt && ( eScan & (UPPER_ALPHA|LOWER_ALPHA) ) &&
[ # # ][ # # ]
[ # # # # ]
[ # # ]
870 : : ( 3 == nStart || 4 == nStart) && 256 > cLow &&
871 : 0 : strchr( "mdclxvi", cLow ) &&
872 : : (( eScan & UPPER_ALPHA ) ? (eTmpScan & (UPPER_ALPHA|UPPER_ROMAN))
873 [ # # ]: 0 : : (eTmpScan & (LOWER_ALPHA|LOWER_ROMAN))) )
874 : : {
875 : 0 : sal_Unicode c = '0';
876 [ # # ]: 0 : nStart = 3 == nStart ? 100 : 500;
877 [ # # ]: 0 : if( UPPER_ALPHA == eTmpScan )
878 : 0 : eTmpScan = UPPER_ROMAN, c += SVX_NUM_ROMAN_UPPER;
879 : : else
880 : 0 : eTmpScan = LOWER_ROMAN, c += SVX_NUM_ROMAN_LOWER;
881 : :
882 : 0 : ( eScan &= ~(UPPER_ALPHA|LOWER_ALPHA)) |= eTmpScan;
883 [ # # ]: 0 : if( pNumTypes )
884 : 0 : pNumTypes->SetChar( pNumTypes->Len() - 1, c );
885 : : }
886 : :
887 [ # # ]: 0 : if( eScan & DELIM )
888 : : {
889 [ # # ]: 0 : if( eScan & CHG ) // nicht wenns mit einer Zahl beginnt
890 : : {
891 : 0 : ++nDigitLvl;
892 [ # # ]: 0 : if( pPostFix )
893 : 0 : *pPostFix += (sal_Unicode)1;
894 : : }
895 : :
896 [ # # ]: 0 : if( pNumTypes )
897 : 0 : *pNumTypes += cNumTyp;
898 : 0 : eScan = eScan | CHG;
899 : : }
900 [ # # ][ # # ]: 0 : else if( pNumTypes && !(eScan & eTmpScan) )
901 : 0 : *pNumTypes += cNumTyp;
902 : :
903 : 0 : eScan &= ~DELIM; // Delim raus
904 : :
905 : : // falls ein andere Type gesetzt ist, brechen wir ab
906 [ # # ][ # # ]: 0 : if( 0 != ( eScan & ~CHG ) && eTmpScan != ( eScan & ~CHG ))
907 : 0 : return USHRT_MAX;
908 : :
909 [ # # ]: 0 : if( eTmpScan & (UPPER_ALPHA | LOWER_ALPHA) )
910 : : {
911 : : // Buchstaben nur zulassen, wenn sie einmalig vorkommen
912 : 0 : return USHRT_MAX;
913 : : }
914 : : else
915 : : {
916 : : // roemische Zahlen: checke ob das gueltige Zeichen sind
917 : : sal_uInt16 nVal;
918 : 0 : sal_Bool bError = sal_False;
919 [ # # # # : 0 : switch( cLow )
# # # # ]
920 : : {
921 : 0 : case 'm': nVal = 1000; goto CHECK_ROMAN_1;
922 : 0 : case 'd': nVal = 500; goto CHECK_ROMAN_5;
923 : 0 : case 'c': nVal = 100; goto CHECK_ROMAN_1;
924 : 0 : case 'l': nVal = 50; goto CHECK_ROMAN_5;
925 : 0 : case 'x': nVal = 10; goto CHECK_ROMAN_1;
926 : 0 : case 'v': nVal = 5; goto CHECK_ROMAN_5;
927 : :
928 : : CHECK_ROMAN_1:
929 : : {
930 : 0 : int nMod5 = nStart % (nVal * 5);
931 : 0 : int nLast = nStart % nVal;
932 : 0 : int n10 = nVal / 10;
933 : :
934 [ # # ][ # # ]: 0 : if( nMod5 == ((3 * nVal) + n10 ) ||
[ # # ]
935 : : nMod5 == ((4 * nVal) + n10 ) ||
936 : : nLast == n10 )
937 : 0 : nStart = static_cast<sal_uInt16>(nStart + (n10 * 8));
938 [ # # ][ # # ]: 0 : else if( nMod5 == 0 ||
[ # # ]
939 : : nMod5 == (1 * nVal) ||
940 : : nMod5 == (2 * nVal) )
941 : 0 : nStart = nStart + nVal;
942 : : else
943 : 0 : bError = sal_True;
944 : : }
945 : 0 : break;
946 : :
947 : : CHECK_ROMAN_5:
948 : : {
949 [ # # ]: 0 : if( ( nStart / nVal ) & 1 )
950 : 0 : bError = sal_True;
951 : : else
952 : : {
953 : 0 : int nMod = nStart % nVal;
954 : 0 : int n10 = nVal / 5;
955 [ # # ]: 0 : if( n10 == nMod )
956 : 0 : nStart = static_cast<sal_uInt16>(nStart + (3 * n10));
957 [ # # ]: 0 : else if( 0 == nMod )
958 : 0 : nStart = nStart + nVal;
959 : : else
960 : 0 : bError = sal_True;
961 : : }
962 : : }
963 : 0 : break;
964 : :
965 : : case 'i':
966 [ # # ]: 0 : if( nStart % 5 >= 3 )
967 : 0 : bError = sal_True;
968 : : else
969 : 0 : nStart += 1;
970 : 0 : break;
971 : :
972 : : default:
973 : 0 : bError = sal_True;
974 : : }
975 : :
976 [ # # ]: 0 : if( bError )
977 : 0 : return USHRT_MAX;
978 : : }
979 : 0 : eScan |= eTmpScan; // Digit rein
980 : 0 : ++nDigitCnt;
981 : : }
982 [ # # # # ]: 0 : else if( (256 > cCurrentChar &&
[ # # ][ # # ]
[ # # ][ # # ]
983 : 0 : strchr( ".)(", cCurrentChar )) ||
984 : : 0x3002 == cCurrentChar /* Chinese trad. dot */||
985 : : 0xff0e == cCurrentChar /* Japanese dot */||
986 : : 0xFF08 == cCurrentChar /* opening bracket Chin./Jap.*/||
987 : : 0xFF09 == cCurrentChar )/* closing bracket Chin./Jap. */
988 : : {
989 [ # # ][ # # ]: 0 : if(cCurrentChar == '(' || cCurrentChar == 0xFF09)
990 : 0 : nOpeningParentheses++;
991 [ # # ][ # # ]: 0 : else if(cCurrentChar == ')'|| cCurrentChar == 0xFF08)
992 : 0 : nClosingParentheses++;
993 : : // nur wenn noch keine Zahlen gelesen wurden!
994 [ # # ][ # # ]: 0 : if( pPreFix && !( eScan & ( NO_DELIM | CHG )) )
995 : 0 : *pPreFix += rTxt.GetChar( nPos );
996 [ # # ]: 0 : else if( pPostFix )
997 : 0 : *pPostFix += rTxt.GetChar( nPos );
998 : :
999 [ # # ]: 0 : if( NO_DELIM & eScan )
1000 : : {
1001 : 0 : eScan |= CHG;
1002 [ # # ]: 0 : if( pPreFix )
1003 [ # # ]: 0 : (*pPreFix += (sal_Unicode)1)
1004 [ # # ]: 0 : += String::CreateFromInt32( nStart );
1005 : : }
1006 : 0 : eScan &= ~NO_DELIM; // Delim raus
1007 : 0 : eScan |= DELIM; // Digit rein
1008 : 0 : nDigitCnt = 0;
1009 : 0 : nStart = 0;
1010 : : }
1011 : : else
1012 : 0 : break;
1013 : 0 : ++nPos;
1014 : : }
1015 [ # # ][ # # : 0 : if( !( CHG & eScan ) || rPos == nPos ||
# # # # ]
[ # # ][ # # ]
1016 : 0 : nPos == rTxt.Len() || !IsSpace( rTxt.GetChar( nPos ) ) ||
1017 : : (nOpeningParentheses > nClosingParentheses))
1018 : 0 : return USHRT_MAX;
1019 : :
1020 [ # # ][ # # ]: 0 : if( (NO_DELIM & eScan) && pPreFix ) // den letzen nicht vergessen
1021 [ # # ][ # # ]: 0 : (*pPreFix += (sal_Unicode)1) += String::CreateFromInt32( nStart );
1022 : :
1023 : 0 : rPos = nPos;
1024 : 0 : return nDigitLvl; // 0 .. 9 (MAXLEVEL - 1)
1025 : : }
1026 : :
1027 : :
1028 : 0 : void SwAutoFormat::SetColl( sal_uInt16 nId, sal_Bool bHdLineOrText )
1029 : : {
1030 [ # # ]: 0 : aDelPam.DeleteMark();
1031 [ # # ]: 0 : aDelPam.GetPoint()->nNode = aNdIdx;
1032 [ # # ][ # # ]: 0 : aDelPam.GetPoint()->nContent.Assign( pAktTxtNd, 0 );
1033 : :
1034 : : // behalte harte Tabs, Ausrichtung, Sprache, Silbentrennung,
1035 : : // DropCaps und fast alle Frame-Attribute
1036 : 0 : SfxItemSet aSet( pDoc->GetAttrPool(),
1037 : : RES_PARATR_ADJUST, RES_PARATR_ADJUST,
1038 : : RES_PARATR_TABSTOP, RES_PARATR_DROP,
1039 : : RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE,
1040 : : RES_BACKGROUND, RES_SHADOW,
1041 [ # # ]: 0 : 0 );
1042 : :
1043 [ # # ][ # # ]: 0 : if( pAktTxtNd->HasSwAttrSet() )
1044 : : {
1045 [ # # ][ # # ]: 0 : aSet.Put( *pAktTxtNd->GetpSwAttrSet() );
1046 : : // einige Sonderbedingungen:
1047 : : // HeaderLine/Textkoerper: nur zentriert oder rechts mitnehmem
1048 : : // sonst nur den Blocksatz
1049 : : SvxAdjustItem* pAdj;
1050 [ # # ]: 0 : if( SFX_ITEM_SET == aSet.GetItemState( RES_PARATR_ADJUST,
1051 [ # # ]: 0 : sal_False, (const SfxPoolItem**)&pAdj ))
1052 : : {
1053 : 0 : SvxAdjust eAdj = pAdj->GetAdjust();
1054 [ # # ][ # # ]: 0 : if( bHdLineOrText ? (SVX_ADJUST_RIGHT != eAdj &&
[ # # ][ # # ]
1055 : : SVX_ADJUST_CENTER != eAdj)
1056 : : : SVX_ADJUST_BLOCK != eAdj )
1057 [ # # ]: 0 : aSet.ClearItem( RES_PARATR_ADJUST );
1058 : : }
1059 : : }
1060 : :
1061 [ # # ][ # # ]: 0 : pDoc->SetTxtFmtCollByAutoFmt( *aDelPam.GetPoint(), nId, &aSet );
1062 : 0 : }
1063 : :
1064 : :
1065 : 0 : sal_Bool SwAutoFormat::HasSelBlanks( SwPaM& rPam ) const
1066 : : {
1067 : : // noch ein Blank am Anfang oder Ende ?
1068 : : // nicht loeschen, wird wieder eingefuegt.
1069 : 0 : SwPosition * pPos = rPam.End();
1070 : 0 : xub_StrLen nBlnkPos = pPos->nContent.GetIndex();
1071 : 0 : SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode();
1072 [ # # # # ]: 0 : if( nBlnkPos && nBlnkPos-- < pTxtNd->GetTxt().Len() &&
[ # # ][ # # ]
1073 : 0 : ( ' ' == pTxtNd->GetTxt().GetChar( nBlnkPos ) ))
1074 : 0 : pPos->nContent--;
1075 : : else
1076 : : {
1077 [ # # ]: 0 : pPos = rPam.GetPoint() == pPos ? rPam.GetMark() : rPam.GetPoint();
1078 : 0 : nBlnkPos = pPos->nContent.GetIndex();
1079 : 0 : pTxtNd = pPos->nNode.GetNode().GetTxtNode();
1080 [ # # ]: 0 : if( nBlnkPos < pTxtNd->GetTxt().Len() &&
[ # # # # ]
1081 : 0 : ( ' ' == pTxtNd->GetTxt().GetChar( nBlnkPos )))
1082 : 0 : pPos->nContent++;
1083 : : else
1084 : 0 : return sal_False;
1085 : : }
1086 : 0 : return sal_True;
1087 : : }
1088 : :
1089 : :
1090 : 0 : sal_Bool SwAutoFormat::HasBreakAttr( const SwTxtNode& rTxtNd ) const
1091 : : {
1092 [ # # ]: 0 : const SfxItemSet* pSet = rTxtNd.GetpSwAttrSet();
1093 [ # # ]: 0 : if( !pSet )
1094 : 0 : return sal_False;
1095 : :
1096 : : const SfxPoolItem* pItem;
1097 [ # # ]: 0 : if( SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, sal_False, &pItem )
[ # # # # ]
[ # # ]
1098 : 0 : && SVX_BREAK_NONE != ((SvxFmtBreakItem*)pItem)->GetBreak() )
1099 : 0 : return sal_True;
1100 : :
1101 [ # # ][ # # : 0 : if( SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC, sal_False, &pItem )
# # # # ]
[ # # ]
1102 : 0 : && ((SwFmtPageDesc*)pItem)->GetPageDesc()
1103 : 0 : && nsUseOnPage::PD_NONE != ((SwFmtPageDesc*)pItem)->GetPageDesc()->GetUseOn() )
1104 : 0 : return sal_True;
1105 : 0 : return sal_False;
1106 : : }
1107 : :
1108 : :
1109 : : // ist ein Punkt am Ende ??
1110 : 0 : sal_Bool SwAutoFormat::IsSentenceAtEnd( const SwTxtNode& rTxtNd ) const
1111 : : {
1112 : 0 : const String& rStr = rTxtNd.GetTxt();
1113 : 0 : xub_StrLen n = rStr.Len();
1114 [ # # ]: 0 : if( !n )
1115 : 0 : return sal_True;
1116 : :
1117 [ # # ][ # # ]: 0 : while( --n && IsSpace( rStr.GetChar( n ) ) )
[ # # ]
1118 : : ;
1119 : 0 : return '.' == rStr.GetChar( n );
1120 : : }
1121 : :
1122 : :
1123 : : // loesche im Node Anfang oder/und Ende
1124 : 0 : void SwAutoFormat::DeleteAktPara( sal_Bool bStart, sal_Bool bEnd )
1125 : : {
1126 [ # # ]: 0 : if( aFlags.bAFmtByInput
1127 : : ? aFlags.bAFmtByInpDelSpacesAtSttEnd
1128 [ # # ]: 0 : : aFlags.bAFmtDelSpacesAtSttEnd )
1129 : : {
1130 : : // Loesche Blanks am Ende vom akt. und am Anfang vom naechsten
1131 : 0 : aDelPam.DeleteMark();
1132 : 0 : aDelPam.GetPoint()->nNode = aNdIdx;
1133 : : xub_StrLen nPos;
1134 [ # # ][ # # ]: 0 : if( bStart && 0 != ( nPos = GetLeadingBlanks( pAktTxtNd->GetTxt() )))
[ # # ]
1135 : : {
1136 [ # # ]: 0 : aDelPam.GetPoint()->nContent.Assign( pAktTxtNd, 0 );
1137 : 0 : aDelPam.SetMark();
1138 : 0 : aDelPam.GetPoint()->nContent = nPos;
1139 : 0 : DeleteSel( aDelPam );
1140 : 0 : aDelPam.DeleteMark();
1141 : : }
1142 [ # # ][ # # ]: 0 : if( bEnd && pAktTxtNd->GetTxt().Len() !=
[ # # ]
1143 : 0 : ( nPos = GetTrailingBlanks( pAktTxtNd->GetTxt() )) )
1144 : : {
1145 [ # # ]: 0 : aDelPam.GetPoint()->nContent.Assign( pAktTxtNd, pAktTxtNd->GetTxt().Len() );
1146 : 0 : aDelPam.SetMark();
1147 : 0 : aDelPam.GetPoint()->nContent = nPos;
1148 : 0 : DeleteSel( aDelPam );
1149 : 0 : aDelPam.DeleteMark();
1150 : : }
1151 : : }
1152 : 0 : }
1153 : :
1154 : 0 : void SwAutoFormat::DeleteSel( SwPaM& rDelPam )
1155 : : {
1156 [ # # ]: 0 : if( aFlags.bWithRedlining )
1157 : : {
1158 : : // damit der DelPam auch verschoben wird, in den Shell-Cursr-Ring
1159 : : // mit aufnehmen !!
1160 [ # # ]: 0 : SwPaM* pShCrsr = pEditShell->_GetCrsr();
1161 [ # # ]: 0 : SwPaM aTmp( *pAktTxtNd, 0, pShCrsr );
1162 : :
1163 : 0 : Ring *pPrev = rDelPam.GetPrev();
1164 [ # # ]: 0 : rDelPam.MoveRingTo( pShCrsr );
1165 : :
1166 [ # # ]: 0 : pEditShell->DeleteSel( rDelPam );
1167 : :
1168 : : // und den Pam wieder herausnehmen:
1169 : 0 : Ring *p, *pNext = (Ring*)&rDelPam;
1170 [ # # ]: 0 : do {
1171 : 0 : p = pNext;
1172 : 0 : pNext = p->GetNext();
1173 [ # # ]: 0 : p->MoveTo( &rDelPam );
1174 : : } while( p != pPrev );
1175 : :
1176 [ # # ]: 0 : aNdIdx = aTmp.GetPoint()->nNode;
1177 [ # # ]: 0 : pAktTxtNd = aNdIdx.GetNode().GetTxtNode();
1178 : : }
1179 : : else
1180 : 0 : pEditShell->DeleteSel( rDelPam );
1181 : 0 : }
1182 : :
1183 : 0 : sal_Bool SwAutoFormat::DeleteAktNxtPara( const String& rNxtPara )
1184 : : {
1185 : : // Loesche Blanks am Ende vom akt. und am Anfang vom naechsten
1186 : 0 : aDelPam.DeleteMark();
1187 : 0 : aDelPam.GetPoint()->nNode = aNdIdx;
1188 : 0 : aDelPam.GetPoint()->nContent.Assign( pAktTxtNd,
1189 [ # # ]: 0 : GetTrailingBlanks( pAktTxtNd->GetTxt() ) );
1190 : 0 : aDelPam.SetMark();
1191 : :
1192 : 0 : aDelPam.GetPoint()->nNode++;
1193 : 0 : SwTxtNode* pTNd = aDelPam.GetNode()->GetTxtNode();
1194 [ # # ]: 0 : if( !pTNd )
1195 : : {
1196 : : // dann nur bis zum Ende von Absatz loeschen
1197 : 0 : aDelPam.GetPoint()->nNode--;
1198 : 0 : aDelPam.GetPoint()->nContent = pAktTxtNd->GetTxt().Len();
1199 : : }
1200 : : else
1201 : 0 : aDelPam.GetPoint()->nContent.Assign( pTNd,
1202 [ # # ]: 0 : GetLeadingBlanks( rNxtPara ));
1203 : :
1204 : : // noch ein Blank am Anfang oder Ende ?
1205 : : // nicht loeschen, wird wieder eingefuegt.
1206 : 0 : sal_Bool bHasBlnks = HasSelBlanks( aDelPam );
1207 : :
1208 [ # # ]: 0 : if( *aDelPam.GetPoint() != *aDelPam.GetMark() )
1209 : 0 : DeleteSel( aDelPam );
1210 : 0 : aDelPam.DeleteMark();
1211 : :
1212 : 0 : return !bHasBlnks;
1213 : : }
1214 : :
1215 : :
1216 : 0 : void SwAutoFormat::DelEmptyLine( sal_Bool bTstNextPara )
1217 : : {
1218 : 0 : SetRedlineTxt( STR_AUTOFMTREDL_DEL_EMPTY_PARA );
1219 : : // Loesche Blanks den leeren Absatz
1220 : 0 : aDelPam.DeleteMark();
1221 : 0 : aDelPam.GetPoint()->nNode = aNdIdx;
1222 [ # # ]: 0 : aDelPam.GetPoint()->nContent.Assign( pAktTxtNd, pAktTxtNd->GetTxt().Len() );
1223 : 0 : aDelPam.SetMark();
1224 : :
1225 : 0 : aDelPam.GetMark()->nNode--;
1226 : 0 : SwTxtNode* pTNd = aDelPam.GetNode( sal_False )->GetTxtNode();
1227 [ # # ]: 0 : if( pTNd )
1228 : : // erstmal den vorherigen Textnode benutzen.
1229 [ # # ]: 0 : aDelPam.GetMark()->nContent.Assign( pTNd, pTNd->GetTxt().Len() );
1230 [ # # ]: 0 : else if( bTstNextPara )
1231 : : {
1232 : : // dann versuche den naechsten (am Anfang vom Dok, Tabellen-Zellen,
1233 : : // Rahmen, ...
1234 : 0 : aDelPam.GetMark()->nNode += 2;
1235 : 0 : pTNd = aDelPam.GetNode( sal_False )->GetTxtNode();
1236 [ # # ]: 0 : if( pTNd )
1237 : : {
1238 [ # # ]: 0 : aDelPam.GetMark()->nContent.Assign( pTNd, 0 );
1239 : 0 : aDelPam.GetPoint()->nContent = 0;
1240 : : }
1241 : : }
1242 : : else
1243 : : {
1244 : 0 : aDelPam.GetMark()->nNode = aNdIdx;
1245 : 0 : aDelPam.GetMark()->nContent = 0;
1246 : 0 : pTNd = pAktTxtNd;
1247 : : }
1248 [ # # ]: 0 : if( pTNd )
1249 : 0 : DeleteSel( aDelPam );
1250 : :
1251 : 0 : aDelPam.DeleteMark();
1252 : 0 : ClearRedlineTxt();
1253 : 0 : }
1254 : :
1255 : :
1256 : 0 : void SwAutoFormat::DelMoreLinesBlanks( sal_Bool bWithLineBreaks )
1257 : : {
1258 [ # # ]: 0 : if( aFlags.bAFmtByInput
1259 : : ? aFlags.bAFmtByInpDelSpacesBetweenLines
1260 [ # # ]: 0 : : aFlags.bAFmtDelSpacesBetweenLines )
1261 : : {
1262 : : // loesche alle "Blanks" Links und Rechts vom Einzug
1263 [ # # ]: 0 : aDelPam.DeleteMark();
1264 [ # # ]: 0 : aDelPam.GetPoint()->nNode = aNdIdx;
1265 [ # # ][ # # ]: 0 : aDelPam.GetPoint()->nContent.Assign( pAktTxtNd, 0 );
1266 : :
1267 : 0 : SwTxtFrmInfo aFInfo( pAktTxtFrm );
1268 [ # # ][ # # ]: 0 : aFInfo.GetSpaces( aDelPam, !aFlags.bAFmtByInput || bWithLineBreaks );
[ # # ]
1269 : :
1270 : : SwPaM* pNxt;
1271 : 0 : do {
1272 : 0 : pNxt = (SwPaM*)aDelPam.GetNext();
1273 [ # # ][ # # ]: 0 : if( pNxt->HasMark() && *pNxt->GetPoint() != *pNxt->GetMark() )
[ # # ][ # # ]
1274 : : {
1275 [ # # ]: 0 : sal_Bool bHasBlnks = HasSelBlanks( *pNxt );
1276 [ # # ]: 0 : DeleteSel( *pNxt );
1277 [ # # ]: 0 : if( !bHasBlnks )
1278 : : {
1279 [ # # ][ # # ]: 0 : pDoc->InsertString( *pNxt, rtl::OUString(' ') );
[ # # ]
1280 : : }
1281 : : }
1282 : :
1283 [ # # ]: 0 : if( pNxt == &aDelPam )
1284 : 0 : break;
1285 [ # # ][ # # ]: 0 : delete pNxt;
1286 : : } while( sal_True );
1287 : :
1288 [ # # ]: 0 : aDelPam.DeleteMark();
1289 : : }
1290 : 0 : }
1291 : :
1292 : :
1293 : : // loesche den vorherigen Absatz
1294 : 0 : void SwAutoFormat::DelPrevPara()
1295 : : {
1296 : 0 : aDelPam.DeleteMark();
1297 : 0 : aDelPam.GetPoint()->nNode = aNdIdx;
1298 [ # # ]: 0 : aDelPam.GetPoint()->nContent.Assign( pAktTxtNd, 0 );
1299 : 0 : aDelPam.SetMark();
1300 : :
1301 : 0 : aDelPam.GetPoint()->nNode--;
1302 : 0 : SwTxtNode* pTNd = aDelPam.GetNode()->GetTxtNode();
1303 [ # # ]: 0 : if( pTNd )
1304 : : {
1305 : : // erstmal den vorherigen Textnode benutzen.
1306 [ # # ]: 0 : aDelPam.GetPoint()->nContent.Assign( pTNd, pTNd->GetTxt().Len() );
1307 : 0 : DeleteSel( aDelPam );
1308 : : }
1309 : 0 : aDelPam.DeleteMark();
1310 : 0 : }
1311 : :
1312 : :
1313 : 0 : void SwAutoFormat::BuildIndent()
1314 : : {
1315 : 0 : SetRedlineTxt( STR_AUTOFMTREDL_SET_TMPL_INDENT );
1316 : :
1317 : : // lese alle nachfolgenden Absaetze die zu diesem Einzug gehoeren
1318 : 0 : sal_Bool bBreak = sal_True;
1319 [ # # ]: 0 : if( bMoreLines )
1320 : 0 : DelMoreLinesBlanks( sal_True );
1321 : : else
1322 : 0 : bBreak = !IsFastFullLine( *pAktTxtNd ) ||
1323 : 0 : IsBlanksInString( *pAktTxtNd ) ||
1324 [ # # ]: 0 : IsSentenceAtEnd( *pAktTxtNd );
[ # # # # ]
1325 : 0 : SetColl( RES_POOLCOLL_TEXT_IDENT );
1326 [ # # ]: 0 : if( !bBreak )
1327 : : {
1328 : 0 : SetRedlineTxt( STR_AUTOFMTREDL_DEL_MORELINES );
1329 : 0 : const SwTxtNode* pNxtNd = GetNextNode();
1330 [ # # ][ # # ]: 0 : if( pNxtNd && !bEnde )
1331 : : {
1332 [ # # ]: 0 : do {
[ # # # # ]
1333 : 0 : bBreak = !IsFastFullLine( *pNxtNd ) ||
1334 : 0 : IsBlanksInString( *pNxtNd ) ||
1335 [ # # ]: 0 : IsSentenceAtEnd( *pNxtNd );
[ # # # # ]
1336 [ # # ]: 0 : if( DeleteAktNxtPara( pNxtNd->GetTxt() ))
1337 : : {
1338 [ # # ][ # # ]: 0 : pDoc->InsertString( aDelPam, rtl::OUString(' ') );
[ # # ]
1339 : : }
1340 [ # # ]: 0 : if( bBreak )
1341 : 0 : break;
1342 : 0 : pNxtNd = GetNextNode();
1343 : 0 : } while( CanJoin( pNxtNd ) &&
1344 : 0 : !CalcLevel( *pNxtNd ) );
1345 : : }
1346 : : }
1347 : 0 : DeleteAktPara( sal_True, sal_True );
1348 : 0 : AutoCorrect();
1349 : 0 : }
1350 : :
1351 : :
1352 : 0 : void SwAutoFormat::BuildTextIndent()
1353 : : {
1354 : 0 : SetRedlineTxt( STR_AUTOFMTREDL_SET_TMPL_TEXT_INDENT);
1355 : : // lese alle nachfolgenden Absaetze die zu diesem Einzug gehoeren
1356 : 0 : sal_Bool bBreak = sal_True;
1357 [ # # ]: 0 : if( bMoreLines )
1358 : 0 : DelMoreLinesBlanks( sal_True );
1359 : : else
1360 : 0 : bBreak = !IsFastFullLine( *pAktTxtNd ) ||
1361 : 0 : IsBlanksInString( *pAktTxtNd ) ||
1362 [ # # ]: 0 : IsSentenceAtEnd( *pAktTxtNd );
[ # # # # ]
1363 : :
1364 [ # # ]: 0 : if( aFlags.bAFmtByInput )
1365 : 0 : pAktTxtNd->SetAutoFmtLvl( (sal_uInt8)CalcLevel( *pAktTxtNd ) );
1366 : :
1367 : 0 : SetColl( RES_POOLCOLL_TEXT_MOVE );
1368 [ # # ]: 0 : if( !bBreak )
1369 : : {
1370 : 0 : SetRedlineTxt( STR_AUTOFMTREDL_DEL_MORELINES );
1371 : 0 : const SwTxtNode* pNxtNd = GetNextNode();
1372 [ # # # # ]: 0 : while( CanJoin( pNxtNd ) &&
[ # # ]
1373 : 0 : CalcLevel( *pNxtNd ) )
1374 : : {
1375 : 0 : bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
1376 [ # # ]: 0 : IsSentenceAtEnd( *pNxtNd );
[ # # # # ]
1377 [ # # ]: 0 : if( DeleteAktNxtPara( pNxtNd->GetTxt() ) )
1378 : : {
1379 [ # # ][ # # ]: 0 : pDoc->InsertString( aDelPam, rtl::OUString(' ') );
[ # # ]
1380 : : }
1381 [ # # ]: 0 : if( bBreak )
1382 : 0 : break;
1383 : 0 : pNxtNd = GetNextNode();
1384 : : }
1385 : : }
1386 : 0 : DeleteAktPara( sal_True, sal_True );
1387 : 0 : AutoCorrect();
1388 : 0 : }
1389 : :
1390 : :
1391 : 0 : void SwAutoFormat::BuildText()
1392 : : {
1393 : 0 : SetRedlineTxt( STR_AUTOFMTREDL_SET_TMPL_TEXT );
1394 : : // lese alle nachfolgenden Absaetze die zu diesem Text
1395 : : // ohne Einzug gehoeren
1396 : 0 : sal_Bool bBreak = sal_True;
1397 [ # # ]: 0 : if( bMoreLines )
1398 : 0 : DelMoreLinesBlanks();
1399 : : else
1400 : 0 : bBreak = !IsFastFullLine( *pAktTxtNd ) ||
1401 : 0 : IsBlanksInString( *pAktTxtNd ) ||
1402 [ # # ]: 0 : IsSentenceAtEnd( *pAktTxtNd );
[ # # # # ]
1403 : 0 : SetColl( RES_POOLCOLL_TEXT, sal_True );
1404 [ # # ]: 0 : if( !bBreak )
1405 : : {
1406 : 0 : SetRedlineTxt( STR_AUTOFMTREDL_DEL_MORELINES );
1407 : 0 : const SwTxtNode* pNxtNd = GetNextNode();
1408 [ # # # # ]: 0 : while( CanJoin( pNxtNd ) &&
[ # # ]
1409 : 0 : !CalcLevel( *pNxtNd ) )
1410 : : {
1411 : 0 : bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
1412 [ # # ]: 0 : IsSentenceAtEnd( *pNxtNd );
[ # # # # ]
1413 [ # # ]: 0 : if( DeleteAktNxtPara( pNxtNd->GetTxt() ) )
1414 : : {
1415 [ # # ][ # # ]: 0 : pDoc->InsertString( aDelPam, rtl::OUString(' ') );
[ # # ]
1416 : : }
1417 [ # # ]: 0 : if( bBreak )
1418 : 0 : break;
1419 : 0 : const SwTxtNode* pCurrNode = pNxtNd;
1420 : 0 : pNxtNd = GetNextNode();
1421 [ # # ][ # # ]: 0 : if(!pNxtNd || pCurrNode == pNxtNd)
1422 : 0 : break;
1423 : : }
1424 : : }
1425 : 0 : DeleteAktPara( sal_True, sal_True );
1426 : 0 : AutoCorrect();
1427 : 0 : }
1428 : :
1429 : :
1430 : 0 : void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
1431 : : {
1432 [ # # ]: 0 : SetRedlineTxt( STR_AUTOFMTREDL_SET_NUMBULET );
1433 : :
1434 : 0 : sal_Bool bBreak = sal_True;
1435 : :
1436 : : // als erstes den akt. Einzug bestimmen und die Framebreite bestimmen
1437 : 0 : SwTwips nFrmWidth = pAktTxtFrm->Prt().Width();;
1438 : : SwTwips nLeftTxtPos;
1439 : : {
1440 : 0 : const sal_Unicode* pTxt = pAktTxtNd->GetTxt().GetBuffer(), *pSav = pTxt;
1441 [ # # ]: 0 : while( IsSpace( *pTxt ) )
1442 : 0 : ++pTxt;
1443 : :
1444 : 0 : SwTxtFrmInfo aInfo( pAktTxtFrm );
1445 [ # # ]: 0 : nLeftTxtPos = aInfo.GetCharPos( static_cast<xub_StrLen>(pTxt - pSav) );
1446 [ # # ][ # # ]: 0 : nLeftTxtPos -= pAktTxtNd->GetSwAttrSet().GetLRSpace().GetLeft();
1447 : : }
1448 : :
1449 [ # # ]: 0 : if( bMoreLines )
1450 [ # # ]: 0 : DelMoreLinesBlanks();
1451 : : else
1452 [ # # ]: 0 : bBreak = !IsFastFullLine( *pAktTxtNd ) ||
1453 [ # # ]: 0 : IsBlanksInString( *pAktTxtNd ) ||
1454 [ # # ][ # # ]: 0 : IsSentenceAtEnd( *pAktTxtNd );
[ # # ]
1455 [ # # ]: 0 : sal_Bool bRTL = pEditShell->IsInRightToLeftText();
1456 [ # # ]: 0 : DeleteAktPara( sal_True, sal_True );
1457 : :
1458 : 0 : sal_Bool bChgBullet = sal_False, bChgEnum = sal_False;
1459 : 0 : xub_StrLen nAutoCorrPos = 0;
1460 : :
1461 : : // falls die Numerierung gesetzt werden, die akt. besorgen
1462 : : SwNumRule aRule( pDoc->GetUniqueNumRuleName(),
1463 : : // #i89178#
1464 [ # # ][ # # ]: 0 : numfunc::GetDefaultPositionAndSpaceMode() );
[ # # ][ # # ]
1465 : :
1466 : 0 : const SwNumRule* pCur = 0;
1467 [ # # ][ # # ]: 0 : if( aFlags.bSetNumRule && 0 != (pCur = pAktTxtNd->GetNumRule()) )
[ # # ][ # # ]
1468 [ # # ]: 0 : aRule = *pCur;
1469 : :
1470 : : // ersetze das Bullet-Zeichen mit dem definiertem
1471 : 0 : const String& rStr = pAktTxtNd->GetTxt();
1472 : 0 : xub_StrLen nTxtStt = 0, nOrigTxtStt = 0;
1473 : : const sal_Unicode* pFndBulletChr;
1474 [ # # ][ # # : 0 : if( aFlags.bChgEnumNum &&
# # # # #
# ]
1475 : 0 : 2 < rStr.Len() &&
1476 : 0 : 0 != ( pFndBulletChr = StrChr( pBulletChar, rStr.GetChar( nTxtStt ) ))
1477 : 0 : && IsSpace( rStr.GetChar( nTxtStt + 1 ) ) )
1478 : : {
1479 [ # # ]: 0 : if( aFlags.bAFmtByInput )
1480 : : {
1481 [ # # ]: 0 : if( aFlags.bSetNumRule )
1482 : : {
1483 : : SwCharFmt* pCFmt = pDoc->GetCharFmtFromPool(
1484 [ # # ]: 0 : RES_POOLCHR_BUL_LEVEL );
1485 : 0 : bChgBullet = sal_True;
1486 : : // wurde das Format schon mal angepasst?
1487 [ # # ][ # # ]: 0 : if( !aRule.GetNumFmt( nLvl ) )
1488 : : {
1489 : 0 : int nBulletPos = pFndBulletChr - pBulletChar;
1490 : : sal_Unicode cBullChar;
1491 : 0 : const Font* pBullFnt( 0 );
1492 [ # # ]: 0 : if( nBulletPos < cnPosEnDash )
1493 : : {
1494 : 0 : cBullChar = aFlags.cBullet;
1495 : 0 : pBullFnt = &aFlags.aBulletFont;
1496 : : }
1497 : : else
1498 : : {
1499 : : cBullChar = nBulletPos < cnPosEmDash
1500 : : ? cStarSymbolEnDash
1501 [ # # ]: 0 : : cStarSymbolEmDash;
1502 : : // #i63395#
1503 : : // Only apply user defined default bullet font
1504 [ # # ][ # # ]: 0 : if ( numfunc::IsDefBulletFontUserDefined() )
1505 : : {
1506 [ # # ]: 0 : pBullFnt = &numfunc::GetDefBulletFont();
1507 : : }
1508 : : }
1509 : :
1510 : 0 : sal_uInt16 nAbsPos = lBullIndent;
1511 : : sal_uInt16 nSpaceSteps = nLvl
1512 : : ? sal_uInt16(nLeftTxtPos / nLvl)
1513 [ # # ]: 0 : : lBullIndent;
1514 [ # # ]: 0 : for( sal_uInt8 n = 0; n < MAXLEVEL; ++n, nAbsPos = nAbsPos + nSpaceSteps )
1515 : : {
1516 [ # # ][ # # ]: 0 : SwNumFmt aFmt( aRule.Get( n ) );
1517 [ # # ]: 0 : aFmt.SetBulletFont( pBullFnt );
1518 : 0 : aFmt.SetBulletChar( cBullChar );
1519 : 0 : aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
1520 : : // #i93908# clear suffix for bullet lists
1521 : 0 : aFmt.SetPrefix(::rtl::OUString());
1522 : 0 : aFmt.SetSuffix(::rtl::OUString());
1523 : 0 : aFmt.SetFirstLineOffset( lBullFirstLineOffset );
1524 : 0 : aFmt.SetAbsLSpace( nAbsPos );
1525 [ # # ]: 0 : if( !aFmt.GetCharFmt() )
1526 [ # # ]: 0 : aFmt.SetCharFmt( pCFmt );
1527 [ # # ]: 0 : if( bRTL )
1528 : 0 : aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
1529 : :
1530 [ # # ]: 0 : aRule.Set( n, aFmt );
1531 : :
1532 [ # # ][ # # ]: 0 : if( n == nLvl &&
1533 : : nFrmWidth < ( nSpaceSteps * MAXLEVEL ) )
1534 : : nSpaceSteps = static_cast<sal_uInt16>(( nFrmWidth - nLeftTxtPos ) /
1535 : 0 : ( MAXLEVEL - nLvl ));
1536 [ # # ]: 0 : }
1537 : : }
1538 : : }
1539 : : }
1540 : : else
1541 : : {
1542 : 0 : bChgBullet = sal_True;
1543 [ # # ]: 0 : SetColl( static_cast<sal_uInt16>(RES_POOLCOLL_BUL_LEVEL1 + ( Min( nLvl, cnNumBullColls ) * 4 )) );
1544 : : }
1545 : : }
1546 : : else
1547 : : {
1548 : : // dann ist das eine Nummerierung
1549 : :
1550 : : //JP 21.11.97: Der NumLevel wird entweder der DigitLevel oder
1551 : : // wenn der nicht vorhanden oder 0 ist, durch den
1552 : : // (Einrueckungs-)Level.
1553 : :
1554 [ # # ][ # # ]: 0 : String aPostFix, aPreFix, aNumTypes;
[ # # ]
1555 [ # # ][ # # ]: 0 : if( USHRT_MAX != ( nDigitLevel = GetDigitLevel( *pAktTxtNd, nTxtStt,
1556 : 0 : &aPreFix, &aPostFix, &aNumTypes )) )
1557 : : {
1558 : 0 : bChgEnum = sal_True;
1559 : :
1560 : : // Ebene 0 und Einrueckung dann wird die Ebene durch den linken
1561 : : // Einzug und der default NumEinrueckung bestimmt.
1562 [ # # ][ # # ]: 0 : if( !nDigitLevel && nLeftTxtPos )
1563 : : nLvl = Min( sal_uInt16( nLeftTxtPos / lNumIndent ),
1564 : 0 : sal_uInt16( MAXLEVEL - 1 ) );
1565 : : else
1566 : 0 : nLvl = nDigitLevel;
1567 : : }
1568 : :
1569 [ # # ][ # # ]: 0 : if( bChgEnum && aFlags.bSetNumRule )
1570 : : {
1571 [ # # ]: 0 : if( !pCur ) // NumRule anpassen, wenn sie neu ist
1572 : : {
1573 : : SwCharFmt* pCFmt = pDoc->GetCharFmtFromPool(
1574 [ # # ]: 0 : RES_POOLCHR_NUM_LEVEL );
1575 [ # # ]: 0 : if( !nDigitLevel )
1576 : : {
1577 [ # # ][ # # ]: 0 : SwNumFmt aFmt( aRule.Get( nLvl ) );
1578 : : aFmt.SetStart( static_cast<sal_uInt16>(aPreFix.GetToken( 1,
1579 [ # # ][ # # ]: 0 : (sal_Unicode)1 ).ToInt32()));
[ # # ]
1580 [ # # ][ # # ]: 0 : aFmt.SetPrefix( aPreFix.GetToken( 0, (sal_Unicode)1 ));
[ # # ]
1581 [ # # ][ # # ]: 0 : aFmt.SetSuffix( aPostFix.GetToken( 0, (sal_Unicode)1 ));
[ # # ]
1582 : 0 : aFmt.SetIncludeUpperLevels( 0 );
1583 : :
1584 [ # # ]: 0 : if( !aFmt.GetCharFmt() )
1585 [ # # ]: 0 : aFmt.SetCharFmt( pCFmt );
1586 : :
1587 [ # # ]: 0 : if( aNumTypes.Len() )
1588 : 0 : aFmt.SetNumberingType(aNumTypes.GetChar( 0 ) - '0');
1589 : :
1590 [ # # ]: 0 : if( bRTL )
1591 : 0 : aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
1592 [ # # ][ # # ]: 0 : aRule.Set( nLvl, aFmt );
1593 : : }
1594 : : else
1595 : : {
1596 [ # # ]: 0 : sal_uInt16 nSpaceSteps = nLvl ? sal_uInt16(nLeftTxtPos / nLvl) : 0;
1597 : : sal_uInt8 n;
1598 [ # # ]: 0 : for( n = 0; n <= nLvl; ++n )
1599 : : {
1600 [ # # ][ # # ]: 0 : SwNumFmt aFmt( aRule.Get( n ) );
1601 : :
1602 : : aFmt.SetStart( static_cast<sal_uInt16>(aPreFix.GetToken( n+1,
1603 [ # # ][ # # ]: 0 : (sal_Unicode)1 ).ToInt32() ));
[ # # ]
1604 [ # # ]: 0 : if( !n )
1605 [ # # ][ # # ]: 0 : aFmt.SetPrefix( aPreFix.GetToken( n, (sal_Unicode)1 ));
[ # # ]
1606 [ # # ][ # # ]: 0 : aFmt.SetSuffix( aPostFix.GetToken( n, (sal_Unicode)1 ));
[ # # ]
1607 : 0 : aFmt.SetIncludeUpperLevels( MAXLEVEL );
1608 [ # # ]: 0 : if( n < aNumTypes.Len() )
1609 : 0 : aFmt.SetNumberingType((aNumTypes.GetChar( n ) - '0'));
1610 : :
1611 : : aFmt.SetAbsLSpace( sal_uInt16( nSpaceSteps * n )
1612 : 0 : + lNumIndent );
1613 : :
1614 [ # # ]: 0 : if( !aFmt.GetCharFmt() )
1615 [ # # ]: 0 : aFmt.SetCharFmt( pCFmt );
1616 [ # # ]: 0 : if( bRTL )
1617 : 0 : aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
1618 : :
1619 [ # # ]: 0 : aRule.Set( n, aFmt );
1620 [ # # ]: 0 : }
1621 : :
1622 : : // passt alles vollstaendig in den Frame?
1623 : 0 : sal_Bool bDefStep = nFrmWidth < (nSpaceSteps * MAXLEVEL);
1624 [ # # ]: 0 : for( ; n < MAXLEVEL; ++n )
1625 : : {
1626 [ # # ][ # # ]: 0 : SwNumFmt aFmt( aRule.Get( n ) );
1627 : 0 : aFmt.SetIncludeUpperLevels( MAXLEVEL );
1628 [ # # ]: 0 : if( bDefStep )
1629 : : aFmt.SetAbsLSpace( sal_uInt16( (nLeftTxtPos +
1630 [ # # ]: 0 : SwNumRule::GetNumIndent(static_cast<sal_uInt8>(n-nLvl)))));
1631 : : else
1632 : : aFmt.SetAbsLSpace( sal_uInt16( nSpaceSteps * n )
1633 : 0 : + lNumIndent );
1634 [ # # ]: 0 : aRule.Set( n, aFmt );
1635 [ # # ]: 0 : }
1636 : : }
1637 : 0 : }
1638 : : }
1639 [ # # ]: 0 : else if( !aFlags.bAFmtByInput )
1640 [ # # ]: 0 : SetColl( static_cast<sal_uInt16>(RES_POOLCOLL_NUM_LEVEL1 + ( Min( nLvl, cnNumBullColls ) * 4 ) ));
1641 : : else
1642 [ # # ][ # # ]: 0 : bChgEnum = sal_False;
[ # # ]
1643 : : }
1644 : :
1645 [ # # ][ # # ]: 0 : if( bChgEnum || bChgBullet )
1646 : : {
1647 [ # # ]: 0 : aDelPam.DeleteMark();
1648 [ # # ]: 0 : aDelPam.GetPoint()->nNode = aNdIdx;
1649 : :
1650 [ # # ]: 0 : if( aFlags.bSetNumRule )
1651 : : {
1652 [ # # ]: 0 : if( aFlags.bAFmtByInput )
1653 : : {
1654 [ # # ]: 0 : aDelPam.SetMark();
1655 [ # # ]: 0 : aDelPam.GetMark()->nNode++;
1656 [ # # ]: 0 : aDelPam.GetNode(sal_False)->GetTxtNode()->SetAttrListLevel( nLvl );
1657 : : }
1658 : :
1659 [ # # ]: 0 : pAktTxtNd->SetAttrListLevel(nLvl);
1660 : 0 : pAktTxtNd->SetNumLSpace( sal_True );
1661 : :
1662 : : // start new list
1663 [ # # ][ # # ]: 0 : pDoc->SetNumRule( aDelPam, aRule, true );
[ # # ]
1664 [ # # ]: 0 : aDelPam.DeleteMark();
1665 : :
1666 [ # # ][ # # ]: 0 : aDelPam.GetPoint()->nContent.Assign( pAktTxtNd, 0 );
1667 : : }
1668 : : else
1669 : 0 : aDelPam.GetPoint()->nContent.Assign( pAktTxtNd,
1670 [ # # ][ # # ]: 0 : bChgEnum ? (nTxtStt - nOrigTxtStt) : 0 );
[ # # ]
1671 [ # # ]: 0 : aDelPam.SetMark();
1672 : :
1673 [ # # ]: 0 : if( bChgBullet )
1674 : 0 : nTxtStt += 2;
1675 : :
1676 [ # # ][ # # ]: 0 : while( nTxtStt < rStr.Len() && IsSpace( rStr.GetChar( nTxtStt ) ))
[ # # ]
1677 : 0 : nTxtStt++;
1678 : :
1679 [ # # ]: 0 : aDelPam.GetPoint()->nContent = nTxtStt - nOrigTxtStt;
1680 [ # # ]: 0 : DeleteSel( aDelPam );
1681 : :
1682 [ # # ]: 0 : if( !aFlags.bSetNumRule )
1683 : : {
1684 [ # # ]: 0 : String sChgStr = rtl::OUString('\t');
1685 [ # # ]: 0 : if( bChgBullet )
1686 [ # # ]: 0 : sChgStr.Insert( aFlags.cBullet, 0 );
1687 [ # # ]: 0 : pDoc->InsertString( aDelPam, sChgStr );
1688 : :
1689 [ # # ]: 0 : SfxItemSet aSet( pDoc->GetAttrPool(), aTxtNodeSetRange );
1690 [ # # ]: 0 : if( bChgBullet )
1691 : : {
1692 [ # # ]: 0 : aDelPam.GetPoint()->nContent = 0;
1693 [ # # ]: 0 : aDelPam.SetMark();
1694 [ # # ]: 0 : aDelPam.GetMark()->nContent = 1;
1695 : : SetAllScriptItem( aSet,
1696 : : SvxFontItem( aFlags.aBulletFont.GetFamily(),
1697 [ # # ]: 0 : aFlags.aBulletFont.GetName(),
1698 [ # # ]: 0 : aFlags.aBulletFont.GetStyleName(),
1699 : : aFlags.aBulletFont.GetPitch(),
1700 [ # # ]: 0 : aFlags.aBulletFont.GetCharSet(),
1701 [ # # ][ # # ]: 0 : RES_CHRATR_FONT ) );
[ # # ][ # # ]
[ # # ]
1702 [ # # ]: 0 : pDoc->SetFmtItemByAutoFmt( aDelPam, aSet );
1703 [ # # ]: 0 : aDelPam.DeleteMark();
1704 : 0 : nAutoCorrPos = 2;
1705 [ # # ]: 0 : aSet.ClearItem();
1706 : : }
1707 [ # # ][ # # ]: 0 : SvxTabStopItem aTStops( RES_PARATR_TABSTOP ); aTStops.Insert( SvxTabStop( 0 ));
[ # # ]
1708 [ # # ]: 0 : aSet.Put( aTStops );
1709 [ # # ][ # # ]: 0 : pDoc->SetFmtItemByAutoFmt( aDelPam, aSet );
[ # # ][ # # ]
1710 : : }
1711 : : }
1712 : :
1713 [ # # ]: 0 : if( bBreak )
1714 : : {
1715 [ # # ]: 0 : AutoCorrect( nAutoCorrPos ); /* Offset wegen Bullet + Tab */
1716 : 0 : return;
1717 : : }
1718 : :
1719 [ # # ]: 0 : const SwTxtNode* pNxtNd = GetNextNode();
1720 [ # # ][ # # ]: 0 : while( CanJoin( pNxtNd ) &&
[ # # ][ # # ]
1721 [ # # ]: 0 : nLvl == CalcLevel( *pNxtNd ) )
1722 : : {
1723 [ # # ]: 0 : SetRedlineTxt( STR_AUTOFMTREDL_DEL_MORELINES );
1724 [ # # ][ # # ]: 0 : bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) ||
1725 [ # # ][ # # ]: 0 : IsSentenceAtEnd( *pNxtNd );
[ # # ]
1726 [ # # ][ # # ]: 0 : if( DeleteAktNxtPara( pNxtNd->GetTxt() ) )
1727 : : {
1728 [ # # ][ # # ]: 0 : pDoc->InsertString( aDelPam, rtl::OUString(' ') );
[ # # ]
1729 : : }
1730 [ # # ]: 0 : if( bBreak )
1731 : 0 : break;
1732 : 0 : const SwTxtNode* pCurrNode = pNxtNd;
1733 [ # # ]: 0 : pNxtNd = GetNextNode();
1734 [ # # ][ # # ]: 0 : if(!pNxtNd || pCurrNode == pNxtNd)
1735 : 0 : break;
1736 : : }
1737 [ # # ]: 0 : DeleteAktPara( sal_False, sal_True );
1738 [ # # ][ # # ]: 0 : AutoCorrect( nAutoCorrPos );
[ # # ]
1739 : : }
1740 : :
1741 : :
1742 : 0 : void SwAutoFormat::BuildNegIndent( SwTwips nSpaces )
1743 : : {
1744 [ # # ]: 0 : SetRedlineTxt( STR_AUTOFMTREDL_SET_TMPL_NEG_INDENT );
1745 : : // Test auf Gegenueberstellung:
1746 : : // (n Worte, durch Space/Tabs getrennt, mit gleicher
1747 : : // Einrueckung in der 2.Zeile)
1748 : :
1749 : : // lese alle nachfolgenden Absaetze die zu dieser Aufzaehlung gehoeren
1750 : 0 : sal_Bool bBreak = sal_True;
1751 [ # # ]: 0 : xub_StrLen nSpacePos, nTxtPos = GetBigIndent( nSpacePos );
1752 [ # # ]: 0 : if( bMoreLines )
1753 [ # # ]: 0 : DelMoreLinesBlanks( sal_True );
1754 : : else
1755 [ # # ]: 0 : bBreak = !IsFastFullLine( *pAktTxtNd ) ||
1756 [ # # ]: 0 : ( !nTxtPos && IsBlanksInString( *pAktTxtNd )) ||
1757 [ # # ][ # # ]: 0 : IsSentenceAtEnd( *pAktTxtNd );
[ # # ][ # # ]
1758 : :
1759 : : SetColl( static_cast<sal_uInt16>( nTxtPos
1760 : : ? RES_POOLCOLL_CONFRONTATION
1761 [ # # ][ # # ]: 0 : : RES_POOLCOLL_TEXT_NEGIDENT ) );
1762 : :
1763 [ # # ]: 0 : if( nTxtPos )
1764 : : {
1765 : 0 : const String& rStr = pAktTxtNd->GetTxt();
1766 : 0 : sal_Bool bInsTab = sal_True;
1767 : :
1768 [ # # ]: 0 : if( '\t' == rStr.GetChar( nSpacePos+1 )) // ein Tab, das belassen wir
1769 : : {
1770 : 0 : --nSpacePos;
1771 : 0 : bInsTab = sal_False;
1772 : : }
1773 : :
1774 : 0 : xub_StrLen nSpaceStt = nSpacePos;
1775 [ # # ][ # # ]: 0 : while( nSpaceStt && IsSpace( rStr.GetChar( --nSpaceStt ) ) )
[ # # ]
1776 : : ;
1777 : 0 : ++nSpaceStt;
1778 : :
1779 [ # # ][ # # ]: 0 : if( bInsTab && '\t' == rStr.GetChar( nSpaceStt ) ) // ein Tab, das belassen wir
[ # # ]
1780 : : {
1781 : 0 : ++nSpaceStt;
1782 : 0 : bInsTab = sal_False;
1783 : : }
1784 : :
1785 : :
1786 [ # # ]: 0 : aDelPam.DeleteMark();
1787 [ # # ]: 0 : aDelPam.GetPoint()->nNode = aNdIdx;
1788 [ # # ][ # # ]: 0 : aDelPam.GetPoint()->nContent.Assign( pAktTxtNd, nSpacePos );
1789 : :
1790 : : // alten Spaces, usw. loeschen
1791 [ # # ]: 0 : if( nSpaceStt < nSpacePos )
1792 : : {
1793 [ # # ]: 0 : aDelPam.SetMark();
1794 [ # # ]: 0 : aDelPam.GetMark()->nContent = nSpaceStt;
1795 [ # # ]: 0 : DeleteSel( aDelPam );
1796 [ # # ]: 0 : if( bInsTab )
1797 : : {
1798 [ # # ][ # # ]: 0 : pDoc->InsertString( aDelPam, rtl::OUString('\t') );
[ # # ]
1799 : : }
1800 : : }
1801 : : }
1802 : :
1803 [ # # ]: 0 : if( !bBreak )
1804 : : {
1805 [ # # ]: 0 : SetRedlineTxt( STR_AUTOFMTREDL_DEL_MORELINES );
1806 : 0 : SwTxtFrmInfo aFInfo( pAktTxtFrm );
1807 [ # # ]: 0 : const SwTxtNode* pNxtNd = GetNextNode();
1808 [ # # ]: 0 : while( CanJoin( pNxtNd ) &&
[ # # # # ]
[ # # ]
1809 : : 20 < Abs( (long)(nSpaces - aFInfo.SetFrm(
1810 [ # # ][ # # ]: 0 : GetFrm( *pNxtNd ) ).GetLineStart() ))
1811 : : )
1812 : : {
1813 [ # # ]: 0 : bBreak = !IsFastFullLine( *pNxtNd ) ||
1814 [ # # ]: 0 : IsBlanksInString( *pNxtNd ) ||
1815 [ # # ][ # # ]: 0 : IsSentenceAtEnd( *pNxtNd );
[ # # ]
1816 [ # # ][ # # ]: 0 : if( DeleteAktNxtPara( pNxtNd->GetTxt() ) )
1817 : : {
1818 [ # # ][ # # ]: 0 : pDoc->InsertString( aDelPam, rtl::OUString(' ') );
[ # # ]
1819 : : }
1820 [ # # ]: 0 : if( bBreak )
1821 : 0 : break;
1822 [ # # ]: 0 : pNxtNd = GetNextNode();
1823 : : }
1824 : : }
1825 [ # # ]: 0 : DeleteAktPara( sal_True, sal_True );
1826 [ # # ]: 0 : AutoCorrect();
1827 : 0 : }
1828 : :
1829 : :
1830 : 0 : void SwAutoFormat::BuildHeadLine( sal_uInt16 nLvl )
1831 : : {
1832 [ # # ]: 0 : if( aFlags.bWithRedlining )
1833 : : {
1834 [ # # ][ # # ]: 0 : String sTxt(ViewShell::GetShellRes()->GetAutoFmtNameLst()[
1835 [ # # ][ # # ]: 0 : STR_AUTOFMTREDL_SET_TMPL_HEADLINE ] );
1836 : : sTxt.SearchAndReplace( rtl::OUString("$(ARG1)"),
1837 [ # # ][ # # ]: 0 : String::CreateFromInt32( nLvl + 1 ) );
[ # # ][ # # ]
[ # # ]
1838 [ # # ][ # # ]: 0 : pDoc->SetAutoFmtRedlineComment( &sTxt );
1839 : : }
1840 : :
1841 : 0 : SetColl( static_cast<sal_uInt16>(RES_POOLCOLL_HEADLINE1 + nLvl ), sal_True );
1842 [ # # ]: 0 : if( aFlags.bAFmtByInput )
1843 : : {
1844 : 0 : SwTxtFmtColl& rNxtColl = pAktTxtNd->GetTxtColl()->GetNextTxtFmtColl();
1845 : :
1846 : 0 : DelPrevPara();
1847 : :
1848 : 0 : DeleteAktPara( sal_True, sal_False );
1849 : 0 : DeleteAktNxtPara( aEmptyStr );
1850 : :
1851 : 0 : aDelPam.DeleteMark();
1852 : 0 : aDelPam.GetPoint()->nNode = aNdIdx.GetIndex() + 1;
1853 [ # # ]: 0 : aDelPam.GetPoint()->nContent.Assign( aDelPam.GetCntntNode(), 0 );
1854 : 0 : pDoc->SetTxtFmtColl( aDelPam, &rNxtColl );
1855 : : }
1856 : : else
1857 : : {
1858 : 0 : DeleteAktPara( sal_True, sal_True );
1859 : 0 : AutoCorrect();
1860 : : }
1861 : 0 : }
1862 : :
1863 : :
1864 : : // dann lasse doch mal das AutoCorrect auf den akt. TextNode los
1865 : 0 : void SwAutoFormat::AutoCorrect( xub_StrLen nPos )
1866 : : {
1867 [ # # ]: 0 : SvxAutoCorrect* pATst = SvxAutoCorrCfg::Get().GetAutoCorrect();
1868 : 0 : long aSvxFlags = pATst->GetFlags( );
1869 : 0 : bool bReplaceQuote = ( aSvxFlags & ChgQuotes ) > 0;
1870 : 0 : bool bReplaceSglQuote = ( aSvxFlags & ChgSglQuotes ) > 0;
1871 : :
1872 [ # # ][ # # ]: 0 : if( aFlags.bAFmtByInput ||
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1873 : 0 : (!aFlags.bAutoCorrect && !bReplaceQuote && !bReplaceSglQuote &&
1874 : 0 : !aFlags.bCptlSttSntnc && !aFlags.bCptlSttWrd &&
1875 : 0 : !aFlags.bChgOrdinalNumber &&
1876 : 0 : !aFlags.bChgToEnEmDash && !aFlags.bSetINetAttr &&
1877 : 0 : !aFlags.bChgWeightUnderl && !aFlags.bAddNonBrkSpace) )
1878 : : return;
1879 : :
1880 : 0 : const String* pTxt = &pAktTxtNd->GetTxt();
1881 [ # # ]: 0 : if( nPos >= pTxt->Len() )
1882 : : return;
1883 : :
1884 : : sal_Bool bGetLanguage = aFlags.bChgOrdinalNumber ||
1885 : : aFlags.bChgToEnEmDash || aFlags.bSetINetAttr ||
1886 : : aFlags.bCptlSttWrd || aFlags.bCptlSttSntnc ||
1887 [ # # ][ # # ]: 0 : aFlags.bAddNonBrkSpace;
[ # # ][ # # ]
[ # # ][ # # ]
1888 : :
1889 : :
1890 [ # # ]: 0 : aDelPam.DeleteMark();
1891 [ # # ]: 0 : aDelPam.GetPoint()->nNode = aNdIdx;
1892 [ # # ][ # # ]: 0 : aDelPam.GetPoint()->nContent.Assign( pAktTxtNd, 0 );
1893 : :
1894 [ # # ]: 0 : SwAutoCorrDoc aACorrDoc( *pEditShell, aDelPam );
1895 : :
1896 : 0 : SwTxtFrmInfo aFInfo( 0 );
1897 : :
1898 : 0 : xub_StrLen nSttPos, nLastBlank = nPos;
1899 : 0 : sal_Bool bFirst = aFlags.bCptlSttSntnc, bFirstSent = bFirst;
1900 : 0 : sal_Unicode cChar = 0;
1901 : :
1902 [ # # ]: 0 : CharClass& rAppCC = GetAppCharClass();
1903 : :
1904 [ # # ]: 0 : do {
1905 [ # # ][ # # ]: 0 : while( nPos < pTxt->Len() && IsSpace( cChar = pTxt->GetChar( nPos ) ))
[ # # ]
1906 : 0 : ++nPos;
1907 [ # # ]: 0 : if( nPos == pTxt->Len() )
1908 : 0 : break; // das wars
1909 : :
1910 [ # # ][ # # ]: 0 : if( ( ( bReplaceQuote && '\"' == cChar ) ||
[ # # ][ # # ]
[ # # # # ]
[ # # ]
1911 : : ( bReplaceSglQuote && '\'' == cChar ) ) &&
1912 : 0 : ( !nPos || ' ' == pTxt->GetChar( nPos-1 ) ) )
1913 : : {
1914 : : // --------------------------------------
1915 : : // beachte: Sonderfall Symbolfonts !!!
1916 [ # # ]: 0 : if( !aFInfo.GetFrm() )
1917 [ # # ]: 0 : aFInfo.SetFrm( GetFrm( *pAktTxtNd ) );
1918 [ # # ][ # # ]: 0 : if( !aFInfo.IsBullet( nPos ))
1919 : : {
1920 [ # # ]: 0 : SetRedlineTxt( STR_AUTOFMTREDL_TYPO );
1921 [ # # ]: 0 : aDelPam.GetPoint()->nContent = nPos;
1922 : 0 : sal_Bool bSetHardBlank = sal_False;
1923 : :
1924 : : String sReplace( pATst->GetQuote( aACorrDoc,
1925 [ # # ]: 0 : nPos, cChar, sal_True ));
1926 : :
1927 [ # # ]: 0 : aDelPam.SetMark();
1928 [ # # ]: 0 : aDelPam.GetPoint()->nContent = nPos+1;
1929 [ # # ][ # # ]: 0 : if( 2 == sReplace.Len() && ' ' == sReplace.GetChar( 1 ))
[ # # ]
1930 : : {
1931 [ # # ]: 0 : sReplace.Erase( 1 );
1932 : 0 : bSetHardBlank = sal_True;
1933 : : }
1934 [ # # ]: 0 : pDoc->ReplaceRange( aDelPam, sReplace, false );
1935 : :
1936 [ # # ]: 0 : if( aFlags.bWithRedlining )
1937 : : {
1938 [ # # ]: 0 : aNdIdx = aDelPam.GetPoint()->nNode;
1939 : 0 : pAktTxtNd = aNdIdx.GetNode().GetTxtNode();
1940 : 0 : pTxt = &pAktTxtNd->GetTxt();
1941 [ # # ]: 0 : aDelPam.SetMark();
1942 : 0 : aFInfo.SetFrm( 0 );
1943 : : }
1944 : :
1945 : 0 : nPos += sReplace.Len() - 1;
1946 [ # # ]: 0 : aDelPam.DeleteMark();
1947 [ # # ]: 0 : if( bSetHardBlank )
1948 : : {
1949 [ # # ][ # # ]: 0 : pDoc->InsertString( aDelPam, rtl::OUString(CHAR_HARDBLANK) );
[ # # ]
1950 : 0 : ++nPos;
1951 [ # # ]: 0 : }
1952 : : }
1953 : : }
1954 : :
1955 : 0 : int bCallACorr = sal_False;
1956 : 0 : int bBreak = 0;
1957 [ # # ][ # # ]: 0 : if( nPos && IsSpace( pTxt->GetChar( nPos-1 )))
[ # # ]
1958 : 0 : nLastBlank = nPos;
1959 [ # # ][ # # ]: 0 : for( nSttPos = nPos; !bBreak && nPos < pTxt->Len(); ++nPos )
[ # # ]
1960 [ # # # # : 0 : switch( cChar = pTxt->GetChar( nPos ) )
# ]
1961 : : {
1962 : : case '\"':
1963 : : case '\'':
1964 [ # # ][ # # ]: 0 : if( ( cChar == '\"' && bReplaceQuote ) || ( cChar == '\'' && bReplaceSglQuote ) )
[ # # ][ # # ]
1965 : : {
1966 : : // --------------------------------------
1967 : : // beachte: Sonderfall Symbolfonts !!!
1968 [ # # ]: 0 : if( !aFInfo.GetFrm() )
1969 [ # # ]: 0 : aFInfo.SetFrm( GetFrm( *pAktTxtNd ) );
1970 [ # # ][ # # ]: 0 : if( !aFInfo.IsBullet( nPos ))
1971 : : {
1972 [ # # ]: 0 : SetRedlineTxt( STR_AUTOFMTREDL_TYPO );
1973 : 0 : sal_Bool bSetHardBlank = sal_False;
1974 [ # # ]: 0 : aDelPam.GetPoint()->nContent = nPos;
1975 : : String sReplace( pATst->GetQuote( aACorrDoc,
1976 [ # # ]: 0 : nPos, cChar, sal_False ));
1977 : :
1978 [ # # ][ # # ]: 0 : if( 2 == sReplace.Len() && ' ' == sReplace.GetChar( 0 ))
[ # # ]
1979 : : {
1980 [ # # ]: 0 : sReplace.Erase( 0, 1 );
1981 : 0 : bSetHardBlank = sal_True;
1982 : : }
1983 : :
1984 [ # # ]: 0 : aDelPam.SetMark();
1985 [ # # ]: 0 : aDelPam.GetPoint()->nContent = nPos+1;
1986 [ # # ]: 0 : pDoc->ReplaceRange( aDelPam, sReplace, false );
1987 : :
1988 [ # # ]: 0 : if( aFlags.bWithRedlining )
1989 : : {
1990 [ # # ]: 0 : aNdIdx = aDelPam.GetPoint()->nNode;
1991 : 0 : pAktTxtNd = aNdIdx.GetNode().GetTxtNode();
1992 : 0 : pTxt = &pAktTxtNd->GetTxt();
1993 [ # # ]: 0 : aDelPam.SetMark();
1994 [ # # ]: 0 : aDelPam.DeleteMark();
1995 : 0 : aFInfo.SetFrm( 0 );
1996 : : }
1997 : :
1998 : 0 : nPos += sReplace.Len() - 1;
1999 [ # # ]: 0 : aDelPam.DeleteMark();
2000 : :
2001 [ # # ]: 0 : if( bSetHardBlank )
2002 : : {
2003 [ # # ]: 0 : aDelPam.GetPoint()->nContent = nPos;
2004 [ # # ][ # # ]: 0 : pDoc->InsertString( aDelPam, rtl::OUString(CHAR_HARDBLANK) );
[ # # ]
2005 [ # # ]: 0 : aDelPam.GetPoint()->nContent = ++nPos;
2006 [ # # ]: 0 : }
2007 : : }
2008 : : }
2009 : 0 : break;
2010 : : case '*':
2011 : : case '_':
2012 [ # # ]: 0 : if( aFlags.bChgWeightUnderl )
2013 : : {
2014 : : // --------------------------------------
2015 : : // beachte: Sonderfall Symbolfonts !!!
2016 [ # # ]: 0 : if( !aFInfo.GetFrm() )
2017 [ # # ]: 0 : aFInfo.SetFrm( GetFrm( *pAktTxtNd ) );
2018 [ # # ][ # # ]: 0 : if( !aFInfo.IsBullet( nPos ))
2019 : : {
2020 : : SetRedlineTxt( '*' == cChar
2021 : : ? STR_AUTOFMTREDL_BOLD
2022 [ # # ][ # # ]: 0 : : STR_AUTOFMTREDL_UNDER );
2023 : :
2024 [ # # ]: 0 : sal_Unicode cBlank = nSttPos ? pTxt->GetChar(nSttPos - 1) : 0;
2025 [ # # ]: 0 : aDelPam.GetPoint()->nContent = nPos;
2026 : :
2027 [ # # ]: 0 : if( pATst->FnChgWeightUnderl( aACorrDoc, *pTxt,
2028 [ # # ]: 0 : nSttPos, nPos ))
2029 : : {
2030 [ # # ]: 0 : if( aFlags.bWithRedlining )
2031 : : {
2032 [ # # ]: 0 : aNdIdx = aDelPam.GetPoint()->nNode;
2033 : 0 : pAktTxtNd = aNdIdx.GetNode().GetTxtNode();
2034 : 0 : pTxt = &pAktTxtNd->GetTxt();
2035 [ # # ]: 0 : aDelPam.SetMark();
2036 [ # # ]: 0 : aDelPam.DeleteMark();
2037 : 0 : aFInfo.SetFrm( 0 );
2038 : : }
2039 : : //#125102# in case of the mode REDLINE_SHOW_DELETE the ** are still contained in pTxt
2040 [ # # ][ # # ]: 0 : if(0 == (pDoc->GetRedlineMode() & nsRedlineMode_t::REDLINE_SHOW_DELETE))
2041 : 0 : nPos = aDelPam.GetPoint()->nContent.GetIndex() - 1;
2042 : : // wurde vorm Start ein Zeichen entfernt?
2043 [ # # ][ # # ]: 0 : if( cBlank && cBlank != pTxt->GetChar(nSttPos - 1) )
[ # # ]
2044 : 0 : --nSttPos;
2045 : : }
2046 : : }
2047 : : }
2048 : 0 : break;
2049 : : case '/':
2050 [ # # ]: 0 : if ( aFlags.bAddNonBrkSpace )
2051 : : {
2052 : : LanguageType eLang = (bGetLanguage && pAktTxtNd)
2053 : 0 : ? pAktTxtNd->GetLang( nSttPos )
2054 [ # # ][ # # ]: 0 : : LANGUAGE_SYSTEM;
[ # # ]
2055 : :
2056 [ # # ]: 0 : SetRedlineTxt( STR_AUTOFMTREDL_NON_BREAK_SPACE );
2057 [ # # ][ # # ]: 0 : if ( pATst->FnAddNonBrkSpace( aACorrDoc, *pTxt, nSttPos, nPos, eLang ) )
2058 : 0 : --nPos;
2059 : : }
2060 : 0 : break;
2061 : :
2062 : : case '.':
2063 : : case '!':
2064 : : case '?':
2065 [ # # ]: 0 : if( aFlags.bCptlSttSntnc )
2066 : 0 : bFirstSent = sal_True;
2067 : : default:
2068 [ # # ][ # # ]: 0 : if( !( rAppCC.isLetterNumeric( *pTxt, nPos )
2069 [ # # ][ # # ]: 0 : || '/' == cChar )) // '/' should not be a word seperator (e.g. '1/2' needs to be handled as one word for replacement)
2070 : : {
2071 : 0 : --nPos; // ++nPos von dem for ungueltig machen !
2072 : 0 : ++bBreak;
2073 : : }
2074 : 0 : break;
2075 : : }
2076 : :
2077 [ # # ]: 0 : if( nPos == nSttPos )
2078 : : {
2079 [ # # ]: 0 : if( ++nPos == pTxt->Len() )
2080 : 0 : bCallACorr = sal_True;
2081 : : }
2082 : : else
2083 : 0 : bCallACorr = sal_True;
2084 : :
2085 : :
2086 [ # # ]: 0 : if( bCallACorr )
2087 : : {
2088 : 0 : bCallACorr = sal_False;
2089 [ # # ]: 0 : aDelPam.GetPoint()->nContent = nPos;
2090 [ # # ]: 0 : SetRedlineTxt( STR_AUTOFMTREDL_USE_REPLACE );
2091 [ # # ][ # # ]: 0 : if( aFlags.bAutoCorrect &&
[ # # ]
2092 [ # # ]: 0 : aACorrDoc.ChgAutoCorrWord( nSttPos, nPos, *pATst, 0 ) )
2093 : : {
2094 : 0 : nPos = aDelPam.GetPoint()->nContent.GetIndex();
2095 : :
2096 [ # # ]: 0 : if( aFlags.bWithRedlining )
2097 : : {
2098 [ # # ]: 0 : aNdIdx = aDelPam.GetPoint()->nNode;
2099 : 0 : pAktTxtNd = aNdIdx.GetNode().GetTxtNode();
2100 : 0 : pTxt = &pAktTxtNd->GetTxt();
2101 [ # # ]: 0 : aDelPam.SetMark();
2102 [ # # ]: 0 : aDelPam.DeleteMark();
2103 : : }
2104 : :
2105 : 0 : continue; // nichts weiter mehr abpruefen
2106 : : }
2107 : :
2108 : : LanguageType eLang = (bGetLanguage && pAktTxtNd)
2109 : 0 : ? pAktTxtNd->GetLang( nSttPos )
2110 [ # # ][ # # ]: 0 : : LANGUAGE_SYSTEM;
[ # # ]
2111 : :
2112 [ # # ]: 0 : if ( aFlags.bAddNonBrkSpace )
2113 : : {
2114 [ # # ]: 0 : SetRedlineTxt( STR_AUTOFMTREDL_NON_BREAK_SPACE );
2115 [ # # ]: 0 : pATst->FnAddNonBrkSpace( aACorrDoc, *pTxt, nSttPos, nPos, eLang );
2116 : : }
2117 : :
2118 [ # # ][ # # ]: 0 : if( ( aFlags.bChgOrdinalNumber &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # ][ # # ]
[ # # ][ # # ]
2119 [ # # ]: 0 : SetRedlineTxt( STR_AUTOFMTREDL_ORDINAL ) &&
2120 [ # # ]: 0 : pATst->FnChgOrdinalNumber( aACorrDoc, *pTxt, nSttPos, nPos, eLang ) ) ||
2121 : : ( aFlags.bChgToEnEmDash &&
2122 [ # # ]: 0 : SetRedlineTxt( STR_AUTOFMTREDL_DASH ) &&
2123 [ # # ]: 0 : pATst->FnChgToEnEmDash( aACorrDoc, *pTxt, nSttPos, nPos, eLang ) ) ||
2124 : : ( aFlags.bSetINetAttr &&
2125 : 0 : ( nPos == pTxt->Len() || IsSpace( pTxt->GetChar( nPos )) ) &&
2126 [ # # ]: 0 : SetRedlineTxt( STR_AUTOFMTREDL_DETECT_URL ) &&
2127 [ # # ]: 0 : pATst->FnSetINetAttr( aACorrDoc, *pTxt, nLastBlank, nPos, eLang ) ) )
2128 : 0 : nPos = aDelPam.GetPoint()->nContent.GetIndex();
2129 : : else
2130 : : {
2131 : : // Zwei Grossbuchstaben am Wort-Anfang ??
2132 [ # # ]: 0 : if( aFlags.bCptlSttWrd )
2133 : : {
2134 [ # # ]: 0 : SetRedlineTxt( STR_AUTOFMTREDL_CPTL_STT_WORD );
2135 [ # # ]: 0 : pATst->FnCptlSttWrd( aACorrDoc, *pTxt, nSttPos, nPos, eLang );
2136 : : }
2137 : : // Grossbuchstabe am Satz-Anfang ??
2138 [ # # ][ # # ]: 0 : if( aFlags.bCptlSttSntnc && bFirst )
2139 : : {
2140 [ # # ]: 0 : SetRedlineTxt( STR_AUTOFMTREDL_CPTL_STT_SENT );
2141 [ # # ]: 0 : pATst->FnCptlSttSntnc( aACorrDoc, *pTxt, sal_True, nSttPos, nPos, eLang);
2142 : 0 : bFirst = sal_False;
2143 : : }
2144 : :
2145 : 0 : bFirst = bFirstSent;
2146 : 0 : bFirstSent = sal_False;
2147 : :
2148 [ # # ]: 0 : if( aFlags.bWithRedlining )
2149 : : {
2150 [ # # ]: 0 : aNdIdx = aDelPam.GetPoint()->nNode;
2151 : 0 : pAktTxtNd = aNdIdx.GetNode().GetTxtNode();
2152 : 0 : pTxt = &pAktTxtNd->GetTxt();
2153 [ # # ]: 0 : aDelPam.SetMark();
2154 [ # # ]: 0 : aDelPam.DeleteMark();
2155 : : }
2156 : : }
2157 : : }
2158 : 0 : } while( nPos < pTxt->Len() );
2159 [ # # ][ # # ]: 0 : ClearRedlineTxt();
2160 : : }
2161 : :
2162 : :
2163 : 0 : SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFmtFlags& rFlags,
2164 : : SwNodeIndex* pSttNd, SwNodeIndex* pEndNd )
2165 : : : aFlags( rFlags ),
2166 [ # # ]: 0 : aDelPam( pEdShell->GetDoc()->GetNodes().GetEndOfExtras() ),
2167 [ # # ]: 0 : aNdIdx( pEdShell->GetDoc()->GetNodes().GetEndOfExtras(), +1 ),
2168 [ # # ]: 0 : aEndNdIdx( pEdShell->GetDoc()->GetNodes().GetEndOfContent() ),
2169 : : pEditShell( pEdShell ),
2170 : 0 : pDoc( pEdShell->GetDoc() ),
2171 : : pAktTxtNd( 0 ), pAktTxtFrm( 0 ),
2172 : : pCharClass( 0 ),
2173 [ # # # # : 0 : nRedlAutoFmtSeqId( 0 )
# # ]
2174 : : {
2175 : : OSL_ENSURE( (pSttNd && pEndNd) || (!pSttNd && !pEndNd),
2176 : : "Kein Bereich angegeben" );
2177 : :
2178 [ # # ][ # # ]: 0 : if( aFlags.bSetNumRule && !aFlags.bAFmtByInput )
2179 : 0 : aFlags.bSetNumRule = sal_False;
2180 : :
2181 [ # # ][ # # ]: 0 : sal_Bool bReplaceStyles = !aFlags.bAFmtByInput || aFlags.bReplaceStyles;
2182 : :
2183 : 0 : const SwTxtNode* pNxtNd = 0;
2184 : 0 : sal_Bool bNxtEmpty = sal_False;
2185 : 0 : sal_Bool bNxtAlpha = sal_False;
2186 : 0 : sal_uInt16 nNxtLevel = 0;
2187 : :
2188 : : // setze den Bereich zum Autoformatieren
2189 [ # # ]: 0 : if( pSttNd )
2190 : : {
2191 [ # # ]: 0 : aNdIdx = *pSttNd;
2192 [ # # ]: 0 : aNdIdx--; // fuer GoNextPara, ein Absatz davor
2193 [ # # ]: 0 : aEndNdIdx = *pEndNd;
2194 [ # # ]: 0 : aEndNdIdx++;
2195 : :
2196 : : // teste den vorhergehenden TextNode
2197 : 0 : pNxtNd = aNdIdx.GetNode().GetTxtNode();
2198 : : bEmptyLine = !pNxtNd ||
2199 [ # # ]: 0 : IsEmptyLine( *pNxtNd ) ||
2200 [ # # ][ # # ]: 0 : IsNoAlphaLine( *pNxtNd );
[ # # ][ # # ]
2201 : : }
2202 : : else
2203 : 0 : bEmptyLine = sal_True; // am Dokument Anfang
2204 : :
2205 : 0 : bEnde = sal_False;
2206 : :
2207 : : // setze die Werte fuer die Prozent-Anzeige
2208 : 0 : nEndNdIdx = aEndNdIdx.GetIndex();
2209 : :
2210 [ # # ]: 0 : if( !aFlags.bAFmtByInput )
2211 : 0 : ::StartProgress( STR_STATSTR_AUTOFORMAT, aNdIdx.GetIndex(),
2212 : 0 : nEndNdIdx = aEndNdIdx.GetIndex(),
2213 [ # # ]: 0 : pDoc->GetDocShell() );
2214 : :
2215 [ # # ]: 0 : RedlineMode_t eRedlMode = pDoc->GetRedlineMode(), eOldMode = eRedlMode;
2216 [ # # ]: 0 : if( aFlags.bWithRedlining )
2217 : : {
2218 : 0 : pDoc->SetAutoFmtRedline( sal_True );
2219 : 0 : eRedlMode = (RedlineMode_t)(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_INSERT);
2220 : : }
2221 : : else
2222 : 0 : eRedlMode = (RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_IGNORE);
2223 [ # # ]: 0 : pDoc->SetRedlineMode( eRedlMode );
2224 : :
2225 : : // save undo state (might be turned off)
2226 [ # # ][ # # ]: 0 : bool const bUndoState = pDoc->GetIDocumentUndoRedo().DoesUndo();
2227 : :
2228 : : // wenn mehrere Zeilen, dann erstmal nicht mit
2229 : : // dem nachfolgenden Absatz zusammenfassen.
2230 : 0 : bMoreLines = sal_False;
2231 : :
2232 : 0 : nLastCalcHeadLvl = nLastCalcEnumLvl = 0;
2233 : 0 : nLastHeadLvl = nLastEnumLvl = USHRT_MAX;
2234 : 0 : sal_uInt16 nLevel = 0;
2235 : 0 : sal_uInt16 nDigitLvl = 0;
2236 : :
2237 : : // defaulten
2238 : 0 : SwTxtFrmInfo aFInfo( 0 );
2239 : :
2240 : : // das ist unser Automat fuer die Auto-Formatierung
2241 : 0 : eStat = READ_NEXT_PARA;
2242 [ # # ]: 0 : while( !bEnde )
2243 : : {
2244 [ # # # # : 0 : switch( eStat )
# # # # #
# # # ]
2245 : : {
2246 : : case READ_NEXT_PARA:
2247 : : {
2248 [ # # ][ # # ]: 0 : GoNextPara();
2249 [ # # ]: 0 : eStat = bEnde ? IS_ENDE : TST_EMPTY_LINE;
2250 : : }
2251 : 0 : break;
2252 : :
2253 : : case TST_EMPTY_LINE:
2254 [ # # ][ # # ]: 0 : if( IsEmptyLine( *pAktTxtNd ) )
2255 : : {
2256 [ # # ][ # # ]: 0 : if( aFlags.bDelEmptyNode && !HasObjects( *pAktTxtNd ) )
[ # # ][ # # ]
2257 : : {
2258 : 0 : bEmptyLine = sal_True;
2259 [ # # ]: 0 : sal_uLong nOldCnt = pDoc->GetNodes().Count();
2260 [ # # ]: 0 : DelEmptyLine();
2261 : : // wurde wiklich ein Node geloescht ?
2262 [ # # ][ # # ]: 0 : if( nOldCnt != pDoc->GetNodes().Count() )
2263 [ # # ]: 0 : aNdIdx--; // nicht den naechsten Absatz ueberspringen
2264 : : }
2265 : 0 : eStat = READ_NEXT_PARA;
2266 : : }
2267 : : else
2268 : 0 : eStat = TST_ALPHA_LINE;
2269 : 0 : break;
2270 : :
2271 : : case TST_ALPHA_LINE:
2272 [ # # ][ # # ]: 0 : if( IsNoAlphaLine( *pAktTxtNd ))
2273 : : {
2274 : : // erkenne eine Tabellendefinition +---+---+
2275 [ # # ][ # # ]: 0 : if( aFlags.bAFmtByInput && aFlags.bCreateTable && DoTable() )
[ # # ][ # # ]
[ # # ]
2276 : : {
2277 : : //JP 30.09.96: das DoTable() verlaesst sich auf das
2278 : : // Pop und Move - Crsr nach dem AutoFormat!
2279 [ # # ]: 0 : pEdShell->Pop( sal_False );
2280 [ # # ][ # # ]: 0 : *pEdShell->GetCrsr() = aDelPam;
2281 [ # # ]: 0 : pEdShell->Push();
2282 : :
2283 : 0 : eStat = IS_ENDE;
2284 : 0 : break;
2285 : : }
2286 : :
2287 : : // dann teste mal auf 3 "---" oder "===". In dem Fall
2288 : : // soll der vorherige Absatz unterstrichen und dieser
2289 : : // geloescht werden!
2290 [ # # ][ # # ]: 0 : if( !DoUnderline() && bReplaceStyles )
[ # # ][ # # ]
2291 : : {
2292 [ # # ]: 0 : SetColl( RES_POOLCOLL_STANDARD, sal_True );
2293 : 0 : bEmptyLine = sal_True;
2294 : : }
2295 : 0 : eStat = READ_NEXT_PARA;
2296 : : }
2297 : : else
2298 : 0 : eStat = GET_ALL_INFO;
2299 : 0 : break;
2300 : :
2301 : : case GET_ALL_INFO:
2302 : : {
2303 [ # # ][ # # ]: 0 : if( pAktTxtNd->GetNumRule() )
2304 : : {
2305 : : // in Numerierung nichts machen, zum naechsten
2306 : 0 : bEmptyLine = sal_False;
2307 : 0 : eStat = READ_NEXT_PARA;
2308 : : // loesche alle Blanks am Anfang/Ende
2309 : : // und alle mitten drin
2310 : : //JP 29.04.98: erstmal nur alle "mitten drin".
2311 [ # # ]: 0 : DelMoreLinesBlanks( sal_False );
2312 : 0 : break;
2313 : : }
2314 : :
2315 : 0 : aFInfo.SetFrm( pAktTxtFrm );
2316 : :
2317 : : // erstmal: wurden schon mal entsprechende Vorlagen
2318 : : // vergeben, so behalte die bei, gehe zum
2319 : : // naechsten Node.
2320 : 0 : sal_uInt16 nPoolId = pAktTxtNd->GetTxtColl()->GetPoolFmtId();
2321 [ # # ][ # # ]: 0 : if( IsPoolUserFmt( nPoolId )
[ # # ][ # # ]
[ # # ][ # # ]
2322 : 0 : ? !aFlags.bChgUserColl
2323 : : : ( RES_POOLCOLL_STANDARD != nPoolId &&
2324 : 0 : ( !aFlags.bAFmtByInput ||
2325 : : (RES_POOLCOLL_TEXT_MOVE != nPoolId &&
2326 : : RES_POOLCOLL_TEXT != nPoolId )) ))
2327 : : {
2328 : 0 : eStat = HAS_FMTCOLL;
2329 : 0 : break;
2330 : : }
2331 : :
2332 : : // teste auf Harte oder aus Vorlagen gesetzte LRSpaces
2333 [ # # ][ # # ]: 0 : if( IsPoolUserFmt( nPoolId ) ||
[ # # ]
2334 : : RES_POOLCOLL_STANDARD == nPoolId )
2335 : : {
2336 : : short nSz;
2337 : : SvxLRSpaceItem* pLRSpace;
2338 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET == pAktTxtNd->GetSwAttrSet().
[ # # # # ]
[ # # ]
2339 : : GetItemState( RES_LR_SPACE, sal_True,
2340 [ # # ]: 0 : (const SfxPoolItem**)&pLRSpace ) &&
2341 : 0 : ( 0 != (nSz = pLRSpace->GetTxtFirstLineOfst()) ||
2342 : 0 : 0 != pLRSpace->GetTxtLeft() ) )
2343 : : {
2344 : : // Ausnahme: Numerierun/Aufzaehlung kann mit Einzug
2345 : : // existieren!!
2346 [ # # ][ # # ]: 0 : if( IsEnumericChar( *pAktTxtNd ))
2347 : : {
2348 [ # # ]: 0 : nLevel = CalcLevel( *pAktTxtNd, &nDigitLvl );
2349 [ # # ]: 0 : if( nLevel >= MAXLEVEL )
2350 : 0 : nLevel = MAXLEVEL-1;
2351 [ # # ]: 0 : BuildEnum( nLevel, nDigitLvl );
2352 : 0 : eStat = READ_NEXT_PARA;
2353 : : break;
2354 : : }
2355 : :
2356 : :
2357 : : // nie zusammenfassen, so belassen
2358 : : // (Opt. vielleicht als Ausnahmen nur Einzug)
2359 : 0 : bMoreLines = sal_True;
2360 : :
2361 [ # # ]: 0 : if( bReplaceStyles )
2362 : : {
2363 : : // dann setze doch eine unserer Vorlagen
2364 [ # # ]: 0 : if( 0 < nSz ) // positiver 1. Zeileneinzug
2365 [ # # ]: 0 : BuildIndent();
2366 [ # # ]: 0 : else if( 0 > nSz ) // negativer 1. Zeileneinzug
2367 [ # # ][ # # ]: 0 : BuildNegIndent( aFInfo.GetLineStart() );
2368 [ # # ]: 0 : else if( pLRSpace->GetTxtLeft() ) // ist ein Einzug
2369 [ # # ]: 0 : BuildTextIndent();
2370 : : }
2371 : 0 : eStat = READ_NEXT_PARA;
2372 : : break;
2373 : : }
2374 : : }
2375 : :
2376 [ # # ]: 0 : nLevel = CalcLevel( *pAktTxtNd, &nDigitLvl );
2377 [ # # ]: 0 : bMoreLines = !IsOneLine( *pAktTxtNd );
2378 [ # # ]: 0 : pNxtNd = GetNextNode();
2379 [ # # ]: 0 : if( pNxtNd )
2380 : : {
2381 [ # # ]: 0 : bNxtEmpty = IsEmptyLine( *pNxtNd );
2382 [ # # ]: 0 : bNxtAlpha = IsNoAlphaLine( *pNxtNd );
2383 [ # # ]: 0 : nNxtLevel = CalcLevel( *pNxtNd );
2384 : :
2385 [ # # ][ # # ]: 0 : if( !bEmptyLine && HasBreakAttr( *pAktTxtNd ) )
[ # # ][ # # ]
2386 : 0 : bEmptyLine = sal_True;
2387 [ # # ][ # # ]: 0 : if( !bNxtEmpty && HasBreakAttr( *pNxtNd ) )
[ # # ][ # # ]
2388 : 0 : bNxtEmpty = sal_True;
2389 : :
2390 : : }
2391 : : else
2392 : : {
2393 : 0 : bNxtEmpty = sal_False; // sal_True;
2394 : 0 : bNxtAlpha = sal_False;
2395 : 0 : nNxtLevel = 0;
2396 : : }
2397 [ # # ]: 0 : eStat = !bMoreLines ? IS_ONE_LINE : TST_ENUMERIC;
2398 : : }
2399 : 0 : break;
2400 : :
2401 : : case IS_ONE_LINE:
2402 : : {
2403 : 0 : eStat = TST_ENUMERIC;
2404 [ # # ]: 0 : if( !bReplaceStyles )
2405 : : break;
2406 : :
2407 [ # # ]: 0 : String sClrStr( pAktTxtNd->GetTxt() );
2408 : :
2409 [ # # ][ # # ]: 0 : if( !DelLeadingBlanks( sClrStr ).Len() )
2410 : : {
2411 : 0 : bEmptyLine = sal_True;
2412 : 0 : eStat = READ_NEXT_PARA;
2413 : : break; // naechsten Absatz lesen
2414 : : }
2415 : :
2416 : : // Teste auf Ueberschrift
2417 [ # # ][ # # ]: 0 : if( !bEmptyLine || !IsFirstCharCapital( *pAktTxtNd ) ||
[ # # ][ # # ]
[ # # ]
2418 [ # # ]: 0 : IsBlanksInString( *pAktTxtNd ) )
2419 : : break;
2420 : :
2421 : 0 : bEmptyLine = sal_False;
2422 [ # # ]: 0 : String sEndClrStr( sClrStr );
2423 [ # # ]: 0 : xub_StrLen nLen = DelTrailingBlanks( sEndClrStr ).Len();
2424 : :
2425 : : // nicht, dann teste auf Ueberschrift
2426 [ # # ]: 0 : if( ':' == sEndClrStr.GetChar( nLen - 1 ) )
2427 : : {
2428 : : {
2429 [ # # ]: 0 : BuildHeadLine( 2 );
2430 : 0 : eStat = READ_NEXT_PARA;
2431 : : break;
2432 : : }
2433 : : }
2434 [ # # # # ]: 0 : else if( 256 <= sEndClrStr.GetChar( nLen-1 ) ||
[ # # ]
2435 : 0 : !strchr( ",.;", sEndClrStr.GetChar( nLen-1 )) )
2436 : : {
2437 [ # # ][ # # ]: 0 : if( bNxtEmpty || bNxtAlpha
[ # # ][ # # ]
[ # # ]
2438 [ # # ]: 0 : || ( pNxtNd && IsEnumericChar( *pNxtNd ))
2439 : :
2440 : : )
2441 : : {
2442 : :
2443 : : // eine Ebene runter ?
2444 [ # # ]: 0 : if( nLevel >= MAXLEVEL )
2445 : 0 : nLevel = MAXLEVEL-1;
2446 : :
2447 [ # # ]: 0 : if( USHRT_MAX == nLastHeadLvl )
2448 : 0 : nLastHeadLvl = 0;
2449 [ # # ]: 0 : else if( nLastCalcHeadLvl < nLevel )
2450 : : {
2451 [ # # ]: 0 : if( nLastHeadLvl+1 < MAXLEVEL )
2452 : 0 : ++nLastHeadLvl;
2453 : : }
2454 : : // eine Ebene hoch ?
2455 [ # # ]: 0 : else if( nLastCalcHeadLvl > nLevel )
2456 : : {
2457 [ # # ]: 0 : if( nLastHeadLvl )
2458 : 0 : --nLastHeadLvl;
2459 : : }
2460 : 0 : nLastCalcHeadLvl = nLevel;
2461 : :
2462 [ # # ]: 0 : if( aFlags.bAFmtByInput )
2463 [ # # ]: 0 : BuildHeadLine( nLevel );
2464 : : else
2465 [ # # ]: 0 : BuildHeadLine( nLastHeadLvl );
2466 : 0 : eStat = READ_NEXT_PARA;
2467 : : break;
2468 : : }
2469 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
2470 : : }
2471 : 0 : break;
2472 : :
2473 : : case TST_ENUMERIC:
2474 : : {
2475 : 0 : bEmptyLine = sal_False;
2476 [ # # ][ # # ]: 0 : if( IsEnumericChar( *pAktTxtNd ))
2477 : : {
2478 [ # # ]: 0 : if( nLevel >= MAXLEVEL )
2479 : 0 : nLevel = MAXLEVEL-1;
2480 [ # # ]: 0 : BuildEnum( nLevel, nDigitLvl );
2481 : 0 : eStat = READ_NEXT_PARA;
2482 : : }
2483 [ # # ]: 0 : else if( bReplaceStyles )
2484 [ # # ]: 0 : eStat = nLevel ? TST_IDENT : TST_NEG_IDENT;
2485 : : else
2486 : 0 : eStat = READ_NEXT_PARA;
2487 : : }
2488 : 0 : break;
2489 : :
2490 : : case TST_IDENT:
2491 : : // Spaces am Anfang, dann teste doch mal auf Einzuege
2492 [ # # ][ # # ]: 0 : if( bMoreLines && nLevel )
2493 : : {
2494 [ # # ]: 0 : SwTwips nSz = aFInfo.GetFirstIndent();
2495 [ # # ]: 0 : if( 0 < nSz ) // positiver 1. Zeileneinzug
2496 [ # # ]: 0 : BuildIndent();
2497 [ # # ]: 0 : else if( 0 > nSz ) // negativer 1. Zeileneinzug
2498 [ # # ][ # # ]: 0 : BuildNegIndent( aFInfo.GetLineStart() );
2499 : : else // ist ein Einzug
2500 [ # # ]: 0 : BuildTextIndent();
2501 : 0 : eStat = READ_NEXT_PARA;
2502 : : }
2503 [ # # ][ # # ]: 0 : else if( nLevel && pNxtNd && !bEnde &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
2504 : : !bNxtEmpty && !bNxtAlpha && !nNxtLevel &&
2505 [ # # ]: 0 : !IsEnumericChar( *pNxtNd ) )
2506 : : {
2507 : : // ist ein Einzug
2508 [ # # ]: 0 : BuildIndent();
2509 : 0 : eStat = READ_NEXT_PARA;
2510 : : }
2511 : : else
2512 : 0 : eStat = TST_TXT_BODY;
2513 : 0 : break;
2514 : :
2515 : : case TST_NEG_IDENT:
2516 : : // keine Spaces am Anfang, dann teste doch mal auf neg. Einzuege
2517 : : {
2518 [ # # ][ # # ]: 0 : if( bMoreLines && !nLevel )
2519 : : {
2520 [ # # ]: 0 : SwTwips nSz = aFInfo.GetFirstIndent();
2521 [ # # ]: 0 : if( 0 < nSz ) // positiver 1. Zeileneinzug
2522 [ # # ]: 0 : BuildIndent();
2523 [ # # ]: 0 : else if( 0 > nSz ) // negativer 1. Zeileneinzug
2524 [ # # ][ # # ]: 0 : BuildNegIndent( aFInfo.GetLineStart() );
2525 : : else // ist ein kein Einzug
2526 [ # # ]: 0 : BuildText();
2527 : 0 : eStat = READ_NEXT_PARA;
2528 : : }
2529 [ # # ][ # # ]: 0 : else if( !nLevel && pNxtNd && !bEnde &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
2530 : : !bNxtEmpty && !bNxtAlpha && nNxtLevel &&
2531 [ # # ]: 0 : !IsEnumericChar( *pNxtNd ) )
2532 : : {
2533 : : // ist ein neg. Einzug
2534 [ # # ][ # # ]: 0 : BuildNegIndent( aFInfo.GetLineStart() );
2535 : 0 : eStat = READ_NEXT_PARA;
2536 : : }
2537 : : else
2538 : 0 : eStat = TST_TXT_BODY;
2539 : : }
2540 : 0 : break;
2541 : :
2542 : : case TST_TXT_BODY:
2543 : : {
2544 [ # # ]: 0 : if( bMoreLines )
2545 : : {
2546 [ # # ]: 0 : SwTwips nSz = aFInfo.GetFirstIndent();
2547 [ # # ]: 0 : if( 0 < nSz ) // positiver 1. Zeileneinzug
2548 [ # # ]: 0 : BuildIndent();
2549 [ # # ]: 0 : else if( 0 > nSz ) // negativer 1. Zeileneinzug
2550 [ # # ][ # # ]: 0 : BuildNegIndent( aFInfo.GetLineStart() );
2551 [ # # ]: 0 : else if( nLevel ) // ist ein Einzug
2552 [ # # ]: 0 : BuildTextIndent();
2553 : : else
2554 [ # # ]: 0 : BuildText();
2555 : : }
2556 [ # # ]: 0 : else if( nLevel )
2557 [ # # ]: 0 : BuildTextIndent();
2558 : : else
2559 [ # # ]: 0 : BuildText();
2560 : 0 : eStat = READ_NEXT_PARA;
2561 : : }
2562 : 0 : break;
2563 : :
2564 : : case HAS_FMTCOLL:
2565 : : {
2566 : : // erstmal: wurden schon mal entsprechende Vorlagen
2567 : : // vergeben, so behalte die bei, gehe zum
2568 : : // naechsten Node.
2569 : 0 : bEmptyLine = sal_False;
2570 : 0 : eStat = READ_NEXT_PARA;
2571 : : // loesche alle Blanks am Anfang/Ende
2572 : : // und alle mitten drin
2573 : : //JP 29.04.98: erstmal nur alle "mitten drin".
2574 [ # # ]: 0 : DelMoreLinesBlanks( sal_False );
2575 : :
2576 : : // behandel die harte Attributierung
2577 [ # # ][ # # ]: 0 : if( pAktTxtNd->HasSwAttrSet() )
2578 : : {
2579 : : short nSz;
2580 : : SvxLRSpaceItem* pLRSpace;
2581 [ # # ][ # # ]: 0 : if( bReplaceStyles &&
[ # # # # ]
[ # # ]
2582 [ # # ]: 0 : SFX_ITEM_SET == pAktTxtNd->GetSwAttrSet().
2583 : : GetItemState( RES_LR_SPACE, sal_False,
2584 [ # # ]: 0 : (const SfxPoolItem**)&pLRSpace ) &&
2585 : 0 : ( 0 != (nSz = pLRSpace->GetTxtFirstLineOfst()) ||
2586 : 0 : 0 != pLRSpace->GetTxtLeft() ) )
2587 : : {
2588 : : // dann setze doch eine unserer Vorlagen
2589 [ # # ]: 0 : if( 0 < nSz ) // positiver 1. Zeileneinzug
2590 [ # # ]: 0 : BuildIndent();
2591 [ # # ]: 0 : else if( 0 > nSz ) // negativer 1. Zeileneinzug
2592 : : {
2593 [ # # ][ # # ]: 0 : BuildNegIndent( aFInfo.GetLineStart() );
2594 : : }
2595 [ # # ]: 0 : else if( pLRSpace->GetTxtLeft() ) // ist ein Einzug
2596 [ # # ]: 0 : BuildTextIndent();
2597 : : else
2598 [ # # ]: 0 : BuildText();
2599 : : }
2600 : : }
2601 : : }
2602 : 0 : break;
2603 : :
2604 : : case IS_ENDE:
2605 : 0 : bEnde = sal_True;
2606 : 0 : break;
2607 : : }
2608 : : }
2609 : :
2610 [ # # ]: 0 : if( aFlags.bWithRedlining )
2611 : 0 : pDoc->SetAutoFmtRedline( sal_False );
2612 [ # # ]: 0 : pDoc->SetRedlineMode( eOldMode );
2613 : :
2614 : : // restore undo (in case it has been changed)
2615 [ # # ][ # # ]: 0 : pDoc->GetIDocumentUndoRedo().DoUndo(bUndoState);
2616 : :
2617 : : // Prozent-Anzeige wieder abschalten
2618 [ # # ]: 0 : if( !aFlags.bAFmtByInput )
2619 [ # # ]: 0 : ::EndProgress( pDoc->GetDocShell() );
2620 : 0 : }
2621 : :
2622 : 0 : void SwEditShell::AutoFormat( const SvxSwAutoFmtFlags* pAFlags )
2623 : : {
2624 : 0 : SwWait* pWait = 0;
2625 : :
2626 [ # # ]: 0 : SET_CURR_SHELL( this );
2627 [ # # ]: 0 : StartAllAction();
2628 [ # # ]: 0 : StartUndo( UNDO_AUTOFORMAT );
2629 : :
2630 [ # # ]: 0 : SvxSwAutoFmtFlags aAFFlags; // erst mal default - Werte
2631 [ # # ]: 0 : if( pAFlags ) // oder doch angegeben ??
2632 : : {
2633 [ # # ]: 0 : aAFFlags = *pAFlags;
2634 [ # # ]: 0 : if( !aAFFlags.bAFmtByInput )
2635 [ # # ][ # # ]: 0 : pWait = new SwWait( *GetDoc()->GetDocShell(), sal_True );
2636 : : }
2637 : :
2638 [ # # ]: 0 : SwPaM* pCrsr = GetCrsr();
2639 : : // es gibt mehr als einen oder ist eine Selektion offen
2640 [ # # ][ # # ]: 0 : if( pCrsr->GetNext() != pCrsr || pCrsr->HasMark() )
[ # # ]
2641 : : {
2642 [ # # ][ # # ]: 0 : FOREACHPAM_START(this)
2643 [ # # ]: 0 : if( PCURCRSR->HasMark() )
2644 : : {
2645 [ # # ]: 0 : SwAutoFormat aFmt( this, aAFFlags, &PCURCRSR->Start()->nNode,
2646 [ # # ][ # # ]: 0 : &PCURCRSR->End()->nNode );
[ # # ]
2647 : : }
2648 : 0 : FOREACHPAM_END()
2649 : : }
2650 : : else
2651 : : {
2652 [ # # ][ # # ]: 0 : SwAutoFormat aFmt( this, aAFFlags );
2653 : : }
2654 : :
2655 [ # # ]: 0 : EndUndo( UNDO_AUTOFORMAT );
2656 [ # # ]: 0 : EndAllAction();
2657 : :
2658 [ # # ][ # # ]: 0 : delete pWait;
[ # # ][ # # ]
2659 : 0 : }
2660 : :
2661 : :
2662 : 0 : void SwEditShell::AutoFmtBySplitNode()
2663 : : {
2664 [ # # ]: 0 : SET_CURR_SHELL( this );
2665 [ # # ]: 0 : SwPaM* pCrsr = GetCrsr();
2666 [ # # ][ # # ]: 0 : if( pCrsr->GetNext() == pCrsr && pCrsr->Move( fnMoveBackward, fnGoNode ) )
[ # # ][ # # ]
2667 : : {
2668 [ # # ]: 0 : StartAllAction();
2669 [ # # ]: 0 : StartUndo( UNDO_AUTOFORMAT );
2670 : :
2671 : 0 : sal_Bool bRange = sal_False;
2672 [ # # ]: 0 : pCrsr->SetMark();
2673 : 0 : SwIndex* pCntnt = &pCrsr->GetMark()->nContent;
2674 [ # # ]: 0 : if( pCntnt->GetIndex() )
2675 : : {
2676 [ # # ]: 0 : *pCntnt = 0;
2677 : 0 : bRange = sal_True;
2678 : : }
2679 : : else
2680 : : {
2681 : : // dann einen Node zurueckspringen
2682 [ # # ]: 0 : SwNodeIndex aNdIdx( pCrsr->GetMark()->nNode, -1 );
2683 : 0 : SwTxtNode* pTxtNd = aNdIdx.GetNode().GetTxtNode();
2684 [ # # ][ # # ]: 0 : if( pTxtNd && pTxtNd->GetTxt().Len() )
[ # # ]
2685 : : {
2686 [ # # ][ # # ]: 0 : pCntnt->Assign( pTxtNd, 0 );
2687 [ # # ]: 0 : pCrsr->GetMark()->nNode = aNdIdx;
2688 : 0 : bRange = sal_True;
2689 [ # # ]: 0 : }
2690 : : }
2691 : :
2692 [ # # ]: 0 : if( bRange )
2693 : : {
2694 [ # # ]: 0 : Push(); // Cursor sichern
2695 : :
2696 [ # # ][ # # ]: 0 : SvxSwAutoFmtFlags aAFFlags = *GetAutoFmtFlags(); // erst mal default - Werte
2697 : :
2698 : 0 : SwAutoFormat aFmt( this, aAFFlags, &pCrsr->GetMark()->nNode,
2699 [ # # ]: 0 : &pCrsr->GetPoint()->nNode );
2700 : :
2701 : : //JP 30.09.96: das DoTable() verlaesst sich auf das PopCrsr
2702 : : // und MoveCrsr!
2703 [ # # ]: 0 : Pop( sal_False );
2704 [ # # ][ # # ]: 0 : pCrsr = GetCrsr();
[ # # ]
2705 : : }
2706 [ # # ]: 0 : pCrsr->DeleteMark();
2707 [ # # ]: 0 : pCrsr->Move( fnMoveForward, fnGoNode );
2708 : :
2709 [ # # ]: 0 : EndUndo( UNDO_AUTOFORMAT );
2710 [ # # ]: 0 : EndAllAction();
2711 [ # # ]: 0 : }
2712 : 0 : }
2713 : :
2714 : 73 : SvxSwAutoFmtFlags* SwEditShell::GetAutoFmtFlags()
2715 : : {
2716 [ + - ]: 73 : if (!pAutoFmtFlags)
2717 [ + - ]: 73 : pAutoFmtFlags = new SvxSwAutoFmtFlags;
2718 : :
2719 : 73 : return pAutoFmtFlags;
2720 : : }
2721 : :
2722 : 73 : void SwEditShell::SetAutoFmtFlags(SvxSwAutoFmtFlags * pFlags)
2723 : : {
2724 : 73 : SvxSwAutoFmtFlags* pEditFlags = GetAutoFmtFlags();
2725 : :
2726 : 73 : pEditFlags->bSetNumRule = pFlags->bSetNumRule;
2727 : 73 : pEditFlags->bChgEnumNum = pFlags->bChgEnumNum;
2728 : 73 : pEditFlags->bSetBorder = pFlags->bSetBorder;
2729 : 73 : pEditFlags->bCreateTable = pFlags->bCreateTable;
2730 : 73 : pEditFlags->bReplaceStyles = pFlags->bReplaceStyles;
2731 : : pEditFlags->bAFmtByInpDelSpacesAtSttEnd =
2732 : 73 : pFlags->bAFmtByInpDelSpacesAtSttEnd;
2733 : : pEditFlags->bAFmtByInpDelSpacesBetweenLines =
2734 : 73 : pFlags->bAFmtByInpDelSpacesBetweenLines;
2735 : :
2736 : : //JP 15.12.98: BulletZeichen und Font in die "normalen" kopieren,
2737 : : // weil beim Autoformat nur mit diesen gearbeitet wird!
2738 : 73 : pEditFlags->cBullet = pFlags->cByInputBullet;
2739 : 73 : pEditFlags->aBulletFont = pFlags->aByInputBulletFont;
2740 : 73 : pEditFlags->cByInputBullet = pFlags->cByInputBullet;
2741 : 73 : pEditFlags->aByInputBulletFont = pFlags->aByInputBulletFont;
2742 : 73 : }
2743 : :
2744 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|