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