LibreOffice Module oox (master)  1
vmlshapecontainer.hxx
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 #ifndef INCLUDED_OOX_VML_VMLSHAPECONTAINER_HXX
21 #define INCLUDED_OOX_VML_VMLSHAPECONTAINER_HXX
22 
23 #include <cstddef>
24 #include <functional>
25 #include <memory>
26 #include <stack>
27 
28 #include <com/sun/star/awt/Rectangle.hpp>
29 #include <com/sun/star/uno/Reference.hxx>
30 #include <oox/helper/refmap.hxx>
31 #include <oox/helper/refvector.hxx>
32 #include <rtl/ustring.hxx>
33 
34 namespace com::sun::star {
35  namespace drawing { class XShapes; }
36 }
37 
38 namespace oox::vml {
39 
40 class Drawing;
41 class ShapeType;
42 class ShapeBase;
43 
44 
46 {
47  css::awt::Rectangle maShapeRect;
48  css::awt::Rectangle maCoordSys;
49 };
50 
51 
54 {
55 public:
56  explicit ShapeContainer( Drawing& rDrawing );
58 
60  Drawing& getDrawing() { return mrDrawing; }
61 
63  std::shared_ptr<ShapeType> createShapeType();
65  template< typename ShapeT >
66  std::shared_ptr<ShapeT> createShape();
67 
70 
72  bool empty() const { return maShapes.empty(); }
73 
76  const ShapeType* getShapeTypeById( const OUString& rShapeId ) const;
79  const ShapeBase* getShapeById( const OUString& rShapeId ) const;
80 
83  template< typename Functor >
84  const ShapeBase* findShape( const Functor& rFunctor ) const;
85 
90  std::shared_ptr< ShapeBase > takeLastShape();
98  void pushMark();
102  void popMark();
103 
105  void convertAndInsert(
106  const css::uno::Reference< css::drawing::XShapes >& rxShapes,
107  const ShapeParentAnchor* pParentAnchor = nullptr ) const;
108 
109 private:
114 
116  ShapeTypeVector maTypes;
117  ShapeVector maShapes;
118  ShapeTypeMap maTypesById;
119  ShapeMap maShapesById;
120  std::stack< size_t > markStack;
121 };
122 
123 
124 template< typename ShapeT >
125 std::shared_ptr<ShapeT> ShapeContainer::createShape()
126 {
127  auto xShape = std::make_shared<ShapeT>( mrDrawing );
128  xShape->setContainer(this);
129  maShapes.push_back( xShape );
130  return xShape;
131 }
132 
133 template< typename Functor >
134 const ShapeBase* ShapeContainer::findShape( const Functor& rFunctor ) const
135 {
136  return maShapes.findIf( rFunctor ).get();
137 }
138 
139 
140 } // namespace oox::vml
141 
142 #endif
143 
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Drawing & mrDrawing
The VML drawing page that contains this shape.
std::shared_ptr< ShapeType > createShapeType()
Creates and returns a new shape template object.
css::awt::Rectangle maShapeRect
A shape object that is part of a drawing.
Definition: vmlshape.hxx:234
const ShapeBase * getShapeById(const OUString &rShapeId) const
Returns the shape with the passed identifier.
void pushMark()
Adds a recursion mark to the stack.
void convertAndInsert(const css::uno::Reference< css::drawing::XShapes > &rxShapes, const ShapeParentAnchor *pParentAnchor=nullptr) const
Creates and inserts all UNO shapes into the passed container.
A shape template contains all formatting properties of shapes and can serve as templates for several ...
Definition: vmlshape.hxx:124
void popMark()
Removes a recursion mark.
ShapeMap maShapesById
All shape definitions mapped by identifier.
::cppu::WeakComponentImplHelper< css::report::XShape, css::lang::XServiceInfo > ShapeBase
bool empty() const
Returns true, if this container does not contain any shapes.
exports com.sun.star. drawing
value_type findIf(const FunctorType &rFunctor) const
Searches for an element by using the passed functor that takes a constant reference of the object typ...
Definition: refvector.hxx:116
RefVector< ShapeBase > ShapeVector
Container that holds a list of shapes and shape templates.
Drawing & getDrawing()
Returns the drawing this shape container is part of.
std::shared_ptr< ShapeT > createShape()
Creates and returns a new shape object of the specified type.
const ShapeType * getShapeTypeById(const OUString &rShapeId) const
Returns the shape template with the passed identifier.
ShapeContainer(Drawing &rDrawing)
std::stack< size_t > markStack
Recursion marks from pushMark()/popMark().
RefMap< OUString, ShapeType > ShapeTypeMap
void finalizeFragmentImport()
Final processing after import of the drawing fragment.
css::awt::Rectangle maCoordSys
ShapeTypeVector maTypes
All shape templates.
std::shared_ptr< ShapeBase > takeLastShape()
(Word only) Returns the last shape in the collection, if it is after the last mark from pushMark()...
ShapeVector maShapes
All shape definitions.
RefMap< OUString, ShapeBase > ShapeMap
const ShapeBase * findShape(const Functor &rFunctor) const
Searches for a shape by using the passed functor that takes a constant reference of a ShapeBase objec...
Represents the collection of VML shapes for a complete draw page.
Definition: vmldrawing.hxx:93
ShapeTypeMap maTypesById
All shape templates mapped by identifier.
RefVector< ShapeType > ShapeTypeVector