Teach symstore more duplicated DLLs
[LibreOffice.git] / drawinglayer / source / processor3d / geometry2dextractor.cxx
blobd935546c11183a28249ab505fe17d50a76c8fe5a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <drawinglayer/processor3d/geometry2dextractor.hxx>
21 #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
22 #include <drawinglayer/primitive3d/transformprimitive3d.hxx>
23 #include <drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx>
24 #include <drawinglayer/primitive3d/polygonprimitive3d.hxx>
25 #include <basegfx/polygon/b2dpolygontools.hxx>
26 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
27 #include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx>
28 #include <basegfx/polygon/b2dpolypolygontools.hxx>
29 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
30 #include <drawinglayer/primitive3d/textureprimitive3d.hxx>
33 using namespace com::sun::star;
36 namespace drawinglayer
38 namespace processor3d
40 // as tooling, the process() implementation takes over API handling and calls this
41 // virtual render method when the primitive implementation is BasePrimitive3D-based.
42 void Geometry2DExtractingProcessor::processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate)
44 // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch
45 switch(rCandidate.getPrimitive3DID())
47 case PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D :
49 // transform group. Remember current transformations
50 const primitive3d::TransformPrimitive3D& rPrimitive = static_cast< const primitive3d::TransformPrimitive3D& >(rCandidate);
51 const geometry::ViewInformation3D aLastViewInformation3D(getViewInformation3D());
53 // create new transformation; add new object transform from right side
54 const geometry::ViewInformation3D aNewViewInformation3D(
55 aLastViewInformation3D.getObjectTransformation() * rPrimitive.getTransformation(),
56 aLastViewInformation3D.getOrientation(),
57 aLastViewInformation3D.getProjection(),
58 aLastViewInformation3D.getDeviceToView(),
59 aLastViewInformation3D.getViewTime(),
60 aLastViewInformation3D.getExtendedInformationSequence());
61 updateViewInformation(aNewViewInformation3D);
63 // let break down recursively
64 process(rPrimitive.getChildren());
66 // restore transformations
67 updateViewInformation(aLastViewInformation3D);
68 break;
70 case PRIMITIVE3D_ID_MODIFIEDCOLORPRIMITIVE3D :
72 // ModifiedColorPrimitive3D; push, process and pop
73 const primitive3d::ModifiedColorPrimitive3D& rModifiedCandidate = static_cast< const primitive3d::ModifiedColorPrimitive3D& >(rCandidate);
74 const primitive3d::Primitive3DContainer& rSubSequence = rModifiedCandidate.getChildren();
76 if(!rSubSequence.empty())
78 maBColorModifierStack.push(rModifiedCandidate.getColorModifier());
79 process(rModifiedCandidate.getChildren());
80 maBColorModifierStack.pop();
82 break;
84 case PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D :
86 // PolygonHairlinePrimitive3D
87 const primitive3d::PolygonHairlinePrimitive3D& rPrimitive = static_cast< const primitive3d::PolygonHairlinePrimitive3D& >(rCandidate);
88 basegfx::B2DPolygon a2DHairline(basegfx::utils::createB2DPolygonFromB3DPolygon(rPrimitive.getB3DPolygon(), getViewInformation3D().getObjectToView()));
90 if(a2DHairline.count())
92 a2DHairline.transform(getObjectTransformation());
93 const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(rPrimitive.getBColor()));
94 const primitive2d::Primitive2DReference xRef(new primitive2d::PolygonHairlinePrimitive2D(a2DHairline, aModifiedColor));
95 maPrimitive2DSequence.push_back(xRef);
97 break;
99 case PRIMITIVE3D_ID_POLYPOLYGONMATERIALPRIMITIVE3D :
101 // PolyPolygonMaterialPrimitive3D
102 const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const primitive3d::PolyPolygonMaterialPrimitive3D& >(rCandidate);
103 basegfx::B2DPolyPolygon a2DFill(basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon(rPrimitive.getB3DPolyPolygon(), getViewInformation3D().getObjectToView()));
105 if(a2DFill.count())
107 a2DFill.transform(getObjectTransformation());
108 const basegfx::BColor aModifiedColor(maBColorModifierStack.getModifiedColor(rPrimitive.getMaterial().getColor()));
109 const primitive2d::Primitive2DReference xRef(new primitive2d::PolyPolygonColorPrimitive2D(a2DFill, aModifiedColor));
110 maPrimitive2DSequence.push_back(xRef);
112 break;
114 case PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D :
115 case PRIMITIVE3D_ID_HATCHTEXTUREPRIMITIVE3D :
116 case PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D :
117 case PRIMITIVE3D_ID_TRANSPARENCETEXTUREPRIMITIVE3D :
118 case PRIMITIVE3D_ID_UNIFIEDTRANSPARENCETEXTUREPRIMITIVE3D :
120 // TexturePrimitive3D: Process children, do not try to decompose
121 const primitive3d::TexturePrimitive3D& rTexturePrimitive = static_cast< const primitive3d::TexturePrimitive3D& >(rCandidate);
122 const primitive3d::Primitive3DContainer& aChildren(rTexturePrimitive.getChildren());
124 if(!aChildren.empty())
126 process(aChildren);
128 break;
130 case PRIMITIVE3D_ID_SHADOWPRIMITIVE3D :
132 // accept but ignore labels and shadow; these should be extracted separately
133 break;
135 default :
137 // process recursively
138 process(rCandidate.get3DDecomposition(getViewInformation3D()));
139 break;
144 Geometry2DExtractingProcessor::Geometry2DExtractingProcessor(
145 const geometry::ViewInformation3D& rViewInformation,
146 const basegfx::B2DHomMatrix& rObjectTransformation)
147 : BaseProcessor3D(rViewInformation),
148 maPrimitive2DSequence(),
149 maObjectTransformation(rObjectTransformation),
150 maBColorModifierStack()
153 } // end of namespace processor3d
154 } // end of namespace drawinglayer
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */