summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-02-09 10:49:54 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-02-10 06:54:22 +0100
commit5853b0b25d439caa619cac2edd9853ac76f84217 (patch)
treebeafe3ba9c19581dfbe067edb8771f8075f27585
parentdb42098d99bd8648fcd7b6f669e3e5ad4142670a (diff)
make Pair protected base in Pair/Size/Selection
as part of cleaning up the use of the non-const-ref returning methods. i.e. methods like long& X() And make the classes final. Change-Id: Ice0aa1932124e77f5ed672b527c2a092ec80c481 Reviewed-on: https://gerrit.libreoffice.org/49475 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--include/svx/unoshape.hxx4
-rw-r--r--include/tools/gen.hxx47
-rw-r--r--sd/source/ui/accessibility/AccessibleSlideSorterView.cxx6
-rw-r--r--sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx2
-rw-r--r--sd/source/ui/slidesorter/view/SlideSorterView.cxx2
5 files changed, 47 insertions, 14 deletions
diff --git a/include/svx/unoshape.hxx b/include/svx/unoshape.hxx
index eec731fbe971..11334b4d4940 100644
--- a/include/svx/unoshape.hxx
+++ b/include/svx/unoshape.hxx
@@ -141,7 +141,11 @@ protected:
SdrModel* mpModel;
// translations for writer, which works in TWIPS
void ForceMetricToItemPoolMetric(Pair& rPoint) const throw();
+ void ForceMetricToItemPoolMetric(Point& rPoint) const throw() { ForceMetricToItemPoolMetric(rPoint.toPair()); }
+ void ForceMetricToItemPoolMetric(Size& rPoint) const throw() { ForceMetricToItemPoolMetric(rPoint.toPair()); }
void ForceMetricTo100th_mm(Pair& rPoint) const throw();
+ void ForceMetricTo100th_mm(Point& rPoint) const throw() { ForceMetricTo100th_mm(rPoint.toPair()); }
+ void ForceMetricTo100th_mm(Size& rPoint) const throw() { ForceMetricTo100th_mm(rPoint.toPair()); }
// Dimension arrows change size/position on save/reload (#i59051#)
void ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) const throw();
void ForceMetricTo100th_mm(basegfx::B2DPolyPolygon& rPolyPolygon) const throw();
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 1fb1a283a60e..87e1e54b3eed 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -69,7 +69,7 @@ inline bool equal(Pair const & p1, Pair const & p2)
// Point
-class SAL_WARN_UNUSED SAL_DLLPUBLIC_EXPORT Point : public Pair
+class SAL_WARN_UNUSED SAL_DLLPUBLIC_EXPORT Point final : protected Pair
{
public:
Point() {}
@@ -100,6 +100,11 @@ public:
long getY() const { return Y(); }
void setX(long nX) { X() = nX; }
void setY(long nY) { Y() = nY; }
+
+ Pair const & toPair() const { return *this; }
+ Pair & toPair() { return *this; }
+
+ using Pair::toString;
};
inline void Point::Move( long nHorzMove, long nVertMove )
@@ -158,7 +163,7 @@ inline Point operator/( const Point &rVal1, const long nVal2 )
inline bool operator ==(Point const & p1, Point const & p2)
{
- return tools::detail::equal(p1, p2);
+ return tools::detail::equal(p1.toPair(), p2.toPair());
}
inline bool operator !=(Point const & p1, Point const & p2)
@@ -175,7 +180,7 @@ inline std::basic_ostream<charT, traits> & operator <<(
// Size
-class SAL_WARN_UNUSED Size : public Pair
+class SAL_WARN_UNUSED Size final : protected Pair
{
public:
Size() {}
@@ -191,11 +196,16 @@ public:
long getHeight() const { return Height(); }
void setWidth(long nWidth) { Width() = nWidth; }
void setHeight(long nHeight) { Height() = nHeight; }
+
+ Pair const & toPair() const { return *this; }
+ Pair & toPair() { return *this; }
+
+ using Pair::toString;
};
inline bool operator ==(Size const & s1, Size const & s2)
{
- return tools::detail::equal(s1, s2);
+ return tools::detail::equal(s1.toPair(), s2.toPair());
}
inline bool operator !=(Size const & s1, Size const & s2)
@@ -214,7 +224,7 @@ inline std::basic_ostream<charT, traits> & operator <<(
#define RANGE_MAX LONG_MAX
-class SAL_WARN_UNUSED Range : public Pair
+class SAL_WARN_UNUSED Range final : protected Pair
{
public:
Range() {}
@@ -230,6 +240,11 @@ public:
bool IsInside( long nIs ) const;
void Justify();
+
+ Pair const & toPair() const { return *this; }
+ Pair & toPair() { return *this; }
+
+ using Pair::toString;
};
inline bool Range::IsInside( long nIs ) const
@@ -249,7 +264,7 @@ inline void Range::Justify()
inline bool operator ==(Range const & r1, Range const & r2)
{
- return tools::detail::equal(r1, r2);
+ return tools::detail::equal(r1.toPair(), r2.toPair());
}
inline bool operator !=(Range const & r1, Range const & r2)
@@ -269,7 +284,7 @@ inline std::basic_ostream<charT, traits> & operator <<(
#define SELECTION_MIN LONG_MIN
#define SELECTION_MAX LONG_MAX
-class SAL_WARN_UNUSED Selection : public Pair
+class SAL_WARN_UNUSED Selection final : protected Pair
{
public:
Selection() {}
@@ -292,6 +307,11 @@ public:
long getMin() const { return Min(); }
void setMin(long nMin) { Min() = nMin; }
void setMax(long nMax) { Max() = nMax; }
+
+ Pair const & toPair() const { return *this; }
+ Pair & toPair() { return *this; }
+
+ using Pair::toString;
};
inline bool Selection::IsInside( long nIs ) const
@@ -311,7 +331,7 @@ inline void Selection::Justify()
inline bool operator ==(Selection const & s1, Selection const & s2)
{
- return tools::detail::equal(s1, s2);
+ return tools::detail::equal(s1.toPair(), s2.toPair());
}
inline bool operator !=(Selection const & s1, Selection const & s2)
@@ -341,7 +361,7 @@ inline std::basic_ostream<charT, traits> & operator <<(
/// Ok, now is the time for despair.
namespace tools
{
-class SAL_WARN_UNUSED TOOLS_DLLPUBLIC Rectangle
+class SAL_WARN_UNUSED TOOLS_DLLPUBLIC Rectangle final
{
static constexpr short RECT_EMPTY = -32767;
public:
@@ -714,6 +734,15 @@ inline std::basic_ostream<charT, traits> & operator <<(
<< "@(" << rectangle.getX() << ',' << rectangle.getY() << ")";
}
+inline SvStream& ReadPair( SvStream& rIStream, Point& v ) { return ReadPair(rIStream, v.toPair()); }
+inline SvStream& WritePair( SvStream& rOStream, const Point& v ) { return WritePair(rOStream, v.toPair()); }
+inline SvStream& ReadPair( SvStream& rIStream, Size& v ) { return ReadPair(rIStream, v.toPair()); }
+inline SvStream& WritePair( SvStream& rOStream, const Size& v ) { return WritePair(rOStream, v.toPair()); }
+inline SvStream& ReadPair( SvStream& rIStream, Range& v ) { return ReadPair(rIStream, v.toPair()); }
+inline SvStream& WritePair( SvStream& rOStream, const Range& v ) { return WritePair(rOStream, v.toPair()); }
+inline SvStream& ReadPair( SvStream& rIStream, Selection& v ) { return ReadPair(rIStream, v.toPair()); }
+inline SvStream& WritePair( SvStream& rOStream, const Selection& v ) { return WritePair(rOStream, v.toPair()); }
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx
index 85c65293d485..d070bcd14a6d 100644
--- a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx
+++ b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx
@@ -672,9 +672,9 @@ void AccessibleSlideSorterView::Implementation::UpdateChildren()
return;
}
- const Pair aRange (mrSlideSorter.GetView().GetVisiblePageRange());
- mnFirstVisibleChild = aRange.A();
- mnLastVisibleChild = aRange.B();
+ const Range aRange (mrSlideSorter.GetView().GetVisiblePageRange());
+ mnFirstVisibleChild = aRange.Min();
+ mnLastVisibleChild = aRange.Max();
// Release all children.
Clear();
diff --git a/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx b/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx
index a8349967e801..8da2748ef70d 100644
--- a/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx
+++ b/sd/source/ui/slidesorter/inc/view/SlideSorterView.hxx
@@ -152,7 +152,7 @@ public:
The returned pair of page object indices is empty when the
second index is lower than the first.
*/
- Pair const & GetVisiblePageRange();
+ Range const & GetVisiblePageRange();
/** Add a shape to the page. Typically used from inside
PostModelChange().
diff --git a/sd/source/ui/slidesorter/view/SlideSorterView.cxx b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
index 0a4998df6f22..529c51413a8a 100644
--- a/sd/source/ui/slidesorter/view/SlideSorterView.cxx
+++ b/sd/source/ui/slidesorter/view/SlideSorterView.cxx
@@ -703,7 +703,7 @@ std::shared_ptr<cache::PageCache> const & SlideSorterView::GetPreviewCache()
return mpPreviewCache;
}
-Pair const & SlideSorterView::GetVisiblePageRange()
+Range const & SlideSorterView::GetVisiblePageRange()
{
if ( ! mbPageObjectVisibilitiesValid)
DeterminePageObjectVisibilities();