tdf#149529 crash on deref deleted ScDocument*
[LibreOffice.git] / include / vcl / textdata.hxx
blob907a6fdd8852bf0b0386c300f64b5435d70f4cd7
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 <rtl/ustring.hxx>
25 #include <svl/hint.hxx>
26 #include <vcl/dllapi.h>
27 #include <memory>
29 enum class ExtTextInputAttr;
31 // for Notify, if all paragraphs were deleted
32 #define TEXT_PARA_ALL SAL_MAX_UINT32
33 #define TEXT_INDEX_ALL SAL_MAX_INT32
35 class TextPaM
37 private:
38 sal_uInt32 mnPara;
39 sal_Int32 mnIndex;
41 public:
42 TextPaM() : mnPara(0), mnIndex(0) {}
43 TextPaM( sal_uInt32 nPara, sal_Int32 nIndex ) : mnPara(nPara), mnIndex(nIndex) {}
45 sal_uInt32 GetPara() const { return mnPara; }
46 sal_uInt32& GetPara() { return mnPara; }
48 sal_Int32 GetIndex() const { return mnIndex; }
49 sal_Int32& GetIndex() { return mnIndex; }
51 inline bool operator == ( const TextPaM& rPaM ) const;
52 inline bool operator != ( const TextPaM& rPaM ) const;
53 inline bool operator < ( const TextPaM& rPaM ) const;
54 inline bool operator > ( const TextPaM& rPaM ) const;
57 inline bool TextPaM::operator == ( const TextPaM& rPaM ) const
59 return ( mnPara == rPaM.mnPara ) && ( mnIndex == rPaM.mnIndex );
62 inline bool TextPaM::operator != ( const TextPaM& rPaM ) const
64 return !( *this == rPaM );
67 inline bool TextPaM::operator < ( const TextPaM& rPaM ) const
69 return ( mnPara < rPaM.mnPara ) ||
70 ( ( mnPara == rPaM.mnPara ) && mnIndex < rPaM.mnIndex );
73 inline bool TextPaM::operator > ( const TextPaM& rPaM ) const
75 return ( mnPara > rPaM.mnPara ) ||
76 ( ( mnPara == rPaM.mnPara ) && mnIndex > rPaM.mnIndex );
79 class VCL_DLLPUBLIC TextSelection
81 private:
82 TextPaM maStartPaM;
83 TextPaM maEndPaM;
85 public:
86 TextSelection();
87 TextSelection( const TextPaM& rPaM );
88 TextSelection( const TextPaM& rStart, const TextPaM& rEnd );
90 const TextPaM& GetStart() const { return maStartPaM; }
91 TextPaM& GetStart() { return maStartPaM; }
93 const TextPaM& GetEnd() const { return maEndPaM; }
94 TextPaM& GetEnd() { return maEndPaM; }
96 void Justify();
98 bool HasRange() const { return maStartPaM != maEndPaM; }
100 inline bool operator == ( const TextSelection& rSel ) const;
101 inline bool operator != ( const TextSelection& rSel ) const;
104 inline bool TextSelection::operator == ( const TextSelection& rSel ) const
106 return ( ( maStartPaM == rSel.maStartPaM ) && ( maEndPaM == rSel.maEndPaM ) );
109 inline bool TextSelection::operator != ( const TextSelection& rSel ) const
111 return !( *this == rSel );
114 class VCL_DLLPUBLIC TextHint : public SfxHint
116 private:
117 sal_Int32 mnValue;
119 public:
120 TextHint( SfxHintId nId );
121 TextHint( SfxHintId nId, sal_Int32 nValue );
123 sal_Int32 GetValue() const { return mnValue; }
126 struct TEIMEInfos
128 OUString aOldTextAfterStartPos;
129 std::unique_ptr<ExtTextInputAttr[]> pAttribs;
130 TextPaM aPos;
131 sal_Int32 nLen;
132 bool bWasCursorOverwrite;
134 TEIMEInfos(const TextPaM& rPos, const OUString& rOldTextAfterStartPos);
135 ~TEIMEInfos();
137 void CopyAttribs(const ExtTextInputAttr* pA, sal_Int32 nL);
138 void DestroyAttribs();
141 #endif // INCLUDED_VCL_TEXTDATA_HXX
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */