/src/libreoffice/drawinglayer/source/processor2d/baseprocessor2d.cxx
Line | Count | Source |
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 <drawinglayer/primitive2d/Primitive2DContainer.hxx> |
21 | | #include <drawinglayer/processor2d/baseprocessor2d.hxx> |
22 | | #include <utility> |
23 | | |
24 | | |
25 | | namespace drawinglayer::processor2d |
26 | | { |
27 | | void BaseProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& /*rCandidate*/) |
28 | 0 | { |
29 | 0 | } |
30 | | |
31 | | BaseProcessor2D::BaseProcessor2D(geometry::ViewInformation2D aViewInformation) |
32 | 64.0k | : maViewInformation2D(std::move(aViewInformation)) |
33 | 64.0k | { |
34 | 64.0k | } |
35 | | |
36 | | BaseProcessor2D::~BaseProcessor2D() |
37 | 64.0k | { |
38 | 64.0k | } |
39 | | |
40 | | void BaseProcessor2D::process(const primitive2d::BasePrimitive2D& rCandidate) |
41 | 351k | { |
42 | | // use the visitor API to avoid the cost of constructing Primitive2DContainers |
43 | 351k | rCandidate.get2DDecomposition(*this, getViewInformation2D()); |
44 | 351k | } |
45 | | |
46 | | // Primitive2DDecompositionVisitor |
47 | | void BaseProcessor2D::visit(const primitive2d::Primitive2DReference& rCandidate) |
48 | 342k | { |
49 | 342k | if (rCandidate) |
50 | 8.30k | processBasePrimitive2D(*rCandidate); |
51 | 342k | } |
52 | | void BaseProcessor2D::visit(const primitive2d::Primitive2DContainer& rContainer) |
53 | 8.39k | { |
54 | 8.39k | process(rContainer); |
55 | 8.39k | } |
56 | | void BaseProcessor2D::visit(primitive2d::Primitive2DContainer&& rCandidate) |
57 | 0 | { |
58 | 0 | process(rCandidate); |
59 | 0 | } |
60 | | |
61 | | void BaseProcessor2D::process(const primitive2d::Primitive2DContainer& rSource) |
62 | 73.6k | { |
63 | 73.6k | for (const primitive2d::Primitive2DReference& rCandidate : rSource) |
64 | 351k | { |
65 | | // Skip, if not visible |
66 | 351k | if (rCandidate && rCandidate->getVisible()) |
67 | 351k | processBasePrimitive2D(*rCandidate); |
68 | 351k | } |
69 | 73.6k | } |
70 | | |
71 | | void BaseProcessor2D::setViewInformation2D(const geometry::ViewInformation2D& rNew) |
72 | 908 | { |
73 | 908 | if (rNew != maViewInformation2D) |
74 | 908 | { |
75 | | // set if changed |
76 | 908 | maViewInformation2D = rNew; |
77 | | |
78 | | // allow reaction on change |
79 | 908 | onViewInformation2DChanged(); |
80 | 908 | } |
81 | 908 | } |
82 | | } // end of namespace |
83 | | |
84 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |