merge the formfield patch from ooo-build
[ooovba.git] / sw / source / filter / xml / xmltexte.cxx
blob254cae1f7f3c3466f6694cb5359b08de598e4f4b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmltexte.cxx,v $
10 * $Revision: 1.49 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <sot/clsids.hxx>
36 #include <com/sun/star/embed/XEmbedObjectCreator.hpp>
37 #include <com/sun/star/embed/XEmbeddedObject.hpp>
38 #include <com/sun/star/embed/XLinkageSupport.hpp>
39 #include <com/sun/star/embed/EmbedStates.hpp>
40 #include <com/sun/star/embed/XClassifiedObject.hpp>
41 #include <com/sun/star/embed/Aspects.hpp>
42 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
43 #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
44 #include <xmloff/families.hxx>
45 #include <xmloff/xmlnmspe.hxx>
46 #include <xmloff/xmltoken.hxx>
47 #ifndef _XMLOFF_TXTPRMAP_HXX
48 #include <xmloff/txtprmap.hxx>
49 #endif
51 #include <svx/svdobj.hxx>
52 #include <doc.hxx>
53 #include <ndole.hxx>
54 #include <unostyle.hxx>
55 #include <unoframe.hxx>
56 #include <ndgrf.hxx>
57 #include "xmlexp.hxx"
58 #include "xmltexte.hxx"
59 #include <tools/urlobj.hxx>
60 #include <SwAppletImpl.hxx>
62 #define _SVSTDARR_ULONGS
63 #include <svtools/svstdarr.hxx>
64 #include "svtools/urihelper.hxx"
65 #include <sfx2/frmdescr.hxx>
66 #include <SwStyleNameMapper.hxx>
68 using ::rtl::OUString;
69 using ::rtl::OUStringBuffer;
70 using namespace ::com::sun::star;
71 using namespace ::com::sun::star::uno;
72 using namespace ::com::sun::star::style;
73 using namespace ::com::sun::star::beans;
74 using namespace ::com::sun::star::lang;
75 using namespace ::com::sun::star::document;
76 using namespace ::com::sun::star::io;
77 using namespace ::xmloff::token;
79 enum SvEmbeddedObjectTypes
81 SV_EMBEDDED_OWN,
82 SV_EMBEDDED_OUTPLACE,
83 SV_EMBEDDED_APPLET,
84 SV_EMBEDDED_PLUGIN,
85 SV_EMBEDDED_FRAME
88 const sal_Char sObjectReplacements[] = "ObjectReplacements/";
90 // ---------------------------------------------------------------------
92 SwNoTxtNode *SwXMLTextParagraphExport::GetNoTxtNode(
93 const Reference < XPropertySet >& rPropSet ) const
95 Reference<XUnoTunnel> xCrsrTunnel( rPropSet, UNO_QUERY );
96 ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for embedded" );
97 SwXFrame *pFrame = reinterpret_cast< SwXFrame * >(
98 sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( SwXFrame::getUnoTunnelId() )));
99 ASSERT( pFrame, "SwXFrame missing" );
100 SwFrmFmt *pFrmFmt = pFrame->GetFrmFmt();
101 const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
102 const SwNodeIndex *pNdIdx = rCntnt.GetCntntIdx();
103 return pNdIdx->GetNodes()[pNdIdx->GetIndex() + 1]->GetNoTxtNode();
106 void SwXMLTextParagraphExport::exportStyleContent(
107 const Reference< XStyle > & rStyle )
110 const SwXStyle* pStyle = 0;
111 Reference<XUnoTunnel> xStyleTunnel( rStyle, UNO_QUERY);
112 if( xStyleTunnel.is() )
114 pStyle = reinterpret_cast< SwXStyle * >(
115 sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId() )));
117 if( pStyle && SFX_STYLE_FAMILY_PARA == pStyle->GetFamily() )
119 const SwDoc *pDoc = pStyle->GetDoc();
120 const SwTxtFmtColl *pColl =
121 pDoc->FindTxtFmtCollByName( pStyle->GetStyleName() );
122 ASSERT( pColl, "There is the text collection?" );
123 if( pColl && RES_CONDTXTFMTCOLL == pColl->Which() )
125 const SwFmtCollConditions& rConditions =
126 ((const SwConditionTxtFmtColl *)pColl)->GetCondColls();
127 for( sal_uInt16 i=0; i < rConditions.Count(); i++ )
129 const SwCollCondition& rCond = *rConditions[i];
131 enum XMLTokenEnum eFunc = XML_TOKEN_INVALID;
132 OUStringBuffer sBuffer( 20 );
133 switch( rCond.GetCondition() )
135 case PARA_IN_LIST:
136 eFunc = XML_LIST_LEVEL;
137 sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
138 break;
139 case PARA_IN_OUTLINE:
140 eFunc = XML_OUTLINE_LEVEL;
141 sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
142 break;
143 case PARA_IN_FRAME:
144 eFunc = XML_TEXT_BOX;
145 break;
146 case PARA_IN_TABLEHEAD:
147 eFunc = XML_TABLE_HEADER;
148 break;
149 case PARA_IN_TABLEBODY:
150 eFunc = XML_TABLE;
151 break;
152 case PARA_IN_SECTION:
153 eFunc = XML_SECTION;
154 break;
155 case PARA_IN_FOOTENOTE:
156 eFunc = XML_FOOTNOTE;
157 break;
158 case PARA_IN_FOOTER:
159 eFunc = XML_FOOTER;
160 break;
161 case PARA_IN_HEADER:
162 eFunc = XML_HEADER;
163 break;
164 case PARA_IN_ENDNOTE:
165 eFunc = XML_ENDNOTE;
166 break;
168 OUString sVal( sBuffer.makeStringAndClear() );
170 DBG_ASSERT( eFunc != XML_TOKEN_INVALID,
171 "SwXMLExport::ExportFmt: unknown condition" );
172 if( eFunc != XML_TOKEN_INVALID )
174 sBuffer.append( GetXMLToken(eFunc) );
175 sBuffer.append( (sal_Unicode)'(' );
176 sBuffer.append( (sal_Unicode)')' );
177 if( sVal.getLength() )
179 sBuffer.append( (sal_Unicode)'=' );
180 sBuffer.append( sVal );
183 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
184 XML_CONDITION,
185 sBuffer.makeStringAndClear() );
186 String aString;
187 SwStyleNameMapper::FillProgName(
188 rCond.GetTxtFmtColl()->GetName(),
189 aString,
190 nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL,
191 sal_True);
192 aString = GetExport().EncodeStyleName( aString );
193 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
194 XML_APPLY_STYLE_NAME, aString );
195 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
196 XML_MAP, sal_True, sal_True );
203 SwXMLTextParagraphExport::SwXMLTextParagraphExport(
204 SwXMLExport& rExp,
205 SvXMLAutoStylePoolP& _rAutoStylePool ) :
206 XMLTextParagraphExport( rExp, _rAutoStylePool ),
207 sTextTable( RTL_CONSTASCII_USTRINGPARAM( "TextTable" ) ),
208 sEmbeddedObjectProtocol( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ) ),
209 sGraphicObjectProtocol( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:" ) ),
210 aAppletClassId( SO3_APPLET_CLASSID ),
211 aPluginClassId( SO3_PLUGIN_CLASSID ),
212 aIFrameClassId( SO3_IFRAME_CLASSID ),
213 aOutplaceClassId( SO3_OUT_CLASSID )
217 SwXMLTextParagraphExport::~SwXMLTextParagraphExport()
221 void SwXMLTextParagraphExport::setTextEmbeddedGraphicURL(
222 const Reference < XPropertySet >& rPropSet,
223 OUString& rURL) const
225 if( !rURL.getLength() )
226 return;
228 SwGrfNode *pGrfNd = GetNoTxtNode( rPropSet )->GetGrfNode();
229 if( !pGrfNd->IsGrfLink() )
231 String aNewURL( RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.Package:") );
232 aNewURL += String(rURL);
233 pGrfNd->SetNewStreamName( aNewURL );
235 // #i15411# save-as will swap all graphics in; we need to swap
236 // them out again, to prevent excessive memory use
237 pGrfNd->SwapOut();
241 static void lcl_addParam ( SvXMLExport &rExport, const SvCommand &rCommand )
243 rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, rCommand.GetCommand() );
244 rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, rCommand.GetArgument() );
245 SvXMLElementExport aElem( rExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True );
248 static void lcl_addURL ( SvXMLExport &rExport, const String &rURL,
249 sal_Bool bToRel = sal_True )
251 String sRelURL;
253 if( bToRel && (rURL.Len() > 0) )
254 sRelURL = URIHelper::simpleNormalizedMakeRelative(rExport.GetOrigFileName(),
255 rURL);
256 else
257 sRelURL = rURL;
259 if (sRelURL.Len())
261 rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, sRelURL );
262 rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
263 rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
264 rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
268 void lcl_addAspect(
269 const svt::EmbeddedObjectRef& rObj,
270 const XMLPropertyState **pStates,
271 const UniReference < XMLPropertySetMapper >& rMapper )
274 sal_Int64 nAspect = rObj.GetViewAspect();
276 if ( nAspect )
278 *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_DRAW_ASPECT ), uno::makeAny( nAspect ) );
279 pStates++;
284 void lcl_addOutplaceProperties(
285 const svt::EmbeddedObjectRef& rObj,
286 const XMLPropertyState **pStates,
287 const UniReference < XMLPropertySetMapper >& rMapper )
290 MapMode aMode( MAP_100TH_MM ); // the API expects this map mode for the embedded objects
291 Size aSize = rObj.GetSize( &aMode ); // get the size in the requested map mode
293 if( aSize.Width() && aSize.Height() )
295 Any aAny;
296 //aAny <<= (sal_Int32)rVisArea.Left();
297 aAny <<= 0L;
298 *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_LEFT ), aAny );
299 pStates++;
301 //aAny <<= (sal_Int32)rVisArea.Top();
302 aAny <<= 0L;
303 *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_TOP ), aAny );
304 pStates++;
306 //aAny <<= (sal_Int32)rVisArea.GetWidth();
307 aAny <<= (sal_Int32)aSize.Width();
308 *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_WIDTH ), aAny );
309 pStates++;
311 //aAny <<= (sal_Int32)rVisArea.GetHeight();
312 aAny <<= (sal_Int32)aSize.Height();
313 *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_HEIGHT ), aAny );
314 pStates++;
319 void lcl_addFrameProperties(
320 const uno::Reference < embed::XEmbeddedObject >& xObj,
321 const XMLPropertyState **pStates,
322 const UniReference < XMLPropertySetMapper >& rMapper )
324 if ( !::svt::EmbeddedObjectRef::TryRunningState( xObj ) )
325 return;
327 uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
328 if ( !xSet.is() )
329 return;
331 ::rtl::OUString aURL;
332 Any aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameURL") );
333 aAny >>= aURL;
335 ::rtl::OUString aName;
336 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameName") );
337 aAny >>= aName;
339 sal_Bool bIsAutoScroll = sal_False, bIsScrollingMode;
340 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoScroll") );
341 aAny >>= bIsAutoScroll;
342 if ( !bIsAutoScroll )
344 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsScrollingMode") );
345 aAny >>= bIsScrollingMode;
348 sal_Bool bIsBorderSet, bIsAutoBorder = sal_False;
349 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoBorder") );
350 aAny >>= bIsAutoBorder;
351 if ( !bIsAutoBorder )
353 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsBorder") );
354 aAny >>= bIsBorderSet;
357 sal_Int32 nWidth, nHeight;
358 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginWidth") );
359 aAny >>= nWidth;
360 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginHeight") );
361 aAny >>= nHeight;
363 if( !bIsAutoScroll )
365 Any aAny2( &bIsScrollingMode, ::getBooleanCppuType() );
366 *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_DISPLAY_SCROLLBAR ), aAny2 );
367 pStates++;
369 if( !bIsAutoBorder )
371 Any aAny2( &bIsBorderSet, ::getBooleanCppuType() );
372 *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_DISPLAY_BORDER ), aAny2 );
373 pStates++;
375 if( SIZE_NOT_SET != nWidth )
377 Any aAny2;
378 aAny <<= nWidth;
379 *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_MARGIN_HORI ), aAny2 );
380 pStates++;
382 if( SIZE_NOT_SET != nHeight )
384 Any aAny2;
385 aAny <<= nHeight;
386 *pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_MARGIN_VERT ), aAny2 );
387 pStates++;
391 void SwXMLTextParagraphExport::_collectTextEmbeddedAutoStyles(
392 const Reference < XPropertySet > & rPropSet )
394 SwOLENode *pOLENd = GetNoTxtNode( rPropSet )->GetOLENode();
395 svt::EmbeddedObjectRef& rObjRef = pOLENd->GetOLEObj().GetObject();
396 if( !rObjRef.is() )
397 return;
399 const XMLPropertyState *aStates[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
400 SvGlobalName aClassId( rObjRef->getClassID() );
402 if( aIFrameClassId == aClassId )
404 lcl_addFrameProperties( rObjRef.GetObject(), aStates,
405 GetAutoFramePropMapper()->getPropertySetMapper() );
407 else if ( !SotExchange::IsInternal( aClassId ) )
409 lcl_addOutplaceProperties( rObjRef, aStates,
410 GetAutoFramePropMapper()->getPropertySetMapper() );
413 lcl_addAspect( rObjRef, aStates,
414 GetAutoFramePropMapper()->getPropertySetMapper() );
416 Add( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, aStates );
418 const XMLPropertyState **pStates = aStates;
419 while( *pStates )
421 delete *pStates;
422 pStates++;
426 void SwXMLTextParagraphExport::_exportTextEmbedded(
427 const Reference < XPropertySet > & rPropSet,
428 const Reference < XPropertySetInfo > & rPropSetInfo )
430 SwOLENode *pOLENd = GetNoTxtNode( rPropSet )->GetOLENode();
431 SwOLEObj& rOLEObj = pOLENd->GetOLEObj();
432 svt::EmbeddedObjectRef& rObjRef = rOLEObj.GetObject();
433 if( !rObjRef.is() )
434 return;
436 SvGlobalName aClassId( rObjRef->getClassID() );
438 SvEmbeddedObjectTypes nType = SV_EMBEDDED_OWN;
439 if( aPluginClassId == aClassId )
441 nType = SV_EMBEDDED_PLUGIN;
443 else if( aAppletClassId == aClassId )
445 nType = SV_EMBEDDED_APPLET;
447 else if( aIFrameClassId == aClassId )
449 nType = SV_EMBEDDED_FRAME;
451 else if ( !SotExchange::IsInternal( aClassId ) )
453 nType = SV_EMBEDDED_OUTPLACE;
456 enum XMLTokenEnum eElementName = XML__UNKNOWN_;
457 SvXMLExport &rXMLExport = GetExport();
459 // First the stuff common to each of Applet/Plugin/Floating Frame
460 OUString sStyle;
461 Any aAny;
462 if( rPropSetInfo->hasPropertyByName( sFrameStyleName ) )
464 aAny = rPropSet->getPropertyValue( sFrameStyleName );
465 aAny >>= sStyle;
468 const XMLPropertyState *aStates[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
469 switch( nType )
471 case SV_EMBEDDED_FRAME:
472 lcl_addFrameProperties( rObjRef.GetObject(), aStates,
473 GetAutoFramePropMapper()->getPropertySetMapper() );
474 break;
475 case SV_EMBEDDED_OUTPLACE:
476 lcl_addOutplaceProperties( rObjRef, aStates,
477 GetAutoFramePropMapper()->getPropertySetMapper() );
478 break;
479 default:
483 lcl_addAspect( rObjRef, aStates,
484 GetAutoFramePropMapper()->getPropertySetMapper() );
486 OUString sAutoStyle( sStyle );
487 sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, sStyle,
488 aStates );
489 const XMLPropertyState **pStates = aStates;
490 while( *pStates )
492 delete *pStates;
493 pStates++;
496 if( sAutoStyle.getLength() )
497 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_STYLE_NAME, sAutoStyle );
498 addTextFrameAttributes( rPropSet, sal_False );
500 SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW,
501 XML_FRAME, sal_False, sal_True );
503 switch (nType)
505 case SV_EMBEDDED_OUTPLACE:
506 case SV_EMBEDDED_OWN:
507 if( (rXMLExport.getExportFlags() & EXPORT_EMBEDDED) == 0 )
509 OUString sURL;
511 sal_Bool bIsOwnLink = sal_False;
512 if( SV_EMBEDDED_OWN == nType )
516 uno::Reference< embed::XLinkageSupport > xLinkage( rObjRef.GetObject(), uno::UNO_QUERY );
517 bIsOwnLink = xLinkage.is() && xLinkage->isLink();
518 if ( bIsOwnLink )
519 sURL = xLinkage->getLinkURL();
521 catch( uno::Exception )
523 // TODO/LATER: error handling
524 DBG_ERROR( "Link detection or retrieving of the URL of OOo link is failed!\n" );
528 if ( !bIsOwnLink )
530 sURL = OUString( sEmbeddedObjectProtocol );
531 sURL += rOLEObj.GetCurrentPersistName();
534 sURL = GetExport().AddEmbeddedObject( sURL );
535 lcl_addURL( rXMLExport, sURL, sal_False );
537 if( SV_EMBEDDED_OWN == nType && pOLENd->GetChartTblName().Len() )
539 OUString sRange( pOLENd->GetChartTblName() );
540 OUStringBuffer aBuffer( sRange.getLength() + 2 );
541 for( sal_Int32 i=0; i < sRange.getLength(); i++ )
543 sal_Unicode c = sRange[i];
544 switch( c )
546 case ' ':
547 case '.':
548 case '\'':
549 case '\\':
550 if( !aBuffer.getLength() )
552 aBuffer.append( (sal_Unicode)'\'' );
553 aBuffer.append( sRange.copy( 0, i ) );
555 if( '\'' == c || '\\' == c )
556 aBuffer.append( (sal_Unicode)'\\' );
557 // no break!
558 default:
559 if( aBuffer.getLength() )
560 aBuffer.append( c );
563 if( aBuffer.getLength() )
565 aBuffer.append( (sal_Unicode)'\'' );
566 sRange = aBuffer.makeStringAndClear();
569 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES,
570 sRange );
572 eElementName = SV_EMBEDDED_OUTPLACE==nType ? XML_OBJECT_OLE
573 : XML_OBJECT;
574 break;
575 case SV_EMBEDDED_APPLET:
577 // It's an applet!
578 if( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
580 uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
581 ::rtl::OUString aStr;
582 Any aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCodeBase") );
583 aAny2 >>= aStr;
584 if (aStr.getLength() )
585 lcl_addURL(rXMLExport, aStr);
587 aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletName") );
588 aAny2 >>= aStr;
589 if (aStr.getLength())
590 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_APPLET_NAME, aStr );
592 aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCode") );
593 aAny2 >>= aStr;
594 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CODE, aStr );
596 sal_Bool bScript = sal_False;
597 aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletIsScript") );
598 aAny2 >>= bScript;
599 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MAY_SCRIPT, bScript ? XML_TRUE : XML_FALSE );
601 uno::Sequence < beans::PropertyValue > aProps;
602 aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCommands") );
603 aAny2 >>= aProps;
605 sal_Int32 i = aProps.getLength();
606 while ( i > 0 )
608 beans::PropertyValue& aProp = aProps[--i];
609 USHORT nType2 = SwApplet_Impl::GetOptionType( aProp.Name, TRUE );
610 if ( nType2 == SWHTML_OPTTYPE_TAG)
612 ::rtl::OUString aStr2;
613 aProp.Value >>= aStr2;
614 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, aProp.Name, aStr2);
618 eElementName = XML_APPLET;
621 break;
622 case SV_EMBEDDED_PLUGIN:
624 // It's a plugin!
625 if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
627 uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
628 ::rtl::OUString aStr;
629 Any aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("PluginURL") );
630 aAny2 >>= aStr;
631 lcl_addURL( rXMLExport, aStr );
633 aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("PluginMimeType") );
634 aAny2 >>= aStr;
635 if (aStr.getLength())
636 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIME_TYPE, aStr );
637 eElementName = XML_PLUGIN;
640 break;
641 case SV_EMBEDDED_FRAME:
643 // It's a floating frame!
644 if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
646 uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
647 ::rtl::OUString aStr;
648 Any aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameURL") );
649 aAny2 >>= aStr;
651 lcl_addURL( rXMLExport, aStr );
653 aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameName") );
654 aAny2 >>= aStr;
656 if (aStr.getLength())
657 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_FRAME_NAME, aStr );
658 eElementName = XML_FLOATING_FRAME;
661 break;
662 default:
663 ASSERT( !this, "unknown object type! Base class should have been called!" );
667 SvXMLElementExport aElementExport( rXMLExport, XML_NAMESPACE_DRAW, eElementName,
668 sal_False, sal_True );
669 switch( nType )
671 case SV_EMBEDDED_OWN:
672 if( (rXMLExport.getExportFlags() & EXPORT_EMBEDDED) != 0 )
674 Reference < XEmbeddedObjectSupplier > xEOS( rPropSet, UNO_QUERY );
675 ASSERT( xEOS.is(), "no embedded object supplier for own object" );
676 Reference < XComponent > xComp = xEOS->getEmbeddedObject();
677 rXMLExport.ExportEmbeddedOwnObject( xComp );
679 break;
680 case SV_EMBEDDED_OUTPLACE:
681 if( (rXMLExport.getExportFlags() & EXPORT_EMBEDDED) != 0 )
683 OUString sURL( sEmbeddedObjectProtocol );
684 sURL += rOLEObj.GetCurrentPersistName();
686 if ( ( rXMLExport.getExportFlags() & EXPORT_OASIS ) == 0 )
687 sURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "?oasis=false" ) );
689 rXMLExport.AddEmbeddedObjectAsBase64( sURL );
691 break;
692 case SV_EMBEDDED_APPLET:
694 if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
696 uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
697 uno::Sequence < beans::PropertyValue > aProps;
698 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCommands") );
699 aAny >>= aProps;
701 sal_Int32 i = aProps.getLength();
702 while ( i > 0 )
704 beans::PropertyValue& aProp = aProps[--i];
705 USHORT nType2 = SwApplet_Impl::GetOptionType( aProp.Name, TRUE );
706 if (SWHTML_OPTTYPE_PARAM == nType2 || SWHTML_OPTTYPE_SIZE == nType2 )
708 ::rtl::OUString aStr;
709 aProp.Value >>= aStr;
710 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aProp.Name );
711 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
712 SvXMLElementExport aElementExport2( rXMLExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True );
717 break;
718 case SV_EMBEDDED_PLUGIN:
720 if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
722 uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
723 uno::Sequence < beans::PropertyValue > aProps;
724 aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("PluginCommands") );
725 aAny >>= aProps;
727 sal_Int32 i = aProps.getLength();
728 while ( i > 0 )
730 beans::PropertyValue& aProp = aProps[--i];
731 USHORT nType2 = SwApplet_Impl::GetOptionType( aProp.Name, FALSE );
732 if ( nType2 == SWHTML_OPTTYPE_TAG)
734 ::rtl::OUString aStr;
735 aProp.Value >>= aStr;
736 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aProp.Name );
737 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
738 SvXMLElementExport aElementExport2( rXMLExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True );
743 break;
744 default:
745 break;
748 if( SV_EMBEDDED_OUTPLACE==nType || SV_EMBEDDED_OWN==nType )
750 OUString sURL( sGraphicObjectProtocol );
751 sURL += rOLEObj.GetCurrentPersistName();
752 if( (rXMLExport.getExportFlags() & EXPORT_EMBEDDED) == 0 )
754 sURL = GetExport().AddEmbeddedObject( sURL );
755 lcl_addURL( rXMLExport, sURL, sal_False );
758 SvXMLElementExport aElementExport( GetExport(), XML_NAMESPACE_DRAW,
759 XML_IMAGE, sal_False, sal_True );
761 if( (rXMLExport.getExportFlags() & EXPORT_EMBEDDED) != 0 )
762 GetExport().AddEmbeddedObjectAsBase64( sURL );
765 // Lastly the stuff common to each of Applet/Plugin/Floating Frame
766 exportEvents( rPropSet );
767 // --> OD 2009-07-22 #i73249#
768 exportTitleAndDescription( rPropSet, rPropSetInfo );
769 // <--
770 exportContour( rPropSet, rPropSetInfo );