1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ximpshap.cxx,v $
10 * $Revision: 1.128.2.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
36 #include <tools/debug.hxx>
37 #include <com/sun/star/document/XEventsSupplier.hpp>
38 #include <com/sun/star/container/XNameReplace.hpp>
39 #include <com/sun/star/presentation/ClickAction.hpp>
40 #include <com/sun/star/drawing/FillStyle.hpp>
41 #include <com/sun/star/drawing/LineStyle.hpp>
42 #include "unointerfacetouniqueidentifiermapper.hxx"
43 #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
44 #include <com/sun/star/container/XIdentifierAccess.hpp>
45 #include <com/sun/star/drawing/GluePoint2.hpp>
46 #include <com/sun/star/drawing/Alignment.hpp>
47 #include <com/sun/star/drawing/EscapeDirection.hpp>
48 #include <com/sun/star/media/ZoomLevel.hpp>
49 #include <com/sun/star/awt/Rectangle.hpp>
51 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
52 #include <com/sun/star/container/XNameAccess.hpp>
53 #include <comphelper/extract.hxx>
54 #include "ximpshap.hxx"
55 #include <xmloff/XMLBase64ImportContext.hxx>
56 #include <xmloff/XMLShapeStyleContext.hxx>
57 #include <xmloff/xmluconv.hxx>
58 #include <com/sun/star/container/XNamed.hpp>
59 #include <com/sun/star/drawing/CircleKind.hpp>
60 #include <com/sun/star/beans/XPropertySet.hpp>
61 #include <com/sun/star/awt/XControlModel.hpp>
62 #include <com/sun/star/drawing/XControlShape.hpp>
63 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
64 #include <com/sun/star/drawing/PointSequence.hpp>
65 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
66 #include <com/sun/star/lang/XServiceInfo.hpp>
67 #include <com/sun/star/util/XCloneable.hpp>
68 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
69 #include "xexptran.hxx"
70 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
71 #include <com/sun/star/beans/XPropertySetInfo.hpp>
72 #include <com/sun/star/drawing/ConnectorType.hpp>
73 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
74 #include "PropertySetMerger.hxx"
75 #include <xmloff/families.hxx>
76 #include "ximpstyl.hxx"
77 #include"xmlnmspe.hxx"
78 #include <xmloff/xmltoken.hxx>
79 #include "EnhancedCustomShapeToken.hxx"
80 #include "XMLReplacementImageContext.hxx"
81 #include "XMLImageMapContext.hxx"
82 #include "sdpropls.hxx"
83 #include "eventimp.hxx"
85 #include "descriptionimp.hxx"
86 #include "ximpcustomshape.hxx"
87 #include "XMLEmbeddedObjectImportContext.hxx"
88 #include "xmlerror.hxx"
89 #include <basegfx/matrix/b2dhommatrix.hxx>
90 #include <tools/string.hxx>
91 #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
93 // --> OD 2006-02-22 #b6382898#
94 #include <com/sun/star/text/XTextDocument.hpp>
97 using ::rtl::OUString
;
98 using ::rtl::OUStringBuffer
;
100 using namespace ::com::sun::star
;
101 using namespace ::com::sun::star::uno
;
102 using namespace ::com::sun::star::drawing
;
103 using namespace ::com::sun::star::style
;
104 using namespace ::com::sun::star::container
;
105 using namespace ::com::sun::star::document
;
106 using namespace ::xmloff::token
;
107 using namespace ::xmloff::EnhancedCustomShapeToken
;
109 SvXMLEnumMapEntry aXML_GlueAlignment_EnumMap
[] =
111 { XML_TOP_LEFT
, drawing::Alignment_TOP_LEFT
},
112 { XML_TOP
, drawing::Alignment_TOP
},
113 { XML_TOP_RIGHT
, drawing::Alignment_TOP_RIGHT
},
114 { XML_LEFT
, drawing::Alignment_LEFT
},
115 { XML_CENTER
, drawing::Alignment_CENTER
},
116 { XML_RIGHT
, drawing::Alignment_RIGHT
},
117 { XML_BOTTOM_LEFT
, drawing::Alignment_BOTTOM_LEFT
},
118 { XML_BOTTOM
, drawing::Alignment_BOTTOM
},
119 { XML_BOTTOM_RIGHT
, drawing::Alignment_BOTTOM_RIGHT
},
120 { XML_TOKEN_INVALID
, 0 }
123 SvXMLEnumMapEntry aXML_GlueEscapeDirection_EnumMap
[] =
125 { XML_AUTO
, drawing::EscapeDirection_SMART
},
126 { XML_LEFT
, drawing::EscapeDirection_LEFT
},
127 { XML_RIGHT
, drawing::EscapeDirection_RIGHT
},
128 { XML_UP
, drawing::EscapeDirection_UP
},
129 { XML_DOWN
, drawing::EscapeDirection_DOWN
},
130 { XML_HORIZONTAL
, drawing::EscapeDirection_HORIZONTAL
},
131 { XML_VERTICAL
, drawing::EscapeDirection_VERTICAL
},
132 { XML_TOKEN_INVALID
, 0 }
135 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
137 static bool ImpIsEmptyURL( const ::rtl::OUString
& rURL
)
139 if( rURL
.getLength() == 0 )
142 // #i13140# Also compare against 'toplevel' URLs. which also
143 // result in empty filename strings.
144 if( 0 == rURL
.compareToAscii( "#./" ) )
150 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
152 TYPEINIT1( SvXMLShapeContext
, SvXMLImportContext
);
153 TYPEINIT1( SdXMLShapeContext
, SvXMLShapeContext
);
155 SdXMLShapeContext::SdXMLShapeContext(
156 SvXMLImport
& rImport
,
158 const OUString
& rLocalName
,
159 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
160 uno::Reference
< drawing::XShapes
>& rShapes
,
161 sal_Bool bTemporaryShape
)
162 : SvXMLShapeContext( rImport
, nPrfx
, rLocalName
, bTemporaryShape
)
163 , mxShapes( rShapes
)
164 , mxAttrList(xAttrList
)
165 , mbListContextPushed( false )
166 , mnStyleFamily(XML_STYLE_FAMILY_SD_GRAPHICS_ID
)
167 , mbIsPlaceholder(FALSE
)
168 , mbClearDefaultAttributes( true )
169 , mbIsUserTransformed(FALSE
)
176 //////////////////////////////////////////////////////////////////////////////
178 SdXMLShapeContext::~SdXMLShapeContext()
182 //////////////////////////////////////////////////////////////////////////////
184 SvXMLImportContext
*SdXMLShapeContext::CreateChildContext( USHORT p_nPrefix
,
185 const OUString
& rLocalName
,
186 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
188 SvXMLImportContext
* pContext
= NULL
;
191 if( p_nPrefix
== XML_NAMESPACE_SVG
&&
192 (IsXMLToken( rLocalName
, XML_TITLE
) || IsXMLToken( rLocalName
, XML_DESC
) ) )
194 pContext
= new SdXMLDescriptionContext( GetImport(), p_nPrefix
, rLocalName
, xAttrList
, mxShape
);
196 else if( p_nPrefix
== XML_NAMESPACE_OFFICE
&& IsXMLToken( rLocalName
, XML_EVENT_LISTENERS
) )
198 pContext
= new SdXMLEventsContext( GetImport(), p_nPrefix
, rLocalName
, xAttrList
, mxShape
);
200 else if( p_nPrefix
== XML_NAMESPACE_DRAW
&& IsXMLToken( rLocalName
, XML_GLUE_POINT
) )
202 addGluePoint( xAttrList
);
204 else if( p_nPrefix
== XML_NAMESPACE_DRAW
&& IsXMLToken( rLocalName
, XML_THUMBNAIL
) )
206 // search attributes for xlink:href
207 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
208 for(sal_Int16 i
=0; i
< nAttrCount
; i
++)
210 OUString sAttrName
= xAttrList
->getNameByIndex( i
);
212 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName
, &aLocalName
);
214 if( nPrefix
== XML_NAMESPACE_XLINK
)
216 if( IsXMLToken( aLocalName
, XML_HREF
) )
218 maThumbnailURL
= xAttrList
->getValueByIndex( i
);
226 // create text cursor on demand
229 uno::Reference
< text::XText
> xText( mxShape
, uno::UNO_QUERY
);
232 UniReference
< XMLTextImportHelper
> xTxtImport
=
233 GetImport().GetTextImport();
234 mxOldCursor
= xTxtImport
->GetCursor();
235 mxCursor
= xText
->createTextCursor();
238 xTxtImport
->SetCursor( mxCursor
);
241 // remember old list item and block (#91964#) and reset them
242 // for the text frame
243 xTxtImport
->PushListContext();
244 mbListContextPushed
= true;
248 // if we have a text cursor, lets try to import some text
251 pContext
= GetImport().GetTextImport()->CreateTextChildContext(
252 GetImport(), p_nPrefix
, rLocalName
, xAttrList
);
256 // call parent for content
258 pContext
= SvXMLImportContext::CreateChildContext( p_nPrefix
, rLocalName
, xAttrList
);
263 void SdXMLShapeContext::addGluePoint( const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
265 // get the glue points container for this shape if its not already there
266 if( !mxGluePoints
.is() )
268 uno::Reference
< drawing::XGluePointsSupplier
> xSupplier( mxShape
, uno::UNO_QUERY
);
269 if( !xSupplier
.is() )
272 mxGluePoints
= uno::Reference
< container::XIdentifierContainer
>::query( xSupplier
->getGluePoints() );
274 if( !mxGluePoints
.is() )
278 drawing::GluePoint2 aGluePoint
;
279 aGluePoint
.IsUserDefined
= sal_True
;
280 aGluePoint
.Position
.X
= 0;
281 aGluePoint
.Position
.Y
= 0;
282 aGluePoint
.Escape
= drawing::EscapeDirection_SMART
;
283 aGluePoint
.PositionAlignment
= drawing::Alignment_CENTER
;
284 aGluePoint
.IsRelative
= sal_True
;
288 // read attributes for the 3DScene
289 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
290 for(sal_Int16 i
=0; i
< nAttrCount
; i
++)
292 OUString sAttrName
= xAttrList
->getNameByIndex( i
);
294 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName
, &aLocalName
);
295 const OUString
sValue( xAttrList
->getValueByIndex( i
) );
297 if( nPrefix
== XML_NAMESPACE_SVG
)
299 if( IsXMLToken( aLocalName
, XML_X
) )
301 GetImport().GetMM100UnitConverter().convertMeasure(aGluePoint
.Position
.X
, sValue
);
303 else if( IsXMLToken( aLocalName
, XML_Y
) )
305 GetImport().GetMM100UnitConverter().convertMeasure(aGluePoint
.Position
.Y
, sValue
);
308 else if( nPrefix
== XML_NAMESPACE_DRAW
)
310 if( IsXMLToken( aLocalName
, XML_ID
) )
312 nId
= sValue
.toInt32();
314 else if( IsXMLToken( aLocalName
, XML_ALIGN
) )
317 if( SvXMLUnitConverter::convertEnum( eKind
, sValue
, aXML_GlueAlignment_EnumMap
) )
319 aGluePoint
.PositionAlignment
= (drawing::Alignment
)eKind
;
320 aGluePoint
.IsRelative
= sal_False
;
323 else if( IsXMLToken( aLocalName
, XML_ESCAPE_DIRECTION
) )
326 if( SvXMLUnitConverter::convertEnum( eKind
, sValue
, aXML_GlueEscapeDirection_EnumMap
) )
328 aGluePoint
.Escape
= (drawing::EscapeDirection
)eKind
;
338 sal_Int32 nInternalId
= mxGluePoints
->insert( uno::makeAny( aGluePoint
) );
339 GetImport().GetShapeImport()->addGluePointMapping( mxShape
, nId
, nInternalId
);
341 catch( uno::Exception
& )
343 DBG_ERROR( "exception during setting of glue points!");
347 //////////////////////////////////////////////////////////////////////////////
349 void SdXMLShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>&)
351 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
354 void SdXMLShapeContext::EndElement()
358 // delete addition newline
359 const OUString aEmpty
;
360 mxCursor
->gotoEnd( sal_False
);
361 mxCursor
->goLeft( 1, sal_True
);
362 mxCursor
->setString( aEmpty
);
365 GetImport().GetTextImport()->ResetCursor();
369 GetImport().GetTextImport()->SetCursor( mxOldCursor
);
371 // reinstall old list item (if necessary) #91964#
372 if (mbListContextPushed
) {
373 GetImport().GetTextImport()->PopListContext();
376 if( msHyperlink
.getLength() != 0 ) try
378 uno::Reference
< beans::XPropertySet
> xProp( mxShape
, uno::UNO_QUERY
);
380 rtl::OUString
sLink( RTL_CONSTASCII_USTRINGPARAM( "Hyperlink" ) );
381 if ( xProp
.is() && xProp
->getPropertySetInfo()->hasPropertyByName( sLink
) )
382 xProp
->setPropertyValue( sLink
, uno::Any( msHyperlink
) );
383 Reference
< XEventsSupplier
> xEventsSupplier( mxShape
, UNO_QUERY_THROW
);
384 Reference
< XNameReplace
> xEvents( xEventsSupplier
->getEvents(), UNO_QUERY_THROW
);
386 uno::Sequence
< beans::PropertyValue
> aProperties( 3 );
387 aProperties
[0].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM( "EventType" ) );
388 aProperties
[0].Handle
= -1;
389 aProperties
[0].Value
<<= OUString( RTL_CONSTASCII_USTRINGPARAM("Presentation") );
390 aProperties
[0].State
= beans::PropertyState_DIRECT_VALUE
;
392 aProperties
[1].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM( "ClickAction" ) );
393 aProperties
[1].Handle
= -1;
394 aProperties
[1].Value
<<= ::com::sun::star::presentation::ClickAction_DOCUMENT
;
395 aProperties
[1].State
= beans::PropertyState_DIRECT_VALUE
;
397 aProperties
[2].Name
= OUString( RTL_CONSTASCII_USTRINGPARAM( "Bookmark" ) );
398 aProperties
[2].Handle
= -1;
399 aProperties
[2].Value
<<= msHyperlink
;
400 aProperties
[2].State
= beans::PropertyState_DIRECT_VALUE
;
402 const OUString
sAPIEventName( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) );
403 xEvents
->replaceByName( sAPIEventName
, Any( aProperties
) );
407 DBG_ERROR("xmloff::SdXMLShapeContext::EndElement(), exception caught!");
410 if( mxLockable
.is() )
411 mxLockable
->removeActionLock();
414 //////////////////////////////////////////////////////////////////////////////
416 void SdXMLShapeContext::AddShape(uno::Reference
< drawing::XShape
>& xShape
)
423 if(maShapeName
.getLength())
425 uno::Reference
< container::XNamed
> xNamed( mxShape
, uno::UNO_QUERY
);
427 xNamed
->setName( maShapeName
);
430 UniReference
< XMLShapeImportHelper
> xImp( GetImport().GetShapeImport() );
431 xImp
->addShape( xShape
, mxAttrList
, mxShapes
);
433 if( mbClearDefaultAttributes
)
435 uno::Reference
<beans::XMultiPropertyStates
> xMultiPropertyStates(xShape
, uno::UNO_QUERY
);
436 if (xMultiPropertyStates
.is())
437 xMultiPropertyStates
->setAllPropertiesToDefault();
441 if(!mbTemporaryShape
&& (!GetImport().HasTextImport()
442 || !GetImport().GetTextImport()->IsInsideDeleteContext()))
444 xImp
->shapeWithZIndexAdded( xShape
, mnZOrder
);
447 if( maShapeId
.getLength() )
449 uno::Reference
< uno::XInterface
> xRef( xShape
, uno::UNO_QUERY
);
450 GetImport().getInterfaceToIdentifierMapper().registerReference( maShapeId
, xRef
);
453 // #91065# count only if counting for shape import is enabled
454 if(GetImport().GetShapeImport()->IsHandleProgressBarEnabled())
456 // #80365# increment progress bar at load once for each draw object
457 GetImport().GetProgressBarHelper()->Increment();
461 mxLockable
= uno::Reference
< document::XActionLockable
>::query( xShape
);
463 if( mxLockable
.is() )
464 mxLockable
->addActionLock();
468 //////////////////////////////////////////////////////////////////////////////
470 void SdXMLShapeContext::AddShape(const char* pServiceName
)
472 uno::Reference
< lang::XMultiServiceFactory
> xServiceFact(GetImport().GetModel(), uno::UNO_QUERY
);
473 if(xServiceFact
.is())
477 // --> OD 2006-02-22 #b6382898#
478 // Since fix for issue i33294 the Writer model doesn't support
479 // com.sun.star.drawing.OLE2Shape anymore.
480 // To handle Draw OLE objects it's decided to import these
481 // objects as com.sun.star.drawing.OLE2Shape and convert these
482 // objects after the import into com.sun.star.drawing.GraphicObjectShape.
483 uno::Reference
< drawing::XShape
> xShape
;
484 if ( OUString::createFromAscii(pServiceName
).compareToAscii( "com.sun.star.drawing.OLE2Shape" ) == 0 &&
485 uno::Reference
< text::XTextDocument
>(GetImport().GetModel(), uno::UNO_QUERY
).is() )
487 xShape
= uno::Reference
< drawing::XShape
>(xServiceFact
->createInstance(OUString::createFromAscii("com.sun.star.drawing.temporaryForXMLImportOLE2Shape")), uno::UNO_QUERY
);
491 xShape
= uno::Reference
< drawing::XShape
>(xServiceFact
->createInstance(OUString::createFromAscii(pServiceName
)), uno::UNO_QUERY
);
497 catch( const uno::Exception
& e
)
499 uno::Sequence
<rtl::OUString
> aSeq( 1 );
500 aSeq
[0] = OUString::createFromAscii(pServiceName
);
501 GetImport().SetError( XMLERROR_FLAG_ERROR
| XMLERROR_API
,
502 aSeq
, e
.Message
, NULL
);
507 //////////////////////////////////////////////////////////////////////////////
509 void SdXMLShapeContext::SetTransformation()
513 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
516 ::basegfx::B2DHomMatrix aTransformation
;
518 if(maSize
.Width
!= 1 || maSize
.Height
!= 1)
520 // take care there are no zeros used by error
521 if(0 == maSize
.Width
)
523 if(0 == maSize
.Height
)
526 // set global size. This should always be used.
527 aTransformation
.scale(maSize
.Width
, maSize
.Height
);
530 if(maPosition
.X
!= 0 || maPosition
.Y
!= 0)
532 // if global position is used, add it to transformation
533 aTransformation
.translate(maPosition
.X
, maPosition
.Y
);
536 if(mnTransform
.NeedsAction())
538 // transformation is used, apply to object.
539 // NOTICE: The transformation is applied AFTER evtl. used
540 // global positioning and scaling is used, so any shear or
541 // rotate used herein is applied around the (0,0) position
542 // of the PAGE object !!!
543 ::basegfx::B2DHomMatrix aMat
;
544 mnTransform
.GetFullTransform(aMat
);
546 // now add to transformation
547 aTransformation
*= aMat
;
550 // now set transformation for this object
552 drawing::HomogenMatrix3 aMatrix
;
554 aMatrix
.Line1
.Column1
= aTransformation
.get(0, 0);
555 aMatrix
.Line1
.Column2
= aTransformation
.get(0, 1);
556 aMatrix
.Line1
.Column3
= aTransformation
.get(0, 2);
558 aMatrix
.Line2
.Column1
= aTransformation
.get(1, 0);
559 aMatrix
.Line2
.Column2
= aTransformation
.get(1, 1);
560 aMatrix
.Line2
.Column3
= aTransformation
.get(1, 2);
562 aMatrix
.Line3
.Column1
= aTransformation
.get(2, 0);
563 aMatrix
.Line3
.Column2
= aTransformation
.get(2, 1);
564 aMatrix
.Line3
.Column3
= aTransformation
.get(2, 2);
568 xPropSet
->setPropertyValue(
569 OUString(RTL_CONSTASCII_USTRINGPARAM("Transformation")), aAny
);
574 //////////////////////////////////////////////////////////////////////////////
576 void SdXMLShapeContext::SetStyle( bool bSupportsStyle
/* = true */)
580 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
586 XMLPropStyleContext
* pDocStyle
= NULL
;
588 // set style on shape
589 if(maDrawStyleName
.getLength() == 0)
592 const SvXMLStyleContext
* pStyle
= 0L;
593 sal_Bool
bAutoStyle(FALSE
);
595 if(GetImport().GetShapeImport()->GetAutoStylesContext())
596 pStyle
= GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(mnStyleFamily
, maDrawStyleName
);
601 if(!pStyle
&& GetImport().GetShapeImport()->GetStylesContext())
602 pStyle
= GetImport().GetShapeImport()->GetStylesContext()->FindStyleChildContext(mnStyleFamily
, maDrawStyleName
);
604 OUString aStyleName
= maDrawStyleName
;
605 uno::Reference
< style::XStyle
> xStyle
;
607 if( pStyle
&& pStyle
->ISA(XMLShapeStyleContext
) )
609 pDocStyle
= PTR_CAST( XMLShapeStyleContext
, pStyle
);
611 if( pDocStyle
->GetStyle().is() )
613 xStyle
= pDocStyle
->GetStyle();
617 aStyleName
= pDocStyle
->GetParentName();
621 if( !xStyle
.is() && aStyleName
.getLength() )
626 uno::Reference
< style::XStyleFamiliesSupplier
> xFamiliesSupplier( GetImport().GetModel(), uno::UNO_QUERY
);
628 if( xFamiliesSupplier
.is() )
630 uno::Reference
< container::XNameAccess
> xFamilies( xFamiliesSupplier
->getStyleFamilies() );
634 uno::Reference
< container::XNameAccess
> xFamily
;
636 if( XML_STYLE_FAMILY_SD_PRESENTATION_ID
== mnStyleFamily
)
638 aStyleName
= GetImport().GetStyleDisplayName(
639 XML_STYLE_FAMILY_SD_PRESENTATION_ID
,
641 sal_Int32 nPos
= aStyleName
.lastIndexOf( sal_Unicode('-') );
644 OUString
aFamily( aStyleName
.copy( 0, nPos
) );
646 xFamilies
->getByName( aFamily
) >>= xFamily
;
647 aStyleName
= aStyleName
.copy( nPos
+ 1 );
652 // get graphics familie
653 xFamilies
->getByName( OUString( RTL_CONSTASCII_USTRINGPARAM( "graphics" ) ) ) >>= xFamily
;
654 aStyleName
= GetImport().GetStyleDisplayName(
655 XML_STYLE_FAMILY_SD_GRAPHICS_ID
,
660 xFamily
->getByName( aStyleName
) >>= xStyle
;
664 catch( uno::Exception
& )
666 DBG_ERROR( "could not find style for shape!" );
670 if( bSupportsStyle
&& xStyle
.is() )
674 // set style on object
677 xPropSet
->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Style")), aAny
);
679 catch( uno::Exception
& )
681 DBG_ERROR( "could not find style for shape!" );
685 // if this is an auto style, set its properties
686 if(bAutoStyle
&& pDocStyle
)
688 // set PropertySet on object
689 pDocStyle
->FillPropertySet(xPropSet
);
694 // try to set text auto style
697 // set style on shape
698 if( 0 == maTextStyleName
.getLength() )
701 if( NULL
== GetImport().GetShapeImport()->GetAutoStylesContext())
704 const SvXMLStyleContext
* pTempStyle
= GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(XML_STYLE_FAMILY_TEXT_PARAGRAPH
, maTextStyleName
);
705 XMLPropStyleContext
* pStyle
= PTR_CAST( XMLPropStyleContext
, pTempStyle
); // use temp var, PTR_CAST is a bad macro, FindStyleChildContext will be called twice
709 // set PropertySet on object
710 pStyle
->FillPropertySet(xPropSet
);
714 catch( uno::Exception
& )
719 void SdXMLShapeContext::SetLayer()
721 if( maLayerName
.getLength() )
725 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
729 aAny
<<= maLayerName
;
731 xPropSet
->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("LayerName")), aAny
);
735 catch( uno::Exception e
)
741 void SdXMLShapeContext::SetThumbnail()
743 if( 0 == maThumbnailURL
.getLength() )
748 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
752 const OUString
sProperty(RTL_CONSTASCII_USTRINGPARAM("ThumbnailGraphicURL"));
754 uno::Reference
< beans::XPropertySetInfo
> xPropSetInfo( xPropSet
->getPropertySetInfo() );
755 if( xPropSetInfo
.is() && xPropSetInfo
->hasPropertyByName( sProperty
) )
757 // load the thumbnail graphic and export it to a wmf stream so we can set
760 const OUString
aInternalURL( GetImport().ResolveGraphicObjectURL( maThumbnailURL
, sal_False
) );
761 xPropSet
->setPropertyValue( sProperty
, uno::makeAny( aInternalURL
) );
764 catch( uno::Exception e
)
769 // this is called from the parent group for each unparsed attribute in the attribute list
770 void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
772 if( XML_NAMESPACE_DRAW
== nPrefix
)
774 if( IsXMLToken( rLocalName
, XML_ZINDEX
) )
776 mnZOrder
= rValue
.toInt32();
778 else if( IsXMLToken( rLocalName
, XML_ID
) )
782 else if( IsXMLToken( rLocalName
, XML_NAME
) )
784 maShapeName
= rValue
;
786 else if( IsXMLToken( rLocalName
, XML_STYLE_NAME
) )
788 maDrawStyleName
= rValue
;
790 else if( IsXMLToken( rLocalName
, XML_TEXT_STYLE_NAME
) )
792 maTextStyleName
= rValue
;
794 else if( IsXMLToken( rLocalName
, XML_LAYER
) )
796 maLayerName
= rValue
;
798 else if( IsXMLToken( rLocalName
, XML_TRANSFORM
) )
800 mnTransform
.SetString(rValue
, GetImport().GetMM100UnitConverter());
803 else if( XML_NAMESPACE_PRESENTATION
== nPrefix
)
805 if( IsXMLToken( rLocalName
, XML_USER_TRANSFORMED
) )
807 mbIsUserTransformed
= IsXMLToken( rValue
, XML_TRUE
);
809 else if( IsXMLToken( rLocalName
, XML_PLACEHOLDER
) )
811 mbIsPlaceholder
= IsXMLToken( rValue
, XML_TRUE
);
812 if( mbIsPlaceholder
)
813 mbClearDefaultAttributes
= false;
815 else if( IsXMLToken( rLocalName
, XML_CLASS
) )
817 maPresentationClass
= rValue
;
819 else if( IsXMLToken( rLocalName
, XML_STYLE_NAME
) )
821 maDrawStyleName
= rValue
;
822 mnStyleFamily
= XML_STYLE_FAMILY_SD_PRESENTATION_ID
;
825 else if( XML_NAMESPACE_SVG
== nPrefix
)
827 if( IsXMLToken( rLocalName
, XML_X
) )
829 GetImport().GetMM100UnitConverter().convertMeasure(maPosition
.X
, rValue
);
831 else if( IsXMLToken( rLocalName
, XML_Y
) )
833 GetImport().GetMM100UnitConverter().convertMeasure(maPosition
.Y
, rValue
);
835 else if( IsXMLToken( rLocalName
, XML_WIDTH
) )
837 GetImport().GetMM100UnitConverter().convertMeasure(maSize
.Width
, rValue
);
838 if( maSize
.Width
> 0 )
840 else if( maSize
.Width
< 0 )
843 else if( IsXMLToken( rLocalName
, XML_HEIGHT
) )
845 GetImport().GetMM100UnitConverter().convertMeasure(maSize
.Height
, rValue
);
846 if( maSize
.Height
> 0 )
848 else if( maSize
.Height
< 0 )
851 else if( IsXMLToken( rLocalName
, XML_TRANSFORM
) )
853 // because of #85127# take svg:transform into account and hanle like
854 // draw:transform for compatibility
855 mnTransform
.SetString(rValue
, GetImport().GetMM100UnitConverter());
859 else if( IsXMLToken( rLocalName
, XML_TITLE
) )
861 maShapeTitle
= rValue
;
863 else if( IsXMLToken( rLocalName
, XML_DESC
) )
865 maShapeDescription
= rValue
;
868 else if( (XML_NAMESPACE_NONE
== nPrefix
) || (XML_NAMESPACE_XML
== nPrefix
) )
870 if( IsXMLToken( rLocalName
, XML_ID
) )
877 sal_Bool
SdXMLShapeContext::isPresentationShape() const
879 if( maPresentationClass
.getLength() && (const_cast<SdXMLShapeContext
*>(this))->GetImport().GetShapeImport()->IsPresentationShapesSupported() )
881 if(XML_STYLE_FAMILY_SD_PRESENTATION_ID
== mnStyleFamily
)
886 if( IsXMLToken( maPresentationClass
, XML_HEADER
) || IsXMLToken( maPresentationClass
, XML_FOOTER
) ||
887 IsXMLToken( maPresentationClass
, XML_PAGE_NUMBER
) || IsXMLToken( maPresentationClass
, XML_DATE_TIME
) )
896 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
897 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
899 TYPEINIT1( SdXMLRectShapeContext
, SdXMLShapeContext
);
901 SdXMLRectShapeContext::SdXMLRectShapeContext(
902 SvXMLImport
& rImport
,
904 const OUString
& rLocalName
,
905 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
906 uno::Reference
< drawing::XShapes
>& rShapes
,
907 sal_Bool bTemporaryShape
)
908 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
913 //////////////////////////////////////////////////////////////////////////////
915 SdXMLRectShapeContext::~SdXMLRectShapeContext()
919 //////////////////////////////////////////////////////////////////////////////
921 // this is called from the parent group for each unparsed attribute in the attribute list
922 void SdXMLRectShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
924 if( XML_NAMESPACE_DRAW
== nPrefix
)
926 if( IsXMLToken( rLocalName
, XML_CORNER_RADIUS
) )
928 GetImport().GetMM100UnitConverter().convertMeasure(mnRadius
, rValue
);
933 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
936 //////////////////////////////////////////////////////////////////////////////
938 void SdXMLRectShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
940 // create rectangle shape
941 AddShape("com.sun.star.drawing.RectangleShape");
944 // Add, set Style and properties from base shape
948 // set pos, size, shear and rotate
953 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
958 xPropSet
->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius")), uno::makeAny( mnRadius
) );
960 catch( uno::Exception
& )
962 DBG_ERROR( "exception during setting of corner radius!");
966 SdXMLShapeContext::StartElement(xAttrList
);
970 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
971 ////////////////////////////////////////3////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
973 TYPEINIT1( SdXMLLineShapeContext
, SdXMLShapeContext
);
975 SdXMLLineShapeContext::SdXMLLineShapeContext(
976 SvXMLImport
& rImport
,
978 const OUString
& rLocalName
,
979 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
980 uno::Reference
< drawing::XShapes
>& rShapes
,
981 sal_Bool bTemporaryShape
)
982 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
990 //////////////////////////////////////////////////////////////////////////////
992 SdXMLLineShapeContext::~SdXMLLineShapeContext()
996 //////////////////////////////////////////////////////////////////////////////
998 // this is called from the parent group for each unparsed attribute in the attribute list
999 void SdXMLLineShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1001 if( XML_NAMESPACE_SVG
== nPrefix
)
1003 if( IsXMLToken( rLocalName
, XML_X1
) )
1005 GetImport().GetMM100UnitConverter().convertMeasure(mnX1
, rValue
);
1008 if( IsXMLToken( rLocalName
, XML_Y1
) )
1010 GetImport().GetMM100UnitConverter().convertMeasure(mnY1
, rValue
);
1013 if( IsXMLToken( rLocalName
, XML_X2
) )
1015 GetImport().GetMM100UnitConverter().convertMeasure(mnX2
, rValue
);
1018 if( IsXMLToken( rLocalName
, XML_Y2
) )
1020 GetImport().GetMM100UnitConverter().convertMeasure(mnY2
, rValue
);
1025 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1028 //////////////////////////////////////////////////////////////////////////////
1030 void SdXMLLineShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1032 // #85920# use SetTransformation() to handle import of simple lines.
1033 // This is necessary to kake into account all anchor positions and
1034 // other things. All shape imports use the same import schemata now.
1035 // create necessary shape (Line Shape)
1036 AddShape("com.sun.star.drawing.PolyLineShape");
1040 // Add, set Style and properties from base shape
1044 // get sizes and offsets
1045 awt::Point
aTopLeft(mnX1
, mnY1
);
1046 awt::Point
aBottomRight(mnX2
, mnY2
);
1051 aBottomRight
.X
= mnX1
;
1057 aBottomRight
.Y
= mnY1
;
1060 // set local parameters on shape
1061 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
1064 drawing::PointSequenceSequence
aPolyPoly(1L);
1065 drawing::PointSequence
* pOuterSequence
= aPolyPoly
.getArray();
1066 pOuterSequence
->realloc(2L);
1067 awt::Point
* pInnerSequence
= pOuterSequence
->getArray();
1070 *pInnerSequence
= awt::Point( mnX1
- aTopLeft
.X
, mnY1
- aTopLeft
.Y
);
1072 *pInnerSequence
= awt::Point( mnX2
- aTopLeft
.X
, mnY2
- aTopLeft
.Y
);
1075 xPropSet
->setPropertyValue(
1076 OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny
);
1079 // set sizes for transformation
1080 maSize
.Width
= aBottomRight
.X
- aTopLeft
.X
;
1081 maSize
.Height
= aBottomRight
.Y
- aTopLeft
.Y
;
1082 maPosition
.X
= aTopLeft
.X
;
1083 maPosition
.Y
= aTopLeft
.Y
;
1085 // set pos, size, shear and rotate and get copy of matrix
1086 SetTransformation();
1088 SdXMLShapeContext::StartElement(xAttrList
);
1092 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1093 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1095 TYPEINIT1( SdXMLEllipseShapeContext
, SdXMLShapeContext
);
1097 SdXMLEllipseShapeContext::SdXMLEllipseShapeContext(
1098 SvXMLImport
& rImport
,
1100 const OUString
& rLocalName
,
1101 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1102 uno::Reference
< drawing::XShapes
>& rShapes
,
1103 sal_Bool bTemporaryShape
)
1104 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1109 meKind( drawing::CircleKind_FULL
),
1115 //////////////////////////////////////////////////////////////////////////////
1117 SdXMLEllipseShapeContext::~SdXMLEllipseShapeContext()
1121 //////////////////////////////////////////////////////////////////////////////
1123 // this is called from the parent group for each unparsed attribute in the attribute list
1124 void SdXMLEllipseShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1126 if( XML_NAMESPACE_SVG
== nPrefix
)
1128 if( IsXMLToken( rLocalName
, XML_RX
) )
1130 GetImport().GetMM100UnitConverter().convertMeasure(mnRX
, rValue
);
1133 if( IsXMLToken( rLocalName
, XML_RY
) )
1135 GetImport().GetMM100UnitConverter().convertMeasure(mnRY
, rValue
);
1138 if( IsXMLToken( rLocalName
, XML_CX
) )
1140 GetImport().GetMM100UnitConverter().convertMeasure(mnCX
, rValue
);
1143 if( IsXMLToken( rLocalName
, XML_CY
) )
1145 GetImport().GetMM100UnitConverter().convertMeasure(mnCY
, rValue
);
1148 if( IsXMLToken( rLocalName
, XML_R
) )
1150 // single radius, it's a circle and both radii are the same
1151 GetImport().GetMM100UnitConverter().convertMeasure(mnRX
, rValue
);
1156 else if( XML_NAMESPACE_DRAW
== nPrefix
)
1158 if( IsXMLToken( rLocalName
, XML_KIND
) )
1161 if( SvXMLUnitConverter::convertEnum( eKind
, rValue
, aXML_CircleKind_EnumMap
) )
1167 if( IsXMLToken( rLocalName
, XML_START_ANGLE
) )
1170 if( SvXMLUnitConverter::convertDouble( dStartAngle
, rValue
) )
1171 mnStartAngle
= (sal_Int32
)(dStartAngle
* 100.0);
1174 if( IsXMLToken( rLocalName
, XML_END_ANGLE
) )
1177 if( SvXMLUnitConverter::convertDouble( dEndAngle
, rValue
) )
1178 mnEndAngle
= (sal_Int32
)(dEndAngle
* 100.0);
1183 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1186 //////////////////////////////////////////////////////////////////////////////
1188 void SdXMLEllipseShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1190 // create rectangle shape
1191 AddShape("com.sun.star.drawing.EllipseShape");
1194 // Add, set Style and properties from base shape
1198 // set pos, size, shear and rotate
1199 SetTransformation();
1201 if( meKind
!= drawing::CircleKind_FULL
)
1203 uno::Reference
< beans::XPropertySet
> xPropSet( mxShape
, uno::UNO_QUERY
);
1207 aAny
<<= (drawing::CircleKind
)meKind
;
1208 xPropSet
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleKind")), aAny
);
1210 aAny
<<= mnStartAngle
;
1211 xPropSet
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleStartAngle")), aAny
);
1213 aAny
<<= mnEndAngle
;
1214 xPropSet
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CircleEndAngle")), aAny
);
1218 SdXMLShapeContext::StartElement(xAttrList
);
1222 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1223 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1225 TYPEINIT1( SdXMLPolygonShapeContext
, SdXMLShapeContext
);
1227 SdXMLPolygonShapeContext::SdXMLPolygonShapeContext(
1228 SvXMLImport
& rImport
,
1230 const OUString
& rLocalName
,
1231 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1232 uno::Reference
< drawing::XShapes
>& rShapes
, sal_Bool bClosed
, sal_Bool bTemporaryShape
)
1233 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1238 //////////////////////////////////////////////////////////////////////////////
1240 // this is called from the parent group for each unparsed attribute in the attribute list
1241 void SdXMLPolygonShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1243 if( XML_NAMESPACE_SVG
== nPrefix
)
1245 if( IsXMLToken( rLocalName
, XML_VIEWBOX
) )
1251 else if( XML_NAMESPACE_DRAW
== nPrefix
)
1253 if( IsXMLToken( rLocalName
, XML_POINTS
) )
1260 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1263 //////////////////////////////////////////////////////////////////////////////
1265 SdXMLPolygonShapeContext::~SdXMLPolygonShapeContext()
1269 //////////////////////////////////////////////////////////////////////////////
1271 void SdXMLPolygonShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1273 // Add, set Style and properties from base shape
1275 AddShape("com.sun.star.drawing.PolyPolygonShape");
1277 AddShape("com.sun.star.drawing.PolyLineShape");
1284 // set local parameters on shape
1285 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
1289 if(maPoints
.getLength() && maViewBox
.getLength())
1291 SdXMLImExViewBox
aViewBox(maViewBox
, GetImport().GetMM100UnitConverter());
1292 awt::Size
aSize(aViewBox
.GetWidth(), aViewBox
.GetHeight());
1293 if (maSize
.Width
!= 0 && maSize
.Height
!=0)
1297 awt::Point
aPosition(aViewBox
.GetX(), aViewBox
.GetY());
1298 SdXMLImExPointsElement
aPoints(maPoints
, aViewBox
,
1299 aPosition
, aSize
, GetImport().GetMM100UnitConverter());
1302 aAny
<<= aPoints
.GetPointSequenceSequence();
1303 xPropSet
->setPropertyValue(
1304 OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny
);
1308 // set pos, size, shear and rotate and get copy of matrix
1309 SetTransformation();
1311 SdXMLShapeContext::StartElement(xAttrList
);
1315 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1316 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1318 TYPEINIT1( SdXMLPathShapeContext
, SdXMLShapeContext
);
1320 SdXMLPathShapeContext::SdXMLPathShapeContext(
1321 SvXMLImport
& rImport
,
1323 const OUString
& rLocalName
,
1324 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1325 uno::Reference
< drawing::XShapes
>& rShapes
,
1326 sal_Bool bTemporaryShape
)
1327 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1332 //////////////////////////////////////////////////////////////////////////////
1334 SdXMLPathShapeContext::~SdXMLPathShapeContext()
1338 //////////////////////////////////////////////////////////////////////////////
1340 // this is called from the parent group for each unparsed attribute in the attribute list
1341 void SdXMLPathShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1343 if( XML_NAMESPACE_SVG
== nPrefix
)
1345 if( IsXMLToken( rLocalName
, XML_VIEWBOX
) )
1350 else if( IsXMLToken( rLocalName
, XML_D
) )
1357 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1360 //////////////////////////////////////////////////////////////////////////////
1362 void SdXMLPathShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1364 // create polygon shape
1367 // prepare some of the parameters
1368 SdXMLImExViewBox
aViewBox(maViewBox
, GetImport().GetMM100UnitConverter());
1369 awt::Size
aSize(aViewBox
.GetWidth(), aViewBox
.GetHeight());
1370 awt::Point
aPosition(aViewBox
.GetX(), aViewBox
.GetY());
1371 if (maSize
.Width
!= 0 && maSize
.Height
!=0)
1375 SdXMLImExSvgDElement
aPoints(maD
, aViewBox
,
1376 aPosition
, aSize
, GetImport().GetMM100UnitConverter());
1378 const char* pService
;
1380 if(aPoints
.IsCurve())
1382 if(aPoints
.IsClosed())
1384 pService
= "com.sun.star.drawing.ClosedBezierShape";
1388 pService
= "com.sun.star.drawing.OpenBezierShape";
1393 if(aPoints
.IsClosed())
1395 pService
= "com.sun.star.drawing.PolyPolygonShape";
1399 pService
= "com.sun.star.drawing.PolyLineShape";
1403 // Add, set Style and properties from base shape
1406 // #89344# test for mxShape.is() and not for mxShapes.is() to support
1407 // shape import helper classes WITHOUT XShapes (member mxShapes). This
1408 // is used by the writer.
1414 // set local parameters on shape
1415 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
1423 if(aPoints
.IsCurve())
1425 drawing::PolyPolygonBezierCoords
aSourcePolyPolygon(
1426 aPoints
.GetPointSequenceSequence(),
1427 aPoints
.GetFlagSequenceSequence());
1429 aAny
<<= aSourcePolyPolygon
;
1430 xPropSet
->setPropertyValue(
1431 OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny
);
1435 aAny
<<= aPoints
.GetPointSequenceSequence();
1436 xPropSet
->setPropertyValue(
1437 OUString(RTL_CONSTASCII_USTRINGPARAM("Geometry")), aAny
);
1442 // set pos, size, shear and rotate
1443 SetTransformation();
1445 SdXMLShapeContext::StartElement(xAttrList
);
1450 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1451 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1453 TYPEINIT1( SdXMLTextBoxShapeContext
, SdXMLShapeContext
);
1455 SdXMLTextBoxShapeContext::SdXMLTextBoxShapeContext(
1456 SvXMLImport
& rImport
,
1458 const OUString
& rLocalName
,
1459 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1460 uno::Reference
< drawing::XShapes
>& rShapes
,
1461 sal_Bool bTemporaryShape
)
1462 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1467 //////////////////////////////////////////////////////////////////////////////
1469 SdXMLTextBoxShapeContext::~SdXMLTextBoxShapeContext()
1473 //////////////////////////////////////////////////////////////////////////////
1475 // this is called from the parent group for each unparsed attribute in the attribute list
1476 void SdXMLTextBoxShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1478 if( XML_NAMESPACE_DRAW
== nPrefix
)
1480 if( IsXMLToken( rLocalName
, XML_CORNER_RADIUS
) )
1482 GetImport().GetMM100UnitConverter().convertMeasure(mnRadius
, rValue
);
1487 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1490 //////////////////////////////////////////////////////////////////////////////
1492 void SdXMLTextBoxShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>&)
1494 // create textbox shape
1495 sal_Bool bIsPresShape
= sal_False
;
1496 bool bClearText
= false;
1498 const char *pService
= NULL
;
1500 if( isPresentationShape() )
1502 // check if the current document supports presentation shapes
1503 if( GetImport().GetShapeImport()->IsPresentationShapesSupported() )
1505 if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_SUBTITLE
))
1507 // XmlShapeTypePresSubtitleShape
1508 pService
= "com.sun.star.presentation.SubtitleShape";
1510 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_OUTLINE
) )
1512 // XmlShapeTypePresOutlinerShape
1513 pService
= "com.sun.star.presentation.OutlinerShape";
1515 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_NOTES
) )
1517 // XmlShapeTypePresNotesShape
1518 pService
= "com.sun.star.presentation.NotesShape";
1520 else if( IsXMLToken( maPresentationClass
, XML_HEADER
) )
1522 // XmlShapeTypePresHeaderShape
1523 pService
= "com.sun.star.presentation.HeaderShape";
1526 else if( IsXMLToken( maPresentationClass
, XML_FOOTER
) )
1528 // XmlShapeTypePresFooterShape
1529 pService
= "com.sun.star.presentation.FooterShape";
1532 else if( IsXMLToken( maPresentationClass
, XML_PAGE_NUMBER
) )
1534 // XmlShapeTypePresSlideNumberShape
1535 pService
= "com.sun.star.presentation.SlideNumberShape";
1538 else if( IsXMLToken( maPresentationClass
, XML_DATE_TIME
) )
1540 // XmlShapeTypePresDateTimeShape
1541 pService
= "com.sun.star.presentation.DateTimeShape";
1544 else // IsXMLToken( maPresentationClass, XML_PRESENTATION_TITLE ) )
1546 // XmlShapeTypePresTitleTextShape
1547 pService
= "com.sun.star.presentation.TitleTextShape";
1549 bIsPresShape
= TRUE
;
1553 if( NULL
== pService
)
1555 // normal text shape
1556 pService
= "com.sun.star.drawing.TextShape";
1559 // Add, set Style and properties from base shape
1569 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
1572 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
1573 if( xPropsInfo
.is() )
1575 if( !mbIsPlaceholder
&& xPropsInfo
->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
1576 xProps
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False
) );
1578 if( mbIsUserTransformed
&& xPropsInfo
->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
1579 xProps
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False
) );
1586 uno::Reference
< text::XText
> xText( mxShape
, uno::UNO_QUERY
);
1588 xText
->setString( aEmpty
);
1591 // set parameters on shape
1592 //A AW->CL: Eventually You need to strip scale and translate from the transformation
1593 //A to reach the same goal again.
1594 //A if(!bIsPresShape || mbIsUserTransformed)
1596 //A // set pos and size on shape, this should remove binding
1597 //A // to pres object on masterpage
1598 //A SetSizeAndPosition();
1601 // set pos, size, shear and rotate
1602 SetTransformation();
1606 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
1611 xPropSet
->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius")), uno::makeAny( mnRadius
) );
1613 catch( uno::Exception
& )
1615 DBG_ERROR( "exception during setting of corner radius!");
1620 SdXMLShapeContext::StartElement(mxAttrList
);
1624 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1625 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1627 TYPEINIT1( SdXMLControlShapeContext
, SdXMLShapeContext
);
1629 SdXMLControlShapeContext::SdXMLControlShapeContext(
1630 SvXMLImport
& rImport
,
1632 const OUString
& rLocalName
,
1633 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1634 uno::Reference
< drawing::XShapes
>& rShapes
,
1635 sal_Bool bTemporaryShape
)
1636 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
)
1640 //////////////////////////////////////////////////////////////////////////////
1642 SdXMLControlShapeContext::~SdXMLControlShapeContext()
1646 //////////////////////////////////////////////////////////////////////////////
1648 // this is called from the parent group for each unparsed attribute in the attribute list
1649 void SdXMLControlShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1651 if( XML_NAMESPACE_DRAW
== nPrefix
)
1653 if( IsXMLToken( rLocalName
, XML_CONTROL
) )
1660 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1663 void SdXMLControlShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1665 // create Control shape
1666 // add, set style and properties from base shape
1667 AddShape("com.sun.star.drawing.ControlShape");
1670 DBG_ASSERT( maFormId
.getLength(), "draw:control without a form:id attribute!" );
1671 if( maFormId
.getLength() )
1674 if( GetImport().IsFormsSupported() )
1676 uno::Reference
< awt::XControlModel
> xControlModel( GetImport().GetFormImport()->lookupControl( maFormId
), uno::UNO_QUERY
);
1677 if( xControlModel
.is() )
1679 uno::Reference
< drawing::XControlShape
> xControl( mxShape
, uno::UNO_QUERY
);
1681 xControl
->setControl( xControlModel
);
1685 #endif // #ifndef SVX_LIGHT
1691 // set pos, size, shear and rotate
1692 SetTransformation();
1694 SdXMLShapeContext::StartElement(xAttrList
);
1698 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1699 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1701 TYPEINIT1( SdXMLConnectorShapeContext
, SdXMLShapeContext
);
1703 SdXMLConnectorShapeContext::SdXMLConnectorShapeContext(
1704 SvXMLImport
& rImport
,
1706 const OUString
& rLocalName
,
1707 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1708 uno::Reference
< drawing::XShapes
>& rShapes
,
1709 sal_Bool bTemporaryShape
)
1710 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1713 mnType( (USHORT
)drawing::ConnectorType_STANDARD
),
1722 //////////////////////////////////////////////////////////////////////////////
1724 SdXMLConnectorShapeContext::~SdXMLConnectorShapeContext()
1728 //////////////////////////////////////////////////////////////////////////////
1730 // this is called from the parent group for each unparsed attribute in the attribute list
1731 void SdXMLConnectorShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1735 case XML_NAMESPACE_DRAW
:
1737 if( IsXMLToken( rLocalName
, XML_START_SHAPE
) )
1739 maStartShapeId
= rValue
;
1742 if( IsXMLToken( rLocalName
, XML_START_GLUE_POINT
) )
1744 mnStartGlueId
= rValue
.toInt32();
1747 if( IsXMLToken( rLocalName
, XML_END_SHAPE
) )
1749 maEndShapeId
= rValue
;
1752 if( IsXMLToken( rLocalName
, XML_END_GLUE_POINT
) )
1754 mnEndGlueId
= rValue
.toInt32();
1757 if( IsXMLToken( rLocalName
, XML_LINE_SKEW
) )
1759 SvXMLTokenEnumerator
aTokenEnum( rValue
);
1761 if( aTokenEnum
.getNextToken( aToken
) )
1763 GetImport().GetMM100UnitConverter().convertMeasure(mnDelta1
, aToken
);
1764 if( aTokenEnum
.getNextToken( aToken
) )
1766 GetImport().GetMM100UnitConverter().convertMeasure(mnDelta2
, aToken
);
1767 if( aTokenEnum
.getNextToken( aToken
) )
1769 GetImport().GetMM100UnitConverter().convertMeasure(mnDelta3
, aToken
);
1775 if( IsXMLToken( rLocalName
, XML_TYPE
) )
1777 SvXMLUnitConverter::convertEnum( mnType
, rValue
, aXML_ConnectionKind_EnumMap
);
1781 case XML_NAMESPACE_SVG
:
1783 if( IsXMLToken( rLocalName
, XML_X1
) )
1785 GetImport().GetMM100UnitConverter().convertMeasure(maStart
.X
, rValue
);
1788 if( IsXMLToken( rLocalName
, XML_Y1
) )
1790 GetImport().GetMM100UnitConverter().convertMeasure(maStart
.Y
, rValue
);
1793 if( IsXMLToken( rLocalName
, XML_X2
) )
1795 GetImport().GetMM100UnitConverter().convertMeasure(maEnd
.X
, rValue
);
1798 if( IsXMLToken( rLocalName
, XML_Y2
) )
1800 GetImport().GetMM100UnitConverter().convertMeasure(maEnd
.Y
, rValue
);
1803 if( IsXMLToken( rLocalName
, XML_D
) )
1805 SdXMLImExViewBox
aViewBox( 0, 0, 1, 1 );
1806 awt::Point
aPoint( 0, 0 );
1807 awt::Size
aSize( 1, 1 );
1809 SdXMLImExSvgDElement
aPoints( rValue
, aViewBox
,
1810 aPoint
, aSize
, GetImport().GetMM100UnitConverter() );
1812 if ( aPoints
.IsCurve() )
1814 drawing::PolyPolygonBezierCoords
aSourcePolyPolygon(
1815 aPoints
.GetPointSequenceSequence(),
1816 aPoints
.GetFlagSequenceSequence());
1817 maPath
<<= aSourcePolyPolygon
;
1821 const drawing::PointSequenceSequence
& rOuterSeq
= aPoints
.GetPointSequenceSequence();
1822 drawing::FlagSequenceSequence
aFlagSeqSeq( rOuterSeq
.getLength() );
1823 for ( int a
= 0; a
< rOuterSeq
.getLength(); a
++ )
1824 aFlagSeqSeq
[ a
] = drawing::FlagSequence( rOuterSeq
[ a
].getLength() );
1826 drawing::PolyPolygonBezierCoords
aSourcePolyPolygon(
1827 aPoints
.GetPointSequenceSequence(),
1829 maPath
<<= aSourcePolyPolygon
;
1835 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1838 //////////////////////////////////////////////////////////////////////////////
1840 void SdXMLConnectorShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1843 // For security reasons, do not add empty connectors. There may have been an error in EA2
1844 // that created empty, far set off connectors (e.g. 63 meters below top of document). This
1845 // is not guaranteed, but it's definitely safe to not add empty connectors.
1846 sal_Bool
bDoAdd(sal_True
);
1848 if( 0 == maStartShapeId
.getLength()
1849 && 0 == maEndShapeId
.getLength()
1850 && maStart
.X
== maEnd
.X
1851 && maStart
.Y
== maEnd
.Y
1862 // create Connector shape
1863 // add, set style and properties from base shape
1864 AddShape("com.sun.star.drawing.ConnectorShape");
1867 // add connection ids
1868 if( maStartShapeId
.getLength() )
1869 GetImport().GetShapeImport()->addShapeConnection( mxShape
, sal_True
, maStartShapeId
, mnStartGlueId
);
1870 if( maEndShapeId
.getLength() )
1871 GetImport().GetShapeImport()->addShapeConnection( mxShape
, sal_False
, maEndShapeId
, mnEndGlueId
);
1873 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
1878 xProps
->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")), aAny
);
1881 xProps
->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")), aAny
);
1883 aAny
<<= (drawing::ConnectorType
)mnType
;
1884 xProps
->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeKind")), aAny
);
1887 xProps
->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine1Delta")), aAny
);
1890 xProps
->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine2Delta")), aAny
);
1893 xProps
->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EdgeLine3Delta")), aAny
);
1898 if ( maPath
.hasValue() )
1899 xProps
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("PolyPolygonBezier") ), maPath
);
1901 SdXMLShapeContext::StartElement(xAttrList
);
1906 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1907 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1909 TYPEINIT1( SdXMLMeasureShapeContext
, SdXMLShapeContext
);
1911 SdXMLMeasureShapeContext::SdXMLMeasureShapeContext(
1912 SvXMLImport
& rImport
,
1914 const OUString
& rLocalName
,
1915 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1916 uno::Reference
< drawing::XShapes
>& rShapes
,
1917 sal_Bool bTemporaryShape
)
1918 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1924 //////////////////////////////////////////////////////////////////////////////
1926 SdXMLMeasureShapeContext::~SdXMLMeasureShapeContext()
1930 // this is called from the parent group for each unparsed attribute in the attribute list
1931 void SdXMLMeasureShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1935 case XML_NAMESPACE_SVG
:
1937 if( IsXMLToken( rLocalName
, XML_X1
) )
1939 GetImport().GetMM100UnitConverter().convertMeasure(maStart
.X
, rValue
);
1942 if( IsXMLToken( rLocalName
, XML_Y1
) )
1944 GetImport().GetMM100UnitConverter().convertMeasure(maStart
.Y
, rValue
);
1947 if( IsXMLToken( rLocalName
, XML_X2
) )
1949 GetImport().GetMM100UnitConverter().convertMeasure(maEnd
.X
, rValue
);
1952 if( IsXMLToken( rLocalName
, XML_Y2
) )
1954 GetImport().GetMM100UnitConverter().convertMeasure(maEnd
.Y
, rValue
);
1960 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1963 //////////////////////////////////////////////////////////////////////////////
1965 void SdXMLMeasureShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1967 // create Measure shape
1968 // add, set style and properties from base shape
1969 AddShape("com.sun.star.drawing.MeasureShape");
1975 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
1980 xProps
->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("StartPosition")), aAny
);
1983 xProps
->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("EndPosition")), aAny
);
1986 // delete pre created fields
1987 uno::Reference
< text::XText
> xText( mxShape
, uno::UNO_QUERY
);
1990 const OUString
aEmpty( RTL_CONSTASCII_USTRINGPARAM( " " ) );
1991 xText
->setString( aEmpty
);
1994 SdXMLShapeContext::StartElement(xAttrList
);
1998 void SdXMLMeasureShapeContext::EndElement()
2002 // delete pre created fields
2003 uno::Reference
< text::XText
> xText( mxShape
, uno::UNO_QUERY
);
2007 uno::Reference
< text::XTextCursor
> xCursor( xText
->createTextCursor() );
2011 const OUString aEmpty
;
2012 xCursor
->collapseToStart();
2013 xCursor
->goRight( 1, sal_True
);
2014 xCursor
->setString( aEmpty
);
2018 SdXMLShapeContext::EndElement();
2021 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2022 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2024 TYPEINIT1( SdXMLPageShapeContext
, SdXMLShapeContext
);
2026 SdXMLPageShapeContext::SdXMLPageShapeContext(
2027 SvXMLImport
& rImport
,
2029 const OUString
& rLocalName
,
2030 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2031 uno::Reference
< drawing::XShapes
>& rShapes
,
2032 sal_Bool bTemporaryShape
)
2033 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
), mnPageNumber(0)
2035 mbClearDefaultAttributes
= false;
2038 //////////////////////////////////////////////////////////////////////////////
2040 SdXMLPageShapeContext::~SdXMLPageShapeContext()
2044 //////////////////////////////////////////////////////////////////////////////
2046 // this is called from the parent group for each unparsed attribute in the attribute list
2047 void SdXMLPageShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2049 if( XML_NAMESPACE_DRAW
== nPrefix
)
2051 if( IsXMLToken( rLocalName
, XML_PAGE_NUMBER
) )
2053 mnPageNumber
= rValue
.toInt32();
2058 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2061 //////////////////////////////////////////////////////////////////////////////
2063 void SdXMLPageShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
2065 // create Page shape
2066 // add, set style and properties from base shape
2068 // #86163# take into account which type of PageShape needs to
2069 // be constructed. It's an pres shape if presentation:XML_CLASS == XML_PRESENTATION_PAGE.
2070 sal_Bool bIsPresentation
= maPresentationClass
.getLength() &&
2071 GetImport().GetShapeImport()->IsPresentationShapesSupported();
2073 uno::Reference
< lang::XServiceInfo
> xInfo( mxShapes
, uno::UNO_QUERY
);
2074 const sal_Bool bIsOnHandoutPage
= xInfo
.is() && xInfo
->supportsService( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutMasterPage")) );
2076 if( bIsOnHandoutPage
)
2078 AddShape("com.sun.star.presentation.HandoutShape");
2082 if(bIsPresentation
&& !IsXMLToken( maPresentationClass
, XML_PRESENTATION_PAGE
) )
2084 bIsPresentation
= FALSE
;
2089 AddShape("com.sun.star.presentation.PageShape");
2093 AddShape("com.sun.star.drawing.PageShape");
2102 // set pos, size, shear and rotate
2103 SetTransformation();
2105 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
2108 uno::Reference
< beans::XPropertySetInfo
> xPropSetInfo( xPropSet
->getPropertySetInfo() );
2109 const OUString
aPageNumberStr(RTL_CONSTASCII_USTRINGPARAM("PageNumber"));
2110 if( xPropSetInfo
.is() && xPropSetInfo
->hasPropertyByName(aPageNumberStr
))
2111 xPropSet
->setPropertyValue(aPageNumberStr
, uno::makeAny( mnPageNumber
));
2114 SdXMLShapeContext::StartElement(xAttrList
);
2118 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2119 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2121 TYPEINIT1( SdXMLCaptionShapeContext
, SdXMLShapeContext
);
2123 SdXMLCaptionShapeContext::SdXMLCaptionShapeContext(
2124 SvXMLImport
& rImport
,
2126 const OUString
& rLocalName
,
2127 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2128 uno::Reference
< drawing::XShapes
>& rShapes
,
2129 sal_Bool bTemporaryShape
)
2130 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2131 // #86616# for correct edge rounding import mnRadius needs to be initialized
2136 //////////////////////////////////////////////////////////////////////////////
2138 SdXMLCaptionShapeContext::~SdXMLCaptionShapeContext()
2142 //////////////////////////////////////////////////////////////////////////////
2144 void SdXMLCaptionShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
2146 // create Caption shape
2147 // add, set style and properties from base shape
2148 AddShape("com.sun.star.drawing.CaptionShape");
2154 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
2156 // SJ: If AutoGrowWidthItem is set, SetTransformation will lead to the wrong SnapRect
2157 // because NbcAdjustTextFrameWidthAndHeight() is called (text is set later and center alignment
2158 // is the default setting, so the top left reference point that is used by the caption point is
2159 // no longer correct) There are two ways to solve this problem, temporarily disabling the
2160 // autogrowwith as we are doing here or to apply the CaptionPoint after setting text
2161 sal_Bool bIsAutoGrowWidth
= sal_False
;
2164 uno::Any
aAny( xProps
->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("TextAutoGrowWidth") ) ) );
2165 aAny
>>= bIsAutoGrowWidth
;
2167 if ( bIsAutoGrowWidth
)
2168 xProps
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("TextAutoGrowWidth")), uno::makeAny( sal_False
) );
2171 // set pos, size, shear and rotate
2172 SetTransformation();
2174 xProps
->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CaptionPoint")), uno::makeAny( maCaptionPoint
) );
2176 if ( bIsAutoGrowWidth
)
2177 xProps
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("TextAutoGrowWidth")), uno::makeAny( sal_True
) );
2181 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
2186 xPropSet
->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("CornerRadius")), uno::makeAny( mnRadius
) );
2188 catch( uno::Exception
& )
2190 DBG_ERROR( "exception during setting of corner radius!");
2195 SdXMLShapeContext::StartElement(xAttrList
);
2199 // this is called from the parent group for each unparsed attribute in the attribute list
2200 void SdXMLCaptionShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2202 if( XML_NAMESPACE_DRAW
== nPrefix
)
2204 if( IsXMLToken( rLocalName
, XML_CAPTION_POINT_X
) )
2206 GetImport().GetMM100UnitConverter().convertMeasure(maCaptionPoint
.X
, rValue
);
2209 if( IsXMLToken( rLocalName
, XML_CAPTION_POINT_Y
) )
2211 GetImport().GetMM100UnitConverter().convertMeasure(maCaptionPoint
.Y
, rValue
);
2214 if( IsXMLToken( rLocalName
, XML_CORNER_RADIUS
) )
2216 GetImport().GetMM100UnitConverter().convertMeasure(mnRadius
, rValue
);
2220 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2223 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2224 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2226 TYPEINIT1( SdXMLGraphicObjectShapeContext
, SdXMLShapeContext
);
2228 SdXMLGraphicObjectShapeContext::SdXMLGraphicObjectShapeContext(
2229 SvXMLImport
& rImport
,
2231 const OUString
& rLocalName
,
2232 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2233 uno::Reference
< drawing::XShapes
>& rShapes
,
2234 sal_Bool bTemporaryShape
)
2235 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2240 //////////////////////////////////////////////////////////////////////////////
2242 // this is called from the parent group for each unparsed attribute in the attribute list
2243 void SdXMLGraphicObjectShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2245 if( XML_NAMESPACE_XLINK
== nPrefix
)
2247 if( IsXMLToken( rLocalName
, XML_HREF
) )
2254 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2257 //////////////////////////////////////////////////////////////////////////////
2259 void SdXMLGraphicObjectShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& )
2261 // create graphic object shape
2262 const char *pService
;
2264 if( IsXMLToken( maPresentationClass
, XML_GRAPHIC
) && GetImport().GetShapeImport()->IsPresentationShapesSupported() )
2266 pService
= "com.sun.star.presentation.GraphicObjectShape";
2270 pService
= "com.sun.star.drawing.GraphicObjectShape";
2273 AddShape( pService
);
2280 uno::Reference
< beans::XPropertySet
> xPropset(mxShape
, uno::UNO_QUERY
);
2283 // since OOo 1.x had no line or fill style for graphics, but may create
2284 // documents with them, we have to override them here
2285 sal_Int32 nUPD
, nBuildId
;
2286 if( GetImport().getBuildIds( nUPD
, nBuildId
) && (nUPD
== 645) ) try
2288 xPropset
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle")), Any( FillStyle_NONE
) );
2289 xPropset
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("LineStyle")), Any( LineStyle_NONE
) );
2295 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xPropset
->getPropertySetInfo() );
2296 if( xPropsInfo
.is() && xPropsInfo
->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
2297 xPropset
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( mbIsPlaceholder
) );
2299 if( !mbIsPlaceholder
)
2301 if( maURL
.getLength() )
2304 aAny
<<= GetImport().ResolveGraphicObjectURL( maURL
, GetImport().isGraphicLoadOnDemandSupported() );
2307 xPropset
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL") ), aAny
);
2308 xPropset
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL") ), aAny
);
2310 catch (lang::IllegalArgumentException
const &)
2317 if(mbIsUserTransformed
)
2319 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2322 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
2323 if( xPropsInfo
.is() )
2325 if( xPropsInfo
->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
2326 xProps
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False
) );
2331 // set pos, size, shear and rotate
2332 SetTransformation();
2334 SdXMLShapeContext::StartElement(mxAttrList
);
2338 void SdXMLGraphicObjectShapeContext::EndElement()
2340 if( mxBase64Stream
.is() )
2342 OUString
sURL( GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream
) );
2343 if( sURL
.getLength() )
2347 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2350 const uno::Any
aAny( uno::makeAny( sURL
) );
2351 xProps
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicURL") ), aAny
);
2352 xProps
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("GraphicStreamURL") ), aAny
);
2355 catch (lang::IllegalArgumentException
const &)
2361 SdXMLShapeContext::EndElement();
2365 //////////////////////////////////////////////////////////////////////////////
2367 SvXMLImportContext
* SdXMLGraphicObjectShapeContext::CreateChildContext(
2368 USHORT nPrefix
, const ::rtl::OUString
& rLocalName
,
2369 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
)
2371 SvXMLImportContext
* pContext
= NULL
;
2373 if( (XML_NAMESPACE_OFFICE
== nPrefix
) &&
2374 xmloff::token::IsXMLToken( rLocalName
, xmloff::token::XML_BINARY_DATA
) )
2376 if( !maURL
.getLength() && !mxBase64Stream
.is() )
2378 mxBase64Stream
= GetImport().GetStreamForGraphicObjectURLFromBase64();
2379 if( mxBase64Stream
.is() )
2380 pContext
= new XMLBase64ImportContext( GetImport(), nPrefix
,
2381 rLocalName
, xAttrList
,
2386 // delegate to parent class if no context could be created
2387 if ( NULL
== pContext
)
2388 pContext
= SdXMLShapeContext::CreateChildContext(nPrefix
, rLocalName
,
2394 //////////////////////////////////////////////////////////////////////////////
2396 SdXMLGraphicObjectShapeContext::~SdXMLGraphicObjectShapeContext()
2401 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2402 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2404 TYPEINIT1( SdXMLChartShapeContext
, SdXMLShapeContext
);
2406 SdXMLChartShapeContext::SdXMLChartShapeContext(
2407 SvXMLImport
& rImport
,
2409 const OUString
& rLocalName
,
2410 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2411 uno::Reference
< drawing::XShapes
>& rShapes
,
2412 sal_Bool bTemporaryShape
)
2413 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2414 mpChartContext( NULL
)
2418 //////////////////////////////////////////////////////////////////////////////
2420 SdXMLChartShapeContext::~SdXMLChartShapeContext()
2422 if( mpChartContext
)
2423 delete mpChartContext
;
2426 //////////////////////////////////////////////////////////////////////////////
2428 void SdXMLChartShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
2430 const sal_Bool bIsPresentation
= isPresentationShape();
2432 AddShape( bIsPresentation
? "com.sun.star.presentation.ChartShape" : "com.sun.star.drawing.OLE2Shape" );
2439 if( !mbIsPlaceholder
)
2441 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2444 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
2445 if( xPropsInfo
.is() && xPropsInfo
->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
2446 xProps
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False
) );
2450 const OUString
aCLSID( RTL_CONSTASCII_USTRINGPARAM("12DCAE26-281F-416F-a234-c3086127382e"));
2453 xProps
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID") ), aAny
);
2456 aAny
= xProps
->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) );
2457 uno::Reference
< frame::XModel
> xChartModel
;
2458 if( aAny
>>= xChartModel
)
2460 mpChartContext
= GetImport().GetChartImport()->CreateChartContext( GetImport(), XML_NAMESPACE_SVG
, GetXMLToken(XML_CHART
), xChartModel
, xAttrList
);
2466 if(mbIsUserTransformed
)
2468 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2471 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
2472 if( xPropsInfo
.is() )
2474 if( xPropsInfo
->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
2475 xProps
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False
) );
2481 // set pos, size, shear and rotate
2482 SetTransformation();
2484 SdXMLShapeContext::StartElement(xAttrList
);
2486 if( mpChartContext
)
2487 mpChartContext
->StartElement( xAttrList
);
2491 void SdXMLChartShapeContext::EndElement()
2493 if( mpChartContext
)
2494 mpChartContext
->EndElement();
2496 SdXMLShapeContext::EndElement();
2499 void SdXMLChartShapeContext::Characters( const ::rtl::OUString
& rChars
)
2501 if( mpChartContext
)
2502 mpChartContext
->Characters( rChars
);
2505 SvXMLImportContext
* SdXMLChartShapeContext::CreateChildContext( USHORT nPrefix
, const ::rtl::OUString
& rLocalName
,
2506 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
2508 if( mpChartContext
)
2509 return mpChartContext
->CreateChildContext( nPrefix
, rLocalName
, xAttrList
);
2514 //////////////////////////////////////////////////////////////////////////////
2516 TYPEINIT1( SdXMLObjectShapeContext
, SdXMLShapeContext
);
2518 SdXMLObjectShapeContext::SdXMLObjectShapeContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
2519 const rtl::OUString
& rLocalName
,
2520 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2521 com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
>& rShapes
,
2522 sal_Bool bTemporaryShape
)
2523 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
)
2527 SdXMLObjectShapeContext::~SdXMLObjectShapeContext()
2531 void SdXMLObjectShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& )
2533 // #96717# in theorie, if we don't have a url we shouldn't even
2534 // export this ole shape. But practical its to risky right now
2535 // to change this so we better dispose this on load
2536 //if( !mbIsPlaceholder && ImpIsEmptyURL(maHref) )
2539 // #100592# this BugFix prevents that a shape is created. CL
2540 // is thinking about an alternative.
2541 // #i13140# Check for more than empty string in maHref, there are
2542 // other possibilities that maHref results in empty container
2544 if( !(GetImport().getImportFlags() & IMPORT_EMBEDDED
) && !mbIsPlaceholder
&& ImpIsEmptyURL(maHref
) )
2547 const char* pService
= "com.sun.star.drawing.OLE2Shape";
2549 sal_Bool bIsPresShape
= maPresentationClass
.getLength() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
2553 if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_CHART
) )
2555 pService
= "com.sun.star.presentation.ChartShape";
2557 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_TABLE
) )
2559 pService
= "com.sun.star.presentation.TableShape";
2561 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_OBJECT
) )
2563 pService
= "com.sun.star.presentation.OLE2Shape";
2567 AddShape( pService
);
2575 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2578 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
2579 if( xPropsInfo
.is() )
2581 if( !mbIsPlaceholder
&& xPropsInfo
->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
2582 xProps
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False
) );
2584 if( mbIsUserTransformed
&& xPropsInfo
->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
2585 xProps
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False
) );
2590 if( !mbIsPlaceholder
&& maHref
.getLength() )
2592 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
2596 OUString aPersistName
= GetImport().ResolveEmbeddedObjectURL( maHref
, maCLSID
);
2598 if ( GetImport().IsPackageURL( maHref
) )
2600 const OUString
sURL(RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ));
2602 if ( aPersistName
.compareTo( sURL
, sURL
.getLength() ) == 0 )
2603 aPersistName
= aPersistName
.copy( sURL
.getLength() );
2605 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PersistName" ) ),
2606 uno::makeAny( aPersistName
) );
2610 // this is OOo link object
2611 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LinkURL" ) ),
2612 uno::makeAny( aPersistName
) );
2617 // set pos, size, shear and rotate
2618 SetTransformation();
2622 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
2626 void SdXMLObjectShapeContext::EndElement()
2629 if( mxBase64Stream
.is() )
2631 OUString
aPersistName( GetImport().ResolveEmbeddedObjectURLFromBase64() );
2632 const OUString
sURL(RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.EmbeddedObject:" ));
2634 aPersistName
= aPersistName
.copy( sURL
.getLength() );
2636 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2638 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PersistName" ) ), uno::makeAny( aPersistName
) );
2641 SdXMLShapeContext::EndElement();
2644 // this is called from the parent group for each unparsed attribute in the attribute list
2645 void SdXMLObjectShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2649 case XML_NAMESPACE_DRAW
:
2650 if( IsXMLToken( rLocalName
, XML_CLASS_ID
) )
2656 case XML_NAMESPACE_XLINK
:
2657 if( IsXMLToken( rLocalName
, XML_HREF
) )
2665 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2668 SvXMLImportContext
* SdXMLObjectShapeContext::CreateChildContext(
2669 USHORT nPrefix
, const ::rtl::OUString
& rLocalName
,
2670 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
)
2673 SvXMLImportContext
* pContext
= NULL
;
2675 if((XML_NAMESPACE_OFFICE
== nPrefix
) && IsXMLToken(rLocalName
, XML_BINARY_DATA
))
2677 mxBase64Stream
= GetImport().GetStreamForEmbeddedObjectURLFromBase64();
2678 if( mxBase64Stream
.is() )
2679 pContext
= new XMLBase64ImportContext( GetImport(), nPrefix
,
2680 rLocalName
, xAttrList
,
2683 else if( ((XML_NAMESPACE_OFFICE
== nPrefix
) && IsXMLToken(rLocalName
, XML_DOCUMENT
)) ||
2684 ((XML_NAMESPACE_MATH
== nPrefix
) && IsXMLToken(rLocalName
, XML_MATH
)) )
2686 XMLEmbeddedObjectImportContext
*pEContext
=
2687 new XMLEmbeddedObjectImportContext( GetImport(), nPrefix
,
2688 rLocalName
, xAttrList
);
2689 maCLSID
= pEContext
->GetFilterCLSID();
2690 if( maCLSID
.getLength() != 0 )
2692 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
2695 xPropSet
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("CLSID") ), uno::makeAny( maCLSID
) );
2697 uno::Reference
< lang::XComponent
> xComp
;
2698 xPropSet
->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ) >>= xComp
;
2699 DBG_ASSERT( xComp
.is(), "no xModel for own OLE format" );
2700 pEContext
->SetComponent( xComp
);
2703 pContext
= pEContext
;
2706 // delegate to parent class if no context could be created
2708 pContext
= SdXMLShapeContext::CreateChildContext(nPrefix
, rLocalName
, xAttrList
);
2713 //////////////////////////////////////////////////////////////////////////////
2715 TYPEINIT1( SdXMLAppletShapeContext
, SdXMLShapeContext
);
2717 SdXMLAppletShapeContext::SdXMLAppletShapeContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
2718 const rtl::OUString
& rLocalName
,
2719 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2720 com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
>& rShapes
,
2721 sal_Bool bTemporaryShape
)
2722 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2723 mbIsScript( sal_False
)
2727 SdXMLAppletShapeContext::~SdXMLAppletShapeContext()
2731 void SdXMLAppletShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& )
2733 const char* pService
= "com.sun.star.drawing.AppletShape";
2734 AddShape( pService
);
2740 // set pos, size, shear and rotate
2741 SetTransformation();
2742 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
2746 // this is called from the parent group for each unparsed attribute in the attribute list
2747 void SdXMLAppletShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2751 case XML_NAMESPACE_DRAW
:
2752 if( IsXMLToken( rLocalName
, XML_APPLET_NAME
) )
2754 maAppletName
= rValue
;
2757 if( IsXMLToken( rLocalName
, XML_CODE
) )
2759 maAppletCode
= rValue
;
2762 if( IsXMLToken( rLocalName
, XML_MAY_SCRIPT
) )
2764 mbIsScript
= IsXMLToken( rValue
, XML_TRUE
);
2768 case XML_NAMESPACE_XLINK
:
2769 if( IsXMLToken( rLocalName
, XML_HREF
) )
2771 maHref
= GetImport().GetAbsoluteReference(rValue
);
2777 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2780 void SdXMLAppletShapeContext::EndElement()
2782 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
2787 if ( maSize
.Width
&& maSize
.Height
)
2789 // the visual area for applet must be set on loading
2790 awt::Rectangle
aRect( 0, 0, maSize
.Width
, maSize
.Height
);
2792 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) ), aAny
);
2795 if( maParams
.getLength() )
2798 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCommands" ) ), aAny
);
2801 if( maHref
.getLength() )
2804 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCodeBase" ) ), aAny
);
2807 if( maAppletName
.getLength() )
2809 aAny
<<= maAppletName
;
2810 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletName" ) ), aAny
);
2815 aAny
<<= mbIsScript
;
2816 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletIsScript" ) ), aAny
);
2820 if( maAppletCode
.getLength() )
2822 aAny
<<= maAppletCode
;
2823 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletCode" ) ), aAny
);
2826 aAny
<<= ::rtl::OUString( GetImport().GetDocumentBase() );
2827 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "AppletDocBase" ) ), aAny
);
2832 SdXMLShapeContext::EndElement();
2835 SvXMLImportContext
* SdXMLAppletShapeContext::CreateChildContext( USHORT p_nPrefix
, const ::rtl::OUString
& rLocalName
, const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
2837 if( p_nPrefix
== XML_NAMESPACE_DRAW
&& IsXMLToken( rLocalName
, XML_PARAM
) )
2839 OUString aParamName
, aParamValue
;
2840 const sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
2841 // now parse the attribute list and look for draw:name and draw:value
2842 for(sal_Int16
a(0); a
< nAttrCount
; a
++)
2844 const OUString
& rAttrName
= xAttrList
->getNameByIndex(a
);
2845 OUString aLocalName
;
2846 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName
, &aLocalName
);
2847 const OUString
aValue( xAttrList
->getValueByIndex(a
) );
2849 if( nPrefix
== XML_NAMESPACE_DRAW
)
2851 if( IsXMLToken( aLocalName
, XML_NAME
) )
2853 aParamName
= aValue
;
2855 else if( IsXMLToken( aLocalName
, XML_VALUE
) )
2857 aParamValue
= aValue
;
2862 if( aParamName
.getLength() )
2864 sal_Int32 nIndex
= maParams
.getLength();
2865 maParams
.realloc( nIndex
+ 1 );
2866 maParams
[nIndex
].Name
= aParamName
;
2867 maParams
[nIndex
].Handle
= -1;
2868 maParams
[nIndex
].Value
<<= aParamValue
;
2869 maParams
[nIndex
].State
= beans::PropertyState_DIRECT_VALUE
;
2872 return new SvXMLImportContext( GetImport(), p_nPrefix
, rLocalName
);
2875 return SdXMLShapeContext::CreateChildContext( p_nPrefix
, rLocalName
, xAttrList
);
2878 //////////////////////////////////////////////////////////////////////////////
2880 TYPEINIT1( SdXMLPluginShapeContext
, SdXMLShapeContext
);
2882 SdXMLPluginShapeContext::SdXMLPluginShapeContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
2883 const rtl::OUString
& rLocalName
,
2884 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2885 com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
>& rShapes
,
2886 sal_Bool bTemporaryShape
) :
2887 SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2892 SdXMLPluginShapeContext::~SdXMLPluginShapeContext()
2896 void SdXMLPluginShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
2898 // watch for MimeType attribute to see if we have a media object
2899 for( sal_Int16 n
= 0, nAttrCount
= ( xAttrList
.is() ? xAttrList
->getLength() : 0 ); n
< nAttrCount
; ++n
)
2901 OUString aLocalName
;
2902 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList
->getNameByIndex( n
), &aLocalName
);
2904 if( nPrefix
== XML_NAMESPACE_DRAW
&& IsXMLToken( aLocalName
, XML_MIME_TYPE
) )
2906 if( 0 == xAttrList
->getValueByIndex( n
).compareToAscii( "application/vnd.sun.star.media" ) )
2914 const char* pService
;
2917 pService
= "com.sun.star.drawing.MediaShape";
2919 pService
= "com.sun.star.drawing.PluginShape";
2921 AddShape( pService
);
2927 // set pos, size, shear and rotate
2928 SetTransformation();
2929 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
2933 // this is called from the parent group for each unparsed attribute in the attribute list
2934 void SdXMLPluginShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2938 case XML_NAMESPACE_DRAW
:
2939 if( IsXMLToken( rLocalName
, XML_MIME_TYPE
) )
2941 maMimeType
= rValue
;
2945 case XML_NAMESPACE_XLINK
:
2946 if( IsXMLToken( rLocalName
, XML_HREF
) )
2948 maHref
= GetImport().GetAbsoluteReference(rValue
);
2954 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2957 void SdXMLPluginShapeContext::EndElement()
2959 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
2965 if ( maSize
.Width
&& maSize
.Height
)
2967 const rtl::OUString
sVisibleArea( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) );
2968 uno::Reference
< beans::XPropertySetInfo
> aXPropSetInfo( xProps
->getPropertySetInfo() );
2969 if ( !aXPropSetInfo
.is() || aXPropSetInfo
->hasPropertyByName( sVisibleArea
) )
2971 // the visual area for a plugin must be set on loading
2972 awt::Rectangle
aRect( 0, 0, maSize
.Width
, maSize
.Height
);
2974 xProps
->setPropertyValue( sVisibleArea
, aAny
);
2980 // in case we have a plugin object
2981 if( maParams
.getLength() )
2984 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginCommands" ) ), aAny
);
2987 if( maMimeType
.getLength() )
2989 aAny
<<= maMimeType
;
2990 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginMimeType" ) ), aAny
);
2993 if( maHref
.getLength() )
2996 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "PluginURL" ) ), aAny
);
3001 // in case we have a media object
3002 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaURL" ) ), uno::makeAny( maHref
) );
3004 for( sal_Int32 nParam
= 0; nParam
< maParams
.getLength(); ++nParam
)
3006 const OUString
& rName
= maParams
[ nParam
].Name
;
3008 if( 0 == rName
.compareToAscii( "Loop" ) )
3011 maParams
[ nParam
].Value
>>= aValueStr
;
3012 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Loop" ) ),
3013 uno::makeAny( static_cast< sal_Bool
>( 0 == aValueStr
.compareToAscii( "true" ) ) ) );
3015 else if( 0 == rName
.compareToAscii( "Mute" ) )
3018 maParams
[ nParam
].Value
>>= aValueStr
;
3019 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Mute" ) ),
3020 uno::makeAny( static_cast< sal_Bool
>( 0 == aValueStr
.compareToAscii( "true" ) ) ) );
3022 else if( 0 == rName
.compareToAscii( "VolumeDB" ) )
3025 maParams
[ nParam
].Value
>>= aValueStr
;
3026 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VolumeDB" ) ),
3027 uno::makeAny( static_cast< sal_Int16
>( aValueStr
.toInt32() ) ) );
3029 else if( 0 == rName
.compareToAscii( "Zoom" ) )
3032 media::ZoomLevel eZoomLevel
;
3034 maParams
[ nParam
].Value
>>= aZoomStr
;
3036 if( 0 == aZoomStr
.compareToAscii( "25%" ) )
3037 eZoomLevel
= media::ZoomLevel_ZOOM_1_TO_4
;
3038 else if( 0 == aZoomStr
.compareToAscii( "50%" ) )
3039 eZoomLevel
= media::ZoomLevel_ZOOM_1_TO_2
;
3040 else if( 0 == aZoomStr
.compareToAscii( "100%" ) )
3041 eZoomLevel
= media::ZoomLevel_ORIGINAL
;
3042 else if( 0 == aZoomStr
.compareToAscii( "200%" ) )
3043 eZoomLevel
= media::ZoomLevel_ZOOM_2_TO_1
;
3044 else if( 0 == aZoomStr
.compareToAscii( "400%" ) )
3045 eZoomLevel
= media::ZoomLevel_ZOOM_4_TO_1
;
3046 else if( 0 == aZoomStr
.compareToAscii( "fit" ) )
3047 eZoomLevel
= media::ZoomLevel_FIT_TO_WINDOW
;
3048 else if( 0 == aZoomStr
.compareToAscii( "fixedfit" ) )
3049 eZoomLevel
= media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT
;
3050 else if( 0 == aZoomStr
.compareToAscii( "fullscreen" ) )
3051 eZoomLevel
= media::ZoomLevel_FULLSCREEN
;
3053 eZoomLevel
= media::ZoomLevel_NOT_AVAILABLE
;
3055 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Zoom" ) ), uno::makeAny( eZoomLevel
) );
3063 SdXMLShapeContext::EndElement();
3066 SvXMLImportContext
* SdXMLPluginShapeContext::CreateChildContext( USHORT p_nPrefix
, const ::rtl::OUString
& rLocalName
, const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
3068 if( p_nPrefix
== XML_NAMESPACE_DRAW
&& IsXMLToken( rLocalName
, XML_PARAM
) )
3070 OUString aParamName
, aParamValue
;
3071 const sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
3072 // now parse the attribute list and look for draw:name and draw:value
3073 for(sal_Int16
a(0); a
< nAttrCount
; a
++)
3075 const OUString
& rAttrName
= xAttrList
->getNameByIndex(a
);
3076 OUString aLocalName
;
3077 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName
, &aLocalName
);
3078 const OUString
aValue( xAttrList
->getValueByIndex(a
) );
3080 if( nPrefix
== XML_NAMESPACE_DRAW
)
3082 if( IsXMLToken( aLocalName
, XML_NAME
) )
3084 aParamName
= aValue
;
3086 else if( IsXMLToken( aLocalName
, XML_VALUE
) )
3088 aParamValue
= aValue
;
3092 if( aParamName
.getLength() )
3094 sal_Int32 nIndex
= maParams
.getLength();
3095 maParams
.realloc( nIndex
+ 1 );
3096 maParams
[nIndex
].Name
= aParamName
;
3097 maParams
[nIndex
].Handle
= -1;
3098 maParams
[nIndex
].Value
<<= aParamValue
;
3099 maParams
[nIndex
].State
= beans::PropertyState_DIRECT_VALUE
;
3103 return new SvXMLImportContext( GetImport(), p_nPrefix
, rLocalName
);
3106 return SdXMLShapeContext::CreateChildContext( p_nPrefix
, rLocalName
, xAttrList
);
3109 //////////////////////////////////////////////////////////////////////////////
3111 TYPEINIT1( SdXMLFloatingFrameShapeContext
, SdXMLShapeContext
);
3113 SdXMLFloatingFrameShapeContext::SdXMLFloatingFrameShapeContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
3114 const rtl::OUString
& rLocalName
,
3115 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
3116 com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
>& rShapes
,
3117 sal_Bool bTemporaryShape
)
3118 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
)
3122 SdXMLFloatingFrameShapeContext::~SdXMLFloatingFrameShapeContext()
3126 void SdXMLFloatingFrameShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& )
3128 const char* pService
= "com.sun.star.drawing.FrameShape";
3129 AddShape( pService
);
3135 // set pos, size, shear and rotate
3136 SetTransformation();
3138 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
3143 if( maFrameName
.getLength() )
3145 aAny
<<= maFrameName
;
3146 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "FrameName" ) ), aAny
);
3149 if( maHref
.getLength() )
3152 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "FrameURL" ) ), aAny
);
3158 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
3162 // this is called from the parent group for each unparsed attribute in the attribute list
3163 void SdXMLFloatingFrameShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
3167 case XML_NAMESPACE_DRAW
:
3168 if( IsXMLToken( rLocalName
, XML_FRAME_NAME
) )
3170 maFrameName
= rValue
;
3174 case XML_NAMESPACE_XLINK
:
3175 if( IsXMLToken( rLocalName
, XML_HREF
) )
3177 maHref
= GetImport().GetAbsoluteReference(rValue
);
3183 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
3186 void SdXMLFloatingFrameShapeContext::EndElement()
3188 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
3192 if ( maSize
.Width
&& maSize
.Height
)
3194 // the visual area for a floating frame must be set on loading
3195 awt::Rectangle
aRect( 0, 0, maSize
.Width
, maSize
.Height
);
3198 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "VisibleArea" ) ), aAny
);
3203 SdXMLShapeContext::EndElement();
3206 //////////////////////////////////////////////////////////////////////////////
3208 TYPEINIT1( SdXMLFrameShapeContext
, SdXMLShapeContext
);
3210 SdXMLFrameShapeContext::SdXMLFrameShapeContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
3211 const rtl::OUString
& rLocalName
,
3212 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
3213 com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
>& rShapes
,
3214 sal_Bool bTemporaryShape
)
3215 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
3216 mbSupportsReplacement( sal_False
)
3218 uno::Reference
< util::XCloneable
> xClone( xAttrList
, uno::UNO_QUERY
);
3220 mxAttrList
.set( xClone
->createClone(), uno::UNO_QUERY
);
3222 mxAttrList
= new SvXMLAttributeList( xAttrList
);
3226 SdXMLFrameShapeContext::~SdXMLFrameShapeContext()
3230 SvXMLImportContext
*SdXMLFrameShapeContext::CreateChildContext( USHORT nPrefix
,
3231 const OUString
& rLocalName
,
3232 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
3234 SvXMLImportContext
* pContext
= 0;
3236 if( !mxImplContext
.Is() )
3239 SvXMLShapeContext
* pShapeContext
= GetImport().GetShapeImport()->CreateFrameChildContext(
3240 GetImport(), nPrefix
, rLocalName
, xAttrList
, mxShapes
, mxAttrList
);
3242 pContext
= pShapeContext
;
3244 // propagate the hyperlink to child context
3245 if ( msHyperlink
.getLength() > 0 )
3246 pShapeContext
->setHyperlink( msHyperlink
);
3248 mxImplContext
= pContext
;
3249 mbSupportsReplacement
= IsXMLToken( rLocalName
, XML_OBJECT
) ||
3250 IsXMLToken( rLocalName
, XML_OBJECT_OLE
);
3252 else if( mbSupportsReplacement
&& !mxReplImplContext
&&
3253 XML_NAMESPACE_DRAW
== nPrefix
&&
3254 IsXMLToken( rLocalName
, XML_IMAGE
) )
3256 // read replacement image
3257 SvXMLImportContext
*pImplContext
= &mxImplContext
;
3258 SdXMLShapeContext
*pSContext
=
3259 PTR_CAST( SdXMLShapeContext
, pImplContext
);
3262 uno::Reference
< beans::XPropertySet
> xPropSet(
3263 pSContext
->getShape(), uno::UNO_QUERY
);
3266 pContext
= new XMLReplacementImageContext( GetImport(),
3267 nPrefix
, rLocalName
, xAttrList
, xPropSet
);
3268 mxReplImplContext
= pContext
;
3273 ( nPrefix
== XML_NAMESPACE_SVG
&& // #i68101#
3274 (IsXMLToken( rLocalName
, XML_TITLE
) || IsXMLToken( rLocalName
, XML_DESC
) ) ) ||
3275 (nPrefix
== XML_NAMESPACE_OFFICE
&& IsXMLToken( rLocalName
, XML_EVENT_LISTENERS
) ) ||
3276 (nPrefix
== XML_NAMESPACE_DRAW
&& (IsXMLToken( rLocalName
, XML_GLUE_POINT
) ||
3277 IsXMLToken( rLocalName
, XML_THUMBNAIL
) ) ) )
3279 SvXMLImportContext
*pImplContext
= &mxImplContext
;
3280 pContext
= PTR_CAST( SdXMLShapeContext
, pImplContext
)->CreateChildContext( nPrefix
,
3281 rLocalName
, xAttrList
);
3283 else if ( (XML_NAMESPACE_DRAW
== nPrefix
) && IsXMLToken( rLocalName
, XML_IMAGE_MAP
) )
3285 SdXMLShapeContext
*pSContext
= dynamic_cast< SdXMLShapeContext
* >( &mxImplContext
);
3288 uno::Reference
< beans::XPropertySet
> xPropSet( pSContext
->getShape(), uno::UNO_QUERY
);
3291 pContext
= new XMLImageMapContext(GetImport(), nPrefix
, rLocalName
, xPropSet
);
3296 // call parent for content
3298 pContext
= SvXMLImportContext::CreateChildContext( nPrefix
, rLocalName
, xAttrList
);
3303 void SdXMLFrameShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>&)
3308 void SdXMLFrameShapeContext::EndElement()
3310 if( !mxImplContext
.Is() )
3312 // now check if this is an empty presentation object
3313 sal_Int16 nAttrCount
= mxAttrList
.is() ? mxAttrList
->getLength() : 0;
3314 for(sal_Int16
a(0); a
< nAttrCount
; a
++)
3316 OUString aLocalName
;
3317 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName(mxAttrList
->getNameByIndex(a
), &aLocalName
);
3319 if( nPrefix
== XML_NAMESPACE_PRESENTATION
)
3321 if( IsXMLToken( aLocalName
, XML_PLACEHOLDER
) )
3323 mbIsPlaceholder
= IsXMLToken( mxAttrList
->getValueByIndex(a
), XML_TRUE
);
3325 else if( IsXMLToken( aLocalName
, XML_CLASS
) )
3327 maPresentationClass
= mxAttrList
->getValueByIndex(a
);
3332 if( (maPresentationClass
.getLength() != 0) && mbIsPlaceholder
)
3334 uno::Reference
< xml::sax::XAttributeList
> xEmpty
;
3336 enum XMLTokenEnum eToken
= XML_TEXT_BOX
;
3338 if( IsXMLToken( maPresentationClass
, XML_GRAPHIC
) )
3343 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_PAGE
) )
3345 eToken
= XML_PAGE_THUMBNAIL
;
3347 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_CHART
) ||
3348 IsXMLToken( maPresentationClass
, XML_PRESENTATION_TABLE
) ||
3349 IsXMLToken( maPresentationClass
, XML_PRESENTATION_OBJECT
) )
3351 eToken
= XML_OBJECT
;
3354 mxImplContext
= GetImport().GetShapeImport()->CreateFrameChildContext(
3355 GetImport(), XML_NAMESPACE_DRAW
, GetXMLToken( eToken
), mxAttrList
, mxShapes
, xEmpty
);
3357 if( mxImplContext
.Is() )
3359 mxImplContext
->StartElement( mxAttrList
);
3360 mxImplContext
->EndElement();
3366 SdXMLShapeContext::EndElement();
3369 void SdXMLFrameShapeContext::processAttribute( sal_uInt16
,
3370 const ::rtl::OUString
&, const ::rtl::OUString
& )
3375 TYPEINIT1( SdXMLCustomShapeContext
, SdXMLShapeContext
);
3377 SdXMLCustomShapeContext::SdXMLCustomShapeContext(
3378 SvXMLImport
& rImport
,
3380 const OUString
& rLocalName
,
3381 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
3382 uno::Reference
< drawing::XShapes
>& rShapes
,
3383 sal_Bool bTemporaryShape
)
3384 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
)
3388 //////////////////////////////////////////////////////////////////////////////
3390 SdXMLCustomShapeContext::~SdXMLCustomShapeContext()
3394 //////////////////////////////////////////////////////////////////////////////
3396 // this is called from the parent group for each unparsed attribute in the attribute list
3397 void SdXMLCustomShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
3399 if( XML_NAMESPACE_DRAW
== nPrefix
)
3401 if( IsXMLToken( rLocalName
, XML_ENGINE
) )
3403 maCustomShapeEngine
= rValue
;
3406 if ( IsXMLToken( rLocalName
, XML_DATA
) )
3408 maCustomShapeData
= rValue
;
3412 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
3415 //////////////////////////////////////////////////////////////////////////////
3417 void SdXMLCustomShapeContext::StartElement( const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
3419 // create rectangle shape
3420 AddShape("com.sun.star.drawing.CustomShape");
3423 // Add, set Style and properties from base shape
3427 // set pos, size, shear and rotate
3428 SetTransformation();
3432 uno::Reference
< beans::XPropertySet
> xPropSet( mxShape
, uno::UNO_QUERY
);
3435 if ( maCustomShapeEngine
.getLength() )
3438 aAny
<<= maCustomShapeEngine
;
3439 xPropSet
->setPropertyValue( EASGet( EAS_CustomShapeEngine
), aAny
);
3441 if ( maCustomShapeData
.getLength() )
3444 aAny
<<= maCustomShapeData
;
3445 xPropSet
->setPropertyValue( EASGet( EAS_CustomShapeData
), aAny
);
3449 catch( uno::Exception
& )
3451 DBG_ERROR( "could not set enhanced customshape geometry" );
3453 SdXMLShapeContext::StartElement(xAttrList
);
3457 void SdXMLCustomShapeContext::EndElement()
3459 if ( !maCustomShapeGeometry
.empty() )
3461 const rtl::OUString
sCustomShapeGeometry ( RTL_CONSTASCII_USTRINGPARAM( "CustomShapeGeometry" ) );
3463 // converting the vector to a sequence
3464 uno::Sequence
< beans::PropertyValue
> aSeq( maCustomShapeGeometry
.size() );
3465 beans::PropertyValue
* pValues
= aSeq
.getArray();
3466 std::vector
< beans::PropertyValue
>::const_iterator
aIter( maCustomShapeGeometry
.begin() );
3467 std::vector
< beans::PropertyValue
>::const_iterator
aEnd( maCustomShapeGeometry
.end() );
3468 while ( aIter
!= aEnd
)
3469 *pValues
++ = *aIter
++;
3473 uno::Reference
< beans::XPropertySet
> xPropSet( mxShape
, uno::UNO_QUERY
);
3478 xPropSet
->setPropertyValue( sCustomShapeGeometry
, aAny
);
3481 catch( uno::Exception
& )
3483 DBG_ERROR( "could not set enhanced customshape geometry" );
3486 sal_Int32
nUPD( 0 );
3487 sal_Int32
nBuild( 0 );
3488 GetImport().getBuildIds( nUPD
, nBuild
);
3489 if( ((nUPD
>= 640 && nUPD
<= 645) || (nUPD
== 680)) && (nBuild
<= 9221) )
3491 Reference
< drawing::XEnhancedCustomShapeDefaulter
> xDefaulter( mxShape
, UNO_QUERY
);
3492 if( xDefaulter
.is() )
3494 rtl::OUString aEmptyType
;
3495 xDefaulter
->createCustomShapeDefaults( aEmptyType
);
3500 SdXMLShapeContext::EndElement();
3503 //////////////////////////////////////////////////////////////////////////////
3505 SvXMLImportContext
* SdXMLCustomShapeContext::CreateChildContext(
3506 USHORT nPrefix
, const ::rtl::OUString
& rLocalName
,
3507 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
)
3509 SvXMLImportContext
* pContext
= NULL
;
3510 if ( XML_NAMESPACE_DRAW
== nPrefix
)
3512 if ( IsXMLToken( rLocalName
, XML_ENHANCED_GEOMETRY
) )
3514 uno::Reference
< beans::XPropertySet
> xPropSet( mxShape
,uno::UNO_QUERY
);
3515 if ( xPropSet
.is() )
3516 pContext
= new XMLEnhancedCustomShapeContext( GetImport(), mxShape
, nPrefix
, rLocalName
, maCustomShapeGeometry
);
3519 // delegate to parent class if no context could be created
3520 if ( NULL
== pContext
)
3521 pContext
= SdXMLShapeContext::CreateChildContext( nPrefix
, rLocalName
,
3526 ///////////////////////////////////////////////////////////////////////
3528 //////////////////////////////////////////////////////////////////////////////
3530 TYPEINIT1( SdXMLTableShapeContext
, SdXMLShapeContext
);
3532 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
)
3533 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, sal_False
)
3535 memset( &maTemplateStylesUsed
, 0, sizeof( maTemplateStylesUsed
) );
3538 SdXMLTableShapeContext::~SdXMLTableShapeContext()
3542 void SdXMLTableShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
3544 const char* pService
= "com.sun.star.drawing.TableShape";
3546 sal_Bool bIsPresShape
= sal_False
; //maPresentationClass.getLength() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
3550 if( IsXMLToken( maPresentationClass, XML_PRESENTATION_TABLE ) )
3552 pService = "com.sun.star.presentation.TableShape";
3556 AddShape( pService
);
3562 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
3568 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
3569 if( xPropsInfo
.is() )
3571 if( !mbIsPlaceholder
&& xPropsInfo
->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") )))
3572 xProps
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsEmptyPresentationObject") ), ::cppu::bool2any( sal_False
) );
3574 if( mbIsUserTransformed
&& xPropsInfo
->hasPropertyByName(OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") )))
3575 xProps
->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("IsPlaceholderDependent") ), ::cppu::bool2any( sal_False
) );
3584 if( msTemplateStyleName
.getLength() ) try
3586 Reference
< XStyleFamiliesSupplier
> xFamiliesSupp( GetImport().GetModel(), UNO_QUERY_THROW
);
3587 Reference
< XNameAccess
> xFamilies( xFamiliesSupp
->getStyleFamilies() );
3588 const OUString
sFamilyName( RTL_CONSTASCII_USTRINGPARAM("table" ) );
3589 Reference
< XNameAccess
> xTableFamily( xFamilies
->getByName( sFamilyName
), UNO_QUERY_THROW
);
3590 Reference
< XStyle
> xTableStyle( xTableFamily
->getByName( msTemplateStyleName
), UNO_QUERY_THROW
);
3591 xProps
->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TableTemplate" ) ), Any( xTableStyle
) );
3595 DBG_ERROR("SdXMLTableShapeContext::StartElement(), exception caught!");
3598 const XMLPropertyMapEntry
* pEntry
= &aXMLTableShapeAttributes
[0];
3599 for( int i
= 0; pEntry
->msApiName
&& (i
< 6); i
++, pEntry
++ )
3603 const OUString
sAPIPropertyName( OUString(pEntry
->msApiName
, pEntry
->nApiNameLength
, RTL_TEXTENCODING_ASCII_US
) );
3604 xProps
->setPropertyValue( sAPIPropertyName
, Any( maTemplateStylesUsed
[i
] ) );
3608 DBG_ERROR("SdXMLTableShapeContext::StartElement(), exception caught!");
3613 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
3615 const rtl::Reference
< XMLTableImport
>& xTableImport( GetImport().GetShapeImport()->GetShapeTableImport() );
3616 if( xTableImport
.is() && xProps
.is() )
3618 uno::Reference
< table::XColumnRowRange
> xColumnRowRange(
3619 xProps
->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ), uno::UNO_QUERY
);
3621 if( xColumnRowRange
.is() )
3622 mxTableImportContext
= xTableImport
->CreateTableContext( GetPrefix(), GetLocalName(), xColumnRowRange
);
3624 if( mxTableImportContext
.Is() )
3625 mxTableImportContext
->StartElement( xAttrList
);
3630 void SdXMLTableShapeContext::EndElement()
3632 if( mxTableImportContext
.Is() )
3633 mxTableImportContext
->EndElement();
3635 SdXMLShapeContext::EndElement();
3639 // set pos, size, shear and rotate
3640 SetTransformation();
3644 // this is called from the parent group for each unparsed attribute in the attribute list
3645 void SdXMLTableShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
3647 if( nPrefix
== XML_NAMESPACE_TABLE
)
3649 if( IsXMLToken( rLocalName
, XML_TEMPLATE_NAME
) )
3651 msTemplateStyleName
= rValue
;
3656 const XMLPropertyMapEntry
* pEntry
= &aXMLTableShapeAttributes
[0];
3657 while( pEntry
->msApiName
&& (i
< 6) )
3659 if( IsXMLToken( rLocalName
, pEntry
->meXMLName
) )
3661 if( IsXMLToken( rValue
, XML_TRUE
) )
3662 maTemplateStylesUsed
[i
] = sal_True
;
3670 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
3673 SvXMLImportContext
* SdXMLTableShapeContext::CreateChildContext( USHORT nPrefix
, const ::rtl::OUString
& rLocalName
, const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
)
3675 if( mxTableImportContext
.Is() )
3676 return mxTableImportContext
->CreateChildContext(nPrefix
, rLocalName
, xAttrList
);
3678 return SdXMLShapeContext::CreateChildContext(nPrefix
, rLocalName
, xAttrList
);