cool#6580 sw: fix infinite loop when changing document language
[LibreOffice.git] / include / vcl / textdata.hxx
blob339c539597d235a0b86c69353d5f9d49300dbca6
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_VCL_TEXTDATA_HXX
21 #define INCLUDED_VCL_TEXTDATA_HXX
23 #include <sal/types.h>
24 #include <tools/solar.h>
25 #include <rtl/ustring.hxx>
26 #include <svl/hint.hxx>
27 #include <vcl/dllapi.h>
28 #include <memory>
30 enum class ExtTextInputAttr;
32 // for Notify, if all paragraphs were deleted
33 #define TEXT_PARA_ALL SAL_MAX_UINT32
34 #define TEXT_INDEX_ALL SAL_MAX_INT32
36 class TextPaM
38 private:
39 sal_uInt32 mnPara;
40 sal_Int32 mnIndex;
42 public:
43 TextPaM() : mnPara(0), mnIndex(0) {}
44 TextPaM( sal_uInt32 nPara, sal_Int32 nIndex ) : mnPara(nPara), mnIndex(nIndex) {}
46 sal_uInt32 GetPara() const { return mnPara; }
47 sal_uInt32& GetPara() { return mnPara; }
49 sal_Int32 GetIndex() const { return mnIndex; }
50 sal_Int32& GetIndex() { return mnIndex; }
52 inline bool operator == ( const TextPaM& rPaM ) const;
53 inline bool operator != ( const TextPaM& rPaM ) const;
54 inline bool operator < ( const TextPaM& rPaM ) const;
55 inline bool operator > ( const TextPaM& rPaM ) const;
58 inline bool TextPaM::operator == ( const TextPaM& rPaM ) const
60 return ( mnPara == rPaM.mnPara ) && ( mnIndex == rPaM.mnIndex );
63 inline bool TextPaM::operator != ( const TextPaM& rPaM ) const
65 return !( *this == rPaM );
68 inline bool TextPaM::operator < ( const TextPaM& rPaM ) const
70 return ( mnPara < rPaM.mnPara ) ||
71 ( ( mnPara == rPaM.mnPara ) && mnIndex < rPaM.mnIndex );
74 inline bool TextPaM::operator > ( const TextPaM& rPaM ) const
76 return ( mnPara > rPaM.mnPara ) ||
77 ( ( mnPara == rPaM.mnPara ) && mnIndex > rPaM.mnIndex );
80 class VCL_DLLPUBLIC TextSelection
82 private:
83 TextPaM maStartPaM;
84 TextPaM maEndPaM;
86 public:
87 TextSelection();
88 TextSelection( const TextPaM& rPaM );
89 TextSelection( const TextPaM& rStart, const TextPaM& rEnd );
91 const TextPaM& GetStart() const { return maStartPaM; }
92 TextPaM& GetStart() { return maStartPaM; }
94 const TextPaM& GetEnd() const { return maEndPaM; }
95 TextPaM& GetEnd() { return maEndPaM; }
97 void Justify();
99 bool HasRange() const { return maStartPaM != maEndPaM; }
101 inline bool operator == ( const TextSelection& rSel ) const;
102 inline bool operator != ( const TextSelection& rSel ) const;
105 inline bool TextSelection::operator == ( const TextSelection& rSel ) const
107 return ( ( maStartPaM == rSel.maStartPaM ) && ( maEndPaM == rSel.maEndPaM ) );
110 inline bool TextSelection::operator != ( const TextSelection& rSel ) const
112 return !( *this == rSel );
115 class VCL_DLLPUBLIC TextHint : public SfxHint
117 private:
118 sal_uLong const mnValue;
120 public:
121 TextHint( SfxHintId nId );
122 TextHint( SfxHintId nId, sal_uLong nValue );
124 sal_uLong GetValue() const { return mnValue; }
127 struct TEIMEInfos
129 OUString const aOldTextAfterStartPos;
130 std::unique_ptr<ExtTextInputAttr[]> pAttribs;
131 TextPaM aPos;
132 sal_Int32 nLen;
133 bool bWasCursorOverwrite;
135 TEIMEInfos(const TextPaM& rPos, const OUString& rOldTextAfterStartPos);
136 ~TEIMEInfos();
138 void CopyAttribs(const ExtTextInputAttr* pA, sal_Int32 nL);
139 void DestroyAttribs();
142 #endif // INCLUDED_VCL_TEXTDATA_HXX
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */