1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <drawinglayer/drawinglayerdllapi.h>
24 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
25 #include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
27 // GroupPrimitive2D class
29 namespace drawinglayer::primitive2d
31 /** GroupPrimitive2D class
33 Baseclass for all grouping 2D primitives
35 The grouping primitive in its basic form is capable of holding
36 a child primitive content and returns it on decomposition on default.
37 It is used for two main purposes, but more may apply:
39 - to transport extended information, e.g. for text classification,
40 see e.g. TextHierarchy*Primitive2D implementations. Since they
41 decompose to their child content, renderers not aware/interested
42 in that extra information will just ignore these primitives
44 - to encapsulate common geometry, e.g. the ShadowPrimitive2D implements
45 applying a generic shadow to a child sequence by adding the needed
46 offset and color stuff in the decomposition
48 In most cases the decomposition is straightforward, so by default
49 this primitive will not buffer the result and is not derived from
50 BufferedDecompositionPrimitive2D, but from BasePrimitive2D.
52 A renderer has to take GroupPrimitive2D derivations into account which
53 are used to hold a state.
55 Current Basic 2D StatePrimitives are:
57 - TransparencePrimitive2D (objects with freely defined transparence)
58 - InvertPrimitive2D (for XOR)
59 - MaskPrimitive2D (for masking)
60 - ModifiedColorPrimitive2D (for a stack of color modifications)
61 - TransformPrimitive2D (for a transformation stack)
63 class DRAWINGLAYER_DLLPUBLIC GroupPrimitive2D
: public BasePrimitive2D
66 /// the children. Declared private since this shall never be changed at all after construction
67 Primitive2DContainer maChildren
;
71 explicit GroupPrimitive2D(Primitive2DContainer
&& aChildren
);
74 const Primitive2DContainer
& getChildren() const { return maChildren
; }
76 void getChildren(Primitive2DDecompositionVisitor
& rVisitor
) const { rVisitor
.visit(maChildren
); }
79 virtual bool operator==( const BasePrimitive2D
& rPrimitive
) const override
;
81 /// local decomposition. Implementation will just return children
82 virtual void get2DDecomposition(Primitive2DDecompositionVisitor
& rVisitor
, const geometry::ViewInformation2D
& rViewInformation
) const override
;
85 virtual sal_uInt32
getPrimitive2DID() const override
;
88 virtual sal_Int64
estimateUsage() override
;
90 } // end of namespace drawinglayer::primitive2d
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */