1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <tools/debug.hxx>
23 #include <com/sun/star/document/XEventsSupplier.hpp>
24 #include <com/sun/star/container/XNameReplace.hpp>
25 #include <com/sun/star/presentation/ClickAction.hpp>
26 #include <com/sun/star/drawing/FillStyle.hpp>
27 #include <com/sun/star/drawing/LineStyle.hpp>
28 #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
29 #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
30 #include <com/sun/star/container/XIdentifierAccess.hpp>
31 #include <com/sun/star/drawing/GluePoint2.hpp>
32 #include <com/sun/star/drawing/Alignment.hpp>
33 #include <com/sun/star/drawing/EscapeDirection.hpp>
34 #include <com/sun/star/media/ZoomLevel.hpp>
35 #include <com/sun/star/awt/Rectangle.hpp>
37 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
38 #include <com/sun/star/container/XNameAccess.hpp>
39 #include <comphelper/extract.hxx>
40 #include "ximpshap.hxx"
41 #include <xmloff/XMLBase64ImportContext.hxx>
42 #include <xmloff/XMLShapeStyleContext.hxx>
43 #include <xmloff/xmluconv.hxx>
44 #include <com/sun/star/container/XNamed.hpp>
45 #include <com/sun/star/drawing/CircleKind.hpp>
46 #include <com/sun/star/beans/XPropertySet.hpp>
47 #include <com/sun/star/awt/XControlModel.hpp>
48 #include <com/sun/star/drawing/XControlShape.hpp>
49 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
50 #include <com/sun/star/drawing/PointSequence.hpp>
51 #include <com/sun/star/lang/XServiceInfo.hpp>
52 #include <com/sun/star/util/XCloneable.hpp>
53 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
54 #include "xexptran.hxx"
55 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
56 #include <com/sun/star/beans/XPropertySetInfo.hpp>
57 #include <com/sun/star/drawing/ConnectorType.hpp>
58 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
60 #include <sax/tools/converter.hxx>
62 #include "PropertySetMerger.hxx"
63 #include <xmloff/families.hxx>
64 #include "ximpstyl.hxx"
65 #include"xmloff/xmlnmspe.hxx"
66 #include <xmloff/xmltoken.hxx>
67 #include "EnhancedCustomShapeToken.hxx"
68 #include "XMLReplacementImageContext.hxx"
69 #include "XMLImageMapContext.hxx"
70 #include "sdpropls.hxx"
71 #include "eventimp.hxx"
73 #include "descriptionimp.hxx"
74 #include "ximpcustomshape.hxx"
75 #include "XMLEmbeddedObjectImportContext.hxx"
76 #include "xmloff/xmlerror.hxx"
77 #include <basegfx/matrix/b2dhommatrix.hxx>
78 #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
79 #include <com/sun/star/container/XChild.hpp>
80 #include <com/sun/star/text/XTextDocument.hpp>
82 using ::rtl::OUString
;
83 using ::rtl::OUStringBuffer
;
85 using namespace ::com::sun::star
;
86 using namespace ::com::sun::star::uno
;
87 using namespace ::com::sun::star::drawing
;
88 using namespace ::com::sun::star::style
;
89 using namespace ::com::sun::star::container
;
90 using namespace ::com::sun::star::document
;
91 using namespace ::xmloff::token
;
92 using namespace ::xmloff::EnhancedCustomShapeToken
;
94 SvXMLEnumMapEntry aXML_GlueAlignment_EnumMap
[] =
96 { XML_TOP_LEFT
, drawing::Alignment_TOP_LEFT
},
97 { XML_TOP
, drawing::Alignment_TOP
},
98 { XML_TOP_RIGHT
, drawing::Alignment_TOP_RIGHT
},
99 { XML_LEFT
, drawing::Alignment_LEFT
},
100 { XML_CENTER
, drawing::Alignment_CENTER
},
101 { XML_RIGHT
, drawing::Alignment_RIGHT
},
102 { XML_BOTTOM_LEFT
, drawing::Alignment_BOTTOM_LEFT
},
103 { XML_BOTTOM
, drawing::Alignment_BOTTOM
},
104 { XML_BOTTOM_RIGHT
, drawing::Alignment_BOTTOM_RIGHT
},
105 { XML_TOKEN_INVALID
, 0 }
108 SvXMLEnumMapEntry aXML_GlueEscapeDirection_EnumMap
[] =
110 { XML_AUTO
, drawing::EscapeDirection_SMART
},
111 { XML_LEFT
, drawing::EscapeDirection_LEFT
},
112 { XML_RIGHT
, drawing::EscapeDirection_RIGHT
},
113 { XML_UP
, drawing::EscapeDirection_UP
},
114 { XML_DOWN
, drawing::EscapeDirection_DOWN
},
115 { XML_HORIZONTAL
, drawing::EscapeDirection_HORIZONTAL
},
116 { XML_VERTICAL
, drawing::EscapeDirection_VERTICAL
},
117 { XML_TOKEN_INVALID
, 0 }
120 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
122 static bool ImpIsEmptyURL( const ::rtl::OUString
& rURL
)
127 // #i13140# Also compare against 'toplevel' URLs. which also
128 // result in empty filename strings.
129 if( 0 == rURL
.compareToAscii( "#./" ) )
135 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
137 TYPEINIT1( SvXMLShapeContext
, SvXMLImportContext
);
138 TYPEINIT1( SdXMLShapeContext
, SvXMLShapeContext
);
140 SdXMLShapeContext::SdXMLShapeContext(
141 SvXMLImport
& rImport
,
143 const OUString
& rLocalName
,
144 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
145 uno::Reference
< drawing::XShapes
>& rShapes
,
146 sal_Bool bTemporaryShape
)
147 : SvXMLShapeContext( rImport
, nPrfx
, rLocalName
, bTemporaryShape
)
148 , mxShapes( rShapes
)
149 , mxAttrList(xAttrList
)
150 , mbListContextPushed( false )
151 , mnStyleFamily(XML_STYLE_FAMILY_SD_GRAPHICS_ID
)
152 , mbIsPlaceholder(sal_False
)
153 , mbClearDefaultAttributes( true )
154 , mbIsUserTransformed(sal_False
)
163 //////////////////////////////////////////////////////////////////////////////
165 SdXMLShapeContext::~SdXMLShapeContext()
169 //////////////////////////////////////////////////////////////////////////////
171 SvXMLImportContext
*SdXMLShapeContext::CreateChildContext( sal_uInt16 p_nPrefix
,
172 const OUString
& rLocalName
,
173 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
175 SvXMLImportContext
* pContext
= NULL
;
178 if( p_nPrefix
== XML_NAMESPACE_SVG
&&
179 (IsXMLToken( rLocalName
, XML_TITLE
) || IsXMLToken( rLocalName
, XML_DESC
) ) )
181 pContext
= new SdXMLDescriptionContext( GetImport(), p_nPrefix
, rLocalName
, xAttrList
, mxShape
);
183 else if( p_nPrefix
== XML_NAMESPACE_OFFICE
&& IsXMLToken( rLocalName
, XML_EVENT_LISTENERS
) )
185 pContext
= new SdXMLEventsContext( GetImport(), p_nPrefix
, rLocalName
, xAttrList
, mxShape
);
187 else if( p_nPrefix
== XML_NAMESPACE_DRAW
&& IsXMLToken( rLocalName
, XML_GLUE_POINT
) )
189 addGluePoint( xAttrList
);
191 else if( p_nPrefix
== XML_NAMESPACE_DRAW
&& IsXMLToken( rLocalName
, XML_THUMBNAIL
) )
193 // search attributes for xlink:href
194 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
195 for(sal_Int16 i
=0; i
< nAttrCount
; i
++)
197 OUString sAttrName
= xAttrList
->getNameByIndex( i
);
199 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName
, &aLocalName
);
201 if( nPrefix
== XML_NAMESPACE_XLINK
)
203 if( IsXMLToken( aLocalName
, XML_HREF
) )
205 maThumbnailURL
= xAttrList
->getValueByIndex( i
);
213 // create text cursor on demand
216 uno::Reference
< text::XText
> xText( mxShape
, uno::UNO_QUERY
);
219 UniReference
< XMLTextImportHelper
> xTxtImport
=
220 GetImport().GetTextImport();
221 mxOldCursor
= xTxtImport
->GetCursor();
222 mxCursor
= xText
->createTextCursor();
225 xTxtImport
->SetCursor( mxCursor
);
228 // remember old list item and block (#91964#) and reset them
229 // for the text frame
230 xTxtImport
->PushListContext();
231 mbListContextPushed
= true;
235 // if we have a text cursor, lets try to import some text
238 pContext
= GetImport().GetTextImport()->CreateTextChildContext(
239 GetImport(), p_nPrefix
, rLocalName
, xAttrList
);
243 // call parent for content
245 pContext
= SvXMLImportContext::CreateChildContext( p_nPrefix
, rLocalName
, xAttrList
);
250 void SdXMLShapeContext::addGluePoint( const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
252 // get the glue points container for this shape if its not already there
253 if( !mxGluePoints
.is() )
255 uno::Reference
< drawing::XGluePointsSupplier
> xSupplier( mxShape
, uno::UNO_QUERY
);
256 if( !xSupplier
.is() )
259 mxGluePoints
= uno::Reference
< container::XIdentifierContainer
>::query( xSupplier
->getGluePoints() );
261 if( !mxGluePoints
.is() )
265 drawing::GluePoint2 aGluePoint
;
266 aGluePoint
.IsUserDefined
= sal_True
;
267 aGluePoint
.Position
.X
= 0;
268 aGluePoint
.Position
.Y
= 0;
269 aGluePoint
.Escape
= drawing::EscapeDirection_SMART
;
270 aGluePoint
.PositionAlignment
= drawing::Alignment_CENTER
;
271 aGluePoint
.IsRelative
= sal_True
;
275 // read attributes for the 3DScene
276 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
277 for(sal_Int16 i
=0; i
< nAttrCount
; i
++)
279 OUString sAttrName
= xAttrList
->getNameByIndex( i
);
281 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName
, &aLocalName
);
282 const OUString
sValue( xAttrList
->getValueByIndex( i
) );
284 if( nPrefix
== XML_NAMESPACE_SVG
)
286 if( IsXMLToken( aLocalName
, XML_X
) )
288 GetImport().GetMM100UnitConverter().convertMeasureToCore(
289 aGluePoint
.Position
.X
, sValue
);
291 else if( IsXMLToken( aLocalName
, XML_Y
) )
293 GetImport().GetMM100UnitConverter().convertMeasureToCore(
294 aGluePoint
.Position
.Y
, sValue
);
297 else if( nPrefix
== XML_NAMESPACE_DRAW
)
299 if( IsXMLToken( aLocalName
, XML_ID
) )
301 nId
= sValue
.toInt32();
303 else if( IsXMLToken( aLocalName
, XML_ALIGN
) )
306 if( SvXMLUnitConverter::convertEnum( eKind
, sValue
, aXML_GlueAlignment_EnumMap
) )
308 aGluePoint
.PositionAlignment
= (drawing::Alignment
)eKind
;
309 aGluePoint
.IsRelative
= sal_False
;
312 else if( IsXMLToken( aLocalName
, XML_ESCAPE_DIRECTION
) )
315 if( SvXMLUnitConverter::convertEnum( eKind
, sValue
, aXML_GlueEscapeDirection_EnumMap
) )
317 aGluePoint
.Escape
= (drawing::EscapeDirection
)eKind
;
327 sal_Int32 nInternalId
= mxGluePoints
->insert( uno::makeAny( aGluePoint
) );
328 GetImport().GetShapeImport()->addGluePointMapping( mxShape
, nId
, nInternalId
);
330 catch(const uno::Exception
&)
332 OSL_FAIL( "exception during setting of glue points!");
336 //////////////////////////////////////////////////////////////////////////////
338 void SdXMLShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>&)
340 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
343 void SdXMLShapeContext::EndElement()
347 // delete addition newline
348 const OUString aEmpty
;
349 mxCursor
->gotoEnd( sal_False
);
350 mxCursor
->goLeft( 1, sal_True
);
351 mxCursor
->setString( aEmpty
);
354 GetImport().GetTextImport()->ResetCursor();
358 GetImport().GetTextImport()->SetCursor( mxOldCursor
);
360 // reinstall old list item (if necessary) #91964#
361 if (mbListContextPushed
) {
362 GetImport().GetTextImport()->PopListContext();
365 if( !msHyperlink
.isEmpty() ) try
367 uno::Reference
< beans::XPropertySet
> xProp( mxShape
, uno::UNO_QUERY
);
369 rtl::OUString
sLink( "Hyperlink" );
370 if ( xProp
.is() && xProp
->getPropertySetInfo()->hasPropertyByName( sLink
) )
371 xProp
->setPropertyValue( sLink
, uno::Any( msHyperlink
) );
372 Reference
< XEventsSupplier
> xEventsSupplier( mxShape
, UNO_QUERY
);
373 const OUString
sBookmark( "Bookmark" );
375 if( xEventsSupplier
.is() )
377 const OUString
sEventType( "EventType" );
378 const OUString
sClickAction( "ClickAction" );
380 Reference
< XNameReplace
> xEvents( xEventsSupplier
->getEvents(), UNO_QUERY_THROW
);
382 uno::Sequence
< beans::PropertyValue
> aProperties( 3 );
383 aProperties
[0].Name
= sEventType
;
384 aProperties
[0].Handle
= -1;
385 aProperties
[0].Value
<<= OUString( "Presentation" );
386 aProperties
[0].State
= beans::PropertyState_DIRECT_VALUE
;
388 aProperties
[1].Name
= sClickAction
;
389 aProperties
[1].Handle
= -1;
390 aProperties
[1].Value
<<= ::com::sun::star::presentation::ClickAction_DOCUMENT
;
391 aProperties
[1].State
= beans::PropertyState_DIRECT_VALUE
;
393 aProperties
[2].Name
= sBookmark
;
394 aProperties
[2].Handle
= -1;
395 aProperties
[2].Value
<<= msHyperlink
;
396 aProperties
[2].State
= beans::PropertyState_DIRECT_VALUE
;
398 const OUString
sAPIEventName( "OnClick" );
399 xEvents
->replaceByName( sAPIEventName
, Any( aProperties
) );
403 // in draw use the Bookmark property
404 Reference
< beans::XPropertySet
> xSet( mxShape
, UNO_QUERY_THROW
);
405 xSet
->setPropertyValue( sBookmark
, Any( msHyperlink
) );
406 xSet
->setPropertyValue( OUString( "OnClick" ), Any( ::com::sun::star::presentation::ClickAction_DOCUMENT
) );
409 catch(const Exception
&)
411 OSL_FAIL("xmloff::SdXMLShapeContext::EndElement(), exception caught while setting hyperlink!");
414 if( mxLockable
.is() )
415 mxLockable
->removeActionLock();
418 //////////////////////////////////////////////////////////////////////////////
420 void SdXMLShapeContext::AddShape(uno::Reference
< drawing::XShape
>& xShape
)
427 if(!maShapeName
.isEmpty())
429 uno::Reference
< container::XNamed
> xNamed( mxShape
, uno::UNO_QUERY
);
431 xNamed
->setName( maShapeName
);
434 UniReference
< XMLShapeImportHelper
> xImp( GetImport().GetShapeImport() );
435 xImp
->addShape( xShape
, mxAttrList
, mxShapes
);
437 if( mbClearDefaultAttributes
)
439 uno::Reference
<beans::XMultiPropertyStates
> xMultiPropertyStates(xShape
, uno::UNO_QUERY
);
440 if (xMultiPropertyStates
.is())
441 xMultiPropertyStates
->setAllPropertiesToDefault();
444 if( !mbVisible
|| !mbPrintable
) try
446 uno::Reference
< beans::XPropertySet
> xSet( xShape
, uno::UNO_QUERY_THROW
);
448 xSet
->setPropertyValue( rtl::OUString( "Visible" ), uno::Any( sal_False
) );
451 xSet
->setPropertyValue( rtl::OUString( "Printable" ), uno::Any( sal_False
) );
453 catch(const Exception
&)
455 OSL_FAIL( "SdXMLShapeContext::AddShape(), exception caught!" );
459 if(!mbTemporaryShape
&& (!GetImport().HasTextImport()
460 || !GetImport().GetTextImport()->IsInsideDeleteContext()))
462 xImp
->shapeWithZIndexAdded( xShape
, mnZOrder
);
465 if( !maShapeId
.isEmpty() )
467 uno::Reference
< uno::XInterface
> xRef( static_cast<uno::XInterface
*>(xShape
.get()) );
468 GetImport().getInterfaceToIdentifierMapper().registerReference( maShapeId
, xRef
);
471 // #91065# count only if counting for shape import is enabled
472 if(GetImport().GetShapeImport()->IsHandleProgressBarEnabled())
474 // #80365# increment progress bar at load once for each draw object
475 GetImport().GetProgressBarHelper()->Increment();
479 mxLockable
= uno::Reference
< document::XActionLockable
>::query( xShape
);
481 if( mxLockable
.is() )
482 mxLockable
->addActionLock();
486 //////////////////////////////////////////////////////////////////////////////
488 void SdXMLShapeContext::AddShape(const char* pServiceName
)
490 uno::Reference
< lang::XMultiServiceFactory
> xServiceFact(GetImport().GetModel(), uno::UNO_QUERY
);
491 if(xServiceFact
.is())
495 /* Since fix for issue i33294 the Writer model doesn't support
496 com.sun.star.drawing.OLE2Shape anymore.
497 To handle Draw OLE objects it's decided to import these
498 objects as com.sun.star.drawing.OLE2Shape and convert these
499 objects after the import into com.sun.star.drawing.GraphicObjectShape.
501 uno::Reference
< drawing::XShape
> xShape
;
502 if ( OUString::createFromAscii(pServiceName
).compareToAscii( "com.sun.star.drawing.OLE2Shape" ) == 0 &&
503 uno::Reference
< text::XTextDocument
>(GetImport().GetModel(), uno::UNO_QUERY
).is() )
505 xShape
= uno::Reference
< drawing::XShape
>(xServiceFact
->createInstance(OUString("com.sun.star.drawing.temporaryForXMLImportOLE2Shape")), uno::UNO_QUERY
);
509 xShape
= uno::Reference
< drawing::XShape
>(xServiceFact
->createInstance(OUString::createFromAscii(pServiceName
)), uno::UNO_QUERY
);
514 catch(const uno::Exception
& e
)
516 uno::Sequence
<rtl::OUString
> aSeq( 1 );
517 aSeq
[0] = OUString::createFromAscii(pServiceName
);
518 GetImport().SetError( XMLERROR_FLAG_ERROR
| XMLERROR_API
,
519 aSeq
, e
.Message
, NULL
);
524 //////////////////////////////////////////////////////////////////////////////
526 void SdXMLShapeContext::SetTransformation()
530 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
533 ::basegfx::B2DHomMatrix aTransformation
;
535 if(maSize
.Width
!= 1 || maSize
.Height
!= 1)
537 // take care there are no zeros used by error
538 if(0 == maSize
.Width
)
540 if(0 == maSize
.Height
)
543 // set global size. This should always be used.
544 aTransformation
.scale(maSize
.Width
, maSize
.Height
);
547 if(maPosition
.X
!= 0 || maPosition
.Y
!= 0)
549 // if global position is used, add it to transformation
550 aTransformation
.translate(maPosition
.X
, maPosition
.Y
);
553 if(mnTransform
.NeedsAction())
555 // transformation is used, apply to object.
556 // NOTICE: The transformation is applied AFTER evtl. used
557 // global positioning and scaling is used, so any shear or
558 // rotate used herein is applied around the (0,0) position
559 // of the PAGE object !!!
560 ::basegfx::B2DHomMatrix aMat
;
561 mnTransform
.GetFullTransform(aMat
);
563 // now add to transformation
564 aTransformation
*= aMat
;
567 // now set transformation for this object
569 drawing::HomogenMatrix3 aMatrix
;
571 aMatrix
.Line1
.Column1
= aTransformation
.get(0, 0);
572 aMatrix
.Line1
.Column2
= aTransformation
.get(0, 1);
573 aMatrix
.Line1
.Column3
= aTransformation
.get(0, 2);
575 aMatrix
.Line2
.Column1
= aTransformation
.get(1, 0);
576 aMatrix
.Line2
.Column2
= aTransformation
.get(1, 1);
577 aMatrix
.Line2
.Column3
= aTransformation
.get(1, 2);
579 aMatrix
.Line3
.Column1
= aTransformation
.get(2, 0);
580 aMatrix
.Line3
.Column2
= aTransformation
.get(2, 1);
581 aMatrix
.Line3
.Column3
= aTransformation
.get(2, 2);
585 xPropSet
->setPropertyValue(
586 OUString("Transformation"), aAny
);
591 //////////////////////////////////////////////////////////////////////////////
593 void SdXMLShapeContext::SetStyle( bool bSupportsStyle
/* = true */)
597 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
603 XMLPropStyleContext
* pDocStyle
= NULL
;
605 // set style on shape
606 if(maDrawStyleName
.isEmpty())
609 const SvXMLStyleContext
* pStyle
= 0L;
610 sal_Bool
bAutoStyle(sal_False
);
612 if(GetImport().GetShapeImport()->GetAutoStylesContext())
613 pStyle
= GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(mnStyleFamily
, maDrawStyleName
);
616 bAutoStyle
= sal_True
;
618 if(!pStyle
&& GetImport().GetShapeImport()->GetStylesContext())
619 pStyle
= GetImport().GetShapeImport()->GetStylesContext()->FindStyleChildContext(mnStyleFamily
, maDrawStyleName
);
621 OUString aStyleName
= maDrawStyleName
;
622 uno::Reference
< style::XStyle
> xStyle
;
624 if( pStyle
&& pStyle
->ISA(XMLShapeStyleContext
) )
626 pDocStyle
= PTR_CAST( XMLShapeStyleContext
, pStyle
);
628 if( pDocStyle
->GetStyle().is() )
630 xStyle
= pDocStyle
->GetStyle();
634 aStyleName
= pDocStyle
->GetParentName();
638 if( !xStyle
.is() && !aStyleName
.isEmpty() )
643 uno::Reference
< style::XStyleFamiliesSupplier
> xFamiliesSupplier( GetImport().GetModel(), uno::UNO_QUERY
);
645 if( xFamiliesSupplier
.is() )
647 uno::Reference
< container::XNameAccess
> xFamilies( xFamiliesSupplier
->getStyleFamilies() );
651 uno::Reference
< container::XNameAccess
> xFamily
;
653 if( XML_STYLE_FAMILY_SD_PRESENTATION_ID
== mnStyleFamily
)
655 aStyleName
= GetImport().GetStyleDisplayName(
656 XML_STYLE_FAMILY_SD_PRESENTATION_ID
,
658 sal_Int32 nPos
= aStyleName
.lastIndexOf( sal_Unicode('-') );
661 OUString
aFamily( aStyleName
.copy( 0, nPos
) );
663 xFamilies
->getByName( aFamily
) >>= xFamily
;
664 aStyleName
= aStyleName
.copy( nPos
+ 1 );
669 // get graphics familie
670 xFamilies
->getByName( OUString( "graphics" ) ) >>= xFamily
;
671 aStyleName
= GetImport().GetStyleDisplayName(
672 XML_STYLE_FAMILY_SD_GRAPHICS_ID
,
677 xFamily
->getByName( aStyleName
) >>= xStyle
;
681 catch(const uno::Exception
&)
683 OSL_FAIL( "could not find style for shape!" );
687 if( bSupportsStyle
&& xStyle
.is() )
691 // set style on object
694 xPropSet
->setPropertyValue(OUString("Style"), aAny
);
696 catch(const uno::Exception
&)
698 OSL_FAIL( "could not find style for shape!" );
702 // if this is an auto style, set its properties
703 if(bAutoStyle
&& pDocStyle
)
705 // set PropertySet on object
706 pDocStyle
->FillPropertySet(xPropSet
);
711 // try to set text auto style
714 // set style on shape
715 if( maTextStyleName
.isEmpty() )
718 if( NULL
== GetImport().GetShapeImport()->GetAutoStylesContext())
721 const SvXMLStyleContext
* pTempStyle
= GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(XML_STYLE_FAMILY_TEXT_PARAGRAPH
, maTextStyleName
);
722 XMLPropStyleContext
* pStyle
= PTR_CAST( XMLPropStyleContext
, pTempStyle
); // use temp var, PTR_CAST is a bad macro, FindStyleChildContext will be called twice
726 // set PropertySet on object
727 pStyle
->FillPropertySet(xPropSet
);
731 catch(const uno::Exception
&)
736 void SdXMLShapeContext::SetLayer()
738 if( !maLayerName
.isEmpty() )
742 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
746 aAny
<<= maLayerName
;
748 xPropSet
->setPropertyValue(OUString("LayerName"), aAny
);
752 catch(const uno::Exception
&)
758 void SdXMLShapeContext::SetThumbnail()
760 if( maThumbnailURL
.isEmpty() )
765 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
769 const OUString
sProperty("ThumbnailGraphicURL");
771 uno::Reference
< beans::XPropertySetInfo
> xPropSetInfo( xPropSet
->getPropertySetInfo() );
772 if( xPropSetInfo
.is() && xPropSetInfo
->hasPropertyByName( sProperty
) )
774 // load the thumbnail graphic and export it to a wmf stream so we can set
777 const OUString
aInternalURL( GetImport().ResolveGraphicObjectURL( maThumbnailURL
, sal_False
) );
778 xPropSet
->setPropertyValue( sProperty
, uno::makeAny( aInternalURL
) );
781 catch(const uno::Exception
&)
786 // this is called from the parent group for each unparsed attribute in the attribute list
787 void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
789 bool bHaveXmlId( false );
790 if( (XML_NAMESPACE_DRAW
== nPrefix
) || (XML_NAMESPACE_DRAW_EXT
== nPrefix
) )
792 if( IsXMLToken( rLocalName
, XML_ZINDEX
) )
794 mnZOrder
= rValue
.toInt32();
796 else if( IsXMLToken( rLocalName
, XML_ID
) )
798 if (!bHaveXmlId
) { maShapeId
= rValue
; };
800 else if( IsXMLToken( rLocalName
, XML_NAME
) )
802 maShapeName
= rValue
;
804 else if( IsXMLToken( rLocalName
, XML_STYLE_NAME
) )
806 maDrawStyleName
= rValue
;
808 else if( IsXMLToken( rLocalName
, XML_TEXT_STYLE_NAME
) )
810 maTextStyleName
= rValue
;
812 else if( IsXMLToken( rLocalName
, XML_LAYER
) )
814 maLayerName
= rValue
;
816 else if( IsXMLToken( rLocalName
, XML_TRANSFORM
) )
818 mnTransform
.SetString(rValue
, GetImport().GetMM100UnitConverter());
820 else if( IsXMLToken( rLocalName
, XML_DISPLAY
) )
822 mbVisible
= IsXMLToken( rValue
, XML_ALWAYS
) || IsXMLToken( rValue
, XML_SCREEN
);
823 mbPrintable
= IsXMLToken( rValue
, XML_ALWAYS
) || IsXMLToken( rValue
, XML_PRINTER
);
826 else if( XML_NAMESPACE_PRESENTATION
== nPrefix
)
828 if( IsXMLToken( rLocalName
, XML_USER_TRANSFORMED
) )
830 mbIsUserTransformed
= IsXMLToken( rValue
, XML_TRUE
);
832 else if( IsXMLToken( rLocalName
, XML_PLACEHOLDER
) )
834 mbIsPlaceholder
= IsXMLToken( rValue
, XML_TRUE
);
835 if( mbIsPlaceholder
)
836 mbClearDefaultAttributes
= false;
838 else if( IsXMLToken( rLocalName
, XML_CLASS
) )
840 maPresentationClass
= rValue
;
842 else if( IsXMLToken( rLocalName
, XML_STYLE_NAME
) )
844 maDrawStyleName
= rValue
;
845 mnStyleFamily
= XML_STYLE_FAMILY_SD_PRESENTATION_ID
;
848 else if( XML_NAMESPACE_SVG
== nPrefix
)
850 if( IsXMLToken( rLocalName
, XML_X
) )
852 GetImport().GetMM100UnitConverter().convertMeasureToCore(
853 maPosition
.X
, rValue
);
855 else if( IsXMLToken( rLocalName
, XML_Y
) )
857 GetImport().GetMM100UnitConverter().convertMeasureToCore(
858 maPosition
.Y
, rValue
);
860 else if( IsXMLToken( rLocalName
, XML_WIDTH
) )
862 GetImport().GetMM100UnitConverter().convertMeasureToCore(
863 maSize
.Width
, rValue
);
864 if( maSize
.Width
> 0 )
866 else if( maSize
.Width
< 0 )
869 else if( IsXMLToken( rLocalName
, XML_HEIGHT
) )
871 GetImport().GetMM100UnitConverter().convertMeasureToCore(
872 maSize
.Height
, rValue
);
873 if( maSize
.Height
> 0 )
875 else if( maSize
.Height
< 0 )
878 else if( IsXMLToken( rLocalName
, XML_TRANSFORM
) )
880 // because of #85127# take svg:transform into account and hanle like
881 // draw:transform for compatibility
882 mnTransform
.SetString(rValue
, GetImport().GetMM100UnitConverter());
886 else if( IsXMLToken( rLocalName
, XML_TITLE
) )
888 maShapeTitle
= rValue
;
890 else if( IsXMLToken( rLocalName
, XML_DESC
) )
892 maShapeDescription
= rValue
;
895 else if( (XML_NAMESPACE_NONE
== nPrefix
) || (XML_NAMESPACE_XML
== nPrefix
) )
897 if( IsXMLToken( rLocalName
, XML_ID
) )
905 sal_Bool
SdXMLShapeContext::isPresentationShape() const
907 if( !maPresentationClass
.isEmpty() && (const_cast<SdXMLShapeContext
*>(this))->GetImport().GetShapeImport()->IsPresentationShapesSupported() )
909 if(XML_STYLE_FAMILY_SD_PRESENTATION_ID
== mnStyleFamily
)
914 if( IsXMLToken( maPresentationClass
, XML_HEADER
) || IsXMLToken( maPresentationClass
, XML_FOOTER
) ||
915 IsXMLToken( maPresentationClass
, XML_PAGE_NUMBER
) || IsXMLToken( maPresentationClass
, XML_DATE_TIME
) )
924 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
925 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
927 TYPEINIT1( SdXMLRectShapeContext
, SdXMLShapeContext
);
929 SdXMLRectShapeContext::SdXMLRectShapeContext(
930 SvXMLImport
& rImport
,
932 const OUString
& rLocalName
,
933 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
934 uno::Reference
< drawing::XShapes
>& rShapes
,
935 sal_Bool bTemporaryShape
)
936 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
941 //////////////////////////////////////////////////////////////////////////////
943 SdXMLRectShapeContext::~SdXMLRectShapeContext()
947 //////////////////////////////////////////////////////////////////////////////
949 // this is called from the parent group for each unparsed attribute in the attribute list
950 void SdXMLRectShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
952 if( XML_NAMESPACE_DRAW
== nPrefix
)
954 if( IsXMLToken( rLocalName
, XML_CORNER_RADIUS
) )
956 GetImport().GetMM100UnitConverter().convertMeasureToCore(
962 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
965 //////////////////////////////////////////////////////////////////////////////
967 void SdXMLRectShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
969 // create rectangle shape
970 AddShape("com.sun.star.drawing.RectangleShape");
973 // Add, set Style and properties from base shape
977 // set pos, size, shear and rotate
982 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
987 xPropSet
->setPropertyValue(OUString("CornerRadius"), uno::makeAny( mnRadius
) );
989 catch(const uno::Exception
&)
991 OSL_FAIL( "exception during setting of corner radius!");
995 SdXMLShapeContext::StartElement(xAttrList
);
999 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1000 ////////////////////////////////////////3////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1002 TYPEINIT1( SdXMLLineShapeContext
, SdXMLShapeContext
);
1004 SdXMLLineShapeContext::SdXMLLineShapeContext(
1005 SvXMLImport
& rImport
,
1007 const OUString
& rLocalName
,
1008 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1009 uno::Reference
< drawing::XShapes
>& rShapes
,
1010 sal_Bool bTemporaryShape
)
1011 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1019 //////////////////////////////////////////////////////////////////////////////
1021 SdXMLLineShapeContext::~SdXMLLineShapeContext()
1025 //////////////////////////////////////////////////////////////////////////////
1027 // this is called from the parent group for each unparsed attribute in the attribute list
1028 void SdXMLLineShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1030 if( XML_NAMESPACE_SVG
== nPrefix
)
1032 if( IsXMLToken( rLocalName
, XML_X1
) )
1034 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1038 if( IsXMLToken( rLocalName
, XML_Y1
) )
1040 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1044 if( IsXMLToken( rLocalName
, XML_X2
) )
1046 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1050 if( IsXMLToken( rLocalName
, XML_Y2
) )
1052 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1058 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1061 //////////////////////////////////////////////////////////////////////////////
1063 void SdXMLLineShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1065 // #85920# use SetTransformation() to handle import of simple lines.
1066 // This is necessary to kake into account all anchor positions and
1067 // other things. All shape imports use the same import schemata now.
1068 // create necessary shape (Line Shape)
1069 AddShape("com.sun.star.drawing.PolyLineShape");
1073 // Add, set Style and properties from base shape
1077 // get sizes and offsets
1078 awt::Point
aTopLeft(mnX1
, mnY1
);
1079 awt::Point
aBottomRight(mnX2
, mnY2
);
1084 aBottomRight
.X
= mnX1
;
1090 aBottomRight
.Y
= mnY1
;
1093 // set local parameters on shape
1094 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
1097 drawing::PointSequenceSequence
aPolyPoly(1L);
1098 drawing::PointSequence
* pOuterSequence
= aPolyPoly
.getArray();
1099 pOuterSequence
->realloc(2L);
1100 awt::Point
* pInnerSequence
= pOuterSequence
->getArray();
1103 *pInnerSequence
= awt::Point( mnX1
- aTopLeft
.X
, mnY1
- aTopLeft
.Y
);
1105 *pInnerSequence
= awt::Point( mnX2
- aTopLeft
.X
, mnY2
- aTopLeft
.Y
);
1108 xPropSet
->setPropertyValue(
1109 OUString("Geometry"), aAny
);
1112 // set sizes for transformation
1113 maSize
.Width
= aBottomRight
.X
- aTopLeft
.X
;
1114 maSize
.Height
= aBottomRight
.Y
- aTopLeft
.Y
;
1115 maPosition
.X
= aTopLeft
.X
;
1116 maPosition
.Y
= aTopLeft
.Y
;
1118 // set pos, size, shear and rotate and get copy of matrix
1119 SetTransformation();
1121 SdXMLShapeContext::StartElement(xAttrList
);
1125 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1126 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1128 TYPEINIT1( SdXMLEllipseShapeContext
, SdXMLShapeContext
);
1130 SdXMLEllipseShapeContext::SdXMLEllipseShapeContext(
1131 SvXMLImport
& rImport
,
1133 const OUString
& rLocalName
,
1134 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1135 uno::Reference
< drawing::XShapes
>& rShapes
,
1136 sal_Bool bTemporaryShape
)
1137 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1142 meKind( drawing::CircleKind_FULL
),
1148 //////////////////////////////////////////////////////////////////////////////
1150 SdXMLEllipseShapeContext::~SdXMLEllipseShapeContext()
1154 //////////////////////////////////////////////////////////////////////////////
1156 // this is called from the parent group for each unparsed attribute in the attribute list
1157 void SdXMLEllipseShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1159 if( XML_NAMESPACE_SVG
== nPrefix
)
1161 if( IsXMLToken( rLocalName
, XML_RX
) )
1163 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1167 if( IsXMLToken( rLocalName
, XML_RY
) )
1169 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1173 if( IsXMLToken( rLocalName
, XML_CX
) )
1175 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1179 if( IsXMLToken( rLocalName
, XML_CY
) )
1181 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1185 if( IsXMLToken( rLocalName
, XML_R
) )
1187 // single radius, it's a circle and both radii are the same
1188 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1194 else if( XML_NAMESPACE_DRAW
== nPrefix
)
1196 if( IsXMLToken( rLocalName
, XML_KIND
) )
1199 if( SvXMLUnitConverter::convertEnum( eKind
, rValue
, aXML_CircleKind_EnumMap
) )
1205 if( IsXMLToken( rLocalName
, XML_START_ANGLE
) )
1208 if (::sax::Converter::convertDouble( dStartAngle
, rValue
))
1209 mnStartAngle
= (sal_Int32
)(dStartAngle
* 100.0);
1212 if( IsXMLToken( rLocalName
, XML_END_ANGLE
) )
1215 if (::sax::Converter::convertDouble( dEndAngle
, rValue
))
1216 mnEndAngle
= (sal_Int32
)(dEndAngle
* 100.0);
1221 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1224 //////////////////////////////////////////////////////////////////////////////
1226 void SdXMLEllipseShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1228 // create rectangle shape
1229 AddShape("com.sun.star.drawing.EllipseShape");
1232 // Add, set Style and properties from base shape
1236 // set pos, size, shear and rotate
1237 SetTransformation();
1239 if( meKind
!= drawing::CircleKind_FULL
)
1241 uno::Reference
< beans::XPropertySet
> xPropSet( mxShape
, uno::UNO_QUERY
);
1245 aAny
<<= (drawing::CircleKind
)meKind
;
1246 xPropSet
->setPropertyValue( OUString("CircleKind"), aAny
);
1248 aAny
<<= mnStartAngle
;
1249 xPropSet
->setPropertyValue( OUString("CircleStartAngle"), aAny
);
1251 aAny
<<= mnEndAngle
;
1252 xPropSet
->setPropertyValue( OUString("CircleEndAngle"), aAny
);
1256 SdXMLShapeContext::StartElement(xAttrList
);
1260 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1261 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1263 TYPEINIT1( SdXMLPolygonShapeContext
, SdXMLShapeContext
);
1265 SdXMLPolygonShapeContext::SdXMLPolygonShapeContext(
1266 SvXMLImport
& rImport
,
1268 const OUString
& rLocalName
,
1269 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1270 uno::Reference
< drawing::XShapes
>& rShapes
, sal_Bool bClosed
, sal_Bool bTemporaryShape
)
1271 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1276 //////////////////////////////////////////////////////////////////////////////
1278 // this is called from the parent group for each unparsed attribute in the attribute list
1279 void SdXMLPolygonShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1281 if( XML_NAMESPACE_SVG
== nPrefix
)
1283 if( IsXMLToken( rLocalName
, XML_VIEWBOX
) )
1289 else if( XML_NAMESPACE_DRAW
== nPrefix
)
1291 if( IsXMLToken( rLocalName
, XML_POINTS
) )
1298 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1301 //////////////////////////////////////////////////////////////////////////////
1303 SdXMLPolygonShapeContext::~SdXMLPolygonShapeContext()
1307 //////////////////////////////////////////////////////////////////////////////
1309 void SdXMLPolygonShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1311 // Add, set Style and properties from base shape
1313 AddShape("com.sun.star.drawing.PolyPolygonShape");
1315 AddShape("com.sun.star.drawing.PolyLineShape");
1322 // set local parameters on shape
1323 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
1327 if(!maPoints
.isEmpty() && !maViewBox
.isEmpty())
1329 SdXMLImExViewBox
aViewBox(maViewBox
, GetImport().GetMM100UnitConverter());
1330 awt::Size
aSize(aViewBox
.GetWidth(), aViewBox
.GetHeight());
1331 if (maSize
.Width
!= 0 && maSize
.Height
!=0)
1335 awt::Point
aPosition(aViewBox
.GetX(), aViewBox
.GetY());
1336 SdXMLImExPointsElement
aPoints(maPoints
, aViewBox
,
1337 aPosition
, aSize
, GetImport().GetMM100UnitConverter());
1340 aAny
<<= aPoints
.GetPointSequenceSequence();
1341 xPropSet
->setPropertyValue(
1342 OUString("Geometry"), aAny
);
1346 // set pos, size, shear and rotate and get copy of matrix
1347 SetTransformation();
1349 SdXMLShapeContext::StartElement(xAttrList
);
1353 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1354 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1356 TYPEINIT1( SdXMLPathShapeContext
, SdXMLShapeContext
);
1358 SdXMLPathShapeContext::SdXMLPathShapeContext(
1359 SvXMLImport
& rImport
,
1361 const OUString
& rLocalName
,
1362 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1363 uno::Reference
< drawing::XShapes
>& rShapes
,
1364 sal_Bool bTemporaryShape
)
1365 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
)
1369 //////////////////////////////////////////////////////////////////////////////
1371 SdXMLPathShapeContext::~SdXMLPathShapeContext()
1375 //////////////////////////////////////////////////////////////////////////////
1377 // this is called from the parent group for each unparsed attribute in the attribute list
1378 void SdXMLPathShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1380 if( XML_NAMESPACE_SVG
== nPrefix
)
1382 if( IsXMLToken( rLocalName
, XML_VIEWBOX
) )
1387 else if( IsXMLToken( rLocalName
, XML_D
) )
1394 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1397 //////////////////////////////////////////////////////////////////////////////
1399 void SdXMLPathShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1401 // create polygon shape
1404 // prepare some of the parameters
1405 SdXMLImExViewBox
aViewBox(maViewBox
, GetImport().GetMM100UnitConverter());
1406 awt::Size
aSize(aViewBox
.GetWidth(), aViewBox
.GetHeight());
1407 awt::Point
aPosition(aViewBox
.GetX(), aViewBox
.GetY());
1408 if (maSize
.Width
!= 0 && maSize
.Height
!=0)
1412 SdXMLImExSvgDElement
aPoints(maD
, aViewBox
, aPosition
, aSize
, GetImport());
1414 const char* pService
;
1416 if(aPoints
.IsCurve())
1418 if(aPoints
.IsClosed())
1420 pService
= "com.sun.star.drawing.ClosedBezierShape";
1424 pService
= "com.sun.star.drawing.OpenBezierShape";
1429 if(aPoints
.IsClosed())
1431 pService
= "com.sun.star.drawing.PolyPolygonShape";
1435 pService
= "com.sun.star.drawing.PolyLineShape";
1439 // Add, set Style and properties from base shape
1442 // #89344# test for mxShape.is() and not for mxShapes.is() to support
1443 // shape import helper classes WITHOUT XShapes (member mxShapes). This
1444 // is used by the writer.
1450 // set local parameters on shape
1451 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
1459 if(aPoints
.IsCurve())
1461 drawing::PolyPolygonBezierCoords
aSourcePolyPolygon(
1462 aPoints
.GetPointSequenceSequence(),
1463 aPoints
.GetFlagSequenceSequence());
1465 aAny
<<= aSourcePolyPolygon
;
1466 xPropSet
->setPropertyValue(
1467 OUString("Geometry"), aAny
);
1471 aAny
<<= aPoints
.GetPointSequenceSequence();
1472 xPropSet
->setPropertyValue(
1473 OUString("Geometry"), aAny
);
1478 // set pos, size, shear and rotate
1479 SetTransformation();
1481 SdXMLShapeContext::StartElement(xAttrList
);
1486 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1487 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1489 TYPEINIT1( SdXMLTextBoxShapeContext
, SdXMLShapeContext
);
1491 SdXMLTextBoxShapeContext::SdXMLTextBoxShapeContext(
1492 SvXMLImport
& rImport
,
1494 const OUString
& rLocalName
,
1495 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1496 uno::Reference
< drawing::XShapes
>& rShapes
,
1497 sal_Bool bTemporaryShape
)
1498 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1503 //////////////////////////////////////////////////////////////////////////////
1505 SdXMLTextBoxShapeContext::~SdXMLTextBoxShapeContext()
1509 //////////////////////////////////////////////////////////////////////////////
1511 // this is called from the parent group for each unparsed attribute in the attribute list
1512 void SdXMLTextBoxShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1514 if( XML_NAMESPACE_DRAW
== nPrefix
)
1516 if( IsXMLToken( rLocalName
, XML_CORNER_RADIUS
) )
1518 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1524 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1527 //////////////////////////////////////////////////////////////////////////////
1529 void SdXMLTextBoxShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>&)
1531 // create textbox shape
1532 sal_Bool bIsPresShape
= sal_False
;
1533 bool bClearText
= false;
1535 const char *pService
= NULL
;
1537 if( isPresentationShape() )
1539 // check if the current document supports presentation shapes
1540 if( GetImport().GetShapeImport()->IsPresentationShapesSupported() )
1542 if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_SUBTITLE
))
1544 // XmlShapeTypePresSubtitleShape
1545 pService
= "com.sun.star.presentation.SubtitleShape";
1547 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_OUTLINE
) )
1549 // XmlShapeTypePresOutlinerShape
1550 pService
= "com.sun.star.presentation.OutlinerShape";
1552 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_NOTES
) )
1554 // XmlShapeTypePresNotesShape
1555 pService
= "com.sun.star.presentation.NotesShape";
1557 else if( IsXMLToken( maPresentationClass
, XML_HEADER
) )
1559 // XmlShapeTypePresHeaderShape
1560 pService
= "com.sun.star.presentation.HeaderShape";
1563 else if( IsXMLToken( maPresentationClass
, XML_FOOTER
) )
1565 // XmlShapeTypePresFooterShape
1566 pService
= "com.sun.star.presentation.FooterShape";
1569 else if( IsXMLToken( maPresentationClass
, XML_PAGE_NUMBER
) )
1571 // XmlShapeTypePresSlideNumberShape
1572 pService
= "com.sun.star.presentation.SlideNumberShape";
1575 else if( IsXMLToken( maPresentationClass
, XML_DATE_TIME
) )
1577 // XmlShapeTypePresDateTimeShape
1578 pService
= "com.sun.star.presentation.DateTimeShape";
1581 else // IsXMLToken( maPresentationClass, XML_PRESENTATION_TITLE ) )
1583 // XmlShapeTypePresTitleTextShape
1584 pService
= "com.sun.star.presentation.TitleTextShape";
1586 bIsPresShape
= sal_True
;
1590 if( NULL
== pService
)
1592 // normal text shape
1593 pService
= "com.sun.star.drawing.TextShape";
1596 // Add, set Style and properties from base shape
1606 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
1609 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
1610 if( xPropsInfo
.is() )
1612 if( !mbIsPlaceholder
&& xPropsInfo
->hasPropertyByName(OUString("IsEmptyPresentationObject" )))
1613 xProps
->setPropertyValue( OUString("IsEmptyPresentationObject" ), ::cppu::bool2any( sal_False
) );
1615 if( mbIsUserTransformed
&& xPropsInfo
->hasPropertyByName(OUString("IsPlaceholderDependent" )))
1616 xProps
->setPropertyValue( OUString("IsPlaceholderDependent" ), ::cppu::bool2any( sal_False
) );
1623 uno::Reference
< text::XText
> xText( mxShape
, uno::UNO_QUERY
);
1625 xText
->setString( aEmpty
);
1628 // set parameters on shape
1629 //A AW->CL: Eventually You need to strip scale and translate from the transformation
1630 //A to reach the same goal again.
1631 //A if(!bIsPresShape || mbIsUserTransformed)
1633 //A // set pos and size on shape, this should remove binding
1634 //A // to pres object on masterpage
1635 //A SetSizeAndPosition();
1638 // set pos, size, shear and rotate
1639 SetTransformation();
1643 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
1648 xPropSet
->setPropertyValue(OUString("CornerRadius"), uno::makeAny( mnRadius
) );
1650 catch(const uno::Exception
&)
1652 OSL_FAIL( "exception during setting of corner radius!");
1657 SdXMLShapeContext::StartElement(mxAttrList
);
1661 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1662 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1664 TYPEINIT1( SdXMLControlShapeContext
, SdXMLShapeContext
);
1666 SdXMLControlShapeContext::SdXMLControlShapeContext(
1667 SvXMLImport
& rImport
,
1669 const OUString
& rLocalName
,
1670 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1671 uno::Reference
< drawing::XShapes
>& rShapes
,
1672 sal_Bool bTemporaryShape
)
1673 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
)
1677 //////////////////////////////////////////////////////////////////////////////
1679 SdXMLControlShapeContext::~SdXMLControlShapeContext()
1683 //////////////////////////////////////////////////////////////////////////////
1685 // this is called from the parent group for each unparsed attribute in the attribute list
1686 void SdXMLControlShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1688 if( XML_NAMESPACE_DRAW
== nPrefix
)
1690 if( IsXMLToken( rLocalName
, XML_CONTROL
) )
1697 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1700 void SdXMLControlShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1702 // create Control shape
1703 // add, set style and properties from base shape
1704 AddShape("com.sun.star.drawing.ControlShape");
1707 DBG_ASSERT( !maFormId
.isEmpty(), "draw:control without a form:id attribute!" );
1708 if( !maFormId
.isEmpty() )
1710 if( GetImport().IsFormsSupported() )
1712 uno::Reference
< awt::XControlModel
> xControlModel( GetImport().GetFormImport()->lookupControl( maFormId
), uno::UNO_QUERY
);
1713 if( xControlModel
.is() )
1715 uno::Reference
< drawing::XControlShape
> xControl( mxShape
, uno::UNO_QUERY
);
1717 xControl
->setControl( xControlModel
);
1726 // set pos, size, shear and rotate
1727 SetTransformation();
1729 SdXMLShapeContext::StartElement(xAttrList
);
1733 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1734 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1736 TYPEINIT1( SdXMLConnectorShapeContext
, SdXMLShapeContext
);
1738 SdXMLConnectorShapeContext::SdXMLConnectorShapeContext(
1739 SvXMLImport
& rImport
,
1741 const OUString
& rLocalName
,
1742 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1743 uno::Reference
< drawing::XShapes
>& rShapes
,
1744 sal_Bool bTemporaryShape
)
1745 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1748 mnType( (sal_uInt16
)drawing::ConnectorType_STANDARD
),
1757 //////////////////////////////////////////////////////////////////////////////
1759 SdXMLConnectorShapeContext::~SdXMLConnectorShapeContext()
1763 //////////////////////////////////////////////////////////////////////////////
1765 // this is called from the parent group for each unparsed attribute in the attribute list
1766 void SdXMLConnectorShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1770 case XML_NAMESPACE_DRAW
:
1772 if( IsXMLToken( rLocalName
, XML_START_SHAPE
) )
1774 maStartShapeId
= rValue
;
1777 if( IsXMLToken( rLocalName
, XML_START_GLUE_POINT
) )
1779 mnStartGlueId
= rValue
.toInt32();
1782 if( IsXMLToken( rLocalName
, XML_END_SHAPE
) )
1784 maEndShapeId
= rValue
;
1787 if( IsXMLToken( rLocalName
, XML_END_GLUE_POINT
) )
1789 mnEndGlueId
= rValue
.toInt32();
1792 if( IsXMLToken( rLocalName
, XML_LINE_SKEW
) )
1794 SvXMLTokenEnumerator
aTokenEnum( rValue
);
1796 if( aTokenEnum
.getNextToken( aToken
) )
1798 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1800 if( aTokenEnum
.getNextToken( aToken
) )
1802 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1804 if( aTokenEnum
.getNextToken( aToken
) )
1806 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1813 if( IsXMLToken( rLocalName
, XML_TYPE
) )
1815 SvXMLUnitConverter::convertEnum( mnType
, rValue
, aXML_ConnectionKind_EnumMap
);
1819 case XML_NAMESPACE_SVG
:
1821 if( IsXMLToken( rLocalName
, XML_X1
) )
1823 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1827 if( IsXMLToken( rLocalName
, XML_Y1
) )
1829 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1833 if( IsXMLToken( rLocalName
, XML_X2
) )
1835 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1839 if( IsXMLToken( rLocalName
, XML_Y2
) )
1841 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1845 if( IsXMLToken( rLocalName
, XML_D
) )
1847 SdXMLImExViewBox
aViewBox( 0, 0, 1, 1 );
1848 awt::Point
aPoint( 0, 0 );
1849 awt::Size
aSize( 1, 1 );
1851 SdXMLImExSvgDElement
aPoints( rValue
, aViewBox
, aPoint
, aSize
, GetImport() );
1853 if ( aPoints
.IsCurve() )
1855 drawing::PolyPolygonBezierCoords
aSourcePolyPolygon(
1856 aPoints
.GetPointSequenceSequence(),
1857 aPoints
.GetFlagSequenceSequence());
1858 maPath
<<= aSourcePolyPolygon
;
1862 const drawing::PointSequenceSequence
& rOuterSeq
= aPoints
.GetPointSequenceSequence();
1863 drawing::FlagSequenceSequence
aFlagSeqSeq( rOuterSeq
.getLength() );
1864 for ( int a
= 0; a
< rOuterSeq
.getLength(); a
++ )
1865 aFlagSeqSeq
[ a
] = drawing::FlagSequence( rOuterSeq
[ a
].getLength() );
1867 drawing::PolyPolygonBezierCoords
aSourcePolyPolygon(
1868 aPoints
.GetPointSequenceSequence(),
1870 maPath
<<= aSourcePolyPolygon
;
1876 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1879 //////////////////////////////////////////////////////////////////////////////
1881 void SdXMLConnectorShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1884 // For security reasons, do not add empty connectors. There may have been an error in EA2
1885 // that created empty, far set off connectors (e.g. 63 meters below top of document). This
1886 // is not guaranteed, but it's definitely safe to not add empty connectors.
1887 sal_Bool
bDoAdd(sal_True
);
1889 if( maStartShapeId
.isEmpty()
1890 && maEndShapeId
.isEmpty()
1891 && maStart
.X
== maEnd
.X
1892 && maStart
.Y
== maEnd
.Y
1903 // create Connector shape
1904 // add, set style and properties from base shape
1905 AddShape("com.sun.star.drawing.ConnectorShape");
1908 // add connection ids
1909 if( !maStartShapeId
.isEmpty() )
1910 GetImport().GetShapeImport()->addShapeConnection( mxShape
, sal_True
, maStartShapeId
, mnStartGlueId
);
1911 if( !maEndShapeId
.isEmpty() )
1912 GetImport().GetShapeImport()->addShapeConnection( mxShape
, sal_False
, maEndShapeId
, mnEndGlueId
);
1914 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
1919 xProps
->setPropertyValue(OUString("StartPosition"), aAny
);
1922 xProps
->setPropertyValue(OUString("EndPosition"), aAny
);
1924 aAny
<<= (drawing::ConnectorType
)mnType
;
1925 xProps
->setPropertyValue(OUString("EdgeKind"), aAny
);
1928 xProps
->setPropertyValue(OUString("EdgeLine1Delta"), aAny
);
1931 xProps
->setPropertyValue(OUString("EdgeLine2Delta"), aAny
);
1934 xProps
->setPropertyValue(OUString("EdgeLine3Delta"), aAny
);
1939 if ( maPath
.hasValue() )
1942 // Ignore svg:d attribute for text documents created by OpenOffice.org
1943 // versions before OOo 3.3, because these OOo versions are storing
1944 // svg:d values not using the correct unit.
1945 bool bApplySVGD( true );
1946 if ( uno::Reference
< text::XTextDocument
>(GetImport().GetModel(), uno::UNO_QUERY
).is() )
1948 sal_Int32
nUPD( 0 );
1949 sal_Int32
nBuild( 0 );
1950 const bool bBuildIdFound
= GetImport().getBuildIds( nUPD
, nBuild
);
1951 if ( GetImport().IsTextDocInOOoFileFormat() ||
1953 ( ( nUPD
== 641 ) || ( nUPD
== 645 ) || // prior OOo 2.0
1954 ( nUPD
== 680 ) || // OOo 2.x
1955 ( nUPD
== 300 ) || // OOo 3.0 - OOo 3.0.1
1956 ( nUPD
== 310 ) || // OOo 3.1 - OOo 3.1.1
1957 ( nUPD
== 320 ) ) ) ) // OOo 3.2 - OOo 3.2.1
1965 xProps
->setPropertyValue( OUString("PolyPolygonBezier" ), maPath
);
1969 SdXMLShapeContext::StartElement(xAttrList
);
1974 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1975 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1977 TYPEINIT1( SdXMLMeasureShapeContext
, SdXMLShapeContext
);
1979 SdXMLMeasureShapeContext::SdXMLMeasureShapeContext(
1980 SvXMLImport
& rImport
,
1982 const OUString
& rLocalName
,
1983 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1984 uno::Reference
< drawing::XShapes
>& rShapes
,
1985 sal_Bool bTemporaryShape
)
1986 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1992 //////////////////////////////////////////////////////////////////////////////
1994 SdXMLMeasureShapeContext::~SdXMLMeasureShapeContext()
1998 // this is called from the parent group for each unparsed attribute in the attribute list
1999 void SdXMLMeasureShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2003 case XML_NAMESPACE_SVG
:
2005 if( IsXMLToken( rLocalName
, XML_X1
) )
2007 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2011 if( IsXMLToken( rLocalName
, XML_Y1
) )
2013 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2017 if( IsXMLToken( rLocalName
, XML_X2
) )
2019 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2023 if( IsXMLToken( rLocalName
, XML_Y2
) )
2025 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2032 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2035 //////////////////////////////////////////////////////////////////////////////
2037 void SdXMLMeasureShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
2039 // create Measure shape
2040 // add, set style and properties from base shape
2041 AddShape("com.sun.star.drawing.MeasureShape");
2047 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
2052 xProps
->setPropertyValue(OUString("StartPosition"), aAny
);
2055 xProps
->setPropertyValue(OUString("EndPosition"), aAny
);
2058 // delete pre created fields
2059 uno::Reference
< text::XText
> xText( mxShape
, uno::UNO_QUERY
);
2062 const OUString
aEmpty( " " );
2063 xText
->setString( aEmpty
);
2066 SdXMLShapeContext::StartElement(xAttrList
);
2070 void SdXMLMeasureShapeContext::EndElement()
2074 // delete pre created fields
2075 uno::Reference
< text::XText
> xText( mxShape
, uno::UNO_QUERY
);
2079 uno::Reference
< text::XTextCursor
> xCursor( xText
->createTextCursor() );
2083 const OUString aEmpty
;
2084 xCursor
->collapseToStart();
2085 xCursor
->goRight( 1, sal_True
);
2086 xCursor
->setString( aEmpty
);
2090 SdXMLShapeContext::EndElement();
2093 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2094 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2096 TYPEINIT1( SdXMLPageShapeContext
, SdXMLShapeContext
);
2098 SdXMLPageShapeContext::SdXMLPageShapeContext(
2099 SvXMLImport
& rImport
,
2101 const OUString
& rLocalName
,
2102 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2103 uno::Reference
< drawing::XShapes
>& rShapes
,
2104 sal_Bool bTemporaryShape
)
2105 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
), mnPageNumber(0)
2107 mbClearDefaultAttributes
= false;
2110 //////////////////////////////////////////////////////////////////////////////
2112 SdXMLPageShapeContext::~SdXMLPageShapeContext()
2116 //////////////////////////////////////////////////////////////////////////////
2118 // this is called from the parent group for each unparsed attribute in the attribute list
2119 void SdXMLPageShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2121 if( XML_NAMESPACE_DRAW
== nPrefix
)
2123 if( IsXMLToken( rLocalName
, XML_PAGE_NUMBER
) )
2125 mnPageNumber
= rValue
.toInt32();
2130 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2133 //////////////////////////////////////////////////////////////////////////////
2135 void SdXMLPageShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
2137 // create Page shape
2138 // add, set style and properties from base shape
2140 // #86163# take into account which type of PageShape needs to
2141 // be constructed. It's an pres shape if presentation:XML_CLASS == XML_PRESENTATION_PAGE.
2142 sal_Bool bIsPresentation
= !maPresentationClass
.isEmpty() &&
2143 GetImport().GetShapeImport()->IsPresentationShapesSupported();
2145 uno::Reference
< lang::XServiceInfo
> xInfo( mxShapes
, uno::UNO_QUERY
);
2146 const sal_Bool bIsOnHandoutPage
= xInfo
.is() && xInfo
->supportsService( OUString( "com.sun.star.presentation.HandoutMasterPage") );
2148 if( bIsOnHandoutPage
)
2150 AddShape("com.sun.star.presentation.HandoutShape");
2154 if(bIsPresentation
&& !IsXMLToken( maPresentationClass
, XML_PRESENTATION_PAGE
) )
2156 bIsPresentation
= sal_False
;
2161 AddShape("com.sun.star.presentation.PageShape");
2165 AddShape("com.sun.star.drawing.PageShape");
2174 // set pos, size, shear and rotate
2175 SetTransformation();
2177 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
2180 uno::Reference
< beans::XPropertySetInfo
> xPropSetInfo( xPropSet
->getPropertySetInfo() );
2181 const OUString
aPageNumberStr("PageNumber");
2182 if( xPropSetInfo
.is() && xPropSetInfo
->hasPropertyByName(aPageNumberStr
))
2183 xPropSet
->setPropertyValue(aPageNumberStr
, uno::makeAny( mnPageNumber
));
2186 SdXMLShapeContext::StartElement(xAttrList
);
2190 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2191 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2193 TYPEINIT1( SdXMLCaptionShapeContext
, SdXMLShapeContext
);
2195 SdXMLCaptionShapeContext::SdXMLCaptionShapeContext(
2196 SvXMLImport
& rImport
,
2198 const OUString
& rLocalName
,
2199 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2200 uno::Reference
< drawing::XShapes
>& rShapes
,
2201 sal_Bool bTemporaryShape
)
2202 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2203 // #86616# for correct edge rounding import mnRadius needs to be initialized
2208 //////////////////////////////////////////////////////////////////////////////
2210 SdXMLCaptionShapeContext::~SdXMLCaptionShapeContext()
2214 //////////////////////////////////////////////////////////////////////////////
2216 void SdXMLCaptionShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
2218 // create Caption shape
2219 // add, set style and properties from base shape
2220 AddShape("com.sun.star.drawing.CaptionShape");
2226 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
2228 // SJ: If AutoGrowWidthItem is set, SetTransformation will lead to the wrong SnapRect
2229 // because NbcAdjustTextFrameWidthAndHeight() is called (text is set later and center alignment
2230 // is the default setting, so the top left reference point that is used by the caption point is
2231 // no longer correct) There are two ways to solve this problem, temporarily disabling the
2232 // autogrowwith as we are doing here or to apply the CaptionPoint after setting text
2233 sal_Bool bIsAutoGrowWidth
= sal_False
;
2236 uno::Any
aAny( xProps
->getPropertyValue( OUString("TextAutoGrowWidth" ) ) );
2237 aAny
>>= bIsAutoGrowWidth
;
2239 if ( bIsAutoGrowWidth
)
2240 xProps
->setPropertyValue( OUString("TextAutoGrowWidth"), uno::makeAny( sal_False
) );
2243 // set pos, size, shear and rotate
2244 SetTransformation();
2246 xProps
->setPropertyValue(OUString("CaptionPoint"), uno::makeAny( maCaptionPoint
) );
2248 if ( bIsAutoGrowWidth
)
2249 xProps
->setPropertyValue( OUString("TextAutoGrowWidth"), uno::makeAny( sal_True
) );
2253 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
2258 xPropSet
->setPropertyValue(OUString("CornerRadius"), uno::makeAny( mnRadius
) );
2260 catch(const uno::Exception
&)
2262 OSL_FAIL( "exception during setting of corner radius!");
2267 SdXMLShapeContext::StartElement(xAttrList
);
2271 // this is called from the parent group for each unparsed attribute in the attribute list
2272 void SdXMLCaptionShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2274 if( XML_NAMESPACE_DRAW
== nPrefix
)
2276 if( IsXMLToken( rLocalName
, XML_CAPTION_POINT_X
) )
2278 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2279 maCaptionPoint
.X
, rValue
);
2282 if( IsXMLToken( rLocalName
, XML_CAPTION_POINT_Y
) )
2284 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2285 maCaptionPoint
.Y
, rValue
);
2288 if( IsXMLToken( rLocalName
, XML_CORNER_RADIUS
) )
2290 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2295 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2298 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2299 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2301 TYPEINIT1( SdXMLGraphicObjectShapeContext
, SdXMLShapeContext
);
2303 SdXMLGraphicObjectShapeContext::SdXMLGraphicObjectShapeContext(
2304 SvXMLImport
& rImport
,
2306 const OUString
& rLocalName
,
2307 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2308 uno::Reference
< drawing::XShapes
>& rShapes
,
2309 sal_Bool bTemporaryShape
)
2310 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2315 //////////////////////////////////////////////////////////////////////////////
2317 // this is called from the parent group for each unparsed attribute in the attribute list
2318 void SdXMLGraphicObjectShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2320 if( XML_NAMESPACE_XLINK
== nPrefix
)
2322 if( IsXMLToken( rLocalName
, XML_HREF
) )
2329 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2332 //////////////////////////////////////////////////////////////////////////////
2334 void SdXMLGraphicObjectShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& )
2336 // create graphic object shape
2337 const char *pService
;
2339 if( IsXMLToken( maPresentationClass
, XML_GRAPHIC
) && GetImport().GetShapeImport()->IsPresentationShapesSupported() )
2341 pService
= "com.sun.star.presentation.GraphicObjectShape";
2345 pService
= "com.sun.star.drawing.GraphicObjectShape";
2348 AddShape( pService
);
2355 uno::Reference
< beans::XPropertySet
> xPropset(mxShape
, uno::UNO_QUERY
);
2358 // since OOo 1.x had no line or fill style for graphics, but may create
2359 // documents with them, we have to override them here
2360 sal_Int32 nUPD
, nBuildId
;
2361 if( GetImport().getBuildIds( nUPD
, nBuildId
) && (nUPD
== 645) ) try
2363 xPropset
->setPropertyValue( OUString("FillStyle"), Any( FillStyle_NONE
) );
2364 xPropset
->setPropertyValue( OUString("LineStyle"), Any( LineStyle_NONE
) );
2366 catch(const Exception
&)
2370 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xPropset
->getPropertySetInfo() );
2371 if( xPropsInfo
.is() && xPropsInfo
->hasPropertyByName(OUString("IsEmptyPresentationObject" )))
2372 xPropset
->setPropertyValue( OUString("IsEmptyPresentationObject" ), ::cppu::bool2any( mbIsPlaceholder
) );
2374 if( !mbIsPlaceholder
)
2376 if( !maURL
.isEmpty() )
2379 aAny
<<= GetImport().ResolveGraphicObjectURL( maURL
, GetImport().isGraphicLoadOnDemandSupported() );
2382 xPropset
->setPropertyValue( OUString("GraphicURL" ), aAny
);
2383 xPropset
->setPropertyValue( OUString("GraphicStreamURL" ), aAny
);
2385 catch (const lang::IllegalArgumentException
&)
2392 if(mbIsUserTransformed
)
2394 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2397 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
2398 if( xPropsInfo
.is() )
2400 if( xPropsInfo
->hasPropertyByName(OUString("IsPlaceholderDependent" )))
2401 xProps
->setPropertyValue( OUString("IsPlaceholderDependent" ), ::cppu::bool2any( sal_False
) );
2406 // set pos, size, shear and rotate
2407 SetTransformation();
2409 SdXMLShapeContext::StartElement(mxAttrList
);
2413 void SdXMLGraphicObjectShapeContext::EndElement()
2415 if( mxBase64Stream
.is() )
2417 OUString
sURL( GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream
) );
2418 if( !sURL
.isEmpty() )
2422 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2425 const uno::Any
aAny( uno::makeAny( sURL
) );
2426 xProps
->setPropertyValue( OUString("GraphicURL" ), aAny
);
2427 xProps
->setPropertyValue( OUString("GraphicStreamURL" ), aAny
);
2430 catch (const lang::IllegalArgumentException
&)
2436 SdXMLShapeContext::EndElement();
2440 //////////////////////////////////////////////////////////////////////////////
2442 SvXMLImportContext
* SdXMLGraphicObjectShapeContext::CreateChildContext(
2443 sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
,
2444 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
)
2446 SvXMLImportContext
* pContext
= NULL
;
2448 if( (XML_NAMESPACE_OFFICE
== nPrefix
) &&
2449 xmloff::token::IsXMLToken( rLocalName
, xmloff::token::XML_BINARY_DATA
) )
2451 if( maURL
.isEmpty() && !mxBase64Stream
.is() )
2453 mxBase64Stream
= GetImport().GetStreamForGraphicObjectURLFromBase64();
2454 if( mxBase64Stream
.is() )
2455 pContext
= new XMLBase64ImportContext( GetImport(), nPrefix
,
2456 rLocalName
, xAttrList
,
2461 // delegate to parent class if no context could be created
2462 if ( NULL
== pContext
)
2463 pContext
= SdXMLShapeContext::CreateChildContext(nPrefix
, rLocalName
,
2469 //////////////////////////////////////////////////////////////////////////////
2471 SdXMLGraphicObjectShapeContext::~SdXMLGraphicObjectShapeContext()
2476 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2477 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2479 TYPEINIT1( SdXMLChartShapeContext
, SdXMLShapeContext
);
2481 SdXMLChartShapeContext::SdXMLChartShapeContext(
2482 SvXMLImport
& rImport
,
2484 const OUString
& rLocalName
,
2485 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2486 uno::Reference
< drawing::XShapes
>& rShapes
,
2487 sal_Bool bTemporaryShape
)
2488 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2489 mpChartContext( NULL
)
2493 //////////////////////////////////////////////////////////////////////////////
2495 SdXMLChartShapeContext::~SdXMLChartShapeContext()
2497 if( mpChartContext
)
2498 delete mpChartContext
;
2501 //////////////////////////////////////////////////////////////////////////////
2503 void SdXMLChartShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
2505 const sal_Bool bIsPresentation
= isPresentationShape();
2507 AddShape( bIsPresentation
? "com.sun.star.presentation.ChartShape" : "com.sun.star.drawing.OLE2Shape" );
2514 if( !mbIsPlaceholder
)
2516 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2519 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
2520 if( xPropsInfo
.is() && xPropsInfo
->hasPropertyByName(OUString("IsEmptyPresentationObject" )))
2521 xProps
->setPropertyValue( OUString("IsEmptyPresentationObject" ), ::cppu::bool2any( sal_False
) );
2525 const OUString
aCLSID( "12DCAE26-281F-416F-a234-c3086127382e");
2528 xProps
->setPropertyValue( OUString("CLSID" ), aAny
);
2530 aAny
= xProps
->getPropertyValue( OUString("Model" ) );
2531 uno::Reference
< frame::XModel
> xChartModel
;
2532 if( aAny
>>= xChartModel
)
2534 mpChartContext
= GetImport().GetChartImport()->CreateChartContext( GetImport(), XML_NAMESPACE_SVG
, GetXMLToken(XML_CHART
), xChartModel
, xAttrList
);
2539 if(mbIsUserTransformed
)
2541 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2544 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
2545 if( xPropsInfo
.is() )
2547 if( xPropsInfo
->hasPropertyByName(OUString("IsPlaceholderDependent" )))
2548 xProps
->setPropertyValue( OUString("IsPlaceholderDependent" ), ::cppu::bool2any( sal_False
) );
2554 // set pos, size, shear and rotate
2555 SetTransformation();
2557 SdXMLShapeContext::StartElement(xAttrList
);
2559 if( mpChartContext
)
2560 mpChartContext
->StartElement( xAttrList
);
2564 void SdXMLChartShapeContext::EndElement()
2566 if( mpChartContext
)
2567 mpChartContext
->EndElement();
2569 SdXMLShapeContext::EndElement();
2572 void SdXMLChartShapeContext::Characters( const ::rtl::OUString
& rChars
)
2574 if( mpChartContext
)
2575 mpChartContext
->Characters( rChars
);
2578 SvXMLImportContext
* SdXMLChartShapeContext::CreateChildContext( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
,
2579 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
2581 if( mpChartContext
)
2582 return mpChartContext
->CreateChildContext( nPrefix
, rLocalName
, xAttrList
);
2587 //////////////////////////////////////////////////////////////////////////////
2589 TYPEINIT1( SdXMLObjectShapeContext
, SdXMLShapeContext
);
2591 SdXMLObjectShapeContext::SdXMLObjectShapeContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
2592 const rtl::OUString
& rLocalName
,
2593 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2594 com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
>& rShapes
,
2595 sal_Bool bTemporaryShape
)
2596 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
)
2600 SdXMLObjectShapeContext::~SdXMLObjectShapeContext()
2604 void SdXMLObjectShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& )
2606 // #96717# in theorie, if we don't have a url we shouldn't even
2607 // export this ole shape. But practical its to risky right now
2608 // to change this so we better dispose this on load
2609 //if( !mbIsPlaceholder && ImpIsEmptyURL(maHref) )
2612 // #100592# this BugFix prevents that a shape is created. CL
2613 // is thinking about an alternative.
2614 // #i13140# Check for more than empty string in maHref, there are
2615 // other possibilities that maHref results in empty container
2617 if( !(GetImport().getImportFlags() & IMPORT_EMBEDDED
) && !mbIsPlaceholder
&& ImpIsEmptyURL(maHref
) )
2620 const char* pService
= "com.sun.star.drawing.OLE2Shape";
2622 sal_Bool bIsPresShape
= !maPresentationClass
.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
2626 if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_CHART
) )
2628 pService
= "com.sun.star.presentation.ChartShape";
2630 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_TABLE
) )
2632 pService
= "com.sun.star.presentation.CalcShape";
2634 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_OBJECT
) )
2636 pService
= "com.sun.star.presentation.OLE2Shape";
2640 AddShape( pService
);
2648 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2651 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
2652 if( xPropsInfo
.is() )
2654 if( !mbIsPlaceholder
&& xPropsInfo
->hasPropertyByName(OUString("IsEmptyPresentationObject" )))
2655 xProps
->setPropertyValue( OUString("IsEmptyPresentationObject" ), ::cppu::bool2any( sal_False
) );
2657 if( mbIsUserTransformed
&& xPropsInfo
->hasPropertyByName(OUString("IsPlaceholderDependent" )))
2658 xProps
->setPropertyValue( OUString("IsPlaceholderDependent" ), ::cppu::bool2any( sal_False
) );
2663 if( !mbIsPlaceholder
&& !maHref
.isEmpty() )
2665 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
2669 OUString aPersistName
= GetImport().ResolveEmbeddedObjectURL( maHref
, maCLSID
);
2671 if ( GetImport().IsPackageURL( maHref
) )
2673 const OUString
sURL( "vnd.sun.star.EmbeddedObject:" );
2675 if ( aPersistName
.compareTo( sURL
, sURL
.getLength() ) == 0 )
2676 aPersistName
= aPersistName
.copy( sURL
.getLength() );
2678 xProps
->setPropertyValue( OUString( "PersistName" ),
2679 uno::makeAny( aPersistName
) );
2683 // this is OOo link object
2684 xProps
->setPropertyValue( OUString( "LinkURL" ),
2685 uno::makeAny( aPersistName
) );
2690 // set pos, size, shear and rotate
2691 SetTransformation();
2695 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
2699 void SdXMLObjectShapeContext::EndElement()
2701 if (GetImport().isGeneratorVersionOlderThan(
2702 SvXMLImport::OOo_34x
, SvXMLImport::LO_4x
))
2705 // If it's an old file from us written before OOo3.4, we need to correct
2706 // FillStyle and LineStyle for OLE2 objects. The error was that the old paint
2707 // implementations just ignored added fill/linestyles completely, thus
2708 // those objects need to be corrected to not show blue and hairline which
2709 // always was the default, but would be shown now
2710 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2714 xProps
->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle")), uno::makeAny(drawing::FillStyle_NONE
));
2715 xProps
->setPropertyValue(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LineStyle")), uno::makeAny(drawing::LineStyle_NONE
));
2720 if( mxBase64Stream
.is() )
2722 OUString
aPersistName( GetImport().ResolveEmbeddedObjectURLFromBase64() );
2723 const OUString
sURL( "vnd.sun.star.EmbeddedObject:" );
2725 aPersistName
= aPersistName
.copy( sURL
.getLength() );
2727 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2729 xProps
->setPropertyValue( OUString( "PersistName" ), uno::makeAny( aPersistName
) );
2732 SdXMLShapeContext::EndElement();
2735 // this is called from the parent group for each unparsed attribute in the attribute list
2736 void SdXMLObjectShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2740 case XML_NAMESPACE_DRAW
:
2741 if( IsXMLToken( rLocalName
, XML_CLASS_ID
) )
2747 case XML_NAMESPACE_XLINK
:
2748 if( IsXMLToken( rLocalName
, XML_HREF
) )
2756 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2759 SvXMLImportContext
* SdXMLObjectShapeContext::CreateChildContext(
2760 sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
,
2761 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
)
2764 SvXMLImportContext
* pContext
= NULL
;
2766 if((XML_NAMESPACE_OFFICE
== nPrefix
) && IsXMLToken(rLocalName
, XML_BINARY_DATA
))
2768 mxBase64Stream
= GetImport().GetStreamForEmbeddedObjectURLFromBase64();
2769 if( mxBase64Stream
.is() )
2770 pContext
= new XMLBase64ImportContext( GetImport(), nPrefix
,
2771 rLocalName
, xAttrList
,
2774 else if( ((XML_NAMESPACE_OFFICE
== nPrefix
) && IsXMLToken(rLocalName
, XML_DOCUMENT
)) ||
2775 ((XML_NAMESPACE_MATH
== nPrefix
) && IsXMLToken(rLocalName
, XML_MATH
)) )
2777 XMLEmbeddedObjectImportContext
*pEContext
=
2778 new XMLEmbeddedObjectImportContext( GetImport(), nPrefix
,
2779 rLocalName
, xAttrList
);
2780 maCLSID
= pEContext
->GetFilterCLSID();
2781 if( !maCLSID
.isEmpty() )
2783 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
2786 xPropSet
->setPropertyValue( OUString("CLSID" ), uno::makeAny( maCLSID
) );
2788 uno::Reference
< lang::XComponent
> xComp
;
2789 xPropSet
->getPropertyValue( OUString("Model" ) ) >>= xComp
;
2790 DBG_ASSERT( xComp
.is(), "no xModel for own OLE format" );
2791 pEContext
->SetComponent( xComp
);
2794 pContext
= pEContext
;
2797 // delegate to parent class if no context could be created
2799 pContext
= SdXMLShapeContext::CreateChildContext(nPrefix
, rLocalName
, xAttrList
);
2804 //////////////////////////////////////////////////////////////////////////////
2806 TYPEINIT1( SdXMLAppletShapeContext
, SdXMLShapeContext
);
2808 SdXMLAppletShapeContext::SdXMLAppletShapeContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
2809 const rtl::OUString
& rLocalName
,
2810 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2811 com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
>& rShapes
,
2812 sal_Bool bTemporaryShape
)
2813 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2814 mbIsScript( sal_False
)
2818 SdXMLAppletShapeContext::~SdXMLAppletShapeContext()
2822 void SdXMLAppletShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& )
2824 const char* pService
= "com.sun.star.drawing.AppletShape";
2825 AddShape( pService
);
2831 // set pos, size, shear and rotate
2832 SetTransformation();
2833 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
2837 // this is called from the parent group for each unparsed attribute in the attribute list
2838 void SdXMLAppletShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2842 case XML_NAMESPACE_DRAW
:
2843 if( IsXMLToken( rLocalName
, XML_APPLET_NAME
) )
2845 maAppletName
= rValue
;
2848 if( IsXMLToken( rLocalName
, XML_CODE
) )
2850 maAppletCode
= rValue
;
2853 if( IsXMLToken( rLocalName
, XML_MAY_SCRIPT
) )
2855 mbIsScript
= IsXMLToken( rValue
, XML_TRUE
);
2859 case XML_NAMESPACE_XLINK
:
2860 if( IsXMLToken( rLocalName
, XML_HREF
) )
2862 maHref
= GetImport().GetAbsoluteReference(rValue
);
2868 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2871 void SdXMLAppletShapeContext::EndElement()
2873 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
2878 if ( maSize
.Width
&& maSize
.Height
)
2880 // the visual area for applet must be set on loading
2881 awt::Rectangle
aRect( 0, 0, maSize
.Width
, maSize
.Height
);
2883 xProps
->setPropertyValue( OUString( "VisibleArea" ), aAny
);
2886 if( maParams
.getLength() )
2889 xProps
->setPropertyValue( OUString( "AppletCommands" ), aAny
);
2892 if( !maHref
.isEmpty() )
2895 xProps
->setPropertyValue( OUString( "AppletCodeBase" ), aAny
);
2898 if( !maAppletName
.isEmpty() )
2900 aAny
<<= maAppletName
;
2901 xProps
->setPropertyValue( OUString( "AppletName" ), aAny
);
2906 aAny
<<= mbIsScript
;
2907 xProps
->setPropertyValue( OUString( "AppletIsScript" ), aAny
);
2911 if( !maAppletCode
.isEmpty() )
2913 aAny
<<= maAppletCode
;
2914 xProps
->setPropertyValue( OUString( "AppletCode" ), aAny
);
2917 aAny
<<= ::rtl::OUString( GetImport().GetDocumentBase() );
2918 xProps
->setPropertyValue( OUString( "AppletDocBase" ), aAny
);
2923 SdXMLShapeContext::EndElement();
2926 SvXMLImportContext
* SdXMLAppletShapeContext::CreateChildContext( sal_uInt16 p_nPrefix
, const ::rtl::OUString
& rLocalName
, const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
2928 if( p_nPrefix
== XML_NAMESPACE_DRAW
&& IsXMLToken( rLocalName
, XML_PARAM
) )
2930 OUString aParamName
, aParamValue
;
2931 const sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
2932 // now parse the attribute list and look for draw:name and draw:value
2933 for(sal_Int16
a(0); a
< nAttrCount
; a
++)
2935 const OUString
& rAttrName
= xAttrList
->getNameByIndex(a
);
2936 OUString aLocalName
;
2937 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName
, &aLocalName
);
2938 const OUString
aValue( xAttrList
->getValueByIndex(a
) );
2940 if( nPrefix
== XML_NAMESPACE_DRAW
)
2942 if( IsXMLToken( aLocalName
, XML_NAME
) )
2944 aParamName
= aValue
;
2946 else if( IsXMLToken( aLocalName
, XML_VALUE
) )
2948 aParamValue
= aValue
;
2953 if( !aParamName
.isEmpty() )
2955 sal_Int32 nIndex
= maParams
.getLength();
2956 maParams
.realloc( nIndex
+ 1 );
2957 maParams
[nIndex
].Name
= aParamName
;
2958 maParams
[nIndex
].Handle
= -1;
2959 maParams
[nIndex
].Value
<<= aParamValue
;
2960 maParams
[nIndex
].State
= beans::PropertyState_DIRECT_VALUE
;
2963 return new SvXMLImportContext( GetImport(), p_nPrefix
, rLocalName
);
2966 return SdXMLShapeContext::CreateChildContext( p_nPrefix
, rLocalName
, xAttrList
);
2969 //////////////////////////////////////////////////////////////////////////////
2971 TYPEINIT1( SdXMLPluginShapeContext
, SdXMLShapeContext
);
2973 SdXMLPluginShapeContext::SdXMLPluginShapeContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
2974 const rtl::OUString
& rLocalName
,
2975 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2976 com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
>& rShapes
,
2977 sal_Bool bTemporaryShape
) :
2978 SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2983 SdXMLPluginShapeContext::~SdXMLPluginShapeContext()
2987 void SdXMLPluginShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
2989 // watch for MimeType attribute to see if we have a media object
2990 for( sal_Int16 n
= 0, nAttrCount
= ( xAttrList
.is() ? xAttrList
->getLength() : 0 ); n
< nAttrCount
; ++n
)
2992 OUString aLocalName
;
2993 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList
->getNameByIndex( n
), &aLocalName
);
2995 if( nPrefix
== XML_NAMESPACE_DRAW
&& IsXMLToken( aLocalName
, XML_MIME_TYPE
) )
2997 if( 0 == xAttrList
->getValueByIndex( n
).compareToAscii( "application/vnd.sun.star.media" ) )
3005 const char* pService
;
3007 sal_Bool bIsPresShape
= sal_False
;
3011 pService
= "com.sun.star.drawing.MediaShape";
3013 bIsPresShape
= !maPresentationClass
.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
3016 if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_OBJECT
) )
3018 pService
= "com.sun.star.presentation.MediaShape";
3023 pService
= "com.sun.star.drawing.PluginShape";
3025 AddShape( pService
);
3033 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
3036 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
3037 if( xPropsInfo
.is() )
3039 if( !mbIsPlaceholder
&& xPropsInfo
->hasPropertyByName(OUString("IsEmptyPresentationObject" )))
3040 xProps
->setPropertyValue( OUString("IsEmptyPresentationObject" ), ::cppu::bool2any( sal_False
) );
3042 if( mbIsUserTransformed
&& xPropsInfo
->hasPropertyByName(OUString("IsPlaceholderDependent" )))
3043 xProps
->setPropertyValue( OUString("IsPlaceholderDependent" ), ::cppu::bool2any( sal_False
) );
3048 // set pos, size, shear and rotate
3049 SetTransformation();
3050 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
3054 static ::rtl::OUString
3055 lcl_GetMediaReference(SvXMLImport
const& rImport
, ::rtl::OUString
const& rURL
)
3057 if (rImport
.IsPackageURL(rURL
))
3059 return ::rtl::OUString( "vnd.sun.star.Package:") + rURL
;
3063 return rImport
.GetAbsoluteReference(rURL
);
3067 // this is called from the parent group for each unparsed attribute in the attribute list
3068 void SdXMLPluginShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
3072 case XML_NAMESPACE_DRAW
:
3073 if( IsXMLToken( rLocalName
, XML_MIME_TYPE
) )
3075 maMimeType
= rValue
;
3079 case XML_NAMESPACE_XLINK
:
3080 if( IsXMLToken( rLocalName
, XML_HREF
) )
3082 maHref
= lcl_GetMediaReference(GetImport(), rValue
);
3088 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
3091 void SdXMLPluginShapeContext::EndElement()
3093 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
3099 if ( maSize
.Width
&& maSize
.Height
)
3101 const rtl::OUString
sVisibleArea( "VisibleArea" );
3102 uno::Reference
< beans::XPropertySetInfo
> aXPropSetInfo( xProps
->getPropertySetInfo() );
3103 if ( !aXPropSetInfo
.is() || aXPropSetInfo
->hasPropertyByName( sVisibleArea
) )
3105 // the visual area for a plugin must be set on loading
3106 awt::Rectangle
aRect( 0, 0, maSize
.Width
, maSize
.Height
);
3108 xProps
->setPropertyValue( sVisibleArea
, aAny
);
3114 // in case we have a plugin object
3115 if( maParams
.getLength() )
3118 xProps
->setPropertyValue( OUString( "PluginCommands" ), aAny
);
3121 if( !maMimeType
.isEmpty() )
3123 aAny
<<= maMimeType
;
3124 xProps
->setPropertyValue( OUString( "PluginMimeType" ), aAny
);
3127 if( !maHref
.isEmpty() )
3130 xProps
->setPropertyValue( OUString( "PluginURL" ), aAny
);
3135 // in case we have a media object
3136 xProps
->setPropertyValue(
3137 OUString("MediaURL"),
3138 uno::makeAny(maHref
));
3140 for( sal_Int32 nParam
= 0; nParam
< maParams
.getLength(); ++nParam
)
3142 const OUString
& rName
= maParams
[ nParam
].Name
;
3144 if( 0 == rName
.compareToAscii( "Loop" ) )
3147 maParams
[ nParam
].Value
>>= aValueStr
;
3148 xProps
->setPropertyValue( OUString( "Loop" ),
3149 uno::makeAny( static_cast< sal_Bool
>( 0 == aValueStr
.compareToAscii( "true" ) ) ) );
3151 else if( 0 == rName
.compareToAscii( "Mute" ) )
3154 maParams
[ nParam
].Value
>>= aValueStr
;
3155 xProps
->setPropertyValue( OUString( "Mute" ),
3156 uno::makeAny( static_cast< sal_Bool
>( 0 == aValueStr
.compareToAscii( "true" ) ) ) );
3158 else if( 0 == rName
.compareToAscii( "VolumeDB" ) )
3161 maParams
[ nParam
].Value
>>= aValueStr
;
3162 xProps
->setPropertyValue( OUString( "VolumeDB" ),
3163 uno::makeAny( static_cast< sal_Int16
>( aValueStr
.toInt32() ) ) );
3165 else if( 0 == rName
.compareToAscii( "Zoom" ) )
3168 media::ZoomLevel eZoomLevel
;
3170 maParams
[ nParam
].Value
>>= aZoomStr
;
3172 if( 0 == aZoomStr
.compareToAscii( "25%" ) )
3173 eZoomLevel
= media::ZoomLevel_ZOOM_1_TO_4
;
3174 else if( 0 == aZoomStr
.compareToAscii( "50%" ) )
3175 eZoomLevel
= media::ZoomLevel_ZOOM_1_TO_2
;
3176 else if( 0 == aZoomStr
.compareToAscii( "100%" ) )
3177 eZoomLevel
= media::ZoomLevel_ORIGINAL
;
3178 else if( 0 == aZoomStr
.compareToAscii( "200%" ) )
3179 eZoomLevel
= media::ZoomLevel_ZOOM_2_TO_1
;
3180 else if( 0 == aZoomStr
.compareToAscii( "400%" ) )
3181 eZoomLevel
= media::ZoomLevel_ZOOM_4_TO_1
;
3182 else if( 0 == aZoomStr
.compareToAscii( "fit" ) )
3183 eZoomLevel
= media::ZoomLevel_FIT_TO_WINDOW
;
3184 else if( 0 == aZoomStr
.compareToAscii( "fixedfit" ) )
3185 eZoomLevel
= media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT
;
3186 else if( 0 == aZoomStr
.compareToAscii( "fullscreen" ) )
3187 eZoomLevel
= media::ZoomLevel_FULLSCREEN
;
3189 eZoomLevel
= media::ZoomLevel_NOT_AVAILABLE
;
3191 xProps
->setPropertyValue( OUString( "Zoom" ), uno::makeAny( eZoomLevel
) );
3199 SdXMLShapeContext::EndElement();
3202 SvXMLImportContext
* SdXMLPluginShapeContext::CreateChildContext( sal_uInt16 p_nPrefix
, const ::rtl::OUString
& rLocalName
, const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
3204 if( p_nPrefix
== XML_NAMESPACE_DRAW
&& IsXMLToken( rLocalName
, XML_PARAM
) )
3206 OUString aParamName
, aParamValue
;
3207 const sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
3208 // now parse the attribute list and look for draw:name and draw:value
3209 for(sal_Int16
a(0); a
< nAttrCount
; a
++)
3211 const OUString
& rAttrName
= xAttrList
->getNameByIndex(a
);
3212 OUString aLocalName
;
3213 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName
, &aLocalName
);
3214 const OUString
aValue( xAttrList
->getValueByIndex(a
) );
3216 if( nPrefix
== XML_NAMESPACE_DRAW
)
3218 if( IsXMLToken( aLocalName
, XML_NAME
) )
3220 aParamName
= aValue
;
3222 else if( IsXMLToken( aLocalName
, XML_VALUE
) )
3224 aParamValue
= aValue
;
3228 if( !aParamName
.isEmpty() )
3230 sal_Int32 nIndex
= maParams
.getLength();
3231 maParams
.realloc( nIndex
+ 1 );
3232 maParams
[nIndex
].Name
= aParamName
;
3233 maParams
[nIndex
].Handle
= -1;
3234 maParams
[nIndex
].Value
<<= aParamValue
;
3235 maParams
[nIndex
].State
= beans::PropertyState_DIRECT_VALUE
;
3239 return new SvXMLImportContext( GetImport(), p_nPrefix
, rLocalName
);
3242 return SdXMLShapeContext::CreateChildContext( p_nPrefix
, rLocalName
, xAttrList
);
3245 //////////////////////////////////////////////////////////////////////////////
3247 TYPEINIT1( SdXMLFloatingFrameShapeContext
, SdXMLShapeContext
);
3249 SdXMLFloatingFrameShapeContext::SdXMLFloatingFrameShapeContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
3250 const rtl::OUString
& rLocalName
,
3251 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
3252 com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
>& rShapes
,
3253 sal_Bool bTemporaryShape
)
3254 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
)
3258 SdXMLFloatingFrameShapeContext::~SdXMLFloatingFrameShapeContext()
3262 void SdXMLFloatingFrameShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& )
3264 const char* pService
= "com.sun.star.drawing.FrameShape";
3265 AddShape( pService
);
3271 // set pos, size, shear and rotate
3272 SetTransformation();
3274 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
3279 if( !maFrameName
.isEmpty() )
3281 aAny
<<= maFrameName
;
3282 xProps
->setPropertyValue( OUString( "FrameName" ), aAny
);
3285 if( !maHref
.isEmpty() )
3288 xProps
->setPropertyValue( OUString( "FrameURL" ), aAny
);
3294 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
3298 // this is called from the parent group for each unparsed attribute in the attribute list
3299 void SdXMLFloatingFrameShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
3303 case XML_NAMESPACE_DRAW
:
3304 if( IsXMLToken( rLocalName
, XML_FRAME_NAME
) )
3306 maFrameName
= rValue
;
3310 case XML_NAMESPACE_XLINK
:
3311 if( IsXMLToken( rLocalName
, XML_HREF
) )
3313 maHref
= GetImport().GetAbsoluteReference(rValue
);
3319 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
3322 void SdXMLFloatingFrameShapeContext::EndElement()
3324 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
3328 if ( maSize
.Width
&& maSize
.Height
)
3330 // the visual area for a floating frame must be set on loading
3331 awt::Rectangle
aRect( 0, 0, maSize
.Width
, maSize
.Height
);
3334 xProps
->setPropertyValue( OUString( "VisibleArea" ), aAny
);
3339 SdXMLShapeContext::EndElement();
3342 //////////////////////////////////////////////////////////////////////////////
3344 TYPEINIT1( SdXMLFrameShapeContext
, SdXMLShapeContext
);
3346 SdXMLFrameShapeContext::SdXMLFrameShapeContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
3347 const rtl::OUString
& rLocalName
,
3348 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
3349 com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
>& rShapes
,
3350 sal_Bool bTemporaryShape
)
3351 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
3352 MultiImageImportHelper(),
3353 mbSupportsReplacement( sal_False
),
3357 uno::Reference
< util::XCloneable
> xClone( xAttrList
, uno::UNO_QUERY
);
3359 mxAttrList
.set( xClone
->createClone(), uno::UNO_QUERY
);
3361 mxAttrList
= new SvXMLAttributeList( xAttrList
);
3365 SdXMLFrameShapeContext::~SdXMLFrameShapeContext()
3369 void SdXMLFrameShapeContext::removeGraphicFromImportContext(const SvXMLImportContext
& rContext
) const
3371 const SdXMLGraphicObjectShapeContext
* pSdXMLGraphicObjectShapeContext
= dynamic_cast< const SdXMLGraphicObjectShapeContext
* >(&rContext
);
3373 if(pSdXMLGraphicObjectShapeContext
)
3377 uno::Reference
< container::XChild
> xChild(pSdXMLGraphicObjectShapeContext
->getShape(), uno::UNO_QUERY_THROW
);
3381 uno::Reference
< drawing::XShapes
> xParent(xChild
->getParent(), uno::UNO_QUERY_THROW
);
3385 // remove from parent
3386 xParent
->remove(pSdXMLGraphicObjectShapeContext
->getShape());
3389 uno::Reference
< lang::XComponent
> xComp(pSdXMLGraphicObjectShapeContext
->getShape(), UNO_QUERY
);
3398 catch( uno::Exception
& )
3400 OSL_FAIL( "Error in cleanup of multiple graphic object import (!)" );
3405 rtl::OUString
SdXMLFrameShapeContext::getGraphicURLFromImportContext(const SvXMLImportContext
& rContext
) const
3407 rtl::OUString aRetval
;
3408 const SdXMLGraphicObjectShapeContext
* pSdXMLGraphicObjectShapeContext
= dynamic_cast< const SdXMLGraphicObjectShapeContext
* >(&rContext
);
3410 if(pSdXMLGraphicObjectShapeContext
)
3414 const uno::Reference
< beans::XPropertySet
> xPropSet(pSdXMLGraphicObjectShapeContext
->getShape(), uno::UNO_QUERY_THROW
);
3418 xPropSet
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL"))) >>= aRetval
;
3420 if(!aRetval
.getLength())
3422 // it maybe a link, try GraphicURL
3423 xPropSet
->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))) >>= aRetval
;
3427 catch( uno::Exception
& )
3429 OSL_FAIL( "Error in cleanup of multiple graphic object import (!)" );
3436 SvXMLImportContext
*SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPrefix
,
3437 const OUString
& rLocalName
,
3438 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
3440 SvXMLImportContext
* pContext
= 0;
3442 if( !mxImplContext
.Is() )
3445 SvXMLShapeContext
* pShapeContext
= GetImport().GetShapeImport()->CreateFrameChildContext(
3446 GetImport(), nPrefix
, rLocalName
, xAttrList
, mxShapes
, mxAttrList
);
3448 pContext
= pShapeContext
;
3450 // propagate the hyperlink to child context
3451 if ( !msHyperlink
.isEmpty() )
3452 pShapeContext
->setHyperlink( msHyperlink
);
3454 mxImplContext
= pContext
;
3455 mbSupportsReplacement
= IsXMLToken(rLocalName
, XML_OBJECT
) || IsXMLToken(rLocalName
, XML_OBJECT_OLE
);
3456 setSupportsMultipleContents(IsXMLToken(rLocalName
, XML_IMAGE
));
3458 if(getSupportsMultipleContents() && dynamic_cast< SdXMLGraphicObjectShapeContext
* >(pContext
))
3460 addContent(*mxImplContext
);
3463 else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW
== nPrefix
&& IsXMLToken(rLocalName
, XML_IMAGE
))
3465 // read another image
3466 pContext
= GetImport().GetShapeImport()->CreateFrameChildContext(
3467 GetImport(), nPrefix
, rLocalName
, xAttrList
, mxShapes
, mxAttrList
);
3468 mxImplContext
= pContext
;
3470 if(dynamic_cast< SdXMLGraphicObjectShapeContext
* >(pContext
))
3472 addContent(*mxImplContext
);
3475 else if( mbSupportsReplacement
&& !mxReplImplContext
&&
3476 XML_NAMESPACE_DRAW
== nPrefix
&&
3477 IsXMLToken( rLocalName
, XML_IMAGE
) )
3479 // read replacement image
3480 SvXMLImportContext
*pImplContext
= &mxImplContext
;
3481 SdXMLShapeContext
*pSContext
=
3482 PTR_CAST( SdXMLShapeContext
, pImplContext
);
3485 uno::Reference
< beans::XPropertySet
> xPropSet(
3486 pSContext
->getShape(), uno::UNO_QUERY
);
3489 pContext
= new XMLReplacementImageContext( GetImport(),
3490 nPrefix
, rLocalName
, xAttrList
, xPropSet
);
3491 mxReplImplContext
= pContext
;
3496 ( nPrefix
== XML_NAMESPACE_SVG
&& // #i68101#
3497 (IsXMLToken( rLocalName
, XML_TITLE
) || IsXMLToken( rLocalName
, XML_DESC
) ) ) ||
3498 (nPrefix
== XML_NAMESPACE_OFFICE
&& IsXMLToken( rLocalName
, XML_EVENT_LISTENERS
) ) ||
3499 (nPrefix
== XML_NAMESPACE_DRAW
&& (IsXMLToken( rLocalName
, XML_GLUE_POINT
) ||
3500 IsXMLToken( rLocalName
, XML_THUMBNAIL
) ) ) )
3502 SvXMLImportContext
*pImplContext
= &mxImplContext
;
3503 pContext
= PTR_CAST( SdXMLShapeContext
, pImplContext
)->CreateChildContext( nPrefix
,
3504 rLocalName
, xAttrList
);
3506 else if ( (XML_NAMESPACE_DRAW
== nPrefix
) && IsXMLToken( rLocalName
, XML_IMAGE_MAP
) )
3508 SdXMLShapeContext
*pSContext
= dynamic_cast< SdXMLShapeContext
* >( &mxImplContext
);
3511 uno::Reference
< beans::XPropertySet
> xPropSet( pSContext
->getShape(), uno::UNO_QUERY
);
3514 pContext
= new XMLImageMapContext(GetImport(), nPrefix
, rLocalName
, xPropSet
);
3519 // call parent for content
3521 pContext
= SvXMLImportContext::CreateChildContext( nPrefix
, rLocalName
, xAttrList
);
3526 void SdXMLFrameShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>&)
3531 void SdXMLFrameShapeContext::EndElement()
3533 // solve if multiple image child contexts were imported
3534 const SvXMLImportContext
* const pSelectedContext(solveMultipleImages());
3535 const SdXMLGraphicObjectShapeContext
* pShapeContext( dynamic_cast<const SdXMLGraphicObjectShapeContext
*>( pSelectedContext
) );
3536 if ( pShapeContext
&& !maShapeId
.isEmpty() )
3538 // fdo#64512 and fdo#60075 - make sure *this* shape is
3539 // registered for given ID
3540 assert( mxImplContext
.Is() );
3541 const uno::Reference
< uno::XInterface
> xShape( pShapeContext
->getShape() );
3542 GetImport().getInterfaceToIdentifierMapper().registerReferenceAlways( maShapeId
, xShape
);
3545 if( !mxImplContext
.Is() )
3547 // now check if this is an empty presentation object
3548 sal_Int16 nAttrCount
= mxAttrList
.is() ? mxAttrList
->getLength() : 0;
3549 for(sal_Int16
a(0); a
< nAttrCount
; a
++)
3551 OUString aLocalName
;
3552 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName(mxAttrList
->getNameByIndex(a
), &aLocalName
);
3554 if( nPrefix
== XML_NAMESPACE_PRESENTATION
)
3556 if( IsXMLToken( aLocalName
, XML_PLACEHOLDER
) )
3558 mbIsPlaceholder
= IsXMLToken( mxAttrList
->getValueByIndex(a
), XML_TRUE
);
3560 else if( IsXMLToken( aLocalName
, XML_CLASS
) )
3562 maPresentationClass
= mxAttrList
->getValueByIndex(a
);
3567 if( (!maPresentationClass
.isEmpty()) && mbIsPlaceholder
)
3569 uno::Reference
< xml::sax::XAttributeList
> xEmpty
;
3571 enum XMLTokenEnum eToken
= XML_TEXT_BOX
;
3573 if( IsXMLToken( maPresentationClass
, XML_GRAPHIC
) )
3578 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_PAGE
) )
3580 eToken
= XML_PAGE_THUMBNAIL
;
3582 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_CHART
) ||
3583 IsXMLToken( maPresentationClass
, XML_PRESENTATION_TABLE
) ||
3584 IsXMLToken( maPresentationClass
, XML_PRESENTATION_OBJECT
) )
3586 eToken
= XML_OBJECT
;
3589 mxImplContext
= GetImport().GetShapeImport()->CreateFrameChildContext(
3590 GetImport(), XML_NAMESPACE_DRAW
, GetXMLToken( eToken
), mxAttrList
, mxShapes
, xEmpty
);
3592 if( mxImplContext
.Is() )
3594 mxImplContext
->StartElement( mxAttrList
);
3595 mxImplContext
->EndElement();
3601 SdXMLShapeContext::EndElement();
3604 void SdXMLFrameShapeContext::processAttribute( sal_uInt16 nPrefix
,
3605 const OUString
& rLocalName
, const OUString
& rValue
)
3611 case XML_NAMESPACE_DRAW
:
3612 case XML_NAMESPACE_DRAW_EXT
:
3613 bId
= IsXMLToken( rLocalName
, XML_ID
);
3615 case XML_NAMESPACE_NONE
:
3616 case XML_NAMESPACE_XML
:
3617 bId
= IsXMLToken( rLocalName
, XML_ID
);
3622 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
3625 TYPEINIT1( SdXMLCustomShapeContext
, SdXMLShapeContext
);
3627 SdXMLCustomShapeContext::SdXMLCustomShapeContext(
3628 SvXMLImport
& rImport
,
3630 const OUString
& rLocalName
,
3631 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
3632 uno::Reference
< drawing::XShapes
>& rShapes
,
3633 sal_Bool bTemporaryShape
)
3634 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
)
3638 //////////////////////////////////////////////////////////////////////////////
3640 SdXMLCustomShapeContext::~SdXMLCustomShapeContext()
3644 //////////////////////////////////////////////////////////////////////////////
3646 // this is called from the parent group for each unparsed attribute in the attribute list
3647 void SdXMLCustomShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
3649 if( XML_NAMESPACE_DRAW
== nPrefix
)
3651 if( IsXMLToken( rLocalName
, XML_ENGINE
) )
3653 maCustomShapeEngine
= rValue
;
3656 if ( IsXMLToken( rLocalName
, XML_DATA
) )
3658 maCustomShapeData
= rValue
;
3662 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
3665 //////////////////////////////////////////////////////////////////////////////
3667 void SdXMLCustomShapeContext::StartElement( const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
3669 // create rectangle shape
3670 AddShape("com.sun.star.drawing.CustomShape");
3673 // Add, set Style and properties from base shape
3677 // set pos, size, shear and rotate
3678 SetTransformation();
3682 uno::Reference
< beans::XPropertySet
> xPropSet( mxShape
, uno::UNO_QUERY
);
3685 if ( !maCustomShapeEngine
.isEmpty() )
3688 aAny
<<= maCustomShapeEngine
;
3689 xPropSet
->setPropertyValue( EASGet( EAS_CustomShapeEngine
), aAny
);
3691 if ( !maCustomShapeData
.isEmpty() )
3694 aAny
<<= maCustomShapeData
;
3695 xPropSet
->setPropertyValue( EASGet( EAS_CustomShapeData
), aAny
);
3699 catch(const uno::Exception
&)
3701 OSL_FAIL( "could not set enhanced customshape geometry" );
3703 SdXMLShapeContext::StartElement(xAttrList
);
3707 void SdXMLCustomShapeContext::EndElement()
3709 if ( !maCustomShapeGeometry
.empty() )
3711 const rtl::OUString
sCustomShapeGeometry ( "CustomShapeGeometry" );
3713 // converting the vector to a sequence
3714 uno::Sequence
< beans::PropertyValue
> aSeq( maCustomShapeGeometry
.size() );
3715 beans::PropertyValue
* pValues
= aSeq
.getArray();
3716 std::vector
< beans::PropertyValue
>::const_iterator
aIter( maCustomShapeGeometry
.begin() );
3717 std::vector
< beans::PropertyValue
>::const_iterator
aEnd( maCustomShapeGeometry
.end() );
3718 while ( aIter
!= aEnd
)
3719 *pValues
++ = *aIter
++;
3723 uno::Reference
< beans::XPropertySet
> xPropSet( mxShape
, uno::UNO_QUERY
);
3728 xPropSet
->setPropertyValue( sCustomShapeGeometry
, aAny
);
3731 catch(const uno::Exception
&)
3733 OSL_FAIL( "could not set enhanced customshape geometry" );
3736 sal_Int32
nUPD( 0 );
3737 sal_Int32
nBuild( 0 );
3738 GetImport().getBuildIds( nUPD
, nBuild
);
3739 if( ((nUPD
>= 640 && nUPD
<= 645) || (nUPD
== 680)) && (nBuild
<= 9221) )
3741 Reference
< drawing::XEnhancedCustomShapeDefaulter
> xDefaulter( mxShape
, UNO_QUERY
);
3742 if( xDefaulter
.is() )
3744 rtl::OUString aEmptyType
;
3745 xDefaulter
->createCustomShapeDefaults( aEmptyType
);
3750 SdXMLShapeContext::EndElement();
3753 //////////////////////////////////////////////////////////////////////////////
3755 SvXMLImportContext
* SdXMLCustomShapeContext::CreateChildContext(
3756 sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
,
3757 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
)
3759 SvXMLImportContext
* pContext
= NULL
;
3760 if ( XML_NAMESPACE_DRAW
== nPrefix
)
3762 if ( IsXMLToken( rLocalName
, XML_ENHANCED_GEOMETRY
) )
3764 uno::Reference
< beans::XPropertySet
> xPropSet( mxShape
,uno::UNO_QUERY
);
3765 if ( xPropSet
.is() )
3766 pContext
= new XMLEnhancedCustomShapeContext( GetImport(), mxShape
, nPrefix
, rLocalName
, maCustomShapeGeometry
);
3769 // delegate to parent class if no context could be created
3770 if ( NULL
== pContext
)
3771 pContext
= SdXMLShapeContext::CreateChildContext( nPrefix
, rLocalName
,
3776 ///////////////////////////////////////////////////////////////////////
3778 //////////////////////////////////////////////////////////////////////////////
3780 TYPEINIT1( SdXMLTableShapeContext
, SdXMLShapeContext
);
3782 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
)
3783 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, sal_False
)
3785 memset( &maTemplateStylesUsed
, 0, sizeof( maTemplateStylesUsed
) );
3788 SdXMLTableShapeContext::~SdXMLTableShapeContext()
3792 void SdXMLTableShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
3794 const char* pService
= "com.sun.star.drawing.TableShape";
3796 sal_Bool bIsPresShape
= !maPresentationClass
.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
3799 if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_TABLE
) )
3801 pService
= "com.sun.star.presentation.TableShape";
3805 AddShape( pService
);
3811 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
3817 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
3818 if( xPropsInfo
.is() )
3820 if( !mbIsPlaceholder
&& xPropsInfo
->hasPropertyByName(OUString("IsEmptyPresentationObject" )))
3821 xProps
->setPropertyValue( OUString("IsEmptyPresentationObject" ), ::cppu::bool2any( sal_False
) );
3823 if( mbIsUserTransformed
&& xPropsInfo
->hasPropertyByName(OUString("IsPlaceholderDependent" )))
3824 xProps
->setPropertyValue( OUString("IsPlaceholderDependent" ), ::cppu::bool2any( sal_False
) );
3833 if( !msTemplateStyleName
.isEmpty() ) try
3835 Reference
< XStyleFamiliesSupplier
> xFamiliesSupp( GetImport().GetModel(), UNO_QUERY_THROW
);
3836 Reference
< XNameAccess
> xFamilies( xFamiliesSupp
->getStyleFamilies() );
3837 const OUString
sFamilyName( "table" );
3838 Reference
< XNameAccess
> xTableFamily( xFamilies
->getByName( sFamilyName
), UNO_QUERY_THROW
);
3839 Reference
< XStyle
> xTableStyle( xTableFamily
->getByName( msTemplateStyleName
), UNO_QUERY_THROW
);
3840 xProps
->setPropertyValue( OUString( "TableTemplate" ), Any( xTableStyle
) );
3842 catch(const Exception
&)
3844 OSL_FAIL("SdXMLTableShapeContext::StartElement(), exception caught!");
3847 const XMLPropertyMapEntry
* pEntry
= &aXMLTableShapeAttributes
[0];
3848 for( int i
= 0; pEntry
->msApiName
&& (i
< 6); i
++, pEntry
++ )
3852 const OUString
sAPIPropertyName( OUString(pEntry
->msApiName
, pEntry
->nApiNameLength
, RTL_TEXTENCODING_ASCII_US
) );
3853 xProps
->setPropertyValue( sAPIPropertyName
, Any( maTemplateStylesUsed
[i
] ) );
3855 catch(const Exception
&)
3857 OSL_FAIL("SdXMLTableShapeContext::StartElement(), exception caught!");
3862 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
3864 const rtl::Reference
< XMLTableImport
>& xTableImport( GetImport().GetShapeImport()->GetShapeTableImport() );
3865 if( xTableImport
.is() && xProps
.is() )
3867 uno::Reference
< table::XColumnRowRange
> xColumnRowRange(
3868 xProps
->getPropertyValue( OUString("Model" ) ), uno::UNO_QUERY
);
3870 if( xColumnRowRange
.is() )
3871 mxTableImportContext
= xTableImport
->CreateTableContext( GetPrefix(), GetLocalName(), xColumnRowRange
);
3873 if( mxTableImportContext
.Is() )
3874 mxTableImportContext
->StartElement( xAttrList
);
3879 void SdXMLTableShapeContext::EndElement()
3881 if( mxTableImportContext
.Is() )
3882 mxTableImportContext
->EndElement();
3884 SdXMLShapeContext::EndElement();
3888 // set pos, size, shear and rotate
3889 SetTransformation();
3893 // this is called from the parent group for each unparsed attribute in the attribute list
3894 void SdXMLTableShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
3896 if( nPrefix
== XML_NAMESPACE_TABLE
)
3898 if( IsXMLToken( rLocalName
, XML_TEMPLATE_NAME
) )
3900 msTemplateStyleName
= rValue
;
3905 const XMLPropertyMapEntry
* pEntry
= &aXMLTableShapeAttributes
[0];
3906 while( pEntry
->msApiName
&& (i
< 6) )
3908 if( IsXMLToken( rLocalName
, pEntry
->meXMLName
) )
3910 if( IsXMLToken( rValue
, XML_TRUE
) )
3911 maTemplateStylesUsed
[i
] = sal_True
;
3919 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
3922 SvXMLImportContext
* SdXMLTableShapeContext::CreateChildContext( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
)
3924 if( mxTableImportContext
.Is() && (nPrefix
== XML_NAMESPACE_TABLE
) )
3925 return mxTableImportContext
->CreateChildContext(nPrefix
, rLocalName
, xAttrList
);
3927 return SdXMLShapeContext::CreateChildContext(nPrefix
, rLocalName
, xAttrList
);
3930 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */