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 <comphelper/classids.hxx>
21 : #include <com/sun/star/embed/XEmbedObjectCreator.hpp>
22 : #include <com/sun/star/embed/XEmbeddedObject.hpp>
23 : #include <com/sun/star/embed/XLinkageSupport.hpp>
24 : #include <com/sun/star/embed/EmbedStates.hpp>
25 : #include <com/sun/star/embed/XClassifiedObject.hpp>
26 : #include <com/sun/star/embed/Aspects.hpp>
27 : #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
28 : #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
29 : #include <xmloff/families.hxx>
30 : #include <xmloff/xmlnmspe.hxx>
31 : #include <xmloff/xmltoken.hxx>
32 : #include <xmloff/txtprmap.hxx>
33 : #include <xmloff/maptype.hxx>
34 :
35 : #include <svx/svdobj.hxx>
36 : #include <doc.hxx>
37 : #include <ndole.hxx>
38 : #include <fmtcntnt.hxx>
39 : #include <unostyle.hxx>
40 : #include <unoframe.hxx>
41 : #include <ndgrf.hxx>
42 : #include "xmlexp.hxx"
43 : #include "xmltexte.hxx"
44 : #include <SwAppletImpl.hxx>
45 :
46 : #include <svl/urihelper.hxx>
47 : #include <sfx2/frmdescr.hxx>
48 : #include <SwStyleNameMapper.hxx>
49 :
50 : using namespace ::com::sun::star;
51 : using namespace ::com::sun::star::uno;
52 : using namespace ::com::sun::star::style;
53 : using namespace ::com::sun::star::beans;
54 : using namespace ::com::sun::star::lang;
55 : using namespace ::com::sun::star::document;
56 : using namespace ::com::sun::star::io;
57 : using namespace ::xmloff::token;
58 :
59 : enum SvEmbeddedObjectTypes
60 : {
61 : SV_EMBEDDED_OWN,
62 : SV_EMBEDDED_OUTPLACE,
63 : SV_EMBEDDED_APPLET,
64 : SV_EMBEDDED_PLUGIN,
65 : SV_EMBEDDED_FRAME
66 : };
67 :
68 18 : SwNoTextNode *SwXMLTextParagraphExport::GetNoTextNode(
69 : const Reference < XPropertySet >& rPropSet )
70 : {
71 18 : Reference<XUnoTunnel> xCrsrTunnel( rPropSet, UNO_QUERY );
72 : assert(xCrsrTunnel.is() && "missing XUnoTunnel for embedded");
73 : SwXFrame *pFrame = reinterpret_cast< SwXFrame * >(
74 18 : sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( SwXFrame::getUnoTunnelId() )));
75 : assert(pFrame && "SwXFrame missing");
76 18 : SwFrameFormat *pFrameFormat = pFrame->GetFrameFormat();
77 18 : const SwFormatContent& rContent = pFrameFormat->GetContent();
78 18 : const SwNodeIndex *pNdIdx = rContent.GetContentIdx();
79 18 : return pNdIdx->GetNodes()[pNdIdx->GetIndex() + 1]->GetNoTextNode();
80 : }
81 :
82 998 : void SwXMLTextParagraphExport::exportStyleContent(
83 : const Reference< XStyle > & rStyle )
84 : {
85 :
86 998 : const SwXStyle* pStyle = 0;
87 998 : Reference<XUnoTunnel> xStyleTunnel( rStyle, UNO_QUERY);
88 998 : if( xStyleTunnel.is() )
89 : {
90 : pStyle = reinterpret_cast< SwXStyle * >(
91 998 : sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId() )));
92 : }
93 998 : if( pStyle && SFX_STYLE_FAMILY_PARA == pStyle->GetFamily() )
94 : {
95 745 : const SwDoc *pDoc = pStyle->GetDoc();
96 : const SwTextFormatColl *pColl =
97 745 : pDoc->FindTextFormatCollByName( pStyle->GetStyleName() );
98 : OSL_ENSURE( pColl, "There is the text collection?" );
99 745 : if( pColl && RES_CONDTXTFMTCOLL == pColl->Which() )
100 : {
101 : const SwFormatCollConditions& rConditions =
102 72 : static_cast<const SwConditionTextFormatColl *>(pColl)->GetCondColls();
103 72 : for( size_t i=0; i < rConditions.size(); ++i )
104 : {
105 0 : const SwCollCondition& rCond = rConditions[i];
106 :
107 0 : enum XMLTokenEnum eFunc = XML_TOKEN_INVALID;
108 0 : OUString sVal;
109 0 : switch( rCond.GetCondition() )
110 : {
111 : case PARA_IN_LIST:
112 0 : eFunc = XML_LIST_LEVEL;
113 0 : sVal = OUString::number(rCond.GetSubCondition()+1);
114 0 : break;
115 : case PARA_IN_OUTLINE:
116 0 : eFunc = XML_OUTLINE_LEVEL;
117 0 : sVal = OUString::number(rCond.GetSubCondition()+1);
118 0 : break;
119 : case PARA_IN_FRAME:
120 0 : eFunc = XML_TEXT_BOX;
121 0 : break;
122 : case PARA_IN_TABLEHEAD:
123 0 : eFunc = XML_TABLE_HEADER;
124 0 : break;
125 : case PARA_IN_TABLEBODY:
126 0 : eFunc = XML_TABLE;
127 0 : break;
128 : case PARA_IN_SECTION:
129 0 : eFunc = XML_SECTION;
130 0 : break;
131 : case PARA_IN_FOOTENOTE:
132 0 : eFunc = XML_FOOTNOTE;
133 0 : break;
134 : case PARA_IN_FOOTER:
135 0 : eFunc = XML_FOOTER;
136 0 : break;
137 : case PARA_IN_HEADER:
138 0 : eFunc = XML_HEADER;
139 0 : break;
140 : case PARA_IN_ENDNOTE:
141 0 : eFunc = XML_ENDNOTE;
142 0 : break;
143 : }
144 : OSL_ENSURE( eFunc != XML_TOKEN_INVALID,
145 : "SwXMLExport::ExportFormat: unknown condition" );
146 0 : if( eFunc != XML_TOKEN_INVALID )
147 : {
148 0 : OUString sCond = GetXMLToken(eFunc) + "()";
149 0 : if( !sVal.isEmpty() )
150 : {
151 0 : sCond += "=" + sVal;
152 : }
153 :
154 0 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
155 0 : XML_CONDITION, sCond );
156 0 : OUString aString;
157 : SwStyleNameMapper::FillProgName(
158 0 : rCond.GetTextFormatColl()->GetName(),
159 : aString,
160 : nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL,
161 0 : true);
162 0 : aString = GetExport().EncodeStyleName( aString );
163 0 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
164 0 : XML_APPLY_STYLE_NAME, aString );
165 0 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
166 0 : XML_MAP, true, true );
167 : }
168 0 : }
169 : }
170 998 : }
171 998 : }
172 :
173 144 : SwXMLTextParagraphExport::SwXMLTextParagraphExport(
174 : SwXMLExport& rExp,
175 : SvXMLAutoStylePoolP& _rAutoStylePool ) :
176 : XMLTextParagraphExport( rExp, _rAutoStylePool ),
177 : sTextTable( "TextTable" ),
178 : sEmbeddedObjectProtocol( "vnd.sun.star.EmbeddedObject:" ),
179 : sGraphicObjectProtocol( "vnd.sun.star.GraphicObject:" ),
180 : aAppletClassId( SO3_APPLET_CLASSID ),
181 : aPluginClassId( SO3_PLUGIN_CLASSID ),
182 : aIFrameClassId( SO3_IFRAME_CLASSID ),
183 144 : aOutplaceClassId( SO3_OUT_CLASSID )
184 : {
185 144 : }
186 :
187 288 : SwXMLTextParagraphExport::~SwXMLTextParagraphExport()
188 : {
189 288 : }
190 :
191 18 : static void lcl_addURL ( SvXMLExport &rExport, const OUString &rURL,
192 : bool bToRel = true )
193 : {
194 0 : const OUString sRelURL = ( bToRel && !rURL.isEmpty() )
195 0 : ? URIHelper::simpleNormalizedMakeRelative(rExport.GetOrigFileName(), rURL)
196 18 : : rURL;
197 :
198 18 : if (!sRelURL.isEmpty())
199 : {
200 18 : rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, sRelURL );
201 18 : rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
202 18 : rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
203 18 : rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
204 18 : }
205 18 : }
206 :
207 18 : static void lcl_addAspect(
208 : const svt::EmbeddedObjectRef& rObj,
209 : const XMLPropertyState **pStates,
210 : const rtl::Reference < XMLPropertySetMapper >& rMapper )
211 : {
212 : {
213 18 : sal_Int64 nAspect = rObj.GetViewAspect();
214 :
215 18 : if ( nAspect )
216 : {
217 18 : *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_DRAW_ASPECT ), uno::makeAny( nAspect ) );
218 18 : pStates++;
219 : }
220 : }
221 18 : }
222 :
223 12 : static void lcl_addOutplaceProperties(
224 : const svt::EmbeddedObjectRef& rObj,
225 : const XMLPropertyState **pStates,
226 : const rtl::Reference < XMLPropertySetMapper >& rMapper )
227 : {
228 : {
229 12 : MapMode aMode( MAP_100TH_MM ); // the API expects this map mode for the embedded objects
230 12 : Size aSize = rObj.GetSize( &aMode ); // get the size in the requested map mode
231 :
232 12 : if( aSize.Width() && aSize.Height() )
233 : {
234 12 : Any aAny;
235 12 : aAny <<= 0L;
236 12 : *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_LEFT ), aAny );
237 12 : pStates++;
238 :
239 12 : aAny <<= 0L;
240 12 : *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_TOP ), aAny );
241 12 : pStates++;
242 :
243 12 : aAny <<= (sal_Int32)aSize.Width();
244 12 : *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_WIDTH ), aAny );
245 12 : pStates++;
246 :
247 12 : aAny <<= (sal_Int32)aSize.Height();
248 12 : *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_HEIGHT ), aAny );
249 12 : pStates++;
250 12 : }
251 : }
252 12 : }
253 :
254 0 : static void lcl_addFrameProperties(
255 : const uno::Reference < embed::XEmbeddedObject >& xObj,
256 : const XMLPropertyState **pStates,
257 : const rtl::Reference < XMLPropertySetMapper >& rMapper )
258 : {
259 0 : if ( !::svt::EmbeddedObjectRef::TryRunningState( xObj ) )
260 0 : return;
261 :
262 0 : uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
263 0 : if ( !xSet.is() )
264 0 : return;
265 :
266 0 : OUString aURL;
267 0 : Any aAny = xSet->getPropertyValue("FrameURL");
268 0 : aAny >>= aURL;
269 :
270 0 : OUString aName;
271 0 : aAny = xSet->getPropertyValue("FrameName");
272 0 : aAny >>= aName;
273 :
274 0 : bool bIsAutoScroll = false, bIsScrollingMode = false;
275 0 : aAny = xSet->getPropertyValue("FrameIsAutoScroll");
276 0 : aAny >>= bIsAutoScroll;
277 0 : if ( !bIsAutoScroll )
278 : {
279 0 : aAny = xSet->getPropertyValue("FrameIsScrollingMode");
280 0 : aAny >>= bIsScrollingMode;
281 : }
282 :
283 0 : bool bIsBorderSet = false, bIsAutoBorder = false;
284 0 : aAny = xSet->getPropertyValue("FrameIsAutoBorder");
285 0 : aAny >>= bIsAutoBorder;
286 0 : if ( !bIsAutoBorder )
287 : {
288 0 : aAny = xSet->getPropertyValue("FrameIsBorder");
289 0 : aAny >>= bIsBorderSet;
290 : }
291 :
292 : sal_Int32 nWidth, nHeight;
293 0 : aAny = xSet->getPropertyValue("FrameMarginWidth");
294 0 : aAny >>= nWidth;
295 0 : aAny = xSet->getPropertyValue("FrameMarginHeight");
296 0 : aAny >>= nHeight;
297 :
298 0 : if( !bIsAutoScroll )
299 : {
300 0 : *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_DISPLAY_SCROLLBAR ), makeAny(bIsScrollingMode) );
301 0 : pStates++;
302 : }
303 0 : if( !bIsAutoBorder )
304 : {
305 0 : *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_DISPLAY_BORDER ), makeAny(bIsBorderSet) );
306 0 : pStates++;
307 : }
308 0 : if( SIZE_NOT_SET != nWidth )
309 : {
310 0 : Any aAny2;
311 0 : aAny <<= nWidth;
312 0 : *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_MARGIN_HORI ), aAny2 );
313 0 : pStates++;
314 : }
315 0 : if( SIZE_NOT_SET != nHeight )
316 : {
317 0 : Any aAny2;
318 0 : aAny <<= nHeight;
319 0 : *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_MARGIN_VERT ), aAny2 );
320 0 : pStates++;
321 0 : }
322 : }
323 :
324 9 : void SwXMLTextParagraphExport::_collectTextEmbeddedAutoStyles(
325 : const Reference < XPropertySet > & rPropSet )
326 : {
327 9 : SwOLENode *pOLENd = GetNoTextNode( rPropSet )->GetOLENode();
328 9 : svt::EmbeddedObjectRef& rObjRef = pOLENd->GetOLEObj().GetObject();
329 9 : if( !rObjRef.is() )
330 9 : return;
331 :
332 9 : const XMLPropertyState *aStates[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
333 9 : SvGlobalName aClassId( rObjRef->getClassID() );
334 :
335 9 : if( aIFrameClassId == aClassId )
336 : {
337 0 : lcl_addFrameProperties( rObjRef.GetObject(), aStates,
338 0 : GetAutoFramePropMapper()->getPropertySetMapper() );
339 : }
340 9 : else if ( !SotExchange::IsInternal( aClassId ) )
341 : {
342 : lcl_addOutplaceProperties( rObjRef, aStates,
343 6 : GetAutoFramePropMapper()->getPropertySetMapper() );
344 : }
345 :
346 : lcl_addAspect( rObjRef, aStates,
347 9 : GetAutoFramePropMapper()->getPropertySetMapper() );
348 :
349 9 : Add( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, aStates );
350 :
351 9 : const XMLPropertyState **pStates = aStates;
352 45 : while( *pStates )
353 : {
354 27 : delete *pStates;
355 27 : pStates++;
356 9 : }
357 : }
358 :
359 9 : void SwXMLTextParagraphExport::_exportTextEmbedded(
360 : const Reference < XPropertySet > & rPropSet,
361 : const Reference < XPropertySetInfo > & rPropSetInfo )
362 : {
363 9 : SwOLENode *pOLENd = GetNoTextNode( rPropSet )->GetOLENode();
364 9 : SwOLEObj& rOLEObj = pOLENd->GetOLEObj();
365 9 : svt::EmbeddedObjectRef& rObjRef = rOLEObj.GetObject();
366 9 : if( !rObjRef.is() )
367 9 : return;
368 :
369 9 : SvGlobalName aClassId( rObjRef->getClassID() );
370 :
371 9 : SvEmbeddedObjectTypes nType = SV_EMBEDDED_OWN;
372 9 : if( aPluginClassId == aClassId )
373 : {
374 0 : nType = SV_EMBEDDED_PLUGIN;
375 : }
376 9 : else if( aAppletClassId == aClassId )
377 : {
378 0 : nType = SV_EMBEDDED_APPLET;
379 : }
380 9 : else if( aIFrameClassId == aClassId )
381 : {
382 0 : nType = SV_EMBEDDED_FRAME;
383 : }
384 9 : else if ( !SotExchange::IsInternal( aClassId ) )
385 : {
386 6 : nType = SV_EMBEDDED_OUTPLACE;
387 : }
388 :
389 9 : enum XMLTokenEnum eElementName = XML__UNKNOWN_;
390 9 : SvXMLExport &rXMLExport = GetExport();
391 :
392 : // First the stuff common to each of Applet/Plugin/Floating Frame
393 18 : OUString sStyle;
394 18 : Any aAny;
395 9 : if( rPropSetInfo->hasPropertyByName( sFrameStyleName ) )
396 : {
397 9 : aAny = rPropSet->getPropertyValue( sFrameStyleName );
398 9 : aAny >>= sStyle;
399 : }
400 :
401 9 : const XMLPropertyState *aStates[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
402 9 : switch( nType )
403 : {
404 : case SV_EMBEDDED_FRAME:
405 0 : lcl_addFrameProperties( rObjRef.GetObject(), aStates,
406 0 : GetAutoFramePropMapper()->getPropertySetMapper() );
407 0 : break;
408 : case SV_EMBEDDED_OUTPLACE:
409 : lcl_addOutplaceProperties( rObjRef, aStates,
410 6 : GetAutoFramePropMapper()->getPropertySetMapper() );
411 6 : break;
412 : default:
413 : ;
414 : }
415 :
416 : lcl_addAspect( rObjRef, aStates,
417 9 : GetAutoFramePropMapper()->getPropertySetMapper() );
418 :
419 : const OUString sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_FRAME,
420 9 : rPropSet, sStyle, aStates );
421 9 : const XMLPropertyState **pStates = aStates;
422 45 : while( *pStates )
423 : {
424 27 : delete *pStates;
425 27 : pStates++;
426 : }
427 :
428 9 : if( !sAutoStyle.isEmpty() )
429 9 : rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_STYLE_NAME, sAutoStyle );
430 9 : addTextFrameAttributes( rPropSet, false );
431 :
432 9 : SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW,
433 18 : XML_FRAME, false, true );
434 :
435 9 : switch (nType)
436 : {
437 : case SV_EMBEDDED_OUTPLACE:
438 : case SV_EMBEDDED_OWN:
439 9 : if( !(rXMLExport.getExportFlags() & SvXMLExportFlags::EMBEDDED) )
440 : {
441 9 : OUString sURL;
442 :
443 9 : bool bIsOwnLink = false;
444 9 : if( SV_EMBEDDED_OWN == nType )
445 : {
446 : try
447 : {
448 3 : uno::Reference< embed::XLinkageSupport > xLinkage( rObjRef.GetObject(), uno::UNO_QUERY );
449 3 : bIsOwnLink = xLinkage.is() && xLinkage->isLink();
450 3 : if ( bIsOwnLink )
451 0 : sURL = xLinkage->getLinkURL();
452 : }
453 0 : catch(const uno::Exception&)
454 : {
455 : // TODO/LATER: error handling
456 : OSL_FAIL( "Link detection or retrieving of the URL of OOo link is failed!\n" );
457 : }
458 : }
459 :
460 9 : if ( !bIsOwnLink )
461 : {
462 9 : sURL = sEmbeddedObjectProtocol + rOLEObj.GetCurrentPersistName();
463 : }
464 :
465 9 : sURL = GetExport().AddEmbeddedObject( sURL );
466 9 : lcl_addURL( rXMLExport, sURL, false );
467 : }
468 9 : if( SV_EMBEDDED_OWN == nType && !pOLENd->GetChartTableName().isEmpty() )
469 : {
470 0 : OUString sRange( pOLENd->GetChartTableName() );
471 0 : OUStringBuffer aBuffer( sRange.getLength() + 2 );
472 0 : for( sal_Int32 i=0; i < sRange.getLength(); i++ )
473 : {
474 0 : sal_Unicode c = sRange[i];
475 0 : switch( c )
476 : {
477 : case ' ':
478 : case '.':
479 : case '\'':
480 : case '\\':
481 0 : if( aBuffer.isEmpty() )
482 : {
483 0 : aBuffer.append( '\'' );
484 0 : aBuffer.append( sRange.copy( 0, i ) );
485 : }
486 0 : if( '\'' == c || '\\' == c )
487 0 : aBuffer.append( '\\' );
488 : // no break!
489 : default:
490 0 : if( !aBuffer.isEmpty() )
491 0 : aBuffer.append( c );
492 : }
493 : }
494 0 : if( !aBuffer.isEmpty() )
495 : {
496 0 : aBuffer.append( '\'' );
497 0 : sRange = aBuffer.makeStringAndClear();
498 : }
499 :
500 : rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES,
501 0 : sRange );
502 : }
503 : eElementName = SV_EMBEDDED_OUTPLACE==nType ? XML_OBJECT_OLE
504 9 : : XML_OBJECT;
505 9 : break;
506 : case SV_EMBEDDED_APPLET:
507 : {
508 : // It's an applet!
509 0 : if( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
510 : {
511 0 : uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
512 0 : OUString aStr;
513 0 : Any aAny2 = xSet->getPropertyValue("AppletCodeBase");
514 0 : aAny2 >>= aStr;
515 0 : if (!aStr.isEmpty() )
516 0 : lcl_addURL(rXMLExport, aStr);
517 :
518 0 : aAny2 = xSet->getPropertyValue("AppletName");
519 0 : aAny2 >>= aStr;
520 0 : if (!aStr.isEmpty())
521 0 : rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_APPLET_NAME, aStr );
522 :
523 0 : aAny2 = xSet->getPropertyValue("AppletCode");
524 0 : aAny2 >>= aStr;
525 0 : rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CODE, aStr );
526 :
527 0 : bool bScript = false;
528 0 : aAny2 = xSet->getPropertyValue("AppletIsScript");
529 0 : aAny2 >>= bScript;
530 0 : rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MAY_SCRIPT, bScript ? XML_TRUE : XML_FALSE );
531 :
532 0 : uno::Sequence < beans::PropertyValue > aProps;
533 0 : aAny2 = xSet->getPropertyValue("AppletCommands");
534 0 : aAny2 >>= aProps;
535 :
536 0 : sal_Int32 i = aProps.getLength();
537 0 : while ( i > 0 )
538 : {
539 0 : beans::PropertyValue& aProp = aProps[--i];
540 0 : const SwHtmlOptType nType2 = SwApplet_Impl::GetOptionType( aProp.Name, true );
541 0 : if ( nType2 == SwHtmlOptType::TAG)
542 : {
543 0 : OUString aStr2;
544 0 : aProp.Value >>= aStr2;
545 0 : rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, aProp.Name, aStr2);
546 : }
547 : }
548 :
549 0 : eElementName = XML_APPLET;
550 : }
551 : }
552 0 : break;
553 : case SV_EMBEDDED_PLUGIN:
554 : {
555 : // It's a plugin!
556 0 : if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
557 : {
558 0 : uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
559 0 : OUString aStr;
560 0 : Any aAny2 = xSet->getPropertyValue("PluginURL");
561 0 : aAny2 >>= aStr;
562 0 : lcl_addURL( rXMLExport, aStr );
563 :
564 0 : aAny2 = xSet->getPropertyValue("PluginMimeType");
565 0 : aAny2 >>= aStr;
566 0 : if (!aStr.isEmpty())
567 0 : rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIME_TYPE, aStr );
568 0 : eElementName = XML_PLUGIN;
569 : }
570 : }
571 0 : break;
572 : case SV_EMBEDDED_FRAME:
573 : {
574 : // It's a floating frame!
575 0 : if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
576 : {
577 0 : uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
578 0 : OUString aStr;
579 0 : Any aAny2 = xSet->getPropertyValue("FrameURL");
580 0 : aAny2 >>= aStr;
581 :
582 0 : lcl_addURL( rXMLExport, aStr );
583 :
584 0 : aAny2 = xSet->getPropertyValue("FrameName");
585 0 : aAny2 >>= aStr;
586 :
587 0 : if (!aStr.isEmpty())
588 0 : rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_FRAME_NAME, aStr );
589 0 : eElementName = XML_FLOATING_FRAME;
590 : }
591 : }
592 0 : break;
593 : default:
594 : OSL_ENSURE( false, "unknown object type! Base class should have been called!" );
595 : }
596 :
597 : {
598 : SvXMLElementExport aElementExport( rXMLExport, XML_NAMESPACE_DRAW, eElementName,
599 9 : false, true );
600 9 : switch( nType )
601 : {
602 : case SV_EMBEDDED_OWN:
603 3 : if( rXMLExport.getExportFlags() & SvXMLExportFlags::EMBEDDED )
604 : {
605 0 : Reference < XEmbeddedObjectSupplier > xEOS( rPropSet, UNO_QUERY );
606 : OSL_ENSURE( xEOS.is(), "no embedded object supplier for own object" );
607 0 : Reference < XComponent > xComp = xEOS->getEmbeddedObject();
608 0 : rXMLExport.ExportEmbeddedOwnObject( xComp );
609 : }
610 3 : break;
611 : case SV_EMBEDDED_OUTPLACE:
612 6 : if( rXMLExport.getExportFlags() & SvXMLExportFlags::EMBEDDED )
613 : {
614 0 : OUString sURL( sEmbeddedObjectProtocol + rOLEObj.GetCurrentPersistName() );
615 :
616 0 : if ( !( rXMLExport.getExportFlags() & SvXMLExportFlags::OASIS ) )
617 0 : sURL += "?oasis=false";
618 :
619 0 : rXMLExport.AddEmbeddedObjectAsBase64( sURL );
620 : }
621 6 : break;
622 : case SV_EMBEDDED_APPLET:
623 : {
624 0 : if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
625 : {
626 0 : uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
627 0 : uno::Sequence < beans::PropertyValue > aProps;
628 0 : aAny = xSet->getPropertyValue("AppletCommands");
629 0 : aAny >>= aProps;
630 :
631 0 : sal_Int32 i = aProps.getLength();
632 0 : while ( i > 0 )
633 : {
634 0 : beans::PropertyValue& aProp = aProps[--i];
635 0 : const SwHtmlOptType nType2 = SwApplet_Impl::GetOptionType( aProp.Name, true );
636 0 : if (SwHtmlOptType::PARAM == nType2 || SwHtmlOptType::SIZE == nType2 )
637 : {
638 0 : OUString aStr;
639 0 : aProp.Value >>= aStr;
640 0 : rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aProp.Name );
641 0 : rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
642 0 : SvXMLElementExport aElementExport2( rXMLExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true );
643 : }
644 0 : }
645 : }
646 : }
647 0 : break;
648 : case SV_EMBEDDED_PLUGIN:
649 : {
650 0 : if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
651 : {
652 0 : uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
653 0 : uno::Sequence < beans::PropertyValue > aProps;
654 0 : aAny = xSet->getPropertyValue("PluginCommands");
655 0 : aAny >>= aProps;
656 :
657 0 : sal_Int32 i = aProps.getLength();
658 0 : while ( i > 0 )
659 : {
660 0 : beans::PropertyValue& aProp = aProps[--i];
661 0 : const SwHtmlOptType nType2 = SwApplet_Impl::GetOptionType( aProp.Name, false );
662 0 : if ( nType2 == SwHtmlOptType::TAG)
663 : {
664 0 : OUString aStr;
665 0 : aProp.Value >>= aStr;
666 0 : rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aProp.Name );
667 0 : rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
668 0 : SvXMLElementExport aElementExport2( rXMLExport, XML_NAMESPACE_DRAW, XML_PARAM, false, true );
669 : }
670 0 : }
671 : }
672 : }
673 0 : break;
674 : default:
675 0 : break;
676 9 : }
677 : }
678 9 : if( SV_EMBEDDED_OUTPLACE==nType || SV_EMBEDDED_OWN==nType )
679 : {
680 9 : OUString sURL( sGraphicObjectProtocol + rOLEObj.GetCurrentPersistName() );
681 9 : if( !(rXMLExport.getExportFlags() & SvXMLExportFlags::EMBEDDED) )
682 : {
683 9 : sURL = GetExport().AddEmbeddedObject( sURL );
684 9 : lcl_addURL( rXMLExport, sURL, false );
685 : }
686 :
687 9 : SvXMLElementExport aElementExport( GetExport(), XML_NAMESPACE_DRAW,
688 18 : XML_IMAGE, false, true );
689 :
690 9 : if( rXMLExport.getExportFlags() & SvXMLExportFlags::EMBEDDED )
691 9 : GetExport().AddEmbeddedObjectAsBase64( sURL );
692 : }
693 :
694 : // Lastly the stuff common to each of Applet/Plugin/Floating Frame
695 9 : exportEvents( rPropSet );
696 9 : exportTitleAndDescription( rPropSet, rPropSetInfo ); // #i73249#
697 27 : exportContour( rPropSet, rPropSetInfo );
698 177 : }
699 :
700 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|