LibreOffice Module oox (master) 1
shapegroupcontext.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
20#include <com/sun/star/xml/sax/FastToken.hpp>
21#include <com/sun/star/beans/XMultiPropertySet.hpp>
22
29#include <oox/token/namespaces.hxx>
30#include <oox/token/tokens.hxx>
31#include <sal/log.hxx>
32#include <utility>
33
34using namespace oox::core;
35using namespace ::com::sun::star;
36using namespace ::com::sun::star::uno;
37using namespace ::com::sun::star::drawing;
38using namespace ::com::sun::star::beans;
39using namespace ::com::sun::star::xml::sax;
40
41namespace oox::drawingml {
42
43ShapeGroupContext::ShapeGroupContext( FragmentHandler2 const & rParent, ShapePtr const & pMasterShapePtr, ShapePtr pGroupShapePtr )
44: FragmentHandler2( rParent )
45, mpGroupShapePtr(std::move( pGroupShapePtr ))
46{
47 if( pMasterShapePtr )
48 mpGroupShapePtr->setWps(pMasterShapePtr->getWps());
49 if( pMasterShapePtr && mpGroupShapePtr )
50 pMasterShapePtr->addChild( mpGroupShapePtr );
51}
52
54{
55}
56
57ContextHandlerRef ShapeGroupContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
58{
59 switch( getBaseToken( aElementToken ) )
60 {
61 case XML_extLst:
62 case XML_ext:
63 break;
64 case XML_decorative:
65 {
66 mpGroupShapePtr->setDecorative(rAttribs.getBool(XML_val, false));
67 }
68 break;
69 case XML_cNvPr:
70 {
71 mpGroupShapePtr->setHidden( rAttribs.getBool( XML_hidden, false ) );
72 mpGroupShapePtr->setId( rAttribs.getStringDefaulted( XML_id ) );
73 mpGroupShapePtr->setName( rAttribs.getStringDefaulted( XML_name ) );
74 break;
75 }
76 case XML_ph:
77 mpGroupShapePtr->setSubType( rAttribs.getToken( XML_type, FastToken::DONTKNOW ) );
78 if( rAttribs.hasAttribute( XML_idx ) )
79 mpGroupShapePtr->setSubTypeIndex( rAttribs.getInteger( XML_idx, 0 ) );
80 break;
81 // nvSpPr CT_ShapeNonVisual end
82
83 case XML_grpSpPr:
84 return new ShapePropertiesContext( *this, *mpGroupShapePtr );
85 case XML_nvGrpSpPr:
86 return this;
87 case XML_spPr:
88 return new ShapePropertiesContext( *this, *mpGroupShapePtr );
89/*
90 case XML_style:
91 return new ShapeStyleContext( getParser() );
92*/
93 case XML_cxnSp: // connector shape
94 {
95 ShapePtr pShape = std::make_shared<Shape>("com.sun.star.drawing.ConnectorShape");
96 pShape->setLockedCanvas(mpGroupShapePtr->getLockedCanvas());
97 return new ConnectorShapeContext(*this, mpGroupShapePtr, pShape,
98 pShape->getConnectorShapeProperties());
99 }
100 case XML_grpSp: // group shape
101 return new ShapeGroupContext( *this, mpGroupShapePtr, std::make_shared<Shape>( "com.sun.star.drawing.GroupShape" ) );
102 case XML_sp: // shape
103 case XML_wsp:
104 // Don't set default character height for WPS shapes, Writer has its
105 // own way to set the default, and if we don't set it here, editing
106 // properly inherits it.
107 return new ShapeContext( *this, mpGroupShapePtr, std::make_shared<Shape>( "com.sun.star.drawing.CustomShape", getBaseToken(aElementToken) == XML_sp ) );
108 case XML_pic: // CT_Picture
109 return new GraphicShapeContext( *this, mpGroupShapePtr, std::make_shared<Shape>( "com.sun.star.drawing.GraphicObjectShape" ) );
110 case XML_graphicFrame: // CT_GraphicalObjectFrame
111 return new GraphicalObjectFrameContext( *this, mpGroupShapePtr, std::make_shared<Shape>( "com.sun.star.drawing.GraphicObjectShape" ), true );
112 case XML_cNvGrpSpPr:
113 break;
114 case XML_grpSpLocks:
115 break;
116 default:
117 SAL_WARN("oox", "ShapeGroupContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
118 break;
119 }
120
121 return this;
122}
123
124}
125
126/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides access to attribute values of an element.
OUString getStringDefaulted(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute, returns an empty string if attribute not present...
bool hasAttribute(sal_Int32 nAttrToken) const
Returns true, if the specified attribute is present.
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
std::optional< bool > getBool(sal_Int32 nAttrToken) const
Returns the boolean value of the specified attribute.
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
ShapeGroupContext(::oox::core::FragmentHandler2 const &rParent, ShapePtr const &pMasterShapePtr, ShapePtr pGroupShapePtr)
#define SAL_WARN(area, stream)
std::shared_ptr< Shape > ShapePtr
XML_type