xref: /aoo42x/main/sw/source/filter/xml/xmltexte.cxx (revision 870262e3)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 #include <sot/clsids.hxx>
28 #include <com/sun/star/embed/XEmbedObjectCreator.hpp>
29 #include <com/sun/star/embed/XEmbeddedObject.hpp>
30 #include <com/sun/star/embed/XLinkageSupport.hpp>
31 #include <com/sun/star/embed/EmbedStates.hpp>
32 #include <com/sun/star/embed/XClassifiedObject.hpp>
33 #include <com/sun/star/embed/Aspects.hpp>
34 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
35 #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
36 #include <xmloff/families.hxx>
37 #include <xmloff/xmlnmspe.hxx>
38 #include <xmloff/xmltoken.hxx>
39 #include <xmloff/txtprmap.hxx>
40 
41 #include <svx/svdobj.hxx>
42 #include <doc.hxx>
43 #include <ndole.hxx>
44 #include <fmtcntnt.hxx>
45 #include <unostyle.hxx>
46 #include <unoframe.hxx>
47 #include <ndgrf.hxx>
48 #include "xmlexp.hxx"
49 #include "xmltexte.hxx"
50 #include <tools/urlobj.hxx>
51 #include <SwAppletImpl.hxx>
52 
53 #define _SVSTDARR_ULONGS
54 #include <svl/svstdarr.hxx>
55 #include "svl/urihelper.hxx"
56 #include <sfx2/frmdescr.hxx>
57 #include <SwStyleNameMapper.hxx>
58 
59 
60 using ::rtl::OUString;
61 using ::rtl::OUStringBuffer;
62 using namespace ::com::sun::star;
63 using namespace ::com::sun::star::uno;
64 using namespace ::com::sun::star::style;
65 using namespace ::com::sun::star::beans;
66 using namespace ::com::sun::star::lang;
67 using namespace ::com::sun::star::document;
68 using namespace ::com::sun::star::io;
69 using namespace ::xmloff::token;
70 
71 enum SvEmbeddedObjectTypes
72 {
73     SV_EMBEDDED_OWN,
74     SV_EMBEDDED_OUTPLACE,
75     SV_EMBEDDED_APPLET,
76     SV_EMBEDDED_PLUGIN,
77     SV_EMBEDDED_FRAME
78 };
79 
80 const sal_Char sObjectReplacements[] = "ObjectReplacements/";
81 
82 // ---------------------------------------------------------------------
83 
GetNoTxtNode(const Reference<XPropertySet> & rPropSet) const84 SwNoTxtNode *SwXMLTextParagraphExport::GetNoTxtNode(
85 	const Reference < XPropertySet >& rPropSet ) const
86 {
87 	Reference<XUnoTunnel> xCrsrTunnel( rPropSet, UNO_QUERY );
88 	ASSERT( xCrsrTunnel.is(), "missing XUnoTunnel for embedded" );
89 	SwXFrame *pFrame = reinterpret_cast< SwXFrame * >(
90 				sal::static_int_cast< sal_IntPtr >( xCrsrTunnel->getSomething( SwXFrame::getUnoTunnelId() )));
91 	ASSERT( pFrame, "SwXFrame missing" );
92 	SwFrmFmt *pFrmFmt = pFrame->GetFrmFmt();
93 	const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt();
94 	const SwNodeIndex *pNdIdx = rCntnt.GetCntntIdx();
95 	return	pNdIdx->GetNodes()[pNdIdx->GetIndex() + 1]->GetNoTxtNode();
96 }
97 
exportStyleContent(const Reference<XStyle> & rStyle)98 void SwXMLTextParagraphExport::exportStyleContent(
99 		const Reference< XStyle > & rStyle )
100 {
101 
102 	const SwXStyle* pStyle = 0;
103 	Reference<XUnoTunnel> xStyleTunnel( rStyle, UNO_QUERY);
104 	if( xStyleTunnel.is() )
105 	{
106 		pStyle = reinterpret_cast< SwXStyle * >(
107 				sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId() )));
108 	}
109 	if( pStyle && SFX_STYLE_FAMILY_PARA == pStyle->GetFamily() )
110 	{
111 		const SwDoc *pDoc = pStyle->GetDoc();
112 		const SwTxtFmtColl *pColl =
113 			pDoc->FindTxtFmtCollByName( pStyle->GetStyleName() );
114 		ASSERT( pColl, "There is the text collection?" );
115 		if( pColl && RES_CONDTXTFMTCOLL == pColl->Which() )
116 		{
117 			const SwFmtCollConditions& rConditions =
118 				((const SwConditionTxtFmtColl *)pColl)->GetCondColls();
119 			for( sal_uInt16 i=0; i < rConditions.Count(); i++ )
120 			{
121 				const SwCollCondition& rCond = *rConditions[i];
122 
123 				enum XMLTokenEnum eFunc = XML_TOKEN_INVALID;
124 				OUStringBuffer sBuffer( 20 );
125 				switch( rCond.GetCondition() )
126 				{
127 				case PARA_IN_LIST:
128 					eFunc = XML_LIST_LEVEL;
129 					sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
130 					break;
131 				case PARA_IN_OUTLINE:
132 					eFunc = XML_OUTLINE_LEVEL;
133 					sBuffer.append( (sal_Int32)(rCond.GetSubCondition()+1) );
134 					break;
135 				case PARA_IN_FRAME:
136 					eFunc = XML_TEXT_BOX;
137 					break;
138 				case PARA_IN_TABLEHEAD:
139 					eFunc = XML_TABLE_HEADER;
140 					break;
141 				case PARA_IN_TABLEBODY:
142 					eFunc = XML_TABLE;
143 					break;
144 				case PARA_IN_SECTION:
145 					eFunc = XML_SECTION;
146 					break;
147 				case PARA_IN_FOOTENOTE:
148 					eFunc = XML_FOOTNOTE;
149 					break;
150 				case PARA_IN_FOOTER:
151 					eFunc = XML_FOOTER;
152 					break;
153 				case PARA_IN_HEADER:
154 					eFunc = XML_HEADER;
155 					break;
156 				case PARA_IN_ENDNOTE:
157 					eFunc = XML_ENDNOTE;
158 					break;
159 				}
160 				OUString sVal( sBuffer.makeStringAndClear() );
161 
162 				DBG_ASSERT( eFunc != XML_TOKEN_INVALID,
163                             "SwXMLExport::ExportFmt: unknown condition" );
164 				if( eFunc != XML_TOKEN_INVALID )
165 				{
166 					sBuffer.append( GetXMLToken(eFunc) );
167 					sBuffer.append( (sal_Unicode)'(' );
168 					sBuffer.append( (sal_Unicode)')' );
169 					if( sVal.getLength() )
170 					{
171 						sBuffer.append( (sal_Unicode)'=' );
172 						sBuffer.append( sVal );
173 					}
174 
175 					GetExport().AddAttribute( XML_NAMESPACE_STYLE,
176 								XML_CONDITION,
177 								sBuffer.makeStringAndClear() );
178 					String aString;
179 					SwStyleNameMapper::FillProgName(
180 									rCond.GetTxtFmtColl()->GetName(),
181 									aString,
182 									nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL,
183 									sal_True);
184 					aString = GetExport().EncodeStyleName( aString );
185 					GetExport().AddAttribute( XML_NAMESPACE_STYLE,
186 								XML_APPLY_STYLE_NAME, aString );
187 					SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_STYLE,
188 											  XML_MAP, sal_True, sal_True );
189 				}
190 			}
191 		}
192 	}
193 }
194 
SwXMLTextParagraphExport(SwXMLExport & rExp,SvXMLAutoStylePoolP & _rAutoStylePool)195 SwXMLTextParagraphExport::SwXMLTextParagraphExport(
196 		SwXMLExport& rExp,
197 	 	SvXMLAutoStylePoolP& _rAutoStylePool ) :
198 	XMLTextParagraphExport( rExp, _rAutoStylePool ),
199 	sTextTable( RTL_CONSTASCII_USTRINGPARAM( "TextTable" ) ),
200 	sEmbeddedObjectProtocol( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ) ),
201 	sGraphicObjectProtocol( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:" ) ),
202 	aAppletClassId( SO3_APPLET_CLASSID ),
203 	aPluginClassId( SO3_PLUGIN_CLASSID ),
204 	aIFrameClassId( SO3_IFRAME_CLASSID ),
205 	aOutplaceClassId( SO3_OUT_CLASSID )
206 {
207 }
208 
~SwXMLTextParagraphExport()209 SwXMLTextParagraphExport::~SwXMLTextParagraphExport()
210 {
211 }
212 
setTextEmbeddedGraphicURL(const Reference<XPropertySet> & rPropSet,OUString & rURL) const213 void SwXMLTextParagraphExport::setTextEmbeddedGraphicURL(
214     const Reference< XPropertySet >& rPropSet,
215     OUString& rURL ) const
216     {
217     if ( !rURL.getLength() )
218         return;
219 
220     SwGrfNode *pGrfNd = GetNoTxtNode( rPropSet )->GetGrfNode();
221     if ( !pGrfNd->IsGrfLink() )
222     {
223         // Apply new embedded stream name, only if graphic node already has one.
224         // - The saving of recovery information triggers this method, but for a newly created
225         //   document the new embedded stream name shall not be applied.
226         // - The saving of a newly created document to own format (ODF) triggers this method,
227         //   but the embedded stream name is not needed as its original inserted data is still in use.
228         if ( pGrfNd->HasEmbeddedStreamName() )
229         {
230             String aNewURL( RTL_CONSTASCII_STRINGPARAM( "vnd.sun.star.Package:" ) );
231             aNewURL += String( rURL );
232             pGrfNd->ApplyNewEmbeddedStreamName( aNewURL );
233         }
234 
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();
238     }
239 }
240 
241 
lcl_addURL(SvXMLExport & rExport,const String & rURL,sal_Bool bToRel=sal_True)242 static void lcl_addURL ( SvXMLExport &rExport, const String &rURL,
243 						 sal_Bool bToRel = sal_True )
244 {
245     String sRelURL;
246 
247 	if( bToRel && (rURL.Len() > 0) )
248     sRelURL = URIHelper::simpleNormalizedMakeRelative(rExport.GetOrigFileName(),
249               rURL);
250 	else
251 		sRelURL = rURL;
252 
253     if (sRelURL.Len())
254     {
255         rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_HREF, sRelURL );
256         rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
257         rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_SHOW, XML_EMBED );
258         rExport.AddAttribute ( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONLOAD );
259     }
260 }
261 
lcl_addAspect(const svt::EmbeddedObjectRef & rObj,const XMLPropertyState ** pStates,const UniReference<XMLPropertySetMapper> & rMapper)262 void lcl_addAspect(
263 		const svt::EmbeddedObjectRef& rObj,
264 		const XMLPropertyState **pStates,
265 		const UniReference < XMLPropertySetMapper >& rMapper )
266 {
267 	{
268 		sal_Int64 nAspect = rObj.GetViewAspect();
269 
270 		if ( nAspect )
271 		{
272 			*pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_DRAW_ASPECT ), uno::makeAny( nAspect ) );
273 			pStates++;
274 		}
275 	}
276 }
277 
lcl_addOutplaceProperties(const svt::EmbeddedObjectRef & rObj,const XMLPropertyState ** pStates,const UniReference<XMLPropertySetMapper> & rMapper)278 void lcl_addOutplaceProperties(
279 		const svt::EmbeddedObjectRef& rObj,
280 		const XMLPropertyState **pStates,
281 		const UniReference < XMLPropertySetMapper >& rMapper )
282 {
283 	{
284         MapMode aMode( MAP_100TH_MM ); // the API expects this map mode for the embedded objects
285 		Size aSize = rObj.GetSize( &aMode ); // get the size in the requested map mode
286 
287         if( aSize.Width() && aSize.Height() )
288 		{
289 			Any aAny;
290             //aAny <<= (sal_Int32)rVisArea.Left();
291             aAny <<= 0L;
292 			*pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_LEFT ), aAny );
293 			pStates++;
294 
295             //aAny <<= (sal_Int32)rVisArea.Top();
296             aAny <<= 0L;
297 			*pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_TOP ), aAny );
298 			pStates++;
299 
300             //aAny <<= (sal_Int32)rVisArea.GetWidth();
301             aAny <<= (sal_Int32)aSize.Width();
302 			*pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_WIDTH ), aAny );
303 			pStates++;
304 
305             //aAny <<= (sal_Int32)rVisArea.GetHeight();
306             aAny <<= (sal_Int32)aSize.Height();
307 			*pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_OLE_VIS_AREA_HEIGHT ), aAny );
308 			pStates++;
309 		}
310 	}
311 }
312 
lcl_addFrameProperties(const uno::Reference<embed::XEmbeddedObject> & xObj,const XMLPropertyState ** pStates,const UniReference<XMLPropertySetMapper> & rMapper)313 void lcl_addFrameProperties(
314         const uno::Reference < embed::XEmbeddedObject >& xObj,
315 		const XMLPropertyState **pStates,
316 		const UniReference < XMLPropertySetMapper >& rMapper )
317 {
318     if ( !::svt::EmbeddedObjectRef::TryRunningState( xObj ) )
319         return;
320 
321     uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
322     if ( !xSet.is() )
323         return;
324 
325     ::rtl::OUString aURL;
326     Any aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameURL") );
327     aAny >>= aURL;
328 
329     ::rtl::OUString aName;
330     aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameName") );
331     aAny >>= aName;
332 
333     sal_Bool bIsAutoScroll = sal_False, bIsScrollingMode;
334     aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoScroll") );
335     aAny >>= bIsAutoScroll;
336     if ( !bIsAutoScroll )
337     {
338         aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsScrollingMode") );
339         aAny >>= bIsScrollingMode;
340     }
341 
342     sal_Bool bIsBorderSet, bIsAutoBorder = sal_False;
343     aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsAutoBorder") );
344     aAny >>= bIsAutoBorder;
345     if ( !bIsAutoBorder )
346     {
347         aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameIsBorder") );
348         aAny >>= bIsBorderSet;
349     }
350 
351     sal_Int32 nWidth, nHeight;
352     aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginWidth") );
353     aAny >>= nWidth;
354     aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameMarginHeight") );
355     aAny >>= nHeight;
356 
357     if( !bIsAutoScroll )
358 	{
359         Any aAny2( &bIsScrollingMode, ::getBooleanCppuType() );
360 		*pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_DISPLAY_SCROLLBAR ), aAny2 );
361 		pStates++;
362 	}
363     if( !bIsAutoBorder )
364 	{
365         Any aAny2( &bIsBorderSet, ::getBooleanCppuType() );
366 		*pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_DISPLAY_BORDER ), aAny2 );
367 		pStates++;
368 	}
369     if( SIZE_NOT_SET != nWidth )
370 	{
371 		Any aAny2;
372         aAny <<= nWidth;
373 		*pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_MARGIN_HORI ), aAny2 );
374 		pStates++;
375 	}
376     if( SIZE_NOT_SET != nHeight )
377 	{
378 		Any aAny2;
379         aAny <<= nHeight;
380 		*pStates = new XMLPropertyState( rMapper->FindEntryIndex( CTF_FRAME_MARGIN_VERT ), aAny2 );
381 		pStates++;
382 	}
383 }
384 
_collectTextEmbeddedAutoStyles(const Reference<XPropertySet> & rPropSet)385 void SwXMLTextParagraphExport::_collectTextEmbeddedAutoStyles(
386 		const Reference < XPropertySet > & rPropSet )
387 {
388 	SwOLENode *pOLENd = GetNoTxtNode( rPropSet )->GetOLENode();
389 	svt::EmbeddedObjectRef& rObjRef = pOLENd->GetOLEObj().GetObject();
390     if( !rObjRef.is() )
391 		return;
392 
393 	const XMLPropertyState *aStates[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
394     SvGlobalName aClassId( rObjRef->getClassID() );
395 
396     if( aIFrameClassId == aClassId )
397 	{
398         lcl_addFrameProperties( rObjRef.GetObject(), aStates,
399 		   	GetAutoFramePropMapper()->getPropertySetMapper() );
400 	}
401     else if ( !SotExchange::IsInternal( aClassId ) )
402     {
403         lcl_addOutplaceProperties( rObjRef, aStates,
404 		   	GetAutoFramePropMapper()->getPropertySetMapper() );
405     }
406 
407     lcl_addAspect( rObjRef, aStates,
408 	   	GetAutoFramePropMapper()->getPropertySetMapper() );
409 
410 	Add( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, aStates );
411 
412 	const XMLPropertyState **pStates = aStates;
413 	while( *pStates )
414 	{
415 		delete *pStates;
416 		pStates++;
417 	}
418 }
419 
_exportTextEmbedded(const Reference<XPropertySet> & rPropSet,const Reference<XPropertySetInfo> & rPropSetInfo)420 void SwXMLTextParagraphExport::_exportTextEmbedded(
421 		const Reference < XPropertySet > & rPropSet,
422 		const Reference < XPropertySetInfo > & rPropSetInfo )
423 {
424 	SwOLENode *pOLENd = GetNoTxtNode( rPropSet )->GetOLENode();
425 	SwOLEObj& rOLEObj = pOLENd->GetOLEObj();
426 	svt::EmbeddedObjectRef& rObjRef = rOLEObj.GetObject();
427     if( !rObjRef.is() )
428 		return;
429 
430     SvGlobalName aClassId( rObjRef->getClassID() );
431 
432     SvEmbeddedObjectTypes nType = SV_EMBEDDED_OWN;
433 	if( aPluginClassId == aClassId )
434 	{
435         nType = SV_EMBEDDED_PLUGIN;
436 	}
437 	else if( aAppletClassId == aClassId )
438 	{
439         nType = SV_EMBEDDED_APPLET;
440 	}
441 	else if( aIFrameClassId == aClassId )
442 	{
443         nType = SV_EMBEDDED_FRAME;
444 	}
445     else if ( !SotExchange::IsInternal( aClassId ) )
446 	{
447         nType = SV_EMBEDDED_OUTPLACE;
448 	}
449 
450     enum XMLTokenEnum eElementName = XML__UNKNOWN_;
451     SvXMLExport &rXMLExport = GetExport();
452 
453 	// First the stuff common to each of Applet/Plugin/Floating Frame
454 	OUString sStyle;
455 	Any aAny;
456 	if( rPropSetInfo->hasPropertyByName( sFrameStyleName ) )
457 	{
458 		aAny = rPropSet->getPropertyValue( sFrameStyleName );
459 		aAny >>= sStyle;
460 	}
461 
462 	const XMLPropertyState *aStates[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
463 	switch( nType )
464 	{
465 	case SV_EMBEDDED_FRAME:
466         lcl_addFrameProperties( rObjRef.GetObject(), aStates,
467 			GetAutoFramePropMapper()->getPropertySetMapper() );
468 		break;
469 	case SV_EMBEDDED_OUTPLACE:
470         lcl_addOutplaceProperties( rObjRef, aStates,
471 			GetAutoFramePropMapper()->getPropertySetMapper() );
472 		break;
473 	default:
474 		;
475 	}
476 
477     lcl_addAspect( rObjRef, aStates,
478 		GetAutoFramePropMapper()->getPropertySetMapper() );
479 
480 	OUString sAutoStyle( sStyle );
481 	sAutoStyle = Find( XML_STYLE_FAMILY_TEXT_FRAME, rPropSet, sStyle,
482 					   aStates );
483 	const XMLPropertyState **pStates = aStates;
484 	while( *pStates )
485 	{
486 		delete *pStates;
487 		pStates++;
488 	}
489 
490 	if( sAutoStyle.getLength() )
491 		rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_STYLE_NAME, sAutoStyle );
492 	addTextFrameAttributes( rPropSet, sal_False );
493 
494 	SvXMLElementExport aElem( GetExport(), XML_NAMESPACE_DRAW,
495 							  XML_FRAME, sal_False, sal_True );
496 
497 	switch (nType)
498 	{
499 	case SV_EMBEDDED_OUTPLACE:
500 	case SV_EMBEDDED_OWN:
501 		if( (rXMLExport.getExportFlags() & EXPORT_EMBEDDED) == 0 )
502 		{
503 			OUString sURL;
504 
505 			sal_Bool bIsOwnLink = sal_False;
506 			if( SV_EMBEDDED_OWN == nType )
507 			{
508 				try
509 				{
510 					uno::Reference< embed::XLinkageSupport > xLinkage( rObjRef.GetObject(), uno::UNO_QUERY );
511 					bIsOwnLink = xLinkage.is() && xLinkage->isLink();
512 					if ( bIsOwnLink )
513 						sURL = xLinkage->getLinkURL();
514 				}
515 				catch( uno::Exception )
516 				{
517 					// TODO/LATER: error handling
518 					DBG_ERROR( "Link detection or retrieving of the URL of OOo link is failed!\n" );
519 				}
520 			}
521 
522 			if ( !bIsOwnLink )
523 			{
524 				sURL = OUString( sEmbeddedObjectProtocol );
525                 sURL += rOLEObj.GetCurrentPersistName();
526 			}
527 
528 			sURL = GetExport().AddEmbeddedObject( sURL );
529 			lcl_addURL( rXMLExport, sURL, sal_False );
530 		}
531 		if( SV_EMBEDDED_OWN == nType && pOLENd->GetChartTblName().Len() )
532 		{
533 			OUString sRange( pOLENd->GetChartTblName() );
534 			OUStringBuffer aBuffer( sRange.getLength() + 2 );
535 			for( sal_Int32 i=0; i < sRange.getLength(); i++ )
536 			{
537 				sal_Unicode c = sRange[i];
538 				switch( c  )
539 				{
540 					case ' ':
541 					case '.':
542 					case '\'':
543 					case '\\':
544 						if( !aBuffer.getLength() )
545 						{
546 							aBuffer.append( (sal_Unicode)'\'' );
547 							aBuffer.append( sRange.copy( 0, i ) );
548 						}
549 						if( '\'' == c || '\\' == c )
550 							aBuffer.append( (sal_Unicode)'\\' );
551 						// no break!
552 					default:
553 						if( aBuffer.getLength() )
554 							aBuffer.append( c );
555 				}
556 			}
557 			if( aBuffer.getLength() )
558 			{
559 				aBuffer.append( (sal_Unicode)'\'' );
560 				sRange = aBuffer.makeStringAndClear();
561 			}
562 
563 			rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NOTIFY_ON_UPDATE_OF_RANGES,
564 			sRange );
565 		}
566 		eElementName = SV_EMBEDDED_OUTPLACE==nType ? XML_OBJECT_OLE
567 												   : XML_OBJECT;
568 		break;
569 	case SV_EMBEDDED_APPLET:
570 		{
571 			// It's an applet!
572             if( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
573             {
574                 uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
575                 ::rtl::OUString aStr;
576                 Any aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCodeBase") );
577                 aAny2 >>= aStr;
578                 if (aStr.getLength() )
579                     lcl_addURL(rXMLExport, aStr);
580 
581                 aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletName") );
582                 aAny2 >>= aStr;
583                 if (aStr.getLength())
584                     rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_APPLET_NAME, aStr );
585 
586                 aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCode") );
587                 aAny2 >>= aStr;
588                 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_CODE, aStr );
589 
590                 sal_Bool bScript = sal_False;
591                 aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletIsScript") );
592                 aAny2 >>= bScript;
593                 rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MAY_SCRIPT, bScript ? XML_TRUE : XML_FALSE );
594 
595                 uno::Sequence < beans::PropertyValue > aProps;
596                 aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCommands") );
597                 aAny2 >>= aProps;
598 
599                 sal_Int32 i = aProps.getLength();
600                 while ( i > 0 )
601                 {
602                     beans::PropertyValue& aProp = aProps[--i];
603                     sal_uInt16 nType2 = SwApplet_Impl::GetOptionType( aProp.Name, sal_True );
604                     if ( nType2 == SWHTML_OPTTYPE_TAG)
605                     {
606                         ::rtl::OUString aStr2;
607                         aProp.Value >>= aStr2;
608                         rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, aProp.Name, aStr2);
609                     }
610                 }
611 
612                 eElementName = XML_APPLET;
613             }
614 		}
615 		break;
616 	case SV_EMBEDDED_PLUGIN:
617 		{
618 			// It's a plugin!
619             if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
620             {
621                 uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
622                 ::rtl::OUString aStr;
623                 Any aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("PluginURL") );
624                 aAny2 >>= aStr;
625                 lcl_addURL( rXMLExport, aStr );
626 
627                 aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("PluginMimeType") );
628                 aAny2 >>= aStr;
629                 if (aStr.getLength())
630                     rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_MIME_TYPE, aStr );
631                 eElementName = XML_PLUGIN;
632             }
633 		}
634 		break;
635 	case SV_EMBEDDED_FRAME:
636 		{
637 			// It's a floating frame!
638             if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
639             {
640                 uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
641                 ::rtl::OUString aStr;
642                 Any aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameURL") );
643                 aAny2 >>= aStr;
644 
645                 lcl_addURL( rXMLExport, aStr );
646 
647                 aAny2 = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("FrameName") );
648                 aAny2 >>= aStr;
649 
650                 if (aStr.getLength())
651                     rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_FRAME_NAME, aStr );
652                 eElementName = XML_FLOATING_FRAME;
653             }
654 		}
655 		break;
656 	default:
657 		ASSERT( sal_False, "unknown object type! Base class should have been called!" );
658 	}
659 
660 	{
661 		SvXMLElementExport aElementExport( rXMLExport, XML_NAMESPACE_DRAW, eElementName,
662 									  sal_False, sal_True );
663 		switch( nType )
664 		{
665 		case SV_EMBEDDED_OWN:
666 			if( (rXMLExport.getExportFlags() & EXPORT_EMBEDDED) != 0 )
667 			{
668 				Reference < XEmbeddedObjectSupplier > xEOS( rPropSet, UNO_QUERY );
669 				ASSERT( xEOS.is(), "no embedded object supplier for own object" );
670 				Reference < XComponent > xComp = xEOS->getEmbeddedObject();
671 				rXMLExport.ExportEmbeddedOwnObject( xComp );
672 			}
673 			break;
674 		case SV_EMBEDDED_OUTPLACE:
675 			if( (rXMLExport.getExportFlags() & EXPORT_EMBEDDED) != 0 )
676 			{
677 				OUString sURL( sEmbeddedObjectProtocol );
678             	sURL += rOLEObj.GetCurrentPersistName();
679 
680 				if ( ( rXMLExport.getExportFlags() & EXPORT_OASIS ) == 0 )
681 					sURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "?oasis=false" ) );
682 
683 				rXMLExport.AddEmbeddedObjectAsBase64( sURL );
684 			}
685 			break;
686 		case SV_EMBEDDED_APPLET:
687 			{
688                 if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
689                 {
690                     uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
691                     uno::Sequence < beans::PropertyValue > aProps;
692                     aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("AppletCommands") );
693                     aAny >>= aProps;
694 
695                     sal_Int32 i = aProps.getLength();
696                     while ( i > 0 )
697                     {
698                         beans::PropertyValue& aProp = aProps[--i];
699                         sal_uInt16 nType2 = SwApplet_Impl::GetOptionType( aProp.Name, sal_True );
700                         if (SWHTML_OPTTYPE_PARAM == nType2 || SWHTML_OPTTYPE_SIZE == nType2 )
701                         {
702                             ::rtl::OUString aStr;
703                             aProp.Value >>= aStr;
704                             rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aProp.Name );
705                             rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
706                             SvXMLElementExport aElementExport2( rXMLExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True );
707                         }
708                     }
709                 }
710 			}
711 			break;
712 		case SV_EMBEDDED_PLUGIN:
713 			{
714                 if ( svt::EmbeddedObjectRef::TryRunningState( rObjRef.GetObject() ) )
715                 {
716                     uno::Reference < beans::XPropertySet > xSet( rObjRef->getComponent(), uno::UNO_QUERY );
717                     uno::Sequence < beans::PropertyValue > aProps;
718                     aAny = xSet->getPropertyValue( ::rtl::OUString::createFromAscii("PluginCommands") );
719                     aAny >>= aProps;
720 
721                     sal_Int32 i = aProps.getLength();
722                     while ( i > 0 )
723                     {
724                         beans::PropertyValue& aProp = aProps[--i];
725                         sal_uInt16 nType2 = SwApplet_Impl::GetOptionType( aProp.Name, sal_False );
726                         if ( nType2 == SWHTML_OPTTYPE_TAG)
727                         {
728                             ::rtl::OUString aStr;
729                             aProp.Value >>= aStr;
730                             rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, aProp.Name );
731                             rXMLExport.AddAttribute( XML_NAMESPACE_DRAW, XML_VALUE, aStr );
732                             SvXMLElementExport aElementExport2( rXMLExport, XML_NAMESPACE_DRAW, XML_PARAM, sal_False, sal_True );
733                         }
734                     }
735                 }
736 			}
737 			break;
738 		default:
739 			break;
740 		}
741 	}
742 	if( SV_EMBEDDED_OUTPLACE==nType || SV_EMBEDDED_OWN==nType )
743 	{
744 		OUString sURL( sGraphicObjectProtocol );
745 		sURL += rOLEObj.GetCurrentPersistName();
746 		if( (rXMLExport.getExportFlags() & EXPORT_EMBEDDED) == 0 )
747 		{
748 			sURL = GetExport().AddEmbeddedObject( sURL );
749 			lcl_addURL( rXMLExport, sURL, sal_False );
750 		}
751 
752 		SvXMLElementExport aElementExport( GetExport(), XML_NAMESPACE_DRAW,
753 								  XML_IMAGE, sal_False, sal_True );
754 
755 		if( (rXMLExport.getExportFlags() & EXPORT_EMBEDDED) != 0 )
756 			GetExport().AddEmbeddedObjectAsBase64( sURL );
757 	}
758 
759 	// Lastly the stuff common to each of Applet/Plugin/Floating Frame
760 	exportEvents( rPropSet );
761     // --> OD 2009-07-22 #i73249#
762     exportTitleAndDescription( rPropSet, rPropSetInfo );
763     // <--
764 	exportContour( rPropSet, rPropSetInfo );
765 }
766