Update ooo320-m1
[ooovba.git] / sw / source / filter / html / htmldraw.cxx
blobe31acbabc0e573ed23583b468663bf0bdd75496f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: htmldraw.cxx,v $
10 * $Revision: 1.20 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include "hintids.hxx"
36 #include <vcl/svapp.hxx>
37 #ifndef _WRKWIN_HXX //autogen
38 #include <vcl/wrkwin.hxx>
39 #endif
40 #include <svx/svdmodel.hxx>
41 #include <svx/svdpage.hxx>
42 #include <svx/svdobj.hxx>
43 #include <svx/svdotext.hxx>
44 #include <svx/eeitem.hxx>
46 #ifndef _OUTLINER_HXX //autogen
47 #define _EEITEMID_HXX
48 #include <svx/outliner.hxx>
49 #endif
50 #include <svx/xfillit.hxx>
51 #include <svx/colritem.hxx>
52 #include <svx/brshitem.hxx>
53 #include <svx/lrspitem.hxx>
54 #include <svx/ulspitem.hxx>
55 #include <svtools/itemiter.hxx>
56 #include <svtools/whiter.hxx>
57 #include <svtools/htmlout.hxx>
58 #include <svtools/htmltokn.h>
59 #include <svtools/htmlkywd.hxx>
60 #include <svx/svdpool.hxx>
63 #include "charatr.hxx"
64 #include <frmfmt.hxx>
65 #include <fmtanchr.hxx>
66 #include <fmtsrnd.hxx>
67 #include "ndtxt.hxx"
68 #include "doc.hxx"
69 #include "dcontact.hxx"
70 #include "poolfmt.hxx"
71 #include "swcss1.hxx"
72 #include "swhtml.hxx"
73 #include "wrthtml.hxx"
75 using namespace ::com::sun::star;
78 const sal_uInt32 HTML_FRMOPTS_MARQUEE =
79 HTML_FRMOPT_ALIGN |
80 HTML_FRMOPT_SPACE;
82 const sal_uInt32 HTML_FRMOPTS_MARQUEE_CSS1 =
83 HTML_FRMOPT_S_ALIGN |
84 HTML_FRMOPT_S_SPACE;
86 static HTMLOptionEnum __FAR_DATA aHTMLMarqBehaviorTable[] =
88 { OOO_STRING_SVTOOLS_HTML_BEHAV_scroll, SDRTEXTANI_SCROLL },
89 { OOO_STRING_SVTOOLS_HTML_BEHAV_alternate, SDRTEXTANI_ALTERNATE },
90 { OOO_STRING_SVTOOLS_HTML_BEHAV_slide, SDRTEXTANI_SLIDE },
91 { 0, 0 }
94 static HTMLOptionEnum __FAR_DATA aHTMLMarqDirectionTable[] =
96 { OOO_STRING_SVTOOLS_HTML_AL_left, SDRTEXTANI_LEFT },
97 { OOO_STRING_SVTOOLS_HTML_AL_right, SDRTEXTANI_RIGHT },
98 { 0, 0 }
101 /* \f */
102 void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj,
103 const Size& rPixSpace,
104 sal_Int16 eVertOri,
105 sal_Int16 eHoriOri,
106 SfxItemSet& rCSS1ItemSet,
107 SvxCSS1PropertyInfo& rCSS1PropInfo,
108 sal_Bool bHidden )
110 // always on top of text.
111 // OD 02.07.2003 #108784# but in invisible layer. <ConnectToLayout> will
112 // move the object to the visible layer.
113 pNewDrawObj->SetLayer( pDoc->GetInvisibleHeavenId() );
115 SfxItemSet aFrmSet( pDoc->GetAttrPool(),
116 RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
117 if( !IsNewDoc() )
118 Reader::ResetFrmFmtAttrs( aFrmSet );
120 sal_uInt16 nLeftSpace = 0, nRightSpace = 0, nUpperSpace = 0, nLowerSpace = 0;
121 if( (rPixSpace.Width() || rPixSpace.Height()) && Application::GetDefaultDevice() )
123 Size aTwipSpc( rPixSpace.Width(), rPixSpace.Height() );
124 aTwipSpc =
125 Application::GetDefaultDevice()->PixelToLogic( aTwipSpc,
126 MapMode(MAP_TWIP) );
127 nLeftSpace = nRightSpace = (sal_uInt16)aTwipSpc.Width();
128 nUpperSpace = nLowerSpace = (sal_uInt16)aTwipSpc.Height();
131 // linken/rechten Rand setzen
132 const SfxPoolItem *pItem;
133 if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, sal_True, &pItem ) )
135 // Ggf. den Erstzeilen-Einzug noch plaetten
136 const SvxLRSpaceItem *pLRItem = (const SvxLRSpaceItem *)pItem;
137 SvxLRSpaceItem aLRItem( *pLRItem );
138 aLRItem.SetTxtFirstLineOfst( 0 );
139 if( rCSS1PropInfo.bLeftMargin )
141 nLeftSpace = static_cast< sal_uInt16 >(aLRItem.GetLeft());
142 rCSS1PropInfo.bLeftMargin = sal_False;
144 if( rCSS1PropInfo.bRightMargin )
146 nRightSpace = static_cast< sal_uInt16 >(aLRItem.GetRight());
147 rCSS1PropInfo.bRightMargin = sal_False;
149 rCSS1ItemSet.ClearItem( RES_LR_SPACE );
151 if( nLeftSpace || nRightSpace )
153 SvxLRSpaceItem aLRItem( RES_LR_SPACE );
154 aLRItem.SetLeft( nLeftSpace );
155 aLRItem.SetRight( nRightSpace );
156 aFrmSet.Put( aLRItem );
159 // oberen/unteren Rand setzen
160 if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, sal_True, &pItem ) )
162 // Ggf. den Erstzeilen-Einzug noch plaetten
163 const SvxULSpaceItem *pULItem = (const SvxULSpaceItem *)pItem;
164 if( rCSS1PropInfo.bTopMargin )
166 nUpperSpace = pULItem->GetUpper();
167 rCSS1PropInfo.bTopMargin = sal_False;
169 if( rCSS1PropInfo.bBottomMargin )
171 nLowerSpace = pULItem->GetLower();
172 rCSS1PropInfo.bBottomMargin = sal_False;
175 rCSS1ItemSet.ClearItem( RES_UL_SPACE );
177 if( nUpperSpace || nLowerSpace )
179 SvxULSpaceItem aULItem( RES_UL_SPACE );
180 aULItem.SetUpper( nUpperSpace );
181 aULItem.SetLower( nLowerSpace );
182 aFrmSet.Put( aULItem );
185 SwFmtAnchor aAnchor( FLY_IN_CNTNT );
186 if( SVX_CSS1_POS_ABSOLUTE == rCSS1PropInfo.ePosition &&
187 SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eLeftType &&
188 SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eTopType )
190 const SwStartNode *pFlySttNd =
191 pDoc->GetNodes()[pPam->GetPoint()->nNode]->FindFlyStartNode();
193 if( pFlySttNd )
195 aAnchor.SetType( FLY_AT_FLY );
196 SwPosition aPos( *pFlySttNd );
197 aAnchor.SetAnchor( &aPos );
199 else
201 aAnchor.SetType( FLY_PAGE );
203 // OD 2004-04-13 #i26791# - direct positioning for <SwDoc::Insert(..)>
204 pNewDrawObj->SetRelativePos( Point(rCSS1PropInfo.nLeft + nLeftSpace,
205 rCSS1PropInfo.nTop + nUpperSpace) );
206 aFrmSet.Put( SwFmtSurround(SURROUND_THROUGHT) );
208 else if( SVX_ADJUST_LEFT == rCSS1PropInfo.eFloat ||
209 text::HoriOrientation::LEFT == eHoriOri )
211 aAnchor.SetType( FLY_AT_CNTNT );
212 aFrmSet.Put( SwFmtSurround(bHidden ? SURROUND_THROUGHT
213 : SURROUND_RIGHT) );
214 // OD 2004-04-13 #i26791# - direct positioning for <SwDoc::Insert(..)>
215 pNewDrawObj->SetRelativePos( Point(nLeftSpace, nUpperSpace) );
217 else if( text::VertOrientation::NONE != eVertOri )
219 aFrmSet.Put( SwFmtVertOrient( 0, eVertOri ) );
222 if( FLY_PAGE == aAnchor.GetAnchorId() )
223 aAnchor.SetPageNum( 1 );
224 else if( FLY_AT_FLY != aAnchor.GetAnchorId() )
225 aAnchor.SetAnchor( pPam->GetPoint() );
226 aFrmSet.Put( aAnchor );
228 pDoc->Insert( *pPam, *pNewDrawObj, &aFrmSet, NULL );
231 /* \f */
233 static void PutEEPoolItem( SfxItemSet &rEEItemSet,
234 const SfxPoolItem& rSwItem )
237 sal_uInt16 nEEWhich = 0;
239 switch( rSwItem.Which() )
241 case RES_CHRATR_COLOR: nEEWhich = EE_CHAR_COLOR; break;
242 case RES_CHRATR_CROSSEDOUT: nEEWhich = EE_CHAR_STRIKEOUT; break;
243 case RES_CHRATR_ESCAPEMENT: nEEWhich = EE_CHAR_ESCAPEMENT; break;
244 case RES_CHRATR_FONT: nEEWhich = EE_CHAR_FONTINFO; break;
245 case RES_CHRATR_CJK_FONT: nEEWhich = EE_CHAR_FONTINFO_CJK; break;
246 case RES_CHRATR_CTL_FONT: nEEWhich = EE_CHAR_FONTINFO_CTL; break;
247 case RES_CHRATR_FONTSIZE: nEEWhich = EE_CHAR_FONTHEIGHT; break;
248 case RES_CHRATR_CJK_FONTSIZE: nEEWhich = EE_CHAR_FONTHEIGHT_CJK; break;
249 case RES_CHRATR_CTL_FONTSIZE: nEEWhich = EE_CHAR_FONTHEIGHT_CTL; break;
250 case RES_CHRATR_KERNING: nEEWhich = EE_CHAR_KERNING; break;
251 case RES_CHRATR_POSTURE: nEEWhich = EE_CHAR_ITALIC; break;
252 case RES_CHRATR_CJK_POSTURE: nEEWhich = EE_CHAR_ITALIC_CJK; break;
253 case RES_CHRATR_CTL_POSTURE: nEEWhich = EE_CHAR_ITALIC_CTL; break;
254 case RES_CHRATR_UNDERLINE: nEEWhich = EE_CHAR_UNDERLINE; break;
255 case RES_CHRATR_WEIGHT: nEEWhich = EE_CHAR_WEIGHT; break;
256 case RES_CHRATR_CJK_WEIGHT: nEEWhich = EE_CHAR_WEIGHT_CJK; break;
257 case RES_CHRATR_CTL_WEIGHT: nEEWhich = EE_CHAR_WEIGHT_CTL; break;
258 case RES_BACKGROUND:
259 case RES_CHRATR_BACKGROUND:
261 const SvxBrushItem& rBrushItem = (const SvxBrushItem&)rSwItem;
262 rEEItemSet.Put( XFillStyleItem(XFILL_SOLID) );
263 rEEItemSet.Put( XFillColorItem(aEmptyStr,
264 rBrushItem.GetColor()) );
266 break;
269 if( nEEWhich )
271 SfxPoolItem *pEEItem = rSwItem.Clone();
272 pEEItem->SetWhich( nEEWhich );
273 rEEItemSet.Put( *pEEItem );
274 delete pEEItem;
278 void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
281 ASSERT( !pMarquee, "Marquee in Marquee???" );
282 aContents.Erase();
284 String aId, aStyle, aClass;
286 long nWidth=0, nHeight=0;
287 sal_Bool bPrcWidth = sal_False, bDirection = sal_False, bBGColor = sal_False;
288 Size aSpace( 0, 0 );
289 sal_Int16 eVertOri = text::VertOrientation::TOP;
290 sal_Int16 eHoriOri = text::HoriOrientation::NONE;
291 SdrTextAniKind eAniKind = SDRTEXTANI_SCROLL;
292 SdrTextAniDirection eAniDir = SDRTEXTANI_LEFT;
293 sal_uInt16 nCount = 0, nDelay = 60;
294 sal_Int16 nAmount = -6;
295 Color aBGColor;
297 const HTMLOptions *pHTMLOptions = GetOptions();
298 sal_uInt16 nArrLen = pHTMLOptions->Count();
299 for ( sal_uInt16 i=0; i<nArrLen; i++ )
301 const HTMLOption *pOption = (*pHTMLOptions)[i];
302 switch( pOption->GetToken() )
304 case HTML_O_ID:
305 aId = pOption->GetString();
306 break;
307 case HTML_O_STYLE:
308 aStyle = pOption->GetString();
309 break;
310 case HTML_O_CLASS:
311 aClass = pOption->GetString();
312 break;
314 case HTML_O_BEHAVIOR:
315 eAniKind =
316 (SdrTextAniKind)pOption->GetEnum( aHTMLMarqBehaviorTable,
317 static_cast< sal_uInt16 >(eAniKind) );
318 break;
320 case HTML_O_BGCOLOR:
321 pOption->GetColor( aBGColor );
322 bBGColor = sal_True;
323 break;
325 case HTML_O_DIRECTION:
326 eAniDir =
327 (SdrTextAniDirection)pOption->GetEnum( aHTMLMarqDirectionTable,
328 static_cast< sal_uInt16 >(eAniDir) );
329 bDirection = sal_True;
330 break;
332 case HTML_O_LOOP:
333 if( pOption->GetString().
334 EqualsIgnoreCaseAscii(OOO_STRING_SVTOOLS_HTML_LOOP_infinite) )
336 nCount = 0;
338 else
340 sal_uInt32 nLoop = pOption->GetSNumber();
341 nCount = (sal_uInt16)(nLoop>0 ? nLoop : 0 );
343 break;
345 case HTML_O_SCROLLAMOUNT:
346 nAmount = -((sal_Int16)pOption->GetNumber());
347 break;
349 case HTML_O_SCROLLDELAY:
350 nDelay = (sal_uInt16)pOption->GetNumber();
351 break;
353 case HTML_O_WIDTH:
354 // erstmal nur als Pixelwerte merken!
355 nWidth = pOption->GetNumber();
356 bPrcWidth = pOption->GetString().Search('%') != STRING_NOTFOUND;
357 if( bPrcWidth && nWidth>100 )
358 nWidth = 100;
359 break;
361 case HTML_O_HEIGHT:
362 // erstmal nur als Pixelwerte merken!
363 nHeight = pOption->GetNumber();
364 if( pOption->GetString().Search('%') != STRING_NOTFOUND )
365 nHeight = 0;
366 break;
368 case HTML_O_HSPACE:
369 // erstmal nur als Pixelwerte merken!
370 aSpace.Height() = pOption->GetNumber();
371 break;
373 case HTML_O_VSPACE:
374 // erstmal nur als Pixelwerte merken!
375 aSpace.Width() = pOption->GetNumber();
376 break;
378 case HTML_O_ALIGN:
379 eVertOri =
380 pOption->GetEnum( aHTMLImgVAlignTable,
381 text::VertOrientation::TOP );
382 eHoriOri =
383 pOption->GetEnum( aHTMLImgHAlignTable,
384 text::HoriOrientation::NONE );
385 break;
389 // Ein DrawTxtobj anlegen
390 // --> OD 2005-08-08 #i52858# - method name changed
391 SdrModel* pModel = pDoc->GetOrCreateDrawModel();
392 // <--
393 SdrPage* pPg = pModel->GetPage( 0 );
394 pMarquee = SdrObjFactory::MakeNewObject( SdrInventor,
395 OBJ_TEXT, pPg, pModel );
396 if( !pMarquee )
397 return;
399 pPg->InsertObject( pMarquee );
401 if( aId.Len() )
402 InsertBookmark( aId );
404 // (Nur) Alternate leueft per Default von links nach rechts
405 if( SDRTEXTANI_ALTERNATE==eAniKind && !bDirection )
406 eAniDir = SDRTEXTANI_RIGHT;
408 // die fuer das Scrollen benoetigten Attribute umsetzen
409 sal_uInt16 aWhichMap[7] = { XATTR_FILL_FIRST, XATTR_FILL_LAST,
410 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
411 EE_CHAR_START, EE_CHAR_END,
412 0 };
413 SfxItemSet aItemSet( pModel->GetItemPool(), aWhichMap );
414 aItemSet.Put( SdrTextAutoGrowWidthItem( sal_False ) );
415 aItemSet.Put( SdrTextAutoGrowHeightItem( sal_True ) );
416 aItemSet.Put( SdrTextAniKindItem( eAniKind ) );
417 aItemSet.Put( SdrTextAniDirectionItem( eAniDir ) );
418 aItemSet.Put( SdrTextAniCountItem( nCount ) );
419 aItemSet.Put( SdrTextAniDelayItem( nDelay ) );
420 aItemSet.Put( SdrTextAniAmountItem( nAmount ) );
421 if( SDRTEXTANI_ALTERNATE==eAniKind )
423 // (Nur) Alternate startet und stoppt per default Inside
424 aItemSet.Put( SdrTextAniStartInsideItem(sal_True) );
425 aItemSet.Put( SdrTextAniStopInsideItem(sal_True) );
426 if( SDRTEXTANI_LEFT==eAniDir )
427 aItemSet.Put( SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT) );
430 // die Default-Farbe (aus der Standard-Vorlage) setzen, damit ueberhaupt
431 // eine sinnvolle Farbe gesetzt ist.
432 const Color& rDfltColor =
433 pCSS1Parser->GetTxtCollFromPool( RES_POOLCOLL_STANDARD )
434 ->GetColor().GetValue();
435 aItemSet.Put( SvxColorItem( rDfltColor, EE_CHAR_COLOR ) );
437 // Die Attribute der aktuellen Absatzvorlage setzen
438 sal_uInt16 nWhichIds[] =
440 RES_CHRATR_COLOR, RES_CHRATR_CROSSEDOUT, RES_CHRATR_ESCAPEMENT,
441 RES_CHRATR_FONT, RES_CHRATR_FONTSIZE, RES_CHRATR_KERNING,
442 RES_CHRATR_POSTURE, RES_CHRATR_UNDERLINE, RES_CHRATR_WEIGHT,
443 RES_CHRATR_BACKGROUND,
444 RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONTSIZE,
445 RES_CHRATR_CJK_POSTURE, RES_CHRATR_CJK_WEIGHT,
446 RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONTSIZE,
447 RES_CHRATR_CTL_POSTURE, RES_CHRATR_CTL_WEIGHT,
450 const SwTxtNode *pTxtNd = pDoc->GetNodes()[pPam->GetPoint()->nNode]
451 ->GetTxtNode();
452 if( pTxtNd )
454 const SfxItemSet& rItemSet = pTxtNd->GetAnyFmtColl().GetAttrSet();
455 const SfxPoolItem *pItem;
456 for( sal_uInt16 i=0; nWhichIds[i]; i++ )
458 if( SFX_ITEM_SET == rItemSet.GetItemState( nWhichIds[i], sal_True, &pItem ) )
459 PutEEPoolItem( aItemSet, *pItem );
463 // die Attribute der Umgebung am Draw-Objekt setzen
464 _HTMLAttr** pTbl = (_HTMLAttr**)&aAttrTab;
465 for( sal_uInt16 nCnt = sizeof( _HTMLAttrTable ) / sizeof( _HTMLAttr* );
466 nCnt--; ++pTbl )
468 _HTMLAttr *pAttr = *pTbl;
469 if( pAttr )
470 PutEEPoolItem( aItemSet, pAttr->GetItem() );
473 if( bBGColor )
475 aItemSet.Put( XFillStyleItem(XFILL_SOLID) );
476 aItemSet.Put( XFillColorItem(aEmptyStr, aBGColor) );
479 // Styles parsen (funktioniert hier nur fuer Attribute, die auch
480 // am Zeichen-Objekt gesetzt werden koennen)
481 SfxItemSet aStyleItemSet( pDoc->GetAttrPool(),
482 pCSS1Parser->GetWhichMap() );
483 SvxCSS1PropertyInfo aPropInfo;
484 if( HasStyleOptions( aStyle, aId, aClass ) &&
485 ParseStyleOptions( aStyle, aId, aClass, aStyleItemSet, aPropInfo ) )
487 SfxItemIter aIter( aStyleItemSet );
489 const SfxPoolItem *pItem = aIter.FirstItem();
490 while( pItem )
492 PutEEPoolItem( aItemSet, *pItem );
493 pItem = aIter.NextItem();
497 // jetzt noch die Groesse setzen
498 Size aTwipSz( bPrcWidth ? 0 : nWidth, nHeight );
499 if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
501 aTwipSz = Application::GetDefaultDevice()
502 ->PixelToLogic( aTwipSz, MapMode( MAP_TWIP ) );
505 if( SVX_CSS1_LTYPE_TWIP== aPropInfo.eWidthType )
507 aTwipSz.Width() = aPropInfo.nWidth;
508 nWidth = 1; // != 0;
509 bPrcWidth = sal_False;
511 if( SVX_CSS1_LTYPE_TWIP== aPropInfo.eHeightType )
512 aTwipSz.Height() = aPropInfo.nHeight;
514 bFixMarqueeWidth = sal_False;
515 if( !nWidth || bPrcWidth )
517 if( pTable )
519 if( !pCurTable )
521 // Die Laufschrift steht in einer Tabelle, aber nicht
522 // in einer Zelle. Da jetzt keine vernuenftige Zuordung
523 // zu einer Zelle moeglich ist, passen wir hir die
524 // Breite dem Inhalt der Laufschrift an.
525 bFixMarqueeWidth = sal_True;
527 else if( !nWidth )
529 // Da wir wissen, in welcher Zelle die Laufschrift ist,
530 // koennen wir die Breite auch anpassen. Keine Breitenangabe
531 // wird wie 100% behandelt.
532 nWidth = 100;
533 bPrcWidth = sal_True;
535 aTwipSz.Width() = MINLAY;
537 else
539 long nBrowseWidth = GetCurrentBrowseWidth();
540 aTwipSz.Width() = !nWidth ? nBrowseWidth
541 : (nWidth*nBrowseWidth) / 100;
545 // Die Hoehe ist nur eine Mindest-Hoehe
546 if( aTwipSz.Height() < MINFLY )
547 aTwipSz.Height() = MINFLY;
548 aItemSet.Put( SdrTextMinFrameHeightItem( aTwipSz.Height() ) );
550 pMarquee->SetMergedItemSetAndBroadcast(aItemSet);
552 if( aTwipSz.Width() < MINFLY )
553 aTwipSz.Width() = MINFLY;
554 pMarquee->SetLogicRect( Rectangle( 0, 0, aTwipSz.Width(), aTwipSz.Height() ) );
556 // und das Objekt in das Dok einfuegen
557 InsertDrawObject( pMarquee, aSpace, eVertOri, eHoriOri, aStyleItemSet,
558 aPropInfo );
560 // Das Zeichen-Objekt der Tabelle bekanntmachen. Ist ein bisserl
561 // umstaendlich, weil noch ueber den Parser gegangen wird, obwohl die
562 // Tabelle bekannt ist, aber anderenfalls muesste man die Tabelle
563 // oeffentlich machen, und das ist auch nicht schoen. Das globale
564 // pTable kann uebrigens auch nicht verwendet werden, denn die
565 // Laufschrift kann sich auch mal in einer Sub-Tabelle befinden.
566 if( pCurTable && bPrcWidth)
567 RegisterDrawObjectToTable( pCurTable, pMarquee, (sal_uInt8)nWidth );
570 void SwHTMLParser::EndMarquee()
572 ASSERT( pMarquee && OBJ_TEXT==pMarquee->GetObjIdentifier(),
573 "kein Marquee oder falscher Typ" );
575 if( bFixMarqueeWidth )
577 // Da es keine fixe Hoehe gibt, das Text-Objekt erstmal breiter
578 // als den Text machen, damit nicht umgebrochen wird.
579 const Rectangle& rOldRect = pMarquee->GetLogicRect();
580 pMarquee->SetLogicRect( Rectangle( rOldRect.TopLeft(),
581 Size( USHRT_MAX, 240 ) ) );
584 // den gesammelten Text einfuegen
585 ((SdrTextObj*)pMarquee)->SetText( aContents );
586 pMarquee->SetMergedItemSetAndBroadcast( pMarquee->GetMergedItemSet() );
588 if( bFixMarqueeWidth )
590 // die Groesse dem Text anpassen.
591 ((SdrTextObj*)pMarquee)->FitFrameToTextSize();
594 aContents.Erase();
595 pMarquee = 0;
598 void SwHTMLParser::InsertMarqueeText()
600 ASSERT( pMarquee && OBJ_TEXT==pMarquee->GetObjIdentifier(),
601 "kein Marquee oder falscher Typ" );
603 // das akteulle Textstueck an den Text anhaengen
604 aContents += aToken;
607 void SwHTMLParser::ResizeDrawObject( SdrObject* pObj, SwTwips nWidth )
609 ASSERT( OBJ_TEXT==pObj->GetObjIdentifier(),
610 "kein Marquee oder falscher Typ" );
612 if( OBJ_TEXT!=pObj->GetObjIdentifier() )
613 return;
615 // die alte Groesse
616 const Rectangle& rOldRect = pObj->GetLogicRect();
617 Size aNewSz( nWidth, rOldRect.GetSize().Height() );
618 pObj->SetLogicRect( Rectangle( rOldRect.TopLeft(), aNewSz ) );
621 /* \f */
623 const SdrObject *SwHTMLWriter::GetMarqueeTextObj( const SwDrawFrmFmt& rFmt )
625 const SdrObject* pObj = rFmt.FindSdrObject();
626 return (pObj && ::IsMarqueeTextObj( *pObj )) ? pObj : 0;
629 void SwHTMLWriter::GetEEAttrsFromDrwObj( SfxItemSet& rItemSet,
630 const SdrObject *pObj,
631 sal_Bool bSetDefaults )
633 // die Edit script::Engine-Attribute aus dem Objekt holen
634 SfxItemSet rObjItemSet = pObj->GetMergedItemSet();
636 // ueber die Edit script::Engine-Attribute iterieren und die Attribute
637 // in SW-Attrs wandeln bzw. default setzen
638 SfxWhichIter aIter( rObjItemSet );
639 sal_uInt16 nEEWhich = aIter.FirstWhich();
640 while( nEEWhich )
642 const SfxPoolItem *pEEItem;
643 sal_Bool bSet = SFX_ITEM_SET == rObjItemSet.GetItemState( nEEWhich, sal_False,
644 &pEEItem );
646 if( bSet || bSetDefaults )
648 sal_uInt16 nSwWhich = 0;
649 switch( nEEWhich )
651 case EE_CHAR_COLOR: nSwWhich = RES_CHRATR_COLOR; break;
652 case EE_CHAR_STRIKEOUT: nSwWhich = RES_CHRATR_CROSSEDOUT; break;
653 case EE_CHAR_ESCAPEMENT: nSwWhich = RES_CHRATR_ESCAPEMENT; break;
654 case EE_CHAR_FONTINFO: nSwWhich = RES_CHRATR_FONT; break;
655 case EE_CHAR_FONTINFO_CJK: nSwWhich = RES_CHRATR_CJK_FONT; break;
656 case EE_CHAR_FONTINFO_CTL: nSwWhich = RES_CHRATR_CTL_FONT; break;
657 case EE_CHAR_FONTHEIGHT: nSwWhich = RES_CHRATR_FONTSIZE; break;
658 case EE_CHAR_FONTHEIGHT_CJK:nSwWhich = RES_CHRATR_CJK_FONTSIZE; break;
659 case EE_CHAR_FONTHEIGHT_CTL:nSwWhich = RES_CHRATR_CTL_FONTSIZE; break;
660 case EE_CHAR_KERNING: nSwWhich = RES_CHRATR_KERNING; break;
661 case EE_CHAR_ITALIC: nSwWhich = RES_CHRATR_POSTURE; break;
662 case EE_CHAR_ITALIC_CJK: nSwWhich = RES_CHRATR_CJK_POSTURE; break;
663 case EE_CHAR_ITALIC_CTL: nSwWhich = RES_CHRATR_CTL_POSTURE; break;
664 case EE_CHAR_UNDERLINE: nSwWhich = RES_CHRATR_UNDERLINE; break;
665 case EE_CHAR_WEIGHT: nSwWhich = RES_CHRATR_WEIGHT; break;
666 case EE_CHAR_WEIGHT_CJK: nSwWhich = RES_CHRATR_CJK_WEIGHT; break;
667 case EE_CHAR_WEIGHT_CTL: nSwWhich = RES_CHRATR_CTL_WEIGHT; break;
670 if( nSwWhich )
672 // wenn das Item nicht gesetzt ist nehmen wir ggf. das
673 // Default-Item
674 if( !bSet )
675 pEEItem = &rObjItemSet.GetPool()->GetDefaultItem(nEEWhich);
677 // jetzt Clonen wir das Item mit der Which-Id des Writers
678 SfxPoolItem *pSwItem = pEEItem->Clone();
679 pSwItem->SetWhich( nSwWhich );
680 rItemSet.Put( *pSwItem );
681 delete pSwItem;
685 nEEWhich = aIter.NextWhich();
690 Writer& OutHTML_DrawFrmFmtAsMarquee( Writer& rWrt,
691 const SwDrawFrmFmt& rFmt,
692 const SdrObject& rSdrObject )
694 SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
696 ASSERT( rWrt.pDoc->GetDrawModel(), "Da gibt's ein Draw-Obj ohne ein Draw-Model zu haben?" );
697 const SdrTextObj *pTextObj = (const SdrTextObj *)&rSdrObject;
699 // Gibt es ueberhaupt auszugebenden Text
700 const OutlinerParaObject *pOutlinerParaObj =
701 pTextObj->GetOutlinerParaObject();
702 if( !pOutlinerParaObj )
703 return rWrt;
705 ByteString sOut( '<' );
706 sOut += OOO_STRING_SVTOOLS_HTML_marquee;
708 // Die Attribute des Objektd holen
709 const SfxItemSet& rItemSet = pTextObj->GetMergedItemSet();
711 // BEHAVIOUR
712 SdrTextAniKind eAniKind = pTextObj->GetTextAniKind();
713 ASSERT( SDRTEXTANI_SCROLL==eAniKind ||
714 SDRTEXTANI_ALTERNATE==eAniKind ||
715 SDRTEXTANI_SLIDE==eAniKind,
716 "Text-Draw-Objekt nicht fuer Marquee geeignet" )
718 const sal_Char *pStr = 0;
719 switch( eAniKind )
721 case SDRTEXTANI_SCROLL: pStr = OOO_STRING_SVTOOLS_HTML_BEHAV_scroll; break;
722 case SDRTEXTANI_SLIDE: pStr = OOO_STRING_SVTOOLS_HTML_BEHAV_slide; break;
723 case SDRTEXTANI_ALTERNATE: pStr = OOO_STRING_SVTOOLS_HTML_BEHAV_alternate; break;
724 default:
728 if( pStr )
729 (((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_behavior) += '=') += pStr;
731 // DIRECTION
732 pStr = 0;
733 SdrTextAniDirection eAniDir = pTextObj->GetTextAniDirection();
734 switch( eAniDir )
736 case SDRTEXTANI_LEFT: pStr = OOO_STRING_SVTOOLS_HTML_AL_left; break;
737 case SDRTEXTANI_RIGHT: pStr = OOO_STRING_SVTOOLS_HTML_AL_right; break;
738 default:
742 if( pStr )
743 (((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_direction) += '=') += pStr;
745 // LOOP
746 sal_Int32 nCount =
747 ((const SdrTextAniCountItem&)rItemSet.Get( SDRATTR_TEXT_ANICOUNT ))
748 .GetValue();
749 if( 0==nCount )
750 nCount = SDRTEXTANI_SLIDE==eAniKind ? 1 : -1;
751 (((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_loop) += '=')
752 += ByteString::CreateFromInt32( nCount );
754 // SCROLLDELAY
755 sal_uInt16 nDelay =
756 ((const SdrTextAniDelayItem&)rItemSet.Get( SDRATTR_TEXT_ANIDELAY ))
757 .GetValue();
758 (((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_scrolldelay) += '=')
759 += ByteString::CreateFromInt32( nDelay );
761 // SCROLLAMOUNT
762 sal_Int16 nAmount =
763 ((const SdrTextAniAmountItem&)rItemSet.Get( SDRATTR_TEXT_ANIAMOUNT ))
764 .GetValue();
765 if( nAmount < 0 )
767 nAmount = -nAmount;
769 else if( nAmount && Application::GetDefaultDevice() )
771 nAmount = (sal_uInt16)(Application::GetDefaultDevice()
772 ->LogicToPixel( Size(nAmount,0),
773 MapMode(MAP_TWIP) ).Width());
775 if( nAmount )
776 (((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_scrollamount) += '=')
777 += ByteString::CreateFromInt32( nAmount );
779 Size aTwipSz( pTextObj->GetLogicRect().GetSize() );
780 if( pTextObj->IsAutoGrowWidth() )
781 aTwipSz.Width() = 0;
782 // Die Hoehe ist bei MS eine Mindesthoehe, also geben wir auch die
783 // Mindestheoehe aus, wenn es sie gibt. Da eine Mindesthoehe MINFLY
784 // mit hoher Wahrscheinlichkeit vom Import kommt, wird sie nicht mit
785 // ausgegeben. Falsch machen kann man da nichst, denn jeder Font ist
786 // hoeher.
787 if( pTextObj->IsAutoGrowHeight() )
789 aTwipSz.Height() = pTextObj->GetMinTextFrameHeight();
790 if( MINFLY==aTwipSz.Height() )
791 aTwipSz.Height() = 0;
794 if( (aTwipSz.Width() || aTwipSz.Height()) &&
795 Application::GetDefaultDevice() )
797 Size aPixelSz =
798 Application::GetDefaultDevice()->LogicToPixel( aTwipSz,
799 MapMode(MAP_TWIP) );
800 if( !aPixelSz.Width() && aTwipSz.Width() )
801 aPixelSz.Width() = 1;
802 if( !aPixelSz.Height() && aTwipSz.Height() )
803 aPixelSz.Height() = 1;
805 if( aPixelSz.Width() )
806 (((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_width) += '=')
807 += ByteString::CreateFromInt32( aPixelSz.Width() );
809 if( aPixelSz.Height() )
810 (((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_height) += '=')
811 += ByteString::CreateFromInt32( aPixelSz.Height() );
814 // BGCOLOR
815 XFillStyle eFillStyle =
816 ((const XFillStyleItem&)rItemSet.Get(XATTR_FILLSTYLE)).GetValue();
817 if( XFILL_SOLID==eFillStyle )
819 const Color& rFillColor =
820 ((const XFillColorItem&)rItemSet.Get(XATTR_FILLCOLOR)).GetColorValue();
822 ((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_bgcolor) += '=';
823 rWrt.Strm() << sOut.GetBuffer();
824 HTMLOutFuncs::Out_Color( rWrt.Strm(), rFillColor, rHTMLWrt.eDestEnc );
825 sOut.Erase();
828 if( sOut.Len() )
829 rWrt.Strm() << sOut.GetBuffer();
831 // und nun noch ALIGN, HSPACE und VSPACE
832 ByteString aEndTags;
833 sal_uInt32 nFrmFlags = HTML_FRMOPTS_MARQUEE;
834 if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) )
835 nFrmFlags |= HTML_FRMOPTS_MARQUEE_CSS1;
836 rHTMLWrt.OutFrmFmtOptions( rFmt, aEmptyStr, aEndTags, nFrmFlags );
837 if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_DRAW ) )
838 rHTMLWrt.OutCSS1_FrmFmtOptions( rFmt, nFrmFlags, &rSdrObject );
841 rWrt.Strm() << '>';
843 // Was jetzt kommt ist das Gegenstueck zu SdrTextObjectt::SetText()
844 Outliner aOutliner(0, OUTLINERMODE_TEXTOBJECT);
845 aOutliner.SetUpdateMode( sal_False );
846 aOutliner.SetText( *pOutlinerParaObj );
847 String aText( aOutliner.GetText( aOutliner.GetParagraph(0),
848 aOutliner.GetParagraphCount() ) );
849 HTMLOutFuncs::Out_String( rWrt.Strm(), aText,
850 rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
852 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_marquee, sal_False );
854 if( aEndTags.Len() )
855 rWrt.Strm() << aEndTags.GetBuffer();
857 return rWrt;