1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: linepropertiescontext.cxx,v $
9 * last change: $Author: rt $ $Date: 2008-01-17 08:05:51 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 ************************************************************************/
36 #include "oox/drawingml/linepropertiescontext.hxx"
38 #include <com/sun/star/drawing/LineJoint.hpp>
39 #include <com/sun/star/drawing/LineStyle.hpp>
40 #include "oox/helper/propertymap.hxx"
41 #include "oox/core/namespaces.hxx"
42 #include "oox/drawingml/colorchoicecontext.hxx"
43 #include "oox/drawingml/drawingmltypes.hxx"
47 using ::rtl::OUString
;
48 using ::com::sun::star::beans::NamedValue
;
49 using namespace ::oox::core
;
50 using namespace ::com::sun::star
;
51 using namespace ::com::sun::star::drawing
;
52 using namespace ::com::sun::star::uno
;
53 using namespace ::com::sun::star::xml::sax
;
57 namespace oox
{ namespace drawingml
{
58 // ---------------------------------------------------------------------
60 LinePropertiesContext::LinePropertiesContext( const FragmentHandlerRef
& xHandler
, const Reference
< XFastAttributeList
>& xAttribs
,
61 oox::drawingml::LineProperties
& rLineProperties
) throw()
63 , mrLineProperties( rLineProperties
)
66 if( xAttribs
->hasAttribute( XML_w
) )
67 mrLineProperties
.getLineWidth() = boost::optional
< sal_Int32
>( GetCoordinate( xAttribs
->getOptionalValue( XML_w
) ) );
70 if( xAttribs
->hasAttribute( XML_cap
) )
71 mrLineProperties
.getLineCap() = boost::optional
< sal_Int32
>( xAttribs
->getOptionalValueToken( XML_cap
, 0 ) );
73 // if ( xAttribs->hasAttribute( XML_cmpd ) ) ST_CompoundLine
74 // if ( xAttribs->hasAttribute( XML_algn ) ) ST_PenAlignment
77 LinePropertiesContext::~LinePropertiesContext()
81 Reference
< XFastContextHandler
> LinePropertiesContext::createFastChildContext( sal_Int32 aElementToken
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
83 Reference
< XFastContextHandler
> xRet
;
84 const rtl::OUString
sLineStyle( RTL_CONSTASCII_USTRINGPARAM( "LineStyle" ) );
85 switch( aElementToken
)
87 // LineFillPropertiesGroup, line fillings currently unsuported
88 case NMSP_DRAWINGML
|XML_noFill
:
89 mrLineProperties
.getLinePropertyMap()[ sLineStyle
] <<= LineStyle_NONE
;
91 case NMSP_DRAWINGML
|XML_solidFill
:
93 mrLineProperties
.getLinePropertyMap()[ sLineStyle
] <<= LineStyle_SOLID
;
94 xRet
= new colorChoiceContext( getHandler(), *mrLineProperties
.getLineColor().get() );
97 case NMSP_DRAWINGML
|XML_gradFill
:
98 case NMSP_DRAWINGML
|XML_pattFill
:
99 mrLineProperties
.getLinePropertyMap()[ sLineStyle
] <<= LineStyle_SOLID
;
102 // LineDashPropertiesGroup
103 case NMSP_DRAWINGML
|XML_prstDash
: // CT_PresetLineDashProperties
104 mrLineProperties
.getPresetDash() = boost::optional
< sal_Int32
>( xAttribs
->getOptionalValueToken( XML_val
, XML_solid
) );
106 case NMSP_DRAWINGML
|XML_custDash
: // CT_DashStopList
109 // LineJoinPropertiesGroup
110 case NMSP_DRAWINGML
|XML_round
:
111 case NMSP_DRAWINGML
|XML_bevel
:
112 case NMSP_DRAWINGML
|XML_miter
:
114 LineJoint eJoint
= (aElementToken
== (NMSP_DRAWINGML
|XML_round
)) ? LineJoint_ROUND
:
115 (aElementToken
== (NMSP_DRAWINGML
|XML_bevel
)) ? LineJoint_BEVEL
:
117 static const OUString
sLineJoint( RTL_CONSTASCII_USTRINGPARAM( "LineJoint" ) );
118 mrLineProperties
.getLinePropertyMap()[ sLineJoint
] <<= eJoint
;
122 case NMSP_DRAWINGML
|XML_headEnd
: // CT_LineEndProperties
123 case NMSP_DRAWINGML
|XML_tailEnd
: // CT_LineEndProperties
125 if( xAttribs
->hasAttribute( XML_type
) )
127 sal_Int32 nType
= xAttribs
->getOptionalValueToken( XML_type
, 0 );
128 if ( aElementToken
== ( NMSP_DRAWINGML
|XML_tailEnd
) )
129 mrLineProperties
.getStartArrow() = boost::optional
< sal_Int32
>( nType
);
131 mrLineProperties
.getEndArrow() = boost::optional
< sal_Int32
>( nType
);
133 if ( xAttribs
->hasAttribute( XML_w
) )
135 sal_Int32 nW
= xAttribs
->getOptionalValueToken( XML_w
, 0 );
136 if ( aElementToken
== ( NMSP_DRAWINGML
|XML_tailEnd
) )
137 mrLineProperties
.getStartArrowWidth() = boost::optional
< sal_Int32
>( nW
);
139 mrLineProperties
.getEndArrowWidth() = boost::optional
< sal_Int32
>( nW
);
141 if ( xAttribs
->hasAttribute( XML_len
) )
143 sal_Int32 nLen
= xAttribs
->getOptionalValueToken( XML_len
, 0 );
144 if ( aElementToken
== ( NMSP_DRAWINGML
|XML_tailEnd
) )
145 mrLineProperties
.getStartArrowLength() = boost::optional
< sal_Int32
>( nLen
);
147 mrLineProperties
.getEndArrowLength() = boost::optional
< sal_Int32
>( nLen
);