Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "hintids.hxx"
21 : #include <vcl/svapp.hxx>
22 : #include <vcl/wrkwin.hxx>
23 : #include <svx/svdmodel.hxx>
24 : #include <svx/svdpage.hxx>
25 : #include <svx/svdobj.hxx>
26 : #include <svx/svdotext.hxx>
27 : #include <editeng/eeitem.hxx>
28 : #include <editeng/outliner.hxx>
29 : #include <svx/xfillit.hxx>
30 : #include <editeng/colritem.hxx>
31 : #include <editeng/brushitem.hxx>
32 : #include <editeng/lrspitem.hxx>
33 : #include <editeng/ulspitem.hxx>
34 : #include <svl/itemiter.hxx>
35 : #include <svl/whiter.hxx>
36 : #include <svtools/htmlout.hxx>
37 : #include <svtools/htmltokn.h>
38 : #include <svtools/htmlkywd.hxx>
39 : #include <svx/svdpool.hxx>
40 :
41 : #include "charatr.hxx"
42 : #include "drawdoc.hxx"
43 : #include <frmfmt.hxx>
44 : #include <fmtanchr.hxx>
45 : #include <fmtsrnd.hxx>
46 : #include "ndtxt.hxx"
47 : #include "doc.hxx"
48 : #include <IDocumentDrawModelAccess.hxx>
49 : #include "dcontact.hxx"
50 : #include "poolfmt.hxx"
51 : #include "swcss1.hxx"
52 : #include "swhtml.hxx"
53 : #include <shellio.hxx>
54 : #include <rtl/strbuf.hxx>
55 :
56 : using namespace css;
57 :
58 : static HTMLOptionEnum aHTMLMarqBehaviorTable[] =
59 : {
60 : { OOO_STRING_SVTOOLS_HTML_BEHAV_scroll, SDRTEXTANI_SCROLL },
61 : { OOO_STRING_SVTOOLS_HTML_BEHAV_alternate, SDRTEXTANI_ALTERNATE },
62 : { OOO_STRING_SVTOOLS_HTML_BEHAV_slide, SDRTEXTANI_SLIDE },
63 : { 0, 0 }
64 : };
65 :
66 : static HTMLOptionEnum aHTMLMarqDirectionTable[] =
67 : {
68 : { OOO_STRING_SVTOOLS_HTML_AL_left, SDRTEXTANI_LEFT },
69 : { OOO_STRING_SVTOOLS_HTML_AL_right, SDRTEXTANI_RIGHT },
70 : { 0, 0 }
71 : };
72 :
73 0 : void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj,
74 : const Size& rPixSpace,
75 : sal_Int16 eVertOri,
76 : sal_Int16 eHoriOri,
77 : SfxItemSet& rCSS1ItemSet,
78 : SvxCSS1PropertyInfo& rCSS1PropInfo,
79 : bool bHidden )
80 : {
81 : // always on top of text.
82 : // but in invisible layer. <ConnectToLayout> will move the object
83 : // to the visible layer.
84 0 : pNewDrawObj->SetLayer( pDoc->getIDocumentDrawModelAccess().GetInvisibleHeavenId() );
85 :
86 0 : SfxItemSet aFrmSet( pDoc->GetAttrPool(),
87 0 : RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
88 0 : if( !IsNewDoc() )
89 0 : Reader::ResetFrameFormatAttrs( aFrmSet );
90 :
91 0 : sal_uInt16 nLeftSpace = 0, nRightSpace = 0, nUpperSpace = 0, nLowerSpace = 0;
92 0 : if( (rPixSpace.Width() || rPixSpace.Height()) && Application::GetDefaultDevice() )
93 : {
94 0 : Size aTwipSpc( rPixSpace.Width(), rPixSpace.Height() );
95 : aTwipSpc =
96 : Application::GetDefaultDevice()->PixelToLogic( aTwipSpc,
97 0 : MapMode(MAP_TWIP) );
98 0 : nLeftSpace = nRightSpace = (sal_uInt16)aTwipSpc.Width();
99 0 : nUpperSpace = nLowerSpace = (sal_uInt16)aTwipSpc.Height();
100 : }
101 :
102 : // linken/rechten Rand setzen
103 : const SfxPoolItem *pItem;
104 0 : if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, true, &pItem ) )
105 : {
106 : // Ggf. den Erstzeilen-Einzug noch plaetten
107 0 : const SvxLRSpaceItem *pLRItem = static_cast<const SvxLRSpaceItem *>(pItem);
108 0 : SvxLRSpaceItem aLRItem( *pLRItem );
109 0 : aLRItem.SetTextFirstLineOfst( 0 );
110 0 : if( rCSS1PropInfo.bLeftMargin )
111 : {
112 0 : nLeftSpace = static_cast< sal_uInt16 >(aLRItem.GetLeft());
113 0 : rCSS1PropInfo.bLeftMargin = false;
114 : }
115 0 : if( rCSS1PropInfo.bRightMargin )
116 : {
117 0 : nRightSpace = static_cast< sal_uInt16 >(aLRItem.GetRight());
118 0 : rCSS1PropInfo.bRightMargin = false;
119 : }
120 0 : rCSS1ItemSet.ClearItem( RES_LR_SPACE );
121 : }
122 0 : if( nLeftSpace || nRightSpace )
123 : {
124 0 : SvxLRSpaceItem aLRItem( RES_LR_SPACE );
125 0 : aLRItem.SetLeft( nLeftSpace );
126 0 : aLRItem.SetRight( nRightSpace );
127 0 : aFrmSet.Put( aLRItem );
128 : }
129 :
130 : // oberen/unteren Rand setzen
131 0 : if( SfxItemState::SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, true, &pItem ) )
132 : {
133 : // Ggf. den Erstzeilen-Einzug noch plaetten
134 0 : const SvxULSpaceItem *pULItem = static_cast<const SvxULSpaceItem *>(pItem);
135 0 : if( rCSS1PropInfo.bTopMargin )
136 : {
137 0 : nUpperSpace = pULItem->GetUpper();
138 0 : rCSS1PropInfo.bTopMargin = false;
139 : }
140 0 : if( rCSS1PropInfo.bBottomMargin )
141 : {
142 0 : nLowerSpace = pULItem->GetLower();
143 0 : rCSS1PropInfo.bBottomMargin = false;
144 : }
145 :
146 0 : rCSS1ItemSet.ClearItem( RES_UL_SPACE );
147 : }
148 0 : if( nUpperSpace || nLowerSpace )
149 : {
150 0 : SvxULSpaceItem aULItem( RES_UL_SPACE );
151 0 : aULItem.SetUpper( nUpperSpace );
152 0 : aULItem.SetLower( nLowerSpace );
153 0 : aFrmSet.Put( aULItem );
154 : }
155 :
156 0 : SwFormatAnchor aAnchor( FLY_AS_CHAR );
157 0 : if( SVX_CSS1_POS_ABSOLUTE == rCSS1PropInfo.ePosition &&
158 0 : SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eLeftType &&
159 0 : SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eTopType )
160 : {
161 : const SwStartNode *pFlySttNd =
162 0 : pPam->GetPoint()->nNode.GetNode().FindFlyStartNode();
163 :
164 0 : if( pFlySttNd )
165 : {
166 0 : aAnchor.SetType( FLY_AT_FLY );
167 0 : SwPosition aPos( *pFlySttNd );
168 0 : aAnchor.SetAnchor( &aPos );
169 : }
170 : else
171 : {
172 0 : aAnchor.SetType( FLY_AT_PAGE );
173 : }
174 : // #i26791# - direct positioning for <SwDoc::Insert(..)>
175 : pNewDrawObj->SetRelativePos( Point(rCSS1PropInfo.nLeft + nLeftSpace,
176 0 : rCSS1PropInfo.nTop + nUpperSpace) );
177 0 : aFrmSet.Put( SwFormatSurround(SURROUND_THROUGHT) );
178 : }
179 0 : else if( SVX_ADJUST_LEFT == rCSS1PropInfo.eFloat ||
180 : text::HoriOrientation::LEFT == eHoriOri )
181 : {
182 0 : aAnchor.SetType( FLY_AT_PARA );
183 : aFrmSet.Put( SwFormatSurround(bHidden ? SURROUND_THROUGHT
184 0 : : SURROUND_RIGHT) );
185 : // #i26791# - direct positioning for <SwDoc::Insert(..)>
186 0 : pNewDrawObj->SetRelativePos( Point(nLeftSpace, nUpperSpace) );
187 : }
188 0 : else if( text::VertOrientation::NONE != eVertOri )
189 : {
190 0 : aFrmSet.Put( SwFormatVertOrient( 0, eVertOri ) );
191 : }
192 :
193 0 : if (FLY_AT_PAGE == aAnchor.GetAnchorId())
194 : {
195 0 : aAnchor.SetPageNum( 1 );
196 : }
197 0 : else if( FLY_AT_FLY != aAnchor.GetAnchorId() )
198 : {
199 0 : aAnchor.SetAnchor( pPam->GetPoint() );
200 : }
201 0 : aFrmSet.Put( aAnchor );
202 :
203 0 : pDoc->getIDocumentContentOperations().InsertDrawObj( *pPam, *pNewDrawObj, aFrmSet );
204 0 : }
205 :
206 0 : static void PutEEPoolItem( SfxItemSet &rEEItemSet,
207 : const SfxPoolItem& rSwItem )
208 : {
209 :
210 0 : sal_uInt16 nEEWhich = 0;
211 :
212 0 : switch( rSwItem.Which() )
213 : {
214 0 : case RES_CHRATR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
215 0 : case RES_CHRATR_CROSSEDOUT: nEEWhich = EE_CHAR_STRIKEOUT; break;
216 0 : case RES_CHRATR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break;
217 0 : case RES_CHRATR_FONT: nEEWhich = EE_CHAR_FONTINFO; break;
218 0 : case RES_CHRATR_CJK_FONT: nEEWhich = EE_CHAR_FONTINFO_CJK; break;
219 0 : case RES_CHRATR_CTL_FONT: nEEWhich = EE_CHAR_FONTINFO_CTL; break;
220 0 : case RES_CHRATR_FONTSIZE: nEEWhich = EE_CHAR_FONTHEIGHT; break;
221 0 : case RES_CHRATR_CJK_FONTSIZE: nEEWhich = EE_CHAR_FONTHEIGHT_CJK; break;
222 0 : case RES_CHRATR_CTL_FONTSIZE: nEEWhich = EE_CHAR_FONTHEIGHT_CTL; break;
223 0 : case RES_CHRATR_KERNING: nEEWhich = EE_CHAR_KERNING; break;
224 0 : case RES_CHRATR_POSTURE: nEEWhich = EE_CHAR_ITALIC; break;
225 0 : case RES_CHRATR_CJK_POSTURE: nEEWhich = EE_CHAR_ITALIC_CJK; break;
226 0 : case RES_CHRATR_CTL_POSTURE: nEEWhich = EE_CHAR_ITALIC_CTL; break;
227 0 : case RES_CHRATR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE; break;
228 0 : case RES_CHRATR_WEIGHT: nEEWhich = EE_CHAR_WEIGHT; break;
229 0 : case RES_CHRATR_CJK_WEIGHT: nEEWhich = EE_CHAR_WEIGHT_CJK; break;
230 0 : case RES_CHRATR_CTL_WEIGHT: nEEWhich = EE_CHAR_WEIGHT_CTL; break;
231 : case RES_BACKGROUND:
232 : case RES_CHRATR_BACKGROUND:
233 : {
234 0 : const SvxBrushItem& rBrushItem = static_cast<const SvxBrushItem&>(rSwItem);
235 0 : rEEItemSet.Put( XFillStyleItem(drawing::FillStyle_SOLID) );
236 : rEEItemSet.Put( XFillColorItem(aEmptyOUStr,
237 0 : rBrushItem.GetColor()) );
238 : }
239 0 : break;
240 : }
241 :
242 0 : if( nEEWhich )
243 : {
244 0 : SfxPoolItem *pEEItem = rSwItem.Clone();
245 0 : pEEItem->SetWhich( nEEWhich );
246 0 : rEEItemSet.Put( *pEEItem );
247 0 : delete pEEItem;
248 : }
249 0 : }
250 :
251 0 : void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
252 : {
253 :
254 : OSL_ENSURE( !pMarquee, "Marquee in Marquee???" );
255 0 : aContents.clear();
256 :
257 0 : OUString aId, aStyle, aClass;
258 :
259 0 : long nWidth=0, nHeight=0;
260 0 : bool bPrcWidth = false, bDirection = false, bBGColor = false;
261 0 : Size aSpace( 0, 0 );
262 0 : sal_Int16 eVertOri = text::VertOrientation::TOP;
263 0 : sal_Int16 eHoriOri = text::HoriOrientation::NONE;
264 0 : SdrTextAniKind eAniKind = SDRTEXTANI_SCROLL;
265 0 : SdrTextAniDirection eAniDir = SDRTEXTANI_LEFT;
266 0 : sal_uInt16 nCount = 0, nDelay = 60;
267 0 : sal_Int16 nAmount = -6;
268 0 : Color aBGColor;
269 :
270 0 : const HTMLOptions& rHTMLOptions = GetOptions();
271 0 : for (size_t i = 0, n = rHTMLOptions.size(); i < n; ++i)
272 : {
273 0 : const HTMLOption& rOption = rHTMLOptions[i];
274 0 : switch( rOption.GetToken() )
275 : {
276 : case HTML_O_ID:
277 0 : aId = rOption.GetString();
278 0 : break;
279 : case HTML_O_STYLE:
280 0 : aStyle = rOption.GetString();
281 0 : break;
282 : case HTML_O_CLASS:
283 0 : aClass = rOption.GetString();
284 0 : break;
285 :
286 : case HTML_O_BEHAVIOR:
287 : eAniKind =
288 : (SdrTextAniKind)rOption.GetEnum( aHTMLMarqBehaviorTable,
289 0 : static_cast< sal_uInt16 >(eAniKind) );
290 0 : break;
291 :
292 : case HTML_O_BGCOLOR:
293 0 : rOption.GetColor( aBGColor );
294 0 : bBGColor = true;
295 0 : break;
296 :
297 : case HTML_O_DIRECTION:
298 : eAniDir =
299 : (SdrTextAniDirection)rOption.GetEnum( aHTMLMarqDirectionTable,
300 0 : static_cast< sal_uInt16 >(eAniDir) );
301 0 : bDirection = true;
302 0 : break;
303 :
304 : case HTML_O_LOOP:
305 0 : if (rOption.GetString().
306 : equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_LOOP_infinite))
307 : {
308 0 : nCount = 0;
309 : }
310 : else
311 : {
312 0 : const sal_Int32 nLoop = rOption.GetSNumber();
313 0 : nCount = static_cast<sal_uInt16>(nLoop>0 ? nLoop : 0);
314 : }
315 0 : break;
316 :
317 : case HTML_O_SCROLLAMOUNT:
318 0 : nAmount = -((sal_Int16)rOption.GetNumber());
319 0 : break;
320 :
321 : case HTML_O_SCROLLDELAY:
322 0 : nDelay = (sal_uInt16)rOption.GetNumber();
323 0 : break;
324 :
325 : case HTML_O_WIDTH:
326 : // erstmal nur als Pixelwerte merken!
327 0 : nWidth = rOption.GetNumber();
328 0 : bPrcWidth = rOption.GetString().indexOf('%') != -1;
329 0 : if( bPrcWidth && nWidth>100 )
330 0 : nWidth = 100;
331 0 : break;
332 :
333 : case HTML_O_HEIGHT:
334 : // erstmal nur als Pixelwerte merken!
335 0 : nHeight = rOption.GetNumber();
336 0 : if( rOption.GetString().indexOf('%') != -1 )
337 0 : nHeight = 0;
338 0 : break;
339 :
340 : case HTML_O_HSPACE:
341 : // erstmal nur als Pixelwerte merken!
342 0 : aSpace.Height() = rOption.GetNumber();
343 0 : break;
344 :
345 : case HTML_O_VSPACE:
346 : // erstmal nur als Pixelwerte merken!
347 0 : aSpace.Width() = rOption.GetNumber();
348 0 : break;
349 :
350 : case HTML_O_ALIGN:
351 : eVertOri =
352 : rOption.GetEnum( aHTMLImgVAlignTable,
353 0 : text::VertOrientation::TOP );
354 : eHoriOri =
355 : rOption.GetEnum( aHTMLImgHAlignTable,
356 0 : text::HoriOrientation::NONE );
357 0 : break;
358 : }
359 : }
360 :
361 : // Ein DrawTextobj anlegen
362 : // #i52858# - method name changed
363 0 : SwDrawModel* pModel = pDoc->getIDocumentDrawModelAccess().GetOrCreateDrawModel();
364 0 : SdrPage* pPg = pModel->GetPage( 0 );
365 : pMarquee = SdrObjFactory::MakeNewObject( SdrInventor,
366 0 : OBJ_TEXT, pPg, pModel );
367 0 : if( !pMarquee )
368 0 : return;
369 :
370 0 : pPg->InsertObject( pMarquee );
371 :
372 0 : if( !aId.isEmpty() )
373 0 : InsertBookmark( aId );
374 :
375 : // (Nur) Alternate leueft per Default von links nach rechts
376 0 : if( SDRTEXTANI_ALTERNATE==eAniKind && !bDirection )
377 0 : eAniDir = SDRTEXTANI_RIGHT;
378 :
379 : // die fuer das Scrollen benoetigten Attribute umsetzen
380 : sal_uInt16 aWhichMap[7] = { XATTR_FILL_FIRST, XATTR_FILL_LAST,
381 : SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
382 : EE_CHAR_START, EE_CHAR_END,
383 0 : 0 };
384 0 : SfxItemSet aItemSet( pModel->GetItemPool(), aWhichMap );
385 0 : aItemSet.Put( makeSdrTextAutoGrowWidthItem( false ) );
386 0 : aItemSet.Put( makeSdrTextAutoGrowHeightItem( true ) );
387 0 : aItemSet.Put( SdrTextAniKindItem( eAniKind ) );
388 0 : aItemSet.Put( SdrTextAniDirectionItem( eAniDir ) );
389 0 : aItemSet.Put( SdrTextAniCountItem( nCount ) );
390 0 : aItemSet.Put( SdrTextAniDelayItem( nDelay ) );
391 0 : aItemSet.Put( SdrTextAniAmountItem( nAmount ) );
392 0 : if( SDRTEXTANI_ALTERNATE==eAniKind )
393 : {
394 : // (Nur) Alternate startet und stoppt per default Inside
395 0 : aItemSet.Put( SdrTextAniStartInsideItem(true) );
396 0 : aItemSet.Put( SdrTextAniStopInsideItem(true) );
397 0 : if( SDRTEXTANI_LEFT==eAniDir )
398 0 : aItemSet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT) );
399 : }
400 :
401 : // die Default-Farbe (aus der Standard-Vorlage) setzen, damit ueberhaupt
402 : // eine sinnvolle Farbe gesetzt ist.
403 : const Color& rDfltColor =
404 0 : pCSS1Parser->GetTextCollFromPool( RES_POOLCOLL_STANDARD )
405 0 : ->GetColor().GetValue();
406 0 : aItemSet.Put( SvxColorItem( rDfltColor, EE_CHAR_COLOR ) );
407 :
408 : // Die Attribute der aktuellen Absatzvorlage setzen
409 : sal_uInt16 nWhichIds[] =
410 : {
411 : RES_CHRATR_COLOR, RES_CHRATR_CROSSEDOUT, RES_CHRATR_ESCAPEMENT,
412 : RES_CHRATR_FONT, RES_CHRATR_FONTSIZE, RES_CHRATR_KERNING,
413 : RES_CHRATR_POSTURE, RES_CHRATR_UNDERLINE, RES_CHRATR_WEIGHT,
414 : RES_CHRATR_BACKGROUND,
415 : RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONTSIZE,
416 : RES_CHRATR_CJK_POSTURE, RES_CHRATR_CJK_WEIGHT,
417 : RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONTSIZE,
418 : RES_CHRATR_CTL_POSTURE, RES_CHRATR_CTL_WEIGHT,
419 : 0
420 0 : };
421 : SwTextNode const*const pTextNd =
422 0 : pPam->GetPoint()->nNode.GetNode().GetTextNode();
423 0 : if( pTextNd )
424 : {
425 0 : const SfxItemSet& rItemSet = pTextNd->GetAnyFormatColl().GetAttrSet();
426 : const SfxPoolItem *pItem;
427 0 : for( int i=0; nWhichIds[i]; ++i )
428 : {
429 0 : if( SfxItemState::SET == rItemSet.GetItemState( nWhichIds[i], true, &pItem ) )
430 0 : PutEEPoolItem( aItemSet, *pItem );
431 : }
432 : }
433 :
434 : // die Attribute der Umgebung am Draw-Objekt setzen
435 0 : _HTMLAttr** pHTMLAttributes = reinterpret_cast<_HTMLAttr**>(&aAttrTab);
436 0 : for (auto nCnt = sizeof(_HTMLAttrTable) / sizeof(_HTMLAttr*); nCnt--; ++pHTMLAttributes)
437 : {
438 0 : _HTMLAttr *pAttr = *pHTMLAttributes;
439 0 : if( pAttr )
440 0 : PutEEPoolItem( aItemSet, pAttr->GetItem() );
441 : }
442 :
443 0 : if( bBGColor )
444 : {
445 0 : aItemSet.Put( XFillStyleItem(drawing::FillStyle_SOLID) );
446 0 : aItemSet.Put( XFillColorItem(aEmptyOUStr, aBGColor) );
447 : }
448 :
449 : // Styles parsen (funktioniert hier nur fuer Attribute, die auch
450 : // am Zeichen-Objekt gesetzt werden koennen)
451 0 : SfxItemSet aStyleItemSet( pDoc->GetAttrPool(),
452 0 : pCSS1Parser->GetWhichMap() );
453 0 : SvxCSS1PropertyInfo aPropInfo;
454 0 : if( HasStyleOptions( aStyle, aId, aClass ) &&
455 0 : ParseStyleOptions( aStyle, aId, aClass, aStyleItemSet, aPropInfo ) )
456 : {
457 0 : SfxItemIter aIter( aStyleItemSet );
458 :
459 0 : const SfxPoolItem *pItem = aIter.FirstItem();
460 0 : while( pItem )
461 : {
462 0 : PutEEPoolItem( aItemSet, *pItem );
463 0 : pItem = aIter.NextItem();
464 0 : }
465 : }
466 :
467 : // jetzt noch die Groesse setzen
468 0 : Size aTwipSz( bPrcWidth ? 0 : nWidth, nHeight );
469 0 : if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
470 : {
471 : aTwipSz = Application::GetDefaultDevice()
472 0 : ->PixelToLogic( aTwipSz, MapMode( MAP_TWIP ) );
473 : }
474 :
475 0 : if( SVX_CSS1_LTYPE_TWIP== aPropInfo.eWidthType )
476 : {
477 0 : aTwipSz.Width() = aPropInfo.nWidth;
478 0 : nWidth = 1; // != 0;
479 0 : bPrcWidth = false;
480 : }
481 0 : if( SVX_CSS1_LTYPE_TWIP== aPropInfo.eHeightType )
482 0 : aTwipSz.Height() = aPropInfo.nHeight;
483 :
484 0 : bFixMarqueeWidth = false;
485 0 : if( !nWidth || bPrcWidth )
486 : {
487 0 : if( pTable )
488 : {
489 0 : if( !pCurTable )
490 : {
491 : // Die Laufschrift steht in einer Tabelle, aber nicht
492 : // in einer Zelle. Da jetzt keine vernuenftige Zuordung
493 : // zu einer Zelle moeglich ist, passen wir hir die
494 : // Breite dem Inhalt der Laufschrift an.
495 0 : bFixMarqueeWidth = true;
496 : }
497 0 : else if( !nWidth )
498 : {
499 : // Da wir wissen, in welcher Zelle die Laufschrift ist,
500 : // koennen wir die Breite auch anpassen. Keine Breitenangabe
501 : // wird wie 100% behandelt.
502 0 : nWidth = 100;
503 0 : bPrcWidth = true;
504 : }
505 0 : aTwipSz.Width() = MINLAY;
506 : }
507 : else
508 : {
509 0 : long nBrowseWidth = GetCurrentBrowseWidth();
510 0 : aTwipSz.Width() = !nWidth ? nBrowseWidth
511 0 : : (nWidth*nBrowseWidth) / 100;
512 : }
513 : }
514 :
515 : // Die Hoehe ist nur eine Mindest-Hoehe
516 0 : if( aTwipSz.Height() < MINFLY )
517 0 : aTwipSz.Height() = MINFLY;
518 0 : aItemSet.Put( makeSdrTextMinFrameHeightItem( aTwipSz.Height() ) );
519 :
520 0 : pMarquee->SetMergedItemSetAndBroadcast(aItemSet);
521 :
522 0 : if( aTwipSz.Width() < MINFLY )
523 0 : aTwipSz.Width() = MINFLY;
524 0 : pMarquee->SetLogicRect( Rectangle( 0, 0, aTwipSz.Width(), aTwipSz.Height() ) );
525 :
526 : // und das Objekt in das Dok einfuegen
527 : InsertDrawObject( pMarquee, aSpace, eVertOri, eHoriOri, aStyleItemSet,
528 0 : aPropInfo );
529 :
530 : // Das Zeichen-Objekt der Tabelle bekanntmachen. Ist ein bisserl
531 : // umstaendlich, weil noch ueber den Parser gegangen wird, obwohl die
532 : // Tabelle bekannt ist, aber anderenfalls muesste man die Tabelle
533 : // oeffentlich machen, und das ist auch nicht schoen. Das globale
534 : // pTable kann uebrigens auch nicht verwendet werden, denn die
535 : // Laufschrift kann sich auch mal in einer Sub-Tabelle befinden.
536 0 : if( pCurTable && bPrcWidth)
537 0 : RegisterDrawObjectToTable( pCurTable, pMarquee, (sal_uInt8)nWidth );
538 : }
539 :
540 0 : void SwHTMLParser::EndMarquee()
541 : {
542 : OSL_ENSURE( pMarquee && OBJ_TEXT==pMarquee->GetObjIdentifier(),
543 : "kein Marquee oder falscher Typ" );
544 :
545 0 : if( bFixMarqueeWidth )
546 : {
547 : // Da es keine fixe Hoehe gibt, das Text-Objekt erstmal breiter
548 : // als den Text machen, damit nicht umgebrochen wird.
549 0 : const Rectangle& rOldRect = pMarquee->GetLogicRect();
550 : pMarquee->SetLogicRect( Rectangle( rOldRect.TopLeft(),
551 0 : Size( USHRT_MAX, 240 ) ) );
552 : }
553 :
554 : // den gesammelten Text einfuegen
555 0 : static_cast<SdrTextObj*>(pMarquee)->SetText( aContents );
556 0 : pMarquee->SetMergedItemSetAndBroadcast( pMarquee->GetMergedItemSet() );
557 :
558 0 : if( bFixMarqueeWidth )
559 : {
560 : // die Groesse dem Text anpassen.
561 0 : static_cast<SdrTextObj*>(pMarquee)->FitFrameToTextSize();
562 : }
563 :
564 0 : aContents.clear();
565 0 : pMarquee = 0;
566 0 : }
567 :
568 0 : void SwHTMLParser::InsertMarqueeText()
569 : {
570 : OSL_ENSURE( pMarquee && OBJ_TEXT==pMarquee->GetObjIdentifier(),
571 : "kein Marquee oder falscher Typ" );
572 :
573 : // das akteulle Textstueck an den Text anhaengen
574 0 : aContents += aToken;
575 0 : }
576 :
577 0 : void SwHTMLParser::ResizeDrawObject( SdrObject* pObj, SwTwips nWidth )
578 : {
579 : OSL_ENSURE( OBJ_TEXT==pObj->GetObjIdentifier(),
580 : "kein Marquee oder falscher Typ" );
581 :
582 0 : if( OBJ_TEXT!=pObj->GetObjIdentifier() )
583 0 : return;
584 :
585 : // die alte Groesse
586 0 : const Rectangle& rOldRect = pObj->GetLogicRect();
587 0 : Size aNewSz( nWidth, rOldRect.GetSize().Height() );
588 0 : pObj->SetLogicRect( Rectangle( rOldRect.TopLeft(), aNewSz ) );
589 177 : }
590 :
591 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|