LibreOffice Module oox (master)  1
shapepropertiescontext.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
21 
29 #include <oox/token/namespaces.hxx>
30 #include <oox/token/tokens.hxx>
32 
33 using namespace oox::core;
34 using namespace ::com::sun::star;
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::drawing;
37 using namespace ::com::sun::star::beans;
38 using namespace ::com::sun::star::xml::sax;
39 
40 namespace oox::drawingml {
41 
42 // CT_ShapeProperties
43 ShapePropertiesContext::ShapePropertiesContext( ContextHandler2Helper const & rParent, Shape& rShape )
44 : ContextHandler2( rParent )
45 , mrShape( rShape )
46 {
47 }
48 
49 ContextHandlerRef ShapePropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
50 {
51  switch( aElementToken )
52  {
53  // CT_Transform2D
54  case A_TOKEN( xfrm ):
55  return new Transform2DContext( *this, rAttribs, mrShape );
56 
57  // GeometryGroup
58  case A_TOKEN( custGeom ): // custom geometry "CT_CustomGeometry2D"
60 
61  case A_TOKEN( prstGeom ): // preset geometry "CT_PresetGeometry2D"
62  {
63  sal_Int32 nToken = rAttribs.getToken( XML_prst, 0 );
64  // TODO: Move the following checks to a separate place or as a separate function
65  if ( nToken == XML_line )
66  {
67  mrShape.getServiceName() = "com.sun.star.drawing.LineShape";
68  }
69  if( ( nToken >= XML_bentConnector2 && nToken <= XML_bentConnector5 ) ||
70  ( nToken >= XML_curvedConnector2 && nToken <= XML_curvedConnector5 ) ||
71  nToken == XML_straightConnector1 )
72  {
73  mrShape.getServiceName() = "com.sun.star.drawing.CustomShape";
74  }
75 
76  // We got a preset geometry, forget the geometry inherited from the placeholder shape.
77  mrShape.getCustomShapeProperties() = std::make_shared<CustomShapeProperties>();
78 
79  return new PresetShapeGeometryContext( *this, rAttribs, *(mrShape.getCustomShapeProperties()) );
80  }
81 
82  case A_TOKEN( prstTxWarp ):
83  return new PresetTextShapeContext( *this, rAttribs, *(mrShape.getCustomShapeProperties()) );
84 
85  // CT_LineProperties
86  case A_TOKEN( ln ):
87  return new LinePropertiesContext( *this, rAttribs, mrShape.getLineProperties() );
88 
89  // EffectPropertiesGroup
90  // todo not supported by core
91  case A_TOKEN( effectLst ): // CT_EffectList
92  case A_TOKEN( effectDag ): // CT_EffectContainer
94 
95  // todo not supported by core, only for preservation via grab bags
96  case A_TOKEN( scene3d ): // CT_Scene3D
97  return new Scene3DPropertiesContext( *this, mrShape.get3DProperties() );
98 
99  // todo not supported by core, only for preservation via grab bags
100  case A_TOKEN( sp3d ): // CT_Shape3D
101  return new Shape3DPropertiesContext( *this, rAttribs, mrShape.get3DProperties() );
102  }
103 
104  return FillPropertiesContext::createFillContext( *this, aElementToken, rAttribs, mrShape.getFillProperties() );
105 }
106 
107 }
108 
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Shape3DProperties & get3DProperties()
Definition: shape.hxx:128
EffectProperties & getEffectProperties() const
Definition: shape.hxx:133
OUString & getServiceName()
Definition: shape.hxx:112
LineProperties & getLineProperties()
Definition: shape.hxx:117
Provides access to attribute values of an element.
CustomShapePropertiesPtr & getCustomShapeProperties()
Definition: shape.hxx:126
DefTokenId nToken
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
context to import a CT_Transform2D
::oox::core::ContextHandlerRef createFillContext(::oox::core::ContextHandler2Helper const &rParent, sal_Int32 nElement, const ::oox::AttributeList &rAttribs, FillProperties &rFillProps)
FillProperties & getFillProperties()
Definition: shape.hxx:120
Helper class that provides a context stack.
OptValue< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.