1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <basegfx/tuple/Size2D.hxx>
23 #include <basegfx/matrix/b2dhommatrix.hxx>
24 #include <basegfx/vector/b2isize.hxx>
25 #include <basegfx/numeric/ftools.hxx>
29 class B2DSize
: public Size2D
<double>
37 B2DSize(double fX
, double fY
)
42 B2DSize(Size2D
<double> const& rSize
)
47 explicit B2DSize(B2ISize
const& rSize
)
48 : Size2D(rSize
.getWidth(), rSize
.getHeight())
52 /** Transform size by given transformation matrix. */
53 B2DSize
& operator*=(const B2DHomMatrix
& rMatrix
)
55 const double fTempX(rMatrix
.get(0, 0) * getWidth() + rMatrix
.get(0, 1) * getHeight());
56 const double fTempY(rMatrix
.get(1, 0) * getWidth() + rMatrix
.get(1, 1) * getHeight());
62 using Size2D
<double>::operator+=;
63 using Size2D
<double>::operator-=;
64 using Size2D
<double>::operator*=;
65 using Size2D
<double>::operator/=;
66 using Size2D
<double>::operator-;
68 double getLength() const
70 if (fTools::equalZero(getWidth()))
72 return fabs(getHeight());
74 else if (fTools::equalZero(getHeight()))
76 return fabs(getWidth());
79 return hypot(getWidth(), getHeight());
83 template <typename charT
, typename traits
>
84 inline std::basic_ostream
<charT
, traits
>& operator<<(std::basic_ostream
<charT
, traits
>& stream
,
87 return stream
<< "(" << size
.getWidth() << "," << size
.getHeight() << ")";
90 inline B2DSize
operator*(B2DHomMatrix
const& rMatrix
, B2DSize
const& rSize
)
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */