1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
23 #include <sal/types.h>
24 #include <tools/gen.hxx>
25 #include <vcl/kernarray.hxx>
32 KernArray maPositions
;
33 std::vector
<sal_Bool
> maKashidaPositions
;
34 sal_Int32 mnTextWidth
= 0;
35 sal_Int32 mnStartPosX
= 0;
36 sal_Int32 mnNextLinePosXDiff
= 0;
37 sal_Int32 mnStart
= 0; // could be replaced by nStartPortion
38 sal_Int32 mnEnd
= 0; // could be replaced by nEndPortion
39 sal_Int32 mnStartPortion
= 0;
40 sal_Int32 mnEndPortion
= 0;
41 sal_uInt16 mnHeight
= 0; // Total height of the line
42 sal_uInt16 mnTextHeight
= 0; // Pure Text height
43 sal_uInt16 mnMaxAscent
= 0;
44 bool mbHangingPunctuation
: 1 = false;
45 bool mbInvalid
: 1 = true; // for skillful formatting
49 EditLine(const EditLine
& rEditLine
)
50 : mnStart(rEditLine
.mnStart
)
51 , mnEnd(rEditLine
.mnEnd
)
52 , mnStartPortion(rEditLine
.mnStartPortion
)
53 , mnEndPortion(rEditLine
.mnEndPortion
)
54 , mbHangingPunctuation(rEditLine
.mbHangingPunctuation
)
58 bool IsIn(sal_Int32 nIndex
) const { return nIndex
>= mnStart
&& nIndex
< mnEnd
; }
60 bool IsIn(sal_Int32 nIndex
, bool bIncludeEnd
) const
62 return nIndex
>= mnStart
&& (bIncludeEnd
? nIndex
<= mnEnd
: nIndex
< mnEnd
);
65 void SetStart(sal_Int32 nStart
) { mnStart
= nStart
; }
66 sal_Int32
GetStart() const { return mnStart
; }
67 sal_Int32
& GetStart() { return mnStart
; }
69 void SetEnd(sal_Int32 nEnd
) { mnEnd
= nEnd
; }
70 sal_Int32
GetEnd() const { return mnEnd
; }
71 sal_Int32
& GetEnd() { return mnEnd
; }
73 void SetStartPortion(sal_Int32 nStartPortion
) { mnStartPortion
= nStartPortion
; }
74 sal_Int32
GetStartPortion() const { return mnStartPortion
; }
75 sal_Int32
& GetStartPortion() { return mnStartPortion
; }
77 void SetEndPortion(sal_Int32 nEndPortion
) { mnEndPortion
= nEndPortion
; }
78 sal_Int32
GetEndPortion() const { return mnEndPortion
; }
79 sal_Int32
& GetEndPortion() { return mnEndPortion
; }
81 void SetHeight(sal_uInt16 nHeight
, sal_uInt16 nTextHeight
= 0);
82 sal_uInt16
GetHeight() const { return mnHeight
; }
83 sal_uInt16
GetTxtHeight() const { return mnTextHeight
; }
85 void SetTextWidth(sal_Int32 nTextWidth
) { mnTextWidth
= nTextWidth
; }
86 sal_Int32
GetTextWidth() const { return mnTextWidth
; }
88 void SetMaxAscent(sal_uInt16 nMaxAscent
) { mnMaxAscent
= nMaxAscent
; }
89 sal_uInt16
GetMaxAscent() const { return mnMaxAscent
; }
91 void SetHangingPunctuation(bool bHangingPunctuation
)
93 mbHangingPunctuation
= bHangingPunctuation
;
95 bool IsHangingPunctuation() const { return mbHangingPunctuation
; }
97 sal_Int32
GetLen() const { return mnEnd
- mnStart
; }
99 sal_Int32
GetStartPosX() const { return mnStartPosX
; }
100 void SetStartPosX(sal_Int32 nStart
);
101 sal_Int32
GetNextLinePosXDiff() const { return mnNextLinePosXDiff
; }
102 void SetNextLinePosXDiff(sal_Int32 nDiff
) { mnNextLinePosXDiff
= nDiff
; }
103 Size
CalcTextSize(ParaPortion
& rParaPortion
);
105 bool IsInvalid() const { return mbInvalid
; }
106 bool IsValid() const { return !mbInvalid
; }
107 void SetInvalid() { mbInvalid
= true; }
108 void SetValid() { mbInvalid
= false; }
110 bool IsEmpty() const { return mnEnd
<= mnStart
; }
112 KernArray
& GetCharPosArray() { return maPositions
; }
113 const KernArray
& GetCharPosArray() const { return maPositions
; }
115 std::vector
<sal_Bool
>& GetKashidaArray() { return maKashidaPositions
; }
116 const std::vector
<sal_Bool
>& GetKashidaArray() const { return maKashidaPositions
; }
118 EditLine
* Clone() const;
120 EditLine
& operator=(const EditLine
& rLine
)
123 mnStart
= rLine
.mnStart
;
124 mnEndPortion
= rLine
.mnEndPortion
;
125 mnStartPortion
= rLine
.mnStartPortion
;
129 bool operator==(const EditLine
& rLine
) const
131 return mnStart
== rLine
.mnStart
&& mnEnd
== rLine
.mnEnd
132 && mnStartPortion
== rLine
.mnStartPortion
&& mnEndPortion
== rLine
.mnEndPortion
;
136 template <typename charT
, typename traits
>
137 inline std::basic_ostream
<charT
, traits
>& operator<<(std::basic_ostream
<charT
, traits
>& stream
,
138 EditLine
const& rLine
)
140 return stream
<< "EditLine(" << rLine
.GetStart() << ", " << rLine
.GetEnd() << ")";
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */