LibreOffice Module svx (master)  1
svdhlpln.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 
20 #ifndef INCLUDED_SVX_SVDHLPLN_HXX
21 #define INCLUDED_SVX_SVDHLPLN_HXX
22 
23 #include <sal/types.h>
24 #include <tools/gen.hxx>
25 
26 #include <svx/svxdllapi.h>
27 
28 #include <vector>
29 #include <memory>
30 
31 class OutputDevice;
32 enum class PointerStyle;
33 
35 
36 #define SDRHELPLINE_POINT_PIXELSIZE 15 /* actual size = PIXELSIZE*2+1 */
37 
38 class SdrHelpLine {
39  Point aPos; // X or Y may be unimportant, depending on the value of eKind
41 
42 public:
43  explicit SdrHelpLine(SdrHelpLineKind eNewKind=SdrHelpLineKind::Point): eKind(eNewKind) {}
44  SdrHelpLine(SdrHelpLineKind eNewKind, const Point& rNewPos): aPos(rNewPos), eKind(eNewKind) {}
45  bool operator==(const SdrHelpLine& rCmp) const { return aPos==rCmp.aPos && eKind==rCmp.eKind; }
46  bool operator!=(const SdrHelpLine& rCmp) const { return !operator==(rCmp); }
47 
48  void SetKind(SdrHelpLineKind eNewKind) { eKind=eNewKind; }
49  SdrHelpLineKind GetKind() const { return eKind; }
50  void SetPos(const Point& rPnt) { aPos=rPnt; }
51  const Point& GetPos() const { return aPos; }
52 
53  PointerStyle GetPointer() const;
54  bool IsHit(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const;
55  // OutputDevice is required because capture points have a fixed pixel size
56  tools::Rectangle GetBoundRect(const OutputDevice& rOut) const;
57 };
58 
59 #define SDRHELPLINE_NOTFOUND 0xFFFF
60 
62  std::vector<std::unique_ptr<SdrHelpLine>> aList;
63 
64 public:
66  SdrHelpLineList(const SdrHelpLineList& rSrcList) { *this=rSrcList; }
67  SdrHelpLineList& operator=(const SdrHelpLineList& rSrcList);
68  bool operator==(const SdrHelpLineList& rCmp) const;
69  bool operator!=(const SdrHelpLineList& rCmp) const { return !operator==(rCmp); }
70  sal_uInt16 GetCount() const { return sal_uInt16(aList.size()); }
71  void Insert(const SdrHelpLine& rHL) { aList.emplace_back(new SdrHelpLine(rHL)); }
72  void Insert(const SdrHelpLine& rHL, sal_uInt16 nPos)
73  {
74  if(nPos==0xFFFF)
75  aList.emplace_back(new SdrHelpLine(rHL));
76  else
77  aList.emplace(aList.begin() + nPos, new SdrHelpLine(rHL));
78  }
79  void Delete(sal_uInt16 nPos)
80  {
81  aList.erase(aList.begin() + nPos);
82  }
83  SdrHelpLine& operator[](sal_uInt16 nPos) { return *aList[nPos]; }
84  const SdrHelpLine& operator[](sal_uInt16 nPos) const { return *aList[nPos]; }
85  sal_uInt16 HitTest(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const;
86 };
87 
88 
89 #endif // INCLUDED_SVX_SVDHLPLN_HXX
90 
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetPos(const Point &rPnt)
Definition: svdhlpln.hxx:50
void Insert(const SdrHelpLine &rHL)
Definition: svdhlpln.hxx:71
Point aPos
Definition: svdhlpln.hxx:39
SdrHelpLine(SdrHelpLineKind eNewKind, const Point &rNewPos)
Definition: svdhlpln.hxx:44
SdrHelpLine & operator[](sal_uInt16 nPos)
Definition: svdhlpln.hxx:83
bool operator!=(const SdrHelpLine &rCmp) const
Definition: svdhlpln.hxx:46
tools::Rectangle GetBoundRect(const OutputDevice &rOut) const
Definition: svdhlpln.cxx:55
bool IsHit(const Point &rPnt, sal_uInt16 nTolLog, const OutputDevice &rOut) const
Definition: svdhlpln.cxx:36
SdrHelpLineKind GetKind() const
Definition: svdhlpln.hxx:49
const Point & GetPos() const
Definition: svdhlpln.hxx:51
const SdrHelpLine & operator[](sal_uInt16 nPos) const
Definition: svdhlpln.hxx:84
PointerStyle GetPointer() const
Definition: svdhlpln.cxx:27
bool operator==(const SdrHelpLine &rCmp) const
Definition: svdhlpln.hxx:45
SdrHelpLineKind eKind
Definition: svdhlpln.hxx:40
std::vector< std::unique_ptr< SdrHelpLine > > aList
Definition: svdhlpln.hxx:62
sal_uInt16 GetCount() const
Definition: svdhlpln.hxx:70
SdrHelpLineList(const SdrHelpLineList &rSrcList)
Definition: svdhlpln.hxx:66
SdrHelpLineKind
Definition: svdhlpln.hxx:34
void SetKind(SdrHelpLineKind eNewKind)
Definition: svdhlpln.hxx:48
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
void Insert(const SdrHelpLine &rHL, sal_uInt16 nPos)
Definition: svdhlpln.hxx:72
bool operator!=(const SdrHelpLineList &rCmp) const
Definition: svdhlpln.hxx:69
PointerStyle
void Delete(sal_uInt16 nPos)
Definition: svdhlpln.hxx:79
SdrHelpLine(SdrHelpLineKind eNewKind=SdrHelpLineKind::Point)
Definition: svdhlpln.hxx:43
bool operator==(const ScCsvLayoutData &rData1, const ScCsvLayoutData &rData2)