merge the formfield patch from ooo-build
[ooovba.git] / sw / source / filter / html / htmlplug.cxx
blob27852b37abec95bc97d56f2dcf4c9d5f5a94266e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: htmlplug.cxx,v $
10 * $Revision: 1.29 $
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"
33 #include <com/sun/star/embed/EmbedStates.hpp>
34 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include "hintids.hxx"
39 #include <svtools/urihelper.hxx>
40 #define _SVSTDARR_ULONGS
41 #include <svtools/svstdarr.hxx>
42 #include <vcl/svapp.hxx>
43 #include <sfx2/frmhtml.hxx>
44 #include <sfx2/frmhtmlw.hxx>
45 #ifndef _WRKWIN_HXX //autogen
46 #include <vcl/wrkwin.hxx>
47 #endif
48 #include <sot/storage.hxx>
49 #include <svx/xoutbmp.hxx>
50 #include <svx/ulspitem.hxx>
51 #include <svx/lrspitem.hxx>
52 #include <svtools/htmlkywd.hxx>
53 #include <svtools/htmltokn.h>
54 #include <SwAppletImpl.hxx>
55 #include <fmtornt.hxx>
56 #include <fmtfsize.hxx>
57 #include <fmtsrnd.hxx>
58 #include <fmtanchr.hxx>
59 #include <fmtcntnt.hxx>
60 #include <frmfmt.hxx>
62 #include <svtools/ownlist.hxx>
63 #include "pam.hxx"
64 #include "doc.hxx"
65 #include "ndtxt.hxx"
66 #include "swerror.h"
67 #include "ndole.hxx"
68 #include "swtable.hxx"
69 #include "swhtml.hxx"
70 #include "wrthtml.hxx"
71 #include "htmlfly.hxx"
72 #include "swcss1.hxx"
73 #include <com/sun/star/embed/XClassifiedObject.hpp>
74 #include <com/sun/star/embed/EmbedStates.hpp>
75 #include <comphelper/embeddedobjectcontainer.hxx>
76 #include <sot/clsids.hxx>
78 using namespace com::sun::star;
80 #define HTML_DFLT_EMBED_WIDTH ((MM50*5)/2)
81 #define HTML_DFLT_EMBED_HEIGHT ((MM50*5)/2)
83 #define HTML_DFLT_APPLET_WIDTH ((MM50*5)/2)
84 #define HTML_DFLT_APPLET_HEIGHT ((MM50*5)/2)
86 namespace {
88 static char const sHTML_O_Hidden_False[] = "FALSE";
92 const ULONG HTML_FRMOPTS_EMBED_ALL =
93 HTML_FRMOPT_ALT |
94 HTML_FRMOPT_SIZE |
95 HTML_FRMOPT_NAME;
96 const ULONG HTML_FRMOPTS_EMBED_CNTNR =
97 HTML_FRMOPTS_EMBED_ALL |
98 HTML_FRMOPT_ABSSIZE;
99 const ULONG HTML_FRMOPTS_EMBED =
100 HTML_FRMOPTS_EMBED_ALL |
101 HTML_FRMOPT_ALIGN |
102 HTML_FRMOPT_SPACE |
103 HTML_FRMOPT_BRCLEAR |
104 HTML_FRMOPT_NAME;
105 const ULONG HTML_FRMOPTS_HIDDEN_EMBED =
106 HTML_FRMOPT_ALT |
107 HTML_FRMOPT_NAME;
109 const ULONG HTML_FRMOPTS_APPLET_ALL =
110 HTML_FRMOPT_ALT |
111 HTML_FRMOPT_SIZE;
112 const ULONG HTML_FRMOPTS_APPLET_CNTNR =
113 HTML_FRMOPTS_APPLET_ALL |
114 HTML_FRMOPT_ABSSIZE;
115 const ULONG HTML_FRMOPTS_APPLET =
116 HTML_FRMOPTS_APPLET_ALL |
117 HTML_FRMOPT_ALIGN |
118 HTML_FRMOPT_SPACE |
119 HTML_FRMOPT_BRCLEAR;
121 const ULONG HTML_FRMOPTS_IFRAME_ALL =
122 HTML_FRMOPT_ALT |
123 HTML_FRMOPT_SIZE;
124 const ULONG HTML_FRMOPTS_IFRAME_CNTNR =
125 HTML_FRMOPTS_IFRAME_ALL |
126 HTML_FRMOPT_ABSSIZE;
127 const ULONG HTML_FRMOPTS_IFRAME =
128 HTML_FRMOPTS_IFRAME_ALL |
129 HTML_FRMOPT_ALIGN |
130 HTML_FRMOPT_SPACE |
131 HTML_FRMOPT_BORDER |
132 HTML_FRMOPT_BRCLEAR;
134 const ULONG HTML_FRMOPTS_OLE_CSS1 =
135 HTML_FRMOPT_S_ALIGN |
136 HTML_FRMOPT_S_SPACE;
138 /* \f */
140 void SwHTMLParser::SetFixSize( const Size& rPixSize,
141 const Size& rTwipDfltSize,
142 BOOL bPrcWidth, BOOL bPrcHeight,
143 SfxItemSet& /*rCSS1ItemSet*/,
144 SvxCSS1PropertyInfo& rCSS1PropInfo,
145 SfxItemSet& rFlyItemSet )
147 // absolulte Groessenangaben in Twip umrechnen
148 BYTE nPrcWidth = 0, nPrcHeight = 0;
149 Size aTwipSz( bPrcWidth || USHRT_MAX==rPixSize.Width() ? 0 : rPixSize.Width(),
150 bPrcHeight || USHRT_MAX==rPixSize.Height() ? 0 : rPixSize.Height() );
151 if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
153 aTwipSz =
154 Application::GetDefaultDevice()->PixelToLogic( aTwipSz,
155 MapMode(MAP_TWIP) );
158 // die Breite bearbeiten
159 if( SVX_CSS1_LTYPE_PERCENTAGE == rCSS1PropInfo.eWidthType )
161 nPrcWidth = (BYTE)rCSS1PropInfo.nWidth;
162 aTwipSz.Width() = rTwipDfltSize.Width();
164 else if( SVX_CSS1_LTYPE_TWIP== rCSS1PropInfo.eWidthType )
166 aTwipSz.Width() = rCSS1PropInfo.nWidth;
168 else if( bPrcWidth && rPixSize.Width() )
170 nPrcWidth = (BYTE)rPixSize.Width();
171 if( nPrcWidth > 100 )
172 nPrcWidth = 100;
174 aTwipSz.Width() = rTwipDfltSize.Width();
176 else if( USHRT_MAX==rPixSize.Width() )
178 aTwipSz.Width() = rTwipDfltSize.Width();
180 if( aTwipSz.Width() < MINFLY )
182 aTwipSz.Width() = MINFLY;
185 // Hoehe bearbeiten
186 if( SVX_CSS1_LTYPE_PERCENTAGE == rCSS1PropInfo.eHeightType )
188 nPrcHeight = (BYTE)rCSS1PropInfo.nHeight;
189 aTwipSz.Height() = rTwipDfltSize.Height();
191 else if( SVX_CSS1_LTYPE_TWIP== rCSS1PropInfo.eHeightType )
193 aTwipSz.Height() = rCSS1PropInfo.nHeight;
195 else if( bPrcHeight && rPixSize.Height() )
197 nPrcHeight = (BYTE)rPixSize.Height();
198 if( nPrcHeight > 100 )
199 nPrcHeight = 100;
201 aTwipSz.Height() = rTwipDfltSize.Height();
203 else if( USHRT_MAX==rPixSize.Height() )
205 aTwipSz.Height() = rTwipDfltSize.Height();
207 if( aTwipSz.Height() < MINFLY )
209 aTwipSz.Height() = MINFLY;
212 // Size setzen
213 SwFmtFrmSize aFrmSize( ATT_FIX_SIZE, aTwipSz.Width(), aTwipSz.Height() );
214 aFrmSize.SetWidthPercent( nPrcWidth );
215 aFrmSize.SetHeightPercent( nPrcHeight );
216 rFlyItemSet.Put( aFrmSize );
219 void SwHTMLParser::SetSpace( const Size& rPixSpace,
220 SfxItemSet& rCSS1ItemSet,
221 SvxCSS1PropertyInfo& rCSS1PropInfo,
222 SfxItemSet& rFlyItemSet )
224 sal_Int32 nLeftSpace = 0, nRightSpace = 0;
225 sal_uInt16 nUpperSpace = 0, nLowerSpace = 0;
226 if( (rPixSpace.Width() || rPixSpace.Height()) && Application::GetDefaultDevice() )
228 Size aTwipSpc( rPixSpace.Width(), rPixSpace.Height() );
229 aTwipSpc =
230 Application::GetDefaultDevice()->PixelToLogic( aTwipSpc,
231 MapMode(MAP_TWIP) );
232 nLeftSpace = nRightSpace = aTwipSpc.Width();
233 nUpperSpace = nLowerSpace = (USHORT)aTwipSpc.Height();
236 // linken/rechten Rand setzen
237 const SfxPoolItem *pItem;
238 if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, TRUE, &pItem ) )
240 // Ggf. den Erstzeilen-Einzug noch plaetten
241 const SvxLRSpaceItem *pLRItem = (const SvxLRSpaceItem *)pItem;
242 SvxLRSpaceItem aLRItem( *pLRItem );
243 aLRItem.SetTxtFirstLineOfst( 0 );
244 if( rCSS1PropInfo.bLeftMargin )
246 nLeftSpace = aLRItem.GetLeft();
247 rCSS1PropInfo.bLeftMargin = FALSE;
249 if( rCSS1PropInfo.bRightMargin )
251 nRightSpace = aLRItem.GetRight();
252 rCSS1PropInfo.bRightMargin = FALSE;
254 rCSS1ItemSet.ClearItem( RES_LR_SPACE );
256 if( nLeftSpace > 0 || nRightSpace > 0 )
258 SvxLRSpaceItem aLRItem( RES_LR_SPACE );
259 aLRItem.SetLeft( nLeftSpace > 0 ? nLeftSpace : 0 );
260 aLRItem.SetRight( nRightSpace > 0 ? nRightSpace : 0 );
261 rFlyItemSet.Put( aLRItem );
262 if( nLeftSpace )
264 const SwFmtHoriOrient& rHoriOri =
265 (const SwFmtHoriOrient&)rFlyItemSet.Get( RES_HORI_ORIENT );
266 if( text::HoriOrientation::NONE == rHoriOri.GetHoriOrient() )
268 SwFmtHoriOrient aHoriOri( rHoriOri );
269 aHoriOri.SetPos( aHoriOri.GetPos() + nLeftSpace );
270 rFlyItemSet.Put( aHoriOri );
275 // oberen/unteren Rand setzen
276 if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, TRUE, &pItem ) )
278 // Ggf. den Erstzeilen-Einzug noch plaetten
279 const SvxULSpaceItem *pULItem = (const SvxULSpaceItem *)pItem;
280 if( rCSS1PropInfo.bTopMargin )
282 nUpperSpace = pULItem->GetUpper();
283 rCSS1PropInfo.bTopMargin = FALSE;
285 if( rCSS1PropInfo.bBottomMargin )
287 nLowerSpace = pULItem->GetLower();
288 rCSS1PropInfo.bBottomMargin = FALSE;
290 rCSS1ItemSet.ClearItem( RES_UL_SPACE );
292 if( nUpperSpace || nLowerSpace )
294 SvxULSpaceItem aULItem( RES_UL_SPACE );
295 aULItem.SetUpper( nUpperSpace );
296 aULItem.SetLower( nLowerSpace );
297 rFlyItemSet.Put( aULItem );
298 if( nUpperSpace )
300 const SwFmtVertOrient& rVertOri =
301 (const SwFmtVertOrient&)rFlyItemSet.Get( RES_VERT_ORIENT );
302 if( text::VertOrientation::NONE == rVertOri.GetVertOrient() )
304 SwFmtVertOrient aVertOri( rVertOri );
305 aVertOri.SetPos( aVertOri.GetPos() + nUpperSpace );
306 rFlyItemSet.Put( aVertOri );
312 /* \f */
314 void SwHTMLParser::InsertEmbed()
316 String aURL, aType, aName, aAlt, aId, aStyle, aClass;
317 Size aSize( USHRT_MAX, USHRT_MAX );
318 Size aSpace( USHRT_MAX, USHRT_MAX );
319 BOOL bPrcWidth = FALSE, bPrcHeight = FALSE, bHidden = FALSE;
320 sal_Int16 eVertOri = text::VertOrientation::NONE;
321 sal_Int16 eHoriOri = text::HoriOrientation::NONE;
322 SvCommandList aCmdLst;
323 const HTMLOptions *pHTMLOptions = GetOptions();
325 // Die Optionen werden vorwaerts gelesen, weil die Plugins sie in
326 // dieser Reihenfolge erwarten. Trotzdem darf immer nur der erste
327 // Wert einer Option beruecksichtigt werden.
328 USHORT nArrLen = pHTMLOptions->Count();
329 for( USHORT i=0; i<nArrLen; i++ )
331 const HTMLOption *pOption = (*pHTMLOptions)[i];
332 switch( pOption->GetToken() )
334 case HTML_O_ID:
335 aId = pOption->GetString();
336 break;
337 case HTML_O_STYLE:
338 aStyle = pOption->GetString();
339 break;
340 case HTML_O_CLASS:
341 aClass = pOption->GetString();
342 break;
343 case HTML_O_NAME:
344 aName = pOption->GetString();
345 break;
346 case HTML_O_SRC:
347 if( !aURL.Len() )
348 aURL = pOption->GetString();
349 break;
350 case HTML_O_ALT:
351 aAlt = pOption->GetString();
352 break;
353 case HTML_O_TYPE:
354 if( !aType.Len() )
355 aType = pOption->GetString();
356 break;
357 case HTML_O_ALIGN:
358 if( eVertOri==text::VertOrientation::NONE && eHoriOri==text::HoriOrientation::NONE )
360 eVertOri = pOption->GetEnum( aHTMLImgVAlignTable, eVertOri );
361 eHoriOri = pOption->GetEnum( aHTMLImgHAlignTable, eHoriOri );
363 break;
364 case HTML_O_WIDTH:
365 if( USHRT_MAX==aSize.Width() )
367 bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
368 aSize.Width() = (long)pOption->GetNumber();
370 break;
371 case HTML_O_HEIGHT:
372 if( USHRT_MAX==aSize.Height() )
374 bPrcHeight = (pOption->GetString().Search('%') != STRING_NOTFOUND);
375 aSize.Height() = (long)pOption->GetNumber();
377 break;
378 case HTML_O_HSPACE:
379 if( USHRT_MAX==aSpace.Width() )
380 aSpace.Width() = (long)pOption->GetNumber();
381 break;
382 case HTML_O_VSPACE:
383 if( USHRT_MAX==aSpace.Height() )
384 aSpace.Height() = (long)pOption->GetNumber();
385 break;
386 case HTML_O_UNKNOWN:
387 if( pOption->GetTokenString().EqualsIgnoreCaseAscii( OOO_STRING_SW_HTML_O_Hidden ) )
388 bHidden =
389 !pOption->GetString().EqualsIgnoreCaseAscii( sHTML_O_Hidden_False );
390 break;
393 // Es werden alle Parameter an das Plugin weitergereicht
394 aCmdLst.Append( pOption->GetTokenString(), pOption->GetString() );
397 SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
398 SvxCSS1PropertyInfo aPropInfo;
399 if( HasStyleOptions( aStyle, aId, aClass ) )
400 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
402 // Die Default-Werte umsetzen (ausser Hoehe/Breite, das macht schon
403 // SetFrmSize() fuer uns)
404 if( eVertOri==text::VertOrientation::NONE && eHoriOri==text::HoriOrientation::NONE )
405 eVertOri = text::VertOrientation::TOP;
406 if( USHRT_MAX==aSpace.Width() )
407 aSpace.Width() = 0;
408 if( USHRT_MAX==aSpace.Height() )
409 aSpace.Height() = 0;
410 if( bHidden )
412 // Size (0,0) wird in SetFrmSize auf (MINFLY, MINFLY) umgebogen
413 aSize.Width() = 0; aSize.Height() = 0;
414 aSpace.Width() = 0; aSpace.Height() = 0;
415 bPrcWidth = bPrcHeight = FALSE;
418 // die URL aufbereiten
419 INetURLObject aURLObj;
420 bool bHasURL = aURL.Len() &&
421 aURLObj.SetURL(
422 URIHelper::SmartRel2Abs(
423 INetURLObject(sBaseURL), aURL,
424 URIHelper::GetMaybeFileHdl()) );
426 // #109761# do not insert plugin if it has neither URL nor type
427 bool bHasType = aType.Len() != 0;
428 if( !bHasURL && !bHasType )
429 return;
431 // das Plugin anlegen
432 comphelper::EmbeddedObjectContainer aCnt;
433 ::rtl::OUString aObjName;
434 uno::Reference < embed::XEmbeddedObject > xObj = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aObjName );
435 if ( svt::EmbeddedObjectRef::TryRunningState( xObj ) )
437 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
438 if ( xSet.is() )
440 if( bHasURL )
441 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginURL"),
442 uno::makeAny( ::rtl::OUString( aURL ) ) );
443 if( bHasType )
444 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginMimeType"),
445 uno::makeAny( ::rtl::OUString( aType ) ) );
447 uno::Sequence < beans::PropertyValue > aProps;
448 aCmdLst.FillSequence( aProps );
449 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginCommands"), uno::makeAny( aProps ) );
451 // TODO/LATER: EnableSetModified?!
452 //pPlugin->EnableSetModified( TRUE );
456 SfxItemSet aFrmSet( pDoc->GetAttrPool(),
457 RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
458 if( !IsNewDoc() )
459 Reader::ResetFrmFmtAttrs( aFrmSet );
461 // den Anker setzen
462 if( !bHidden )
464 SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, aFrmSet );
466 else
468 SwFmtAnchor aAnchor( FLY_AT_CNTNT );
469 aAnchor.SetAnchor( pPam->GetPoint() );
470 aFrmSet.Put( aAnchor );
471 aFrmSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME) );
472 aFrmSet.Put( SwFmtSurround( SURROUND_THROUGHT ) );
473 aFrmSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::PRINT_AREA ) );
476 // und noch die Groesse des Rahmens
477 Size aDfltSz( HTML_DFLT_EMBED_WIDTH, HTML_DFLT_EMBED_HEIGHT );
478 SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
479 aFrmSet );
480 SetSpace( aSpace, aItemSet, aPropInfo, aFrmSet );
482 // und in das Dok einfuegen
483 SwFrmFmt* pFlyFmt =
484 pDoc->Insert( *pPam, ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), &aFrmSet, NULL, NULL );
486 // Namen am FrmFmt setzen
487 if( aName.Len() )
488 pFlyFmt->SetName( aName );
490 // den alternativen Text setzen
491 SwNoTxtNode *pNoTxtNd =
492 pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
493 ->GetIndex()+1 ]->GetNoTxtNode();
494 pNoTxtNd->SetTitle( aAlt );
496 // Ggf Frames anlegen und auto-geb. Rahmen registrieren
497 if( !bHidden )
499 // HIDDEN-Plugins sollen absatzgebunden bleiben. Da RegisterFlyFrm
500 // absatzgebundene Rahmen mit DUrchlauf in am Zeichen gebundene
501 // Rahmen umwandelt, muessen die Frames hier von Hand angelegt werden.
502 RegisterFlyFrm( pFlyFmt );
506 /* \f */
508 #ifdef SOLAR_JAVA
509 void SwHTMLParser::NewObject()
511 String aClassID, aName, aStandBy, aId, aStyle, aClass;
512 Size aSize( USHRT_MAX, USHRT_MAX );
513 Size aSpace( 0, 0 );
514 sal_Int16 eVertOri = text::VertOrientation::TOP;
515 sal_Int16 eHoriOri = text::HoriOrientation::NONE;
517 sal_Bool bPrcWidth = sal_False, bPrcHeight = sal_False,
518 bDeclare = sal_False;
519 // Eine neue Command-List anlegen
520 if( pAppletImpl )
521 delete pAppletImpl;
522 pAppletImpl = new SwApplet_Impl( pDoc->GetAttrPool(),
523 RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
525 const HTMLOptions *pHTMLOptions = GetOptions();
526 for( USHORT i = pHTMLOptions->Count(); i; )
528 const HTMLOption *pOption = (*pHTMLOptions)[--i];
529 switch( pOption->GetToken() )
531 case HTML_O_ID:
532 aId = pOption->GetString();
533 break;
534 case HTML_O_STYLE:
535 aStyle = pOption->GetString();
536 break;
537 case HTML_O_CLASS:
538 aClass = pOption->GetString();
539 break;
540 case HTML_O_DECLARE:
541 bDeclare = sal_True;
542 break;
543 case HTML_O_CLASSID:
544 aClassID = pOption->GetString();
545 break;
546 case HTML_O_CODEBASE:
547 break;
548 case HTML_O_DATA:
549 break;
550 case HTML_O_TYPE:
551 break;
552 case HTML_O_CODETYPE:
553 break;
554 case HTML_O_ARCHIVE:
555 case HTML_O_UNKNOWN:
556 break;
557 case HTML_O_STANDBY:
558 aStandBy = pOption->GetString();
559 break;
560 case HTML_O_WIDTH:
561 bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
562 aSize.Width() = (long)pOption->GetNumber();
563 break;
564 case HTML_O_HEIGHT:
565 bPrcHeight = (pOption->GetString().Search('%') != STRING_NOTFOUND);
566 aSize.Height() = (long)pOption->GetNumber();
567 break;
568 case HTML_O_ALIGN:
569 eVertOri = pOption->GetEnum( aHTMLImgVAlignTable, eVertOri );
570 eHoriOri = pOption->GetEnum( aHTMLImgHAlignTable, eHoriOri );
571 break;
572 case HTML_O_USEMAP:
573 break;
574 case HTML_O_NAME:
575 aName = pOption->GetString();
576 break;
577 case HTML_O_HSPACE:
578 aSpace.Width() = (long)pOption->GetNumber();
579 break;
580 case HTML_O_VSPACE:
581 aSpace.Height() = (long)pOption->GetNumber();
582 break;
583 case HTML_O_BORDER:
584 break;
586 case HTML_O_SDONCLICK:
587 case HTML_O_ONCLICK:
588 case HTML_O_SDONMOUSEOVER:
589 case HTML_O_ONMOUSEOVER:
590 case HTML_O_SDONMOUSEOUT:
591 case HTML_O_ONMOUSEOUT:
592 break;
594 // Es werden alle Parameter auch an das Applet weitergereicht
595 pAppletImpl->AppendParam( pOption->GetTokenString(),
596 pOption->GetString() );
600 // Objects that are declared only are not evaluated. Moreover, only
601 // Java applets are supported.
602 sal_Bool bIsApplet = sal_False;;
604 if( !bDeclare && aClassID.Len() == 42 &&
605 aClassID.EqualsAscii( "clsid:", 0, 6 ) )
607 aClassID.Erase( 0, 6 );
608 SvGlobalName aCID;
609 if( aCID.MakeId( aClassID ) )
611 SvGlobalName aJavaCID( 0x8AD9C840UL, 0x044EU, 0x11D1U, 0xB3U, 0xE9U,
612 0x00U, 0x80U, 0x5FU, 0x49U, 0x9DU, 0x93U );
614 bIsApplet = aJavaCID == aCID;
618 if( !bIsApplet )
620 delete pAppletImpl;
621 pAppletImpl = 0;
622 return;
625 pAppletImpl->SetAltText( aStandBy );
627 SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
628 SvxCSS1PropertyInfo aPropInfo;
629 if( HasStyleOptions( aStyle, aId, aClass ) )
630 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
632 SfxItemSet& rFrmSet = pAppletImpl->GetItemSet();
633 if( !IsNewDoc() )
634 Reader::ResetFrmFmtAttrs( rFrmSet );
636 // den Anker und die Ausrichtung setzen
637 SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, rFrmSet );
639 // und noch die Groesse des Rahmens
640 Size aDfltSz( HTML_DFLT_APPLET_WIDTH, HTML_DFLT_APPLET_HEIGHT );
641 SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
642 rFrmSet );
643 SetSpace( aSpace, aItemSet, aPropInfo, rFrmSet );
645 #endif
647 void SwHTMLParser::EndObject()
649 #ifdef SOLAR_JAVA
650 if( !pAppletImpl )
651 return;
652 if( pAppletImpl->CreateApplet( sBaseURL ) )
654 pAppletImpl->FinishApplet();
656 // und in das Dok einfuegen
657 SwFrmFmt* pFlyFmt =
658 pDoc->Insert( *pPam,
659 ::svt::EmbeddedObjectRef( pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
660 &pAppletImpl->GetItemSet(),
661 NULL,
662 NULL );
664 // den alternativen Namen setzen
665 SwNoTxtNode *pNoTxtNd =
666 pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
667 ->GetIndex()+1 ]->GetNoTxtNode();
668 pNoTxtNd->SetTitle( pAppletImpl->GetAltText() );
670 // Ggf Frames anlegen und auto-geb. Rahmen registrieren
671 RegisterFlyFrm( pFlyFmt );
673 delete pAppletImpl;
674 pAppletImpl = 0;
676 #endif
679 #ifdef SOLAR_JAVA
680 void SwHTMLParser::InsertApplet()
682 String aCodeBase, aCode, aName, aAlt, aId, aStyle, aClass;
683 Size aSize( USHRT_MAX, USHRT_MAX );
684 Size aSpace( 0, 0 );
685 BOOL bPrcWidth = FALSE, bPrcHeight = FALSE, bMayScript = FALSE;
686 sal_Int16 eVertOri = text::VertOrientation::TOP;
687 sal_Int16 eHoriOri = text::HoriOrientation::NONE;
689 // Eine neue Command-List anlegen
690 if( pAppletImpl )
691 delete pAppletImpl;
692 pAppletImpl = new SwApplet_Impl( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
694 const HTMLOptions *pHTMLOptions = GetOptions();
695 for( USHORT i = pHTMLOptions->Count(); i; )
697 const HTMLOption *pOption = (*pHTMLOptions)[--i];
698 switch( pOption->GetToken() )
700 case HTML_O_ID:
701 aId = pOption->GetString();
702 break;
703 case HTML_O_STYLE:
704 aStyle = pOption->GetString();
705 break;
706 case HTML_O_CLASS:
707 aClass = pOption->GetString();
708 break;
709 case HTML_O_CODEBASE:
710 aCodeBase = pOption->GetString();
711 break;
712 case HTML_O_CODE:
713 aCode = pOption->GetString();
714 break;
715 case HTML_O_NAME:
716 aName = pOption->GetString();
717 break;
718 case HTML_O_ALT:
719 aAlt = pOption->GetString();
720 break;
721 case HTML_O_ALIGN:
722 eVertOri = pOption->GetEnum( aHTMLImgVAlignTable, eVertOri );
723 eHoriOri = pOption->GetEnum( aHTMLImgHAlignTable, eHoriOri );
724 break;
725 case HTML_O_WIDTH:
726 bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
727 aSize.Width() = (long)pOption->GetNumber();
728 break;
729 case HTML_O_HEIGHT:
730 bPrcHeight = (pOption->GetString().Search('%') != STRING_NOTFOUND);
731 aSize.Height() = (long)pOption->GetNumber();
732 break;
733 case HTML_O_HSPACE:
734 aSpace.Width() = (long)pOption->GetNumber();
735 break;
736 case HTML_O_VSPACE:
737 aSpace.Height() = (long)pOption->GetNumber();
738 break;
739 case HTML_O_MAYSCRIPT:
740 bMayScript = TRUE;
741 break;
744 // Es werden alle Parameter auch an das Applet weitergereicht
745 pAppletImpl->AppendParam( pOption->GetTokenString(),
746 pOption->GetString() );
749 if( !aCode.Len() )
751 delete pAppletImpl;
752 pAppletImpl = 0;
753 return;
756 if ( aCodeBase.Len() )
757 aCodeBase = INetURLObject::GetAbsURL( sBaseURL, aCodeBase );
758 pAppletImpl->CreateApplet( aCode, aName, bMayScript, aCodeBase, sBaseURL );//, aAlt );
759 pAppletImpl->SetAltText( aAlt );
761 SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
762 SvxCSS1PropertyInfo aPropInfo;
763 if( HasStyleOptions( aStyle, aId, aClass ) )
764 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
766 SfxItemSet& rFrmSet = pAppletImpl->GetItemSet();
767 if( !IsNewDoc() )
768 Reader::ResetFrmFmtAttrs( rFrmSet );
770 // den Anker und die Ausrichtung setzen
771 SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, rFrmSet );
773 // und noch die Groesse des Rahmens
774 Size aDfltSz( HTML_DFLT_APPLET_WIDTH, HTML_DFLT_APPLET_HEIGHT );
775 SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
776 rFrmSet );
777 SetSpace( aSpace, aItemSet, aPropInfo, rFrmSet );
779 #endif
781 void SwHTMLParser::EndApplet()
783 #ifdef SOLAR_JAVA
784 if( !pAppletImpl )
785 return;
787 pAppletImpl->FinishApplet();
789 // und in das Dok einfuegen
790 SwFrmFmt* pFlyFmt =
791 pDoc->Insert( *pPam,
792 ::svt::EmbeddedObjectRef( pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
793 &pAppletImpl->GetItemSet(),
794 NULL,
795 NULL );
797 // den alternativen Namen setzen
798 SwNoTxtNode *pNoTxtNd =
799 pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
800 ->GetIndex()+1 ]->GetNoTxtNode();
801 pNoTxtNd->SetTitle( pAppletImpl->GetAltText() );
803 // Ggf Frames anlegen und auto-geb. Rahmen registrieren
804 RegisterFlyFrm( pFlyFmt );
806 delete pAppletImpl;
807 pAppletImpl = 0;
808 #endif
811 void SwHTMLParser::InsertParam()
813 #ifdef SOLAR_JAVA
814 if( !pAppletImpl )
815 return;
817 String aName, aValue;
819 const HTMLOptions *pHTMLOptions = GetOptions();
820 for( USHORT i = pHTMLOptions->Count(); i; )
822 const HTMLOption *pOption = (*pHTMLOptions)[--i];
823 switch( pOption->GetToken() )
825 case HTML_O_NAME:
826 aName = pOption->GetString();
827 break;
828 case HTML_O_VALUE:
829 aValue = pOption->GetString();
830 break;
834 if( !aName.Len() )
835 return;
837 pAppletImpl->AppendParam( aName, aValue );
838 #endif
842 /* \f */
844 void SwHTMLParser::InsertFloatingFrame()
846 String aAlt, aId, aStyle, aClass;
847 Size aSize( USHRT_MAX, USHRT_MAX );
848 Size aSpace( 0, 0 );
849 BOOL bPrcWidth = FALSE, bPrcHeight = FALSE;
850 sal_Int16 eVertOri = text::VertOrientation::TOP;
851 sal_Int16 eHoriOri = text::HoriOrientation::NONE;
853 const HTMLOptions *pHTMLOptions = GetOptions();
855 // Erstmal die Optionen f?r das Writer-Frame-Format holen
856 USHORT nArrLen = pHTMLOptions->Count();
857 for ( USHORT i=0; i<nArrLen; i++ )
859 const HTMLOption *pOption = (*pHTMLOptions)[i];
860 switch( pOption->GetToken() )
862 case HTML_O_ID:
863 aId = pOption->GetString();
864 break;
865 case HTML_O_STYLE:
866 aStyle = pOption->GetString();
867 break;
868 case HTML_O_CLASS:
869 aClass = pOption->GetString();
870 break;
871 case HTML_O_ALT:
872 aAlt = pOption->GetString();
873 break;
874 case HTML_O_ALIGN:
875 eVertOri = pOption->GetEnum( aHTMLImgVAlignTable, eVertOri );
876 eHoriOri = pOption->GetEnum( aHTMLImgHAlignTable, eHoriOri );
877 break;
878 case HTML_O_WIDTH:
879 bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
880 aSize.Width() = (long)pOption->GetNumber();
881 break;
882 case HTML_O_HEIGHT:
883 bPrcHeight = (pOption->GetString().Search('%') != STRING_NOTFOUND);
884 aSize.Height() = (long)pOption->GetNumber();
885 break;
886 case HTML_O_HSPACE:
887 aSpace.Width() = (long)pOption->GetNumber();
888 break;
889 case HTML_O_VSPACE:
890 aSpace.Height() = (long)pOption->GetNumber();
891 break;
895 // und jetzt die fuer den SfxFrame
896 SfxFrameDescriptor aFrameDesc;
898 SfxFrameHTMLParser::ParseFrameOptions( &aFrameDesc, pHTMLOptions, sBaseURL );
900 // den Floating-Frame anlegen
901 comphelper::EmbeddedObjectContainer aCnt;
902 ::rtl::OUString aObjName;
903 uno::Reference < embed::XEmbeddedObject > xObj = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_IFRAME_CLASSID ).GetByteSequence(), aObjName );
905 //pFrame->EnableSetModified( FALSE );
908 // TODO/MBA: testing
909 if ( svt::EmbeddedObjectRef::TryRunningState( xObj ) )
911 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
912 if ( xSet.is() )
914 ::rtl::OUString aName = aFrameDesc.GetName();
915 ScrollingMode eScroll = aFrameDesc.GetScrollingMode();
916 sal_Bool bHasBorder = aFrameDesc.HasFrameBorder();
917 Size aMargin = aFrameDesc.GetMargin();
919 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameURL"), uno::makeAny( ::rtl::OUString( aFrameDesc.GetURL().GetMainURL( INetURLObject::NO_DECODE ) ) ) );
920 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameName"), uno::makeAny( aName ) );
922 if ( eScroll == ScrollingAuto )
923 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoScroll"),
924 uno::makeAny( sal_True ) );
925 else
926 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsScrollingMode"),
927 uno::makeAny( (sal_Bool) ( eScroll == ScrollingYes) ) );
929 //if ( aFrmDescr.IsFrameBorderSet() )
930 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsBorder"),
931 uno::makeAny( bHasBorder ) );
932 /*else
933 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoBorder"),
934 uno::makeAny( sal_True ) );*/
936 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginWidth"),
937 uno::makeAny( sal_Int32( aMargin.Width() ) ) );
939 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginHeight"),
940 uno::makeAny( sal_Int32( aMargin.Height() ) ) );
944 catch ( uno::Exception& )
948 //pFrame->EnableSetModified( TRUE );
950 SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
951 SvxCSS1PropertyInfo aPropInfo;
952 if( HasStyleOptions( aStyle, aId, aClass ) )
953 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
955 // den Itemset holen
956 SfxItemSet aFrmSet( pDoc->GetAttrPool(),
957 RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
958 if( !IsNewDoc() )
959 Reader::ResetFrmFmtAttrs( aFrmSet );
961 // den Anker und die Ausrichtung setzen
962 SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, aFrmSet );
964 // und noch die Groesse des Rahmens
965 Size aDfltSz( HTML_DFLT_APPLET_WIDTH, HTML_DFLT_APPLET_HEIGHT );
966 SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
967 aFrmSet );
968 SetSpace( aSpace, aItemSet, aPropInfo, aFrmSet );
970 // und in das Dok einfuegen
971 SwFrmFmt* pFlyFmt =
972 pDoc->Insert( *pPam, ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), &aFrmSet, NULL, NULL );
974 // den alternativen Namen setzen
975 SwNoTxtNode *pNoTxtNd =
976 pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
977 ->GetIndex()+1 ]->GetNoTxtNode();
978 pNoTxtNd->SetTitle( aAlt );
980 // Ggf Frames anlegen und auto-geb. Rahmen registrieren
981 RegisterFlyFrm( pFlyFmt );
983 bInFloatingFrame = TRUE;
986 /* \f */
989 #define SWHTML_OPTTYPE_IGNORE 0
990 #define SWHTML_OPTTYPE_TAG 1
991 #define SWHTML_OPTTYPE_PARAM 2
994 static USHORT GetOptionType( const String& rName, BOOL bApplet )
996 USHORT nType = bApplet ? SWHTML_OPTTYPE_PARAM : SWHTML_OPTTYPE_TAG;
998 switch( rName.GetChar(0) )
1000 case 'A':
1001 case 'a':
1002 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_align ) ||
1003 rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_alt ) )
1004 nType = SWHTML_OPTTYPE_IGNORE;
1005 else if( bApplet &&
1006 (rName.EqualsIgnoreCaseAscii( sHTML_O_archive ) ||
1007 rName.EqualsIgnoreCaseAscii( sHTML_O_Archives )) )
1008 nType = SWHTML_OPTTYPE_TAG;
1009 break;
1010 case 'C':
1011 case 'c':
1012 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_class ) ||
1013 (bApplet && (rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_code ) ||
1014 rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_codebase ))) )
1015 nType = SWHTML_OPTTYPE_IGNORE;
1016 break;
1017 case 'H':
1018 case 'h':
1019 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_height ) ||
1020 rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_hspace ) ||
1021 (!bApplet && rName.EqualsIgnoreCaseAscii( OOO_STRING_SW_HTML_O_Hidden )) )
1022 nType = SWHTML_OPTTYPE_IGNORE;
1023 break;
1024 case 'I':
1025 case 'i':
1026 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_id ) )
1027 nType = SWHTML_OPTTYPE_IGNORE;
1028 break;
1029 case 'M':
1030 case 'm':
1031 if( bApplet && rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_mayscript ) )
1032 nType = SWHTML_OPTTYPE_IGNORE;
1033 break;
1034 case 'N':
1035 case 'n':
1036 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_name ) )
1037 nType = SWHTML_OPTTYPE_IGNORE;
1038 break;
1039 case 'O':
1040 case 'o':
1041 if( bApplet && rName.EqualsIgnoreCaseAscii( sHTML_O_Object ) )
1042 nType = SWHTML_OPTTYPE_TAG;
1043 break;
1044 case 'S':
1045 case 's':
1046 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_style ) ||
1047 (!bApplet && rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_src )) )
1048 nType = SWHTML_OPTTYPE_IGNORE;
1049 break;
1050 case 'T':
1051 case 't':
1052 if( !bApplet && rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_type ) )
1053 nType = SWHTML_OPTTYPE_IGNORE;
1054 break;
1055 case 'V':
1056 case 'v':
1057 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_vspace ) )
1058 nType = SWHTML_OPTTYPE_IGNORE;
1059 break;
1060 case 'W':
1061 case 'w':
1062 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_width ) )
1063 nType = SWHTML_OPTTYPE_IGNORE;
1064 break;
1067 return nType;
1071 USHORT SwHTMLWriter::GuessOLENodeFrmType( const SwNode& rNode )
1073 SwOLEObj& rObj = ((SwOLENode*)rNode.GetOLENode())->GetOLEObj();
1075 SwHTMLFrmType eType = HTML_FRMTYPE_OLE;
1077 uno::Reference < embed::XClassifiedObject > xClass ( rObj.GetOleRef(), uno::UNO_QUERY );
1078 SvGlobalName aClass( xClass->getClassID() );
1079 if( aClass == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1081 eType = HTML_FRMTYPE_PLUGIN;
1083 else if( aClass == SvGlobalName( SO3_IFRAME_CLASSID ) )
1085 eType = HTML_FRMTYPE_IFRAME;
1087 #ifdef SOLAR_JAVA
1088 else if( aClass == SvGlobalName( SO3_APPLET_CLASSID ) )
1090 eType = HTML_FRMTYPE_APPLET;
1092 #endif
1094 return static_cast< USHORT >(eType);
1097 Writer& OutHTML_FrmFmtOLENode( Writer& rWrt, const SwFrmFmt& rFrmFmt,
1098 BOOL bInCntnr )
1100 SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
1102 const SwFmtCntnt& rFlyCntnt = rFrmFmt.GetCntnt();
1103 ULONG nStt = rFlyCntnt.GetCntntIdx()->GetIndex()+1;
1104 SwOLENode *pOLENd = rHTMLWrt.pDoc->GetNodes()[ nStt ]->GetOLENode();
1106 ASSERT( pOLENd, "OLE-Node erwartet" );
1107 if( !pOLENd )
1108 return rWrt;
1110 SwOLEObj &rObj = pOLENd->GetOLEObj();
1112 uno::Reference < embed::XEmbeddedObject > xObj( rObj.GetOleRef() );
1113 if ( !svt::EmbeddedObjectRef::TryRunningState( xObj ) )
1114 return rWrt;
1116 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
1117 BOOL bHiddenEmbed = FALSE;
1119 if( !xSet.is() )
1121 DBG_ERROR("Unknown Object" );
1122 return rWrt;
1125 ByteString aEndTags;
1126 ULONG nFrmOpts;
1128 // wenn meoglich vor dem "Objekt" einen Zeilen-Umbruch ausgeben
1129 if( rHTMLWrt.bLFPossible )
1130 rHTMLWrt.OutNewLine( TRUE );
1132 if( rFrmFmt.GetName().Len() )
1133 rHTMLWrt.OutImplicitMark( rFrmFmt.GetName(),
1134 pMarkToOLE );
1135 uno::Any aAny;
1136 SvGlobalName aGlobName( xObj->getClassID() );
1137 ByteString sOut('<');
1138 if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1140 // erstmal das Plug-spezifische
1141 sOut += OOO_STRING_SVTOOLS_HTML_embed;
1143 ::rtl::OUString aStr;
1144 String aURL;
1145 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("PluginURL" ) );
1146 if( (aAny >>= aStr) && aStr.getLength() )
1148 aURL = URIHelper::simpleNormalizedMakeRelative( rWrt.GetBaseURL(),
1149 aStr);
1152 if( aURL.Len() )
1154 ((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_src) += "=\"";
1155 rWrt.Strm() << sOut.GetBuffer();
1156 HTMLOutFuncs::Out_String( rWrt.Strm(), aURL, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1157 sOut = '\"';
1160 ::rtl::OUString aType;
1161 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("PluginMimeType" ) );
1162 if( (aAny >>= aType) && aType.getLength() )
1164 ((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_type) += "=\"";
1165 rWrt.Strm() << sOut.GetBuffer();
1166 HTMLOutFuncs::Out_String( rWrt.Strm(), aType, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1167 sOut = '\"';
1170 if( FLY_AT_CNTNT == rFrmFmt.GetAnchor().GetAnchorId() &&
1171 SURROUND_THROUGHT == rFrmFmt.GetSurround().GetSurround() )
1173 // Das Plugin ist HIDDEN
1174 (sOut += ' ') += OOO_STRING_SW_HTML_O_Hidden;
1175 nFrmOpts = HTML_FRMOPTS_HIDDEN_EMBED;
1176 bHiddenEmbed = TRUE;
1178 else
1180 nFrmOpts = bInCntnr ? HTML_FRMOPTS_EMBED_CNTNR
1181 : HTML_FRMOPTS_EMBED;
1184 else if( aGlobName == SvGlobalName( SO3_APPLET_CLASSID ) )
1186 // oder das Applet-Spezifische
1188 sOut += OOO_STRING_SVTOOLS_HTML_applet;
1190 // CODEBASE
1191 ::rtl::OUString aCd;
1192 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCodeBase" ) );
1193 if( (aAny >>= aCd) && aCd.getLength() )
1195 String sCodeBase( URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aCd) );
1196 if( sCodeBase.Len() )
1198 ((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_codebase) += "=\"";
1199 rWrt.Strm() << sOut.GetBuffer();
1200 HTMLOutFuncs::Out_String( rWrt.Strm(), sCodeBase, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1201 sOut = '\"';
1205 // CODE
1206 ::rtl::OUString aClass;
1207 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCode" ) );
1208 aAny >>= aClass;
1209 ((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_code) += "=\"";
1210 rWrt.Strm() << sOut.GetBuffer();
1211 HTMLOutFuncs::Out_String( rWrt.Strm(), aClass, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1212 sOut = '\"';
1214 // NAME
1215 ::rtl::OUString aAppletName;
1216 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletName" ) );
1217 aAny >>= aAppletName;
1218 if( aAppletName.getLength() )
1220 ((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_name) += "=\"";
1221 rWrt.Strm() << sOut.GetBuffer();
1222 HTMLOutFuncs::Out_String( rWrt.Strm(), aAppletName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1223 sOut = '\"';
1226 sal_Bool bScript = sal_False;
1227 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletIsScript" ) );
1228 aAny >>= bScript;
1229 if( bScript )
1230 (sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_mayscript;
1232 nFrmOpts = bInCntnr ? HTML_FRMOPTS_APPLET_CNTNR
1233 : HTML_FRMOPTS_APPLET;
1235 else
1237 // oder das Flating-Frame spezifische
1239 sOut += OOO_STRING_SVTOOLS_HTML_iframe;
1240 rWrt.Strm() << sOut.GetBuffer();
1242 SfxFrameHTMLWriter::Out_FrameDescriptor( rWrt.Strm(), rWrt.GetBaseURL(),
1243 xSet,
1244 rHTMLWrt.eDestEnc,
1245 &rHTMLWrt.aNonConvertableCharacters );
1246 sOut.Erase();
1248 nFrmOpts = bInCntnr ? HTML_FRMOPTS_IFRAME_CNTNR
1249 : HTML_FRMOPTS_IFRAME;
1252 rWrt.Strm() << sOut.GetBuffer();
1254 // ALT, WIDTH, HEIGHT, HSPACE, VSPACE, ALIGN
1255 if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
1256 nFrmOpts |= HTML_FRMOPTS_OLE_CSS1;
1257 rHTMLWrt.OutFrmFmtOptions( rFrmFmt, pOLENd->GetTitle(),
1258 aEndTags, nFrmOpts );
1259 if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
1260 rHTMLWrt.OutCSS1_FrmFmtOptions( rFrmFmt, nFrmOpts );
1262 if( aGlobName == SvGlobalName( SO3_APPLET_CLASSID ) )
1264 // fuer Applets die Parameter als eigene Tags ausgeben
1265 // und ein </APPLET> schreiben
1267 uno::Sequence < beans::PropertyValue > aProps;
1268 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCommands" ) );
1269 aAny >>= aProps;
1271 SvCommandList aCommands;
1272 aCommands.FillFromSequence( aProps );
1273 SvULongs aParams;
1274 ULONG i = aCommands.Count();
1275 while( i > 0 )
1277 const SvCommand& rCommand = aCommands[ --i ];
1278 const String& rName = rCommand.GetCommand();
1279 USHORT nType = SwApplet_Impl::GetOptionType( rName, TRUE );
1280 if( SWHTML_OPTTYPE_TAG == nType )
1282 const String& rValue = rCommand.GetArgument();
1283 rWrt.Strm() << ' ';
1284 HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1285 rWrt.Strm() << "=\"";
1286 HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters ) << '\"';
1288 else if( SWHTML_OPTTYPE_PARAM == nType )
1290 aParams.Insert( i, aParams.Count() );
1294 rHTMLWrt.Strm() << '>';
1296 rHTMLWrt.IncIndentLevel(); // Inhalt von Applet einruecken
1298 USHORT ii = aParams.Count();
1299 while( ii > 0 )
1301 const SvCommand& rCommand = aCommands[ aParams[--ii] ];
1302 const String& rName = rCommand.GetCommand();
1303 const String& rValue = rCommand.GetArgument();
1304 rHTMLWrt.OutNewLine();
1305 ((((sOut = '<') += OOO_STRING_SVTOOLS_HTML_param) += ' ') += OOO_STRING_SVTOOLS_HTML_O_name)
1306 += "=\"";
1307 rWrt.Strm() << sOut.GetBuffer();
1308 HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1309 ((sOut = "\" ") += OOO_STRING_SVTOOLS_HTML_O_value) += "=\"";
1310 rWrt.Strm() << sOut.GetBuffer();
1311 HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters ) << "\">";
1314 rHTMLWrt.DecIndentLevel(); // Inhalt von Applet einruecken
1315 if( aCommands.Count() )
1316 rHTMLWrt.OutNewLine();
1317 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_applet, FALSE );
1319 else
1320 if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1322 // fuer Plugins die Paramater als Optionen schreiben
1324 uno::Sequence < beans::PropertyValue > aProps;
1325 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("PluginCommands" ) );
1326 aAny >>= aProps;
1328 SvCommandList aCommands;
1329 aCommands.FillFromSequence( aProps );
1330 for( ULONG i=0; i<aCommands.Count(); i++ )
1332 const SvCommand& rCommand = aCommands[ i ];
1333 const String& rName = rCommand.GetCommand();
1335 if( SwApplet_Impl::GetOptionType( rName, FALSE ) == SWHTML_OPTTYPE_TAG )
1337 const String& rValue = rCommand.GetArgument();
1338 rWrt.Strm() << ' ';
1339 HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1340 rWrt.Strm() << "=\"";
1341 HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters ) << '\"';
1344 rHTMLWrt.Strm() << '>';
1346 else
1348 // und fuer Floating-Frames einfach noch ein </IFRAME>
1349 // ausgeben
1351 rHTMLWrt.Strm() << '>';
1352 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_iframe, FALSE );
1355 if( aEndTags.Len() )
1356 rWrt.Strm() << aEndTags.GetBuffer();
1358 return rWrt;
1361 Writer& OutHTML_FrmFmtOLENodeGrf( Writer& rWrt, const SwFrmFmt& rFrmFmt,
1362 BOOL bInCntnr )
1364 SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
1366 const SwFmtCntnt& rFlyCntnt = rFrmFmt.GetCntnt();
1367 ULONG nStt = rFlyCntnt.GetCntntIdx()->GetIndex()+1;
1368 SwOLENode *pOLENd = rHTMLWrt.pDoc->GetNodes()[ nStt ]->GetOLENode();
1370 ASSERT( pOLENd, "OLE-Node erwartet" );
1371 if( !pOLENd )
1372 return rWrt;
1374 // Inhalt des Nodes als Grafik speichern
1375 //uno::Reference < embed::XEmbeddedObject > xObj = pOLENd->GetOLEObj().GetOleRef();
1376 //GDIMetaFile aPic;
1377 //if( xObj.is() && xRef->GetGDIMetaFile( aPic ).GetActionCount() )
1379 //Graphic aGrf( aPic );
1380 Graphic aGrf( *pOLENd->GetGraphic() );
1381 String aGrfNm;
1382 const String* pTempFileName = rHTMLWrt.GetOrigFileName();
1383 if(pTempFileName)
1384 aGrfNm = *pTempFileName;
1386 USHORT nErr = XOutBitmap::WriteGraphic( aGrf, aGrfNm,
1387 String::CreateFromAscii("JPG"),
1388 (XOUTBMP_USE_GIF_IF_POSSIBLE |
1389 XOUTBMP_USE_NATIVE_IF_POSSIBLE) );
1390 if( nErr ) // fehlerhaft, da ist nichts auszugeben
1392 rHTMLWrt.nWarn = WARN_SWG_POOR_LOAD | WARN_SW_WRITE_BASE;
1393 return rWrt;
1395 aGrfNm = URIHelper::SmartRel2Abs(
1396 INetURLObject(rWrt.GetBaseURL()), aGrfNm,
1397 URIHelper::GetMaybeFileHdl() );
1398 ULONG nFlags = bInCntnr ? HTML_FRMOPTS_GENIMG_CNTNR
1399 : HTML_FRMOPTS_GENIMG;
1400 OutHTML_Image( rWrt, rFrmFmt, aGrfNm,
1401 pOLENd->GetTitle(), pOLENd->GetTwipSize(),
1402 nFlags, pMarkToOLE );
1405 return rWrt;