/src/libreoffice/vcl/source/edit/TextLine.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ |
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 <vcl/seleng.hxx> |
23 | | #include <vcl/cursor.hxx> |
24 | | #include <vcl/idle.hxx> |
25 | | #include <vcl/textdata.hxx> |
26 | | |
27 | | #include <cstddef> |
28 | | #include <limits> |
29 | | #include <vector> |
30 | | |
31 | | class TextLine |
32 | | { |
33 | | private: |
34 | | sal_Int32 mnStart; |
35 | | sal_Int32 mnEnd; |
36 | | std::size_t mnStartPortion; |
37 | | std::size_t mnEndPortion; |
38 | | |
39 | | short mnStartX; |
40 | | |
41 | | bool mbInvalid; // for clever formatting/output |
42 | | |
43 | | public: |
44 | | TextLine() |
45 | 0 | : mnStart {0} |
46 | 0 | , mnEnd {0} |
47 | 0 | , mnStartPortion {0} |
48 | 0 | , mnEndPortion {0} |
49 | 0 | , mnStartX {0} |
50 | 0 | , mbInvalid {true} |
51 | 0 | {} |
52 | | |
53 | | bool IsIn( sal_Int32 nIndex, bool bInclEnd ) const |
54 | 0 | { return nIndex >= mnStart && ( bInclEnd ? nIndex <= mnEnd : nIndex < mnEnd ); } |
55 | | |
56 | 0 | void SetStart( sal_Int32 n ) { mnStart = n; } |
57 | 0 | sal_Int32 GetStart() const { return mnStart; } |
58 | | |
59 | 0 | void SetEnd( sal_Int32 n ) { mnEnd = n; } |
60 | 0 | sal_Int32 GetEnd() const { return mnEnd; } |
61 | | |
62 | 0 | void SetStartPortion( std::size_t n ) { mnStartPortion = n; } |
63 | 0 | std::size_t GetStartPortion() const { return mnStartPortion; } |
64 | | |
65 | 0 | void SetEndPortion( std::size_t n ) { mnEndPortion = n; } |
66 | 0 | std::size_t GetEndPortion() const { return mnEndPortion; } |
67 | | |
68 | 0 | sal_Int32 GetLen() const { return mnEnd - mnStart; } |
69 | | |
70 | 0 | bool IsInvalid() const { return mbInvalid; } |
71 | 0 | bool IsValid() const { return !mbInvalid; } |
72 | 0 | void SetInvalid() { mbInvalid = true; } |
73 | 0 | void SetValid() { mbInvalid = false; } |
74 | | |
75 | 0 | short GetStartX() const { return mnStartX; } |
76 | 0 | void SetStartX( short n ) { mnStartX = n; } |
77 | | |
78 | | inline bool operator == ( const TextLine& rLine ) const; |
79 | | }; |
80 | | |
81 | | inline bool TextLine::operator == ( const TextLine& rLine ) const |
82 | 0 | { |
83 | 0 | return mnStart == rLine.mnStart && |
84 | 0 | mnEnd == rLine.mnEnd && |
85 | 0 | mnStartPortion == rLine.mnStartPortion && |
86 | 0 | mnEndPortion == rLine.mnEndPortion; |
87 | 0 | } |
88 | | |
89 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |