1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "oox/drawingml/linepropertiescontext.hxx"
29 #include "oox/drawingml/drawingmltypes.hxx"
30 #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
31 #include "oox/drawingml/lineproperties.hxx"
32 #include "oox/helper/attributelist.hxx"
33 
34 using ::rtl::OUString;
35 using namespace ::oox::core;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::xml::sax;
38 
39 // CT_LineProperties
40 
41 namespace oox { namespace drawingml {
42 // ---------------------------------------------------------------------
43 
44 LinePropertiesContext::LinePropertiesContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs,
45     LineProperties& rLineProperties ) throw()
46 : ContextHandler( rParent )
47 , mrLineProperties( rLineProperties )
48 {
49     AttributeList aAttribs( xAttribs );
50     mrLineProperties.moLineWidth = aAttribs.getInteger( XML_w );
51     mrLineProperties.moLineCompound = aAttribs.getToken( XML_cmpd );
52     mrLineProperties.moLineCap = aAttribs.getToken( XML_cap );
53 }
54 
55 LinePropertiesContext::~LinePropertiesContext()
56 {
57 }
58 
59 Reference< XFastContextHandler > LinePropertiesContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
60 {
61     Reference< XFastContextHandler > xRet;
62     AttributeList aAttribs( xAttribs );
63     switch( nElement )
64     {
65         // LineFillPropertiesGroup
66         case A_TOKEN( noFill ):
67         case A_TOKEN( solidFill ):
68         case A_TOKEN( gradFill ):
69         case A_TOKEN( pattFill ):
70             xRet = FillPropertiesContext::createFillContext( *this, nElement, xAttribs, mrLineProperties.maLineFill );
71         break;
72 
73         // LineDashPropertiesGroup
74         case A_TOKEN( prstDash ):  // CT_PresetLineDashProperties
75             mrLineProperties.moPresetDash = aAttribs.getToken( XML_val );
76         break;
77         case A_TOKEN( custDash ):  // CT_DashStopList
78             xRet = this;
79         break;
80         case A_TOKEN( ds ):
81             mrLineProperties.maCustomDash.push_back( LineProperties::DashStop(
82                 aAttribs.getInteger( XML_d, 0 ), aAttribs.getInteger( XML_sp, 0 ) ) );
83         break;
84 
85         // LineJoinPropertiesGroup
86         case A_TOKEN( round ):
87         case A_TOKEN( bevel ):
88         case A_TOKEN( miter ):
89             mrLineProperties.moLineJoint = getBaseToken( nElement );
90         break;
91 
92         case A_TOKEN( headEnd ):  // CT_LineEndProperties
93         case A_TOKEN( tailEnd ):  // CT_LineEndProperties
94         {                         // ST_LineEndType
95             bool bTailEnd = nElement == A_TOKEN( tailEnd );
96             LineArrowProperties& rArrowProps = bTailEnd ? mrLineProperties.maEndArrow : mrLineProperties.maStartArrow;
97             rArrowProps.moArrowType = aAttribs.getToken( XML_type );
98             rArrowProps.moArrowWidth = aAttribs.getToken( XML_w );
99             rArrowProps.moArrowLength = aAttribs.getToken( XML_len );
100         }
101         break;
102     }
103     return xRet;
104 }
105 
106 } }
107