LibreOffice Module sw (master)  1
possiz.hxx
Go to the documentation of this file.
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 #pragma once
20 
21 #include <tools/gen.hxx>
22 #include <sal/types.h>
23 #include <swtypes.hxx>
24 
25 // Compared to the SV sizes SwPosSize is always positive
26 class SwPosSize
27 {
30 public:
31  SwPosSize( const SwTwips nW = 0, const SwTwips nH = 0 )
32  : m_nWidth(nW)
33  , m_nHeight(nH)
34  {
35  }
36  explicit SwPosSize( const Size &rSize )
37  : m_nWidth(SwTwips(rSize.Width()))
38  , m_nHeight(SwTwips(rSize.Height()))
39  {
40  }
41 #if defined(__COVERITY__)
42  virtual ~SwPosSize() COVERITY_NOEXCEPT_FALSE {}
43 #else
44  virtual ~SwPosSize() {}
45 #endif
46  SwPosSize(SwPosSize const &) = default;
47  SwPosSize(SwPosSize &&) = default;
48  SwPosSize & operator =(SwPosSize const &) = default;
49  SwPosSize & operator =(SwPosSize &&) = default;
50  SwTwips Height() const { return m_nHeight; }
51  virtual void Height(const SwTwips nNew, const bool = true) { m_nHeight = nNew; }
52  SwTwips Width() const { return m_nWidth; }
53  void Width( const SwTwips nNew ) { m_nWidth = nNew; }
54  Size SvLSize() const { return Size( m_nWidth, m_nHeight ); }
55  void SvLSize( const Size &rSize )
56  {
57  m_nWidth = SwTwips(rSize.Width());
58  m_nHeight = SwTwips(rSize.Height());
59  }
60  void SvXSize( const Size &rSize )
61  {
62  m_nHeight = SwTwips(rSize.Width());
63  m_nWidth = SwTwips(rSize.Height());
64  }
65  SwPosSize& operator=( const Size &rSize )
66  {
67  m_nWidth = SwTwips(rSize.Width());
68  m_nHeight = SwTwips(rSize.Height());
69  return *this;
70  }
71 };
72 
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void Height(const SwTwips nNew, const bool=true)
Definition: possiz.hxx:51
SwTwips m_nHeight
Definition: possiz.hxx:29
void Width(const SwTwips nNew)
Definition: possiz.hxx:53
Size SvLSize() const
Definition: possiz.hxx:54
void SvLSize(const Size &rSize)
Definition: possiz.hxx:55
constexpr tools::Long Width() const
SwPosSize & operator=(SwPosSize const &)=default
SwPosSize & operator=(const Size &rSize)
Definition: possiz.hxx:65
SwTwips m_nWidth
Definition: possiz.hxx:28
virtual ~SwPosSize()
Definition: possiz.hxx:44
SwPosSize(const Size &rSize)
Definition: possiz.hxx:36
void SvXSize(const Size &rSize)
Definition: possiz.hxx:60
SwTwips Height() const
Definition: possiz.hxx:50
tools::Long SwTwips
Definition: swtypes.hxx:52
SwTwips Width() const
Definition: possiz.hxx:52
constexpr tools::Long Height() const
SwPosSize(const SwTwips nW=0, const SwTwips nH=0)
Definition: possiz.hxx:31