Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / drawinglayer / inc / primitive2d / cropprimitive2d.hxx
blobe1c66cffab2729cb21ff5e8d214bd26b1bffe25a
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 #pragma once
22 #include <drawinglayer/primitive2d/groupprimitive2d.hxx>
23 #include <basegfx/matrix/b2dhommatrix.hxx>
26 namespace drawinglayer::primitive2d
28 /** CropPrimitive2D class
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.
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).
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)...
49 Of course this is a primitive, so feel free to just ignore all that
50 stuff and use the automatically generated decomposition. Sigh.
52 class CropPrimitive2D final : public GroupPrimitive2D
54 private:
55 // the transformation already applied to the child geometry
56 basegfx::B2DHomMatrix maTransformation;
58 // the crop offsets relative to the range of the unrotated content
59 double mfCropLeft;
60 double mfCropTop;
61 double mfCropRight;
62 double mfCropBottom;
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);
74 /// data read access
75 const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; }
76 double getCropLeft() const { return mfCropLeft; }
77 double getCropTop() const { return mfCropTop; }
78 double getCropRight() const { return mfCropRight; }
79 double getCropBottom() const { return mfCropBottom; }
81 /// compare operator
82 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
84 /// local decomposition
85 virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override;
87 /// provide unique ID
88 virtual sal_uInt32 getPrimitive2DID() const override;
91 } // end of namespace drawinglayer::primitive2d
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */