1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 #include <com/sun/star/embed/EmbedStates.hpp>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28
29 #include "hintids.hxx"
30 #include <svl/urihelper.hxx>
31 #define _SVSTDARR_ULONGS
32 #include <svl/svstdarr.hxx>
33 #include <vcl/svapp.hxx>
34 #include <sfx2/frmhtml.hxx>
35 #include <sfx2/frmhtmlw.hxx>
36 #include <vcl/wrkwin.hxx>
37 #include <sot/storage.hxx>
38 #include <svx/xoutbmp.hxx>
39 #include <editeng/ulspitem.hxx>
40 #include <editeng/lrspitem.hxx>
41 #include <svtools/htmlkywd.hxx>
42 #include <svtools/htmltokn.h>
43 #include <SwAppletImpl.hxx>
44 #include <fmtornt.hxx>
45 #include <fmtfsize.hxx>
46 #include <fmtsrnd.hxx>
47 #include <fmtanchr.hxx>
48 #include <fmtcntnt.hxx>
49 #include <frmfmt.hxx>
50
51 #include <svl/ownlist.hxx>
52 #include "pam.hxx"
53 #include "doc.hxx"
54 #include "ndtxt.hxx"
55 #include "swerror.h"
56 #include "ndole.hxx"
57 #include "swtable.hxx"
58 #include "swhtml.hxx"
59 #include "wrthtml.hxx"
60 #include "htmlfly.hxx"
61 #include "swcss1.hxx"
62 #include <com/sun/star/embed/XClassifiedObject.hpp>
63 #include <com/sun/star/embed/EmbedStates.hpp>
64 #include <comphelper/embeddedobjectcontainer.hxx>
65 #include <sot/clsids.hxx>
66
67 using namespace com::sun::star;
68
69 #define HTML_DFLT_EMBED_WIDTH ((MM50*5)/2)
70 #define HTML_DFLT_EMBED_HEIGHT ((MM50*5)/2)
71
72 #define HTML_DFLT_APPLET_WIDTH ((MM50*5)/2)
73 #define HTML_DFLT_APPLET_HEIGHT ((MM50*5)/2)
74
75 namespace {
76
77 static char const sHTML_O_Hidden_False[] = "sal_False";
78
79 }
80
81 const sal_uLong HTML_FRMOPTS_EMBED_ALL =
82 HTML_FRMOPT_ALT |
83 HTML_FRMOPT_SIZE |
84 HTML_FRMOPT_NAME;
85 const sal_uLong HTML_FRMOPTS_EMBED_CNTNR =
86 HTML_FRMOPTS_EMBED_ALL |
87 HTML_FRMOPT_ABSSIZE;
88 const sal_uLong HTML_FRMOPTS_EMBED =
89 HTML_FRMOPTS_EMBED_ALL |
90 HTML_FRMOPT_ALIGN |
91 HTML_FRMOPT_SPACE |
92 HTML_FRMOPT_BRCLEAR |
93 HTML_FRMOPT_NAME;
94 const sal_uLong HTML_FRMOPTS_HIDDEN_EMBED =
95 HTML_FRMOPT_ALT |
96 HTML_FRMOPT_NAME;
97
98 const sal_uLong HTML_FRMOPTS_APPLET_ALL =
99 HTML_FRMOPT_ALT |
100 HTML_FRMOPT_SIZE;
101 const sal_uLong HTML_FRMOPTS_APPLET_CNTNR =
102 HTML_FRMOPTS_APPLET_ALL |
103 HTML_FRMOPT_ABSSIZE;
104 const sal_uLong HTML_FRMOPTS_APPLET =
105 HTML_FRMOPTS_APPLET_ALL |
106 HTML_FRMOPT_ALIGN |
107 HTML_FRMOPT_SPACE |
108 HTML_FRMOPT_BRCLEAR;
109
110 const sal_uLong HTML_FRMOPTS_IFRAME_ALL =
111 HTML_FRMOPT_ALT |
112 HTML_FRMOPT_SIZE;
113 const sal_uLong HTML_FRMOPTS_IFRAME_CNTNR =
114 HTML_FRMOPTS_IFRAME_ALL |
115 HTML_FRMOPT_ABSSIZE;
116 const sal_uLong HTML_FRMOPTS_IFRAME =
117 HTML_FRMOPTS_IFRAME_ALL |
118 HTML_FRMOPT_ALIGN |
119 HTML_FRMOPT_SPACE |
120 HTML_FRMOPT_BORDER |
121 HTML_FRMOPT_BRCLEAR;
122
123 const sal_uLong HTML_FRMOPTS_OLE_CSS1 =
124 HTML_FRMOPT_S_ALIGN |
125 HTML_FRMOPT_S_SPACE;
126
127 /* */
128
SetFixSize(const Size & rPixSize,const Size & rTwipDfltSize,sal_Bool bPrcWidth,sal_Bool bPrcHeight,SfxItemSet &,SvxCSS1PropertyInfo & rCSS1PropInfo,SfxItemSet & rFlyItemSet)129 void SwHTMLParser::SetFixSize( const Size& rPixSize,
130 const Size& rTwipDfltSize,
131 sal_Bool bPrcWidth, sal_Bool bPrcHeight,
132 SfxItemSet& /*rCSS1ItemSet*/,
133 SvxCSS1PropertyInfo& rCSS1PropInfo,
134 SfxItemSet& rFlyItemSet )
135 {
136 // absolulte Groessenangaben in Twip umrechnen
137 sal_uInt8 nPrcWidth = 0, nPrcHeight = 0;
138 Size aTwipSz( bPrcWidth || USHRT_MAX==rPixSize.Width() ? 0 : rPixSize.Width(),
139 bPrcHeight || USHRT_MAX==rPixSize.Height() ? 0 : rPixSize.Height() );
140 if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
141 {
142 aTwipSz =
143 Application::GetDefaultDevice()->PixelToLogic( aTwipSz,
144 MapMode(MAP_TWIP) );
145 }
146
147 // die Breite bearbeiten
148 if( SVX_CSS1_LTYPE_PERCENTAGE == rCSS1PropInfo.eWidthType )
149 {
150 nPrcWidth = (sal_uInt8)rCSS1PropInfo.nWidth;
151 aTwipSz.Width() = rTwipDfltSize.Width();
152 }
153 else if( SVX_CSS1_LTYPE_TWIP== rCSS1PropInfo.eWidthType )
154 {
155 aTwipSz.Width() = rCSS1PropInfo.nWidth;
156 }
157 else if( bPrcWidth && rPixSize.Width() )
158 {
159 nPrcWidth = (sal_uInt8)rPixSize.Width();
160 if( nPrcWidth > 100 )
161 nPrcWidth = 100;
162
163 aTwipSz.Width() = rTwipDfltSize.Width();
164 }
165 else if( USHRT_MAX==rPixSize.Width() )
166 {
167 aTwipSz.Width() = rTwipDfltSize.Width();
168 }
169 if( aTwipSz.Width() < MINFLY )
170 {
171 aTwipSz.Width() = MINFLY;
172 }
173
174 // Hoehe bearbeiten
175 if( SVX_CSS1_LTYPE_PERCENTAGE == rCSS1PropInfo.eHeightType )
176 {
177 nPrcHeight = (sal_uInt8)rCSS1PropInfo.nHeight;
178 aTwipSz.Height() = rTwipDfltSize.Height();
179 }
180 else if( SVX_CSS1_LTYPE_TWIP== rCSS1PropInfo.eHeightType )
181 {
182 aTwipSz.Height() = rCSS1PropInfo.nHeight;
183 }
184 else if( bPrcHeight && rPixSize.Height() )
185 {
186 nPrcHeight = (sal_uInt8)rPixSize.Height();
187 if( nPrcHeight > 100 )
188 nPrcHeight = 100;
189
190 aTwipSz.Height() = rTwipDfltSize.Height();
191 }
192 else if( USHRT_MAX==rPixSize.Height() )
193 {
194 aTwipSz.Height() = rTwipDfltSize.Height();
195 }
196 if( aTwipSz.Height() < MINFLY )
197 {
198 aTwipSz.Height() = MINFLY;
199 }
200
201 // Size setzen
202 SwFmtFrmSize aFrmSize( ATT_FIX_SIZE, aTwipSz.Width(), aTwipSz.Height() );
203 aFrmSize.SetWidthPercent( nPrcWidth );
204 aFrmSize.SetHeightPercent( nPrcHeight );
205 rFlyItemSet.Put( aFrmSize );
206 }
207
SetSpace(const Size & rPixSpace,SfxItemSet & rCSS1ItemSet,SvxCSS1PropertyInfo & rCSS1PropInfo,SfxItemSet & rFlyItemSet)208 void SwHTMLParser::SetSpace( const Size& rPixSpace,
209 SfxItemSet& rCSS1ItemSet,
210 SvxCSS1PropertyInfo& rCSS1PropInfo,
211 SfxItemSet& rFlyItemSet )
212 {
213 sal_Int32 nLeftSpace = 0, nRightSpace = 0;
214 sal_uInt16 nUpperSpace = 0, nLowerSpace = 0;
215 if( (rPixSpace.Width() || rPixSpace.Height()) && Application::GetDefaultDevice() )
216 {
217 Size aTwipSpc( rPixSpace.Width(), rPixSpace.Height() );
218 aTwipSpc =
219 Application::GetDefaultDevice()->PixelToLogic( aTwipSpc,
220 MapMode(MAP_TWIP) );
221 nLeftSpace = nRightSpace = aTwipSpc.Width();
222 nUpperSpace = nLowerSpace = (sal_uInt16)aTwipSpc.Height();
223 }
224
225 // linken/rechten Rand setzen
226 const SfxPoolItem *pItem;
227 if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_LR_SPACE, sal_True, &pItem ) )
228 {
229 // Ggf. den Erstzeilen-Einzug noch plaetten
230 const SvxLRSpaceItem *pLRItem = (const SvxLRSpaceItem *)pItem;
231 SvxLRSpaceItem aLRItem( *pLRItem );
232 aLRItem.SetTxtFirstLineOfst( 0 );
233 if( rCSS1PropInfo.bLeftMargin )
234 {
235 nLeftSpace = aLRItem.GetLeft();
236 rCSS1PropInfo.bLeftMargin = sal_False;
237 }
238 if( rCSS1PropInfo.bRightMargin )
239 {
240 nRightSpace = aLRItem.GetRight();
241 rCSS1PropInfo.bRightMargin = sal_False;
242 }
243 rCSS1ItemSet.ClearItem( RES_LR_SPACE );
244 }
245 if( nLeftSpace > 0 || nRightSpace > 0 )
246 {
247 SvxLRSpaceItem aLRItem( RES_LR_SPACE );
248 aLRItem.SetLeft( nLeftSpace > 0 ? nLeftSpace : 0 );
249 aLRItem.SetRight( nRightSpace > 0 ? nRightSpace : 0 );
250 rFlyItemSet.Put( aLRItem );
251 if( nLeftSpace )
252 {
253 const SwFmtHoriOrient& rHoriOri =
254 (const SwFmtHoriOrient&)rFlyItemSet.Get( RES_HORI_ORIENT );
255 if( text::HoriOrientation::NONE == rHoriOri.GetHoriOrient() )
256 {
257 SwFmtHoriOrient aHoriOri( rHoriOri );
258 aHoriOri.SetPos( aHoriOri.GetPos() + nLeftSpace );
259 rFlyItemSet.Put( aHoriOri );
260 }
261 }
262 }
263
264 // oberen/unteren Rand setzen
265 if( SFX_ITEM_SET==rCSS1ItemSet.GetItemState( RES_UL_SPACE, sal_True, &pItem ) )
266 {
267 // Ggf. den Erstzeilen-Einzug noch plaetten
268 const SvxULSpaceItem *pULItem = (const SvxULSpaceItem *)pItem;
269 if( rCSS1PropInfo.bTopMargin )
270 {
271 nUpperSpace = pULItem->GetUpper();
272 rCSS1PropInfo.bTopMargin = sal_False;
273 }
274 if( rCSS1PropInfo.bBottomMargin )
275 {
276 nLowerSpace = pULItem->GetLower();
277 rCSS1PropInfo.bBottomMargin = sal_False;
278 }
279 rCSS1ItemSet.ClearItem( RES_UL_SPACE );
280 }
281 if( nUpperSpace || nLowerSpace )
282 {
283 SvxULSpaceItem aULItem( RES_UL_SPACE );
284 aULItem.SetUpper( nUpperSpace );
285 aULItem.SetLower( nLowerSpace );
286 rFlyItemSet.Put( aULItem );
287 if( nUpperSpace )
288 {
289 const SwFmtVertOrient& rVertOri =
290 (const SwFmtVertOrient&)rFlyItemSet.Get( RES_VERT_ORIENT );
291 if( text::VertOrientation::NONE == rVertOri.GetVertOrient() )
292 {
293 SwFmtVertOrient aVertOri( rVertOri );
294 aVertOri.SetPos( aVertOri.GetPos() + nUpperSpace );
295 rFlyItemSet.Put( aVertOri );
296 }
297 }
298 }
299 }
300
301 /* */
302
InsertEmbed()303 void SwHTMLParser::InsertEmbed()
304 {
305 String aURL, aType, aName, aAlt, aId, aStyle, aClass;
306 Size aSize( USHRT_MAX, USHRT_MAX );
307 Size aSpace( USHRT_MAX, USHRT_MAX );
308 sal_Bool bPrcWidth = sal_False, bPrcHeight = sal_False, bHidden = sal_False;
309 sal_Int16 eVertOri = text::VertOrientation::NONE;
310 sal_Int16 eHoriOri = text::HoriOrientation::NONE;
311 SvCommandList aCmdLst;
312 const HTMLOptions *pHTMLOptions = GetOptions();
313
314 // Die Optionen werden vorwaerts gelesen, weil die Plugins sie in
315 // dieser Reihenfolge erwarten. Trotzdem darf immer nur der erste
316 // Wert einer Option beruecksichtigt werden.
317 sal_uInt16 nArrLen = pHTMLOptions->Count();
318 for( sal_uInt16 i=0; i<nArrLen; i++ )
319 {
320 const HTMLOption *pOption = (*pHTMLOptions)[i];
321 switch( pOption->GetToken() )
322 {
323 case HTML_O_ID:
324 aId = pOption->GetString();
325 break;
326 case HTML_O_STYLE:
327 aStyle = pOption->GetString();
328 break;
329 case HTML_O_CLASS:
330 aClass = pOption->GetString();
331 break;
332 case HTML_O_NAME:
333 aName = pOption->GetString();
334 break;
335 case HTML_O_SRC:
336 if( !aURL.Len() )
337 aURL = pOption->GetString();
338 break;
339 case HTML_O_ALT:
340 aAlt = pOption->GetString();
341 break;
342 case HTML_O_TYPE:
343 if( !aType.Len() )
344 aType = pOption->GetString();
345 break;
346 case HTML_O_ALIGN:
347 if( eVertOri==text::VertOrientation::NONE && eHoriOri==text::HoriOrientation::NONE )
348 {
349 eVertOri = pOption->GetEnum( aHTMLImgVAlignTable, eVertOri );
350 eHoriOri = pOption->GetEnum( aHTMLImgHAlignTable, eHoriOri );
351 }
352 break;
353 case HTML_O_WIDTH:
354 if( USHRT_MAX==aSize.Width() )
355 {
356 bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
357 aSize.Width() = (long)pOption->GetNumber();
358 }
359 break;
360 case HTML_O_HEIGHT:
361 if( USHRT_MAX==aSize.Height() )
362 {
363 bPrcHeight = (pOption->GetString().Search('%') != STRING_NOTFOUND);
364 aSize.Height() = (long)pOption->GetNumber();
365 }
366 break;
367 case HTML_O_HSPACE:
368 if( USHRT_MAX==aSpace.Width() )
369 aSpace.Width() = (long)pOption->GetNumber();
370 break;
371 case HTML_O_VSPACE:
372 if( USHRT_MAX==aSpace.Height() )
373 aSpace.Height() = (long)pOption->GetNumber();
374 break;
375 case HTML_O_UNKNOWN:
376 if( pOption->GetTokenString().EqualsIgnoreCaseAscii( OOO_STRING_SW_HTML_O_Hidden ) )
377 bHidden =
378 !pOption->GetString().EqualsIgnoreCaseAscii( sHTML_O_Hidden_False );
379 break;
380 }
381
382 // Es werden alle Parameter an das Plugin weitergereicht
383 aCmdLst.Append( pOption->GetTokenString(), pOption->GetString() );
384 }
385
386 SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
387 SvxCSS1PropertyInfo aPropInfo;
388 if( HasStyleOptions( aStyle, aId, aClass ) )
389 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
390
391 // Die Default-Werte umsetzen (ausser Hoehe/Breite, das macht schon
392 // SetFrmSize() fuer uns)
393 if( eVertOri==text::VertOrientation::NONE && eHoriOri==text::HoriOrientation::NONE )
394 eVertOri = text::VertOrientation::TOP;
395 if( USHRT_MAX==aSpace.Width() )
396 aSpace.Width() = 0;
397 if( USHRT_MAX==aSpace.Height() )
398 aSpace.Height() = 0;
399 if( bHidden )
400 {
401 // Size (0,0) wird in SetFrmSize auf (MINFLY, MINFLY) umgebogen
402 aSize.Width() = 0; aSize.Height() = 0;
403 aSpace.Width() = 0; aSpace.Height() = 0;
404 bPrcWidth = bPrcHeight = sal_False;
405 }
406
407 // die URL aufbereiten
408 INetURLObject aURLObj;
409 bool bHasURL = aURL.Len() &&
410 aURLObj.SetURL(
411 URIHelper::SmartRel2Abs(
412 INetURLObject(sBaseURL), aURL,
413 URIHelper::GetMaybeFileHdl()) );
414
415 // #109761# do not insert plugin if it has neither URL nor type
416 bool bHasType = aType.Len() != 0;
417 if( !bHasURL && !bHasType )
418 return;
419
420 // das Plugin anlegen
421 comphelper::EmbeddedObjectContainer aCnt;
422 ::rtl::OUString aObjName;
423 uno::Reference < embed::XEmbeddedObject > xObj = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aObjName );
424 if ( svt::EmbeddedObjectRef::TryRunningState( xObj ) )
425 {
426 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
427 if ( xSet.is() )
428 {
429 if( bHasURL )
430 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginURL"),
431 uno::makeAny( ::rtl::OUString( aURL ) ) );
432 if( bHasType )
433 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginMimeType"),
434 uno::makeAny( ::rtl::OUString( aType ) ) );
435
436 uno::Sequence < beans::PropertyValue > aProps;
437 aCmdLst.FillSequence( aProps );
438 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginCommands"), uno::makeAny( aProps ) );
439
440 // TODO/LATER: EnableSetModified?!
441 //pPlugin->EnableSetModified( sal_True );
442 }
443 }
444
445 SfxItemSet aFrmSet( pDoc->GetAttrPool(),
446 RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
447 if( !IsNewDoc() )
448 Reader::ResetFrmFmtAttrs( aFrmSet );
449
450 // den Anker setzen
451 if( !bHidden )
452 {
453 SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, aFrmSet );
454 }
455 else
456 {
457 SwFmtAnchor aAnchor( FLY_AT_PARA );
458 aAnchor.SetAnchor( pPam->GetPoint() );
459 aFrmSet.Put( aAnchor );
460 aFrmSet.Put( SwFmtHoriOrient( 0, text::HoriOrientation::LEFT, text::RelOrientation::FRAME) );
461 aFrmSet.Put( SwFmtSurround( SURROUND_THROUGHT ) );
462 aFrmSet.Put( SwFmtVertOrient( 0, text::VertOrientation::TOP, text::RelOrientation::PRINT_AREA ) );
463 }
464
465 // und noch die Groesse des Rahmens
466 Size aDfltSz( HTML_DFLT_EMBED_WIDTH, HTML_DFLT_EMBED_HEIGHT );
467 SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
468 aFrmSet );
469 SetSpace( aSpace, aItemSet, aPropInfo, aFrmSet );
470
471 // und in das Dok einfuegen
472 SwFrmFmt* pFlyFmt =
473 pDoc->Insert( *pPam, ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), &aFrmSet, NULL, NULL );
474
475 // Namen am FrmFmt setzen
476 if( aName.Len() )
477 pFlyFmt->SetName( aName );
478
479 // den alternativen Text setzen
480 SwNoTxtNode *pNoTxtNd =
481 pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
482 ->GetIndex()+1 ]->GetNoTxtNode();
483 pNoTxtNd->SetTitle( aAlt );
484
485 // Ggf Frames anlegen und auto-geb. Rahmen registrieren
486 if( !bHidden )
487 {
488 // HIDDEN-Plugins sollen absatzgebunden bleiben. Da RegisterFlyFrm
489 // absatzgebundene Rahmen mit DUrchlauf in am Zeichen gebundene
490 // Rahmen umwandelt, muessen die Frames hier von Hand angelegt werden.
491 RegisterFlyFrm( pFlyFmt );
492 }
493 }
494
495 /* */
496
497 #ifdef SOLAR_JAVA
NewObject()498 void SwHTMLParser::NewObject()
499 {
500 String aClassID, aName, aStandBy, aId, aStyle, aClass;
501 Size aSize( USHRT_MAX, USHRT_MAX );
502 Size aSpace( 0, 0 );
503 sal_Int16 eVertOri = text::VertOrientation::TOP;
504 sal_Int16 eHoriOri = text::HoriOrientation::NONE;
505
506 sal_Bool bPrcWidth = sal_False, bPrcHeight = sal_False,
507 bDeclare = sal_False;
508 // Eine neue Command-List anlegen
509 if( pAppletImpl )
510 delete pAppletImpl;
511 pAppletImpl = new SwApplet_Impl( pDoc->GetAttrPool(),
512 RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
513
514 const HTMLOptions *pHTMLOptions = GetOptions();
515 for( sal_uInt16 i = pHTMLOptions->Count(); i; )
516 {
517 const HTMLOption *pOption = (*pHTMLOptions)[--i];
518 switch( pOption->GetToken() )
519 {
520 case HTML_O_ID:
521 aId = pOption->GetString();
522 break;
523 case HTML_O_STYLE:
524 aStyle = pOption->GetString();
525 break;
526 case HTML_O_CLASS:
527 aClass = pOption->GetString();
528 break;
529 case HTML_O_DECLARE:
530 bDeclare = sal_True;
531 break;
532 case HTML_O_CLASSID:
533 aClassID = pOption->GetString();
534 break;
535 case HTML_O_CODEBASE:
536 break;
537 case HTML_O_DATA:
538 break;
539 case HTML_O_TYPE:
540 break;
541 case HTML_O_CODETYPE:
542 break;
543 case HTML_O_ARCHIVE:
544 case HTML_O_UNKNOWN:
545 break;
546 case HTML_O_STANDBY:
547 aStandBy = pOption->GetString();
548 break;
549 case HTML_O_WIDTH:
550 bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
551 aSize.Width() = (long)pOption->GetNumber();
552 break;
553 case HTML_O_HEIGHT:
554 bPrcHeight = (pOption->GetString().Search('%') != STRING_NOTFOUND);
555 aSize.Height() = (long)pOption->GetNumber();
556 break;
557 case HTML_O_ALIGN:
558 eVertOri = pOption->GetEnum( aHTMLImgVAlignTable, eVertOri );
559 eHoriOri = pOption->GetEnum( aHTMLImgHAlignTable, eHoriOri );
560 break;
561 case HTML_O_USEMAP:
562 break;
563 case HTML_O_NAME:
564 aName = pOption->GetString();
565 break;
566 case HTML_O_HSPACE:
567 aSpace.Width() = (long)pOption->GetNumber();
568 break;
569 case HTML_O_VSPACE:
570 aSpace.Height() = (long)pOption->GetNumber();
571 break;
572 case HTML_O_BORDER:
573 break;
574
575 case HTML_O_SDONCLICK:
576 case HTML_O_ONCLICK:
577 case HTML_O_SDONMOUSEOVER:
578 case HTML_O_ONMOUSEOVER:
579 case HTML_O_SDONMOUSEOUT:
580 case HTML_O_ONMOUSEOUT:
581 break;
582 }
583 // Es werden alle Parameter auch an das Applet weitergereicht
584 pAppletImpl->AppendParam( pOption->GetTokenString(),
585 pOption->GetString() );
586
587 }
588
589 // Objects that are declared only are not evaluated. Moreover, only
590 // Java applets are supported.
591 sal_Bool bIsApplet = sal_False;;
592
593 if( !bDeclare && aClassID.Len() == 42 &&
594 aClassID.EqualsAscii( "clsid:", 0, 6 ) )
595 {
596 aClassID.Erase( 0, 6 );
597 SvGlobalName aCID;
598 if( aCID.MakeId( aClassID ) )
599 {
600 SvGlobalName aJavaCID( 0x8AD9C840UL, 0x044EU, 0x11D1U, 0xB3U, 0xE9U,
601 0x00U, 0x80U, 0x5FU, 0x49U, 0x9DU, 0x93U );
602
603 bIsApplet = aJavaCID == aCID;
604 }
605 }
606
607 if( !bIsApplet )
608 {
609 delete pAppletImpl;
610 pAppletImpl = 0;
611 return;
612 }
613
614 pAppletImpl->SetAltText( aStandBy );
615
616 SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
617 SvxCSS1PropertyInfo aPropInfo;
618 if( HasStyleOptions( aStyle, aId, aClass ) )
619 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
620
621 SfxItemSet& rFrmSet = pAppletImpl->GetItemSet();
622 if( !IsNewDoc() )
623 Reader::ResetFrmFmtAttrs( rFrmSet );
624
625 // den Anker und die Ausrichtung setzen
626 SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, rFrmSet );
627
628 // und noch die Groesse des Rahmens
629 Size aDfltSz( HTML_DFLT_APPLET_WIDTH, HTML_DFLT_APPLET_HEIGHT );
630 SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
631 rFrmSet );
632 SetSpace( aSpace, aItemSet, aPropInfo, rFrmSet );
633 }
634 #endif
635
EndObject()636 void SwHTMLParser::EndObject()
637 {
638 #ifdef SOLAR_JAVA
639 if( !pAppletImpl )
640 return;
641 if( pAppletImpl->CreateApplet( sBaseURL ) )
642 {
643 pAppletImpl->FinishApplet();
644
645 // und in das Dok einfuegen
646 SwFrmFmt* pFlyFmt =
647 pDoc->Insert( *pPam,
648 ::svt::EmbeddedObjectRef( pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
649 &pAppletImpl->GetItemSet(),
650 NULL,
651 NULL );
652
653 // den alternativen Namen setzen
654 SwNoTxtNode *pNoTxtNd =
655 pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
656 ->GetIndex()+1 ]->GetNoTxtNode();
657 pNoTxtNd->SetTitle( pAppletImpl->GetAltText() );
658
659 // Ggf Frames anlegen und auto-geb. Rahmen registrieren
660 RegisterFlyFrm( pFlyFmt );
661
662 delete pAppletImpl;
663 pAppletImpl = 0;
664 }
665 #endif
666 }
667
668 #ifdef SOLAR_JAVA
InsertApplet()669 void SwHTMLParser::InsertApplet()
670 {
671 String aCodeBase, aCode, aName, aAlt, aId, aStyle, aClass;
672 Size aSize( USHRT_MAX, USHRT_MAX );
673 Size aSpace( 0, 0 );
674 sal_Bool bPrcWidth = sal_False, bPrcHeight = sal_False, bMayScript = sal_False;
675 sal_Int16 eVertOri = text::VertOrientation::TOP;
676 sal_Int16 eHoriOri = text::HoriOrientation::NONE;
677
678 // Eine neue Command-List anlegen
679 if( pAppletImpl )
680 delete pAppletImpl;
681 pAppletImpl = new SwApplet_Impl( pDoc->GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
682
683 const HTMLOptions *pHTMLOptions = GetOptions();
684 for( sal_uInt16 i = pHTMLOptions->Count(); i; )
685 {
686 const HTMLOption *pOption = (*pHTMLOptions)[--i];
687 switch( pOption->GetToken() )
688 {
689 case HTML_O_ID:
690 aId = pOption->GetString();
691 break;
692 case HTML_O_STYLE:
693 aStyle = pOption->GetString();
694 break;
695 case HTML_O_CLASS:
696 aClass = pOption->GetString();
697 break;
698 case HTML_O_CODEBASE:
699 aCodeBase = pOption->GetString();
700 break;
701 case HTML_O_CODE:
702 aCode = pOption->GetString();
703 break;
704 case HTML_O_NAME:
705 aName = pOption->GetString();
706 break;
707 case HTML_O_ALT:
708 aAlt = pOption->GetString();
709 break;
710 case HTML_O_ALIGN:
711 eVertOri = pOption->GetEnum( aHTMLImgVAlignTable, eVertOri );
712 eHoriOri = pOption->GetEnum( aHTMLImgHAlignTable, eHoriOri );
713 break;
714 case HTML_O_WIDTH:
715 bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
716 aSize.Width() = (long)pOption->GetNumber();
717 break;
718 case HTML_O_HEIGHT:
719 bPrcHeight = (pOption->GetString().Search('%') != STRING_NOTFOUND);
720 aSize.Height() = (long)pOption->GetNumber();
721 break;
722 case HTML_O_HSPACE:
723 aSpace.Width() = (long)pOption->GetNumber();
724 break;
725 case HTML_O_VSPACE:
726 aSpace.Height() = (long)pOption->GetNumber();
727 break;
728 case HTML_O_MAYSCRIPT:
729 bMayScript = sal_True;
730 break;
731 }
732
733 // Es werden alle Parameter auch an das Applet weitergereicht
734 pAppletImpl->AppendParam( pOption->GetTokenString(),
735 pOption->GetString() );
736 }
737
738 if( !aCode.Len() )
739 {
740 delete pAppletImpl;
741 pAppletImpl = 0;
742 return;
743 }
744
745 if ( aCodeBase.Len() )
746 aCodeBase = INetURLObject::GetAbsURL( sBaseURL, aCodeBase );
747 pAppletImpl->CreateApplet( aCode, aName, bMayScript, aCodeBase, sBaseURL );//, aAlt );
748 pAppletImpl->SetAltText( aAlt );
749
750 SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
751 SvxCSS1PropertyInfo aPropInfo;
752 if( HasStyleOptions( aStyle, aId, aClass ) )
753 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
754
755 SfxItemSet& rFrmSet = pAppletImpl->GetItemSet();
756 if( !IsNewDoc() )
757 Reader::ResetFrmFmtAttrs( rFrmSet );
758
759 // den Anker und die Ausrichtung setzen
760 SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, rFrmSet );
761
762 // und noch die Groesse des Rahmens
763 Size aDfltSz( HTML_DFLT_APPLET_WIDTH, HTML_DFLT_APPLET_HEIGHT );
764 SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
765 rFrmSet );
766 SetSpace( aSpace, aItemSet, aPropInfo, rFrmSet );
767 }
768 #endif
769
EndApplet()770 void SwHTMLParser::EndApplet()
771 {
772 #ifdef SOLAR_JAVA
773 if( !pAppletImpl )
774 return;
775
776 pAppletImpl->FinishApplet();
777
778 // und in das Dok einfuegen
779 SwFrmFmt* pFlyFmt =
780 pDoc->Insert( *pPam,
781 ::svt::EmbeddedObjectRef( pAppletImpl->GetApplet(), embed::Aspects::MSOLE_CONTENT ),
782 &pAppletImpl->GetItemSet(),
783 NULL,
784 NULL );
785
786 // den alternativen Namen setzen
787 SwNoTxtNode *pNoTxtNd =
788 pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
789 ->GetIndex()+1 ]->GetNoTxtNode();
790 pNoTxtNd->SetTitle( pAppletImpl->GetAltText() );
791
792 // Ggf Frames anlegen und auto-geb. Rahmen registrieren
793 RegisterFlyFrm( pFlyFmt );
794
795 delete pAppletImpl;
796 pAppletImpl = 0;
797 #endif
798 }
799
InsertParam()800 void SwHTMLParser::InsertParam()
801 {
802 #ifdef SOLAR_JAVA
803 if( !pAppletImpl )
804 return;
805
806 String aName, aValue;
807
808 const HTMLOptions *pHTMLOptions = GetOptions();
809 for( sal_uInt16 i = pHTMLOptions->Count(); i; )
810 {
811 const HTMLOption *pOption = (*pHTMLOptions)[--i];
812 switch( pOption->GetToken() )
813 {
814 case HTML_O_NAME:
815 aName = pOption->GetString();
816 break;
817 case HTML_O_VALUE:
818 aValue = pOption->GetString();
819 break;
820 }
821 }
822
823 if( !aName.Len() )
824 return;
825
826 pAppletImpl->AppendParam( aName, aValue );
827 #endif
828 }
829
830
831 /* */
832
InsertFloatingFrame()833 void SwHTMLParser::InsertFloatingFrame()
834 {
835 String aAlt, aId, aStyle, aClass;
836 Size aSize( USHRT_MAX, USHRT_MAX );
837 Size aSpace( 0, 0 );
838 sal_Bool bPrcWidth = sal_False, bPrcHeight = sal_False;
839 sal_Int16 eVertOri = text::VertOrientation::TOP;
840 sal_Int16 eHoriOri = text::HoriOrientation::NONE;
841
842 const HTMLOptions *pHTMLOptions = GetOptions();
843
844 // Erstmal die Optionen f?r das Writer-Frame-Format holen
845 sal_uInt16 nArrLen = pHTMLOptions->Count();
846 for ( sal_uInt16 i=0; i<nArrLen; i++ )
847 {
848 const HTMLOption *pOption = (*pHTMLOptions)[i];
849 switch( pOption->GetToken() )
850 {
851 case HTML_O_ID:
852 aId = pOption->GetString();
853 break;
854 case HTML_O_STYLE:
855 aStyle = pOption->GetString();
856 break;
857 case HTML_O_CLASS:
858 aClass = pOption->GetString();
859 break;
860 case HTML_O_ALT:
861 aAlt = pOption->GetString();
862 break;
863 case HTML_O_ALIGN:
864 eVertOri = pOption->GetEnum( aHTMLImgVAlignTable, eVertOri );
865 eHoriOri = pOption->GetEnum( aHTMLImgHAlignTable, eHoriOri );
866 break;
867 case HTML_O_WIDTH:
868 bPrcWidth = (pOption->GetString().Search('%') != STRING_NOTFOUND);
869 aSize.Width() = (long)pOption->GetNumber();
870 break;
871 case HTML_O_HEIGHT:
872 bPrcHeight = (pOption->GetString().Search('%') != STRING_NOTFOUND);
873 aSize.Height() = (long)pOption->GetNumber();
874 break;
875 case HTML_O_HSPACE:
876 aSpace.Width() = (long)pOption->GetNumber();
877 break;
878 case HTML_O_VSPACE:
879 aSpace.Height() = (long)pOption->GetNumber();
880 break;
881 }
882 }
883
884 // und jetzt die fuer den SfxFrame
885 SfxFrameDescriptor aFrameDesc;
886
887 SfxFrameHTMLParser::ParseFrameOptions( &aFrameDesc, pHTMLOptions, sBaseURL );
888
889 // den Floating-Frame anlegen
890 comphelper::EmbeddedObjectContainer aCnt;
891 ::rtl::OUString aObjName;
892 uno::Reference < embed::XEmbeddedObject > xObj = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_IFRAME_CLASSID ).GetByteSequence(), aObjName );
893
894 //pFrame->EnableSetModified( sal_False );
895 try
896 {
897 // TODO/MBA: testing
898 if ( svt::EmbeddedObjectRef::TryRunningState( xObj ) )
899 {
900 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
901 if ( xSet.is() )
902 {
903 ::rtl::OUString aName = aFrameDesc.GetName();
904 ScrollingMode eScroll = aFrameDesc.GetScrollingMode();
905 sal_Bool bHasBorder = aFrameDesc.HasFrameBorder();
906 Size aMargin = aFrameDesc.GetMargin();
907
908 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameURL"), uno::makeAny( ::rtl::OUString( aFrameDesc.GetURL().GetMainURL( INetURLObject::NO_DECODE ) ) ) );
909 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameName"), uno::makeAny( aName ) );
910
911 if ( eScroll == ScrollingAuto )
912 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoScroll"),
913 uno::makeAny( sal_True ) );
914 else
915 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsScrollingMode"),
916 uno::makeAny( (sal_Bool) ( eScroll == ScrollingYes) ) );
917
918 //if ( aFrmDescr.IsFrameBorderSet() )
919 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsBorder"),
920 uno::makeAny( bHasBorder ) );
921 /*else
922 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoBorder"),
923 uno::makeAny( sal_True ) );*/
924
925 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginWidth"),
926 uno::makeAny( sal_Int32( aMargin.Width() ) ) );
927
928 xSet->setPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginHeight"),
929 uno::makeAny( sal_Int32( aMargin.Height() ) ) );
930 }
931 }
932 }
933 catch ( uno::Exception& )
934 {
935 }
936
937 //pFrame->EnableSetModified( sal_True );
938
939 SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
940 SvxCSS1PropertyInfo aPropInfo;
941 if( HasStyleOptions( aStyle, aId, aClass ) )
942 ParseStyleOptions( aStyle, aId, aClass, aItemSet, aPropInfo );
943
944 // den Itemset holen
945 SfxItemSet aFrmSet( pDoc->GetAttrPool(),
946 RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
947 if( !IsNewDoc() )
948 Reader::ResetFrmFmtAttrs( aFrmSet );
949
950 // den Anker und die Ausrichtung setzen
951 SetAnchorAndAdjustment( eVertOri, eHoriOri, aItemSet, aPropInfo, aFrmSet );
952
953 // und noch die Groesse des Rahmens
954 Size aDfltSz( HTML_DFLT_APPLET_WIDTH, HTML_DFLT_APPLET_HEIGHT );
955 SetFixSize( aSize, aDfltSz, bPrcWidth, bPrcHeight, aItemSet, aPropInfo,
956 aFrmSet );
957 SetSpace( aSpace, aItemSet, aPropInfo, aFrmSet );
958
959 // und in das Dok einfuegen
960 SwFrmFmt* pFlyFmt =
961 pDoc->Insert( *pPam, ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), &aFrmSet, NULL, NULL );
962
963 // den alternativen Namen setzen
964 SwNoTxtNode *pNoTxtNd =
965 pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
966 ->GetIndex()+1 ]->GetNoTxtNode();
967 pNoTxtNd->SetTitle( aAlt );
968
969 // Ggf Frames anlegen und auto-geb. Rahmen registrieren
970 RegisterFlyFrm( pFlyFmt );
971
972 bInFloatingFrame = sal_True;
973 }
974
975 /* */
976
977 /*
978 #define SWHTML_OPTTYPE_IGNORE 0
979 #define SWHTML_OPTTYPE_TAG 1
980 #define SWHTML_OPTTYPE_PARAM 2
981
982
983 static sal_uInt16 GetOptionType( const String& rName, sal_Bool bApplet )
984 {
985 sal_uInt16 nType = bApplet ? SWHTML_OPTTYPE_PARAM : SWHTML_OPTTYPE_TAG;
986
987 switch( rName.GetChar(0) )
988 {
989 case 'A':
990 case 'a':
991 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_align ) ||
992 rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_alt ) )
993 nType = SWHTML_OPTTYPE_IGNORE;
994 else if( bApplet &&
995 (rName.EqualsIgnoreCaseAscii( sHTML_O_archive ) ||
996 rName.EqualsIgnoreCaseAscii( sHTML_O_Archives )) )
997 nType = SWHTML_OPTTYPE_TAG;
998 break;
999 case 'C':
1000 case 'c':
1001 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_class ) ||
1002 (bApplet && (rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_code ) ||
1003 rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_codebase ))) )
1004 nType = SWHTML_OPTTYPE_IGNORE;
1005 break;
1006 case 'H':
1007 case 'h':
1008 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_height ) ||
1009 rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_hspace ) ||
1010 (!bApplet && rName.EqualsIgnoreCaseAscii( OOO_STRING_SW_HTML_O_Hidden )) )
1011 nType = SWHTML_OPTTYPE_IGNORE;
1012 break;
1013 case 'I':
1014 case 'i':
1015 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_id ) )
1016 nType = SWHTML_OPTTYPE_IGNORE;
1017 break;
1018 case 'M':
1019 case 'm':
1020 if( bApplet && rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_mayscript ) )
1021 nType = SWHTML_OPTTYPE_IGNORE;
1022 break;
1023 case 'N':
1024 case 'n':
1025 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_name ) )
1026 nType = SWHTML_OPTTYPE_IGNORE;
1027 break;
1028 case 'O':
1029 case 'o':
1030 if( bApplet && rName.EqualsIgnoreCaseAscii( sHTML_O_Object ) )
1031 nType = SWHTML_OPTTYPE_TAG;
1032 break;
1033 case 'S':
1034 case 's':
1035 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_style ) ||
1036 (!bApplet && rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_src )) )
1037 nType = SWHTML_OPTTYPE_IGNORE;
1038 break;
1039 case 'T':
1040 case 't':
1041 if( !bApplet && rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_type ) )
1042 nType = SWHTML_OPTTYPE_IGNORE;
1043 break;
1044 case 'V':
1045 case 'v':
1046 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_vspace ) )
1047 nType = SWHTML_OPTTYPE_IGNORE;
1048 break;
1049 case 'W':
1050 case 'w':
1051 if( rName.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_O_width ) )
1052 nType = SWHTML_OPTTYPE_IGNORE;
1053 break;
1054 }
1055
1056 return nType;
1057 }
1058 */
1059
GuessOLENodeFrmType(const SwNode & rNode)1060 sal_uInt16 SwHTMLWriter::GuessOLENodeFrmType( const SwNode& rNode )
1061 {
1062 SwOLEObj& rObj = ((SwOLENode*)rNode.GetOLENode())->GetOLEObj();
1063
1064 SwHTMLFrmType eType = HTML_FRMTYPE_OLE;
1065
1066 uno::Reference < embed::XClassifiedObject > xClass ( rObj.GetOleRef(), uno::UNO_QUERY );
1067 SvGlobalName aClass( xClass->getClassID() );
1068 if( aClass == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1069 {
1070 eType = HTML_FRMTYPE_PLUGIN;
1071 }
1072 else if( aClass == SvGlobalName( SO3_IFRAME_CLASSID ) )
1073 {
1074 eType = HTML_FRMTYPE_IFRAME;
1075 }
1076 #ifdef SOLAR_JAVA
1077 else if( aClass == SvGlobalName( SO3_APPLET_CLASSID ) )
1078 {
1079 eType = HTML_FRMTYPE_APPLET;
1080 }
1081 #endif
1082
1083 return static_cast< sal_uInt16 >(eType);
1084 }
1085
OutHTML_FrmFmtOLENode(Writer & rWrt,const SwFrmFmt & rFrmFmt,sal_Bool bInCntnr)1086 Writer& OutHTML_FrmFmtOLENode( Writer& rWrt, const SwFrmFmt& rFrmFmt,
1087 sal_Bool bInCntnr )
1088 {
1089 SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
1090
1091 const SwFmtCntnt& rFlyCntnt = rFrmFmt.GetCntnt();
1092 sal_uLong nStt = rFlyCntnt.GetCntntIdx()->GetIndex()+1;
1093 SwOLENode *pOLENd = rHTMLWrt.pDoc->GetNodes()[ nStt ]->GetOLENode();
1094
1095 ASSERT( pOLENd, "OLE-Node erwartet" );
1096 if( !pOLENd )
1097 return rWrt;
1098
1099 SwOLEObj &rObj = pOLENd->GetOLEObj();
1100
1101 uno::Reference < embed::XEmbeddedObject > xObj( rObj.GetOleRef() );
1102 if ( !svt::EmbeddedObjectRef::TryRunningState( xObj ) )
1103 return rWrt;
1104
1105 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
1106 sal_Bool bHiddenEmbed = sal_False;
1107
1108 if( !xSet.is() )
1109 {
1110 DBG_ERROR("Unknown Object" );
1111 return rWrt;
1112 }
1113
1114 ByteString aEndTags;
1115 sal_uLong nFrmOpts;
1116
1117 // wenn meoglich vor dem "Objekt" einen Zeilen-Umbruch ausgeben
1118 if( rHTMLWrt.bLFPossible )
1119 rHTMLWrt.OutNewLine( sal_True );
1120
1121 if( rFrmFmt.GetName().Len() )
1122 rHTMLWrt.OutImplicitMark( rFrmFmt.GetName(),
1123 pMarkToOLE );
1124 uno::Any aAny;
1125 SvGlobalName aGlobName( xObj->getClassID() );
1126 ByteString sOut('<');
1127 if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1128 {
1129 // erstmal das Plug-spezifische
1130 sOut += OOO_STRING_SVTOOLS_HTML_embed;
1131
1132 ::rtl::OUString aStr;
1133 String aURL;
1134 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("PluginURL" ) );
1135 if( (aAny >>= aStr) && aStr.getLength() )
1136 {
1137 aURL = URIHelper::simpleNormalizedMakeRelative( rWrt.GetBaseURL(),
1138 aStr);
1139 }
1140
1141 if( aURL.Len() )
1142 {
1143 ((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_src) += "=\"";
1144 rWrt.Strm() << sOut.GetBuffer();
1145 HTMLOutFuncs::Out_String( rWrt.Strm(), aURL, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1146 sOut = '\"';
1147 }
1148
1149 ::rtl::OUString aType;
1150 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("PluginMimeType" ) );
1151 if( (aAny >>= aType) && aType.getLength() )
1152 {
1153 ((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_type) += "=\"";
1154 rWrt.Strm() << sOut.GetBuffer();
1155 HTMLOutFuncs::Out_String( rWrt.Strm(), aType, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1156 sOut = '\"';
1157 }
1158
1159 if ((FLY_AT_PARA == rFrmFmt.GetAnchor().GetAnchorId()) &&
1160 SURROUND_THROUGHT == rFrmFmt.GetSurround().GetSurround() )
1161 {
1162 // Das Plugin ist HIDDEN
1163 (sOut += ' ') += OOO_STRING_SW_HTML_O_Hidden;
1164 nFrmOpts = HTML_FRMOPTS_HIDDEN_EMBED;
1165 bHiddenEmbed = sal_True;
1166 }
1167 else
1168 {
1169 nFrmOpts = bInCntnr ? HTML_FRMOPTS_EMBED_CNTNR
1170 : HTML_FRMOPTS_EMBED;
1171 }
1172 }
1173 else if( aGlobName == SvGlobalName( SO3_APPLET_CLASSID ) )
1174 {
1175 // oder das Applet-Spezifische
1176
1177 sOut += OOO_STRING_SVTOOLS_HTML_applet;
1178
1179 // CODEBASE
1180 ::rtl::OUString aCd;
1181 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCodeBase" ) );
1182 if( (aAny >>= aCd) && aCd.getLength() )
1183 {
1184 String sCodeBase( URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), aCd) );
1185 if( sCodeBase.Len() )
1186 {
1187 ((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_codebase) += "=\"";
1188 rWrt.Strm() << sOut.GetBuffer();
1189 HTMLOutFuncs::Out_String( rWrt.Strm(), sCodeBase, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1190 sOut = '\"';
1191 }
1192 }
1193
1194 // CODE
1195 ::rtl::OUString aClass;
1196 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCode" ) );
1197 aAny >>= aClass;
1198 ((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_code) += "=\"";
1199 rWrt.Strm() << sOut.GetBuffer();
1200 HTMLOutFuncs::Out_String( rWrt.Strm(), aClass, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1201 sOut = '\"';
1202
1203 // NAME
1204 ::rtl::OUString aAppletName;
1205 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletName" ) );
1206 aAny >>= aAppletName;
1207 if( aAppletName.getLength() )
1208 {
1209 ((sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_name) += "=\"";
1210 rWrt.Strm() << sOut.GetBuffer();
1211 HTMLOutFuncs::Out_String( rWrt.Strm(), aAppletName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1212 sOut = '\"';
1213 }
1214
1215 sal_Bool bScript = sal_False;
1216 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletIsScript" ) );
1217 aAny >>= bScript;
1218 if( bScript )
1219 (sOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_mayscript;
1220
1221 nFrmOpts = bInCntnr ? HTML_FRMOPTS_APPLET_CNTNR
1222 : HTML_FRMOPTS_APPLET;
1223 }
1224 else
1225 {
1226 // oder das Flating-Frame spezifische
1227
1228 sOut += OOO_STRING_SVTOOLS_HTML_iframe;
1229 rWrt.Strm() << sOut.GetBuffer();
1230
1231 SfxFrameHTMLWriter::Out_FrameDescriptor( rWrt.Strm(), rWrt.GetBaseURL(),
1232 xSet,
1233 rHTMLWrt.eDestEnc,
1234 &rHTMLWrt.aNonConvertableCharacters );
1235 sOut.Erase();
1236
1237 nFrmOpts = bInCntnr ? HTML_FRMOPTS_IFRAME_CNTNR
1238 : HTML_FRMOPTS_IFRAME;
1239 }
1240
1241 rWrt.Strm() << sOut.GetBuffer();
1242
1243 // ALT, WIDTH, HEIGHT, HSPACE, VSPACE, ALIGN
1244 if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
1245 nFrmOpts |= HTML_FRMOPTS_OLE_CSS1;
1246 rHTMLWrt.OutFrmFmtOptions( rFrmFmt, pOLENd->GetTitle(),
1247 aEndTags, nFrmOpts );
1248 if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed )
1249 rHTMLWrt.OutCSS1_FrmFmtOptions( rFrmFmt, nFrmOpts );
1250
1251 if( aGlobName == SvGlobalName( SO3_APPLET_CLASSID ) )
1252 {
1253 // fuer Applets die Parameter als eigene Tags ausgeben
1254 // und ein </APPLET> schreiben
1255
1256 uno::Sequence < beans::PropertyValue > aProps;
1257 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCommands" ) );
1258 aAny >>= aProps;
1259
1260 SvCommandList aCommands;
1261 aCommands.FillFromSequence( aProps );
1262 SvULongs aParams;
1263 sal_uLong i = aCommands.Count();
1264 while( i > 0 )
1265 {
1266 const SvCommand& rCommand = aCommands[ --i ];
1267 const String& rName = rCommand.GetCommand();
1268 sal_uInt16 nType = SwApplet_Impl::GetOptionType( rName, sal_True );
1269 if( SWHTML_OPTTYPE_TAG == nType )
1270 {
1271 const String& rValue = rCommand.GetArgument();
1272 rWrt.Strm() << ' ';
1273 HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1274 rWrt.Strm() << "=\"";
1275 HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters ) << '\"';
1276 }
1277 else if( SWHTML_OPTTYPE_PARAM == nType )
1278 {
1279 aParams.Insert( i, aParams.Count() );
1280 }
1281 }
1282
1283 rHTMLWrt.Strm() << '>';
1284
1285 rHTMLWrt.IncIndentLevel(); // Inhalt von Applet einruecken
1286
1287 sal_uInt16 ii = aParams.Count();
1288 while( ii > 0 )
1289 {
1290 const SvCommand& rCommand = aCommands[ aParams[--ii] ];
1291 const String& rName = rCommand.GetCommand();
1292 const String& rValue = rCommand.GetArgument();
1293 rHTMLWrt.OutNewLine();
1294 ((((sOut = '<') += OOO_STRING_SVTOOLS_HTML_param) += ' ') += OOO_STRING_SVTOOLS_HTML_O_name)
1295 += "=\"";
1296 rWrt.Strm() << sOut.GetBuffer();
1297 HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1298 ((sOut = "\" ") += OOO_STRING_SVTOOLS_HTML_O_value) += "=\"";
1299 rWrt.Strm() << sOut.GetBuffer();
1300 HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters ) << "\">";
1301 }
1302
1303 rHTMLWrt.DecIndentLevel(); // Inhalt von Applet einruecken
1304 if( aCommands.Count() )
1305 rHTMLWrt.OutNewLine();
1306 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_applet, sal_False );
1307 }
1308 else
1309 if( aGlobName == SvGlobalName( SO3_PLUGIN_CLASSID ) )
1310 {
1311 // fuer Plugins die Parameter als Optionen schreiben
1312
1313 uno::Sequence < beans::PropertyValue > aProps;
1314 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("PluginCommands" ) );
1315 aAny >>= aProps;
1316
1317 SvCommandList aCommands;
1318 aCommands.FillFromSequence( aProps );
1319 for( sal_uLong i=0; i<aCommands.Count(); i++ )
1320 {
1321 const SvCommand& rCommand = aCommands[ i ];
1322 const String& rName = rCommand.GetCommand();
1323
1324 if( SwApplet_Impl::GetOptionType( rName, sal_False ) == SWHTML_OPTTYPE_TAG )
1325 {
1326 const String& rValue = rCommand.GetArgument();
1327 rWrt.Strm() << ' ';
1328 HTMLOutFuncs::Out_String( rWrt.Strm(), rName, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters );
1329 rWrt.Strm() << "=\"";
1330 HTMLOutFuncs::Out_String( rWrt.Strm(), rValue, rHTMLWrt.eDestEnc, &rHTMLWrt.aNonConvertableCharacters ) << '\"';
1331 }
1332 }
1333 rHTMLWrt.Strm() << '>';
1334 }
1335 else
1336 {
1337 // und fuer Floating-Frames einfach noch ein </IFRAME>
1338 // ausgeben
1339
1340 rHTMLWrt.Strm() << '>';
1341 HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OOO_STRING_SVTOOLS_HTML_iframe, sal_False );
1342 }
1343
1344 if( aEndTags.Len() )
1345 rWrt.Strm() << aEndTags.GetBuffer();
1346
1347 return rWrt;
1348 }
1349
OutHTML_FrmFmtOLENodeGrf(Writer & rWrt,const SwFrmFmt & rFrmFmt,sal_Bool bInCntnr)1350 Writer& OutHTML_FrmFmtOLENodeGrf( Writer& rWrt, const SwFrmFmt& rFrmFmt,
1351 sal_Bool bInCntnr )
1352 {
1353 SwHTMLWriter& rHTMLWrt = (SwHTMLWriter&)rWrt;
1354
1355 const SwFmtCntnt& rFlyCntnt = rFrmFmt.GetCntnt();
1356 sal_uLong nStt = rFlyCntnt.GetCntntIdx()->GetIndex()+1;
1357 SwOLENode *pOLENd = rHTMLWrt.pDoc->GetNodes()[ nStt ]->GetOLENode();
1358
1359 ASSERT( pOLENd, "OLE-Node erwartet" );
1360 if( !pOLENd )
1361 return rWrt;
1362
1363 // Inhalt des Nodes als Grafik speichern
1364 //uno::Reference < embed::XEmbeddedObject > xObj = pOLENd->GetOLEObj().GetOleRef();
1365 //GDIMetaFile aPic;
1366 //if( xObj.is() && xRef->GetGDIMetaFile( aPic ).GetActionCount() )
1367 {
1368 //Graphic aGrf( aPic );
1369 Graphic aGrf( *pOLENd->GetGraphic() );
1370 String aGrfNm;
1371 const String* pTempFileName = rHTMLWrt.GetOrigFileName();
1372 if(pTempFileName)
1373 aGrfNm = *pTempFileName;
1374
1375 sal_uInt16 nErr = XOutBitmap::WriteGraphic( aGrf, aGrfNm,
1376 String::CreateFromAscii("JPG"),
1377 (XOUTBMP_USE_GIF_IF_POSSIBLE |
1378 XOUTBMP_USE_NATIVE_IF_POSSIBLE) );
1379 if( nErr ) // fehlerhaft, da ist nichts auszugeben
1380 {
1381 rHTMLWrt.nWarn = WARN_SWG_POOR_LOAD | WARN_SW_WRITE_BASE;
1382 return rWrt;
1383 }
1384 aGrfNm = URIHelper::SmartRel2Abs(
1385 INetURLObject(rWrt.GetBaseURL()), aGrfNm,
1386 URIHelper::GetMaybeFileHdl() );
1387 sal_uLong nFlags = bInCntnr ? HTML_FRMOPTS_GENIMG_CNTNR
1388 : HTML_FRMOPTS_GENIMG;
1389 OutHTML_Image( rWrt, rFrmFmt, aGrfNm,
1390 pOLENd->GetTitle(), pOLENd->GetTwipSize(),
1391 nFlags, pMarkToOLE );
1392 }
1393
1394 return rWrt;
1395 }
1396
1397 /* vim: set noet sw=4 ts=4: */
1398