1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: linepropertiescontext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/drawingml/linepropertiescontext.hxx"
32 #include "oox/drawingml/drawingmltypes.hxx"
33 #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
34 #include "oox/drawingml/lineproperties.hxx"
35 #include "oox/helper/attributelist.hxx"
36 #include "oox/core/namespaces.hxx"
39 using ::rtl::OUString
;
40 using namespace ::oox::core
;
41 using namespace ::com::sun::star::uno
;
42 using namespace ::com::sun::star::xml::sax
;
46 namespace oox
{ namespace drawingml
{
47 // ---------------------------------------------------------------------
49 LinePropertiesContext::LinePropertiesContext( ContextHandler
& rParent
, const Reference
< XFastAttributeList
>& xAttribs
,
50 LineProperties
& rLineProperties
) throw()
51 : ContextHandler( rParent
)
52 , mrLineProperties( rLineProperties
)
54 AttributeList
aAttribs( xAttribs
);
55 mrLineProperties
.moLineWidth
= aAttribs
.getInteger( XML_w
);
56 mrLineProperties
.moLineCap
= aAttribs
.getToken( XML_cap
);
59 LinePropertiesContext::~LinePropertiesContext()
63 Reference
< XFastContextHandler
> LinePropertiesContext::createFastChildContext( sal_Int32 nElement
, const Reference
< XFastAttributeList
>& xAttribs
) throw (SAXException
, RuntimeException
)
65 Reference
< XFastContextHandler
> xRet
;
66 AttributeList
aAttribs( xAttribs
);
69 // LineFillPropertiesGroup
70 case A_TOKEN( noFill
):
71 case A_TOKEN( solidFill
):
72 case A_TOKEN( gradFill
):
73 case A_TOKEN( pattFill
):
74 xRet
= FillPropertiesContext::createFillContext( *this, nElement
, xAttribs
, mrLineProperties
.maLineFill
);
77 // LineDashPropertiesGroup
78 case A_TOKEN( prstDash
): // CT_PresetLineDashProperties
79 mrLineProperties
.moPresetDash
= aAttribs
.getToken( XML_val
);
81 case A_TOKEN( custDash
): // CT_DashStopList
84 // LineJoinPropertiesGroup
85 case A_TOKEN( round
):
86 case A_TOKEN( bevel
):
87 case A_TOKEN( miter
):
88 mrLineProperties
.moLineJoint
= getToken( nElement
);
91 case A_TOKEN( headEnd
): // CT_LineEndProperties
92 case A_TOKEN( tailEnd
): // CT_LineEndProperties
94 bool bTailEnd
= nElement
== A_TOKEN( tailEnd
);
95 LineArrowProperties
& rArrowProps
= bTailEnd
? mrLineProperties
.maEndArrow
: mrLineProperties
.maStartArrow
;
96 rArrowProps
.moArrowType
= aAttribs
.getToken( XML_type
);
97 rArrowProps
.moArrowWidth
= aAttribs
.getToken( XML_w
);
98 rArrowProps
.moArrowLength
= aAttribs
.getToken( XML_len
);