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 <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
31 : : #include <com/sun/star/document/XDocumentProperties.hpp>
32 : : #include <com/sun/star/i18n/ScriptType.hpp>
33 : : #include <comphelper/string.hxx>
34 : : #include <rtl/ustrbuf.hxx>
35 : : #include <sfx2/sfx.hrc>
36 : : #include <svx/svxids.hrc>
37 : : #if OSL_DEBUG_LEVEL > 0
38 : : #include <stdlib.h>
39 : : #endif
40 : : #include <hintids.hxx>
41 : :
42 : : #include <svl/stritem.hxx>
43 : : #include <svtools/imap.hxx>
44 : : #include <svtools/htmltokn.h>
45 : : #include <svtools/htmlkywd.hxx>
46 : : #include <svtools/ctrltool.hxx>
47 : : #include <unotools/pathoptions.hxx>
48 : : #include <vcl/svapp.hxx>
49 : : #include <vcl/wrkwin.hxx>
50 : : #include <sfx2/fcontnr.hxx>
51 : : #include <sfx2/docfile.hxx>
52 : :
53 : : #include <svtools/htmlcfg.hxx>
54 : : #include <sfx2/linkmgr.hxx>
55 : : #include <editeng/kernitem.hxx>
56 : : #include <editeng/boxitem.hxx>
57 : : #include <editeng/fhgtitem.hxx>
58 : : #include <editeng/brkitem.hxx>
59 : : #include <editeng/postitem.hxx>
60 : : #include <editeng/wghtitem.hxx>
61 : : #include <editeng/crsditem.hxx>
62 : : #include <editeng/udlnitem.hxx>
63 : : #include <editeng/escpitem.hxx>
64 : : #include <editeng/blnkitem.hxx>
65 : : #include <editeng/ulspitem.hxx>
66 : : #include <editeng/colritem.hxx>
67 : : #include <editeng/fontitem.hxx>
68 : : #include <editeng/adjitem.hxx>
69 : : #include <editeng/lrspitem.hxx>
70 : : #include <editeng/protitem.hxx>
71 : : #include <editeng/flstitem.hxx>
72 : :
73 : :
74 : : #include <frmatr.hxx>
75 : : #include <charatr.hxx>
76 : : #include <fmtfld.hxx>
77 : : #include <fmtpdsc.hxx>
78 : : #include <txtfld.hxx>
79 : : #include <fmtanchr.hxx>
80 : : #include <fmtsrnd.hxx>
81 : : #include <fmtfsize.hxx>
82 : : #include <fmtclds.hxx>
83 : : #include <fchrfmt.hxx>
84 : : #include <fmtinfmt.hxx>
85 : : #include <docary.hxx>
86 : : #include <docstat.hxx>
87 : : #include <doc.hxx>
88 : : #include <IDocumentUndoRedo.hxx>
89 : : #include <pam.hxx>
90 : : #include <ndtxt.hxx>
91 : : #include <mdiexp.hxx> // ...Percent()
92 : : #include <expfld.hxx>
93 : : #include <poolfmt.hxx>
94 : : #include <pagedesc.hxx>
95 : : #include <IMark.hxx> // fuer SwBookmark ...
96 : : #include <docsh.hxx>
97 : : #include <editsh.hxx> // fuer Start/EndAction
98 : : #include <docufld.hxx>
99 : : #include <swcss1.hxx>
100 : : #include <htmlvsh.hxx>
101 : : #include <fltini.hxx>
102 : : #include <htmltbl.hxx>
103 : : #include <htmlnum.hxx>
104 : : #include <swhtml.hxx>
105 : : #include <linkenum.hxx>
106 : : #include <breakit.hxx>
107 : : #include <SwAppletImpl.hxx>
108 : :
109 : : #include <sfx2/viewfrm.hxx>
110 : :
111 : : #include <statstr.hrc> // ResId fuer Statusleiste
112 : : #include <swerror.h>
113 : :
114 : : #define FONTSIZE_MASK 7
115 : :
116 : : #define HTML_ESC_PROP 80
117 : : #define HTML_ESC_SUPER DFLT_ESC_SUPER
118 : : #define HTML_ESC_SUB DFLT_ESC_SUB
119 : :
120 : : #define HTML_SPTYPE_NONE 0
121 : : #define HTML_SPTYPE_BLOCK 1
122 : : #define HTML_SPTYPE_HORI 2
123 : : #define HTML_SPTYPE_VERT 3
124 : :
125 : : #ifndef TOOLS_CONSTASCII_STRINGPARAM
126 : : #define TOOLS_CONSTASCII_STRINGPARAM( constAsciiStr ) constAsciiStr, sizeof( constAsciiStr )-1
127 : : #endif
128 : :
129 : : using editeng::SvxBorderLine;
130 : : using namespace ::com::sun::star;
131 : :
132 : : // <P ALIGN=xxx>, <Hn ALIGN=xxx>, <TD ALIGN=xxx> usw.
133 : : HTMLOptionEnum aHTMLPAlignTable[] =
134 : : {
135 : : { OOO_STRING_SVTOOLS_HTML_AL_left, SVX_ADJUST_LEFT },
136 : : { OOO_STRING_SVTOOLS_HTML_AL_center, SVX_ADJUST_CENTER },
137 : : { OOO_STRING_SVTOOLS_HTML_AL_middle, SVX_ADJUST_CENTER }, // Netscape
138 : : { OOO_STRING_SVTOOLS_HTML_AL_right, SVX_ADJUST_RIGHT },
139 : : { OOO_STRING_SVTOOLS_HTML_AL_justify, SVX_ADJUST_BLOCK },
140 : : { OOO_STRING_SVTOOLS_HTML_AL_char, SVX_ADJUST_LEFT },
141 : : { 0, 0 }
142 : : };
143 : :
144 : : // <SPACER TYPE=...>
145 : : static HTMLOptionEnum aHTMLSpacerTypeTable[] =
146 : : {
147 : : { OOO_STRING_SVTOOLS_HTML_SPTYPE_block, HTML_SPTYPE_BLOCK },
148 : : { OOO_STRING_SVTOOLS_HTML_SPTYPE_horizontal, HTML_SPTYPE_HORI },
149 : : { OOO_STRING_SVTOOLS_HTML_SPTYPE_vertical, HTML_SPTYPE_VERT },
150 : : { 0, 0 }
151 : : };
152 : :
153 : 73 : HTMLReader::HTMLReader()
154 : : {
155 : 73 : bTmplBrowseMode = sal_True;
156 : 73 : }
157 : :
158 : 2 : String HTMLReader::GetTemplateName() const
159 : : {
160 [ + - ]: 2 : String sTemplate(rtl::OUString("html"));
161 [ + - ]: 2 : String sTemplateWithoutExt( sTemplate );
162 : : // first search for OpenDocument Writer/Web template
163 [ + - ]: 2 : sTemplate.AppendAscii( TOOLS_CONSTASCII_STRINGPARAM(".oth") );
164 : :
165 : : //Added path for the common HTML template
166 [ + - ]: 2 : SvtPathOptions aPathOpt;
167 [ + - ]: 2 : const String sCommonTemplatePath("share/template/common/internal");
168 [ + - ]: 2 : aPathOpt.SetTemplatePath(sCommonTemplatePath);
169 : : // OpenDocument Writer/Web template (extension .oth)
170 [ + - ]: 2 : sal_Bool bSet = aPathOpt.SearchFile( sTemplate, SvtPathOptions::PATH_TEMPLATE );
171 : :
172 [ + - ]: 2 : if( !bSet )
173 : : {
174 : : // 6.0 (extension .stw)
175 [ + - ]: 2 : sTemplate = sTemplateWithoutExt;
176 : : // no OpenDocument Writer/Web template found.
177 : : // search for OpenOffice.org Writer/Web template
178 [ + - ]: 2 : sTemplate.AppendAscii( TOOLS_CONSTASCII_STRINGPARAM(".stw") );
179 [ + - ]: 2 : bSet = aPathOpt.SearchFile( sTemplate, SvtPathOptions::PATH_TEMPLATE );
180 : : }
181 : :
182 [ + - ]: 2 : if( !bSet )
183 : : {
184 [ + - ]: 2 : sTemplate.Erase();
185 : : OSL_ENSURE( !this,
186 : : "Die html.vor befindet sich nicht mehr im definierten Directory!");
187 : : }
188 : :
189 [ + - ][ + - ]: 2 : return sTemplate;
[ + - ]
190 : : }
191 : :
192 : 2 : int HTMLReader::SetStrmStgPtr()
193 : : {
194 : : OSL_ENSURE( pMedium, "Wo ist das Medium??" );
195 : :
196 [ + - ][ + - ]: 2 : if( pMedium->IsRemote() || !pMedium->IsStorage() )
[ + - ]
197 : : {
198 : 2 : pStrm = pMedium->GetInStream();
199 : 2 : return sal_True;
200 : : }
201 : 2 : return sal_False;
202 : :
203 : : }
204 : :
205 : : // Aufruf fuer die allg. Reader-Schnittstelle
206 : 2 : sal_uLong HTMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPam, const String & rName )
207 : : {
208 [ - + ]: 2 : if( !pStrm )
209 : : {
210 : : OSL_ENSURE( pStrm, "HTML-Read ohne Stream" );
211 : 0 : return ERR_SWG_READ_ERROR;
212 : : }
213 : :
214 [ + - ]: 2 : if( !bInsertMode )
215 : : {
216 [ + - ]: 2 : Reader::ResetFrmFmts( rDoc );
217 : :
218 : : // Die HTML-Seitenvorlage setzen, wenn des kein HTML-Dokument ist,
219 : : // sonst ist sie schon gesetzt.
220 [ + - ][ - + ]: 2 : if( !rDoc.get(IDocumentSettingAccess::HTML_MODE) )
221 : : {
222 : : rDoc.InsertPoolItem( rPam, SwFmtPageDesc(
223 [ # # ][ # # ]: 0 : rDoc.GetPageDescFromPool( RES_POOLPAGE_HTML, false )), 0 );
[ # # ][ # # ]
224 : : }
225 : : }
226 : :
227 : : // damit keiner das Doc klaut!
228 [ + - ]: 2 : rDoc.acquire();
229 : 2 : sal_uLong nRet = 0;
230 : : SvParserRef xParser = new SwHTMLParser( &rDoc, rPam, *pStrm,
231 : : rName, rBaseURL, !bInsertMode, pMedium,
232 : 2 : IsReadUTF8(),
233 [ + - ][ + - ]: 2 : bIgnoreHTMLComments );
234 : :
235 [ + - ]: 2 : SvParserState eState = xParser->CallParser();
236 : :
237 [ - + ]: 2 : if( SVPAR_PENDING == eState )
238 [ # # ]: 0 : pStrm->ResetError();
239 [ - + ]: 2 : else if( SVPAR_ACCEPTED != eState )
240 : : {
241 [ # # ]: 0 : String sErr( String::CreateFromInt32((sal_Int32)xParser->GetLineNr()));
242 [ # # ]: 0 : sErr += ',';
243 [ # # ][ # # ]: 0 : sErr += String::CreateFromInt32((sal_Int32)xParser->GetLinePos());
[ # # ]
244 : :
245 : : // den Stream als Fehlernummer Transporter benutzen
246 : : nRet = *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
247 [ # # ][ # # ]: 0 : ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
[ # # ][ # # ]
248 : : }
249 : :
250 : :
251 [ + - ]: 2 : return nRet;
252 : : }
253 : :
254 : :
255 : :
256 : 2 : SwHTMLParser::SwHTMLParser( SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn,
257 : : const String& rPath,
258 : : const String& rBaseURL,
259 : : int bReadNewDoc,
260 : : SfxMedium* pMed, sal_Bool bReadUTF8,
261 : : sal_Bool bNoHTMLComments )
262 : : : SfxHTMLParser( rIn, static_cast< sal_Bool >(bReadNewDoc), pMed ),
263 : : SwClient( 0 ),
264 : : aPathToFile( rPath ),
265 : : sBaseURL( rBaseURL ),
266 : : pAppletImpl( 0 ),
267 : : pCSS1Parser( 0 ),
268 : 2 : pNumRuleInfo( new SwHTMLNumRuleInfo ),
269 : : pPendStack( 0 ),
270 : : pDoc( pD ),
271 : : pActionViewShell( 0 ),
272 : : pSttNdIdx( 0 ),
273 : : pTable(0),
274 : : pFormImpl( 0 ),
275 : : pMarquee( 0 ),
276 : : pField( 0 ),
277 : : pImageMap( 0 ),
278 : : pImageMaps( 0 ),
279 : : pFootEndNoteImpl( 0 ),
280 : : nScriptStartLineNr( 0 ),
281 : : nBaseFontStMin( 0 ),
282 : : nFontStMin( 0 ),
283 : : nDefListDeep( 0 ),
284 : : nFontStHeadStart( 0 ),
285 : : nSBModuleCnt( 0 ),
286 : : nMissingImgMaps( 0 ),
287 : : nParaCnt( 5 ),
288 : : // #i83625#
289 : : nContextStMin( 0 ),
290 : : nContextStAttrMin( 0 ),
291 : : nOpenParaToken( 0 ),
292 : : eJumpTo( JUMPTO_NONE ),
293 : : #ifdef DBG_UTIL
294 : : m_nContinue( 0 ),
295 : : #endif
296 : : eParaAdjust( SVX_ADJUST_END ),
297 : : bDocInitalized( sal_False ),
298 : : bSetModEnabled( sal_False ),
299 : : bInFloatingFrame( sal_False ),
300 : : bInField( sal_False ),
301 : : bCallNextToken( sal_False ),
302 : : bIgnoreRawData( sal_False ),
303 : : bNoParSpace( sal_False ),
304 : : bInNoEmbed( sal_False ),
305 : : bInTitle( sal_False ),
306 : : bUpdateDocStat( sal_False ),
307 : : bFixSelectWidth( sal_False ),
308 : : bFixSelectHeight( sal_False ),
309 : : bTextArea( sal_False ),
310 : : bSelect( sal_False ),
311 : : bInFootEndNoteAnchor( sal_False ),
312 : : bInFootEndNoteSymbol( sal_False ),
313 : : bIgnoreHTMLComments( bNoHTMLComments ),
314 : : bRemoveHidden( sal_False ),
315 [ + - ][ + - ]: 32 : pTempViewFrame(0)
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + + ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + + # #
# # ]
316 : : {
317 : 2 : nEventId = 0;
318 : : bUpperSpace = bViewCreated = bChkJumpMark =
319 : 2 : bSetCrsr = sal_False;
320 : :
321 : 2 : eScriptLang = HTML_SL_UNKNOWN;
322 : 2 : bAnyStarBasic = sal_True;
323 : :
324 [ + - ][ + - ]: 2 : pPam = new SwPaM( *rCrsr.GetPoint() );
325 : 2 : memset( &aAttrTab, 0, sizeof( _HTMLAttrTable ));
326 : :
327 : : // Die Font-Groessen 1-7 aus der INI-Datei lesen
328 [ + - ]: 2 : SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
329 [ + - ]: 2 : aFontHeights[0] = rHtmlOptions.GetFontSize( 0 ) * 20;
330 [ + - ]: 2 : aFontHeights[1] = rHtmlOptions.GetFontSize( 1 ) * 20;
331 [ + - ]: 2 : aFontHeights[2] = rHtmlOptions.GetFontSize( 2 ) * 20;
332 [ + - ]: 2 : aFontHeights[3] = rHtmlOptions.GetFontSize( 3 ) * 20;
333 [ + - ]: 2 : aFontHeights[4] = rHtmlOptions.GetFontSize( 4 ) * 20;
334 [ + - ]: 2 : aFontHeights[5] = rHtmlOptions.GetFontSize( 5 ) * 20;
335 [ + - ]: 2 : aFontHeights[6] = rHtmlOptions.GetFontSize( 6 ) * 20;
336 : :
337 [ + - ]: 2 : bKeepUnknown = rHtmlOptions.IsImportUnknown();
338 : :
339 [ + - ]: 2 : if(bReadNewDoc)
340 : : {
341 : : //CJK has different defaults, so a different object should be used for this
342 : : //RES_CHARTR_CJK_FONTSIZE is a valid value
343 [ + - ]: 2 : SvxFontHeightItem aFontHeight(aFontHeights[2], 100, RES_CHRATR_FONTSIZE);
344 [ + - ]: 2 : pDoc->SetDefault( aFontHeight );
345 [ + - ]: 2 : SvxFontHeightItem aFontHeightCJK(aFontHeights[2], 100, RES_CHRATR_CJK_FONTSIZE);
346 [ + - ]: 2 : pDoc->SetDefault( aFontHeightCJK );
347 [ + - ]: 2 : SvxFontHeightItem aFontHeightCTL(aFontHeights[2], 100, RES_CHRATR_CTL_FONTSIZE);
348 [ + - ][ + - ]: 2 : pDoc->SetDefault( aFontHeightCTL );
[ + - ][ + - ]
349 : : }
350 : :
351 : : // Waehrend des Imports in den HTML-Modus schalten, damit die
352 : : // richrigen Vorlagen angelegt werden
353 [ + - ]: 2 : bOldIsHTMLMode = pDoc->get(IDocumentSettingAccess::HTML_MODE);
354 [ + - ]: 2 : pDoc->set(IDocumentSettingAccess::HTML_MODE, true);
355 : :
356 [ + - ][ + - ]: 2 : pCSS1Parser = new SwCSS1Parser( pDoc, aFontHeights, sBaseURL, IsNewDoc() );
357 [ + - ]: 2 : pCSS1Parser->SetIgnoreFontFamily( rHtmlOptions.IsIgnoreFontFamily() );
358 : :
359 [ - + ]: 2 : if( bReadUTF8 )
360 : : {
361 [ # # ]: 0 : SetSrcEncoding( RTL_TEXTENCODING_UTF8 );
362 : : }
363 : : else
364 : : {
365 : 2 : SwDocShell *pDocSh = pDoc->GetDocShell();
366 : : SvKeyValueIterator *pHeaderAttrs =
367 [ + - ]: 2 : pDocSh->GetHeaderAttributes();
368 [ + - ]: 2 : if( pHeaderAttrs )
369 [ + - ]: 2 : SetEncodingByHTTPHeader( pHeaderAttrs );
370 : : }
371 [ + - ][ + - ]: 2 : pCSS1Parser->SetDfltEncoding( osl_getThreadTextEncoding() );
372 : :
373 : : // Timer nur bei ganz normalen Dokumenten aufsetzen!
374 : 2 : SwDocShell* pDocSh = pDoc->GetDocShell();
375 [ + - ]: 2 : if( pDocSh )
376 : : {
377 : 2 : bViewCreated = sal_True; // nicht, synchron laden
378 : :
379 : : // es ist ein Sprungziel vorgegeben.
380 : :
381 [ + - ]: 2 : if( pMed )
382 : : {
383 [ + - ][ + - ]: 2 : sJmpMark = pMed->GetURLObject().GetMark();
[ + - ]
384 [ - + ]: 2 : if( sJmpMark.Len() )
385 : : {
386 : 0 : eJumpTo = JUMPTO_MARK;
387 : 0 : xub_StrLen nLastPos, nPos = 0;
388 [ # # ][ # # ]: 0 : while( STRING_NOTFOUND != ( nLastPos =
389 : 0 : sJmpMark.Search( cMarkSeperator, nPos + 1 )) )
390 : 0 : nPos = nLastPos;
391 : :
392 [ # # ]: 0 : String sCmp;
393 [ # # ]: 0 : if (nPos)
394 : : {
395 : : sCmp = comphelper::string::remove(
396 [ # # ][ # # ]: 0 : sJmpMark.Copy(nPos + 1), ' ');
[ # # ][ # # ]
397 : : }
398 : :
399 [ # # ]: 0 : if( sCmp.Len() )
400 : : {
401 [ # # ]: 0 : sCmp.ToLowerAscii();
402 [ # # ][ # # ]: 0 : if( sCmp.EqualsAscii( pMarkToRegion ) )
403 : 0 : eJumpTo = JUMPTO_REGION;
404 [ # # ][ # # ]: 0 : else if( sCmp.EqualsAscii( pMarkToTable ) )
405 : 0 : eJumpTo = JUMPTO_TABLE;
406 [ # # ][ # # ]: 0 : else if( sCmp.EqualsAscii( pMarkToGraphic ) )
407 : 0 : eJumpTo = JUMPTO_GRAPHIC;
408 [ # # ][ # # ]: 0 : else if( sCmp.EqualsAscii( pMarkToOutline ) ||
[ # # ][ # # ]
[ # # ]
409 [ # # ]: 0 : sCmp.EqualsAscii( pMarkToText ) ||
410 [ # # ]: 0 : sCmp.EqualsAscii( pMarkToFrame ) )
411 : 0 : eJumpTo = JUMPTO_NONE; // das ist nichts gueltiges!
412 : : else
413 : : // ansonsten ist das ein normaler (Book)Mark
414 : 0 : nPos = STRING_LEN;
415 : : }
416 : : else
417 : 0 : nPos = STRING_LEN;
418 : :
419 [ # # ]: 0 : sJmpMark.Erase( nPos );
420 [ # # ]: 0 : if( !sJmpMark.Len() )
421 [ # # ]: 0 : eJumpTo = JUMPTO_NONE;
422 : : }
423 : : }
424 : : }
425 [ # # # # : 2 : }
# # # # ]
426 : :
427 [ + - ][ + - ]: 32 : SwHTMLParser::~SwHTMLParser()
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
428 : : {
429 : : #ifdef DBG_UTIL
430 : : OSL_ENSURE( !m_nContinue, "DTOR im Continue!" );
431 : : #endif
432 : 2 : sal_Bool bAsync = pDoc->IsInLoadAsynchron();
433 : 2 : pDoc->SetInLoadAsynchron( sal_False );
434 [ + - ]: 2 : pDoc->set(IDocumentSettingAccess::HTML_MODE, bOldIsHTMLMode);
435 : :
436 [ + - ][ - + ]: 2 : if( pDoc->GetDocShell() && nEventId )
[ - + ]
437 [ # # ]: 0 : Application::RemoveUserEvent( nEventId );
438 : :
439 : : // das DocumentDetected kann ggfs. die DocShells loeschen, darum nochmals
440 : : // abfragen
441 [ + - ]: 2 : if( pDoc->GetDocShell() )
442 : : {
443 : : // Gelinkte Bereiche updaten
444 [ + - ]: 2 : sal_uInt16 nLinkMode = pDoc->getLinkUpdateMode( true );
445 [ + - ]: 2 : if( nLinkMode != NEVER && bAsync &&
[ - + # # ]
[ - + ]
446 : 0 : SFX_CREATE_MODE_INTERNAL!=pDoc->GetDocShell()->GetCreateMode() )
447 [ # # ]: 0 : pDoc->GetLinkManager().UpdateAllLinks( nLinkMode == MANUAL,
448 [ # # ]: 0 : sal_True, sal_False );
449 : :
450 [ + - ][ + - ]: 2 : if ( pDoc->GetDocShell()->IsLoading() )
451 : : {
452 : : // #i59688#
453 [ + - ]: 2 : pDoc->GetDocShell()->LoadingFinished();
454 : : }
455 : : }
456 : :
457 [ - + ][ # # ]: 2 : delete pSttNdIdx;
458 : :
459 [ - + ]: 2 : if( !aSetAttrTab.empty() )
460 : : {
461 : : OSL_ENSURE( aSetAttrTab.empty(),"Es stehen noch Attribute auf dem Stack" );
462 [ # # # # ]: 0 : for ( _HTMLAttrs::const_iterator it = aSetAttrTab.begin();
[ # # ]
463 : 0 : it != aSetAttrTab.end(); ++it )
464 [ # # ][ # # ]: 0 : delete *it;
465 : 0 : aSetAttrTab.clear();
466 : : }
467 : :
468 [ + - ][ + - ]: 2 : delete pPam;
469 [ + - ][ + - ]: 2 : delete pCSS1Parser;
470 : 2 : delete pNumRuleInfo;
471 [ + - ]: 2 : DeleteFormImpl();
472 [ + - ]: 2 : DeleteFootEndNoteImpl();
473 : :
474 : : OSL_ENSURE( !pTable, "Es existiert noch eine offene Tabelle" );
475 [ - + ][ # # ]: 2 : delete pImageMaps;
476 : :
477 : : OSL_ENSURE( !pPendStack,
478 : : "SwHTMLParser::~SwHTMLParser: Hier sollte es keinen Pending-Stack mehr geben" );
479 [ - + ]: 2 : while( pPendStack )
480 : : {
481 : 0 : SwPendingStack* pTmp = pPendStack;
482 : 0 : pPendStack = pPendStack->pNext;
483 [ # # ][ # # ]: 0 : delete pTmp->pData;
484 : 0 : delete pTmp;
485 : : }
486 : :
487 [ + - ][ - + ]: 2 : if( !pDoc->release() )
488 : : {
489 : : // keiner will mehr das Doc haben, also weg damit
490 [ # # ][ # # ]: 0 : delete pDoc;
491 : 0 : pDoc = NULL;
492 : : }
493 : :
494 [ - + ]: 2 : if ( pTempViewFrame )
495 : : {
496 [ # # ]: 0 : pTempViewFrame->DoClose();
497 : :
498 : : // the temporary view frame is hidden, so the hidden flag might need to be removed
499 [ # # ][ # # ]: 0 : if ( bRemoveHidden && pDoc && pDoc->GetDocShell() && pDoc->GetDocShell()->GetMedium() )
[ # # ][ # # ]
[ # # ]
500 [ # # ][ # # ]: 0 : pDoc->GetDocShell()->GetMedium()->GetItemSet()->ClearItem( SID_HIDDEN );
501 : : }
502 [ + - ][ + + ]: 36 : }
[ + - ][ + + ]
[ - + ][ # #
# # # # #
# ]
503 : :
504 : 0 : IMPL_LINK( SwHTMLParser, AsyncCallback, void*, /*pVoid*/ )
505 : : {
506 : 0 : nEventId=0;
507 : :
508 : : // #i47907# - If the document has already been destructed,
509 : : // the parser should be aware of this:
510 [ # # ]: 0 : if( ( pDoc->GetDocShell() && pDoc->GetDocShell()->IsAbortingImport() )
[ # # # # ]
[ # # ]
511 : 0 : || 1 == pDoc->getReferenceCount() )
512 : : {
513 : : // wurde der Import vom SFX abgebrochen?
514 : 0 : eState = SVPAR_ERROR;
515 : : }
516 : :
517 [ # # ]: 0 : GetAsynchCallLink().Call(0);
518 : 0 : return 0;
519 : : }
520 : :
521 : 2 : SvParserState SwHTMLParser::CallParser()
522 : : {
523 : : // einen temporaeren Index anlegen, auf Pos 0 so wird er nicht bewegt!
524 [ + - ]: 2 : pSttNdIdx = new SwNodeIndex( pDoc->GetNodes() );
525 [ - + ]: 2 : if( !IsNewDoc() ) // in ein Dokument einfuegen ?
526 : : {
527 : 0 : const SwPosition* pPos = pPam->GetPoint();
528 : :
529 [ # # ]: 0 : pDoc->SplitNode( *pPos, false );
530 : :
531 [ # # ]: 0 : *pSttNdIdx = pPos->nNode.GetIndex()-1;
532 [ # # ]: 0 : pDoc->SplitNode( *pPos, false );
533 : :
534 [ # # ]: 0 : SwPaM aInsertionRangePam( *pPos );
535 : :
536 [ # # ]: 0 : pPam->Move( fnMoveBackward );
537 : :
538 : : // split any redline over the insertion point
539 [ # # ]: 0 : aInsertionRangePam.SetMark();
540 [ # # ]: 0 : *aInsertionRangePam.GetPoint() = *pPam->GetPoint();
541 [ # # ]: 0 : aInsertionRangePam.Move( fnMoveBackward );
542 [ # # ]: 0 : pDoc->SplitRedline( aInsertionRangePam );
543 : :
544 : : pDoc->SetTxtFmtColl( *pPam,
545 [ # # ][ # # ]: 0 : pCSS1Parser->GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
[ # # ]
546 : : }
547 : :
548 [ + - ]: 2 : if( GetMedium() )
549 : : {
550 [ - + ]: 2 : if( !bViewCreated )
551 : : {
552 [ # # ]: 0 : nEventId = Application::PostUserEvent( LINK( this, SwHTMLParser, AsyncCallback ), 0 );
553 : : }
554 : : else
555 : : {
556 : 2 : bViewCreated = sal_True;
557 : 2 : nEventId = 0;
558 : : }
559 : : }
560 : :
561 : : // Laufbalken anzeigen
562 [ # # ][ # # ]: 0 : else if( !GetMedium() || !GetMedium()->IsRemote() )
[ # # ]
563 : : {
564 : 0 : rInput.Seek(STREAM_SEEK_TO_END);
565 : 0 : rInput.ResetError();
566 : 0 : ::StartProgress( STR_STATSTR_W4WREAD, 0, rInput.Tell(),
567 : 0 : pDoc->GetDocShell() );
568 : 0 : rInput.Seek(STREAM_SEEK_TO_BEGIN);
569 : 0 : rInput.ResetError();
570 : : }
571 : :
572 : 2 : pDoc->GetPageDesc( 0 ).Add( this );
573 : :
574 : 2 : SvParserState eRet = HTMLParser::CallParser();
575 : 2 : return eRet;
576 : : }
577 : :
578 : 2 : void SwHTMLParser::Continue( int nToken )
579 : : {
580 : : #ifdef DBG_UTIL
581 : : OSL_ENSURE(!m_nContinue, "Continue im Continue - not supposed to happen");
582 : : m_nContinue++;
583 : : #endif
584 : :
585 : : // Wenn der Import (vom SFX) abgebrochen wurde, wird ein Fehler
586 : : // gesetzt aber trotzdem noch weiter gemacht, damit vernuenftig
587 : : // aufgeraeumt wird.
588 : : OSL_ENSURE( SVPAR_ERROR!=eState,
589 : : "SwHTMLParser::Continue: bereits ein Fehler gesetzt" );
590 [ + - ][ + - ]: 2 : if( pDoc->GetDocShell() && pDoc->GetDocShell()->IsAbortingImport() )
[ - + ][ - + ]
591 : 0 : eState = SVPAR_ERROR;
592 : :
593 : : // Die ViewShell vom Dokument holen, merken und als aktuelle setzen.
594 [ + - ]: 2 : ViewShell *pInitVSh = CallStartAction();
595 : :
596 [ + - ][ + - ]: 2 : if( SVPAR_ERROR != eState && GetMedium() && !bViewCreated )
[ - + ][ - + ]
597 : : {
598 : : // Beim ersten Aufruf erstmal returnen, Doc anzeigen
599 : : // und auf Timer Callback warten.
600 : : // An dieser Stelle wurde im CallParser gerade mal ein Zeichen
601 : : // gelesen und ein SaveState(0) gerufen.
602 : 0 : eState = SVPAR_PENDING;
603 : 0 : bViewCreated = sal_True;
604 : 0 : pDoc->SetInLoadAsynchron( sal_True );
605 : :
606 : : #ifdef DBG_UTIL
607 : : m_nContinue--;
608 : : #endif
609 : :
610 : 2 : return;
611 : : }
612 : :
613 : 2 : bSetModEnabled = sal_False;
614 [ + - ][ - + ]: 4 : if( pDoc->GetDocShell() &&
[ - + ]
615 [ + - ]: 2 : 0 != (bSetModEnabled = pDoc->GetDocShell()->IsEnableSetModified()) )
616 : : {
617 [ # # ]: 0 : pDoc->GetDocShell()->EnableSetModified( sal_False );
618 : : }
619 : :
620 : : // waehrend des einlesens kein OLE-Modified rufen
621 : 2 : Link aOLELink( pDoc->GetOle2Link() );
622 [ + - ]: 2 : pDoc->SetOle2Link( Link() );
623 : :
624 [ + - ]: 2 : sal_Bool bModified = pDoc->IsModified();
625 [ + - ][ + - ]: 2 : bool const bWasUndo = pDoc->GetIDocumentUndoRedo().DoesUndo();
626 [ + - ][ + - ]: 2 : pDoc->GetIDocumentUndoRedo().DoUndo(false);
627 : :
628 : : // Wenn der Import abgebrochen wird, kein Continue mehr rufen.
629 : : // Falls ein Pending-Stack existiert aber durch einen Aufruf
630 : : // von NextToken dafuer sorgen, dass der Pending-Stack noch
631 : : // beendet wird.
632 [ - + ]: 2 : if( SVPAR_ERROR == eState )
633 : : {
634 : : OSL_ENSURE( !pPendStack || pPendStack->nToken,
635 : : "SwHTMLParser::Continue: Pending-Stack ohne Token" );
636 [ # # ][ # # ]: 0 : if( pPendStack && pPendStack->nToken )
637 [ # # ]: 0 : NextToken( pPendStack->nToken );
638 : : OSL_ENSURE( !pPendStack,
639 : : "SwHTMLParser::Continue: Es gibt wieder einen Pend-Stack" );
640 : : }
641 : : else
642 : : {
643 [ - + ][ + - ]: 2 : HTMLParser::Continue( pPendStack ? pPendStack->nToken : nToken );
644 : : }
645 : :
646 : : // Laufbalken wieder abschalten
647 [ + - ]: 2 : EndProgress( pDoc->GetDocShell() );
648 : :
649 : 2 : sal_Bool bLFStripped = sal_False;
650 [ + - ]: 2 : if( SVPAR_PENDING != GetStatus() )
651 : : {
652 : : // noch die letzten Attribute setzen
653 : : {
654 [ - + ]: 2 : if( aScriptSource.Len() )
655 : : {
656 : : SwScriptFieldType *pType =
657 [ # # ]: 0 : (SwScriptFieldType*)pDoc->GetSysFldType( RES_SCRIPTFLD );
658 : :
659 : : SwScriptField aFld( pType, aScriptType, aScriptSource,
660 [ # # ]: 0 : sal_False );
661 [ # # ][ # # ]: 0 : InsertAttr( SwFmtFld( aFld ) );
[ # # ][ # # ]
662 : : }
663 : :
664 [ - + ]: 2 : if( pAppletImpl )
665 : : {
666 [ # # ][ # # ]: 0 : if( pAppletImpl->GetApplet().is() )
667 [ # # ]: 0 : EndApplet();
668 : : else
669 [ # # ]: 0 : EndObject();
670 : : }
671 : :
672 : : // ggf. ein noch vorhandes LF hinter dem letzen Absatz entfernen
673 [ + - ]: 2 : if( IsNewDoc() )
674 [ + - ]: 2 : bLFStripped = StripTrailingLF() > 0;
675 : :
676 : : // noch offene Nummerierungen beenden.
677 [ - + ]: 2 : while( GetNumInfo().GetNumRule() )
678 [ # # ]: 0 : EndNumBulList();
679 : :
680 : : OSL_ENSURE( !nContextStMin, "Es gibt geschuetzte Kontexte" );
681 : 2 : nContextStMin = 0;
682 [ - + ]: 2 : while( aContexts.size() )
683 : : {
684 [ # # ]: 0 : _HTMLAttrContext *pCntxt = PopContext();
685 [ # # ]: 0 : if( pCntxt )
686 : : {
687 [ # # ]: 0 : EndContext( pCntxt );
688 [ # # ][ # # ]: 0 : delete pCntxt;
689 : : }
690 : : }
691 : :
692 [ - + ]: 2 : if( !aParaAttrs.empty() )
693 : 0 : aParaAttrs.clear();
694 : :
695 [ + - ]: 2 : SetAttr( sal_False );
696 : :
697 : : // Noch die erst verzoegert gesetzten Styles setzen
698 [ + - ]: 2 : pCSS1Parser->SetDelayedStyles();
699 : : }
700 : :
701 : : // den Start wieder korrigieren
702 [ - + ][ # # ]: 2 : if( !IsNewDoc() && pSttNdIdx->GetIndex() )
[ - + ]
703 : : {
704 : 0 : SwTxtNode* pTxtNode = pSttNdIdx->GetNode().GetTxtNode();
705 [ # # ]: 0 : SwNodeIndex aNxtIdx( *pSttNdIdx );
706 [ # # ][ # # ]: 0 : if( pTxtNode && pTxtNode->CanJoinNext( &aNxtIdx ))
[ # # ][ # # ]
707 : : {
708 : 0 : xub_StrLen nStt = pTxtNode->GetTxt().Len();
709 : : // wenn der Cursor noch in dem Node steht, dann setze in an das Ende
710 [ # # ]: 0 : if( pPam->GetPoint()->nNode == aNxtIdx )
711 : : {
712 [ # # ]: 0 : pPam->GetPoint()->nNode = *pSttNdIdx;
713 [ # # ][ # # ]: 0 : pPam->GetPoint()->nContent.Assign( pTxtNode, nStt );
714 : : }
715 : :
716 : : #if OSL_DEBUG_LEVEL > 0
717 : : // !!! sollte nicht moeglich sein, oder ??
718 : : OSL_ENSURE( pSttNdIdx->GetIndex()+1 != pPam->GetBound( sal_True ).nNode.GetIndex(),
719 : : "Pam.Bound1 steht noch im Node" );
720 : : OSL_ENSURE( pSttNdIdx->GetIndex()+1 != pPam->GetBound( sal_False ).nNode.GetIndex(),
721 : : "Pam.Bound2 steht noch im Node" );
722 : :
723 : : if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( sal_True ).nNode.GetIndex() )
724 : : {
725 : : xub_StrLen nCntPos = pPam->GetBound( sal_True ).nContent.GetIndex();
726 : : pPam->GetBound( sal_True ).nContent.Assign( pTxtNode,
727 : : pTxtNode->GetTxt().Len() + nCntPos );
728 : : }
729 : : if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( sal_False ).nNode.GetIndex() )
730 : : {
731 : : xub_StrLen nCntPos = pPam->GetBound( sal_False ).nContent.GetIndex();
732 : : pPam->GetBound( sal_False ).nContent.Assign( pTxtNode,
733 : : pTxtNode->GetTxt().Len() + nCntPos );
734 : : }
735 : : #endif
736 : : // Zeichen Attribute beibehalten!
737 : 0 : SwTxtNode* pDelNd = aNxtIdx.GetNode().GetTxtNode();
738 [ # # ]: 0 : if( pTxtNode->GetTxt().Len() )
739 [ # # ]: 0 : pDelNd->FmtToTxtAttr( pTxtNode );
740 : : else
741 [ # # ]: 0 : pTxtNode->ChgFmtColl( pDelNd->GetTxtColl() );
742 [ # # ]: 0 : pTxtNode->JoinNext();
743 [ # # ]: 0 : }
744 : : }
745 : : }
746 : :
747 [ + - ]: 2 : if( SVPAR_ACCEPTED == eState )
748 : : {
749 [ - + ]: 2 : if( nMissingImgMaps )
750 : : {
751 : : // es fehlen noch ein paar Image-Map zuordungen.
752 : : // vielleicht sind die Image-Maps ja jetzt da?
753 [ # # ]: 0 : ConnectImageMaps();
754 : : }
755 : :
756 : : // jetzt noch den letzten ueberfluessigen Absatz loeschen
757 : 2 : SwPosition* pPos = pPam->GetPoint();
758 [ + - ][ + - ]: 2 : if( !pPos->nContent.GetIndex() && !bLFStripped )
[ + - ]
759 : : {
760 : : SwTxtNode* pAktNd;
761 : 2 : sal_uLong nNodeIdx = pPos->nNode.GetIndex();
762 : :
763 : : sal_Bool bHasFlysOrMarks =
764 [ + - ][ + - ]: 2 : HasCurrentParaFlys() || HasCurrentParaBookmarks( sal_True );
[ - + ][ + - ]
765 : :
766 [ + - ]: 2 : if( IsNewDoc() )
767 : : {
768 [ + - ][ + - ]: 2 : const SwNode *pPrev = pDoc->GetNodes()[nNodeIdx -1];
769 [ + - - + : 4 : if( !pPam->GetPoint()->nContent.GetIndex() &&
# # # # ]
[ + - ]
770 : 2 : ( pPrev->IsCntntNode() ||
771 : 0 : (pPrev->IsEndNode() &&
772 : 0 : pPrev->StartOfSectionNode()->IsSectionNode()) ) )
773 : : {
774 : 2 : SwCntntNode* pCNd = pPam->GetCntntNode();
775 [ + - ][ + - ]: 4 : if( pCNd && pCNd->StartOfSectionIndex()+2 <
[ + - ][ + - ]
776 : 2 : pCNd->EndOfSectionIndex() && !bHasFlysOrMarks )
777 : : {
778 [ + - ]: 2 : ViewShell *pVSh = CheckActionViewShell();
779 [ # # ][ # # ]: 0 : SwCrsrShell *pCrsrSh = pVSh && pVSh->ISA(SwCrsrShell)
780 : : ? static_cast < SwCrsrShell * >( pVSh )
781 [ - + ][ # # ]: 2 : : 0;
782 [ - + # # ]: 2 : if( pCrsrSh &&
[ - + ]
783 [ # # ]: 0 : pCrsrSh->GetCrsr()->GetPoint()
784 : 0 : ->nNode.GetIndex() == nNodeIdx )
785 : : {
786 [ # # ]: 0 : pCrsrSh->MovePara(fnParaPrev, fnParaEnd );
787 [ # # ]: 0 : pCrsrSh->SetMark();
788 [ # # ]: 0 : pCrsrSh->ClearMark();
789 : : }
790 [ + - ]: 2 : pPam->GetBound(sal_True).nContent.Assign( 0, 0 );
791 [ + - ]: 2 : pPam->GetBound(sal_False).nContent.Assign( 0, 0 );
792 [ + - ][ + - ]: 2 : pDoc->GetNodes().Delete( pPam->GetPoint()->nNode );
793 : : }
794 : : }
795 : : }
796 [ # # ][ # # ]: 0 : else if( 0 != ( pAktNd = pDoc->GetNodes()[ nNodeIdx ]->GetTxtNode()) && !bHasFlysOrMarks )
[ # # ][ # # ]
[ # # ]
797 : : {
798 [ # # ][ # # ]: 0 : if( pAktNd->CanJoinNext( &pPos->nNode ))
799 : : {
800 : 0 : SwTxtNode* pNextNd = pPos->nNode.GetNode().GetTxtNode();
801 [ # # ][ # # ]: 0 : pPos->nContent.Assign( pNextNd, 0 );
802 [ # # ][ # # ]: 0 : pPam->SetMark(); pPam->DeleteMark();
803 [ # # ]: 0 : pNextNd->JoinPrev();
804 : : }
805 [ # # ]: 0 : else if( !pAktNd->GetTxt().Len() )
806 : : {
807 [ # # ]: 0 : pPos->nContent.Assign( 0, 0 );
808 [ # # ][ # # ]: 0 : pPam->SetMark(); pPam->DeleteMark();
809 [ # # ][ # # ]: 0 : pDoc->GetNodes().Delete( pPos->nNode, 1 );
810 [ # # ]: 0 : pPam->Move( fnMoveBackward );
811 : : }
812 : : }
813 : : }
814 : :
815 : : // nun noch das SplitNode vom Anfang aufheben
816 [ # # ]: 0 : else if( !IsNewDoc() )
817 : : {
818 [ # # ]: 0 : if( pPos->nContent.GetIndex() ) // dann gabs am Ende kein <P>,
819 [ # # ]: 0 : pPam->Move( fnMoveForward, fnGoNode ); // als zum naechsten Node
820 : 0 : SwTxtNode* pTxtNode = pPos->nNode.GetNode().GetTxtNode();
821 [ # # ]: 0 : SwNodeIndex aPrvIdx( pPos->nNode );
822 [ # # ][ # # ]: 0 : if( pTxtNode && pTxtNode->CanJoinPrev( &aPrvIdx ) &&
[ # # # # ]
[ # # ]
823 : 0 : *pSttNdIdx <= aPrvIdx )
824 : : {
825 : : // eigentlich muss hier ein JoinNext erfolgen, aber alle Cursor
826 : : // usw. sind im pTxtNode angemeldet, so dass der bestehen
827 : : // bleiben MUSS.
828 : :
829 : : // Absatz in Zeichen-Attribute umwandeln, aus dem Prev die
830 : : // Absatzattribute und die Vorlage uebernehmen!
831 : 0 : SwTxtNode* pPrev = aPrvIdx.GetNode().GetTxtNode();
832 [ # # ]: 0 : pTxtNode->ChgFmtColl( pPrev->GetTxtColl() );
833 [ # # ]: 0 : pTxtNode->FmtToTxtAttr( pPrev );
834 [ # # ]: 0 : pTxtNode->ResetAllAttr();
835 : :
836 [ # # ][ # # ]: 0 : if( pPrev->HasSwAttrSet() )
837 [ # # ][ # # ]: 0 : pTxtNode->SetAttr( *pPrev->GetpSwAttrSet() );
838 : :
839 [ # # ][ # # ]: 0 : if( &pPam->GetBound(sal_True).nNode.GetNode() == pPrev )
840 [ # # ][ # # ]: 0 : pPam->GetBound(sal_True).nContent.Assign( pTxtNode, 0 );
841 [ # # ][ # # ]: 0 : if( &pPam->GetBound(sal_False).nNode.GetNode() == pPrev )
842 [ # # ][ # # ]: 0 : pPam->GetBound(sal_False).nContent.Assign( pTxtNode, 0 );
843 : :
844 [ # # ]: 0 : pTxtNode->JoinPrev();
845 [ # # ]: 0 : }
846 : : }
847 : :
848 : : // und noch die DocumentInfo aufbereiten
849 [ + - ]: 2 : if( IsNewDoc() )
850 : : {
851 : 2 : SwDocShell *pDocShell(pDoc->GetDocShell());
852 : : OSL_ENSURE(pDocShell, "no SwDocShell");
853 [ + - ]: 2 : if (pDocShell) {
854 : : uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
855 [ + - ][ + - ]: 2 : pDocShell->GetModel(), uno::UNO_QUERY_THROW);
856 : : uno::Reference<document::XDocumentProperties> xDocProps(
857 [ + - ][ + - ]: 2 : xDPS->getDocumentProperties());
858 : : OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
859 [ + - ][ + - ]: 4 : if ( xDocProps.is() && (xDocProps->getAutoloadSecs() > 0) &&
[ + - ]
[ - + # # ]
[ - + ]
860 [ # # ][ # # ]: 2 : (xDocProps->getAutoloadURL().isEmpty()) )
[ - + ][ # # ]
861 : : {
862 [ # # ][ # # ]: 0 : xDocProps->setAutoloadURL(aPathToFile);
[ # # ]
863 : 2 : }
864 : : }
865 : : }
866 : :
867 [ - + ]: 2 : if( bUpdateDocStat )
868 : : {
869 [ # # ]: 0 : pDoc->UpdateDocStat();
870 : : }
871 : : }
872 : :
873 [ + - ]: 2 : if( SVPAR_PENDING != GetStatus() )
874 [ + - ][ + - ]: 2 : delete pSttNdIdx, pSttNdIdx = 0;
875 : :
876 : : // sollte der Parser der Letzte sein, der das Doc haelt, dann braucht
877 : : // man hier auch nichts mehr tun, Doc wird gleich zerstoert!
878 [ + - ][ + - ]: 2 : if( 1 < pDoc->getReferenceCount() )
879 : : {
880 [ - + ]: 2 : if( bWasUndo )
881 : : {
882 [ # # ][ # # ]: 0 : pDoc->GetIDocumentUndoRedo().DelAllUndoObj();
883 [ # # ][ # # ]: 0 : pDoc->GetIDocumentUndoRedo().DoUndo(true);
884 : : }
885 [ + - ]: 2 : else if( !pInitVSh )
886 : : {
887 : : // Wenn zu Beginn des Continue keine Shell vorhanden war,
888 : : // kann trotzdem mitlerweile eine angelegt worden sein.
889 : : // In dieses Fall stimmt das bWasUndo-Flag nicht und
890 : : // wir muessen das Undo noch anschalten.
891 [ + - ]: 2 : ViewShell *pTmpVSh = CheckActionViewShell();
892 [ - + ]: 2 : if( pTmpVSh )
893 : : {
894 [ # # ][ # # ]: 0 : pDoc->GetIDocumentUndoRedo().DoUndo(true);
895 : : }
896 : : }
897 : :
898 : 2 : pDoc->SetOle2Link( aOLELink );
899 [ - + ]: 2 : if( !bModified )
900 [ # # ]: 0 : pDoc->ResetModified();
901 [ - + ][ # # ]: 2 : if( bSetModEnabled && pDoc->GetDocShell() )
[ - + ]
902 : : {
903 [ # # ]: 0 : pDoc->GetDocShell()->EnableSetModified( sal_True );
904 : 0 : bSetModEnabled = sal_False; // this is unnecessary here
905 : : }
906 : : }
907 : :
908 : :
909 : : // Wenn die Dokuemnt-ViewShell noch existiert und eine Action
910 : : // offen ist (muss bei Abbruch nicht sein), die Action beenden,
911 : : // uns von der Shell abmelden und schliesslich die alte Shell
912 : : // wieder rekonstruieren.
913 [ + - ]: 2 : CallEndAction( sal_True );
914 : :
915 : : #ifdef DBG_UTIL
916 : : m_nContinue--;
917 : : #endif
918 : : }
919 : :
920 : 0 : void SwHTMLParser::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
921 : : {
922 [ # # ][ # # ]: 0 : switch( pOld ? pOld->Which() : pNew ? pNew->Which() : 0 )
[ # # ]
923 : : {
924 : : case RES_OBJECTDYING:
925 [ # # ]: 0 : if( ((SwPtrMsgPoolItem *)pOld)->pObject == GetRegisteredIn() )
926 : : {
927 : : // dann uns selbst beenden
928 : 0 : GetRegisteredInNonConst()->Remove( this );
929 : 0 : ReleaseRef(); // ansonsten sind wir fertig!
930 : : }
931 : 0 : break;
932 : : }
933 : 0 : }
934 : :
935 : 2 : void SwHTMLParser::DocumentDetected()
936 : : {
937 : : OSL_ENSURE( !bDocInitalized, "DocumentDetected mehrfach aufgerufen" );
938 : 2 : bDocInitalized = sal_True;
939 [ + - ]: 2 : if( IsNewDoc() )
940 : : {
941 [ + - ]: 2 : if( IsInHeader() )
942 : 2 : FinishHeader( sal_True );
943 : :
944 : 2 : CallEndAction( sal_True, sal_True );
945 : :
946 : 2 : pDoc->GetIDocumentUndoRedo().DoUndo(false);
947 : : // Durch das DocumentDetected wurde im allgemeinen eine
948 : : // ViewShell angelegt. Es kann aber auch sein, dass sie
949 : : // erst spaeter angelegt wird, naemlich dann, wenn die UI
950 : : // gecaptured ist.
951 : 2 : CallStartAction();
952 : : }
953 : 2 : }
954 : :
955 : : // is called for every token that is recognised in CallParser
956 : 58 : void SwHTMLParser::NextToken( int nToken )
957 : : {
958 [ + - ]: 116 : if( ( pDoc->GetDocShell() && pDoc->GetDocShell()->IsAbortingImport() )
[ + - - + ]
[ - + ]
959 : 58 : || 1 == pDoc->getReferenceCount() )
960 : : {
961 : : // Was the import cancelled by SFX? If a pending stack
962 : : // exists, clean it.
963 : 0 : eState = SVPAR_ERROR;
964 : : OSL_ENSURE( !pPendStack || pPendStack->nToken,
965 : : "SwHTMLParser::NextToken: Pending-Stack without token" );
966 [ # # ][ # # ]: 0 : if( 1 == pDoc->getReferenceCount() || !pPendStack )
[ # # ]
967 : 0 : return ;
968 : : }
969 : :
970 : : #if OSL_DEBUG_LEVEL > 0
971 : : if( pPendStack )
972 : : {
973 : : switch( nToken )
974 : : {
975 : : // tables are read by recursive method calls
976 : : case HTML_TABLE_ON:
977 : : // For CSS declarations we might have to wait
978 : : // for a file download to finish
979 : : case HTML_LINK:
980 : : // For controls we might have to set the size.
981 : : case HTML_INPUT:
982 : : case HTML_TEXTAREA_ON:
983 : : case HTML_SELECT_ON:
984 : : case HTML_SELECT_OFF:
985 : : break;
986 : : default:
987 : : OSL_ENSURE( !pPendStack, "Unbekanntes Token fuer Pending-Stack" );
988 : : break;
989 : : }
990 : : }
991 : : #endif
992 : :
993 : : // The following special cases have to be treated before the
994 : : // filter detection, because Netscape doesn't reference the content
995 : : // of the title for filter detection either.
996 [ + - ]: 58 : if( !pPendStack )
997 : : {
998 [ + + ]: 58 : if( bInTitle )
999 : : {
1000 [ + - - - : 2 : switch( nToken )
- ]
1001 : : {
1002 : : case HTML_TITLE_OFF:
1003 [ + - ][ - + ]: 2 : if( IsNewDoc() && sTitle.Len() )
[ - + ]
1004 : : {
1005 [ # # ]: 0 : if( pDoc->GetDocShell() ) {
1006 : : uno::Reference<document::XDocumentPropertiesSupplier>
1007 : 0 : xDPS(pDoc->GetDocShell()->GetModel(),
1008 [ # # ][ # # ]: 0 : uno::UNO_QUERY_THROW);
1009 : : uno::Reference<document::XDocumentProperties> xDocProps(
1010 [ # # ][ # # ]: 0 : xDPS->getDocumentProperties());
1011 : : OSL_ENSURE(xDocProps.is(), "no DocumentProperties");
1012 [ # # ]: 0 : if (xDocProps.is()) {
1013 [ # # ][ # # ]: 0 : xDocProps->setTitle(sTitle);
[ # # ]
1014 : : }
1015 : :
1016 [ # # ]: 0 : pDoc->GetDocShell()->SetTitle( sTitle );
1017 : : }
1018 : : }
1019 : 2 : bInTitle = sal_False;
1020 : 2 : sTitle.Erase();
1021 : 2 : break;
1022 : :
1023 : : case HTML_NONBREAKSPACE:
1024 : 0 : sTitle += ' ';
1025 : 0 : break;
1026 : :
1027 : : case HTML_SOFTHYPH:
1028 : 0 : sTitle += '-';
1029 : 0 : break;
1030 : :
1031 : : case HTML_TEXTTOKEN:
1032 : 0 : sTitle += aToken;
1033 : 0 : break;
1034 : :
1035 : : default:
1036 : 0 : sTitle += '<';
1037 [ # # ][ # # ]: 0 : if( (HTML_TOKEN_ONOFF & nToken) && (1 & nToken) )
1038 : 0 : sTitle += '/';
1039 : 0 : sTitle += sSaveToken;
1040 [ # # ]: 0 : if( aToken.Len() )
1041 : : {
1042 : 0 : sTitle += ' ';
1043 : 0 : sTitle += aToken;
1044 : : }
1045 : 0 : sTitle += '>';
1046 : 0 : break;
1047 : : }
1048 : :
1049 : 2 : return;
1050 : : }
1051 : : }
1052 : :
1053 : : // Find out what type of document it is if we don't know already.
1054 : : // For Controls this has to be finished before the control is inserted
1055 : : // because for inserting a View is needed.
1056 [ + + ]: 56 : if( !bDocInitalized )
1057 : 2 : DocumentDetected();
1058 : :
1059 : 56 : sal_Bool bGetIDOption = sal_False, bInsertUnknown = sal_False;
1060 : 56 : sal_Bool bUpperSpaceSave = bUpperSpace;
1061 : 56 : bUpperSpace = sal_False;
1062 : :
1063 : : // The following special cases may or have to be treated after the
1064 : : // filter detection
1065 [ + - ]: 56 : if( !pPendStack )
1066 : : {
1067 [ - + ]: 56 : if( bInFloatingFrame )
1068 : : {
1069 : : // <SCRIPT> is ignored here (from us), because it is ignored in
1070 : : // Applets as well
1071 [ # # ]: 0 : if( HTML_IFRAME_OFF == nToken )
1072 : : {
1073 : 0 : bCallNextToken = sal_False;
1074 : 0 : EndFloatingFrame();
1075 : : }
1076 : :
1077 : 0 : return;
1078 : : }
1079 [ - + ]: 56 : else if( bInNoEmbed )
1080 : : {
1081 [ # # # ]: 0 : switch( nToken )
1082 : : {
1083 : : case HTML_NOEMBED_OFF:
1084 [ # # ][ # # ]: 0 : aContents = convertLineEnd(aContents, GetSystemLineEnd());
1085 : 0 : InsertComment( aContents, OOO_STRING_SVTOOLS_HTML_noembed );
1086 : 0 : aContents.Erase();
1087 : 0 : bCallNextToken = sal_False;
1088 : 0 : bInNoEmbed = sal_False;
1089 : 0 : break;
1090 : :
1091 : : case HTML_RAWDATA:
1092 : 0 : InsertCommentText( OOO_STRING_SVTOOLS_HTML_noembed );
1093 : 0 : break;
1094 : :
1095 : : default:
1096 : : OSL_ENSURE( !this, "SwHTMLParser::NextToken: invalid tag" );
1097 : 0 : break;
1098 : : }
1099 : :
1100 : 0 : return;
1101 : : }
1102 [ - + ]: 56 : else if( pAppletImpl )
1103 : : {
1104 : : // in an applet only <PARAM> tags and the </APPLET> tag
1105 : : // are of interest for us (for the moment)
1106 : : // <SCRIPT> is ignored here (from Netscape)!
1107 : :
1108 [ # # # # ]: 0 : switch( nToken )
1109 : : {
1110 : : case HTML_APPLET_OFF:
1111 : 0 : bCallNextToken = sal_False;
1112 : 0 : EndApplet();
1113 : 0 : break;
1114 : : case HTML_OBJECT_OFF:
1115 : 0 : bCallNextToken = sal_False;
1116 : 0 : EndObject();
1117 : 0 : break;
1118 : :
1119 : : case HTML_PARAM:
1120 : 0 : InsertParam();
1121 : 0 : break;
1122 : : }
1123 : :
1124 : 0 : return;
1125 : : }
1126 [ - + ]: 56 : else if( bTextArea )
1127 : : {
1128 : : // in a TextArea everything up to </TEXTAREA> is inserted as text.
1129 : : // <SCRIPT> is ignored here (from Netscape)!
1130 : :
1131 [ # # ]: 0 : switch( nToken )
1132 : : {
1133 : : case HTML_TEXTAREA_OFF:
1134 : 0 : bCallNextToken = sal_False;
1135 : 0 : EndTextArea();
1136 : 0 : break;
1137 : :
1138 : : default:
1139 : 0 : InsertTextAreaText( static_cast< sal_uInt16 >(nToken) );
1140 : 0 : break;
1141 : : }
1142 : :
1143 : 0 : return;
1144 : : }
1145 [ - + ]: 56 : else if( bSelect )
1146 : : {
1147 : : // HAS to be treated after bNoScript!
1148 [ # # # # : 0 : switch( nToken )
# ]
1149 : : {
1150 : : case HTML_SELECT_OFF:
1151 : 0 : bCallNextToken = sal_False;
1152 : 0 : EndSelect();
1153 : 0 : return;
1154 : :
1155 : : case HTML_OPTION:
1156 : 0 : InsertSelectOption();
1157 : 0 : return;
1158 : :
1159 : : case HTML_TEXTTOKEN:
1160 : 0 : InsertSelectText();
1161 : 0 : return;
1162 : :
1163 : : case HTML_INPUT:
1164 : : case HTML_SCRIPT_ON:
1165 : : case HTML_SCRIPT_OFF:
1166 : : case HTML_NOSCRIPT_ON:
1167 : : case HTML_NOSCRIPT_OFF:
1168 : : case HTML_RAWDATA:
1169 : : // treat in normal switch
1170 : 0 : break;
1171 : :
1172 : : default:
1173 : : // ignore
1174 : 0 : return;
1175 : : }
1176 : : }
1177 [ - + ]: 56 : else if( pMarquee )
1178 : : {
1179 : : // in a TextArea everything up to </TEXTAREA> is inserted as text.
1180 : : // The <SCRIPT> tags are ignored from MS-IE, we ignore the whole
1181 : : // script.
1182 [ # # # ]: 0 : switch( nToken )
1183 : : {
1184 : : case HTML_MARQUEE_OFF:
1185 : 0 : bCallNextToken = sal_False;
1186 : 0 : EndMarquee();
1187 : 0 : break;
1188 : :
1189 : : case HTML_TEXTTOKEN:
1190 : 0 : InsertMarqueeText();
1191 : 0 : break;
1192 : : }
1193 : :
1194 : 0 : return;
1195 : : }
1196 [ - + ]: 56 : else if( bInField )
1197 : : {
1198 [ # # # ]: 0 : switch( nToken )
1199 : : {
1200 : : case HTML_SDFIELD_OFF:
1201 : 0 : bCallNextToken = sal_False;
1202 : 0 : EndField();
1203 : 0 : break;
1204 : :
1205 : : case HTML_TEXTTOKEN:
1206 : 0 : InsertFieldText();
1207 : 0 : break;
1208 : : }
1209 : :
1210 : 0 : return;
1211 : : }
1212 [ + - ][ - + ]: 56 : else if( bInFootEndNoteAnchor || bInFootEndNoteSymbol )
1213 : : {
1214 [ # # # ]: 0 : switch( nToken )
1215 : : {
1216 : : case HTML_ANCHOR_OFF:
1217 : 0 : EndAnchor();
1218 : 0 : bCallNextToken = sal_False;
1219 : 0 : break;
1220 : :
1221 : : case HTML_TEXTTOKEN:
1222 : 0 : InsertFootEndNoteText();
1223 : 0 : break;
1224 : : }
1225 : 0 : return;
1226 : : }
1227 [ - + ]: 56 : else if( aUnknownToken.Len() )
1228 : : {
1229 : : // Paste content of unknown tags.
1230 : : // (but surely if we are not in the header section) fdo#36080 fdo#34666
1231 [ # # ][ # # ]: 0 : if (aToken.Len() > 0 && !IsInHeader() )
[ # # ]
1232 : : {
1233 [ # # ]: 0 : if( !bDocInitalized )
1234 : 0 : DocumentDetected();
1235 : 0 : pDoc->InsertString( *pPam, aToken );
1236 : :
1237 : : // if there are temporary paragraph attributes and the
1238 : : // paragraph isn't empty then the paragraph attributes
1239 : : // are final.
1240 [ # # ]: 0 : if( !aParaAttrs.empty() )
1241 : 0 : aParaAttrs.clear();
1242 : :
1243 : 0 : SetAttr();
1244 : : }
1245 : :
1246 : : // Unknown token in the header are only closed by a matching
1247 : : // end-token, </HEAD> or <BODY>. Text inside is ignored.
1248 [ # # # # ]: 0 : switch( nToken )
1249 : : {
1250 : : case HTML_UNKNOWNCONTROL_OFF:
1251 [ # # ]: 0 : if( aUnknownToken.CompareTo(sSaveToken) != COMPARE_EQUAL )
1252 : 0 : return;
1253 : : case HTML_FRAMESET_ON:
1254 : : case HTML_HEAD_OFF:
1255 : : case HTML_BODY_ON:
1256 : : case HTML_IMAGE: // Don't know why Netscape acts this way.
1257 : 0 : aUnknownToken.Erase();
1258 : 0 : break;
1259 : : case HTML_TEXTTOKEN:
1260 : 0 : return;
1261 : : default:
1262 : 0 : aUnknownToken.Erase();
1263 : 0 : break;
1264 : : }
1265 : : }
1266 : : }
1267 : :
1268 [ + - - + : 56 : switch( nToken )
+ - - - -
- - - - -
+ - - - -
+ - - - -
- - - - -
- - - - -
- - + + -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
+ + + - -
- - - - -
- - - - -
- ]
1269 : : {
1270 : : case HTML_BODY_ON:
1271 [ - + ]: 2 : if( aStyleSource.Len() )
1272 : : {
1273 : 0 : pCSS1Parser->ParseStyleSheet( aStyleSource );
1274 : 0 : aStyleSource.Erase();
1275 : : }
1276 [ + - ]: 2 : if( IsNewDoc() )
1277 : : {
1278 : 2 : InsertBodyOptions();
1279 : : // If there is a template for the first or the right page,
1280 : : // it is set here.
1281 : 2 : const SwPageDesc *pPageDesc = 0;
1282 [ - + ]: 2 : if( pCSS1Parser->IsSetFirstPageDesc() )
1283 : 0 : pPageDesc = pCSS1Parser->GetFirstPageDesc();
1284 [ - + ]: 2 : else if( pCSS1Parser->IsSetRightPageDesc() )
1285 : 0 : pPageDesc = pCSS1Parser->GetRightPageDesc();
1286 : :
1287 [ - + ]: 2 : if( pPageDesc )
1288 : : {
1289 [ # # ]: 0 : pDoc->InsertPoolItem( *pPam, SwFmtPageDesc( pPageDesc ), 0 );
1290 : : }
1291 : : }
1292 : 2 : break;
1293 : :
1294 : : case HTML_LINK:
1295 : 0 : InsertLink();
1296 : 0 : break;
1297 : :
1298 : : case HTML_BASE:
1299 : : {
1300 : 0 : const HTMLOptions& rHTMLOptions = GetOptions();
1301 [ # # ]: 0 : for (size_t i = rHTMLOptions.size(); i; )
1302 : : {
1303 : 0 : const HTMLOption& rOption = rHTMLOptions[--i];
1304 [ # # # ]: 0 : switch( rOption.GetToken() )
1305 : : {
1306 : : case HTML_O_HREF:
1307 : 0 : sBaseURL = rOption.GetString();
1308 : 0 : break;
1309 : : case HTML_O_TARGET:
1310 [ # # ]: 0 : if( IsNewDoc() )
1311 : : {
1312 : 0 : SwDocShell *pDocShell(pDoc->GetDocShell());
1313 : : OSL_ENSURE(pDocShell, "no SwDocShell");
1314 [ # # ]: 0 : if (pDocShell) {
1315 : : uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
1316 [ # # ][ # # ]: 0 : pDocShell->GetModel(), uno::UNO_QUERY_THROW);
1317 : : uno::Reference<document::XDocumentProperties>
1318 [ # # ][ # # ]: 0 : xDocProps(xDPS->getDocumentProperties());
1319 : : OSL_ENSURE(xDocProps.is(),"no DocumentProperties");
1320 [ # # ]: 0 : if (xDocProps.is()) {
1321 [ # # ]: 0 : xDocProps->setDefaultTarget(
1322 [ # # ][ # # ]: 0 : rOption.GetString());
1323 : 0 : }
1324 : : }
1325 : : }
1326 : 0 : break;
1327 : : }
1328 : : }
1329 : : }
1330 : 0 : break;
1331 : :
1332 : : case HTML_META:
1333 : : {
1334 : 8 : SvKeyValueIterator *pHTTPHeader = 0;
1335 [ + - ]: 8 : if( IsNewDoc() )
1336 : : {
1337 : 8 : SwDocShell *pDocSh = pDoc->GetDocShell();
1338 [ + - ]: 8 : if( pDocSh )
1339 : 8 : pHTTPHeader = pDocSh->GetHeaderAttributes();
1340 : : }
1341 : 8 : SwDocShell *pDocShell(pDoc->GetDocShell());
1342 : : OSL_ENSURE(pDocShell, "no SwDocShell");
1343 [ + - ]: 8 : if (pDocShell)
1344 : : {
1345 : 8 : uno::Reference<document::XDocumentProperties> xDocProps;
1346 [ + - ]: 8 : if (IsNewDoc())
1347 : : {
1348 : : const uno::Reference<document::XDocumentPropertiesSupplier>
1349 [ + - ][ + - ]: 8 : xDPS( pDocShell->GetModel(), uno::UNO_QUERY_THROW );
1350 [ + - ][ + - ]: 8 : xDocProps = xDPS->getDocumentProperties();
[ + - ]
1351 : 8 : OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
1352 : : }
1353 [ + - ]: 8 : ParseMetaOptions( xDocProps, pHTTPHeader );
1354 : : }
1355 : : }
1356 : 8 : break;
1357 : :
1358 : : case HTML_TITLE_ON:
1359 : 2 : bInTitle = sal_True;
1360 : 2 : break;
1361 : :
1362 : : case HTML_SCRIPT_ON:
1363 : 0 : NewScript();
1364 : 0 : break;
1365 : :
1366 : : case HTML_SCRIPT_OFF:
1367 : 0 : EndScript();
1368 : 0 : break;
1369 : :
1370 : : case HTML_NOSCRIPT_ON:
1371 : : case HTML_NOSCRIPT_OFF:
1372 : 0 : bInsertUnknown = sal_True;
1373 : 0 : break;
1374 : :
1375 : : case HTML_STYLE_ON:
1376 : 0 : NewStyle();
1377 : 0 : break;
1378 : :
1379 : : case HTML_STYLE_OFF:
1380 : 0 : EndStyle();
1381 : 0 : break;
1382 : :
1383 : : case HTML_RAWDATA:
1384 [ # # ]: 0 : if( !bIgnoreRawData )
1385 : : {
1386 [ # # ]: 0 : if( IsReadScript() )
1387 : : {
1388 : 0 : AddScriptSource();
1389 : : }
1390 [ # # ]: 0 : else if( IsReadStyle() )
1391 : : {
1392 [ # # ]: 0 : if( aStyleSource.Len() )
1393 : 0 : aStyleSource += '\n';
1394 : 0 : aStyleSource += aToken;
1395 : : }
1396 : : }
1397 : 0 : break;
1398 : :
1399 : : case HTML_OBJECT_ON:
1400 : : #ifdef SOLAR_JAVA
1401 : 0 : NewObject();
1402 [ # # ][ # # ]: 0 : bCallNextToken = pAppletImpl!=0 && pTable!=0;
1403 : : #endif
1404 : 0 : break;
1405 : :
1406 : : case HTML_APPLET_ON:
1407 : : #ifdef SOLAR_JAVA
1408 : 0 : InsertApplet();
1409 [ # # ][ # # ]: 0 : bCallNextToken = pAppletImpl!=0 && pTable!=0;
1410 : : #endif
1411 : 0 : break;
1412 : :
1413 : : case HTML_IFRAME_ON:
1414 : 0 : InsertFloatingFrame();
1415 [ # # ][ # # ]: 0 : bCallNextToken = bInFloatingFrame && pTable!=0;
1416 : 0 : break;
1417 : :
1418 : : case HTML_LINEBREAK:
1419 [ + - ]: 4 : if( !IsReadPRE() )
1420 : : {
1421 : 4 : InsertLineBreak();
1422 : 4 : break;
1423 : : }
1424 : : else
1425 : 0 : bGetIDOption = sal_True;
1426 : : // <BR>s in <PRE> resemble true LFs, hence no break
1427 : :
1428 : : case HTML_NEWPARA:
1429 : : // CR in PRE/LISTING/XMP
1430 : : {
1431 [ # # # # ]: 0 : if( HTML_NEWPARA==nToken ||
[ # # ]
1432 : 0 : pPam->GetPoint()->nContent.GetIndex() )
1433 : : {
1434 : 0 : AppendTxtNode(); // there is no LF at this place
1435 : : // therefore it will cause no problems
1436 : 0 : SetTxtCollAttrs();
1437 : : }
1438 : : // progress bar
1439 [ # # ][ # # ]: 0 : if( !GetMedium() || !GetMedium()->IsRemote() )
[ # # ]
1440 : 0 : ::SetProgressState( rInput.Tell(), pDoc->GetDocShell() );
1441 : : }
1442 : 0 : break;
1443 : :
1444 : : case HTML_NONBREAKSPACE:
1445 [ # # ][ # # ]: 0 : pDoc->InsertString( *pPam, rtl::OUString(CHAR_HARDBLANK) );
[ # # ]
1446 : 0 : break;
1447 : :
1448 : : case HTML_SOFTHYPH:
1449 [ # # ][ # # ]: 0 : pDoc->InsertString( *pPam, rtl::OUString(CHAR_SOFTHYPHEN) );
[ # # ]
1450 : 0 : break;
1451 : :
1452 : : case HTML_LINEFEEDCHAR:
1453 [ # # ]: 0 : if( pPam->GetPoint()->nContent.GetIndex() )
1454 : 0 : AppendTxtNode();
1455 [ # # ][ # # ]: 0 : if( !pTable && !pDoc->IsInHeaderFooter( pPam->GetPoint()->nNode ) )
[ # # ]
1456 : : {
1457 [ # # ]: 0 : NewAttr( &aAttrTab.pBreak, SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK) );
1458 : 0 : EndAttr( aAttrTab.pBreak, 0, sal_False );
1459 : : }
1460 : 0 : break;
1461 : :
1462 : : case HTML_TEXTTOKEN:
1463 : : // insert string without spanning attributes at the end.
1464 [ + - ][ + - ]: 26 : if( aToken.Len() && ' '==aToken.GetChar(0) && !IsReadPRE() )
[ + - ][ + - ]
1465 : : {
1466 : 26 : xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex();
1467 [ + + ]: 26 : if( nPos )
1468 : : {
1469 : : const String& rText =
1470 : 2 : pPam->GetPoint()->nNode.GetNode().GetTxtNode()->GetTxt();
1471 : 2 : sal_Unicode cLast = rText.GetChar(--nPos);
1472 [ + - ][ + - ]: 2 : if( ' ' == cLast || '\x0a' == cLast)
1473 : 2 : aToken.Erase(0,1);
1474 : : }
1475 : : else
1476 : 24 : aToken.Erase(0,1);
1477 : :
1478 [ + - ]: 26 : if( !aToken.Len() )
1479 : : {
1480 : 26 : bUpperSpace = bUpperSpaceSave;
1481 : 26 : break;
1482 : : }
1483 : : }
1484 : :
1485 [ # # ]: 0 : if( aToken.Len() )
1486 : : {
1487 [ # # ]: 0 : if( !bDocInitalized )
1488 : 0 : DocumentDetected();
1489 : 0 : pDoc->InsertString( *pPam, aToken );
1490 : :
1491 : : // if there are temporary paragraph attributes and the
1492 : : // paragraph isn't empty then the paragraph attributes
1493 : : // are final.
1494 [ # # ]: 0 : if( !aParaAttrs.empty() )
1495 : 0 : aParaAttrs.clear();
1496 : :
1497 : 0 : SetAttr();
1498 : : }
1499 : 0 : break;
1500 : :
1501 : : case HTML_HORZRULE:
1502 : 0 : InsertHorzRule();
1503 : 0 : break;
1504 : :
1505 : : case HTML_IMAGE:
1506 : 0 : InsertImage();
1507 : : // if only the parser references the doc, we can break and set
1508 : : // an error code
1509 [ # # ]: 0 : if( 1 == pDoc->getReferenceCount() )
1510 : : {
1511 : 0 : eState = SVPAR_ERROR;
1512 : : }
1513 : 0 : break;
1514 : :
1515 : : case HTML_SPACER:
1516 : 0 : InsertSpacer();
1517 : 0 : break;
1518 : :
1519 : : case HTML_EMBED:
1520 : 0 : InsertEmbed();
1521 : 0 : break;
1522 : :
1523 : : case HTML_NOEMBED_ON:
1524 : 0 : bInNoEmbed = sal_True;
1525 : 0 : bCallNextToken = pTable!=0;
1526 : 0 : ReadRawData( OOO_STRING_SVTOOLS_HTML_noembed );
1527 : 0 : break;
1528 : :
1529 : : case HTML_DEFLIST_ON:
1530 [ # # ]: 0 : if( nOpenParaToken )
1531 : 0 : EndPara();
1532 : 0 : NewDefList();
1533 : 0 : break;
1534 : : case HTML_DEFLIST_OFF:
1535 [ # # ]: 0 : if( nOpenParaToken )
1536 : 0 : EndPara();
1537 : 0 : EndDefListItem( 0, sal_False, 1==nDefListDeep );
1538 : 0 : EndDefList();
1539 : 0 : break;
1540 : :
1541 : : case HTML_DD_ON:
1542 : : case HTML_DT_ON:
1543 [ # # ]: 0 : if( nOpenParaToken )
1544 : 0 : EndPara();
1545 : 0 : EndDefListItem( 0, sal_False );// close <DD>/<DT> and set no template
1546 : 0 : NewDefListItem( nToken );
1547 : 0 : break;
1548 : :
1549 : : case HTML_DD_OFF:
1550 : : case HTML_DT_OFF:
1551 : : // c.f. HTML_LI_OFF
1552 : : // Actually we should close a DD/DT now.
1553 : : // But neither Netscape nor Microsoft do this and so don't we.
1554 : 0 : EndDefListItem( nToken, sal_False );
1555 : 0 : break;
1556 : :
1557 : : // divisions
1558 : : case HTML_DIVISION_ON:
1559 : : case HTML_CENTER_ON:
1560 [ # # ]: 0 : if( nOpenParaToken )
1561 : : {
1562 [ # # ]: 0 : if( IsReadPRE() )
1563 : 0 : nOpenParaToken = 0;
1564 : : else
1565 : 0 : EndPara();
1566 : : }
1567 : 0 : NewDivision( nToken );
1568 : 0 : break;
1569 : :
1570 : : case HTML_DIVISION_OFF:
1571 : : case HTML_CENTER_OFF:
1572 [ # # ]: 0 : if( nOpenParaToken )
1573 : : {
1574 [ # # ]: 0 : if( IsReadPRE() )
1575 : 0 : nOpenParaToken = 0;
1576 : : else
1577 : 0 : EndPara();
1578 : : }
1579 : 0 : EndDivision( nToken );
1580 : 0 : break;
1581 : :
1582 : : case HTML_MULTICOL_ON:
1583 [ # # ]: 0 : if( nOpenParaToken )
1584 : 0 : EndPara();
1585 : 0 : NewMultiCol();
1586 : 0 : break;
1587 : :
1588 : : case HTML_MULTICOL_OFF:
1589 [ # # ]: 0 : if( nOpenParaToken )
1590 : 0 : EndPara();
1591 : 0 : EndTag( HTML_MULTICOL_ON );
1592 : 0 : break;
1593 : :
1594 : : case HTML_MARQUEE_ON:
1595 : 0 : NewMarquee();
1596 [ # # ][ # # ]: 0 : bCallNextToken = pMarquee!=0 && pTable!=0;
1597 : 0 : break;
1598 : :
1599 : : case HTML_FORM_ON:
1600 : 0 : NewForm();
1601 : 0 : break;
1602 : : case HTML_FORM_OFF:
1603 : 0 : EndForm();
1604 : 0 : break;
1605 : :
1606 : : // templates
1607 : : case HTML_PARABREAK_ON:
1608 [ - + ]: 2 : if( nOpenParaToken )
1609 : 0 : EndPara( sal_True );
1610 : 2 : NewPara();
1611 : 2 : break;
1612 : :
1613 : : case HTML_PARABREAK_OFF:
1614 : 2 : EndPara( sal_True );
1615 : 2 : break;
1616 : :
1617 : : case HTML_ADDRESS_ON:
1618 [ # # ]: 0 : if( nOpenParaToken )
1619 : 0 : EndPara();
1620 : 0 : NewTxtFmtColl( HTML_ADDRESS_ON, RES_POOLCOLL_SENDADRESS );
1621 : 0 : break;
1622 : :
1623 : : case HTML_ADDRESS_OFF:
1624 [ # # ]: 0 : if( nOpenParaToken )
1625 : 0 : EndPara();
1626 : 0 : EndTxtFmtColl( HTML_ADDRESS_OFF );
1627 : 0 : break;
1628 : :
1629 : : case HTML_BLOCKQUOTE_ON:
1630 : : case HTML_BLOCKQUOTE30_ON:
1631 [ # # ]: 0 : if( nOpenParaToken )
1632 : 0 : EndPara();
1633 : 0 : NewTxtFmtColl( HTML_BLOCKQUOTE_ON, RES_POOLCOLL_HTML_BLOCKQUOTE );
1634 : 0 : break;
1635 : :
1636 : : case HTML_BLOCKQUOTE_OFF:
1637 : : case HTML_BLOCKQUOTE30_OFF:
1638 [ # # ]: 0 : if( nOpenParaToken )
1639 : 0 : EndPara();
1640 : 0 : EndTxtFmtColl( HTML_BLOCKQUOTE_ON );
1641 : 0 : break;
1642 : :
1643 : : case HTML_PREFORMTXT_ON:
1644 : : case HTML_LISTING_ON:
1645 : : case HTML_XMP_ON:
1646 [ # # ]: 0 : if( nOpenParaToken )
1647 : 0 : EndPara();
1648 : 0 : NewTxtFmtColl( nToken, RES_POOLCOLL_HTML_PRE );
1649 : 0 : break;
1650 : :
1651 : : case HTML_PREFORMTXT_OFF:
1652 : 0 : bNoParSpace = sal_True; // the last PRE-paragraph gets a spacing
1653 : 0 : EndTxtFmtColl( HTML_PREFORMTXT_OFF );
1654 : 0 : break;
1655 : :
1656 : : case HTML_LISTING_OFF:
1657 : : case HTML_XMP_OFF:
1658 : 0 : EndTxtFmtColl( nToken );
1659 : 0 : break;
1660 : :
1661 : : case HTML_HEAD1_ON:
1662 : : case HTML_HEAD2_ON:
1663 : : case HTML_HEAD3_ON:
1664 : : case HTML_HEAD4_ON:
1665 : : case HTML_HEAD5_ON:
1666 : : case HTML_HEAD6_ON:
1667 [ # # ]: 0 : if( nOpenParaToken )
1668 : : {
1669 [ # # ]: 0 : if( IsReadPRE() )
1670 : 0 : nOpenParaToken = 0;
1671 : : else
1672 : 0 : EndPara();
1673 : : }
1674 : 0 : NewHeading( nToken );
1675 : 0 : break;
1676 : :
1677 : : case HTML_HEAD1_OFF:
1678 : : case HTML_HEAD2_OFF:
1679 : : case HTML_HEAD3_OFF:
1680 : : case HTML_HEAD4_OFF:
1681 : : case HTML_HEAD5_OFF:
1682 : : case HTML_HEAD6_OFF:
1683 : 0 : EndHeading();
1684 : 0 : break;
1685 : :
1686 : : case HTML_TABLE_ON:
1687 [ # # ]: 0 : if( pPendStack )
1688 : 0 : BuildTable( SVX_ADJUST_END );
1689 : : else
1690 : : {
1691 [ # # ]: 0 : if( nOpenParaToken )
1692 : 0 : EndPara();
1693 : : OSL_ENSURE( !pTable, "table in table not allowed here" );
1694 [ # # ][ # # ]: 0 : if( !pTable && (IsNewDoc() || !pPam->GetNode()->FindTableNode()) &&
[ # # # #
# # ][ # # ]
1695 : 0 : (pPam->GetPoint()->nNode.GetIndex() >
1696 : 0 : pDoc->GetNodes().GetEndOfExtras().GetIndex() ||
1697 : 0 : !pPam->GetNode()->FindFootnoteStartNode() ) )
1698 : : {
1699 [ # # ]: 0 : if ( nParaCnt < 5 )
1700 : 0 : Show(); // show what we have up to here
1701 : :
1702 : : SvxAdjust eAdjust = aAttrTab.pAdjust
1703 : 0 : ? ((const SvxAdjustItem&)aAttrTab.pAdjust->GetItem()).
1704 : : GetAdjust()
1705 [ # # ]: 0 : : SVX_ADJUST_END;
1706 : 0 : BuildTable( eAdjust );
1707 : : }
1708 : : else
1709 : 0 : bInsertUnknown = bKeepUnknown;
1710 : : }
1711 : 0 : break;
1712 : :
1713 : : // lists
1714 : : case HTML_DIRLIST_ON:
1715 : : case HTML_MENULIST_ON:
1716 : : case HTML_ORDERLIST_ON:
1717 : : case HTML_UNORDERLIST_ON:
1718 [ # # ]: 0 : if( nOpenParaToken )
1719 : 0 : EndPara();
1720 : 0 : NewNumBulList( nToken );
1721 : 0 : break;
1722 : :
1723 : : case HTML_DIRLIST_OFF:
1724 : : case HTML_MENULIST_OFF:
1725 : : case HTML_ORDERLIST_OFF:
1726 : : case HTML_UNORDERLIST_OFF:
1727 [ # # ]: 0 : if( nOpenParaToken )
1728 : 0 : EndPara();
1729 : 0 : EndNumBulListItem( 0, sal_True, GetNumInfo().GetDepth()==1 );
1730 : 0 : EndNumBulList( nToken );
1731 : 0 : break;
1732 : :
1733 : : case HTML_LI_ON:
1734 : : case HTML_LISTHEADER_ON:
1735 [ # # # # ]: 0 : if( nOpenParaToken &&
[ # # ][ # # ]
1736 : 0 : (pPam->GetPoint()->nContent.GetIndex()
1737 : : || HTML_PARABREAK_ON==nOpenParaToken) )
1738 : : {
1739 : : // only finish paragraph for <P><LI>, not for <DD><LI>
1740 : 0 : EndPara();
1741 : : }
1742 : :
1743 : 0 : EndNumBulListItem( 0, sal_False );// close <LI>/<LH> and don't set a template
1744 : 0 : NewNumBulListItem( nToken );
1745 : 0 : break;
1746 : :
1747 : : case HTML_LI_OFF:
1748 : : case HTML_LISTHEADER_OFF:
1749 : 0 : EndNumBulListItem( nToken, sal_False );
1750 : 0 : break;
1751 : :
1752 : : // Attribute :
1753 : : case HTML_ITALIC_ON:
1754 : : {
1755 [ # # ]: 0 : SvxPostureItem aPosture( ITALIC_NORMAL, RES_CHRATR_POSTURE );
1756 [ # # ]: 0 : SvxPostureItem aPostureCJK( ITALIC_NORMAL, RES_CHRATR_CJK_POSTURE );
1757 [ # # ]: 0 : SvxPostureItem aPostureCTL( ITALIC_NORMAL, RES_CHRATR_CTL_POSTURE );
1758 : : NewStdAttr( HTML_ITALIC_ON,
1759 : : &aAttrTab.pItalic, aPosture,
1760 : : &aAttrTab.pItalicCJK, &aPostureCJK,
1761 [ # # ][ # # ]: 0 : &aAttrTab.pItalicCTL, &aPostureCTL );
[ # # ][ # # ]
1762 : : }
1763 : 0 : break;
1764 : :
1765 : : case HTML_BOLD_ON:
1766 : : {
1767 [ # # ]: 0 : SvxWeightItem aWeight( WEIGHT_BOLD, RES_CHRATR_WEIGHT );
1768 [ # # ]: 0 : SvxWeightItem aWeightCJK( WEIGHT_BOLD, RES_CHRATR_CJK_WEIGHT );
1769 [ # # ]: 0 : SvxWeightItem aWeightCTL( WEIGHT_BOLD, RES_CHRATR_CTL_WEIGHT );
1770 : : NewStdAttr( HTML_BOLD_ON,
1771 : : &aAttrTab.pBold, aWeight,
1772 : : &aAttrTab.pBoldCJK, &aWeightCJK,
1773 [ # # ][ # # ]: 0 : &aAttrTab.pBoldCTL, &aWeightCTL );
[ # # ][ # # ]
1774 : : }
1775 : 0 : break;
1776 : :
1777 : :
1778 : : case HTML_STRIKE_ON:
1779 : : case HTML_STRIKETHROUGH_ON:
1780 : : {
1781 : : NewStdAttr( HTML_STRIKE_ON, &aAttrTab.pStrike,
1782 [ # # ]: 0 : SvxCrossedOutItem(STRIKEOUT_SINGLE, RES_CHRATR_CROSSEDOUT) );
1783 : : }
1784 : 0 : break;
1785 : :
1786 : : case HTML_UNDERLINE_ON:
1787 : : {
1788 : : NewStdAttr( HTML_UNDERLINE_ON, &aAttrTab.pUnderline,
1789 [ # # ]: 0 : SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE) );
1790 : : }
1791 : 0 : break;
1792 : :
1793 : : case HTML_SUPERSCRIPT_ON:
1794 : : {
1795 : : NewStdAttr( HTML_SUPERSCRIPT_ON, &aAttrTab.pEscapement,
1796 [ # # ]: 0 : SvxEscapementItem(HTML_ESC_SUPER,HTML_ESC_PROP, RES_CHRATR_ESCAPEMENT) );
1797 : : }
1798 : 0 : break;
1799 : :
1800 : : case HTML_SUBSCRIPT_ON:
1801 : : {
1802 : : NewStdAttr( HTML_SUBSCRIPT_ON, &aAttrTab.pEscapement,
1803 [ # # ]: 0 : SvxEscapementItem(HTML_ESC_SUB,HTML_ESC_PROP, RES_CHRATR_ESCAPEMENT) );
1804 : : }
1805 : 0 : break;
1806 : :
1807 : : case HTML_BLINK_ON:
1808 : : {
1809 : : NewStdAttr( HTML_BLINK_ON, &aAttrTab.pBlink,
1810 [ # # ]: 0 : SvxBlinkItem( sal_True, RES_CHRATR_BLINK ) );
1811 : : }
1812 : 0 : break;
1813 : :
1814 : : case HTML_SPAN_ON:
1815 : 0 : NewStdAttr( HTML_SPAN_ON );
1816 : 0 : break;
1817 : :
1818 : :
1819 : : case HTML_ITALIC_OFF:
1820 : : case HTML_BOLD_OFF:
1821 : : case HTML_STRIKE_OFF:
1822 : : case HTML_UNDERLINE_OFF:
1823 : : case HTML_SUPERSCRIPT_OFF:
1824 : : case HTML_SUBSCRIPT_OFF:
1825 : : case HTML_BLINK_OFF:
1826 : : case HTML_SPAN_OFF:
1827 : 0 : EndTag( nToken );
1828 : 0 : break;
1829 : :
1830 : : case HTML_STRIKETHROUGH_OFF:
1831 : 0 : EndTag( HTML_STRIKE_OFF );
1832 : 0 : break;
1833 : :
1834 : : case HTML_BASEFONT_ON:
1835 : 0 : NewBasefontAttr();
1836 : 0 : break;
1837 : : case HTML_BASEFONT_OFF:
1838 : 0 : EndBasefontAttr();
1839 : 0 : break;
1840 : : case HTML_FONT_ON:
1841 : : case HTML_BIGPRINT_ON:
1842 : : case HTML_SMALLPRINT_ON:
1843 : 0 : NewFontAttr( nToken );
1844 : 0 : break;
1845 : : case HTML_FONT_OFF:
1846 : : case HTML_BIGPRINT_OFF:
1847 : : case HTML_SMALLPRINT_OFF:
1848 : 0 : EndFontAttr( nToken );
1849 : 0 : break;
1850 : :
1851 : : case HTML_EMPHASIS_ON:
1852 : : case HTML_CITIATION_ON:
1853 : : case HTML_STRONG_ON:
1854 : : case HTML_CODE_ON:
1855 : : case HTML_SAMPLE_ON:
1856 : : case HTML_KEYBOARD_ON:
1857 : : case HTML_VARIABLE_ON:
1858 : : case HTML_DEFINSTANCE_ON:
1859 : : case HTML_SHORTQUOTE_ON:
1860 : : case HTML_LANGUAGE_ON:
1861 : : case HTML_AUTHOR_ON:
1862 : : case HTML_PERSON_ON:
1863 : : case HTML_ACRONYM_ON:
1864 : : case HTML_ABBREVIATION_ON:
1865 : : case HTML_INSERTEDTEXT_ON:
1866 : : case HTML_DELETEDTEXT_ON:
1867 : :
1868 : : case HTML_TELETYPE_ON:
1869 : 0 : NewCharFmt( nToken );
1870 : 0 : break;
1871 : :
1872 : : case HTML_SDFIELD_ON:
1873 : 0 : NewField();
1874 [ # # ][ # # ]: 0 : bCallNextToken = bInField && pTable!=0;
1875 : 0 : break;
1876 : :
1877 : : case HTML_EMPHASIS_OFF:
1878 : : case HTML_CITIATION_OFF:
1879 : : case HTML_STRONG_OFF:
1880 : : case HTML_CODE_OFF:
1881 : : case HTML_SAMPLE_OFF:
1882 : : case HTML_KEYBOARD_OFF:
1883 : : case HTML_VARIABLE_OFF:
1884 : : case HTML_DEFINSTANCE_OFF:
1885 : : case HTML_SHORTQUOTE_OFF:
1886 : : case HTML_LANGUAGE_OFF:
1887 : : case HTML_AUTHOR_OFF:
1888 : : case HTML_PERSON_OFF:
1889 : : case HTML_ACRONYM_OFF:
1890 : : case HTML_ABBREVIATION_OFF:
1891 : : case HTML_INSERTEDTEXT_OFF:
1892 : : case HTML_DELETEDTEXT_OFF:
1893 : :
1894 : : case HTML_TELETYPE_OFF:
1895 : 0 : EndTag( nToken );
1896 : 0 : break;
1897 : :
1898 : : case HTML_HEAD_OFF:
1899 [ - + ]: 2 : if( aStyleSource.Len() )
1900 : : {
1901 : 0 : pCSS1Parser->ParseStyleSheet( aStyleSource );
1902 : 0 : aStyleSource.Erase();
1903 : : }
1904 : 2 : break;
1905 : :
1906 : : case HTML_DOCTYPE:
1907 : : case HTML_BODY_OFF:
1908 : : case HTML_HTML_OFF:
1909 : : case HTML_HEAD_ON:
1910 : : case HTML_TITLE_OFF:
1911 : 6 : break; // don't evaluate further???
1912 : : case HTML_HTML_ON:
1913 : : {
1914 : 2 : const HTMLOptions& rHTMLOptions = GetOptions();
1915 [ - + ]: 2 : for (size_t i = rHTMLOptions.size(); i; )
1916 : : {
1917 : 0 : const HTMLOption& rOption = rHTMLOptions[--i];
1918 [ # # ]: 0 : if( HTML_O_DIR == rOption.GetToken() )
1919 : : {
1920 : 0 : const String& rDir = rOption.GetString();
1921 : 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(),
1922 [ # # # # ]: 0 : pCSS1Parser->GetWhichMap() );
1923 [ # # ]: 0 : SvxCSS1PropertyInfo aPropInfo;
1924 [ # # ]: 0 : String aDummy;
1925 : : ParseStyleOptions( aDummy, aDummy, aDummy, aItemSet,
1926 [ # # ]: 0 : aPropInfo, 0, &rDir );
1927 : :
1928 [ # # ]: 0 : pCSS1Parser->SetPageDescAttrs( 0, &aItemSet );
1929 [ # # ][ # # ]: 0 : break;
[ # # ]
1930 : : }
1931 : : }
1932 : : }
1933 : 2 : break;
1934 : :
1935 : : case HTML_INPUT:
1936 : 0 : InsertInput();
1937 : 0 : break;
1938 : :
1939 : : case HTML_TEXTAREA_ON:
1940 : 0 : NewTextArea();
1941 [ # # ][ # # ]: 0 : bCallNextToken = bTextArea && pTable!=0;
1942 : 0 : break;
1943 : :
1944 : : case HTML_SELECT_ON:
1945 : 0 : NewSelect();
1946 [ # # ][ # # ]: 0 : bCallNextToken = bSelect && pTable!=0;
1947 : 0 : break;
1948 : :
1949 : : case HTML_ANCHOR_ON:
1950 : 0 : NewAnchor();
1951 : 0 : break;
1952 : :
1953 : : case HTML_ANCHOR_OFF:
1954 : 0 : EndAnchor();
1955 : 0 : break;
1956 : :
1957 : : case HTML_COMMENT:
1958 [ # # ][ # # ]: 0 : if( ( aToken.Len() > 5 ) && ( ! bIgnoreHTMLComments ) )
[ # # ]
1959 : : {
1960 : : // insert as Post-It
1961 : : // If there are no space characters right behind
1962 : : // the <!-- and on front of the -->, leave the comment untouched.
1963 [ # # # # ]: 0 : if( ' ' == aToken.GetChar( 3 ) &&
[ # # ]
1964 : 0 : ' ' == aToken.GetChar( aToken.Len()-3 ) )
1965 : : {
1966 [ # # ]: 0 : String aComment( aToken.Copy( 3, aToken.Len()-5 ) );
1967 [ # # ][ # # ]: 0 : InsertComment(comphelper::string::strip(aComment, ' '));
[ # # ][ # # ]
[ # # ][ # # ]
1968 : : }
1969 : : else
1970 : : {
1971 : 0 : rtl::OUStringBuffer aComment;
1972 [ # # ][ # # ]: 0 : aComment.append('<').append(aToken).append('>');
[ # # ][ # # ]
1973 [ # # ][ # # ]: 0 : InsertComment( aComment.makeStringAndClear() );
[ # # ][ # # ]
1974 : : }
1975 : : }
1976 : 0 : break;
1977 : :
1978 : : case HTML_MAP_ON:
1979 : : // Image Maps are read asynchronously: At first only an image map is created
1980 : : // Areas are processed later. Nevertheless the
1981 : : // ImageMap is inserted into the IMap-Array, because it might be used
1982 : : // already.
1983 [ # # ]: 0 : pImageMap = new ImageMap;
1984 [ # # ]: 0 : if( ParseMapOptions( pImageMap) )
1985 : : {
1986 [ # # ]: 0 : if( !pImageMaps )
1987 [ # # ]: 0 : pImageMaps = new ImageMaps;
1988 : 0 : pImageMaps->push_back( pImageMap );
1989 : : }
1990 : : else
1991 : : {
1992 [ # # ]: 0 : delete pImageMap;
1993 : 0 : pImageMap = 0;
1994 : : }
1995 : 0 : break;
1996 : :
1997 : : case HTML_MAP_OFF:
1998 : : // there is no ImageMap anymore (don't delete IMap, because it's
1999 : : // already contained in the array!)
2000 : 0 : pImageMap = 0;
2001 : 0 : break;
2002 : :
2003 : : case HTML_AREA:
2004 [ # # ]: 0 : if( pImageMap )
2005 : : ParseAreaOptions( pImageMap, sBaseURL, SFX_EVENT_MOUSEOVER_OBJECT,
2006 : 0 : SFX_EVENT_MOUSEOUT_OBJECT );
2007 : 0 : break;
2008 : :
2009 : : case HTML_FRAMESET_ON:
2010 : 0 : bInsertUnknown = bKeepUnknown;
2011 : 0 : break;
2012 : :
2013 : : case HTML_NOFRAMES_ON:
2014 [ # # ]: 0 : if( IsInHeader() )
2015 : 0 : FinishHeader( sal_True );
2016 : 0 : bInsertUnknown = bKeepUnknown;
2017 : 0 : break;
2018 : :
2019 : : case HTML_UNKNOWNCONTROL_ON:
2020 : : // Ignore content of unknown token in the header, if the token
2021 : : // does not start with a '!'.
2022 : : // (but judging from the code, also if does not start with a '%')
2023 : : // (and also if we're not somewhere we consider PRE)
2024 [ # # ][ # # ]: 0 : if( IsInHeader() && !IsReadPRE() && !aUnknownToken.Len() &&
[ # # # #
# # # # ]
[ # # ]
2025 : 0 : sSaveToken.Len() && '!' != sSaveToken.GetChar(0) &&
2026 : 0 : '%' != sSaveToken.GetChar(0) )
2027 : 0 : aUnknownToken = sSaveToken;
2028 : : // no break
2029 : :
2030 : : default:
2031 : 0 : bInsertUnknown = bKeepUnknown;
2032 : 0 : break;
2033 : : }
2034 : :
2035 [ - + ]: 56 : if( bGetIDOption )
2036 : 0 : InsertIDOption();
2037 : :
2038 [ - + ]: 56 : if( bInsertUnknown )
2039 : : {
2040 [ # # ]: 0 : String aComment(rtl::OUString("HTML: <"));
2041 [ # # ][ # # ]: 0 : if( (HTML_TOKEN_ONOFF & nToken) != 0 && (1 & nToken) != 0 )
2042 [ # # ]: 0 : aComment += '/';
2043 [ # # ]: 0 : aComment += sSaveToken;
2044 [ # # ]: 0 : if( aToken.Len() )
2045 : : {
2046 [ # # ]: 0 : UnescapeToken();
2047 [ # # ][ # # ]: 0 : (aComment += ' ') += aToken;
2048 : : }
2049 [ # # ]: 0 : aComment += '>';
2050 [ # # ][ # # ]: 0 : InsertComment( aComment );
2051 : : }
2052 : :
2053 : : // if there are temporary paragraph attributes and the
2054 : : // paragraph isn't empty then the paragraph attributes are final.
2055 [ - + ][ # # ]: 56 : if( !aParaAttrs.empty() && pPam->GetPoint()->nContent.GetIndex() )
[ - + ]
2056 : 58 : aParaAttrs.clear();
2057 : : }
2058 : :
2059 : :
2060 : : extern sal_Bool lcl_css1atr_equalFontItems( const SfxPoolItem& r1, const SfxPoolItem& r2 );
2061 : :
2062 : 0 : void lcl_swhtml_getItemInfo( const _HTMLAttr& rAttr,
2063 : : sal_Bool& rScriptDependent, sal_Bool& rFont,
2064 : : sal_uInt16& rScriptType )
2065 : : {
2066 : 0 : sal_uInt16 nWhich = rAttr.GetItem().Which();
2067 [ # # # # : 0 : switch( nWhich )
# # # ]
2068 : : {
2069 : : case RES_CHRATR_FONT:
2070 : 0 : rFont = sal_True;
2071 : : case RES_CHRATR_FONTSIZE:
2072 : : case RES_CHRATR_LANGUAGE:
2073 : : case RES_CHRATR_POSTURE:
2074 : : case RES_CHRATR_WEIGHT:
2075 : 0 : rScriptType = i18n::ScriptType::LATIN;
2076 : 0 : rScriptDependent = sal_True;
2077 : 0 : break;
2078 : : case RES_CHRATR_CJK_FONT:
2079 : 0 : rFont = sal_True;
2080 : : case RES_CHRATR_CJK_FONTSIZE:
2081 : : case RES_CHRATR_CJK_LANGUAGE:
2082 : : case RES_CHRATR_CJK_POSTURE:
2083 : : case RES_CHRATR_CJK_WEIGHT:
2084 : 0 : rScriptType = i18n::ScriptType::ASIAN;
2085 : 0 : rScriptDependent = sal_True;
2086 : 0 : break;
2087 : : case RES_CHRATR_CTL_FONT:
2088 : 0 : rFont = sal_True;
2089 : : case RES_CHRATR_CTL_FONTSIZE:
2090 : : case RES_CHRATR_CTL_LANGUAGE:
2091 : : case RES_CHRATR_CTL_POSTURE:
2092 : : case RES_CHRATR_CTL_WEIGHT:
2093 : 0 : rScriptType = i18n::ScriptType::COMPLEX;
2094 : 0 : rScriptDependent = sal_True;
2095 : 0 : break;
2096 : : default:
2097 : 0 : rScriptDependent = sal_False;
2098 : 0 : rFont = sal_False;
2099 : 0 : break;
2100 : : }
2101 : 0 : }
2102 : :
2103 : 2 : sal_Bool SwHTMLParser::AppendTxtNode( SwHTMLAppendMode eMode, sal_Bool bUpdateNum )
2104 : : {
2105 : : // Ein harter Zeilen-Umbruch am Ende muss immer entfernt werden.
2106 : : // Einen zweiten ersetzen wir durch einen Absatz-Abstand.
2107 [ + - ]: 2 : xub_StrLen nLFStripped = StripTrailingLF();
2108 [ + - ][ - + ]: 2 : if( (AM_NOSPACE==eMode || AM_SOFTNOSPACE==eMode) && nLFStripped > 1 )
[ # # ]
2109 : 0 : eMode = AM_SPACE;
2110 : :
2111 : : // die harten Attribute an diesem Absatz werden nie mehr ungueltig
2112 [ - + ]: 2 : if( !aParaAttrs.empty() )
2113 : 0 : aParaAttrs.clear();
2114 : :
2115 [ - + ][ # # ]: 2 : if( AM_SPACE==eMode || AM_NOSPACE==eMode )
2116 : : {
2117 : : SwTxtNode *pTxtNode =
2118 : 2 : pPam->GetPoint()->nNode.GetNode().GetTxtNode();
2119 : :
2120 : : const SvxULSpaceItem& rULSpace =
2121 [ + - ]: 2 : (const SvxULSpaceItem&)pTxtNode->SwCntntNode::GetAttr( RES_UL_SPACE );
2122 : :
2123 : 0 : sal_Bool bChange = AM_NOSPACE==eMode ? rULSpace.GetLower() > 0
2124 [ - + ]: 2 : : rULSpace.GetLower() == 0;
2125 : :
2126 [ - + ]: 2 : if( bChange )
2127 : : {
2128 : : const SvxULSpaceItem& rCollULSpace =
2129 [ # # ]: 0 : pTxtNode->GetAnyFmtColl().GetULSpace();
2130 : :
2131 : 0 : sal_Bool bMayReset = AM_NOSPACE==eMode ? rCollULSpace.GetLower() == 0
2132 [ # # ]: 0 : : rCollULSpace.GetLower() > 0;
2133 : :
2134 [ # # # # ]: 0 : if( bMayReset &&
[ # # ]
2135 : 0 : rCollULSpace.GetUpper() == rULSpace.GetUpper() )
2136 : : {
2137 [ # # ]: 0 : pTxtNode->ResetAttr( RES_UL_SPACE );
2138 : : }
2139 : : else
2140 : : {
2141 : : pTxtNode->SetAttr(
2142 : 0 : SvxULSpaceItem( rULSpace.GetUpper(),
2143 [ # # ][ # # ]: 0 : AM_NOSPACE==eMode ? 0 : HTML_PARSPACE, RES_UL_SPACE ) );
[ # # ][ # # ]
2144 : : }
2145 : : }
2146 : : }
2147 [ + - ][ - + ]: 2 : bNoParSpace = AM_NOSPACE==eMode || AM_SOFTNOSPACE==eMode;
2148 : :
2149 [ + - ]: 2 : SwPosition aOldPos( *pPam->GetPoint() );
2150 : :
2151 [ + - ]: 2 : sal_Bool bRet = pDoc->AppendTxtNode( *pPam->GetPoint() );
2152 : :
2153 : : // Zeichen-Attribute aufspalten und ggf keine setzen, die ueber den
2154 : : // ganzen Absatz gesetzt sind
2155 : 2 : const SwNodeIndex& rEndIdx = aOldPos.nNode;
2156 : 2 : xub_StrLen nEndCnt = aOldPos.nContent.GetIndex();
2157 : 2 : const SwPosition& rPos = *pPam->GetPoint();
2158 : :
2159 : 2 : _HTMLAttr** pTbl = (_HTMLAttr**)&aAttrTab;
2160 [ + + ]: 80 : for( sal_uInt16 nCnt = sizeof( _HTMLAttrTable ) / sizeof( _HTMLAttr* );
2161 : : nCnt--; ++pTbl )
2162 : : {
2163 : 78 : _HTMLAttr *pAttr = *pTbl;
2164 [ - + ][ # # ]: 78 : if( pAttr && pAttr->GetItem().Which() < RES_PARATR_BEGIN )
[ - + ]
2165 : : {
2166 : 0 : sal_Bool bWholePara = sal_False;
2167 : :
2168 [ # # ]: 0 : while( pAttr )
2169 : : {
2170 : 0 : _HTMLAttr *pNext = pAttr->GetNext();
2171 [ # # # # : 0 : if( pAttr->GetSttParaIdx() < rEndIdx.GetIndex() ||
# # ][ # # ]
[ # # ]
2172 : : (!bWholePara &&
2173 : 0 : pAttr->GetSttPara() == rEndIdx &&
2174 : 0 : pAttr->GetSttCnt() != nEndCnt) )
2175 : : {
2176 : : bWholePara =
2177 : 0 : pAttr->GetSttPara() == rEndIdx &&
2178 [ # # ][ # # ]: 0 : pAttr->GetSttCnt() == 0;
2179 : :
2180 : 0 : xub_StrLen nStt = pAttr->nSttCntnt;
2181 : 0 : sal_Bool bScript = sal_False, bFont = sal_False;
2182 : : sal_uInt16 nScriptItem;
2183 : 0 : sal_Bool bInsert = sal_True;
2184 : : lcl_swhtml_getItemInfo( *pAttr, bScript, bFont,
2185 : 0 : nScriptItem );
2186 : : // den besehrigen Teil setzen
2187 [ # # ][ # # ]: 0 : if( bInsert && bScript )
2188 : : {
2189 : : const SwTxtNode *pTxtNd =
2190 : 0 : pAttr->GetSttPara().GetNode().GetTxtNode();
2191 : : OSL_ENSURE( pTxtNd, "No text node" );
2192 [ # # ]: 0 : if( pTxtNd )
2193 : : {
2194 : 0 : const String& rText = pTxtNd->GetTxt();
2195 : : sal_uInt16 nScriptTxt =
2196 [ # # ][ # # ]: 0 : pBreakIt->GetBreakIter()->getScriptType(
2197 [ # # ][ # # ]: 0 : rText, pAttr->GetSttCnt() );
2198 : : xub_StrLen nScriptEnd = (xub_StrLen)pBreakIt->GetBreakIter()
2199 [ # # ][ # # ]: 0 : ->endOfScript( rText, nStt, nScriptTxt );
[ # # ][ # # ]
2200 [ # # ]: 0 : while( nScriptEnd < nEndCnt )
2201 : : {
2202 [ # # ]: 0 : if( nScriptItem == nScriptTxt )
2203 : : {
2204 : : _HTMLAttr *pSetAttr =
2205 [ # # ]: 0 : pAttr->Clone( rEndIdx, nScriptEnd );
2206 : 0 : pSetAttr->nSttCntnt = nStt;
2207 : 0 : pSetAttr->ClearPrev();
2208 [ # # ][ # # ]: 0 : if( !pNext || bWholePara )
2209 : : {
2210 [ # # ]: 0 : if (pSetAttr->bInsAtStart)
2211 [ # # ]: 0 : aSetAttrTab.push_front( pSetAttr );
2212 : : else
2213 [ # # ]: 0 : aSetAttrTab.push_back( pSetAttr );
2214 : : }
2215 : : else
2216 : 0 : pNext->InsertPrev( pSetAttr );
2217 : : }
2218 : 0 : nStt = nScriptEnd;
2219 [ # # ][ # # ]: 0 : nScriptTxt = pBreakIt->GetBreakIter()->getScriptType(
2220 [ # # ][ # # ]: 0 : rText, nStt );
2221 : : nScriptEnd = (xub_StrLen)pBreakIt->GetBreakIter()
2222 [ # # ][ # # ]: 0 : ->endOfScript( rText, nStt, nScriptTxt );
[ # # ][ # # ]
2223 : : }
2224 : 0 : bInsert = nScriptItem == nScriptTxt;
2225 : : }
2226 : : }
2227 [ # # ]: 0 : if( bInsert )
2228 : : {
2229 : : _HTMLAttr *pSetAttr =
2230 [ # # ]: 0 : pAttr->Clone( rEndIdx, nEndCnt );
2231 : 0 : pSetAttr->nSttCntnt = nStt;
2232 : :
2233 : : // Wenn das Attribut den gesamten Absatz umspannt, werden
2234 : : // alle auesseren Attribute nicht mehr beachtet. Deshalb
2235 : : // darf es auch nicht in die Prev-Liste eines ausseren
2236 : : // Attributs eingetragen werden, denn dieses wird ja
2237 : : // erstmal nicht gesetzt. Das fuehrt zu verschiebenungen,
2238 : : // wenn Felder ins Rennen kommen
2239 [ # # ][ # # ]: 0 : if( !pNext || bWholePara )
2240 : : {
2241 [ # # ]: 0 : if (pSetAttr->bInsAtStart)
2242 [ # # ]: 0 : aSetAttrTab.push_front( pSetAttr );
2243 : : else
2244 [ # # ]: 0 : aSetAttrTab.push_back( pSetAttr );
2245 : : }
2246 : : else
2247 : 0 : pNext->InsertPrev( pSetAttr );
2248 : : }
2249 : : else
2250 : : {
2251 : 0 : _HTMLAttr *pPrev = pAttr->GetPrev();
2252 [ # # ]: 0 : if( pPrev )
2253 : : {
2254 : : // Die Previous-Attribute muessen trotzdem gesetzt werden.
2255 [ # # ][ # # ]: 0 : if( !pNext || bWholePara )
2256 : : {
2257 [ # # ]: 0 : if (pPrev->bInsAtStart)
2258 [ # # ]: 0 : aSetAttrTab.push_front( pPrev );
2259 : : else
2260 [ # # ]: 0 : aSetAttrTab.push_back( pPrev );
2261 : : }
2262 : : else
2263 : 0 : pNext->InsertPrev( pPrev );
2264 : : }
2265 : : }
2266 : 0 : pAttr->ClearPrev();
2267 : : }
2268 : :
2269 [ # # ]: 0 : pAttr->SetStart( rPos );
2270 : 0 : pAttr = pNext;
2271 : : }
2272 : : }
2273 : : }
2274 : :
2275 [ + - ]: 2 : if( bUpdateNum )
2276 : : {
2277 [ - + ]: 2 : if( GetNumInfo().GetDepth() )
2278 : : {
2279 : 0 : sal_uInt8 nLvl = GetNumInfo().GetLevel();
2280 [ # # ]: 0 : SetNodeNum( nLvl, false );
2281 : : }
2282 : : else
2283 [ + - ]: 2 : pPam->GetNode()->GetTxtNode()->ResetAttr( RES_PARATR_NUMRULE );
2284 : : }
2285 : :
2286 : : // Attrubute im Absatz davor sollte man jetzt setzen (wegen JavaScript)
2287 [ + - ]: 2 : SetAttr();
2288 : :
2289 : : // Now it is time to get rid of all script dependent hints that are
2290 : : // equal to the settings in the style
2291 : 2 : SwTxtNode *pTxtNd = rEndIdx.GetNode().GetTxtNode();
2292 : : OSL_ENSURE( pTxtNd, "There is the txt node" );
2293 : 2 : sal_uInt16 nCntAttr = (pTxtNd && pTxtNd->GetpSwpHints())
2294 [ + - - + ]: 4 : ? pTxtNd->GetSwpHints().Count() : 0;
2295 [ - + ]: 2 : if( nCntAttr )
2296 : : {
2297 : : // These are the end position of all script depenent hints.
2298 : : // If we find a hint that starts before the current end position,
2299 : : // we have to set it. If we find a hint that start behind or at
2300 : : // that position, we have to take the hint's value into account.
2301 : : // If it is equal to the style, or in fact the paragarph's value
2302 : : // for that hint, the hint is removed. Otherwise it's end position
2303 : : // is remembered.
2304 : : xub_StrLen aEndPos[15] =
2305 : 0 : { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2306 : 0 : SwpHints& rHints = pTxtNd->GetSwpHints();
2307 [ # # ]: 0 : for( sal_uInt16 i=0; i < nCntAttr; i++ )
2308 : : {
2309 [ # # ]: 0 : SwTxtAttr *pHt = rHints.GetTextHint( i );
2310 [ # # ]: 0 : sal_uInt16 nWhich = pHt->Which();
2311 : 0 : sal_Int16 nIdx = -1;
2312 : : //In 'hintids.hxx', the following five attributes don't follow
2313 : : //each other in the Latin attributes as they do among CJK and
2314 : : //CTL attributes, so the old code just made a mess, IMHO.
2315 : : //E.g. 29-22=7, which should be LANGUAGE, but it's FONT.
2316 : : //Moreover, it should occur between 0 and 4.
2317 : : //Since it would be too risky to change the attribute codes,
2318 : : //I repaired the following source code the 'brute force' way.
2319 : :
2320 : : //Old code:
2321 : : /*
2322 : : if( RES_CHRATR_CJK_FONT <= nWhich &&
2323 : : nWhich <= RES_CHRATR_CTL_WEIGHT )
2324 : : {
2325 : : nIdx = static_cast< sal_uInt16 >(nWhich - RES_CHRATR_CJK_FONT + 5);
2326 : : }
2327 : : else switch...
2328 : : */
2329 : :
2330 [ # # ][ # # ]: 0 : if( RES_CHRATR_CJK_FONT == nWhich || RES_CHRATR_CTL_FONT == nWhich )
2331 : : {
2332 : 0 : nIdx = static_cast< sal_uInt16 >(0);
2333 : : }
2334 [ # # ][ # # ]: 0 : else if( RES_CHRATR_CJK_FONTSIZE == nWhich || RES_CHRATR_CTL_FONTSIZE == nWhich )
2335 : : {
2336 : 0 : nIdx = static_cast< sal_uInt16 >(1);
2337 : : }
2338 [ # # ][ # # ]: 0 : else if( RES_CHRATR_CJK_LANGUAGE == nWhich || RES_CHRATR_CTL_LANGUAGE == nWhich )
2339 : : {
2340 : 0 : nIdx = static_cast< sal_uInt16 >(2);
2341 : : }
2342 [ # # ][ # # ]: 0 : else if( RES_CHRATR_CJK_POSTURE == nWhich || RES_CHRATR_CTL_POSTURE == nWhich )
2343 : : {
2344 : 0 : nIdx = static_cast< sal_uInt16 >(3);
2345 : : }
2346 [ # # ][ # # ]: 0 : else if( RES_CHRATR_CJK_WEIGHT == nWhich || RES_CHRATR_CTL_WEIGHT == nWhich )
2347 : : {
2348 : 0 : nIdx = static_cast< sal_uInt16 >(4);
2349 : : }
2350 [ # # # # : 0 : else switch( nWhich )
# # ]
2351 : : {
2352 : 0 : case RES_CHRATR_FONT: nIdx = 0; break;
2353 : 0 : case RES_CHRATR_FONTSIZE: nIdx = 1; break;
2354 : 0 : case RES_CHRATR_LANGUAGE: nIdx = 2; break;
2355 : 0 : case RES_CHRATR_POSTURE: nIdx = 3; break;
2356 : 0 : case RES_CHRATR_WEIGHT: nIdx = 4; break;
2357 : : }
2358 [ # # ]: 0 : if( nIdx != -1 )
2359 : : {
2360 : 0 : xub_StrLen nStt = *pHt->GetStart();
2361 [ # # ]: 0 : if( nStt >= aEndPos[nIdx] )
2362 : : {
2363 : 0 : sal_Bool bFont = (nIdx % 5) == 0;
2364 : : const SfxPoolItem& rItem =
2365 [ # # ]: 0 : ((const SwCntntNode *)pTxtNd)->GetAttr( nWhich );
2366 [ # # ][ # # ]: 0 : if( bFont ? lcl_css1atr_equalFontItems(rItem,pHt->GetAttr())
2367 [ # # ][ # # ]: 0 : : rItem == pHt->GetAttr() )
2368 : : {
2369 : : // The hint is the same as set in the paragraph and
2370 : : // therefore, it can be deleted
2371 : : // CAUTION!!! This WILL delete the hint and it MAY
2372 : : // also delete the SwpHints!!! To avoid any trouble
2373 : : // we leave the loop immediately if this is the last
2374 : : // hint.
2375 [ # # ]: 0 : pTxtNd->DeleteAttribute( pHt );
2376 [ # # ]: 0 : if( 1 == nCntAttr )
2377 : 0 : break;
2378 : 0 : i--;
2379 : 0 : nCntAttr--;
2380 : : }
2381 : : else
2382 : : {
2383 : : // The hint is different. Therefore all hints within that
2384 : : // hint have to be ignored.
2385 [ # # ][ # # ]: 0 : aEndPos[nIdx] = pHt->GetEnd() ? *pHt->GetEnd() : nStt;
[ # # ]
2386 : : }
2387 : : }
2388 : : else
2389 : : {
2390 : : // The hint starts before another one ends.
2391 : : // The hint in this case is not deleted
2392 : : OSL_ENSURE( pHt->GetEnd() && *pHt->GetEnd() <= aEndPos[nIdx],
2393 : : "hints aren't nested properly!" );
2394 : : }
2395 : : }
2396 : : }
2397 : : }
2398 : :
2399 : :
2400 [ + - ][ - + ]: 2 : if( !pTable && !--nParaCnt )
[ - + ]
2401 [ # # ]: 0 : Show();
2402 : :
2403 [ + - ]: 2 : return bRet;
2404 : : }
2405 : :
2406 : 2 : void SwHTMLParser::AddParSpace()
2407 : : {
2408 : : //If it already has ParSpace, return
2409 [ - + ]: 2 : if( !bNoParSpace )
2410 : : return;
2411 : :
2412 : 0 : bNoParSpace = sal_False;
2413 : :
2414 : 0 : sal_uLong nNdIdx = pPam->GetPoint()->nNode.GetIndex() - 1;
2415 : :
2416 [ # # ][ # # ]: 0 : SwTxtNode *pTxtNode = pDoc->GetNodes()[nNdIdx]->GetTxtNode();
2417 [ # # ]: 0 : if( !pTxtNode )
2418 : : return;
2419 : :
2420 : : SvxULSpaceItem rULSpace =
2421 [ # # ][ # # ]: 0 : (const SvxULSpaceItem&)pTxtNode->SwCntntNode::GetAttr( RES_UL_SPACE );
2422 [ # # ]: 0 : if( !rULSpace.GetLower() )
2423 : : {
2424 : : const SvxULSpaceItem& rCollULSpace =
2425 [ # # ]: 0 : pTxtNode->GetAnyFmtColl().GetULSpace();
2426 [ # # # # ]: 0 : if( rCollULSpace.GetLower() &&
[ # # ]
2427 : 0 : rCollULSpace.GetUpper() == rULSpace.GetUpper() )
2428 : : {
2429 [ # # ]: 0 : pTxtNode->ResetAttr( RES_UL_SPACE );
2430 : : }
2431 : : else
2432 : : {
2433 : : //What I do here, is that I examine the attributes, and if
2434 : : //I find out, that it's CJK/CTL, then I set the paragraph space
2435 : : //to the value set in HTML_CJK_PARSPACE/HTML_CTL_PARSPACE.
2436 : :
2437 : 0 : sal_Bool bIsCJK = false;
2438 : 0 : sal_Bool bIsCTL = false;
2439 : 0 : SwpHints& rHints = pTxtNode->GetSwpHints();
2440 : : sal_uInt16 nWhich;
2441 : : SwTxtAttr *pHt;
2442 : :
2443 : 0 : sal_uInt16 nCntAttr = (pTxtNode && pTxtNode->GetpSwpHints())
2444 [ # # # # ]: 0 : ? pTxtNode->GetSwpHints().Count() : 0;
2445 : :
2446 [ # # ][ # # ]: 0 : for(sal_uInt16 i = 0; (i < nCntAttr) && !bIsCJK; ++i)
[ # # ]
2447 : : {
2448 [ # # ]: 0 : pHt = rHints.GetTextHint(i);
2449 [ # # ]: 0 : nWhich = pHt->Which();
2450 [ # # ][ # # ]: 0 : if( RES_CHRATR_CJK_FONT == nWhich ||
[ # # ][ # # ]
[ # # ]
2451 : : RES_CHRATR_CJK_FONTSIZE == nWhich ||
2452 : : RES_CHRATR_CJK_LANGUAGE == nWhich ||
2453 : : RES_CHRATR_CJK_POSTURE == nWhich ||
2454 : : RES_CHRATR_CJK_WEIGHT == nWhich )
2455 : 0 : bIsCJK = true;
2456 [ # # ][ # # ]: 0 : if( RES_CHRATR_CTL_FONT == nWhich ||
[ # # ][ # # ]
[ # # ]
2457 : : RES_CHRATR_CTL_FONTSIZE == nWhich ||
2458 : : RES_CHRATR_CTL_LANGUAGE == nWhich ||
2459 : : RES_CHRATR_CTL_POSTURE == nWhich ||
2460 : : RES_CHRATR_CTL_WEIGHT == nWhich )
2461 : 0 : bIsCJK = false;
2462 : : }
2463 : :
2464 [ # # ]: 0 : if( bIsCTL )
2465 : : {
2466 : : pTxtNode->SetAttr(
2467 [ # # ][ # # ]: 0 : SvxULSpaceItem( rULSpace.GetUpper(), HTML_CTL_PARSPACE, RES_UL_SPACE ) );
[ # # ]
2468 : : }
2469 [ # # ]: 0 : else if( bIsCJK )
2470 : : {
2471 : : pTxtNode->SetAttr(
2472 [ # # ][ # # ]: 0 : SvxULSpaceItem( rULSpace.GetUpper(), HTML_CJK_PARSPACE, RES_UL_SPACE ) );
[ # # ]
2473 : : } else {
2474 : : pTxtNode->SetAttr(
2475 [ # # ][ # # ]: 0 : SvxULSpaceItem( rULSpace.GetUpper(), HTML_PARSPACE, RES_UL_SPACE ) );
[ # # ]
2476 : : }
2477 : : }
2478 [ # # ]: 2 : }
2479 : : }
2480 : :
2481 : :
2482 : 0 : void SwHTMLParser::Show()
2483 : : {
2484 : : // Hier wird
2485 : : // - ein EndAction gerufen, damit formatiert wird
2486 : : // - ein Reschedule gerufen,
2487 : : // - die eiegen View-Shell wieder gesetzt
2488 : : // - und Start-Action gerufen
2489 : :
2490 : : OSL_ENSURE( SVPAR_WORKING==eState, "Show nicht im Working-State - Das kann ins Auge gehen" );
2491 : 0 : ViewShell *pOldVSh = CallEndAction();
2492 : :
2493 : 0 : GetpApp()->Reschedule();
2494 : :
2495 [ # # # # ]: 0 : if( ( pDoc->GetDocShell() && pDoc->GetDocShell()->IsAbortingImport() )
[ # # ][ # # ]
2496 : 0 : || 1 == pDoc->getReferenceCount() )
2497 : : {
2498 : : // wurde der Import vom SFX abgebrochen?
2499 : 0 : eState = SVPAR_ERROR;
2500 : : }
2501 : :
2502 : : // Die ViewShell nochmal holen, denn sie koennte im Reschedule
2503 : : // zerstoert wirden sein.
2504 : 0 : ViewShell *pVSh = CallStartAction( pOldVSh );
2505 : :
2506 : : // ist der aktuelle Node nicht mehr sichtbar, dann benutzen wir
2507 : : // eine groessere Schrittweite
2508 [ # # ]: 0 : if( pVSh )
2509 : : {
2510 : 0 : nParaCnt = (pPam->GetPoint()->nNode.GetNode().IsInVisibleArea(pVSh))
2511 [ # # ]: 0 : ? 5 : 50;
2512 : : }
2513 : 0 : }
2514 : :
2515 : 2 : void SwHTMLParser::ShowStatline()
2516 : : {
2517 : : // Hier wird
2518 : : // - ein Reschedule gerufen, damit gescrollt werden kann
2519 : : // - die eiegen View-Shell wieder gesetzt
2520 : : // - ein Start/End-Action gerufen, wenn gescrollt wurde.
2521 : :
2522 : : OSL_ENSURE( SVPAR_WORKING==eState, "ShowStatLine nicht im Working-State - Das kann ins Auge gehen" );
2523 : :
2524 : : // Laufbalkenanzeige
2525 [ + - ][ + - ]: 2 : if( !GetMedium() || !GetMedium()->IsRemote() )
[ + - ]
2526 : : {
2527 : 2 : ::SetProgressState( rInput.Tell(), pDoc->GetDocShell() );
2528 : 2 : CheckActionViewShell();
2529 : : }
2530 : : else
2531 : : {
2532 : 0 : GetpApp()->Reschedule();
2533 : :
2534 [ # # # # ]: 0 : if( ( pDoc->GetDocShell() && pDoc->GetDocShell()->IsAbortingImport() )
[ # # ][ # # ]
2535 : 0 : || 1 == pDoc->getReferenceCount() )
2536 : : // wurde der Import vom SFX abgebrochen?
2537 : 0 : eState = SVPAR_ERROR;
2538 : :
2539 : 0 : ViewShell *pVSh = CheckActionViewShell();
2540 [ # # ][ # # ]: 0 : if( pVSh && pVSh->HasInvalidRect() )
[ # # ]
2541 : : {
2542 : 0 : CallEndAction( sal_False, sal_False );
2543 : 0 : CallStartAction( pVSh, sal_False );
2544 : : }
2545 : : }
2546 : 2 : }
2547 : :
2548 : 4 : ViewShell *SwHTMLParser::CallStartAction( ViewShell *pVSh, sal_Bool bChkPtr )
2549 : : {
2550 : : OSL_ENSURE( !pActionViewShell, "CallStartAction: ViewShell schon gesetzt" );
2551 : :
2552 [ - + ][ # # ]: 4 : if( !pVSh || bChkPtr )
2553 : : {
2554 : : #if OSL_DEBUG_LEVEL > 0
2555 : : ViewShell *pOldVSh = pVSh;
2556 : : #endif
2557 : 4 : pDoc->GetEditShell( &pVSh );
2558 : : #if OSL_DEBUG_LEVEL > 0
2559 : : OSL_ENSURE( !pVSh || !pOldVSh || pOldVSh == pVSh, "CallStartAction: Wer hat die ViewShell ausgetauscht?" );
2560 : : if( pOldVSh && !pVSh )
2561 : : pVSh = 0;
2562 : : #endif
2563 : : }
2564 : 4 : pActionViewShell = pVSh;
2565 : :
2566 [ - + ]: 4 : if( pActionViewShell )
2567 : : {
2568 [ # # ]: 0 : if( pActionViewShell->ISA( SwEditShell ) )
2569 : 0 : ((SwEditShell*)pActionViewShell)->StartAction();
2570 : : else
2571 : 0 : pActionViewShell->StartAction();
2572 : : }
2573 : :
2574 : 4 : return pActionViewShell;
2575 : : }
2576 : :
2577 : 4 : ViewShell *SwHTMLParser::CallEndAction( sal_Bool bChkAction, sal_Bool bChkPtr )
2578 : : {
2579 [ + - ]: 4 : if( bChkPtr )
2580 : : {
2581 : 4 : ViewShell *pVSh = 0;
2582 [ + - ]: 4 : pDoc->GetEditShell( &pVSh );
2583 : : OSL_ENSURE( !pVSh || pActionViewShell == pVSh,
2584 : : "CallEndAction: Wer hat die ViewShell ausgetauscht?" );
2585 : : #if OSL_DEBUG_LEVEL > 0
2586 : : if( pActionViewShell && !pVSh )
2587 : : pVSh = 0;
2588 : : #endif
2589 [ - + ]: 4 : if( pVSh != pActionViewShell )
2590 : 4 : pActionViewShell = 0;
2591 : : }
2592 : :
2593 [ - + ][ # # ]: 4 : if( !pActionViewShell || (bChkAction && !pActionViewShell->ActionPend()) )
[ # # ][ + - ]
2594 : 4 : return pActionViewShell;
2595 : :
2596 [ # # ]: 0 : if( bSetCrsr )
2597 : : {
2598 : : // an allen CrsrEditShells die Cursor auf den Doc-Anfang setzen
2599 : 0 : ViewShell *pSh = pActionViewShell;
2600 [ # # ]: 0 : do {
2601 [ # # ]: 0 : if( pSh->IsA( TYPE( SwCrsrShell ) ) )
2602 : 0 : ((SwCrsrShell*)pSh)->SttEndDoc(sal_True);
2603 : 0 : pSh = (ViewShell *)pSh->GetNext();
2604 : : } while( pSh != pActionViewShell );
2605 : :
2606 : 0 : bSetCrsr = sal_False;
2607 : : }
2608 [ # # ]: 0 : if( pActionViewShell->ISA( SwEditShell ) )
2609 : : {
2610 : : //Schon gescrollt?, dann dafuer sorgen, dass die View sich nicht bewegt!
2611 : 0 : const sal_Bool bOldLock = pActionViewShell->IsViewLocked();
2612 : 0 : pActionViewShell->LockView( sal_True );
2613 : 0 : const sal_Bool bOldEndActionByVirDev = pActionViewShell->IsEndActionByVirDev();
2614 : 0 : pActionViewShell->SetEndActionByVirDev( sal_True );;
2615 : 0 : ((SwEditShell*)pActionViewShell)->EndAction();
2616 : 0 : pActionViewShell->SetEndActionByVirDev( bOldEndActionByVirDev );
2617 : 0 : pActionViewShell->LockView( bOldLock );
2618 : :
2619 : : // bChkJumpMark ist nur gesetzt, wenn das Object auch gefunden wurde
2620 [ # # ]: 0 : if( bChkJumpMark )
2621 : : {
2622 : 0 : const Point aVisSttPos( DOCUMENTBORDER, DOCUMENTBORDER );
2623 [ # # ][ # # ]: 0 : if( GetMedium() && aVisSttPos == pActionViewShell->VisArea().Pos() )
[ # # ]
2624 : : ::JumpToSwMark( pActionViewShell,
2625 [ # # ][ # # ]: 0 : GetMedium()->GetURLObject().GetMark() );
[ # # ]
2626 : 0 : bChkJumpMark = sal_False;
2627 : : }
2628 : : }
2629 : : else
2630 : 0 : pActionViewShell->EndAction();
2631 : :
2632 : : // sollte der Parser der Letzte sein, der das Doc haelt, dann kann
2633 : : // man hier abbrechen und einen Fehler setzen.
2634 [ # # ]: 0 : if( 1 == pDoc->getReferenceCount() )
2635 : : {
2636 : 0 : eState = SVPAR_ERROR;
2637 : : }
2638 : :
2639 : 0 : ViewShell *pVSh = pActionViewShell;
2640 : 0 : pActionViewShell = 0;
2641 : :
2642 : 4 : return pVSh;
2643 : : }
2644 : :
2645 : 6 : ViewShell *SwHTMLParser::CheckActionViewShell()
2646 : : {
2647 : 6 : ViewShell *pVSh = 0;
2648 [ + - ]: 6 : pDoc->GetEditShell( &pVSh );
2649 : : OSL_ENSURE( !pVSh || pActionViewShell == pVSh,
2650 : : "CheckActionViewShell: Wer hat die ViewShell ausgetauscht?" );
2651 : : #if OSL_DEBUG_LEVEL > 0
2652 : : if( pActionViewShell && !pVSh )
2653 : : pVSh = 0;
2654 : : #endif
2655 [ - + ]: 6 : if( pVSh != pActionViewShell )
2656 : 0 : pActionViewShell = 0;
2657 : :
2658 : 6 : return pActionViewShell;
2659 : : }
2660 : :
2661 : :
2662 : 0 : void SwHTMLParser::_SetAttr( sal_Bool bChkEnd, sal_Bool bBeforeTable,
2663 : : _HTMLAttrs *pPostIts )
2664 : : {
2665 [ # # ][ # # ]: 0 : SwPaM* pAttrPam = new SwPaM( *pPam->GetPoint() );
2666 : 0 : const SwNodeIndex& rEndIdx = pPam->GetPoint()->nNode;
2667 : 0 : xub_StrLen nEndCnt = pPam->GetPoint()->nContent.GetIndex();
2668 : : _HTMLAttr* pAttr;
2669 : : SwCntntNode* pCNd;
2670 : : sal_uInt16 n;
2671 : :
2672 [ # # ]: 0 : _HTMLAttrs aFields;
2673 : :
2674 [ # # ]: 0 : for( n = aSetAttrTab.size(); n; )
2675 : : {
2676 [ # # ]: 0 : pAttr = aSetAttrTab[ --n ];
2677 : 0 : sal_uInt16 nWhich = pAttr->pItem->Which();
2678 : :
2679 : 0 : sal_uLong nEndParaIdx = pAttr->GetEndParaIdx();
2680 : : sal_Bool bSetAttr;
2681 [ # # ]: 0 : if( bChkEnd )
2682 : : {
2683 : : // Zechen-Attribute mit Ende moeglich frueh,
2684 : : // also noch im aktuellen Absatz setzen (wegen JavaScript
2685 : : // und diversen Chats). das darf man aber nicht fuer Attribute,
2686 : : // die ueber den ganzen Absatz aufgspannt werden sollen, weil
2687 : : // sie aus Absatzvorlgen stammen, die nicht gesetzt werden
2688 : : // koennen. Weil die Attribute mit SETATTR_DONTREPLACE
2689 : : // eingefuegt werden, sollte man sie auch anchtraeglich
2690 : : // noch setzen koennen.
2691 : 0 : bSetAttr = ( nEndParaIdx < rEndIdx.GetIndex() &&
2692 : 0 : (RES_LR_SPACE != nWhich || !GetNumInfo().GetNumRule()) ) ||
2693 : 0 : ( !pAttr->IsLikePara() &&
2694 : 0 : nEndParaIdx == rEndIdx.GetIndex() &&
2695 : 0 : pAttr->GetEndCnt() < nEndCnt &&
2696 : 0 : (isCHRATR(nWhich) || isTXTATR_WITHEND(nWhich)) ) ||
2697 : : ( bBeforeTable &&
2698 : 0 : nEndParaIdx == rEndIdx.GetIndex() &&
2699 [ # # # # : 0 : !pAttr->GetEndCnt() );
# # # # #
# # # #
# ]
[ # # # # ]
[ # # ][ # # ]
2700 : : }
2701 : : else
2702 : : {
2703 : : // Attribiute im Content-Bereich duerfen nicht gesetzt
2704 : : // werden, wenn wir in einem Sonderbereich stehen, aber
2705 : : // umgekekehrt schon.
2706 [ # # ]: 0 : sal_uLong nEndOfIcons = pDoc->GetNodes().GetEndOfExtras().GetIndex();
2707 : 0 : bSetAttr = nEndParaIdx < rEndIdx.GetIndex() ||
2708 : 0 : rEndIdx.GetIndex() > nEndOfIcons ||
2709 [ # # ]: 0 : nEndParaIdx <= nEndOfIcons;
[ # # # # ]
2710 : : }
2711 : :
2712 [ # # ]: 0 : if( bSetAttr )
2713 : : {
2714 : : // Das Attribute darf nicht in der liste der vorlaeufigen
2715 : : // Absatz-Attribute stehen, weil es sonst geloescht wurde.
2716 [ # # ]: 0 : while( !aParaAttrs.empty() )
2717 : : {
2718 : : OSL_ENSURE( pAttr != aParaAttrs.back(),
2719 : : "SetAttr: Attribut duerfte noch nicht gesetzt werden" );
2720 [ # # ]: 0 : aParaAttrs.pop_back();
2721 : : }
2722 : :
2723 : :
2724 : : // dann also setzen
2725 [ # # ][ # # ]: 0 : aSetAttrTab.erase( aSetAttrTab.begin() + n );
2726 : :
2727 [ # # ]: 0 : while( pAttr )
2728 : : {
2729 : 0 : _HTMLAttr *pPrev = pAttr->GetPrev();
2730 [ # # ]: 0 : if( !pAttr->bValid )
2731 : : {
2732 : : // ungueltige Attribute koennen gloescht werden
2733 [ # # ][ # # ]: 0 : delete pAttr;
2734 : 0 : pAttr = pPrev;
2735 : 0 : continue; //break;
2736 : : }
2737 : :
2738 : :
2739 : 0 : pCNd = pAttr->nSttPara.GetNode().GetCntntNode();
2740 [ # # ]: 0 : if( !pCNd )
2741 : : {
2742 : : // durch die elende Loescherei von Nodes kann auch mal
2743 : : // ein Index auf einen End-Node zeigen :-(
2744 [ # # # # ]: 0 : if ( (pAttr->GetSttPara() == pAttr->GetEndPara()) &&
[ # # ]
2745 : 0 : !isTXTATR_NOEND(nWhich) )
2746 : : {
2747 : : // wenn der End-Index auch auf den Node zeigt
2748 : : // brauchen wir auch kein Attribut mehr zu setzen,
2749 : : // es sei denn, es ist ein Text-Attribut.
2750 [ # # ][ # # ]: 0 : delete pAttr;
2751 : 0 : pAttr = pPrev;
2752 : 0 : continue; //break;
2753 : : }
2754 [ # # ][ # # ]: 0 : pCNd = pDoc->GetNodes().GoNext( &(pAttr->nSttPara) );
2755 [ # # ]: 0 : if( pCNd )
2756 : 0 : pAttr->nSttCntnt = 0;
2757 : : else
2758 : : {
2759 : : OSL_ENSURE( !this, "SetAttr: GoNext() failed!" );
2760 [ # # ][ # # ]: 0 : delete pAttr;
2761 : 0 : pAttr = pPrev;
2762 : 0 : continue; // break;
2763 : : }
2764 : : }
2765 [ # # ]: 0 : pAttrPam->GetPoint()->nNode = pAttr->nSttPara;
2766 : :
2767 : :
2768 : :
2769 : : // durch das Loeschen von BRs kann der Start-Index
2770 : : // auch mal hinter das Ende des Textes zeigen
2771 [ # # ][ # # ]: 0 : if( pAttr->nSttCntnt > pCNd->Len() )
2772 [ # # ]: 0 : pAttr->nSttCntnt = pCNd->Len();
2773 [ # # ][ # # ]: 0 : pAttrPam->GetPoint()->nContent.Assign( pCNd, pAttr->nSttCntnt );
2774 : :
2775 [ # # ]: 0 : pAttrPam->SetMark();
2776 [ # # # # ]: 0 : if ( (pAttr->GetSttPara() != pAttr->GetEndPara()) &&
[ # # ]
2777 : 0 : !isTXTATR_NOEND(nWhich) )
2778 : : {
2779 : 0 : pCNd = pAttr->nEndPara.GetNode().GetCntntNode();
2780 [ # # ]: 0 : if( !pCNd )
2781 : : {
2782 [ # # ][ # # ]: 0 : pCNd = pDoc->GetNodes().GoPrevious( &(pAttr->nEndPara) );
2783 [ # # ]: 0 : if( pCNd )
2784 [ # # ]: 0 : pAttr->nEndCntnt = pCNd->Len();
2785 : : else
2786 : : {
2787 : : OSL_ENSURE( !this, "SetAttr: GoPrevious() failed!" );
2788 [ # # ]: 0 : pAttrPam->DeleteMark();
2789 [ # # ][ # # ]: 0 : delete pAttr;
2790 : 0 : pAttr = pPrev;
2791 : 0 : continue; // break;
2792 : : }
2793 : : }
2794 : :
2795 [ # # ]: 0 : pAttrPam->GetPoint()->nNode = pAttr->nEndPara;
2796 : : }
2797 [ # # ]: 0 : else if( pAttr->IsLikePara() )
2798 : : {
2799 [ # # ]: 0 : pAttr->nEndCntnt = pCNd->Len();
2800 : : }
2801 : :
2802 : : // durch das Loeschen von BRs kann der End-Index
2803 : : // auch mal hinter das Ende des Textes zeigen
2804 [ # # ][ # # ]: 0 : if( pAttr->nEndCntnt > pCNd->Len() )
2805 [ # # ]: 0 : pAttr->nEndCntnt = pCNd->Len();
2806 : :
2807 [ # # ][ # # ]: 0 : pAttrPam->GetPoint()->nContent.Assign( pCNd, pAttr->nEndCntnt );
2808 [ # # # # ]: 0 : if( bBeforeTable &&
[ # # ]
2809 : 0 : pAttrPam->GetPoint()->nNode.GetIndex() ==
2810 : 0 : rEndIdx.GetIndex() )
2811 : : {
2812 : : // wenn wir vor dem Einfuegen einer Tabelle stehen
2813 : : // und das Attribut im aktuellen Node beendet wird,
2814 : : // muessen wir es im Node davor beenden oder wegschmeissen,
2815 : : // wenn es erst in dem Node beginnt
2816 [ # # ]: 0 : if( nWhich != RES_BREAK && nWhich != RES_PAGEDESC &&
[ # # # # ]
[ # # ]
2817 : 0 : !isTXTATR_NOEND(nWhich) )
2818 : : {
2819 [ # # ]: 0 : if( pAttrPam->GetMark()->nNode.GetIndex() !=
2820 : 0 : rEndIdx.GetIndex() )
2821 : : {
2822 : : OSL_ENSURE( !pAttrPam->GetPoint()->nContent.GetIndex(),
2823 : : "Content-Position vor Tabelle nicht 0???" );
2824 [ # # ]: 0 : pAttrPam->Move( fnMoveBackward );
2825 : : }
2826 : : else
2827 : : {
2828 [ # # ]: 0 : pAttrPam->DeleteMark();
2829 [ # # ][ # # ]: 0 : delete pAttr;
2830 : 0 : pAttr = pPrev;
2831 : 0 : continue;
2832 : : }
2833 : : }
2834 : : }
2835 : :
2836 [ # # # # ]: 0 : switch( nWhich )
2837 : : {
2838 : : case RES_FLTR_BOOKMARK: // insert bookmark
2839 : : {
2840 [ # # ]: 0 : const String sName( ((SfxStringItem*)pAttr->pItem)->GetValue() );
2841 [ # # ]: 0 : IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
2842 [ # # ][ # # ]: 0 : IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->findMark( sName );
2843 [ # # ][ # # ]: 0 : if( ppBkmk != pMarkAccess->getMarksEnd() &&
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
2844 [ # # ][ # # ]: 0 : ppBkmk->get()->GetMarkStart() == *pAttrPam->GetPoint() )
2845 : : break; // do not generate duplicates on this position
2846 [ # # ]: 0 : pAttrPam->DeleteMark();
2847 : : const ::sw::mark::IMark* const pNewMark = pMarkAccess->makeMark(
2848 : : *pAttrPam,
2849 : : sName,
2850 [ # # ][ # # ]: 0 : IDocumentMarkAccess::BOOKMARK );
2851 : :
2852 : : // jump to bookmark
2853 [ # # ][ # # ]: 0 : if( JUMPTO_MARK == eJumpTo && pNewMark->GetName() == ::rtl::OUString(sJmpMark) )
[ # # ][ # # ]
[ # # # # ]
[ # # ]
2854 : : {
2855 : 0 : bChkJumpMark = sal_True;
2856 : 0 : eJumpTo = JUMPTO_NONE;
2857 [ # # ][ # # ]: 0 : }
2858 : : }
2859 : 0 : break;
2860 : : case RES_TXTATR_FIELD:
2861 : : {
2862 : : sal_uInt16 nFldWhich =
2863 : : pPostIts ? ((const SwFmtFld *)pAttr->pItem)
2864 [ # # ]: 0 : ->GetFld()->GetTyp()->Which() : 0;
2865 [ # # ][ # # ]: 0 : if( pPostIts && (RES_POSTITFLD == nFldWhich ||
[ # # ]
2866 : : RES_SCRIPTFLD == nFldWhich) )
2867 : : {
2868 [ # # ]: 0 : pPostIts->push_front( pAttr );
2869 : : }
2870 : : else
2871 : : {
2872 [ # # ]: 0 : aFields.push_back( pAttr);
2873 : : }
2874 : : }
2875 [ # # ]: 0 : pAttrPam->DeleteMark();
2876 : 0 : pAttr = pPrev;
2877 : 0 : continue;
2878 : :
2879 : : case RES_LR_SPACE:
2880 [ # # ][ # # ]: 0 : if( pAttrPam->GetPoint()->nNode.GetIndex() ==
[ # # ]
2881 : 0 : pAttrPam->GetMark()->nNode.GetIndex() &&
2882 : : pCNd )
2883 : : {
2884 : : // wegen Numerierungen dieses Attribut direkt
2885 : : // am Node setzen
2886 [ # # ]: 0 : pCNd->SetAttr( *pAttr->pItem );
2887 : 0 : break;
2888 : : }
2889 : : OSL_ENSURE( !this,
2890 : : "LRSpace ueber mehrere Absaetze gesetzt!" );
2891 : : // kein break (hier sollen wir trotzdem nie hinkommen;
2892 : : default:
2893 : :
2894 : : // ggfs. ein Bookmark anspringen
2895 [ # # ][ # # ]: 0 : if( RES_TXTATR_INETFMT == nWhich &&
[ # # ][ # # ]
2896 : : JUMPTO_MARK == eJumpTo &&
2897 [ # # ]: 0 : sJmpMark == ((SwFmtINetFmt*)pAttr->pItem)->GetName() )
2898 : : {
2899 : 0 : bChkJumpMark = sal_True;
2900 : 0 : eJumpTo = JUMPTO_NONE;
2901 : : }
2902 : :
2903 [ # # ]: 0 : pDoc->InsertPoolItem( *pAttrPam, *pAttr->pItem, nsSetAttrMode::SETATTR_DONTREPLACE );
2904 : : }
2905 [ # # ]: 0 : pAttrPam->DeleteMark();
2906 : :
2907 [ # # ][ # # ]: 0 : delete pAttr;
2908 : 0 : pAttr = pPrev;
2909 : : }
2910 : : }
2911 : : }
2912 : :
2913 [ # # ]: 0 : for( n = aMoveFlyFrms.size(); n; )
2914 : : {
2915 : 0 : SwFrmFmt *pFrmFmt = aMoveFlyFrms[ --n ];
2916 : :
2917 [ # # ]: 0 : const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
2918 : : OSL_ENSURE( FLY_AT_PARA == rAnchor.GetAnchorId(),
2919 : : "Nur Auto-Rahmen brauchen eine Spezialbehandlung" );
2920 [ # # ]: 0 : const SwPosition *pFlyPos = rAnchor.GetCntntAnchor();
2921 : 0 : sal_uLong nFlyParaIdx = pFlyPos->nNode.GetIndex();
2922 : : sal_Bool bMoveFly;
2923 [ # # ]: 0 : if( bChkEnd )
2924 : : {
2925 : 0 : bMoveFly = nFlyParaIdx < rEndIdx.GetIndex() ||
2926 : 0 : ( nFlyParaIdx == rEndIdx.GetIndex() &&
2927 [ # # ][ # # ]: 0 : aMoveFlyCnts[n] < nEndCnt );
[ # # # # ]
2928 : : }
2929 : : else
2930 : : {
2931 [ # # ]: 0 : sal_uLong nEndOfIcons = pDoc->GetNodes().GetEndOfExtras().GetIndex();
2932 : 0 : bMoveFly = nFlyParaIdx < rEndIdx.GetIndex() ||
2933 : 0 : rEndIdx.GetIndex() > nEndOfIcons ||
2934 [ # # ]: 0 : nFlyParaIdx <= nEndOfIcons;
[ # # # # ]
2935 : : }
2936 [ # # ]: 0 : if( bMoveFly )
2937 : : {
2938 [ # # ]: 0 : pFrmFmt->DelFrms();
2939 [ # # ]: 0 : *pAttrPam->GetPoint() = *pFlyPos;
2940 : 0 : pAttrPam->GetPoint()->nContent.Assign( pAttrPam->GetCntntNode(),
2941 [ # # # # ]: 0 : aMoveFlyCnts[n] );
[ # # ]
2942 [ # # ]: 0 : SwFmtAnchor aAnchor( rAnchor );
2943 : 0 : aAnchor.SetType( FLY_AT_CHAR );
2944 [ # # ]: 0 : aAnchor.SetAnchor( pAttrPam->GetPoint() );
2945 [ # # ]: 0 : pFrmFmt->SetFmtAttr( aAnchor );
2946 : :
2947 [ # # ]: 0 : const SwFmtHoriOrient& rHoriOri = pFrmFmt->GetHoriOrient();
2948 [ # # ]: 0 : if( text::HoriOrientation::LEFT == rHoriOri.GetHoriOrient() )
2949 : : {
2950 [ # # ]: 0 : SwFmtHoriOrient aHoriOri( rHoriOri );
2951 : 0 : aHoriOri.SetRelationOrient( text::RelOrientation::CHAR );
2952 [ # # ][ # # ]: 0 : pFrmFmt->SetFmtAttr( aHoriOri );
2953 : : }
2954 [ # # ]: 0 : const SwFmtVertOrient& rVertOri = pFrmFmt->GetVertOrient();
2955 [ # # ]: 0 : if( text::VertOrientation::TOP == rVertOri.GetVertOrient() )
2956 : : {
2957 [ # # ]: 0 : SwFmtVertOrient aVertOri( rVertOri );
2958 : 0 : aVertOri.SetRelationOrient( text::RelOrientation::CHAR );
2959 [ # # ][ # # ]: 0 : pFrmFmt->SetFmtAttr( aVertOri );
2960 : : }
2961 : :
2962 [ # # ]: 0 : pFrmFmt->MakeFrms();
2963 [ # # ][ # # ]: 0 : aMoveFlyFrms.erase( aMoveFlyFrms.begin() + n );
2964 [ # # ][ # # ]: 0 : aMoveFlyCnts.erase( aMoveFlyCnts.begin() + n );
[ # # ]
2965 : : }
2966 : : }
2967 [ # # ]: 0 : while( !aFields.empty() )
2968 : : {
2969 [ # # ]: 0 : pAttr = aFields[0];
2970 : :
2971 : 0 : pCNd = pAttr->nSttPara.GetNode().GetCntntNode();
2972 [ # # ]: 0 : pAttrPam->GetPoint()->nNode = pAttr->nSttPara;
2973 [ # # ][ # # ]: 0 : pAttrPam->GetPoint()->nContent.Assign( pCNd, pAttr->nSttCntnt );
2974 : :
2975 [ # # # # ]: 0 : if( bBeforeTable &&
[ # # ]
2976 : 0 : pAttrPam->GetPoint()->nNode.GetIndex() == rEndIdx.GetIndex() )
2977 : : {
2978 : : OSL_ENSURE( !bBeforeTable, "Aha, der Fall tritt also doch ein" );
2979 : : OSL_ENSURE( !pAttrPam->GetPoint()->nContent.GetIndex(),
2980 : : "Content-Position vor Tabelle nicht 0???" );
2981 : : // !!!
2982 [ # # ]: 0 : pAttrPam->Move( fnMoveBackward );
2983 : : }
2984 : :
2985 [ # # ]: 0 : pDoc->InsertPoolItem( *pAttrPam, *pAttr->pItem, 0 );
2986 : :
2987 [ # # ]: 0 : aFields.pop_front();
2988 [ # # ][ # # ]: 0 : delete pAttr;
2989 : : }
2990 : :
2991 [ # # ][ # # ]: 0 : delete pAttrPam;
2992 : 0 : }
2993 : :
2994 : 0 : void SwHTMLParser::NewAttr( _HTMLAttr **ppAttr, const SfxPoolItem& rItem )
2995 : : {
2996 : : // Font-Hoehen und -Farben- sowie Escapement-Attribute duerfen nicht
2997 : : // zusammengefasst werden. Sie werden deshalb in einer Liste gespeichert,
2998 : : // in der das zuletzt aufgespannte Attribut vorne steht und der Count
2999 : : // immer 1 ist. Fuer alle anderen Attribute wird der Count einfach
3000 : : // hochgezaehlt.
3001 [ # # ]: 0 : if( *ppAttr )
3002 : : {
3003 : 0 : _HTMLAttr *pAttr = new _HTMLAttr( *pPam->GetPoint(), rItem,
3004 [ # # ]: 0 : ppAttr );
3005 : 0 : pAttr->InsertNext( *ppAttr );
3006 : 0 : (*ppAttr) = pAttr;
3007 : : }
3008 : : else
3009 [ # # ]: 0 : (*ppAttr) = new _HTMLAttr( *pPam->GetPoint(), rItem, ppAttr );
3010 : 0 : }
3011 : :
3012 : :
3013 : 0 : void SwHTMLParser::EndAttr( _HTMLAttr* pAttr, _HTMLAttr **ppDepAttr,
3014 : : sal_Bool bChkEmpty )
3015 : : {
3016 : : OSL_ENSURE( !ppDepAttr, "SwHTMLParser::EndAttr: ppDepAttr-Feature ungetestet?" );
3017 : : // Der Listenkopf ist im Attribut gespeichert
3018 : 0 : _HTMLAttr **ppHead = pAttr->ppHead;
3019 : :
3020 : : OSL_ENSURE( ppHead, "keinen Attributs-Listenkopf gefunden!" );
3021 : :
3022 : : // die aktuelle Psoition als Ende-Position merken
3023 : 0 : const SwNodeIndex* pEndIdx = &pPam->GetPoint()->nNode;
3024 : 0 : xub_StrLen nEndCnt = pPam->GetPoint()->nContent.GetIndex();
3025 : :
3026 : : // WIrd das zueltzt gestartete oder ein frueher gestartetes Attribut
3027 : : // beendet?
3028 : 0 : _HTMLAttr *pLast = 0;
3029 [ # # ][ # # ]: 0 : if( ppHead && pAttr != *ppHead )
3030 : : {
3031 : : // Es wird nicht das zuletzt gestartete Attribut beendet
3032 : :
3033 : : // Dann suche wir das unmittelbar danach gestartete Attribut, das
3034 : : // ja ebenfalls noch nicht beendet wurde (sonst stuende es nicht
3035 : : // mehr in der Liste
3036 : 0 : pLast = *ppHead;
3037 [ # # ][ # # ]: 0 : while( pLast && pLast->GetNext() != pAttr )
[ # # ]
3038 : 0 : pLast = pLast->GetNext();
3039 : :
3040 : : OSL_ENSURE( pLast, "Attribut nicht in eigener Liste gefunden!" );
3041 : : }
3042 : :
3043 : 0 : sal_Bool bMoveBack = sal_False;
3044 : 0 : sal_uInt16 nWhich = pAttr->pItem->Which();
3045 [ # # # # ]: 0 : if( !nEndCnt && RES_PARATR_BEGIN <= nWhich &&
[ # # ][ # # ]
3046 : 0 : *pEndIdx != pAttr->GetSttPara() )
3047 : : {
3048 : : // dann eine Cntntnt Position zurueck!
3049 [ # # ]: 0 : bMoveBack = pPam->Move( fnMoveBackward );
3050 : 0 : nEndCnt = pPam->GetPoint()->nContent.GetIndex();
3051 : : }
3052 : :
3053 : : // nun das Attrubut beenden
3054 : 0 : _HTMLAttr *pNext = pAttr->GetNext();
3055 : :
3056 : :
3057 : : sal_Bool bInsert;
3058 : 0 : sal_uInt16 nScriptItem = 0;
3059 : 0 : sal_Bool bScript = sal_False, bFont = sal_False;
3060 : : // ein Bereich ??
3061 [ # # ][ # # ]: 0 : if( !bChkEmpty || (RES_PARATR_BEGIN <= nWhich && bMoveBack) ||
[ # # ][ # #
# # # # ]
[ # # ][ # # ]
3062 : : RES_PAGEDESC == nWhich || RES_BREAK == nWhich ||
3063 : 0 : *pEndIdx != pAttr->GetSttPara() ||
3064 : 0 : nEndCnt != pAttr->GetSttCnt() )
3065 : : {
3066 : 0 : bInsert = sal_True;
3067 : : // We do some optimization for script depenedent attribtes here.
3068 [ # # ]: 0 : if( *pEndIdx == pAttr->GetSttPara() )
3069 : : {
3070 : 0 : lcl_swhtml_getItemInfo( *pAttr, bScript, bFont, nScriptItem );
3071 : : }
3072 : : }
3073 : : else
3074 : : {
3075 : 0 : bInsert = sal_False;
3076 : : }
3077 : :
3078 [ # # ][ # # ]: 0 : if( bInsert && bScript )
3079 : : {
3080 : 0 : const SwTxtNode *pTxtNd = pAttr->GetSttPara().GetNode()
3081 : 0 : .GetTxtNode();
3082 : : OSL_ENSURE( pTxtNd, "No text node" );
3083 : 0 : const String& rText = pTxtNd->GetTxt();
3084 [ # # ][ # # ]: 0 : sal_uInt16 nScriptTxt = pBreakIt->GetBreakIter()->getScriptType(
3085 [ # # ][ # # ]: 0 : rText, pAttr->GetSttCnt() );
3086 : : xub_StrLen nScriptEnd = (xub_StrLen)pBreakIt->GetBreakIter()
3087 [ # # ][ # # ]: 0 : ->endOfScript( rText, pAttr->GetSttCnt(), nScriptTxt );
[ # # ][ # # ]
3088 [ # # ]: 0 : while( nScriptEnd < nEndCnt )
3089 : : {
3090 [ # # ]: 0 : if( nScriptItem == nScriptTxt )
3091 : : {
3092 [ # # ]: 0 : _HTMLAttr *pSetAttr = pAttr->Clone( *pEndIdx, nScriptEnd );
3093 : 0 : pSetAttr->ClearPrev();
3094 [ # # ]: 0 : if( pNext )
3095 : 0 : pNext->InsertPrev( pSetAttr );
3096 : : else
3097 : : {
3098 [ # # ]: 0 : if (pSetAttr->bInsAtStart)
3099 [ # # ]: 0 : aSetAttrTab.push_front( pSetAttr );
3100 : : else
3101 [ # # ]: 0 : aSetAttrTab.push_back( pSetAttr );
3102 : : }
3103 : : }
3104 : 0 : pAttr->nSttCntnt = nScriptEnd;
3105 [ # # ][ # # ]: 0 : nScriptTxt = pBreakIt->GetBreakIter()->getScriptType(
3106 [ # # ][ # # ]: 0 : rText, nScriptEnd );
3107 : : nScriptEnd = (xub_StrLen)pBreakIt->GetBreakIter()
3108 [ # # ][ # # ]: 0 : ->endOfScript( rText, nScriptEnd, nScriptTxt );
[ # # ][ # # ]
3109 : : }
3110 : 0 : bInsert = nScriptItem == nScriptTxt;
3111 : : }
3112 [ # # ]: 0 : if( bInsert )
3113 : : {
3114 [ # # ]: 0 : pAttr->nEndPara = *pEndIdx;
3115 : 0 : pAttr->nEndCntnt = nEndCnt;
3116 : : pAttr->bInsAtStart = RES_TXTATR_INETFMT != nWhich &&
3117 [ # # ][ # # ]: 0 : RES_TXTATR_CHARFMT != nWhich;
3118 : :
3119 [ # # ]: 0 : if( !pNext )
3120 : : {
3121 : : // keine offenen Attribute dieses Typs mehr da,
3122 : : // dann koennen alle gesetzt werden, es sei denn
3123 : : // sie haengen noch von einem anderen Attribut ab,
3124 : : // dann werden sie dort angehaengt
3125 [ # # ][ # # ]: 0 : if( ppDepAttr && *ppDepAttr )
3126 : 0 : (*ppDepAttr)->InsertPrev( pAttr );
3127 : : else
3128 : : {
3129 [ # # ]: 0 : if (pAttr->bInsAtStart)
3130 [ # # ]: 0 : aSetAttrTab.push_front( pAttr );
3131 : : else
3132 [ # # ]: 0 : aSetAttrTab.push_back( pAttr );
3133 : : }
3134 : : }
3135 : : else
3136 : : {
3137 : : // es gibt noch andere offene Attribute des Typs,
3138 : : // daher muss das Setzen zurueckgestellt werden.
3139 : : // das aktuelle Attribut wird deshalb hinten an die
3140 : : // Previous-Liste des Nachfolgers angehaengt
3141 : 0 : pNext->InsertPrev( pAttr );
3142 : : }
3143 : : }
3144 : : else
3145 : : {
3146 : : // dann nicht einfuegen, sondern Loeschen. Durch das "tuerken" von
3147 : : // Vorlagen durch harte Attributierung koennen sich auch mal andere
3148 : : // leere Attribute in der Prev-Liste befinden, die dann trotzdem
3149 : : // gesetzt werden muessen
3150 : 0 : _HTMLAttr *pPrev = pAttr->GetPrev();
3151 [ # # ][ # # ]: 0 : delete pAttr;
3152 : :
3153 [ # # ]: 0 : if( pPrev )
3154 : : {
3155 : : // Die Previous-Attribute muessen trotzdem gesetzt werden.
3156 [ # # ]: 0 : if( pNext )
3157 : 0 : pNext->InsertPrev( pPrev );
3158 : : else
3159 : : {
3160 [ # # ]: 0 : if (pPrev->bInsAtStart)
3161 [ # # ]: 0 : aSetAttrTab.push_front( pPrev );
3162 : : else
3163 [ # # ]: 0 : aSetAttrTab.push_back( pPrev );
3164 : : }
3165 : : }
3166 : :
3167 : : }
3168 : :
3169 : : // wenn das erste Attribut der Liste gesetzt wurde muss noch der
3170 : : // Listenkopf korrigiert werden.
3171 [ # # ]: 0 : if( pLast )
3172 : 0 : pLast->pNext = pNext;
3173 [ # # ]: 0 : else if( ppHead )
3174 : 0 : *ppHead = pNext;
3175 : :
3176 [ # # ]: 0 : if( bMoveBack )
3177 [ # # ]: 0 : pPam->Move( fnMoveForward );
3178 : 0 : }
3179 : :
3180 : 0 : void SwHTMLParser::DeleteAttr( _HTMLAttr* pAttr )
3181 : : {
3182 : : // preliminary paragraph attributes are not allowed here, they could
3183 : : // be set here and then the pointers become invalid!
3184 : : OSL_ENSURE(aParaAttrs.empty(),
3185 : : "Danger: there are non-final paragraph attributes");
3186 [ # # ]: 0 : if( !aParaAttrs.empty() )
3187 : 0 : aParaAttrs.clear();
3188 : :
3189 : : // Der Listenkopf ist im Attribut gespeichert
3190 : 0 : _HTMLAttr **ppHead = pAttr->ppHead;
3191 : :
3192 : : OSL_ENSURE( ppHead, "keinen Attributs-Listenkopf gefunden!" );
3193 : :
3194 : : // Wird das zueltzt gestartete oder ein frueher gestartetes Attribut
3195 : : // entfernt?
3196 : 0 : _HTMLAttr *pLast = 0;
3197 [ # # ][ # # ]: 0 : if( ppHead && pAttr != *ppHead )
3198 : : {
3199 : : // Es wird nicht das zuletzt gestartete Attribut beendet
3200 : :
3201 : : // Dann suche wir das unmittelbar danach gestartete Attribut, das
3202 : : // ja ebenfalls noch nicht beendet wurde (sonst stuende es nicht
3203 : : // mehr in der Liste
3204 : 0 : pLast = *ppHead;
3205 [ # # ][ # # ]: 0 : while( pLast && pLast->GetNext() != pAttr )
[ # # ]
3206 : 0 : pLast = pLast->GetNext();
3207 : :
3208 : : OSL_ENSURE( pLast, "Attribut nicht in eigener Liste gefunden!" );
3209 : : }
3210 : :
3211 : : // nun das Attrubut entfernen
3212 : 0 : _HTMLAttr *pNext = pAttr->GetNext();
3213 : 0 : _HTMLAttr *pPrev = pAttr->GetPrev();
3214 [ # # ][ # # ]: 0 : delete pAttr;
3215 : :
3216 [ # # ]: 0 : if( pPrev )
3217 : : {
3218 : : // Die Previous-Attribute muessen trotzdem gesetzt werden.
3219 [ # # ]: 0 : if( pNext )
3220 : 0 : pNext->InsertPrev( pPrev );
3221 : : else
3222 : : {
3223 [ # # ]: 0 : if (pPrev->bInsAtStart)
3224 [ # # ]: 0 : aSetAttrTab.push_front( pPrev );
3225 : : else
3226 [ # # ]: 0 : aSetAttrTab.push_back( pPrev );
3227 : : }
3228 : : }
3229 : :
3230 : : // wenn das erste Attribut der Liste entfernt wurde muss noch der
3231 : : // Listenkopf korrigiert werden.
3232 [ # # ]: 0 : if( pLast )
3233 : 0 : pLast->pNext = pNext;
3234 [ # # ]: 0 : else if( ppHead )
3235 : 0 : *ppHead = pNext;
3236 : 0 : }
3237 : :
3238 : 0 : void SwHTMLParser::SaveAttrTab( _HTMLAttrTable& rNewAttrTab )
3239 : : {
3240 : : // preliminary paragraph attributes are not allowed here, they could
3241 : : // be set here and then the pointers become invalid!
3242 : : OSL_ENSURE(aParaAttrs.empty(),
3243 : : "Danger: there are non-final paragraph attributes");
3244 [ # # ]: 0 : if( !aParaAttrs.empty() )
3245 : 0 : aParaAttrs.clear();
3246 : :
3247 : 0 : _HTMLAttr** pTbl = (_HTMLAttr**)&aAttrTab;
3248 : 0 : _HTMLAttr** pSaveTbl = (_HTMLAttr**)&rNewAttrTab;
3249 : :
3250 [ # # ]: 0 : for( sal_uInt16 nCnt = sizeof( _HTMLAttrTable ) / sizeof( _HTMLAttr* );
3251 : : nCnt--; (++pTbl, ++pSaveTbl) )
3252 : : {
3253 : 0 : *pSaveTbl = *pTbl;
3254 : :
3255 : 0 : _HTMLAttr *pAttr = *pSaveTbl;
3256 [ # # ]: 0 : while( pAttr )
3257 : : {
3258 : 0 : pAttr->SetHead( pSaveTbl );
3259 : 0 : pAttr = pAttr->GetNext();
3260 : : }
3261 : :
3262 : 0 : *pTbl = 0;
3263 : : }
3264 : 0 : }
3265 : :
3266 : 0 : void SwHTMLParser::SplitAttrTab( _HTMLAttrTable& rNewAttrTab,
3267 : : sal_Bool bMoveEndBack )
3268 : : {
3269 : : // preliminary paragraph attributes are not allowed here, they could
3270 : : // be set here and then the pointers become invalid!
3271 : : OSL_ENSURE(aParaAttrs.empty(),
3272 : : "Danger: there are non-final paragraph attributes");
3273 [ # # ]: 0 : if( !aParaAttrs.empty() )
3274 : 0 : aParaAttrs.clear();
3275 : :
3276 : 0 : const SwNodeIndex& nSttIdx = pPam->GetPoint()->nNode;
3277 [ # # ]: 0 : SwNodeIndex nEndIdx( nSttIdx );
3278 : :
3279 : : // alle noch offenen Attribute beenden und hinter der Tabelle
3280 : : // neu aufspannen
3281 : 0 : _HTMLAttr** pTbl = (_HTMLAttr**)&aAttrTab;
3282 : 0 : _HTMLAttr** pSaveTbl = (_HTMLAttr**)&rNewAttrTab;
3283 : 0 : sal_Bool bSetAttr = sal_True;
3284 : 0 : xub_StrLen nSttCnt = pPam->GetPoint()->nContent.GetIndex();
3285 : 0 : xub_StrLen nEndCnt = nSttCnt;
3286 : :
3287 [ # # ]: 0 : if( bMoveEndBack )
3288 : : {
3289 : 0 : sal_uLong nOldEnd = nEndIdx.GetIndex();
3290 : : sal_uLong nTmpIdx;
3291 [ # # # # ]: 0 : if( ( nTmpIdx = pDoc->GetNodes().GetEndOfExtras().GetIndex()) >= nOldEnd ||
[ # # ][ # # ]
3292 [ # # ]: 0 : ( nTmpIdx = pDoc->GetNodes().GetEndOfAutotext().GetIndex()) >= nOldEnd )
3293 : : {
3294 [ # # ]: 0 : nTmpIdx = pDoc->GetNodes().GetEndOfInserts().GetIndex();
3295 : : }
3296 [ # # ][ # # ]: 0 : SwCntntNode* pCNd = pDoc->GetNodes().GoPrevious(&nEndIdx);
3297 : :
3298 : : // keine Attribute setzen, wenn der PaM aus dem Content-Bereich
3299 : : // herausgeschoben wurde.
3300 [ # # ][ # # ]: 0 : bSetAttr = pCNd && nTmpIdx < nEndIdx.GetIndex();
3301 : :
3302 [ # # ][ # # ]: 0 : nEndCnt = (bSetAttr ? pCNd->Len() : 0);
3303 : : }
3304 [ # # ]: 0 : for( sal_uInt16 nCnt = sizeof( _HTMLAttrTable ) / sizeof( _HTMLAttr* );
3305 : : nCnt--; (++pTbl, ++pSaveTbl) )
3306 : : {
3307 : 0 : _HTMLAttr *pAttr = *pTbl;
3308 : 0 : *pSaveTbl = 0;
3309 [ # # ]: 0 : while( pAttr )
3310 : : {
3311 : 0 : _HTMLAttr *pNext = pAttr->GetNext();
3312 : 0 : _HTMLAttr *pPrev = pAttr->GetPrev();
3313 : :
3314 [ # # ][ # # : 0 : if( bSetAttr &&
# # # # #
# ]
3315 : 0 : ( pAttr->GetSttParaIdx() < nEndIdx.GetIndex() ||
3316 : 0 : (pAttr->GetSttPara() == nEndIdx &&
3317 : 0 : pAttr->GetSttCnt() != nEndCnt) ) )
3318 : : {
3319 : : // das Attribut muss vor der Liste gesetzt werden. Da wir
3320 : : // das Original noch brauchen, weil Zeiger auf das Attribut
3321 : : // noch in den Kontexten existieren, muessen wir es clonen.
3322 : : // Die Next-Liste geht dabei verloren, aber die
3323 : : // Previous-Liste bleibt erhalten
3324 [ # # ]: 0 : _HTMLAttr *pSetAttr = pAttr->Clone( nEndIdx, nEndCnt );
3325 : :
3326 [ # # ]: 0 : if( pNext )
3327 : 0 : pNext->InsertPrev( pSetAttr );
3328 : : else
3329 : : {
3330 [ # # ]: 0 : if (pSetAttr->bInsAtStart)
3331 [ # # ]: 0 : aSetAttrTab.push_front( pSetAttr );
3332 : : else
3333 [ # # ]: 0 : aSetAttrTab.push_back( pSetAttr );
3334 : : }
3335 : : }
3336 [ # # ]: 0 : else if( pPrev )
3337 : : {
3338 : : // Wenn das Attribut nicht gesetzt vor der Tabelle
3339 : : // gesetzt werden muss, muessen der Previous-Attribute
3340 : : // trotzdem gesetzt werden.
3341 [ # # ]: 0 : if( pNext )
3342 : 0 : pNext->InsertPrev( pPrev );
3343 : : else
3344 : : {
3345 [ # # ]: 0 : if (pPrev->bInsAtStart)
3346 [ # # ]: 0 : aSetAttrTab.push_front( pPrev );
3347 : : else
3348 [ # # ]: 0 : aSetAttrTab.push_back( pPrev );
3349 : : }
3350 : : }
3351 : :
3352 : : // den Start des Attributs neu setzen und die Verkettungen
3353 : : // aufbrechen
3354 [ # # ]: 0 : pAttr->Reset( nSttIdx, nSttCnt, pSaveTbl );
3355 : :
3356 [ # # ]: 0 : if( *pSaveTbl )
3357 : : {
3358 : 0 : _HTMLAttr *pSAttr = *pSaveTbl;
3359 [ # # ]: 0 : while( pSAttr->GetNext() )
3360 : 0 : pSAttr = pSAttr->GetNext();
3361 : 0 : pSAttr->InsertNext( pAttr );
3362 : : }
3363 : : else
3364 : 0 : *pSaveTbl = pAttr;
3365 : :
3366 : 0 : pAttr = pNext;
3367 : : }
3368 : :
3369 : 0 : *pTbl = 0;
3370 [ # # ]: 0 : }
3371 : 0 : }
3372 : :
3373 : 0 : void SwHTMLParser::RestoreAttrTab( const _HTMLAttrTable& rNewAttrTab,
3374 : : sal_Bool bSetNewStart )
3375 : : {
3376 : : // preliminary paragraph attributes are not allowed here, they could
3377 : : // be set here and then the pointers become invalid!
3378 : : OSL_ENSURE(aParaAttrs.empty(),
3379 : : "Danger: there are non-final paragraph attributes");
3380 [ # # ]: 0 : if( !aParaAttrs.empty() )
3381 : 0 : aParaAttrs.clear();
3382 : :
3383 : 0 : _HTMLAttr** pTbl = (_HTMLAttr**)&aAttrTab;
3384 : 0 : _HTMLAttr** pSaveTbl = (_HTMLAttr**)&rNewAttrTab;
3385 : :
3386 [ # # ]: 0 : for( sal_uInt16 nCnt = sizeof( _HTMLAttrTable ) / sizeof( _HTMLAttr* );
3387 : : nCnt--; (++pTbl, ++pSaveTbl) )
3388 : : {
3389 : : OSL_ENSURE( !*pTbl, "Die Attribut-Tabelle ist nicht leer!" );
3390 : :
3391 : 0 : const SwPosition *pPos = pPam->GetPoint();
3392 : 0 : const SwNodeIndex& rSttPara = pPos->nNode;
3393 : 0 : xub_StrLen nSttCnt = pPos->nContent.GetIndex();
3394 : :
3395 : 0 : *pTbl = *pSaveTbl;
3396 : :
3397 : 0 : _HTMLAttr *pAttr = *pTbl;
3398 [ # # ]: 0 : while( pAttr )
3399 : : {
3400 : : OSL_ENSURE( !pAttr->GetPrev() || !pAttr->GetPrev()->ppHead,
3401 : : "Previous-Attribut hat noch einen Header" );
3402 : 0 : pAttr->SetHead( pTbl );
3403 [ # # ]: 0 : if( bSetNewStart )
3404 : : {
3405 : 0 : pAttr->nSttPara = rSttPara;
3406 : 0 : pAttr->nEndPara = rSttPara;
3407 : 0 : pAttr->nSttCntnt = nSttCnt;
3408 : 0 : pAttr->nEndCntnt = nSttCnt;
3409 : : }
3410 : 0 : pAttr = pAttr->GetNext();
3411 : : }
3412 : :
3413 : 0 : *pSaveTbl = 0;
3414 : : }
3415 : 0 : }
3416 : :
3417 : 0 : void SwHTMLParser::InsertAttr( const SfxPoolItem& rItem, sal_Bool bLikePara,
3418 : : sal_Bool bInsAtStart )
3419 : : {
3420 : 0 : _HTMLAttr* pTmp = new _HTMLAttr( *pPam->GetPoint(),
3421 [ # # ][ # # ]: 0 : rItem );
3422 [ # # ]: 0 : if( bLikePara )
3423 : 0 : pTmp->SetLikePara();
3424 [ # # ]: 0 : if (bInsAtStart)
3425 [ # # ]: 0 : aSetAttrTab.push_front( pTmp );
3426 : : else
3427 [ # # ]: 0 : aSetAttrTab.push_back( pTmp );
3428 : 0 : }
3429 : :
3430 : 0 : void SwHTMLParser::InsertAttrs( _HTMLAttrs& rAttrs )
3431 : : {
3432 [ # # ]: 0 : while( !rAttrs.empty() )
3433 : : {
3434 : 0 : _HTMLAttr *pAttr = rAttrs.front();
3435 : 0 : InsertAttr( pAttr->GetItem() );
3436 : 0 : rAttrs.pop_front();
3437 [ # # ]: 0 : delete pAttr;
3438 : : }
3439 : 0 : }
3440 : :
3441 : 0 : void SwHTMLParser::NewStdAttr( int nToken )
3442 : : {
3443 [ # # ][ # # ]: 0 : String aId, aStyle, aClass, aLang, aDir;
[ # # ][ # # ]
[ # # ]
3444 : :
3445 [ # # ]: 0 : const HTMLOptions& rHTMLOptions = GetOptions();
3446 [ # # ]: 0 : for (size_t i = rHTMLOptions.size(); i; )
3447 : : {
3448 [ # # ]: 0 : const HTMLOption& rOption = rHTMLOptions[--i];
3449 [ # # # # : 0 : switch( rOption.GetToken() )
# # ]
3450 : : {
3451 : : case HTML_O_ID:
3452 [ # # ]: 0 : aId = rOption.GetString();
3453 : 0 : break;
3454 : : case HTML_O_STYLE:
3455 [ # # ]: 0 : aStyle = rOption.GetString();
3456 : 0 : break;
3457 : : case HTML_O_CLASS:
3458 [ # # ]: 0 : aClass = rOption.GetString();
3459 : 0 : break;
3460 : : case HTML_O_LANG:
3461 [ # # ]: 0 : aLang = rOption.GetString();
3462 : 0 : break;
3463 : : case HTML_O_DIR:
3464 [ # # ]: 0 : aDir = rOption.GetString();
3465 : 0 : break;
3466 : : }
3467 : : }
3468 : :
3469 : : // einen neuen Kontext anlegen
3470 [ # # ][ # # ]: 0 : _HTMLAttrContext *pCntxt = new _HTMLAttrContext( static_cast< sal_uInt16 >(nToken) );
3471 : :
3472 : : // Styles parsen
3473 [ # # ]: 0 : if( HasStyleOptions( aStyle, aId, aClass, &aLang, &aDir ) )
3474 : : {
3475 [ # # ][ # # ]: 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
3476 [ # # ]: 0 : SvxCSS1PropertyInfo aPropInfo;
3477 : :
3478 [ # # ][ # # ]: 0 : if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo, &aLang, &aDir ) )
3479 : : {
3480 [ # # ][ # # ]: 0 : if( HTML_SPAN_ON != nToken || !aClass.Len() ||
[ # # ][ # # ]
3481 [ # # ]: 0 : !CreateContainer( aClass, aItemSet, aPropInfo, pCntxt ) )
3482 [ # # ]: 0 : DoPositioning( aItemSet, aPropInfo, pCntxt );
3483 [ # # ]: 0 : InsertAttrs( aItemSet, aPropInfo, pCntxt, sal_True );
3484 [ # # ][ # # ]: 0 : }
3485 : : }
3486 : :
3487 : : // den Kontext merken
3488 [ # # ][ # # ]: 0 : PushContext( pCntxt );
[ # # ][ # # ]
[ # # ][ # # ]
3489 : 0 : }
3490 : :
3491 : 0 : void SwHTMLParser::NewStdAttr( int nToken,
3492 : : _HTMLAttr **ppAttr, const SfxPoolItem & rItem,
3493 : : _HTMLAttr **ppAttr2, const SfxPoolItem *pItem2,
3494 : : _HTMLAttr **ppAttr3, const SfxPoolItem *pItem3 )
3495 : : {
3496 [ # # ][ # # ]: 0 : String aId, aStyle, aClass, aLang, aDir;
[ # # ][ # # ]
[ # # ]
3497 : :
3498 [ # # ]: 0 : const HTMLOptions& rHTMLOptions = GetOptions();
3499 [ # # ]: 0 : for (size_t i = rHTMLOptions.size(); i; )
3500 : : {
3501 [ # # ]: 0 : const HTMLOption& rOption = rHTMLOptions[--i];
3502 [ # # # # : 0 : switch( rOption.GetToken() )
# # ]
3503 : : {
3504 : : case HTML_O_ID:
3505 [ # # ]: 0 : aId = rOption.GetString();
3506 : 0 : break;
3507 : : case HTML_O_STYLE:
3508 [ # # ]: 0 : aStyle = rOption.GetString();
3509 : 0 : break;
3510 : : case HTML_O_CLASS:
3511 [ # # ]: 0 : aClass = rOption.GetString();
3512 : 0 : break;
3513 : : case HTML_O_LANG:
3514 [ # # ]: 0 : aLang = rOption.GetString();
3515 : 0 : break;
3516 : : case HTML_O_DIR:
3517 [ # # ]: 0 : aDir = rOption.GetString();
3518 : 0 : break;
3519 : : }
3520 : : }
3521 : :
3522 : : // einen neuen Kontext anlegen
3523 [ # # ][ # # ]: 0 : _HTMLAttrContext *pCntxt = new _HTMLAttrContext( static_cast< sal_uInt16 >(nToken) );
3524 : :
3525 : : // Styles parsen
3526 [ # # ]: 0 : if( HasStyleOptions( aStyle, aId, aClass, &aLang, &aDir ) )
3527 : : {
3528 [ # # ][ # # ]: 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
3529 [ # # ]: 0 : SvxCSS1PropertyInfo aPropInfo;
3530 : :
3531 [ # # ]: 0 : aItemSet.Put( rItem );
3532 [ # # ]: 0 : if( pItem2 )
3533 [ # # ]: 0 : aItemSet.Put( *pItem2 );
3534 [ # # ]: 0 : if( pItem3 )
3535 [ # # ]: 0 : aItemSet.Put( *pItem3 );
3536 : :
3537 [ # # ][ # # ]: 0 : if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo, &aLang, &aDir ) )
3538 [ # # ]: 0 : DoPositioning( aItemSet, aPropInfo, pCntxt );
3539 : :
3540 [ # # ][ # # ]: 0 : InsertAttrs( aItemSet, aPropInfo, pCntxt, sal_True );
[ # # ]
3541 : : }
3542 : : else
3543 : : {
3544 [ # # ]: 0 : InsertAttr( ppAttr ,rItem, pCntxt );
3545 [ # # ]: 0 : if( pItem2 )
3546 : : {
3547 : : OSL_ENSURE( ppAttr2, "missing table entry for item2" );
3548 [ # # ]: 0 : InsertAttr( ppAttr2, *pItem2, pCntxt );
3549 : : }
3550 [ # # ]: 0 : if( pItem3 )
3551 : : {
3552 : : OSL_ENSURE( ppAttr3, "missing table entry for item3" );
3553 [ # # ]: 0 : InsertAttr( ppAttr3, *pItem3, pCntxt );
3554 : : }
3555 : : }
3556 : :
3557 : : // den Kontext merken
3558 [ # # ][ # # ]: 0 : PushContext( pCntxt );
[ # # ][ # # ]
[ # # ][ # # ]
3559 : 0 : }
3560 : :
3561 : 0 : void SwHTMLParser::EndTag( int nToken )
3562 : : {
3563 : : // den Kontext holen
3564 : 0 : _HTMLAttrContext *pCntxt = PopContext( static_cast< sal_uInt16 >(nToken & ~1) );
3565 [ # # ]: 0 : if( pCntxt )
3566 : : {
3567 : : // und ggf. die Attribute beenden
3568 : 0 : EndContext( pCntxt );
3569 [ # # ]: 0 : delete pCntxt;
3570 : : }
3571 : 0 : }
3572 : :
3573 : :
3574 : 0 : void SwHTMLParser::NewBasefontAttr()
3575 : : {
3576 [ # # ][ # # ]: 0 : String aId, aStyle, aClass, aLang, aDir;
[ # # ][ # # ]
[ # # ]
3577 : 0 : sal_uInt16 nSize = 3;
3578 : :
3579 [ # # ]: 0 : const HTMLOptions& rHTMLOptions = GetOptions();
3580 [ # # ]: 0 : for (size_t i = rHTMLOptions.size(); i; )
3581 : : {
3582 [ # # ]: 0 : const HTMLOption& rOption = rHTMLOptions[--i];
3583 [ # # # # : 0 : switch( rOption.GetToken() )
# # # ]
3584 : : {
3585 : : case HTML_O_SIZE:
3586 [ # # ]: 0 : nSize = (sal_uInt16)rOption.GetNumber();
3587 : 0 : break;
3588 : : case HTML_O_ID:
3589 [ # # ]: 0 : aId = rOption.GetString();
3590 : 0 : break;
3591 : : case HTML_O_STYLE:
3592 [ # # ]: 0 : aStyle = rOption.GetString();
3593 : 0 : break;
3594 : : case HTML_O_CLASS:
3595 [ # # ]: 0 : aClass = rOption.GetString();
3596 : 0 : break;
3597 : : case HTML_O_LANG:
3598 [ # # ]: 0 : aLang = rOption.GetString();
3599 : 0 : break;
3600 : : case HTML_O_DIR:
3601 [ # # ]: 0 : aDir = rOption.GetString();
3602 : 0 : break;
3603 : : }
3604 : : }
3605 : :
3606 [ # # ]: 0 : if( nSize < 1 )
3607 : 0 : nSize = 1;
3608 : :
3609 [ # # ]: 0 : if( nSize > 7 )
3610 : 0 : nSize = 7;
3611 : :
3612 : : // einen neuen Kontext anlegen
3613 [ # # ][ # # ]: 0 : _HTMLAttrContext *pCntxt = new _HTMLAttrContext( HTML_BASEFONT_ON );
3614 : :
3615 : : // Styles parsen
3616 [ # # ]: 0 : if( HasStyleOptions( aStyle, aId, aClass, &aLang, &aDir ) )
3617 : : {
3618 [ # # ][ # # ]: 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
3619 [ # # ]: 0 : SvxCSS1PropertyInfo aPropInfo;
3620 : :
3621 : : //CJK has different defaults
3622 [ # # ]: 0 : SvxFontHeightItem aFontHeight( aFontHeights[nSize-1], 100, RES_CHRATR_FONTSIZE );
3623 [ # # ]: 0 : aItemSet.Put( aFontHeight );
3624 [ # # ]: 0 : SvxFontHeightItem aFontHeightCJK( aFontHeights[nSize-1], 100, RES_CHRATR_CJK_FONTSIZE );
3625 [ # # ]: 0 : aItemSet.Put( aFontHeightCJK );
3626 : : //Complex type can contain so many types of letters,
3627 : : //that it's not really worthy to bother, IMO.
3628 : : //Still, I have set a default.
3629 [ # # ]: 0 : SvxFontHeightItem aFontHeightCTL( aFontHeights[nSize-1], 100, RES_CHRATR_CTL_FONTSIZE );
3630 [ # # ]: 0 : aItemSet.Put( aFontHeightCTL );
3631 : :
3632 [ # # ][ # # ]: 0 : if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo, &aLang, &aDir ) )
3633 [ # # ]: 0 : DoPositioning( aItemSet, aPropInfo, pCntxt );
3634 : :
3635 [ # # ][ # # ]: 0 : InsertAttrs( aItemSet, aPropInfo, pCntxt, sal_True );
[ # # ][ # # ]
[ # # ][ # # ]
3636 : : }
3637 : : else
3638 : : {
3639 [ # # ]: 0 : SvxFontHeightItem aFontHeight( aFontHeights[nSize-1], 100, RES_CHRATR_FONTSIZE );
3640 [ # # ]: 0 : InsertAttr( &aAttrTab.pFontHeight, aFontHeight, pCntxt );
3641 [ # # ]: 0 : SvxFontHeightItem aFontHeightCJK( aFontHeights[nSize-1], 100, RES_CHRATR_CJK_FONTSIZE );
3642 [ # # ]: 0 : InsertAttr( &aAttrTab.pFontHeightCJK, aFontHeightCJK, pCntxt );
3643 [ # # ]: 0 : SvxFontHeightItem aFontHeightCTL( aFontHeights[nSize-1], 100, RES_CHRATR_CTL_FONTSIZE );
3644 [ # # ][ # # ]: 0 : InsertAttr( &aAttrTab.pFontHeightCJK, aFontHeightCTL, pCntxt );
[ # # ][ # # ]
3645 : : }
3646 : :
3647 : : // den Kontext merken
3648 [ # # ]: 0 : PushContext( pCntxt );
3649 : :
3650 : : // die Font-Size merken
3651 [ # # ][ # # ]: 0 : aBaseFontStack.push_back( nSize );
[ # # ][ # # ]
[ # # ][ # # ]
3652 : 0 : }
3653 : :
3654 : 0 : void SwHTMLParser::EndBasefontAttr()
3655 : : {
3656 : 0 : EndTag( HTML_BASEFONT_ON );
3657 : :
3658 : : // Stack-Unterlauf in Tabellen vermeiden
3659 [ # # ]: 0 : if( aBaseFontStack.size() > nBaseFontStMin )
3660 [ # # ][ # # ]: 0 : aBaseFontStack.erase( aBaseFontStack.begin() + aBaseFontStack.size() - 1 );
[ # # ]
3661 : 0 : }
3662 : :
3663 : 0 : void SwHTMLParser::NewFontAttr( int nToken )
3664 : : {
3665 : : sal_uInt16 nBaseSize =
3666 : 0 : ( aBaseFontStack.size() > nBaseFontStMin
3667 [ # # ]: 0 : ? (aBaseFontStack[aBaseFontStack.size()-1] & FONTSIZE_MASK)
3668 [ # # ]: 0 : : 3 );
3669 : : sal_uInt16 nFontSize =
3670 : 0 : ( aFontStack.size() > nFontStMin
3671 [ # # ]: 0 : ? (aFontStack[aFontStack.size()-1] & FONTSIZE_MASK)
3672 [ # # ]: 0 : : nBaseSize );
3673 : :
3674 [ # # ][ # # ]: 0 : String aFace, aId, aStyle, aClass, aLang, aDir;
[ # # ][ # # ]
[ # # ][ # # ]
3675 : 0 : Color aColor;
3676 : 0 : sal_uLong nFontHeight = 0; // tatsaechlich einzustellende Font-Hoehe
3677 : 0 : sal_uInt16 nSize = 0; // Fontgroesse in Netscape-Notation (1-7)
3678 : 0 : sal_Bool bColor = sal_False;
3679 : :
3680 [ # # ]: 0 : const HTMLOptions& rHTMLOptions = GetOptions();
3681 [ # # ]: 0 : for (size_t i = rHTMLOptions.size(); i; )
3682 : : {
3683 [ # # ]: 0 : const HTMLOption& rOption = rHTMLOptions[--i];
3684 [ # # # # : 0 : switch( rOption.GetToken() )
# # # #
# ]
3685 : : {
3686 : : case HTML_O_SIZE:
3687 [ # # ][ # # ]: 0 : if( HTML_FONT_ON==nToken && rOption.GetString().Len() )
[ # # ]
3688 : : {
3689 : : sal_Int32 nSSize;
3690 [ # # # # ]: 0 : if( '+' == rOption.GetString().GetChar(0) ||
[ # # ]
3691 : 0 : '-' == rOption.GetString().GetChar(0) )
3692 [ # # ]: 0 : nSSize = nBaseSize + rOption.GetSNumber();
3693 : : else
3694 [ # # ]: 0 : nSSize = (sal_Int32)rOption.GetNumber();
3695 : :
3696 [ # # ]: 0 : if( nSSize < 1 )
3697 : 0 : nSSize = 1;
3698 [ # # ]: 0 : else if( nSSize > 7 )
3699 : 0 : nSSize = 7;
3700 : :
3701 : 0 : nSize = (sal_uInt16)nSSize;
3702 : 0 : nFontHeight = aFontHeights[nSize-1];
3703 : : }
3704 : 0 : break;
3705 : : case HTML_O_COLOR:
3706 [ # # ]: 0 : if( HTML_FONT_ON==nToken )
3707 : : {
3708 [ # # ]: 0 : rOption.GetColor( aColor );
3709 : 0 : bColor = sal_True;
3710 : : }
3711 : 0 : break;
3712 : : case HTML_O_FACE:
3713 [ # # ]: 0 : if( HTML_FONT_ON==nToken )
3714 [ # # ]: 0 : aFace = rOption.GetString();
3715 : 0 : break;
3716 : : case HTML_O_ID:
3717 [ # # ]: 0 : aId = rOption.GetString();
3718 : 0 : break;
3719 : : case HTML_O_STYLE:
3720 [ # # ]: 0 : aStyle = rOption.GetString();
3721 : 0 : break;
3722 : : case HTML_O_CLASS:
3723 [ # # ]: 0 : aClass = rOption.GetString();
3724 : 0 : break;
3725 : : case HTML_O_LANG:
3726 [ # # ]: 0 : aLang = rOption.GetString();
3727 : 0 : break;
3728 : : case HTML_O_DIR:
3729 [ # # ]: 0 : aDir = rOption.GetString();
3730 : 0 : break;
3731 : : }
3732 : : }
3733 : :
3734 [ # # ]: 0 : if( HTML_FONT_ON != nToken )
3735 : : {
3736 : : // HTML_BIGPRINT_ON oder HTML_SMALLPRINT_ON
3737 : :
3738 : : // in Ueberschriften bestimmt die aktuelle Ueberschrift
3739 : : // die Font-Hoehe und nicht BASEFONT
3740 : 0 : sal_uInt16 nPoolId = GetCurrFmtColl()->GetPoolFmtId();
3741 [ # # ][ # # ]: 0 : if( (nPoolId>=RES_POOLCOLL_HEADLINE1 &&
3742 : : nPoolId<=RES_POOLCOLL_HEADLINE6) )
3743 : : {
3744 : : // wenn die Schriftgroesse in der Ueberschrift noch
3745 : : // nicht veraendert ist, die aus der Vorlage nehmen
3746 [ # # ]: 0 : if( nFontStHeadStart==aFontStack.size() )
3747 : 0 : nFontSize = static_cast< sal_uInt16 >(6 - (nPoolId - RES_POOLCOLL_HEADLINE1));
3748 : : }
3749 : : else
3750 : 0 : nPoolId = 0;
3751 : :
3752 [ # # ]: 0 : if( HTML_BIGPRINT_ON == nToken )
3753 [ # # ]: 0 : nSize = ( nFontSize<7 ? nFontSize+1 : 7 );
3754 : : else
3755 [ # # ]: 0 : nSize = ( nFontSize>1 ? nFontSize-1 : 1 );
3756 : :
3757 : : // in Ueberschriften wird die neue Fonthoehe wenn moeglich aus
3758 : : // den Vorlagen geholt.
3759 [ # # ][ # # ]: 0 : if( nPoolId && nSize>=1 && nSize <=6 )
[ # # ]
3760 : : nFontHeight =
3761 : : pCSS1Parser->GetTxtCollFromPool(
3762 [ # # ][ # # ]: 0 : RES_POOLCOLL_HEADLINE1+6-nSize )->GetSize().GetHeight();
3763 : : else
3764 : 0 : nFontHeight = aFontHeights[nSize-1];
3765 : : }
3766 : :
3767 : : OSL_ENSURE( !nSize == !nFontHeight, "HTML-Font-Size != Font-Height" );
3768 : :
3769 [ # # ][ # # ]: 0 : String aFontName, aStyleName;
3770 : 0 : FontFamily eFamily = FAMILY_DONTKNOW; // Family und Pitch,
3771 : 0 : FontPitch ePitch = PITCH_DONTKNOW; // falls nicht gefunden
3772 [ # # ]: 0 : rtl_TextEncoding eEnc = osl_getThreadTextEncoding();
3773 : :
3774 [ # # ][ # # ]: 0 : if( aFace.Len() && !pCSS1Parser->IsIgnoreFontFamily() )
[ # # ]
3775 : : {
3776 : 0 : const FontList *pFList = 0;
3777 : 0 : SwDocShell *pDocSh = pDoc->GetDocShell();
3778 [ # # ]: 0 : if( pDocSh )
3779 : : {
3780 : : const SvxFontListItem *pFListItem =
3781 [ # # ]: 0 : (const SvxFontListItem *)pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST);
3782 [ # # ]: 0 : if( pFListItem )
3783 : 0 : pFList = pFListItem->GetFontList();
3784 : : }
3785 : :
3786 : 0 : sal_Bool bFound = sal_False;
3787 : 0 : xub_StrLen nStrPos = 0;
3788 [ # # ]: 0 : while( nStrPos!=STRING_NOTFOUND )
3789 : : {
3790 [ # # ]: 0 : String aFName = aFace.GetToken( 0, ',', nStrPos );
3791 [ # # ][ # # ]: 0 : aFName = comphelper::string::strip(aFName, ' ');
[ # # ]
3792 [ # # ]: 0 : if( aFName.Len() )
3793 : : {
3794 [ # # ][ # # ]: 0 : if( !bFound && pFList )
3795 : : {
3796 [ # # ]: 0 : sal_Handle hFont = pFList->GetFirstFontInfo( aFName );
3797 [ # # ]: 0 : if( 0 != hFont )
3798 : : {
3799 [ # # ]: 0 : const FontInfo& rFInfo = pFList->GetFontInfo( hFont );
3800 [ # # ][ # # ]: 0 : if( RTL_TEXTENCODING_DONTKNOW != rFInfo.GetCharSet() )
3801 : : {
3802 : 0 : bFound = sal_True;
3803 [ # # ][ # # ]: 0 : if( RTL_TEXTENCODING_SYMBOL == rFInfo.GetCharSet() )
3804 : 0 : eEnc = RTL_TEXTENCODING_SYMBOL;
3805 : : }
3806 : : }
3807 : : }
3808 [ # # ]: 0 : if( aFontName.Len() )
3809 [ # # ]: 0 : aFontName += ';';
3810 [ # # ]: 0 : aFontName += aFName;
3811 : : }
3812 [ # # ]: 0 : }
3813 : : }
3814 : :
3815 : :
3816 : : // einen neuen Kontext anlegen
3817 [ # # ][ # # ]: 0 : _HTMLAttrContext *pCntxt = new _HTMLAttrContext( static_cast< sal_uInt16 >(nToken) );
3818 : :
3819 : : // Styles parsen
3820 [ # # ]: 0 : if( HasStyleOptions( aStyle, aId, aClass, &aLang, &aDir ) )
3821 : : {
3822 [ # # ][ # # ]: 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
3823 [ # # ]: 0 : SvxCSS1PropertyInfo aPropInfo;
3824 : :
3825 [ # # ]: 0 : if( nFontHeight )
3826 : : {
3827 [ # # ]: 0 : SvxFontHeightItem aFontHeight( nFontHeight, 100, RES_CHRATR_FONTSIZE );
3828 [ # # ]: 0 : aItemSet.Put( aFontHeight );
3829 [ # # ]: 0 : SvxFontHeightItem aFontHeightCJK( nFontHeight, 100, RES_CHRATR_CJK_FONTSIZE );
3830 [ # # ]: 0 : aItemSet.Put( aFontHeightCJK );
3831 [ # # ]: 0 : SvxFontHeightItem aFontHeightCTL( nFontHeight, 100, RES_CHRATR_CTL_FONTSIZE );
3832 [ # # ][ # # ]: 0 : aItemSet.Put( aFontHeightCTL );
[ # # ][ # # ]
3833 : : }
3834 [ # # ]: 0 : if( bColor )
3835 [ # # ][ # # ]: 0 : aItemSet.Put( SvxColorItem(aColor, RES_CHRATR_COLOR) );
[ # # ]
3836 [ # # ]: 0 : if( aFontName.Len() )
3837 : : {
3838 [ # # ]: 0 : SvxFontItem aFont( eFamily, aFontName, aStyleName, ePitch, eEnc, RES_CHRATR_FONT );
3839 [ # # ]: 0 : aItemSet.Put( aFont );
3840 [ # # ]: 0 : SvxFontItem aFontCJK( eFamily, aFontName, aStyleName, ePitch, eEnc, RES_CHRATR_CJK_FONT );
3841 [ # # ]: 0 : aItemSet.Put( aFontCJK );
3842 [ # # ]: 0 : SvxFontItem aFontCTL( eFamily, aFontName, aStyleName, ePitch, eEnc, RES_CHRATR_CTL_FONT );
3843 [ # # ][ # # ]: 0 : aItemSet.Put( aFontCTL );
[ # # ][ # # ]
3844 : : }
3845 : :
3846 : :
3847 [ # # ][ # # ]: 0 : if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo, &aLang, &aDir ) )
3848 [ # # ]: 0 : DoPositioning( aItemSet, aPropInfo, pCntxt );
3849 : :
3850 [ # # ][ # # ]: 0 : InsertAttrs( aItemSet, aPropInfo, pCntxt, sal_True );
[ # # ]
3851 : : }
3852 : : else
3853 : : {
3854 [ # # ]: 0 : if( nFontHeight )
3855 : : {
3856 [ # # ]: 0 : SvxFontHeightItem aFontHeight( nFontHeight, 100, RES_CHRATR_FONTSIZE );
3857 [ # # ]: 0 : InsertAttr( &aAttrTab.pFontHeight, aFontHeight, pCntxt );
3858 [ # # ]: 0 : SvxFontHeightItem aFontHeightCJK( nFontHeight, 100, RES_CHRATR_CJK_FONTSIZE );
3859 [ # # ]: 0 : InsertAttr( &aAttrTab.pFontHeight, aFontHeightCJK, pCntxt );
3860 [ # # ]: 0 : SvxFontHeightItem aFontHeightCTL( nFontHeight, 100, RES_CHRATR_CTL_FONTSIZE );
3861 [ # # ][ # # ]: 0 : InsertAttr( &aAttrTab.pFontHeight, aFontHeightCTL, pCntxt );
[ # # ][ # # ]
3862 : : }
3863 [ # # ]: 0 : if( bColor )
3864 [ # # ][ # # ]: 0 : InsertAttr( &aAttrTab.pFontColor, SvxColorItem(aColor, RES_CHRATR_COLOR), pCntxt );
[ # # ]
3865 [ # # ]: 0 : if( aFontName.Len() )
3866 : : {
3867 [ # # ]: 0 : SvxFontItem aFont( eFamily, aFontName, aStyleName, ePitch, eEnc, RES_CHRATR_FONT );
3868 [ # # ]: 0 : InsertAttr( &aAttrTab.pFont, aFont, pCntxt );
3869 [ # # ]: 0 : SvxFontItem aFontCJK( eFamily, aFontName, aStyleName, ePitch, eEnc, RES_CHRATR_CJK_FONT );
3870 [ # # ]: 0 : InsertAttr( &aAttrTab.pFont, aFontCJK, pCntxt );
3871 [ # # ]: 0 : SvxFontItem aFontCTL( eFamily, aFontName, aStyleName, ePitch, eEnc, RES_CHRATR_CTL_FONT );
3872 [ # # ][ # # ]: 0 : InsertAttr( &aAttrTab.pFont, aFontCTL, pCntxt );
[ # # ][ # # ]
3873 : : }
3874 : : }
3875 : :
3876 : : // den Kontext merken
3877 [ # # ]: 0 : PushContext( pCntxt );
3878 : :
3879 [ # # ][ # # ]: 0 : aFontStack.push_back( nSize );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
3880 : 0 : }
3881 : :
3882 : 0 : void SwHTMLParser::EndFontAttr( int nToken )
3883 : : {
3884 : 0 : EndTag( nToken );
3885 : :
3886 : : // Stack-Unterlauf in Tabellen vermeiden
3887 [ # # ]: 0 : if( aFontStack.size() > nFontStMin )
3888 [ # # ][ # # ]: 0 : aFontStack.erase( aFontStack.begin() + aFontStack.size() - 1 );
[ # # ]
3889 : 0 : }
3890 : :
3891 : :
3892 : 2 : void SwHTMLParser::NewPara()
3893 : : {
3894 [ - + ]: 2 : if( pPam->GetPoint()->nContent.GetIndex() )
3895 [ # # ]: 0 : AppendTxtNode( AM_SPACE );
3896 : : else
3897 [ + - ]: 2 : AddParSpace();
3898 : :
3899 : 2 : eParaAdjust = SVX_ADJUST_END;
3900 [ + - ][ + - ]: 2 : String aId, aStyle, aClass, aLang, aDir;
[ + - ][ + - ]
[ + - ]
3901 : :
3902 [ + - ]: 2 : const HTMLOptions& rHTMLOptions = GetOptions();
3903 [ - + ]: 2 : for (size_t i = rHTMLOptions.size(); i; )
3904 : : {
3905 [ # # ]: 0 : const HTMLOption& rOption = rHTMLOptions[--i];
3906 [ # # # # : 0 : switch( rOption.GetToken() )
# # # ]
3907 : : {
3908 : : case HTML_O_ID:
3909 [ # # ]: 0 : aId = rOption.GetString();
3910 : 0 : break;
3911 : : case HTML_O_ALIGN:
3912 [ # # ]: 0 : eParaAdjust = (SvxAdjust)rOption.GetEnum( aHTMLPAlignTable, static_cast< sal_uInt16 >(eParaAdjust) );
3913 : 0 : break;
3914 : : case HTML_O_STYLE:
3915 [ # # ]: 0 : aStyle = rOption.GetString();
3916 : 0 : break;
3917 : : case HTML_O_CLASS:
3918 [ # # ]: 0 : aClass = rOption.GetString();
3919 : 0 : break;
3920 : : case HTML_O_LANG:
3921 [ # # ]: 0 : aLang = rOption.GetString();
3922 : 0 : break;
3923 : : case HTML_O_DIR:
3924 [ # # ]: 0 : aDir = rOption.GetString();
3925 : 0 : break;
3926 : : }
3927 : : }
3928 : :
3929 : : // einen neuen Kontext anlegen
3930 : : _HTMLAttrContext *pCntxt =
3931 : 2 : aClass.Len() ? new _HTMLAttrContext( HTML_PARABREAK_ON,
3932 [ # # ]: 0 : RES_POOLCOLL_TEXT, aClass )
3933 [ # # ][ + - ]: 2 : : new _HTMLAttrContext( HTML_PARABREAK_ON );
[ + - ][ - + ]
3934 : :
3935 : : // Styles parsen (Class nicht beruecksichtigen. Das geht nur, solange
3936 : : // keine der CSS1-Properties der Klasse hart formatiert werden muss!!!)
3937 [ - + ]: 2 : if( HasStyleOptions( aStyle, aId, aEmptyStr, &aLang, &aDir ) )
3938 : : {
3939 [ # # ][ # # ]: 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
3940 [ # # ]: 0 : SvxCSS1PropertyInfo aPropInfo;
3941 : :
3942 [ # # ][ # # ]: 0 : if( ParseStyleOptions( aStyle, aId, aEmptyStr, aItemSet, aPropInfo, &aLang, &aDir ) )
3943 : : {
3944 : : OSL_ENSURE( !aClass.Len() || !pCSS1Parser->GetClass( aClass ),
3945 : : "Class wird nicht beruecksichtigt" );
3946 [ # # ]: 0 : DoPositioning( aItemSet, aPropInfo, pCntxt );
3947 [ # # ]: 0 : InsertAttrs( aItemSet, aPropInfo, pCntxt );
3948 [ # # ][ # # ]: 0 : }
3949 : : }
3950 : :
3951 [ - + ]: 2 : if( SVX_ADJUST_END != eParaAdjust )
3952 [ # # ][ # # ]: 0 : InsertAttr( &aAttrTab.pAdjust, SvxAdjustItem(eParaAdjust, RES_PARATR_ADJUST), pCntxt );
[ # # ]
3953 : :
3954 : : // und auf den Stack packen
3955 [ + - ]: 2 : PushContext( pCntxt );
3956 : :
3957 : : // die aktuelle Vorlage oder deren Attribute setzen
3958 [ - + ][ + - ]: 2 : SetTxtCollAttrs( aClass.Len() ? pCntxt : 0 );
3959 : :
3960 : : // Laufbalkenanzeige
3961 [ + - ]: 2 : ShowStatline();
3962 : :
3963 : : OSL_ENSURE( !nOpenParaToken, "Jetzt geht ein offenes Absatz-Element verloren" );
3964 [ + - ][ + - ]: 2 : nOpenParaToken = HTML_PARABREAK_ON;
[ + - ][ + - ]
[ + - ]
3965 : 2 : }
3966 : :
3967 : 2 : void SwHTMLParser::EndPara( sal_Bool bReal )
3968 : : {
3969 [ - + ]: 2 : if( HTML_LI_ON==nOpenParaToken && pTable )
3970 : : {
3971 : : #if OSL_DEBUG_LEVEL > 0
3972 : : const SwNumRule *pNumRule = pPam->GetNode()->GetTxtNode()->GetNumRule();
3973 : : OSL_ENSURE( pNumRule, "Wo ist die Numrule geblieben" );
3974 : : #endif
3975 : : }
3976 : :
3977 : : // leere Absaetze werden von Netscape uebersprungen, von uns jetzt auch
3978 [ + - ]: 2 : if( bReal )
3979 : : {
3980 [ + - ]: 2 : if( pPam->GetPoint()->nContent.GetIndex() )
3981 : 2 : AppendTxtNode( AM_SPACE );
3982 : : else
3983 : 0 : AddParSpace();
3984 : : }
3985 : :
3986 : : // wenn ein DD oder DT offen war, handelt es sich um eine
3987 : : // implizite Def-Liste, die jetzt beendet werden muss
3988 [ + - ][ - + ]: 2 : if( (nOpenParaToken==HTML_DT_ON || nOpenParaToken==HTML_DD_ON) &&
[ # # ]
3989 : : nDefListDeep)
3990 : : {
3991 : 0 : nDefListDeep--;
3992 : : }
3993 : :
3994 : : // den Kontext vom Stack holen. Er kann auch von einer implizit
3995 : : // geoeffneten Definitionsliste kommen
3996 : : _HTMLAttrContext *pCntxt =
3997 : : PopContext( static_cast< sal_uInt16 >(nOpenParaToken ? (nOpenParaToken & ~1)
3998 [ + - ]: 2 : : HTML_PARABREAK_ON) );
3999 : :
4000 : : // Attribute beenden
4001 [ + - ]: 2 : if( pCntxt )
4002 : : {
4003 : 2 : EndContext( pCntxt );
4004 : 2 : SetAttr(); // Absatz-Atts wegen JavaScript moeglichst schnell setzen
4005 [ + - ]: 2 : delete pCntxt;
4006 : : }
4007 : :
4008 : : // und die bisherige Vorlage neu setzen
4009 [ + - ]: 2 : if( bReal )
4010 : 2 : SetTxtCollAttrs();
4011 : :
4012 : 2 : nOpenParaToken = 0;
4013 : 2 : }
4014 : :
4015 : :
4016 : 0 : void SwHTMLParser::NewHeading( int nToken )
4017 : : {
4018 : 0 : eParaAdjust = SVX_ADJUST_END;
4019 : :
4020 [ # # ][ # # ]: 0 : String aId, aStyle, aClass, aLang, aDir;
[ # # ][ # # ]
[ # # ]
4021 : :
4022 [ # # ]: 0 : const HTMLOptions& rHTMLOptions = GetOptions();
4023 [ # # ]: 0 : for (size_t i = rHTMLOptions.size(); i; )
4024 : : {
4025 [ # # ]: 0 : const HTMLOption& rOption = rHTMLOptions[--i];
4026 [ # # # # : 0 : switch( rOption.GetToken() )
# # # ]
4027 : : {
4028 : : case HTML_O_ID:
4029 [ # # ]: 0 : aId = rOption.GetString();
4030 : 0 : break;
4031 : : case HTML_O_ALIGN:
4032 [ # # ]: 0 : eParaAdjust = (SvxAdjust)rOption.GetEnum( aHTMLPAlignTable, static_cast< sal_uInt16 >(eParaAdjust) );
4033 : 0 : break;
4034 : : case HTML_O_STYLE:
4035 [ # # ]: 0 : aStyle = rOption.GetString();
4036 : 0 : break;
4037 : : case HTML_O_CLASS:
4038 [ # # ]: 0 : aClass = rOption.GetString();
4039 : 0 : break;
4040 : : case HTML_O_LANG:
4041 [ # # ]: 0 : aLang = rOption.GetString();
4042 : 0 : break;
4043 : : case HTML_O_DIR:
4044 [ # # ]: 0 : aDir = rOption.GetString();
4045 : 0 : break;
4046 : : }
4047 : : }
4048 : :
4049 : : // einen neuen Absatz aufmachen
4050 [ # # ]: 0 : if( pPam->GetPoint()->nContent.GetIndex() )
4051 [ # # ]: 0 : AppendTxtNode( AM_SPACE );
4052 : : else
4053 [ # # ]: 0 : AddParSpace();
4054 : :
4055 : : // die passende Vorlage suchen
4056 : : sal_uInt16 nTxtColl;
4057 [ # # # # : 0 : switch( nToken )
# # # ]
4058 : : {
4059 : 0 : case HTML_HEAD1_ON: nTxtColl = RES_POOLCOLL_HEADLINE1; break;
4060 : 0 : case HTML_HEAD2_ON: nTxtColl = RES_POOLCOLL_HEADLINE2; break;
4061 : 0 : case HTML_HEAD3_ON: nTxtColl = RES_POOLCOLL_HEADLINE3; break;
4062 : 0 : case HTML_HEAD4_ON: nTxtColl = RES_POOLCOLL_HEADLINE4; break;
4063 : 0 : case HTML_HEAD5_ON: nTxtColl = RES_POOLCOLL_HEADLINE5; break;
4064 : 0 : case HTML_HEAD6_ON: nTxtColl = RES_POOLCOLL_HEADLINE6; break;
4065 : 0 : default: nTxtColl = RES_POOLCOLL_STANDARD; break;
4066 : : }
4067 : :
4068 : : // den Kontext anlegen
4069 [ # # ][ # # ]: 0 : _HTMLAttrContext *pCntxt = new _HTMLAttrContext( static_cast< sal_uInt16 >(nToken), nTxtColl, aClass );
4070 : :
4071 : : // Styles parsen (zu Class siehe auch NewPara)
4072 [ # # ]: 0 : if( HasStyleOptions( aStyle, aId, aEmptyStr, &aLang, &aDir ) )
4073 : : {
4074 [ # # ][ # # ]: 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
4075 [ # # ]: 0 : SvxCSS1PropertyInfo aPropInfo;
4076 : :
4077 [ # # ][ # # ]: 0 : if( ParseStyleOptions( aStyle, aId, aEmptyStr, aItemSet, aPropInfo, &aLang, &aDir ) )
4078 : : {
4079 : : OSL_ENSURE( !aClass.Len() || !pCSS1Parser->GetClass( aClass ),
4080 : : "Class wird nicht beruecksichtigt" );
4081 [ # # ]: 0 : DoPositioning( aItemSet, aPropInfo, pCntxt );
4082 [ # # ]: 0 : InsertAttrs( aItemSet, aPropInfo, pCntxt );
4083 [ # # ][ # # ]: 0 : }
4084 : : }
4085 : :
4086 [ # # ]: 0 : if( SVX_ADJUST_END != eParaAdjust )
4087 [ # # ][ # # ]: 0 : InsertAttr( &aAttrTab.pAdjust, SvxAdjustItem(eParaAdjust, RES_PARATR_ADJUST), pCntxt );
[ # # ]
4088 : :
4089 : : // udn auf den Stack packen
4090 [ # # ]: 0 : PushContext( pCntxt );
4091 : :
4092 : : // und die Vorlage oder deren Attribute setzen
4093 [ # # ]: 0 : SetTxtCollAttrs( pCntxt );
4094 : :
4095 : 0 : nFontStHeadStart = aFontStack.size();
4096 : :
4097 : : // Laufbalkenanzeige
4098 [ # # ][ # # ]: 0 : ShowStatline();
[ # # ][ # # ]
[ # # ][ # # ]
4099 : 0 : }
4100 : :
4101 : 0 : void SwHTMLParser::EndHeading()
4102 : : {
4103 : : // einen neuen Absatz aufmachen
4104 [ # # ]: 0 : if( pPam->GetPoint()->nContent.GetIndex() )
4105 : 0 : AppendTxtNode( AM_SPACE );
4106 : : else
4107 : 0 : AddParSpace();
4108 : :
4109 : : // Kontext zu dem Token suchen und vom Stack holen
4110 : 0 : _HTMLAttrContext *pCntxt = 0;
4111 : 0 : sal_uInt16 nPos = aContexts.size();
4112 [ # # ][ # # ]: 0 : while( !pCntxt && nPos>nContextStMin )
[ # # ]
4113 : : {
4114 [ # # ]: 0 : switch( aContexts[--nPos]->GetToken() )
4115 : : {
4116 : : case HTML_HEAD1_ON:
4117 : : case HTML_HEAD2_ON:
4118 : : case HTML_HEAD3_ON:
4119 : : case HTML_HEAD4_ON:
4120 : : case HTML_HEAD5_ON:
4121 : : case HTML_HEAD6_ON:
4122 : 0 : pCntxt = aContexts[nPos];
4123 [ # # ][ # # ]: 0 : aContexts.erase( aContexts.begin() + nPos );
4124 : 0 : break;
4125 : : }
4126 : : }
4127 : :
4128 : : // und noch Attribute beenden
4129 [ # # ]: 0 : if( pCntxt )
4130 : : {
4131 : 0 : EndContext( pCntxt );
4132 : 0 : SetAttr(); // Absatz-Atts wegen JavaScript moeglichst schnell setzen
4133 [ # # ]: 0 : delete pCntxt;
4134 : : }
4135 : :
4136 : : // die bisherige Vorlage neu setzen
4137 : 0 : SetTxtCollAttrs();
4138 : :
4139 : 0 : nFontStHeadStart = nFontStMin;
4140 : 0 : }
4141 : :
4142 : :
4143 : 0 : void SwHTMLParser::NewTxtFmtColl( int nToken, sal_uInt16 nColl )
4144 : : {
4145 [ # # ][ # # ]: 0 : String aId, aStyle, aClass, aLang, aDir;
[ # # ][ # # ]
[ # # ]
4146 : :
4147 [ # # ]: 0 : const HTMLOptions& rHTMLOptions = GetOptions();
4148 [ # # ]: 0 : for (size_t i = rHTMLOptions.size(); i; )
4149 : : {
4150 [ # # ]: 0 : const HTMLOption& rOption = rHTMLOptions[--i];
4151 [ # # # # : 0 : switch( rOption.GetToken() )
# # ]
4152 : : {
4153 : : case HTML_O_ID:
4154 [ # # ]: 0 : aId = rOption.GetString();
4155 : 0 : break;
4156 : : case HTML_O_STYLE:
4157 [ # # ]: 0 : aStyle = rOption.GetString();
4158 : 0 : break;
4159 : : case HTML_O_CLASS:
4160 [ # # ]: 0 : aClass = rOption.GetString();
4161 : 0 : break;
4162 : : case HTML_O_LANG:
4163 [ # # ]: 0 : aLang = rOption.GetString();
4164 : 0 : break;
4165 : : case HTML_O_DIR:
4166 [ # # ]: 0 : aDir = rOption.GetString();
4167 : 0 : break;
4168 : : }
4169 : : }
4170 : :
4171 : : // einen neuen Absatz aufmachen
4172 : 0 : SwHTMLAppendMode eMode = AM_NORMAL;
4173 [ # # # # : 0 : switch( nToken )
# ]
4174 : : {
4175 : : case HTML_LISTING_ON:
4176 : : case HTML_XMP_ON:
4177 : : // Diese beiden Tags werden jetzt auf die PRE-Vorlage gemappt.
4178 : : // Fuer dem Fall, dass ein CLASS angegeben ist, loeschen wir
4179 : : // es damit wir nicht die CLASS der PRE-Vorlage bekommen.
4180 [ # # ]: 0 : aClass = aEmptyStr;
4181 : : case HTML_BLOCKQUOTE_ON:
4182 : : case HTML_BLOCKQUOTE30_ON:
4183 : : case HTML_PREFORMTXT_ON:
4184 : 0 : eMode = AM_SPACE;
4185 : 0 : break;
4186 : : case HTML_ADDRESS_ON:
4187 : 0 : eMode = AM_NOSPACE; // ADDRESS kann auf einen <P> ohne </P> folgen
4188 : 0 : break;
4189 : : case HTML_DT_ON:
4190 : : case HTML_DD_ON:
4191 : 0 : eMode = AM_SOFTNOSPACE;
4192 : 0 : break;
4193 : : default:
4194 : : OSL_ENSURE( !this, "unbekannte Vorlage" );
4195 : 0 : break;
4196 : : }
4197 [ # # ]: 0 : if( pPam->GetPoint()->nContent.GetIndex() )
4198 [ # # ]: 0 : AppendTxtNode( eMode );
4199 [ # # ]: 0 : else if( AM_SPACE==eMode )
4200 [ # # ]: 0 : AddParSpace();
4201 : :
4202 : : // ... und in einem Kontext merken
4203 [ # # ][ # # ]: 0 : _HTMLAttrContext *pCntxt = new _HTMLAttrContext( static_cast< sal_uInt16 >(nToken), nColl, aClass );
4204 : :
4205 : : // Styles parsen (zu Class siehe auch NewPara)
4206 [ # # ]: 0 : if( HasStyleOptions( aStyle, aId, aEmptyStr, &aLang, &aDir ) )
4207 : : {
4208 [ # # ][ # # ]: 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
4209 [ # # ]: 0 : SvxCSS1PropertyInfo aPropInfo;
4210 : :
4211 [ # # ][ # # ]: 0 : if( ParseStyleOptions( aStyle, aId, aEmptyStr, aItemSet, aPropInfo, &aLang, &aDir ) )
4212 : : {
4213 : : OSL_ENSURE( !aClass.Len() || !pCSS1Parser->GetClass( aClass ),
4214 : : "Class wird nicht beruecksichtigt" );
4215 [ # # ]: 0 : DoPositioning( aItemSet, aPropInfo, pCntxt );
4216 [ # # ]: 0 : InsertAttrs( aItemSet, aPropInfo, pCntxt );
4217 [ # # ][ # # ]: 0 : }
4218 : : }
4219 : :
4220 [ # # ]: 0 : PushContext( pCntxt );
4221 : :
4222 : : // die neue Vorlage setzen
4223 [ # # ]: 0 : SetTxtCollAttrs( pCntxt );
4224 : :
4225 : : // Laufbalkenanzeige aktualisieren
4226 [ # # ][ # # ]: 0 : ShowStatline();
[ # # ][ # # ]
[ # # ][ # # ]
4227 : 0 : }
4228 : :
4229 : 0 : void SwHTMLParser::EndTxtFmtColl( int nToken )
4230 : : {
4231 : 0 : SwHTMLAppendMode eMode = AM_NORMAL;
4232 [ # # # ]: 0 : switch( nToken & ~1 )
4233 : : {
4234 : : case HTML_BLOCKQUOTE_ON:
4235 : : case HTML_BLOCKQUOTE30_ON:
4236 : : case HTML_PREFORMTXT_ON:
4237 : : case HTML_LISTING_ON:
4238 : : case HTML_XMP_ON:
4239 : 0 : eMode = AM_SPACE;
4240 : 0 : break;
4241 : : case HTML_ADDRESS_ON:
4242 : : case HTML_DT_ON:
4243 : : case HTML_DD_ON:
4244 : 0 : eMode = AM_SOFTNOSPACE;
4245 : 0 : break;
4246 : : default:
4247 : : OSL_ENSURE( !this, "unbekannte Vorlage" );
4248 : 0 : break;
4249 : : }
4250 [ # # ]: 0 : if( pPam->GetPoint()->nContent.GetIndex() )
4251 : 0 : AppendTxtNode( eMode );
4252 [ # # ]: 0 : else if( AM_SPACE==eMode )
4253 : 0 : AddParSpace();
4254 : :
4255 : : // den aktuellen Kontext vom Stack holen
4256 : 0 : _HTMLAttrContext *pCntxt = PopContext( static_cast< sal_uInt16 >(nToken & ~1) );
4257 : :
4258 : : // und noch Attribute beenden
4259 [ # # ]: 0 : if( pCntxt )
4260 : : {
4261 : 0 : EndContext( pCntxt );
4262 : 0 : SetAttr(); // Absatz-Atts wegen JavaScript moeglichst schnell setzen
4263 [ # # ]: 0 : delete pCntxt;
4264 : : }
4265 : :
4266 : : // und die bisherige Vorlage setzen
4267 : 0 : SetTxtCollAttrs();
4268 : 0 : }
4269 : :
4270 : :
4271 : 0 : void SwHTMLParser::NewDefList()
4272 : : {
4273 [ # # ][ # # ]: 0 : String aId, aStyle, aClass, aLang, aDir;
[ # # ][ # # ]
[ # # ]
4274 : :
4275 [ # # ]: 0 : const HTMLOptions& rHTMLOptions = GetOptions();
4276 [ # # ]: 0 : for (size_t i = rHTMLOptions.size(); i; )
4277 : : {
4278 [ # # ]: 0 : const HTMLOption& rOption = rHTMLOptions[--i];
4279 [ # # # # : 0 : switch( rOption.GetToken() )
# # ]
4280 : : {
4281 : : case HTML_O_ID:
4282 [ # # ]: 0 : aId = rOption.GetString();
4283 : 0 : break;
4284 : : case HTML_O_STYLE:
4285 [ # # ]: 0 : aStyle = rOption.GetString();
4286 : 0 : break;
4287 : : case HTML_O_CLASS:
4288 [ # # ]: 0 : aClass = rOption.GetString();
4289 : 0 : break;
4290 : : case HTML_O_LANG:
4291 [ # # ]: 0 : aLang = rOption.GetString();
4292 : 0 : break;
4293 : : case HTML_O_DIR:
4294 [ # # ]: 0 : aDir = rOption.GetString();
4295 : 0 : break;
4296 : : }
4297 : : }
4298 : :
4299 : : // einen neuen Absatz aufmachen
4300 : 0 : sal_Bool bSpace = (GetNumInfo().GetDepth() + nDefListDeep) == 0;
4301 [ # # ]: 0 : if( pPam->GetPoint()->nContent.GetIndex() )
4302 [ # # ][ # # ]: 0 : AppendTxtNode( bSpace ? AM_SPACE : AM_SOFTNOSPACE );
4303 [ # # ]: 0 : else if( bSpace )
4304 [ # # ]: 0 : AddParSpace();
4305 : :
4306 : : // ein Level mehr
4307 : 0 : nDefListDeep++;
4308 : :
4309 : :
4310 : 0 : sal_Bool bInDD = sal_False, bNotInDD = sal_False;
4311 : 0 : sal_uInt16 nPos = aContexts.size();
4312 [ # # ][ # # ]: 0 : while( !bInDD && !bNotInDD && nPos>nContextStMin )
[ # # ][ # # ]
4313 : : {
4314 : 0 : sal_uInt16 nCntxtToken = aContexts[--nPos]->GetToken();
4315 [ # # # ]: 0 : switch( nCntxtToken )
4316 : : {
4317 : : case HTML_DEFLIST_ON:
4318 : : case HTML_DIRLIST_ON:
4319 : : case HTML_MENULIST_ON:
4320 : : case HTML_ORDERLIST_ON:
4321 : : case HTML_UNORDERLIST_ON:
4322 : 0 : bNotInDD = sal_True;
4323 : 0 : break;
4324 : : case HTML_DD_ON:
4325 : 0 : bInDD = sal_True;
4326 : 0 : break;
4327 : : }
4328 : : }
4329 : :
4330 : :
4331 : : // ... und in einem Kontext merken
4332 [ # # ][ # # ]: 0 : _HTMLAttrContext *pCntxt = new _HTMLAttrContext( HTML_DEFLIST_ON );
4333 : :
4334 : : // darin auch die Raender merken
4335 : 0 : sal_uInt16 nLeft=0, nRight=0;
4336 : 0 : short nIndent=0;
4337 [ # # ]: 0 : GetMarginsFromContext( nLeft, nRight, nIndent );
4338 : :
4339 : : // Die Einrueckung, die sich schon aus einem DL-ergibt, entspricht der
4340 : : // eines DT auf dem aktuellen Level, und die entspricht der eines
4341 : : // DD auf dem Level davor. Fue einen Level >=2 muss also ein DD-Abstand
4342 : : // hinzugefuegt werden
4343 [ # # ][ # # ]: 0 : if( !bInDD && nDefListDeep > 1 )
4344 : : {
4345 : :
4346 : : // und den der DT-Vorlage des aktuellen Levels
4347 : : SvxLRSpaceItem rLRSpace =
4348 [ # # ]: 0 : pCSS1Parser->GetTxtFmtColl( RES_POOLCOLL_HTML_DD, aEmptyStr )
4349 [ # # ][ # # ]: 0 : ->GetLRSpace();
4350 [ # # ]: 0 : nLeft = nLeft + static_cast< sal_uInt16 >(rLRSpace.GetTxtLeft());
4351 : : }
4352 : :
4353 : 0 : pCntxt->SetMargins( nLeft, nRight, nIndent );
4354 : :
4355 : : // Styles parsen
4356 [ # # ]: 0 : if( HasStyleOptions( aStyle, aId, aClass, &aLang, &aDir ) )
4357 : : {
4358 [ # # ][ # # ]: 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
4359 [ # # ]: 0 : SvxCSS1PropertyInfo aPropInfo;
4360 : :
4361 [ # # ][ # # ]: 0 : if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo, &aLang, &aDir ) )
4362 : : {
4363 [ # # ]: 0 : DoPositioning( aItemSet, aPropInfo, pCntxt );
4364 [ # # ]: 0 : InsertAttrs( aItemSet, aPropInfo, pCntxt );
4365 [ # # ][ # # ]: 0 : }
4366 : : }
4367 : :
4368 [ # # ]: 0 : PushContext( pCntxt );
4369 : :
4370 : : // die Attribute der neuen Vorlage setzen
4371 [ # # ]: 0 : if( nDefListDeep > 1 )
4372 [ # # ][ # # ]: 0 : SetTxtCollAttrs( pCntxt );
[ # # ][ # # ]
[ # # ][ # # ]
4373 : 0 : }
4374 : :
4375 : 0 : void SwHTMLParser::EndDefList()
4376 : : {
4377 : 0 : sal_Bool bSpace = (GetNumInfo().GetDepth() + nDefListDeep) == 1;
4378 [ # # ]: 0 : if( pPam->GetPoint()->nContent.GetIndex() )
4379 [ # # ]: 0 : AppendTxtNode( bSpace ? AM_SPACE : AM_SOFTNOSPACE );
4380 [ # # ]: 0 : else if( bSpace )
4381 : 0 : AddParSpace();
4382 : :
4383 : : // ein Level weniger
4384 [ # # ]: 0 : if( nDefListDeep > 0 )
4385 : 0 : nDefListDeep--;
4386 : :
4387 : : // den aktuellen Kontext vom Stack holen
4388 : 0 : _HTMLAttrContext *pCntxt = PopContext( HTML_DEFLIST_ON );
4389 : :
4390 : : // und noch Attribute beenden
4391 [ # # ]: 0 : if( pCntxt )
4392 : : {
4393 : 0 : EndContext( pCntxt );
4394 : 0 : SetAttr(); // Absatz-Atts wegen JavaScript moeglichst schnell setzen
4395 [ # # ]: 0 : delete pCntxt;
4396 : : }
4397 : :
4398 : : // und Vorlage setzen
4399 : 0 : SetTxtCollAttrs();
4400 : 0 : }
4401 : :
4402 : 0 : void SwHTMLParser::NewDefListItem( int nToken )
4403 : : {
4404 : : // festellen, ob das DD/DT in einer DL vorkommt
4405 : 0 : sal_Bool bInDefList = sal_False, bNotInDefList = sal_False;
4406 : 0 : sal_uInt16 nPos = aContexts.size();
4407 [ # # ][ # # ]: 0 : while( !bInDefList && !bNotInDefList && nPos>nContextStMin )
[ # # ][ # # ]
4408 : : {
4409 : 0 : sal_uInt16 nCntxtToken = aContexts[--nPos]->GetToken();
4410 [ # # # ]: 0 : switch( nCntxtToken )
4411 : : {
4412 : : case HTML_DEFLIST_ON:
4413 : 0 : bInDefList = sal_True;
4414 : 0 : break;
4415 : : case HTML_DIRLIST_ON:
4416 : : case HTML_MENULIST_ON:
4417 : : case HTML_ORDERLIST_ON:
4418 : : case HTML_UNORDERLIST_ON:
4419 : 0 : bNotInDefList = sal_True;
4420 : 0 : break;
4421 : : }
4422 : : }
4423 : :
4424 : : // wenn nicht, implizit eine neue DL aufmachen
4425 [ # # ]: 0 : if( !bInDefList )
4426 : : {
4427 : 0 : nDefListDeep++;
4428 : : OSL_ENSURE( !nOpenParaToken,
4429 : : "Jetzt geht ein offenes Absatz-Element verloren" );
4430 : 0 : nOpenParaToken = static_cast< sal_uInt16 >(nToken);
4431 : : }
4432 : :
4433 : : NewTxtFmtColl( nToken, static_cast< sal_uInt16 >(nToken==HTML_DD_ON ? RES_POOLCOLL_HTML_DD
4434 [ # # ]: 0 : : RES_POOLCOLL_HTML_DT) );
4435 : 0 : }
4436 : :
4437 : 0 : void SwHTMLParser::EndDefListItem( int nToken, sal_Bool bSetColl,
4438 : : sal_Bool /*bLastPara*/ )
4439 : : {
4440 : : // einen neuen Absatz aufmachen
4441 [ # # ][ # # ]: 0 : if( !nToken && pPam->GetPoint()->nContent.GetIndex() )
[ # # ]
4442 : 0 : AppendTxtNode( AM_SOFTNOSPACE );
4443 : :
4444 : : // Kontext zu dem Token suchen und vom Stack holen
4445 : 0 : nToken &= ~1;
4446 : 0 : _HTMLAttrContext *pCntxt = 0;
4447 : 0 : sal_uInt16 nPos = aContexts.size();
4448 [ # # ][ # # ]: 0 : while( !pCntxt && nPos>nContextStMin )
[ # # ]
4449 : : {
4450 : 0 : sal_uInt16 nCntxtToken = aContexts[--nPos]->GetToken();
4451 [ # # # ]: 0 : switch( nCntxtToken )
4452 : : {
4453 : : case HTML_DD_ON:
4454 : : case HTML_DT_ON:
4455 [ # # ][ # # ]: 0 : if( !nToken || nToken == nCntxtToken )
4456 : : {
4457 : 0 : pCntxt = aContexts[nPos];
4458 [ # # ][ # # ]: 0 : aContexts.erase( aContexts.begin() + nPos );
4459 : : }
4460 : 0 : break;
4461 : : case HTML_DEFLIST_ON:
4462 : : // keine DD/DT ausserhalb der aktuelen DefListe betrachten
4463 : : case HTML_DIRLIST_ON:
4464 : : case HTML_MENULIST_ON:
4465 : : case HTML_ORDERLIST_ON:
4466 : : case HTML_UNORDERLIST_ON:
4467 : : // und auch nicht ausserhalb einer anderen Liste
4468 : 0 : nPos = nContextStMin;
4469 : 0 : break;
4470 : : }
4471 : : }
4472 : :
4473 : : // und noch Attribute beenden
4474 [ # # ]: 0 : if( pCntxt )
4475 : : {
4476 : 0 : EndContext( pCntxt );
4477 : 0 : SetAttr(); // Absatz-Atts wegen JavaScript moeglichst schnell setzen
4478 [ # # ]: 0 : delete pCntxt;
4479 : : }
4480 : :
4481 : : // und die bisherige Vorlage setzen
4482 [ # # ]: 0 : if( bSetColl )
4483 : 0 : SetTxtCollAttrs();
4484 : 0 : }
4485 : :
4486 : :
4487 : 2 : sal_Bool SwHTMLParser::HasCurrentParaFlys( sal_Bool bNoSurroundOnly,
4488 : : sal_Bool bSurroundOnly ) const
4489 : : {
4490 : : // bNoSurroundOnly: Der Absatz enthaelt mindestens einen Rahmen
4491 : : // ohne Umlauf
4492 : : // bSurroundOnly: Der Absatz enthaelt mindestens einen Rahmen
4493 : : // mit Umlauf aber keinen ohne Umlauf
4494 : : // sonst: Der Absatz enthaelt irgendeinen Rahmen
4495 : 2 : SwNodeIndex& rNodeIdx = pPam->GetPoint()->nNode;
4496 : :
4497 : 2 : const SwFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts();
4498 : :
4499 : 2 : sal_Bool bFound = sal_False;
4500 [ - + ]: 2 : for ( sal_uInt16 i=0; i<rFrmFmtTbl.size(); i++ )
4501 : : {
4502 : 0 : SwFrmFmt *const pFmt = rFrmFmtTbl[i];
4503 : 0 : SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor();
4504 : : // Ein Rahmen wurde gefunden, wenn
4505 : : // - er absatzgebunden ist, und
4506 : : // - im aktuellen Absatz verankert ist, und
4507 : : // - jeder absatzgebunene Rahmen zaehlt, oder
4508 : : // - (nur Rahmen oder umlauf zaehlen und ) der Rahmen keinen
4509 : : // Umlauf besitzt
4510 : 0 : SwPosition const*const pAPos = pAnchor->GetCntntAnchor();
4511 [ # # ][ # # : 0 : if (pAPos &&
# # # # #
# ]
4512 : 0 : ((FLY_AT_PARA == pAnchor->GetAnchorId()) ||
4513 : 0 : (FLY_AT_CHAR == pAnchor->GetAnchorId())) &&
4514 : 0 : pAPos->nNode == rNodeIdx )
4515 : : {
4516 [ # # ][ # # ]: 0 : if( !(bNoSurroundOnly || bSurroundOnly) )
4517 : : {
4518 : 0 : bFound = sal_True;
4519 : 0 : break;
4520 : : }
4521 : : else
4522 : : {
4523 : : // Wenn Rahmen mit Umlauf gesucht sind,
4524 : : // auch keine mit Durchlauf beachten. Dabei handelt es
4525 : : // sich (noch) um HIDDEN-Controls, und denen weicht man
4526 : : // besser auch nicht aus.
4527 : 0 : SwSurround eSurround = pFmt->GetSurround().GetSurround();
4528 [ # # ]: 0 : if( bNoSurroundOnly )
4529 : : {
4530 [ # # ]: 0 : if( SURROUND_NONE==eSurround )
4531 : : {
4532 : 0 : bFound = sal_True;
4533 : 0 : break;
4534 : : }
4535 : : }
4536 [ # # ]: 0 : if( bSurroundOnly )
4537 : : {
4538 [ # # ]: 0 : if( SURROUND_NONE==eSurround )
4539 : : {
4540 : 0 : bFound = sal_False;
4541 : 0 : break;
4542 : : }
4543 [ # # ]: 0 : else if( SURROUND_THROUGHT!=eSurround )
4544 : : {
4545 : 0 : bFound = sal_True;
4546 : : // weitersuchen: Es koennten ja noch welche ohne
4547 : : // Umlauf kommen ...
4548 : : }
4549 : : }
4550 : : }
4551 : : }
4552 : : }
4553 : :
4554 : 2 : return bFound;
4555 : : }
4556 : :
4557 : :
4558 : : // die speziellen Methoden zum Einfuegen von Objecten
4559 : :
4560 : 0 : const SwFmtColl *SwHTMLParser::GetCurrFmtColl() const
4561 : : {
4562 : 0 : const SwCntntNode* pCNd = pPam->GetCntntNode();
4563 : 0 : return &pCNd->GetAnyFmtColl();
4564 : : }
4565 : :
4566 : :
4567 : 4 : void SwHTMLParser::SetTxtCollAttrs( _HTMLAttrContext *pContext )
4568 : : {
4569 : 4 : SwTxtFmtColl *pCollToSet = 0; // die zu setzende Vorlage
4570 : 4 : SfxItemSet *pItemSet = 0; // der Set fuer harte Attrs
4571 [ - + ]: 4 : sal_uInt16 nTopColl = pContext ? pContext->GetTxtFmtColl() : 0;
4572 [ - + ]: 4 : const String& rTopClass = pContext ? pContext->GetClass() : (const String&) aEmptyStr;
4573 : 4 : sal_uInt16 nDfltColl = RES_POOLCOLL_TEXT;
4574 : :
4575 : 4 : sal_Bool bInPRE=sal_False; // etwas Kontext Info
4576 : :
4577 : 4 : sal_uInt16 nLeftMargin = 0, nRightMargin = 0; // die Einzuege und
4578 : 4 : short nFirstLineIndent = 0; // Abstaende
4579 : : sal_uInt16 i;
4580 : :
4581 [ + + ]: 6 : for( i = nContextStAttrMin; i < aContexts.size(); i++ )
4582 : : {
4583 : 2 : const _HTMLAttrContext *pCntxt = aContexts[i];
4584 : :
4585 : 2 : sal_uInt16 nColl = pCntxt->GetTxtFmtColl();
4586 [ - + ]: 2 : if( nColl )
4587 : : {
4588 : : // Es gibt eine Vorlage, die zu setzen ist. Dann
4589 : : // muss zunaechst einmal entschieden werden,
4590 : : // ob die Vorlage auch gesetzt werden kann
4591 : 0 : sal_Bool bSetThis = sal_True;
4592 [ # # # # ]: 0 : switch( nColl )
4593 : : {
4594 : : case sal_uInt16(RES_POOLCOLL_HTML_PRE):
4595 : 0 : bInPRE = sal_True;
4596 : 0 : break;
4597 : : case sal_uInt16(RES_POOLCOLL_TEXT):
4598 : : // <TD><P CLASS=xxx> muss TD.xxx werden
4599 [ # # ][ # # ]: 0 : if( nDfltColl==RES_POOLCOLL_TABLE ||
4600 : : nDfltColl==RES_POOLCOLL_TABLE_HDLN )
4601 : 0 : nColl = nDfltColl;
4602 : 0 : break;
4603 : : case sal_uInt16(RES_POOLCOLL_HTML_HR):
4604 : : // <HR> auch in <PRE> als Vorlage setzen, sonst kann man sie
4605 : : // nicht mehr exportieren
4606 : 0 : break;
4607 : : default:
4608 [ # # ]: 0 : if( bInPRE )
4609 : 0 : bSetThis = sal_False;
4610 : 0 : break;
4611 : : }
4612 : :
4613 : : SwTxtFmtColl *pNewColl =
4614 [ # # ]: 0 : pCSS1Parser->GetTxtFmtColl( nColl, pCntxt->GetClass() );
4615 : :
4616 [ # # ]: 0 : if( bSetThis )
4617 : : {
4618 : : // wenn jetzt eine andere Vorlage gesetzt werden soll als
4619 : : // bisher, muss die bishere Vorlage durch harte Attributierung
4620 : : // ersetzt werden
4621 : :
4622 [ # # ]: 0 : if( pCollToSet )
4623 : : {
4624 : : // die Attribute, die die bisherige Vorlage setzt
4625 : : // hart einfuegen
4626 [ # # ]: 0 : if( !pItemSet )
4627 [ # # ][ # # ]: 0 : pItemSet = new SfxItemSet( pCollToSet->GetAttrSet() );
4628 : : else
4629 : : {
4630 : 0 : const SfxItemSet& rCollSet = pCollToSet->GetAttrSet();
4631 : 0 : SfxItemSet aItemSet( *rCollSet.GetPool(),
4632 [ # # ]: 0 : rCollSet.GetRanges() );
4633 [ # # ]: 0 : aItemSet.Set( rCollSet );
4634 [ # # ][ # # ]: 0 : pItemSet->Put( aItemSet );
4635 : : }
4636 : : // aber die Attribute, die aktuelle Vorlage setzt
4637 : : // entfernen, weil sie sonst spaeter ueberschrieben
4638 : : // werden
4639 [ # # ]: 0 : pItemSet->Differentiate( pNewColl->GetAttrSet() );
4640 : : }
4641 : :
4642 : 0 : pCollToSet = pNewColl;
4643 : : }
4644 : : else
4645 : : {
4646 : : // hart Attributieren
4647 [ # # ]: 0 : if( !pItemSet )
4648 [ # # ][ # # ]: 0 : pItemSet = new SfxItemSet( pNewColl->GetAttrSet() );
4649 : : else
4650 : : {
4651 : 0 : const SfxItemSet& rCollSet = pNewColl->GetAttrSet();
4652 : 0 : SfxItemSet aItemSet( *rCollSet.GetPool(),
4653 [ # # ]: 0 : rCollSet.GetRanges() );
4654 [ # # ]: 0 : aItemSet.Set( rCollSet );
4655 [ # # ][ # # ]: 0 : pItemSet->Put( aItemSet );
4656 : : }
4657 : : }
4658 : : }
4659 : : else
4660 : : {
4661 : : // vielliecht gibt es ja eine Default-Vorlage?
4662 : 2 : nColl = pCntxt->GetDfltTxtFmtColl();
4663 [ - + ]: 2 : if( nColl )
4664 : 0 : nDfltColl = nColl;
4665 : : }
4666 : :
4667 : : // ggf. neue Absatz-Einzuege holen
4668 [ - + ]: 2 : if( pCntxt->IsLRSpaceChanged() )
4669 : : {
4670 : 0 : sal_uInt16 nLeft=0, nRight=0;
4671 : :
4672 : 0 : pCntxt->GetMargins( nLeft, nRight, nFirstLineIndent );
4673 : 0 : nLeftMargin = nLeft;
4674 : 0 : nRightMargin = nRight;
4675 : : }
4676 : : }
4677 : :
4678 : : // wenn im aktuellen Kontext eine neue Vorlage gesetzt werden soll,
4679 : : // muessen deren Absatz-Abstaende noch in den Kontext eingetragen werden
4680 [ - + ][ # # ]: 4 : if( pContext && nTopColl )
4681 : : {
4682 : : // <TD><P CLASS=xxx> muss TD.xxx werden
4683 [ # # ][ # # ]: 0 : if( nTopColl==RES_POOLCOLL_TEXT &&
[ # # ]
4684 : : (nDfltColl==RES_POOLCOLL_TABLE ||
4685 : : nDfltColl==RES_POOLCOLL_TABLE_HDLN) )
4686 : 0 : nTopColl = nDfltColl;
4687 : :
4688 : : const SwTxtFmtColl *pTopColl =
4689 [ # # ]: 0 : pCSS1Parser->GetTxtFmtColl( nTopColl, rTopClass );
4690 : 0 : const SfxItemSet& rItemSet = pTopColl->GetAttrSet();
4691 : : const SfxPoolItem *pItem;
4692 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET == rItemSet.GetItemState(RES_LR_SPACE,sal_True, &pItem) )
4693 : : {
4694 : : const SvxLRSpaceItem *pLRItem =
4695 : 0 : (const SvxLRSpaceItem *)pItem;
4696 : :
4697 : 0 : sal_Int32 nLeft = pLRItem->GetTxtLeft();
4698 : 0 : sal_Int32 nRight = pLRItem->GetRight();
4699 : 0 : nFirstLineIndent = pLRItem->GetTxtFirstLineOfst();
4700 : :
4701 : : // In Definitions-Listen enthalten die Abstaende auch die der
4702 : : // vorhergehenden Level
4703 [ # # ]: 0 : if( RES_POOLCOLL_HTML_DD == nTopColl )
4704 : : {
4705 : : const SvxLRSpaceItem& rDTLRSpace = pCSS1Parser
4706 [ # # ]: 0 : ->GetTxtFmtColl( RES_POOLCOLL_HTML_DT, aEmptyStr )
4707 [ # # ]: 0 : ->GetLRSpace();
4708 : 0 : nLeft -= rDTLRSpace.GetTxtLeft();
4709 : 0 : nRight -= rDTLRSpace.GetRight();
4710 : : }
4711 [ # # ]: 0 : else if( RES_POOLCOLL_HTML_DT == nTopColl )
4712 : : {
4713 : 0 : nLeft = 0;
4714 : 0 : nRight = 0;
4715 : : }
4716 : :
4717 : : // die Absatz-Abstaende addieren sich
4718 : 0 : nLeftMargin = nLeftMargin + static_cast< sal_uInt16 >(nLeft);
4719 : 0 : nRightMargin = nRightMargin + static_cast< sal_uInt16 >(nRight);
4720 : :
4721 : : pContext->SetMargins( nLeftMargin, nRightMargin,
4722 : 0 : nFirstLineIndent );
4723 : : }
4724 [ # # ][ # # ]: 0 : if( SFX_ITEM_SET == rItemSet.GetItemState(RES_UL_SPACE,sal_True, &pItem) )
4725 : : {
4726 : : const SvxULSpaceItem *pULItem =
4727 : 0 : (const SvxULSpaceItem *)pItem;
4728 : 0 : pContext->SetULSpace( pULItem->GetUpper(), pULItem->GetLower() );
4729 : : }
4730 : : }
4731 : :
4732 : : // wenn gar keine Vorlage im Kontext gesetzt ist, Textkoerper nehmen
4733 [ + - ]: 4 : if( !pCollToSet )
4734 : : {
4735 [ + - ]: 4 : pCollToSet = pCSS1Parser->GetTxtCollFromPool( nDfltColl );
4736 [ + - ]: 4 : const SvxLRSpaceItem& rLRItem = pCollToSet->GetLRSpace();
4737 [ + - ]: 4 : if( !nLeftMargin )
4738 : 4 : nLeftMargin = static_cast< sal_uInt16 >(rLRItem.GetTxtLeft());
4739 [ + - ]: 4 : if( !nRightMargin )
4740 : 4 : nRightMargin = static_cast< sal_uInt16 >(rLRItem.GetRight());
4741 [ + - ]: 4 : if( !nFirstLineIndent )
4742 : 4 : nFirstLineIndent = rLRItem.GetTxtFirstLineOfst();
4743 : : }
4744 : :
4745 : : // bisherige harte Attributierung des Absatzes entfernen
4746 [ - + ]: 4 : if( !aParaAttrs.empty() )
4747 : : {
4748 [ # # ]: 0 : for( i=0; i<aParaAttrs.size(); i++ )
4749 [ # # ]: 0 : aParaAttrs[i]->Invalidate();
4750 : :
4751 : 0 : aParaAttrs.clear();
4752 : : }
4753 : :
4754 : : // Die Vorlage setzen
4755 [ + - ]: 4 : pDoc->SetTxtFmtColl( *pPam, pCollToSet );
4756 : :
4757 : : // ggf. noch den Absatz-Einzug korrigieren
4758 [ + - ]: 4 : const SvxLRSpaceItem& rLRItem = pCollToSet->GetLRSpace();
4759 : : sal_Bool bSetLRSpace;
4760 : :
4761 : 4 : bSetLRSpace = nLeftMargin != rLRItem.GetTxtLeft() ||
4762 : 4 : nFirstLineIndent != rLRItem.GetTxtFirstLineOfst() ||
4763 [ - + ]: 8 : nRightMargin != rLRItem.GetRight();
[ + - + - ]
4764 : :
4765 [ - + ]: 4 : if( bSetLRSpace )
4766 : : {
4767 [ # # ]: 0 : SvxLRSpaceItem aLRItem( rLRItem );
4768 [ # # ]: 0 : aLRItem.SetTxtLeft( nLeftMargin );
4769 : 0 : aLRItem.SetRight( nRightMargin );
4770 [ # # ]: 0 : aLRItem.SetTxtFirstLineOfst( nFirstLineIndent );
4771 [ # # ]: 0 : if( pItemSet )
4772 [ # # ]: 0 : pItemSet->Put( aLRItem );
4773 : : else
4774 : : {
4775 [ # # ]: 0 : NewAttr( &aAttrTab.pLRSpace, aLRItem );
4776 : 0 : aAttrTab.pLRSpace->SetLikePara();
4777 [ # # ]: 0 : aParaAttrs.push_back( aAttrTab.pLRSpace );
4778 [ # # ]: 0 : EndAttr( aAttrTab.pLRSpace, 0, sal_False );
4779 [ # # ]: 0 : }
4780 : : }
4781 : :
4782 : : // und nun noch die Attribute setzen
4783 [ - + ]: 4 : if( pItemSet )
4784 : : {
4785 [ # # ]: 0 : InsertParaAttrs( *pItemSet );
4786 [ # # ][ # # ]: 0 : delete pItemSet;
4787 : : }
4788 : 4 : }
4789 : :
4790 : :
4791 : 0 : void SwHTMLParser::NewCharFmt( int nToken )
4792 : : {
4793 [ # # ][ # # ]: 0 : String aId, aStyle, aClass, aLang, aDir;
[ # # ][ # # ]
[ # # ]
4794 : :
4795 [ # # ]: 0 : const HTMLOptions& rHTMLOptions = GetOptions();
4796 [ # # ]: 0 : for (size_t i = rHTMLOptions.size(); i; )
4797 : : {
4798 [ # # ]: 0 : const HTMLOption& rOption = rHTMLOptions[--i];
4799 [ # # # # : 0 : switch( rOption.GetToken() )
# # ]
4800 : : {
4801 : : case HTML_O_ID:
4802 [ # # ]: 0 : aId = rOption.GetString();
4803 : 0 : break;
4804 : : case HTML_O_STYLE:
4805 [ # # ]: 0 : aStyle = rOption.GetString();
4806 : 0 : break;
4807 : : case HTML_O_CLASS:
4808 [ # # ]: 0 : aClass = rOption.GetString();
4809 : 0 : break;
4810 : : case HTML_O_LANG:
4811 [ # # ]: 0 : aLang = rOption.GetString();
4812 : 0 : break;
4813 : : case HTML_O_DIR:
4814 [ # # ]: 0 : aDir = rOption.GetString();
4815 : 0 : break;
4816 : : }
4817 : : }
4818 : :
4819 : : // einen neuen Kontext anlegen
4820 [ # # ][ # # ]: 0 : _HTMLAttrContext *pCntxt = new _HTMLAttrContext( static_cast< sal_uInt16 >(nToken) );
4821 : :
4822 : : // die Vorlage setzen und im Kontext merken
4823 [ # # ]: 0 : SwCharFmt* pCFmt = pCSS1Parser->GetChrFmt( static_cast< sal_uInt16 >(nToken), aClass );
4824 : : OSL_ENSURE( pCFmt, "keine Zeichenvorlage zu Token gefunden" );
4825 : :
4826 : :
4827 : : // Styles parsen (zu Class siehe auch NewPara)
4828 [ # # ]: 0 : if( HasStyleOptions( aStyle, aId, aEmptyStr, &aLang, &aDir ) )
4829 : : {
4830 [ # # ][ # # ]: 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
4831 [ # # ]: 0 : SvxCSS1PropertyInfo aPropInfo;
4832 : :
4833 [ # # ][ # # ]: 0 : if( ParseStyleOptions( aStyle, aId, aEmptyStr, aItemSet, aPropInfo, &aLang, &aDir ) )
4834 : : {
4835 : : OSL_ENSURE( !aClass.Len() || !pCSS1Parser->GetClass( aClass ),
4836 : : "Class wird nicht beruecksichtigt" );
4837 [ # # ]: 0 : DoPositioning( aItemSet, aPropInfo, pCntxt );
4838 [ # # ]: 0 : InsertAttrs( aItemSet, aPropInfo, pCntxt, sal_True );
4839 [ # # ][ # # ]: 0 : }
4840 : : }
4841 : :
4842 : : // Zeichen-Vorlagen werden in einem eigenen Stack gehalten und
4843 : : // koennen nie durch Styles eingefuegt werden. Das Attribut ist deshalb
4844 : : // auch gar nicht im CSS1-Which-Range enthalten
4845 [ # # ]: 0 : if( pCFmt )
4846 [ # # ][ # # ]: 0 : InsertAttr( &aAttrTab.pCharFmts, SwFmtCharFmt( pCFmt ), pCntxt );
[ # # ]
4847 : :
4848 : : // den Kontext merken
4849 [ # # ][ # # ]: 0 : PushContext( pCntxt );
[ # # ][ # # ]
[ # # ][ # # ]
4850 : 0 : }
4851 : :
4852 : :
4853 : :
4854 : 0 : void SwHTMLParser::InsertSpacer()
4855 : : {
4856 : : // und es ggf. durch die Optionen veraendern
4857 [ # # ]: 0 : String aId;
4858 : 0 : sal_Int16 eVertOri = text::VertOrientation::TOP;
4859 : 0 : sal_Int16 eHoriOri = text::HoriOrientation::NONE;
4860 : 0 : Size aSize( 0, 0);
4861 : 0 : long nSize = 0;
4862 : 0 : sal_Bool bPrcWidth = sal_False;
4863 : 0 : sal_Bool bPrcHeight = sal_False;
4864 : 0 : sal_uInt16 nType = HTML_SPTYPE_HORI;
4865 : :
4866 [ # # ]: 0 : const HTMLOptions& rHTMLOptions = GetOptions();
4867 [ # # ]: 0 : for (size_t i = rHTMLOptions.size(); i; )
4868 : : {
4869 [ # # ]: 0 : const HTMLOption& rOption = rHTMLOptions[--i];
4870 [ # # # # : 0 : switch( rOption.GetToken() )
# # # ]
4871 : : {
4872 : : case HTML_O_ID:
4873 [ # # ]: 0 : aId = rOption.GetString();
4874 : 0 : break;
4875 : : case HTML_O_TYPE:
4876 [ # # ]: 0 : rOption.GetEnum( nType, aHTMLSpacerTypeTable );
4877 : 0 : break;
4878 : : case HTML_O_ALIGN:
4879 : : eVertOri =
4880 : : rOption.GetEnum( aHTMLImgVAlignTable,
4881 [ # # ]: 0 : eVertOri );
4882 : : eHoriOri =
4883 : : rOption.GetEnum( aHTMLImgHAlignTable,
4884 [ # # ]: 0 : eHoriOri );
4885 : 0 : break;
4886 : : case HTML_O_WIDTH:
4887 : : // erstmal nur als Pixelwerte merken!
4888 [ # # ]: 0 : bPrcWidth = (rOption.GetString().Search('%') != STRING_NOTFOUND);
4889 [ # # ]: 0 : aSize.Width() = (long)rOption.GetNumber();
4890 : 0 : break;
4891 : : case HTML_O_HEIGHT:
4892 : : // erstmal nur als Pixelwerte merken!
4893 [ # # ]: 0 : bPrcHeight = (rOption.GetString().Search('%') != STRING_NOTFOUND);
4894 [ # # ]: 0 : aSize.Height() = (long)rOption.GetNumber();
4895 : 0 : break;
4896 : : case HTML_O_SIZE:
4897 : : // erstmal nur als Pixelwerte merken!
4898 [ # # ]: 0 : nSize = rOption.GetNumber();
4899 : 0 : break;
4900 : : }
4901 : : }
4902 : :
4903 [ # # # # ]: 0 : switch( nType )
4904 : : {
4905 : : case HTML_SPTYPE_BLOCK:
4906 : : {
4907 : : // einen leeren Textrahmen anlegen
4908 : :
4909 : : // den Itemset holen
4910 : 0 : SfxItemSet aFrmSet( pDoc->GetAttrPool(),
4911 [ # # ]: 0 : RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
4912 [ # # ]: 0 : if( !IsNewDoc() )
4913 [ # # ]: 0 : Reader::ResetFrmFmtAttrs( aFrmSet );
4914 : :
4915 : : // den Anker und die Ausrichtung setzen
4916 [ # # ]: 0 : SetAnchorAndAdjustment( eVertOri, eHoriOri, aFrmSet );
4917 : :
4918 : : // und noch die Groesse des Rahmens
4919 : 0 : Size aDfltSz( MINFLY, MINFLY );
4920 : 0 : Size aSpace( 0, 0 );
4921 : 0 : SfxItemSet aDummyItemSet( pDoc->GetAttrPool(),
4922 [ # # # # ]: 0 : pCSS1Parser->GetWhichMap() );
4923 [ # # ]: 0 : SvxCSS1PropertyInfo aDummyPropInfo;
4924 : :
4925 : : SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight,
4926 [ # # ]: 0 : aDummyItemSet, aDummyPropInfo, aFrmSet );
4927 [ # # ]: 0 : SetSpace( aSpace, aDummyItemSet, aDummyPropInfo, aFrmSet );
4928 : :
4929 : : // den Inhalt schuetzen
4930 [ # # ]: 0 : SvxProtectItem aProtectItem( RES_PROTECT) ;
4931 : 0 : aProtectItem.SetCntntProtect( sal_True );
4932 [ # # ]: 0 : aFrmSet.Put( aProtectItem );
4933 : :
4934 : : // der Rahmen anlegen
4935 : : RndStdIds eAnchorId =
4936 [ # # ]: 0 : ((const SwFmtAnchor &)aFrmSet.Get(RES_ANCHOR)).GetAnchorId();
4937 : : SwFrmFmt *pFlyFmt = pDoc->MakeFlySection( eAnchorId,
4938 [ # # ]: 0 : pPam->GetPoint(), &aFrmSet );
4939 : : // Ggf Frames anlegen und auto-geb. Rahmen registrieren
4940 [ # # ][ # # ]: 0 : RegisterFlyFrm( pFlyFmt );
[ # # ][ # # ]
[ # # ]
4941 : : }
4942 : 0 : break;
4943 : : case HTML_SPTYPE_VERT:
4944 [ # # ]: 0 : if( nSize > 0 )
4945 : : {
4946 [ # # ][ # # ]: 0 : if( nSize && Application::GetDefaultDevice() )
[ # # ][ # # ]
4947 : : {
4948 : : nSize = Application::GetDefaultDevice()
4949 : : ->PixelToLogic( Size(0,nSize),
4950 [ # # ][ # # ]: 0 : MapMode(MAP_TWIP) ).Height();
[ # # ][ # # ]
4951 : : }
4952 : :
4953 : : // einen Absatz-Abstand setzen
4954 : 0 : SwTxtNode *pTxtNode = 0;
4955 [ # # ]: 0 : if( !pPam->GetPoint()->nContent.GetIndex() )
4956 : : {
4957 : : // den unteren Absatz-Abstand des vorherigen Nodes aendern,
4958 : : // wenn moeglich
4959 : :
4960 [ # # ]: 0 : SetAttr(); // noch offene Absatz-Attribute setzen
4961 : :
4962 [ # # ]: 0 : pTxtNode = pDoc->GetNodes()[pPam->GetPoint()->nNode.GetIndex()-1]
4963 [ # # ]: 0 : ->GetTxtNode();
4964 : :
4965 : : // Wenn der Abstz davor kein Txtenode ist, dann wird jetzt
4966 : : // ein leere Absatz angelegt, der eh schon eine Zeilenhoehe
4967 : : // Abstand erzeugt.
4968 [ # # ]: 0 : if( !pTxtNode )
4969 [ # # ]: 0 : nSize = nSize>HTML_PARSPACE ? nSize-HTML_PARSPACE : 0;
4970 : : }
4971 : :
4972 [ # # ]: 0 : if( pTxtNode )
4973 : : {
4974 : : SvxULSpaceItem aULSpace( (const SvxULSpaceItem&)pTxtNode
4975 [ # # ][ # # ]: 0 : ->SwCntntNode::GetAttr( RES_UL_SPACE ) );
4976 : 0 : aULSpace.SetLower( aULSpace.GetLower() + (sal_uInt16)nSize );
4977 [ # # ][ # # ]: 0 : pTxtNode->SetAttr( aULSpace );
4978 : : }
4979 : : else
4980 : : {
4981 [ # # ][ # # ]: 0 : NewAttr( &aAttrTab.pULSpace, SvxULSpaceItem( 0, (sal_uInt16)nSize, RES_UL_SPACE ) );
[ # # ]
4982 [ # # ]: 0 : EndAttr( aAttrTab.pULSpace, 0, sal_False );
4983 : :
4984 [ # # ]: 0 : AppendTxtNode(); // nicht am Abstand drehen!
4985 : : }
4986 : : }
4987 : 0 : break;
4988 : : case HTML_SPTYPE_HORI:
4989 [ # # ]: 0 : if( nSize > 0 )
4990 : : {
4991 : : // wenn der Absatz noch leer ist, einen Erstzeilen-Einzug
4992 : : // setzen, sondern Sperrschrift ueber einem Space aufspannen
4993 : :
4994 [ # # ][ # # ]: 0 : if( nSize && Application::GetDefaultDevice() )
[ # # ][ # # ]
4995 : : {
4996 : : nSize = Application::GetDefaultDevice()
4997 : : ->PixelToLogic( Size(nSize,0),
4998 [ # # ][ # # ]: 0 : MapMode(MAP_TWIP) ).Width();
[ # # ][ # # ]
4999 : : }
5000 : :
5001 [ # # ]: 0 : if( !pPam->GetPoint()->nContent.GetIndex() )
5002 : : {
5003 : 0 : sal_uInt16 nLeft=0, nRight=0;
5004 : 0 : short nIndent = 0;
5005 : :
5006 [ # # ]: 0 : GetMarginsFromContextWithNumBul( nLeft, nRight, nIndent );
5007 : 0 : nIndent = nIndent + (short)nSize;
5008 : :
5009 [ # # ]: 0 : SvxLRSpaceItem aLRItem( RES_LR_SPACE );
5010 [ # # ]: 0 : aLRItem.SetTxtLeft( nLeft );
5011 : 0 : aLRItem.SetRight( nRight );
5012 [ # # ]: 0 : aLRItem.SetTxtFirstLineOfst( nIndent );
5013 : :
5014 [ # # ]: 0 : NewAttr( &aAttrTab.pLRSpace, aLRItem );
5015 [ # # ][ # # ]: 0 : EndAttr( aAttrTab.pLRSpace, 0, sal_False );
5016 : : }
5017 : : else
5018 : : {
5019 [ # # ][ # # ]: 0 : NewAttr( &aAttrTab.pKerning, SvxKerningItem( (short)nSize, RES_CHRATR_KERNING ) );
[ # # ]
5020 : 0 : rtl::OUString aTmp( ' ' );
5021 [ # # ][ # # ]: 0 : pDoc->InsertString( *pPam, aTmp );
[ # # ]
5022 [ # # ]: 0 : EndAttr( aAttrTab.pKerning );
5023 : : }
5024 : : }
5025 [ # # ]: 0 : }
5026 : 0 : }
5027 : :
5028 : 0 : sal_uInt16 SwHTMLParser::ToTwips( sal_uInt16 nPixel ) const
5029 : : {
5030 [ # # ][ # # ]: 0 : if( nPixel && Application::GetDefaultDevice() )
[ # # ]
5031 : : {
5032 : : long nTwips = Application::GetDefaultDevice()->PixelToLogic(
5033 [ # # ][ # # ]: 0 : Size( nPixel, nPixel ), MapMode( MAP_TWIP ) ).Width();
5034 [ # # ]: 0 : return nTwips <= USHRT_MAX ? (sal_uInt16)nTwips : USHRT_MAX;
5035 : : }
5036 : : else
5037 : 0 : return nPixel;
5038 : : }
5039 : :
5040 : 0 : SwTwips SwHTMLParser::GetCurrentBrowseWidth()
5041 : : {
5042 : 0 : const SwTwips nWidth = SwHTMLTableLayout::GetBrowseWidth( *pDoc );
5043 [ # # ]: 0 : if( nWidth )
5044 : 0 : return nWidth;
5045 : :
5046 [ # # ]: 0 : if( !aHTMLPageSize.Width() )
5047 : : {
5048 : 0 : const SwFrmFmt& rPgFmt = pCSS1Parser->GetMasterPageDesc()->GetMaster();
5049 : :
5050 : 0 : const SwFmtFrmSize& rSz = rPgFmt.GetFrmSize();
5051 : 0 : const SvxLRSpaceItem& rLR = rPgFmt.GetLRSpace();
5052 : 0 : const SvxULSpaceItem& rUL = rPgFmt.GetULSpace();
5053 : 0 : const SwFmtCol& rCol = rPgFmt.GetCol();
5054 : :
5055 : 0 : aHTMLPageSize.Width() = rSz.GetWidth() - rLR.GetLeft() - rLR.GetRight();
5056 : 0 : aHTMLPageSize.Height() = rSz.GetHeight() - rUL.GetUpper() - rUL.GetLower();
5057 : :
5058 [ # # ]: 0 : if( 1 < rCol.GetNumCols() )
5059 : 0 : aHTMLPageSize.Width() /= rCol.GetNumCols();
5060 : : }
5061 : :
5062 : 0 : return aHTMLPageSize.Width();
5063 : : }
5064 : :
5065 : :
5066 : :
5067 : 0 : void SwHTMLParser::InsertIDOption()
5068 : : {
5069 [ # # ]: 0 : String aId;
5070 [ # # ]: 0 : const HTMLOptions& rHTMLOptions = GetOptions();
5071 [ # # ]: 0 : for (size_t i = rHTMLOptions.size(); i; )
5072 : : {
5073 [ # # ]: 0 : const HTMLOption& rOption = rHTMLOptions[--i];
5074 [ # # ]: 0 : if( HTML_O_ID==rOption.GetToken() )
5075 : : {
5076 [ # # ]: 0 : aId = rOption.GetString();
5077 : 0 : break;
5078 : : }
5079 : : }
5080 : :
5081 [ # # ]: 0 : if( aId.Len() )
5082 [ # # ][ # # ]: 0 : InsertBookmark( aId );
5083 : 0 : }
5084 : :
5085 : :
5086 : :
5087 : :
5088 : 4 : void SwHTMLParser::InsertLineBreak()
5089 : : {
5090 : : // <BR CLEAR=xxx> wird wie folgt behandelt:
5091 : : // 1.) Es werden nur nur absatzgebundene Rahmen betrachtet, die
5092 : : // im aktuellen Absatz verankert sind.
5093 : : // 2.) Fuer linksbuendig ausgerichtete Rahmen wird bei CLEAR=LEFT
5094 : : // oder ALL und auf rechtsbuendige ausgerichtete Rahmen bei
5095 : : // CLEAR=RIGHT oder ALL der Durchlauf wie folgt geaendert:
5096 : : // 3.) Wenn der Absatz keinen Text enthaelt, bekommt der Rahmen keinen
5097 : : // Umlauf
5098 : : // 4.) sonst erhaelt ein links ausgerichteter Rahmen eine rechten
5099 : : // "nur Anker" Umlauf und recht rechst ausg. Rahmen einen linken
5100 : : // "nur Anker" Umlauf.
5101 : : // 5.) wenn in einem nicht-leeren Absatz der Umlauf eines Rahmens
5102 : : // geaendert wird, wird ein neuer Absatz aufgemacht
5103 : : // 6.) Wenn von keinem Rahmen der Umlauf geaendert wird, wird ein
5104 : : // harter Zeilenumbruch eingefuegt
5105 : :
5106 [ + - ][ + - ]: 4 : String aId, aStyle, aClass; // die ID der Bookmark
[ + - ]
5107 : 4 : sal_Bool bClearLeft = sal_False, bClearRight = sal_False;
5108 : 4 : sal_Bool bCleared = sal_False; // wurde ein CLEAR ausgefuehrt?
5109 : :
5110 : : // dann holen wir mal die Optionen
5111 [ + - ]: 4 : const HTMLOptions& rHTMLOptions = GetOptions();
5112 [ - + ]: 4 : for (size_t i = rHTMLOptions.size(); i; )
5113 : : {
5114 [ # # ]: 0 : const HTMLOption& rOption = rHTMLOptions[--i];
5115 [ # # # # : 0 : switch( rOption.GetToken() )
# ]
5116 : : {
5117 : : case HTML_O_CLEAR:
5118 : : {
5119 : 0 : const String &aClear = rOption.GetString();
5120 [ # # ][ # # ]: 0 : if( aClear.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_AL_all ) )
5121 : : {
5122 : 0 : bClearLeft = sal_True;
5123 : 0 : bClearRight = sal_True;
5124 : : }
5125 [ # # ][ # # ]: 0 : else if( aClear.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_AL_left ) )
5126 : 0 : bClearLeft = sal_True;
5127 [ # # ][ # # ]: 0 : else if( aClear.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_AL_right ) )
5128 : 0 : bClearRight = sal_True;
5129 : : }
5130 : 0 : break;
5131 : : case HTML_O_ID:
5132 [ # # ]: 0 : aId = rOption.GetString();
5133 : 0 : break;
5134 : : case HTML_O_STYLE:
5135 [ # # ]: 0 : aStyle = rOption.GetString();
5136 : 0 : break;
5137 : : case HTML_O_CLASS:
5138 [ # # ]: 0 : aClass = rOption.GetString();
5139 : 0 : break;
5140 : : }
5141 : : }
5142 : :
5143 : : // CLEAR wird nur fuer den aktuellen Absaetz unterstuetzt
5144 [ + - ][ - + ]: 4 : if( bClearLeft || bClearRight )
5145 : : {
5146 : 0 : SwNodeIndex& rNodeIdx = pPam->GetPoint()->nNode;
5147 : 0 : SwTxtNode* pTxtNd = rNodeIdx.GetNode().GetTxtNode();
5148 [ # # ]: 0 : if( pTxtNd )
5149 : : {
5150 : 0 : const SwFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts();
5151 : :
5152 [ # # ]: 0 : for( sal_uInt16 i=0; i<rFrmFmtTbl.size(); i++ )
5153 : : {
5154 : 0 : SwFrmFmt *const pFmt = rFrmFmtTbl[i];
5155 [ # # ]: 0 : SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor();
5156 [ # # ]: 0 : SwPosition const*const pAPos = pAnchor->GetCntntAnchor();
5157 [ # # # # : 0 : if (pAPos &&
# # # # #
# ][ # # ]
5158 : 0 : ((FLY_AT_PARA == pAnchor->GetAnchorId()) ||
5159 : 0 : (FLY_AT_CHAR == pAnchor->GetAnchorId())) &&
5160 : 0 : pAPos->nNode == rNodeIdx &&
5161 [ # # ]: 0 : pFmt->GetSurround().GetSurround() != SURROUND_NONE )
5162 : : {
5163 : 0 : sal_Int16 eHori = RES_DRAWFRMFMT == pFmt->Which()
5164 : : ? text::HoriOrientation::LEFT
5165 [ # # ][ # # ]: 0 : : pFmt->GetHoriOrient().GetHoriOrient();
5166 : :
5167 : 0 : SwSurround eSurround = SURROUND_PARALLEL;
5168 [ # # ]: 0 : if( pPam->GetPoint()->nContent.GetIndex() )
5169 : : {
5170 [ # # ][ # # ]: 0 : if( bClearLeft && text::HoriOrientation::LEFT==eHori )
5171 : 0 : eSurround = SURROUND_RIGHT;
5172 [ # # ][ # # ]: 0 : else if( bClearRight && text::HoriOrientation::RIGHT==eHori )
5173 : 0 : eSurround = SURROUND_LEFT;
5174 : : }
5175 [ # # ][ # # ]: 0 : else if( (bClearLeft && text::HoriOrientation::LEFT==eHori) ||
[ # # ][ # # ]
5176 : : (bClearRight && text::HoriOrientation::RIGHT==eHori) )
5177 : : {
5178 : 0 : eSurround = SURROUND_NONE;
5179 : : }
5180 : :
5181 [ # # ]: 0 : if( SURROUND_PARALLEL != eSurround )
5182 : : {
5183 [ # # ]: 0 : SwFmtSurround aSurround( eSurround );
5184 [ # # ]: 0 : if( SURROUND_NONE != eSurround )
5185 : 0 : aSurround.SetAnchorOnly( sal_True );
5186 [ # # ]: 0 : pFmt->SetFmtAttr( aSurround );
5187 [ # # ]: 0 : bCleared = sal_True;
5188 : : }
5189 : : } // Anker ist nicht im Node
5190 : : } // Schleife ueber Fly-Frames
5191 : : } // kein Text-Node
5192 : : } // kein CLEAR
5193 : :
5194 : : // Styles parsen
5195 [ + - ]: 4 : SvxFmtBreakItem aBreakItem( SVX_BREAK_NONE, RES_BREAK );
5196 : 4 : sal_Bool bBreakItem = sal_False;
5197 [ - + ]: 4 : if( HasStyleOptions( aStyle, aId, aClass ) )
5198 : : {
5199 [ # # ][ # # ]: 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
5200 [ # # ]: 0 : SvxCSS1PropertyInfo aPropInfo;
5201 : :
5202 [ # # ][ # # ]: 0 : if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo ) )
5203 : : {
5204 [ # # ][ # # ]: 0 : if( pCSS1Parser->SetFmtBreak( aItemSet, aPropInfo ) )
5205 : : {
5206 [ # # ]: 0 : aBreakItem = (const SvxFmtBreakItem &)aItemSet.Get( RES_BREAK );
5207 : 0 : bBreakItem = sal_True;
5208 : : }
5209 [ # # ]: 0 : if( aPropInfo.aId.Len() )
5210 [ # # ]: 0 : InsertBookmark( aPropInfo.aId );
5211 [ # # ][ # # ]: 0 : }
5212 : : }
5213 : :
5214 [ - + ][ # # ]: 4 : if( bBreakItem && SVX_BREAK_PAGE_AFTER==aBreakItem.GetBreak() )
[ - + ]
5215 : : {
5216 [ # # ]: 0 : NewAttr( &aAttrTab.pBreak, aBreakItem );
5217 [ # # ]: 0 : EndAttr( aAttrTab.pBreak, 0, sal_False );
5218 : : }
5219 : :
5220 [ + - ][ + - ]: 4 : if( !bCleared && !bBreakItem )
5221 : : {
5222 : : // wenn kein CLEAR ausgefuehrt werden sollte oder konnte, wird
5223 : : // ein Zeilenumbruch eingef?gt
5224 : 4 : rtl::OUString sTmp( (sal_Unicode)0x0a ); // make the Mac happy :-)
5225 [ + - ][ + - ]: 4 : pDoc->InsertString( *pPam, sTmp );
[ + - ]
5226 : : }
5227 [ # # ]: 0 : else if( pPam->GetPoint()->nContent.GetIndex() )
5228 : : {
5229 : : // wenn ein Claer in einem nicht-leeren Absatz ausgefuehrt wurde,
5230 : : // muss anschliessen ein neuer Absatz aufgemacht werden
5231 : : // MIB 21.02.97: Eigentlich muesste man hier den unteren Absatz-
5232 : : // Absatnd auf 0 drehen. Das geht aber bei sowas wie <BR ..><P>
5233 : : // schief (>Netacpe). Deshalb lassen wir das erstmal.
5234 [ # # ]: 0 : AppendTxtNode( AM_NOSPACE );
5235 : : }
5236 [ - + ][ # # ]: 4 : if( bBreakItem && SVX_BREAK_PAGE_BEFORE==aBreakItem.GetBreak() )
[ - + ]
5237 : : {
5238 [ # # ]: 0 : NewAttr( &aAttrTab.pBreak, aBreakItem );
5239 [ # # ]: 0 : EndAttr( aAttrTab.pBreak, 0, sal_False );
5240 [ + - ][ + - ]: 4 : }
[ + - ][ + - ]
5241 : 4 : }
5242 : :
5243 : 0 : void SwHTMLParser::InsertHorzRule()
5244 : : {
5245 : 0 : sal_uInt16 nSize = 0;
5246 : 0 : sal_uInt16 nWidth = 0;
5247 : :
5248 : 0 : SvxAdjust eAdjust = SVX_ADJUST_END;
5249 : :
5250 : 0 : sal_Bool bPrcWidth = sal_False;
5251 : 0 : sal_Bool bNoShade = sal_False;
5252 : 0 : sal_Bool bColor = sal_False;
5253 : :
5254 : 0 : Color aColor;
5255 [ # # ]: 0 : String aId;
5256 : :
5257 : : // dann holen wir mal die Optionen
5258 [ # # ]: 0 : const HTMLOptions& rHTMLOptions = GetOptions();
5259 [ # # ]: 0 : for (size_t i = rHTMLOptions.size(); i; )
5260 : : {
5261 [ # # ]: 0 : const HTMLOption& rOption = rHTMLOptions[--i];
5262 [ # # # # : 0 : switch( rOption.GetToken() )
# # # ]
5263 : : {
5264 : : case HTML_O_ID:
5265 [ # # ]: 0 : aId = rOption.GetString();
5266 : 0 : break;
5267 : : case HTML_O_SIZE:
5268 [ # # ]: 0 : nSize = (sal_uInt16)rOption.GetNumber();
5269 : 0 : break;
5270 : : case HTML_O_WIDTH:
5271 [ # # ]: 0 : bPrcWidth = (rOption.GetString().Search('%') != STRING_NOTFOUND);
5272 [ # # ]: 0 : nWidth = (sal_uInt16)rOption.GetNumber();
5273 [ # # ][ # # ]: 0 : if( bPrcWidth && nWidth>=100 )
5274 : : {
5275 : : // 100%-Linien sind der default-Fall (keine Attrs neotig)
5276 : 0 : nWidth = 0;
5277 : 0 : bPrcWidth = sal_False;
5278 : : }
5279 : 0 : break;
5280 : : case HTML_O_ALIGN:
5281 : : eAdjust =
5282 [ # # ]: 0 : (SvxAdjust)rOption.GetEnum( aHTMLPAlignTable, static_cast< sal_uInt16 >(eAdjust) );
5283 : 0 : break;
5284 : : case HTML_O_NOSHADE:
5285 : 0 : bNoShade = sal_True;
5286 : 0 : break;
5287 : : case HTML_O_COLOR:
5288 [ # # ]: 0 : rOption.GetColor( aColor );
5289 : 0 : bColor = sal_True;
5290 : 0 : break;
5291 : : }
5292 : : }
5293 : :
5294 [ # # ]: 0 : if( pPam->GetPoint()->nContent.GetIndex() )
5295 [ # # ]: 0 : AppendTxtNode( AM_NOSPACE );
5296 [ # # ]: 0 : if( nOpenParaToken )
5297 [ # # ]: 0 : EndPara();
5298 [ # # ]: 0 : AppendTxtNode();
5299 [ # # ]: 0 : pPam->Move( fnMoveBackward );
5300 : :
5301 : : // ... und in einem Kontext merken
5302 : : _HTMLAttrContext *pCntxt =
5303 [ # # ][ # # ]: 0 : new _HTMLAttrContext( HTML_HORZRULE, RES_POOLCOLL_HTML_HR, aEmptyStr );
5304 : :
5305 [ # # ]: 0 : PushContext( pCntxt );
5306 : :
5307 : : // die neue Vorlage setzen
5308 [ # # ]: 0 : SetTxtCollAttrs( pCntxt );
5309 : :
5310 : : // die harten Attribute an diesem Absatz werden nie mehr ungueltig
5311 [ # # ]: 0 : if( !aParaAttrs.empty() )
5312 : 0 : aParaAttrs.clear();
5313 : :
5314 [ # # ][ # # ]: 0 : if( nSize>0 || bColor || bNoShade )
[ # # ]
5315 : : {
5316 : : // Farbe und/oder Breite der Linie setzen
5317 [ # # ]: 0 : if( !bColor )
5318 : 0 : aColor.SetColor( COL_GRAY );
5319 : :
5320 [ # # ]: 0 : SvxBorderLine aBorderLine( &aColor );
5321 [ # # ]: 0 : if( nSize )
5322 : : {
5323 : 0 : long nPWidth = 0;
5324 : 0 : long nPHeight = (long)nSize;
5325 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
5326 [ # # ]: 0 : if ( !bNoShade )
5327 : : {
5328 [ # # ]: 0 : aBorderLine.SetBorderLineStyle(table::BorderLineStyle::DOUBLE);
5329 : : }
5330 : 0 : aBorderLine.SetWidth( nPHeight );
5331 : : }
5332 [ # # ]: 0 : else if( bNoShade )
5333 : : {
5334 : 0 : aBorderLine.SetWidth( DEF_LINE_WIDTH_2 );
5335 : : }
5336 : : else
5337 : : {
5338 [ # # ]: 0 : aBorderLine.SetBorderLineStyle(table::BorderLineStyle::DOUBLE);
5339 : 0 : aBorderLine.SetWidth( DEF_LINE_WIDTH_0 );
5340 : : }
5341 : :
5342 [ # # ]: 0 : SvxBoxItem aBoxItem(RES_BOX);
5343 [ # # ]: 0 : aBoxItem.SetLine( &aBorderLine, BOX_LINE_BOTTOM );
5344 [ # # ][ # # ]: 0 : _HTMLAttr* pTmp = new _HTMLAttr( *pPam->GetPoint(), aBoxItem );
5345 [ # # ][ # # ]: 0 : aSetAttrTab.push_back( pTmp );
5346 : : }
5347 [ # # ]: 0 : if( nWidth )
5348 : : {
5349 : : // Wenn wir in keiner Tabelle sind, wird die Breitenangabe durch
5350 : : // Absatz-Einzuege "getuerkt". In einer Tabelle macht das wenig
5351 : : // Sinn. Um zu Vermeiden, dass die Linie bei der Breitenberechnung
5352 : : // beruecksichtigt wird, bekommt sie aber trotzdem entsprechendes
5353 : : // LRSpace-Item verpasst.
5354 [ # # ]: 0 : if( !pTable )
5355 : : {
5356 : : // Laenge und Ausrichtung der Linie ueber Absatz-Einzuege "tuerken"
5357 [ # # ]: 0 : long nBrowseWidth = GetCurrentBrowseWidth();
5358 : : nWidth = bPrcWidth ? (sal_uInt16)((nWidth*nBrowseWidth) / 100)
5359 [ # # ][ # # ]: 0 : : ToTwips( (sal_uInt16)nBrowseWidth );
5360 [ # # ]: 0 : if( nWidth < MINLAY )
5361 : 0 : nWidth = MINLAY;
5362 : :
5363 [ # # ]: 0 : if( (long)nWidth < nBrowseWidth )
5364 : : {
5365 : 0 : const SwFmtColl *pColl = GetCurrFmtColl();
5366 [ # # ][ # # ]: 0 : SvxLRSpaceItem aLRItem( pColl->GetLRSpace() );
5367 : 0 : long nDist = nBrowseWidth - nWidth;
5368 : :
5369 [ # # # ]: 0 : switch( eAdjust )
5370 : : {
5371 : : case SVX_ADJUST_RIGHT:
5372 [ # # ]: 0 : aLRItem.SetTxtLeft( (sal_uInt16)nDist );
5373 : 0 : break;
5374 : : case SVX_ADJUST_LEFT:
5375 : 0 : aLRItem.SetRight( (sal_uInt16)nDist );
5376 : 0 : break;
5377 : : case SVX_ADJUST_CENTER:
5378 : : default:
5379 : 0 : nDist /= 2;
5380 [ # # ]: 0 : aLRItem.SetTxtLeft( (sal_uInt16)nDist );
5381 : 0 : aLRItem.SetRight( (sal_uInt16)nDist );
5382 : 0 : break;
5383 : : }
5384 : :
5385 [ # # ][ # # ]: 0 : _HTMLAttr* pTmp = new _HTMLAttr( *pPam->GetPoint(), aLRItem );
5386 [ # # ][ # # ]: 0 : aSetAttrTab.push_back( pTmp );
5387 : : }
5388 : : }
5389 : : }
5390 : :
5391 : : // Bookmarks koennen nicht in Hyperlinks eingefueht werden
5392 [ # # ]: 0 : if( aId.Len() )
5393 [ # # ]: 0 : InsertBookmark( aId );
5394 : :
5395 : : // den aktuellen Kontext vom Stack holen
5396 [ # # ]: 0 : _HTMLAttrContext *pPoppedContext = PopContext( HTML_HORZRULE );
5397 : : OSL_ENSURE( pPoppedContext==pCntxt, "wo kommt denn da ein HR-Kontext her?" );
5398 [ # # ][ # # ]: 0 : delete pPoppedContext;
5399 : :
5400 [ # # ]: 0 : pPam->Move( fnMoveForward );
5401 : :
5402 : : // und im Absatz danach die dort aktuelle Vorlage setzen
5403 [ # # ][ # # ]: 0 : SetTxtCollAttrs();
5404 : 0 : }
5405 : :
5406 : 4 : void SwHTMLParser::ParseMoreMetaOptions()
5407 : : {
5408 [ + - ][ + - ]: 4 : String aName, aContent;
5409 : 4 : sal_Bool bHTTPEquiv = sal_False;
5410 : :
5411 [ + - ]: 4 : const HTMLOptions& rHTMLOptions = GetOptions();
5412 [ + + ]: 12 : for (size_t i = rHTMLOptions.size(); i; )
5413 : : {
5414 [ + - ]: 8 : const HTMLOption& rOption = rHTMLOptions[--i];
5415 [ + + + - ]: 8 : switch( rOption.GetToken() )
5416 : : {
5417 : : case HTML_O_NAME:
5418 [ + - ]: 2 : aName = rOption.GetString();
5419 : 2 : bHTTPEquiv = sal_False;
5420 : 2 : break;
5421 : : case HTML_O_HTTPEQUIV:
5422 [ + - ]: 2 : aName = rOption.GetString();
5423 : 2 : bHTTPEquiv = sal_True;
5424 : 2 : break;
5425 : : case HTML_O_CONTENT:
5426 [ + - ]: 4 : aContent = rOption.GetString();
5427 : 4 : break;
5428 : : }
5429 : : }
5430 : :
5431 : : // Hier wird es etwas tricky: Wir wissen genau, da? die Dok-Info
5432 : : // nicht geaendert wurde. Deshalb genuegt es, auf Generator und
5433 : : // auf refresh abzufragen, um noch nicht verarbeitete Token zu finden,
5434 : : // denn das sind die einzigen, die die Dok-Info nicht modifizieren.
5435 [ + - ][ + + ]: 8 : if( aName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_META_generator ) ||
[ + - ][ - + ]
[ # # ][ + - ]
5436 [ + - ]: 2 : aName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_META_refresh ) ||
5437 [ + - ]: 2 : aName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_META_content_type ) ||
5438 [ # # ]: 0 : aName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_META_content_script_type ) )
5439 : : return;
5440 : :
5441 [ # # ][ # # ]: 0 : aContent = comphelper::string::remove(aContent, _CR);
5442 [ # # ][ # # ]: 0 : aContent = comphelper::string::remove(aContent, _LF);
5443 : :
5444 [ # # ][ # # ]: 0 : if( aName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_META_sdendnote ) )
5445 : : {
5446 [ # # ]: 0 : FillEndNoteInfo( aContent );
5447 : : return;
5448 : : }
5449 : :
5450 [ # # ][ # # ]: 0 : if( aName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_META_sdfootnote ) )
5451 : : {
5452 [ # # ]: 0 : FillFootNoteInfo( aContent );
5453 : : return;
5454 : : }
5455 : :
5456 : 0 : rtl::OUStringBuffer sText;
5457 [ # # ]: 0 : sText.append("HTML: <");
5458 [ # # ]: 0 : sText.append(OOO_STRING_SVTOOLS_HTML_meta);
5459 [ # # ]: 0 : sText.append(' ');
5460 [ # # ]: 0 : if( bHTTPEquiv )
5461 [ # # ]: 0 : sText.append(OOO_STRING_SVTOOLS_HTML_O_httpequiv);
5462 : : else
5463 [ # # ]: 0 : sText.append(OOO_STRING_SVTOOLS_HTML_O_name);
5464 [ # # ]: 0 : sText.append("=\"");
5465 [ # # ][ # # ]: 0 : sText.append(aName);
5466 [ # # ]: 0 : sText.append("\" ");
5467 [ # # ]: 0 : sText.append(OOO_STRING_SVTOOLS_HTML_O_content);
5468 [ # # ]: 0 : sText.append("=\"");
5469 [ # # ][ # # ]: 0 : sText.append(aContent);
5470 [ # # ]: 0 : sText.append("\">");
5471 : :
5472 : : SwPostItField aPostItFld(
5473 [ # # ]: 0 : (SwPostItFieldType*)pDoc->GetSysFldType( RES_POSTITFLD ),
5474 [ # # ][ # # ]: 0 : aEmptyStr, sText.makeStringAndClear(), aEmptyStr, aEmptyStr, DateTime( DateTime::SYSTEM ) );
[ # # ][ # # ]
[ # # ]
5475 [ # # ]: 0 : SwFmtFld aFmtFld( aPostItFld );
5476 [ # # ][ # # ]: 4 : InsertAttr( aFmtFld );
[ # # ][ + - ]
[ + - ][ + - ]
[ - + ]
5477 : : }
5478 : :
5479 : :
5480 : 0 : _HTMLAttr::_HTMLAttr( const SwPosition& rPos, const SfxPoolItem& rItem,
5481 : : _HTMLAttr **ppHd ) :
5482 : : nSttPara( rPos.nNode ),
5483 : : nEndPara( rPos.nNode ),
5484 : 0 : nSttCntnt( rPos.nContent.GetIndex() ),
5485 : 0 : nEndCntnt(rPos.nContent.GetIndex() ),
5486 : : bInsAtStart( sal_True ),
5487 : : bLikePara( sal_False ),
5488 : : bValid( sal_True ),
5489 : : nCount( 1 ),
5490 : : pNext( 0 ),
5491 : : pPrev( 0 ),
5492 [ # # ]: 0 : ppHead( ppHd )
5493 : : {
5494 [ # # ]: 0 : pItem = rItem.Clone();
5495 : 0 : }
5496 : :
5497 : 0 : _HTMLAttr::_HTMLAttr( const _HTMLAttr &rAttr, const SwNodeIndex &rEndPara,
5498 : : sal_uInt16 nEndCnt, _HTMLAttr **ppHd ) :
5499 : : nSttPara( rAttr.nSttPara ),
5500 : : nEndPara( rEndPara ),
5501 : : nSttCntnt( rAttr.nSttCntnt ),
5502 : : nEndCntnt( nEndCnt ),
5503 : : bInsAtStart( rAttr.bInsAtStart ),
5504 : : bLikePara( rAttr.bLikePara ),
5505 : : bValid( rAttr.bValid ),
5506 : : nCount( rAttr.nCount ),
5507 : : pNext( 0 ),
5508 : : pPrev( 0 ),
5509 [ # # ]: 0 : ppHead( ppHd )
5510 : : {
5511 [ # # ]: 0 : pItem = rAttr.pItem->Clone();
5512 : 0 : }
5513 : :
5514 [ # # ]: 0 : _HTMLAttr::~_HTMLAttr()
5515 : : {
5516 [ # # ][ # # ]: 0 : delete pItem;
5517 : 0 : }
5518 : :
5519 : 0 : _HTMLAttr *_HTMLAttr::Clone( const SwNodeIndex& rEndPara, sal_uInt16 nEndCnt ) const
5520 : : {
5521 : : // das Attribut mit der alten Start-Position neu anlegen
5522 [ # # ]: 0 : _HTMLAttr *pNew = new _HTMLAttr( *this, rEndPara, nEndCnt, ppHead );
5523 : :
5524 : : // die Previous-Liste muss uebernommen werden, die Next-Liste nicht!
5525 : 0 : pNew->pPrev = pPrev;
5526 : :
5527 : 0 : return pNew;
5528 : : }
5529 : :
5530 : 0 : void _HTMLAttr::Reset( const SwNodeIndex& rSttPara, sal_uInt16 nSttCnt,
5531 : : _HTMLAttr **ppHd )
5532 : : {
5533 : : // den Anfang (und das Ende) neu setzen
5534 : 0 : nSttPara = rSttPara;
5535 : 0 : nSttCntnt = nSttCnt;
5536 : 0 : nEndPara = rSttPara;
5537 : 0 : nEndCntnt = nSttCnt;
5538 : :
5539 : : // den Head korrigieren und die Verkettungen aufheben
5540 : 0 : pNext = 0;
5541 : 0 : pPrev = 0;
5542 : 0 : ppHead = ppHd;
5543 : 0 : }
5544 : :
5545 : 0 : void _HTMLAttr::InsertPrev( _HTMLAttr *pPrv )
5546 : : {
5547 : : OSL_ENSURE( !pPrv->pNext || pPrv->pNext == this,
5548 : : "_HTMLAttr::InsertPrev: pNext falsch" );
5549 : 0 : pPrv->pNext = 0;
5550 : :
5551 : : OSL_ENSURE( 0 == pPrv->ppHead || ppHead == pPrv->ppHead,
5552 : : "_HTMLAttr::InsertPrev: ppHead falsch" );
5553 : 0 : pPrv->ppHead = 0;
5554 : :
5555 : 0 : _HTMLAttr *pAttr = this;
5556 [ # # ]: 0 : while( pAttr->GetPrev() )
5557 : 0 : pAttr = pAttr->GetPrev();
5558 : :
5559 : 0 : pAttr->pPrev = pPrv;
5560 : 0 : }
5561 : :
5562 : 8 : bool SwHTMLParser::ParseMetaOptions(
5563 : : const uno::Reference<document::XDocumentProperties> & i_xDocProps,
5564 : : SvKeyValueIterator *i_pHeader )
5565 : : {
5566 : : // always call base ParseMetaOptions, it sets the encoding (#i96700#)
5567 : 8 : bool ret( HTMLParser::ParseMetaOptions(i_xDocProps, i_pHeader) );
5568 [ + - ][ + + ]: 8 : if (!ret && IsNewDoc())
[ + + ]
5569 : : {
5570 : 4 : ParseMoreMetaOptions();
5571 : : }
5572 : 8 : return ret;
5573 : : }
5574 : :
5575 : : // override so we can parse DOCINFO field subtypes INFO[1-4]
5576 : 0 : void SwHTMLParser::AddMetaUserDefined( ::rtl::OUString const & i_rMetaName )
5577 : : {
5578 : : // unless we already have 4 names, append the argument to m_InfoNames
5579 : : ::rtl::OUString* pName // the first empty string in m_InfoNames
5580 : 0 : (m_InfoNames[0].isEmpty() ? &m_InfoNames[0] :
5581 : 0 : (m_InfoNames[1].isEmpty() ? &m_InfoNames[1] :
5582 : 0 : (m_InfoNames[2].isEmpty() ? &m_InfoNames[2] :
5583 [ # # ][ # # ]: 0 : (m_InfoNames[3].isEmpty() ? &m_InfoNames[3] : 0 ))));
[ # # ][ # # ]
5584 [ # # ]: 0 : if (pName)
5585 : : {
5586 : 0 : (*pName) = i_rMetaName;
5587 : : }
5588 : 0 : }
5589 : :
5590 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|