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