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