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 "hintids.hxx"
31 : : #include <comphelper/string.hxx>
32 : : #include <vcl/svapp.hxx>
33 : : #include <vcl/wrkwin.hxx>
34 : : #include <svx/svxids.hrc>
35 : : #include <sfx2/sfx.hrc>
36 : : #include <i18npool/mslangid.hxx>
37 : : #include <svl/stritem.hxx>
38 : : #include <svl/urihelper.hxx>
39 : : #include <editeng/fhgtitem.hxx>
40 : : #include <editeng/lrspitem.hxx>
41 : : #include <editeng/adjitem.hxx>
42 : : #include <editeng/brshitem.hxx>
43 : : #include <editeng/colritem.hxx>
44 : : #include <editeng/boxitem.hxx>
45 : : #include <editeng/ulspitem.hxx>
46 : : #include <editeng/langitem.hxx>
47 : : #include <editeng/scripttypeitem.hxx>
48 : : #include <sfx2/docfile.hxx>
49 : : #include <svtools/imap.hxx>
50 : : #include <svtools/htmltokn.h>
51 : : #include <svtools/htmlkywd.hxx>
52 : : #include <unotools/eventcfg.hxx>
53 : :
54 : : #include <fmtornt.hxx>
55 : : #include <fmturl.hxx>
56 : : #include <fmtsrnd.hxx>
57 : : #include <fmtinfmt.hxx>
58 : : #include <fmtcntnt.hxx>
59 : : #include <fmtanchr.hxx>
60 : : #include <fmtfsize.hxx>
61 : : #include "frmatr.hxx"
62 : : #include "charatr.hxx"
63 : : #include <frmfmt.hxx>
64 : : #include <charfmt.hxx>
65 : : #include <docary.hxx>
66 : : #include <docsh.hxx>
67 : : #include <pam.hxx>
68 : : #include <doc.hxx>
69 : : #include <ndtxt.hxx>
70 : : #include <shellio.hxx>
71 : : #include <poolfmt.hxx>
72 : : #include <IMark.hxx>
73 : : #include <ndgrf.hxx>
74 : : #include <htmlnum.hxx>
75 : : #include <swcss1.hxx>
76 : : #include <swhtml.hxx>
77 : : #include <numrule.hxx>
78 : : #include <boost/shared_ptr.hpp>
79 : :
80 : : using namespace ::com::sun::star;
81 : :
82 : :
83 : : HTMLOptionEnum aHTMLImgHAlignTable[] =
84 : : {
85 : : { OOO_STRING_SVTOOLS_HTML_AL_left, text::HoriOrientation::LEFT },
86 : : { OOO_STRING_SVTOOLS_HTML_AL_right, text::HoriOrientation::RIGHT },
87 : : { 0, 0 }
88 : : };
89 : :
90 : :
91 : : HTMLOptionEnum aHTMLImgVAlignTable[] =
92 : : {
93 : : { OOO_STRING_SVTOOLS_HTML_VA_top, text::VertOrientation::LINE_TOP },
94 : : { OOO_STRING_SVTOOLS_HTML_VA_texttop, text::VertOrientation::CHAR_TOP },
95 : : { OOO_STRING_SVTOOLS_HTML_VA_middle, text::VertOrientation::CENTER },
96 : : { OOO_STRING_SVTOOLS_HTML_AL_center, text::VertOrientation::CENTER },
97 : : { OOO_STRING_SVTOOLS_HTML_VA_absmiddle, text::VertOrientation::LINE_CENTER },
98 : : { OOO_STRING_SVTOOLS_HTML_VA_bottom, text::VertOrientation::TOP },
99 : : { OOO_STRING_SVTOOLS_HTML_VA_baseline, text::VertOrientation::TOP },
100 : : { OOO_STRING_SVTOOLS_HTML_VA_absbottom, text::VertOrientation::LINE_BOTTOM },
101 : : { 0, 0 }
102 : : };
103 : :
104 : 0 : ImageMap *SwHTMLParser::FindImageMap( const String& rName ) const
105 : : {
106 : 0 : ImageMap *pMap = 0;
107 : :
108 : : OSL_ENSURE( rName.GetChar(0) != '#', "FindImageName: Name beginnt mit #!" );
109 : :
110 [ # # ]: 0 : if( pImageMaps )
111 : : {
112 [ # # ]: 0 : for( sal_uInt16 i=0; i<pImageMaps->size(); i++ )
113 : : {
114 : 0 : ImageMap *pIMap = &(*pImageMaps)[i];
115 [ # # ]: 0 : if( rName.EqualsIgnoreCaseAscii( pIMap->GetName() ) )
116 : : {
117 : 0 : pMap = pIMap;
118 : 0 : break;
119 : : }
120 : : }
121 : : }
122 : 0 : return pMap;
123 : : }
124 : :
125 : 0 : void SwHTMLParser::ConnectImageMaps()
126 : : {
127 : 0 : SwNodes& rNds = pDoc->GetNodes();
128 : : // auf den Start-Node der 1. Section
129 : 0 : sal_uLong nIdx = rNds.GetEndOfAutotext().StartOfSectionIndex() + 1;
130 : 0 : sal_uLong nEndIdx = rNds.GetEndOfAutotext().GetIndex();
131 : :
132 : : SwGrfNode* pGrfNd;
133 [ # # ][ # # ]: 0 : while( nMissingImgMaps > 0 && nIdx < nEndIdx )
[ # # ]
134 : : {
135 : 0 : SwNode *pNd = rNds[nIdx + 1];
136 [ # # ]: 0 : if( 0 != (pGrfNd = pNd->GetGrfNode()) )
137 : : {
138 [ # # ]: 0 : SwFrmFmt *pFmt = pGrfNd->GetFlyFmt();
139 [ # # ][ # # ]: 0 : SwFmtURL aURL( pFmt->GetURL() );
140 : 0 : const ImageMap *pIMap = aURL.GetMap();
141 [ # # ][ # # ]: 0 : if( pIMap && pIMap->GetIMapObjectCount()==0 )
[ # # ]
142 : : {
143 : : // Die (leere) Image-Map des Nodes wird entweder
144 : : // durch die jetzt gefundene Image-Map ersetzt
145 : : // oder geloescht.
146 : : ImageMap *pNewIMap =
147 [ # # ]: 0 : FindImageMap( pIMap->GetName() );
148 [ # # ]: 0 : aURL.SetMap( pNewIMap );
149 [ # # ]: 0 : pFmt->SetFmtAttr( aURL );
150 [ # # ]: 0 : if( !pGrfNd->IsScaleImageMap() )
151 : : {
152 : : // die Grafikgroesse ist mitlerweile da oder dir
153 : : // Grafik muss nicht skaliert werden
154 [ # # ]: 0 : pGrfNd->ScaleImageMap();
155 : : }
156 : 0 : nMissingImgMaps--; // eine Map weniger suchen
157 [ # # ]: 0 : }
158 : : }
159 : 0 : nIdx = rNds[nIdx]->EndOfSectionIndex() + 1;
160 : : }
161 : 0 : }
162 : :
163 : :
164 : : /* */
165 : :
166 : 0 : void SwHTMLParser::SetAnchorAndAdjustment( sal_Int16 eVertOri,
167 : : sal_Int16 eHoriOri,
168 : : const SfxItemSet &rCSS1ItemSet,
169 : : const SvxCSS1PropertyInfo &rCSS1PropInfo,
170 : : SfxItemSet& rFrmItemSet )
171 : : {
172 : 0 : const SfxItemSet *pCntnrItemSet = 0;
173 : 0 : sal_uInt16 i = aContexts.size();
174 [ # # ][ # # ]: 0 : while( !pCntnrItemSet && i > nContextStMin )
[ # # ]
175 : 0 : pCntnrItemSet = aContexts[--i]->GetFrmItemSet();
176 : :
177 [ # # ]: 0 : if( pCntnrItemSet )
178 : : {
179 : : // Wenn wir und in einem Container befinden wird die Verankerung
180 : : // des Containers uebernommen.
181 : 0 : rFrmItemSet.Put( *pCntnrItemSet );
182 : : }
183 [ # # ]: 0 : else if( pCSS1Parser->MayBePositioned( rCSS1PropInfo, sal_True ) )
184 : : {
185 : : // Wenn die Ausrichtung anhand der CSS1-Optionen gesetzt werden kann
186 : : // werden die benutzt.
187 : 0 : SetAnchorAndAdjustment( rCSS1ItemSet, rCSS1PropInfo, rFrmItemSet );
188 : : }
189 : : else
190 : : {
191 : : // Sonst wird die Ausrichtung entsprechend der normalen HTML-Optionen
192 : : // gesetzt.
193 : 0 : SetAnchorAndAdjustment( eVertOri, eHoriOri, rFrmItemSet );
194 : : }
195 : 0 : }
196 : :
197 : 0 : void SwHTMLParser::SetAnchorAndAdjustment( sal_Int16 eVertOri,
198 : : sal_Int16 eHoriOri,
199 : : SfxItemSet& rFrmSet,
200 : : sal_Bool bDontAppend )
201 : : {
202 : 0 : sal_Bool bMoveBackward = sal_False;
203 [ # # ]: 0 : SwFmtAnchor aAnchor( FLY_AS_CHAR );
204 : 0 : sal_Int16 eVertRel = text::RelOrientation::FRAME;
205 : :
206 [ # # ]: 0 : if( text::HoriOrientation::NONE != eHoriOri )
207 : : {
208 : : // den Absatz-Einzug bestimmen
209 : 0 : sal_uInt16 nLeftSpace = 0, nRightSpace = 0;
210 : 0 : short nIndent = 0;
211 [ # # ]: 0 : GetMarginsFromContextWithNumBul( nLeftSpace, nRightSpace, nIndent );
212 : :
213 : : // Horizonale Ausrichtung und Umlauf bestimmen.
214 : : sal_Int16 eHoriRel;
215 : : SwSurround eSurround;
216 [ # # # # ]: 0 : switch( eHoriOri )
217 : : {
218 : : case text::HoriOrientation::LEFT:
219 [ # # ]: 0 : eHoriRel = nLeftSpace ? text::RelOrientation::PRINT_AREA : text::RelOrientation::FRAME;
220 : 0 : eSurround = SURROUND_RIGHT;
221 : 0 : break;
222 : : case text::HoriOrientation::RIGHT:
223 [ # # ]: 0 : eHoriRel = nRightSpace ? text::RelOrientation::PRINT_AREA : text::RelOrientation::FRAME;
224 : 0 : eSurround = SURROUND_LEFT;
225 : 0 : break;
226 : : case text::HoriOrientation::CENTER: // fuer Tabellen
227 : 0 : eHoriRel = text::RelOrientation::FRAME;
228 : 0 : eSurround = SURROUND_NONE;
229 : 0 : break;
230 : : default:
231 : 0 : eHoriRel = text::RelOrientation::FRAME;
232 : 0 : eSurround = SURROUND_PARALLEL;
233 : 0 : break;
234 : : }
235 : :
236 : : // Einen neuen Absatz aufmachen, wenn der aktuelle
237 : : // absatzgebundene Rahmen ohne Umlauf enthaelt.
238 [ # # ][ # # ]: 0 : if( !bDontAppend && HasCurrentParaFlys( sal_True ) )
[ # # ][ # # ]
239 : : {
240 : : // Wenn der Absatz nur Grafiken enthaelt, braucht er
241 : : // auch keinen unteren Absatz-Abstand. Da hier auch bei
242 : : // Verwendung von Styles kein Abstand enstehen soll, wird
243 : : // hier auch geweohnlich attributiert !!!
244 : 0 : sal_uInt16 nUpper=0, nLower=0;
245 [ # # ]: 0 : GetULSpaceFromContext( nUpper, nLower );
246 [ # # ][ # # ]: 0 : InsertAttr( SvxULSpaceItem( nUpper, 0, RES_UL_SPACE ), sal_False, sal_True );
[ # # ]
247 : :
248 [ # # ]: 0 : AppendTxtNode( AM_NOSPACE );
249 : :
250 [ # # ]: 0 : if( nUpper )
251 : : {
252 [ # # ][ # # ]: 0 : NewAttr( &aAttrTab.pULSpace, SvxULSpaceItem( 0, nLower, RES_UL_SPACE ) );
[ # # ]
253 [ # # ]: 0 : aParaAttrs.push_back( aAttrTab.pULSpace );
254 [ # # ]: 0 : EndAttr( aAttrTab.pULSpace, 0, sal_False );
255 : : }
256 : : }
257 : :
258 : : // Vertikale Ausrichtung und Verankerung bestimmen.
259 : 0 : xub_StrLen nCntnt = pPam->GetPoint()->nContent.GetIndex();
260 [ # # ]: 0 : if( nCntnt )
261 : : {
262 : 0 : aAnchor.SetType( FLY_AT_CHAR );
263 : 0 : bMoveBackward = sal_True;
264 : 0 : eVertOri = text::VertOrientation::CHAR_BOTTOM;
265 : 0 : eVertRel = text::RelOrientation::CHAR;
266 : : }
267 : : else
268 : : {
269 : 0 : aAnchor.SetType( FLY_AT_PARA );
270 : 0 : eVertOri = text::VertOrientation::TOP;
271 : 0 : eVertRel = text::RelOrientation::PRINT_AREA;
272 : : }
273 : :
274 [ # # ][ # # ]: 0 : rFrmSet.Put( SwFmtHoriOrient( 0, eHoriOri, eHoriRel) );
[ # # ]
275 : :
276 [ # # ][ # # ]: 0 : rFrmSet.Put( SwFmtSurround( eSurround ) );
[ # # ]
277 : : }
278 [ # # ][ # # ]: 0 : rFrmSet.Put( SwFmtVertOrient( 0, eVertOri, eVertRel) );
[ # # ]
279 : :
280 [ # # ]: 0 : if( bMoveBackward )
281 [ # # ]: 0 : pPam->Move( fnMoveBackward );
282 : :
283 [ # # ]: 0 : aAnchor.SetAnchor( pPam->GetPoint() );
284 : :
285 [ # # ]: 0 : if( bMoveBackward )
286 [ # # ]: 0 : pPam->Move( fnMoveForward );
287 : :
288 [ # # ][ # # ]: 0 : rFrmSet.Put( aAnchor );
289 : 0 : }
290 : :
291 : 0 : void SwHTMLParser::RegisterFlyFrm( SwFrmFmt *pFlyFmt )
292 : : {
293 : : // automatisch verankerte Rahmen muessen noch um eine Position
294 : : // nach vorne verschoben werden.
295 [ # # # # : 0 : if( RES_DRAWFRMFMT != pFlyFmt->Which() &&
# # ][ # # ]
296 : 0 : (FLY_AT_PARA == pFlyFmt->GetAnchor().GetAnchorId()) &&
297 : 0 : SURROUND_THROUGHT == pFlyFmt->GetSurround().GetSurround() )
298 : : {
299 : 0 : aMoveFlyFrms.push_back( pFlyFmt );
300 [ # # ]: 0 : aMoveFlyCnts.push_back( pPam->GetPoint()->nContent.GetIndex() );
301 : : }
302 : 0 : }
303 : :
304 : : /* */
305 : :
306 : 2 : void SwHTMLParser::GetDefaultScriptType( ScriptType& rType,
307 : : String& rTypeStr ) const
308 : : {
309 : 2 : SwDocShell *pDocSh = pDoc->GetDocShell();
310 : 2 : SvKeyValueIterator* pHeaderAttrs = pDocSh ? pDocSh->GetHeaderAttributes()
311 [ + - ]: 2 : : 0;
312 : 2 : rType = GetScriptType( pHeaderAttrs );
313 : 2 : rTypeStr = GetScriptTypeString( pHeaderAttrs );
314 : 2 : }
315 : :
316 : : /* */
317 : :
318 : 0 : void SwHTMLParser::InsertImage()
319 : : {
320 : : // und jetzt auswerten
321 [ # # ][ # # ]: 0 : String sGrfNm, sAltNm, aId, aClass, aStyle, aMap, sHTMLGrfName;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
322 : 0 : sal_Int16 eVertOri = text::VertOrientation::TOP;
323 : 0 : sal_Int16 eHoriOri = text::HoriOrientation::NONE;
324 : 0 : long nWidth=0, nHeight=0;
325 : 0 : long nVSpace=0, nHSpace=0;
326 : :
327 [ # # ]: 0 : sal_uInt16 nBorder = (aAttrTab.pINetFmt ? 1 : 0);
328 : 0 : sal_Bool bIsMap = sal_False;
329 : 0 : sal_Bool bPrcWidth = sal_False;
330 : 0 : sal_Bool bPrcHeight = sal_False;
331 [ # # ]: 0 : SvxMacroItem aMacroItem(RES_FRMMACRO);
332 : :
333 : : ScriptType eDfltScriptType;
334 [ # # ]: 0 : String sDfltScriptType;
335 [ # # ]: 0 : GetDefaultScriptType( eDfltScriptType, sDfltScriptType );
336 : :
337 [ # # ]: 0 : const HTMLOptions& rHTMLOptions = GetOptions();
338 [ # # ]: 0 : for (size_t i = rHTMLOptions.size(); i; )
339 : : {
340 : 0 : sal_uInt16 nEvent = 0;
341 : 0 : ScriptType eScriptType2 = eDfltScriptType;
342 [ # # ]: 0 : const HTMLOption& rOption = rHTMLOptions[--i];
343 [ # # # # : 0 : switch( rOption.GetToken() )
# # # # #
# # # # #
# # # # #
# # ]
344 : : {
345 : : case HTML_O_ID:
346 [ # # ]: 0 : aId = rOption.GetString();
347 : 0 : break;
348 : : case HTML_O_STYLE:
349 [ # # ]: 0 : aStyle = rOption.GetString();
350 : 0 : break;
351 : : case HTML_O_CLASS:
352 [ # # ]: 0 : aClass = rOption.GetString();
353 : 0 : break;
354 : : case HTML_O_SRC:
355 [ # # ]: 0 : sGrfNm = rOption.GetString();
356 [ # # ][ # # ]: 0 : if( !InternalImgToPrivateURL(sGrfNm) )
357 [ # # ][ # # ]: 0 : sGrfNm = INetURLObject::GetAbsURL( sBaseURL, sGrfNm );
[ # # ][ # # ]
358 : 0 : break;
359 : : case HTML_O_ALIGN:
360 : : eVertOri =
361 : : rOption.GetEnum( aHTMLImgVAlignTable,
362 [ # # ]: 0 : text::VertOrientation::TOP );
363 : : eHoriOri =
364 : : rOption.GetEnum( aHTMLImgHAlignTable,
365 [ # # ]: 0 : text::HoriOrientation::NONE );
366 : 0 : break;
367 : : case HTML_O_WIDTH:
368 : : // erstmal nur als Pixelwerte merken!
369 [ # # ]: 0 : nWidth = rOption.GetNumber();
370 [ # # ]: 0 : bPrcWidth = (rOption.GetString().Search('%') != STRING_NOTFOUND);
371 [ # # ][ # # ]: 0 : if( bPrcWidth && nWidth>100 )
372 : 0 : nWidth = 100;
373 : 0 : break;
374 : : case HTML_O_HEIGHT:
375 : : // erstmal nur als Pixelwerte merken!
376 [ # # ]: 0 : nHeight = rOption.GetNumber();
377 [ # # ]: 0 : bPrcHeight = (rOption.GetString().Search('%') != STRING_NOTFOUND);
378 [ # # ][ # # ]: 0 : if( bPrcHeight && nHeight>100 )
379 : 0 : nHeight = 100;
380 : 0 : break;
381 : : case HTML_O_VSPACE:
382 [ # # ]: 0 : nVSpace = rOption.GetNumber();
383 : 0 : break;
384 : : case HTML_O_HSPACE:
385 [ # # ]: 0 : nHSpace = rOption.GetNumber();
386 : 0 : break;
387 : : case HTML_O_ALT:
388 [ # # ]: 0 : sAltNm = rOption.GetString();
389 : 0 : break;
390 : : case HTML_O_BORDER:
391 [ # # ]: 0 : nBorder = (sal_uInt16)rOption.GetNumber();
392 : 0 : break;
393 : : case HTML_O_ISMAP:
394 : 0 : bIsMap = sal_True;
395 : 0 : break;
396 : : case HTML_O_USEMAP:
397 [ # # ]: 0 : aMap = rOption.GetString();
398 : 0 : break;
399 : : case HTML_O_NAME:
400 [ # # ]: 0 : sHTMLGrfName = rOption.GetString();
401 : 0 : break;
402 : :
403 : : case HTML_O_SDONLOAD:
404 : 0 : eScriptType2 = STARBASIC;
405 : : case HTML_O_ONLOAD:
406 : 0 : nEvent = SVX_EVENT_IMAGE_LOAD;
407 : 0 : goto IMAGE_SETEVENT;
408 : :
409 : : case HTML_O_SDONABORT:
410 : 0 : eScriptType2 = STARBASIC;
411 : : case HTML_O_ONABORT:
412 : 0 : nEvent = SVX_EVENT_IMAGE_ABORT;
413 : 0 : goto IMAGE_SETEVENT;
414 : :
415 : : case HTML_O_SDONERROR:
416 : 0 : eScriptType2 = STARBASIC;
417 : : case HTML_O_ONERROR:
418 : 0 : nEvent = SVX_EVENT_IMAGE_ERROR;
419 : 0 : goto IMAGE_SETEVENT;
420 : : IMAGE_SETEVENT:
421 : : {
422 [ # # ]: 0 : String sTmp( rOption.GetString() );
423 [ # # ]: 0 : if( sTmp.Len() )
424 : : {
425 [ # # ][ # # ]: 0 : sTmp = convertLineEnd(sTmp, GetSystemLineEnd());
[ # # ]
426 [ # # ]: 0 : String sScriptType;
427 [ # # ]: 0 : if( EXTENDED_STYPE == eScriptType2 )
428 [ # # ]: 0 : sScriptType = sDfltScriptType;
429 : : aMacroItem.SetMacro( nEvent,
430 [ # # ][ # # ]: 0 : SvxMacro( sTmp, sScriptType, eScriptType2 ));
[ # # ][ # # ]
[ # # ][ # # ]
431 [ # # ]: 0 : }
432 : : }
433 : 0 : break;
434 : : }
435 : : }
436 : :
437 [ # # ]: 0 : if( !sGrfNm.Len() )
438 : : return;
439 : :
440 : : // Wenn wir in einer Numerierung stehen und der Absatz noch leer und
441 : : // nicht numeriert ist, handelt es sich vielleicht um die Grafik
442 : : // einer Bullet-Liste
443 [ # # # # : 0 : if( !pPam->GetPoint()->nContent.GetIndex() &&
# # # # ]
[ # # ][ # # ]
444 : 0 : GetNumInfo().GetDepth() > 0 && GetNumInfo().GetDepth() <= MAXLEVEL &&
445 : 0 : aBulletGrfs[GetNumInfo().GetDepth()-1].Len() &&
446 [ # # ]: 0 : aBulletGrfs[GetNumInfo().GetDepth()-1]==sGrfNm )
447 : : {
448 : 0 : SwTxtNode* pTxtNode = pPam->GetNode()->GetTxtNode();
449 : :
450 [ # # ][ # # ]: 0 : if( pTxtNode && ! pTxtNode->IsCountedInList())
[ # # ][ # # ]
451 : : {
452 : : OSL_ENSURE( pTxtNode->GetActualListLevel() == GetNumInfo().GetLevel(),
453 : : "Numerierungs-Ebene stimmt nicht" );
454 : :
455 [ # # ]: 0 : pTxtNode->SetCountedInList( true );
456 : :
457 : : // Rule invalisieren ist noetig, weil zwischem dem einlesen
458 : : // des LI und der Grafik ein EndAction gerufen worden sein kann.
459 [ # # ]: 0 : if( GetNumInfo().GetNumRule() )
460 [ # # ]: 0 : GetNumInfo().GetNumRule()->SetInvalidRule( sal_True );
461 : :
462 : : // Die Vorlage novh mal setzen. Ist noetig, damit der
463 : : // Erstzeilen-Einzug stimmt.
464 [ # # ]: 0 : SetTxtCollAttrs();
465 : :
466 : : return;
467 : : }
468 : : }
469 : :
470 [ # # ][ # # ]: 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
471 [ # # ]: 0 : SvxCSS1PropertyInfo aPropInfo;
472 [ # # ]: 0 : if( HasStyleOptions( aStyle, aId, aClass ) )
473 [ # # ]: 0 : ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
474 : :
475 : 0 : SfxItemSet aFrmSet( pDoc->GetAttrPool(),
476 [ # # ]: 0 : RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
477 [ # # ]: 0 : if( !IsNewDoc() )
478 [ # # ]: 0 : Reader::ResetFrmFmtAttrs( aFrmSet );
479 : :
480 : : // Umrandung setzen
481 : 0 : long nHBorderWidth = 0, nVBorderWidth = 0;
482 [ # # ]: 0 : if( nBorder )
483 : : {
484 : 0 : nHBorderWidth = (long)nBorder;
485 : 0 : nVBorderWidth = (long)nBorder;
486 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nVBorderWidth, nHBorderWidth );
487 : :
488 [ # # ]: 0 : ::editeng::SvxBorderLine aHBorderLine( NULL, nHBorderWidth );
489 [ # # ]: 0 : ::editeng::SvxBorderLine aVBorderLine( NULL, nVBorderWidth );
490 : :
491 [ # # ]: 0 : if( aAttrTab.pINetFmt )
492 : : {
493 : : const String& rURL =
494 : 0 : ((const SwFmtINetFmt&)aAttrTab.pINetFmt->GetItem()).GetValue();
495 : :
496 [ # # ]: 0 : pCSS1Parser->SetATagStyles();
497 [ # # ]: 0 : sal_uInt16 nPoolId = static_cast< sal_uInt16 >(pDoc->IsVisitedURL( rURL )
498 : : ? RES_POOLCHR_INET_VISIT
499 [ # # ]: 0 : : RES_POOLCHR_INET_NORMAL);
500 [ # # ]: 0 : const SwCharFmt *pCharFmt = pCSS1Parser->GetCharFmtFromPool( nPoolId );
501 [ # # ]: 0 : aHBorderLine.SetColor( pCharFmt->GetColor().GetValue() );
502 : 0 : aVBorderLine.SetColor( aHBorderLine.GetColor() );
503 : : }
504 : : else
505 : : {
506 : : const SvxColorItem& rColorItem = aAttrTab.pFontColor ?
507 : 0 : (const SvxColorItem &)aAttrTab.pFontColor->GetItem() :
508 [ # # ][ # # ]: 0 : (const SvxColorItem &)pDoc->GetDefault(RES_CHRATR_COLOR);
509 : 0 : aHBorderLine.SetColor( rColorItem.GetValue() );
510 : 0 : aVBorderLine.SetColor( aHBorderLine.GetColor() );
511 : : }
512 : :
513 : :
514 [ # # ]: 0 : SvxBoxItem aBoxItem( RES_BOX );
515 [ # # ]: 0 : aBoxItem.SetLine( &aHBorderLine, BOX_LINE_TOP );
516 [ # # ]: 0 : aBoxItem.SetLine( &aHBorderLine, BOX_LINE_BOTTOM );
517 [ # # ]: 0 : aBoxItem.SetLine( &aVBorderLine, BOX_LINE_LEFT );
518 [ # # ]: 0 : aBoxItem.SetLine( &aVBorderLine, BOX_LINE_RIGHT );
519 [ # # ][ # # ]: 0 : aFrmSet.Put( aBoxItem );
520 : : }
521 : :
522 : : // Ausrichtung setzen
523 [ # # ]: 0 : SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, aFrmSet );
524 : :
525 : : // Abstaende setzen
526 [ # # ]: 0 : SetSpace( Size( nHSpace, nVSpace), aItemSet, aPropInfo, aFrmSet );
527 : :
528 : : // Sonstige CSS1-Attribute Setzen
529 [ # # ]: 0 : SetFrmFmtAttrs( aItemSet, aPropInfo, HTML_FF_BOX, aFrmSet );
530 : :
531 [ # # ][ # # ]: 0 : Size aTwipSz( bPrcWidth ? 0 : nWidth, bPrcHeight ? 0 : nHeight );
532 [ # # ][ # # ]: 0 : if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
[ # # ][ # # ]
[ # # ]
533 : : {
534 : : aTwipSz = Application::GetDefaultDevice()
535 [ # # ][ # # ]: 0 : ->PixelToLogic( aTwipSz, MapMode( MAP_TWIP ) );
[ # # ][ # # ]
536 : : }
537 : :
538 : : // CSS1-Groesse auf "normale" Groesse umrechnen
539 [ # # # ]: 0 : switch( aPropInfo.eWidthType )
540 : : {
541 : : case SVX_CSS1_LTYPE_TWIP:
542 : 0 : aTwipSz.Width() = aPropInfo.nWidth;
543 : 0 : nWidth = 1; // != 0
544 : 0 : bPrcWidth = sal_False;
545 : 0 : break;
546 : : case SVX_CSS1_LTYPE_PERCENTAGE:
547 : 0 : aTwipSz.Width() = 0;
548 : 0 : nWidth = aPropInfo.nWidth;
549 : 0 : bPrcWidth = sal_True;
550 : 0 : break;
551 : : default:
552 : : ;
553 : : }
554 [ # # # ]: 0 : switch( aPropInfo.eHeightType )
555 : : {
556 : : case SVX_CSS1_LTYPE_TWIP:
557 : 0 : aTwipSz.Height() = aPropInfo.nHeight;
558 : 0 : nHeight = 1; // != 0
559 : 0 : bPrcHeight = sal_False;
560 : 0 : break;
561 : : case SVX_CSS1_LTYPE_PERCENTAGE:
562 : 0 : aTwipSz.Height() = 0;
563 : 0 : nHeight = aPropInfo.nHeight;
564 : 0 : bPrcHeight = sal_True;
565 : 0 : break;
566 : : default:
567 : : ;
568 : : }
569 : :
570 : 0 : Size aGrfSz( 0, 0 );
571 : 0 : sal_Bool bSetTwipSize = sal_True; // Twip-Size am Node setzen?
572 : 0 : sal_Bool bChangeFrmSize = sal_False; // Frame-Format nachtraeglich anpassen?
573 : 0 : sal_Bool bRequestGrfNow = sal_False;
574 : 0 : sal_Bool bSetScaleImageMap = sal_False;
575 : 0 : sal_uInt8 nPrcWidth = 0, nPrcHeight = 0;
576 : :
577 [ # # ][ # # ]: 0 : if( !nWidth || !nHeight )
578 : : {
579 : : // Es fehlt die Breite oder die Hoehe
580 : : // Wenn die Grfik in einer Tabelle steht, wird sie gleich
581 : : // angefordert, damit sie eventuell schon da ist, bevor die
582 : : // Tabelle layoutet wird.
583 [ # # ][ # # ]: 0 : if( pTable!=0 && !nWidth )
584 : : {
585 : 0 : bRequestGrfNow = sal_True;
586 [ # # ]: 0 : IncGrfsThatResizeTable();
587 : : }
588 : :
589 : : // Die Groesse des Rahmens wird nachtraeglich gesetzt
590 : 0 : bChangeFrmSize = sal_True;
591 : 0 : aGrfSz = aTwipSz;
592 [ # # ][ # # ]: 0 : if( !nWidth && !nHeight )
593 : : {
594 : 0 : aTwipSz.Width() = HTML_DFLT_IMG_WIDTH;
595 : 0 : aTwipSz.Height() = HTML_DFLT_IMG_HEIGHT;
596 : : }
597 [ # # ]: 0 : else if( nWidth )
598 : : {
599 : : // eine %-Angabe
600 [ # # ]: 0 : if( bPrcWidth )
601 : : {
602 : 0 : nPrcWidth = (sal_uInt8)nWidth;
603 : 0 : nPrcHeight = 255;
604 : : }
605 : : else
606 : : {
607 : 0 : aTwipSz.Height() = HTML_DFLT_IMG_HEIGHT;
608 : : }
609 : : }
610 [ # # ]: 0 : else if( nHeight )
611 : : {
612 [ # # ]: 0 : if( bPrcHeight )
613 : : {
614 : 0 : nPrcHeight = (sal_uInt8)nHeight;
615 : 0 : nPrcWidth = 255;
616 : : }
617 : : else
618 : : {
619 : 0 : aTwipSz.Width() = HTML_DFLT_IMG_WIDTH;
620 : : }
621 : : }
622 : : }
623 : : else
624 : : {
625 : : // Breite und Hoehe wurden angegeben und brauchen nicht gesetzt
626 : : // zu werden
627 : 0 : bSetTwipSize = sal_False;
628 : :
629 [ # # ]: 0 : if( bPrcWidth )
630 : 0 : nPrcWidth = (sal_uInt8)nWidth;
631 : :
632 [ # # ]: 0 : if( bPrcHeight )
633 : 0 : nPrcHeight = (sal_uInt8)nHeight;
634 : : }
635 : :
636 : : // Image-Map setzen
637 [ # # ][ # # ]: 0 : aMap = comphelper::string::stripEnd(aMap, ' ');
[ # # ]
638 [ # # ]: 0 : if( aMap.Len() )
639 : : {
640 : : // Da wir nur lokale Image-Maps kennen nehmen wireinfach alles
641 : : // hinter dem # als Namen
642 [ # # ]: 0 : xub_StrLen nPos = aMap.Search( '#' );
643 [ # # ]: 0 : String aName;
644 [ # # ]: 0 : if ( STRING_NOTFOUND==nPos )
645 [ # # ]: 0 : aName = aMap ;
646 : : else
647 [ # # ][ # # ]: 0 : aName = aMap.Copy(nPos+1);
[ # # ]
648 : :
649 [ # # ]: 0 : ImageMap *pImgMap = FindImageMap( aName );
650 [ # # ]: 0 : if( pImgMap )
651 : : {
652 [ # # ][ # # ]: 0 : SwFmtURL aURL; aURL.SetMap( pImgMap );//wird kopieiert
653 : :
654 [ # # ][ # # ]: 0 : bSetScaleImageMap = !nPrcWidth || !nPrcHeight;
655 [ # # ][ # # ]: 0 : aFrmSet.Put( aURL );
656 : : }
657 : : else
658 : : {
659 [ # # ]: 0 : ImageMap aEmptyImgMap( aName );
660 [ # # ][ # # ]: 0 : SwFmtURL aURL; aURL.SetMap( &aEmptyImgMap );//wird kopieiert
661 [ # # ]: 0 : aFrmSet.Put( aURL );
662 : 0 : nMissingImgMaps++; // es fehlen noch Image-Maps
663 : :
664 : : // die Grafik muss beim SetTwipSize skaliert werden, wenn
665 : : // wir keine Groesse am Node gesetzt haben oder die Groesse
666 : : // nicht der Grafikgroesse entsprach.
667 [ # # ][ # # ]: 0 : bSetScaleImageMap = sal_True;
668 [ # # ]: 0 : }
669 : : }
670 : :
671 : : // min. Werte einhalten !!
672 [ # # ]: 0 : if( nPrcWidth )
673 : : {
674 : : OSL_ENSURE( !aTwipSz.Width(),
675 : : "Wieso ist da trotz %-Angabe eine Breite gesetzt?" );
676 : 0 : aTwipSz.Width() = aGrfSz.Width() ? aGrfSz.Width()
677 [ # # ]: 0 : : HTML_DFLT_IMG_WIDTH;
678 : : }
679 : : else
680 : : {
681 : 0 : aTwipSz.Width() += 2*nVBorderWidth;
682 [ # # ]: 0 : if( aTwipSz.Width() < MINFLY )
683 : 0 : aTwipSz.Width() = MINFLY;
684 : : }
685 [ # # ]: 0 : if( nPrcHeight )
686 : : {
687 : : OSL_ENSURE( !aTwipSz.Height(),
688 : : "Wieso ist da trotz %-Angabe eine Hoehe gesetzt?" );
689 : 0 : aTwipSz.Height() = aGrfSz.Height() ? aGrfSz.Height()
690 [ # # ]: 0 : : HTML_DFLT_IMG_HEIGHT;
691 : : }
692 : : else
693 : : {
694 : 0 : aTwipSz.Height() += 2*nHBorderWidth;
695 [ # # ]: 0 : if( aTwipSz.Height() < MINFLY )
696 : 0 : aTwipSz.Height() = MINFLY;
697 : : }
698 : :
699 [ # # ]: 0 : SwFmtFrmSize aFrmSize( ATT_FIX_SIZE, aTwipSz.Width(), aTwipSz.Height() );
700 : 0 : aFrmSize.SetWidthPercent( nPrcWidth );
701 : 0 : aFrmSize.SetHeightPercent( nPrcHeight );
702 [ # # ]: 0 : aFrmSet.Put( aFrmSize );
703 : :
704 [ # # ]: 0 : Graphic aEmptyGrf;
705 [ # # ]: 0 : aEmptyGrf.SetDefaultType();
706 : : SwFrmFmt *pFlyFmt = pDoc->Insert( *pPam, sGrfNm, aEmptyStr, &aEmptyGrf,
707 [ # # ]: 0 : &aFrmSet, NULL, NULL );
708 [ # # # # ]: 0 : SwGrfNode *pGrfNd = pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
709 [ # # ]: 0 : ->GetIndex()+1 ]->GetGrfNode();
710 : :
711 [ # # ]: 0 : if( sHTMLGrfName.Len() )
712 : : {
713 [ # # ]: 0 : pFlyFmt->SetName( sHTMLGrfName );
714 : :
715 : : // ggfs. eine Grafik anspringen
716 [ # # ][ # # ]: 0 : if( JUMPTO_GRAPHIC == eJumpTo && sHTMLGrfName == sJmpMark )
[ # # ][ # # ]
717 : : {
718 : 0 : bChkJumpMark = sal_True;
719 : 0 : eJumpTo = JUMPTO_NONE;
720 : : }
721 : : }
722 : :
723 [ # # ]: 0 : if( sAltNm.Len() )
724 [ # # ]: 0 : pGrfNd->SetTitle( sAltNm );
725 : :
726 [ # # ]: 0 : if( bSetTwipSize )
727 [ # # ]: 0 : pGrfNd->SetTwipSize( aGrfSz );
728 : :
729 : 0 : pGrfNd->SetChgTwipSize( bChangeFrmSize, bChangeFrmSize );
730 : :
731 [ # # ]: 0 : if( bSetScaleImageMap )
732 : 0 : pGrfNd->SetScaleImageMap( sal_True );
733 : :
734 [ # # ]: 0 : if( aAttrTab.pINetFmt )
735 : : {
736 : : const SwFmtINetFmt &rINetFmt =
737 : 0 : (const SwFmtINetFmt&)aAttrTab.pINetFmt->GetItem();
738 : :
739 [ # # ][ # # ]: 0 : SwFmtURL aURL( pFlyFmt->GetURL() );
740 : :
741 [ # # ]: 0 : aURL.SetURL( rINetFmt.GetValue(), bIsMap );
742 [ # # ]: 0 : aURL.SetTargetFrameName( rINetFmt.GetTargetFrame() );
743 [ # # ]: 0 : aURL.SetName( rINetFmt.GetName() );
744 [ # # ]: 0 : pFlyFmt->SetFmtAttr( aURL );
745 : :
746 : : {
747 : : const SvxMacro *pMacro;
748 : : static sal_uInt16 aEvents[] = {
749 : : SFX_EVENT_MOUSEOVER_OBJECT,
750 : : SFX_EVENT_MOUSECLICK_OBJECT,
751 : : SFX_EVENT_MOUSEOUT_OBJECT,
752 : : 0 };
753 : :
754 [ # # ]: 0 : for( sal_uInt16 n = 0; aEvents[ n ]; ++n )
755 [ # # ][ # # ]: 0 : if( 0 != ( pMacro = rINetFmt.GetMacro( aEvents[ n ] ) ))
756 [ # # ]: 0 : aMacroItem.SetMacro( aEvents[ n ], *pMacro );
757 : : }
758 : :
759 [ # # ][ # # : 0 : if ((FLY_AS_CHAR == pFlyFmt->GetAnchor().GetAnchorId()) &&
# # # # ]
[ # # ]
760 : 0 : aAttrTab.pINetFmt->GetSttPara() ==
761 : 0 : pPam->GetPoint()->nNode &&
762 : 0 : aAttrTab.pINetFmt->GetSttCnt() ==
763 : 0 : pPam->GetPoint()->nContent.GetIndex() - 1 )
764 : : {
765 : : // das Attribut wurde unmitellbar vor einer zeichengeb.
766 : : // Grafik eingefuegt, also verschieben wir es
767 [ # # ]: 0 : aAttrTab.pINetFmt->SetStart( *pPam->GetPoint() );
768 : :
769 : : // Wenn das Attribut auch ein Sprungziel ist, fuegen
770 : : // wir noch eine Bookmark vor der Grafik ein, weil das
771 : : // SwFmtURL kein Sprungziel ist.
772 [ # # ]: 0 : if( rINetFmt.GetName().Len() )
773 : : {
774 [ # # ]: 0 : pPam->Move( fnMoveBackward );
775 [ # # ]: 0 : InsertBookmark( rINetFmt.GetName() );
776 [ # # ]: 0 : pPam->Move( fnMoveForward );
777 : : }
778 [ # # ]: 0 : }
779 : :
780 : : }
781 : :
782 [ # # ]: 0 : if( !aMacroItem.GetMacroTable().empty() )
783 [ # # ]: 0 : pFlyFmt->SetFmtAttr( aMacroItem );
784 : :
785 : : // Wenn die Grafik gleich angeforder wird, muss dies geschehen,
786 : : // nachdem das Format vollstaendig aufgebaut ist, weil es evtl.
787 : : // gleich (synchron) angepasst wird (war bug #40983#)
788 [ # # ]: 0 : if( bRequestGrfNow )
789 : : {
790 [ # # ]: 0 : pGrfNd->SwapIn();
791 : : }
792 : :
793 : : // Ggf. Frames anlegen und Auto-gebundenen Rahmen registrieren
794 [ # # ]: 0 : RegisterFlyFrm( pFlyFmt );
795 : :
796 [ # # ]: 0 : if( aId.Len() )
797 [ # # ][ # # ]: 0 : InsertBookmark( aId );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
798 : : }
799 : :
800 : : /* */
801 : :
802 : 2 : void SwHTMLParser::InsertBodyOptions()
803 : : {
804 : : pDoc->SetTxtFmtColl( *pPam,
805 [ + - ][ + - ]: 2 : pCSS1Parser->GetTxtCollFromPool( RES_POOLCOLL_TEXT ) );
806 : :
807 [ + - ][ + - ]: 2 : String aBackGround, aId, aStyle, aLang, aDir;
[ + - ][ + - ]
[ + - ]
808 : 2 : Color aBGColor, aTextColor, aLinkColor, aVLinkColor;
809 : 2 : sal_Bool bBGColor=sal_False, bTextColor=sal_False;
810 : 2 : sal_Bool bLinkColor=sal_False, bVLinkColor=sal_False;
811 : :
812 : : ScriptType eDfltScriptType;
813 [ + - ]: 2 : String sDfltScriptType;
814 [ + - ]: 2 : GetDefaultScriptType( eDfltScriptType, sDfltScriptType );
815 : :
816 [ + - ]: 2 : const HTMLOptions& rHTMLOptions = GetOptions();
817 [ + + ]: 6 : for (size_t i = rHTMLOptions.size(); i; )
818 : : {
819 [ + - ]: 4 : const HTMLOption& rOption = rHTMLOptions[--i];
820 : 4 : ScriptType eScriptType2 = eDfltScriptType;
821 : 4 : rtl::OUString aEvent;
822 : 4 : sal_Bool bSetEvent = sal_False;
823 : :
824 [ - - - - : 4 : switch( rOption.GetToken() )
- - - - -
- - - - -
- - + +
- ]
825 : : {
826 : : case HTML_O_ID:
827 [ # # ]: 0 : aId = rOption.GetString();
828 : 0 : break;
829 : : case HTML_O_BACKGROUND:
830 [ # # ]: 0 : aBackGround = rOption.GetString();
831 : 0 : break;
832 : : case HTML_O_BGCOLOR:
833 [ # # ]: 0 : rOption.GetColor( aBGColor );
834 : 0 : bBGColor = sal_True;
835 : 0 : break;
836 : : case HTML_O_TEXT:
837 [ # # ]: 0 : rOption.GetColor( aTextColor );
838 : 0 : bTextColor = sal_True;
839 : 0 : break;
840 : : case HTML_O_LINK:
841 [ # # ]: 0 : rOption.GetColor( aLinkColor );
842 : 0 : bLinkColor = sal_True;
843 : 0 : break;
844 : : case HTML_O_VLINK:
845 [ # # ]: 0 : rOption.GetColor( aVLinkColor );
846 : 0 : bVLinkColor = sal_True;
847 : 0 : break;
848 : :
849 : : case HTML_O_SDONLOAD:
850 : 0 : eScriptType2 = STARBASIC;
851 : : case HTML_O_ONLOAD:
852 [ # # ]: 0 : aEvent = GlobalEventConfig::GetEventName( STR_EVENT_OPENDOC );
853 : 0 : bSetEvent = sal_True;
854 : 0 : break;
855 : :
856 : : case HTML_O_SDONUNLOAD:
857 : 0 : eScriptType2 = STARBASIC;
858 : : case HTML_O_ONUNLOAD:
859 [ # # ]: 0 : aEvent = GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEDOC );
860 : 0 : bSetEvent = sal_True;
861 : 0 : break;
862 : :
863 : : case HTML_O_SDONFOCUS:
864 : 0 : eScriptType2 = STARBASIC;
865 : : case HTML_O_ONFOCUS:
866 [ # # ]: 0 : aEvent = GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC );
867 : 0 : bSetEvent = sal_True;
868 : 0 : break;
869 : :
870 : : case HTML_O_SDONBLUR:
871 : 0 : eScriptType2 = STARBASIC;
872 : : case HTML_O_ONBLUR:
873 [ # # ]: 0 : aEvent = GlobalEventConfig::GetEventName( STR_EVENT_DEACTIVATEDOC );
874 : 0 : bSetEvent = sal_True;
875 : 0 : break;
876 : :
877 : : case HTML_O_ONERROR:
878 : 0 : break;
879 : :
880 : : case HTML_O_STYLE:
881 [ # # ]: 0 : aStyle = rOption.GetString();
882 : 0 : bTextColor = sal_True;
883 : 0 : break;
884 : : case HTML_O_LANG:
885 [ + - ]: 2 : aLang = rOption.GetString();
886 : 2 : break;
887 : : case HTML_O_DIR:
888 [ + - ]: 2 : aDir = rOption.GetString();
889 : 2 : break;
890 : : }
891 : :
892 [ - + ]: 4 : if( bSetEvent )
893 : : {
894 : 0 : const String& rEvent = rOption.GetString();
895 [ # # ]: 0 : if( rEvent.Len() )
896 : : InsertBasicDocEvent( aEvent, rEvent, eScriptType2,
897 [ # # ]: 0 : sDfltScriptType );
898 : : }
899 : 4 : }
900 : :
901 [ - + ][ # # ]: 2 : if( bTextColor && !pCSS1Parser->IsBodyTextSet() )
[ - + ]
902 : : {
903 : : // Die Textfarbe wird an der Standard-Vorlage gesetzt
904 [ # # ]: 0 : pCSS1Parser->GetTxtCollFromPool( RES_POOLCOLL_STANDARD )
905 [ # # ][ # # ]: 0 : ->SetFmtAttr( SvxColorItem(aTextColor, RES_CHRATR_COLOR) );
[ # # ]
906 : 0 : pCSS1Parser->SetBodyTextSet();
907 : : }
908 : :
909 : :
910 : : // Die Item fuer die Seitenvorlage vorbereiten (Hintergrund, Umrandung)
911 : : // Beim BrushItem muessen schon gesetzte werte erhalten bleiben!
912 [ + - ][ + - ]: 2 : SvxBrushItem aBrushItem( pCSS1Parser->GetPageDescBackground() );
913 : 2 : sal_Bool bSetBrush = sal_False;
914 : :
915 [ - + ][ # # ]: 2 : if( bBGColor && !pCSS1Parser->IsBodyBGColorSet() )
[ - + ]
916 : : {
917 : : // Hintergrundfarbe aus "BGCOLOR"
918 [ # # ]: 0 : String aLink;
919 [ # # ]: 0 : if( aBrushItem.GetGraphicLink() )
920 [ # # ]: 0 : aLink = *aBrushItem.GetGraphicLink();
921 : 0 : SvxGraphicPosition ePos = aBrushItem.GetGraphicPos();
922 : :
923 : 0 : aBrushItem.SetColor( aBGColor );
924 : :
925 [ # # ]: 0 : if( aLink.Len() )
926 : : {
927 [ # # ]: 0 : aBrushItem.SetGraphicLink( aLink );
928 [ # # ]: 0 : aBrushItem.SetGraphicPos( ePos );
929 : : }
930 : 0 : bSetBrush = sal_True;
931 [ # # ]: 0 : pCSS1Parser->SetBodyBGColorSet();
932 : : }
933 : :
934 [ - + ][ # # ]: 2 : if( aBackGround.Len() && !pCSS1Parser->IsBodyBackgroundSet() )
[ - + ]
935 : : {
936 : : // Hintergrundgrafik aus "BACKGROUND"
937 [ # # ][ # # ]: 0 : aBrushItem.SetGraphicLink( INetURLObject::GetAbsURL( sBaseURL, aBackGround ) );
[ # # ][ # # ]
[ # # ][ # # ]
938 [ # # ]: 0 : aBrushItem.SetGraphicPos( GPOS_TILED );
939 : 0 : bSetBrush = sal_True;
940 : 0 : pCSS1Parser->SetBodyBackgroundSet();
941 : : }
942 : :
943 [ + - ][ + - ]: 2 : if( aStyle.Len() || aDir.Len() )
[ + - ]
944 : : {
945 [ + - ][ + - ]: 2 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
946 [ + - ]: 2 : SvxCSS1PropertyInfo aPropInfo;
947 [ + - ]: 2 : String aDummy;
948 [ + - ]: 2 : ParseStyleOptions( aStyle, aDummy, aDummy, aItemSet, aPropInfo, 0, &aDir );
949 : :
950 : : // Ein par Attribute muessen an der Seitenvorlage gesetzt werden,
951 : : // und zwar die, die nicht vererbit werden
952 : : pCSS1Parser->SetPageDescAttrs( bSetBrush ? &aBrushItem : 0,
953 [ - + ][ + - ]: 2 : &aItemSet );
954 : :
955 : : const SfxPoolItem *pItem;
956 : : static sal_uInt16 aWhichIds[3] = { RES_CHRATR_FONTSIZE,
957 : : RES_CHRATR_CJK_FONTSIZE,
958 : : RES_CHRATR_CTL_FONTSIZE };
959 [ + + ]: 8 : for( sal_uInt16 i=0; i<3; i++ )
960 : : {
961 [ - + # # ]: 6 : if( SFX_ITEM_SET == aItemSet.GetItemState( aWhichIds[i], sal_False,
[ - + ]
962 [ + - ]: 6 : &pItem ) &&
963 : 0 : static_cast <const SvxFontHeightItem * >(pItem)->GetProp() != 100)
964 : : {
965 : : sal_uInt32 nHeight =
966 : 0 : ( aFontHeights[2] *
967 : 0 : static_cast <const SvxFontHeightItem * >(pItem)->GetProp() ) / 100;
968 [ # # ]: 0 : SvxFontHeightItem aNewItem( nHeight, 100, aWhichIds[i] );
969 [ # # ][ # # ]: 0 : aItemSet.Put( aNewItem );
970 : : }
971 : : }
972 : :
973 : : // alle noch uebrigen Optionen koennen an der Standard-Vorlage
974 : : // gesetzt werden und gelten dann automatisch als defaults
975 [ + - ]: 2 : pCSS1Parser->GetTxtCollFromPool( RES_POOLCOLL_STANDARD )
976 [ + - ][ + - ]: 2 : ->SetFmtAttr( aItemSet );
[ + - ][ + - ]
977 : : }
978 [ # # ]: 0 : else if( bSetBrush )
979 : : {
980 [ # # ]: 0 : pCSS1Parser->SetPageDescAttrs( &aBrushItem );
981 : : }
982 : :
983 [ - + ][ # # ]: 2 : if( bLinkColor && !pCSS1Parser->IsBodyLinkSet() )
[ - + ]
984 : : {
985 : : SwCharFmt *pCharFmt =
986 [ # # ]: 0 : pCSS1Parser->GetCharFmtFromPool(RES_POOLCHR_INET_NORMAL);
987 [ # # ][ # # ]: 0 : pCharFmt->SetFmtAttr( SvxColorItem(aLinkColor, RES_CHRATR_COLOR) );
[ # # ]
988 : 0 : pCSS1Parser->SetBodyLinkSet();
989 : : }
990 [ - + ][ # # ]: 2 : if( bVLinkColor && !pCSS1Parser->IsBodyVLinkSet() )
[ - + ]
991 : : {
992 : : SwCharFmt *pCharFmt =
993 [ # # ]: 0 : pCSS1Parser->GetCharFmtFromPool(RES_POOLCHR_INET_VISIT);
994 [ # # ][ # # ]: 0 : pCharFmt->SetFmtAttr( SvxColorItem(aVLinkColor, RES_CHRATR_COLOR) );
[ # # ]
995 : 0 : pCSS1Parser->SetBodyVLinkSet();
996 : : }
997 [ + - ]: 2 : if( aLang.Len() )
998 : : {
999 [ + - ][ + - ]: 2 : LanguageType eLang = MsLangId::convertIsoStringToLanguage( aLang );
1000 [ + - ]: 2 : if( LANGUAGE_DONTKNOW != eLang )
1001 : : {
1002 : 2 : sal_uInt16 nWhich = 0;
1003 [ + - ]: 2 : switch( SvtLanguageOptions::GetScriptTypeOfLanguage( eLang ) )
[ + - - - ]
1004 : : {
1005 : : case SCRIPTTYPE_LATIN:
1006 : 2 : nWhich = RES_CHRATR_LANGUAGE;
1007 : 2 : break;
1008 : : case SCRIPTTYPE_ASIAN:
1009 : 0 : nWhich = RES_CHRATR_CJK_LANGUAGE;
1010 : 0 : break;
1011 : : case SCRIPTTYPE_COMPLEX:
1012 : 0 : nWhich = RES_CHRATR_CTL_LANGUAGE;
1013 : 0 : break;
1014 : : }
1015 [ + - ]: 2 : if( nWhich )
1016 : : {
1017 [ + - ]: 2 : SvxLanguageItem aLanguage( eLang, nWhich );
1018 : 2 : aLanguage.SetWhich( nWhich );
1019 [ + - ][ + - ]: 2 : pDoc->SetDefault( aLanguage );
1020 : : }
1021 : : }
1022 : : }
1023 : :
1024 [ - + ]: 2 : if( aId.Len() )
1025 [ # # ][ + - ]: 2 : InsertBookmark( aId );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1026 : 2 : }
1027 : :
1028 : : /* */
1029 : :
1030 : 0 : void SwHTMLParser::NewAnchor()
1031 : : {
1032 : : // den voherigen Link beenden, falls es einen gab
1033 [ # # ]: 0 : _HTMLAttrContext *pOldCntxt = PopContext( HTML_ANCHOR_ON );
1034 [ # # ]: 0 : if( pOldCntxt )
1035 : : {
1036 : : // und ggf. die Attribute beenden
1037 [ # # ]: 0 : EndContext( pOldCntxt );
1038 [ # # ][ # # ]: 0 : delete pOldCntxt;
1039 : : }
1040 : :
1041 [ # # ]: 0 : SvxMacroTableDtor aMacroTbl;
1042 [ # # ][ # # ]: 0 : String sHRef, aName, sTarget;
[ # # ]
1043 [ # # ][ # # ]: 0 : String aId, aStyle, aClass, aLang, aDir;
[ # # ][ # # ]
[ # # ]
1044 : 0 : sal_Bool bHasHRef = sal_False, bFixed = sal_False;
1045 : :
1046 : : ScriptType eDfltScriptType;
1047 [ # # ]: 0 : String sDfltScriptType;
1048 [ # # ]: 0 : GetDefaultScriptType( eDfltScriptType, sDfltScriptType );
1049 : :
1050 [ # # ]: 0 : const HTMLOptions& rHTMLOptions = GetOptions();
1051 [ # # ]: 0 : for (size_t i = rHTMLOptions.size(); i; )
1052 : : {
1053 : 0 : sal_uInt16 nEvent = 0;
1054 : 0 : ScriptType eScriptType2 = eDfltScriptType;
1055 [ # # ]: 0 : const HTMLOption& rOption = rHTMLOptions[--i];
1056 [ # # # # : 0 : switch( rOption.GetToken() )
# # # # #
# # # # #
# # ]
1057 : : {
1058 : : case HTML_O_NAME:
1059 [ # # ]: 0 : aName = rOption.GetString();
1060 : 0 : break;
1061 : :
1062 : : case HTML_O_HREF:
1063 [ # # ]: 0 : sHRef = rOption.GetString();
1064 : 0 : bHasHRef = sal_True;
1065 : 0 : break;
1066 : : case HTML_O_TARGET:
1067 [ # # ]: 0 : sTarget = rOption.GetString();
1068 : 0 : break;
1069 : :
1070 : : case HTML_O_STYLE:
1071 [ # # ]: 0 : aStyle = rOption.GetString();
1072 : 0 : break;
1073 : : case HTML_O_ID:
1074 [ # # ]: 0 : aId = rOption.GetString();
1075 : 0 : break;
1076 : : case HTML_O_CLASS:
1077 [ # # ]: 0 : aClass = rOption.GetString();
1078 : 0 : break;
1079 : : case HTML_O_SDFIXED:
1080 : 0 : bFixed = sal_True;
1081 : 0 : break;
1082 : : case HTML_O_LANG:
1083 [ # # ]: 0 : aLang = rOption.GetString();
1084 : 0 : break;
1085 : : case HTML_O_DIR:
1086 [ # # ]: 0 : aDir = rOption.GetString();
1087 : 0 : break;
1088 : :
1089 : : case HTML_O_SDONCLICK:
1090 : 0 : eScriptType2 = STARBASIC;
1091 : : case HTML_O_ONCLICK:
1092 : 0 : nEvent = SFX_EVENT_MOUSECLICK_OBJECT;
1093 : 0 : goto ANCHOR_SETEVENT;
1094 : :
1095 : : case HTML_O_SDONMOUSEOVER:
1096 : 0 : eScriptType2 = STARBASIC;
1097 : : case HTML_O_ONMOUSEOVER:
1098 : 0 : nEvent = SFX_EVENT_MOUSEOVER_OBJECT;
1099 : 0 : goto ANCHOR_SETEVENT;
1100 : :
1101 : : case HTML_O_SDONMOUSEOUT:
1102 : 0 : eScriptType2 = STARBASIC;
1103 : : case HTML_O_ONMOUSEOUT:
1104 : 0 : nEvent = SFX_EVENT_MOUSEOUT_OBJECT;
1105 : 0 : goto ANCHOR_SETEVENT;
1106 : : ANCHOR_SETEVENT:
1107 : : {
1108 [ # # ]: 0 : String sTmp( rOption.GetString() );
1109 [ # # ]: 0 : if( sTmp.Len() )
1110 : : {
1111 [ # # ][ # # ]: 0 : sTmp = convertLineEnd(sTmp, GetSystemLineEnd());
[ # # ]
1112 [ # # ]: 0 : String sScriptType;
1113 [ # # ]: 0 : if( EXTENDED_STYPE == eScriptType2 )
1114 [ # # ]: 0 : sScriptType = sDfltScriptType;
1115 [ # # ][ # # ]: 0 : aMacroTbl.Insert( nEvent, SvxMacro( sTmp, sScriptType, eScriptType2 ));
[ # # ][ # # ]
[ # # ][ # # ]
1116 [ # # ]: 0 : }
1117 : : }
1118 : 0 : break;
1119 : :
1120 : : }
1121 : : }
1122 : :
1123 : : // Sprungziele, die unseren ipmliziten Zielen entsprechen, schmeissen
1124 : : // wir hier ganz rigoros raus.
1125 [ # # ]: 0 : if( aName.Len() )
1126 : : {
1127 : : String sDecoded( INetURLObject::decode( aName, INET_HEX_ESCAPE,
1128 : : INetURLObject::DECODE_UNAMBIGUOUS,
1129 [ # # ][ # # ]: 0 : RTL_TEXTENCODING_UTF8 ));
[ # # ]
1130 [ # # ]: 0 : xub_StrLen nPos = sDecoded.SearchBackward( cMarkSeperator );
1131 [ # # ]: 0 : if( STRING_NOTFOUND != nPos )
1132 : : {
1133 [ # # ][ # # ]: 0 : String sCmp(comphelper::string::remove(sDecoded.Copy(nPos+1), ' '));
[ # # ][ # # ]
1134 [ # # ]: 0 : if( sCmp.Len() )
1135 : : {
1136 [ # # ]: 0 : sCmp.ToLowerAscii();
1137 [ # # ][ # # ]: 0 : if( sCmp.EqualsAscii( pMarkToRegion ) ||
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1138 [ # # ]: 0 : sCmp.EqualsAscii( pMarkToFrame ) ||
1139 [ # # ]: 0 : sCmp.EqualsAscii( pMarkToGraphic ) ||
1140 [ # # ]: 0 : sCmp.EqualsAscii( pMarkToOLE ) ||
1141 [ # # ]: 0 : sCmp.EqualsAscii( pMarkToTable ) ||
1142 [ # # ]: 0 : sCmp.EqualsAscii( pMarkToOutline ) ||
1143 [ # # ]: 0 : sCmp.EqualsAscii( pMarkToText ) )
1144 : : {
1145 [ # # ]: 0 : aName.Erase();
1146 : : }
1147 [ # # ]: 0 : }
1148 [ # # ]: 0 : }
1149 : : }
1150 : :
1151 : : // einen neuen Kontext anlegen
1152 [ # # ][ # # ]: 0 : _HTMLAttrContext *pCntxt = new _HTMLAttrContext( HTML_ANCHOR_ON );
1153 : :
1154 : 0 : sal_Bool bEnAnchor = sal_False, bFtnAnchor = sal_False, bFtnEnSymbol = sal_False;
1155 [ # # ]: 0 : String aFtnName;
1156 [ # # ]: 0 : String aStrippedClass( aClass );
1157 [ # # ]: 0 : SwCSS1Parser::GetScriptFromClass( aStrippedClass, sal_False );
1158 [ # # ][ # # ]: 0 : if( aStrippedClass.Len() >=9 && bHasHRef && sHRef.Len() > 1 &&
[ # # # #
# # # # #
# ][ # # ]
1159 : 0 : ('s' == aStrippedClass.GetChar(0) || 'S' == aStrippedClass.GetChar(0)) &&
1160 : 0 : ('d' == aStrippedClass.GetChar(1) || 'D' == aStrippedClass.GetChar(1)) )
1161 : : {
1162 [ # # ][ # # ]: 0 : if( aStrippedClass.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_sdendnote_anc ) )
1163 : 0 : bEnAnchor = sal_True;
1164 [ # # ][ # # ]: 0 : else if( aStrippedClass.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_sdfootnote_anc ) )
1165 : 0 : bFtnAnchor = sal_True;
1166 [ # # ][ # # ]: 0 : else if( aStrippedClass.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_sdendnote_sym ) ||
[ # # ][ # # ]
1167 [ # # ]: 0 : aStrippedClass.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_sdfootnote_sym ) )
1168 : 0 : bFtnEnSymbol = sal_True;
1169 [ # # ][ # # ]: 0 : if( bEnAnchor || bFtnAnchor || bFtnEnSymbol )
[ # # ]
1170 : : {
1171 [ # # ][ # # ]: 0 : aFtnName = sHRef.Copy( 1 );
[ # # ]
1172 [ # # ][ # # ]: 0 : aClass = aStrippedClass = aName = aEmptyStr;
[ # # ]
1173 : 0 : bHasHRef = sal_False;
1174 : : }
1175 : : }
1176 : :
1177 : : // Styles parsen
1178 [ # # ]: 0 : if( HasStyleOptions( aStyle, aId, aStrippedClass, &aLang, &aDir ) )
1179 : : {
1180 [ # # ][ # # ]: 0 : SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
1181 [ # # ]: 0 : SvxCSS1PropertyInfo aPropInfo;
1182 : :
1183 [ # # ][ # # ]: 0 : if( ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo, &aLang, &aDir ) )
1184 : : {
1185 [ # # ]: 0 : DoPositioning( aItemSet, aPropInfo, pCntxt );
1186 [ # # ]: 0 : InsertAttrs( aItemSet, aPropInfo, pCntxt, sal_True );
1187 [ # # ][ # # ]: 0 : }
1188 : : }
1189 : :
1190 [ # # ]: 0 : if( bHasHRef )
1191 : : {
1192 [ # # ]: 0 : if( sHRef.Len() )
1193 : : {
1194 [ # # ][ # # ]: 0 : sHRef = URIHelper::SmartRel2Abs( INetURLObject(sBaseURL), sHRef, Link(), false );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1195 : : }
1196 : : else
1197 : : {
1198 : : // Bei leerer URL das Directory nehmen
1199 [ # # ][ # # ]: 0 : INetURLObject aURLObj( aPathToFile );
1200 [ # # ][ # # ]: 0 : sHRef = aURLObj.GetPartBeforeLastName();
[ # # ]
1201 : : }
1202 : :
1203 [ # # ]: 0 : pCSS1Parser->SetATagStyles();
1204 [ # # ]: 0 : SwFmtINetFmt aINetFmt( sHRef, sTarget );
1205 [ # # ]: 0 : aINetFmt.SetName( aName );
1206 : :
1207 [ # # ]: 0 : if( !aMacroTbl.empty() )
1208 [ # # ]: 0 : aINetFmt.SetMacroTbl( &aMacroTbl );
1209 : :
1210 : : // das Default-Attribut setzen
1211 [ # # ][ # # ]: 0 : InsertAttr( &aAttrTab.pINetFmt, aINetFmt, pCntxt );
1212 : : }
1213 [ # # ]: 0 : else if( aName.Len() )
1214 : : {
1215 [ # # ]: 0 : InsertBookmark( aName );
1216 : : }
1217 : :
1218 [ # # ][ # # ]: 0 : if( bEnAnchor || bFtnAnchor )
1219 : : {
1220 [ # # ]: 0 : InsertFootEndNote( aFtnName, bEnAnchor, bFixed );
1221 : 0 : bInFootEndNoteAnchor = bCallNextToken = sal_True;
1222 : : }
1223 [ # # ]: 0 : else if( bFtnEnSymbol )
1224 : : {
1225 : 0 : bInFootEndNoteSymbol = bCallNextToken = sal_True;
1226 : : }
1227 : :
1228 : : // den Kontext merken
1229 [ # # ][ # # ]: 0 : PushContext( pCntxt );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1230 : 0 : }
1231 : :
1232 : 0 : void SwHTMLParser::EndAnchor()
1233 : : {
1234 [ # # ]: 0 : if( bInFootEndNoteAnchor )
1235 : : {
1236 : 0 : FinishFootEndNote();
1237 : 0 : bInFootEndNoteAnchor = sal_False;
1238 : : }
1239 [ # # ]: 0 : else if( bInFootEndNoteSymbol )
1240 : : {
1241 : 0 : bInFootEndNoteSymbol = sal_False;
1242 : : }
1243 : :
1244 : 0 : EndTag( HTML_ANCHOR_OFF );
1245 : 0 : }
1246 : :
1247 : : /* */
1248 : :
1249 : 0 : void SwHTMLParser::InsertBookmark( const String& rName )
1250 : : {
1251 : 0 : _HTMLAttr* pTmp = new _HTMLAttr( *pPam->GetPoint(),
1252 [ # # ][ # # ]: 0 : SfxStringItem( RES_FLTR_BOOKMARK, rName ));
[ # # ][ # # ]
1253 [ # # ]: 0 : aSetAttrTab.push_back( pTmp );
1254 : 0 : }
1255 : :
1256 : 2 : sal_Bool SwHTMLParser::HasCurrentParaBookmarks( sal_Bool bIgnoreStack ) const
1257 : : {
1258 : 2 : sal_Bool bHasMarks = sal_False;
1259 : 2 : sal_uLong nNodeIdx = pPam->GetPoint()->nNode.GetIndex();
1260 : :
1261 : : // first step: are there still bookmark in the attribute-stack?
1262 : : // bookmarks are added to the end of the stack - thus we only have
1263 : : // to check the last bookmark
1264 [ - + ]: 2 : if( !bIgnoreStack )
1265 : : {
1266 : : _HTMLAttr* pAttr;
1267 [ # # ]: 0 : for( sal_uInt16 i = aSetAttrTab.size(); i; )
1268 : : {
1269 : 0 : pAttr = aSetAttrTab[ --i ];
1270 [ # # ]: 0 : if( RES_FLTR_BOOKMARK == pAttr->pItem->Which() )
1271 : : {
1272 [ # # ]: 0 : if( pAttr->GetSttParaIdx() == nNodeIdx )
1273 : 0 : bHasMarks = sal_True;
1274 : 0 : break;
1275 : : }
1276 : : }
1277 : : }
1278 : :
1279 [ + - ]: 2 : if( !bHasMarks )
1280 : : {
1281 : : // second step: when we didnt find a bookmark, check if there is one
1282 : : // set already
1283 : 2 : IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
1284 [ # # ][ + - ]: 4 : for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin();
[ - + ][ + - ]
1285 [ + - ]: 2 : ppMark != pMarkAccess->getMarksEnd();
1286 : : ppMark++)
1287 : : {
1288 : 0 : const ::sw::mark::IMark* pBookmark = ppMark->get();
1289 [ # # ]: 0 : sal_uLong nBookNdIdx = pBookmark->GetMarkPos().nNode.GetIndex();
1290 [ # # ]: 0 : if( nBookNdIdx==nNodeIdx )
1291 : : {
1292 : 0 : bHasMarks = sal_True;
1293 : 0 : break;
1294 : : }
1295 [ # # ]: 0 : else if( nBookNdIdx > nNodeIdx )
1296 : 0 : break;
1297 : : }
1298 : : }
1299 : :
1300 : 2 : return bHasMarks;
1301 : : }
1302 : :
1303 : : /* */
1304 : :
1305 : 0 : void SwHTMLParser::StripTrailingPara()
1306 : : {
1307 : 0 : sal_Bool bSetSmallFont = sal_False;
1308 : :
1309 : 0 : SwCntntNode* pCNd = pPam->GetCntntNode();
1310 [ # # ]: 0 : if( !pPam->GetPoint()->nContent.GetIndex() )
1311 : : {
1312 [ # # ][ # # ]: 0 : if( pCNd && pCNd->StartOfSectionIndex()+2 <
[ # # ]
1313 : 0 : pCNd->EndOfSectionIndex() )
1314 : : {
1315 : 0 : sal_uLong nNodeIdx = pPam->GetPoint()->nNode.GetIndex();
1316 : :
1317 : 0 : const SwFrmFmts& rFrmFmtTbl = *pDoc->GetSpzFrmFmts();
1318 : :
1319 [ # # ]: 0 : for( sal_uInt16 i=0; i<rFrmFmtTbl.size(); i++ )
1320 : : {
1321 : 0 : SwFrmFmt const*const pFmt = rFrmFmtTbl[i];
1322 : 0 : SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor();
1323 : 0 : SwPosition const*const pAPos = pAnchor->GetCntntAnchor();
1324 [ # # ][ # # : 0 : if (pAPos &&
# # # # #
# ]
1325 : 0 : ((FLY_AT_PARA == pAnchor->GetAnchorId()) ||
1326 : 0 : (FLY_AT_CHAR == pAnchor->GetAnchorId())) &&
1327 : 0 : pAPos->nNode == nNodeIdx )
1328 : :
1329 : 0 : return; // den Knoten duerfen wir nicht loeschen
1330 : : }
1331 : :
1332 : 0 : SetAttr( sal_False ); // die noch offenen Attribute muessen
1333 : : // beendet werden, bevor der Node
1334 : : // geloescht wird, weil sonst der
1335 : : // End-Index in die Botanik zeigt
1336 : :
1337 [ # # ][ # # ]: 0 : if( pCNd->Len() && pCNd->IsTxtNode() )
[ # # ]
1338 : : {
1339 : : // es wurden Felder in den Node eingefuegt, die muessen
1340 : : // wir jetzt verschieben
1341 : 0 : SwTxtNode *pPrvNd = pDoc->GetNodes()[nNodeIdx-1]->GetTxtNode();
1342 [ # # ]: 0 : if( pPrvNd )
1343 : : {
1344 [ # # ][ # # ]: 0 : SwIndex aSrc( pCNd, 0 );
1345 [ # # ][ # # ]: 0 : pCNd->GetTxtNode()->CutText( pPrvNd, aSrc, pCNd->Len() );
[ # # ]
1346 : : }
1347 : : }
1348 : :
1349 : : // jetz muessen wir noch eventuell vorhandene Bookmarks
1350 : : // verschieben
1351 : 0 : IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
1352 [ # # ][ # # ]: 0 : for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin();
[ # # ][ # # ]
1353 [ # # ]: 0 : ppMark != pMarkAccess->getMarksEnd();
1354 : : ppMark++)
1355 : : {
1356 : 0 : ::sw::mark::IMark* pMark = ppMark->get();
1357 [ # # ]: 0 : sal_uLong nBookNdIdx = pMark->GetMarkPos().nNode.GetIndex();
1358 [ # # ]: 0 : if(nBookNdIdx==nNodeIdx)
1359 : : {
1360 [ # # ]: 0 : SwNodeIndex nNewNdIdx(pPam->GetPoint()->nNode);
1361 [ # # ][ # # ]: 0 : SwCntntNode* pNd = pDoc->GetNodes().GoPrevious(&nNewNdIdx);
1362 [ # # ]: 0 : if(!pNd)
1363 : : {
1364 : : OSL_ENSURE(!this, "Hoppla, wo ist mein Vorgaenger-Node");
1365 : : return;
1366 : : }
1367 : : // #i81002# - refactoring
1368 : : // Do not directly manipulate member of <SwBookmark>
1369 : : {
1370 [ # # ]: 0 : SwPosition aNewPos(*pNd);
1371 [ # # ][ # # ]: 0 : aNewPos.nContent.Assign(pNd, pNd->Len());
[ # # ]
1372 [ # # ]: 0 : const SwPaM aPaM(aNewPos);
1373 [ # # ][ # # ]: 0 : pMarkAccess->repositionMark(ppMark->get(), aPaM);
[ # # ]
1374 [ # # ][ # # ]: 0 : }
1375 : : }
1376 [ # # ]: 0 : else if( nBookNdIdx > nNodeIdx )
1377 : 0 : break;
1378 : : }
1379 : :
1380 : 0 : pPam->GetPoint()->nContent.Assign( 0, 0 );
1381 : 0 : pPam->SetMark();
1382 : 0 : pPam->DeleteMark();
1383 : 0 : pDoc->GetNodes().Delete( pPam->GetPoint()->nNode );
1384 : 0 : pPam->Move( fnMoveBackward, fnGoNode );
1385 : : }
1386 [ # # ][ # # ]: 0 : else if( pCNd && pCNd->IsTxtNode() && pTable )
[ # # ][ # # ]
1387 : : {
1388 : : // In leeren Zellen stellen wir einen kleinen Font ein, damit die
1389 : : // Zelle nicht hoeher wird als die Grafik bzw. so niedrig wie
1390 : : // moeglich bleibt.
1391 : 0 : bSetSmallFont = sal_True;
1392 : : }
1393 : : }
1394 [ # # ][ # # ]: 0 : else if( pCNd && pCNd->IsTxtNode() && pTable &&
[ # # # # ]
[ # # ]
1395 : 0 : pCNd->StartOfSectionIndex()+2 ==
1396 : 0 : pCNd->EndOfSectionIndex() )
1397 : : {
1398 : : // Wenn die Zelle nur zeichengebundene Grafiken/Rahmen enthaelt
1399 : : // stellen wir ebenfalls einen kleinen Font ein.
1400 : 0 : bSetSmallFont = sal_True;
1401 : 0 : SwTxtNode* pTxtNd = pCNd->GetTxtNode();
1402 : :
1403 : 0 : xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex();
1404 [ # # ][ # # ]: 0 : while( bSetSmallFont && nPos>0 )
[ # # ]
1405 : : {
1406 : 0 : --nPos;
1407 : : bSetSmallFont =
1408 : 0 : (CH_TXTATR_BREAKWORD == pTxtNd->GetTxt().GetChar( nPos )) &&
1409 [ # # ][ # # ]: 0 : (0 != pTxtNd->GetTxtAttrForCharAt( nPos, RES_TXTATR_FLYCNT ));
1410 : : }
1411 : : }
1412 : :
1413 [ # # ]: 0 : if( bSetSmallFont )
1414 : : {
1415 : : //Added default to CJK and CTL
1416 [ # # ]: 0 : SvxFontHeightItem aFontHeight( 40, 100, RES_CHRATR_FONTSIZE );
1417 [ # # ]: 0 : pCNd->SetAttr( aFontHeight );
1418 [ # # ]: 0 : SvxFontHeightItem aFontHeightCJK( 40, 100, RES_CHRATR_CJK_FONTSIZE );
1419 [ # # ]: 0 : pCNd->SetAttr( aFontHeightCJK );
1420 [ # # ]: 0 : SvxFontHeightItem aFontHeightCTL( 40, 100, RES_CHRATR_CTL_FONTSIZE );
1421 [ # # ][ # # ]: 0 : pCNd->SetAttr( aFontHeightCTL );
[ # # ][ # # ]
1422 : : }
1423 : : }
1424 : :
1425 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|