fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / drawinglayer / source / primitive2d / discretebitmapprimitive2d.cxx
blob95ba2e7ac03ccf77801a9c1bd3f14460d9c17eb4
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/primitive2d/discretebitmapprimitive2d.hxx>
21 #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
22 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
24 //////////////////////////////////////////////////////////////////////////////
26 namespace drawinglayer
28 namespace primitive2d
30 Primitive2DSequence DiscreteBitmapPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
32 // use getViewTransformation() and getObjectTransformation() from
33 // ObjectAndViewTransformationDependentPrimitive2D to create a BitmapPrimitive2D
34 // with the correct mapping
35 Primitive2DSequence xRetval;
37 if(!getBitmapEx().IsEmpty())
39 // get discrete size
40 const Size& rSizePixel = getBitmapEx().GetSizePixel();
41 const basegfx::B2DVector aDiscreteSize(rSizePixel.Width(), rSizePixel.Height());
43 // get inverse ViewTransformation
44 basegfx::B2DHomMatrix aInverseViewTransformation(getViewTransformation());
45 aInverseViewTransformation.invert();
47 // get size and position in world coordinates
48 const basegfx::B2DVector aWorldSize(aInverseViewTransformation * aDiscreteSize);
49 const basegfx::B2DPoint aWorldTopLeft(getObjectTransformation() * getTopLeft());
51 // build object matrix in world coordinates so that the top-left
52 // position remains, but eventual transformations (e.g. rotations)
53 // in the ObjectToView stack remain and get correctly applied
54 basegfx::B2DHomMatrix aObjectTransform;
56 aObjectTransform.set(0, 0, aWorldSize.getX());
57 aObjectTransform.set(1, 1, aWorldSize.getY());
58 aObjectTransform.set(0, 2, aWorldTopLeft.getX());
59 aObjectTransform.set(1, 2, aWorldTopLeft.getY());
61 // get inverse ObjectTransformation
62 basegfx::B2DHomMatrix aInverseObjectTransformation(getObjectTransformation());
63 aInverseObjectTransformation.invert();
65 // transform to object coordinate system
66 aObjectTransform = aInverseObjectTransformation * aObjectTransform;
68 // create BitmapPrimitive2D with now object-local coordinate data
69 const Primitive2DReference xRef(new BitmapPrimitive2D(getBitmapEx(), aObjectTransform));
70 xRetval = Primitive2DSequence(&xRef, 1);
73 return xRetval;
76 DiscreteBitmapPrimitive2D::DiscreteBitmapPrimitive2D(
77 const BitmapEx& rBitmapEx,
78 const basegfx::B2DPoint& rTopLeft)
79 : ObjectAndViewTransformationDependentPrimitive2D(),
80 maBitmapEx(rBitmapEx),
81 maTopLeft(rTopLeft)
85 bool DiscreteBitmapPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
87 if(ObjectAndViewTransformationDependentPrimitive2D::operator==(rPrimitive))
89 const DiscreteBitmapPrimitive2D& rCompare = (DiscreteBitmapPrimitive2D&)rPrimitive;
91 return (getBitmapEx() == rCompare.getBitmapEx()
92 && getTopLeft() == rCompare.getTopLeft());
95 return false;
98 // provide unique ID
99 ImplPrimitive2DIDBlock(DiscreteBitmapPrimitive2D, PRIMITIVE2D_ID_DISCRETEBITMAPPRIMITIVE2D)
101 } // end of namespace primitive2d
102 } // end of namespace drawinglayer
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */