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