1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
32 #include <tools/debug.hxx>
33 #include <com/sun/star/document/XEventsSupplier.hpp>
34 #include <com/sun/star/container/XNameReplace.hpp>
35 #include <com/sun/star/presentation/ClickAction.hpp>
36 #include <com/sun/star/drawing/FillStyle.hpp>
37 #include <com/sun/star/drawing/LineStyle.hpp>
38 #include <xmloff/unointerfacetouniqueidentifiermapper.hxx>
39 #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
40 #include <com/sun/star/container/XIdentifierAccess.hpp>
41 #include <com/sun/star/drawing/GluePoint2.hpp>
42 #include <com/sun/star/drawing/Alignment.hpp>
43 #include <com/sun/star/drawing/EscapeDirection.hpp>
44 #include <com/sun/star/media/ZoomLevel.hpp>
45 #include <com/sun/star/awt/Rectangle.hpp>
47 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
48 #include <com/sun/star/container/XNameAccess.hpp>
49 #include <comphelper/extract.hxx>
50 #include "ximpshap.hxx"
51 #include <xmloff/XMLBase64ImportContext.hxx>
52 #include <xmloff/XMLShapeStyleContext.hxx>
53 #include <xmloff/xmluconv.hxx>
54 #include <com/sun/star/container/XNamed.hpp>
55 #include <com/sun/star/drawing/CircleKind.hpp>
56 #include <com/sun/star/beans/XPropertySet.hpp>
57 #include <com/sun/star/awt/XControlModel.hpp>
58 #include <com/sun/star/drawing/XControlShape.hpp>
59 #include <com/sun/star/drawing/PointSequenceSequence.hpp>
60 #include <com/sun/star/drawing/PointSequence.hpp>
61 #include <com/sun/star/lang/XServiceInfo.hpp>
62 #include <com/sun/star/util/XCloneable.hpp>
63 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
64 #include "xexptran.hxx"
65 #include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
66 #include <com/sun/star/beans/XPropertySetInfo.hpp>
67 #include <com/sun/star/drawing/ConnectorType.hpp>
68 #include <com/sun/star/drawing/HomogenMatrix3.hpp>
70 #include <sax/tools/converter.hxx>
72 #include "PropertySetMerger.hxx"
73 #include <xmloff/families.hxx>
74 #include "ximpstyl.hxx"
75 #include"xmloff/xmlnmspe.hxx"
76 #include <xmloff/xmltoken.hxx>
77 #include "EnhancedCustomShapeToken.hxx"
78 #include "XMLReplacementImageContext.hxx"
79 #include "XMLImageMapContext.hxx"
80 #include "sdpropls.hxx"
81 #include "eventimp.hxx"
83 #include "descriptionimp.hxx"
84 #include "ximpcustomshape.hxx"
85 #include "XMLEmbeddedObjectImportContext.hxx"
86 #include "xmloff/xmlerror.hxx"
87 #include <basegfx/matrix/b2dhommatrix.hxx>
88 #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
89 #include <com/sun/star/text/XTextDocument.hpp>
91 using ::rtl::OUString
;
92 using ::rtl::OUStringBuffer
;
94 using namespace ::com::sun::star
;
95 using namespace ::com::sun::star::uno
;
96 using namespace ::com::sun::star::drawing
;
97 using namespace ::com::sun::star::style
;
98 using namespace ::com::sun::star::container
;
99 using namespace ::com::sun::star::document
;
100 using namespace ::xmloff::token
;
101 using namespace ::xmloff::EnhancedCustomShapeToken
;
103 SvXMLEnumMapEntry aXML_GlueAlignment_EnumMap
[] =
105 { XML_TOP_LEFT
, drawing::Alignment_TOP_LEFT
},
106 { XML_TOP
, drawing::Alignment_TOP
},
107 { XML_TOP_RIGHT
, drawing::Alignment_TOP_RIGHT
},
108 { XML_LEFT
, drawing::Alignment_LEFT
},
109 { XML_CENTER
, drawing::Alignment_CENTER
},
110 { XML_RIGHT
, drawing::Alignment_RIGHT
},
111 { XML_BOTTOM_LEFT
, drawing::Alignment_BOTTOM_LEFT
},
112 { XML_BOTTOM
, drawing::Alignment_BOTTOM
},
113 { XML_BOTTOM_RIGHT
, drawing::Alignment_BOTTOM_RIGHT
},
114 { XML_TOKEN_INVALID
, 0 }
117 SvXMLEnumMapEntry aXML_GlueEscapeDirection_EnumMap
[] =
119 { XML_AUTO
, drawing::EscapeDirection_SMART
},
120 { XML_LEFT
, drawing::EscapeDirection_LEFT
},
121 { XML_RIGHT
, drawing::EscapeDirection_RIGHT
},
122 { XML_UP
, drawing::EscapeDirection_UP
},
123 { XML_DOWN
, drawing::EscapeDirection_DOWN
},
124 { XML_HORIZONTAL
, drawing::EscapeDirection_HORIZONTAL
},
125 { XML_VERTICAL
, drawing::EscapeDirection_VERTICAL
},
126 { XML_TOKEN_INVALID
, 0 }
129 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
131 static bool ImpIsEmptyURL( const ::rtl::OUString
& rURL
)
136 // #i13140# Also compare against 'toplevel' URLs. which also
137 // result in empty filename strings.
138 if( 0 == rURL
.compareToAscii( "#./" ) )
144 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
146 TYPEINIT1( SvXMLShapeContext
, SvXMLImportContext
);
147 TYPEINIT1( SdXMLShapeContext
, SvXMLShapeContext
);
149 SdXMLShapeContext::SdXMLShapeContext(
150 SvXMLImport
& rImport
,
152 const OUString
& rLocalName
,
153 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
154 uno::Reference
< drawing::XShapes
>& rShapes
,
155 sal_Bool bTemporaryShape
)
156 : SvXMLShapeContext( rImport
, nPrfx
, rLocalName
, bTemporaryShape
)
157 , mxShapes( rShapes
)
158 , mxAttrList(xAttrList
)
159 , mbListContextPushed( false )
160 , mnStyleFamily(XML_STYLE_FAMILY_SD_GRAPHICS_ID
)
161 , mbIsPlaceholder(sal_False
)
162 , mbClearDefaultAttributes( true )
163 , mbIsUserTransformed(sal_False
)
172 //////////////////////////////////////////////////////////////////////////////
174 SdXMLShapeContext::~SdXMLShapeContext()
178 //////////////////////////////////////////////////////////////////////////////
180 SvXMLImportContext
*SdXMLShapeContext::CreateChildContext( sal_uInt16 p_nPrefix
,
181 const OUString
& rLocalName
,
182 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
184 SvXMLImportContext
* pContext
= NULL
;
187 if( p_nPrefix
== XML_NAMESPACE_SVG
&&
188 (IsXMLToken( rLocalName
, XML_TITLE
) || IsXMLToken( rLocalName
, XML_DESC
) ) )
190 pContext
= new SdXMLDescriptionContext( GetImport(), p_nPrefix
, rLocalName
, xAttrList
, mxShape
);
192 else if( p_nPrefix
== XML_NAMESPACE_OFFICE
&& IsXMLToken( rLocalName
, XML_EVENT_LISTENERS
) )
194 pContext
= new SdXMLEventsContext( GetImport(), p_nPrefix
, rLocalName
, xAttrList
, mxShape
);
196 else if( p_nPrefix
== XML_NAMESPACE_DRAW
&& IsXMLToken( rLocalName
, XML_GLUE_POINT
) )
198 addGluePoint( xAttrList
);
200 else if( p_nPrefix
== XML_NAMESPACE_DRAW
&& IsXMLToken( rLocalName
, XML_THUMBNAIL
) )
202 // search attributes for xlink:href
203 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
204 for(sal_Int16 i
=0; i
< nAttrCount
; i
++)
206 OUString sAttrName
= xAttrList
->getNameByIndex( i
);
208 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName
, &aLocalName
);
210 if( nPrefix
== XML_NAMESPACE_XLINK
)
212 if( IsXMLToken( aLocalName
, XML_HREF
) )
214 maThumbnailURL
= xAttrList
->getValueByIndex( i
);
222 // create text cursor on demand
225 uno::Reference
< text::XText
> xText( mxShape
, uno::UNO_QUERY
);
228 UniReference
< XMLTextImportHelper
> xTxtImport
=
229 GetImport().GetTextImport();
230 mxOldCursor
= xTxtImport
->GetCursor();
231 mxCursor
= xText
->createTextCursor();
234 xTxtImport
->SetCursor( mxCursor
);
237 // remember old list item and block (#91964#) and reset them
238 // for the text frame
239 xTxtImport
->PushListContext();
240 mbListContextPushed
= true;
244 // if we have a text cursor, lets try to import some text
247 pContext
= GetImport().GetTextImport()->CreateTextChildContext(
248 GetImport(), p_nPrefix
, rLocalName
, xAttrList
);
252 // call parent for content
254 pContext
= SvXMLImportContext::CreateChildContext( p_nPrefix
, rLocalName
, xAttrList
);
259 void SdXMLShapeContext::addGluePoint( const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
261 // get the glue points container for this shape if its not already there
262 if( !mxGluePoints
.is() )
264 uno::Reference
< drawing::XGluePointsSupplier
> xSupplier( mxShape
, uno::UNO_QUERY
);
265 if( !xSupplier
.is() )
268 mxGluePoints
= uno::Reference
< container::XIdentifierContainer
>::query( xSupplier
->getGluePoints() );
270 if( !mxGluePoints
.is() )
274 drawing::GluePoint2 aGluePoint
;
275 aGluePoint
.IsUserDefined
= sal_True
;
276 aGluePoint
.Position
.X
= 0;
277 aGluePoint
.Position
.Y
= 0;
278 aGluePoint
.Escape
= drawing::EscapeDirection_SMART
;
279 aGluePoint
.PositionAlignment
= drawing::Alignment_CENTER
;
280 aGluePoint
.IsRelative
= sal_True
;
284 // read attributes for the 3DScene
285 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
286 for(sal_Int16 i
=0; i
< nAttrCount
; i
++)
288 OUString sAttrName
= xAttrList
->getNameByIndex( i
);
290 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName
, &aLocalName
);
291 const OUString
sValue( xAttrList
->getValueByIndex( i
) );
293 if( nPrefix
== XML_NAMESPACE_SVG
)
295 if( IsXMLToken( aLocalName
, XML_X
) )
297 GetImport().GetMM100UnitConverter().convertMeasureToCore(
298 aGluePoint
.Position
.X
, sValue
);
300 else if( IsXMLToken( aLocalName
, XML_Y
) )
302 GetImport().GetMM100UnitConverter().convertMeasureToCore(
303 aGluePoint
.Position
.Y
, sValue
);
306 else if( nPrefix
== XML_NAMESPACE_DRAW
)
308 if( IsXMLToken( aLocalName
, XML_ID
) )
310 nId
= sValue
.toInt32();
312 else if( IsXMLToken( aLocalName
, XML_ALIGN
) )
315 if( SvXMLUnitConverter::convertEnum( eKind
, sValue
, aXML_GlueAlignment_EnumMap
) )
317 aGluePoint
.PositionAlignment
= (drawing::Alignment
)eKind
;
318 aGluePoint
.IsRelative
= sal_False
;
321 else if( IsXMLToken( aLocalName
, XML_ESCAPE_DIRECTION
) )
324 if( SvXMLUnitConverter::convertEnum( eKind
, sValue
, aXML_GlueEscapeDirection_EnumMap
) )
326 aGluePoint
.Escape
= (drawing::EscapeDirection
)eKind
;
336 sal_Int32 nInternalId
= mxGluePoints
->insert( uno::makeAny( aGluePoint
) );
337 GetImport().GetShapeImport()->addGluePointMapping( mxShape
, nId
, nInternalId
);
339 catch(const uno::Exception
&)
341 OSL_FAIL( "exception during setting of glue points!");
345 //////////////////////////////////////////////////////////////////////////////
347 void SdXMLShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>&)
349 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
352 void SdXMLShapeContext::EndElement()
356 // delete addition newline
357 const OUString aEmpty
;
358 mxCursor
->gotoEnd( sal_False
);
359 mxCursor
->goLeft( 1, sal_True
);
360 mxCursor
->setString( aEmpty
);
363 GetImport().GetTextImport()->ResetCursor();
367 GetImport().GetTextImport()->SetCursor( mxOldCursor
);
369 // reinstall old list item (if necessary) #91964#
370 if (mbListContextPushed
) {
371 GetImport().GetTextImport()->PopListContext();
374 if( !msHyperlink
.isEmpty() ) try
376 uno::Reference
< beans::XPropertySet
> xProp( mxShape
, uno::UNO_QUERY
);
378 rtl::OUString
sLink( "Hyperlink" );
379 if ( xProp
.is() && xProp
->getPropertySetInfo()->hasPropertyByName( sLink
) )
380 xProp
->setPropertyValue( sLink
, uno::Any( msHyperlink
) );
381 Reference
< XEventsSupplier
> xEventsSupplier( mxShape
, UNO_QUERY_THROW
);
382 const OUString
sBookmark( "Bookmark" );
384 if( xEventsSupplier
.is() )
386 const OUString
sEventType( "EventType" );
387 const OUString
sClickAction( "ClickAction" );
389 Reference
< XNameReplace
> xEvents( xEventsSupplier
->getEvents(), UNO_QUERY_THROW
);
391 uno::Sequence
< beans::PropertyValue
> aProperties( 3 );
392 aProperties
[0].Name
= sEventType
;
393 aProperties
[0].Handle
= -1;
394 aProperties
[0].Value
<<= OUString( "Presentation" );
395 aProperties
[0].State
= beans::PropertyState_DIRECT_VALUE
;
397 aProperties
[1].Name
= sClickAction
;
398 aProperties
[1].Handle
= -1;
399 aProperties
[1].Value
<<= ::com::sun::star::presentation::ClickAction_DOCUMENT
;
400 aProperties
[1].State
= beans::PropertyState_DIRECT_VALUE
;
402 aProperties
[2].Name
= sBookmark
;
403 aProperties
[2].Handle
= -1;
404 aProperties
[2].Value
<<= msHyperlink
;
405 aProperties
[2].State
= beans::PropertyState_DIRECT_VALUE
;
407 const OUString
sAPIEventName( "OnClick" );
408 xEvents
->replaceByName( sAPIEventName
, Any( aProperties
) );
412 // in draw use the Bookmark property
413 Reference
< beans::XPropertySet
> xSet( mxShape
, UNO_QUERY_THROW
);
414 xSet
->setPropertyValue( sBookmark
, Any( msHyperlink
) );
415 xSet
->setPropertyValue( OUString( "OnClick" ), Any( ::com::sun::star::presentation::ClickAction_DOCUMENT
) );
418 catch(const Exception
&)
420 OSL_FAIL("xmloff::SdXMLShapeContext::EndElement(), exception caught while setting hyperlink!");
423 if( mxLockable
.is() )
424 mxLockable
->removeActionLock();
427 //////////////////////////////////////////////////////////////////////////////
429 void SdXMLShapeContext::AddShape(uno::Reference
< drawing::XShape
>& xShape
)
436 if(!maShapeName
.isEmpty())
438 uno::Reference
< container::XNamed
> xNamed( mxShape
, uno::UNO_QUERY
);
440 xNamed
->setName( maShapeName
);
443 UniReference
< XMLShapeImportHelper
> xImp( GetImport().GetShapeImport() );
444 xImp
->addShape( xShape
, mxAttrList
, mxShapes
);
446 if( mbClearDefaultAttributes
)
448 uno::Reference
<beans::XMultiPropertyStates
> xMultiPropertyStates(xShape
, uno::UNO_QUERY
);
449 if (xMultiPropertyStates
.is())
450 xMultiPropertyStates
->setAllPropertiesToDefault();
453 if( !mbVisible
|| !mbPrintable
) try
455 uno::Reference
< beans::XPropertySet
> xSet( xShape
, uno::UNO_QUERY_THROW
);
457 xSet
->setPropertyValue( rtl::OUString( "Visible" ), uno::Any( sal_False
) );
460 xSet
->setPropertyValue( rtl::OUString( "Printable" ), uno::Any( sal_False
) );
462 catch(const Exception
&)
464 OSL_FAIL( "SdXMLShapeContext::AddShape(), exception caught!" );
468 if(!mbTemporaryShape
&& (!GetImport().HasTextImport()
469 || !GetImport().GetTextImport()->IsInsideDeleteContext()))
471 xImp
->shapeWithZIndexAdded( xShape
, mnZOrder
);
474 if( !maShapeId
.isEmpty() )
476 uno::Reference
< uno::XInterface
> xRef( xShape
, uno::UNO_QUERY
);
477 GetImport().getInterfaceToIdentifierMapper().registerReference( maShapeId
, xRef
);
480 // #91065# count only if counting for shape import is enabled
481 if(GetImport().GetShapeImport()->IsHandleProgressBarEnabled())
483 // #80365# increment progress bar at load once for each draw object
484 GetImport().GetProgressBarHelper()->Increment();
488 mxLockable
= uno::Reference
< document::XActionLockable
>::query( xShape
);
490 if( mxLockable
.is() )
491 mxLockable
->addActionLock();
495 //////////////////////////////////////////////////////////////////////////////
497 void SdXMLShapeContext::AddShape(const char* pServiceName
)
499 uno::Reference
< lang::XMultiServiceFactory
> xServiceFact(GetImport().GetModel(), uno::UNO_QUERY
);
500 if(xServiceFact
.is())
504 /* Since fix for issue i33294 the Writer model doesn't support
505 com.sun.star.drawing.OLE2Shape anymore.
506 To handle Draw OLE objects it's decided to import these
507 objects as com.sun.star.drawing.OLE2Shape and convert these
508 objects after the import into com.sun.star.drawing.GraphicObjectShape.
510 uno::Reference
< drawing::XShape
> xShape
;
511 if ( OUString::createFromAscii(pServiceName
).compareToAscii( "com.sun.star.drawing.OLE2Shape" ) == 0 &&
512 uno::Reference
< text::XTextDocument
>(GetImport().GetModel(), uno::UNO_QUERY
).is() )
514 xShape
= uno::Reference
< drawing::XShape
>(xServiceFact
->createInstance(OUString("com.sun.star.drawing.temporaryForXMLImportOLE2Shape")), uno::UNO_QUERY
);
518 xShape
= uno::Reference
< drawing::XShape
>(xServiceFact
->createInstance(OUString::createFromAscii(pServiceName
)), uno::UNO_QUERY
);
523 catch(const uno::Exception
& e
)
525 uno::Sequence
<rtl::OUString
> aSeq( 1 );
526 aSeq
[0] = OUString::createFromAscii(pServiceName
);
527 GetImport().SetError( XMLERROR_FLAG_ERROR
| XMLERROR_API
,
528 aSeq
, e
.Message
, NULL
);
533 //////////////////////////////////////////////////////////////////////////////
535 void SdXMLShapeContext::SetTransformation()
539 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
542 ::basegfx::B2DHomMatrix aTransformation
;
544 if(maSize
.Width
!= 1 || maSize
.Height
!= 1)
546 // take care there are no zeros used by error
547 if(0 == maSize
.Width
)
549 if(0 == maSize
.Height
)
552 // set global size. This should always be used.
553 aTransformation
.scale(maSize
.Width
, maSize
.Height
);
556 if(maPosition
.X
!= 0 || maPosition
.Y
!= 0)
558 // if global position is used, add it to transformation
559 aTransformation
.translate(maPosition
.X
, maPosition
.Y
);
562 if(mnTransform
.NeedsAction())
564 // transformation is used, apply to object.
565 // NOTICE: The transformation is applied AFTER evtl. used
566 // global positioning and scaling is used, so any shear or
567 // rotate used herein is applied around the (0,0) position
568 // of the PAGE object !!!
569 ::basegfx::B2DHomMatrix aMat
;
570 mnTransform
.GetFullTransform(aMat
);
572 // now add to transformation
573 aTransformation
*= aMat
;
576 // now set transformation for this object
578 drawing::HomogenMatrix3 aMatrix
;
580 aMatrix
.Line1
.Column1
= aTransformation
.get(0, 0);
581 aMatrix
.Line1
.Column2
= aTransformation
.get(0, 1);
582 aMatrix
.Line1
.Column3
= aTransformation
.get(0, 2);
584 aMatrix
.Line2
.Column1
= aTransformation
.get(1, 0);
585 aMatrix
.Line2
.Column2
= aTransformation
.get(1, 1);
586 aMatrix
.Line2
.Column3
= aTransformation
.get(1, 2);
588 aMatrix
.Line3
.Column1
= aTransformation
.get(2, 0);
589 aMatrix
.Line3
.Column2
= aTransformation
.get(2, 1);
590 aMatrix
.Line3
.Column3
= aTransformation
.get(2, 2);
594 xPropSet
->setPropertyValue(
595 OUString("Transformation"), aAny
);
600 //////////////////////////////////////////////////////////////////////////////
602 void SdXMLShapeContext::SetStyle( bool bSupportsStyle
/* = true */)
606 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
612 XMLPropStyleContext
* pDocStyle
= NULL
;
614 // set style on shape
615 if(maDrawStyleName
.isEmpty())
618 const SvXMLStyleContext
* pStyle
= 0L;
619 sal_Bool
bAutoStyle(sal_False
);
621 if(GetImport().GetShapeImport()->GetAutoStylesContext())
622 pStyle
= GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(mnStyleFamily
, maDrawStyleName
);
625 bAutoStyle
= sal_True
;
627 if(!pStyle
&& GetImport().GetShapeImport()->GetStylesContext())
628 pStyle
= GetImport().GetShapeImport()->GetStylesContext()->FindStyleChildContext(mnStyleFamily
, maDrawStyleName
);
630 OUString aStyleName
= maDrawStyleName
;
631 uno::Reference
< style::XStyle
> xStyle
;
633 if( pStyle
&& pStyle
->ISA(XMLShapeStyleContext
) )
635 pDocStyle
= PTR_CAST( XMLShapeStyleContext
, pStyle
);
637 if( pDocStyle
->GetStyle().is() )
639 xStyle
= pDocStyle
->GetStyle();
643 aStyleName
= pDocStyle
->GetParentName();
647 if( !xStyle
.is() && !aStyleName
.isEmpty() )
652 uno::Reference
< style::XStyleFamiliesSupplier
> xFamiliesSupplier( GetImport().GetModel(), uno::UNO_QUERY
);
654 if( xFamiliesSupplier
.is() )
656 uno::Reference
< container::XNameAccess
> xFamilies( xFamiliesSupplier
->getStyleFamilies() );
660 uno::Reference
< container::XNameAccess
> xFamily
;
662 if( XML_STYLE_FAMILY_SD_PRESENTATION_ID
== mnStyleFamily
)
664 aStyleName
= GetImport().GetStyleDisplayName(
665 XML_STYLE_FAMILY_SD_PRESENTATION_ID
,
667 sal_Int32 nPos
= aStyleName
.lastIndexOf( sal_Unicode('-') );
670 OUString
aFamily( aStyleName
.copy( 0, nPos
) );
672 xFamilies
->getByName( aFamily
) >>= xFamily
;
673 aStyleName
= aStyleName
.copy( nPos
+ 1 );
678 // get graphics familie
679 xFamilies
->getByName( OUString( "graphics" ) ) >>= xFamily
;
680 aStyleName
= GetImport().GetStyleDisplayName(
681 XML_STYLE_FAMILY_SD_GRAPHICS_ID
,
686 xFamily
->getByName( aStyleName
) >>= xStyle
;
690 catch(const uno::Exception
&)
692 OSL_FAIL( "could not find style for shape!" );
696 if( bSupportsStyle
&& xStyle
.is() )
700 // set style on object
703 xPropSet
->setPropertyValue(OUString("Style"), aAny
);
705 catch(const uno::Exception
&)
707 OSL_FAIL( "could not find style for shape!" );
711 // if this is an auto style, set its properties
712 if(bAutoStyle
&& pDocStyle
)
714 // set PropertySet on object
715 pDocStyle
->FillPropertySet(xPropSet
);
720 // try to set text auto style
723 // set style on shape
724 if( maTextStyleName
.isEmpty() )
727 if( NULL
== GetImport().GetShapeImport()->GetAutoStylesContext())
730 const SvXMLStyleContext
* pTempStyle
= GetImport().GetShapeImport()->GetAutoStylesContext()->FindStyleChildContext(XML_STYLE_FAMILY_TEXT_PARAGRAPH
, maTextStyleName
);
731 XMLPropStyleContext
* pStyle
= PTR_CAST( XMLPropStyleContext
, pTempStyle
); // use temp var, PTR_CAST is a bad macro, FindStyleChildContext will be called twice
735 // set PropertySet on object
736 pStyle
->FillPropertySet(xPropSet
);
740 catch(const uno::Exception
&)
745 void SdXMLShapeContext::SetLayer()
747 if( !maLayerName
.isEmpty() )
751 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
755 aAny
<<= maLayerName
;
757 xPropSet
->setPropertyValue(OUString("LayerName"), aAny
);
761 catch(const uno::Exception
&)
767 void SdXMLShapeContext::SetThumbnail()
769 if( maThumbnailURL
.isEmpty() )
774 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
778 const OUString
sProperty("ThumbnailGraphicURL");
780 uno::Reference
< beans::XPropertySetInfo
> xPropSetInfo( xPropSet
->getPropertySetInfo() );
781 if( xPropSetInfo
.is() && xPropSetInfo
->hasPropertyByName( sProperty
) )
783 // load the thumbnail graphic and export it to a wmf stream so we can set
786 const OUString
aInternalURL( GetImport().ResolveGraphicObjectURL( maThumbnailURL
, sal_False
) );
787 xPropSet
->setPropertyValue( sProperty
, uno::makeAny( aInternalURL
) );
790 catch(const uno::Exception
&)
795 // this is called from the parent group for each unparsed attribute in the attribute list
796 void SdXMLShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
798 bool bHaveXmlId( false );
799 if( (XML_NAMESPACE_DRAW
== nPrefix
) || (XML_NAMESPACE_DRAW_EXT
== nPrefix
) )
801 if( IsXMLToken( rLocalName
, XML_ZINDEX
) )
803 mnZOrder
= rValue
.toInt32();
805 else if( IsXMLToken( rLocalName
, XML_ID
) )
807 if (!bHaveXmlId
) { maShapeId
= rValue
; };
809 else if( IsXMLToken( rLocalName
, XML_NAME
) )
811 maShapeName
= rValue
;
813 else if( IsXMLToken( rLocalName
, XML_STYLE_NAME
) )
815 maDrawStyleName
= rValue
;
817 else if( IsXMLToken( rLocalName
, XML_TEXT_STYLE_NAME
) )
819 maTextStyleName
= rValue
;
821 else if( IsXMLToken( rLocalName
, XML_LAYER
) )
823 maLayerName
= rValue
;
825 else if( IsXMLToken( rLocalName
, XML_TRANSFORM
) )
827 mnTransform
.SetString(rValue
, GetImport().GetMM100UnitConverter());
829 else if( IsXMLToken( rLocalName
, XML_DISPLAY
) )
831 mbVisible
= IsXMLToken( rValue
, XML_ALWAYS
) || IsXMLToken( rValue
, XML_SCREEN
);
832 mbPrintable
= IsXMLToken( rValue
, XML_ALWAYS
) || IsXMLToken( rValue
, XML_PRINTER
);
835 else if( XML_NAMESPACE_PRESENTATION
== nPrefix
)
837 if( IsXMLToken( rLocalName
, XML_USER_TRANSFORMED
) )
839 mbIsUserTransformed
= IsXMLToken( rValue
, XML_TRUE
);
841 else if( IsXMLToken( rLocalName
, XML_PLACEHOLDER
) )
843 mbIsPlaceholder
= IsXMLToken( rValue
, XML_TRUE
);
844 if( mbIsPlaceholder
)
845 mbClearDefaultAttributes
= false;
847 else if( IsXMLToken( rLocalName
, XML_CLASS
) )
849 maPresentationClass
= rValue
;
851 else if( IsXMLToken( rLocalName
, XML_STYLE_NAME
) )
853 maDrawStyleName
= rValue
;
854 mnStyleFamily
= XML_STYLE_FAMILY_SD_PRESENTATION_ID
;
857 else if( XML_NAMESPACE_SVG
== nPrefix
)
859 if( IsXMLToken( rLocalName
, XML_X
) )
861 GetImport().GetMM100UnitConverter().convertMeasureToCore(
862 maPosition
.X
, rValue
);
864 else if( IsXMLToken( rLocalName
, XML_Y
) )
866 GetImport().GetMM100UnitConverter().convertMeasureToCore(
867 maPosition
.Y
, rValue
);
869 else if( IsXMLToken( rLocalName
, XML_WIDTH
) )
871 GetImport().GetMM100UnitConverter().convertMeasureToCore(
872 maSize
.Width
, rValue
);
873 if( maSize
.Width
> 0 )
875 else if( maSize
.Width
< 0 )
878 else if( IsXMLToken( rLocalName
, XML_HEIGHT
) )
880 GetImport().GetMM100UnitConverter().convertMeasureToCore(
881 maSize
.Height
, rValue
);
882 if( maSize
.Height
> 0 )
884 else if( maSize
.Height
< 0 )
887 else if( IsXMLToken( rLocalName
, XML_TRANSFORM
) )
889 // because of #85127# take svg:transform into account and hanle like
890 // draw:transform for compatibility
891 mnTransform
.SetString(rValue
, GetImport().GetMM100UnitConverter());
895 else if( IsXMLToken( rLocalName
, XML_TITLE
) )
897 maShapeTitle
= rValue
;
899 else if( IsXMLToken( rLocalName
, XML_DESC
) )
901 maShapeDescription
= rValue
;
904 else if( (XML_NAMESPACE_NONE
== nPrefix
) || (XML_NAMESPACE_XML
== nPrefix
) )
906 if( IsXMLToken( rLocalName
, XML_ID
) )
914 sal_Bool
SdXMLShapeContext::isPresentationShape() const
916 if( !maPresentationClass
.isEmpty() && (const_cast<SdXMLShapeContext
*>(this))->GetImport().GetShapeImport()->IsPresentationShapesSupported() )
918 if(XML_STYLE_FAMILY_SD_PRESENTATION_ID
== mnStyleFamily
)
923 if( IsXMLToken( maPresentationClass
, XML_HEADER
) || IsXMLToken( maPresentationClass
, XML_FOOTER
) ||
924 IsXMLToken( maPresentationClass
, XML_PAGE_NUMBER
) || IsXMLToken( maPresentationClass
, XML_DATE_TIME
) )
933 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
934 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
936 TYPEINIT1( SdXMLRectShapeContext
, SdXMLShapeContext
);
938 SdXMLRectShapeContext::SdXMLRectShapeContext(
939 SvXMLImport
& rImport
,
941 const OUString
& rLocalName
,
942 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
943 uno::Reference
< drawing::XShapes
>& rShapes
,
944 sal_Bool bTemporaryShape
)
945 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
950 //////////////////////////////////////////////////////////////////////////////
952 SdXMLRectShapeContext::~SdXMLRectShapeContext()
956 //////////////////////////////////////////////////////////////////////////////
958 // this is called from the parent group for each unparsed attribute in the attribute list
959 void SdXMLRectShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
961 if( XML_NAMESPACE_DRAW
== nPrefix
)
963 if( IsXMLToken( rLocalName
, XML_CORNER_RADIUS
) )
965 GetImport().GetMM100UnitConverter().convertMeasureToCore(
971 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
974 //////////////////////////////////////////////////////////////////////////////
976 void SdXMLRectShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
978 // create rectangle shape
979 AddShape("com.sun.star.drawing.RectangleShape");
982 // Add, set Style and properties from base shape
986 // set pos, size, shear and rotate
991 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
996 xPropSet
->setPropertyValue(OUString("CornerRadius"), uno::makeAny( mnRadius
) );
998 catch(const uno::Exception
&)
1000 OSL_FAIL( "exception during setting of corner radius!");
1004 SdXMLShapeContext::StartElement(xAttrList
);
1008 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1009 ////////////////////////////////////////3////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1011 TYPEINIT1( SdXMLLineShapeContext
, SdXMLShapeContext
);
1013 SdXMLLineShapeContext::SdXMLLineShapeContext(
1014 SvXMLImport
& rImport
,
1016 const OUString
& rLocalName
,
1017 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1018 uno::Reference
< drawing::XShapes
>& rShapes
,
1019 sal_Bool bTemporaryShape
)
1020 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1028 //////////////////////////////////////////////////////////////////////////////
1030 SdXMLLineShapeContext::~SdXMLLineShapeContext()
1034 //////////////////////////////////////////////////////////////////////////////
1036 // this is called from the parent group for each unparsed attribute in the attribute list
1037 void SdXMLLineShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1039 if( XML_NAMESPACE_SVG
== nPrefix
)
1041 if( IsXMLToken( rLocalName
, XML_X1
) )
1043 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1047 if( IsXMLToken( rLocalName
, XML_Y1
) )
1049 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1053 if( IsXMLToken( rLocalName
, XML_X2
) )
1055 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1059 if( IsXMLToken( rLocalName
, XML_Y2
) )
1061 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1067 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1070 //////////////////////////////////////////////////////////////////////////////
1072 void SdXMLLineShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1074 // #85920# use SetTransformation() to handle import of simple lines.
1075 // This is necessary to kake into account all anchor positions and
1076 // other things. All shape imports use the same import schemata now.
1077 // create necessary shape (Line Shape)
1078 AddShape("com.sun.star.drawing.PolyLineShape");
1082 // Add, set Style and properties from base shape
1086 // get sizes and offsets
1087 awt::Point
aTopLeft(mnX1
, mnY1
);
1088 awt::Point
aBottomRight(mnX2
, mnY2
);
1093 aBottomRight
.X
= mnX1
;
1099 aBottomRight
.Y
= mnY1
;
1102 // set local parameters on shape
1103 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
1106 drawing::PointSequenceSequence
aPolyPoly(1L);
1107 drawing::PointSequence
* pOuterSequence
= aPolyPoly
.getArray();
1108 pOuterSequence
->realloc(2L);
1109 awt::Point
* pInnerSequence
= pOuterSequence
->getArray();
1112 *pInnerSequence
= awt::Point( mnX1
- aTopLeft
.X
, mnY1
- aTopLeft
.Y
);
1114 *pInnerSequence
= awt::Point( mnX2
- aTopLeft
.X
, mnY2
- aTopLeft
.Y
);
1117 xPropSet
->setPropertyValue(
1118 OUString("Geometry"), aAny
);
1121 // set sizes for transformation
1122 maSize
.Width
= aBottomRight
.X
- aTopLeft
.X
;
1123 maSize
.Height
= aBottomRight
.Y
- aTopLeft
.Y
;
1124 maPosition
.X
= aTopLeft
.X
;
1125 maPosition
.Y
= aTopLeft
.Y
;
1127 // set pos, size, shear and rotate and get copy of matrix
1128 SetTransformation();
1130 SdXMLShapeContext::StartElement(xAttrList
);
1134 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1135 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1137 TYPEINIT1( SdXMLEllipseShapeContext
, SdXMLShapeContext
);
1139 SdXMLEllipseShapeContext::SdXMLEllipseShapeContext(
1140 SvXMLImport
& rImport
,
1142 const OUString
& rLocalName
,
1143 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1144 uno::Reference
< drawing::XShapes
>& rShapes
,
1145 sal_Bool bTemporaryShape
)
1146 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1151 meKind( drawing::CircleKind_FULL
),
1157 //////////////////////////////////////////////////////////////////////////////
1159 SdXMLEllipseShapeContext::~SdXMLEllipseShapeContext()
1163 //////////////////////////////////////////////////////////////////////////////
1165 // this is called from the parent group for each unparsed attribute in the attribute list
1166 void SdXMLEllipseShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1168 if( XML_NAMESPACE_SVG
== nPrefix
)
1170 if( IsXMLToken( rLocalName
, XML_RX
) )
1172 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1176 if( IsXMLToken( rLocalName
, XML_RY
) )
1178 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1182 if( IsXMLToken( rLocalName
, XML_CX
) )
1184 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1188 if( IsXMLToken( rLocalName
, XML_CY
) )
1190 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1194 if( IsXMLToken( rLocalName
, XML_R
) )
1196 // single radius, it's a circle and both radii are the same
1197 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1203 else if( XML_NAMESPACE_DRAW
== nPrefix
)
1205 if( IsXMLToken( rLocalName
, XML_KIND
) )
1208 if( SvXMLUnitConverter::convertEnum( eKind
, rValue
, aXML_CircleKind_EnumMap
) )
1214 if( IsXMLToken( rLocalName
, XML_START_ANGLE
) )
1217 if (::sax::Converter::convertDouble( dStartAngle
, rValue
))
1218 mnStartAngle
= (sal_Int32
)(dStartAngle
* 100.0);
1221 if( IsXMLToken( rLocalName
, XML_END_ANGLE
) )
1224 if (::sax::Converter::convertDouble( dEndAngle
, rValue
))
1225 mnEndAngle
= (sal_Int32
)(dEndAngle
* 100.0);
1230 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1233 //////////////////////////////////////////////////////////////////////////////
1235 void SdXMLEllipseShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1237 // create rectangle shape
1238 AddShape("com.sun.star.drawing.EllipseShape");
1241 // Add, set Style and properties from base shape
1245 // set pos, size, shear and rotate
1246 SetTransformation();
1248 if( meKind
!= drawing::CircleKind_FULL
)
1250 uno::Reference
< beans::XPropertySet
> xPropSet( mxShape
, uno::UNO_QUERY
);
1254 aAny
<<= (drawing::CircleKind
)meKind
;
1255 xPropSet
->setPropertyValue( OUString("CircleKind"), aAny
);
1257 aAny
<<= mnStartAngle
;
1258 xPropSet
->setPropertyValue( OUString("CircleStartAngle"), aAny
);
1260 aAny
<<= mnEndAngle
;
1261 xPropSet
->setPropertyValue( OUString("CircleEndAngle"), aAny
);
1265 SdXMLShapeContext::StartElement(xAttrList
);
1269 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1270 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1272 TYPEINIT1( SdXMLPolygonShapeContext
, SdXMLShapeContext
);
1274 SdXMLPolygonShapeContext::SdXMLPolygonShapeContext(
1275 SvXMLImport
& rImport
,
1277 const OUString
& rLocalName
,
1278 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1279 uno::Reference
< drawing::XShapes
>& rShapes
, sal_Bool bClosed
, sal_Bool bTemporaryShape
)
1280 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1285 //////////////////////////////////////////////////////////////////////////////
1287 // this is called from the parent group for each unparsed attribute in the attribute list
1288 void SdXMLPolygonShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1290 if( XML_NAMESPACE_SVG
== nPrefix
)
1292 if( IsXMLToken( rLocalName
, XML_VIEWBOX
) )
1298 else if( XML_NAMESPACE_DRAW
== nPrefix
)
1300 if( IsXMLToken( rLocalName
, XML_POINTS
) )
1307 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1310 //////////////////////////////////////////////////////////////////////////////
1312 SdXMLPolygonShapeContext::~SdXMLPolygonShapeContext()
1316 //////////////////////////////////////////////////////////////////////////////
1318 void SdXMLPolygonShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1320 // Add, set Style and properties from base shape
1322 AddShape("com.sun.star.drawing.PolyPolygonShape");
1324 AddShape("com.sun.star.drawing.PolyLineShape");
1331 // set local parameters on shape
1332 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
1336 if(!maPoints
.isEmpty() && !maViewBox
.isEmpty())
1338 SdXMLImExViewBox
aViewBox(maViewBox
, GetImport().GetMM100UnitConverter());
1339 awt::Size
aSize(aViewBox
.GetWidth(), aViewBox
.GetHeight());
1340 if (maSize
.Width
!= 0 && maSize
.Height
!=0)
1344 awt::Point
aPosition(aViewBox
.GetX(), aViewBox
.GetY());
1345 SdXMLImExPointsElement
aPoints(maPoints
, aViewBox
,
1346 aPosition
, aSize
, GetImport().GetMM100UnitConverter());
1349 aAny
<<= aPoints
.GetPointSequenceSequence();
1350 xPropSet
->setPropertyValue(
1351 OUString("Geometry"), aAny
);
1355 // set pos, size, shear and rotate and get copy of matrix
1356 SetTransformation();
1358 SdXMLShapeContext::StartElement(xAttrList
);
1362 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1363 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1365 TYPEINIT1( SdXMLPathShapeContext
, SdXMLShapeContext
);
1367 SdXMLPathShapeContext::SdXMLPathShapeContext(
1368 SvXMLImport
& rImport
,
1370 const OUString
& rLocalName
,
1371 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1372 uno::Reference
< drawing::XShapes
>& rShapes
,
1373 sal_Bool bTemporaryShape
)
1374 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1375 mbClosed( sal_True
)
1379 //////////////////////////////////////////////////////////////////////////////
1381 SdXMLPathShapeContext::~SdXMLPathShapeContext()
1385 //////////////////////////////////////////////////////////////////////////////
1387 // this is called from the parent group for each unparsed attribute in the attribute list
1388 void SdXMLPathShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1390 if( XML_NAMESPACE_SVG
== nPrefix
)
1392 if( IsXMLToken( rLocalName
, XML_VIEWBOX
) )
1397 else if( IsXMLToken( rLocalName
, XML_D
) )
1404 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1407 //////////////////////////////////////////////////////////////////////////////
1409 void SdXMLPathShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1411 // create polygon shape
1414 // prepare some of the parameters
1415 SdXMLImExViewBox
aViewBox(maViewBox
, GetImport().GetMM100UnitConverter());
1416 awt::Size
aSize(aViewBox
.GetWidth(), aViewBox
.GetHeight());
1417 awt::Point
aPosition(aViewBox
.GetX(), aViewBox
.GetY());
1418 if (maSize
.Width
!= 0 && maSize
.Height
!=0)
1422 SdXMLImExSvgDElement
aPoints(maD
, aViewBox
, aPosition
, aSize
, GetImport());
1424 const char* pService
;
1426 if(aPoints
.IsCurve())
1428 if(aPoints
.IsClosed())
1430 pService
= "com.sun.star.drawing.ClosedBezierShape";
1434 pService
= "com.sun.star.drawing.OpenBezierShape";
1439 if(aPoints
.IsClosed())
1441 pService
= "com.sun.star.drawing.PolyPolygonShape";
1445 pService
= "com.sun.star.drawing.PolyLineShape";
1449 // Add, set Style and properties from base shape
1452 // #89344# test for mxShape.is() and not for mxShapes.is() to support
1453 // shape import helper classes WITHOUT XShapes (member mxShapes). This
1454 // is used by the writer.
1460 // set local parameters on shape
1461 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
1469 if(aPoints
.IsCurve())
1471 drawing::PolyPolygonBezierCoords
aSourcePolyPolygon(
1472 aPoints
.GetPointSequenceSequence(),
1473 aPoints
.GetFlagSequenceSequence());
1475 aAny
<<= aSourcePolyPolygon
;
1476 xPropSet
->setPropertyValue(
1477 OUString("Geometry"), aAny
);
1481 aAny
<<= aPoints
.GetPointSequenceSequence();
1482 xPropSet
->setPropertyValue(
1483 OUString("Geometry"), aAny
);
1488 // set pos, size, shear and rotate
1489 SetTransformation();
1491 SdXMLShapeContext::StartElement(xAttrList
);
1496 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1497 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1499 TYPEINIT1( SdXMLTextBoxShapeContext
, SdXMLShapeContext
);
1501 SdXMLTextBoxShapeContext::SdXMLTextBoxShapeContext(
1502 SvXMLImport
& rImport
,
1504 const OUString
& rLocalName
,
1505 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1506 uno::Reference
< drawing::XShapes
>& rShapes
,
1507 sal_Bool bTemporaryShape
)
1508 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1513 //////////////////////////////////////////////////////////////////////////////
1515 SdXMLTextBoxShapeContext::~SdXMLTextBoxShapeContext()
1519 //////////////////////////////////////////////////////////////////////////////
1521 // this is called from the parent group for each unparsed attribute in the attribute list
1522 void SdXMLTextBoxShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1524 if( XML_NAMESPACE_DRAW
== nPrefix
)
1526 if( IsXMLToken( rLocalName
, XML_CORNER_RADIUS
) )
1528 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1534 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1537 //////////////////////////////////////////////////////////////////////////////
1539 void SdXMLTextBoxShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>&)
1541 // create textbox shape
1542 sal_Bool bIsPresShape
= sal_False
;
1543 bool bClearText
= false;
1545 const char *pService
= NULL
;
1547 if( isPresentationShape() )
1549 // check if the current document supports presentation shapes
1550 if( GetImport().GetShapeImport()->IsPresentationShapesSupported() )
1552 if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_SUBTITLE
))
1554 // XmlShapeTypePresSubtitleShape
1555 pService
= "com.sun.star.presentation.SubtitleShape";
1557 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_OUTLINE
) )
1559 // XmlShapeTypePresOutlinerShape
1560 pService
= "com.sun.star.presentation.OutlinerShape";
1562 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_NOTES
) )
1564 // XmlShapeTypePresNotesShape
1565 pService
= "com.sun.star.presentation.NotesShape";
1567 else if( IsXMLToken( maPresentationClass
, XML_HEADER
) )
1569 // XmlShapeTypePresHeaderShape
1570 pService
= "com.sun.star.presentation.HeaderShape";
1573 else if( IsXMLToken( maPresentationClass
, XML_FOOTER
) )
1575 // XmlShapeTypePresFooterShape
1576 pService
= "com.sun.star.presentation.FooterShape";
1579 else if( IsXMLToken( maPresentationClass
, XML_PAGE_NUMBER
) )
1581 // XmlShapeTypePresSlideNumberShape
1582 pService
= "com.sun.star.presentation.SlideNumberShape";
1585 else if( IsXMLToken( maPresentationClass
, XML_DATE_TIME
) )
1587 // XmlShapeTypePresDateTimeShape
1588 pService
= "com.sun.star.presentation.DateTimeShape";
1591 else // IsXMLToken( maPresentationClass, XML_PRESENTATION_TITLE ) )
1593 // XmlShapeTypePresTitleTextShape
1594 pService
= "com.sun.star.presentation.TitleTextShape";
1596 bIsPresShape
= sal_True
;
1600 if( NULL
== pService
)
1602 // normal text shape
1603 pService
= "com.sun.star.drawing.TextShape";
1606 // Add, set Style and properties from base shape
1616 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
1619 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
1620 if( xPropsInfo
.is() )
1622 if( !mbIsPlaceholder
&& xPropsInfo
->hasPropertyByName(OUString("IsEmptyPresentationObject" )))
1623 xProps
->setPropertyValue( OUString("IsEmptyPresentationObject" ), ::cppu::bool2any( sal_False
) );
1625 if( mbIsUserTransformed
&& xPropsInfo
->hasPropertyByName(OUString("IsPlaceholderDependent" )))
1626 xProps
->setPropertyValue( OUString("IsPlaceholderDependent" ), ::cppu::bool2any( sal_False
) );
1633 uno::Reference
< text::XText
> xText( mxShape
, uno::UNO_QUERY
);
1635 xText
->setString( aEmpty
);
1638 // set parameters on shape
1639 //A AW->CL: Eventually You need to strip scale and translate from the transformation
1640 //A to reach the same goal again.
1641 //A if(!bIsPresShape || mbIsUserTransformed)
1643 //A // set pos and size on shape, this should remove binding
1644 //A // to pres object on masterpage
1645 //A SetSizeAndPosition();
1648 // set pos, size, shear and rotate
1649 SetTransformation();
1653 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
1658 xPropSet
->setPropertyValue(OUString("CornerRadius"), uno::makeAny( mnRadius
) );
1660 catch(const uno::Exception
&)
1662 OSL_FAIL( "exception during setting of corner radius!");
1667 SdXMLShapeContext::StartElement(mxAttrList
);
1671 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1672 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1674 TYPEINIT1( SdXMLControlShapeContext
, SdXMLShapeContext
);
1676 SdXMLControlShapeContext::SdXMLControlShapeContext(
1677 SvXMLImport
& rImport
,
1679 const OUString
& rLocalName
,
1680 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1681 uno::Reference
< drawing::XShapes
>& rShapes
,
1682 sal_Bool bTemporaryShape
)
1683 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
)
1687 //////////////////////////////////////////////////////////////////////////////
1689 SdXMLControlShapeContext::~SdXMLControlShapeContext()
1693 //////////////////////////////////////////////////////////////////////////////
1695 // this is called from the parent group for each unparsed attribute in the attribute list
1696 void SdXMLControlShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1698 if( XML_NAMESPACE_DRAW
== nPrefix
)
1700 if( IsXMLToken( rLocalName
, XML_CONTROL
) )
1707 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1710 void SdXMLControlShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1712 // create Control shape
1713 // add, set style and properties from base shape
1714 AddShape("com.sun.star.drawing.ControlShape");
1717 DBG_ASSERT( !maFormId
.isEmpty(), "draw:control without a form:id attribute!" );
1718 if( !maFormId
.isEmpty() )
1720 if( GetImport().IsFormsSupported() )
1722 uno::Reference
< awt::XControlModel
> xControlModel( GetImport().GetFormImport()->lookupControl( maFormId
), uno::UNO_QUERY
);
1723 if( xControlModel
.is() )
1725 uno::Reference
< drawing::XControlShape
> xControl( mxShape
, uno::UNO_QUERY
);
1727 xControl
->setControl( xControlModel
);
1736 // set pos, size, shear and rotate
1737 SetTransformation();
1739 SdXMLShapeContext::StartElement(xAttrList
);
1743 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1744 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1746 TYPEINIT1( SdXMLConnectorShapeContext
, SdXMLShapeContext
);
1748 SdXMLConnectorShapeContext::SdXMLConnectorShapeContext(
1749 SvXMLImport
& rImport
,
1751 const OUString
& rLocalName
,
1752 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1753 uno::Reference
< drawing::XShapes
>& rShapes
,
1754 sal_Bool bTemporaryShape
)
1755 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
1758 mnType( (sal_uInt16
)drawing::ConnectorType_STANDARD
),
1767 //////////////////////////////////////////////////////////////////////////////
1769 SdXMLConnectorShapeContext::~SdXMLConnectorShapeContext()
1773 //////////////////////////////////////////////////////////////////////////////
1775 // this is called from the parent group for each unparsed attribute in the attribute list
1776 void SdXMLConnectorShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
1780 case XML_NAMESPACE_DRAW
:
1782 if( IsXMLToken( rLocalName
, XML_START_SHAPE
) )
1784 maStartShapeId
= rValue
;
1787 if( IsXMLToken( rLocalName
, XML_START_GLUE_POINT
) )
1789 mnStartGlueId
= rValue
.toInt32();
1792 if( IsXMLToken( rLocalName
, XML_END_SHAPE
) )
1794 maEndShapeId
= rValue
;
1797 if( IsXMLToken( rLocalName
, XML_END_GLUE_POINT
) )
1799 mnEndGlueId
= rValue
.toInt32();
1802 if( IsXMLToken( rLocalName
, XML_LINE_SKEW
) )
1804 SvXMLTokenEnumerator
aTokenEnum( rValue
);
1806 if( aTokenEnum
.getNextToken( aToken
) )
1808 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1810 if( aTokenEnum
.getNextToken( aToken
) )
1812 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1814 if( aTokenEnum
.getNextToken( aToken
) )
1816 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1823 if( IsXMLToken( rLocalName
, XML_TYPE
) )
1825 SvXMLUnitConverter::convertEnum( mnType
, rValue
, aXML_ConnectionKind_EnumMap
);
1829 case XML_NAMESPACE_SVG
:
1831 if( IsXMLToken( rLocalName
, XML_X1
) )
1833 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1837 if( IsXMLToken( rLocalName
, XML_Y1
) )
1839 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1843 if( IsXMLToken( rLocalName
, XML_X2
) )
1845 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1849 if( IsXMLToken( rLocalName
, XML_Y2
) )
1851 GetImport().GetMM100UnitConverter().convertMeasureToCore(
1855 if( IsXMLToken( rLocalName
, XML_D
) )
1857 SdXMLImExViewBox
aViewBox( 0, 0, 1, 1 );
1858 awt::Point
aPoint( 0, 0 );
1859 awt::Size
aSize( 1, 1 );
1861 SdXMLImExSvgDElement
aPoints( rValue
, aViewBox
, aPoint
, aSize
, GetImport() );
1863 if ( aPoints
.IsCurve() )
1865 drawing::PolyPolygonBezierCoords
aSourcePolyPolygon(
1866 aPoints
.GetPointSequenceSequence(),
1867 aPoints
.GetFlagSequenceSequence());
1868 maPath
<<= aSourcePolyPolygon
;
1872 const drawing::PointSequenceSequence
& rOuterSeq
= aPoints
.GetPointSequenceSequence();
1873 drawing::FlagSequenceSequence
aFlagSeqSeq( rOuterSeq
.getLength() );
1874 for ( int a
= 0; a
< rOuterSeq
.getLength(); a
++ )
1875 aFlagSeqSeq
[ a
] = drawing::FlagSequence( rOuterSeq
[ a
].getLength() );
1877 drawing::PolyPolygonBezierCoords
aSourcePolyPolygon(
1878 aPoints
.GetPointSequenceSequence(),
1880 maPath
<<= aSourcePolyPolygon
;
1886 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
1889 //////////////////////////////////////////////////////////////////////////////
1891 void SdXMLConnectorShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
1894 // For security reasons, do not add empty connectors. There may have been an error in EA2
1895 // that created empty, far set off connectors (e.g. 63 meters below top of document). This
1896 // is not guaranteed, but it's definitely safe to not add empty connectors.
1897 sal_Bool
bDoAdd(sal_True
);
1899 if( maStartShapeId
.isEmpty()
1900 && maEndShapeId
.isEmpty()
1901 && maStart
.X
== maEnd
.X
1902 && maStart
.Y
== maEnd
.Y
1913 // create Connector shape
1914 // add, set style and properties from base shape
1915 AddShape("com.sun.star.drawing.ConnectorShape");
1918 // add connection ids
1919 if( !maStartShapeId
.isEmpty() )
1920 GetImport().GetShapeImport()->addShapeConnection( mxShape
, sal_True
, maStartShapeId
, mnStartGlueId
);
1921 if( !maEndShapeId
.isEmpty() )
1922 GetImport().GetShapeImport()->addShapeConnection( mxShape
, sal_False
, maEndShapeId
, mnEndGlueId
);
1924 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
1929 xProps
->setPropertyValue(OUString("StartPosition"), aAny
);
1932 xProps
->setPropertyValue(OUString("EndPosition"), aAny
);
1934 aAny
<<= (drawing::ConnectorType
)mnType
;
1935 xProps
->setPropertyValue(OUString("EdgeKind"), aAny
);
1938 xProps
->setPropertyValue(OUString("EdgeLine1Delta"), aAny
);
1941 xProps
->setPropertyValue(OUString("EdgeLine2Delta"), aAny
);
1944 xProps
->setPropertyValue(OUString("EdgeLine3Delta"), aAny
);
1949 if ( maPath
.hasValue() )
1952 // Ignore svg:d attribute for text documents created by OpenOffice.org
1953 // versions before OOo 3.3, because these OOo versions are storing
1954 // svg:d values not using the correct unit.
1955 bool bApplySVGD( true );
1956 if ( uno::Reference
< text::XTextDocument
>(GetImport().GetModel(), uno::UNO_QUERY
).is() )
1958 sal_Int32
nUPD( 0 );
1959 sal_Int32
nBuild( 0 );
1960 const bool bBuildIdFound
= GetImport().getBuildIds( nUPD
, nBuild
);
1961 if ( GetImport().IsTextDocInOOoFileFormat() ||
1963 ( ( nUPD
== 641 ) || ( nUPD
== 645 ) || // prior OOo 2.0
1964 ( nUPD
== 680 ) || // OOo 2.x
1965 ( nUPD
== 300 ) || // OOo 3.0 - OOo 3.0.1
1966 ( nUPD
== 310 ) || // OOo 3.1 - OOo 3.1.1
1967 ( nUPD
== 320 ) ) ) ) // OOo 3.2 - OOo 3.2.1
1975 xProps
->setPropertyValue( OUString("PolyPolygonBezier" ), maPath
);
1979 SdXMLShapeContext::StartElement(xAttrList
);
1984 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1985 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1987 TYPEINIT1( SdXMLMeasureShapeContext
, SdXMLShapeContext
);
1989 SdXMLMeasureShapeContext::SdXMLMeasureShapeContext(
1990 SvXMLImport
& rImport
,
1992 const OUString
& rLocalName
,
1993 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
1994 uno::Reference
< drawing::XShapes
>& rShapes
,
1995 sal_Bool bTemporaryShape
)
1996 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2002 //////////////////////////////////////////////////////////////////////////////
2004 SdXMLMeasureShapeContext::~SdXMLMeasureShapeContext()
2008 // this is called from the parent group for each unparsed attribute in the attribute list
2009 void SdXMLMeasureShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2013 case XML_NAMESPACE_SVG
:
2015 if( IsXMLToken( rLocalName
, XML_X1
) )
2017 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2021 if( IsXMLToken( rLocalName
, XML_Y1
) )
2023 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2027 if( IsXMLToken( rLocalName
, XML_X2
) )
2029 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2033 if( IsXMLToken( rLocalName
, XML_Y2
) )
2035 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2042 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2045 //////////////////////////////////////////////////////////////////////////////
2047 void SdXMLMeasureShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
2049 // create Measure shape
2050 // add, set style and properties from base shape
2051 AddShape("com.sun.star.drawing.MeasureShape");
2057 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
2062 xProps
->setPropertyValue(OUString("StartPosition"), aAny
);
2065 xProps
->setPropertyValue(OUString("EndPosition"), aAny
);
2068 // delete pre created fields
2069 uno::Reference
< text::XText
> xText( mxShape
, uno::UNO_QUERY
);
2072 const OUString
aEmpty( " " );
2073 xText
->setString( aEmpty
);
2076 SdXMLShapeContext::StartElement(xAttrList
);
2080 void SdXMLMeasureShapeContext::EndElement()
2084 // delete pre created fields
2085 uno::Reference
< text::XText
> xText( mxShape
, uno::UNO_QUERY
);
2089 uno::Reference
< text::XTextCursor
> xCursor( xText
->createTextCursor() );
2093 const OUString aEmpty
;
2094 xCursor
->collapseToStart();
2095 xCursor
->goRight( 1, sal_True
);
2096 xCursor
->setString( aEmpty
);
2100 SdXMLShapeContext::EndElement();
2103 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2104 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2106 TYPEINIT1( SdXMLPageShapeContext
, SdXMLShapeContext
);
2108 SdXMLPageShapeContext::SdXMLPageShapeContext(
2109 SvXMLImport
& rImport
,
2111 const OUString
& rLocalName
,
2112 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2113 uno::Reference
< drawing::XShapes
>& rShapes
,
2114 sal_Bool bTemporaryShape
)
2115 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
), mnPageNumber(0)
2117 mbClearDefaultAttributes
= false;
2120 //////////////////////////////////////////////////////////////////////////////
2122 SdXMLPageShapeContext::~SdXMLPageShapeContext()
2126 //////////////////////////////////////////////////////////////////////////////
2128 // this is called from the parent group for each unparsed attribute in the attribute list
2129 void SdXMLPageShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2131 if( XML_NAMESPACE_DRAW
== nPrefix
)
2133 if( IsXMLToken( rLocalName
, XML_PAGE_NUMBER
) )
2135 mnPageNumber
= rValue
.toInt32();
2140 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2143 //////////////////////////////////////////////////////////////////////////////
2145 void SdXMLPageShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
2147 // create Page shape
2148 // add, set style and properties from base shape
2150 // #86163# take into account which type of PageShape needs to
2151 // be constructed. It's an pres shape if presentation:XML_CLASS == XML_PRESENTATION_PAGE.
2152 sal_Bool bIsPresentation
= !maPresentationClass
.isEmpty() &&
2153 GetImport().GetShapeImport()->IsPresentationShapesSupported();
2155 uno::Reference
< lang::XServiceInfo
> xInfo( mxShapes
, uno::UNO_QUERY
);
2156 const sal_Bool bIsOnHandoutPage
= xInfo
.is() && xInfo
->supportsService( OUString( "com.sun.star.presentation.HandoutMasterPage") );
2158 if( bIsOnHandoutPage
)
2160 AddShape("com.sun.star.presentation.HandoutShape");
2164 if(bIsPresentation
&& !IsXMLToken( maPresentationClass
, XML_PRESENTATION_PAGE
) )
2166 bIsPresentation
= sal_False
;
2171 AddShape("com.sun.star.presentation.PageShape");
2175 AddShape("com.sun.star.drawing.PageShape");
2184 // set pos, size, shear and rotate
2185 SetTransformation();
2187 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
2190 uno::Reference
< beans::XPropertySetInfo
> xPropSetInfo( xPropSet
->getPropertySetInfo() );
2191 const OUString
aPageNumberStr("PageNumber");
2192 if( xPropSetInfo
.is() && xPropSetInfo
->hasPropertyByName(aPageNumberStr
))
2193 xPropSet
->setPropertyValue(aPageNumberStr
, uno::makeAny( mnPageNumber
));
2196 SdXMLShapeContext::StartElement(xAttrList
);
2200 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2201 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2203 TYPEINIT1( SdXMLCaptionShapeContext
, SdXMLShapeContext
);
2205 SdXMLCaptionShapeContext::SdXMLCaptionShapeContext(
2206 SvXMLImport
& rImport
,
2208 const OUString
& rLocalName
,
2209 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2210 uno::Reference
< drawing::XShapes
>& rShapes
,
2211 sal_Bool bTemporaryShape
)
2212 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2213 // #86616# for correct edge rounding import mnRadius needs to be initialized
2218 //////////////////////////////////////////////////////////////////////////////
2220 SdXMLCaptionShapeContext::~SdXMLCaptionShapeContext()
2224 //////////////////////////////////////////////////////////////////////////////
2226 void SdXMLCaptionShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
2228 // create Caption shape
2229 // add, set style and properties from base shape
2230 AddShape("com.sun.star.drawing.CaptionShape");
2236 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
2238 // SJ: If AutoGrowWidthItem is set, SetTransformation will lead to the wrong SnapRect
2239 // because NbcAdjustTextFrameWidthAndHeight() is called (text is set later and center alignment
2240 // is the default setting, so the top left reference point that is used by the caption point is
2241 // no longer correct) There are two ways to solve this problem, temporarily disabling the
2242 // autogrowwith as we are doing here or to apply the CaptionPoint after setting text
2243 sal_Bool bIsAutoGrowWidth
= sal_False
;
2246 uno::Any
aAny( xProps
->getPropertyValue( OUString("TextAutoGrowWidth" ) ) );
2247 aAny
>>= bIsAutoGrowWidth
;
2249 if ( bIsAutoGrowWidth
)
2250 xProps
->setPropertyValue( OUString("TextAutoGrowWidth"), uno::makeAny( sal_False
) );
2253 // set pos, size, shear and rotate
2254 SetTransformation();
2256 xProps
->setPropertyValue(OUString("CaptionPoint"), uno::makeAny( maCaptionPoint
) );
2258 if ( bIsAutoGrowWidth
)
2259 xProps
->setPropertyValue( OUString("TextAutoGrowWidth"), uno::makeAny( sal_True
) );
2263 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
2268 xPropSet
->setPropertyValue(OUString("CornerRadius"), uno::makeAny( mnRadius
) );
2270 catch(const uno::Exception
&)
2272 OSL_FAIL( "exception during setting of corner radius!");
2277 SdXMLShapeContext::StartElement(xAttrList
);
2281 // this is called from the parent group for each unparsed attribute in the attribute list
2282 void SdXMLCaptionShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2284 if( XML_NAMESPACE_DRAW
== nPrefix
)
2286 if( IsXMLToken( rLocalName
, XML_CAPTION_POINT_X
) )
2288 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2289 maCaptionPoint
.X
, rValue
);
2292 if( IsXMLToken( rLocalName
, XML_CAPTION_POINT_Y
) )
2294 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2295 maCaptionPoint
.Y
, rValue
);
2298 if( IsXMLToken( rLocalName
, XML_CORNER_RADIUS
) )
2300 GetImport().GetMM100UnitConverter().convertMeasureToCore(
2305 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2308 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2309 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2311 TYPEINIT1( SdXMLGraphicObjectShapeContext
, SdXMLShapeContext
);
2313 SdXMLGraphicObjectShapeContext::SdXMLGraphicObjectShapeContext(
2314 SvXMLImport
& rImport
,
2316 const OUString
& rLocalName
,
2317 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2318 uno::Reference
< drawing::XShapes
>& rShapes
,
2319 sal_Bool bTemporaryShape
)
2320 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2325 //////////////////////////////////////////////////////////////////////////////
2327 // this is called from the parent group for each unparsed attribute in the attribute list
2328 void SdXMLGraphicObjectShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2330 if( XML_NAMESPACE_XLINK
== nPrefix
)
2332 if( IsXMLToken( rLocalName
, XML_HREF
) )
2339 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2342 //////////////////////////////////////////////////////////////////////////////
2344 void SdXMLGraphicObjectShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& )
2346 // create graphic object shape
2347 const char *pService
;
2349 if( IsXMLToken( maPresentationClass
, XML_GRAPHIC
) && GetImport().GetShapeImport()->IsPresentationShapesSupported() )
2351 pService
= "com.sun.star.presentation.GraphicObjectShape";
2355 pService
= "com.sun.star.drawing.GraphicObjectShape";
2358 AddShape( pService
);
2365 uno::Reference
< beans::XPropertySet
> xPropset(mxShape
, uno::UNO_QUERY
);
2368 // since OOo 1.x had no line or fill style for graphics, but may create
2369 // documents with them, we have to override them here
2370 sal_Int32 nUPD
, nBuildId
;
2371 if( GetImport().getBuildIds( nUPD
, nBuildId
) && (nUPD
== 645) ) try
2373 xPropset
->setPropertyValue( OUString("FillStyle"), Any( FillStyle_NONE
) );
2374 xPropset
->setPropertyValue( OUString("LineStyle"), Any( LineStyle_NONE
) );
2376 catch(const Exception
&)
2380 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xPropset
->getPropertySetInfo() );
2381 if( xPropsInfo
.is() && xPropsInfo
->hasPropertyByName(OUString("IsEmptyPresentationObject" )))
2382 xPropset
->setPropertyValue( OUString("IsEmptyPresentationObject" ), ::cppu::bool2any( mbIsPlaceholder
) );
2384 if( !mbIsPlaceholder
)
2386 if( !maURL
.isEmpty() )
2389 aAny
<<= GetImport().ResolveGraphicObjectURL( maURL
, GetImport().isGraphicLoadOnDemandSupported() );
2392 xPropset
->setPropertyValue( OUString("GraphicURL" ), aAny
);
2393 xPropset
->setPropertyValue( OUString("GraphicStreamURL" ), aAny
);
2395 catch (const lang::IllegalArgumentException
&)
2402 if(mbIsUserTransformed
)
2404 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2407 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
2408 if( xPropsInfo
.is() )
2410 if( xPropsInfo
->hasPropertyByName(OUString("IsPlaceholderDependent" )))
2411 xProps
->setPropertyValue( OUString("IsPlaceholderDependent" ), ::cppu::bool2any( sal_False
) );
2416 // set pos, size, shear and rotate
2417 SetTransformation();
2419 SdXMLShapeContext::StartElement(mxAttrList
);
2423 void SdXMLGraphicObjectShapeContext::EndElement()
2425 if( mxBase64Stream
.is() )
2427 OUString
sURL( GetImport().ResolveGraphicObjectURLFromBase64( mxBase64Stream
) );
2428 if( !sURL
.isEmpty() )
2432 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2435 const uno::Any
aAny( uno::makeAny( sURL
) );
2436 xProps
->setPropertyValue( OUString("GraphicURL" ), aAny
);
2437 xProps
->setPropertyValue( OUString("GraphicStreamURL" ), aAny
);
2440 catch (const lang::IllegalArgumentException
&)
2446 SdXMLShapeContext::EndElement();
2450 //////////////////////////////////////////////////////////////////////////////
2452 SvXMLImportContext
* SdXMLGraphicObjectShapeContext::CreateChildContext(
2453 sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
,
2454 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
)
2456 SvXMLImportContext
* pContext
= NULL
;
2458 if( (XML_NAMESPACE_OFFICE
== nPrefix
) &&
2459 xmloff::token::IsXMLToken( rLocalName
, xmloff::token::XML_BINARY_DATA
) )
2461 if( maURL
.isEmpty() && !mxBase64Stream
.is() )
2463 mxBase64Stream
= GetImport().GetStreamForGraphicObjectURLFromBase64();
2464 if( mxBase64Stream
.is() )
2465 pContext
= new XMLBase64ImportContext( GetImport(), nPrefix
,
2466 rLocalName
, xAttrList
,
2471 // delegate to parent class if no context could be created
2472 if ( NULL
== pContext
)
2473 pContext
= SdXMLShapeContext::CreateChildContext(nPrefix
, rLocalName
,
2479 //////////////////////////////////////////////////////////////////////////////
2481 SdXMLGraphicObjectShapeContext::~SdXMLGraphicObjectShapeContext()
2486 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2487 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2489 TYPEINIT1( SdXMLChartShapeContext
, SdXMLShapeContext
);
2491 SdXMLChartShapeContext::SdXMLChartShapeContext(
2492 SvXMLImport
& rImport
,
2494 const OUString
& rLocalName
,
2495 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2496 uno::Reference
< drawing::XShapes
>& rShapes
,
2497 sal_Bool bTemporaryShape
)
2498 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2499 mpChartContext( NULL
)
2503 //////////////////////////////////////////////////////////////////////////////
2505 SdXMLChartShapeContext::~SdXMLChartShapeContext()
2507 if( mpChartContext
)
2508 delete mpChartContext
;
2511 //////////////////////////////////////////////////////////////////////////////
2513 void SdXMLChartShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
2515 const sal_Bool bIsPresentation
= isPresentationShape();
2517 AddShape( bIsPresentation
? "com.sun.star.presentation.ChartShape" : "com.sun.star.drawing.OLE2Shape" );
2524 if( !mbIsPlaceholder
)
2526 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2529 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
2530 if( xPropsInfo
.is() && xPropsInfo
->hasPropertyByName(OUString("IsEmptyPresentationObject" )))
2531 xProps
->setPropertyValue( OUString("IsEmptyPresentationObject" ), ::cppu::bool2any( sal_False
) );
2535 const OUString
aCLSID( "12DCAE26-281F-416F-a234-c3086127382e");
2538 xProps
->setPropertyValue( OUString("CLSID" ), aAny
);
2540 aAny
= xProps
->getPropertyValue( OUString("Model" ) );
2541 uno::Reference
< frame::XModel
> xChartModel
;
2542 if( aAny
>>= xChartModel
)
2544 mpChartContext
= GetImport().GetChartImport()->CreateChartContext( GetImport(), XML_NAMESPACE_SVG
, GetXMLToken(XML_CHART
), xChartModel
, xAttrList
);
2549 if(mbIsUserTransformed
)
2551 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2554 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
2555 if( xPropsInfo
.is() )
2557 if( xPropsInfo
->hasPropertyByName(OUString("IsPlaceholderDependent" )))
2558 xProps
->setPropertyValue( OUString("IsPlaceholderDependent" ), ::cppu::bool2any( sal_False
) );
2564 // set pos, size, shear and rotate
2565 SetTransformation();
2567 SdXMLShapeContext::StartElement(xAttrList
);
2569 if( mpChartContext
)
2570 mpChartContext
->StartElement( xAttrList
);
2574 void SdXMLChartShapeContext::EndElement()
2576 if( mpChartContext
)
2577 mpChartContext
->EndElement();
2579 SdXMLShapeContext::EndElement();
2582 void SdXMLChartShapeContext::Characters( const ::rtl::OUString
& rChars
)
2584 if( mpChartContext
)
2585 mpChartContext
->Characters( rChars
);
2588 SvXMLImportContext
* SdXMLChartShapeContext::CreateChildContext( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
,
2589 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
2591 if( mpChartContext
)
2592 return mpChartContext
->CreateChildContext( nPrefix
, rLocalName
, xAttrList
);
2597 //////////////////////////////////////////////////////////////////////////////
2599 TYPEINIT1( SdXMLObjectShapeContext
, SdXMLShapeContext
);
2601 SdXMLObjectShapeContext::SdXMLObjectShapeContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
2602 const rtl::OUString
& rLocalName
,
2603 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2604 com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
>& rShapes
,
2605 sal_Bool bTemporaryShape
)
2606 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
)
2610 SdXMLObjectShapeContext::~SdXMLObjectShapeContext()
2614 void SdXMLObjectShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& )
2616 // #96717# in theorie, if we don't have a url we shouldn't even
2617 // export this ole shape. But practical its to risky right now
2618 // to change this so we better dispose this on load
2619 //if( !mbIsPlaceholder && ImpIsEmptyURL(maHref) )
2622 // #100592# this BugFix prevents that a shape is created. CL
2623 // is thinking about an alternative.
2624 // #i13140# Check for more than empty string in maHref, there are
2625 // other possibilities that maHref results in empty container
2627 if( !(GetImport().getImportFlags() & IMPORT_EMBEDDED
) && !mbIsPlaceholder
&& ImpIsEmptyURL(maHref
) )
2630 const char* pService
= "com.sun.star.drawing.OLE2Shape";
2632 sal_Bool bIsPresShape
= !maPresentationClass
.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
2636 if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_CHART
) )
2638 pService
= "com.sun.star.presentation.ChartShape";
2640 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_TABLE
) )
2642 pService
= "com.sun.star.presentation.CalcShape";
2644 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_OBJECT
) )
2646 pService
= "com.sun.star.presentation.OLE2Shape";
2650 AddShape( pService
);
2658 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2661 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
2662 if( xPropsInfo
.is() )
2664 if( !mbIsPlaceholder
&& xPropsInfo
->hasPropertyByName(OUString("IsEmptyPresentationObject" )))
2665 xProps
->setPropertyValue( OUString("IsEmptyPresentationObject" ), ::cppu::bool2any( sal_False
) );
2667 if( mbIsUserTransformed
&& xPropsInfo
->hasPropertyByName(OUString("IsPlaceholderDependent" )))
2668 xProps
->setPropertyValue( OUString("IsPlaceholderDependent" ), ::cppu::bool2any( sal_False
) );
2673 if( !mbIsPlaceholder
&& !maHref
.isEmpty() )
2675 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
2679 OUString aPersistName
= GetImport().ResolveEmbeddedObjectURL( maHref
, maCLSID
);
2681 if ( GetImport().IsPackageURL( maHref
) )
2683 const OUString
sURL( "vnd.sun.star.EmbeddedObject:" );
2685 if ( aPersistName
.compareTo( sURL
, sURL
.getLength() ) == 0 )
2686 aPersistName
= aPersistName
.copy( sURL
.getLength() );
2688 xProps
->setPropertyValue( OUString( "PersistName" ),
2689 uno::makeAny( aPersistName
) );
2693 // this is OOo link object
2694 xProps
->setPropertyValue( OUString( "LinkURL" ),
2695 uno::makeAny( aPersistName
) );
2700 // set pos, size, shear and rotate
2701 SetTransformation();
2705 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
2709 void SdXMLObjectShapeContext::EndElement()
2712 if( mxBase64Stream
.is() )
2714 OUString
aPersistName( GetImport().ResolveEmbeddedObjectURLFromBase64() );
2715 const OUString
sURL( "vnd.sun.star.EmbeddedObject:" );
2717 aPersistName
= aPersistName
.copy( sURL
.getLength() );
2719 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
2721 xProps
->setPropertyValue( OUString( "PersistName" ), uno::makeAny( aPersistName
) );
2724 SdXMLShapeContext::EndElement();
2727 // this is called from the parent group for each unparsed attribute in the attribute list
2728 void SdXMLObjectShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2732 case XML_NAMESPACE_DRAW
:
2733 if( IsXMLToken( rLocalName
, XML_CLASS_ID
) )
2739 case XML_NAMESPACE_XLINK
:
2740 if( IsXMLToken( rLocalName
, XML_HREF
) )
2748 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2751 SvXMLImportContext
* SdXMLObjectShapeContext::CreateChildContext(
2752 sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
,
2753 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
)
2756 SvXMLImportContext
* pContext
= NULL
;
2758 if((XML_NAMESPACE_OFFICE
== nPrefix
) && IsXMLToken(rLocalName
, XML_BINARY_DATA
))
2760 mxBase64Stream
= GetImport().GetStreamForEmbeddedObjectURLFromBase64();
2761 if( mxBase64Stream
.is() )
2762 pContext
= new XMLBase64ImportContext( GetImport(), nPrefix
,
2763 rLocalName
, xAttrList
,
2766 else if( ((XML_NAMESPACE_OFFICE
== nPrefix
) && IsXMLToken(rLocalName
, XML_DOCUMENT
)) ||
2767 ((XML_NAMESPACE_MATH
== nPrefix
) && IsXMLToken(rLocalName
, XML_MATH
)) )
2769 XMLEmbeddedObjectImportContext
*pEContext
=
2770 new XMLEmbeddedObjectImportContext( GetImport(), nPrefix
,
2771 rLocalName
, xAttrList
);
2772 maCLSID
= pEContext
->GetFilterCLSID();
2773 if( !maCLSID
.isEmpty() )
2775 uno::Reference
< beans::XPropertySet
> xPropSet(mxShape
, uno::UNO_QUERY
);
2778 xPropSet
->setPropertyValue( OUString("CLSID" ), uno::makeAny( maCLSID
) );
2780 uno::Reference
< lang::XComponent
> xComp
;
2781 xPropSet
->getPropertyValue( OUString("Model" ) ) >>= xComp
;
2782 DBG_ASSERT( xComp
.is(), "no xModel for own OLE format" );
2783 pEContext
->SetComponent( xComp
);
2786 pContext
= pEContext
;
2789 // delegate to parent class if no context could be created
2791 pContext
= SdXMLShapeContext::CreateChildContext(nPrefix
, rLocalName
, xAttrList
);
2796 //////////////////////////////////////////////////////////////////////////////
2798 TYPEINIT1( SdXMLAppletShapeContext
, SdXMLShapeContext
);
2800 SdXMLAppletShapeContext::SdXMLAppletShapeContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
2801 const rtl::OUString
& rLocalName
,
2802 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2803 com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
>& rShapes
,
2804 sal_Bool bTemporaryShape
)
2805 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2806 mbIsScript( sal_False
)
2810 SdXMLAppletShapeContext::~SdXMLAppletShapeContext()
2814 void SdXMLAppletShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& )
2816 const char* pService
= "com.sun.star.drawing.AppletShape";
2817 AddShape( pService
);
2823 // set pos, size, shear and rotate
2824 SetTransformation();
2825 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
2829 // this is called from the parent group for each unparsed attribute in the attribute list
2830 void SdXMLAppletShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
2834 case XML_NAMESPACE_DRAW
:
2835 if( IsXMLToken( rLocalName
, XML_APPLET_NAME
) )
2837 maAppletName
= rValue
;
2840 if( IsXMLToken( rLocalName
, XML_CODE
) )
2842 maAppletCode
= rValue
;
2845 if( IsXMLToken( rLocalName
, XML_MAY_SCRIPT
) )
2847 mbIsScript
= IsXMLToken( rValue
, XML_TRUE
);
2851 case XML_NAMESPACE_XLINK
:
2852 if( IsXMLToken( rLocalName
, XML_HREF
) )
2854 maHref
= GetImport().GetAbsoluteReference(rValue
);
2860 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
2863 void SdXMLAppletShapeContext::EndElement()
2865 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
2870 if ( maSize
.Width
&& maSize
.Height
)
2872 // the visual area for applet must be set on loading
2873 awt::Rectangle
aRect( 0, 0, maSize
.Width
, maSize
.Height
);
2875 xProps
->setPropertyValue( OUString( "VisibleArea" ), aAny
);
2878 if( maParams
.getLength() )
2881 xProps
->setPropertyValue( OUString( "AppletCommands" ), aAny
);
2884 if( !maHref
.isEmpty() )
2887 xProps
->setPropertyValue( OUString( "AppletCodeBase" ), aAny
);
2890 if( !maAppletName
.isEmpty() )
2892 aAny
<<= maAppletName
;
2893 xProps
->setPropertyValue( OUString( "AppletName" ), aAny
);
2898 aAny
<<= mbIsScript
;
2899 xProps
->setPropertyValue( OUString( "AppletIsScript" ), aAny
);
2903 if( !maAppletCode
.isEmpty() )
2905 aAny
<<= maAppletCode
;
2906 xProps
->setPropertyValue( OUString( "AppletCode" ), aAny
);
2909 aAny
<<= ::rtl::OUString( GetImport().GetDocumentBase() );
2910 xProps
->setPropertyValue( OUString( "AppletDocBase" ), aAny
);
2915 SdXMLShapeContext::EndElement();
2918 SvXMLImportContext
* SdXMLAppletShapeContext::CreateChildContext( sal_uInt16 p_nPrefix
, const ::rtl::OUString
& rLocalName
, const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
2920 if( p_nPrefix
== XML_NAMESPACE_DRAW
&& IsXMLToken( rLocalName
, XML_PARAM
) )
2922 OUString aParamName
, aParamValue
;
2923 const sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
2924 // now parse the attribute list and look for draw:name and draw:value
2925 for(sal_Int16
a(0); a
< nAttrCount
; a
++)
2927 const OUString
& rAttrName
= xAttrList
->getNameByIndex(a
);
2928 OUString aLocalName
;
2929 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName
, &aLocalName
);
2930 const OUString
aValue( xAttrList
->getValueByIndex(a
) );
2932 if( nPrefix
== XML_NAMESPACE_DRAW
)
2934 if( IsXMLToken( aLocalName
, XML_NAME
) )
2936 aParamName
= aValue
;
2938 else if( IsXMLToken( aLocalName
, XML_VALUE
) )
2940 aParamValue
= aValue
;
2945 if( !aParamName
.isEmpty() )
2947 sal_Int32 nIndex
= maParams
.getLength();
2948 maParams
.realloc( nIndex
+ 1 );
2949 maParams
[nIndex
].Name
= aParamName
;
2950 maParams
[nIndex
].Handle
= -1;
2951 maParams
[nIndex
].Value
<<= aParamValue
;
2952 maParams
[nIndex
].State
= beans::PropertyState_DIRECT_VALUE
;
2955 return new SvXMLImportContext( GetImport(), p_nPrefix
, rLocalName
);
2958 return SdXMLShapeContext::CreateChildContext( p_nPrefix
, rLocalName
, xAttrList
);
2961 //////////////////////////////////////////////////////////////////////////////
2963 TYPEINIT1( SdXMLPluginShapeContext
, SdXMLShapeContext
);
2965 SdXMLPluginShapeContext::SdXMLPluginShapeContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
2966 const rtl::OUString
& rLocalName
,
2967 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
2968 com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
>& rShapes
,
2969 sal_Bool bTemporaryShape
) :
2970 SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
2975 SdXMLPluginShapeContext::~SdXMLPluginShapeContext()
2979 void SdXMLPluginShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
2981 // watch for MimeType attribute to see if we have a media object
2982 for( sal_Int16 n
= 0, nAttrCount
= ( xAttrList
.is() ? xAttrList
->getLength() : 0 ); n
< nAttrCount
; ++n
)
2984 OUString aLocalName
;
2985 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList
->getNameByIndex( n
), &aLocalName
);
2987 if( nPrefix
== XML_NAMESPACE_DRAW
&& IsXMLToken( aLocalName
, XML_MIME_TYPE
) )
2989 if( 0 == xAttrList
->getValueByIndex( n
).compareToAscii( "application/vnd.sun.star.media" ) )
2997 const char* pService
;
2999 sal_Bool bIsPresShape
= sal_False
;
3003 pService
= "com.sun.star.drawing.MediaShape";
3005 bIsPresShape
= !maPresentationClass
.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
3008 if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_OBJECT
) )
3010 pService
= "com.sun.star.presentation.MediaShape";
3015 pService
= "com.sun.star.drawing.PluginShape";
3017 AddShape( pService
);
3025 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
3028 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
3029 if( xPropsInfo
.is() )
3031 if( !mbIsPlaceholder
&& xPropsInfo
->hasPropertyByName(OUString("IsEmptyPresentationObject" )))
3032 xProps
->setPropertyValue( OUString("IsEmptyPresentationObject" ), ::cppu::bool2any( sal_False
) );
3034 if( mbIsUserTransformed
&& xPropsInfo
->hasPropertyByName(OUString("IsPlaceholderDependent" )))
3035 xProps
->setPropertyValue( OUString("IsPlaceholderDependent" ), ::cppu::bool2any( sal_False
) );
3040 // set pos, size, shear and rotate
3041 SetTransformation();
3042 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
3046 static ::rtl::OUString
3047 lcl_GetMediaReference(SvXMLImport
const& rImport
, ::rtl::OUString
const& rURL
)
3049 if (rImport
.IsPackageURL(rURL
))
3051 return ::rtl::OUString( "vnd.sun.star.Package:") + rURL
;
3055 return rImport
.GetAbsoluteReference(rURL
);
3059 // this is called from the parent group for each unparsed attribute in the attribute list
3060 void SdXMLPluginShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
3064 case XML_NAMESPACE_DRAW
:
3065 if( IsXMLToken( rLocalName
, XML_MIME_TYPE
) )
3067 maMimeType
= rValue
;
3071 case XML_NAMESPACE_XLINK
:
3072 if( IsXMLToken( rLocalName
, XML_HREF
) )
3074 maHref
= lcl_GetMediaReference(GetImport(), rValue
);
3080 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
3083 void SdXMLPluginShapeContext::EndElement()
3085 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
3091 if ( maSize
.Width
&& maSize
.Height
)
3093 const rtl::OUString
sVisibleArea( "VisibleArea" );
3094 uno::Reference
< beans::XPropertySetInfo
> aXPropSetInfo( xProps
->getPropertySetInfo() );
3095 if ( !aXPropSetInfo
.is() || aXPropSetInfo
->hasPropertyByName( sVisibleArea
) )
3097 // the visual area for a plugin must be set on loading
3098 awt::Rectangle
aRect( 0, 0, maSize
.Width
, maSize
.Height
);
3100 xProps
->setPropertyValue( sVisibleArea
, aAny
);
3106 // in case we have a plugin object
3107 if( maParams
.getLength() )
3110 xProps
->setPropertyValue( OUString( "PluginCommands" ), aAny
);
3113 if( !maMimeType
.isEmpty() )
3115 aAny
<<= maMimeType
;
3116 xProps
->setPropertyValue( OUString( "PluginMimeType" ), aAny
);
3119 if( !maHref
.isEmpty() )
3122 xProps
->setPropertyValue( OUString( "PluginURL" ), aAny
);
3127 // in case we have a media object
3128 xProps
->setPropertyValue(
3129 OUString("MediaURL"),
3130 uno::makeAny(maHref
));
3132 for( sal_Int32 nParam
= 0; nParam
< maParams
.getLength(); ++nParam
)
3134 const OUString
& rName
= maParams
[ nParam
].Name
;
3136 if( 0 == rName
.compareToAscii( "Loop" ) )
3139 maParams
[ nParam
].Value
>>= aValueStr
;
3140 xProps
->setPropertyValue( OUString( "Loop" ),
3141 uno::makeAny( static_cast< sal_Bool
>( 0 == aValueStr
.compareToAscii( "true" ) ) ) );
3143 else if( 0 == rName
.compareToAscii( "Mute" ) )
3146 maParams
[ nParam
].Value
>>= aValueStr
;
3147 xProps
->setPropertyValue( OUString( "Mute" ),
3148 uno::makeAny( static_cast< sal_Bool
>( 0 == aValueStr
.compareToAscii( "true" ) ) ) );
3150 else if( 0 == rName
.compareToAscii( "VolumeDB" ) )
3153 maParams
[ nParam
].Value
>>= aValueStr
;
3154 xProps
->setPropertyValue( OUString( "VolumeDB" ),
3155 uno::makeAny( static_cast< sal_Int16
>( aValueStr
.toInt32() ) ) );
3157 else if( 0 == rName
.compareToAscii( "Zoom" ) )
3160 media::ZoomLevel eZoomLevel
;
3162 maParams
[ nParam
].Value
>>= aZoomStr
;
3164 if( 0 == aZoomStr
.compareToAscii( "25%" ) )
3165 eZoomLevel
= media::ZoomLevel_ZOOM_1_TO_4
;
3166 else if( 0 == aZoomStr
.compareToAscii( "50%" ) )
3167 eZoomLevel
= media::ZoomLevel_ZOOM_1_TO_2
;
3168 else if( 0 == aZoomStr
.compareToAscii( "100%" ) )
3169 eZoomLevel
= media::ZoomLevel_ORIGINAL
;
3170 else if( 0 == aZoomStr
.compareToAscii( "200%" ) )
3171 eZoomLevel
= media::ZoomLevel_ZOOM_2_TO_1
;
3172 else if( 0 == aZoomStr
.compareToAscii( "400%" ) )
3173 eZoomLevel
= media::ZoomLevel_ZOOM_4_TO_1
;
3174 else if( 0 == aZoomStr
.compareToAscii( "fit" ) )
3175 eZoomLevel
= media::ZoomLevel_FIT_TO_WINDOW
;
3176 else if( 0 == aZoomStr
.compareToAscii( "fixedfit" ) )
3177 eZoomLevel
= media::ZoomLevel_FIT_TO_WINDOW_FIXED_ASPECT
;
3178 else if( 0 == aZoomStr
.compareToAscii( "fullscreen" ) )
3179 eZoomLevel
= media::ZoomLevel_FULLSCREEN
;
3181 eZoomLevel
= media::ZoomLevel_NOT_AVAILABLE
;
3183 xProps
->setPropertyValue( OUString( "Zoom" ), uno::makeAny( eZoomLevel
) );
3191 SdXMLShapeContext::EndElement();
3194 SvXMLImportContext
* SdXMLPluginShapeContext::CreateChildContext( sal_uInt16 p_nPrefix
, const ::rtl::OUString
& rLocalName
, const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
3196 if( p_nPrefix
== XML_NAMESPACE_DRAW
&& IsXMLToken( rLocalName
, XML_PARAM
) )
3198 OUString aParamName
, aParamValue
;
3199 const sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
3200 // now parse the attribute list and look for draw:name and draw:value
3201 for(sal_Int16
a(0); a
< nAttrCount
; a
++)
3203 const OUString
& rAttrName
= xAttrList
->getNameByIndex(a
);
3204 OUString aLocalName
;
3205 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName(rAttrName
, &aLocalName
);
3206 const OUString
aValue( xAttrList
->getValueByIndex(a
) );
3208 if( nPrefix
== XML_NAMESPACE_DRAW
)
3210 if( IsXMLToken( aLocalName
, XML_NAME
) )
3212 aParamName
= aValue
;
3214 else if( IsXMLToken( aLocalName
, XML_VALUE
) )
3216 aParamValue
= aValue
;
3220 if( !aParamName
.isEmpty() )
3222 sal_Int32 nIndex
= maParams
.getLength();
3223 maParams
.realloc( nIndex
+ 1 );
3224 maParams
[nIndex
].Name
= aParamName
;
3225 maParams
[nIndex
].Handle
= -1;
3226 maParams
[nIndex
].Value
<<= aParamValue
;
3227 maParams
[nIndex
].State
= beans::PropertyState_DIRECT_VALUE
;
3231 return new SvXMLImportContext( GetImport(), p_nPrefix
, rLocalName
);
3234 return SdXMLShapeContext::CreateChildContext( p_nPrefix
, rLocalName
, xAttrList
);
3237 //////////////////////////////////////////////////////////////////////////////
3239 TYPEINIT1( SdXMLFloatingFrameShapeContext
, SdXMLShapeContext
);
3241 SdXMLFloatingFrameShapeContext::SdXMLFloatingFrameShapeContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
3242 const rtl::OUString
& rLocalName
,
3243 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
3244 com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
>& rShapes
,
3245 sal_Bool bTemporaryShape
)
3246 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
)
3250 SdXMLFloatingFrameShapeContext::~SdXMLFloatingFrameShapeContext()
3254 void SdXMLFloatingFrameShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& )
3256 const char* pService
= "com.sun.star.drawing.FrameShape";
3257 AddShape( pService
);
3263 // set pos, size, shear and rotate
3264 SetTransformation();
3266 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
3271 if( !maFrameName
.isEmpty() )
3273 aAny
<<= maFrameName
;
3274 xProps
->setPropertyValue( OUString( "FrameName" ), aAny
);
3277 if( !maHref
.isEmpty() )
3280 xProps
->setPropertyValue( OUString( "FrameURL" ), aAny
);
3286 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
3290 // this is called from the parent group for each unparsed attribute in the attribute list
3291 void SdXMLFloatingFrameShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
3295 case XML_NAMESPACE_DRAW
:
3296 if( IsXMLToken( rLocalName
, XML_FRAME_NAME
) )
3298 maFrameName
= rValue
;
3302 case XML_NAMESPACE_XLINK
:
3303 if( IsXMLToken( rLocalName
, XML_HREF
) )
3305 maHref
= GetImport().GetAbsoluteReference(rValue
);
3311 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
3314 void SdXMLFloatingFrameShapeContext::EndElement()
3316 uno::Reference
< beans::XPropertySet
> xProps( mxShape
, uno::UNO_QUERY
);
3320 if ( maSize
.Width
&& maSize
.Height
)
3322 // the visual area for a floating frame must be set on loading
3323 awt::Rectangle
aRect( 0, 0, maSize
.Width
, maSize
.Height
);
3326 xProps
->setPropertyValue( OUString( "VisibleArea" ), aAny
);
3331 SdXMLShapeContext::EndElement();
3334 //////////////////////////////////////////////////////////////////////////////
3336 TYPEINIT1( SdXMLFrameShapeContext
, SdXMLShapeContext
);
3338 SdXMLFrameShapeContext::SdXMLFrameShapeContext( SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
3339 const rtl::OUString
& rLocalName
,
3340 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
3341 com::sun::star::uno::Reference
< com::sun::star::drawing::XShapes
>& rShapes
,
3342 sal_Bool bTemporaryShape
)
3343 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
),
3344 mbSupportsReplacement( sal_False
)
3346 uno::Reference
< util::XCloneable
> xClone( xAttrList
, uno::UNO_QUERY
);
3348 mxAttrList
.set( xClone
->createClone(), uno::UNO_QUERY
);
3350 mxAttrList
= new SvXMLAttributeList( xAttrList
);
3354 SdXMLFrameShapeContext::~SdXMLFrameShapeContext()
3358 SvXMLImportContext
*SdXMLFrameShapeContext::CreateChildContext( sal_uInt16 nPrefix
,
3359 const OUString
& rLocalName
,
3360 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
3362 SvXMLImportContext
* pContext
= 0;
3364 if( !mxImplContext
.Is() )
3367 SvXMLShapeContext
* pShapeContext
= GetImport().GetShapeImport()->CreateFrameChildContext(
3368 GetImport(), nPrefix
, rLocalName
, xAttrList
, mxShapes
, mxAttrList
);
3370 pContext
= pShapeContext
;
3372 // propagate the hyperlink to child context
3373 if ( !msHyperlink
.isEmpty() )
3374 pShapeContext
->setHyperlink( msHyperlink
);
3376 mxImplContext
= pContext
;
3377 mbSupportsReplacement
= IsXMLToken( rLocalName
, XML_OBJECT
) ||
3378 IsXMLToken( rLocalName
, XML_OBJECT_OLE
);
3380 else if( mbSupportsReplacement
&& !mxReplImplContext
&&
3381 XML_NAMESPACE_DRAW
== nPrefix
&&
3382 IsXMLToken( rLocalName
, XML_IMAGE
) )
3384 // read replacement image
3385 SvXMLImportContext
*pImplContext
= &mxImplContext
;
3386 SdXMLShapeContext
*pSContext
=
3387 PTR_CAST( SdXMLShapeContext
, pImplContext
);
3390 uno::Reference
< beans::XPropertySet
> xPropSet(
3391 pSContext
->getShape(), uno::UNO_QUERY
);
3394 pContext
= new XMLReplacementImageContext( GetImport(),
3395 nPrefix
, rLocalName
, xAttrList
, xPropSet
);
3396 mxReplImplContext
= pContext
;
3401 ( nPrefix
== XML_NAMESPACE_SVG
&& // #i68101#
3402 (IsXMLToken( rLocalName
, XML_TITLE
) || IsXMLToken( rLocalName
, XML_DESC
) ) ) ||
3403 (nPrefix
== XML_NAMESPACE_OFFICE
&& IsXMLToken( rLocalName
, XML_EVENT_LISTENERS
) ) ||
3404 (nPrefix
== XML_NAMESPACE_DRAW
&& (IsXMLToken( rLocalName
, XML_GLUE_POINT
) ||
3405 IsXMLToken( rLocalName
, XML_THUMBNAIL
) ) ) )
3407 SvXMLImportContext
*pImplContext
= &mxImplContext
;
3408 pContext
= PTR_CAST( SdXMLShapeContext
, pImplContext
)->CreateChildContext( nPrefix
,
3409 rLocalName
, xAttrList
);
3411 else if ( (XML_NAMESPACE_DRAW
== nPrefix
) && IsXMLToken( rLocalName
, XML_IMAGE_MAP
) )
3413 SdXMLShapeContext
*pSContext
= dynamic_cast< SdXMLShapeContext
* >( &mxImplContext
);
3416 uno::Reference
< beans::XPropertySet
> xPropSet( pSContext
->getShape(), uno::UNO_QUERY
);
3419 pContext
= new XMLImageMapContext(GetImport(), nPrefix
, rLocalName
, xPropSet
);
3424 // call parent for content
3426 pContext
= SvXMLImportContext::CreateChildContext( nPrefix
, rLocalName
, xAttrList
);
3431 void SdXMLFrameShapeContext::StartElement(const uno::Reference
< xml::sax::XAttributeList
>&)
3436 void SdXMLFrameShapeContext::EndElement()
3438 if( !mxImplContext
.Is() )
3440 // now check if this is an empty presentation object
3441 sal_Int16 nAttrCount
= mxAttrList
.is() ? mxAttrList
->getLength() : 0;
3442 for(sal_Int16
a(0); a
< nAttrCount
; a
++)
3444 OUString aLocalName
;
3445 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName(mxAttrList
->getNameByIndex(a
), &aLocalName
);
3447 if( nPrefix
== XML_NAMESPACE_PRESENTATION
)
3449 if( IsXMLToken( aLocalName
, XML_PLACEHOLDER
) )
3451 mbIsPlaceholder
= IsXMLToken( mxAttrList
->getValueByIndex(a
), XML_TRUE
);
3453 else if( IsXMLToken( aLocalName
, XML_CLASS
) )
3455 maPresentationClass
= mxAttrList
->getValueByIndex(a
);
3460 if( (!maPresentationClass
.isEmpty()) && mbIsPlaceholder
)
3462 uno::Reference
< xml::sax::XAttributeList
> xEmpty
;
3464 enum XMLTokenEnum eToken
= XML_TEXT_BOX
;
3466 if( IsXMLToken( maPresentationClass
, XML_GRAPHIC
) )
3471 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_PAGE
) )
3473 eToken
= XML_PAGE_THUMBNAIL
;
3475 else if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_CHART
) ||
3476 IsXMLToken( maPresentationClass
, XML_PRESENTATION_TABLE
) ||
3477 IsXMLToken( maPresentationClass
, XML_PRESENTATION_OBJECT
) )
3479 eToken
= XML_OBJECT
;
3482 mxImplContext
= GetImport().GetShapeImport()->CreateFrameChildContext(
3483 GetImport(), XML_NAMESPACE_DRAW
, GetXMLToken( eToken
), mxAttrList
, mxShapes
, xEmpty
);
3485 if( mxImplContext
.Is() )
3487 mxImplContext
->StartElement( mxAttrList
);
3488 mxImplContext
->EndElement();
3494 SdXMLShapeContext::EndElement();
3497 void SdXMLFrameShapeContext::processAttribute( sal_uInt16
,
3498 const ::rtl::OUString
&, const ::rtl::OUString
& )
3503 TYPEINIT1( SdXMLCustomShapeContext
, SdXMLShapeContext
);
3505 SdXMLCustomShapeContext::SdXMLCustomShapeContext(
3506 SvXMLImport
& rImport
,
3508 const OUString
& rLocalName
,
3509 const com::sun::star::uno::Reference
< com::sun::star::xml::sax::XAttributeList
>& xAttrList
,
3510 uno::Reference
< drawing::XShapes
>& rShapes
,
3511 sal_Bool bTemporaryShape
)
3512 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, bTemporaryShape
)
3516 //////////////////////////////////////////////////////////////////////////////
3518 SdXMLCustomShapeContext::~SdXMLCustomShapeContext()
3522 //////////////////////////////////////////////////////////////////////////////
3524 // this is called from the parent group for each unparsed attribute in the attribute list
3525 void SdXMLCustomShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
3527 if( XML_NAMESPACE_DRAW
== nPrefix
)
3529 if( IsXMLToken( rLocalName
, XML_ENGINE
) )
3531 maCustomShapeEngine
= rValue
;
3534 if ( IsXMLToken( rLocalName
, XML_DATA
) )
3536 maCustomShapeData
= rValue
;
3540 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
3543 //////////////////////////////////////////////////////////////////////////////
3545 void SdXMLCustomShapeContext::StartElement( const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
3547 // create rectangle shape
3548 AddShape("com.sun.star.drawing.CustomShape");
3551 // Add, set Style and properties from base shape
3555 // set pos, size, shear and rotate
3556 SetTransformation();
3560 uno::Reference
< beans::XPropertySet
> xPropSet( mxShape
, uno::UNO_QUERY
);
3563 if ( !maCustomShapeEngine
.isEmpty() )
3566 aAny
<<= maCustomShapeEngine
;
3567 xPropSet
->setPropertyValue( EASGet( EAS_CustomShapeEngine
), aAny
);
3569 if ( !maCustomShapeData
.isEmpty() )
3572 aAny
<<= maCustomShapeData
;
3573 xPropSet
->setPropertyValue( EASGet( EAS_CustomShapeData
), aAny
);
3577 catch(const uno::Exception
&)
3579 OSL_FAIL( "could not set enhanced customshape geometry" );
3581 SdXMLShapeContext::StartElement(xAttrList
);
3585 void SdXMLCustomShapeContext::EndElement()
3587 if ( !maCustomShapeGeometry
.empty() )
3589 const rtl::OUString
sCustomShapeGeometry ( "CustomShapeGeometry" );
3591 // converting the vector to a sequence
3592 uno::Sequence
< beans::PropertyValue
> aSeq( maCustomShapeGeometry
.size() );
3593 beans::PropertyValue
* pValues
= aSeq
.getArray();
3594 std::vector
< beans::PropertyValue
>::const_iterator
aIter( maCustomShapeGeometry
.begin() );
3595 std::vector
< beans::PropertyValue
>::const_iterator
aEnd( maCustomShapeGeometry
.end() );
3596 while ( aIter
!= aEnd
)
3597 *pValues
++ = *aIter
++;
3601 uno::Reference
< beans::XPropertySet
> xPropSet( mxShape
, uno::UNO_QUERY
);
3606 xPropSet
->setPropertyValue( sCustomShapeGeometry
, aAny
);
3609 catch(const uno::Exception
&)
3611 OSL_FAIL( "could not set enhanced customshape geometry" );
3614 sal_Int32
nUPD( 0 );
3615 sal_Int32
nBuild( 0 );
3616 GetImport().getBuildIds( nUPD
, nBuild
);
3617 if( ((nUPD
>= 640 && nUPD
<= 645) || (nUPD
== 680)) && (nBuild
<= 9221) )
3619 Reference
< drawing::XEnhancedCustomShapeDefaulter
> xDefaulter( mxShape
, UNO_QUERY
);
3620 if( xDefaulter
.is() )
3622 rtl::OUString aEmptyType
;
3623 xDefaulter
->createCustomShapeDefaults( aEmptyType
);
3628 SdXMLShapeContext::EndElement();
3631 //////////////////////////////////////////////////////////////////////////////
3633 SvXMLImportContext
* SdXMLCustomShapeContext::CreateChildContext(
3634 sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
,
3635 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
)
3637 SvXMLImportContext
* pContext
= NULL
;
3638 if ( XML_NAMESPACE_DRAW
== nPrefix
)
3640 if ( IsXMLToken( rLocalName
, XML_ENHANCED_GEOMETRY
) )
3642 uno::Reference
< beans::XPropertySet
> xPropSet( mxShape
,uno::UNO_QUERY
);
3643 if ( xPropSet
.is() )
3644 pContext
= new XMLEnhancedCustomShapeContext( GetImport(), mxShape
, nPrefix
, rLocalName
, maCustomShapeGeometry
);
3647 // delegate to parent class if no context could be created
3648 if ( NULL
== pContext
)
3649 pContext
= SdXMLShapeContext::CreateChildContext( nPrefix
, rLocalName
,
3654 ///////////////////////////////////////////////////////////////////////
3656 //////////////////////////////////////////////////////////////////////////////
3658 TYPEINIT1( SdXMLTableShapeContext
, SdXMLShapeContext
);
3660 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
)
3661 : SdXMLShapeContext( rImport
, nPrfx
, rLocalName
, xAttrList
, rShapes
, sal_False
)
3663 memset( &maTemplateStylesUsed
, 0, sizeof( maTemplateStylesUsed
) );
3666 SdXMLTableShapeContext::~SdXMLTableShapeContext()
3670 void SdXMLTableShapeContext::StartElement( const ::com::sun::star::uno::Reference
< ::com::sun::star::xml::sax::XAttributeList
>& xAttrList
)
3672 const char* pService
= "com.sun.star.drawing.TableShape";
3674 sal_Bool bIsPresShape
= !maPresentationClass
.isEmpty() && GetImport().GetShapeImport()->IsPresentationShapesSupported();
3677 if( IsXMLToken( maPresentationClass
, XML_PRESENTATION_TABLE
) )
3679 pService
= "com.sun.star.presentation.TableShape";
3683 AddShape( pService
);
3689 uno::Reference
< beans::XPropertySet
> xProps(mxShape
, uno::UNO_QUERY
);
3695 uno::Reference
< beans::XPropertySetInfo
> xPropsInfo( xProps
->getPropertySetInfo() );
3696 if( xPropsInfo
.is() )
3698 if( !mbIsPlaceholder
&& xPropsInfo
->hasPropertyByName(OUString("IsEmptyPresentationObject" )))
3699 xProps
->setPropertyValue( OUString("IsEmptyPresentationObject" ), ::cppu::bool2any( sal_False
) );
3701 if( mbIsUserTransformed
&& xPropsInfo
->hasPropertyByName(OUString("IsPlaceholderDependent" )))
3702 xProps
->setPropertyValue( OUString("IsPlaceholderDependent" ), ::cppu::bool2any( sal_False
) );
3711 if( !msTemplateStyleName
.isEmpty() ) try
3713 Reference
< XStyleFamiliesSupplier
> xFamiliesSupp( GetImport().GetModel(), UNO_QUERY_THROW
);
3714 Reference
< XNameAccess
> xFamilies( xFamiliesSupp
->getStyleFamilies() );
3715 const OUString
sFamilyName( "table" );
3716 Reference
< XNameAccess
> xTableFamily( xFamilies
->getByName( sFamilyName
), UNO_QUERY_THROW
);
3717 Reference
< XStyle
> xTableStyle( xTableFamily
->getByName( msTemplateStyleName
), UNO_QUERY_THROW
);
3718 xProps
->setPropertyValue( OUString( "TableTemplate" ), Any( xTableStyle
) );
3720 catch(const Exception
&)
3722 OSL_FAIL("SdXMLTableShapeContext::StartElement(), exception caught!");
3725 const XMLPropertyMapEntry
* pEntry
= &aXMLTableShapeAttributes
[0];
3726 for( int i
= 0; pEntry
->msApiName
&& (i
< 6); i
++, pEntry
++ )
3730 const OUString
sAPIPropertyName( OUString(pEntry
->msApiName
, pEntry
->nApiNameLength
, RTL_TEXTENCODING_ASCII_US
) );
3731 xProps
->setPropertyValue( sAPIPropertyName
, Any( maTemplateStylesUsed
[i
] ) );
3733 catch(const Exception
&)
3735 OSL_FAIL("SdXMLTableShapeContext::StartElement(), exception caught!");
3740 GetImport().GetShapeImport()->finishShape( mxShape
, mxAttrList
, mxShapes
);
3742 const rtl::Reference
< XMLTableImport
>& xTableImport( GetImport().GetShapeImport()->GetShapeTableImport() );
3743 if( xTableImport
.is() && xProps
.is() )
3745 uno::Reference
< table::XColumnRowRange
> xColumnRowRange(
3746 xProps
->getPropertyValue( OUString("Model" ) ), uno::UNO_QUERY
);
3748 if( xColumnRowRange
.is() )
3749 mxTableImportContext
= xTableImport
->CreateTableContext( GetPrefix(), GetLocalName(), xColumnRowRange
);
3751 if( mxTableImportContext
.Is() )
3752 mxTableImportContext
->StartElement( xAttrList
);
3757 void SdXMLTableShapeContext::EndElement()
3759 if( mxTableImportContext
.Is() )
3760 mxTableImportContext
->EndElement();
3762 SdXMLShapeContext::EndElement();
3766 // set pos, size, shear and rotate
3767 SetTransformation();
3771 // this is called from the parent group for each unparsed attribute in the attribute list
3772 void SdXMLTableShapeContext::processAttribute( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const ::rtl::OUString
& rValue
)
3774 if( nPrefix
== XML_NAMESPACE_TABLE
)
3776 if( IsXMLToken( rLocalName
, XML_TEMPLATE_NAME
) )
3778 msTemplateStyleName
= rValue
;
3783 const XMLPropertyMapEntry
* pEntry
= &aXMLTableShapeAttributes
[0];
3784 while( pEntry
->msApiName
&& (i
< 6) )
3786 if( IsXMLToken( rLocalName
, pEntry
->meXMLName
) )
3788 if( IsXMLToken( rValue
, XML_TRUE
) )
3789 maTemplateStylesUsed
[i
] = sal_True
;
3797 SdXMLShapeContext::processAttribute( nPrefix
, rLocalName
, rValue
);
3800 SvXMLImportContext
* SdXMLTableShapeContext::CreateChildContext( sal_uInt16 nPrefix
, const ::rtl::OUString
& rLocalName
, const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
)
3802 if( mxTableImportContext
.Is() && (nPrefix
== XML_NAMESPACE_TABLE
) )
3803 return mxTableImportContext
->CreateChildContext(nPrefix
, rLocalName
, xAttrList
);
3805 return SdXMLShapeContext::CreateChildContext(nPrefix
, rLocalName
, xAttrList
);
3808 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */