Line data Source code
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 : #ifndef INCLUDED_VCL_TEXTDATA_HXX
21 : #define INCLUDED_VCL_TEXTDATA_HXX
22 :
23 : #include <rtl/ustring.hxx>
24 : #include <svl/smplhint.hxx>
25 : #include <vcl/dllapi.h>
26 :
27 : // for Notify, if all paragraphs were deleted
28 : #define TEXT_PARA_ALL 0xFFFFFFFF
29 :
30 : class TextPaM
31 : {
32 : private:
33 : sal_uLong mnPara;
34 : sal_uInt16 mnIndex;
35 :
36 : public:
37 700 : TextPaM() { mnPara = 0, mnIndex = 0; }
38 244 : TextPaM( sal_uLong nPara, sal_uInt16 nIndex ) { mnPara = nPara, mnIndex = nIndex; }
39 :
40 1076 : sal_uLong GetPara() const { return mnPara; }
41 1154 : sal_uLong& GetPara() { return mnPara; }
42 :
43 752 : sal_uInt16 GetIndex() const { return mnIndex; }
44 524 : sal_uInt16& GetIndex() { return mnIndex; }
45 :
46 : inline bool operator == ( const TextPaM& rPaM ) const;
47 : inline bool operator != ( const TextPaM& rPaM ) const;
48 : inline bool operator < ( const TextPaM& rPaM ) const;
49 : inline bool operator > ( const TextPaM& rPaM ) const;
50 : };
51 :
52 1647 : inline bool TextPaM::operator == ( const TextPaM& rPaM ) const
53 : {
54 1647 : return ( mnPara == rPaM.mnPara ) && ( mnIndex == rPaM.mnIndex );
55 : }
56 :
57 843 : inline bool TextPaM::operator != ( const TextPaM& rPaM ) const
58 : {
59 843 : return !( *this == rPaM );
60 : }
61 :
62 0 : inline bool TextPaM::operator < ( const TextPaM& rPaM ) const
63 : {
64 0 : return ( mnPara < rPaM.mnPara ) ||
65 0 : ( ( mnPara == rPaM.mnPara ) && mnIndex < rPaM.mnIndex );
66 : }
67 :
68 0 : inline bool TextPaM::operator > ( const TextPaM& rPaM ) const
69 : {
70 0 : return ( mnPara > rPaM.mnPara ) ||
71 0 : ( ( mnPara == rPaM.mnPara ) && mnIndex > rPaM.mnIndex );
72 : }
73 :
74 : class VCL_DLLPUBLIC TextSelection
75 : {
76 : private:
77 : TextPaM maStartPaM;
78 : TextPaM maEndPaM;
79 :
80 : public:
81 : TextSelection();
82 : TextSelection( const TextPaM& rPaM );
83 : TextSelection( const TextPaM& rStart, const TextPaM& rEnd );
84 :
85 0 : const TextPaM& GetStart() const { return maStartPaM; }
86 420 : TextPaM& GetStart() { return maStartPaM; }
87 :
88 52 : const TextPaM& GetEnd() const { return maEndPaM; }
89 534 : TextPaM& GetEnd() { return maEndPaM; }
90 :
91 : void Justify();
92 :
93 843 : bool HasRange() const { return maStartPaM != maEndPaM; }
94 :
95 : inline bool operator == ( const TextSelection& rSel ) const;
96 : inline bool operator != ( const TextSelection& rSel ) const;
97 : };
98 :
99 402 : inline bool TextSelection::operator == ( const TextSelection& rSel ) const
100 : {
101 402 : return ( ( maStartPaM == rSel.maStartPaM ) && ( maEndPaM == rSel.maEndPaM ) );
102 : }
103 :
104 402 : inline bool TextSelection::operator != ( const TextSelection& rSel ) const
105 : {
106 402 : return !( *this == rSel );
107 : }
108 :
109 : #define TEXT_HINT_PARAINSERTED 1
110 : #define TEXT_HINT_PARAREMOVED 2
111 : #define TEXT_HINT_PARACONTENTCHANGED 3
112 : #define TEXT_HINT_TEXTHEIGHTCHANGED 4
113 : #define TEXT_HINT_FORMATPARA 5
114 : #define TEXT_HINT_TEXTFORMATTED 6
115 : #define TEXT_HINT_MODIFIED 7
116 : #define TEXT_HINT_BLOCKNOTIFICATION_START 8
117 : #define TEXT_HINT_BLOCKNOTIFICATION_END 9
118 : #define TEXT_HINT_INPUT_START 10
119 : #define TEXT_HINT_INPUT_END 11
120 :
121 : #define TEXT_HINT_VIEWSCROLLED 100
122 : #define TEXT_HINT_VIEWSELECTIONCHANGED 101
123 : #define TEXT_HINT_VIEWCARETCHANGED 102
124 :
125 2088 : class VCL_DLLPUBLIC TextHint : public SfxSimpleHint
126 : {
127 : private:
128 : sal_uLong mnValue;
129 :
130 : public:
131 : TextHint( sal_uLong nId );
132 : TextHint( sal_uLong nId, sal_uLong nValue );
133 :
134 0 : sal_uLong GetValue() const { return mnValue; }
135 : };
136 :
137 : struct TEIMEInfos
138 : {
139 : OUString aOldTextAfterStartPos;
140 : sal_uInt16* pAttribs;
141 : TextPaM aPos;
142 : sal_Int32 nLen;
143 : bool bCursor;
144 : bool bWasCursorOverwrite;
145 :
146 : TEIMEInfos(const TextPaM& rPos, const OUString& rOldTextAfterStartPos);
147 : ~TEIMEInfos();
148 :
149 : void CopyAttribs(const sal_uInt16* pA, sal_Int32 nL);
150 : void DestroyAttribs();
151 : };
152 :
153 : // ----------------- Wrapper for old Tools List -------------------
154 :
155 : #include <vector>
156 : #include <algorithm>
157 :
158 224 : template <class T> class ToolsList : public ::std::vector< T >
159 : {
160 : public:
161 832 : size_t Count() const { return ::std::vector< T >::size(); }
162 0 : size_t GetPos( T pObject ) const { return ( ::std::find( this->begin(), this->end(), pObject ) ) - this->begin(); }
163 2343 : T GetObject( size_t nIndex ) const { return (*this)[nIndex]; }
164 210 : void Insert( T pObject, size_t nPos ) { ::std::vector< T >::insert( this->begin()+nPos, pObject ); }
165 0 : void Remove( size_t nPos ) { ::std::vector< T >::erase( this->begin()+nPos ); }
166 : };
167 :
168 : #endif // INCLUDED_VCL_TEXTDATA_HXX
169 :
170 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|