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