Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <com/sun/star/style/NumberingType.hpp>
21 : #include <hintids.hxx>
22 : #include <svtools/htmltokn.h>
23 : #include <svtools/htmlkywd.hxx>
24 : #include <svtools/htmlout.hxx>
25 : #include <svl/urihelper.hxx>
26 : #include <editeng/brushitem.hxx>
27 : #include <editeng/lrspitem.hxx>
28 : #include <vcl/svapp.hxx>
29 : #include <vcl/wrkwin.hxx>
30 : #include <numrule.hxx>
31 : #include <doc.hxx>
32 : #include <docary.hxx>
33 : #include <poolfmt.hxx>
34 : #include <ndtxt.hxx>
35 : #include <paratr.hxx>
36 :
37 : #include "htmlnum.hxx"
38 : #include "swcss1.hxx"
39 : #include "swhtml.hxx"
40 :
41 : #include <SwNodeNum.hxx>
42 :
43 : using namespace css;
44 :
45 : // <UL TYPE=...>
46 : static HTMLOptionEnum aHTMLULTypeTable[] =
47 : {
48 : { OOO_STRING_SVTOOLS_HTML_ULTYPE_disc, HTML_BULLETCHAR_DISC },
49 : { OOO_STRING_SVTOOLS_HTML_ULTYPE_circle, HTML_BULLETCHAR_CIRCLE },
50 : { OOO_STRING_SVTOOLS_HTML_ULTYPE_square, HTML_BULLETCHAR_SQUARE },
51 : { 0, 0 }
52 : };
53 :
54 :
55 0 : void SwHTMLParser::NewNumBulList( int nToken )
56 : {
57 0 : SwHTMLNumRuleInfo& rInfo = GetNumInfo();
58 :
59 : // Erstmal einen neuen Absatz aufmachen
60 0 : bool bSpace = (rInfo.GetDepth() + nDefListDeep) == 0;
61 0 : if( pPam->GetPoint()->nContent.GetIndex() )
62 0 : AppendTextNode( bSpace ? AM_SPACE : AM_NOSPACE, false );
63 0 : else if( bSpace )
64 0 : AddParSpace();
65 :
66 : // Die Numerierung-Ebene erhoehen
67 0 : rInfo.IncDepth();
68 0 : sal_uInt8 nLevel = (sal_uInt8)( (rInfo.GetDepth() <= MAXLEVEL ? rInfo.GetDepth()
69 0 : : MAXLEVEL) - 1 );
70 :
71 : // ggf. ein Regelwerk anlegen
72 0 : if( !rInfo.GetNumRule() )
73 : {
74 0 : sal_uInt16 nPos = pDoc->MakeNumRule( pDoc->GetUniqueNumRuleName() );
75 0 : rInfo.SetNumRule( pDoc->GetNumRuleTable()[nPos] );
76 : }
77 :
78 : // das Format anpassen, falls es fuer den Level noch nicht
79 : // geschehen ist!
80 0 : bool bNewNumFormat = rInfo.GetNumRule()->GetNumFormat( nLevel ) == 0;
81 0 : bool bChangeNumFormat = false;
82 :
83 : // das default Numerierungsformat erstellen
84 0 : SwNumFormat aNumFormat( rInfo.GetNumRule()->Get(nLevel) );
85 0 : rInfo.SetNodeStartValue( nLevel );
86 0 : if( bNewNumFormat )
87 : {
88 0 : sal_uInt16 nChrFormatPoolId = 0;
89 0 : if( HTML_ORDERLIST_ON == nToken )
90 : {
91 0 : aNumFormat.SetNumberingType(SVX_NUM_ARABIC);
92 0 : nChrFormatPoolId = RES_POOLCHR_NUM_LEVEL;
93 : }
94 : else
95 : {
96 : // Wir setzen hier eine Zeichenvorlage, weil die UI das auch
97 : // so macht. Dadurch wurd immer auch eine 9pt-Schrift
98 : // eingestellt, was in Netscape nicht der Fall ist. Bisher hat
99 : // das noch niemanden gestoert.
100 : // #i63395# - Only apply user defined default bullet font
101 0 : if ( numfunc::IsDefBulletFontUserDefined() )
102 : {
103 0 : aNumFormat.SetBulletFont( &numfunc::GetDefBulletFont() );
104 : }
105 0 : aNumFormat.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
106 0 : aNumFormat.SetBulletChar( cBulletChar ); // das Bulletzeichen !!
107 0 : nChrFormatPoolId = RES_POOLCHR_BUL_LEVEL;
108 : }
109 :
110 0 : sal_uInt16 nAbsLSpace = HTML_NUMBUL_MARGINLEFT;
111 :
112 0 : short nFirstLineIndent = HTML_NUMBUL_INDENT;
113 0 : if( nLevel > 0 )
114 : {
115 0 : const SwNumFormat& rPrevNumFormat = rInfo.GetNumRule()->Get( nLevel-1 );
116 0 : nAbsLSpace = nAbsLSpace + rPrevNumFormat.GetAbsLSpace();
117 0 : nFirstLineIndent = rPrevNumFormat.GetFirstLineOffset();
118 : }
119 0 : aNumFormat.SetAbsLSpace( nAbsLSpace );
120 0 : aNumFormat.SetFirstLineOffset( nFirstLineIndent );
121 0 : aNumFormat.SetCharFormat( pCSS1Parser->GetCharFormatFromPool(nChrFormatPoolId) );
122 :
123 0 : bChangeNumFormat = true;
124 : }
125 0 : else if( 1 != aNumFormat.GetStart() )
126 : {
127 : // Wenn die Ebene schon mal benutzt wurde, muss der Start-Wert
128 : // ggf. hart am Absatz gesetzt werden.
129 0 : rInfo.SetNodeStartValue( nLevel, 1 );
130 : }
131 :
132 : // und es ggf. durch die Optionen veraendern
133 0 : OUString aId, aStyle, aClass, aLang, aDir;
134 0 : OUString aBulletSrc;
135 0 : sal_Int16 eVertOri = text::VertOrientation::NONE;
136 0 : sal_uInt16 nWidth=USHRT_MAX, nHeight=USHRT_MAX;
137 0 : const HTMLOptions& rHTMLOptions = GetOptions();
138 0 : for (size_t i = rHTMLOptions.size(); i; )
139 : {
140 0 : const HTMLOption& rOption = rHTMLOptions[--i];
141 0 : switch( rOption.GetToken() )
142 : {
143 : case HTML_O_ID:
144 0 : aId = rOption.GetString();
145 0 : break;
146 : case HTML_O_TYPE:
147 0 : if( bNewNumFormat && !rOption.GetString().isEmpty() )
148 : {
149 0 : switch( nToken )
150 : {
151 : case HTML_ORDERLIST_ON:
152 0 : bChangeNumFormat = true;
153 0 : switch( rOption.GetString()[0] )
154 : {
155 0 : case 'A': aNumFormat.SetNumberingType(SVX_NUM_CHARS_UPPER_LETTER); break;
156 0 : case 'a': aNumFormat.SetNumberingType(SVX_NUM_CHARS_LOWER_LETTER); break;
157 0 : case 'I': aNumFormat.SetNumberingType(SVX_NUM_ROMAN_UPPER); break;
158 0 : case 'i': aNumFormat.SetNumberingType(SVX_NUM_ROMAN_LOWER); break;
159 0 : default: bChangeNumFormat = false;
160 : }
161 0 : break;
162 :
163 : case HTML_UNORDERLIST_ON:
164 : aNumFormat.SetBulletChar( (sal_Unicode)rOption.GetEnum(
165 0 : aHTMLULTypeTable,aNumFormat.GetBulletChar() ) );
166 0 : bChangeNumFormat = true;
167 0 : break;
168 : }
169 : }
170 0 : break;
171 : case HTML_O_START:
172 : {
173 0 : sal_uInt16 nStart = (sal_uInt16)rOption.GetNumber();
174 0 : if( bNewNumFormat )
175 : {
176 0 : aNumFormat.SetStart( nStart );
177 0 : bChangeNumFormat = true;
178 : }
179 : else
180 : {
181 0 : rInfo.SetNodeStartValue( nLevel, nStart );
182 : }
183 : }
184 0 : break;
185 : case HTML_O_STYLE:
186 0 : aStyle = rOption.GetString();
187 0 : break;
188 : case HTML_O_CLASS:
189 0 : aClass = rOption.GetString();
190 0 : break;
191 : case HTML_O_LANG:
192 0 : aLang = rOption.GetString();
193 0 : break;
194 : case HTML_O_DIR:
195 0 : aDir = rOption.GetString();
196 0 : break;
197 : case HTML_O_SRC:
198 0 : if( bNewNumFormat )
199 : {
200 0 : aBulletSrc = rOption.GetString();
201 0 : if( !InternalImgToPrivateURL(aBulletSrc) )
202 0 : aBulletSrc = URIHelper::SmartRel2Abs( INetURLObject( sBaseURL ), aBulletSrc, Link<OUString *, bool>(), false );
203 : }
204 0 : break;
205 : case HTML_O_WIDTH:
206 0 : nWidth = (sal_uInt16)rOption.GetNumber();
207 0 : break;
208 : case HTML_O_HEIGHT:
209 0 : nHeight = (sal_uInt16)rOption.GetNumber();
210 0 : break;
211 : case HTML_O_ALIGN:
212 : eVertOri =
213 : (sal_Int16)rOption.GetEnum( aHTMLImgVAlignTable,
214 0 : static_cast< sal_uInt16 >(eVertOri) );
215 0 : break;
216 : }
217 : }
218 :
219 0 : if( !aBulletSrc.isEmpty() )
220 : {
221 : // Eine Bullet-Liste mit Grafiken
222 0 : aNumFormat.SetNumberingType(SVX_NUM_BITMAP);
223 :
224 : // Die Grafik als Brush anlegen
225 0 : SvxBrushItem aBrushItem( RES_BACKGROUND );
226 0 : aBrushItem.SetGraphicLink( aBulletSrc );
227 0 : aBrushItem.SetGraphicPos( GPOS_AREA );
228 :
229 : // Die Groesse nur beachten, wenn Breite und Hoehe vorhanden sind
230 0 : Size aTwipSz( nWidth, nHeight), *pTwipSz=0;
231 0 : if( nWidth!=USHRT_MAX && nHeight!=USHRT_MAX )
232 : {
233 : aTwipSz =
234 : Application::GetDefaultDevice()->PixelToLogic( aTwipSz,
235 0 : MapMode(MAP_TWIP) );
236 0 : pTwipSz = &aTwipSz;
237 : }
238 :
239 : // Die Ausrichtung auch nur beachten, wenn eine Ausrichtung
240 : // angegeben wurde
241 : aNumFormat.SetGraphicBrush( &aBrushItem, pTwipSz,
242 0 : text::VertOrientation::NONE!=eVertOri ? &eVertOri : 0);
243 :
244 : // Und noch die Grafik merken, um sie in den Absaetzen nicht
245 : // einzufuegen
246 0 : aBulletGrfs[nLevel] = aBulletSrc;
247 0 : bChangeNumFormat = true;
248 : }
249 : else
250 0 : aBulletGrfs[nLevel].clear();
251 :
252 : // den aktuellen Absatz erst einmal nicht numerieren
253 : {
254 0 : sal_uInt8 nLvl = nLevel;
255 0 : SetNodeNum( nLvl, false );
256 : }
257 :
258 : // einen neuen Kontext anlegen
259 0 : _HTMLAttrContext *pCntxt = new _HTMLAttrContext( static_cast< sal_uInt16 >(nToken) );
260 :
261 : // Styles parsen
262 0 : if( HasStyleOptions( aStyle, aId, aClass, &aLang, &aDir ) )
263 : {
264 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
265 0 : SvxCSS1PropertyInfo aPropInfo;
266 :
267 0 : if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo, &aLang, &aDir ) )
268 : {
269 0 : if( bNewNumFormat )
270 : {
271 0 : if( aPropInfo.bLeftMargin )
272 : {
273 : // Der Der Default-Einzug wurde schon eingefuegt.
274 : sal_uInt16 nAbsLSpace =
275 0 : aNumFormat.GetAbsLSpace() - HTML_NUMBUL_MARGINLEFT;
276 0 : if( aPropInfo.nLeftMargin < 0 &&
277 0 : nAbsLSpace < -aPropInfo.nLeftMargin )
278 0 : nAbsLSpace = 0U;
279 0 : else if( aPropInfo.nLeftMargin > USHRT_MAX ||
280 0 : (long)nAbsLSpace +
281 : aPropInfo.nLeftMargin > USHRT_MAX )
282 0 : nAbsLSpace = USHRT_MAX;
283 : else
284 0 : nAbsLSpace = nAbsLSpace + (sal_uInt16)aPropInfo.nLeftMargin;
285 :
286 0 : aNumFormat.SetAbsLSpace( nAbsLSpace );
287 0 : bChangeNumFormat = true;
288 : }
289 0 : if( aPropInfo.bTextIndent )
290 : {
291 : short nTextIndent =
292 0 : static_cast<const SvxLRSpaceItem &>(aItemSet.Get( RES_LR_SPACE ))
293 0 : .GetTextFirstLineOfst();
294 0 : aNumFormat.SetFirstLineOffset( nTextIndent );
295 0 : bChangeNumFormat = true;
296 : }
297 : }
298 0 : aPropInfo.bLeftMargin = aPropInfo.bTextIndent = false;
299 0 : if( !aPropInfo.bRightMargin )
300 0 : aItemSet.ClearItem( RES_LR_SPACE );
301 :
302 : // #i89812# - Perform change to list style before calling <DoPositioning(..)>,
303 : // because <DoPositioning(..)> may open a new context and thus may
304 : // clear the <SwHTMLNumRuleInfo> instance hold by local variable <rInfo>.
305 0 : if( bChangeNumFormat )
306 : {
307 0 : rInfo.GetNumRule()->Set( nLevel, aNumFormat );
308 0 : pDoc->ChgNumRuleFormats( *rInfo.GetNumRule() );
309 0 : bChangeNumFormat = false;
310 : }
311 :
312 0 : DoPositioning( aItemSet, aPropInfo, pCntxt );
313 :
314 0 : InsertAttrs( aItemSet, aPropInfo, pCntxt );
315 0 : }
316 : }
317 :
318 0 : if( bChangeNumFormat )
319 : {
320 0 : rInfo.GetNumRule()->Set( nLevel, aNumFormat );
321 0 : pDoc->ChgNumRuleFormats( *rInfo.GetNumRule() );
322 : }
323 :
324 0 : PushContext( pCntxt );
325 :
326 : // die Attribute der neuen Vorlage setzen
327 0 : SetTextCollAttrs( pCntxt );
328 0 : }
329 :
330 0 : void SwHTMLParser::EndNumBulList( int nToken )
331 : {
332 0 : SwHTMLNumRuleInfo& rInfo = GetNumInfo();
333 :
334 : // Ein neuer Absatz muss aufgemacht werden, wenn
335 : // - der aktuelle nicht leer ist, also Text oder absatzgebundene Objekte
336 : // enthaelt.
337 : // - der aktuelle Absatz numeriert ist.
338 0 : bool bAppend = pPam->GetPoint()->nContent.GetIndex() > 0;
339 0 : if( !bAppend )
340 : {
341 0 : SwTextNode* pTextNode = pPam->GetNode().GetTextNode();
342 :
343 0 : bAppend = (pTextNode && ! pTextNode->IsOutline() && pTextNode->IsCountedInList()) ||
344 :
345 0 : HasCurrentParaFlys();
346 : }
347 :
348 0 : bool bSpace = (rInfo.GetDepth() + nDefListDeep) == 1;
349 0 : if( bAppend )
350 0 : AppendTextNode( bSpace ? AM_SPACE : AM_NOSPACE, false );
351 0 : else if( bSpace )
352 0 : AddParSpace();
353 :
354 : // den aktuellen Kontext vom Stack holen
355 0 : _HTMLAttrContext *pCntxt = nToken!=0 ? PopContext( static_cast< sal_uInt16 >(nToken & ~1) ) : 0;
356 :
357 : // Keine Liste aufgrund eines Tokens beenden, wenn der Kontext
358 : // nie angelgt wurde oder nicht beendet werden darf.
359 0 : if( rInfo.GetDepth()>0 && (!nToken || pCntxt) )
360 : {
361 0 : rInfo.DecDepth();
362 0 : if( !rInfo.GetDepth() ) // wars der letze Level ?
363 : {
364 : // Die noch nicht angepassten Formate werden jetzt noch
365 : // angepasst, damit es sich besser Editieren laesst.
366 0 : const SwNumFormat *pRefNumFormat = 0;
367 0 : bool bChanged = false;
368 0 : for( sal_uInt16 i=0; i<MAXLEVEL; i++ )
369 : {
370 0 : const SwNumFormat *pNumFormat = rInfo.GetNumRule()->GetNumFormat(i);
371 0 : if( pNumFormat )
372 : {
373 0 : pRefNumFormat = pNumFormat;
374 : }
375 0 : else if( pRefNumFormat )
376 : {
377 0 : SwNumFormat aNumFormat( rInfo.GetNumRule()->Get(i) );
378 0 : aNumFormat.SetNumberingType(pRefNumFormat->GetNumberingType() != SVX_NUM_BITMAP
379 0 : ? pRefNumFormat->GetNumberingType() : style::NumberingType::CHAR_SPECIAL);
380 0 : if( SVX_NUM_CHAR_SPECIAL == aNumFormat.GetNumberingType() )
381 : {
382 : // #i63395# - Only apply user defined default bullet font
383 0 : if ( numfunc::IsDefBulletFontUserDefined() )
384 : {
385 0 : aNumFormat.SetBulletFont( &numfunc::GetDefBulletFont() );
386 : }
387 0 : aNumFormat.SetBulletChar( cBulletChar );
388 : }
389 0 : aNumFormat.SetAbsLSpace( (i+1) * HTML_NUMBUL_MARGINLEFT );
390 0 : aNumFormat.SetFirstLineOffset( HTML_NUMBUL_INDENT );
391 0 : aNumFormat.SetCharFormat( pRefNumFormat->GetCharFormat() );
392 0 : rInfo.GetNumRule()->Set( i, aNumFormat );
393 0 : bChanged = true;
394 : }
395 : }
396 0 : if( bChanged )
397 0 : pDoc->ChgNumRuleFormats( *rInfo.GetNumRule() );
398 :
399 : // Beim letzen Append wurde das NumRule-Item und das
400 : // NodeNum-Objekt mit kopiert. Beides muessen wir noch
401 : // loeschen. Das ResetAttr loescht das NodeNum-Objekt mit!
402 0 : pPam->GetNode().GetTextNode()->ResetAttr( RES_PARATR_NUMRULE );
403 :
404 0 : rInfo.Clear();
405 : }
406 : else
407 : {
408 : // the next paragraph not numbered first
409 0 : SetNodeNum( rInfo.GetLevel(), false );
410 : }
411 : }
412 :
413 : // und noch Attribute beenden
414 0 : bool bSetAttrs = false;
415 0 : if( pCntxt )
416 : {
417 0 : EndContext( pCntxt );
418 0 : delete pCntxt;
419 0 : bSetAttrs = true;
420 : }
421 :
422 0 : if( nToken )
423 0 : SetTextCollAttrs();
424 :
425 0 : if( bSetAttrs )
426 0 : SetAttr(); // Absatz-Atts wegen JavaScript moeglichst schnell setzen
427 :
428 0 : }
429 :
430 0 : void SwHTMLParser::NewNumBulListItem( int nToken )
431 : {
432 0 : sal_uInt8 nLevel = GetNumInfo().GetLevel();
433 0 : OUString aId, aStyle, aClass, aLang, aDir;
434 : sal_uInt16 nStart = HTML_LISTHEADER_ON != nToken
435 0 : ? GetNumInfo().GetNodeStartValue( nLevel )
436 0 : : USHRT_MAX;
437 0 : if( USHRT_MAX != nStart )
438 0 : GetNumInfo().SetNodeStartValue( nLevel );
439 :
440 0 : const HTMLOptions& rHTMLOptions = GetOptions();
441 0 : for (size_t i = rHTMLOptions.size(); i; )
442 : {
443 0 : const HTMLOption& rOption = rHTMLOptions[--i];
444 0 : switch( rOption.GetToken() )
445 : {
446 : case HTML_O_VALUE:
447 0 : nStart = (sal_uInt16)rOption.GetNumber();
448 0 : break;
449 : case HTML_O_ID:
450 0 : aId = rOption.GetString();
451 0 : break;
452 : case HTML_O_STYLE:
453 0 : aStyle = rOption.GetString();
454 0 : break;
455 : case HTML_O_CLASS:
456 0 : aClass = rOption.GetString();
457 0 : break;
458 : case HTML_O_LANG:
459 0 : aLang = rOption.GetString();
460 0 : break;
461 : case HTML_O_DIR:
462 0 : aDir = rOption.GetString();
463 0 : break;
464 : }
465 : }
466 :
467 : // einen neuen Absatz aufmachen
468 0 : if( pPam->GetPoint()->nContent.GetIndex() )
469 0 : AppendTextNode( AM_NOSPACE, false );
470 0 : bNoParSpace = false; // In <LI> wird kein Abstand eingefuegt!
471 :
472 0 : const bool bCountedInList = nToken != HTML_LISTHEADER_ON;
473 :
474 0 : _HTMLAttrContext *pCntxt = new _HTMLAttrContext( static_cast< sal_uInt16 >(nToken) );
475 :
476 0 : OUString aNumRuleName;
477 0 : if( GetNumInfo().GetNumRule() )
478 : {
479 0 : aNumRuleName = GetNumInfo().GetNumRule()->GetName();
480 : }
481 : else
482 : {
483 0 : aNumRuleName = pDoc->GetUniqueNumRuleName();
484 : SwNumRule aNumRule( aNumRuleName,
485 0 : SvxNumberFormat::LABEL_WIDTH_AND_POSITION );
486 0 : SwNumFormat aNumFormat( aNumRule.Get( 0 ) );
487 : // #i63395# - Only apply user defined default bullet font
488 0 : if ( numfunc::IsDefBulletFontUserDefined() )
489 : {
490 0 : aNumFormat.SetBulletFont( &numfunc::GetDefBulletFont() );
491 : }
492 0 : aNumFormat.SetNumberingType(SVX_NUM_CHAR_SPECIAL);
493 0 : aNumFormat.SetBulletChar( cBulletChar ); // das Bulletzeichen !!
494 0 : aNumFormat.SetCharFormat( pCSS1Parser->GetCharFormatFromPool(RES_POOLCHR_BUL_LEVEL) );
495 0 : aNumFormat.SetFirstLineOffset( HTML_NUMBUL_INDENT );
496 0 : aNumRule.Set( 0, aNumFormat );
497 :
498 0 : pDoc->MakeNumRule( aNumRuleName, &aNumRule );
499 :
500 : OSL_ENSURE( !nOpenParaToken,
501 : "Jetzt geht ein offenes Absatz-Element verloren" );
502 : // Wir tun so, als ob wir in einem Absatz sind. Dann wird
503 : // beim naechsten Absatz wenigstens die Numerierung
504 : // weggeschmissen, die nach dem naechsten AppendTextNode uebernommen
505 : // wird.
506 0 : nOpenParaToken = static_cast< sal_uInt16 >(nToken);
507 : }
508 :
509 0 : SwTextNode* pTextNode = pPam->GetNode().GetTextNode();
510 0 : static_cast<SwContentNode *>(pTextNode)->SetAttr( SwNumRuleItem(aNumRuleName) );
511 0 : pTextNode->SetAttrListLevel(nLevel);
512 : // #i57656# - <IsCounted()> state of text node has to be adjusted accordingly.
513 0 : if ( nLevel < MAXLEVEL )
514 : {
515 0 : pTextNode->SetCountedInList( bCountedInList );
516 : }
517 : // #i57919#
518 : // correction of refactoring done by cws swnumtree
519 : // - <nStart> contains the start value, if the numbering has to be restarted
520 : // at this text node. Value <USHRT_MAX> indicates, that numbering isn't
521 : // restarted at this text node
522 0 : if ( nStart != USHRT_MAX )
523 : {
524 0 : pTextNode->SetListRestart( true );
525 0 : pTextNode->SetAttrListRestartValue( nStart );
526 : }
527 :
528 0 : if( GetNumInfo().GetNumRule() )
529 0 : GetNumInfo().GetNumRule()->SetInvalidRule( true );
530 :
531 : // Styles parsen
532 0 : if( HasStyleOptions( aStyle, aId, aClass, &aLang, &aDir ) )
533 : {
534 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
535 0 : SvxCSS1PropertyInfo aPropInfo;
536 :
537 0 : if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo, &aLang, &aDir ) )
538 : {
539 0 : DoPositioning( aItemSet, aPropInfo, pCntxt );
540 0 : InsertAttrs( aItemSet, aPropInfo, pCntxt );
541 0 : }
542 : }
543 :
544 0 : PushContext( pCntxt );
545 :
546 : // die neue Vorlage setzen
547 0 : SetTextCollAttrs( pCntxt );
548 :
549 : // Laufbalkenanzeige aktualisieren
550 0 : ShowStatline();
551 0 : }
552 :
553 0 : void SwHTMLParser::EndNumBulListItem( int nToken, bool bSetColl,
554 : bool /*bLastPara*/ )
555 : {
556 : // einen neuen Absatz aufmachen
557 0 : if( !nToken && pPam->GetPoint()->nContent.GetIndex() )
558 0 : AppendTextNode( AM_NOSPACE );
559 :
560 : // Kontext zu dem Token suchen und vom Stack holen
561 0 : _HTMLAttrContext *pCntxt = 0;
562 0 : auto nPos = aContexts.size();
563 0 : nToken &= ~1;
564 0 : while( !pCntxt && nPos>nContextStMin )
565 : {
566 0 : sal_uInt16 nCntxtToken = aContexts[--nPos]->GetToken();
567 0 : switch( nCntxtToken )
568 : {
569 : case HTML_LI_ON:
570 : case HTML_LISTHEADER_ON:
571 0 : if( !nToken || nToken == nCntxtToken )
572 : {
573 0 : pCntxt = aContexts[nPos];
574 0 : aContexts.erase( aContexts.begin() + nPos );
575 : }
576 0 : break;
577 : case HTML_ORDERLIST_ON:
578 : case HTML_UNORDERLIST_ON:
579 : case HTML_MENULIST_ON:
580 : case HTML_DIRLIST_ON:
581 : // keine LI/LH ausserhalb der aktuellen Liste betrachten
582 0 : nPos = nContextStMin;
583 0 : break;
584 : }
585 : }
586 :
587 : // und noch Attribute beenden
588 0 : if( pCntxt )
589 : {
590 0 : EndContext( pCntxt );
591 0 : SetAttr(); // Absatz-Atts wegen JavaScript moeglichst schnell setzen
592 0 : delete pCntxt;
593 : }
594 :
595 : // und die bisherige Vorlage setzen
596 0 : if( bSetColl )
597 0 : SetTextCollAttrs();
598 0 : }
599 :
600 0 : void SwHTMLParser::SetNodeNum( sal_uInt8 nLevel, bool bCountedInList )
601 : {
602 0 : SwTextNode* pTextNode = pPam->GetNode().GetTextNode();
603 : OSL_ENSURE( pTextNode, "Kein Text-Node an PaM-Position" );
604 :
605 : OSL_ENSURE( GetNumInfo().GetNumRule(), "Kein Numerierungs-Regel" );
606 0 : const OUString& rName = GetNumInfo().GetNumRule()->GetName();
607 0 : static_cast<SwContentNode *>(pTextNode)->SetAttr( SwNumRuleItem(rName) );
608 :
609 0 : pTextNode->SetAttrListLevel( nLevel );
610 0 : pTextNode->SetCountedInList( bCountedInList );
611 :
612 : // NumRule invalidieren, weil sie durch ein EndAction bereits
613 : // auf valid geschaltet worden sein kann.
614 0 : GetNumInfo().GetNumRule()->SetInvalidRule( false );
615 177 : }
616 :
617 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|