Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / editeng / txtrange.hxx
blobc6661f687dad474007bb9915ddf228e0adf6a967
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_EDITENG_TXTRANGE_HXX
21 #define INCLUDED_EDITENG_TXTRANGE_HXX
23 #include <editeng/editengdllapi.h>
24 #include <tools/gen.hxx>
25 #include <tools/poly.hxx>
26 #include <deque>
27 #include <optional>
29 namespace basegfx {
30 class B2DPolyPolygon;
33 class EDITENG_DLLPUBLIC TextRanger
35 //! The RangeCache class is used to cache the result of a single range calculation.
36 struct RangeCacheItem
38 Range range; //!< Range for which we calculated results.
39 std::deque<tools::Long> results; //!< Calculated results for the range.
40 RangeCacheItem(const Range& rng) : range(rng) {};
42 std::deque<RangeCacheItem> mRangeCache; //!< Cached range calculations.
43 tools::PolyPolygon maPolyPolygon; // Surface polygon
44 std::optional<tools::PolyPolygon> mpLinePolyPolygon; // Line polygon
45 mutable std::optional<tools::Rectangle> mxBound; // Comprehensive rectangle
46 sal_uInt16 nCacheSize; // Cache-Size
47 sal_uInt16 nRight; // Distance Contour-Text
48 sal_uInt16 nLeft; // Distance Text-Contour
49 sal_uInt16 nUpper; // Distance Contour-Text
50 sal_uInt16 nLower; // Distance Text-Contour
51 sal_uInt32 nPointCount; // Number of polygon points
52 bool bSimple : 1; // Just outside edge
53 bool bInner : 1; // TRUE: Object inline (EditEngine);
54 // FALSE: Object flow (StarWriter);
55 bool bVertical :1;// for vertical writing mode
57 TextRanger( const TextRanger& ) = delete;
58 const tools::Rectangle& GetBoundRect_() const;
59 public:
60 TextRanger( const basegfx::B2DPolyPolygon& rPolyPolygon,
61 const basegfx::B2DPolyPolygon* pLinePolyPolygon,
62 sal_uInt16 nCacheSize, sal_uInt16 nLeft, sal_uInt16 nRight,
63 bool bSimple, bool bInner, bool bVert = false );
64 ~TextRanger();
65 std::deque<tools::Long>* GetTextRanges( const Range& rRange );
66 sal_uInt16 GetRight() const { return nRight; }
67 sal_uInt16 GetLeft() const { return nLeft; }
68 sal_uInt16 GetUpper() const { return nUpper; }
69 sal_uInt16 GetLower() const { return nLower; }
70 sal_uInt32 GetPointCount() const { return nPointCount; }
71 bool IsSimple() const { return bSimple; }
72 bool IsInner() const { return bInner; }
73 bool IsVertical() const { return bVertical; }
74 const tools::Rectangle& GetBoundRect() const
75 { return mxBound ? const_cast< const tools::Rectangle& >(*mxBound) : GetBoundRect_(); }
76 void SetUpper( sal_uInt16 nNew ){ nUpper = nNew; }
77 void SetLower( sal_uInt16 nNew ){ nLower = nNew; }
78 void SetVertical( bool bNew );
81 #endif // _TXTRANGE_HXX
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */