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 "oox/drawingml/shape.hxx"
21 : #include "drawingml/customshapeproperties.hxx"
22 : #include "oox/drawingml/theme.hxx"
23 : #include "oox/drawingml/fillproperties.hxx"
24 : #include "drawingml/graphicproperties.hxx"
25 : #include <drawingml/scene3dcontext.hxx>
26 : #include "oox/drawingml/lineproperties.hxx"
27 : #include "effectproperties.hxx"
28 : #include "oox/drawingml/shapepropertymap.hxx"
29 : #include "drawingml/textbody.hxx"
30 : #include <drawingml/ThemeOverrideFragmentHandler.hxx>
31 : #include "drawingml/table/tableproperties.hxx"
32 : #include "oox/drawingml/chart/chartconverter.hxx"
33 : #include "drawingml/chart/chartspacefragment.hxx"
34 : #include "drawingml/chart/chartspacemodel.hxx"
35 : #include "oox/ppt/pptimport.hxx"
36 : #include "oox/vml/vmldrawing.hxx"
37 : #include "oox/vml/vmlshape.hxx"
38 : #include "oox/vml/vmlshapecontainer.hxx"
39 : #include "oox/core/xmlfilterbase.hxx"
40 : #include "oox/helper/graphichelper.hxx"
41 : #include "oox/helper/propertyset.hxx"
42 : #include "oox/helper/modelobjecthelper.hxx"
43 :
44 : #include <tools/gen.hxx>
45 : #include <tools/mapunit.hxx>
46 : #include <editeng/unoprnms.hxx>
47 : #include <com/sun/star/awt/Size.hpp>
48 : #include <com/sun/star/graphic/XGraphic.hpp>
49 : #include <com/sun/star/container/XNamed.hpp>
50 : #include <com/sun/star/container/XNameContainer.hpp>
51 : #include <com/sun/star/beans/XMultiPropertySet.hpp>
52 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
53 : #include <com/sun/star/xml/AttributeData.hpp>
54 : #include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
55 : #include <com/sun/star/drawing/HomogenMatrix3.hpp>
56 : #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
57 : #include <com/sun/star/drawing/GraphicExportFilter.hpp>
58 : #include <com/sun/star/text/XText.hpp>
59 : #include <com/sun/star/table/BorderLine2.hpp>
60 : #include <com/sun/star/table/ShadowFormat.hpp>
61 : #include <com/sun/star/chart2/XChartDocument.hpp>
62 : #include <com/sun/star/style/ParagraphAdjust.hpp>
63 : #include <com/sun/star/io/XOutputStream.hpp>
64 :
65 : #include <basegfx/point/b2dpoint.hxx>
66 : #include <basegfx/polygon/b2dpolygon.hxx>
67 : #include <basegfx/matrix/b2dhommatrix.hxx>
68 : #include <com/sun/star/document/XActionLockable.hpp>
69 : #include <com/sun/star/chart2/data/XDataReceiver.hpp>
70 : #include <svl/outstrm.hxx>
71 : #include <svx/svdtrans.hxx>
72 : #include <unotools/streamwrap.hxx>
73 : #include <unotools/fltrcfg.hxx>
74 : #include <vcl/graph.hxx>
75 : #include <vcl/graphicfilter.hxx>
76 : #include <vcl/svapp.hxx>
77 :
78 : #include <vcl/wmf.hxx>
79 :
80 : using namespace ::oox::core;
81 : using namespace ::com::sun::star;
82 : using namespace ::com::sun::star::uno;
83 : using namespace ::com::sun::star::beans;
84 : using namespace ::com::sun::star::frame;
85 : using namespace ::com::sun::star::text;
86 : using namespace ::com::sun::star::drawing;
87 : using namespace ::com::sun::star::style;
88 :
89 : namespace oox { namespace drawingml {
90 :
91 : #define PUT_PROP( aProperties, nPos, sPropName, aPropValue ) \
92 : aProperties[nPos].Name = sPropName; \
93 : aProperties[nPos].Value = Any( aPropValue );
94 :
95 13004 : Shape::Shape( const sal_Char* pServiceName, bool bDefaultHeight )
96 : : mbIsChild( false )
97 13004 : , mpLinePropertiesPtr( new LineProperties )
98 13004 : , mpShapeRefLinePropPtr( new LineProperties )
99 13004 : , mpFillPropertiesPtr( new FillProperties )
100 13004 : , mpShapeRefFillPropPtr( new FillProperties )
101 13004 : , mpGraphicPropertiesPtr( new GraphicProperties )
102 13004 : , mpCustomShapePropertiesPtr( new CustomShapeProperties )
103 13004 : , mp3DPropertiesPtr( new Shape3DProperties )
104 13004 : , mpEffectPropertiesPtr( new EffectProperties )
105 13004 : , mpShapeRefEffectPropPtr( new EffectProperties )
106 13004 : , mpMasterTextListStyle( new TextListStyle )
107 : , mnSubType( 0 )
108 : , meFrameType( FRAMETYPE_GENERIC )
109 : , mnRotation( 0 )
110 : , mbFlipH( false )
111 : , mbFlipV( false )
112 : , mbHidden( false )
113 : , mbHiddenMasterShape( false )
114 : , mbLockedCanvas( false )
115 : , mbWps( false )
116 : , mbTextBox( false )
117 : , mbHasLinkedTxbx( false )
118 143044 : , maDiagramDoms( 0 )
119 : {
120 13004 : if ( pServiceName )
121 4374 : msServiceName = OUString::createFromAscii( pServiceName );
122 13004 : setDefaults(bDefaultHeight);
123 13004 : }
124 :
125 173 : Shape::Shape( const ShapePtr& pSourceShape )
126 : : maChildren()
127 173 : , mbIsChild( pSourceShape->mbIsChild )
128 173 : , mpTextBody(pSourceShape->mpTextBody)
129 173 : , mpLinePropertiesPtr( pSourceShape->mpLinePropertiesPtr )
130 173 : , mpShapeRefLinePropPtr( pSourceShape->mpShapeRefLinePropPtr )
131 173 : , mpFillPropertiesPtr( pSourceShape->mpFillPropertiesPtr )
132 173 : , mpShapeRefFillPropPtr( pSourceShape->mpShapeRefFillPropPtr )
133 173 : , mpGraphicPropertiesPtr( pSourceShape->mpGraphicPropertiesPtr )
134 173 : , mpCustomShapePropertiesPtr( pSourceShape->mpCustomShapePropertiesPtr )
135 173 : , mpTablePropertiesPtr( pSourceShape->mpTablePropertiesPtr )
136 173 : , mp3DPropertiesPtr( pSourceShape->mp3DPropertiesPtr )
137 173 : , mpEffectPropertiesPtr (pSourceShape->mpEffectPropertiesPtr)
138 173 : , mpShapeRefEffectPropPtr(pSourceShape->mpShapeRefEffectPropPtr)
139 173 : , maShapeProperties( pSourceShape->maShapeProperties )
140 173 : , mpMasterTextListStyle( pSourceShape->mpMasterTextListStyle )
141 : , mxShape()
142 173 : , msServiceName( pSourceShape->msServiceName )
143 173 : , msName( pSourceShape->msName )
144 173 : , msId( pSourceShape->msId )
145 173 : , mnSubType( pSourceShape->mnSubType )
146 173 : , moSubTypeIndex( pSourceShape->moSubTypeIndex )
147 173 : , maShapeStyleRefs( pSourceShape->maShapeStyleRefs )
148 173 : , maSize( pSourceShape->maSize )
149 173 : , maPosition( pSourceShape->maPosition )
150 173 : , meFrameType( pSourceShape->meFrameType )
151 173 : , mnRotation( pSourceShape->mnRotation )
152 173 : , mbFlipH( pSourceShape->mbFlipH )
153 173 : , mbFlipV( pSourceShape->mbFlipV )
154 173 : , mbHidden( pSourceShape->mbHidden )
155 173 : , mbHiddenMasterShape( pSourceShape->mbHiddenMasterShape )
156 173 : , mbLockedCanvas( pSourceShape->mbLockedCanvas )
157 173 : , mbWps( pSourceShape->mbWps )
158 173 : , mbTextBox( pSourceShape->mbTextBox )
159 : , maLinkedTxbxAttr()
160 : , mbHasLinkedTxbx(false)
161 5536 : , maDiagramDoms( pSourceShape->maDiagramDoms )
162 173 : {}
163 :
164 18679 : Shape::~Shape()
165 : {
166 18679 : }
167 :
168 12 : table::TablePropertiesPtr Shape::getTableProperties()
169 : {
170 12 : if ( !mpTablePropertiesPtr.get() )
171 12 : mpTablePropertiesPtr.reset( new table::TableProperties() );
172 12 : return mpTablePropertiesPtr;
173 : }
174 :
175 13004 : void Shape::setDefaults(bool bHeight)
176 : {
177 13004 : maDefaultShapeProperties.setProperty(PROP_TextAutoGrowHeight, false);
178 13004 : maDefaultShapeProperties.setProperty(PROP_TextWordWrap, true);
179 13004 : maDefaultShapeProperties.setProperty(PROP_TextLeftDistance, static_cast< sal_Int32 >( 250 ));
180 13004 : maDefaultShapeProperties.setProperty(PROP_TextUpperDistance, static_cast< sal_Int32 >( 125 ));
181 13004 : maDefaultShapeProperties.setProperty(PROP_TextRightDistance, static_cast< sal_Int32 >( 250 ));
182 13004 : maDefaultShapeProperties.setProperty(PROP_TextLowerDistance, static_cast< sal_Int32 >( 125 ));
183 13004 : if (bHeight)
184 12603 : maDefaultShapeProperties.setProperty(PROP_CharHeight, static_cast< float >( 18.0 ));
185 13004 : maDefaultShapeProperties.setProperty(PROP_TextVerticalAdjust, TextVerticalAdjust_TOP);
186 13004 : maDefaultShapeProperties.setProperty(PROP_ParaAdjust, static_cast< sal_Int16 >( ParagraphAdjust_LEFT )); // check for RTL?
187 13004 : }
188 :
189 4 : ::oox::vml::OleObjectInfo& Shape::setOleObjectType()
190 : {
191 : OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setOleObjectType - multiple frame types" );
192 4 : meFrameType = FRAMETYPE_OLEOBJECT;
193 4 : mxOleObjectInfo.reset( new ::oox::vml::OleObjectInfo( true ) );
194 4 : return *mxOleObjectInfo;
195 : }
196 :
197 169 : ChartShapeInfo& Shape::setChartType( bool bEmbedShapes )
198 : {
199 : OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setChartType - multiple frame types" );
200 169 : meFrameType = FRAMETYPE_CHART;
201 169 : msServiceName = "com.sun.star.drawing.OLE2Shape";
202 169 : mxChartShapeInfo.reset( new ChartShapeInfo( bEmbedShapes ) );
203 169 : return *mxChartShapeInfo;
204 : }
205 :
206 75 : void Shape::setDiagramType()
207 : {
208 : OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setDiagramType - multiple frame types" );
209 75 : meFrameType = FRAMETYPE_DIAGRAM;
210 75 : msServiceName = "com.sun.star.drawing.GroupShape";
211 75 : mnSubType = 0;
212 75 : }
213 :
214 12 : void Shape::setTableType()
215 : {
216 : OSL_ENSURE( meFrameType == FRAMETYPE_GENERIC, "Shape::setTableType - multiple frame types" );
217 12 : meFrameType = FRAMETYPE_TABLE;
218 12 : msServiceName = "com.sun.star.drawing.TableShape";
219 12 : mnSubType = 0;
220 12 : }
221 :
222 86 : void Shape::setServiceName( const sal_Char* pServiceName )
223 : {
224 86 : if ( pServiceName )
225 86 : msServiceName = OUString::createFromAscii( pServiceName );
226 86 : }
227 :
228 10680 : const ShapeStyleRef* Shape::getShapeStyleRef( sal_Int32 nRefType ) const
229 : {
230 10680 : ShapeStyleRefMap::const_iterator aIt = maShapeStyleRefs.find( nRefType );
231 10680 : return (aIt == maShapeStyleRefs.end()) ? 0 : &aIt->second;
232 : }
233 :
234 2394 : void Shape::addShape(
235 : ::oox::core::XmlFilterBase& rFilterBase,
236 : const Theme* pTheme,
237 : const Reference< XShapes >& rxShapes,
238 : const basegfx::B2DHomMatrix& aTransformation,
239 : FillProperties& rShapeOrParentShapeFillProps,
240 : const awt::Rectangle* pShapeRect,
241 : ShapeIdMap* pShapeMap )
242 : {
243 : SAL_INFO("oox.drawingml", OSL_THIS_FUNC << " id: " << msId);
244 :
245 : try
246 : {
247 2394 : OUString sServiceName( msServiceName );
248 2394 : if( !sServiceName.isEmpty() )
249 : {
250 2394 : basegfx::B2DHomMatrix aMatrix( aTransformation );
251 4788 : Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, false, false, aMatrix, rShapeOrParentShapeFillProps ) );
252 :
253 2394 : if( pShapeMap && !msId.isEmpty() )
254 : {
255 126 : (*pShapeMap)[ msId ] = shared_from_this();
256 : }
257 :
258 : // if this is a group shape, we have to add also each child shape
259 4788 : Reference< XShapes > xShapes( xShape, UNO_QUERY );
260 2394 : if ( xShapes.is() )
261 222 : addChildren( rFilterBase, *this, pTheme, xShapes, pShapeRect ? *pShapeRect : awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ), pShapeMap, aMatrix );
262 :
263 2394 : if( meFrameType == FRAMETYPE_DIAGRAM )
264 : {
265 38 : if( !SvtFilterOptions::Get().IsSmartArt2Shape() )
266 34 : keepDiagramCompatibilityInfo( rFilterBase );
267 2394 : }
268 2394 : }
269 : }
270 0 : catch( const Exception& e )
271 : {
272 : SAL_WARN( "oox.drawingml", OSL_THIS_FUNC << "Exception: " << e.Message );
273 : }
274 2394 : }
275 :
276 10 : void Shape::setLockedCanvas(bool bLockedCanvas)
277 : {
278 10 : mbLockedCanvas = bLockedCanvas;
279 10 : }
280 :
281 1638 : void Shape::setWps(bool bWps)
282 : {
283 1638 : mbWps = bWps;
284 1638 : }
285 :
286 437 : void Shape::setTextBox(bool bTextBox)
287 : {
288 437 : mbTextBox = bTextBox;
289 437 : }
290 :
291 339 : void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText )
292 : {
293 : SAL_INFO("oox", OSL_THIS_FUNC << "apply shape reference: " << rReferencedShape.msId << " to shape id: " << msId);
294 :
295 339 : if ( rReferencedShape.mpTextBody.get() && bUseText )
296 329 : mpTextBody = TextBodyPtr( new TextBody( *rReferencedShape.mpTextBody.get() ) );
297 : else
298 10 : mpTextBody.reset();
299 339 : maShapeProperties = rReferencedShape.maShapeProperties;
300 339 : mpShapeRefLinePropPtr = LinePropertiesPtr( new LineProperties( *rReferencedShape.mpLinePropertiesPtr.get() ) );
301 339 : mpShapeRefFillPropPtr = FillPropertiesPtr( new FillProperties( *rReferencedShape.mpFillPropertiesPtr.get() ) );
302 339 : mpCustomShapePropertiesPtr = CustomShapePropertiesPtr( new CustomShapeProperties( *rReferencedShape.mpCustomShapePropertiesPtr.get() ) );
303 339 : mpTablePropertiesPtr = table::TablePropertiesPtr( rReferencedShape.mpTablePropertiesPtr.get() ? new table::TableProperties( *rReferencedShape.mpTablePropertiesPtr.get() ) : NULL );
304 339 : mpShapeRefEffectPropPtr = EffectPropertiesPtr( new EffectProperties( *rReferencedShape.mpEffectPropertiesPtr.get() ) );
305 339 : mpMasterTextListStyle = TextListStylePtr( new TextListStyle( *rReferencedShape.mpMasterTextListStyle.get() ) );
306 339 : maShapeStyleRefs = rReferencedShape.maShapeStyleRefs;
307 339 : maSize = rReferencedShape.maSize;
308 339 : maPosition = rReferencedShape.maPosition;
309 339 : mnRotation = rReferencedShape.mnRotation;
310 339 : mbFlipH = rReferencedShape.mbFlipH;
311 339 : mbFlipV = rReferencedShape.mbFlipV;
312 339 : mbHidden = rReferencedShape.mbHidden;
313 339 : }
314 :
315 0 : void Shape::addChildren( ::oox::core::XmlFilterBase& rFilterBase,
316 : const Theme* pTheme,
317 : const Reference< XShapes >& rxShapes,
318 : basegfx::B2DHomMatrix& aTransformation,
319 : const awt::Rectangle* pShapeRect,
320 : ShapeIdMap* pShapeMap )
321 : {
322 : addChildren(rFilterBase, *this, pTheme, rxShapes,
323 : pShapeRect ?
324 : *pShapeRect :
325 : awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ),
326 0 : pShapeMap, aTransformation);
327 0 : }
328 :
329 : struct ActionLockGuard
330 : {
331 3107 : explicit ActionLockGuard(Reference<drawing::XShape> const& xShape)
332 3107 : : m_xLockable(xShape, UNO_QUERY)
333 : {
334 3107 : if (m_xLockable.is()) {
335 3107 : m_xLockable->addActionLock();
336 : }
337 3107 : }
338 3107 : ~ActionLockGuard()
339 3107 : {
340 3107 : if (m_xLockable.is()) {
341 3107 : m_xLockable->removeActionLock();
342 : }
343 3107 : }
344 : private:
345 : Reference<document::XActionLockable> m_xLockable;
346 : };
347 :
348 : // for group shapes, the following method is also adding each child
349 242 : void Shape::addChildren(
350 : XmlFilterBase& rFilterBase,
351 : Shape& rMaster,
352 : const Theme* pTheme,
353 : const Reference< XShapes >& rxShapes,
354 : const awt::Rectangle&,
355 : ShapeIdMap* pShapeMap,
356 : const basegfx::B2DHomMatrix& aTransformation )
357 : {
358 242 : basegfx::B2DHomMatrix aChildTransformation;
359 :
360 242 : aChildTransformation.translate(-maChPosition.X, -maChPosition.Y);
361 242 : aChildTransformation.scale(1/(maChSize.Width ? maChSize.Width : 1.0), 1/(maChSize.Height ? maChSize.Height : 1.0));
362 :
363 : // Child position and size is typically non-zero, but it's allowed to have
364 : // it like that, and in that case Word ignores the parent transformation
365 : // (excluding translate component).
366 242 : if (!mbWps || maChPosition.X || maChPosition.Y || maChSize.Width || maChSize.Height)
367 : {
368 198 : aChildTransformation *= aTransformation;
369 : }
370 : else
371 : {
372 88 : basegfx::B2DVector aScale, aTranslate;
373 : double fRotate, fShearX;
374 44 : aTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
375 88 : aChildTransformation.translate(aTranslate.getX(), aTranslate.getY());
376 : }
377 :
378 : SAL_INFO("oox.drawingml", OSL_THIS_FUNC << "parent matrix:\n"
379 : << aChildTransformation.get(0, 0) << " "
380 : << aChildTransformation.get(0, 1) << " "
381 : << aChildTransformation.get(0, 2) << "\n"
382 : << aChildTransformation.get(1, 0) << " "
383 : << aChildTransformation.get(1, 1) << " "
384 : << aChildTransformation.get(1, 2) << "\n"
385 : << aChildTransformation.get(2, 0) << " "
386 : << aChildTransformation.get(2, 1) << " "
387 : << aChildTransformation.get(2, 2));
388 :
389 242 : std::vector< ShapePtr >::iterator aIter( rMaster.maChildren.begin() );
390 1445 : while( aIter != rMaster.maChildren.end() ) {
391 961 : (*aIter)->setMasterTextListStyle( mpMasterTextListStyle );
392 961 : (*aIter++)->addShape( rFilterBase, pTheme, rxShapes, aChildTransformation, getFillProperties(), NULL, pShapeMap );
393 242 : }
394 242 : }
395 :
396 3107 : Reference< XShape > Shape::createAndInsert(
397 : ::oox::core::XmlFilterBase& rFilterBase,
398 : const OUString& rServiceName,
399 : const Theme* pTheme,
400 : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes,
401 : const awt::Rectangle* /* pShapeRect */,
402 : bool bClearText,
403 : bool bDoNotInsertEmptyTextBody,
404 : basegfx::B2DHomMatrix& aParentTransformation,
405 : FillProperties& rShapeOrParentShapeFillProps )
406 : {
407 3107 : bool bIsEmbMedia = false;
408 : SAL_INFO("oox.drawingml", OSL_THIS_FUNC << " id: " << msId);
409 :
410 : // tdf#90403 PowerPoint ignores a:ext cx and cy values of p:xfrm, and uses real table width and height
411 3107 : if ( mpTablePropertiesPtr.get() && rServiceName == "com.sun.star.drawing.TableShape" )
412 : {
413 12 : maSize.Width = 0;
414 111 : for( std::vector< sal_Int32 >::const_iterator aTableColIter(mpTablePropertiesPtr->getTableGrid().begin());
415 74 : aTableColIter != mpTablePropertiesPtr->getTableGrid().end(); ++aTableColIter )
416 : {
417 25 : maSize.Width += *aTableColIter;
418 : }
419 12 : maSize.Height = 0;
420 141 : for( std::vector< ::oox::drawingml::table::TableRow >::const_iterator aTableRowIter(mpTablePropertiesPtr->getTableRows().begin());
421 94 : aTableRowIter != mpTablePropertiesPtr->getTableRows().end(); ++aTableRowIter )
422 : {
423 35 : maSize.Height += (*aTableRowIter).getHeight();
424 : }
425 : }
426 :
427 3107 : awt::Rectangle aShapeRectHmm( maPosition.X / EMU_PER_HMM, maPosition.Y / EMU_PER_HMM, maSize.Width / EMU_PER_HMM, maSize.Height / EMU_PER_HMM );
428 :
429 3107 : OUString aServiceName;
430 6536 : if( rServiceName == "com.sun.star.drawing.GraphicObjectShape" &&
431 3429 : mpGraphicPropertiesPtr && !mpGraphicPropertiesPtr->m_sMediaPackageURL.isEmpty())
432 : {
433 2 : aServiceName = finalizeServiceName( rFilterBase, "com.sun.star.presentation.MediaShape", aShapeRectHmm );
434 2 : bIsEmbMedia = true;
435 : }
436 : else
437 : {
438 3105 : aServiceName = finalizeServiceName( rFilterBase, rServiceName, aShapeRectHmm );
439 : }
440 4238 : bool bIsCustomShape = ( aServiceName == "com.sun.star.drawing.CustomShape" ||
441 4238 : aServiceName == "com.sun.star.drawing.ConnectorShape" );
442 4044 : bool bUseRotationTransform = ( !mbWps ||
443 1855 : aServiceName == "com.sun.star.drawing.LineShape" ||
444 1745 : aServiceName == "com.sun.star.drawing.GroupShape" ||
445 3925 : mbFlipH ||
446 3107 : mbFlipV );
447 :
448 6214 : basegfx::B2DHomMatrix aTransformation;
449 :
450 3107 : if( maSize.Width != 1 || maSize.Height != 1)
451 : {
452 : // take care there are no zeros used by error
453 : aTransformation.scale(
454 : maSize.Width ? maSize.Width : 1.0,
455 3107 : maSize.Height ? maSize.Height : 1.0 );
456 : }
457 :
458 3107 : if( mbFlipH || mbFlipV || mnRotation != 0)
459 : {
460 : // calculate object's center
461 171 : basegfx::B2DPoint aCenter(0.5, 0.5);
462 171 : aCenter *= aTransformation;
463 :
464 : // center object at origin
465 171 : aTransformation.translate( -aCenter.getX(), -aCenter.getY() );
466 :
467 171 : if( !bIsCustomShape && ( mbFlipH || mbFlipV ) )
468 : {
469 : // mirror around object's center
470 11 : aTransformation.scale( mbFlipH ? -1.0 : 1.0, mbFlipV ? -1.0 : 1.0 );
471 : }
472 :
473 171 : if( bUseRotationTransform && mnRotation != 0 )
474 : {
475 : // rotate around object's center
476 57 : aTransformation.rotate( F_PI180 * ( (double)mnRotation / 60000.0 ) );
477 : }
478 :
479 : // move object back from center
480 171 : aTransformation.translate( aCenter.getX(), aCenter.getY() );
481 : }
482 :
483 3107 : if( maPosition.X != 0 || maPosition.Y != 0)
484 : {
485 : // if global position is used, add it to transformation
486 2399 : if (mbWps && aParentTransformation.isIdentity())
487 792 : aTransformation.translate( maPosition.X * EMU_PER_HMM, maPosition.Y * EMU_PER_HMM);
488 : else
489 1607 : aTransformation.translate( maPosition.X, maPosition.Y );
490 : }
491 :
492 3107 : aTransformation = aParentTransformation*aTransformation;
493 3107 : aParentTransformation = aTransformation;
494 3107 : aTransformation.scale(1/double(EMU_PER_HMM), 1/double(EMU_PER_HMM));
495 :
496 : // special for lineshape
497 3107 : if ( aServiceName == "com.sun.star.drawing.LineShape" )
498 : {
499 44 : ::basegfx::B2DPolygon aPoly;
500 44 : aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) );
501 44 : aPoly.insert( 1, ::basegfx::B2DPoint( maSize.Width ? 1 : 0, maSize.Height ? 1 : 0 ) );
502 44 : aPoly.transform( aTransformation );
503 :
504 : // now creating the corresponding PolyPolygon
505 44 : sal_Int32 i, nNumPoints = aPoly.count();
506 88 : uno::Sequence< awt::Point > aPointSequence( nNumPoints );
507 44 : awt::Point* pPoints = aPointSequence.getArray();
508 132 : for( i = 0; i < nNumPoints; ++i )
509 : {
510 88 : const ::basegfx::B2DPoint aPoint( aPoly.getB2DPoint( i ) );
511 88 : pPoints[ i ] = awt::Point( static_cast< sal_Int32 >( aPoint.getX() ), static_cast< sal_Int32 >( aPoint.getY() ) );
512 88 : }
513 88 : uno::Sequence< uno::Sequence< awt::Point > > aPolyPolySequence( 1 );
514 44 : aPolyPolySequence.getArray()[ 0 ] = aPointSequence;
515 :
516 88 : maShapeProperties.setProperty(PROP_PolyPolygon, aPolyPolySequence);
517 : }
518 3063 : else if ( aServiceName == "com.sun.star.drawing.ConnectorShape" )
519 : {
520 0 : ::basegfx::B2DPolygon aPoly;
521 0 : aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) );
522 0 : aPoly.insert( 1, ::basegfx::B2DPoint( maSize.Width ? 1 : 0, maSize.Height ? 1 : 0 ) );
523 0 : aPoly.transform( aTransformation );
524 :
525 0 : basegfx::B2DPoint aStartPosition( aPoly.getB2DPoint( 0 ) );
526 0 : basegfx::B2DPoint aEndPosition( aPoly.getB2DPoint( 1 ) );
527 0 : awt::Point aAWTStartPosition( static_cast< sal_Int32 >( aStartPosition.getX() ), static_cast< sal_Int32 >( aStartPosition.getY() ) );
528 0 : awt::Point aAWTEndPosition( static_cast< sal_Int32 >( aEndPosition.getX() ), static_cast< sal_Int32 >( aEndPosition.getY() ) );
529 :
530 0 : maShapeProperties.setProperty(PROP_StartPosition, aAWTStartPosition);
531 0 : maShapeProperties.setProperty(PROP_EndPosition, aAWTEndPosition);
532 : }
533 : else
534 : {
535 : // now set transformation for this object
536 3063 : HomogenMatrix3 aMatrix;
537 :
538 3063 : aMatrix.Line1.Column1 = aTransformation.get(0,0);
539 3063 : aMatrix.Line1.Column2 = aTransformation.get(0,1);
540 3063 : aMatrix.Line1.Column3 = aTransformation.get(0,2);
541 :
542 3063 : aMatrix.Line2.Column1 = aTransformation.get(1,0);
543 3063 : aMatrix.Line2.Column2 = aTransformation.get(1,1);
544 3063 : aMatrix.Line2.Column3 = aTransformation.get(1,2);
545 :
546 3063 : aMatrix.Line3.Column1 = aTransformation.get(2,0);
547 3063 : aMatrix.Line3.Column2 = aTransformation.get(2,1);
548 3063 : aMatrix.Line3.Column3 = aTransformation.get(2,2);
549 :
550 3063 : maShapeProperties.setProperty(PROP_Transformation, aMatrix);
551 : }
552 :
553 6214 : Reference< lang::XMultiServiceFactory > xServiceFact( rFilterBase.getModel(), UNO_QUERY_THROW );
554 3107 : if ( !mxShape.is() )
555 3107 : mxShape = Reference< drawing::XShape >( xServiceFact->createInstance( aServiceName ), UNO_QUERY_THROW );
556 :
557 6214 : Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
558 3107 : if( mxShape.is() && xSet.is() )
559 : {
560 3107 : if( !msName.isEmpty() )
561 : {
562 1208 : Reference< container::XNamed > xNamed( mxShape, UNO_QUERY );
563 1208 : if( xNamed.is() )
564 1208 : xNamed->setName( msName );
565 : }
566 3107 : if (aServiceName != "com.sun.star.text.TextFrame")
567 3107 : rxShapes->add( mxShape );
568 :
569 3107 : if ( mbHidden || mbHiddenMasterShape )
570 : {
571 : SAL_INFO("oox.drawingml", OSL_THIS_FUNC << "invisible shape with id: " << msId);
572 4 : const OUString sVisible( "Visible" );
573 4 : xSet->setPropertyValue( sVisible, Any( sal_False ) );
574 : }
575 :
576 3107 : ActionLockGuard const alg(mxShape);
577 :
578 : // sj: removing default text of placeholder objects such as SlideNumberShape or HeaderShape
579 3107 : if ( bClearText )
580 : {
581 289 : uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
582 289 : if ( xText.is() )
583 : {
584 289 : OUString aEmpty;
585 289 : xText->setString( aEmpty );
586 289 : }
587 : }
588 :
589 3107 : const GraphicHelper& rGraphicHelper = rFilterBase.getGraphicHelper();
590 :
591 6214 : LineProperties aLineProperties;
592 3107 : aLineProperties.maLineFill.moFillType = XML_noFill;
593 3107 : sal_Int32 nLinePhClr = -1;
594 6214 : FillProperties aFillProperties;
595 3107 : aFillProperties.moFillType = XML_noFill;
596 3107 : sal_Int32 nFillPhClr = -1;
597 6214 : EffectProperties aEffectProperties;
598 : // TODO: use ph color when applying effect properties
599 : //sal_Int32 nEffectPhClr = -1;
600 :
601 : // First apply reference shape's properties (shape on the master slide)
602 3107 : aFillProperties.assignUsed( *mpShapeRefFillPropPtr );
603 3107 : aLineProperties.assignUsed( *mpShapeRefLinePropPtr );
604 3107 : aEffectProperties.assignUsed( *mpShapeRefEffectPropPtr );
605 :
606 3107 : if( pTheme )
607 : {
608 3083 : if( const ShapeStyleRef* pLineRef = getShapeStyleRef( XML_lnRef ) )
609 : {
610 1070 : if( const LineProperties* pLineProps = pTheme->getLineStyle( pLineRef->mnThemedIdx ) )
611 570 : aLineProperties.assignUsed( *pLineProps );
612 1070 : nLinePhClr = pLineRef->maPhClr.getColor( rGraphicHelper );
613 :
614 : // Store style-related properties to InteropGrabBag to be able to export them back
615 1070 : Sequence< PropertyValue > aProperties( 7 );
616 1070 : PUT_PROP( aProperties, 0, "SchemeClr", pLineRef->maPhClr.getSchemeName() );
617 1070 : PUT_PROP( aProperties, 1, "Idx", pLineRef->mnThemedIdx );
618 1070 : PUT_PROP( aProperties, 2, "Color", nLinePhClr );
619 1070 : PUT_PROP( aProperties, 3, "LineStyle", aLineProperties.getLineStyle() );
620 1070 : PUT_PROP( aProperties, 4, "LineJoint", aLineProperties.getLineJoint() );
621 1070 : PUT_PROP( aProperties, 5, "LineWidth", aLineProperties.getLineWidth() );
622 1070 : PUT_PROP( aProperties, 6, "Transformations", pLineRef->maPhClr.getTransformations() );
623 1070 : putPropertyToGrabBag( "StyleLnRef", Any( aProperties ) );
624 : }
625 3083 : if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) )
626 : {
627 1070 : if( const FillProperties* pFillProps = pTheme->getFillStyle( pFillRef->mnThemedIdx ) )
628 537 : aFillProperties.assignUsed( *pFillProps );
629 1070 : nFillPhClr = pFillRef->maPhClr.getColor( rGraphicHelper );
630 :
631 1070 : OUString sColorScheme = pFillRef->maPhClr.getSchemeName();
632 1070 : if( !sColorScheme.isEmpty() )
633 : {
634 391 : Sequence< PropertyValue > aProperties(4);
635 391 : PUT_PROP( aProperties, 0, "SchemeClr", sColorScheme );
636 391 : PUT_PROP( aProperties, 1, "Idx", pFillRef->mnThemedIdx );
637 391 : PUT_PROP( aProperties, 2, "Color", nFillPhClr );
638 391 : PUT_PROP( aProperties, 3, "Transformations", pFillRef->maPhClr.getTransformations() );
639 :
640 391 : putPropertyToGrabBag( "StyleFillRef", Any( aProperties ) );
641 1070 : }
642 : }
643 3083 : if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_effectRef ) )
644 : {
645 1070 : if( const EffectProperties* pEffectProps = pTheme->getEffectStyle( pEffectRef->mnThemedIdx ) )
646 85 : aEffectProperties.assignUsed( *pEffectProps );
647 : // TODO: use ph color when applying effect properties
648 : // nEffectPhClr = pEffectRef->maPhClr.getColor( rGraphicHelper );
649 :
650 : // Store style-related properties to InteropGrabBag to be able to export them back
651 1070 : Sequence< PropertyValue > aProperties( 3 );
652 1070 : PUT_PROP( aProperties, 0, "SchemeClr", pEffectRef->maPhClr.getSchemeName() );
653 1070 : PUT_PROP( aProperties, 1, "Idx", pEffectRef->mnThemedIdx );
654 1070 : PUT_PROP( aProperties, 2, "Transformations", pEffectRef->maPhClr.getTransformations() );
655 1070 : putPropertyToGrabBag( "StyleEffectRef", Any( aProperties ) );
656 : }
657 : }
658 :
659 3107 : aLineProperties.assignUsed( getLineProperties() );
660 :
661 : // group fill inherits from parent
662 3107 : if ( getFillProperties().moFillType.has() && getFillProperties().moFillType.get() == XML_grpFill )
663 0 : getFillProperties().assignUsed( rShapeOrParentShapeFillProps );
664 3107 : aFillProperties.assignUsed( getFillProperties() );
665 3107 : aEffectProperties.assignUsed ( getEffectProperties() );
666 :
667 6214 : ShapePropertyMap aShapeProps( rFilterBase.getModelObjectHelper() );
668 :
669 : // add properties from textbody to shape properties
670 3107 : if( mpTextBody.get() )
671 : {
672 1111 : mpTextBody->getTextProperties().pushRotationAdjustments();
673 1111 : aShapeProps.assignUsed( mpTextBody->getTextProperties().maPropertyMap );
674 : // Push char properties as well - specifically useful when this is a placeholder
675 1111 : if( mpMasterTextListStyle && mpMasterTextListStyle->getListStyle()[0]->getTextCharacterProperties().moHeight.has() )
676 411 : aShapeProps.setProperty(PROP_CharHeight, GetFontHeight( mpMasterTextListStyle->getListStyle()[0]->getTextCharacterProperties().moHeight.get() ));
677 : }
678 :
679 : // applying properties
680 3107 : aShapeProps.assignUsed( getShapeProperties() );
681 3107 : aShapeProps.assignUsed( maDefaultShapeProperties );
682 3107 : if ( bIsEmbMedia || aServiceName == "com.sun.star.drawing.GraphicObjectShape" || aServiceName == "com.sun.star.drawing.OLE2Shape" )
683 405 : mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper );
684 3107 : if ( mpTablePropertiesPtr.get() && aServiceName == "com.sun.star.drawing.TableShape" )
685 12 : mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle );
686 3107 : aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr, mbFlipH, mbFlipV );
687 3107 : aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr );
688 : // TODO: use ph color when applying effect properties
689 3107 : aEffectProperties.pushToPropMap( aShapeProps, rGraphicHelper );
690 :
691 : // applying autogrowheight property before setting shape size, because
692 : // the shape size might be changed if currently autogrowheight is true
693 : // we must also check that the PropertySet supports the property.
694 6214 : Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
695 3107 : const OUString& rPropName = PropertyMap::getPropertyName( PROP_TextAutoGrowHeight );
696 3107 : if( xSetInfo.is() && xSetInfo->hasPropertyByName( rPropName ) )
697 2843 : if( aShapeProps.hasProperty( PROP_TextAutoGrowHeight ) )
698 2796 : xSet->setPropertyValue( rPropName, Any( false ) );
699 :
700 : // do not set properties at a group shape (this causes
701 : // assertions from svx) ...
702 3107 : if( aServiceName != "com.sun.star.drawing.GroupShape" )
703 : {
704 2865 : if (aServiceName == "com.sun.star.text.TextFrame")
705 : {
706 0 : if (mpCustomShapePropertiesPtr && mpCustomShapePropertiesPtr->getShapeTypeOverride())
707 : {
708 0 : uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
709 0 : uno::Sequence<beans::PropertyValue> aGrabBag;
710 0 : propertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag;
711 0 : sal_Int32 length = aGrabBag.getLength();
712 0 : aGrabBag.realloc( length+1);
713 0 : aGrabBag[length].Name = "mso-orig-shape-type";
714 : const uno::Sequence< sal_Int8 > aNameSeq =
715 0 : mpCustomShapePropertiesPtr->getShapePresetTypeName();
716 : OUString sShapePresetTypeName(reinterpret_cast< const char* >(
717 0 : aNameSeq.getConstArray()), aNameSeq.getLength(), RTL_TEXTENCODING_UTF8);
718 0 : aGrabBag[length].Value = uno::makeAny(sShapePresetTypeName);
719 0 : propertySet->setPropertyValue("FrameInteropGrabBag",uno::makeAny(aGrabBag));
720 : }
721 : //If the text box has links then save the link information so that
722 : //it can be accessed in DomainMapper_Impl.cxx while chaining the text frames.
723 0 : if (this->isLinkedTxbx())
724 : {
725 0 : uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
726 0 : uno::Sequence<beans::PropertyValue> aGrabBag;
727 0 : propertySet->getPropertyValue("FrameInteropGrabBag") >>= aGrabBag;
728 0 : sal_Int32 length = aGrabBag.getLength();
729 0 : aGrabBag.realloc( length + 3 );
730 0 : aGrabBag[length].Name = "TxbxHasLink";
731 0 : aGrabBag[length].Value = uno::makeAny(this->isLinkedTxbx());
732 0 : aGrabBag[length + 1 ].Name = "Txbx-Id";
733 0 : aGrabBag[length + 1 ].Value = uno::makeAny(this->getLinkedTxbxAttributes().id);
734 0 : aGrabBag[length + 2 ].Name = "Txbx-Seq";
735 0 : aGrabBag[length + 2 ].Value = uno::makeAny(this->getLinkedTxbxAttributes().seq);
736 0 : propertySet->setPropertyValue("FrameInteropGrabBag",uno::makeAny(aGrabBag));
737 : }
738 :
739 : // TextFrames have BackColor, not FillColor
740 0 : if (aShapeProps.hasProperty(PROP_FillColor))
741 : {
742 0 : aShapeProps.setProperty(PROP_BackColor, aShapeProps.getProperty(PROP_FillColor));
743 0 : aShapeProps.erase(PROP_FillColor);
744 : }
745 : // TextFrames have BackColorTransparency, not FillTransparence
746 0 : if (aShapeProps.hasProperty(PROP_FillTransparence))
747 : {
748 0 : aShapeProps.setProperty(PROP_BackColorTransparency, aShapeProps.getProperty(PROP_FillTransparence));
749 0 : aShapeProps.erase(PROP_FillTransparence);
750 : }
751 : // TextFrames have BackGrahicURL, not FillBitmapURL
752 0 : if (aShapeProps.hasProperty(PROP_FillBitmapURL))
753 : {
754 0 : aShapeProps.setProperty(PROP_BackGraphicURL, aShapeProps.getProperty(PROP_FillBitmapURL));
755 0 : aShapeProps.erase(PROP_FillBitmapURL);
756 : }
757 0 : if (aShapeProps.hasProperty(PROP_FillBitmapName))
758 : {
759 0 : uno::Any aAny = aShapeProps.getProperty(PROP_FillBitmapName);
760 0 : aShapeProps.setProperty(PROP_BackGraphicURL, rFilterBase.getModelObjectHelper().getFillBitmapUrl( aAny.get<OUString>() ));
761 : // aShapeProps.erase(PROP_FillBitmapName); // Maybe, leave the name as well
762 : }
763 : // And no LineColor property; individual borders can have colors
764 0 : if (aShapeProps.hasProperty(PROP_LineColor))
765 : {
766 0 : uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
767 : static const sal_Int32 aBorders[] =
768 : {
769 : PROP_TopBorder, PROP_LeftBorder, PROP_BottomBorder, PROP_RightBorder
770 : };
771 0 : for (unsigned int i = 0; i < SAL_N_ELEMENTS(aBorders); ++i)
772 : {
773 0 : css::table::BorderLine2 aBorderLine = xPropertySet->getPropertyValue(PropertyMap::getPropertyName(aBorders[i])).get<css::table::BorderLine2>();
774 0 : aBorderLine.Color = aShapeProps.getProperty(PROP_LineColor).get<sal_Int32>();
775 0 : if (aLineProperties.moLineWidth.has())
776 0 : aBorderLine.LineWidth = convertEmuToHmm(aLineProperties.moLineWidth.get());
777 0 : aShapeProps.setProperty(aBorders[i], uno::makeAny(aBorderLine));
778 : }
779 0 : aShapeProps.erase(PROP_LineColor);
780 : }
781 0 : if(mnRotation)
782 : {
783 0 : uno::Reference<beans::XPropertySet> xPropertySet(mxShape, uno::UNO_QUERY);
784 0 : const OUString aGrabBagPropName = "FrameInteropGrabBag";
785 0 : uno::Sequence<beans::PropertyValue> aGrabBag;
786 0 : xPropertySet->getPropertyValue(aGrabBagPropName) >>= aGrabBag;
787 0 : beans::PropertyValue aPair;
788 0 : aPair.Name = "mso-rotation-angle";
789 0 : aPair.Value = uno::makeAny(mnRotation);
790 0 : if (aGrabBag.hasElements())
791 : {
792 0 : sal_Int32 nLength = aGrabBag.getLength();
793 0 : aGrabBag.realloc(nLength + 1);
794 0 : aGrabBag[nLength] = aPair;
795 : }
796 : else
797 : {
798 0 : aGrabBag.realloc(1);
799 0 : aGrabBag[0] = aPair;
800 : }
801 0 : xPropertySet->setPropertyValue(aGrabBagPropName, uno::makeAny(aGrabBag));
802 : }
803 : // TextFrames have ShadowFormat, not individual shadow properties.
804 0 : boost::optional<sal_Int32> oShadowDistance;
805 0 : if (aShapeProps.hasProperty(PROP_ShadowXDistance))
806 : {
807 0 : oShadowDistance = aShapeProps.getProperty(PROP_ShadowXDistance).get<sal_Int32>();
808 0 : aShapeProps.erase(PROP_ShadowXDistance);
809 : }
810 0 : if (aShapeProps.hasProperty(PROP_ShadowYDistance))
811 : {
812 : // There is a single 'dist' attribute, so no need to count the avg of x and y.
813 0 : aShapeProps.erase(PROP_ShadowYDistance);
814 : }
815 0 : boost::optional<sal_Int32> oShadowColor;
816 0 : if (aShapeProps.hasProperty(PROP_ShadowColor))
817 : {
818 0 : oShadowColor = aShapeProps.getProperty(PROP_ShadowColor).get<sal_Int32>();
819 0 : aShapeProps.erase(PROP_ShadowColor);
820 : }
821 0 : if (aShapeProps.hasProperty(PROP_Shadow))
822 0 : aShapeProps.erase(PROP_Shadow);
823 :
824 0 : if (oShadowDistance || oShadowColor || aEffectProperties.maShadow.moShadowDir.has())
825 : {
826 0 : css::table::ShadowFormat aFormat;
827 0 : if (oShadowColor)
828 0 : aFormat.Color = *oShadowColor;
829 0 : if (aEffectProperties.maShadow.moShadowDir.has())
830 : {
831 0 : css::table::ShadowLocation nLocation = css::table::ShadowLocation_NONE;
832 0 : switch (aEffectProperties.maShadow.moShadowDir.get())
833 : {
834 : case 13500000:
835 0 : nLocation = css::table::ShadowLocation_TOP_LEFT;
836 0 : break;
837 : case 18900000:
838 0 : nLocation = css::table::ShadowLocation_TOP_RIGHT;
839 0 : break;
840 : case 8100000:
841 0 : nLocation = css::table::ShadowLocation_BOTTOM_LEFT;
842 0 : break;
843 : case 2700000:
844 0 : nLocation = css::table::ShadowLocation_BOTTOM_RIGHT;
845 0 : break;
846 : }
847 0 : aFormat.Location = nLocation;
848 : }
849 0 : aFormat.ShadowWidth = *oShadowDistance;
850 0 : aShapeProps.setProperty(PROP_ShadowFormat, uno::makeAny(aFormat));
851 0 : }
852 : }
853 2865 : else if (mbTextBox)
854 : {
855 437 : aShapeProps.setProperty(PROP_TextBox, uno::makeAny(true));
856 : }
857 :
858 2865 : if (aServiceName != "com.sun.star.text.TextFrame" && isLinkedTxbx())
859 : {
860 6 : uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY);
861 12 : uno::Sequence<beans::PropertyValue> aGrabBag;
862 6 : propertySet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
863 6 : sal_Int32 length = aGrabBag.getLength();
864 6 : aGrabBag.realloc( length + 3 );
865 6 : aGrabBag[length].Name = "TxbxHasLink";
866 6 : aGrabBag[length].Value = uno::makeAny(this->isLinkedTxbx());
867 6 : aGrabBag[length + 1 ].Name = "Txbx-Id";
868 6 : aGrabBag[length + 1 ].Value = uno::makeAny(this->getLinkedTxbxAttributes().id);
869 6 : aGrabBag[length + 2 ].Name = "Txbx-Seq";
870 6 : aGrabBag[length + 2 ].Value = uno::makeAny(this->getLinkedTxbxAttributes().seq);
871 12 : propertySet->setPropertyValue("InteropGrabBag",uno::makeAny(aGrabBag));
872 : }
873 :
874 2865 : PropertySet( xSet ).setProperties( aShapeProps );
875 2865 : if (mbLockedCanvas)
876 : {
877 4 : putPropertyToGrabBag( "LockedCanvas", Any( true ) );
878 4 : if (aServiceName == "com.sun.star.drawing.LineShape")
879 : {
880 : // It seems the position and size for lines inside a locked canvas is absolute.
881 1 : mxShape->setPosition(awt::Point(aShapeRectHmm.X, aShapeRectHmm.Y));
882 1 : mxShape->setSize(awt::Size(aShapeRectHmm.Width, aShapeRectHmm.Height));
883 : }
884 : }
885 :
886 : // Store original fill and line colors of the shape and the theme color name to InteropGrabBag
887 2865 : Sequence< PropertyValue > aProperties( 6 ); //allocate the maximum possible number of slots
888 2865 : sal_Int32 nSize = 2;
889 2865 : PUT_PROP( aProperties, 0, "OriginalSolidFillClr", aShapeProps.getProperty(PROP_FillColor) );
890 2865 : PUT_PROP( aProperties, 1, "OriginalLnSolidFillClr", aShapeProps.getProperty(PROP_LineColor) );
891 5730 : OUString sColorFillScheme = aFillProperties.maFillColor.getSchemeName();
892 2865 : if( !aFillProperties.maFillColor.isPlaceHolder() && !sColorFillScheme.isEmpty() )
893 : {
894 215 : PUT_PROP( aProperties, nSize, "SpPrSolidFillSchemeClr", sColorFillScheme );
895 215 : nSize++;
896 215 : PUT_PROP( aProperties, nSize, "SpPrSolidFillSchemeClrTransformations",
897 : aFillProperties.maFillColor.getTransformations() );
898 215 : nSize++;
899 : }
900 5730 : OUString sLnColorFillScheme = aLineProperties.maLineFill.maFillColor.getSchemeName();
901 2865 : if( !aLineProperties.maLineFill.maFillColor.isPlaceHolder() && !sLnColorFillScheme.isEmpty() )
902 : {
903 262 : PUT_PROP( aProperties, nSize, "SpPrLnSolidFillSchemeClr", sLnColorFillScheme );
904 262 : nSize++;
905 262 : PUT_PROP( aProperties, nSize, "SpPrLnSolidFillSchemeClrTransformations",
906 : aLineProperties.maLineFill.maFillColor.getTransformations() );
907 262 : nSize++;
908 : }
909 2865 : aProperties.realloc( nSize ); //shrink the Sequence if we didn't use all the slots
910 2865 : putPropertiesToGrabBag( aProperties );
911 :
912 : // Store original gradient fill of the shape to InteropGrabBag
913 : // LibreOffice doesn't support all the kinds of gradient so we save its complete definition
914 2865 : if( aShapeProps.hasProperty( PROP_FillGradient ) )
915 : {
916 149 : Sequence< PropertyValue > aGradientStops( aFillProperties.maGradientProps.maGradientStops.size() );
917 149 : ::std::map< double, Color >::iterator aIt = aFillProperties.maGradientProps.maGradientStops.begin();
918 524 : for( size_t i = 0; i < aFillProperties.maGradientProps.maGradientStops.size(); ++i )
919 : { // for each stop in the gradient definition:
920 :
921 : // save position
922 375 : Sequence< PropertyValue > aGradientStop( 3 );
923 375 : PUT_PROP( aGradientStop, 0, "Pos", aIt->first );
924 :
925 750 : OUString sStopColorScheme = aIt->second.getSchemeName();
926 375 : if( sStopColorScheme.isEmpty() )
927 : {
928 : // save RGB color
929 127 : PUT_PROP( aGradientStop, 1, "RgbClr", aIt->second.getColor( rGraphicHelper, nFillPhClr ) );
930 : // in the case of a RGB color, transformations are already applied to
931 : // the color with the exception of alpha transformations. We only need
932 : // to keep the transparency value to calculate the alpha value later.
933 127 : if( aIt->second.hasTransparency() )
934 : {
935 30 : PUT_PROP( aGradientStop, 2, "Transparency", aIt->second.getTransparency() );
936 : }
937 : }
938 : else
939 : {
940 : // save color with scheme name
941 248 : PUT_PROP( aGradientStop, 1, "SchemeClr", sStopColorScheme );
942 : // save all color transformations
943 248 : PUT_PROP( aGradientStop, 2, "Transformations", aIt->second.getTransformations() );
944 : }
945 :
946 375 : PUT_PROP( aGradientStops, i, OUString::number( i ), aGradientStop );
947 375 : ++aIt;
948 375 : }
949 : // If getFillProperties.moFillType is unused that means gradient is defined by a theme
950 : // which is already saved into StyleFillRef property, so no need to save the explicit values too
951 149 : if( getFillProperties().moFillType.has() )
952 143 : putPropertyToGrabBag( "GradFillDefinition", Any( aGradientStops ) );
953 149 : putPropertyToGrabBag( "OriginalGradFill", aShapeProps.getProperty(PROP_FillGradient) );
954 : }
955 :
956 : // store unsupported effect attributes in the grab bag
957 2865 : if( aEffectProperties.maEffects.size() > 0 )
958 : {
959 208 : Sequence< PropertyValue > aEffects( aEffectProperties.maEffects.size() );
960 208 : sal_uInt32 i = 0;
961 1341 : for( boost::ptr_vector< Effect >::iterator it = aEffectProperties.maEffects.begin();
962 894 : it != aEffectProperties.maEffects.end(); ++it )
963 : {
964 239 : PropertyValue aEffect = it->getEffect();
965 239 : if( !aEffect.Name.isEmpty() )
966 : {
967 239 : Sequence< PropertyValue > aEffectsGrabBag( 3 );
968 239 : PUT_PROP( aEffectsGrabBag, 0, "Attribs", aEffect.Value );
969 :
970 239 : Color& aColor( it->moColor );
971 478 : OUString sColorScheme = aColor.getSchemeName();
972 239 : if( sColorScheme.isEmpty() )
973 : {
974 : // RGB color and transparency value
975 209 : PUT_PROP( aEffectsGrabBag, 1, "RgbClr",
976 : aColor.getColor( rGraphicHelper, nFillPhClr ) );
977 209 : PUT_PROP( aEffectsGrabBag, 2, "RgbClrTransparency",
978 : aColor.getTransparency() );
979 : }
980 : else
981 : {
982 : // scheme color with name and transformations
983 30 : PUT_PROP( aEffectsGrabBag, 1, "SchemeClr", sColorScheme );
984 30 : PUT_PROP( aEffectsGrabBag, 2, "SchemeClrTransformations",
985 : aColor.getTransformations() );
986 : }
987 239 : PUT_PROP( aEffects, i, aEffect.Name, aEffectsGrabBag );
988 478 : ++i;
989 : }
990 239 : }
991 208 : putPropertyToGrabBag( "EffectProperties", Any( aEffects ) );
992 : }
993 :
994 : // add 3D effects if any
995 5730 : Sequence< PropertyValue > aCamera3DEffects = get3DProperties().getCameraAttributes();
996 5730 : Sequence< PropertyValue > aLightRig3DEffects = get3DProperties().getLightRigAttributes();
997 5730 : Sequence< PropertyValue > aShape3DEffects = get3DProperties().getShape3DAttributes( rGraphicHelper, nFillPhClr );
998 2865 : if( aCamera3DEffects.getLength() > 0 || aLightRig3DEffects.getLength() > 0 || aShape3DEffects.getLength() > 0 )
999 : {
1000 82 : Sequence< PropertyValue > a3DEffectsGrabBag( 3 );
1001 82 : PUT_PROP( a3DEffectsGrabBag, 0, "Camera", Any( aCamera3DEffects ) );
1002 82 : PUT_PROP( a3DEffectsGrabBag, 1, "LightRig", Any( aLightRig3DEffects ) );
1003 82 : PUT_PROP( a3DEffectsGrabBag, 2, "Shape3D", Any( aShape3DEffects ) );
1004 82 : putPropertyToGrabBag( "3DEffectProperties", Any( a3DEffectsGrabBag ) );
1005 : }
1006 :
1007 : // store bitmap artistic effects in the grab bag
1008 2865 : if( !mpGraphicPropertiesPtr->maBlipProps.maEffect.isEmpty() )
1009 : putPropertyToGrabBag( "ArtisticEffectProperties",
1010 2884 : Any( mpGraphicPropertiesPtr->maBlipProps.maEffect.getEffect() ) );
1011 : }
1012 :
1013 242 : else if( mbLockedCanvas )
1014 : {
1015 : //If we have aServiceName as "com.sun.star.drawing.GroupShape" and lockedCanvas
1016 3 : putPropertyToGrabBag( "LockedCanvas", Any( true ) );
1017 : }
1018 :
1019 : // These can have a custom geometry, so position should be set here,
1020 : // after creation but before custom shape handling, using the position
1021 : // we got from the caller.
1022 3107 : if (mbWps && aServiceName == "com.sun.star.drawing.LineShape")
1023 19 : mxShape->setPosition(maPosition);
1024 :
1025 3107 : if( bIsCustomShape )
1026 : {
1027 1976 : if ( mbFlipH )
1028 14 : mpCustomShapePropertiesPtr->setMirroredX( true );
1029 1976 : if ( mbFlipV )
1030 91 : mpCustomShapePropertiesPtr->setMirroredY( true );
1031 1976 : if( getTextBody() )
1032 : {
1033 749 : sal_Int32 nTextRotateAngle = static_cast< sal_Int32 >( getTextBody()->getTextProperties().moRotation.get( 0 ) );
1034 : /* OOX measures text rotation clockwise in 1/60000th degrees,
1035 : relative to the containing shape. setTextRotateAngle wants
1036 : degrees anticlockwise. */
1037 749 : mpCustomShapePropertiesPtr->setTextRotateAngle( -1 * nTextRotateAngle / 60000 );
1038 : }
1039 :
1040 : SAL_INFO("oox.cscode", "==cscode== shape name: '" << msName << "'");
1041 : SAL_INFO("oox.csdata", "==csdata== shape name: '" << msName << "'");
1042 1976 : mpCustomShapePropertiesPtr->pushToPropSet( rFilterBase, xSet, mxShape, maSize );
1043 : }
1044 1131 : else if( getTextBody() )
1045 362 : getTextBody()->getTextProperties().pushVertSimulation();
1046 :
1047 3107 : PropertySet aPropertySet(mxShape);
1048 3107 : if ( !bUseRotationTransform && mnRotation != 0 )
1049 : {
1050 : // use the same logic for rotation from VML exporter (SimpleShape::implConvertAndInsert at vmlshape.cxx)
1051 21 : aPropertySet.setAnyProperty( PROP_RotateAngle, makeAny( sal_Int32( NormAngle360( mnRotation / -600 ) ) ) );
1052 21 : aPropertySet.setAnyProperty( PROP_HoriOrientPosition, makeAny( maPosition.X ) );
1053 21 : aPropertySet.setAnyProperty( PROP_VertOrientPosition, makeAny( maPosition.Y ) );
1054 : }
1055 :
1056 : // in some cases, we don't have any text body.
1057 3107 : if( getTextBody() && ( !bDoNotInsertEmptyTextBody || !mpTextBody->isEmpty() ) )
1058 : {
1059 994 : Reference < XText > xText( mxShape, UNO_QUERY );
1060 994 : if ( xText.is() ) // not every shape is supporting an XText interface (e.g. GroupShape)
1061 : {
1062 994 : TextCharacterProperties aCharStyleProperties;
1063 994 : if( const ShapeStyleRef* pFontRef = getShapeStyleRef( XML_fontRef ) )
1064 : {
1065 472 : if( pFontRef->mnThemedIdx != 0 )
1066 : {
1067 458 : if( pTheme )
1068 458 : if( const TextCharacterProperties* pCharProps = pTheme->getFontStyle( pFontRef->mnThemedIdx ) )
1069 431 : aCharStyleProperties.assignUsed( *pCharProps );
1070 : SAL_INFO("oox.drawingml", OSL_THIS_FUNC << "use font color");
1071 458 : aCharStyleProperties.maCharColor.assignIfUsed( pFontRef->maPhClr );
1072 : }
1073 : }
1074 :
1075 1988 : Reference < XTextCursor > xAt = xText->createTextCursor();
1076 1988 : getTextBody()->insertAt( rFilterBase, xText, xAt, aCharStyleProperties, mpMasterTextListStyle );
1077 994 : }
1078 : }
1079 2113 : else if (mbTextBox)
1080 : {
1081 : // No drawingML text, but WPS text is expected: save the theme
1082 : // character color on the shape, then.
1083 437 : if(const ShapeStyleRef* pFontRef = getShapeStyleRef(XML_fontRef))
1084 : {
1085 192 : sal_Int32 nCharColor = pFontRef->maPhClr.getColor(rGraphicHelper);
1086 192 : aPropertySet.setAnyProperty(PROP_CharColor, uno::makeAny(nCharColor));
1087 : }
1088 6214 : }
1089 : }
1090 :
1091 3107 : if( mxShape.is() )
1092 3107 : finalizeXShape( rFilterBase, rxShapes );
1093 :
1094 6214 : return mxShape;
1095 : }
1096 :
1097 34 : void Shape::keepDiagramCompatibilityInfo( XmlFilterBase& rFilterBase )
1098 : {
1099 : try
1100 : {
1101 34 : if( !maDiagramDoms.hasElements() )
1102 0 : return;
1103 :
1104 34 : Reference < XPropertySet > xSet( mxShape, UNO_QUERY_THROW );
1105 68 : Reference < XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
1106 34 : if ( !xSetInfo.is() )
1107 0 : return;
1108 :
1109 68 : const OUString aGrabBagPropName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
1110 34 : if( !xSetInfo->hasPropertyByName( aGrabBagPropName ) )
1111 0 : return;
1112 :
1113 68 : Sequence < PropertyValue > aGrabBag;
1114 34 : xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
1115 :
1116 : // We keep the previous items, if present
1117 34 : if ( aGrabBag.hasElements() )
1118 : {
1119 0 : sal_Int32 length = aGrabBag.getLength();
1120 0 : aGrabBag.realloc( length+maDiagramDoms.getLength() );
1121 :
1122 0 : for( sal_Int32 i = 0; i < maDiagramDoms.getLength(); ++i )
1123 0 : aGrabBag[length+i] = maDiagramDoms[i];
1124 :
1125 0 : xSet->setPropertyValue( aGrabBagPropName, Any( aGrabBag ) );
1126 : } else
1127 34 : xSet->setPropertyValue( aGrabBagPropName, Any( maDiagramDoms ) );
1128 :
1129 34 : xSet->setPropertyValue( OUString( "MoveProtect" ), Any( sal_True ) );
1130 34 : xSet->setPropertyValue( OUString( "SizeProtect" ), Any( sal_True ) );
1131 :
1132 : // Replace existing shapes with a new Graphic Object rendered
1133 : // from them
1134 68 : Reference < XShape > xShape( renderDiagramToGraphic( rFilterBase ) );
1135 68 : Reference < XShapes > xShapes( mxShape, UNO_QUERY_THROW );
1136 278 : while( xShapes->hasElements() )
1137 210 : xShapes->remove( Reference < XShape > ( xShapes->getByIndex( 0 ), UNO_QUERY_THROW ) );
1138 68 : xShapes->add( xShape );
1139 : }
1140 0 : catch( const Exception& e )
1141 : {
1142 : SAL_WARN( "oox.drawingml", OSL_THIS_FUNC << "Exception: " << e.Message );
1143 : }
1144 : }
1145 :
1146 34 : Reference < XShape > Shape::renderDiagramToGraphic( XmlFilterBase& rFilterBase )
1147 : {
1148 34 : Reference< XShape > xShape;
1149 :
1150 : try
1151 : {
1152 34 : if( !maDiagramDoms.hasElements() )
1153 0 : return xShape;
1154 :
1155 : // Stream in which to place the rendered shape
1156 34 : SvMemoryStream mpTempStream;
1157 68 : Reference < io::XStream > xStream( new utl::OStreamWrapper( mpTempStream ) );
1158 68 : Reference < io::XOutputStream > xOutputStream( xStream->getOutputStream() );
1159 :
1160 : // Rendering format
1161 68 : OUString sFormat( "SVM" );
1162 :
1163 : // Size of the rendering
1164 34 : awt::Size aActualSize = mxShape->getSize();
1165 34 : Size aResolution( Application::GetDefaultDevice()->LogicToPixel( Size( 100, 100 ), MAP_CM ) );
1166 34 : double fPixelsPer100thmm = static_cast < double > ( aResolution.Width() ) / 100000.0;
1167 34 : awt::Size aSize = awt::Size( static_cast < sal_Int32 > ( ( fPixelsPer100thmm * aActualSize.Width ) + 0.5 ),
1168 68 : static_cast < sal_Int32 > ( ( fPixelsPer100thmm * aActualSize.Height ) + 0.5 ) );
1169 :
1170 68 : Sequence< PropertyValue > aFilterData( 4 );
1171 34 : aFilterData[ 0 ].Name = "PixelWidth";
1172 34 : aFilterData[ 0 ].Value <<= aSize.Width;
1173 34 : aFilterData[ 1 ].Name = "PixelHeight";
1174 34 : aFilterData[ 1 ].Value <<= aSize.Height;
1175 34 : aFilterData[ 2 ].Name = "LogicalWidth";
1176 34 : aFilterData[ 2 ].Value <<= aActualSize.Width;
1177 34 : aFilterData[ 3 ].Name = "LogicalHeight";
1178 34 : aFilterData[ 3 ].Value <<= aActualSize.Height;
1179 :
1180 68 : Sequence < PropertyValue > aDescriptor( 3 );
1181 34 : aDescriptor[ 0 ].Name = "OutputStream";
1182 34 : aDescriptor[ 0 ].Value <<= xOutputStream;
1183 34 : aDescriptor[ 1 ].Name = "FilterName";
1184 34 : aDescriptor[ 1 ].Value <<= sFormat;
1185 34 : aDescriptor[ 2 ].Name = "FilterData";
1186 34 : aDescriptor[ 2 ].Value <<= aFilterData;
1187 :
1188 68 : Reference < lang::XComponent > xSourceDoc( mxShape, UNO_QUERY_THROW );
1189 61 : Reference < XGraphicExportFilter > xGraphicExporter = GraphicExportFilter::create( rFilterBase.getComponentContext() );
1190 27 : xGraphicExporter->setSourceDocument( xSourceDoc );
1191 27 : xGraphicExporter->filter( aDescriptor );
1192 :
1193 27 : mpTempStream.Seek( STREAM_SEEK_TO_BEGIN );
1194 :
1195 54 : Graphic aGraphic;
1196 54 : GraphicFilter aFilter( false );
1197 27 : if ( aFilter.ImportGraphic( aGraphic, "", mpTempStream, GRFILTER_FORMAT_NOTFOUND, NULL, GraphicFilterImportFlags::NONE, static_cast < Sequence < PropertyValue >* > ( NULL ), NULL ) != GRFILTER_OK )
1198 : {
1199 : SAL_WARN( "oox.drawingml", OSL_THIS_FUNC
1200 : << "Unable to import rendered stream into graphic object" );
1201 0 : return xShape;
1202 : }
1203 :
1204 54 : Reference < graphic::XGraphic > xGraphic( aGraphic.GetXGraphic() );
1205 54 : Reference < lang::XMultiServiceFactory > xServiceFact( rFilterBase.getModel(), UNO_QUERY_THROW );
1206 27 : xShape = Reference < XShape > ( xServiceFact->createInstance( OUString( "com.sun.star.drawing.GraphicObjectShape" ) ), UNO_QUERY_THROW );
1207 54 : Reference < XPropertySet > xPropSet( xShape, UNO_QUERY_THROW );
1208 27 : xPropSet->setPropertyValue( OUString( "Graphic" ), Any( xGraphic ) );
1209 27 : xPropSet->setPropertyValue( OUString( "MoveProtect" ), Any( sal_True ) );
1210 27 : xPropSet->setPropertyValue( OUString( "SizeProtect" ), Any( sal_True ) );
1211 61 : xPropSet->setPropertyValue( OUString( "Name" ), Any( OUString( "RenderedShapes" ) ) );
1212 : }
1213 7 : catch( const Exception& e )
1214 : {
1215 : SAL_WARN( "oox.drawingml", OSL_THIS_FUNC << "Exception: " << e.Message );
1216 : }
1217 :
1218 34 : return xShape;
1219 : }
1220 :
1221 2899 : void Shape::setTextBody(const TextBodyPtr & pTextBody)
1222 : {
1223 2899 : mpTextBody = pTextBody;
1224 2899 : }
1225 :
1226 1674 : void Shape::setMasterTextListStyle( const TextListStylePtr& pMasterTextListStyle )
1227 : {
1228 : SAL_INFO("oox.drawingml", OSL_THIS_FUNC << "set master text list style to shape id: " << msId);
1229 :
1230 1674 : mpMasterTextListStyle = pMasterTextListStyle;
1231 1674 : }
1232 :
1233 3107 : OUString Shape::finalizeServiceName( XmlFilterBase& rFilter, const OUString& rServiceName, const awt::Rectangle& rShapeRect )
1234 : {
1235 3107 : OUString aServiceName = rServiceName;
1236 3107 : switch( meFrameType )
1237 : {
1238 : case FRAMETYPE_OLEOBJECT:
1239 : {
1240 4 : awt::Size aOleSize( rShapeRect.Width, rShapeRect.Height );
1241 4 : if( rFilter.getOleObjectHelper().importOleObject( maShapeProperties, *mxOleObjectInfo, aOleSize ) )
1242 4 : aServiceName = "com.sun.star.drawing.OLE2Shape";
1243 :
1244 : // get the path to the representation graphic
1245 4 : OUString aGraphicPath;
1246 4 : if( !mxOleObjectInfo->maShapeId.isEmpty() )
1247 2 : if( ::oox::vml::Drawing* pVmlDrawing = rFilter.getVmlDrawing() )
1248 2 : if( const ::oox::vml::ShapeBase* pVmlShape = pVmlDrawing->getShapes().getShapeById( mxOleObjectInfo->maShapeId, true ) )
1249 2 : aGraphicPath = pVmlShape->getGraphicPath();
1250 :
1251 : // import and store the graphic
1252 4 : if( !aGraphicPath.isEmpty() )
1253 : {
1254 : // Transfer shape's width and heightto graphicsfilter (can be used by WMF/EMF)
1255 2 : WMF_EXTERNALHEADER aExtHeader;
1256 2 : aExtHeader.mapMode = 8; // MM_ANISOTROPIC
1257 2 : aExtHeader.xExt = rShapeRect.Width;
1258 2 : aExtHeader.yExt = rShapeRect.Height;
1259 :
1260 2 : Reference< graphic::XGraphic > xGraphic = rFilter.getGraphicHelper().importEmbeddedGraphic( aGraphicPath, &aExtHeader );
1261 2 : if( xGraphic.is() )
1262 2 : maShapeProperties.setProperty(PROP_Graphic, xGraphic);
1263 4 : }
1264 : }
1265 4 : break;
1266 :
1267 : default:;
1268 : }
1269 3107 : return aServiceName;
1270 : }
1271 :
1272 3107 : void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >& rxShapes )
1273 : {
1274 3107 : switch( meFrameType )
1275 : {
1276 : case FRAMETYPE_CHART:
1277 : {
1278 : OSL_ENSURE( !mxChartShapeInfo->maFragmentPath.isEmpty(), "Shape::finalizeXShape - missing chart fragment" );
1279 165 : if( mxShape.is() && !mxChartShapeInfo->maFragmentPath.isEmpty() ) try
1280 : {
1281 : // set the chart2 OLE class ID at the OLE shape
1282 165 : PropertySet aShapeProp( mxShape );
1283 165 : aShapeProp.setProperty( PROP_CLSID, OUString( "12dcae26-281f-416f-a234-c3086127382e" ) );
1284 :
1285 : // get the XModel interface of the embedded object from the OLE shape
1286 330 : Reference< frame::XModel > xDocModel;
1287 165 : aShapeProp.getProperty( xDocModel, PROP_Model );
1288 330 : Reference< chart2::XChartDocument > xChartDoc( xDocModel, UNO_QUERY_THROW );
1289 :
1290 : // load the chart data from the XML fragment
1291 165 : bool bMSO2007Doc = rFilter.isMSO2007Document();
1292 330 : chart::ChartSpaceModel aModel(bMSO2007Doc);
1293 : chart::ChartSpaceFragment *pChartSpaceFragment = new chart::ChartSpaceFragment(
1294 165 : rFilter, mxChartShapeInfo->maFragmentPath, aModel );
1295 : const OUString aThemeOverrideFragmentPath( pChartSpaceFragment->
1296 330 : getFragmentPathFromFirstTypeFromOfficeDoc("themeOverride") );
1297 165 : rFilter.importFragment( pChartSpaceFragment );
1298 : ::oox::ppt::PowerPointImport *pPowerPointImport =
1299 165 : dynamic_cast< ::oox::ppt::PowerPointImport* >(&rFilter);
1300 165 : if (!aThemeOverrideFragmentPath.isEmpty() && pPowerPointImport)
1301 : {
1302 : uno::Reference< xml::sax::XFastSAXSerializable > xDoc(
1303 0 : rFilter.importFragment(aThemeOverrideFragmentPath), uno::UNO_QUERY_THROW);
1304 0 : ThemePtr pTheme = pPowerPointImport->getActualSlidePersist()->getTheme();
1305 : rFilter.importFragment(new ThemeOverrideFragmentHandler(
1306 0 : rFilter, aThemeOverrideFragmentPath, *pTheme), xDoc);
1307 0 : pPowerPointImport->getActualSlidePersist()->setTheme(pTheme);
1308 : }
1309 :
1310 : // convert imported chart model to chart document
1311 330 : Reference< drawing::XShapes > xExternalPage;
1312 165 : if( !mxChartShapeInfo->mbEmbedShapes )
1313 0 : xExternalPage = rxShapes;
1314 165 : if( rFilter.getChartConverter() )
1315 : {
1316 165 : rFilter.getChartConverter()->convertFromModel( rFilter, aModel, xChartDoc, xExternalPage, mxShape->getPosition(), mxShape->getSize() );
1317 165 : if( !xChartDoc->hasInternalDataProvider() )
1318 : {
1319 70 : Reference< chart2::data::XDataReceiver > xDataRec( xChartDoc, UNO_QUERY );
1320 140 : Reference< chart2::data::XDataSource > xData( xDataRec->getUsedData(), UNO_QUERY );
1321 280 : if( xData->getDataSequences().getLength() <= 0 || !xData->getDataSequences()[0]->getValues().is() ||
1322 210 : xData->getDataSequences()[0]->getValues()->getData().getLength() <= 0 )
1323 : {
1324 0 : rFilter.useInternalChartDataTable( true );
1325 0 : rFilter.getChartConverter()->convertFromModel( rFilter, aModel, xChartDoc, xExternalPage, mxShape->getPosition(), mxShape->getSize() );
1326 0 : rFilter.useInternalChartDataTable( false );
1327 70 : }
1328 : }
1329 :
1330 165 : }
1331 : }
1332 0 : catch( Exception& )
1333 : {
1334 : }
1335 : }
1336 165 : break;
1337 :
1338 : default:;
1339 : }
1340 3107 : }
1341 :
1342 3139 : void Shape::putPropertyToGrabBag( const OUString& sPropertyName, const Any& aPropertyValue )
1343 : {
1344 3139 : PropertyValue pNewProperty;
1345 3139 : pNewProperty.Name = sPropertyName;
1346 3139 : pNewProperty.Value = aPropertyValue;
1347 3139 : putPropertyToGrabBag( pNewProperty );
1348 3139 : }
1349 :
1350 3139 : void Shape::putPropertyToGrabBag( const PropertyValue& pProperty )
1351 : {
1352 3139 : Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
1353 6278 : Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
1354 6278 : const OUString& aGrabBagPropName = OUString( UNO_NAME_MISC_OBJ_INTEROPGRABBAG );
1355 3139 : if( mxShape.is() && xSet.is() && xSetInfo.is() && xSetInfo->hasPropertyByName( aGrabBagPropName ) )
1356 : {
1357 3127 : Sequence< PropertyValue > aGrabBag;
1358 3127 : xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
1359 :
1360 3127 : sal_Int32 length = aGrabBag.getLength();
1361 3127 : aGrabBag.realloc( length + 1 );
1362 3127 : aGrabBag[length] = pProperty;
1363 :
1364 3127 : xSet->setPropertyValue( aGrabBagPropName, Any( aGrabBag ) );
1365 3139 : }
1366 3139 : }
1367 :
1368 2865 : void Shape::putPropertiesToGrabBag( const Sequence< PropertyValue >& aProperties )
1369 : {
1370 2865 : Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
1371 5730 : Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
1372 5730 : const OUString& aGrabBagPropName = OUString( UNO_NAME_MISC_OBJ_INTEROPGRABBAG );
1373 2865 : if( mxShape.is() && xSet.is() && xSetInfo.is() && xSetInfo->hasPropertyByName( aGrabBagPropName ) )
1374 : {
1375 : // get existing grab bag
1376 2509 : Sequence< PropertyValue > aGrabBag;
1377 2509 : xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
1378 2509 : sal_Int32 length = aGrabBag.getLength();
1379 :
1380 : // update grab bag size to contain the new items
1381 2509 : aGrabBag.realloc( length + aProperties.getLength() );
1382 :
1383 : // put the new items
1384 8473 : for( sal_Int32 i=0; i < aProperties.getLength(); ++i )
1385 : {
1386 5964 : aGrabBag[length + i].Name = aProperties[i].Name;
1387 5964 : aGrabBag[length + i].Value = aProperties[i].Value;
1388 : }
1389 :
1390 : // put it back to the shape
1391 2509 : xSet->setPropertyValue( aGrabBagPropName, Any( aGrabBag ) );
1392 2865 : }
1393 2865 : }
1394 :
1395 75 : uno::Sequence< uno::Sequence< uno::Any > > Shape::resolveRelationshipsOfTypeFromOfficeDoc(core::XmlFilterBase& rFilter, const OUString& sFragment, const OUString& sType )
1396 : {
1397 75 : uno::Sequence< uno::Sequence< uno::Any > > xRelListTemp;
1398 75 : sal_Int32 counter = 0;
1399 :
1400 150 : core::RelationsRef xRels = rFilter.importRelations( sFragment );
1401 75 : if ( xRels )
1402 : {
1403 75 : core::RelationsRef xImageRels = xRels->getRelationsFromTypeFromOfficeDoc( sType );
1404 75 : if ( xImageRels )
1405 : {
1406 75 : xRelListTemp.realloc( xImageRels->size() );
1407 153 : for( ::std::map< OUString, core::Relation >::const_iterator aIt = xImageRels->begin(), aEnd = xImageRels->end(); aIt != aEnd; ++aIt )
1408 : {
1409 78 : uno::Sequence< uno::Any > diagramRelTuple (3);
1410 : // [0] => RID, [1] => InputStream [2] => extension
1411 156 : OUString sRelId = aIt->second.maId;
1412 :
1413 78 : diagramRelTuple[0] = uno::makeAny ( sRelId );
1414 156 : OUString sTarget = xImageRels->getFragmentPathFromRelId( sRelId );
1415 :
1416 156 : uno::Reference< io::XInputStream > xImageInputStrm( rFilter.openInputStream( sTarget ), uno::UNO_SET_THROW );
1417 156 : StreamDataSequence dataSeq;
1418 78 : if ( rFilter.importBinaryData( dataSeq, sTarget ) )
1419 : {
1420 78 : diagramRelTuple[1] = uno::makeAny( dataSeq );
1421 : }
1422 :
1423 78 : diagramRelTuple[2] = uno::makeAny( sTarget.copy( sTarget.lastIndexOf(".") ) );
1424 :
1425 78 : xRelListTemp[counter] = diagramRelTuple;
1426 78 : ++counter;
1427 78 : }
1428 75 : xRelListTemp.realloc(counter);
1429 :
1430 75 : }
1431 : }
1432 150 : return xRelListTemp;
1433 : }
1434 :
1435 246 : } }
1436 :
1437 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|