bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / draw / ximpshap.cxx
blob316b37912a007441df1051f7f4f80dbb018e74e0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <cassert>
22 #include <tools/debug.hxx>
23 #include <osl/diagnose.h>
24 #include <com/sun/star/document/XEventsSupplier.hpp>
25 #include <com/sun/star/container/XNameReplace.hpp>
26 #include <com/sun/star/presentation/ClickAction.hpp>
27 #include <com/sun/star/drawing/FillStyle.hpp>
28 #include <com/sun/star/drawing/LineStyle.hpp>
29 #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
30 #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
31 #include <com/sun/star/container/XIdentifierAccess.hpp>
32 #include <com/sun/star/drawing/GluePoint2.hpp>
33 #include <com/sun/star/drawing/Alignment.hpp>
34 #include <com/sun/star/drawing/EscapeDirection.hpp>
35 #include <com/sun/star/media/ZoomLevel.hpp>
36 #include <com/sun/star/awt/Rectangle.hpp>
37 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
38 #include <com/sun/star/container/XNameAccess.hpp>
39 #include "ximpshap.hxx"
40 #include <xmloff/XMLBase64ImportContext.hxx>
41 #include <xmloff/XMLShapeStyleContext.hxx>
42 #include <xmloff/xmluconv.hxx>
43 #include <com/sun/star/container/XNamed.hpp>
44 #include <com/sun/star/drawing/CircleKind.hpp>
45 #include <com/sun/star/beans/XPropertySet.hpp>
46 #include <com/sun/star/awt/XControlModel.hpp>
47 #include <com/sun/star/drawing/XControlShape.hpp>
48 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
49 #include <com/sun/star/drawing/PointSequence.hpp>
50 #include <com/sun/star/lang/XServiceInfo.hpp>
51 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
52 #include <com/sun/star/util/XCloneable.hpp>
53 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
54 #include "xexptran.hxx"
55 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
56 #include <com/sun/star/beans/XPropertySetInfo.hpp>
57 #include <com/sun/star/drawing/ConnectorType.hpp>
58 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
60 #include <sax/tools/converter.hxx>
62 #include "PropertySetMerger.hxx"
63 #include <xmloff/families.hxx>
64 #include "ximpstyl.hxx"
65 #include"xmloff/xmlnmspe.hxx"
66 #include <xmloff/xmltoken.hxx>
67 #include "EnhancedCustomShapeToken.hxx"
68 #include "XMLReplacementImageContext.hxx"
69 #include "XMLImageMapContext.hxx"
70 #include "sdpropls.hxx"
71 #include "eventimp.hxx"
72 #include "descriptionimp.hxx"
73 #include "ximpcustomshape.hxx"
74 #include "XMLEmbeddedObjectImportContext.hxx"
75 #include <xmloff/xmlerror.hxx>
76 #include <basegfx/matrix/b2dhommatrix.hxx>
77 #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
78 #include <com/sun/star/container/XChild.hpp>
79 #include <com/sun/star/text/XTextDocument.hpp>
80 #include <basegfx/matrix/b2dhommatrixtools.hxx>
81 #include <basegfx/point/b2dpoint.hxx>
82 #include <basegfx/polygon/b2dpolygon.hxx>
83 #include <basegfx/polygon/b2dpolygontools.hxx>
84 #include <basegfx/polygon/b2dpolypolygontools.hxx>
85 #include <basegfx/vector/b2dvector.hxx>
87 #include <config_features.h>
89 using namespace ::com::sun::star;
90 using namespace ::com::sun::star::uno;
91 using namespace ::com::sun::star::drawing;
92 using namespace ::com::sun::star::style;
93 using namespace ::com::sun::star::container;
94 using namespace ::com::sun::star::document;
95 using namespace ::xmloff::token;
96 using namespace ::xmloff::EnhancedCustomShapeToken;
98 SvXMLEnumMapEntry aXML_GlueAlignment_EnumMap[] =
100 { XML_TOP_LEFT, drawing::Alignment_TOP_LEFT },
101 { XML_TOP, drawing::Alignment_TOP },
102 { XML_TOP_RIGHT, drawing::Alignment_TOP_RIGHT },
103 { XML_LEFT, drawing::Alignment_LEFT },
104 { XML_CENTER, drawing::Alignment_CENTER },
105 { XML_RIGHT, drawing::Alignment_RIGHT },
106 { XML_BOTTOM_LEFT, drawing::Alignment_BOTTOM_LEFT },
107 { XML_BOTTOM, drawing::Alignment_BOTTOM },
108 { XML_BOTTOM_RIGHT, drawing::Alignment_BOTTOM_RIGHT },
109 { XML_TOKEN_INVALID, 0 }
112 SvXMLEnumMapEntry aXML_GlueEscapeDirection_EnumMap[] =
114 { XML_AUTO, drawing::EscapeDirection_SMART },
115 { XML_LEFT, drawing::EscapeDirection_LEFT },
116 { XML_RIGHT, drawing::EscapeDirection_RIGHT },
117 { XML_UP, drawing::EscapeDirection_UP },
118 { XML_DOWN, drawing::EscapeDirection_DOWN },
119 { XML_HORIZONTAL, drawing::EscapeDirection_HORIZONTAL },
120 { XML_VERTICAL, drawing::EscapeDirection_VERTICAL },
121 { XML_TOKEN_INVALID, 0 }
124 static bool ImpIsEmptyURL( const OUString& rURL )
126 if( rURL.isEmpty() )
127 return true;
129 // #i13140# Also compare against 'toplevel' URLs. which also
130 // result in empty filename strings.
131 if( rURL == "#./" )
132 return true;
134 return false;
137 TYPEINIT1( SvXMLShapeContext, SvXMLImportContext );
138 TYPEINIT1( SdXMLShapeContext, SvXMLShapeContext );
140 SdXMLShapeContext::SdXMLShapeContext(
141 SvXMLImport& rImport,
142 sal_uInt16 nPrfx,
143 const OUString& rLocalName,
144 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
145 uno::Reference< drawing::XShapes >& rShapes,
146 bool bTemporaryShape)
147 : SvXMLShapeContext( rImport, nPrfx, rLocalName, bTemporaryShape )
148 , mxShapes( rShapes )
149 , mxAttrList(xAttrList)
150 , mbListContextPushed( false )
151 , mnStyleFamily(XML_STYLE_FAMILY_SD_GRAPHICS_ID)
152 , mnClass(0)
153 , mbIsPlaceholder(false)
154 , mbClearDefaultAttributes( true )
155 , mbIsUserTransformed(false)
156 , mnZOrder(-1)
157 , maSize(1, 1)
158 , mnRelWidth(0)
159 , mnRelHeight(0)
160 , maPosition(0, 0)
161 , maUsedTransformation()
162 , mbVisible(true)
163 , mbPrintable(true)
164 , mbHaveXmlId(false)
165 , mbTextBox(false)
169 SdXMLShapeContext::~SdXMLShapeContext()
173 SvXMLImportContext *SdXMLShapeContext::CreateChildContext( sal_uInt16 p_nPrefix,
174 const OUString& rLocalName,
175 const uno::Reference< xml::sax::XAttributeList>& xAttrList )
177 SvXMLImportContext * pContext = NULL;
179 // #i68101#
180 if( p_nPrefix == XML_NAMESPACE_SVG &&
181 (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) )
183 pContext = new SdXMLDescriptionContext( GetImport(), p_nPrefix, rLocalName, xAttrList, mxShape );
185 else if( p_nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
187 pContext = new SdXMLEventsContext( GetImport(), p_nPrefix, rLocalName, xAttrList, mxShape );
189 else if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_GLUE_POINT ) )
191 addGluePoint( xAttrList );
193 else if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_THUMBNAIL ) )
195 // search attributes for xlink:href
196 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
197 for(sal_Int16 i=0; i < nAttrCount; i++)
199 OUString sAttrName = xAttrList->getNameByIndex( i );
200 OUString aLocalName;
201 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
203 if( nPrefix == XML_NAMESPACE_XLINK )
205 if( IsXMLToken( aLocalName, XML_HREF ) )
207 maThumbnailURL = xAttrList->getValueByIndex( i );
208 break;
213 else
215 // create text cursor on demand
216 if( !mxCursor.is() )
218 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
219 if( xText.is() )
221 rtl::Reference < XMLTextImportHelper > xTxtImport =
222 GetImport().GetTextImport();
223 mxOldCursor = xTxtImport->GetCursor();
224 mxCursor = xText->createTextCursor();
225 if( mxCursor.is() )
227 xTxtImport->SetCursor( mxCursor );
230 // remember old list item and block (#91964#) and reset them
231 // for the text frame
232 xTxtImport->PushListContext();
233 mbListContextPushed = true;
237 // if we have a text cursor, lets try to import some text
238 if( mxCursor.is() )
240 pContext = GetImport().GetTextImport()->CreateTextChildContext(
241 GetImport(), p_nPrefix, rLocalName, xAttrList,
242 ( mbTextBox ? XML_TEXT_TYPE_TEXTBOX : XML_TEXT_TYPE_SHAPE ) );
246 // call parent for content
247 if(!pContext)
248 pContext = SvXMLImportContext::CreateChildContext( p_nPrefix, rLocalName, xAttrList );
250 return pContext;
253 void SdXMLShapeContext::addGluePoint( const uno::Reference< xml::sax::XAttributeList>& xAttrList )
255 // get the glue points container for this shape if its not already there
256 if( !mxGluePoints.is() )
258 uno::Reference< drawing::XGluePointsSupplier > xSupplier( mxShape, uno::UNO_QUERY );
259 if( !xSupplier.is() )
260 return;
262 mxGluePoints = uno::Reference< container::XIdentifierContainer >::query( xSupplier->getGluePoints() );
264 if( !mxGluePoints.is() )
265 return;
268 drawing::GluePoint2 aGluePoint;
269 aGluePoint.IsUserDefined = sal_True;
270 aGluePoint.Position.X = 0;
271 aGluePoint.Position.Y = 0;
272 aGluePoint.Escape = drawing::EscapeDirection_SMART;
273 aGluePoint.PositionAlignment = drawing::Alignment_CENTER;
274 aGluePoint.IsRelative = sal_True;
276 sal_Int32 nId = -1;
278 // read attributes for the 3DScene
279 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
280 for(sal_Int16 i=0; i < nAttrCount; i++)
282 OUString sAttrName = xAttrList->getNameByIndex( i );
283 OUString aLocalName;
284 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
285 const OUString sValue( xAttrList->getValueByIndex( i ) );
287 if( nPrefix == XML_NAMESPACE_SVG )
289 if( IsXMLToken( aLocalName, XML_X ) )
291 GetImport().GetMM100UnitConverter().convertMeasureToCore(
292 aGluePoint.Position.X, sValue);
294 else if( IsXMLToken( aLocalName, XML_Y ) )
296 GetImport().GetMM100UnitConverter().convertMeasureToCore(
297 aGluePoint.Position.Y, sValue);
300 else if( nPrefix == XML_NAMESPACE_DRAW )
302 if( IsXMLToken( aLocalName, XML_ID ) )
304 nId = sValue.toInt32();
306 else if( IsXMLToken( aLocalName, XML_ALIGN ) )
308 sal_uInt16 eKind;
309 if( SvXMLUnitConverter::convertEnum( eKind, sValue, aXML_GlueAlignment_EnumMap ) )
311 aGluePoint.PositionAlignment = (drawing::Alignment)eKind;
312 aGluePoint.IsRelative = sal_False;
315 else if( IsXMLToken( aLocalName, XML_ESCAPE_DIRECTION ) )
317 sal_uInt16 eKind;
318 if( SvXMLUnitConverter::convertEnum( eKind, sValue, aXML_GlueEscapeDirection_EnumMap ) )
320 aGluePoint.Escape = (drawing::EscapeDirection)eKind;
326 if( nId != -1 )
330 sal_Int32 nInternalId = mxGluePoints->insert( uno::makeAny( aGluePoint ) );
331 GetImport().GetShapeImport()->addGluePointMapping( mxShape, nId, nInternalId );
333 catch(const uno::Exception&)
335 OSL_FAIL( "exception during setting of glue points!");
340 void SdXMLShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&)
342 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
345 void SdXMLShapeContext::EndElement()
347 if(mxCursor.is())
349 // delete addition newline
350 const OUString aEmpty;
351 mxCursor->gotoEnd( sal_False );
352 mxCursor->goLeft( 1, sal_True );
353 mxCursor->setString( aEmpty );
355 // reset cursor
356 GetImport().GetTextImport()->ResetCursor();
359 if(mxOldCursor.is())
360 GetImport().GetTextImport()->SetCursor( mxOldCursor );
362 // reinstall old list item (if necessary) #91964#
363 if (mbListContextPushed) {
364 GetImport().GetTextImport()->PopListContext();
367 if( !msHyperlink.isEmpty() ) try
369 uno::Reference< beans::XPropertySet > xProp( mxShape, uno::UNO_QUERY );
371 if ( xProp.is() && xProp->getPropertySetInfo()->hasPropertyByName( "Hyperlink" ) )
372 xProp->setPropertyValue( "Hyperlink", uno::Any( msHyperlink ) );
373 Reference< XEventsSupplier > xEventsSupplier( mxShape, UNO_QUERY );
375 if( xEventsSupplier.is() )
377 Reference< XNameReplace > xEvents( xEventsSupplier->getEvents(), UNO_QUERY_THROW );
379 uno::Sequence< beans::PropertyValue > aProperties( 3 );
380 aProperties[0].Name = "EventType";
381 aProperties[0].Handle = -1;
382 aProperties[0].Value <<= OUString( "Presentation" );
383 aProperties[0].State = beans::PropertyState_DIRECT_VALUE;
385 aProperties[1].Name = "ClickAction";
386 aProperties[1].Handle = -1;
387 aProperties[1].Value <<= ::com::sun::star::presentation::ClickAction_DOCUMENT;
388 aProperties[1].State = beans::PropertyState_DIRECT_VALUE;
390 aProperties[2].Name = "Bookmark";
391 aProperties[2].Handle = -1;
392 aProperties[2].Value <<= msHyperlink;
393 aProperties[2].State = beans::PropertyState_DIRECT_VALUE;
395 xEvents->replaceByName( "OnClick", Any( aProperties ) );
397 else
399 // in draw use the Bookmark property
400 Reference< beans::XPropertySet > xSet( mxShape, UNO_QUERY_THROW );
401 xSet->setPropertyValue( "Bookmark", Any( msHyperlink ) );
402 xSet->setPropertyValue("OnClick", Any( ::com::sun::star::presentation::ClickAction_DOCUMENT ) );
405 catch(const Exception&)
407 OSL_FAIL("xmloff::SdXMLShapeContext::EndElement(), exception caught while setting hyperlink!");
410 if( mxLockable.is() )
411 mxLockable->removeActionLock();
414 void SdXMLShapeContext::AddShape(uno::Reference< drawing::XShape >& xShape)
416 if(xShape.is())
418 // set shape local
419 mxShape = xShape;
421 if(!maShapeName.isEmpty())
423 uno::Reference< container::XNamed > xNamed( mxShape, uno::UNO_QUERY );
424 if( xNamed.is() )
425 xNamed->setName( maShapeName );
428 rtl::Reference< XMLShapeImportHelper > xImp( GetImport().GetShapeImport() );
429 xImp->addShape( xShape, mxAttrList, mxShapes );
431 if( mbClearDefaultAttributes )
433 uno::Reference<beans::XMultiPropertyStates> xMultiPropertyStates(xShape, uno::UNO_QUERY );
434 if (xMultiPropertyStates.is())
435 xMultiPropertyStates->setAllPropertiesToDefault();
438 if( !mbVisible || !mbPrintable ) try
440 uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY_THROW );
441 if( !mbVisible )
442 xSet->setPropertyValue("Visible", uno::Any( sal_False ) );
444 if( !mbPrintable )
445 xSet->setPropertyValue("Printable", uno::Any( sal_False ) );
447 catch(const Exception&)
449 OSL_FAIL( "SdXMLShapeContext::AddShape(), exception caught!" );
452 // #107848#
453 if(!mbTemporaryShape && (!GetImport().HasTextImport()
454 || !GetImport().GetTextImport()->IsInsideDeleteContext()))
456 xImp->shapeWithZIndexAdded( xShape, mnZOrder );
459 if (mnRelWidth || mnRelHeight)
461 uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
462 uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropertySet->getPropertySetInfo();
463 if (mnRelWidth && xPropertySetInfo->hasPropertyByName("RelativeWidth"))
464 xPropertySet->setPropertyValue("RelativeWidth", uno::makeAny(mnRelWidth));
465 if (mnRelHeight && xPropertySetInfo->hasPropertyByName("RelativeHeight"))
466 xPropertySet->setPropertyValue("RelativeHeight", uno::makeAny(mnRelHeight));
469 if( !maShapeId.isEmpty() )
471 uno::Reference< uno::XInterface > xRef( static_cast<uno::XInterface *>(xShape.get()) );
472 GetImport().getInterfaceToIdentifierMapper().registerReference( maShapeId, xRef );
475 // #91065# count only if counting for shape import is enabled
476 if(GetImport().GetShapeImport()->IsHandleProgressBarEnabled())
478 // #80365# increment progress bar at load once for each draw object
479 GetImport().GetProgressBarHelper()->Increment();
483 mxLockable = uno::Reference< document::XActionLockable >::query( xShape );
485 if( mxLockable.is() )
486 mxLockable->addActionLock();
490 void SdXMLShapeContext::AddShape(OUString const & serviceName)
492 uno::Reference< lang::XMultiServiceFactory > xServiceFact(GetImport().GetModel(), uno::UNO_QUERY);
493 if(xServiceFact.is())
497 /* Since fix for issue i33294 the Writer model doesn't support
498 com.sun.star.drawing.OLE2Shape anymore.
499 To handle Draw OLE objects it's decided to import these
500 objects as com.sun.star.drawing.OLE2Shape and convert these
501 objects after the import into com.sun.star.drawing.GraphicObjectShape.
503 uno::Reference< drawing::XShape > xShape;
504 if ( serviceName == "com.sun.star.drawing.OLE2Shape" &&
505 uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() )
507 xShape = uno::Reference< drawing::XShape >(xServiceFact->createInstance("com.sun.star.drawing.temporaryForXMLImportOLE2Shape"), uno::UNO_QUERY);
509 else if (serviceName == "com.sun.star.drawing.GraphicObjectShape"
510 || serviceName == "com.sun.star.drawing.MediaShape"
511 || serviceName == "com.sun.star.presentation.MediaShape")
513 css::uno::Sequence<css::uno::Any> args(1);
514 args[0] <<= GetImport().GetDocumentBase();
515 xShape = css::uno::Reference<css::drawing::XShape>(
516 xServiceFact->createInstanceWithArguments(
517 serviceName, args),
518 css::uno::UNO_QUERY);
520 else
522 xShape = uno::Reference< drawing::XShape >(xServiceFact->createInstance(serviceName), uno::UNO_QUERY);
524 if( xShape.is() )
525 AddShape( xShape );
527 catch(const uno::Exception& e)
529 uno::Sequence<OUString> aSeq( 1 );
530 aSeq[0] = serviceName;
531 GetImport().SetError( XMLERROR_FLAG_ERROR | XMLERROR_API,
532 aSeq, e.Message, NULL );
537 void SdXMLShapeContext::SetTransformation()
539 if(mxShape.is())
541 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
542 if(xPropSet.is())
544 maUsedTransformation.identity();
546 if(maSize.Width != 1 || maSize.Height != 1)
548 // take care there are no zeros used by error
549 if(0 == maSize.Width)
550 maSize.Width = 1;
551 if(0 == maSize.Height)
552 maSize.Height = 1;
554 // set global size. This should always be used.
555 maUsedTransformation.scale(maSize.Width, maSize.Height);
558 if(maPosition.X != 0 || maPosition.Y != 0)
560 // if global position is used, add it to transformation
561 maUsedTransformation.translate(maPosition.X, maPosition.Y);
564 if(mnTransform.NeedsAction())
566 // transformation is used, apply to object.
567 // NOTICE: The transformation is applied AFTER evtl. used
568 // global positioning and scaling is used, so any shear or
569 // rotate used herein is applied around the (0,0) position
570 // of the PAGE object !!!
571 ::basegfx::B2DHomMatrix aMat;
572 mnTransform.GetFullTransform(aMat);
574 // now add to transformation
575 maUsedTransformation *= aMat;
578 // now set transformation for this object
579 uno::Any aAny;
580 drawing::HomogenMatrix3 aMatrix;
582 aMatrix.Line1.Column1 = maUsedTransformation.get(0, 0);
583 aMatrix.Line1.Column2 = maUsedTransformation.get(0, 1);
584 aMatrix.Line1.Column3 = maUsedTransformation.get(0, 2);
586 aMatrix.Line2.Column1 = maUsedTransformation.get(1, 0);
587 aMatrix.Line2.Column2 = maUsedTransformation.get(1, 1);
588 aMatrix.Line2.Column3 = maUsedTransformation.get(1, 2);
590 aMatrix.Line3.Column1 = maUsedTransformation.get(2, 0);
591 aMatrix.Line3.Column2 = maUsedTransformation.get(2, 1);
592 aMatrix.Line3.Column3 = maUsedTransformation.get(2, 2);
594 aAny <<= aMatrix;
596 xPropSet->setPropertyValue(
597 OUString("Transformation"), aAny);
602 void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */)
606 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
607 if( !xPropSet.is() )
608 return;
612 XMLPropStyleContext* pDocStyle = NULL;
614 // set style on shape
615 if(maDrawStyleName.isEmpty())
616 break;
618 const SvXMLStyleContext* pStyle = 0L;
619 bool bAutoStyle(false);
621 if(GetImport().GetShapeImport()->GetAutoStylesContext())
622 pStyle = GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(mnStyleFamily, maDrawStyleName);
624 if(pStyle)
625 bAutoStyle = true;
627 if(!pStyle && GetImport().GetShapeImport()->GetStylesContext())
628 pStyle = GetImport().GetShapeImport()->GetStylesContext()->FindStyleChildContext(mnStyleFamily, maDrawStyleName);
630 OUString aStyleName = maDrawStyleName;
631 uno::Reference< style::XStyle > xStyle;
633 if( pStyle && pStyle->ISA(XMLShapeStyleContext) )
635 pDocStyle = const_cast<XMLShapeStyleContext*>(PTR_CAST( XMLShapeStyleContext, pStyle ));
637 if( pDocStyle->GetStyle().is() )
639 xStyle = pDocStyle->GetStyle();
641 else
643 aStyleName = pDocStyle->GetParentName();
647 if( !xStyle.is() && !aStyleName.isEmpty() )
652 uno::Reference< style::XStyleFamiliesSupplier > xFamiliesSupplier( GetImport().GetModel(), uno::UNO_QUERY );
654 if( xFamiliesSupplier.is() )
656 uno::Reference< container::XNameAccess > xFamilies( xFamiliesSupplier->getStyleFamilies() );
657 if( xFamilies.is() )
660 uno::Reference< container::XNameAccess > xFamily;
662 if( XML_STYLE_FAMILY_SD_PRESENTATION_ID == mnStyleFamily )
664 aStyleName = GetImport().GetStyleDisplayName(
665 XML_STYLE_FAMILY_SD_PRESENTATION_ID,
666 aStyleName );
667 sal_Int32 nPos = aStyleName.lastIndexOf( '-' );
668 if( -1 != nPos )
670 OUString aFamily( aStyleName.copy( 0, nPos ) );
672 xFamilies->getByName( aFamily ) >>= xFamily;
673 aStyleName = aStyleName.copy( nPos + 1 );
676 else
678 // get graphics familie
679 xFamilies->getByName("graphics") >>= xFamily;
680 aStyleName = GetImport().GetStyleDisplayName(
681 XML_STYLE_FAMILY_SD_GRAPHICS_ID,
682 aStyleName );
685 if( xFamily.is() )
686 xFamily->getByName( aStyleName ) >>= xStyle;
690 catch(const uno::Exception&)
692 OSL_FAIL( "could not find style for shape!" );
696 if( bSupportsStyle && xStyle.is() )
700 // set style on object
701 uno::Any aAny;
702 aAny <<= xStyle;
703 xPropSet->setPropertyValue("Style", aAny);
705 catch(const uno::Exception&)
707 OSL_FAIL( "could not find style for shape!" );
711 // if this is an auto style, set its properties
712 if(bAutoStyle && pDocStyle)
714 // set PropertySet on object
715 pDocStyle->FillPropertySet(xPropSet);
718 // Writer shapes: if this one has a TextBox, set it here.
719 uno::Reference<beans::XPropertySetInfo> xPropertySetInfo = xPropSet->getPropertySetInfo();
720 if (xPropertySetInfo->hasPropertyByName("TextBox"))
721 xPropSet->setPropertyValue("TextBox", uno::makeAny(mbTextBox));
723 } while(false);
725 // try to set text auto style
728 // set style on shape
729 if( maTextStyleName.isEmpty() )
730 break;
732 if( NULL == GetImport().GetShapeImport()->GetAutoStylesContext())
733 break;
735 const SvXMLStyleContext* pTempStyle = GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(XML_STYLE_FAMILY_TEXT_PARAGRAPH, maTextStyleName);
736 XMLPropStyleContext* pStyle = const_cast<XMLPropStyleContext*>(PTR_CAST( XMLPropStyleContext, pTempStyle )); // use temp var, PTR_CAST is a bad macro, FindStyleChildContext will be called twice
737 if( pStyle == NULL )
738 break;
740 // set PropertySet on object
741 pStyle->FillPropertySet(xPropSet);
743 } while(false);
745 catch(const uno::Exception&)
750 void SdXMLShapeContext::SetLayer()
752 if( !maLayerName.isEmpty() )
756 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
757 if(xPropSet.is() )
759 uno::Any aAny;
760 aAny <<= maLayerName;
762 xPropSet->setPropertyValue("LayerName", aAny);
763 return;
766 catch(const uno::Exception&)
772 void SdXMLShapeContext::SetThumbnail()
774 if( maThumbnailURL.isEmpty() )
775 return;
779 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
780 if( !xPropSet.is() )
781 return;
783 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
784 if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName( "ThumbnailGraphicURL" ) )
786 // load the thumbnail graphic and export it to a wmf stream so we can set
787 // it at the api
789 const OUString aInternalURL( GetImport().ResolveGraphicObjectURL( maThumbnailURL, false ) );
790 xPropSet->setPropertyValue( "ThumbnailGraphicURL", uno::makeAny( aInternalURL ) );
793 catch(const uno::Exception&)
798 // this is called from the parent group for each unparsed attribute in the attribute list
799 void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
801 if( (XML_NAMESPACE_DRAW == nPrefix) || (XML_NAMESPACE_DRAW_EXT == nPrefix) )
803 if( IsXMLToken( rLocalName, XML_ZINDEX ) )
805 mnZOrder = rValue.toInt32();
807 else if( IsXMLToken( rLocalName, XML_ID ) )
809 if (!mbHaveXmlId) { maShapeId = rValue; }
811 else if( IsXMLToken( rLocalName, XML_NAME ) )
813 maShapeName = rValue;
815 else if( IsXMLToken( rLocalName, XML_STYLE_NAME ) )
817 maDrawStyleName = rValue;
819 else if( IsXMLToken( rLocalName, XML_TEXT_STYLE_NAME ) )
821 maTextStyleName = rValue;
823 else if( IsXMLToken( rLocalName, XML_LAYER ) )
825 maLayerName = rValue;
827 else if( IsXMLToken( rLocalName, XML_TRANSFORM ) )
829 mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter());
831 else if( IsXMLToken( rLocalName, XML_DISPLAY ) )
833 mbVisible = IsXMLToken( rValue, XML_ALWAYS ) || IsXMLToken( rValue, XML_SCREEN );
834 mbPrintable = IsXMLToken( rValue, XML_ALWAYS ) || IsXMLToken( rValue, XML_PRINTER );
837 else if( XML_NAMESPACE_PRESENTATION == nPrefix )
839 if( IsXMLToken( rLocalName, XML_USER_TRANSFORMED ) )
841 mbIsUserTransformed = IsXMLToken( rValue, XML_TRUE );
843 else if( IsXMLToken( rLocalName, XML_PLACEHOLDER ) )
845 mbIsPlaceholder = IsXMLToken( rValue, XML_TRUE );
846 if( mbIsPlaceholder )
847 mbClearDefaultAttributes = false;
849 else if( IsXMLToken( rLocalName, XML_CLASS ) )
851 maPresentationClass = rValue;
853 else if( IsXMLToken( rLocalName, XML_STYLE_NAME ) )
855 maDrawStyleName = rValue;
856 mnStyleFamily = XML_STYLE_FAMILY_SD_PRESENTATION_ID;
859 else if( XML_NAMESPACE_SVG == nPrefix )
861 if( IsXMLToken( rLocalName, XML_X ) )
863 GetImport().GetMM100UnitConverter().convertMeasureToCore(
864 maPosition.X, rValue);
866 else if( IsXMLToken( rLocalName, XML_Y ) )
868 GetImport().GetMM100UnitConverter().convertMeasureToCore(
869 maPosition.Y, rValue);
871 else if( IsXMLToken( rLocalName, XML_WIDTH ) )
873 GetImport().GetMM100UnitConverter().convertMeasureToCore(
874 maSize.Width, rValue);
875 if( maSize.Width > 0 )
876 maSize.Width += 1;
877 else if( maSize.Width < 0 )
878 maSize.Width -= 1;
880 else if( IsXMLToken( rLocalName, XML_HEIGHT ) )
882 GetImport().GetMM100UnitConverter().convertMeasureToCore(
883 maSize.Height, rValue);
884 if( maSize.Height > 0 )
885 maSize.Height += 1;
886 else if( maSize.Height < 0 )
887 maSize.Height -= 1;
889 else if( IsXMLToken( rLocalName, XML_TRANSFORM ) )
891 // because of #85127# take svg:transform into account and hanle like
892 // draw:transform for compatibility
893 mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter());
896 // #i68101#
897 else if( IsXMLToken( rLocalName, XML_TITLE ) )
899 maShapeTitle = rValue;
901 else if( IsXMLToken( rLocalName, XML_DESC ) )
903 maShapeDescription = rValue;
906 else if (nPrefix == XML_NAMESPACE_STYLE)
908 sal_Int32 nTmp;
909 if (IsXMLToken(rLocalName, XML_REL_WIDTH))
911 if (sax::Converter::convertPercent(nTmp, rValue))
912 mnRelWidth = static_cast<sal_Int16>(nTmp);
914 else if (IsXMLToken(rLocalName, XML_REL_HEIGHT))
916 if (sax::Converter::convertPercent(nTmp, rValue))
917 mnRelHeight = static_cast<sal_Int16>(nTmp);
920 else if( (XML_NAMESPACE_NONE == nPrefix) || (XML_NAMESPACE_XML == nPrefix) )
922 if( IsXMLToken( rLocalName, XML_ID ) )
924 maShapeId = rValue;
925 mbHaveXmlId = true;
930 bool SdXMLShapeContext::isPresentationShape() const
932 if( !maPresentationClass.isEmpty() && (const_cast<SdXMLShapeContext*>(this))->GetImport().GetShapeImport()->IsPresentationShapesSupported() )
934 if(XML_STYLE_FAMILY_SD_PRESENTATION_ID == mnStyleFamily)
936 return true;
939 if( IsXMLToken( maPresentationClass, XML_HEADER ) || IsXMLToken( maPresentationClass, XML_FOOTER ) ||
940 IsXMLToken( maPresentationClass, XML_PAGE_NUMBER ) || IsXMLToken( maPresentationClass, XML_DATE_TIME ) )
942 return true;
946 return false;
949 void SdXMLShapeContext::onDemandRescueUsefulDataFromTemporary( const SvXMLImportContext& rCandidate )
951 const SdXMLShapeContext* pCandidate = dynamic_cast< const SdXMLShapeContext* >(&rCandidate);
953 if(!mxGluePoints.is() && pCandidate)
955 // try to rescue GluePoints from rCandidate to local if we not yet have GluePoints by copying them
956 uno::Reference< drawing::XGluePointsSupplier > xSourceSupplier( pCandidate->getShape(), uno::UNO_QUERY );
957 if( !xSourceSupplier.is() )
958 return;
960 uno::Reference< container::XIdentifierAccess > xSourceGluePoints( xSourceSupplier->getGluePoints(), uno::UNO_QUERY );
961 if( !xSourceGluePoints.is() )
962 return;
964 uno::Sequence< sal_Int32 > aSourceIdSequence( xSourceGluePoints->getIdentifiers() );
965 const sal_Int32 nSourceCount(aSourceIdSequence.getLength());
966 rtl::Reference< XMLShapeImportHelper > xSourceShapeImportHelper(const_cast< SdXMLShapeContext* >(pCandidate)->GetImport().GetShapeImport());
968 if(nSourceCount)
970 // rCandidate has GluePoints; prepare the GluePoint container for the local shape
971 uno::Reference< drawing::XGluePointsSupplier > xSupplier( mxShape, uno::UNO_QUERY );
972 if( !xSupplier.is() )
973 return;
975 mxGluePoints = uno::Reference< container::XIdentifierContainer >::query( xSupplier->getGluePoints() );
977 if( !mxGluePoints.is() )
978 return;
980 drawing::GluePoint2 aSourceGluePoint;
982 for( sal_Int32 nSourceIndex(0); nSourceIndex < nSourceCount; nSourceIndex++ )
984 const sal_Int32 nSourceIdentifier = aSourceIdSequence[nSourceIndex];
986 // loop over GluePoints which are UserDefined (avoid the auto mapped ones)
987 if((xSourceGluePoints->getByIdentifier( nSourceIdentifier ) >>= aSourceGluePoint)
988 && aSourceGluePoint.IsUserDefined)
990 // get original mappingID back, this is the draw:id imported with a draw:glue-point
991 const sal_Int32 nDestinnationId = xSourceShapeImportHelper->findGluePointMapping(
992 pCandidate->getShape(),
993 nSourceIdentifier );
995 if(-1 != nSourceIdentifier)
997 // if we got that we are able to add a copy of that GluePoint to the local
998 // context and xShape since we have all information that the source shape
999 // and context had at import time
1002 const sal_Int32 nInternalId = mxGluePoints->insert( uno::makeAny( aSourceGluePoint ) );
1003 GetImport().GetShapeImport()->addGluePointMapping( mxShape, nDestinnationId, nInternalId );
1005 catch (const uno::Exception& e)
1007 SAL_WARN("xmloff", "exception during setting of glue points: " << e.Message);
1016 TYPEINIT1( SdXMLRectShapeContext, SdXMLShapeContext );
1018 SdXMLRectShapeContext::SdXMLRectShapeContext(
1019 SvXMLImport& rImport,
1020 sal_uInt16 nPrfx,
1021 const OUString& rLocalName,
1022 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1023 uno::Reference< drawing::XShapes >& rShapes,
1024 bool bTemporaryShape)
1025 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1026 mnRadius( 0L )
1030 SdXMLRectShapeContext::~SdXMLRectShapeContext()
1034 // this is called from the parent group for each unparsed attribute in the attribute list
1035 void SdXMLRectShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
1037 if( XML_NAMESPACE_DRAW == nPrefix )
1039 if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) )
1041 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1042 mnRadius, rValue);
1043 return;
1047 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1050 void SdXMLRectShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1052 // create rectangle shape
1053 AddShape("com.sun.star.drawing.RectangleShape");
1054 if(mxShape.is())
1056 // Add, set Style and properties from base shape
1057 SetStyle();
1058 SetLayer();
1060 // set pos, size, shear and rotate
1061 SetTransformation();
1063 if(mnRadius)
1065 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1066 if(xPropSet.is())
1070 xPropSet->setPropertyValue("CornerRadius", uno::makeAny( mnRadius ) );
1072 catch(const uno::Exception&)
1074 OSL_FAIL( "exception during setting of corner radius!");
1078 SdXMLShapeContext::StartElement(xAttrList);
1082 TYPEINIT1( SdXMLLineShapeContext, SdXMLShapeContext );
1084 SdXMLLineShapeContext::SdXMLLineShapeContext(
1085 SvXMLImport& rImport,
1086 sal_uInt16 nPrfx,
1087 const OUString& rLocalName,
1088 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1089 uno::Reference< drawing::XShapes >& rShapes,
1090 bool bTemporaryShape)
1091 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1092 mnX1( 0L ),
1093 mnY1( 0L ),
1094 mnX2( 1L ),
1095 mnY2( 1L )
1099 SdXMLLineShapeContext::~SdXMLLineShapeContext()
1103 // this is called from the parent group for each unparsed attribute in the attribute list
1104 void SdXMLLineShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
1106 if( XML_NAMESPACE_SVG == nPrefix )
1108 if( IsXMLToken( rLocalName, XML_X1 ) )
1110 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1111 mnX1, rValue);
1112 return;
1114 if( IsXMLToken( rLocalName, XML_Y1 ) )
1116 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1117 mnY1, rValue);
1118 return;
1120 if( IsXMLToken( rLocalName, XML_X2 ) )
1122 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1123 mnX2, rValue);
1124 return;
1126 if( IsXMLToken( rLocalName, XML_Y2 ) )
1128 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1129 mnY2, rValue);
1130 return;
1134 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1137 void SdXMLLineShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1139 // #85920# use SetTransformation() to handle import of simple lines.
1140 // This is necessary to kake into account all anchor positions and
1141 // other things. All shape imports use the same import schemata now.
1142 // create necessary shape (Line Shape)
1143 AddShape("com.sun.star.drawing.PolyLineShape");
1145 if(mxShape.is())
1147 // Add, set Style and properties from base shape
1148 SetStyle();
1149 SetLayer();
1151 // get sizes and offsets
1152 awt::Point aTopLeft(mnX1, mnY1);
1153 awt::Point aBottomRight(mnX2, mnY2);
1155 if(mnX1 > mnX2)
1157 aTopLeft.X = mnX2;
1158 aBottomRight.X = mnX1;
1161 if(mnY1 > mnY2)
1163 aTopLeft.Y = mnY2;
1164 aBottomRight.Y = mnY1;
1167 // set local parameters on shape
1168 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1169 if(xPropSet.is())
1171 drawing::PointSequenceSequence aPolyPoly(1L);
1172 drawing::PointSequence* pOuterSequence = aPolyPoly.getArray();
1173 pOuterSequence->realloc(2L);
1174 awt::Point* pInnerSequence = pOuterSequence->getArray();
1175 uno::Any aAny;
1177 *pInnerSequence = awt::Point( mnX1 - aTopLeft.X, mnY1 - aTopLeft.Y);
1178 pInnerSequence++;
1179 *pInnerSequence = awt::Point( mnX2 - aTopLeft.X, mnY2 - aTopLeft.Y);
1181 aAny <<= aPolyPoly;
1182 xPropSet->setPropertyValue(
1183 OUString("Geometry"), aAny);
1186 // set sizes for transformation
1187 maSize.Width = aBottomRight.X - aTopLeft.X;
1188 maSize.Height = aBottomRight.Y - aTopLeft.Y;
1189 maPosition.X = aTopLeft.X;
1190 maPosition.Y = aTopLeft.Y;
1192 // set pos, size, shear and rotate and get copy of matrix
1193 SetTransformation();
1195 SdXMLShapeContext::StartElement(xAttrList);
1199 TYPEINIT1( SdXMLEllipseShapeContext, SdXMLShapeContext );
1201 SdXMLEllipseShapeContext::SdXMLEllipseShapeContext(
1202 SvXMLImport& rImport,
1203 sal_uInt16 nPrfx,
1204 const OUString& rLocalName,
1205 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1206 uno::Reference< drawing::XShapes >& rShapes,
1207 bool bTemporaryShape)
1208 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1209 mnCX( 0L ),
1210 mnCY( 0L ),
1211 mnRX( 1L ),
1212 mnRY( 1L ),
1213 meKind( drawing::CircleKind_FULL ),
1214 mnStartAngle( 0 ),
1215 mnEndAngle( 0 )
1219 SdXMLEllipseShapeContext::~SdXMLEllipseShapeContext()
1223 // this is called from the parent group for each unparsed attribute in the attribute list
1224 void SdXMLEllipseShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
1226 if( XML_NAMESPACE_SVG == nPrefix )
1228 if( IsXMLToken( rLocalName, XML_RX ) )
1230 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1231 mnRX, rValue);
1232 return;
1234 if( IsXMLToken( rLocalName, XML_RY ) )
1236 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1237 mnRY, rValue);
1238 return;
1240 if( IsXMLToken( rLocalName, XML_CX ) )
1242 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1243 mnCX, rValue);
1244 return;
1246 if( IsXMLToken( rLocalName, XML_CY ) )
1248 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1249 mnCY, rValue);
1250 return;
1252 if( IsXMLToken( rLocalName, XML_R ) )
1254 // single radius, it's a circle and both radii are the same
1255 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1256 mnRX, rValue);
1257 mnRY = mnRX;
1258 return;
1261 else if( XML_NAMESPACE_DRAW == nPrefix )
1263 if( IsXMLToken( rLocalName, XML_KIND ) )
1265 sal_uInt16 eKind;
1266 if( SvXMLUnitConverter::convertEnum( eKind, rValue, aXML_CircleKind_EnumMap ) )
1268 meKind = eKind;
1270 return;
1272 if( IsXMLToken( rLocalName, XML_START_ANGLE ) )
1274 double dStartAngle;
1275 if (::sax::Converter::convertDouble( dStartAngle, rValue ))
1276 mnStartAngle = (sal_Int32)(dStartAngle * 100.0);
1277 return;
1279 if( IsXMLToken( rLocalName, XML_END_ANGLE ) )
1281 double dEndAngle;
1282 if (::sax::Converter::convertDouble( dEndAngle, rValue ))
1283 mnEndAngle = (sal_Int32)(dEndAngle * 100.0);
1284 return;
1288 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1291 void SdXMLEllipseShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1293 // create rectangle shape
1294 AddShape("com.sun.star.drawing.EllipseShape");
1295 if(mxShape.is())
1297 // Add, set Style and properties from base shape
1298 SetStyle();
1299 SetLayer();
1301 if(mnCX != 0 || mnCY != 0 || mnRX != 1 || mnRY != 1)
1303 // #i121972# center/radius is used, put to pos and size
1304 maSize.Width = 2 * mnRX;
1305 maSize.Height = 2 * mnRY;
1306 maPosition.X = mnCX - mnRX;
1307 maPosition.Y = mnCY - mnRY;
1310 // set pos, size, shear and rotate
1311 SetTransformation();
1313 if( meKind != drawing::CircleKind_FULL )
1315 uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
1316 if( xPropSet.is() )
1318 uno::Any aAny;
1319 aAny <<= (drawing::CircleKind)meKind;
1320 xPropSet->setPropertyValue("CircleKind", aAny );
1322 aAny <<= mnStartAngle;
1323 xPropSet->setPropertyValue("CircleStartAngle", aAny );
1325 aAny <<= mnEndAngle;
1326 xPropSet->setPropertyValue("CircleEndAngle", aAny );
1330 SdXMLShapeContext::StartElement(xAttrList);
1334 TYPEINIT1( SdXMLPolygonShapeContext, SdXMLShapeContext );
1336 SdXMLPolygonShapeContext::SdXMLPolygonShapeContext(
1337 SvXMLImport& rImport,
1338 sal_uInt16 nPrfx,
1339 const OUString& rLocalName,
1340 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1341 uno::Reference< drawing::XShapes >& rShapes, bool bClosed, bool bTemporaryShape)
1342 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1343 mbClosed( bClosed )
1347 // this is called from the parent group for each unparsed attribute in the attribute list
1348 void SdXMLPolygonShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
1350 if( XML_NAMESPACE_SVG == nPrefix )
1352 if( IsXMLToken( rLocalName, XML_VIEWBOX ) )
1354 maViewBox = rValue;
1355 return;
1358 else if( XML_NAMESPACE_DRAW == nPrefix )
1360 if( IsXMLToken( rLocalName, XML_POINTS ) )
1362 maPoints = rValue;
1363 return;
1367 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1370 SdXMLPolygonShapeContext::~SdXMLPolygonShapeContext()
1374 void SdXMLPolygonShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1376 // Add, set Style and properties from base shape
1377 if(mbClosed)
1378 AddShape("com.sun.star.drawing.PolyPolygonShape");
1379 else
1380 AddShape("com.sun.star.drawing.PolyLineShape");
1382 if( mxShape.is() )
1384 SetStyle();
1385 SetLayer();
1387 // set local parameters on shape
1388 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1389 if(xPropSet.is())
1391 // set polygon
1392 if(!maPoints.isEmpty() && !maViewBox.isEmpty())
1394 const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter());
1395 basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight());
1397 // Is this correct? It overrides ViewBox stuff; OTOH it makes no
1398 // sense to have the geometry content size different from object size
1399 if(maSize.Width != 0 && maSize.Height != 0)
1401 aSize = basegfx::B2DVector(maSize.Width, maSize.Height);
1404 basegfx::B2DPolygon aPolygon;
1406 if(basegfx::tools::importFromSvgPoints(aPolygon, maPoints))
1408 if(aPolygon.count())
1410 const basegfx::B2DRange aSourceRange(
1411 aViewBox.GetX(), aViewBox.GetY(),
1412 aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
1413 const basegfx::B2DRange aTargetRange(
1414 aViewBox.GetX(), aViewBox.GetY(),
1415 aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY());
1417 if(!aSourceRange.equal(aTargetRange))
1419 aPolygon.transform(
1420 basegfx::tools::createSourceRangeTargetRangeTransform(
1421 aSourceRange,
1422 aTargetRange));
1425 com::sun::star::drawing::PointSequenceSequence aPointSequenceSequence;
1426 uno::Any aAny;
1428 basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence(basegfx::B2DPolyPolygon(aPolygon), aPointSequenceSequence);
1429 aAny <<= aPointSequenceSequence;
1430 xPropSet->setPropertyValue(OUString("Geometry"), aAny);
1436 // set pos, size, shear and rotate and get copy of matrix
1437 SetTransformation();
1439 SdXMLShapeContext::StartElement(xAttrList);
1443 TYPEINIT1( SdXMLPathShapeContext, SdXMLShapeContext );
1445 SdXMLPathShapeContext::SdXMLPathShapeContext(
1446 SvXMLImport& rImport,
1447 sal_uInt16 nPrfx,
1448 const OUString& rLocalName,
1449 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1450 uno::Reference< drawing::XShapes >& rShapes,
1451 bool bTemporaryShape)
1452 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
1456 SdXMLPathShapeContext::~SdXMLPathShapeContext()
1460 // this is called from the parent group for each unparsed attribute in the attribute list
1461 void SdXMLPathShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
1463 if( XML_NAMESPACE_SVG == nPrefix )
1465 if( IsXMLToken( rLocalName, XML_VIEWBOX ) )
1467 maViewBox = rValue;
1468 return;
1470 else if( IsXMLToken( rLocalName, XML_D ) )
1472 maD = rValue;
1473 return;
1477 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1480 void SdXMLPathShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1482 // create polygon shape
1483 if(!maD.isEmpty())
1485 const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter());
1486 basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight());
1488 // Is this correct? It overrides ViewBox stuff; OTOH it makes no
1489 // sense to have the geometry content size different from object size
1490 if(maSize.Width != 0 && maSize.Height != 0)
1492 aSize = basegfx::B2DVector(maSize.Width, maSize.Height);
1495 basegfx::B2DPolyPolygon aPolyPolygon;
1497 if(basegfx::tools::importFromSvgD(aPolyPolygon, maD, GetImport().needFixPositionAfterZ(), 0))
1499 if(aPolyPolygon.count())
1501 const basegfx::B2DRange aSourceRange(
1502 aViewBox.GetX(), aViewBox.GetY(),
1503 aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
1504 const basegfx::B2DRange aTargetRange(
1505 aViewBox.GetX(), aViewBox.GetY(),
1506 aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY());
1508 if(!aSourceRange.equal(aTargetRange))
1510 aPolyPolygon.transform(
1511 basegfx::tools::createSourceRangeTargetRangeTransform(
1512 aSourceRange,
1513 aTargetRange));
1516 // create shape
1517 OUString service;
1519 if(aPolyPolygon.areControlPointsUsed())
1521 if(aPolyPolygon.isClosed())
1523 service = "com.sun.star.drawing.ClosedBezierShape";
1525 else
1527 service = "com.sun.star.drawing.OpenBezierShape";
1530 else
1532 if(aPolyPolygon.isClosed())
1534 service = "com.sun.star.drawing.PolyPolygonShape";
1536 else
1538 service = "com.sun.star.drawing.PolyLineShape";
1542 // Add, set Style and properties from base shape
1543 AddShape(service);
1545 // #89344# test for mxShape.is() and not for mxShapes.is() to support
1546 // shape import helper classes WITHOUT XShapes (member mxShapes). This
1547 // is used by the writer.
1548 if( mxShape.is() )
1550 SetStyle();
1551 SetLayer();
1553 // set local parameters on shape
1554 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1556 if(xPropSet.is())
1558 uno::Any aAny;
1560 // set polygon data
1561 if(aPolyPolygon.areControlPointsUsed())
1563 drawing::PolyPolygonBezierCoords aSourcePolyPolygon;
1565 basegfx::tools::B2DPolyPolygonToUnoPolyPolygonBezierCoords(
1566 aPolyPolygon,
1567 aSourcePolyPolygon);
1568 aAny <<= aSourcePolyPolygon;
1570 else
1572 drawing::PointSequenceSequence aSourcePolyPolygon;
1574 basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence(
1575 aPolyPolygon,
1576 aSourcePolyPolygon);
1577 aAny <<= aSourcePolyPolygon;
1580 xPropSet->setPropertyValue(OUString("Geometry"), aAny);
1583 // set pos, size, shear and rotate
1584 SetTransformation();
1586 SdXMLShapeContext::StartElement(xAttrList);
1593 TYPEINIT1( SdXMLTextBoxShapeContext, SdXMLShapeContext );
1595 SdXMLTextBoxShapeContext::SdXMLTextBoxShapeContext(
1596 SvXMLImport& rImport,
1597 sal_uInt16 nPrfx,
1598 const OUString& rLocalName,
1599 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1600 uno::Reference< drawing::XShapes >& rShapes,
1601 bool bTemporaryShape)
1602 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1603 mnRadius(0)
1607 SdXMLTextBoxShapeContext::~SdXMLTextBoxShapeContext()
1611 // this is called from the parent group for each unparsed attribute in the attribute list
1612 void SdXMLTextBoxShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
1614 if( XML_NAMESPACE_DRAW == nPrefix )
1616 if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) )
1618 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1619 mnRadius, rValue);
1620 return;
1624 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1627 void SdXMLTextBoxShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&)
1629 // create textbox shape
1630 bool bIsPresShape = false;
1631 bool bClearText = false;
1633 OUString service;
1635 if( isPresentationShape() )
1637 // check if the current document supports presentation shapes
1638 if( GetImport().GetShapeImport()->IsPresentationShapesSupported() )
1640 if( IsXMLToken( maPresentationClass, XML_PRESENTATION_SUBTITLE ))
1642 // XmlShapeTypePresSubtitleShape
1643 service = "com.sun.star.presentation.SubtitleShape";
1645 else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_OUTLINE ) )
1647 // XmlShapeTypePresOutlinerShape
1648 service = "com.sun.star.presentation.OutlinerShape";
1650 else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_NOTES ) )
1652 // XmlShapeTypePresNotesShape
1653 service = "com.sun.star.presentation.NotesShape";
1655 else if( IsXMLToken( maPresentationClass, XML_HEADER ) )
1657 // XmlShapeTypePresHeaderShape
1658 service = "com.sun.star.presentation.HeaderShape";
1659 bClearText = true;
1661 else if( IsXMLToken( maPresentationClass, XML_FOOTER ) )
1663 // XmlShapeTypePresFooterShape
1664 service = "com.sun.star.presentation.FooterShape";
1665 bClearText = true;
1667 else if( IsXMLToken( maPresentationClass, XML_PAGE_NUMBER ) )
1669 // XmlShapeTypePresSlideNumberShape
1670 service = "com.sun.star.presentation.SlideNumberShape";
1671 bClearText = true;
1673 else if( IsXMLToken( maPresentationClass, XML_DATE_TIME ) )
1675 // XmlShapeTypePresDateTimeShape
1676 service = "com.sun.star.presentation.DateTimeShape";
1677 bClearText = true;
1679 else // IsXMLToken( maPresentationClass, XML_PRESENTATION_TITLE ) )
1681 // XmlShapeTypePresTitleTextShape
1682 service = "com.sun.star.presentation.TitleTextShape";
1684 bIsPresShape = true;
1688 if( service.isEmpty() )
1690 // normal text shape
1691 service = "com.sun.star.drawing.TextShape";
1694 // Add, set Style and properties from base shape
1695 AddShape(service);
1697 if( mxShape.is() )
1699 SetStyle();
1700 SetLayer();
1702 if(bIsPresShape)
1704 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
1705 if(xProps.is())
1707 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
1708 if( xPropsInfo.is() )
1710 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
1711 xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
1713 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
1714 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
1719 if( bClearText )
1721 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
1722 OUString aEmpty;
1723 xText->setString( aEmpty );
1726 // set parameters on shape
1727 //A AW->CL: Eventually You need to strip scale and translate from the transformation
1728 //A to reach the same goal again.
1729 //A if(!bIsPresShape || mbIsUserTransformed)
1730 //A {
1731 //A // set pos and size on shape, this should remove binding
1732 //A // to pres object on masterpage
1733 //A SetSizeAndPosition();
1734 //A }
1736 // set pos, size, shear and rotate
1737 SetTransformation();
1739 if(mnRadius)
1741 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1742 if(xPropSet.is())
1746 xPropSet->setPropertyValue("CornerRadius", uno::makeAny( mnRadius ) );
1748 catch(const uno::Exception&)
1750 OSL_FAIL( "exception during setting of corner radius!");
1755 SdXMLShapeContext::StartElement(mxAttrList);
1759 TYPEINIT1( SdXMLControlShapeContext, SdXMLShapeContext );
1761 SdXMLControlShapeContext::SdXMLControlShapeContext(
1762 SvXMLImport& rImport,
1763 sal_uInt16 nPrfx,
1764 const OUString& rLocalName,
1765 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1766 uno::Reference< drawing::XShapes >& rShapes,
1767 bool bTemporaryShape)
1768 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
1772 SdXMLControlShapeContext::~SdXMLControlShapeContext()
1776 // this is called from the parent group for each unparsed attribute in the attribute list
1777 void SdXMLControlShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
1779 if( XML_NAMESPACE_DRAW == nPrefix )
1781 if( IsXMLToken( rLocalName, XML_CONTROL ) )
1783 maFormId = rValue;
1784 return;
1788 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1791 void SdXMLControlShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1793 // create Control shape
1794 // add, set style and properties from base shape
1795 AddShape("com.sun.star.drawing.ControlShape");
1796 if( mxShape.is() )
1798 DBG_ASSERT( !maFormId.isEmpty(), "draw:control without a form:id attribute!" );
1799 if( !maFormId.isEmpty() )
1801 if( GetImport().IsFormsSupported() )
1803 uno::Reference< awt::XControlModel > xControlModel( GetImport().GetFormImport()->lookupControl( maFormId ), uno::UNO_QUERY );
1804 if( xControlModel.is() )
1806 uno::Reference< drawing::XControlShape > xControl( mxShape, uno::UNO_QUERY );
1807 if( xControl.is() )
1808 xControl->setControl( xControlModel );
1814 SetStyle();
1815 SetLayer();
1817 // set pos, size, shear and rotate
1818 SetTransformation();
1820 SdXMLShapeContext::StartElement(xAttrList);
1824 TYPEINIT1( SdXMLConnectorShapeContext, SdXMLShapeContext );
1826 SdXMLConnectorShapeContext::SdXMLConnectorShapeContext(
1827 SvXMLImport& rImport,
1828 sal_uInt16 nPrfx,
1829 const OUString& rLocalName,
1830 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1831 uno::Reference< drawing::XShapes >& rShapes,
1832 bool bTemporaryShape)
1833 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1834 maStart(0,0),
1835 maEnd(1,1),
1836 mnType( (sal_uInt16)drawing::ConnectorType_STANDARD ),
1837 mnStartGlueId(-1),
1838 mnEndGlueId(-1),
1839 mnDelta1(0),
1840 mnDelta2(0),
1841 mnDelta3(0)
1845 SdXMLConnectorShapeContext::~SdXMLConnectorShapeContext()
1849 bool SvXMLImport::needFixPositionAfterZ() const
1851 bool bWrongPositionAfterZ( false );
1852 sal_Int32 nUPD( 0 );
1853 sal_Int32 nBuildId( 0 );
1854 if ( getBuildIds( nUPD, nBuildId ) && // test OOo and old versions of LibO and AOO
1855 ( ( ( nUPD == 641 ) || ( nUPD == 645 ) || ( nUPD == 680 ) || ( nUPD == 300 ) ||
1856 ( nUPD == 310 ) || ( nUPD == 320 ) || ( nUPD == 330 ) || ( nUPD == 340 ) ||
1857 ( nUPD == 350 && nBuildId < 202 ) )
1858 || ( getGeneratorVersion() >= SvXMLImport::AOO_40x // test if AOO 4.x
1859 && getGeneratorVersion() < SvXMLImport::AOO_4x ) ) )
1861 bWrongPositionAfterZ = true;
1863 return bWrongPositionAfterZ;
1867 // this is called from the parent group for each unparsed attribute in the attribute list
1868 void SdXMLConnectorShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
1870 switch( nPrefix )
1872 case XML_NAMESPACE_DRAW:
1874 if( IsXMLToken( rLocalName, XML_START_SHAPE ) )
1876 maStartShapeId = rValue;
1877 return;
1879 if( IsXMLToken( rLocalName, XML_START_GLUE_POINT ) )
1881 mnStartGlueId = rValue.toInt32();
1882 return;
1884 if( IsXMLToken( rLocalName, XML_END_SHAPE ) )
1886 maEndShapeId = rValue;
1887 return;
1889 if( IsXMLToken( rLocalName, XML_END_GLUE_POINT ) )
1891 mnEndGlueId = rValue.toInt32();
1892 return;
1894 if( IsXMLToken( rLocalName, XML_LINE_SKEW ) )
1896 SvXMLTokenEnumerator aTokenEnum( rValue );
1897 OUString aToken;
1898 if( aTokenEnum.getNextToken( aToken ) )
1900 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1901 mnDelta1, aToken);
1902 if( aTokenEnum.getNextToken( aToken ) )
1904 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1905 mnDelta2, aToken);
1906 if( aTokenEnum.getNextToken( aToken ) )
1908 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1909 mnDelta3, aToken);
1913 return;
1915 if( IsXMLToken( rLocalName, XML_TYPE ) )
1917 (void)SvXMLUnitConverter::convertEnum( mnType, rValue, aXML_ConnectionKind_EnumMap );
1918 return;
1920 // #121965# draw:transform may be used in ODF1.2, e.g. exports from MS seem to use these
1921 else if( IsXMLToken( rLocalName, XML_TRANSFORM ) )
1923 mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter());
1926 break;
1928 case XML_NAMESPACE_SVG:
1930 if( IsXMLToken( rLocalName, XML_X1 ) )
1932 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1933 maStart.X, rValue);
1934 return;
1936 if( IsXMLToken( rLocalName, XML_Y1 ) )
1938 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1939 maStart.Y, rValue);
1940 return;
1942 if( IsXMLToken( rLocalName, XML_X2 ) )
1944 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1945 maEnd.X, rValue);
1946 return;
1948 if( IsXMLToken( rLocalName, XML_Y2 ) )
1950 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1951 maEnd.Y, rValue);
1952 return;
1954 if( IsXMLToken( rLocalName, XML_D ) )
1956 basegfx::B2DPolyPolygon aPolyPolygon;
1958 if(basegfx::tools::importFromSvgD(aPolyPolygon, rValue, GetImport().needFixPositionAfterZ(), 0))
1960 if(aPolyPolygon.count())
1962 drawing::PolyPolygonBezierCoords aSourcePolyPolygon;
1964 basegfx::tools::B2DPolyPolygonToUnoPolyPolygonBezierCoords(
1965 aPolyPolygon,
1966 aSourcePolyPolygon);
1967 maPath <<= aSourcePolyPolygon;
1974 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1977 void SdXMLConnectorShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1979 // #107928#
1980 // For security reasons, do not add empty connectors. There may have been an error in EA2
1981 // that created empty, far set off connectors (e.g. 63 meters below top of document). This
1982 // is not guaranteed, but it's definitely safe to not add empty connectors.
1983 bool bDoAdd(true);
1985 if( maStartShapeId.isEmpty()
1986 && maEndShapeId.isEmpty()
1987 && maStart.X == maEnd.X
1988 && maStart.Y == maEnd.Y
1989 && 0 == mnDelta1
1990 && 0 == mnDelta2
1991 && 0 == mnDelta3
1994 bDoAdd = false;
1997 if(bDoAdd)
1999 // create Connector shape
2000 // add, set style and properties from base shape
2001 AddShape("com.sun.star.drawing.ConnectorShape");
2002 if(mxShape.is())
2004 // #121965# if draw:transform is used, apply directly to the start
2005 // and end positions before using these
2006 if(mnTransform.NeedsAction())
2008 // transformation is used, apply to object.
2009 ::basegfx::B2DHomMatrix aMat;
2010 mnTransform.GetFullTransform(aMat);
2012 if(!aMat.isIdentity())
2014 basegfx::B2DPoint aStart(maStart.X, maStart.Y);
2015 basegfx::B2DPoint aEnd(maEnd.X, maEnd.Y);
2017 aStart = aMat * aStart;
2018 aEnd = aMat * aEnd;
2020 maStart.X = basegfx::fround(aStart.getX());
2021 maStart.Y = basegfx::fround(aStart.getY());
2022 maEnd.X = basegfx::fround(aEnd.getX());
2023 maEnd.Y = basegfx::fround(aEnd.getY());
2027 // add connection ids
2028 if( !maStartShapeId.isEmpty() )
2029 GetImport().GetShapeImport()->addShapeConnection( mxShape, true, maStartShapeId, mnStartGlueId );
2030 if( !maEndShapeId.isEmpty() )
2031 GetImport().GetShapeImport()->addShapeConnection( mxShape, false, maEndShapeId, mnEndGlueId );
2033 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2034 if( xProps.is() )
2036 uno::Any aAny;
2037 aAny <<= maStart;
2038 xProps->setPropertyValue("StartPosition", aAny);
2040 aAny <<= maEnd;
2041 xProps->setPropertyValue("EndPosition", aAny );
2043 aAny <<= (drawing::ConnectorType)mnType;
2044 xProps->setPropertyValue("EdgeKind", aAny );
2046 aAny <<= mnDelta1;
2047 xProps->setPropertyValue("EdgeLine1Delta", aAny );
2049 aAny <<= mnDelta2;
2050 xProps->setPropertyValue("EdgeLine2Delta", aAny );
2052 aAny <<= mnDelta3;
2053 xProps->setPropertyValue("EdgeLine3Delta", aAny );
2055 SetStyle();
2056 SetLayer();
2058 if ( maPath.hasValue() )
2060 // #i115492#
2061 // Ignore svg:d attribute for text documents created by OpenOffice.org
2062 // versions before OOo 3.3, because these OOo versions are storing
2063 // svg:d values not using the correct unit.
2064 bool bApplySVGD( true );
2065 if ( uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() )
2067 sal_Int32 nUPD( 0 );
2068 sal_Int32 nBuild( 0 );
2069 const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild );
2070 if ( GetImport().IsTextDocInOOoFileFormat() ||
2071 ( bBuildIdFound &&
2072 ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0
2073 ( nUPD == 680 ) || // OOo 2.x
2074 ( nUPD == 300 ) || // OOo 3.0 - OOo 3.0.1
2075 ( nUPD == 310 ) || // OOo 3.1 - OOo 3.1.1
2076 ( nUPD == 320 ) ) ) ) // OOo 3.2 - OOo 3.2.1
2078 bApplySVGD = false;
2082 if ( bApplySVGD )
2084 assert(maPath.getValueType() == cppu::UnoType<drawing::PolyPolygonBezierCoords>::get());
2085 xProps->setPropertyValue("PolyPolygonBezier", maPath);
2089 SdXMLShapeContext::StartElement(xAttrList);
2094 TYPEINIT1( SdXMLMeasureShapeContext, SdXMLShapeContext );
2096 SdXMLMeasureShapeContext::SdXMLMeasureShapeContext(
2097 SvXMLImport& rImport,
2098 sal_uInt16 nPrfx,
2099 const OUString& rLocalName,
2100 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2101 uno::Reference< drawing::XShapes >& rShapes,
2102 bool bTemporaryShape)
2103 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
2104 maStart(0,0),
2105 maEnd(1,1)
2109 SdXMLMeasureShapeContext::~SdXMLMeasureShapeContext()
2113 // this is called from the parent group for each unparsed attribute in the attribute list
2114 void SdXMLMeasureShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
2116 switch( nPrefix )
2118 case XML_NAMESPACE_SVG:
2120 if( IsXMLToken( rLocalName, XML_X1 ) )
2122 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2123 maStart.X, rValue);
2124 return;
2126 if( IsXMLToken( rLocalName, XML_Y1 ) )
2128 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2129 maStart.Y, rValue);
2130 return;
2132 if( IsXMLToken( rLocalName, XML_X2 ) )
2134 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2135 maEnd.X, rValue);
2136 return;
2138 if( IsXMLToken( rLocalName, XML_Y2 ) )
2140 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2141 maEnd.Y, rValue);
2142 return;
2147 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2150 void SdXMLMeasureShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
2152 // create Measure shape
2153 // add, set style and properties from base shape
2154 AddShape("com.sun.star.drawing.MeasureShape");
2155 if(mxShape.is())
2157 SetStyle();
2158 SetLayer();
2160 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2161 if( xProps.is() )
2163 uno::Any aAny;
2164 aAny <<= maStart;
2165 xProps->setPropertyValue("StartPosition", aAny);
2167 aAny <<= maEnd;
2168 xProps->setPropertyValue("EndPosition", aAny );
2171 // delete pre created fields
2172 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
2173 if( xText.is() )
2175 const OUString aEmpty( " " );
2176 xText->setString( aEmpty );
2179 SdXMLShapeContext::StartElement(xAttrList);
2183 void SdXMLMeasureShapeContext::EndElement()
2187 // delete pre created fields
2188 uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
2189 if( !xText.is() )
2190 break;
2192 uno::Reference< text::XTextCursor > xCursor( xText->createTextCursor() );
2193 if( !xCursor.is() )
2194 break;
2196 const OUString aEmpty;
2197 xCursor->collapseToStart();
2198 xCursor->goRight( 1, sal_True );
2199 xCursor->setString( aEmpty );
2201 while(false);
2203 SdXMLShapeContext::EndElement();
2206 TYPEINIT1( SdXMLPageShapeContext, SdXMLShapeContext );
2208 SdXMLPageShapeContext::SdXMLPageShapeContext(
2209 SvXMLImport& rImport,
2210 sal_uInt16 nPrfx,
2211 const OUString& rLocalName,
2212 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2213 uno::Reference< drawing::XShapes >& rShapes,
2214 bool bTemporaryShape)
2215 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), mnPageNumber(0)
2217 mbClearDefaultAttributes = false;
2220 SdXMLPageShapeContext::~SdXMLPageShapeContext()
2224 // this is called from the parent group for each unparsed attribute in the attribute list
2225 void SdXMLPageShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
2227 if( XML_NAMESPACE_DRAW == nPrefix )
2229 if( IsXMLToken( rLocalName, XML_PAGE_NUMBER ) )
2231 mnPageNumber = rValue.toInt32();
2232 return;
2236 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2239 void SdXMLPageShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
2241 // create Page shape
2242 // add, set style and properties from base shape
2244 // #86163# take into account which type of PageShape needs to
2245 // be constructed. It's an pres shape if presentation:XML_CLASS == XML_PRESENTATION_PAGE.
2246 bool bIsPresentation = !maPresentationClass.isEmpty() &&
2247 GetImport().GetShapeImport()->IsPresentationShapesSupported();
2249 uno::Reference< lang::XServiceInfo > xInfo( mxShapes, uno::UNO_QUERY );
2250 const bool bIsOnHandoutPage = xInfo.is() && xInfo->supportsService("com.sun.star.presentation.HandoutMasterPage");
2252 if( bIsOnHandoutPage )
2254 AddShape("com.sun.star.presentation.HandoutShape");
2256 else
2258 if(bIsPresentation && !IsXMLToken( maPresentationClass, XML_PRESENTATION_PAGE ) )
2260 bIsPresentation = false;
2263 if(bIsPresentation)
2265 AddShape("com.sun.star.presentation.PageShape");
2267 else
2269 AddShape("com.sun.star.drawing.PageShape");
2273 if(mxShape.is())
2275 SetStyle();
2276 SetLayer();
2278 // set pos, size, shear and rotate
2279 SetTransformation();
2281 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2282 if(xPropSet.is())
2284 uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
2285 const OUString aPageNumberStr("PageNumber");
2286 if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(aPageNumberStr))
2287 xPropSet->setPropertyValue(aPageNumberStr, uno::makeAny( mnPageNumber ));
2290 SdXMLShapeContext::StartElement(xAttrList);
2294 TYPEINIT1( SdXMLCaptionShapeContext, SdXMLShapeContext );
2296 SdXMLCaptionShapeContext::SdXMLCaptionShapeContext(
2297 SvXMLImport& rImport,
2298 sal_uInt16 nPrfx,
2299 const OUString& rLocalName,
2300 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2301 uno::Reference< drawing::XShapes >& rShapes,
2302 bool bTemporaryShape)
2303 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
2304 // #86616# for correct edge rounding import mnRadius needs to be initialized
2305 mnRadius( 0L )
2309 SdXMLCaptionShapeContext::~SdXMLCaptionShapeContext()
2313 void SdXMLCaptionShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
2315 // create Caption shape
2316 // add, set style and properties from base shape
2317 AddShape("com.sun.star.drawing.CaptionShape");
2318 if( mxShape.is() )
2320 SetStyle();
2321 SetLayer();
2323 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2325 // SJ: If AutoGrowWidthItem is set, SetTransformation will lead to the wrong SnapRect
2326 // because NbcAdjustTextFrameWidthAndHeight() is called (text is set later and center alignment
2327 // is the default setting, so the top left reference point that is used by the caption point is
2328 // no longer correct) There are two ways to solve this problem, temporarily disabling the
2329 // autogrowwith as we are doing here or to apply the CaptionPoint after setting text
2330 bool bIsAutoGrowWidth = false;
2331 if ( xProps.is() )
2333 uno::Any aAny( xProps->getPropertyValue("TextAutoGrowWidth") );
2334 aAny >>= bIsAutoGrowWidth;
2336 if ( bIsAutoGrowWidth )
2337 xProps->setPropertyValue("TextAutoGrowWidth", uno::makeAny( sal_False ) );
2340 // set pos, size, shear and rotate
2341 SetTransformation();
2342 if( xProps.is() )
2343 xProps->setPropertyValue("CaptionPoint", uno::makeAny( maCaptionPoint ) );
2345 if ( bIsAutoGrowWidth )
2346 xProps->setPropertyValue("TextAutoGrowWidth", uno::makeAny( sal_True ) );
2348 if(mnRadius)
2350 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2351 if(xPropSet.is())
2355 xPropSet->setPropertyValue("CornerRadius", uno::makeAny( mnRadius ) );
2357 catch(const uno::Exception&)
2359 OSL_FAIL( "exception during setting of corner radius!");
2364 SdXMLShapeContext::StartElement(xAttrList);
2368 // this is called from the parent group for each unparsed attribute in the attribute list
2369 void SdXMLCaptionShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
2371 if( XML_NAMESPACE_DRAW == nPrefix )
2373 if( IsXMLToken( rLocalName, XML_CAPTION_POINT_X ) )
2375 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2376 maCaptionPoint.X, rValue);
2377 return;
2379 if( IsXMLToken( rLocalName, XML_CAPTION_POINT_Y ) )
2381 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2382 maCaptionPoint.Y, rValue);
2383 return;
2385 if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) )
2387 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2388 mnRadius, rValue);
2389 return;
2392 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2395 TYPEINIT1( SdXMLGraphicObjectShapeContext, SdXMLShapeContext );
2397 SdXMLGraphicObjectShapeContext::SdXMLGraphicObjectShapeContext(
2398 SvXMLImport& rImport,
2399 sal_uInt16 nPrfx,
2400 const OUString& rLocalName,
2401 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2402 uno::Reference< drawing::XShapes >& rShapes,
2403 bool bTemporaryShape)
2404 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
2405 maURL()
2409 // this is called from the parent group for each unparsed attribute in the attribute list
2410 void SdXMLGraphicObjectShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
2412 if( XML_NAMESPACE_XLINK == nPrefix )
2414 if( IsXMLToken( rLocalName, XML_HREF ) )
2416 maURL = rValue;
2417 return;
2421 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2424 void SdXMLGraphicObjectShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& )
2426 // create graphic object shape
2427 OUString service;
2429 if( IsXMLToken( maPresentationClass, XML_GRAPHIC ) && GetImport().GetShapeImport()->IsPresentationShapesSupported() )
2431 service = "com.sun.star.presentation.GraphicObjectShape";
2433 else
2435 service = "com.sun.star.drawing.GraphicObjectShape";
2438 AddShape(service);
2440 if(mxShape.is())
2442 SetStyle();
2443 SetLayer();
2445 uno::Reference< beans::XPropertySet > xPropset(mxShape, uno::UNO_QUERY);
2446 if(xPropset.is())
2448 // since OOo 1.x had no line or fill style for graphics, but may create
2449 // documents with them, we have to override them here
2450 sal_Int32 nUPD, nBuildId;
2451 if( GetImport().getBuildIds( nUPD, nBuildId ) && (nUPD == 645) ) try
2453 xPropset->setPropertyValue("FillStyle", Any( FillStyle_NONE ) );
2454 xPropset->setPropertyValue("LineStyle", Any( LineStyle_NONE ) );
2456 catch(const Exception&)
2460 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xPropset->getPropertySetInfo() );
2461 if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
2462 xPropset->setPropertyValue("IsEmptyPresentationObject", css::uno::makeAny( mbIsPlaceholder ) );
2464 if( !mbIsPlaceholder )
2466 if( !maURL.isEmpty() )
2468 uno::Any aAny;
2469 aAny <<= GetImport().ResolveGraphicObjectURL( maURL, GetImport().isGraphicLoadOnDemandSupported() );
2472 xPropset->setPropertyValue("GraphicURL", aAny );
2473 xPropset->setPropertyValue("GraphicStreamURL", aAny );
2475 catch (const lang::IllegalArgumentException&)
2482 if(mbIsUserTransformed)
2484 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2485 if(xProps.is())
2487 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2488 if( xPropsInfo.is() )
2490 if( xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
2491 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
2496 // set pos, size, shear and rotate
2497 SetTransformation();
2499 SdXMLShapeContext::StartElement(mxAttrList);
2503 void SdXMLGraphicObjectShapeContext::EndElement()
2505 if( mxBase64Stream.is() )
2507 OUString sURL( GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream ) );
2508 if( !sURL.isEmpty() )
2512 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2513 if(xProps.is())
2515 const uno::Any aAny( uno::makeAny( sURL ) );
2516 xProps->setPropertyValue("GraphicURL", aAny );
2517 xProps->setPropertyValue("GraphicStreamURL", aAny );
2520 catch (const lang::IllegalArgumentException&)
2526 SdXMLShapeContext::EndElement();
2529 SvXMLImportContext* SdXMLGraphicObjectShapeContext::CreateChildContext(
2530 sal_uInt16 nPrefix, const OUString& rLocalName,
2531 const uno::Reference<xml::sax::XAttributeList>& xAttrList )
2533 SvXMLImportContext* pContext = NULL;
2535 if( (XML_NAMESPACE_OFFICE == nPrefix) &&
2536 xmloff::token::IsXMLToken( rLocalName, xmloff::token::XML_BINARY_DATA ) )
2538 if( maURL.isEmpty() && !mxBase64Stream.is() )
2540 mxBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64();
2541 if( mxBase64Stream.is() )
2542 pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
2543 rLocalName, xAttrList,
2544 mxBase64Stream );
2548 // delegate to parent class if no context could be created
2549 if ( NULL == pContext )
2550 pContext = SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName,
2551 xAttrList);
2553 return pContext;
2556 SdXMLGraphicObjectShapeContext::~SdXMLGraphicObjectShapeContext()
2561 TYPEINIT1( SdXMLChartShapeContext, SdXMLShapeContext );
2563 SdXMLChartShapeContext::SdXMLChartShapeContext(
2564 SvXMLImport& rImport,
2565 sal_uInt16 nPrfx,
2566 const OUString& rLocalName,
2567 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2568 uno::Reference< drawing::XShapes >& rShapes,
2569 bool bTemporaryShape)
2570 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
2571 mpChartContext( NULL )
2575 SdXMLChartShapeContext::~SdXMLChartShapeContext()
2577 if( mpChartContext )
2578 delete mpChartContext;
2581 void SdXMLChartShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
2583 const bool bIsPresentation = isPresentationShape();
2585 AddShape(
2586 bIsPresentation
2587 ? OUString("com.sun.star.presentation.ChartShape")
2588 : OUString("com.sun.star.drawing.OLE2Shape"));
2590 if(mxShape.is())
2592 SetStyle();
2593 SetLayer();
2595 if( !mbIsPlaceholder )
2597 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2598 if(xProps.is())
2600 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2601 if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
2602 xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
2604 uno::Any aAny;
2606 const OUString aCLSID( "12DCAE26-281F-416F-a234-c3086127382e");
2608 aAny <<= aCLSID;
2609 xProps->setPropertyValue("CLSID", aAny );
2611 aAny = xProps->getPropertyValue("Model");
2612 uno::Reference< frame::XModel > xChartModel;
2613 if( aAny >>= xChartModel )
2615 mpChartContext = GetImport().GetChartImport()->CreateChartContext( GetImport(), XML_NAMESPACE_SVG, GetXMLToken(XML_CHART), xChartModel, xAttrList );
2620 if(mbIsUserTransformed)
2622 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2623 if(xProps.is())
2625 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2626 if( xPropsInfo.is() )
2628 if( xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
2629 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
2634 // set pos, size, shear and rotate
2635 SetTransformation();
2637 SdXMLShapeContext::StartElement(xAttrList);
2639 if( mpChartContext )
2640 mpChartContext->StartElement( xAttrList );
2644 void SdXMLChartShapeContext::EndElement()
2646 if( mpChartContext )
2647 mpChartContext->EndElement();
2649 SdXMLShapeContext::EndElement();
2652 void SdXMLChartShapeContext::Characters( const OUString& rChars )
2654 if( mpChartContext )
2655 mpChartContext->Characters( rChars );
2658 SvXMLImportContext * SdXMLChartShapeContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName,
2659 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
2661 if( mpChartContext )
2662 return mpChartContext->CreateChildContext( nPrefix, rLocalName, xAttrList );
2664 return NULL;
2667 TYPEINIT1( SdXMLObjectShapeContext, SdXMLShapeContext );
2669 SdXMLObjectShapeContext::SdXMLObjectShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
2670 const OUString& rLocalName,
2671 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2672 com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
2673 bool bTemporaryShape)
2674 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
2678 SdXMLObjectShapeContext::~SdXMLObjectShapeContext()
2682 void SdXMLObjectShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& )
2684 // #96717# in theorie, if we don't have a url we shouldn't even
2685 // export this ole shape. But practical its to risky right now
2686 // to change this so we better dispose this on load
2687 //if( !mbIsPlaceholder && ImpIsEmptyURL(maHref) )
2688 // return;
2690 // #100592# this BugFix prevents that a shape is created. CL
2691 // is thinking about an alternative.
2692 // #i13140# Check for more than empty string in maHref, there are
2693 // other possibilities that maHref results in empty container
2694 // storage names
2695 if( !(GetImport().getImportFlags() & SvXMLImportFlags::EMBEDDED) && !mbIsPlaceholder && ImpIsEmptyURL(maHref) )
2696 return;
2698 OUString service("com.sun.star.drawing.OLE2Shape");
2700 bool bIsPresShape = !maPresentationClass.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
2702 if( bIsPresShape )
2704 if( IsXMLToken( maPresentationClass, XML_PRESENTATION_CHART ) )
2706 service = "com.sun.star.presentation.ChartShape";
2708 else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_TABLE ) )
2710 service = "com.sun.star.presentation.CalcShape";
2712 else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_OBJECT ) )
2714 service = "com.sun.star.presentation.OLE2Shape";
2718 AddShape(service);
2720 if( mxShape.is() )
2722 SetLayer();
2724 if(bIsPresShape)
2726 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2727 if(xProps.is())
2729 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2730 if( xPropsInfo.is() )
2732 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
2733 xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
2735 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
2736 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
2741 if( !mbIsPlaceholder && !maHref.isEmpty() )
2743 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2745 if( xProps.is() )
2747 OUString aPersistName = GetImport().ResolveEmbeddedObjectURL( maHref, maCLSID );
2749 if ( GetImport().IsPackageURL( maHref ) )
2751 const OUString sURL( "vnd.sun.star.EmbeddedObject:" );
2753 if ( aPersistName.startsWith( sURL ) )
2754 aPersistName = aPersistName.copy( sURL.getLength() );
2756 xProps->setPropertyValue("PersistName",
2757 uno::makeAny( aPersistName ) );
2759 else
2761 // this is OOo link object
2762 xProps->setPropertyValue("LinkURL",
2763 uno::makeAny( aPersistName ) );
2768 // set pos, size, shear and rotate
2769 SetTransformation();
2771 SetStyle();
2773 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
2777 void SdXMLObjectShapeContext::EndElement()
2779 if (GetImport().isGeneratorVersionOlderThan(
2780 SvXMLImport::OOo_34x, SvXMLImport::LO_41x)) // < LO 4.0
2782 // #i118485#
2783 // If it's an old file from us written before OOo3.4, we need to correct
2784 // FillStyle and LineStyle for OLE2 objects. The error was that the old paint
2785 // implementations just ignored added fill/linestyles completely, thus
2786 // those objects need to be corrected to not show blue and hairline which
2787 // always was the default, but would be shown now
2788 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2790 if( xProps.is() )
2792 xProps->setPropertyValue("FillStyle", uno::makeAny(drawing::FillStyle_NONE));
2793 xProps->setPropertyValue("LineStyle", uno::makeAny(drawing::LineStyle_NONE));
2797 // #100592#
2798 if( mxBase64Stream.is() )
2800 OUString aPersistName( GetImport().ResolveEmbeddedObjectURLFromBase64() );
2801 const OUString sURL( "vnd.sun.star.EmbeddedObject:" );
2803 aPersistName = aPersistName.copy( sURL.getLength() );
2805 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2806 if( xProps.is() )
2807 xProps->setPropertyValue("PersistName", uno::makeAny( aPersistName ) );
2810 SdXMLShapeContext::EndElement();
2813 // this is called from the parent group for each unparsed attribute in the attribute list
2814 void SdXMLObjectShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
2816 switch( nPrefix )
2818 case XML_NAMESPACE_DRAW:
2819 if( IsXMLToken( rLocalName, XML_CLASS_ID ) )
2821 maCLSID = rValue;
2822 return;
2824 break;
2825 case XML_NAMESPACE_XLINK:
2826 if( IsXMLToken( rLocalName, XML_HREF ) )
2828 maHref = rValue;
2829 return;
2831 break;
2834 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2837 SvXMLImportContext* SdXMLObjectShapeContext::CreateChildContext(
2838 sal_uInt16 nPrefix, const OUString& rLocalName,
2839 const uno::Reference<xml::sax::XAttributeList>& xAttrList )
2841 // #100592#
2842 SvXMLImportContext* pContext = NULL;
2844 if((XML_NAMESPACE_OFFICE == nPrefix) && IsXMLToken(rLocalName, XML_BINARY_DATA))
2846 mxBase64Stream = GetImport().GetStreamForEmbeddedObjectURLFromBase64();
2847 if( mxBase64Stream.is() )
2848 pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
2849 rLocalName, xAttrList,
2850 mxBase64Stream );
2852 else if( ((XML_NAMESPACE_OFFICE == nPrefix) && IsXMLToken(rLocalName, XML_DOCUMENT)) ||
2853 ((XML_NAMESPACE_MATH == nPrefix) && IsXMLToken(rLocalName, XML_MATH)) )
2855 XMLEmbeddedObjectImportContext *pEContext =
2856 new XMLEmbeddedObjectImportContext( GetImport(), nPrefix,
2857 rLocalName, xAttrList );
2858 maCLSID = pEContext->GetFilterCLSID();
2859 if( !maCLSID.isEmpty() )
2861 uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2862 if( xPropSet.is() )
2864 xPropSet->setPropertyValue("CLSID", uno::makeAny( maCLSID ) );
2866 uno::Reference< lang::XComponent > xComp;
2867 xPropSet->getPropertyValue("Model") >>= xComp;
2868 DBG_ASSERT( xComp.is(), "no xModel for own OLE format" );
2869 pEContext->SetComponent( xComp );
2872 pContext = pEContext;
2875 // delegate to parent class if no context could be created
2876 if(!pContext)
2877 pContext = SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
2879 return pContext;
2882 TYPEINIT1( SdXMLAppletShapeContext, SdXMLShapeContext );
2884 SdXMLAppletShapeContext::SdXMLAppletShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
2885 const OUString& rLocalName,
2886 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2887 com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
2888 bool bTemporaryShape)
2889 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
2890 mbIsScript( false )
2894 SdXMLAppletShapeContext::~SdXMLAppletShapeContext()
2898 void SdXMLAppletShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& )
2900 AddShape("com.sun.star.drawing.AppletShape");
2902 if( mxShape.is() )
2904 SetLayer();
2906 // set pos, size, shear and rotate
2907 SetTransformation();
2908 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
2912 // this is called from the parent group for each unparsed attribute in the attribute list
2913 void SdXMLAppletShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
2915 switch( nPrefix )
2917 case XML_NAMESPACE_DRAW:
2918 if( IsXMLToken( rLocalName, XML_APPLET_NAME ) )
2920 maAppletName = rValue;
2921 return;
2923 if( IsXMLToken( rLocalName, XML_CODE ) )
2925 maAppletCode = rValue;
2926 return;
2928 if( IsXMLToken( rLocalName, XML_MAY_SCRIPT ) )
2930 mbIsScript = IsXMLToken( rValue, XML_TRUE );
2931 return;
2933 break;
2934 case XML_NAMESPACE_XLINK:
2935 if( IsXMLToken( rLocalName, XML_HREF ) )
2937 maHref = GetImport().GetAbsoluteReference(rValue);
2938 return;
2940 break;
2943 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2946 void SdXMLAppletShapeContext::EndElement()
2948 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2949 if( xProps.is() )
2951 uno::Any aAny;
2953 if ( maSize.Width && maSize.Height )
2955 // the visual area for applet must be set on loading
2956 awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height );
2957 aAny <<= aRect;
2958 xProps->setPropertyValue("VisibleArea", aAny );
2961 if( maParams.getLength() )
2963 aAny <<= maParams;
2964 xProps->setPropertyValue("AppletCommands", aAny );
2967 if( !maHref.isEmpty() )
2969 aAny <<= maHref;
2970 xProps->setPropertyValue("AppletCodeBase", aAny );
2973 if( !maAppletName.isEmpty() )
2975 aAny <<= maAppletName;
2976 xProps->setPropertyValue("AppletName", aAny );
2979 if( mbIsScript )
2981 aAny <<= mbIsScript;
2982 xProps->setPropertyValue("AppletIsScript", aAny );
2986 if( !maAppletCode.isEmpty() )
2988 aAny <<= maAppletCode;
2989 xProps->setPropertyValue("AppletCode", aAny );
2992 aAny <<= OUString( GetImport().GetDocumentBase() );
2993 xProps->setPropertyValue("AppletDocBase", aAny );
2995 SetThumbnail();
2998 SdXMLShapeContext::EndElement();
3001 SvXMLImportContext * SdXMLAppletShapeContext::CreateChildContext( sal_uInt16 p_nPrefix, const OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
3003 if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_PARAM ) )
3005 OUString aParamName, aParamValue;
3006 const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
3007 // now parse the attribute list and look for draw:name and draw:value
3008 for(sal_Int16 a(0); a < nAttrCount; a++)
3010 const OUString& rAttrName = xAttrList->getNameByIndex(a);
3011 OUString aLocalName;
3012 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
3013 const OUString aValue( xAttrList->getValueByIndex(a) );
3015 if( nPrefix == XML_NAMESPACE_DRAW )
3017 if( IsXMLToken( aLocalName, XML_NAME ) )
3019 aParamName = aValue;
3021 else if( IsXMLToken( aLocalName, XML_VALUE ) )
3023 aParamValue = aValue;
3028 if( !aParamName.isEmpty() )
3030 sal_Int32 nIndex = maParams.getLength();
3031 maParams.realloc( nIndex + 1 );
3032 maParams[nIndex].Name = aParamName;
3033 maParams[nIndex].Handle = -1;
3034 maParams[nIndex].Value <<= aParamValue;
3035 maParams[nIndex].State = beans::PropertyState_DIRECT_VALUE;
3038 return new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName );
3041 return SdXMLShapeContext::CreateChildContext( p_nPrefix, rLocalName, xAttrList );
3044 TYPEINIT1( SdXMLPluginShapeContext, SdXMLShapeContext );
3046 SdXMLPluginShapeContext::SdXMLPluginShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
3047 const OUString& rLocalName,
3048 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
3049 com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
3050 bool bTemporaryShape) :
3051 SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
3052 mbMedia( false )
3056 SdXMLPluginShapeContext::~SdXMLPluginShapeContext()
3060 void SdXMLPluginShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList)
3063 // watch for MimeType attribute to see if we have a media object
3064 for( sal_Int16 n = 0, nAttrCount = ( xAttrList.is() ? xAttrList->getLength() : 0 ); n < nAttrCount; ++n )
3066 OUString aLocalName;
3067 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( n ), &aLocalName );
3069 if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( aLocalName, XML_MIME_TYPE ) )
3071 if( xAttrList->getValueByIndex( n ) == "application/vnd.sun.star.media" )
3072 mbMedia = true;
3073 #if HAVE_FEATURE_GLTF
3074 if( xAttrList->getValueByIndex( n ) == "model/vnd.gltf+json" )
3075 mbMedia = true;
3076 #endif
3077 // leave this loop
3078 n = nAttrCount - 1;
3082 OUString service;
3084 bool bIsPresShape = false;
3086 if( mbMedia )
3088 service = "com.sun.star.drawing.MediaShape";
3090 bIsPresShape = !maPresentationClass.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
3091 if( bIsPresShape )
3093 if( IsXMLToken( maPresentationClass, XML_PRESENTATION_OBJECT ) )
3095 service = "com.sun.star.presentation.MediaShape";
3099 else
3100 service = "com.sun.star.drawing.PluginShape";
3102 AddShape(service);
3104 if( mxShape.is() )
3106 SetLayer();
3108 if(bIsPresShape)
3110 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3111 if(xProps.is())
3113 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
3114 if( xPropsInfo.is() )
3116 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
3117 xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
3119 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
3120 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
3125 // set pos, size, shear and rotate
3126 SetTransformation();
3127 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
3131 static OUString
3132 lcl_GetMediaReference(SvXMLImport const& rImport, OUString const& rURL)
3134 if (rImport.IsPackageURL(rURL))
3136 return "vnd.sun.star.Package:" + rURL;
3138 else
3140 return rImport.GetAbsoluteReference(rURL);
3144 // this is called from the parent group for each unparsed attribute in the attribute list
3145 void SdXMLPluginShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
3147 switch( nPrefix )
3149 case XML_NAMESPACE_DRAW:
3150 if( IsXMLToken( rLocalName, XML_MIME_TYPE ) )
3152 maMimeType = rValue;
3153 return;
3155 break;
3156 case XML_NAMESPACE_XLINK:
3157 if( IsXMLToken( rLocalName, XML_HREF ) )
3159 maHref = lcl_GetMediaReference(GetImport(), rValue);
3160 return;
3162 break;
3165 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
3168 void SdXMLPluginShapeContext::EndElement()
3170 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3172 if( xProps.is() )
3174 uno::Any aAny;
3176 if ( maSize.Width && maSize.Height )
3178 const OUString sVisibleArea( "VisibleArea" );
3179 uno::Reference< beans::XPropertySetInfo > aXPropSetInfo( xProps->getPropertySetInfo() );
3180 if ( !aXPropSetInfo.is() || aXPropSetInfo->hasPropertyByName( sVisibleArea ) )
3182 // the visual area for a plugin must be set on loading
3183 awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height );
3184 aAny <<= aRect;
3185 xProps->setPropertyValue( sVisibleArea, aAny );
3189 if( !mbMedia )
3191 // in case we have a plugin object
3192 if( maParams.getLength() )
3194 aAny <<= maParams;
3195 xProps->setPropertyValue("PluginCommands", aAny );
3198 if( !maMimeType.isEmpty() )
3200 aAny <<= maMimeType;
3201 xProps->setPropertyValue("PluginMimeType", aAny );
3204 if( !maHref.isEmpty() )
3206 aAny <<= maHref;
3207 xProps->setPropertyValue("PluginURL", aAny );
3210 else
3212 // in case we have a media object
3213 xProps->setPropertyValue(
3214 OUString("MediaURL"),
3215 uno::makeAny(maHref));
3217 xProps->setPropertyValue("MediaMimeType", uno::makeAny(maMimeType) );
3219 for( sal_Int32 nParam = 0; nParam < maParams.getLength(); ++nParam )
3221 const OUString& rName = maParams[ nParam ].Name;
3223 if( rName == "Loop" )
3225 OUString aValueStr;
3226 maParams[ nParam ].Value >>= aValueStr;
3227 xProps->setPropertyValue("Loop",
3228 uno::makeAny( aValueStr == "true" ) );
3230 else if( rName == "Mute" )
3232 OUString aValueStr;
3233 maParams[ nParam ].Value >>= aValueStr;
3234 xProps->setPropertyValue("Mute",
3235 uno::makeAny( aValueStr == "true" ) );
3237 else if( rName == "VolumeDB" )
3239 OUString aValueStr;
3240 maParams[ nParam ].Value >>= aValueStr;
3241 xProps->setPropertyValue("VolumeDB",
3242 uno::makeAny( static_cast< sal_Int16 >( aValueStr.toInt32() ) ) );
3244 else if( rName == "Zoom" )
3246 OUString aZoomStr;
3247 media::ZoomLevel eZoomLevel;
3249 maParams[ nParam ].Value >>= aZoomStr;
3251 if( aZoomStr == "25%" )
3252 eZoomLevel = media::ZoomLevel_ZOOM_1_TO_4;
3253 else if( aZoomStr == "50%" )
3254 eZoomLevel = media::ZoomLevel_ZOOM_1_TO_2;
3255 else if( aZoomStr == "100%" )
3256 eZoomLevel = media::ZoomLevel_ORIGINAL;
3257 else if( aZoomStr == "200%" )
3258 eZoomLevel = media::ZoomLevel_ZOOM_2_TO_1;
3259 else if( aZoomStr == "400%" )
3260 eZoomLevel = media::ZoomLevel_ZOOM_4_TO_1;
3261 else if( aZoomStr == "fit" )
3262 eZoomLevel = media::ZoomLevel_FIT_TO_WINDOW;
3263 else if( aZoomStr == "fixedfit" )
3264 eZoomLevel = media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT;
3265 else if( aZoomStr == "fullscreen" )
3266 eZoomLevel = media::ZoomLevel_FULLSCREEN;
3267 else
3268 eZoomLevel = media::ZoomLevel_NOT_AVAILABLE;
3270 xProps->setPropertyValue("Zoom", uno::makeAny( eZoomLevel ) );
3275 SetThumbnail();
3278 SdXMLShapeContext::EndElement();
3281 SvXMLImportContext * SdXMLPluginShapeContext::CreateChildContext( sal_uInt16 p_nPrefix, const OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
3283 if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_PARAM ) )
3285 OUString aParamName, aParamValue;
3286 const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
3287 // now parse the attribute list and look for draw:name and draw:value
3288 for(sal_Int16 a(0); a < nAttrCount; a++)
3290 const OUString& rAttrName = xAttrList->getNameByIndex(a);
3291 OUString aLocalName;
3292 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
3293 const OUString aValue( xAttrList->getValueByIndex(a) );
3295 if( nPrefix == XML_NAMESPACE_DRAW )
3297 if( IsXMLToken( aLocalName, XML_NAME ) )
3299 aParamName = aValue;
3301 else if( IsXMLToken( aLocalName, XML_VALUE ) )
3303 aParamValue = aValue;
3307 if( !aParamName.isEmpty() )
3309 sal_Int32 nIndex = maParams.getLength();
3310 maParams.realloc( nIndex + 1 );
3311 maParams[nIndex].Name = aParamName;
3312 maParams[nIndex].Handle = -1;
3313 maParams[nIndex].Value <<= aParamValue;
3314 maParams[nIndex].State = beans::PropertyState_DIRECT_VALUE;
3318 return new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName );
3321 return SdXMLShapeContext::CreateChildContext( p_nPrefix, rLocalName, xAttrList );
3324 TYPEINIT1( SdXMLFloatingFrameShapeContext, SdXMLShapeContext );
3326 SdXMLFloatingFrameShapeContext::SdXMLFloatingFrameShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
3327 const OUString& rLocalName,
3328 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
3329 com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
3330 bool bTemporaryShape)
3331 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
3335 SdXMLFloatingFrameShapeContext::~SdXMLFloatingFrameShapeContext()
3339 void SdXMLFloatingFrameShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& )
3341 AddShape("com.sun.star.drawing.FrameShape");
3343 if( mxShape.is() )
3345 SetLayer();
3347 // set pos, size, shear and rotate
3348 SetTransformation();
3350 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3351 if( xProps.is() )
3353 uno::Any aAny;
3355 if( !maFrameName.isEmpty() )
3357 aAny <<= maFrameName;
3358 xProps->setPropertyValue("FrameName", aAny );
3361 if( !maHref.isEmpty() )
3363 aAny <<= maHref;
3364 xProps->setPropertyValue("FrameURL", aAny );
3368 SetStyle();
3370 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
3374 // this is called from the parent group for each unparsed attribute in the attribute list
3375 void SdXMLFloatingFrameShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
3377 switch( nPrefix )
3379 case XML_NAMESPACE_DRAW:
3380 if( IsXMLToken( rLocalName, XML_FRAME_NAME ) )
3382 maFrameName = rValue;
3383 return;
3385 break;
3386 case XML_NAMESPACE_XLINK:
3387 if( IsXMLToken( rLocalName, XML_HREF ) )
3389 maHref = GetImport().GetAbsoluteReference(rValue);
3390 return;
3392 break;
3395 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
3398 void SdXMLFloatingFrameShapeContext::EndElement()
3400 uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3402 if( xProps.is() )
3404 if ( maSize.Width && maSize.Height )
3406 // the visual area for a floating frame must be set on loading
3407 awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height );
3408 uno::Any aAny;
3409 aAny <<= aRect;
3410 xProps->setPropertyValue("VisibleArea", aAny );
3414 SetThumbnail();
3415 SdXMLShapeContext::EndElement();
3418 TYPEINIT1( SdXMLFrameShapeContext, SdXMLShapeContext );
3420 SdXMLFrameShapeContext::SdXMLFrameShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
3421 const OUString& rLocalName,
3422 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
3423 com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
3424 bool bTemporaryShape)
3425 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
3426 MultiImageImportHelper(),
3427 mbSupportsReplacement( false ),
3428 mxImplContext(),
3429 mxReplImplContext()
3431 uno::Reference < util::XCloneable > xClone( xAttrList, uno::UNO_QUERY );
3432 if( xClone.is() )
3433 mxAttrList.set( xClone->createClone(), uno::UNO_QUERY );
3434 else
3435 mxAttrList = new SvXMLAttributeList( xAttrList );
3439 SdXMLFrameShapeContext::~SdXMLFrameShapeContext()
3443 void SdXMLFrameShapeContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext) const
3445 const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext);
3447 if(pSdXMLGraphicObjectShapeContext)
3451 uno::Reference< container::XChild > xChild(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW);
3453 if(xChild.is())
3455 uno::Reference< drawing::XShapes > xParent(xChild->getParent(), uno::UNO_QUERY_THROW);
3457 if(xParent.is())
3459 // remove from parent
3460 xParent->remove(pSdXMLGraphicObjectShapeContext->getShape());
3462 // dispose
3463 uno::Reference< lang::XComponent > xComp(pSdXMLGraphicObjectShapeContext->getShape(), UNO_QUERY);
3465 if(xComp.is())
3467 xComp->dispose();
3472 catch( uno::Exception& )
3474 OSL_FAIL( "Error in cleanup of multiple graphic object import (!)" );
3479 OUString SdXMLFrameShapeContext::getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const
3481 OUString aRetval;
3482 const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext);
3484 if(pSdXMLGraphicObjectShapeContext)
3488 const uno::Reference< beans::XPropertySet > xPropSet(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW);
3490 if(xPropSet.is())
3492 xPropSet->getPropertyValue("GraphicStreamURL") >>= aRetval;
3494 if(!aRetval.getLength())
3496 // it maybe a link, try GraphicURL
3497 xPropSet->getPropertyValue("GraphicURL") >>= aRetval;
3501 catch( uno::Exception& )
3503 OSL_FAIL( "Error in cleanup of multiple graphic object import (!)" );
3507 return aRetval;
3510 SvXMLImportContext *SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPrefix,
3511 const OUString& rLocalName,
3512 const uno::Reference< xml::sax::XAttributeList>& xAttrList )
3514 SvXMLImportContext * pContext = 0;
3516 if( !mxImplContext.Is() )
3518 SvXMLShapeContext* pShapeContext= GetImport().GetShapeImport()->CreateFrameChildContext(
3519 GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList );
3521 pContext = pShapeContext;
3523 // propagate the hyperlink to child context
3524 if ( !msHyperlink.isEmpty() )
3525 pShapeContext->setHyperlink( msHyperlink );
3527 #if !HAVE_FEATURE_GLTF
3528 // Ignore gltf model if necessary and so the fallback image will be imported
3529 if( IsXMLToken(rLocalName, XML_PLUGIN ) )
3531 SdXMLPluginShapeContext* pPluginContext = dynamic_cast<SdXMLPluginShapeContext*>(pShapeContext);
3532 if( pPluginContext && pPluginContext->getMimeType() == "model/vnd.gltf+json" )
3534 mxImplContext = 0;
3535 return this;
3538 #endif
3540 mxImplContext = pContext;
3541 mbSupportsReplacement = IsXMLToken(rLocalName, XML_OBJECT ) || IsXMLToken(rLocalName, XML_OBJECT_OLE);
3542 setSupportsMultipleContents(IsXMLToken(rLocalName, XML_IMAGE));
3544 if(getSupportsMultipleContents() && dynamic_cast< SdXMLGraphicObjectShapeContext* >(pContext))
3546 addContent(*mxImplContext);
3549 else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == nPrefix && IsXMLToken(rLocalName, XML_IMAGE))
3551 // read another image
3552 pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
3553 GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList);
3554 mxImplContext = pContext;
3556 if(dynamic_cast< SdXMLGraphicObjectShapeContext* >(pContext))
3558 addContent(*mxImplContext);
3561 else if( mbSupportsReplacement && !mxReplImplContext &&
3562 XML_NAMESPACE_DRAW == nPrefix &&
3563 IsXMLToken( rLocalName, XML_IMAGE ) )
3565 // read replacement image
3566 SvXMLImportContext *pImplContext = &mxImplContext;
3567 SdXMLShapeContext *pSContext =
3568 PTR_CAST( SdXMLShapeContext, pImplContext );
3569 if( pSContext )
3571 uno::Reference < beans::XPropertySet > xPropSet(
3572 pSContext->getShape(), uno::UNO_QUERY );
3573 if( xPropSet.is() )
3575 pContext = new XMLReplacementImageContext( GetImport(),
3576 nPrefix, rLocalName, xAttrList, xPropSet );
3577 mxReplImplContext = pContext;
3581 else if(
3582 ( nPrefix == XML_NAMESPACE_SVG && // #i68101#
3583 (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) ) ||
3584 (nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) ||
3585 (nPrefix == XML_NAMESPACE_DRAW && (IsXMLToken( rLocalName, XML_GLUE_POINT ) ||
3586 IsXMLToken( rLocalName, XML_THUMBNAIL ) ) ) )
3588 SvXMLImportContext *pImplContext = &mxImplContext;
3589 pContext = PTR_CAST( SdXMLShapeContext, pImplContext )->CreateChildContext( nPrefix,
3590 rLocalName, xAttrList );
3592 else if ( (XML_NAMESPACE_DRAW == nPrefix) && IsXMLToken( rLocalName, XML_IMAGE_MAP ) )
3594 SdXMLShapeContext *pSContext = dynamic_cast< SdXMLShapeContext* >( &mxImplContext );
3595 if( pSContext )
3597 uno::Reference < beans::XPropertySet > xPropSet( pSContext->getShape(), uno::UNO_QUERY );
3598 if (xPropSet.is())
3600 pContext = new XMLImageMapContext(GetImport(), nPrefix, rLocalName, xPropSet);
3604 // call parent for content
3605 if(!pContext)
3606 pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
3608 return pContext;
3611 void SdXMLFrameShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&)
3613 // ignore
3616 void SdXMLFrameShapeContext::EndElement()
3618 // solve if multiple image child contexts were imported
3619 SvXMLImportContextRef const pSelectedContext(solveMultipleImages());
3620 const SdXMLGraphicObjectShapeContext* pShapeContext(
3621 dynamic_cast<const SdXMLGraphicObjectShapeContext*>(&pSelectedContext));
3622 if ( pShapeContext && !maShapeId.isEmpty() )
3624 // fdo#64512 and fdo#60075 - make sure *this* shape is
3625 // registered for given ID
3626 assert( mxImplContext.Is() );
3627 const uno::Reference< uno::XInterface > xShape( pShapeContext->getShape() );
3628 GetImport().getInterfaceToIdentifierMapper().registerReferenceAlways( maShapeId, xShape );
3631 if( !mxImplContext.Is() )
3633 // now check if this is an empty presentation object
3634 sal_Int16 nAttrCount = mxAttrList.is() ? mxAttrList->getLength() : 0;
3635 for(sal_Int16 a(0); a < nAttrCount; a++)
3637 OUString aLocalName;
3638 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(mxAttrList->getNameByIndex(a), &aLocalName);
3640 if( nPrefix == XML_NAMESPACE_PRESENTATION )
3642 if( IsXMLToken( aLocalName, XML_PLACEHOLDER ) )
3644 mbIsPlaceholder = IsXMLToken( mxAttrList->getValueByIndex(a), XML_TRUE );
3646 else if( IsXMLToken( aLocalName, XML_CLASS ) )
3648 maPresentationClass = mxAttrList->getValueByIndex(a);
3653 if( (!maPresentationClass.isEmpty()) && mbIsPlaceholder )
3655 uno::Reference< xml::sax::XAttributeList> xEmpty;
3657 enum XMLTokenEnum eToken = XML_TEXT_BOX;
3659 if( IsXMLToken( maPresentationClass, XML_GRAPHIC ) )
3661 eToken = XML_IMAGE;
3664 else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_PAGE ) )
3666 eToken = XML_PAGE_THUMBNAIL;
3668 else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_CHART ) ||
3669 IsXMLToken( maPresentationClass, XML_PRESENTATION_TABLE ) ||
3670 IsXMLToken( maPresentationClass, XML_PRESENTATION_OBJECT ) )
3672 eToken = XML_OBJECT;
3675 mxImplContext = GetImport().GetShapeImport()->CreateFrameChildContext(
3676 GetImport(), XML_NAMESPACE_DRAW, GetXMLToken( eToken ), mxAttrList, mxShapes, xEmpty );
3678 if( mxImplContext.Is() )
3680 mxImplContext->StartElement( mxAttrList );
3681 mxImplContext->EndElement();
3686 mxImplContext = 0;
3687 SdXMLShapeContext::EndElement();
3690 void SdXMLFrameShapeContext::processAttribute( sal_uInt16 nPrefix,
3691 const OUString& rLocalName, const OUString& rValue )
3693 bool bId( false );
3695 switch ( nPrefix )
3697 case XML_NAMESPACE_DRAW :
3698 case XML_NAMESPACE_DRAW_EXT :
3699 bId = IsXMLToken( rLocalName, XML_ID );
3700 break;
3701 case XML_NAMESPACE_NONE :
3702 case XML_NAMESPACE_XML :
3703 bId = IsXMLToken( rLocalName, XML_ID );
3704 break;
3707 if ( bId )
3708 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
3711 TYPEINIT1( SdXMLCustomShapeContext, SdXMLShapeContext );
3713 SdXMLCustomShapeContext::SdXMLCustomShapeContext(
3714 SvXMLImport& rImport,
3715 sal_uInt16 nPrfx,
3716 const OUString& rLocalName,
3717 const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
3718 uno::Reference< drawing::XShapes >& rShapes,
3719 bool bTemporaryShape)
3720 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
3722 // See the XMLTextFrameContext ctor, a frame has Writer content (and not
3723 // editeng) if its autostyle has a parent style. Do the same for shapes as well.
3724 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
3725 for (sal_Int16 i=0; i < nAttrCount; ++i)
3727 const OUString& rAttrName = xAttrList->getNameByIndex(i);
3728 OUString aLocalName;
3729 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
3730 if (nPrefix == XML_NAMESPACE_DRAW && IsXMLToken(aLocalName, XML_STYLE_NAME))
3732 OUString aStyleName = xAttrList->getValueByIndex(i);
3733 if(!aStyleName.isEmpty())
3735 rtl::Reference<XMLTextImportHelper> xTxtImport = GetImport().GetTextImport();
3736 XMLPropStyleContext* pStyle = xTxtImport->FindAutoFrameStyle(aStyleName);
3737 if (pStyle && !pStyle->GetParentName().isEmpty())
3739 mbTextBox = true;
3740 break;
3747 SdXMLCustomShapeContext::~SdXMLCustomShapeContext()
3751 // this is called from the parent group for each unparsed attribute in the attribute list
3752 void SdXMLCustomShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
3754 if( XML_NAMESPACE_DRAW == nPrefix )
3756 if( IsXMLToken( rLocalName, XML_ENGINE ) )
3758 maCustomShapeEngine = rValue;
3759 return;
3761 if ( IsXMLToken( rLocalName, XML_DATA ) )
3763 maCustomShapeData = rValue;
3764 return;
3767 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
3770 void SdXMLCustomShapeContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
3772 // create rectangle shape
3773 AddShape("com.sun.star.drawing.CustomShape");
3774 if ( mxShape.is() )
3776 // Add, set Style and properties from base shape
3777 SetStyle();
3778 SetLayer();
3780 // set pos, size, shear and rotate
3781 SetTransformation();
3785 uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
3786 if( xPropSet.is() )
3788 if ( !maCustomShapeEngine.isEmpty() )
3790 uno::Any aAny;
3791 aAny <<= maCustomShapeEngine;
3792 xPropSet->setPropertyValue( EASGet( EAS_CustomShapeEngine ), aAny );
3794 if ( !maCustomShapeData.isEmpty() )
3796 uno::Any aAny;
3797 aAny <<= maCustomShapeData;
3798 xPropSet->setPropertyValue( EASGet( EAS_CustomShapeData ), aAny );
3802 catch(const uno::Exception&)
3804 OSL_FAIL( "could not set enhanced customshape geometry" );
3806 SdXMLShapeContext::StartElement(xAttrList);
3810 void SdXMLCustomShapeContext::EndElement()
3812 // for backward compatibility, the above SetTransformation() may alraedy have
3813 // applied a call to SetMirroredX/SetMirroredY. This is not yet added to the
3814 // beans::PropertyValues in maCustomShapeGeometry. When applying these now, this
3815 // would be lost again.
3816 // TTTT: Remove again after aw080
3817 if(!maUsedTransformation.isIdentity())
3819 basegfx::B2DVector aScale, aTranslate;
3820 double fRotate, fShearX;
3822 maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
3824 bool bFlippedX(aScale.getX() < 0.0);
3825 bool bFlippedY(aScale.getY() < 0.0);
3827 if(bFlippedX && bFlippedY)
3829 // when both are used it is the same as 180 degree rotation; reset
3830 bFlippedX = bFlippedY = false;
3833 if(bFlippedX || bFlippedY)
3835 OUString sName;
3837 if(bFlippedX)
3838 sName = "MirroredX";
3839 else
3840 sName = "MirroredY";
3842 //fdo#84043 overwrite the property if it already exists, otherwise append it
3843 beans::PropertyValue* pItem;
3844 std::vector< beans::PropertyValue >::iterator aI(maCustomShapeGeometry.begin());
3845 std::vector< beans::PropertyValue >::iterator aE(maCustomShapeGeometry.end());
3846 while (aI != aE)
3848 if (aI->Name == sName)
3849 break;
3850 ++aI;
3852 if (aI != aE)
3854 beans::PropertyValue& rItem = *aI;
3855 pItem = &rItem;
3857 else
3859 maCustomShapeGeometry.push_back(beans::PropertyValue());
3860 pItem = &maCustomShapeGeometry.back();
3863 pItem->Name = sName;
3864 pItem->Handle = -1;
3865 pItem->Value <<= sal_True;
3866 pItem->State = beans::PropertyState_DIRECT_VALUE;
3870 if ( !maCustomShapeGeometry.empty() )
3872 const OUString sCustomShapeGeometry ( "CustomShapeGeometry" );
3874 // converting the vector to a sequence
3875 uno::Sequence< beans::PropertyValue > aSeq( maCustomShapeGeometry.size() );
3876 beans::PropertyValue* pValues = aSeq.getArray();
3877 std::vector< beans::PropertyValue >::const_iterator aIter( maCustomShapeGeometry.begin() );
3878 std::vector< beans::PropertyValue >::const_iterator aEnd( maCustomShapeGeometry.end() );
3879 while ( aIter != aEnd )
3880 *pValues++ = *aIter++;
3884 uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
3885 if( xPropSet.is() )
3887 uno::Any aAny;
3888 aAny <<= aSeq;
3889 xPropSet->setPropertyValue( sCustomShapeGeometry, aAny );
3892 catch(const uno::Exception&)
3894 OSL_FAIL( "could not set enhanced customshape geometry" );
3897 sal_Int32 nUPD;
3898 sal_Int32 nBuild;
3899 if (GetImport().getBuildIds(nUPD, nBuild))
3901 if( ((nUPD >= 640 && nUPD <= 645) || (nUPD == 680)) && (nBuild <= 9221) )
3903 Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( mxShape, UNO_QUERY );
3904 if( xDefaulter.is() )
3906 OUString aEmptyType;
3907 xDefaulter->createCustomShapeDefaults( aEmptyType );
3913 SdXMLShapeContext::EndElement();
3916 SvXMLImportContext* SdXMLCustomShapeContext::CreateChildContext(
3917 sal_uInt16 nPrefix, const OUString& rLocalName,
3918 const uno::Reference<xml::sax::XAttributeList>& xAttrList )
3920 SvXMLImportContext* pContext = NULL;
3921 if ( XML_NAMESPACE_DRAW == nPrefix )
3923 if ( IsXMLToken( rLocalName, XML_ENHANCED_GEOMETRY ) )
3925 uno::Reference< beans::XPropertySet > xPropSet( mxShape,uno::UNO_QUERY );
3926 if ( xPropSet.is() )
3927 pContext = new XMLEnhancedCustomShapeContext( GetImport(), mxShape, nPrefix, rLocalName, maCustomShapeGeometry );
3930 // delegate to parent class if no context could be created
3931 if ( NULL == pContext )
3932 pContext = SdXMLShapeContext::CreateChildContext( nPrefix, rLocalName,
3933 xAttrList);
3934 return pContext;
3937 TYPEINIT1( SdXMLTableShapeContext, SdXMLShapeContext );
3939 SdXMLTableShapeContext::SdXMLTableShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes )
3940 : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, false )
3942 memset( &maTemplateStylesUsed, 0, sizeof( maTemplateStylesUsed ) );
3945 SdXMLTableShapeContext::~SdXMLTableShapeContext()
3949 void SdXMLTableShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList )
3951 OUString service("com.sun.star.drawing.TableShape");
3953 bool bIsPresShape = !maPresentationClass.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
3954 if( bIsPresShape )
3956 if( IsXMLToken( maPresentationClass, XML_PRESENTATION_TABLE ) )
3958 service = "com.sun.star.presentation.TableShape";
3962 AddShape(service);
3964 if( mxShape.is() )
3966 SetLayer();
3968 uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
3970 if(bIsPresShape)
3972 if(xProps.is())
3974 uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
3975 if( xPropsInfo.is() )
3977 if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject"))
3978 xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) );
3980 if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent"))
3981 xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) );
3986 SetStyle();
3988 if( xProps.is() )
3990 if( !msTemplateStyleName.isEmpty() ) try
3992 Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetImport().GetModel(), UNO_QUERY_THROW );
3993 Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
3994 const OUString sFamilyName( "table" );
3995 Reference< XNameAccess > xTableFamily( xFamilies->getByName( sFamilyName ), UNO_QUERY_THROW );
3996 Reference< XStyle > xTableStyle( xTableFamily->getByName( msTemplateStyleName ), UNO_QUERY_THROW );
3997 xProps->setPropertyValue("TableTemplate", Any( xTableStyle ) );
3999 catch(const Exception&)
4001 OSL_FAIL("SdXMLTableShapeContext::StartElement(), exception caught!");
4004 const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0];
4005 for( int i = 0; pEntry->msApiName && (i < 6); i++, pEntry++ )
4009 const OUString sAPIPropertyName( pEntry->msApiName, pEntry->nApiNameLength, RTL_TEXTENCODING_ASCII_US );
4010 xProps->setPropertyValue( sAPIPropertyName, Any( maTemplateStylesUsed[i] ) );
4012 catch(const Exception&)
4014 OSL_FAIL("SdXMLTableShapeContext::StartElement(), exception caught!");
4019 GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
4021 const rtl::Reference< XMLTableImport >& xTableImport( GetImport().GetShapeImport()->GetShapeTableImport() );
4022 if( xTableImport.is() && xProps.is() )
4024 uno::Reference< table::XColumnRowRange > xColumnRowRange(
4025 xProps->getPropertyValue("Model"), uno::UNO_QUERY );
4027 if( xColumnRowRange.is() )
4028 mxTableImportContext = xTableImport->CreateTableContext( GetPrefix(), GetLocalName(), xColumnRowRange );
4030 if( mxTableImportContext.Is() )
4031 mxTableImportContext->StartElement( xAttrList );
4036 void SdXMLTableShapeContext::EndElement()
4038 if( mxTableImportContext.Is() )
4039 mxTableImportContext->EndElement();
4041 SdXMLShapeContext::EndElement();
4043 if( mxShape.is() )
4045 // set pos, size, shear and rotate
4046 SetTransformation();
4050 // this is called from the parent group for each unparsed attribute in the attribute list
4051 void SdXMLTableShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue )
4053 if( nPrefix == XML_NAMESPACE_TABLE )
4055 if( IsXMLToken( rLocalName, XML_TEMPLATE_NAME ) )
4057 msTemplateStyleName = rValue;
4059 else
4061 int i = 0;
4062 const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0];
4063 while( pEntry->msApiName && (i < 6) )
4065 if( IsXMLToken( rLocalName, pEntry->meXMLName ) )
4067 if( IsXMLToken( rValue, XML_TRUE ) )
4068 maTemplateStylesUsed[i] = sal_True;
4069 break;
4071 pEntry++;
4072 i++;
4076 SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
4079 SvXMLImportContext* SdXMLTableShapeContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& xAttrList )
4081 if( mxTableImportContext.Is() && (nPrefix == XML_NAMESPACE_TABLE) )
4082 return mxTableImportContext->CreateChildContext(nPrefix, rLocalName, xAttrList);
4083 else
4084 return SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
4087 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */