1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include "oox/drawingml/linepropertiescontext.hxx" 25 #include "oox/drawingml/drawingmltypes.hxx" 26 #include "oox/drawingml/fillpropertiesgroupcontext.hxx" 27 #include "oox/drawingml/lineproperties.hxx" 28 #include "oox/helper/attributelist.hxx" 29 30 using ::rtl::OUString; 31 using namespace ::oox::core; 32 using namespace ::com::sun::star::uno; 33 using namespace ::com::sun::star::xml::sax; 34 35 // CT_LineProperties 36 37 namespace oox { namespace drawingml { 38 // --------------------------------------------------------------------- 39 40 LinePropertiesContext::LinePropertiesContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, 41 LineProperties& rLineProperties ) throw() 42 : ContextHandler( rParent ) 43 , mrLineProperties( rLineProperties ) 44 { 45 AttributeList aAttribs( xAttribs ); 46 mrLineProperties.moLineWidth = aAttribs.getInteger( XML_w ); 47 mrLineProperties.moLineCompound = aAttribs.getToken( XML_cmpd ); 48 mrLineProperties.moLineCap = aAttribs.getToken( XML_cap ); 49 } 50 51 LinePropertiesContext::~LinePropertiesContext() 52 { 53 } 54 55 Reference< XFastContextHandler > LinePropertiesContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) 56 { 57 Reference< XFastContextHandler > xRet; 58 AttributeList aAttribs( xAttribs ); 59 switch( nElement ) 60 { 61 // LineFillPropertiesGroup 62 case A_TOKEN( noFill ): 63 case A_TOKEN( solidFill ): 64 case A_TOKEN( gradFill ): 65 case A_TOKEN( pattFill ): 66 xRet = FillPropertiesContext::createFillContext( *this, nElement, xAttribs, mrLineProperties.maLineFill ); 67 break; 68 69 // LineDashPropertiesGroup 70 case A_TOKEN( prstDash ): // CT_PresetLineDashProperties 71 mrLineProperties.moPresetDash = aAttribs.getToken( XML_val ); 72 break; 73 case A_TOKEN( custDash ): // CT_DashStopList 74 xRet = this; 75 break; 76 case A_TOKEN( ds ): 77 mrLineProperties.maCustomDash.push_back( LineProperties::DashStop( 78 aAttribs.getInteger( XML_d, 0 ), aAttribs.getInteger( XML_sp, 0 ) ) ); 79 break; 80 81 // LineJoinPropertiesGroup 82 case A_TOKEN( round ): 83 case A_TOKEN( bevel ): 84 case A_TOKEN( miter ): 85 mrLineProperties.moLineJoint = getBaseToken( nElement ); 86 break; 87 88 case A_TOKEN( headEnd ): // CT_LineEndProperties 89 case A_TOKEN( tailEnd ): // CT_LineEndProperties 90 { // ST_LineEndType 91 bool bTailEnd = nElement == A_TOKEN( tailEnd ); 92 LineArrowProperties& rArrowProps = bTailEnd ? mrLineProperties.maEndArrow : mrLineProperties.maStartArrow; 93 rArrowProps.moArrowType = aAttribs.getToken( XML_type ); 94 rArrowProps.moArrowWidth = aAttribs.getToken( XML_w ); 95 rArrowProps.moArrowLength = aAttribs.getToken( XML_len ); 96 } 97 break; 98 } 99 return xRet; 100 } 101 102 } } 103