xref: /AOO41X/main/xmloff/source/draw/ximpshap.cxx (revision 32902674698f9be8a0c4935c47acfb91ea8783d2)
163bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
363bba73cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
463bba73cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
563bba73cSAndrew Rist  * distributed with this work for additional information
663bba73cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
763bba73cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
863bba73cSAndrew Rist  * "License"); you may not use this file except in compliance
963bba73cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
1163bba73cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
1363bba73cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1463bba73cSAndrew Rist  * software distributed under the License is distributed on an
1563bba73cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1663bba73cSAndrew Rist  * KIND, either express or implied.  See the License for the
1763bba73cSAndrew Rist  * specific language governing permissions and limitations
1863bba73cSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
2063bba73cSAndrew Rist  *************************************************************/
2163bba73cSAndrew Rist 
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include <tools/debug.hxx>
26cdf0e10cSrcweir #include <com/sun/star/document/XEventsSupplier.hpp>
27cdf0e10cSrcweir #include <com/sun/star/container/XNameReplace.hpp>
28cdf0e10cSrcweir #include <com/sun/star/presentation/ClickAction.hpp>
29cdf0e10cSrcweir #include <com/sun/star/drawing/FillStyle.hpp>
30cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp>
31cdf0e10cSrcweir #include "unointerfacetouniqueidentifiermapper.hxx"
32cdf0e10cSrcweir #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
33cdf0e10cSrcweir #include <com/sun/star/container/XIdentifierAccess.hpp>
34cdf0e10cSrcweir #include <com/sun/star/drawing/GluePoint2.hpp>
35cdf0e10cSrcweir #include <com/sun/star/drawing/Alignment.hpp>
36cdf0e10cSrcweir #include <com/sun/star/drawing/EscapeDirection.hpp>
37cdf0e10cSrcweir #include <com/sun/star/media/ZoomLevel.hpp>
38cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp>
39cdf0e10cSrcweir #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
40cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
41cdf0e10cSrcweir #include <comphelper/extract.hxx>
42cdf0e10cSrcweir #include "ximpshap.hxx"
43cdf0e10cSrcweir #include <xmloff/XMLBase64ImportContext.hxx>
44cdf0e10cSrcweir #include <xmloff/XMLShapeStyleContext.hxx>
45cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
46cdf0e10cSrcweir #include <com/sun/star/container/XNamed.hpp>
47cdf0e10cSrcweir #include <com/sun/star/drawing/CircleKind.hpp>
48cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
49cdf0e10cSrcweir #include <com/sun/star/awt/XControlModel.hpp>
50cdf0e10cSrcweir #include <com/sun/star/drawing/XControlShape.hpp>
51cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequenceSequence.hpp>
52cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequence.hpp>
53cdf0e10cSrcweir #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
54cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
55cdf0e10cSrcweir #include <com/sun/star/util/XCloneable.hpp>
56cdf0e10cSrcweir #include <com/sun/star/beans/XMultiPropertyStates.hpp>
57cdf0e10cSrcweir #include "xexptran.hxx"
58cdf0e10cSrcweir #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
59cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp>
60cdf0e10cSrcweir #include <com/sun/star/drawing/ConnectorType.hpp>
61cdf0e10cSrcweir #include <com/sun/star/drawing/HomogenMatrix3.hpp>
62cdf0e10cSrcweir #include "PropertySetMerger.hxx"
63cdf0e10cSrcweir #include <xmloff/families.hxx>
64cdf0e10cSrcweir #include "ximpstyl.hxx"
65cdf0e10cSrcweir #include"xmloff/xmlnmspe.hxx"
66cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
67cdf0e10cSrcweir #include "EnhancedCustomShapeToken.hxx"
68cdf0e10cSrcweir #include "XMLReplacementImageContext.hxx"
69cdf0e10cSrcweir #include "XMLImageMapContext.hxx"
70cdf0e10cSrcweir #include "sdpropls.hxx"
71cdf0e10cSrcweir #include "eventimp.hxx"
72cdf0e10cSrcweir #include "descriptionimp.hxx"
73cdf0e10cSrcweir #include "ximpcustomshape.hxx"
74cdf0e10cSrcweir #include "XMLEmbeddedObjectImportContext.hxx"
75cdf0e10cSrcweir #include "xmloff/xmlerror.hxx"
76cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
77cdf0e10cSrcweir #include <tools/string.hxx>
78cdf0e10cSrcweir #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
79ddde725dSArmin Le Grand #include <com/sun/star/container/XChild.hpp>
80cdf0e10cSrcweir #include <com/sun/star/text/XTextDocument.hpp>
816381da86SArmin Le Grand #include <basegfx/vector/b2dvector.hxx>
82242c6546SArmin Le Grand #include <basegfx/point/b2dpoint.hxx>
83cdf0e10cSrcweir 
84cdf0e10cSrcweir using ::rtl::OUString;
85cdf0e10cSrcweir using ::rtl::OUStringBuffer;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir using namespace ::com::sun::star;
88cdf0e10cSrcweir using namespace ::com::sun::star::uno;
89cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
90cdf0e10cSrcweir using namespace ::com::sun::star::style;
91cdf0e10cSrcweir using namespace ::com::sun::star::container;
92cdf0e10cSrcweir using namespace ::com::sun::star::document;
93cdf0e10cSrcweir using namespace ::xmloff::token;
94cdf0e10cSrcweir using namespace ::xmloff::EnhancedCustomShapeToken;
95cdf0e10cSrcweir 
96cdf0e10cSrcweir SvXMLEnumMapEntry aXML_GlueAlignment_EnumMap[] =
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	{ XML_TOP_LEFT, 	drawing::Alignment_TOP_LEFT },
99cdf0e10cSrcweir 	{ XML_TOP,			drawing::Alignment_TOP },
100cdf0e10cSrcweir 	{ XML_TOP_RIGHT,	drawing::Alignment_TOP_RIGHT },
101cdf0e10cSrcweir 	{ XML_LEFT,		    drawing::Alignment_LEFT },
102cdf0e10cSrcweir 	{ XML_CENTER,		drawing::Alignment_CENTER },
103cdf0e10cSrcweir 	{ XML_RIGHT,		drawing::Alignment_RIGHT },
104cdf0e10cSrcweir 	{ XML_BOTTOM_LEFT,	drawing::Alignment_BOTTOM_LEFT },
105cdf0e10cSrcweir 	{ XML_BOTTOM,		drawing::Alignment_BOTTOM },
106cdf0e10cSrcweir 	{ XML_BOTTOM_RIGHT, drawing::Alignment_BOTTOM_RIGHT },
107cdf0e10cSrcweir 	{ XML_TOKEN_INVALID, 0 }
108cdf0e10cSrcweir };
109cdf0e10cSrcweir 
110cdf0e10cSrcweir SvXMLEnumMapEntry aXML_GlueEscapeDirection_EnumMap[] =
111cdf0e10cSrcweir {
112cdf0e10cSrcweir 	{ XML_AUTO, 		drawing::EscapeDirection_SMART },
113cdf0e10cSrcweir 	{ XML_LEFT,	    	drawing::EscapeDirection_LEFT },
114cdf0e10cSrcweir     { XML_RIGHT,		drawing::EscapeDirection_RIGHT },
115cdf0e10cSrcweir     { XML_UP,			drawing::EscapeDirection_UP },
116cdf0e10cSrcweir     { XML_DOWN,		    drawing::EscapeDirection_DOWN },
117cdf0e10cSrcweir     { XML_HORIZONTAL,	drawing::EscapeDirection_HORIZONTAL },
118cdf0e10cSrcweir     { XML_VERTICAL,	    drawing::EscapeDirection_VERTICAL },
119cdf0e10cSrcweir 	{ XML_TOKEN_INVALID, 0 }
120cdf0e10cSrcweir };
121cdf0e10cSrcweir 
122cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
123cdf0e10cSrcweir 
124cdf0e10cSrcweir static bool ImpIsEmptyURL( const ::rtl::OUString& rURL )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir     if( rURL.getLength() == 0 )
127cdf0e10cSrcweir         return true;
128cdf0e10cSrcweir 
129cdf0e10cSrcweir     // #i13140# Also compare against 'toplevel' URLs. which also
130cdf0e10cSrcweir     // result in empty filename strings.
131cdf0e10cSrcweir     if( 0 == rURL.compareToAscii( "#./" ) )
132cdf0e10cSrcweir         return true;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     return false;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
138cdf0e10cSrcweir 
139cdf0e10cSrcweir TYPEINIT1( SvXMLShapeContext, SvXMLImportContext );
140cdf0e10cSrcweir TYPEINIT1( SdXMLShapeContext, SvXMLShapeContext );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir SdXMLShapeContext::SdXMLShapeContext(
143cdf0e10cSrcweir 	SvXMLImport& rImport,
144cdf0e10cSrcweir 	sal_uInt16 nPrfx,
145cdf0e10cSrcweir 	const OUString& rLocalName,
146cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
147cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
148cdf0e10cSrcweir     sal_Bool bTemporaryShape)
149cdf0e10cSrcweir :	SvXMLShapeContext( rImport, nPrfx, rLocalName, bTemporaryShape )
150cdf0e10cSrcweir ,	mxShapes( rShapes )
151cdf0e10cSrcweir ,	mxAttrList(xAttrList)
152cdf0e10cSrcweir ,	mbListContextPushed( false )
153cdf0e10cSrcweir ,	mnStyleFamily(XML_STYLE_FAMILY_SD_GRAPHICS_ID)
154cdf0e10cSrcweir ,	mbIsPlaceholder(sal_False)
155cdf0e10cSrcweir ,	mbClearDefaultAttributes( true )
156cdf0e10cSrcweir ,	mbIsUserTransformed(sal_False)
157cdf0e10cSrcweir ,	mnZOrder(-1)
158cdf0e10cSrcweir ,	maSize(1, 1)
159cdf0e10cSrcweir ,	maPosition(0, 0)
1606381da86SArmin Le Grand ,   maUsedTransformation()
161cdf0e10cSrcweir ,	mbVisible(true)
162cdf0e10cSrcweir ,	mbPrintable(true)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
166cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
167cdf0e10cSrcweir 
168cdf0e10cSrcweir SdXMLShapeContext::~SdXMLShapeContext()
169cdf0e10cSrcweir {
170cdf0e10cSrcweir }
171cdf0e10cSrcweir 
172cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
173cdf0e10cSrcweir 
174cdf0e10cSrcweir SvXMLImportContext *SdXMLShapeContext::CreateChildContext( sal_uInt16 p_nPrefix,
175cdf0e10cSrcweir 	const OUString& rLocalName,
176cdf0e10cSrcweir 	const uno::Reference< xml::sax::XAttributeList>& xAttrList )
177cdf0e10cSrcweir {
178cdf0e10cSrcweir 	SvXMLImportContext * pContext = NULL;
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	// #i68101#
181cdf0e10cSrcweir 	if( p_nPrefix == XML_NAMESPACE_SVG &&
182cdf0e10cSrcweir 		(IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) )
183cdf0e10cSrcweir 	{
184cdf0e10cSrcweir 		pContext = new SdXMLDescriptionContext( GetImport(), p_nPrefix, rLocalName, xAttrList, mxShape );
185cdf0e10cSrcweir 	}
186cdf0e10cSrcweir 	else if( p_nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
187cdf0e10cSrcweir 	{
188cdf0e10cSrcweir 		pContext = new SdXMLEventsContext( GetImport(), p_nPrefix, rLocalName, xAttrList, mxShape );
189cdf0e10cSrcweir 	}
190cdf0e10cSrcweir 	else if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_GLUE_POINT ) )
191cdf0e10cSrcweir 	{
192cdf0e10cSrcweir 		addGluePoint( xAttrList );
193cdf0e10cSrcweir 	}
194cdf0e10cSrcweir 	else if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_THUMBNAIL ) )
195cdf0e10cSrcweir 	{
196cdf0e10cSrcweir 		// search attributes for xlink:href
197cdf0e10cSrcweir 		sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
198cdf0e10cSrcweir 		for(sal_Int16 i=0; i < nAttrCount; i++)
199cdf0e10cSrcweir 		{
200cdf0e10cSrcweir 			OUString sAttrName = xAttrList->getNameByIndex( i );
201cdf0e10cSrcweir 			OUString aLocalName;
202cdf0e10cSrcweir 			sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
203cdf0e10cSrcweir 
204cdf0e10cSrcweir 			if( nPrefix == XML_NAMESPACE_XLINK )
205cdf0e10cSrcweir 			{
206cdf0e10cSrcweir 				if( IsXMLToken( aLocalName, XML_HREF ) )
207cdf0e10cSrcweir 				{
208cdf0e10cSrcweir 					maThumbnailURL = xAttrList->getValueByIndex( i );
209cdf0e10cSrcweir 					break;
210cdf0e10cSrcweir 				}
211cdf0e10cSrcweir 			}
212cdf0e10cSrcweir 		}
213cdf0e10cSrcweir 	}
214cdf0e10cSrcweir 	else
215cdf0e10cSrcweir 	{
216cdf0e10cSrcweir 		// create text cursor on demand
217cdf0e10cSrcweir 		if( !mxCursor.is() )
218cdf0e10cSrcweir 		{
219cdf0e10cSrcweir 			uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
220cdf0e10cSrcweir 			if( xText.is() )
221cdf0e10cSrcweir 			{
222cdf0e10cSrcweir 				UniReference < XMLTextImportHelper > xTxtImport =
223cdf0e10cSrcweir 					GetImport().GetTextImport();
224cdf0e10cSrcweir 				mxOldCursor = xTxtImport->GetCursor();
225cdf0e10cSrcweir 				mxCursor = xText->createTextCursor();
226cdf0e10cSrcweir 				if( mxCursor.is() )
227cdf0e10cSrcweir 				{
228cdf0e10cSrcweir 					xTxtImport->SetCursor( mxCursor );
229cdf0e10cSrcweir 				}
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 				// remember old list item and block (#91964#) and reset them
232cdf0e10cSrcweir 				// for the text frame
233cdf0e10cSrcweir                 xTxtImport->PushListContext();
234cdf0e10cSrcweir                 mbListContextPushed = true;
235cdf0e10cSrcweir 			}
236cdf0e10cSrcweir 		}
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 		// if we have a text cursor, lets  try to import some text
239cdf0e10cSrcweir 		if( mxCursor.is() )
240cdf0e10cSrcweir 		{
241cdf0e10cSrcweir 			pContext = GetImport().GetTextImport()->CreateTextChildContext(
242cdf0e10cSrcweir 				GetImport(), p_nPrefix, rLocalName, xAttrList );
243cdf0e10cSrcweir 		}
244cdf0e10cSrcweir 	}
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 	// call parent for content
247cdf0e10cSrcweir 	if(!pContext)
248cdf0e10cSrcweir 		pContext = SvXMLImportContext::CreateChildContext( p_nPrefix, rLocalName, xAttrList );
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 	return pContext;
251cdf0e10cSrcweir }
252cdf0e10cSrcweir 
253cdf0e10cSrcweir void SdXMLShapeContext::addGluePoint( const uno::Reference< xml::sax::XAttributeList>& xAttrList )
254cdf0e10cSrcweir {
255cdf0e10cSrcweir 	// get the glue points container for this shape if its not already there
256cdf0e10cSrcweir 	if( !mxGluePoints.is() )
257cdf0e10cSrcweir 	{
258cdf0e10cSrcweir 		uno::Reference< drawing::XGluePointsSupplier > xSupplier( mxShape, uno::UNO_QUERY );
259cdf0e10cSrcweir 		if( !xSupplier.is() )
260cdf0e10cSrcweir 			return;
261cdf0e10cSrcweir 
262cdf0e10cSrcweir 		mxGluePoints = uno::Reference< container::XIdentifierContainer >::query( xSupplier->getGluePoints() );
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 		if( !mxGluePoints.is() )
265cdf0e10cSrcweir 			return;
266cdf0e10cSrcweir 	}
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 	drawing::GluePoint2 aGluePoint;
269cdf0e10cSrcweir 	aGluePoint.IsUserDefined = sal_True;
270cdf0e10cSrcweir 	aGluePoint.Position.X = 0;
271cdf0e10cSrcweir 	aGluePoint.Position.Y = 0;
272cdf0e10cSrcweir 	aGluePoint.Escape = drawing::EscapeDirection_SMART;
273cdf0e10cSrcweir 	aGluePoint.PositionAlignment = drawing::Alignment_CENTER;
274cdf0e10cSrcweir 	aGluePoint.IsRelative = sal_True;
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	sal_Int32 nId = -1;
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 	// read attributes for the 3DScene
279cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
280cdf0e10cSrcweir 	for(sal_Int16 i=0; i < nAttrCount; i++)
281cdf0e10cSrcweir 	{
282cdf0e10cSrcweir 		OUString sAttrName = xAttrList->getNameByIndex( i );
283cdf0e10cSrcweir 		OUString aLocalName;
284cdf0e10cSrcweir 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
285cdf0e10cSrcweir 		const OUString sValue( xAttrList->getValueByIndex( i ) );
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 		if( nPrefix == XML_NAMESPACE_SVG )
288cdf0e10cSrcweir 		{
289cdf0e10cSrcweir 			if( IsXMLToken( aLocalName, XML_X ) )
290cdf0e10cSrcweir 			{
291cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertMeasure(aGluePoint.Position.X, sValue);
292cdf0e10cSrcweir 			}
293cdf0e10cSrcweir 			else if( IsXMLToken( aLocalName, XML_Y ) )
294cdf0e10cSrcweir 			{
295cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertMeasure(aGluePoint.Position.Y, sValue);
296cdf0e10cSrcweir 			}
297cdf0e10cSrcweir 		}
298cdf0e10cSrcweir 		else if( nPrefix == XML_NAMESPACE_DRAW )
299cdf0e10cSrcweir 		{
300cdf0e10cSrcweir 			if( IsXMLToken( aLocalName, XML_ID ) )
301cdf0e10cSrcweir 			{
302cdf0e10cSrcweir 				nId = sValue.toInt32();
303cdf0e10cSrcweir 			}
304cdf0e10cSrcweir 			else if( IsXMLToken( aLocalName, XML_ALIGN ) )
305cdf0e10cSrcweir 			{
306cdf0e10cSrcweir 				sal_uInt16 eKind;
307cdf0e10cSrcweir 				if( SvXMLUnitConverter::convertEnum( eKind, sValue, aXML_GlueAlignment_EnumMap ) )
308cdf0e10cSrcweir 				{
309cdf0e10cSrcweir 					aGluePoint.PositionAlignment = (drawing::Alignment)eKind;
310cdf0e10cSrcweir 					aGluePoint.IsRelative = sal_False;
311cdf0e10cSrcweir 				}
312cdf0e10cSrcweir 			}
313cdf0e10cSrcweir 			else if( IsXMLToken( aLocalName, XML_ESCAPE_DIRECTION ) )
314cdf0e10cSrcweir 			{
315cdf0e10cSrcweir 				sal_uInt16 eKind;
316cdf0e10cSrcweir 				if( SvXMLUnitConverter::convertEnum( eKind, sValue, aXML_GlueEscapeDirection_EnumMap ) )
317cdf0e10cSrcweir 				{
318cdf0e10cSrcweir 					aGluePoint.Escape = (drawing::EscapeDirection)eKind;
319cdf0e10cSrcweir 				}
320cdf0e10cSrcweir 			}
321cdf0e10cSrcweir 		}
322cdf0e10cSrcweir 	}
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 	if( nId != -1 )
325cdf0e10cSrcweir 	{
326cdf0e10cSrcweir 		try
327cdf0e10cSrcweir 		{
328cdf0e10cSrcweir 			sal_Int32 nInternalId = mxGluePoints->insert( uno::makeAny( aGluePoint ) );
329cdf0e10cSrcweir 			GetImport().GetShapeImport()->addGluePointMapping( mxShape, nId, nInternalId );
330cdf0e10cSrcweir 		}
331cdf0e10cSrcweir 		catch( uno::Exception& )
332cdf0e10cSrcweir 		{
333cdf0e10cSrcweir 			DBG_ERROR( "exception during setting of glue points!");
334cdf0e10cSrcweir 		}
335cdf0e10cSrcweir 	}
336cdf0e10cSrcweir }
337cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
338cdf0e10cSrcweir 
339cdf0e10cSrcweir void SdXMLShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&)
340cdf0e10cSrcweir {
341cdf0e10cSrcweir     GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
342cdf0e10cSrcweir }
343cdf0e10cSrcweir 
344cdf0e10cSrcweir void SdXMLShapeContext::EndElement()
345cdf0e10cSrcweir {
346cdf0e10cSrcweir 	if(mxCursor.is())
347cdf0e10cSrcweir 	{
348cdf0e10cSrcweir 		// delete addition newline
349cdf0e10cSrcweir 		const OUString aEmpty;
350cdf0e10cSrcweir 		mxCursor->gotoEnd( sal_False );
351cdf0e10cSrcweir 		mxCursor->goLeft( 1, sal_True );
352cdf0e10cSrcweir 		mxCursor->setString( aEmpty );
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 		// reset cursor
355cdf0e10cSrcweir 		GetImport().GetTextImport()->ResetCursor();
356cdf0e10cSrcweir 	}
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 	if(mxOldCursor.is())
359cdf0e10cSrcweir 		GetImport().GetTextImport()->SetCursor( mxOldCursor );
360cdf0e10cSrcweir 
361cdf0e10cSrcweir     // reinstall old list item (if necessary) #91964#
362cdf0e10cSrcweir     if (mbListContextPushed) {
363cdf0e10cSrcweir         GetImport().GetTextImport()->PopListContext();
364cdf0e10cSrcweir     }
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 	if( msHyperlink.getLength() != 0 ) try
367cdf0e10cSrcweir 	{
368cdf0e10cSrcweir 		const OUString sBookmark( RTL_CONSTASCII_USTRINGPARAM( "Bookmark" ) );
369cdf0e10cSrcweir 
370cdf0e10cSrcweir         Reference< XEventsSupplier > xEventsSupplier( mxShape, UNO_QUERY );
371cdf0e10cSrcweir 		if( xEventsSupplier.is() )
372cdf0e10cSrcweir 		{
373cdf0e10cSrcweir 			const OUString sEventType( RTL_CONSTASCII_USTRINGPARAM( "EventType" ) );
374cdf0e10cSrcweir 			const OUString sClickAction( RTL_CONSTASCII_USTRINGPARAM( "ClickAction" ) );
375cdf0e10cSrcweir 
376cdf0e10cSrcweir 			Reference< XNameReplace > xEvents( xEventsSupplier->getEvents(), UNO_QUERY_THROW );
377cdf0e10cSrcweir 
378cdf0e10cSrcweir 			uno::Sequence< beans::PropertyValue > aProperties( 3 );
379cdf0e10cSrcweir 			aProperties[0].Name = sEventType;
380cdf0e10cSrcweir 			aProperties[0].Handle = -1;
381cdf0e10cSrcweir 			aProperties[0].Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM("Presentation") );
382cdf0e10cSrcweir 			aProperties[0].State = beans::PropertyState_DIRECT_VALUE;
383cdf0e10cSrcweir 
384cdf0e10cSrcweir 			aProperties[1].Name = sClickAction;
385cdf0e10cSrcweir 			aProperties[1].Handle = -1;
386cdf0e10cSrcweir 			aProperties[1].Value <<= ::com::sun::star::presentation::ClickAction_DOCUMENT;
387cdf0e10cSrcweir 			aProperties[1].State = beans::PropertyState_DIRECT_VALUE;
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 			aProperties[2].Name = sBookmark;
390cdf0e10cSrcweir 			aProperties[2].Handle = -1;
391cdf0e10cSrcweir 			aProperties[2].Value <<= msHyperlink;
392cdf0e10cSrcweir 			aProperties[2].State = beans::PropertyState_DIRECT_VALUE;
393cdf0e10cSrcweir 
394cdf0e10cSrcweir 			const OUString sAPIEventName( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) );
395cdf0e10cSrcweir 			xEvents->replaceByName( sAPIEventName, Any( aProperties ) );
396cdf0e10cSrcweir 		}
397cdf0e10cSrcweir 		else
398cdf0e10cSrcweir 		{
399cdf0e10cSrcweir 			// in draw use the Bookmark property
400cdf0e10cSrcweir 			Reference< beans::XPropertySet > xSet( mxShape, UNO_QUERY_THROW );
401cdf0e10cSrcweir 			xSet->setPropertyValue( sBookmark, Any( msHyperlink ) );
402cdf0e10cSrcweir 			xSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) ), Any( ::com::sun::star::presentation::ClickAction_DOCUMENT ) );
403cdf0e10cSrcweir 		}
404cdf0e10cSrcweir 	}
405cdf0e10cSrcweir 	catch( Exception& )
406cdf0e10cSrcweir 	{
407cdf0e10cSrcweir 		DBG_ERROR("xmloff::SdXMLShapeContext::EndElement(), exception caught while setting hyperlink!");
408cdf0e10cSrcweir 	}
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 	if( mxLockable.is() )
411cdf0e10cSrcweir 		mxLockable->removeActionLock();
412cdf0e10cSrcweir }
413cdf0e10cSrcweir 
414cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
415cdf0e10cSrcweir 
416cdf0e10cSrcweir void SdXMLShapeContext::AddShape(uno::Reference< drawing::XShape >& xShape)
417cdf0e10cSrcweir {
418cdf0e10cSrcweir 	if(xShape.is())
419cdf0e10cSrcweir 	{
420cdf0e10cSrcweir 		// set shape local
421cdf0e10cSrcweir 		mxShape = xShape;
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 		if(maShapeName.getLength())
424cdf0e10cSrcweir 		{
425cdf0e10cSrcweir 			uno::Reference< container::XNamed > xNamed( mxShape, uno::UNO_QUERY );
426cdf0e10cSrcweir 			if( xNamed.is() )
427cdf0e10cSrcweir 				xNamed->setName( maShapeName );
428cdf0e10cSrcweir 		}
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 		UniReference< XMLShapeImportHelper > xImp( GetImport().GetShapeImport() );
431cdf0e10cSrcweir 		xImp->addShape( xShape, mxAttrList, mxShapes );
432cdf0e10cSrcweir 
433cdf0e10cSrcweir 		if( mbClearDefaultAttributes )
434cdf0e10cSrcweir 		{
435cdf0e10cSrcweir 	        uno::Reference<beans::XMultiPropertyStates> xMultiPropertyStates(xShape, uno::UNO_QUERY );
436cdf0e10cSrcweir 		    if (xMultiPropertyStates.is())
437cdf0e10cSrcweir 			    xMultiPropertyStates->setAllPropertiesToDefault();
438cdf0e10cSrcweir 		}
439cdf0e10cSrcweir 
440cdf0e10cSrcweir 		if( !mbVisible || !mbPrintable ) try
441cdf0e10cSrcweir 		{
442cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xSet( xShape, uno::UNO_QUERY_THROW );
443cdf0e10cSrcweir 			if( !mbVisible )
444cdf0e10cSrcweir 				xSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Visible" ) ), uno::Any( sal_False ) );
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 			if( !mbPrintable )
447cdf0e10cSrcweir 				xSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Printable" ) ), uno::Any( sal_False ) );
448cdf0e10cSrcweir 		}
449cdf0e10cSrcweir 		catch( Exception& )
450cdf0e10cSrcweir 		{
451cdf0e10cSrcweir 			DBG_ERROR( "SdXMLShapeContext::AddShape(), exception caught!" );
452cdf0e10cSrcweir 		}
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 		// #107848#
455cdf0e10cSrcweir 		if(!mbTemporaryShape && (!GetImport().HasTextImport()
456cdf0e10cSrcweir 			|| !GetImport().GetTextImport()->IsInsideDeleteContext()))
457cdf0e10cSrcweir 		{
458cdf0e10cSrcweir 			xImp->shapeWithZIndexAdded( xShape, mnZOrder );
459cdf0e10cSrcweir 		}
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 		if( maShapeId.getLength() )
462cdf0e10cSrcweir 		{
463598d8f9fSArmin Le Grand             const SdXMLGraphicObjectShapeContext* pGSC = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(this);
464598d8f9fSArmin Le Grand 
465598d8f9fSArmin Le Grand             /* avoid registering when LateRegister is needed. E.g. MultiImage support where in-between multiple
466598d8f9fSArmin Le Grand                xShapes with the same ID would be registered. Registration is done after deciding which image
467598d8f9fSArmin Le Grand                to keep, see calls to solveMultipleImages */
468598d8f9fSArmin Le Grand             if(!pGSC || !pGSC->getLateAddToIdentifierMapper())
469598d8f9fSArmin Le Grand             {
470cdf0e10cSrcweir                 uno::Reference< uno::XInterface > xRef( xShape, uno::UNO_QUERY );
471cdf0e10cSrcweir                 GetImport().getInterfaceToIdentifierMapper().registerReference( maShapeId, xRef );
472cdf0e10cSrcweir             }
473598d8f9fSArmin Le Grand 		}
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 		// #91065# count only if counting for shape import is enabled
476cdf0e10cSrcweir 		if(GetImport().GetShapeImport()->IsHandleProgressBarEnabled())
477cdf0e10cSrcweir 		{
478cdf0e10cSrcweir 			// #80365# increment progress bar at load once for each draw object
479cdf0e10cSrcweir 			GetImport().GetProgressBarHelper()->Increment();
480cdf0e10cSrcweir 		}
481cdf0e10cSrcweir 	}
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 	mxLockable = uno::Reference< document::XActionLockable >::query( xShape );
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 	if( mxLockable.is() )
486cdf0e10cSrcweir 		mxLockable->addActionLock();
487cdf0e10cSrcweir 
488cdf0e10cSrcweir }
489cdf0e10cSrcweir 
490cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
491cdf0e10cSrcweir 
492cdf0e10cSrcweir void SdXMLShapeContext::AddShape(const char* pServiceName )
493cdf0e10cSrcweir {
494cdf0e10cSrcweir 	uno::Reference< lang::XMultiServiceFactory > xServiceFact(GetImport().GetModel(), uno::UNO_QUERY);
495cdf0e10cSrcweir 	if(xServiceFact.is())
496cdf0e10cSrcweir 	{
497cdf0e10cSrcweir         try
498cdf0e10cSrcweir         {
499cdf0e10cSrcweir             // --> OD 2006-02-22 #b6382898#
500cdf0e10cSrcweir             // Since fix for issue i33294 the Writer model doesn't support
501cdf0e10cSrcweir             // com.sun.star.drawing.OLE2Shape anymore.
502cdf0e10cSrcweir             // To handle Draw OLE objects it's decided to import these
503cdf0e10cSrcweir             // objects as com.sun.star.drawing.OLE2Shape and convert these
504cdf0e10cSrcweir             // objects after the import into com.sun.star.drawing.GraphicObjectShape.
505cdf0e10cSrcweir             uno::Reference< drawing::XShape > xShape;
506cdf0e10cSrcweir             if ( OUString::createFromAscii(pServiceName).compareToAscii( "com.sun.star.drawing.OLE2Shape" ) == 0 &&
507cdf0e10cSrcweir                  uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() )
508cdf0e10cSrcweir             {
509cdf0e10cSrcweir                 xShape = uno::Reference< drawing::XShape >(xServiceFact->createInstance(OUString::createFromAscii("com.sun.star.drawing.temporaryForXMLImportOLE2Shape")), uno::UNO_QUERY);
510cdf0e10cSrcweir             }
511cdf0e10cSrcweir             else
512cdf0e10cSrcweir             {
513cdf0e10cSrcweir                 xShape = uno::Reference< drawing::XShape >(xServiceFact->createInstance(OUString::createFromAscii(pServiceName)), uno::UNO_QUERY);
514cdf0e10cSrcweir             }
515cdf0e10cSrcweir             // <--
516cdf0e10cSrcweir             if( xShape.is() )
517cdf0e10cSrcweir                 AddShape( xShape );
518cdf0e10cSrcweir         }
519cdf0e10cSrcweir         catch( const uno::Exception& e )
520cdf0e10cSrcweir         {
521cdf0e10cSrcweir             uno::Sequence<rtl::OUString> aSeq( 1 );
522cdf0e10cSrcweir             aSeq[0] = OUString::createFromAscii(pServiceName);
523cdf0e10cSrcweir             GetImport().SetError( XMLERROR_FLAG_ERROR | XMLERROR_API,
524cdf0e10cSrcweir                                   aSeq, e.Message, NULL );
525cdf0e10cSrcweir         }
526cdf0e10cSrcweir 	}
527cdf0e10cSrcweir }
528cdf0e10cSrcweir 
529cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
530cdf0e10cSrcweir 
531cdf0e10cSrcweir void SdXMLShapeContext::SetTransformation()
532cdf0e10cSrcweir {
533cdf0e10cSrcweir 	if(mxShape.is())
534cdf0e10cSrcweir 	{
535cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
536cdf0e10cSrcweir 		if(xPropSet.is())
537cdf0e10cSrcweir 		{
5386381da86SArmin Le Grand 			maUsedTransformation.identity();
539cdf0e10cSrcweir 
540cdf0e10cSrcweir 			if(maSize.Width != 1 || maSize.Height != 1)
541cdf0e10cSrcweir 			{
542cdf0e10cSrcweir 				// take care there are no zeros used by error
543cdf0e10cSrcweir 				if(0 == maSize.Width)
544cdf0e10cSrcweir 					maSize.Width = 1;
545cdf0e10cSrcweir 				if(0 == maSize.Height)
546cdf0e10cSrcweir 					maSize.Height = 1;
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 				// set global size. This should always be used.
5496381da86SArmin Le Grand 				maUsedTransformation.scale(maSize.Width, maSize.Height);
550cdf0e10cSrcweir 			}
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 			if(maPosition.X != 0 || maPosition.Y != 0)
553cdf0e10cSrcweir 			{
554cdf0e10cSrcweir 				// if global position is used, add it to transformation
5556381da86SArmin Le Grand 				maUsedTransformation.translate(maPosition.X, maPosition.Y);
556cdf0e10cSrcweir 			}
557cdf0e10cSrcweir 
558cdf0e10cSrcweir 			if(mnTransform.NeedsAction())
559cdf0e10cSrcweir 			{
560cdf0e10cSrcweir 				// transformation is used, apply to object.
561cdf0e10cSrcweir 				// NOTICE: The transformation is applied AFTER evtl. used
562cdf0e10cSrcweir 				// global positioning and scaling is used, so any shear or
563cdf0e10cSrcweir 				// rotate used herein is applied around the (0,0) position
564cdf0e10cSrcweir 				// of the PAGE object !!!
565cdf0e10cSrcweir 				::basegfx::B2DHomMatrix aMat;
566cdf0e10cSrcweir 				mnTransform.GetFullTransform(aMat);
567cdf0e10cSrcweir 
568cdf0e10cSrcweir 				// now add to transformation
5696381da86SArmin Le Grand 				maUsedTransformation *= aMat;
570cdf0e10cSrcweir 			}
571cdf0e10cSrcweir 
572cdf0e10cSrcweir 			// now set transformation for this object
573cdf0e10cSrcweir 			uno::Any aAny;
574cdf0e10cSrcweir 			drawing::HomogenMatrix3 aMatrix;
575cdf0e10cSrcweir 
5766381da86SArmin Le Grand 			aMatrix.Line1.Column1 = maUsedTransformation.get(0, 0);
5776381da86SArmin Le Grand 			aMatrix.Line1.Column2 = maUsedTransformation.get(0, 1);
5786381da86SArmin Le Grand 			aMatrix.Line1.Column3 = maUsedTransformation.get(0, 2);
579cdf0e10cSrcweir 
5806381da86SArmin Le Grand 			aMatrix.Line2.Column1 = maUsedTransformation.get(1, 0);
5816381da86SArmin Le Grand 			aMatrix.Line2.Column2 = maUsedTransformation.get(1, 1);
5826381da86SArmin Le Grand 			aMatrix.Line2.Column3 = maUsedTransformation.get(1, 2);
583cdf0e10cSrcweir 
5846381da86SArmin Le Grand 			aMatrix.Line3.Column1 = maUsedTransformation.get(2, 0);
5856381da86SArmin Le Grand 			aMatrix.Line3.Column2 = maUsedTransformation.get(2, 1);
5866381da86SArmin Le Grand 			aMatrix.Line3.Column3 = maUsedTransformation.get(2, 2);
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 			aAny <<= aMatrix;
589cdf0e10cSrcweir 
590cdf0e10cSrcweir 			xPropSet->setPropertyValue(
591cdf0e10cSrcweir 				OUString(RTL_CONSTASCII_USTRINGPARAM("Transformation")), aAny);
592cdf0e10cSrcweir         }
593cdf0e10cSrcweir 	}
594cdf0e10cSrcweir }
595cdf0e10cSrcweir 
596cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
597cdf0e10cSrcweir 
598cdf0e10cSrcweir void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */)
599cdf0e10cSrcweir {
600cdf0e10cSrcweir 	try
601cdf0e10cSrcweir 	{
602cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
603cdf0e10cSrcweir 		if( !xPropSet.is() )
604cdf0e10cSrcweir 			return;
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 		do
607cdf0e10cSrcweir 		{
608cdf0e10cSrcweir 			XMLPropStyleContext* pDocStyle = NULL;
609cdf0e10cSrcweir 
610cdf0e10cSrcweir 			// set style on shape
611cdf0e10cSrcweir 			if(maDrawStyleName.getLength() == 0)
612cdf0e10cSrcweir 				break;
613cdf0e10cSrcweir 
614cdf0e10cSrcweir 			const SvXMLStyleContext* pStyle = 0L;
615cdf0e10cSrcweir 			sal_Bool bAutoStyle(sal_False);
616cdf0e10cSrcweir 
617cdf0e10cSrcweir 			if(GetImport().GetShapeImport()->GetAutoStylesContext())
618cdf0e10cSrcweir 				pStyle = GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(mnStyleFamily, maDrawStyleName);
619cdf0e10cSrcweir 
620cdf0e10cSrcweir 			if(pStyle)
621cdf0e10cSrcweir 				bAutoStyle = sal_True;
622cdf0e10cSrcweir 
623cdf0e10cSrcweir 			if(!pStyle && GetImport().GetShapeImport()->GetStylesContext())
624cdf0e10cSrcweir 				pStyle = GetImport().GetShapeImport()->GetStylesContext()->FindStyleChildContext(mnStyleFamily, maDrawStyleName);
625cdf0e10cSrcweir 
626cdf0e10cSrcweir 			OUString aStyleName = maDrawStyleName;
627cdf0e10cSrcweir 			uno::Reference< style::XStyle > xStyle;
628cdf0e10cSrcweir 
629cdf0e10cSrcweir 			if( pStyle && pStyle->ISA(XMLShapeStyleContext) )
630cdf0e10cSrcweir 			{
631cdf0e10cSrcweir 				pDocStyle = PTR_CAST( XMLShapeStyleContext, pStyle );
632cdf0e10cSrcweir 
633cdf0e10cSrcweir 				if( pDocStyle->GetStyle().is() )
634cdf0e10cSrcweir 				{
635cdf0e10cSrcweir 					xStyle = pDocStyle->GetStyle();
636cdf0e10cSrcweir 				}
637cdf0e10cSrcweir 				else
638cdf0e10cSrcweir 				{
639cdf0e10cSrcweir                     aStyleName = pDocStyle->GetParentName();
640cdf0e10cSrcweir 				}
641cdf0e10cSrcweir 			}
642cdf0e10cSrcweir 
643cdf0e10cSrcweir 			if( !xStyle.is() && aStyleName.getLength() )
644cdf0e10cSrcweir 			{
645cdf0e10cSrcweir 				try
646cdf0e10cSrcweir 				{
647cdf0e10cSrcweir 
648cdf0e10cSrcweir 					uno::Reference< style::XStyleFamiliesSupplier > xFamiliesSupplier( GetImport().GetModel(), uno::UNO_QUERY );
649cdf0e10cSrcweir 
650cdf0e10cSrcweir 					if( xFamiliesSupplier.is() )
651cdf0e10cSrcweir 					{
652cdf0e10cSrcweir 						uno::Reference< container::XNameAccess > xFamilies( xFamiliesSupplier->getStyleFamilies() );
653cdf0e10cSrcweir 						if( xFamilies.is() )
654cdf0e10cSrcweir 						{
655cdf0e10cSrcweir 
656cdf0e10cSrcweir 							uno::Reference< container::XNameAccess > xFamily;
657cdf0e10cSrcweir 
658cdf0e10cSrcweir 							if( XML_STYLE_FAMILY_SD_PRESENTATION_ID == mnStyleFamily )
659cdf0e10cSrcweir 							{
660cdf0e10cSrcweir 								aStyleName = GetImport().GetStyleDisplayName(
661cdf0e10cSrcweir 									XML_STYLE_FAMILY_SD_PRESENTATION_ID,
662cdf0e10cSrcweir 									aStyleName );
663cdf0e10cSrcweir 								sal_Int32 nPos = aStyleName.lastIndexOf( sal_Unicode('-') );
664cdf0e10cSrcweir 								if( -1 != nPos )
665cdf0e10cSrcweir 								{
666cdf0e10cSrcweir 									OUString aFamily( aStyleName.copy( 0, nPos ) );
667cdf0e10cSrcweir 
668cdf0e10cSrcweir 									xFamilies->getByName( aFamily ) >>= xFamily;
669cdf0e10cSrcweir 									aStyleName = aStyleName.copy( nPos + 1 );
670cdf0e10cSrcweir 								}
671cdf0e10cSrcweir 							}
672cdf0e10cSrcweir 							else
673cdf0e10cSrcweir 							{
674cdf0e10cSrcweir 								// get graphics familie
675cdf0e10cSrcweir 								xFamilies->getByName( OUString( RTL_CONSTASCII_USTRINGPARAM( "graphics" ) ) ) >>= xFamily;
676cdf0e10cSrcweir 								aStyleName = GetImport().GetStyleDisplayName(
677cdf0e10cSrcweir 									XML_STYLE_FAMILY_SD_GRAPHICS_ID,
678cdf0e10cSrcweir 									aStyleName );
679cdf0e10cSrcweir 							}
680cdf0e10cSrcweir 
681cdf0e10cSrcweir 							if( xFamily.is() )
682cdf0e10cSrcweir 								xFamily->getByName( aStyleName ) >>= xStyle;
683cdf0e10cSrcweir 						}
684cdf0e10cSrcweir 					}
685cdf0e10cSrcweir 				}
686cdf0e10cSrcweir 				catch( uno::Exception& )
687cdf0e10cSrcweir 				{
688cdf0e10cSrcweir 					DBG_ERROR( "could not find style for shape!" );
689cdf0e10cSrcweir 				}
690cdf0e10cSrcweir 			}
691cdf0e10cSrcweir 
692cdf0e10cSrcweir 			if( bSupportsStyle && xStyle.is() )
693cdf0e10cSrcweir 			{
694cdf0e10cSrcweir 				try
695cdf0e10cSrcweir 				{
696cdf0e10cSrcweir 					// set style on object
697cdf0e10cSrcweir 					uno::Any aAny;
698cdf0e10cSrcweir 					aAny <<= xStyle;
699cdf0e10cSrcweir 					xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Style")), aAny);
700cdf0e10cSrcweir 				}
701cdf0e10cSrcweir 				catch( uno::Exception& )
702cdf0e10cSrcweir 				{
703cdf0e10cSrcweir 					DBG_ERROR( "could not find style for shape!" );
704cdf0e10cSrcweir 				}
705cdf0e10cSrcweir 			}
706cdf0e10cSrcweir 
707cdf0e10cSrcweir 			// if this is an auto style, set its properties
708cdf0e10cSrcweir 			if(bAutoStyle && pDocStyle)
709cdf0e10cSrcweir 			{
710cdf0e10cSrcweir 				// set PropertySet on object
711cdf0e10cSrcweir 				pDocStyle->FillPropertySet(xPropSet);
712cdf0e10cSrcweir 			}
713cdf0e10cSrcweir 
714cdf0e10cSrcweir 		} while(0);
715cdf0e10cSrcweir 
716cdf0e10cSrcweir 		// try to set text auto style
717cdf0e10cSrcweir 		do
718cdf0e10cSrcweir 		{
719cdf0e10cSrcweir 			// set style on shape
720cdf0e10cSrcweir 			if( 0 == maTextStyleName.getLength() )
721cdf0e10cSrcweir 				break;
722cdf0e10cSrcweir 
723cdf0e10cSrcweir 			if( NULL == GetImport().GetShapeImport()->GetAutoStylesContext())
724cdf0e10cSrcweir 				break;
725cdf0e10cSrcweir 
726cdf0e10cSrcweir             const SvXMLStyleContext* pTempStyle = GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(XML_STYLE_FAMILY_TEXT_PARAGRAPH, maTextStyleName);
727cdf0e10cSrcweir 			XMLPropStyleContext* pStyle = PTR_CAST( XMLPropStyleContext, pTempStyle ); // use temp var, PTR_CAST is a bad macro, FindStyleChildContext will be called twice
728cdf0e10cSrcweir 			if( pStyle == NULL )
729cdf0e10cSrcweir 				break;
730cdf0e10cSrcweir 
731cdf0e10cSrcweir 			// set PropertySet on object
732cdf0e10cSrcweir 			pStyle->FillPropertySet(xPropSet);
733cdf0e10cSrcweir 
734cdf0e10cSrcweir 		} while(0);
735cdf0e10cSrcweir 	}
736cdf0e10cSrcweir 	catch( uno::Exception& )
737cdf0e10cSrcweir 	{
738cdf0e10cSrcweir 	}
739cdf0e10cSrcweir }
740cdf0e10cSrcweir 
741cdf0e10cSrcweir void SdXMLShapeContext::SetLayer()
742cdf0e10cSrcweir {
743cdf0e10cSrcweir 	if( maLayerName.getLength() )
744cdf0e10cSrcweir 	{
745cdf0e10cSrcweir 		try
746cdf0e10cSrcweir 		{
747cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
748cdf0e10cSrcweir 			if(xPropSet.is() )
749cdf0e10cSrcweir 			{
750cdf0e10cSrcweir 				uno::Any aAny;
751cdf0e10cSrcweir 				aAny <<= maLayerName;
752cdf0e10cSrcweir 
753cdf0e10cSrcweir 				xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("LayerName")), aAny);
754cdf0e10cSrcweir 				return;
755cdf0e10cSrcweir 			}
756cdf0e10cSrcweir 		}
757cdf0e10cSrcweir 		catch( uno::Exception e )
758cdf0e10cSrcweir 		{
759cdf0e10cSrcweir 		}
760cdf0e10cSrcweir 	}
761cdf0e10cSrcweir }
762cdf0e10cSrcweir 
763cdf0e10cSrcweir void SdXMLShapeContext::SetThumbnail()
764cdf0e10cSrcweir {
765cdf0e10cSrcweir 	if( 0 == maThumbnailURL.getLength() )
766cdf0e10cSrcweir 		return;
767cdf0e10cSrcweir 
768cdf0e10cSrcweir 	try
769cdf0e10cSrcweir 	{
770cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
771cdf0e10cSrcweir 		if( !xPropSet.is() )
772cdf0e10cSrcweir 			return;
773cdf0e10cSrcweir 
774cdf0e10cSrcweir 		const OUString sProperty(RTL_CONSTASCII_USTRINGPARAM("ThumbnailGraphicURL"));
775cdf0e10cSrcweir 
776cdf0e10cSrcweir 		uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
777cdf0e10cSrcweir 		if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName( sProperty ) )
778cdf0e10cSrcweir 		{
779cdf0e10cSrcweir 			// load the thumbnail graphic and export it to a wmf stream so we can set
780cdf0e10cSrcweir 			// it at the api
781cdf0e10cSrcweir 
782cdf0e10cSrcweir 			const OUString aInternalURL( GetImport().ResolveGraphicObjectURL( maThumbnailURL, sal_False ) );
783cdf0e10cSrcweir 			xPropSet->setPropertyValue( sProperty, uno::makeAny( aInternalURL ) );
784cdf0e10cSrcweir 		}
785cdf0e10cSrcweir 	}
786cdf0e10cSrcweir 	catch( uno::Exception e )
787cdf0e10cSrcweir 	{
788cdf0e10cSrcweir 	}
789cdf0e10cSrcweir }
790cdf0e10cSrcweir 
791cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
792cdf0e10cSrcweir void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
793cdf0e10cSrcweir {
794cdf0e10cSrcweir     bool bHaveXmlId( false );
795cdf0e10cSrcweir 	if( (XML_NAMESPACE_DRAW == nPrefix) || (XML_NAMESPACE_DRAW_EXT == nPrefix) )
796cdf0e10cSrcweir 	{
797cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_ZINDEX ) )
798cdf0e10cSrcweir 		{
799cdf0e10cSrcweir 			mnZOrder = rValue.toInt32();
800cdf0e10cSrcweir 		}
801cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_ID ) )
802cdf0e10cSrcweir         {
803cdf0e10cSrcweir             if (!bHaveXmlId) { maShapeId = rValue; };
804cdf0e10cSrcweir         }
805cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_NAME ) )
806cdf0e10cSrcweir 		{
807cdf0e10cSrcweir 			maShapeName = rValue;
808cdf0e10cSrcweir 		}
809cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_STYLE_NAME ) )
810cdf0e10cSrcweir 		{
811cdf0e10cSrcweir 			maDrawStyleName = rValue;
812cdf0e10cSrcweir 		}
813cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_TEXT_STYLE_NAME ) )
814cdf0e10cSrcweir 		{
815cdf0e10cSrcweir 			maTextStyleName = rValue;
816cdf0e10cSrcweir 		}
817cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_LAYER ) )
818cdf0e10cSrcweir 		{
819cdf0e10cSrcweir 			maLayerName = rValue;
820cdf0e10cSrcweir 		}
821cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_TRANSFORM ) )
822cdf0e10cSrcweir 		{
823cdf0e10cSrcweir 			mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter());
824cdf0e10cSrcweir 		}
825cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_DISPLAY ) )
826cdf0e10cSrcweir 		{
827cdf0e10cSrcweir 			mbVisible = IsXMLToken( rValue, XML_ALWAYS ) || IsXMLToken( rValue, XML_SCREEN );
828cdf0e10cSrcweir 			mbPrintable = IsXMLToken( rValue, XML_ALWAYS ) || IsXMLToken( rValue, XML_PRINTER );
829cdf0e10cSrcweir 		}
830cdf0e10cSrcweir 	}
831cdf0e10cSrcweir 	else if( XML_NAMESPACE_PRESENTATION == nPrefix )
832cdf0e10cSrcweir 	{
833cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_USER_TRANSFORMED ) )
834cdf0e10cSrcweir 		{
835cdf0e10cSrcweir 			mbIsUserTransformed = IsXMLToken( rValue, XML_TRUE );
836cdf0e10cSrcweir 		}
837cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_PLACEHOLDER ) )
838cdf0e10cSrcweir 		{
839cdf0e10cSrcweir 			mbIsPlaceholder = IsXMLToken( rValue, XML_TRUE );
840cdf0e10cSrcweir 			if( mbIsPlaceholder )
841cdf0e10cSrcweir 				mbClearDefaultAttributes = false;
842cdf0e10cSrcweir 		}
843cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_CLASS ) )
844cdf0e10cSrcweir 		{
845cdf0e10cSrcweir 			maPresentationClass = rValue;
846cdf0e10cSrcweir 		}
847cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_STYLE_NAME ) )
848cdf0e10cSrcweir 		{
849cdf0e10cSrcweir 			maDrawStyleName = rValue;
850cdf0e10cSrcweir 			mnStyleFamily = XML_STYLE_FAMILY_SD_PRESENTATION_ID;
851cdf0e10cSrcweir 		}
852cdf0e10cSrcweir 	}
853cdf0e10cSrcweir 	else if( XML_NAMESPACE_SVG == nPrefix )
854cdf0e10cSrcweir 	{
855cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_X ) )
856cdf0e10cSrcweir 		{
857cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(maPosition.X, rValue);
858cdf0e10cSrcweir 		}
859cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_Y ) )
860cdf0e10cSrcweir 		{
861cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(maPosition.Y, rValue);
862cdf0e10cSrcweir 		}
863cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_WIDTH ) )
864cdf0e10cSrcweir 		{
865cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(maSize.Width, rValue);
866cdf0e10cSrcweir 			if( maSize.Width > 0 )
867cdf0e10cSrcweir 				maSize.Width += 1;
868cdf0e10cSrcweir 			else if( maSize.Width < 0 )
869cdf0e10cSrcweir 				maSize.Width -= 1;
870cdf0e10cSrcweir 		}
871cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_HEIGHT ) )
872cdf0e10cSrcweir 		{
873cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(maSize.Height, rValue);
874cdf0e10cSrcweir 			if( maSize.Height > 0 )
875cdf0e10cSrcweir 				maSize.Height += 1;
876cdf0e10cSrcweir 			else if( maSize.Height < 0 )
877cdf0e10cSrcweir 				maSize.Height -= 1;
878cdf0e10cSrcweir 		}
879cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_TRANSFORM ) )
880cdf0e10cSrcweir 		{
881cdf0e10cSrcweir 			// because of #85127# take svg:transform into account and hanle like
882cdf0e10cSrcweir 			// draw:transform for compatibility
883cdf0e10cSrcweir 			mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter());
884cdf0e10cSrcweir 		}
885cdf0e10cSrcweir 
886cdf0e10cSrcweir 		// #i68101#
887cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_TITLE ) )
888cdf0e10cSrcweir 		{
889cdf0e10cSrcweir 			maShapeTitle = rValue;
890cdf0e10cSrcweir 		}
891cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_DESC ) )
892cdf0e10cSrcweir 		{
893cdf0e10cSrcweir 			maShapeDescription = rValue;
894cdf0e10cSrcweir 		}
895cdf0e10cSrcweir 	}
896cdf0e10cSrcweir 	else if( (XML_NAMESPACE_NONE == nPrefix) || (XML_NAMESPACE_XML == nPrefix) )
897cdf0e10cSrcweir 	{
898cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_ID ) )
899cdf0e10cSrcweir 		{
900cdf0e10cSrcweir 			maShapeId = rValue;
901cdf0e10cSrcweir             bHaveXmlId = true;
902cdf0e10cSrcweir         }
903cdf0e10cSrcweir     }
904cdf0e10cSrcweir }
905cdf0e10cSrcweir 
906cdf0e10cSrcweir sal_Bool SdXMLShapeContext::isPresentationShape() const
907cdf0e10cSrcweir {
908cdf0e10cSrcweir 	if( maPresentationClass.getLength() && (const_cast<SdXMLShapeContext*>(this))->GetImport().GetShapeImport()->IsPresentationShapesSupported() )
909cdf0e10cSrcweir 	{
910cdf0e10cSrcweir 		if(XML_STYLE_FAMILY_SD_PRESENTATION_ID == mnStyleFamily)
911cdf0e10cSrcweir 		{
912cdf0e10cSrcweir 			return sal_True;
913cdf0e10cSrcweir 		}
914cdf0e10cSrcweir 
915cdf0e10cSrcweir 		if( IsXMLToken( maPresentationClass, XML_HEADER ) || IsXMLToken( maPresentationClass, XML_FOOTER ) ||
916cdf0e10cSrcweir 			IsXMLToken( maPresentationClass, XML_PAGE_NUMBER ) || IsXMLToken( maPresentationClass, XML_DATE_TIME ) )
917cdf0e10cSrcweir 		{
918cdf0e10cSrcweir 			return sal_True;
919cdf0e10cSrcweir 		}
920cdf0e10cSrcweir 	}
921cdf0e10cSrcweir 
922cdf0e10cSrcweir 	return sal_False;
923cdf0e10cSrcweir }
924cdf0e10cSrcweir 
925cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
926cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
927cdf0e10cSrcweir 
928cdf0e10cSrcweir TYPEINIT1( SdXMLRectShapeContext, SdXMLShapeContext );
929cdf0e10cSrcweir 
930cdf0e10cSrcweir SdXMLRectShapeContext::SdXMLRectShapeContext(
931cdf0e10cSrcweir 	SvXMLImport& rImport,
932cdf0e10cSrcweir 	sal_uInt16 nPrfx,
933cdf0e10cSrcweir 	const OUString& rLocalName,
934cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
935cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
936cdf0e10cSrcweir     sal_Bool bTemporaryShape)
937cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
938cdf0e10cSrcweir 	mnRadius( 0L )
939cdf0e10cSrcweir {
940cdf0e10cSrcweir }
941cdf0e10cSrcweir 
942cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
943cdf0e10cSrcweir 
944cdf0e10cSrcweir SdXMLRectShapeContext::~SdXMLRectShapeContext()
945cdf0e10cSrcweir {
946cdf0e10cSrcweir }
947cdf0e10cSrcweir 
948cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
949cdf0e10cSrcweir 
950cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
951cdf0e10cSrcweir void SdXMLRectShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
952cdf0e10cSrcweir {
953cdf0e10cSrcweir 	if( XML_NAMESPACE_DRAW == nPrefix )
954cdf0e10cSrcweir 	{
955cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) )
956cdf0e10cSrcweir 		{
957cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(mnRadius, rValue);
958cdf0e10cSrcweir 			return;
959cdf0e10cSrcweir 		}
960cdf0e10cSrcweir 	}
961cdf0e10cSrcweir 
962cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
963cdf0e10cSrcweir }
964cdf0e10cSrcweir 
965cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
966cdf0e10cSrcweir 
967cdf0e10cSrcweir void SdXMLRectShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
968cdf0e10cSrcweir {
969cdf0e10cSrcweir 	// create rectangle shape
970cdf0e10cSrcweir 	AddShape("com.sun.star.drawing.RectangleShape");
971cdf0e10cSrcweir 	if(mxShape.is())
972cdf0e10cSrcweir 	{
973cdf0e10cSrcweir 		// Add, set Style and properties from base shape
974cdf0e10cSrcweir 		SetStyle();
975cdf0e10cSrcweir 		SetLayer();
976cdf0e10cSrcweir 
977cdf0e10cSrcweir 		// set pos, size, shear and rotate
978cdf0e10cSrcweir 		SetTransformation();
979cdf0e10cSrcweir 
980cdf0e10cSrcweir 		if(mnRadius)
981cdf0e10cSrcweir 		{
982cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
983cdf0e10cSrcweir 			if(xPropSet.is())
984cdf0e10cSrcweir 			{
985cdf0e10cSrcweir 				try
986cdf0e10cSrcweir 				{
987cdf0e10cSrcweir 					xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius")), uno::makeAny( mnRadius ) );
988cdf0e10cSrcweir 				}
989cdf0e10cSrcweir 				catch( uno::Exception& )
990cdf0e10cSrcweir 				{
991cdf0e10cSrcweir 					DBG_ERROR( "exception during setting of corner radius!");
992cdf0e10cSrcweir 				}
993cdf0e10cSrcweir 			}
994cdf0e10cSrcweir 		}
995cdf0e10cSrcweir 		SdXMLShapeContext::StartElement(xAttrList);
996cdf0e10cSrcweir 	}
997cdf0e10cSrcweir }
998cdf0e10cSrcweir 
999cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1000cdf0e10cSrcweir ////////////////////////////////////////3////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir TYPEINIT1( SdXMLLineShapeContext, SdXMLShapeContext );
1003cdf0e10cSrcweir 
1004cdf0e10cSrcweir SdXMLLineShapeContext::SdXMLLineShapeContext(
1005cdf0e10cSrcweir 	SvXMLImport& rImport,
1006cdf0e10cSrcweir 	sal_uInt16 nPrfx,
1007cdf0e10cSrcweir 	const OUString& rLocalName,
1008cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1009cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
1010cdf0e10cSrcweir     sal_Bool bTemporaryShape)
1011cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1012cdf0e10cSrcweir 	mnX1( 0L ),
1013cdf0e10cSrcweir 	mnY1( 0L ),
1014cdf0e10cSrcweir 	mnX2( 1L ),
1015cdf0e10cSrcweir 	mnY2( 1L )
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir }
1018cdf0e10cSrcweir 
1019cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir SdXMLLineShapeContext::~SdXMLLineShapeContext()
1022cdf0e10cSrcweir {
1023cdf0e10cSrcweir }
1024cdf0e10cSrcweir 
1025cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1026cdf0e10cSrcweir 
1027cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
1028cdf0e10cSrcweir void SdXMLLineShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
1029cdf0e10cSrcweir {
1030cdf0e10cSrcweir 	if( XML_NAMESPACE_SVG == nPrefix )
1031cdf0e10cSrcweir 	{
1032cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_X1 ) )
1033cdf0e10cSrcweir 		{
1034cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(mnX1, rValue);
1035cdf0e10cSrcweir 			return;
1036cdf0e10cSrcweir 		}
1037cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_Y1 ) )
1038cdf0e10cSrcweir 		{
1039cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(mnY1, rValue);
1040cdf0e10cSrcweir 			return;
1041cdf0e10cSrcweir 		}
1042cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_X2 ) )
1043cdf0e10cSrcweir 		{
1044cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(mnX2, rValue);
1045cdf0e10cSrcweir 			return;
1046cdf0e10cSrcweir 		}
1047cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_Y2 ) )
1048cdf0e10cSrcweir 		{
1049cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(mnY2, rValue);
1050cdf0e10cSrcweir 			return;
1051cdf0e10cSrcweir 		}
1052cdf0e10cSrcweir 	}
1053cdf0e10cSrcweir 
1054cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1058cdf0e10cSrcweir 
1059cdf0e10cSrcweir void SdXMLLineShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1060cdf0e10cSrcweir {
1061cdf0e10cSrcweir 	// #85920# use SetTransformation() to handle import of simple lines.
1062cdf0e10cSrcweir 	// This is necessary to kake into account all anchor positions and
1063cdf0e10cSrcweir 	// other things. All shape imports use the same import schemata now.
1064cdf0e10cSrcweir 	// create necessary shape (Line Shape)
1065cdf0e10cSrcweir 	AddShape("com.sun.star.drawing.PolyLineShape");
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir 	if(mxShape.is())
1068cdf0e10cSrcweir 	{
1069cdf0e10cSrcweir 		// Add, set Style and properties from base shape
1070cdf0e10cSrcweir 		SetStyle();
1071cdf0e10cSrcweir 		SetLayer();
1072cdf0e10cSrcweir 
1073cdf0e10cSrcweir 		// get sizes and offsets
1074cdf0e10cSrcweir 		awt::Point aTopLeft(mnX1, mnY1);
1075cdf0e10cSrcweir 		awt::Point aBottomRight(mnX2, mnY2);
1076cdf0e10cSrcweir 
1077cdf0e10cSrcweir 		if(mnX1 > mnX2)
1078cdf0e10cSrcweir 		{
1079cdf0e10cSrcweir 			aTopLeft.X = mnX2;
1080cdf0e10cSrcweir 			aBottomRight.X = mnX1;
1081cdf0e10cSrcweir 		}
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir 		if(mnY1 > mnY2)
1084cdf0e10cSrcweir 		{
1085cdf0e10cSrcweir 			aTopLeft.Y = mnY2;
1086cdf0e10cSrcweir 			aBottomRight.Y = mnY1;
1087cdf0e10cSrcweir 		}
1088cdf0e10cSrcweir 
1089cdf0e10cSrcweir 		// set local parameters on shape
1090cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1091cdf0e10cSrcweir 		if(xPropSet.is())
1092cdf0e10cSrcweir 		{
1093cdf0e10cSrcweir 			drawing::PointSequenceSequence aPolyPoly(1L);
1094cdf0e10cSrcweir 			drawing::PointSequence* pOuterSequence = aPolyPoly.getArray();
1095cdf0e10cSrcweir 			pOuterSequence->realloc(2L);
1096cdf0e10cSrcweir 			awt::Point* pInnerSequence = pOuterSequence->getArray();
1097cdf0e10cSrcweir 			uno::Any aAny;
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir 			*pInnerSequence = awt::Point( mnX1 - aTopLeft.X, mnY1 - aTopLeft.Y);
1100cdf0e10cSrcweir 			pInnerSequence++;
1101cdf0e10cSrcweir 			*pInnerSequence = awt::Point( mnX2 - aTopLeft.X, mnY2 - aTopLeft.Y);
1102cdf0e10cSrcweir 
1103cdf0e10cSrcweir 			aAny <<= aPolyPoly;
1104cdf0e10cSrcweir 			xPropSet->setPropertyValue(
1105cdf0e10cSrcweir 				OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny);
1106cdf0e10cSrcweir 		}
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir 		// set sizes for transformation
1109cdf0e10cSrcweir 		maSize.Width = aBottomRight.X - aTopLeft.X;
1110cdf0e10cSrcweir 		maSize.Height = aBottomRight.Y - aTopLeft.Y;
1111cdf0e10cSrcweir 		maPosition.X = aTopLeft.X;
1112cdf0e10cSrcweir 		maPosition.Y = aTopLeft.Y;
1113cdf0e10cSrcweir 
1114cdf0e10cSrcweir 		// set pos, size, shear and rotate and get copy of matrix
1115cdf0e10cSrcweir 		SetTransformation();
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir 		SdXMLShapeContext::StartElement(xAttrList);
1118cdf0e10cSrcweir 	}
1119cdf0e10cSrcweir }
1120cdf0e10cSrcweir 
1121cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1122cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1123cdf0e10cSrcweir 
1124cdf0e10cSrcweir TYPEINIT1( SdXMLEllipseShapeContext, SdXMLShapeContext );
1125cdf0e10cSrcweir 
1126cdf0e10cSrcweir SdXMLEllipseShapeContext::SdXMLEllipseShapeContext(
1127cdf0e10cSrcweir 	SvXMLImport& rImport,
1128cdf0e10cSrcweir 	sal_uInt16 nPrfx,
1129cdf0e10cSrcweir 	const OUString& rLocalName,
1130cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1131cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
1132cdf0e10cSrcweir     sal_Bool bTemporaryShape)
1133cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1134cdf0e10cSrcweir 	mnCX( 0L ),
1135cdf0e10cSrcweir 	mnCY( 0L ),
1136cdf0e10cSrcweir 	mnRX( 1L ),
1137cdf0e10cSrcweir 	mnRY( 1L ),
1138cdf0e10cSrcweir 	meKind( drawing::CircleKind_FULL ),
1139cdf0e10cSrcweir 	mnStartAngle( 0 ),
1140cdf0e10cSrcweir 	mnEndAngle( 0 )
1141cdf0e10cSrcweir {
1142cdf0e10cSrcweir }
1143cdf0e10cSrcweir 
1144cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1145cdf0e10cSrcweir 
1146cdf0e10cSrcweir SdXMLEllipseShapeContext::~SdXMLEllipseShapeContext()
1147cdf0e10cSrcweir {
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
1153cdf0e10cSrcweir void SdXMLEllipseShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
1154cdf0e10cSrcweir {
1155cdf0e10cSrcweir 	if( XML_NAMESPACE_SVG == nPrefix )
1156cdf0e10cSrcweir 	{
1157cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_RX ) )
1158cdf0e10cSrcweir 		{
1159cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(mnRX, rValue);
1160cdf0e10cSrcweir 			return;
1161cdf0e10cSrcweir 		}
1162cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_RY ) )
1163cdf0e10cSrcweir 		{
1164cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(mnRY, rValue);
1165cdf0e10cSrcweir 			return;
1166cdf0e10cSrcweir 		}
1167cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_CX ) )
1168cdf0e10cSrcweir 		{
1169cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(mnCX, rValue);
1170cdf0e10cSrcweir 			return;
1171cdf0e10cSrcweir 		}
1172cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_CY ) )
1173cdf0e10cSrcweir 		{
1174cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(mnCY, rValue);
1175cdf0e10cSrcweir 			return;
1176cdf0e10cSrcweir 		}
1177cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_R ) )
1178cdf0e10cSrcweir 		{
1179cdf0e10cSrcweir 			// single radius, it's a circle and both radii are the same
1180cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(mnRX, rValue);
1181cdf0e10cSrcweir 			mnRY = mnRX;
1182cdf0e10cSrcweir 			return;
1183cdf0e10cSrcweir 		}
1184cdf0e10cSrcweir 	}
1185cdf0e10cSrcweir 	else if( XML_NAMESPACE_DRAW == nPrefix )
1186cdf0e10cSrcweir 	{
1187cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_KIND ) )
1188cdf0e10cSrcweir 		{
1189cdf0e10cSrcweir 			sal_uInt16 eKind;
1190cdf0e10cSrcweir 			if( SvXMLUnitConverter::convertEnum( eKind, rValue, aXML_CircleKind_EnumMap ) )
1191cdf0e10cSrcweir 			{
1192cdf0e10cSrcweir 				meKind = eKind;
1193cdf0e10cSrcweir 			}
1194cdf0e10cSrcweir 			return;
1195cdf0e10cSrcweir 		}
1196cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_START_ANGLE ) )
1197cdf0e10cSrcweir 		{
1198cdf0e10cSrcweir 			double dStartAngle;
1199cdf0e10cSrcweir 			if( SvXMLUnitConverter::convertDouble( dStartAngle, rValue ) )
1200cdf0e10cSrcweir 				mnStartAngle = (sal_Int32)(dStartAngle * 100.0);
1201cdf0e10cSrcweir 			return;
1202cdf0e10cSrcweir 		}
1203cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_END_ANGLE ) )
1204cdf0e10cSrcweir 		{
1205cdf0e10cSrcweir 			double dEndAngle;
1206cdf0e10cSrcweir 			if( SvXMLUnitConverter::convertDouble( dEndAngle, rValue ) )
1207cdf0e10cSrcweir 				mnEndAngle = (sal_Int32)(dEndAngle * 100.0);
1208cdf0e10cSrcweir 			return;
1209cdf0e10cSrcweir 		}
1210cdf0e10cSrcweir 	}
1211cdf0e10cSrcweir 
1212cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1213cdf0e10cSrcweir }
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1216cdf0e10cSrcweir 
1217cdf0e10cSrcweir void SdXMLEllipseShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1218cdf0e10cSrcweir {
1219cdf0e10cSrcweir 	// create rectangle shape
1220cdf0e10cSrcweir 	AddShape("com.sun.star.drawing.EllipseShape");
1221cdf0e10cSrcweir 	if(mxShape.is())
1222cdf0e10cSrcweir 	{
1223cdf0e10cSrcweir 		// Add, set Style and properties from base shape
1224cdf0e10cSrcweir 		SetStyle();
1225cdf0e10cSrcweir 		SetLayer();
1226cdf0e10cSrcweir 
1227*32902674SArmin Le Grand         if(mnCX != 0 || mnCY != 0 || mnRX != 1 || mnRY != 1)
1228*32902674SArmin Le Grand         {
1229*32902674SArmin Le Grand             // #121972# center/radius is used, put to pos and size
1230*32902674SArmin Le Grand             maSize.Width = 2 * mnRX;
1231*32902674SArmin Le Grand             maSize.Height = 2 * mnRY;
1232*32902674SArmin Le Grand             maPosition.X = mnCX - mnRX;
1233*32902674SArmin Le Grand             maPosition.Y = mnCY - mnRY;
1234*32902674SArmin Le Grand         }
1235*32902674SArmin Le Grand 
1236cdf0e10cSrcweir 		// set pos, size, shear and rotate
1237cdf0e10cSrcweir 		SetTransformation();
1238cdf0e10cSrcweir 
1239cdf0e10cSrcweir 		if( meKind != drawing::CircleKind_FULL )
1240cdf0e10cSrcweir 		{
1241cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
1242cdf0e10cSrcweir 			if( xPropSet.is() )
1243cdf0e10cSrcweir 			{
1244cdf0e10cSrcweir 				uno::Any aAny;
1245cdf0e10cSrcweir 				aAny <<= (drawing::CircleKind)meKind;
1246cdf0e10cSrcweir 				xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleKind")), aAny );
1247cdf0e10cSrcweir 
1248cdf0e10cSrcweir 				aAny <<= mnStartAngle;
1249cdf0e10cSrcweir 				xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleStartAngle")), aAny );
1250cdf0e10cSrcweir 
1251cdf0e10cSrcweir 				aAny <<= mnEndAngle;
1252cdf0e10cSrcweir 				xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleEndAngle")), aAny );
1253cdf0e10cSrcweir 			}
1254cdf0e10cSrcweir 		}
1255cdf0e10cSrcweir 
1256cdf0e10cSrcweir 		SdXMLShapeContext::StartElement(xAttrList);
1257cdf0e10cSrcweir 	}
1258cdf0e10cSrcweir }
1259cdf0e10cSrcweir 
1260cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1261cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1262cdf0e10cSrcweir 
1263cdf0e10cSrcweir TYPEINIT1( SdXMLPolygonShapeContext, SdXMLShapeContext );
1264cdf0e10cSrcweir 
1265cdf0e10cSrcweir SdXMLPolygonShapeContext::SdXMLPolygonShapeContext(
1266cdf0e10cSrcweir 	SvXMLImport& rImport,
1267cdf0e10cSrcweir 	sal_uInt16 nPrfx,
1268cdf0e10cSrcweir 	const OUString& rLocalName,
1269cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1270cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes, sal_Bool bClosed, sal_Bool bTemporaryShape)
1271cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1272cdf0e10cSrcweir 	mbClosed( bClosed )
1273cdf0e10cSrcweir {
1274cdf0e10cSrcweir }
1275cdf0e10cSrcweir 
1276cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1277cdf0e10cSrcweir 
1278cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
1279cdf0e10cSrcweir void SdXMLPolygonShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
1280cdf0e10cSrcweir {
1281cdf0e10cSrcweir 	if( XML_NAMESPACE_SVG == nPrefix )
1282cdf0e10cSrcweir 	{
1283cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_VIEWBOX ) )
1284cdf0e10cSrcweir 		{
1285cdf0e10cSrcweir 			maViewBox = rValue;
1286cdf0e10cSrcweir 			return;
1287cdf0e10cSrcweir 		}
1288cdf0e10cSrcweir 	}
1289cdf0e10cSrcweir 	else if( XML_NAMESPACE_DRAW == nPrefix )
1290cdf0e10cSrcweir 	{
1291cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_POINTS ) )
1292cdf0e10cSrcweir 		{
1293cdf0e10cSrcweir 			maPoints = rValue;
1294cdf0e10cSrcweir 			return;
1295cdf0e10cSrcweir 		}
1296cdf0e10cSrcweir 	}
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1299cdf0e10cSrcweir }
1300cdf0e10cSrcweir 
1301cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1302cdf0e10cSrcweir 
1303cdf0e10cSrcweir SdXMLPolygonShapeContext::~SdXMLPolygonShapeContext()
1304cdf0e10cSrcweir {
1305cdf0e10cSrcweir }
1306cdf0e10cSrcweir 
1307cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir void SdXMLPolygonShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1310cdf0e10cSrcweir {
1311cdf0e10cSrcweir 	// Add, set Style and properties from base shape
1312cdf0e10cSrcweir 	if(mbClosed)
1313cdf0e10cSrcweir 		AddShape("com.sun.star.drawing.PolyPolygonShape");
1314cdf0e10cSrcweir 	else
1315cdf0e10cSrcweir 		AddShape("com.sun.star.drawing.PolyLineShape");
1316cdf0e10cSrcweir 
1317cdf0e10cSrcweir 	if( mxShape.is() )
1318cdf0e10cSrcweir 	{
1319cdf0e10cSrcweir 		SetStyle();
1320cdf0e10cSrcweir 		SetLayer();
1321cdf0e10cSrcweir 
1322cdf0e10cSrcweir 		// set local parameters on shape
1323cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1324cdf0e10cSrcweir 		if(xPropSet.is())
1325cdf0e10cSrcweir 		{
1326cdf0e10cSrcweir 			// set polygon
1327cdf0e10cSrcweir 			if(maPoints.getLength() && maViewBox.getLength())
1328cdf0e10cSrcweir 			{
1329cdf0e10cSrcweir 				SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter());
1330cdf0e10cSrcweir 				awt::Size aSize(aViewBox.GetWidth(), aViewBox.GetHeight());
1331cdf0e10cSrcweir 				if (maSize.Width != 0 && maSize.Height !=0)
1332cdf0e10cSrcweir 				{
1333cdf0e10cSrcweir 					aSize = maSize;
1334cdf0e10cSrcweir 				}
1335cdf0e10cSrcweir 				awt::Point aPosition(aViewBox.GetX(), aViewBox.GetY());
1336cdf0e10cSrcweir 				SdXMLImExPointsElement aPoints(maPoints, aViewBox,
1337cdf0e10cSrcweir 					aPosition, aSize, GetImport().GetMM100UnitConverter());
1338cdf0e10cSrcweir 
1339cdf0e10cSrcweir 				uno::Any aAny;
1340cdf0e10cSrcweir 				aAny <<= aPoints.GetPointSequenceSequence();
1341cdf0e10cSrcweir 				xPropSet->setPropertyValue(
1342cdf0e10cSrcweir 					OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny);
1343cdf0e10cSrcweir 			}
1344cdf0e10cSrcweir 		}
1345cdf0e10cSrcweir 
1346cdf0e10cSrcweir 		// set pos, size, shear and rotate and get copy of matrix
1347cdf0e10cSrcweir 		SetTransformation();
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir 		SdXMLShapeContext::StartElement(xAttrList);
1350cdf0e10cSrcweir 	}
1351cdf0e10cSrcweir }
1352cdf0e10cSrcweir 
1353cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1354cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1355cdf0e10cSrcweir 
1356cdf0e10cSrcweir TYPEINIT1( SdXMLPathShapeContext, SdXMLShapeContext );
1357cdf0e10cSrcweir 
1358cdf0e10cSrcweir SdXMLPathShapeContext::SdXMLPathShapeContext(
1359cdf0e10cSrcweir 	SvXMLImport& rImport,
1360cdf0e10cSrcweir 	sal_uInt16 nPrfx,
1361cdf0e10cSrcweir 	const OUString& rLocalName,
1362cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1363cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
1364cdf0e10cSrcweir     sal_Bool bTemporaryShape)
1365cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1366cdf0e10cSrcweir 	mbClosed( sal_True )
1367cdf0e10cSrcweir {
1368cdf0e10cSrcweir }
1369cdf0e10cSrcweir 
1370cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1371cdf0e10cSrcweir 
1372cdf0e10cSrcweir SdXMLPathShapeContext::~SdXMLPathShapeContext()
1373cdf0e10cSrcweir {
1374cdf0e10cSrcweir }
1375cdf0e10cSrcweir 
1376cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1377cdf0e10cSrcweir 
1378cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
1379cdf0e10cSrcweir void SdXMLPathShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
1380cdf0e10cSrcweir {
1381cdf0e10cSrcweir 	if( XML_NAMESPACE_SVG == nPrefix )
1382cdf0e10cSrcweir 	{
1383cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_VIEWBOX ) )
1384cdf0e10cSrcweir 		{
1385cdf0e10cSrcweir 			maViewBox = rValue;
1386cdf0e10cSrcweir 			return;
1387cdf0e10cSrcweir 		}
1388cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_D ) )
1389cdf0e10cSrcweir 		{
1390cdf0e10cSrcweir 			maD = rValue;
1391cdf0e10cSrcweir 			return;
1392cdf0e10cSrcweir 		}
1393cdf0e10cSrcweir 	}
1394cdf0e10cSrcweir 
1395cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1396cdf0e10cSrcweir }
1397cdf0e10cSrcweir 
1398cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1399cdf0e10cSrcweir 
1400cdf0e10cSrcweir void SdXMLPathShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1401cdf0e10cSrcweir {
1402cdf0e10cSrcweir 	// create polygon shape
1403cdf0e10cSrcweir 	if(maD.getLength())
1404cdf0e10cSrcweir 	{
1405cdf0e10cSrcweir 		// prepare some of the parameters
1406cdf0e10cSrcweir 		SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter());
1407cdf0e10cSrcweir 		awt::Size aSize(aViewBox.GetWidth(), aViewBox.GetHeight());
1408cdf0e10cSrcweir 		awt::Point aPosition(aViewBox.GetX(), aViewBox.GetY());
1409cdf0e10cSrcweir 		if (maSize.Width != 0 && maSize.Height !=0)
1410cdf0e10cSrcweir 		{
1411cdf0e10cSrcweir 			aSize = maSize;
1412cdf0e10cSrcweir 		}
1413cdf0e10cSrcweir 		SdXMLImExSvgDElement aPoints(maD, aViewBox,
1414cdf0e10cSrcweir 			aPosition, aSize, GetImport().GetMM100UnitConverter());
1415cdf0e10cSrcweir 
1416cdf0e10cSrcweir 		const char* pService;
1417cdf0e10cSrcweir 		// now create shape
1418cdf0e10cSrcweir 		if(aPoints.IsCurve())
1419cdf0e10cSrcweir 		{
1420cdf0e10cSrcweir 			if(aPoints.IsClosed())
1421cdf0e10cSrcweir 			{
1422cdf0e10cSrcweir 				pService = "com.sun.star.drawing.ClosedBezierShape";
1423cdf0e10cSrcweir 			}
1424cdf0e10cSrcweir 			else
1425cdf0e10cSrcweir 			{
1426cdf0e10cSrcweir 				pService = "com.sun.star.drawing.OpenBezierShape";
1427cdf0e10cSrcweir 			}
1428cdf0e10cSrcweir 		}
1429cdf0e10cSrcweir 		else
1430cdf0e10cSrcweir 		{
1431cdf0e10cSrcweir 			if(aPoints.IsClosed())
1432cdf0e10cSrcweir 			{
1433cdf0e10cSrcweir 				pService = "com.sun.star.drawing.PolyPolygonShape";
1434cdf0e10cSrcweir 			}
1435cdf0e10cSrcweir 			else
1436cdf0e10cSrcweir 			{
1437cdf0e10cSrcweir 				pService = "com.sun.star.drawing.PolyLineShape";
1438cdf0e10cSrcweir 			}
1439cdf0e10cSrcweir 		}
1440cdf0e10cSrcweir 
1441cdf0e10cSrcweir 		// Add, set Style and properties from base shape
1442cdf0e10cSrcweir 		AddShape(pService);
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir 		// #89344# test for mxShape.is() and not for mxShapes.is() to support
1445cdf0e10cSrcweir 		// shape import helper classes WITHOUT XShapes (member mxShapes). This
1446cdf0e10cSrcweir 		// is used by the writer.
1447cdf0e10cSrcweir 		if( mxShape.is() )
1448cdf0e10cSrcweir 		{
1449cdf0e10cSrcweir 			SetStyle();
1450cdf0e10cSrcweir 			SetLayer();
1451cdf0e10cSrcweir 
1452cdf0e10cSrcweir 			// set local parameters on shape
1453cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1454cdf0e10cSrcweir 			if(xPropSet.is())
1455cdf0e10cSrcweir 			{
1456cdf0e10cSrcweir 				uno::Any aAny;
1457cdf0e10cSrcweir 
1458cdf0e10cSrcweir 				// set svg:d
1459cdf0e10cSrcweir 				if(maD.getLength())
1460cdf0e10cSrcweir 				{
1461cdf0e10cSrcweir 					if(aPoints.IsCurve())
1462cdf0e10cSrcweir 					{
1463cdf0e10cSrcweir 						drawing::PolyPolygonBezierCoords aSourcePolyPolygon(
1464cdf0e10cSrcweir 							aPoints.GetPointSequenceSequence(),
1465cdf0e10cSrcweir 							aPoints.GetFlagSequenceSequence());
1466cdf0e10cSrcweir 
1467cdf0e10cSrcweir 						aAny <<= aSourcePolyPolygon;
1468cdf0e10cSrcweir 						xPropSet->setPropertyValue(
1469cdf0e10cSrcweir 							OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny);
1470cdf0e10cSrcweir 					}
1471cdf0e10cSrcweir 					else
1472cdf0e10cSrcweir 					{
1473cdf0e10cSrcweir 						aAny <<= aPoints.GetPointSequenceSequence();
1474cdf0e10cSrcweir 						xPropSet->setPropertyValue(
1475cdf0e10cSrcweir 							OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny);
1476cdf0e10cSrcweir 					}
1477cdf0e10cSrcweir 				}
1478cdf0e10cSrcweir 			}
1479cdf0e10cSrcweir 
1480cdf0e10cSrcweir 			// set pos, size, shear and rotate
1481cdf0e10cSrcweir 			SetTransformation();
1482cdf0e10cSrcweir 
1483cdf0e10cSrcweir 			SdXMLShapeContext::StartElement(xAttrList);
1484cdf0e10cSrcweir 		}
1485cdf0e10cSrcweir 	}
1486cdf0e10cSrcweir }
1487cdf0e10cSrcweir 
1488cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1489cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1490cdf0e10cSrcweir 
1491cdf0e10cSrcweir TYPEINIT1( SdXMLTextBoxShapeContext, SdXMLShapeContext );
1492cdf0e10cSrcweir 
1493cdf0e10cSrcweir SdXMLTextBoxShapeContext::SdXMLTextBoxShapeContext(
1494cdf0e10cSrcweir 	SvXMLImport& rImport,
1495cdf0e10cSrcweir 	sal_uInt16 nPrfx,
1496cdf0e10cSrcweir 	const OUString& rLocalName,
1497cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1498cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
1499cdf0e10cSrcweir     sal_Bool bTemporaryShape)
1500cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1501cdf0e10cSrcweir 	mnRadius(0)
1502cdf0e10cSrcweir {
1503cdf0e10cSrcweir }
1504cdf0e10cSrcweir 
1505cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1506cdf0e10cSrcweir 
1507cdf0e10cSrcweir SdXMLTextBoxShapeContext::~SdXMLTextBoxShapeContext()
1508cdf0e10cSrcweir {
1509cdf0e10cSrcweir }
1510cdf0e10cSrcweir 
1511cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1512cdf0e10cSrcweir 
1513cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
1514cdf0e10cSrcweir void SdXMLTextBoxShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
1515cdf0e10cSrcweir {
1516cdf0e10cSrcweir 	if( XML_NAMESPACE_DRAW == nPrefix )
1517cdf0e10cSrcweir 	{
1518cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) )
1519cdf0e10cSrcweir 		{
1520cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(mnRadius, rValue);
1521cdf0e10cSrcweir 			return;
1522cdf0e10cSrcweir 		}
1523cdf0e10cSrcweir 	}
1524cdf0e10cSrcweir 
1525cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1526cdf0e10cSrcweir }
1527cdf0e10cSrcweir 
1528cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1529cdf0e10cSrcweir 
1530cdf0e10cSrcweir void SdXMLTextBoxShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&)
1531cdf0e10cSrcweir {
1532cdf0e10cSrcweir 	// create textbox shape
1533cdf0e10cSrcweir 	sal_Bool bIsPresShape = sal_False;
1534cdf0e10cSrcweir 	bool bClearText = false;
1535cdf0e10cSrcweir 
1536cdf0e10cSrcweir 	const char *pService = NULL;
1537cdf0e10cSrcweir 
1538cdf0e10cSrcweir 	if( isPresentationShape() )
1539cdf0e10cSrcweir 	{
1540cdf0e10cSrcweir 		// check if the current document supports presentation shapes
1541cdf0e10cSrcweir 		if( GetImport().GetShapeImport()->IsPresentationShapesSupported() )
1542cdf0e10cSrcweir 		{
1543cdf0e10cSrcweir 			if( IsXMLToken( maPresentationClass, XML_PRESENTATION_SUBTITLE ))
1544cdf0e10cSrcweir 			{
1545cdf0e10cSrcweir 				// XmlShapeTypePresSubtitleShape
1546cdf0e10cSrcweir 				pService = "com.sun.star.presentation.SubtitleShape";
1547cdf0e10cSrcweir 			}
1548cdf0e10cSrcweir 			else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_OUTLINE ) )
1549cdf0e10cSrcweir 			{
1550cdf0e10cSrcweir 				// XmlShapeTypePresOutlinerShape
1551cdf0e10cSrcweir 				pService = "com.sun.star.presentation.OutlinerShape";
1552cdf0e10cSrcweir 			}
1553cdf0e10cSrcweir 			else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_NOTES ) )
1554cdf0e10cSrcweir 			{
1555cdf0e10cSrcweir 				// XmlShapeTypePresNotesShape
1556cdf0e10cSrcweir 				pService = "com.sun.star.presentation.NotesShape";
1557cdf0e10cSrcweir 			}
1558cdf0e10cSrcweir 			else if( IsXMLToken( maPresentationClass, XML_HEADER ) )
1559cdf0e10cSrcweir 			{
1560cdf0e10cSrcweir 				// XmlShapeTypePresHeaderShape
1561cdf0e10cSrcweir 				pService = "com.sun.star.presentation.HeaderShape";
1562cdf0e10cSrcweir 				bClearText = true;
1563cdf0e10cSrcweir 			}
1564cdf0e10cSrcweir 			else if( IsXMLToken( maPresentationClass, XML_FOOTER ) )
1565cdf0e10cSrcweir 			{
1566cdf0e10cSrcweir 				// XmlShapeTypePresFooterShape
1567cdf0e10cSrcweir 				pService = "com.sun.star.presentation.FooterShape";
1568cdf0e10cSrcweir 				bClearText = true;
1569cdf0e10cSrcweir 			}
1570cdf0e10cSrcweir 			else if( IsXMLToken( maPresentationClass, XML_PAGE_NUMBER ) )
1571cdf0e10cSrcweir 			{
1572cdf0e10cSrcweir 				// XmlShapeTypePresSlideNumberShape
1573cdf0e10cSrcweir 				pService = "com.sun.star.presentation.SlideNumberShape";
1574cdf0e10cSrcweir 				bClearText = true;
1575cdf0e10cSrcweir 			}
1576cdf0e10cSrcweir 			else if( IsXMLToken( maPresentationClass, XML_DATE_TIME ) )
1577cdf0e10cSrcweir 			{
1578cdf0e10cSrcweir 				// XmlShapeTypePresDateTimeShape
1579cdf0e10cSrcweir 				pService = "com.sun.star.presentation.DateTimeShape";
1580cdf0e10cSrcweir 				bClearText = true;
1581cdf0e10cSrcweir 			}
1582cdf0e10cSrcweir 			else //  IsXMLToken( maPresentationClass, XML_PRESENTATION_TITLE ) )
1583cdf0e10cSrcweir 			{
1584cdf0e10cSrcweir 				// XmlShapeTypePresTitleTextShape
1585cdf0e10cSrcweir 				pService = "com.sun.star.presentation.TitleTextShape";
1586cdf0e10cSrcweir 			}
1587cdf0e10cSrcweir 			bIsPresShape = sal_True;
1588cdf0e10cSrcweir 		}
1589cdf0e10cSrcweir 	}
1590cdf0e10cSrcweir 
1591cdf0e10cSrcweir 	if( NULL == pService )
1592cdf0e10cSrcweir 	{
1593cdf0e10cSrcweir 		// normal text shape
1594cdf0e10cSrcweir 		pService = "com.sun.star.drawing.TextShape";
1595cdf0e10cSrcweir 	}
1596cdf0e10cSrcweir 
1597cdf0e10cSrcweir 	// Add, set Style and properties from base shape
1598cdf0e10cSrcweir 	AddShape(pService);
1599cdf0e10cSrcweir 
1600cdf0e10cSrcweir 	if( mxShape.is() )
1601cdf0e10cSrcweir 	{
1602cdf0e10cSrcweir 		SetStyle();
1603cdf0e10cSrcweir 		SetLayer();
1604cdf0e10cSrcweir 
1605cdf0e10cSrcweir 		if(bIsPresShape)
1606cdf0e10cSrcweir 		{
1607cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
1608cdf0e10cSrcweir 			if(xProps.is())
1609cdf0e10cSrcweir 			{
1610cdf0e10cSrcweir 				uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
1611cdf0e10cSrcweir 				if( xPropsInfo.is() )
1612cdf0e10cSrcweir 				{
1613cdf0e10cSrcweir 					if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
1614cdf0e10cSrcweir 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) );
1615cdf0e10cSrcweir 
1616cdf0e10cSrcweir 					if( mbIsUserTransformed && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
1617cdf0e10cSrcweir 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) );
1618cdf0e10cSrcweir 				}
1619cdf0e10cSrcweir 			}
1620cdf0e10cSrcweir 		}
1621cdf0e10cSrcweir 
1622cdf0e10cSrcweir 		if( bClearText )
1623cdf0e10cSrcweir 		{
1624cdf0e10cSrcweir 			uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
1625cdf0e10cSrcweir 			OUString aEmpty;
1626cdf0e10cSrcweir 			xText->setString( aEmpty );
1627cdf0e10cSrcweir 		}
1628cdf0e10cSrcweir 
1629cdf0e10cSrcweir 		// set parameters on shape
1630cdf0e10cSrcweir //A AW->CL: Eventually You need to strip scale and translate from the transformation
1631cdf0e10cSrcweir //A to reach the same goal again.
1632cdf0e10cSrcweir //A		if(!bIsPresShape || mbIsUserTransformed)
1633cdf0e10cSrcweir //A		{
1634cdf0e10cSrcweir //A			// set pos and size on shape, this should remove binding
1635cdf0e10cSrcweir //A			// to pres object on masterpage
1636cdf0e10cSrcweir //A			SetSizeAndPosition();
1637cdf0e10cSrcweir //A		}
1638cdf0e10cSrcweir 
1639cdf0e10cSrcweir 		// set pos, size, shear and rotate
1640cdf0e10cSrcweir 		SetTransformation();
1641cdf0e10cSrcweir 
1642cdf0e10cSrcweir 		if(mnRadius)
1643cdf0e10cSrcweir 		{
1644cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
1645cdf0e10cSrcweir 			if(xPropSet.is())
1646cdf0e10cSrcweir 			{
1647cdf0e10cSrcweir 				try
1648cdf0e10cSrcweir 				{
1649cdf0e10cSrcweir 					xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius")), uno::makeAny( mnRadius ) );
1650cdf0e10cSrcweir 				}
1651cdf0e10cSrcweir 				catch( uno::Exception& )
1652cdf0e10cSrcweir 				{
1653cdf0e10cSrcweir 					DBG_ERROR( "exception during setting of corner radius!");
1654cdf0e10cSrcweir 				}
1655cdf0e10cSrcweir 			}
1656cdf0e10cSrcweir 		}
1657cdf0e10cSrcweir 
1658cdf0e10cSrcweir 		SdXMLShapeContext::StartElement(mxAttrList);
1659cdf0e10cSrcweir 	}
1660cdf0e10cSrcweir }
1661cdf0e10cSrcweir 
1662cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1663cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1664cdf0e10cSrcweir 
1665cdf0e10cSrcweir TYPEINIT1( SdXMLControlShapeContext, SdXMLShapeContext );
1666cdf0e10cSrcweir 
1667cdf0e10cSrcweir SdXMLControlShapeContext::SdXMLControlShapeContext(
1668cdf0e10cSrcweir 	SvXMLImport& rImport,
1669cdf0e10cSrcweir 	sal_uInt16 nPrfx,
1670cdf0e10cSrcweir 	const OUString& rLocalName,
1671cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1672cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
1673cdf0e10cSrcweir     sal_Bool bTemporaryShape)
1674cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
1675cdf0e10cSrcweir {
1676cdf0e10cSrcweir }
1677cdf0e10cSrcweir 
1678cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1679cdf0e10cSrcweir 
1680cdf0e10cSrcweir SdXMLControlShapeContext::~SdXMLControlShapeContext()
1681cdf0e10cSrcweir {
1682cdf0e10cSrcweir }
1683cdf0e10cSrcweir 
1684cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1685cdf0e10cSrcweir 
1686cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
1687cdf0e10cSrcweir void SdXMLControlShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
1688cdf0e10cSrcweir {
1689cdf0e10cSrcweir 	if( XML_NAMESPACE_DRAW == nPrefix )
1690cdf0e10cSrcweir 	{
1691cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_CONTROL ) )
1692cdf0e10cSrcweir 		{
1693cdf0e10cSrcweir 			maFormId = rValue;
1694cdf0e10cSrcweir 			return;
1695cdf0e10cSrcweir 		}
1696cdf0e10cSrcweir 	}
1697cdf0e10cSrcweir 
1698cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1699cdf0e10cSrcweir }
1700cdf0e10cSrcweir 
1701cdf0e10cSrcweir void SdXMLControlShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1702cdf0e10cSrcweir {
1703cdf0e10cSrcweir 	// create Control shape
1704cdf0e10cSrcweir 	// add, set style and properties from base shape
1705cdf0e10cSrcweir 	AddShape("com.sun.star.drawing.ControlShape");
1706cdf0e10cSrcweir 	if( mxShape.is() )
1707cdf0e10cSrcweir 	{
1708cdf0e10cSrcweir 		DBG_ASSERT( maFormId.getLength(), "draw:control without a form:id attribute!" );
1709cdf0e10cSrcweir 		if( maFormId.getLength() )
1710cdf0e10cSrcweir 		{
1711cdf0e10cSrcweir #ifndef SVX_LIGHT
1712cdf0e10cSrcweir 			if( GetImport().IsFormsSupported() )
1713cdf0e10cSrcweir 			{
1714cdf0e10cSrcweir 				uno::Reference< awt::XControlModel > xControlModel( GetImport().GetFormImport()->lookupControl( maFormId ), uno::UNO_QUERY );
1715cdf0e10cSrcweir 				if( xControlModel.is() )
1716cdf0e10cSrcweir 				{
1717cdf0e10cSrcweir 					uno::Reference< drawing::XControlShape > xControl( mxShape, uno::UNO_QUERY );
1718cdf0e10cSrcweir 					if( xControl.is() )
1719cdf0e10cSrcweir 						xControl->setControl(  xControlModel );
1720cdf0e10cSrcweir 
1721cdf0e10cSrcweir 				}
1722cdf0e10cSrcweir 			}
1723cdf0e10cSrcweir #endif // #ifndef SVX_LIGHT
1724cdf0e10cSrcweir 		}
1725cdf0e10cSrcweir 
1726cdf0e10cSrcweir 		SetStyle();
1727cdf0e10cSrcweir 		SetLayer();
1728cdf0e10cSrcweir 
1729cdf0e10cSrcweir 		// set pos, size, shear and rotate
1730cdf0e10cSrcweir 		SetTransformation();
1731cdf0e10cSrcweir 
1732cdf0e10cSrcweir 		SdXMLShapeContext::StartElement(xAttrList);
1733cdf0e10cSrcweir 	}
1734cdf0e10cSrcweir }
1735cdf0e10cSrcweir 
1736cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1737cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1738cdf0e10cSrcweir 
1739cdf0e10cSrcweir TYPEINIT1( SdXMLConnectorShapeContext, SdXMLShapeContext );
1740cdf0e10cSrcweir 
1741cdf0e10cSrcweir SdXMLConnectorShapeContext::SdXMLConnectorShapeContext(
1742cdf0e10cSrcweir 	SvXMLImport& rImport,
1743cdf0e10cSrcweir 	sal_uInt16 nPrfx,
1744cdf0e10cSrcweir 	const OUString& rLocalName,
1745cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
1746cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
1747cdf0e10cSrcweir     sal_Bool bTemporaryShape)
1748cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
1749cdf0e10cSrcweir 	maStart(0,0),
1750cdf0e10cSrcweir 	maEnd(1,1),
1751cdf0e10cSrcweir 	mnType( (sal_uInt16)drawing::ConnectorType_STANDARD ),
1752cdf0e10cSrcweir 	mnStartGlueId(-1),
1753cdf0e10cSrcweir 	mnEndGlueId(-1),
1754cdf0e10cSrcweir 	mnDelta1(0),
1755cdf0e10cSrcweir 	mnDelta2(0),
1756cdf0e10cSrcweir 	mnDelta3(0)
1757cdf0e10cSrcweir {
1758cdf0e10cSrcweir }
1759cdf0e10cSrcweir 
1760cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1761cdf0e10cSrcweir 
1762cdf0e10cSrcweir SdXMLConnectorShapeContext::~SdXMLConnectorShapeContext()
1763cdf0e10cSrcweir {
1764cdf0e10cSrcweir }
1765cdf0e10cSrcweir 
1766cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1767cdf0e10cSrcweir 
1768cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
1769cdf0e10cSrcweir void SdXMLConnectorShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
1770cdf0e10cSrcweir {
1771cdf0e10cSrcweir 	switch( nPrefix )
1772cdf0e10cSrcweir 	{
1773cdf0e10cSrcweir 	case XML_NAMESPACE_DRAW:
1774cdf0e10cSrcweir 	{
1775cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_START_SHAPE ) )
1776cdf0e10cSrcweir 		{
1777cdf0e10cSrcweir 			maStartShapeId = rValue;
1778cdf0e10cSrcweir 			return;
1779cdf0e10cSrcweir 		}
1780cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_START_GLUE_POINT ) )
1781cdf0e10cSrcweir 		{
1782cdf0e10cSrcweir 			mnStartGlueId = rValue.toInt32();
1783cdf0e10cSrcweir 			return;
1784cdf0e10cSrcweir 		}
1785cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_END_SHAPE ) )
1786cdf0e10cSrcweir 		{
1787cdf0e10cSrcweir 			maEndShapeId = rValue;
1788cdf0e10cSrcweir 			return;
1789cdf0e10cSrcweir 		}
1790cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_END_GLUE_POINT ) )
1791cdf0e10cSrcweir 		{
1792cdf0e10cSrcweir 			mnEndGlueId = rValue.toInt32();
1793cdf0e10cSrcweir 			return;
1794cdf0e10cSrcweir 		}
1795cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_LINE_SKEW ) )
1796cdf0e10cSrcweir 		{
1797cdf0e10cSrcweir 			SvXMLTokenEnumerator aTokenEnum( rValue );
1798cdf0e10cSrcweir 			OUString aToken;
1799cdf0e10cSrcweir 			if( aTokenEnum.getNextToken( aToken ) )
1800cdf0e10cSrcweir 			{
1801cdf0e10cSrcweir 				GetImport().GetMM100UnitConverter().convertMeasure(mnDelta1, aToken);
1802cdf0e10cSrcweir 				if( aTokenEnum.getNextToken( aToken ) )
1803cdf0e10cSrcweir 				{
1804cdf0e10cSrcweir 					GetImport().GetMM100UnitConverter().convertMeasure(mnDelta2, aToken);
1805cdf0e10cSrcweir 					if( aTokenEnum.getNextToken( aToken ) )
1806cdf0e10cSrcweir 					{
1807cdf0e10cSrcweir 						GetImport().GetMM100UnitConverter().convertMeasure(mnDelta3, aToken);
1808cdf0e10cSrcweir 					}
1809cdf0e10cSrcweir 				}
1810cdf0e10cSrcweir 			}
1811cdf0e10cSrcweir 			return;
1812cdf0e10cSrcweir 		}
1813cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_TYPE ) )
1814cdf0e10cSrcweir 		{
1815cdf0e10cSrcweir 			SvXMLUnitConverter::convertEnum( mnType, rValue, aXML_ConnectionKind_EnumMap );
1816cdf0e10cSrcweir 			return;
1817cdf0e10cSrcweir 		}
1818242c6546SArmin Le Grand         // #121965# draw:transform may be used in ODF1.2, e.g. exports from MS seem to use these
1819242c6546SArmin Le Grand 		else if( IsXMLToken( rLocalName, XML_TRANSFORM ) )
1820242c6546SArmin Le Grand 		{
1821242c6546SArmin Le Grand 			mnTransform.SetString(rValue, GetImport().GetMM100UnitConverter());
1822242c6546SArmin Le Grand 		}
1823cdf0e10cSrcweir 	}
1824cdf0e10cSrcweir 	case XML_NAMESPACE_SVG:
1825cdf0e10cSrcweir 	{
1826cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_X1 ) )
1827cdf0e10cSrcweir 		{
1828cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(maStart.X, rValue);
1829cdf0e10cSrcweir 			return;
1830cdf0e10cSrcweir 		}
1831cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_Y1 ) )
1832cdf0e10cSrcweir 		{
1833cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(maStart.Y, rValue);
1834cdf0e10cSrcweir 			return;
1835cdf0e10cSrcweir 		}
1836cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_X2 ) )
1837cdf0e10cSrcweir 		{
1838cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(maEnd.X, rValue);
1839cdf0e10cSrcweir 			return;
1840cdf0e10cSrcweir 		}
1841cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_Y2 ) )
1842cdf0e10cSrcweir 		{
1843cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(maEnd.Y, rValue);
1844cdf0e10cSrcweir 			return;
1845cdf0e10cSrcweir 		}
1846cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_D ) )
1847cdf0e10cSrcweir 		{
1848cdf0e10cSrcweir 			SdXMLImExViewBox aViewBox( 0, 0, 1, 1 );
1849cdf0e10cSrcweir 			awt::Point aPoint( 0, 0 );
1850cdf0e10cSrcweir 			awt::Size aSize( 1, 1 );
1851cdf0e10cSrcweir 
1852cdf0e10cSrcweir 			SdXMLImExSvgDElement aPoints( rValue, aViewBox,
1853cdf0e10cSrcweir 				aPoint, aSize, GetImport().GetMM100UnitConverter() );
1854cdf0e10cSrcweir 
1855cdf0e10cSrcweir 			if ( aPoints.IsCurve() )
1856cdf0e10cSrcweir 			{
1857cdf0e10cSrcweir 				drawing::PolyPolygonBezierCoords aSourcePolyPolygon(
1858cdf0e10cSrcweir 					aPoints.GetPointSequenceSequence(),
1859cdf0e10cSrcweir 					aPoints.GetFlagSequenceSequence());
1860cdf0e10cSrcweir 				maPath <<= aSourcePolyPolygon;
1861cdf0e10cSrcweir 			}
1862cdf0e10cSrcweir 			else
1863cdf0e10cSrcweir 			{
1864cdf0e10cSrcweir 				const drawing::PointSequenceSequence& rOuterSeq = aPoints.GetPointSequenceSequence();
1865cdf0e10cSrcweir 				drawing::FlagSequenceSequence aFlagSeqSeq( rOuterSeq.getLength() );
1866cdf0e10cSrcweir 				for ( int a = 0; a < rOuterSeq.getLength(); a++ )
1867cdf0e10cSrcweir 					aFlagSeqSeq[ a ] = drawing::FlagSequence( rOuterSeq[ a ].getLength() );
1868cdf0e10cSrcweir 
1869cdf0e10cSrcweir 				drawing::PolyPolygonBezierCoords aSourcePolyPolygon(
1870cdf0e10cSrcweir 					aPoints.GetPointSequenceSequence(),
1871cdf0e10cSrcweir 					aFlagSeqSeq );
1872cdf0e10cSrcweir 				maPath <<= aSourcePolyPolygon;
1873cdf0e10cSrcweir 			}
1874cdf0e10cSrcweir 		}
1875cdf0e10cSrcweir 	}
1876cdf0e10cSrcweir 	}
1877cdf0e10cSrcweir 
1878cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
1879cdf0e10cSrcweir }
1880cdf0e10cSrcweir 
1881cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
1882cdf0e10cSrcweir 
1883cdf0e10cSrcweir void SdXMLConnectorShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
1884cdf0e10cSrcweir {
1885cdf0e10cSrcweir 	// #107928#
1886cdf0e10cSrcweir 	// For security reasons, do not add empty connectors. There may have been an error in EA2
1887cdf0e10cSrcweir 	// that created empty, far set off connectors (e.g. 63 meters below top of document). This
1888cdf0e10cSrcweir 	// is not guaranteed, but it's definitely safe to not add empty connectors.
1889cdf0e10cSrcweir 	sal_Bool bDoAdd(sal_True);
1890cdf0e10cSrcweir 
1891cdf0e10cSrcweir 	if(    0 == maStartShapeId.getLength()
1892cdf0e10cSrcweir 		&& 0 == maEndShapeId.getLength()
1893cdf0e10cSrcweir 		&& maStart.X == maEnd.X
1894cdf0e10cSrcweir 		&& maStart.Y == maEnd.Y
1895cdf0e10cSrcweir 		&& 0 == mnDelta1
1896cdf0e10cSrcweir 		&& 0 == mnDelta2
1897cdf0e10cSrcweir 		&& 0 == mnDelta3
1898cdf0e10cSrcweir 		)
1899cdf0e10cSrcweir 	{
1900cdf0e10cSrcweir 		bDoAdd = sal_False;
1901cdf0e10cSrcweir 	}
1902cdf0e10cSrcweir 
1903cdf0e10cSrcweir 	if(bDoAdd)
1904cdf0e10cSrcweir 	{
1905cdf0e10cSrcweir 		// create Connector shape
1906cdf0e10cSrcweir 		// add, set style and properties from base shape
1907cdf0e10cSrcweir 		AddShape("com.sun.star.drawing.ConnectorShape");
1908cdf0e10cSrcweir 		if(mxShape.is())
1909cdf0e10cSrcweir 		{
1910242c6546SArmin Le Grand             // #121965# if draw:transform is used, apply directly to the start
1911242c6546SArmin Le Grand             // and end positions before using these
1912242c6546SArmin Le Grand             if(mnTransform.NeedsAction())
1913242c6546SArmin Le Grand             {
1914242c6546SArmin Le Grand                 // transformation is used, apply to object.
1915242c6546SArmin Le Grand                 ::basegfx::B2DHomMatrix aMat;
1916242c6546SArmin Le Grand                 mnTransform.GetFullTransform(aMat);
1917242c6546SArmin Le Grand 
1918242c6546SArmin Le Grand                 if(!aMat.isIdentity())
1919242c6546SArmin Le Grand                 {
1920242c6546SArmin Le Grand                     basegfx::B2DPoint aStart(maStart.X, maStart.Y);
1921242c6546SArmin Le Grand                     basegfx::B2DPoint aEnd(maEnd.X, maEnd.Y);
1922242c6546SArmin Le Grand 
1923242c6546SArmin Le Grand                     aStart = aMat * aStart;
1924242c6546SArmin Le Grand                     aEnd = aMat * aEnd;
1925242c6546SArmin Le Grand 
1926242c6546SArmin Le Grand                     maStart.X = basegfx::fround(aStart.getX());
1927242c6546SArmin Le Grand                     maStart.Y = basegfx::fround(aStart.getY());
1928242c6546SArmin Le Grand                     maEnd.X = basegfx::fround(aEnd.getX());
1929242c6546SArmin Le Grand                     maEnd.Y = basegfx::fround(aEnd.getY());
1930242c6546SArmin Le Grand                 }
1931242c6546SArmin Le Grand             }
1932242c6546SArmin Le Grand 
1933cdf0e10cSrcweir             // add connection ids
1934cdf0e10cSrcweir 			if( maStartShapeId.getLength() )
1935cdf0e10cSrcweir 				GetImport().GetShapeImport()->addShapeConnection( mxShape, sal_True, maStartShapeId, mnStartGlueId );
1936cdf0e10cSrcweir 			if( maEndShapeId.getLength() )
1937cdf0e10cSrcweir 				GetImport().GetShapeImport()->addShapeConnection( mxShape, sal_False, maEndShapeId, mnEndGlueId );
1938cdf0e10cSrcweir 
1939cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
1940cdf0e10cSrcweir 			if( xProps.is() )
1941cdf0e10cSrcweir 			{
1942cdf0e10cSrcweir 				uno::Any aAny;
1943cdf0e10cSrcweir 				aAny <<= maStart;
1944cdf0e10cSrcweir 				xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")), aAny);
1945cdf0e10cSrcweir 
1946cdf0e10cSrcweir 				aAny <<= maEnd;
1947cdf0e10cSrcweir 				xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")), aAny );
1948cdf0e10cSrcweir 
1949cdf0e10cSrcweir 				aAny <<= (drawing::ConnectorType)mnType;
1950cdf0e10cSrcweir 				xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeKind")), aAny );
1951cdf0e10cSrcweir 
1952cdf0e10cSrcweir 				aAny <<= mnDelta1;
1953cdf0e10cSrcweir 				xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine1Delta")), aAny );
1954cdf0e10cSrcweir 
1955cdf0e10cSrcweir 				aAny <<= mnDelta2;
1956cdf0e10cSrcweir 				xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine2Delta")), aAny );
1957cdf0e10cSrcweir 
1958cdf0e10cSrcweir 				aAny <<= mnDelta3;
1959cdf0e10cSrcweir 				xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine3Delta")), aAny );
1960cdf0e10cSrcweir 			}
1961cdf0e10cSrcweir 			SetStyle();
1962cdf0e10cSrcweir 			SetLayer();
1963cdf0e10cSrcweir 
1964cdf0e10cSrcweir 			if ( maPath.hasValue() )
1965cdf0e10cSrcweir             {
1966cdf0e10cSrcweir                 // --> OD #i115492#
1967cdf0e10cSrcweir                 // Ignore svg:d attribute for text documents created by OpenOffice.org
1968cdf0e10cSrcweir                 // versions before OOo 3.3, because these OOo versions are storing
1969cdf0e10cSrcweir                 // svg:d values not using the correct unit.
1970cdf0e10cSrcweir                 bool bApplySVGD( true );
1971cdf0e10cSrcweir                 if ( uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() )
1972cdf0e10cSrcweir                 {
1973cdf0e10cSrcweir                     sal_Int32 nUPD( 0 );
1974cdf0e10cSrcweir                     sal_Int32 nBuild( 0 );
1975cdf0e10cSrcweir                     const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild );
1976cdf0e10cSrcweir                     if ( GetImport().IsTextDocInOOoFileFormat() ||
1977cdf0e10cSrcweir                          ( bBuildIdFound &&
1978cdf0e10cSrcweir                            ( ( nUPD == 641 ) || ( nUPD == 645 ) ||  // prior OOo 2.0
1979cdf0e10cSrcweir                              ( nUPD == 680 ) ||                     // OOo 2.x
1980cdf0e10cSrcweir                              ( nUPD == 300 ) ||                     // OOo 3.0 - OOo 3.0.1
1981cdf0e10cSrcweir                              ( nUPD == 310 ) ||                     // OOo 3.1 - OOo 3.1.1
1982cdf0e10cSrcweir                              ( nUPD == 320 ) ) ) )                  // OOo 3.2 - OOo 3.2.1
1983cdf0e10cSrcweir                     {
1984cdf0e10cSrcweir                         bApplySVGD = false;
1985cdf0e10cSrcweir                     }
1986cdf0e10cSrcweir                 }
1987cdf0e10cSrcweir 
1988cdf0e10cSrcweir                 if ( bApplySVGD )
1989cdf0e10cSrcweir                 {
1990cdf0e10cSrcweir                     xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygonBezier") ), maPath );
1991cdf0e10cSrcweir                 }
1992cdf0e10cSrcweir                 // <--
1993cdf0e10cSrcweir             }
1994cdf0e10cSrcweir 
1995cdf0e10cSrcweir 			SdXMLShapeContext::StartElement(xAttrList);
1996cdf0e10cSrcweir 		}
1997cdf0e10cSrcweir 	}
1998cdf0e10cSrcweir }
1999cdf0e10cSrcweir 
2000cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2002cdf0e10cSrcweir 
2003cdf0e10cSrcweir TYPEINIT1( SdXMLMeasureShapeContext, SdXMLShapeContext );
2004cdf0e10cSrcweir 
2005cdf0e10cSrcweir SdXMLMeasureShapeContext::SdXMLMeasureShapeContext(
2006cdf0e10cSrcweir 	SvXMLImport& rImport,
2007cdf0e10cSrcweir 	sal_uInt16 nPrfx,
2008cdf0e10cSrcweir 	const OUString& rLocalName,
2009cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2010cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
2011cdf0e10cSrcweir     sal_Bool bTemporaryShape)
2012cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
2013cdf0e10cSrcweir 	maStart(0,0),
2014cdf0e10cSrcweir 	maEnd(1,1)
2015cdf0e10cSrcweir {
2016cdf0e10cSrcweir }
2017cdf0e10cSrcweir 
2018cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2019cdf0e10cSrcweir 
2020cdf0e10cSrcweir SdXMLMeasureShapeContext::~SdXMLMeasureShapeContext()
2021cdf0e10cSrcweir {
2022cdf0e10cSrcweir }
2023cdf0e10cSrcweir 
2024cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
2025cdf0e10cSrcweir void SdXMLMeasureShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
2026cdf0e10cSrcweir {
2027cdf0e10cSrcweir 	switch( nPrefix )
2028cdf0e10cSrcweir 	{
2029cdf0e10cSrcweir 	case XML_NAMESPACE_SVG:
2030cdf0e10cSrcweir 	{
2031cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_X1 ) )
2032cdf0e10cSrcweir 		{
2033cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(maStart.X, rValue);
2034cdf0e10cSrcweir 			return;
2035cdf0e10cSrcweir 		}
2036cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_Y1 ) )
2037cdf0e10cSrcweir 		{
2038cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(maStart.Y, rValue);
2039cdf0e10cSrcweir 			return;
2040cdf0e10cSrcweir 		}
2041cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_X2 ) )
2042cdf0e10cSrcweir 		{
2043cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(maEnd.X, rValue);
2044cdf0e10cSrcweir 			return;
2045cdf0e10cSrcweir 		}
2046cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_Y2 ) )
2047cdf0e10cSrcweir 		{
2048cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(maEnd.Y, rValue);
2049cdf0e10cSrcweir 			return;
2050cdf0e10cSrcweir 		}
2051cdf0e10cSrcweir 	}
2052cdf0e10cSrcweir 	}
2053cdf0e10cSrcweir 
2054cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2055cdf0e10cSrcweir }
2056cdf0e10cSrcweir 
2057cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2058cdf0e10cSrcweir 
2059cdf0e10cSrcweir void SdXMLMeasureShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
2060cdf0e10cSrcweir {
2061cdf0e10cSrcweir 	// create Measure shape
2062cdf0e10cSrcweir 	// add, set style and properties from base shape
2063cdf0e10cSrcweir 	AddShape("com.sun.star.drawing.MeasureShape");
2064cdf0e10cSrcweir 	if(mxShape.is())
2065cdf0e10cSrcweir 	{
2066cdf0e10cSrcweir 		SetStyle();
2067cdf0e10cSrcweir 		SetLayer();
2068cdf0e10cSrcweir 
2069cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2070cdf0e10cSrcweir 		if( xProps.is() )
2071cdf0e10cSrcweir 		{
2072cdf0e10cSrcweir 			uno::Any aAny;
2073cdf0e10cSrcweir 			aAny <<= maStart;
2074cdf0e10cSrcweir 			xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")), aAny);
2075cdf0e10cSrcweir 
2076cdf0e10cSrcweir 			aAny <<= maEnd;
2077cdf0e10cSrcweir 			xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")), aAny );
2078cdf0e10cSrcweir 		}
2079cdf0e10cSrcweir 
2080cdf0e10cSrcweir 		// delete pre created fields
2081cdf0e10cSrcweir 		uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
2082cdf0e10cSrcweir 		if( xText.is() )
2083cdf0e10cSrcweir 		{
2084cdf0e10cSrcweir 			const OUString aEmpty( RTL_CONSTASCII_USTRINGPARAM( " " ) );
2085cdf0e10cSrcweir 			xText->setString( aEmpty );
2086cdf0e10cSrcweir 		}
2087cdf0e10cSrcweir 
2088cdf0e10cSrcweir 		SdXMLShapeContext::StartElement(xAttrList);
2089cdf0e10cSrcweir 	}
2090cdf0e10cSrcweir }
2091cdf0e10cSrcweir 
2092cdf0e10cSrcweir void SdXMLMeasureShapeContext::EndElement()
2093cdf0e10cSrcweir {
2094cdf0e10cSrcweir 	do
2095cdf0e10cSrcweir 	{
2096cdf0e10cSrcweir 		// delete pre created fields
2097cdf0e10cSrcweir 		uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY );
2098cdf0e10cSrcweir 		if( !xText.is() )
2099cdf0e10cSrcweir 			break;
2100cdf0e10cSrcweir 
2101cdf0e10cSrcweir 		uno::Reference< text::XTextCursor > xCursor( xText->createTextCursor() );
2102cdf0e10cSrcweir 		if( !xCursor.is() )
2103cdf0e10cSrcweir 			break;
2104cdf0e10cSrcweir 
2105cdf0e10cSrcweir 		const OUString aEmpty;
2106cdf0e10cSrcweir 		xCursor->collapseToStart();
2107cdf0e10cSrcweir 		xCursor->goRight( 1, sal_True );
2108cdf0e10cSrcweir 		xCursor->setString( aEmpty );
2109cdf0e10cSrcweir 	}
2110cdf0e10cSrcweir 	while(0);
2111cdf0e10cSrcweir 
2112cdf0e10cSrcweir 	SdXMLShapeContext::EndElement();
2113cdf0e10cSrcweir }
2114cdf0e10cSrcweir 
2115cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2116cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2117cdf0e10cSrcweir 
2118cdf0e10cSrcweir TYPEINIT1( SdXMLPageShapeContext, SdXMLShapeContext );
2119cdf0e10cSrcweir 
2120cdf0e10cSrcweir SdXMLPageShapeContext::SdXMLPageShapeContext(
2121cdf0e10cSrcweir 	SvXMLImport& rImport,
2122cdf0e10cSrcweir 	sal_uInt16 nPrfx,
2123cdf0e10cSrcweir 	const OUString& rLocalName,
2124cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2125cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
2126cdf0e10cSrcweir     sal_Bool bTemporaryShape)
2127cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ), mnPageNumber(0)
2128cdf0e10cSrcweir {
2129cdf0e10cSrcweir 	mbClearDefaultAttributes = false;
2130cdf0e10cSrcweir }
2131cdf0e10cSrcweir 
2132cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2133cdf0e10cSrcweir 
2134cdf0e10cSrcweir SdXMLPageShapeContext::~SdXMLPageShapeContext()
2135cdf0e10cSrcweir {
2136cdf0e10cSrcweir }
2137cdf0e10cSrcweir 
2138cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2139cdf0e10cSrcweir 
2140cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
2141cdf0e10cSrcweir void SdXMLPageShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
2142cdf0e10cSrcweir {
2143cdf0e10cSrcweir 	if( XML_NAMESPACE_DRAW == nPrefix )
2144cdf0e10cSrcweir 	{
2145cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_PAGE_NUMBER ) )
2146cdf0e10cSrcweir 		{
2147cdf0e10cSrcweir 			mnPageNumber = rValue.toInt32();
2148cdf0e10cSrcweir 			return;
2149cdf0e10cSrcweir 		}
2150cdf0e10cSrcweir 	}
2151cdf0e10cSrcweir 
2152cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2153cdf0e10cSrcweir }
2154cdf0e10cSrcweir 
2155cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2156cdf0e10cSrcweir 
2157cdf0e10cSrcweir void SdXMLPageShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
2158cdf0e10cSrcweir {
2159cdf0e10cSrcweir 	// create Page shape
2160cdf0e10cSrcweir 	// add, set style and properties from base shape
2161cdf0e10cSrcweir 
2162cdf0e10cSrcweir 	// #86163# take into account which type of PageShape needs to
2163cdf0e10cSrcweir 	// be constructed. It's an pres shape if presentation:XML_CLASS == XML_PRESENTATION_PAGE.
2164cdf0e10cSrcweir 	sal_Bool bIsPresentation = maPresentationClass.getLength() &&
2165cdf0e10cSrcweir 		   GetImport().GetShapeImport()->IsPresentationShapesSupported();
2166cdf0e10cSrcweir 
2167cdf0e10cSrcweir 	uno::Reference< lang::XServiceInfo > xInfo( mxShapes, uno::UNO_QUERY );
2168cdf0e10cSrcweir 	const sal_Bool bIsOnHandoutPage = xInfo.is() && xInfo->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutMasterPage")) );
2169cdf0e10cSrcweir 
2170cdf0e10cSrcweir 	if( bIsOnHandoutPage )
2171cdf0e10cSrcweir 	{
2172cdf0e10cSrcweir 		AddShape("com.sun.star.presentation.HandoutShape");
2173cdf0e10cSrcweir 	}
2174cdf0e10cSrcweir 	else
2175cdf0e10cSrcweir 	{
2176cdf0e10cSrcweir 		if(bIsPresentation && !IsXMLToken( maPresentationClass, XML_PRESENTATION_PAGE ) )
2177cdf0e10cSrcweir 		{
2178cdf0e10cSrcweir 			bIsPresentation = sal_False;
2179cdf0e10cSrcweir 		}
2180cdf0e10cSrcweir 
2181cdf0e10cSrcweir 		if(bIsPresentation)
2182cdf0e10cSrcweir 		{
2183cdf0e10cSrcweir 			AddShape("com.sun.star.presentation.PageShape");
2184cdf0e10cSrcweir 		}
2185cdf0e10cSrcweir 		else
2186cdf0e10cSrcweir 		{
2187cdf0e10cSrcweir 			AddShape("com.sun.star.drawing.PageShape");
2188cdf0e10cSrcweir 		}
2189cdf0e10cSrcweir 	}
2190cdf0e10cSrcweir 
2191cdf0e10cSrcweir 	if(mxShape.is())
2192cdf0e10cSrcweir 	{
2193cdf0e10cSrcweir 		SetStyle();
2194cdf0e10cSrcweir 		SetLayer();
2195cdf0e10cSrcweir 
2196cdf0e10cSrcweir 		// set pos, size, shear and rotate
2197cdf0e10cSrcweir 		SetTransformation();
2198cdf0e10cSrcweir 
2199cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2200cdf0e10cSrcweir 		if(xPropSet.is())
2201cdf0e10cSrcweir 		{
2202cdf0e10cSrcweir 			uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
2203cdf0e10cSrcweir 			const OUString aPageNumberStr(RTL_CONSTASCII_USTRINGPARAM("PageNumber"));
2204cdf0e10cSrcweir 			if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(aPageNumberStr))
2205cdf0e10cSrcweir 				xPropSet->setPropertyValue(aPageNumberStr, uno::makeAny( mnPageNumber ));
2206cdf0e10cSrcweir 		}
2207cdf0e10cSrcweir 
2208cdf0e10cSrcweir 		SdXMLShapeContext::StartElement(xAttrList);
2209cdf0e10cSrcweir 	}
2210cdf0e10cSrcweir }
2211cdf0e10cSrcweir 
2212cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2213cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2214cdf0e10cSrcweir 
2215cdf0e10cSrcweir TYPEINIT1( SdXMLCaptionShapeContext, SdXMLShapeContext );
2216cdf0e10cSrcweir 
2217cdf0e10cSrcweir SdXMLCaptionShapeContext::SdXMLCaptionShapeContext(
2218cdf0e10cSrcweir 	SvXMLImport& rImport,
2219cdf0e10cSrcweir 	sal_uInt16 nPrfx,
2220cdf0e10cSrcweir 	const OUString& rLocalName,
2221cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2222cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
2223cdf0e10cSrcweir     sal_Bool bTemporaryShape)
2224cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
2225cdf0e10cSrcweir 	// #86616# for correct edge rounding import mnRadius needs to be initialized
2226cdf0e10cSrcweir 	mnRadius( 0L )
2227cdf0e10cSrcweir {
2228cdf0e10cSrcweir }
2229cdf0e10cSrcweir 
2230cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2231cdf0e10cSrcweir 
2232cdf0e10cSrcweir SdXMLCaptionShapeContext::~SdXMLCaptionShapeContext()
2233cdf0e10cSrcweir {
2234cdf0e10cSrcweir }
2235cdf0e10cSrcweir 
2236cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2237cdf0e10cSrcweir 
2238cdf0e10cSrcweir void SdXMLCaptionShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
2239cdf0e10cSrcweir {
2240cdf0e10cSrcweir 	// create Caption shape
2241cdf0e10cSrcweir 	// add, set style and properties from base shape
2242cdf0e10cSrcweir 	AddShape("com.sun.star.drawing.CaptionShape");
2243cdf0e10cSrcweir 	if( mxShape.is() )
2244cdf0e10cSrcweir 	{
2245cdf0e10cSrcweir 		SetStyle();
2246cdf0e10cSrcweir 		SetLayer();
2247cdf0e10cSrcweir 
2248cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2249cdf0e10cSrcweir 
2250cdf0e10cSrcweir 		// SJ: If AutoGrowWidthItem is set, SetTransformation will lead to the wrong SnapRect
2251cdf0e10cSrcweir 		// because NbcAdjustTextFrameWidthAndHeight() is called (text is set later and center alignment
2252cdf0e10cSrcweir 		// is the default setting, so the top left reference point that is used by the caption point is
2253cdf0e10cSrcweir 		// no longer correct) There are two ways to solve this problem, temporarily disabling the
2254cdf0e10cSrcweir 		// autogrowwith as we are doing here or to apply the CaptionPoint after setting text
2255cdf0e10cSrcweir 		sal_Bool bIsAutoGrowWidth = sal_False;
2256cdf0e10cSrcweir 		if ( xProps.is() )
2257cdf0e10cSrcweir 		{
2258cdf0e10cSrcweir 			uno::Any aAny( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("TextAutoGrowWidth") ) ) );
2259cdf0e10cSrcweir 			aAny >>= bIsAutoGrowWidth;
2260cdf0e10cSrcweir 
2261cdf0e10cSrcweir 			if ( bIsAutoGrowWidth )
2262cdf0e10cSrcweir 				xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("TextAutoGrowWidth")), uno::makeAny( sal_False ) );
2263cdf0e10cSrcweir 		}
2264cdf0e10cSrcweir 
2265cdf0e10cSrcweir 		// set pos, size, shear and rotate
2266cdf0e10cSrcweir 		SetTransformation();
2267cdf0e10cSrcweir 		if( xProps.is() )
2268cdf0e10cSrcweir 			xProps->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CaptionPoint")), uno::makeAny( maCaptionPoint ) );
2269cdf0e10cSrcweir 
2270cdf0e10cSrcweir 		if ( bIsAutoGrowWidth )
2271cdf0e10cSrcweir 			xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("TextAutoGrowWidth")), uno::makeAny( sal_True ) );
2272cdf0e10cSrcweir 
2273cdf0e10cSrcweir 		if(mnRadius)
2274cdf0e10cSrcweir 		{
2275cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2276cdf0e10cSrcweir 			if(xPropSet.is())
2277cdf0e10cSrcweir 			{
2278cdf0e10cSrcweir 				try
2279cdf0e10cSrcweir 				{
2280cdf0e10cSrcweir 					xPropSet->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius")), uno::makeAny( mnRadius ) );
2281cdf0e10cSrcweir 				}
2282cdf0e10cSrcweir 				catch( uno::Exception& )
2283cdf0e10cSrcweir 				{
2284cdf0e10cSrcweir 					DBG_ERROR( "exception during setting of corner radius!");
2285cdf0e10cSrcweir 				}
2286cdf0e10cSrcweir 			}
2287cdf0e10cSrcweir 		}
2288cdf0e10cSrcweir 
2289cdf0e10cSrcweir 		SdXMLShapeContext::StartElement(xAttrList);
2290cdf0e10cSrcweir 	}
2291cdf0e10cSrcweir }
2292cdf0e10cSrcweir 
2293cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
2294cdf0e10cSrcweir void SdXMLCaptionShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
2295cdf0e10cSrcweir {
2296cdf0e10cSrcweir 	if( XML_NAMESPACE_DRAW == nPrefix )
2297cdf0e10cSrcweir 	{
2298cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_CAPTION_POINT_X ) )
2299cdf0e10cSrcweir 		{
2300cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(maCaptionPoint.X, rValue);
2301cdf0e10cSrcweir 			return;
2302cdf0e10cSrcweir 		}
2303cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_CAPTION_POINT_Y ) )
2304cdf0e10cSrcweir 		{
2305cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(maCaptionPoint.Y, rValue);
2306cdf0e10cSrcweir 			return;
2307cdf0e10cSrcweir 		}
2308cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_CORNER_RADIUS ) )
2309cdf0e10cSrcweir 		{
2310cdf0e10cSrcweir 			GetImport().GetMM100UnitConverter().convertMeasure(mnRadius, rValue);
2311cdf0e10cSrcweir 			return;
2312cdf0e10cSrcweir 		}
2313cdf0e10cSrcweir 	}
2314cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2315cdf0e10cSrcweir }
2316cdf0e10cSrcweir 
2317cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2318cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2319cdf0e10cSrcweir 
2320cdf0e10cSrcweir TYPEINIT1( SdXMLGraphicObjectShapeContext, SdXMLShapeContext );
2321cdf0e10cSrcweir 
2322cdf0e10cSrcweir SdXMLGraphicObjectShapeContext::SdXMLGraphicObjectShapeContext(
2323cdf0e10cSrcweir 	SvXMLImport& rImport,
2324cdf0e10cSrcweir 	sal_uInt16 nPrfx,
2325cdf0e10cSrcweir 	const OUString& rLocalName,
2326cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2327cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
2328cdf0e10cSrcweir     sal_Bool bTemporaryShape)
2329cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
2330598d8f9fSArmin Le Grand 	maURL(),
2331598d8f9fSArmin Le Grand     mbLateAddToIdentifierMapper(false)
2332cdf0e10cSrcweir {
2333cdf0e10cSrcweir }
2334cdf0e10cSrcweir 
2335cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2336cdf0e10cSrcweir 
2337cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
2338cdf0e10cSrcweir void SdXMLGraphicObjectShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
2339cdf0e10cSrcweir {
2340cdf0e10cSrcweir 	if( XML_NAMESPACE_XLINK == nPrefix )
2341cdf0e10cSrcweir 	{
2342cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_HREF ) )
2343cdf0e10cSrcweir 		{
2344cdf0e10cSrcweir 			maURL = rValue;
2345cdf0e10cSrcweir 			return;
2346cdf0e10cSrcweir 		}
2347cdf0e10cSrcweir 	}
2348cdf0e10cSrcweir 
2349cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2350cdf0e10cSrcweir }
2351cdf0e10cSrcweir 
2352cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2353cdf0e10cSrcweir 
2354cdf0e10cSrcweir void SdXMLGraphicObjectShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& )
2355cdf0e10cSrcweir {
2356cdf0e10cSrcweir 	// create graphic object shape
2357cdf0e10cSrcweir 	const char *pService;
2358cdf0e10cSrcweir 
2359cdf0e10cSrcweir 	if( IsXMLToken( maPresentationClass, XML_GRAPHIC ) && GetImport().GetShapeImport()->IsPresentationShapesSupported() )
2360cdf0e10cSrcweir 	{
2361cdf0e10cSrcweir 		pService = "com.sun.star.presentation.GraphicObjectShape";
2362cdf0e10cSrcweir 	}
2363cdf0e10cSrcweir 	else
2364cdf0e10cSrcweir 	{
2365cdf0e10cSrcweir 		pService = "com.sun.star.drawing.GraphicObjectShape";
2366cdf0e10cSrcweir 	}
2367cdf0e10cSrcweir 
2368cdf0e10cSrcweir 	AddShape( pService );
2369cdf0e10cSrcweir 
2370cdf0e10cSrcweir 	if(mxShape.is())
2371cdf0e10cSrcweir 	{
2372cdf0e10cSrcweir 		SetStyle();
2373cdf0e10cSrcweir 		SetLayer();
2374cdf0e10cSrcweir 
2375cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xPropset(mxShape, uno::UNO_QUERY);
2376cdf0e10cSrcweir 		if(xPropset.is())
2377cdf0e10cSrcweir 		{
2378cdf0e10cSrcweir 			// since OOo 1.x had no line or fill style for graphics, but may create
2379cdf0e10cSrcweir 			// documents with them, we have to override them here
2380cdf0e10cSrcweir 			sal_Int32 nUPD, nBuildId;
2381cdf0e10cSrcweir 			if( GetImport().getBuildIds( nUPD, nBuildId ) && (nUPD == 645) ) try
2382cdf0e10cSrcweir 			{
2383cdf0e10cSrcweir 				xPropset->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle")), Any( FillStyle_NONE ) );
2384cdf0e10cSrcweir 				xPropset->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("LineStyle")), Any( LineStyle_NONE ) );
2385cdf0e10cSrcweir 			}
2386cdf0e10cSrcweir 			catch( Exception& )
2387cdf0e10cSrcweir 			{
2388cdf0e10cSrcweir 			}
2389cdf0e10cSrcweir 
2390cdf0e10cSrcweir 			uno::Reference< beans::XPropertySetInfo > xPropsInfo( xPropset->getPropertySetInfo() );
2391cdf0e10cSrcweir 			if( xPropsInfo.is() && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
2392cdf0e10cSrcweir 				xPropset->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( mbIsPlaceholder ) );
2393cdf0e10cSrcweir 
2394cdf0e10cSrcweir 			if( !mbIsPlaceholder )
2395cdf0e10cSrcweir 			{
2396cdf0e10cSrcweir 				if( maURL.getLength() )
2397cdf0e10cSrcweir 				{
2398cdf0e10cSrcweir 					uno::Any aAny;
2399cdf0e10cSrcweir 					aAny <<= GetImport().ResolveGraphicObjectURL( maURL, GetImport().isGraphicLoadOnDemandSupported() );
2400cdf0e10cSrcweir 					try
2401cdf0e10cSrcweir 					{
2402cdf0e10cSrcweir 						xPropset->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL") ), aAny );
2403cdf0e10cSrcweir 						xPropset->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL") ), aAny );
2404cdf0e10cSrcweir 					}
2405cdf0e10cSrcweir 					catch (lang::IllegalArgumentException const &)
2406cdf0e10cSrcweir 					{
2407cdf0e10cSrcweir 					}
2408cdf0e10cSrcweir 				}
2409cdf0e10cSrcweir 			}
2410cdf0e10cSrcweir 		}
2411cdf0e10cSrcweir 
2412cdf0e10cSrcweir 		if(mbIsUserTransformed)
2413cdf0e10cSrcweir 		{
2414cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2415cdf0e10cSrcweir 			if(xProps.is())
2416cdf0e10cSrcweir 			{
2417cdf0e10cSrcweir 				uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2418cdf0e10cSrcweir 				if( xPropsInfo.is() )
2419cdf0e10cSrcweir 				{
2420cdf0e10cSrcweir 					if( xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
2421cdf0e10cSrcweir 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) );
2422cdf0e10cSrcweir 				}
2423cdf0e10cSrcweir 			}
2424cdf0e10cSrcweir 		}
2425cdf0e10cSrcweir 
2426cdf0e10cSrcweir 		// set pos, size, shear and rotate
2427cdf0e10cSrcweir 		SetTransformation();
2428cdf0e10cSrcweir 
2429cdf0e10cSrcweir 		SdXMLShapeContext::StartElement(mxAttrList);
2430cdf0e10cSrcweir 	}
2431cdf0e10cSrcweir }
2432cdf0e10cSrcweir 
2433cdf0e10cSrcweir void SdXMLGraphicObjectShapeContext::EndElement()
2434cdf0e10cSrcweir {
2435cdf0e10cSrcweir 	if( mxBase64Stream.is() )
2436cdf0e10cSrcweir 	{
2437cdf0e10cSrcweir 		OUString sURL( GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream ) );
2438cdf0e10cSrcweir 		if( sURL.getLength() )
2439cdf0e10cSrcweir 		{
2440cdf0e10cSrcweir 			try
2441cdf0e10cSrcweir 			{
2442cdf0e10cSrcweir 				uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2443cdf0e10cSrcweir 				if(xProps.is())
2444cdf0e10cSrcweir 				{
2445cdf0e10cSrcweir 					const uno::Any aAny( uno::makeAny( sURL ) );
2446cdf0e10cSrcweir 					xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL") ), aAny );
2447cdf0e10cSrcweir 					xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL") ), aAny );
2448cdf0e10cSrcweir 				}
2449cdf0e10cSrcweir 			}
2450cdf0e10cSrcweir 			catch (lang::IllegalArgumentException const &)
2451cdf0e10cSrcweir 			{
2452cdf0e10cSrcweir 			}
2453cdf0e10cSrcweir 		}
2454cdf0e10cSrcweir 	}
2455cdf0e10cSrcweir 
2456cdf0e10cSrcweir 	SdXMLShapeContext::EndElement();
2457cdf0e10cSrcweir }
2458cdf0e10cSrcweir 
2459cdf0e10cSrcweir 
2460cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2461cdf0e10cSrcweir 
2462cdf0e10cSrcweir SvXMLImportContext* SdXMLGraphicObjectShapeContext::CreateChildContext(
2463cdf0e10cSrcweir 	sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
2464cdf0e10cSrcweir 	const uno::Reference<xml::sax::XAttributeList>& xAttrList )
2465cdf0e10cSrcweir {
2466cdf0e10cSrcweir 	SvXMLImportContext* pContext = NULL;
2467cdf0e10cSrcweir 
2468cdf0e10cSrcweir 	if( (XML_NAMESPACE_OFFICE == nPrefix) &&
2469cdf0e10cSrcweir 			 xmloff::token::IsXMLToken( rLocalName, xmloff::token::XML_BINARY_DATA ) )
2470cdf0e10cSrcweir 	{
2471cdf0e10cSrcweir 		if( !maURL.getLength() && !mxBase64Stream.is() )
2472cdf0e10cSrcweir 		{
2473cdf0e10cSrcweir 			mxBase64Stream = GetImport().GetStreamForGraphicObjectURLFromBase64();
2474cdf0e10cSrcweir 			if( mxBase64Stream.is() )
2475cdf0e10cSrcweir 				pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
2476cdf0e10cSrcweir 													rLocalName, xAttrList,
2477cdf0e10cSrcweir 													mxBase64Stream );
2478cdf0e10cSrcweir 		}
2479cdf0e10cSrcweir 	}
2480cdf0e10cSrcweir 
2481cdf0e10cSrcweir 	// delegate to parent class if no context could be created
2482cdf0e10cSrcweir 	if ( NULL == pContext )
2483cdf0e10cSrcweir 		pContext = SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName,
2484cdf0e10cSrcweir 														 xAttrList);
2485cdf0e10cSrcweir 
2486cdf0e10cSrcweir 	return pContext;
2487cdf0e10cSrcweir }
2488cdf0e10cSrcweir 
2489cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2490cdf0e10cSrcweir 
2491cdf0e10cSrcweir SdXMLGraphicObjectShapeContext::~SdXMLGraphicObjectShapeContext()
2492cdf0e10cSrcweir {
2493cdf0e10cSrcweir 
2494cdf0e10cSrcweir }
2495cdf0e10cSrcweir 
2496cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2497cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2498cdf0e10cSrcweir 
2499cdf0e10cSrcweir TYPEINIT1( SdXMLChartShapeContext, SdXMLShapeContext );
2500cdf0e10cSrcweir 
2501cdf0e10cSrcweir SdXMLChartShapeContext::SdXMLChartShapeContext(
2502cdf0e10cSrcweir 	SvXMLImport& rImport,
2503cdf0e10cSrcweir 	sal_uInt16 nPrfx,
2504cdf0e10cSrcweir 	const OUString& rLocalName,
2505cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2506cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
2507cdf0e10cSrcweir     sal_Bool bTemporaryShape)
2508cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
2509cdf0e10cSrcweir 	mpChartContext( NULL )
2510cdf0e10cSrcweir {
2511cdf0e10cSrcweir }
2512cdf0e10cSrcweir 
2513cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2514cdf0e10cSrcweir 
2515cdf0e10cSrcweir SdXMLChartShapeContext::~SdXMLChartShapeContext()
2516cdf0e10cSrcweir {
2517cdf0e10cSrcweir 	if( mpChartContext )
2518cdf0e10cSrcweir 		delete mpChartContext;
2519cdf0e10cSrcweir }
2520cdf0e10cSrcweir 
2521cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2522cdf0e10cSrcweir 
2523cdf0e10cSrcweir void SdXMLChartShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList)
2524cdf0e10cSrcweir {
2525cdf0e10cSrcweir 	const sal_Bool bIsPresentation = isPresentationShape();
2526cdf0e10cSrcweir 
2527cdf0e10cSrcweir 	AddShape( bIsPresentation ? "com.sun.star.presentation.ChartShape" : "com.sun.star.drawing.OLE2Shape" );
2528cdf0e10cSrcweir 
2529cdf0e10cSrcweir 	if(mxShape.is())
2530cdf0e10cSrcweir 	{
2531cdf0e10cSrcweir 		SetStyle();
2532cdf0e10cSrcweir 		SetLayer();
2533cdf0e10cSrcweir 
2534cdf0e10cSrcweir 		if( !mbIsPlaceholder )
2535cdf0e10cSrcweir 		{
2536cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2537cdf0e10cSrcweir 			if(xProps.is())
2538cdf0e10cSrcweir 			{
2539cdf0e10cSrcweir 				uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2540cdf0e10cSrcweir 				if( xPropsInfo.is() && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
2541cdf0e10cSrcweir 					xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) );
2542cdf0e10cSrcweir 
2543cdf0e10cSrcweir 				uno::Any aAny;
2544cdf0e10cSrcweir 
2545cdf0e10cSrcweir 				const OUString aCLSID( RTL_CONSTASCII_USTRINGPARAM("12DCAE26-281F-416F-a234-c3086127382e"));
2546cdf0e10cSrcweir 
2547cdf0e10cSrcweir 				aAny <<= aCLSID;
2548cdf0e10cSrcweir 				xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID") ), aAny );
2549cdf0e10cSrcweir 
2550cdf0e10cSrcweir #ifndef SVX_LIGHT
2551cdf0e10cSrcweir 				aAny = xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) );
2552cdf0e10cSrcweir 				uno::Reference< frame::XModel > xChartModel;
2553cdf0e10cSrcweir 				if( aAny >>= xChartModel )
2554cdf0e10cSrcweir 				{
2555cdf0e10cSrcweir 					mpChartContext = GetImport().GetChartImport()->CreateChartContext( GetImport(), XML_NAMESPACE_SVG, GetXMLToken(XML_CHART), xChartModel, xAttrList );
2556cdf0e10cSrcweir 				}
2557cdf0e10cSrcweir #endif
2558cdf0e10cSrcweir 			}
2559cdf0e10cSrcweir 		}
2560cdf0e10cSrcweir 
2561cdf0e10cSrcweir 		if(mbIsUserTransformed)
2562cdf0e10cSrcweir 		{
2563cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2564cdf0e10cSrcweir 			if(xProps.is())
2565cdf0e10cSrcweir 			{
2566cdf0e10cSrcweir 				uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2567cdf0e10cSrcweir 				if( xPropsInfo.is() )
2568cdf0e10cSrcweir 				{
2569cdf0e10cSrcweir 					if( xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
2570cdf0e10cSrcweir 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) );
2571cdf0e10cSrcweir 				}
2572cdf0e10cSrcweir 			}
2573cdf0e10cSrcweir 		}
2574cdf0e10cSrcweir 
2575cdf0e10cSrcweir 
2576cdf0e10cSrcweir 		// set pos, size, shear and rotate
2577cdf0e10cSrcweir 		SetTransformation();
2578cdf0e10cSrcweir 
2579cdf0e10cSrcweir 		SdXMLShapeContext::StartElement(xAttrList);
2580cdf0e10cSrcweir 
2581cdf0e10cSrcweir 		if( mpChartContext )
2582cdf0e10cSrcweir 			mpChartContext->StartElement( xAttrList );
2583cdf0e10cSrcweir 	}
2584cdf0e10cSrcweir }
2585cdf0e10cSrcweir 
2586cdf0e10cSrcweir void SdXMLChartShapeContext::EndElement()
2587cdf0e10cSrcweir {
2588cdf0e10cSrcweir 	if( mpChartContext )
2589cdf0e10cSrcweir 		mpChartContext->EndElement();
2590cdf0e10cSrcweir 
2591cdf0e10cSrcweir 	SdXMLShapeContext::EndElement();
2592cdf0e10cSrcweir }
2593cdf0e10cSrcweir 
2594cdf0e10cSrcweir void SdXMLChartShapeContext::Characters( const ::rtl::OUString& rChars )
2595cdf0e10cSrcweir {
2596cdf0e10cSrcweir 	if( mpChartContext )
2597cdf0e10cSrcweir 		mpChartContext->Characters( rChars );
2598cdf0e10cSrcweir }
2599cdf0e10cSrcweir 
2600cdf0e10cSrcweir SvXMLImportContext * SdXMLChartShapeContext::CreateChildContext( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
2601cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
2602cdf0e10cSrcweir {
2603cdf0e10cSrcweir 	if( mpChartContext )
2604cdf0e10cSrcweir 		return mpChartContext->CreateChildContext( nPrefix, rLocalName, xAttrList );
2605cdf0e10cSrcweir 
2606cdf0e10cSrcweir 	return NULL;
2607cdf0e10cSrcweir }
2608cdf0e10cSrcweir 
2609cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2610cdf0e10cSrcweir 
2611cdf0e10cSrcweir TYPEINIT1( SdXMLObjectShapeContext, SdXMLShapeContext );
2612cdf0e10cSrcweir 
2613cdf0e10cSrcweir SdXMLObjectShapeContext::SdXMLObjectShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
2614cdf0e10cSrcweir 		const rtl::OUString& rLocalName,
2615cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2616cdf0e10cSrcweir 		com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
2617cdf0e10cSrcweir         sal_Bool bTemporaryShape)
2618cdf0e10cSrcweir : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
2619cdf0e10cSrcweir {
2620cdf0e10cSrcweir }
2621cdf0e10cSrcweir 
2622cdf0e10cSrcweir SdXMLObjectShapeContext::~SdXMLObjectShapeContext()
2623cdf0e10cSrcweir {
2624cdf0e10cSrcweir }
2625cdf0e10cSrcweir 
2626cdf0e10cSrcweir void SdXMLObjectShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& )
2627cdf0e10cSrcweir {
2628cdf0e10cSrcweir 	// #96717# in theorie, if we don't have a url we shouldn't even
2629cdf0e10cSrcweir 	// export this ole shape. But practical its to risky right now
2630cdf0e10cSrcweir 	// to change this so we better dispose this on load
2631cdf0e10cSrcweir 	//if( !mbIsPlaceholder && ImpIsEmptyURL(maHref) )
2632cdf0e10cSrcweir 	//	return;
2633cdf0e10cSrcweir 
2634cdf0e10cSrcweir 	// #100592# this BugFix prevents that a shape is created. CL
2635cdf0e10cSrcweir 	// is thinking about an alternative.
2636cdf0e10cSrcweir     // #i13140# Check for more than empty string in maHref, there are
2637cdf0e10cSrcweir     // other possibilities that maHref results in empty container
2638cdf0e10cSrcweir     // storage names
2639cdf0e10cSrcweir 	if( !(GetImport().getImportFlags() & IMPORT_EMBEDDED) && !mbIsPlaceholder && ImpIsEmptyURL(maHref) )
2640cdf0e10cSrcweir 		return;
2641cdf0e10cSrcweir 
2642cdf0e10cSrcweir 	const char* pService = "com.sun.star.drawing.OLE2Shape";
2643cdf0e10cSrcweir 
2644cdf0e10cSrcweir 	sal_Bool bIsPresShape = maPresentationClass.getLength() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
2645cdf0e10cSrcweir 
2646cdf0e10cSrcweir 	if( bIsPresShape )
2647cdf0e10cSrcweir 	{
2648cdf0e10cSrcweir 		if( IsXMLToken( maPresentationClass, XML_PRESENTATION_CHART ) )
2649cdf0e10cSrcweir 		{
2650cdf0e10cSrcweir 			pService = "com.sun.star.presentation.ChartShape";
2651cdf0e10cSrcweir 		}
2652cdf0e10cSrcweir 		else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_TABLE ) )
2653cdf0e10cSrcweir 		{
2654cdf0e10cSrcweir 			pService = "com.sun.star.presentation.CalcShape";
2655cdf0e10cSrcweir 		}
2656cdf0e10cSrcweir 		else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_OBJECT ) )
2657cdf0e10cSrcweir 		{
2658cdf0e10cSrcweir 			pService = "com.sun.star.presentation.OLE2Shape";
2659cdf0e10cSrcweir 		}
2660cdf0e10cSrcweir 	}
2661cdf0e10cSrcweir 
2662cdf0e10cSrcweir 	AddShape( pService );
2663cdf0e10cSrcweir 
2664cdf0e10cSrcweir 	if( mxShape.is() )
2665cdf0e10cSrcweir 	{
2666cdf0e10cSrcweir 		SetLayer();
2667cdf0e10cSrcweir 
2668cdf0e10cSrcweir 		if(bIsPresShape)
2669cdf0e10cSrcweir 		{
2670cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2671cdf0e10cSrcweir 			if(xProps.is())
2672cdf0e10cSrcweir 			{
2673cdf0e10cSrcweir 				uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
2674cdf0e10cSrcweir 				if( xPropsInfo.is() )
2675cdf0e10cSrcweir 				{
2676cdf0e10cSrcweir 					if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
2677cdf0e10cSrcweir 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) );
2678cdf0e10cSrcweir 
2679cdf0e10cSrcweir 					if( mbIsUserTransformed && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
2680cdf0e10cSrcweir 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) );
2681cdf0e10cSrcweir 				}
2682cdf0e10cSrcweir 			}
2683cdf0e10cSrcweir 		}
2684cdf0e10cSrcweir 
2685cdf0e10cSrcweir 		if( !mbIsPlaceholder && maHref.getLength() )
2686cdf0e10cSrcweir 		{
2687cdf0e10cSrcweir         	uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2688cdf0e10cSrcweir 
2689cdf0e10cSrcweir             if( xProps.is() )
2690cdf0e10cSrcweir         	{
2691cdf0e10cSrcweir 				OUString aPersistName = GetImport().ResolveEmbeddedObjectURL( maHref, maCLSID );
2692cdf0e10cSrcweir 
2693cdf0e10cSrcweir 				if ( GetImport().IsPackageURL( maHref ) )
2694cdf0e10cSrcweir 				{
2695cdf0e10cSrcweir 					const OUString  sURL(RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ));
2696cdf0e10cSrcweir 
2697cdf0e10cSrcweir 					if ( aPersistName.compareTo( sURL, sURL.getLength() ) == 0 )
2698cdf0e10cSrcweir 						aPersistName = aPersistName.copy( sURL.getLength() );
2699cdf0e10cSrcweir 
2700cdf0e10cSrcweir         			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PersistName" ) ),
2701cdf0e10cSrcweir 											  uno::makeAny( aPersistName ) );
2702cdf0e10cSrcweir 				}
2703cdf0e10cSrcweir 				else
2704cdf0e10cSrcweir 				{
2705cdf0e10cSrcweir 					// this is OOo link object
2706cdf0e10cSrcweir 					xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LinkURL" ) ),
2707cdf0e10cSrcweir 											  uno::makeAny( aPersistName ) );
2708cdf0e10cSrcweir 				}
2709cdf0e10cSrcweir 			}
2710cdf0e10cSrcweir 		}
2711cdf0e10cSrcweir 
2712cdf0e10cSrcweir 		// set pos, size, shear and rotate
2713cdf0e10cSrcweir 		SetTransformation();
2714cdf0e10cSrcweir 
2715cdf0e10cSrcweir 		SetStyle();
2716cdf0e10cSrcweir 
2717cdf0e10cSrcweir 		GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
2718cdf0e10cSrcweir 	}
2719cdf0e10cSrcweir }
2720cdf0e10cSrcweir 
2721cdf0e10cSrcweir void SdXMLObjectShapeContext::EndElement()
2722cdf0e10cSrcweir {
2723a5258243SPedro Giffuni     // #i67705#
2724a5258243SPedro Giffuni     const sal_uInt16 nGeneratorVersion(GetImport().getGeneratorVersion());
2725a5258243SPedro Giffuni 
2726a5258243SPedro Giffuni     if(nGeneratorVersion < SvXMLImport::OOo_34x)
2727a5258243SPedro Giffuni     {
2728a5258243SPedro Giffuni         // #i118485#
2729a5258243SPedro Giffuni         // If it's an old file from us written before OOo3.4, we need to correct
2730a5258243SPedro Giffuni         // FillStyle and LineStyle for OLE2 objects. The error was that the old paint
2731a5258243SPedro Giffuni         // implementations just ignored added fill/linestyles completely, thus
2732a5258243SPedro Giffuni         // those objects need to be corrected to not show blue and hairline which
2733a5258243SPedro Giffuni         // always was the default, but would be shown now
2734a5258243SPedro Giffuni 		uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2735a5258243SPedro Giffuni 
2736a5258243SPedro Giffuni         if( xProps.is() )
2737a5258243SPedro Giffuni         {
2738a5258243SPedro Giffuni             xProps->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle")), uno::makeAny(drawing::FillStyle_NONE));
2739a5258243SPedro Giffuni             xProps->setPropertyValue(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LineStyle")), uno::makeAny(drawing::LineStyle_NONE));
2740a5258243SPedro Giffuni         }
2741a5258243SPedro Giffuni     }
2742a5258243SPedro Giffuni 
2743cdf0e10cSrcweir     // #100592#
2744cdf0e10cSrcweir 	if( mxBase64Stream.is() )
2745cdf0e10cSrcweir 	{
2746cdf0e10cSrcweir 		OUString aPersistName( GetImport().ResolveEmbeddedObjectURLFromBase64() );
2747cdf0e10cSrcweir 		const OUString  sURL(RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ));
2748cdf0e10cSrcweir 
2749cdf0e10cSrcweir         aPersistName = aPersistName.copy( sURL.getLength() );
2750cdf0e10cSrcweir 
2751cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
2752cdf0e10cSrcweir 		if( xProps.is() )
2753cdf0e10cSrcweir 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PersistName" ) ), uno::makeAny( aPersistName ) );
2754cdf0e10cSrcweir 	}
2755cdf0e10cSrcweir 
2756cdf0e10cSrcweir 	SdXMLShapeContext::EndElement();
2757cdf0e10cSrcweir }
2758cdf0e10cSrcweir 
2759cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
2760cdf0e10cSrcweir void SdXMLObjectShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
2761cdf0e10cSrcweir {
2762cdf0e10cSrcweir 	switch( nPrefix )
2763cdf0e10cSrcweir 	{
2764cdf0e10cSrcweir 	case XML_NAMESPACE_DRAW:
2765cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_CLASS_ID ) )
2766cdf0e10cSrcweir 		{
2767cdf0e10cSrcweir 			maCLSID = rValue;
2768cdf0e10cSrcweir 			return;
2769cdf0e10cSrcweir 		}
2770cdf0e10cSrcweir 		break;
2771cdf0e10cSrcweir 	case XML_NAMESPACE_XLINK:
2772cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_HREF ) )
2773cdf0e10cSrcweir 		{
2774cdf0e10cSrcweir 			maHref = rValue;
2775cdf0e10cSrcweir 			return;
2776cdf0e10cSrcweir 		}
2777cdf0e10cSrcweir 		break;
2778cdf0e10cSrcweir 	}
2779cdf0e10cSrcweir 
2780cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2781cdf0e10cSrcweir }
2782cdf0e10cSrcweir 
2783cdf0e10cSrcweir SvXMLImportContext* SdXMLObjectShapeContext::CreateChildContext(
2784cdf0e10cSrcweir 	sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
2785cdf0e10cSrcweir 	const uno::Reference<xml::sax::XAttributeList>& xAttrList )
2786cdf0e10cSrcweir {
2787cdf0e10cSrcweir 	// #100592#
2788cdf0e10cSrcweir 	SvXMLImportContext* pContext = NULL;
2789cdf0e10cSrcweir 
2790cdf0e10cSrcweir 	if((XML_NAMESPACE_OFFICE == nPrefix) && IsXMLToken(rLocalName, XML_BINARY_DATA))
2791cdf0e10cSrcweir 	{
2792cdf0e10cSrcweir 		mxBase64Stream = GetImport().GetStreamForEmbeddedObjectURLFromBase64();
2793cdf0e10cSrcweir 		if( mxBase64Stream.is() )
2794cdf0e10cSrcweir 			pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
2795cdf0e10cSrcweir 												rLocalName, xAttrList,
2796cdf0e10cSrcweir 												mxBase64Stream );
2797cdf0e10cSrcweir 	}
2798cdf0e10cSrcweir 	else if( ((XML_NAMESPACE_OFFICE == nPrefix) && IsXMLToken(rLocalName, XML_DOCUMENT)) ||
2799cdf0e10cSrcweir 				((XML_NAMESPACE_MATH == nPrefix) && IsXMLToken(rLocalName, XML_MATH)) )
2800cdf0e10cSrcweir 	{
2801cdf0e10cSrcweir 		XMLEmbeddedObjectImportContext *pEContext =
2802cdf0e10cSrcweir 			new XMLEmbeddedObjectImportContext( GetImport(), nPrefix,
2803cdf0e10cSrcweir 												rLocalName, xAttrList );
2804cdf0e10cSrcweir 		maCLSID = pEContext->GetFilterCLSID();
2805cdf0e10cSrcweir 		if( maCLSID.getLength() != 0 )
2806cdf0e10cSrcweir 		{
2807cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY);
2808cdf0e10cSrcweir 			if( xPropSet.is() )
2809cdf0e10cSrcweir 			{
2810cdf0e10cSrcweir 				xPropSet->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID") ), uno::makeAny( maCLSID ) );
2811cdf0e10cSrcweir 
2812cdf0e10cSrcweir 				uno::Reference< lang::XComponent > xComp;
2813cdf0e10cSrcweir 				xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ) >>= xComp;
2814cdf0e10cSrcweir 				DBG_ASSERT( xComp.is(), "no xModel for own OLE format" );
2815cdf0e10cSrcweir 				pEContext->SetComponent( xComp );
2816cdf0e10cSrcweir 			}
2817cdf0e10cSrcweir 		}
2818cdf0e10cSrcweir 		pContext = pEContext;
2819cdf0e10cSrcweir 	}
2820cdf0e10cSrcweir 
2821cdf0e10cSrcweir 	// delegate to parent class if no context could be created
2822cdf0e10cSrcweir 	if(!pContext)
2823cdf0e10cSrcweir 		pContext = SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
2824cdf0e10cSrcweir 
2825cdf0e10cSrcweir 	return pContext;
2826cdf0e10cSrcweir }
2827cdf0e10cSrcweir 
2828cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2829cdf0e10cSrcweir 
2830cdf0e10cSrcweir TYPEINIT1( SdXMLAppletShapeContext, SdXMLShapeContext );
2831cdf0e10cSrcweir 
2832cdf0e10cSrcweir SdXMLAppletShapeContext::SdXMLAppletShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
2833cdf0e10cSrcweir 		const rtl::OUString& rLocalName,
2834cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
2835cdf0e10cSrcweir 		com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
2836cdf0e10cSrcweir         sal_Bool bTemporaryShape)
2837cdf0e10cSrcweir : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
2838cdf0e10cSrcweir   mbIsScript( sal_False )
2839cdf0e10cSrcweir {
2840cdf0e10cSrcweir }
2841cdf0e10cSrcweir 
2842cdf0e10cSrcweir SdXMLAppletShapeContext::~SdXMLAppletShapeContext()
2843cdf0e10cSrcweir {
2844cdf0e10cSrcweir }
2845cdf0e10cSrcweir 
2846cdf0e10cSrcweir void SdXMLAppletShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& )
2847cdf0e10cSrcweir {
2848cdf0e10cSrcweir 	const char* pService = "com.sun.star.drawing.AppletShape";
2849cdf0e10cSrcweir 	AddShape( pService );
2850cdf0e10cSrcweir 
2851cdf0e10cSrcweir 	if( mxShape.is() )
2852cdf0e10cSrcweir 	{
2853cdf0e10cSrcweir 		SetLayer();
2854cdf0e10cSrcweir 
2855cdf0e10cSrcweir 		// set pos, size, shear and rotate
2856cdf0e10cSrcweir 		SetTransformation();
2857cdf0e10cSrcweir 		GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
2858cdf0e10cSrcweir 	}
2859cdf0e10cSrcweir }
2860cdf0e10cSrcweir 
2861cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
2862cdf0e10cSrcweir void SdXMLAppletShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
2863cdf0e10cSrcweir {
2864cdf0e10cSrcweir 	switch( nPrefix )
2865cdf0e10cSrcweir 	{
2866cdf0e10cSrcweir 	case XML_NAMESPACE_DRAW:
2867cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_APPLET_NAME ) )
2868cdf0e10cSrcweir 		{
2869cdf0e10cSrcweir 			maAppletName = rValue;
2870cdf0e10cSrcweir 			return;
2871cdf0e10cSrcweir 		}
2872cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_CODE ) )
2873cdf0e10cSrcweir 		{
2874cdf0e10cSrcweir 			maAppletCode = rValue;
2875cdf0e10cSrcweir 			return;
2876cdf0e10cSrcweir 		}
2877cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_MAY_SCRIPT ) )
2878cdf0e10cSrcweir 		{
2879cdf0e10cSrcweir 			mbIsScript = IsXMLToken( rValue, XML_TRUE );
2880cdf0e10cSrcweir 			return;
2881cdf0e10cSrcweir 		}
2882cdf0e10cSrcweir 		break;
2883cdf0e10cSrcweir 	case XML_NAMESPACE_XLINK:
2884cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_HREF ) )
2885cdf0e10cSrcweir 		{
2886cdf0e10cSrcweir 			maHref = GetImport().GetAbsoluteReference(rValue);
2887cdf0e10cSrcweir 			return;
2888cdf0e10cSrcweir 		}
2889cdf0e10cSrcweir 		break;
2890cdf0e10cSrcweir 	}
2891cdf0e10cSrcweir 
2892cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
2893cdf0e10cSrcweir }
2894cdf0e10cSrcweir 
2895cdf0e10cSrcweir void SdXMLAppletShapeContext::EndElement()
2896cdf0e10cSrcweir {
2897cdf0e10cSrcweir 	uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
2898cdf0e10cSrcweir 	if( xProps.is() )
2899cdf0e10cSrcweir 	{
2900cdf0e10cSrcweir 		uno::Any aAny;
2901cdf0e10cSrcweir 
2902cdf0e10cSrcweir 		if ( maSize.Width && maSize.Height )
2903cdf0e10cSrcweir 		{
2904cdf0e10cSrcweir 			// the visual area for applet must be set on loading
2905cdf0e10cSrcweir 			awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height );
2906cdf0e10cSrcweir 			aAny <<= aRect;
2907cdf0e10cSrcweir 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) ), aAny );
2908cdf0e10cSrcweir 		}
2909cdf0e10cSrcweir 
2910cdf0e10cSrcweir 		if( maParams.getLength() )
2911cdf0e10cSrcweir 		{
2912cdf0e10cSrcweir 			aAny <<= maParams;
2913cdf0e10cSrcweir 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCommands" ) ), aAny );
2914cdf0e10cSrcweir 		}
2915cdf0e10cSrcweir 
2916cdf0e10cSrcweir 		if( maHref.getLength() )
2917cdf0e10cSrcweir 		{
2918cdf0e10cSrcweir 			aAny <<= maHref;
2919cdf0e10cSrcweir 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCodeBase" ) ), aAny );
2920cdf0e10cSrcweir 		}
2921cdf0e10cSrcweir 
2922cdf0e10cSrcweir 		if( maAppletName.getLength() )
2923cdf0e10cSrcweir 		{
2924cdf0e10cSrcweir 			aAny <<= maAppletName;
2925cdf0e10cSrcweir 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletName" ) ), aAny );
2926cdf0e10cSrcweir 		}
2927cdf0e10cSrcweir 
2928cdf0e10cSrcweir 		if( mbIsScript )
2929cdf0e10cSrcweir 		{
2930cdf0e10cSrcweir 			aAny <<= mbIsScript;
2931cdf0e10cSrcweir 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletIsScript" ) ), aAny );
2932cdf0e10cSrcweir 
2933cdf0e10cSrcweir 		}
2934cdf0e10cSrcweir 
2935cdf0e10cSrcweir 		if( maAppletCode.getLength() )
2936cdf0e10cSrcweir 		{
2937cdf0e10cSrcweir 			aAny <<= maAppletCode;
2938cdf0e10cSrcweir 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCode" ) ), aAny );
2939cdf0e10cSrcweir 		}
2940cdf0e10cSrcweir 
2941cdf0e10cSrcweir         aAny <<= ::rtl::OUString( GetImport().GetDocumentBase() );
2942cdf0e10cSrcweir         xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletDocBase" ) ), aAny );
2943cdf0e10cSrcweir 
2944cdf0e10cSrcweir 		SetThumbnail();
2945cdf0e10cSrcweir 	}
2946cdf0e10cSrcweir 
2947cdf0e10cSrcweir 	SdXMLShapeContext::EndElement();
2948cdf0e10cSrcweir }
2949cdf0e10cSrcweir 
2950cdf0e10cSrcweir SvXMLImportContext * SdXMLAppletShapeContext::CreateChildContext( sal_uInt16 p_nPrefix, const ::rtl::OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
2951cdf0e10cSrcweir {
2952cdf0e10cSrcweir 	if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_PARAM ) )
2953cdf0e10cSrcweir 	{
2954cdf0e10cSrcweir 		OUString aParamName, aParamValue;
2955cdf0e10cSrcweir 		const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
2956cdf0e10cSrcweir 		// now parse the attribute list and look for draw:name and draw:value
2957cdf0e10cSrcweir 		for(sal_Int16 a(0); a < nAttrCount; a++)
2958cdf0e10cSrcweir 		{
2959cdf0e10cSrcweir 			const OUString& rAttrName = xAttrList->getNameByIndex(a);
2960cdf0e10cSrcweir 			OUString aLocalName;
2961cdf0e10cSrcweir 			sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
2962cdf0e10cSrcweir 			const OUString aValue( xAttrList->getValueByIndex(a) );
2963cdf0e10cSrcweir 
2964cdf0e10cSrcweir 			if( nPrefix == XML_NAMESPACE_DRAW )
2965cdf0e10cSrcweir 			{
2966cdf0e10cSrcweir 				if( IsXMLToken( aLocalName, XML_NAME ) )
2967cdf0e10cSrcweir 				{
2968cdf0e10cSrcweir 					aParamName = aValue;
2969cdf0e10cSrcweir 				}
2970cdf0e10cSrcweir 				else if( IsXMLToken( aLocalName, XML_VALUE ) )
2971cdf0e10cSrcweir 				{
2972cdf0e10cSrcweir 					aParamValue = aValue;
2973cdf0e10cSrcweir 				}
2974cdf0e10cSrcweir 			}
2975cdf0e10cSrcweir 		}
2976cdf0e10cSrcweir 
2977cdf0e10cSrcweir 		if( aParamName.getLength() )
2978cdf0e10cSrcweir 		{
2979cdf0e10cSrcweir 			sal_Int32 nIndex = maParams.getLength();
2980cdf0e10cSrcweir 			maParams.realloc( nIndex + 1 );
2981cdf0e10cSrcweir 			maParams[nIndex].Name = aParamName;
2982cdf0e10cSrcweir 			maParams[nIndex].Handle = -1;
2983cdf0e10cSrcweir 			maParams[nIndex].Value <<= aParamValue;
2984cdf0e10cSrcweir 			maParams[nIndex].State = beans::PropertyState_DIRECT_VALUE;
2985cdf0e10cSrcweir 		}
2986cdf0e10cSrcweir 
2987cdf0e10cSrcweir 		return new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName );
2988cdf0e10cSrcweir 	}
2989cdf0e10cSrcweir 
2990cdf0e10cSrcweir 	return SdXMLShapeContext::CreateChildContext( p_nPrefix, rLocalName, xAttrList );
2991cdf0e10cSrcweir }
2992cdf0e10cSrcweir 
2993cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
2994cdf0e10cSrcweir 
2995cdf0e10cSrcweir TYPEINIT1( SdXMLPluginShapeContext, SdXMLShapeContext );
2996cdf0e10cSrcweir 
2997cdf0e10cSrcweir SdXMLPluginShapeContext::SdXMLPluginShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
2998cdf0e10cSrcweir 		const rtl::OUString& rLocalName,
2999cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
3000cdf0e10cSrcweir 		com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
3001cdf0e10cSrcweir         sal_Bool bTemporaryShape) :
3002cdf0e10cSrcweir SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
3003cdf0e10cSrcweir mbMedia( false )
3004cdf0e10cSrcweir {
3005cdf0e10cSrcweir }
3006cdf0e10cSrcweir 
3007cdf0e10cSrcweir SdXMLPluginShapeContext::~SdXMLPluginShapeContext()
3008cdf0e10cSrcweir {
3009cdf0e10cSrcweir }
3010cdf0e10cSrcweir 
3011cdf0e10cSrcweir void SdXMLPluginShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList)
3012cdf0e10cSrcweir {
3013cdf0e10cSrcweir 	// watch for MimeType attribute to see if we have a media object
3014cdf0e10cSrcweir 	for( sal_Int16 n = 0, nAttrCount = ( xAttrList.is() ? xAttrList->getLength() : 0 ); n < nAttrCount; ++n )
3015cdf0e10cSrcweir 	{
3016cdf0e10cSrcweir 		OUString 	aLocalName;
3017cdf0e10cSrcweir 		sal_uInt16 	nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( n ), &aLocalName );
3018cdf0e10cSrcweir 
3019cdf0e10cSrcweir 		if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( aLocalName, XML_MIME_TYPE ) )
3020cdf0e10cSrcweir 		{
3021cdf0e10cSrcweir 			if( 0 == xAttrList->getValueByIndex( n ).compareToAscii( "application/vnd.sun.star.media" ) )
3022cdf0e10cSrcweir 				mbMedia = true;
3023cdf0e10cSrcweir 
3024cdf0e10cSrcweir 			// leave this loop
3025cdf0e10cSrcweir 			n = nAttrCount - 1;
3026cdf0e10cSrcweir 		}
3027cdf0e10cSrcweir 	}
3028cdf0e10cSrcweir 
3029cdf0e10cSrcweir 	const char* pService;
3030cdf0e10cSrcweir 
3031cdf0e10cSrcweir 	sal_Bool bIsPresShape = sal_False;
3032cdf0e10cSrcweir 
3033cdf0e10cSrcweir 	if( mbMedia )
3034cdf0e10cSrcweir 	{
3035cdf0e10cSrcweir 		pService = "com.sun.star.drawing.MediaShape";
3036cdf0e10cSrcweir 
3037cdf0e10cSrcweir 		bIsPresShape = maPresentationClass.getLength() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
3038cdf0e10cSrcweir 		if( bIsPresShape )
3039cdf0e10cSrcweir 		{
3040cdf0e10cSrcweir 			if( IsXMLToken( maPresentationClass, XML_PRESENTATION_OBJECT ) )
3041cdf0e10cSrcweir 			{
3042cdf0e10cSrcweir 				pService = "com.sun.star.presentation.MediaShape";
3043cdf0e10cSrcweir 			}
3044cdf0e10cSrcweir 		}
3045cdf0e10cSrcweir 	}
3046cdf0e10cSrcweir 	else
3047cdf0e10cSrcweir 		pService = "com.sun.star.drawing.PluginShape";
3048cdf0e10cSrcweir 
3049cdf0e10cSrcweir 	AddShape( pService );
3050cdf0e10cSrcweir 
3051cdf0e10cSrcweir 	if( mxShape.is() )
3052cdf0e10cSrcweir 	{
3053cdf0e10cSrcweir 		SetLayer();
3054cdf0e10cSrcweir 
3055cdf0e10cSrcweir 		if(bIsPresShape)
3056cdf0e10cSrcweir 		{
3057cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3058cdf0e10cSrcweir 			if(xProps.is())
3059cdf0e10cSrcweir 			{
3060cdf0e10cSrcweir 				uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
3061cdf0e10cSrcweir 				if( xPropsInfo.is() )
3062cdf0e10cSrcweir 				{
3063cdf0e10cSrcweir 					if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
3064cdf0e10cSrcweir 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) );
3065cdf0e10cSrcweir 
3066cdf0e10cSrcweir 					if( mbIsUserTransformed && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
3067cdf0e10cSrcweir 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) );
3068cdf0e10cSrcweir 				}
3069cdf0e10cSrcweir 			}
3070cdf0e10cSrcweir 		}
3071cdf0e10cSrcweir 
3072cdf0e10cSrcweir 		// set pos, size, shear and rotate
3073cdf0e10cSrcweir 		SetTransformation();
3074cdf0e10cSrcweir 		GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
3075cdf0e10cSrcweir 	}
3076cdf0e10cSrcweir }
3077cdf0e10cSrcweir 
3078cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
3079cdf0e10cSrcweir void SdXMLPluginShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
3080cdf0e10cSrcweir {
3081cdf0e10cSrcweir 	switch( nPrefix )
3082cdf0e10cSrcweir 	{
3083cdf0e10cSrcweir 	case XML_NAMESPACE_DRAW:
3084cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_MIME_TYPE ) )
3085cdf0e10cSrcweir 		{
3086cdf0e10cSrcweir 			maMimeType = rValue;
3087cdf0e10cSrcweir 			return;
3088cdf0e10cSrcweir 		}
3089cdf0e10cSrcweir 		break;
3090cdf0e10cSrcweir 	case XML_NAMESPACE_XLINK:
3091cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_HREF ) )
3092cdf0e10cSrcweir 		{
3093cdf0e10cSrcweir 			maHref = GetImport().GetAbsoluteReference(rValue);
3094cdf0e10cSrcweir 			return;
3095cdf0e10cSrcweir 		}
3096cdf0e10cSrcweir 		break;
3097cdf0e10cSrcweir 	}
3098cdf0e10cSrcweir 
3099cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
3100cdf0e10cSrcweir }
3101cdf0e10cSrcweir 
3102cdf0e10cSrcweir void SdXMLPluginShapeContext::EndElement()
3103cdf0e10cSrcweir {
3104cdf0e10cSrcweir 	uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3105cdf0e10cSrcweir 
3106cdf0e10cSrcweir 	if( xProps.is() )
3107cdf0e10cSrcweir 	{
3108cdf0e10cSrcweir 		uno::Any aAny;
3109cdf0e10cSrcweir 
3110cdf0e10cSrcweir 		if ( maSize.Width && maSize.Height )
3111cdf0e10cSrcweir 		{
3112cdf0e10cSrcweir 			const rtl::OUString sVisibleArea( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) );
3113cdf0e10cSrcweir 			uno::Reference< beans::XPropertySetInfo > aXPropSetInfo( xProps->getPropertySetInfo() );
3114cdf0e10cSrcweir             if ( !aXPropSetInfo.is() || aXPropSetInfo->hasPropertyByName( sVisibleArea ) )
3115cdf0e10cSrcweir 			{
3116cdf0e10cSrcweir 				// the visual area for a plugin must be set on loading
3117cdf0e10cSrcweir 				awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height );
3118cdf0e10cSrcweir 				aAny <<= aRect;
3119cdf0e10cSrcweir 				xProps->setPropertyValue( sVisibleArea, aAny );
3120cdf0e10cSrcweir 			}
3121cdf0e10cSrcweir 		}
3122cdf0e10cSrcweir 
3123cdf0e10cSrcweir 		if( !mbMedia )
3124cdf0e10cSrcweir 		{
3125cdf0e10cSrcweir 			// in case we have a plugin object
3126cdf0e10cSrcweir 			if( maParams.getLength() )
3127cdf0e10cSrcweir 			{
3128cdf0e10cSrcweir 				aAny <<= maParams;
3129cdf0e10cSrcweir 				xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginCommands" ) ), aAny );
3130cdf0e10cSrcweir 			}
3131cdf0e10cSrcweir 
3132cdf0e10cSrcweir 			if( maMimeType.getLength() )
3133cdf0e10cSrcweir 			{
3134cdf0e10cSrcweir 				aAny <<= maMimeType;
3135cdf0e10cSrcweir 				xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginMimeType" ) ), aAny );
3136cdf0e10cSrcweir 			}
3137cdf0e10cSrcweir 
3138cdf0e10cSrcweir 			if( maHref.getLength() )
3139cdf0e10cSrcweir 			{
3140cdf0e10cSrcweir 				aAny <<= maHref;
3141cdf0e10cSrcweir 				xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginURL" ) ), aAny );
3142cdf0e10cSrcweir 			}
3143cdf0e10cSrcweir 		}
3144cdf0e10cSrcweir 		else
3145cdf0e10cSrcweir 		{
3146cdf0e10cSrcweir 			// in case we have a media object
3147cdf0e10cSrcweir 
3148cdf0e10cSrcweir 			OUString sTempRef;
3149cdf0e10cSrcweir 
3150cdf0e10cSrcweir 			// check for package URL
3151cdf0e10cSrcweir 			if( GetImport().IsPackageURL( maHref ) )
3152cdf0e10cSrcweir 			{
3153cdf0e10cSrcweir 			    sTempRef = OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.Package:" ) );
3154cdf0e10cSrcweir 			}
3155cdf0e10cSrcweir 
3156cdf0e10cSrcweir 			sTempRef += maHref;
3157cdf0e10cSrcweir 
3158cdf0e10cSrcweir 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaURL" ) ), uno::makeAny( sTempRef ) );
3159cdf0e10cSrcweir 
3160cdf0e10cSrcweir 			for( sal_Int32 nParam = 0; nParam < maParams.getLength(); ++nParam )
3161cdf0e10cSrcweir 			{
3162cdf0e10cSrcweir 				const OUString& rName = maParams[ nParam ].Name;
3163cdf0e10cSrcweir 
3164cdf0e10cSrcweir 				if( 0 == rName.compareToAscii( "Loop" ) )
3165cdf0e10cSrcweir 				{
3166cdf0e10cSrcweir 					OUString aValueStr;
3167cdf0e10cSrcweir 					maParams[ nParam ].Value >>= aValueStr;
3168cdf0e10cSrcweir 					xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Loop" ) ),
3169cdf0e10cSrcweir 						uno::makeAny( static_cast< sal_Bool >( 0 == aValueStr.compareToAscii( "true" ) ) ) );
3170cdf0e10cSrcweir 				}
3171cdf0e10cSrcweir 				else if( 0 == rName.compareToAscii( "Mute" ) )
3172cdf0e10cSrcweir 				{
3173cdf0e10cSrcweir 					OUString aValueStr;
3174cdf0e10cSrcweir 					maParams[ nParam ].Value >>= aValueStr;
3175cdf0e10cSrcweir 					xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Mute" ) ),
3176cdf0e10cSrcweir 						uno::makeAny( static_cast< sal_Bool >( 0 == aValueStr.compareToAscii( "true" ) ) ) );
3177cdf0e10cSrcweir 				}
3178cdf0e10cSrcweir 				else if( 0 == rName.compareToAscii( "VolumeDB" ) )
3179cdf0e10cSrcweir 				{
3180cdf0e10cSrcweir 					OUString aValueStr;
3181cdf0e10cSrcweir 					maParams[ nParam ].Value >>= aValueStr;
3182cdf0e10cSrcweir 					xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VolumeDB" ) ),
3183cdf0e10cSrcweir 					                            uno::makeAny( static_cast< sal_Int16 >( aValueStr.toInt32() ) ) );
3184cdf0e10cSrcweir 				}
3185cdf0e10cSrcweir 				else if( 0 == rName.compareToAscii( "Zoom" ) )
3186cdf0e10cSrcweir 				{
3187cdf0e10cSrcweir 					OUString 			aZoomStr;
3188cdf0e10cSrcweir 					media::ZoomLevel	eZoomLevel;
3189cdf0e10cSrcweir 
3190cdf0e10cSrcweir 					maParams[ nParam ].Value >>= aZoomStr;
3191cdf0e10cSrcweir 
3192cdf0e10cSrcweir 					if( 0 == aZoomStr.compareToAscii( "25%" ) )
3193cdf0e10cSrcweir 						eZoomLevel = media::ZoomLevel_ZOOM_1_TO_4;
3194cdf0e10cSrcweir 					else if( 0 == aZoomStr.compareToAscii( "50%" ) )
3195cdf0e10cSrcweir 						eZoomLevel = media::ZoomLevel_ZOOM_1_TO_2;
3196cdf0e10cSrcweir 					else if( 0 == aZoomStr.compareToAscii( "100%" ) )
3197cdf0e10cSrcweir 						eZoomLevel = media::ZoomLevel_ORIGINAL;
3198cdf0e10cSrcweir 					else if( 0 == aZoomStr.compareToAscii( "200%" ) )
3199cdf0e10cSrcweir 						eZoomLevel = media::ZoomLevel_ZOOM_2_TO_1;
3200cdf0e10cSrcweir 					else if( 0 == aZoomStr.compareToAscii( "400%" ) )
3201cdf0e10cSrcweir 						eZoomLevel = media::ZoomLevel_ZOOM_4_TO_1;
3202cdf0e10cSrcweir 					else if( 0 == aZoomStr.compareToAscii( "fit" ) )
3203cdf0e10cSrcweir 						eZoomLevel = media::ZoomLevel_FIT_TO_WINDOW;
3204cdf0e10cSrcweir 					else if( 0 == aZoomStr.compareToAscii( "fixedfit" ) )
3205cdf0e10cSrcweir 						eZoomLevel = media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT;
3206cdf0e10cSrcweir 					else if( 0 == aZoomStr.compareToAscii( "fullscreen" ) )
3207cdf0e10cSrcweir 						eZoomLevel = media::ZoomLevel_FULLSCREEN;
3208cdf0e10cSrcweir 					else
3209cdf0e10cSrcweir 						eZoomLevel = media::ZoomLevel_NOT_AVAILABLE;
3210cdf0e10cSrcweir 
3211cdf0e10cSrcweir 					xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Zoom" ) ), uno::makeAny( eZoomLevel ) );
3212cdf0e10cSrcweir 				}
3213cdf0e10cSrcweir 			}
3214cdf0e10cSrcweir 		}
3215cdf0e10cSrcweir 
3216cdf0e10cSrcweir 		SetThumbnail();
3217cdf0e10cSrcweir 	}
3218cdf0e10cSrcweir 
3219cdf0e10cSrcweir 	SdXMLShapeContext::EndElement();
3220cdf0e10cSrcweir }
3221cdf0e10cSrcweir 
3222cdf0e10cSrcweir SvXMLImportContext * SdXMLPluginShapeContext::CreateChildContext( sal_uInt16 p_nPrefix, const ::rtl::OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
3223cdf0e10cSrcweir {
3224cdf0e10cSrcweir 	if( p_nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( rLocalName, XML_PARAM ) )
3225cdf0e10cSrcweir 	{
3226cdf0e10cSrcweir 		OUString aParamName, aParamValue;
3227cdf0e10cSrcweir 		const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
3228cdf0e10cSrcweir 		// now parse the attribute list and look for draw:name and draw:value
3229cdf0e10cSrcweir 		for(sal_Int16 a(0); a < nAttrCount; a++)
3230cdf0e10cSrcweir 		{
3231cdf0e10cSrcweir 			const OUString& rAttrName = xAttrList->getNameByIndex(a);
3232cdf0e10cSrcweir 			OUString aLocalName;
3233cdf0e10cSrcweir 			sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
3234cdf0e10cSrcweir 			const OUString aValue( xAttrList->getValueByIndex(a) );
3235cdf0e10cSrcweir 
3236cdf0e10cSrcweir 			if( nPrefix == XML_NAMESPACE_DRAW )
3237cdf0e10cSrcweir 			{
3238cdf0e10cSrcweir 				if( IsXMLToken( aLocalName, XML_NAME ) )
3239cdf0e10cSrcweir 				{
3240cdf0e10cSrcweir 					aParamName = aValue;
3241cdf0e10cSrcweir 				}
3242cdf0e10cSrcweir 				else if( IsXMLToken( aLocalName, XML_VALUE ) )
3243cdf0e10cSrcweir 				{
3244cdf0e10cSrcweir 					aParamValue = aValue;
3245cdf0e10cSrcweir 				}
3246cdf0e10cSrcweir 			}
3247cdf0e10cSrcweir 
3248cdf0e10cSrcweir 			if( aParamName.getLength() )
3249cdf0e10cSrcweir 			{
3250cdf0e10cSrcweir 				sal_Int32 nIndex = maParams.getLength();
3251cdf0e10cSrcweir 				maParams.realloc( nIndex + 1 );
3252cdf0e10cSrcweir 				maParams[nIndex].Name = aParamName;
3253cdf0e10cSrcweir 				maParams[nIndex].Handle = -1;
3254cdf0e10cSrcweir 				maParams[nIndex].Value <<= aParamValue;
3255cdf0e10cSrcweir 				maParams[nIndex].State = beans::PropertyState_DIRECT_VALUE;
3256cdf0e10cSrcweir 			}
3257cdf0e10cSrcweir 		}
3258cdf0e10cSrcweir 
3259cdf0e10cSrcweir 		return new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName );
3260cdf0e10cSrcweir 	}
3261cdf0e10cSrcweir 
3262cdf0e10cSrcweir 	return SdXMLShapeContext::CreateChildContext( p_nPrefix, rLocalName, xAttrList );
3263cdf0e10cSrcweir }
3264cdf0e10cSrcweir 
3265cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
3266cdf0e10cSrcweir 
3267cdf0e10cSrcweir TYPEINIT1( SdXMLFloatingFrameShapeContext, SdXMLShapeContext );
3268cdf0e10cSrcweir 
3269cdf0e10cSrcweir SdXMLFloatingFrameShapeContext::SdXMLFloatingFrameShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
3270cdf0e10cSrcweir 		const rtl::OUString& rLocalName,
3271cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
3272cdf0e10cSrcweir 		com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
3273cdf0e10cSrcweir         sal_Bool bTemporaryShape)
3274cdf0e10cSrcweir : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
3275cdf0e10cSrcweir {
3276cdf0e10cSrcweir }
3277cdf0e10cSrcweir 
3278cdf0e10cSrcweir SdXMLFloatingFrameShapeContext::~SdXMLFloatingFrameShapeContext()
3279cdf0e10cSrcweir {
3280cdf0e10cSrcweir }
3281cdf0e10cSrcweir 
3282cdf0e10cSrcweir void SdXMLFloatingFrameShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& )
3283cdf0e10cSrcweir {
3284cdf0e10cSrcweir 	const char* pService = "com.sun.star.drawing.FrameShape";
3285cdf0e10cSrcweir 	AddShape( pService );
3286cdf0e10cSrcweir 
3287cdf0e10cSrcweir 	if( mxShape.is() )
3288cdf0e10cSrcweir 	{
3289cdf0e10cSrcweir 		SetLayer();
3290cdf0e10cSrcweir 
3291cdf0e10cSrcweir 		// set pos, size, shear and rotate
3292cdf0e10cSrcweir 		SetTransformation();
3293cdf0e10cSrcweir 
3294cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3295cdf0e10cSrcweir 		if( xProps.is() )
3296cdf0e10cSrcweir 		{
3297cdf0e10cSrcweir 			uno::Any aAny;
3298cdf0e10cSrcweir 
3299cdf0e10cSrcweir 			if( maFrameName.getLength() )
3300cdf0e10cSrcweir 			{
3301cdf0e10cSrcweir 				aAny <<= maFrameName;
3302cdf0e10cSrcweir 				xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "FrameName" ) ), aAny );
3303cdf0e10cSrcweir 			}
3304cdf0e10cSrcweir 
3305cdf0e10cSrcweir 			if( maHref.getLength() )
3306cdf0e10cSrcweir 			{
3307cdf0e10cSrcweir 				aAny <<= maHref;
3308cdf0e10cSrcweir 				xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "FrameURL" ) ), aAny );
3309cdf0e10cSrcweir 			}
3310cdf0e10cSrcweir 		}
3311cdf0e10cSrcweir 
3312cdf0e10cSrcweir 		SetStyle();
3313cdf0e10cSrcweir 
3314cdf0e10cSrcweir 		GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
3315cdf0e10cSrcweir 	}
3316cdf0e10cSrcweir }
3317cdf0e10cSrcweir 
3318cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
3319cdf0e10cSrcweir void SdXMLFloatingFrameShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
3320cdf0e10cSrcweir {
3321cdf0e10cSrcweir 	switch( nPrefix )
3322cdf0e10cSrcweir 	{
3323cdf0e10cSrcweir 	case XML_NAMESPACE_DRAW:
3324cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_FRAME_NAME ) )
3325cdf0e10cSrcweir 		{
3326cdf0e10cSrcweir 			maFrameName = rValue;
3327cdf0e10cSrcweir 			return;
3328cdf0e10cSrcweir 		}
3329cdf0e10cSrcweir 		break;
3330cdf0e10cSrcweir 	case XML_NAMESPACE_XLINK:
3331cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_HREF ) )
3332cdf0e10cSrcweir 		{
3333cdf0e10cSrcweir 			maHref = GetImport().GetAbsoluteReference(rValue);
3334cdf0e10cSrcweir 			return;
3335cdf0e10cSrcweir 		}
3336cdf0e10cSrcweir 		break;
3337cdf0e10cSrcweir 	}
3338cdf0e10cSrcweir 
3339cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
3340cdf0e10cSrcweir }
3341cdf0e10cSrcweir 
3342cdf0e10cSrcweir void SdXMLFloatingFrameShapeContext::EndElement()
3343cdf0e10cSrcweir {
3344cdf0e10cSrcweir 	uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY );
3345cdf0e10cSrcweir 
3346cdf0e10cSrcweir 	if( xProps.is() )
3347cdf0e10cSrcweir 	{
3348cdf0e10cSrcweir 		if ( maSize.Width && maSize.Height )
3349cdf0e10cSrcweir 		{
3350cdf0e10cSrcweir 			// the visual area for a floating frame must be set on loading
3351cdf0e10cSrcweir 			awt::Rectangle aRect( 0, 0, maSize.Width, maSize.Height );
3352cdf0e10cSrcweir 			uno::Any aAny;
3353cdf0e10cSrcweir 			aAny <<= aRect;
3354cdf0e10cSrcweir 			xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) ), aAny );
3355cdf0e10cSrcweir 		}
3356cdf0e10cSrcweir 	}
3357cdf0e10cSrcweir 
3358cdf0e10cSrcweir 	SetThumbnail();
3359cdf0e10cSrcweir 	SdXMLShapeContext::EndElement();
3360cdf0e10cSrcweir }
3361cdf0e10cSrcweir 
3362cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
3363cdf0e10cSrcweir 
3364cdf0e10cSrcweir TYPEINIT1( SdXMLFrameShapeContext, SdXMLShapeContext );
3365cdf0e10cSrcweir 
3366cdf0e10cSrcweir SdXMLFrameShapeContext::SdXMLFrameShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
3367cdf0e10cSrcweir 		const rtl::OUString& rLocalName,
3368cdf0e10cSrcweir 		const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
3369cdf0e10cSrcweir 		com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes,
3370cdf0e10cSrcweir         sal_Bool bTemporaryShape)
3371cdf0e10cSrcweir : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape ),
3372ddde725dSArmin Le Grand     multiImageImportHelper(),
3373ddde725dSArmin Le Grand 	mbSupportsReplacement( sal_False ),
3374ddde725dSArmin Le Grand     mxImplContext(),
3375ddde725dSArmin Le Grand     mxReplImplContext()
3376cdf0e10cSrcweir {
3377cdf0e10cSrcweir 	uno::Reference < util::XCloneable > xClone( xAttrList, uno::UNO_QUERY );
3378cdf0e10cSrcweir 	if( xClone.is() )
3379cdf0e10cSrcweir 		mxAttrList.set( xClone->createClone(), uno::UNO_QUERY );
3380cdf0e10cSrcweir 	else
3381cdf0e10cSrcweir 		mxAttrList = new SvXMLAttributeList( xAttrList );
3382cdf0e10cSrcweir 
3383cdf0e10cSrcweir }
3384cdf0e10cSrcweir 
3385cdf0e10cSrcweir SdXMLFrameShapeContext::~SdXMLFrameShapeContext()
3386cdf0e10cSrcweir {
3387cdf0e10cSrcweir }
3388cdf0e10cSrcweir 
3389ddde725dSArmin Le Grand void SdXMLFrameShapeContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext) const
3390ddde725dSArmin Le Grand {
3391ddde725dSArmin Le Grand     const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext);
3392ddde725dSArmin Le Grand 
3393ddde725dSArmin Le Grand     if(pSdXMLGraphicObjectShapeContext)
3394ddde725dSArmin Le Grand     {
3395ddde725dSArmin Le Grand         try
3396ddde725dSArmin Le Grand         {
3397ddde725dSArmin Le Grand             uno::Reference< container::XChild > xChild(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW);
3398ddde725dSArmin Le Grand 
3399ddde725dSArmin Le Grand             if(xChild.is())
3400ddde725dSArmin Le Grand             {
3401ddde725dSArmin Le Grand                 uno::Reference< drawing::XShapes > xParent(xChild->getParent(), uno::UNO_QUERY_THROW);
3402ddde725dSArmin Le Grand 
3403ddde725dSArmin Le Grand                 if(xParent.is())
3404ddde725dSArmin Le Grand                 {
3405ddde725dSArmin Le Grand                     // remove from parent
3406ddde725dSArmin Le Grand                     xParent->remove(pSdXMLGraphicObjectShapeContext->getShape());
3407ddde725dSArmin Le Grand 
3408ddde725dSArmin Le Grand                     // dispose
3409ddde725dSArmin Le Grand                     uno::Reference< lang::XComponent > xComp(pSdXMLGraphicObjectShapeContext->getShape(), UNO_QUERY);
3410ddde725dSArmin Le Grand 
3411ddde725dSArmin Le Grand                     if(xComp.is())
3412ddde725dSArmin Le Grand                     {
3413ddde725dSArmin Le Grand                         xComp->dispose();
3414ddde725dSArmin Le Grand                     }
3415ddde725dSArmin Le Grand                 }
3416ddde725dSArmin Le Grand             }
3417ddde725dSArmin Le Grand         }
3418ddde725dSArmin Le Grand         catch( uno::Exception& )
3419ddde725dSArmin Le Grand         {
3420ddde725dSArmin Le Grand             DBG_ERROR( "Error in cleanup of multiple graphic object import (!)" );
3421ddde725dSArmin Le Grand         }
3422ddde725dSArmin Le Grand     }
3423ddde725dSArmin Le Grand }
3424ddde725dSArmin Le Grand 
3425ddde725dSArmin Le Grand rtl::OUString SdXMLFrameShapeContext::getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const
3426ddde725dSArmin Le Grand {
3427ddde725dSArmin Le Grand     rtl::OUString aRetval;
3428ddde725dSArmin Le Grand     const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext);
3429ddde725dSArmin Le Grand 
3430ddde725dSArmin Le Grand     if(pSdXMLGraphicObjectShapeContext)
3431ddde725dSArmin Le Grand     {
3432ddde725dSArmin Le Grand         try
3433ddde725dSArmin Le Grand         {
3434ddde725dSArmin Le Grand             const uno::Reference< beans::XPropertySet > xPropSet(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW);
3435ddde725dSArmin Le Grand 
3436ddde725dSArmin Le Grand             if(xPropSet.is())
3437ddde725dSArmin Le Grand             {
3438ddde725dSArmin Le Grand                 xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL"))) >>= aRetval;
3439bfba507cSArmin Le Grand 
3440bfba507cSArmin Le Grand                 if(!aRetval.getLength())
3441bfba507cSArmin Le Grand                 {
3442bfba507cSArmin Le Grand                     // it maybe a link, try GraphicURL
3443bfba507cSArmin Le Grand                     xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))) >>= aRetval;
3444bfba507cSArmin Le Grand                 }
3445ddde725dSArmin Le Grand             }
3446ddde725dSArmin Le Grand         }
3447ddde725dSArmin Le Grand         catch( uno::Exception& )
3448ddde725dSArmin Le Grand         {
3449ddde725dSArmin Le Grand             DBG_ERROR( "Error in cleanup of multiple graphic object import (!)" );
3450ddde725dSArmin Le Grand         }
3451ddde725dSArmin Le Grand     }
3452ddde725dSArmin Le Grand 
3453ddde725dSArmin Le Grand     return aRetval;
3454ddde725dSArmin Le Grand }
3455ddde725dSArmin Le Grand 
3456cdf0e10cSrcweir SvXMLImportContext *SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPrefix,
3457cdf0e10cSrcweir 	const OUString& rLocalName,
3458cdf0e10cSrcweir 	const uno::Reference< xml::sax::XAttributeList>& xAttrList )
3459cdf0e10cSrcweir {
3460cdf0e10cSrcweir 	SvXMLImportContext * pContext = 0;
3461cdf0e10cSrcweir 
3462cdf0e10cSrcweir 	if( !mxImplContext.Is() )
3463cdf0e10cSrcweir 	{
3464cdf0e10cSrcweir         pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
3465cdf0e10cSrcweir             GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList);
3466cdf0e10cSrcweir 
3467cdf0e10cSrcweir         mxImplContext = pContext;
3468ddde725dSArmin Le Grand         mbSupportsReplacement = IsXMLToken(rLocalName, XML_OBJECT ) || IsXMLToken(rLocalName, XML_OBJECT_OLE);
3469ddde725dSArmin Le Grand         setSupportsMultipleContents(IsXMLToken(rLocalName, XML_IMAGE));
3470ddde725dSArmin Le Grand 
3471598d8f9fSArmin Le Grand         if(getSupportsMultipleContents())
3472ddde725dSArmin Le Grand         {
3473598d8f9fSArmin Le Grand             SdXMLGraphicObjectShapeContext* pGSC = dynamic_cast< SdXMLGraphicObjectShapeContext* >(pContext);
3474598d8f9fSArmin Le Grand 
3475598d8f9fSArmin Le Grand             if(pGSC)
3476598d8f9fSArmin Le Grand             {
3477598d8f9fSArmin Le Grand                 // mark context as LateAdd to avoid conflicts with multiple objects registering with the same ID
3478598d8f9fSArmin Le Grand                 pGSC->setLateAddToIdentifierMapper(true);
3479ddde725dSArmin Le Grand                 addContent(*mxImplContext);
3480ddde725dSArmin Le Grand             }
3481ddde725dSArmin Le Grand         }
3482598d8f9fSArmin Le Grand     }
3483ddde725dSArmin Le Grand     else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == nPrefix && IsXMLToken(rLocalName, XML_IMAGE))
3484ddde725dSArmin Le Grand     {
3485ddde725dSArmin Le Grand         // read another image
3486ddde725dSArmin Le Grand         pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
3487ddde725dSArmin Le Grand             GetImport(), nPrefix, rLocalName, xAttrList, mxShapes, mxAttrList);
3488ddde725dSArmin Le Grand         mxImplContext = pContext;
3489ddde725dSArmin Le Grand 
3490598d8f9fSArmin Le Grand         SdXMLGraphicObjectShapeContext* pGSC = dynamic_cast< SdXMLGraphicObjectShapeContext* >(pContext);
3491598d8f9fSArmin Le Grand 
3492598d8f9fSArmin Le Grand         if(pGSC)
3493ddde725dSArmin Le Grand         {
3494598d8f9fSArmin Le Grand             // mark context as LateAdd to avoid conflicts with multiple objects registering with the same ID
3495598d8f9fSArmin Le Grand             pGSC->setLateAddToIdentifierMapper(true);
3496ddde725dSArmin Le Grand             addContent(*mxImplContext);
3497ddde725dSArmin Le Grand         }
3498cdf0e10cSrcweir     }
3499cdf0e10cSrcweir 	else if( mbSupportsReplacement && !mxReplImplContext &&
3500cdf0e10cSrcweir 			 XML_NAMESPACE_DRAW == nPrefix &&
3501cdf0e10cSrcweir 			 IsXMLToken( rLocalName, XML_IMAGE ) )
3502cdf0e10cSrcweir 	{
3503cdf0e10cSrcweir 		// read replacement image
3504cdf0e10cSrcweir 		SvXMLImportContext *pImplContext = &mxImplContext;
3505cdf0e10cSrcweir 		SdXMLShapeContext *pSContext =
3506cdf0e10cSrcweir 			PTR_CAST( SdXMLShapeContext, pImplContext );
3507cdf0e10cSrcweir 		if( pSContext )
3508cdf0e10cSrcweir 		{
3509cdf0e10cSrcweir 			uno::Reference < beans::XPropertySet > xPropSet(
3510cdf0e10cSrcweir 					pSContext->getShape(), uno::UNO_QUERY );
3511cdf0e10cSrcweir 			if( xPropSet.is() )
3512cdf0e10cSrcweir 			{
3513cdf0e10cSrcweir 				pContext = new XMLReplacementImageContext( GetImport(),
3514cdf0e10cSrcweir 									nPrefix, rLocalName, xAttrList, xPropSet );
3515cdf0e10cSrcweir 				mxReplImplContext = pContext;
3516cdf0e10cSrcweir 			}
3517cdf0e10cSrcweir 		}
3518cdf0e10cSrcweir 	}
3519cdf0e10cSrcweir 	else if(
3520cdf0e10cSrcweir 			( nPrefix == XML_NAMESPACE_SVG &&	// #i68101#
3521cdf0e10cSrcweir 				(IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) ) ||
3522cdf0e10cSrcweir 			 (nPrefix == XML_NAMESPACE_OFFICE && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) ) ||
3523cdf0e10cSrcweir 			 (nPrefix == XML_NAMESPACE_DRAW && (IsXMLToken( rLocalName, XML_GLUE_POINT ) ||
3524cdf0e10cSrcweir 												IsXMLToken( rLocalName, XML_THUMBNAIL ) ) ) )
3525cdf0e10cSrcweir 	{
3526cdf0e10cSrcweir 		SvXMLImportContext *pImplContext = &mxImplContext;
3527cdf0e10cSrcweir 		pContext = PTR_CAST( SdXMLShapeContext, pImplContext )->CreateChildContext( nPrefix,
3528cdf0e10cSrcweir 																		rLocalName, xAttrList );
3529cdf0e10cSrcweir 	}
3530cdf0e10cSrcweir 	else if ( (XML_NAMESPACE_DRAW == nPrefix) && IsXMLToken( rLocalName, XML_IMAGE_MAP ) )
3531cdf0e10cSrcweir 	{
3532cdf0e10cSrcweir 		SdXMLShapeContext *pSContext = dynamic_cast< SdXMLShapeContext* >( &mxImplContext );
3533cdf0e10cSrcweir 		if( pSContext )
3534cdf0e10cSrcweir 		{
3535cdf0e10cSrcweir 			uno::Reference < beans::XPropertySet > xPropSet( pSContext->getShape(), uno::UNO_QUERY );
3536cdf0e10cSrcweir 			if (xPropSet.is())
3537cdf0e10cSrcweir 			{
3538cdf0e10cSrcweir 				pContext = new XMLImageMapContext(GetImport(), nPrefix, rLocalName, xPropSet);
3539cdf0e10cSrcweir 			}
3540cdf0e10cSrcweir 		}
3541cdf0e10cSrcweir 	}
3542cdf0e10cSrcweir 
3543cdf0e10cSrcweir 	// call parent for content
3544cdf0e10cSrcweir 	if(!pContext)
3545cdf0e10cSrcweir 		pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName, xAttrList );
3546cdf0e10cSrcweir 
3547cdf0e10cSrcweir 	return pContext;
3548cdf0e10cSrcweir }
3549cdf0e10cSrcweir 
3550cdf0e10cSrcweir void SdXMLFrameShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>&)
3551cdf0e10cSrcweir {
3552cdf0e10cSrcweir 	// ignore
3553cdf0e10cSrcweir }
3554cdf0e10cSrcweir 
3555cdf0e10cSrcweir void SdXMLFrameShapeContext::EndElement()
3556cdf0e10cSrcweir {
3557ddde725dSArmin Le Grand     /// solve if multiple image child contexts were imported
3558598d8f9fSArmin Le Grand     const SvXMLImportContext* pWinner = solveMultipleImages();
3559598d8f9fSArmin Le Grand     const SdXMLGraphicObjectShapeContext* pGSCWinner = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(pWinner);
3560598d8f9fSArmin Le Grand 
3561598d8f9fSArmin Le Grand     /// if we have a winner and it's on LateAdd, add it now
3562598d8f9fSArmin Le Grand     if(pGSCWinner && pGSCWinner->getLateAddToIdentifierMapper() && pGSCWinner->getShapeId().getLength())
3563598d8f9fSArmin Le Grand     {
3564598d8f9fSArmin Le Grand         uno::Reference< uno::XInterface > xRef( pGSCWinner->getShape(), uno::UNO_QUERY );
3565598d8f9fSArmin Le Grand         GetImport().getInterfaceToIdentifierMapper().registerReference( pGSCWinner->getShapeId(), xRef );
3566598d8f9fSArmin Le Grand     }
3567ddde725dSArmin Le Grand 
3568cdf0e10cSrcweir 	if( !mxImplContext.Is() )
3569cdf0e10cSrcweir 	{
3570cdf0e10cSrcweir 		// now check if this is an empty presentation object
3571cdf0e10cSrcweir 		sal_Int16 nAttrCount = mxAttrList.is() ? mxAttrList->getLength() : 0;
3572cdf0e10cSrcweir 		for(sal_Int16 a(0); a < nAttrCount; a++)
3573cdf0e10cSrcweir 		{
3574cdf0e10cSrcweir 			OUString aLocalName;
3575cdf0e10cSrcweir 			sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName(mxAttrList->getNameByIndex(a), &aLocalName);
3576cdf0e10cSrcweir 
3577cdf0e10cSrcweir 			if( nPrefix == XML_NAMESPACE_PRESENTATION )
3578cdf0e10cSrcweir 			{
3579cdf0e10cSrcweir 				if( IsXMLToken( aLocalName, XML_PLACEHOLDER ) )
3580cdf0e10cSrcweir 				{
3581cdf0e10cSrcweir 					mbIsPlaceholder = IsXMLToken( mxAttrList->getValueByIndex(a), XML_TRUE );
3582cdf0e10cSrcweir 				}
3583cdf0e10cSrcweir 				else if( IsXMLToken( aLocalName, XML_CLASS ) )
3584cdf0e10cSrcweir 				{
3585cdf0e10cSrcweir 					maPresentationClass = mxAttrList->getValueByIndex(a);
3586cdf0e10cSrcweir 				}
3587cdf0e10cSrcweir 			}
3588cdf0e10cSrcweir 		}
3589cdf0e10cSrcweir 
3590cdf0e10cSrcweir 		if( (maPresentationClass.getLength() != 0) && mbIsPlaceholder )
3591cdf0e10cSrcweir 		{
3592cdf0e10cSrcweir 			uno::Reference< xml::sax::XAttributeList> xEmpty;
3593cdf0e10cSrcweir 
3594cdf0e10cSrcweir 			enum XMLTokenEnum eToken = XML_TEXT_BOX;
3595cdf0e10cSrcweir 
3596cdf0e10cSrcweir 			if( IsXMLToken( maPresentationClass, XML_GRAPHIC ) )
3597cdf0e10cSrcweir 			{
3598cdf0e10cSrcweir 				eToken = XML_IMAGE;
3599cdf0e10cSrcweir 
3600cdf0e10cSrcweir 			}
3601cdf0e10cSrcweir 			else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_PAGE ) )
3602cdf0e10cSrcweir 			{
3603cdf0e10cSrcweir 				eToken = XML_PAGE_THUMBNAIL;
3604cdf0e10cSrcweir 			}
3605cdf0e10cSrcweir 			else if( IsXMLToken( maPresentationClass, XML_PRESENTATION_CHART ) ||
3606cdf0e10cSrcweir 					 IsXMLToken( maPresentationClass, XML_PRESENTATION_TABLE ) ||
3607cdf0e10cSrcweir 					 IsXMLToken( maPresentationClass, XML_PRESENTATION_OBJECT ) )
3608cdf0e10cSrcweir 			{
3609cdf0e10cSrcweir 				eToken = XML_OBJECT;
3610cdf0e10cSrcweir 			}
3611cdf0e10cSrcweir 
3612cdf0e10cSrcweir 			mxImplContext = GetImport().GetShapeImport()->CreateFrameChildContext(
3613cdf0e10cSrcweir 					GetImport(), XML_NAMESPACE_DRAW, GetXMLToken( eToken ), mxAttrList, mxShapes, xEmpty );
3614cdf0e10cSrcweir 
3615cdf0e10cSrcweir 			if( mxImplContext.Is() )
3616cdf0e10cSrcweir 			{
3617cdf0e10cSrcweir 				mxImplContext->StartElement( mxAttrList );
3618cdf0e10cSrcweir 				mxImplContext->EndElement();
3619cdf0e10cSrcweir 			}
3620cdf0e10cSrcweir 		}
3621cdf0e10cSrcweir 	}
3622cdf0e10cSrcweir 
3623cdf0e10cSrcweir 	mxImplContext = 0;
3624cdf0e10cSrcweir 	SdXMLShapeContext::EndElement();
3625cdf0e10cSrcweir }
3626cdf0e10cSrcweir 
3627cdf0e10cSrcweir void SdXMLFrameShapeContext::processAttribute( sal_uInt16,
3628cdf0e10cSrcweir 		const ::rtl::OUString&, const ::rtl::OUString& )
3629cdf0e10cSrcweir {
3630cdf0e10cSrcweir 	// ignore
3631cdf0e10cSrcweir }
3632cdf0e10cSrcweir 
3633cdf0e10cSrcweir TYPEINIT1( SdXMLCustomShapeContext, SdXMLShapeContext );
3634cdf0e10cSrcweir 
3635cdf0e10cSrcweir SdXMLCustomShapeContext::SdXMLCustomShapeContext(
3636cdf0e10cSrcweir 	SvXMLImport& rImport,
3637cdf0e10cSrcweir 	sal_uInt16 nPrfx,
3638cdf0e10cSrcweir 	const OUString& rLocalName,
3639cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
3640cdf0e10cSrcweir 	uno::Reference< drawing::XShapes >& rShapes,
3641cdf0e10cSrcweir     sal_Bool bTemporaryShape)
3642cdf0e10cSrcweir :	SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, bTemporaryShape )
3643cdf0e10cSrcweir {
3644cdf0e10cSrcweir }
3645cdf0e10cSrcweir 
3646cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
3647cdf0e10cSrcweir 
3648cdf0e10cSrcweir SdXMLCustomShapeContext::~SdXMLCustomShapeContext()
3649cdf0e10cSrcweir {
3650cdf0e10cSrcweir }
3651cdf0e10cSrcweir 
3652cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
3653cdf0e10cSrcweir 
3654cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
3655cdf0e10cSrcweir void SdXMLCustomShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
3656cdf0e10cSrcweir {
3657cdf0e10cSrcweir 	if( XML_NAMESPACE_DRAW == nPrefix )
3658cdf0e10cSrcweir 	{
3659cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_ENGINE ) )
3660cdf0e10cSrcweir 		{
3661cdf0e10cSrcweir 			maCustomShapeEngine = rValue;
3662cdf0e10cSrcweir 			return;
3663cdf0e10cSrcweir 		}
3664cdf0e10cSrcweir 		if ( IsXMLToken( rLocalName, XML_DATA ) )
3665cdf0e10cSrcweir 		{
3666cdf0e10cSrcweir 			maCustomShapeData = rValue;
3667cdf0e10cSrcweir 			return;
3668cdf0e10cSrcweir 		}
3669cdf0e10cSrcweir 	}
3670cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
3671cdf0e10cSrcweir }
3672cdf0e10cSrcweir 
3673cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
3674cdf0e10cSrcweir 
3675cdf0e10cSrcweir void SdXMLCustomShapeContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
3676cdf0e10cSrcweir {
3677cdf0e10cSrcweir 	// create rectangle shape
3678cdf0e10cSrcweir 	AddShape("com.sun.star.drawing.CustomShape");
3679cdf0e10cSrcweir 	if ( mxShape.is() )
3680cdf0e10cSrcweir 	{
3681cdf0e10cSrcweir 		// Add, set Style and properties from base shape
3682cdf0e10cSrcweir 		SetStyle();
3683cdf0e10cSrcweir 		SetLayer();
3684cdf0e10cSrcweir 
3685cdf0e10cSrcweir 		// set pos, size, shear and rotate
3686cdf0e10cSrcweir 		SetTransformation();
3687cdf0e10cSrcweir 
3688cdf0e10cSrcweir 		try
3689cdf0e10cSrcweir 		{
3690cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
3691cdf0e10cSrcweir 			if( xPropSet.is() )
3692cdf0e10cSrcweir 			{
3693cdf0e10cSrcweir 				if ( maCustomShapeEngine.getLength() )
3694cdf0e10cSrcweir 				{
3695cdf0e10cSrcweir 					uno::Any aAny;
3696cdf0e10cSrcweir 					aAny <<= maCustomShapeEngine;
3697cdf0e10cSrcweir 					xPropSet->setPropertyValue( EASGet( EAS_CustomShapeEngine ), aAny );
3698cdf0e10cSrcweir 				}
3699cdf0e10cSrcweir 				if ( maCustomShapeData.getLength() )
3700cdf0e10cSrcweir 				{
3701cdf0e10cSrcweir 					uno::Any aAny;
3702cdf0e10cSrcweir 					aAny <<= maCustomShapeData;
3703cdf0e10cSrcweir 					xPropSet->setPropertyValue( EASGet( EAS_CustomShapeData ), aAny );
3704cdf0e10cSrcweir 				}
3705cdf0e10cSrcweir 			}
3706cdf0e10cSrcweir 		}
3707cdf0e10cSrcweir 		catch( uno::Exception& )
3708cdf0e10cSrcweir 		{
3709cdf0e10cSrcweir 			DBG_ERROR( "could not set enhanced customshape geometry" );
3710cdf0e10cSrcweir 		}
3711cdf0e10cSrcweir 		SdXMLShapeContext::StartElement(xAttrList);
3712cdf0e10cSrcweir 	}
3713cdf0e10cSrcweir }
3714cdf0e10cSrcweir 
3715cdf0e10cSrcweir void SdXMLCustomShapeContext::EndElement()
3716cdf0e10cSrcweir {
37176381da86SArmin Le Grand     // for backward compatibility, the above SetTransformation() may alraedy have
37186381da86SArmin Le Grand     // applied a call to SetMirroredX/SetMirroredY. This is not yet added to the
37196381da86SArmin Le Grand     // beans::PropertyValues in maCustomShapeGeometry. When applying these now, this
37206381da86SArmin Le Grand     // would be lost again.
37216381da86SArmin Le Grand     // TTTT: Remove again after aw080
37226381da86SArmin Le Grand     if(!maUsedTransformation.isIdentity())
37236381da86SArmin Le Grand     {
37246381da86SArmin Le Grand         basegfx::B2DVector aScale, aTranslate;
37256381da86SArmin Le Grand         double fRotate, fShearX;
37266381da86SArmin Le Grand 
37276381da86SArmin Le Grand         maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX);
37286381da86SArmin Le Grand 
37296381da86SArmin Le Grand         bool bFlippedX(aScale.getX() < 0.0);
37306381da86SArmin Le Grand         bool bFlippedY(aScale.getY() < 0.0);
37316381da86SArmin Le Grand 
37326381da86SArmin Le Grand         if(bFlippedX && bFlippedY)
37336381da86SArmin Le Grand         {
37346381da86SArmin Le Grand             // when both are used it is the same as 180 degree rotation; reset
37356381da86SArmin Le Grand             bFlippedX = bFlippedY = false;
37366381da86SArmin Le Grand         }
37376381da86SArmin Le Grand 
37386381da86SArmin Le Grand         if(bFlippedX || bFlippedY)
37396381da86SArmin Le Grand         {
37406381da86SArmin Le Grand             beans::PropertyValue aNewPoroperty;
37416381da86SArmin Le Grand 
37426381da86SArmin Le Grand             if(bFlippedX)
37436381da86SArmin Le Grand             {
37446381da86SArmin Le Grand                 aNewPoroperty.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MirroredX"));
37456381da86SArmin Le Grand             }
37466381da86SArmin Le Grand             else
37476381da86SArmin Le Grand             {
37486381da86SArmin Le Grand                 aNewPoroperty.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MirroredY"));
37496381da86SArmin Le Grand             }
37506381da86SArmin Le Grand 
37516381da86SArmin Le Grand             aNewPoroperty.Handle = -1;
37526381da86SArmin Le Grand             aNewPoroperty.Value <<= sal_True;
37536381da86SArmin Le Grand             aNewPoroperty.State = beans::PropertyState_DIRECT_VALUE;
37546381da86SArmin Le Grand 
37556381da86SArmin Le Grand             maCustomShapeGeometry.push_back(aNewPoroperty);
37566381da86SArmin Le Grand         }
37576381da86SArmin Le Grand     }
37586381da86SArmin Le Grand 
3759cdf0e10cSrcweir 	if ( !maCustomShapeGeometry.empty() )
3760cdf0e10cSrcweir 	{
3761cdf0e10cSrcweir 		const rtl::OUString	sCustomShapeGeometry	( RTL_CONSTASCII_USTRINGPARAM( "CustomShapeGeometry" ) );
3762cdf0e10cSrcweir 
3763cdf0e10cSrcweir 		// converting the vector to a sequence
3764cdf0e10cSrcweir 		uno::Sequence< beans::PropertyValue > aSeq( maCustomShapeGeometry.size() );
3765cdf0e10cSrcweir 		beans::PropertyValue* pValues = aSeq.getArray();
3766cdf0e10cSrcweir 		std::vector< beans::PropertyValue >::const_iterator aIter( maCustomShapeGeometry.begin() );
3767cdf0e10cSrcweir 		std::vector< beans::PropertyValue >::const_iterator aEnd( maCustomShapeGeometry.end() );
3768cdf0e10cSrcweir 		while ( aIter != aEnd )
3769cdf0e10cSrcweir 			*pValues++ = *aIter++;
3770cdf0e10cSrcweir 
3771cdf0e10cSrcweir 		try
3772cdf0e10cSrcweir 		{
3773cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY );
3774cdf0e10cSrcweir 			if( xPropSet.is() )
3775cdf0e10cSrcweir 			{
3776cdf0e10cSrcweir 				uno::Any aAny;
3777cdf0e10cSrcweir 				aAny <<= aSeq;
3778cdf0e10cSrcweir 				xPropSet->setPropertyValue( sCustomShapeGeometry, aAny );
3779cdf0e10cSrcweir 			}
3780cdf0e10cSrcweir 		}
3781cdf0e10cSrcweir 		catch( uno::Exception& )
3782cdf0e10cSrcweir 		{
3783cdf0e10cSrcweir 			DBG_ERROR( "could not set enhanced customshape geometry" );
3784cdf0e10cSrcweir 		}
3785cdf0e10cSrcweir 
3786cdf0e10cSrcweir         sal_Int32 nUPD( 0 );
3787cdf0e10cSrcweir         sal_Int32 nBuild( 0 );
3788cdf0e10cSrcweir         GetImport().getBuildIds( nUPD, nBuild );
3789cdf0e10cSrcweir         if( ((nUPD >= 640 && nUPD <= 645) || (nUPD == 680)) && (nBuild <= 9221) )
3790cdf0e10cSrcweir 		{
3791cdf0e10cSrcweir 			Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( mxShape, UNO_QUERY );
3792cdf0e10cSrcweir 			if( xDefaulter.is() )
3793cdf0e10cSrcweir 			{
3794cdf0e10cSrcweir 				rtl::OUString aEmptyType;
3795cdf0e10cSrcweir 				xDefaulter->createCustomShapeDefaults( aEmptyType );
3796cdf0e10cSrcweir 			}
3797cdf0e10cSrcweir 		}
3798cdf0e10cSrcweir 	}
3799cdf0e10cSrcweir 
3800cdf0e10cSrcweir 	SdXMLShapeContext::EndElement();
3801cdf0e10cSrcweir }
3802cdf0e10cSrcweir 
3803cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
3804cdf0e10cSrcweir 
3805cdf0e10cSrcweir SvXMLImportContext* SdXMLCustomShapeContext::CreateChildContext(
3806cdf0e10cSrcweir 	sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName,
3807cdf0e10cSrcweir 	const uno::Reference<xml::sax::XAttributeList>& xAttrList )
3808cdf0e10cSrcweir {
3809cdf0e10cSrcweir 	SvXMLImportContext* pContext = NULL;
3810cdf0e10cSrcweir 	if ( XML_NAMESPACE_DRAW == nPrefix )
3811cdf0e10cSrcweir 	{
3812cdf0e10cSrcweir 		if ( IsXMLToken( rLocalName, XML_ENHANCED_GEOMETRY ) )
3813cdf0e10cSrcweir 		{
3814cdf0e10cSrcweir 			uno::Reference< beans::XPropertySet > xPropSet( mxShape,uno::UNO_QUERY );
3815cdf0e10cSrcweir 			if ( xPropSet.is() )
3816cdf0e10cSrcweir 				pContext = new XMLEnhancedCustomShapeContext( GetImport(), mxShape, nPrefix, rLocalName, maCustomShapeGeometry );
3817cdf0e10cSrcweir 		}
3818cdf0e10cSrcweir 	}
3819cdf0e10cSrcweir 	// delegate to parent class if no context could be created
3820cdf0e10cSrcweir 	if ( NULL == pContext )
3821cdf0e10cSrcweir 		pContext = SdXMLShapeContext::CreateChildContext( nPrefix, rLocalName,
3822cdf0e10cSrcweir 														 xAttrList);
3823cdf0e10cSrcweir 	return pContext;
3824cdf0e10cSrcweir }
3825cdf0e10cSrcweir 
3826cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////
3827cdf0e10cSrcweir 
3828cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
3829cdf0e10cSrcweir 
3830cdf0e10cSrcweir TYPEINIT1( SdXMLTableShapeContext, SdXMLShapeContext );
3831cdf0e10cSrcweir 
3832cdf0e10cSrcweir SdXMLTableShapeContext::SdXMLTableShapeContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const rtl::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 )
3833cdf0e10cSrcweir : SdXMLShapeContext( rImport, nPrfx, rLocalName, xAttrList, rShapes, sal_False )
3834cdf0e10cSrcweir {
3835cdf0e10cSrcweir 	memset( &maTemplateStylesUsed, 0, sizeof( maTemplateStylesUsed ) );
3836cdf0e10cSrcweir }
3837cdf0e10cSrcweir 
3838cdf0e10cSrcweir SdXMLTableShapeContext::~SdXMLTableShapeContext()
3839cdf0e10cSrcweir {
3840cdf0e10cSrcweir }
3841cdf0e10cSrcweir 
3842cdf0e10cSrcweir void SdXMLTableShapeContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList )
3843cdf0e10cSrcweir {
3844cdf0e10cSrcweir 	const char* pService = "com.sun.star.drawing.TableShape";
3845cdf0e10cSrcweir 
3846cdf0e10cSrcweir 	sal_Bool bIsPresShape = maPresentationClass.getLength() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
3847cdf0e10cSrcweir 	if( bIsPresShape )
3848cdf0e10cSrcweir 	{
3849cdf0e10cSrcweir 		if( IsXMLToken( maPresentationClass, XML_PRESENTATION_TABLE ) )
3850cdf0e10cSrcweir 		{
3851cdf0e10cSrcweir 			pService = "com.sun.star.presentation.TableShape";
3852cdf0e10cSrcweir 		}
3853cdf0e10cSrcweir 	}
3854cdf0e10cSrcweir 
3855cdf0e10cSrcweir 	AddShape( pService );
3856cdf0e10cSrcweir 
3857cdf0e10cSrcweir 	if( mxShape.is() )
3858cdf0e10cSrcweir 	{
3859cdf0e10cSrcweir 		SetLayer();
3860cdf0e10cSrcweir 
3861cdf0e10cSrcweir 		uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY);
3862cdf0e10cSrcweir 
3863cdf0e10cSrcweir 		if(bIsPresShape)
3864cdf0e10cSrcweir 		{
3865cdf0e10cSrcweir 			if(xProps.is())
3866cdf0e10cSrcweir 			{
3867cdf0e10cSrcweir 				uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() );
3868cdf0e10cSrcweir 				if( xPropsInfo.is() )
3869cdf0e10cSrcweir 				{
3870cdf0e10cSrcweir 					if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
3871cdf0e10cSrcweir 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False ) );
3872cdf0e10cSrcweir 
3873cdf0e10cSrcweir 					if( mbIsUserTransformed && xPropsInfo->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
3874cdf0e10cSrcweir 						xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False ) );
3875cdf0e10cSrcweir 				}
3876cdf0e10cSrcweir 			}
3877cdf0e10cSrcweir 		}
3878cdf0e10cSrcweir 
3879cdf0e10cSrcweir 		SetStyle();
3880cdf0e10cSrcweir 
3881cdf0e10cSrcweir 		if( xProps.is() )
3882cdf0e10cSrcweir 		{
3883cdf0e10cSrcweir 			if( msTemplateStyleName.getLength() ) try
3884cdf0e10cSrcweir 			{
3885cdf0e10cSrcweir 				Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetImport().GetModel(), UNO_QUERY_THROW );
3886cdf0e10cSrcweir 				Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() );
3887cdf0e10cSrcweir 				const OUString sFamilyName( RTL_CONSTASCII_USTRINGPARAM("table" ) );
3888cdf0e10cSrcweir 				Reference< XNameAccess > xTableFamily( xFamilies->getByName( sFamilyName ), UNO_QUERY_THROW );
3889cdf0e10cSrcweir 				Reference< XStyle > xTableStyle( xTableFamily->getByName( msTemplateStyleName ), UNO_QUERY_THROW );
3890cdf0e10cSrcweir 				xProps->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TableTemplate" ) ), Any( xTableStyle ) );
3891cdf0e10cSrcweir 			}
3892cdf0e10cSrcweir 			catch( Exception& )
3893cdf0e10cSrcweir 			{
3894cdf0e10cSrcweir 				DBG_ERROR("SdXMLTableShapeContext::StartElement(), exception caught!");
3895cdf0e10cSrcweir 			}
3896cdf0e10cSrcweir 
3897cdf0e10cSrcweir 			const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0];
3898cdf0e10cSrcweir 			for( int i = 0; pEntry->msApiName && (i < 6); i++, pEntry++ )
3899cdf0e10cSrcweir 			{
3900cdf0e10cSrcweir 			    try
3901cdf0e10cSrcweir 			    {
3902cdf0e10cSrcweir 				    const OUString sAPIPropertyName( OUString(pEntry->msApiName, pEntry->nApiNameLength, RTL_TEXTENCODING_ASCII_US ) );
3903cdf0e10cSrcweir 				    xProps->setPropertyValue( sAPIPropertyName, Any( maTemplateStylesUsed[i] ) );
3904cdf0e10cSrcweir 			    }
3905cdf0e10cSrcweir 			    catch( Exception& )
3906cdf0e10cSrcweir 			    {
3907cdf0e10cSrcweir 				    DBG_ERROR("SdXMLTableShapeContext::StartElement(), exception caught!");
3908cdf0e10cSrcweir 			    }
3909cdf0e10cSrcweir             }
3910cdf0e10cSrcweir 		}
3911cdf0e10cSrcweir 
3912cdf0e10cSrcweir 		GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes );
3913cdf0e10cSrcweir 
3914cdf0e10cSrcweir 		const rtl::Reference< XMLTableImport >& xTableImport( GetImport().GetShapeImport()->GetShapeTableImport() );
3915cdf0e10cSrcweir 		if( xTableImport.is() && xProps.is() )
3916cdf0e10cSrcweir 		{
3917cdf0e10cSrcweir 			uno::Reference< table::XColumnRowRange > xColumnRowRange(
3918cdf0e10cSrcweir 				xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ), uno::UNO_QUERY );
3919cdf0e10cSrcweir 
3920cdf0e10cSrcweir 			if( xColumnRowRange.is() )
3921cdf0e10cSrcweir 				mxTableImportContext = xTableImport->CreateTableContext( GetPrefix(), GetLocalName(), xColumnRowRange );
3922cdf0e10cSrcweir 
3923cdf0e10cSrcweir 			if( mxTableImportContext.Is() )
3924cdf0e10cSrcweir 				mxTableImportContext->StartElement( xAttrList );
3925cdf0e10cSrcweir 		}
3926cdf0e10cSrcweir 	}
3927cdf0e10cSrcweir }
3928cdf0e10cSrcweir 
3929cdf0e10cSrcweir void SdXMLTableShapeContext::EndElement()
3930cdf0e10cSrcweir {
3931cdf0e10cSrcweir 	if( mxTableImportContext.Is() )
3932cdf0e10cSrcweir 		mxTableImportContext->EndElement();
3933cdf0e10cSrcweir 
3934cdf0e10cSrcweir 	SdXMLShapeContext::EndElement();
3935cdf0e10cSrcweir 
3936cdf0e10cSrcweir 	if( mxShape.is() )
3937cdf0e10cSrcweir 	{
3938cdf0e10cSrcweir 		// set pos, size, shear and rotate
3939cdf0e10cSrcweir 		SetTransformation();
3940cdf0e10cSrcweir 	}
3941cdf0e10cSrcweir }
3942cdf0e10cSrcweir 
3943cdf0e10cSrcweir // this is called from the parent group for each unparsed attribute in the attribute list
3944cdf0e10cSrcweir void SdXMLTableShapeContext::processAttribute( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::rtl::OUString& rValue )
3945cdf0e10cSrcweir {
3946cdf0e10cSrcweir 	if( nPrefix == XML_NAMESPACE_TABLE )
3947cdf0e10cSrcweir 	{
3948cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_TEMPLATE_NAME ) )
3949cdf0e10cSrcweir 		{
3950cdf0e10cSrcweir 			msTemplateStyleName = rValue;
3951cdf0e10cSrcweir 		}
3952cdf0e10cSrcweir 		else
3953cdf0e10cSrcweir 		{
3954cdf0e10cSrcweir 			int i = 0;
3955cdf0e10cSrcweir 			const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0];
3956cdf0e10cSrcweir 			while( pEntry->msApiName && (i < 6) )
3957cdf0e10cSrcweir 			{
3958cdf0e10cSrcweir 				if( IsXMLToken( rLocalName, pEntry->meXMLName ) )
3959cdf0e10cSrcweir 				{
3960cdf0e10cSrcweir 					if( IsXMLToken( rValue, XML_TRUE ) )
3961cdf0e10cSrcweir 						maTemplateStylesUsed[i] = sal_True;
3962cdf0e10cSrcweir 					break;
3963cdf0e10cSrcweir 				}
3964cdf0e10cSrcweir 				pEntry++;
3965cdf0e10cSrcweir 				i++;
3966cdf0e10cSrcweir 			}
3967cdf0e10cSrcweir 		}
3968cdf0e10cSrcweir 	}
3969cdf0e10cSrcweir 	SdXMLShapeContext::processAttribute( nPrefix, rLocalName, rValue );
3970cdf0e10cSrcweir }
3971cdf0e10cSrcweir 
3972cdf0e10cSrcweir SvXMLImportContext* SdXMLTableShapeContext::CreateChildContext( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const uno::Reference<xml::sax::XAttributeList>& xAttrList )
3973cdf0e10cSrcweir {
3974cdf0e10cSrcweir 	if( mxTableImportContext.Is() && (nPrefix == XML_NAMESPACE_TABLE) )
3975cdf0e10cSrcweir 		return mxTableImportContext->CreateChildContext(nPrefix, rLocalName, xAttrList);
3976cdf0e10cSrcweir 	else
3977cdf0e10cSrcweir 		return SdXMLShapeContext::CreateChildContext(nPrefix, rLocalName, xAttrList);
3978cdf0e10cSrcweir }
3979cdf0e10cSrcweir 
3980