/src/libreoffice/drawinglayer/inc/primitive2d/cropprimitive2d.hxx
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 | | #pragma once |
21 | | |
22 | | #include <drawinglayer/primitive2d/groupprimitive2d.hxx> |
23 | | #include <basegfx/matrix/b2dhommatrix.hxx> |
24 | | |
25 | | |
26 | | namespace drawinglayer::primitive2d |
27 | | { |
28 | | /** CropPrimitive2D class |
29 | | |
30 | | Caution: Due to old constraints (old core definitions) the |
31 | | crop distances describe how the uncropped content is defined |
32 | | relative to the current object size. This means that maTransformation |
33 | | describes the current object size (the part of the object visible |
34 | | with the crop applied). To get the original size and orientation |
35 | | of the uncropped content it is necessary to calc back from the |
36 | | current situation (maTransformation) using the crop values |
37 | | to get to the uncropped original content. |
38 | | |
39 | | Thus a transformation has to be calculated which will be applied |
40 | | to the already existing content to get it to the uncropped state |
41 | | and then this is masked with the current state (mask polygon |
42 | | created from unit polygon and maTransformation). |
43 | | |
44 | | At least in this primitive the units of the crop values are |
45 | | already in the local coordinate system; in the core these distances |
46 | | are defined relative to the object content size (PrefMapMode |
47 | | and PrefSize of the content)... |
48 | | |
49 | | Of course this is a primitive, so feel free to just ignore all that |
50 | | stuff and use the automatically generated decomposition. Sigh. |
51 | | */ |
52 | | class CropPrimitive2D final : public GroupPrimitive2D |
53 | | { |
54 | | private: |
55 | | // the transformation already applied to the child geometry |
56 | | basegfx::B2DHomMatrix maTransformation; |
57 | | |
58 | | // the crop offsets relative to the range of the unrotated content |
59 | | double mfCropLeft; |
60 | | double mfCropTop; |
61 | | double mfCropRight; |
62 | | double mfCropBottom; |
63 | | |
64 | | public: |
65 | | /// constructor |
66 | | CropPrimitive2D( |
67 | | Primitive2DContainer&& aChildren, |
68 | | basegfx::B2DHomMatrix aTransformation, |
69 | | double fCropLeft, |
70 | | double fCropTop, |
71 | | double fCropRight, |
72 | | double fCropBottom); |
73 | | |
74 | | /// data read access |
75 | 0 | const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } |
76 | 0 | double getCropLeft() const { return mfCropLeft; } |
77 | 0 | double getCropTop() const { return mfCropTop; } |
78 | 0 | double getCropRight() const { return mfCropRight; } |
79 | 0 | double getCropBottom() const { return mfCropBottom; } |
80 | | |
81 | | /// compare operator |
82 | | virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; |
83 | | |
84 | | /// local decomposition |
85 | | virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; |
86 | | |
87 | | /// provide unique ID |
88 | | virtual sal_uInt32 getPrimitive2DID() const override; |
89 | | }; |
90 | | |
91 | | } // end of namespace drawinglayer::primitive2d |
92 | | |
93 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |