diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-04-12 13:22:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-04-12 14:55:42 +0200 |
commit | f6a1859704bf7f29d6cb55e37ac82affba9da1e5 (patch) | |
tree | baab8996efd790e1f1e862b3ab841bb0609560c4 /include | |
parent | b0e1592bbbe5d25d65b834e7202b4e6cdee435a6 (diff) |
small cleanups in TextRanger
- no need for mpPolyPolygon to be allocated out of line.
- expand out LongDqPtr typedef, not much longer and makes the code
easier to read
- allocate mpBound inline using std::optional
- rename RangeCache to RangeCacheItem
Change-Id: I55032a31eaefa844059edb5f0ee599f1b813ac80
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92079
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/editeng/txtrange.hxx | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/include/editeng/txtrange.hxx b/include/editeng/txtrange.hxx index c26790115ea6..1898a364966b 100644 --- a/include/editeng/txtrange.hxx +++ b/include/editeng/txtrange.hxx @@ -22,30 +22,28 @@ #include <editeng/editengdllapi.h> #include <tools/gen.hxx> +#include <tools/poly.hxx> #include <deque> #include <memory> - -namespace tools { class PolyPolygon; } +#include <optional> namespace basegfx { class B2DPolyPolygon; } -typedef std::deque<long>* LongDqPtr; - class EDITENG_DLLPUBLIC TextRanger { //! The RangeCache class is used to cache the result of a single range calculation. - struct RangeCache + struct RangeCacheItem { Range range; //!< Range for which we calculated results. std::deque<long> results; //!< Calculated results for the range. - RangeCache(const Range& rng) : range(rng) {}; + RangeCacheItem(const Range& rng) : range(rng) {}; }; - std::deque<RangeCache> mRangeCache; //!< Cached range calculations. - std::unique_ptr<tools::PolyPolygon> mpPolyPolygon; // Surface polygon + std::deque<RangeCacheItem> mRangeCache; //!< Cached range calculations. + tools::PolyPolygon maPolyPolygon; // Surface polygon std::unique_ptr<tools::PolyPolygon> mpLinePolyPolygon; // Line polygon - std::unique_ptr<tools::Rectangle> pBound; // Comprehensive rectangle + mutable std::optional<tools::Rectangle> mxBound; // Comprehensive rectangle sal_uInt16 nCacheSize; // Cache-Size sal_uInt16 nRight; // Distance Contour-Text sal_uInt16 nLeft; // Distance Text-Contour @@ -58,14 +56,14 @@ class EDITENG_DLLPUBLIC TextRanger bool bVertical :1;// for vertical writing mode TextRanger( const TextRanger& ) = delete; - const tools::Rectangle& GetBoundRect_(); + const tools::Rectangle& GetBoundRect_() const; public: TextRanger( const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::B2DPolyPolygon* pLinePolyPolygon, sal_uInt16 nCacheSize, sal_uInt16 nLeft, sal_uInt16 nRight, bool bSimple, bool bInner, bool bVert = false ); ~TextRanger(); - LongDqPtr GetTextRanges( const Range& rRange ); + std::deque<long>* GetTextRanges( const Range& rRange ); sal_uInt16 GetRight() const { return nRight; } sal_uInt16 GetLeft() const { return nLeft; } sal_uInt16 GetUpper() const { return nUpper; } @@ -74,8 +72,8 @@ public: bool IsSimple() const { return bSimple; } bool IsInner() const { return bInner; } bool IsVertical() const { return bVertical; } - const tools::Rectangle& GetBoundRect() - { return pBound ? const_cast< const tools::Rectangle& >(*pBound) : GetBoundRect_(); } + const tools::Rectangle& GetBoundRect() const + { return mxBound ? const_cast< const tools::Rectangle& >(*mxBound) : GetBoundRect_(); } void SetUpper( sal_uInt16 nNew ){ nUpper = nNew; } void SetLower( sal_uInt16 nNew ){ nLower = nNew; } void SetVertical( bool bNew ); |