1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #ifndef _TEXTDATA_HXX
25 #define _TEXTDATA_HXX
26
27 #include "svtools/svtdllapi.h"
28 #include <svl/brdcst.hxx>
29 #include <svl/smplhint.hxx>
30 #include <tools/string.hxx>
31
32 // Fuer Notify, wenn alle Absaetze geloescht wurden...
33 #define TEXT_PARA_ALL 0xFFFFFFFF
34
35 class TextPaM
36 {
37 private:
38 sal_uLong mnPara;
39 sal_uInt16 mnIndex;
40
41 public:
TextPaM()42 TextPaM() { mnPara = 0, mnIndex = 0; }
TextPaM(sal_uLong nPara,sal_uInt16 nIndex)43 TextPaM( sal_uLong nPara, sal_uInt16 nIndex ) { mnPara = nPara, mnIndex = nIndex; }
44
GetPara() const45 sal_uLong GetPara() const { return mnPara; }
GetPara()46 sal_uLong& GetPara() { return mnPara; }
47
GetIndex() const48 sal_uInt16 GetIndex() const { return mnIndex; }
GetIndex()49 sal_uInt16& GetIndex() { return mnIndex; }
50
51 inline sal_Bool operator == ( const TextPaM& rPaM ) const;
52 inline sal_Bool operator != ( const TextPaM& rPaM ) const;
53 inline sal_Bool operator < ( const TextPaM& rPaM ) const;
54 inline sal_Bool operator > ( const TextPaM& rPaM ) const;
55 };
56
operator ==(const TextPaM & rPaM) const57 inline sal_Bool TextPaM::operator == ( const TextPaM& rPaM ) const
58 {
59 return ( ( mnPara == rPaM.mnPara ) && ( mnIndex == rPaM.mnIndex ) ) ? sal_True : sal_False;
60 }
61
operator !=(const TextPaM & rPaM) const62 inline sal_Bool TextPaM::operator != ( const TextPaM& rPaM ) const
63 {
64 return !( *this == rPaM );
65 }
66
operator <(const TextPaM & rPaM) const67 inline sal_Bool TextPaM::operator < ( const TextPaM& rPaM ) const
68 {
69 return ( ( mnPara < rPaM.mnPara ) ||
70 ( ( mnPara == rPaM.mnPara ) && mnIndex < rPaM.mnIndex ) ) ? sal_True : sal_False;
71 }
72
operator >(const TextPaM & rPaM) const73 inline sal_Bool TextPaM::operator > ( const TextPaM& rPaM ) const
74 {
75 return ( ( mnPara > rPaM.mnPara ) ||
76 ( ( mnPara == rPaM.mnPara ) && mnIndex > rPaM.mnIndex ) ) ? sal_True : sal_False;
77 }
78
79 class SVT_DLLPUBLIC TextSelection
80 {
81 private:
82 TextPaM maStartPaM;
83 TextPaM maEndPaM;
84
85 public:
86 TextSelection();
87 TextSelection( const TextPaM& rPaM );
88 TextSelection( const TextPaM& rStart, const TextPaM& rEnd );
89
GetStart() const90 const TextPaM& GetStart() const { return maStartPaM; }
GetStart()91 TextPaM& GetStart() { return maStartPaM; }
92
GetEnd() const93 const TextPaM& GetEnd() const { return maEndPaM; }
GetEnd()94 TextPaM& GetEnd() { return maEndPaM; }
95
96 void Justify();
97
HasRange() const98 sal_Bool HasRange() const { return maStartPaM != maEndPaM; }
99
100 inline sal_Bool operator == ( const TextSelection& rSel ) const;
101 inline sal_Bool operator != ( const TextSelection& rSel ) const;
102 };
103
operator ==(const TextSelection & rSel) const104 inline sal_Bool TextSelection::operator == ( const TextSelection& rSel ) const
105 {
106 return ( ( maStartPaM == rSel.maStartPaM ) && ( maEndPaM == rSel.maEndPaM ) );
107 }
108
operator !=(const TextSelection & rSel) const109 inline sal_Bool TextSelection::operator != ( const TextSelection& rSel ) const
110 {
111 return !( *this == rSel );
112 }
113
114 #define TEXT_HINT_PARAINSERTED 1
115 #define TEXT_HINT_PARAREMOVED 2
116 #define TEXT_HINT_PARACONTENTCHANGED 3
117 #define TEXT_HINT_TEXTHEIGHTCHANGED 4
118 #define TEXT_HINT_FORMATPARA 5
119 #define TEXT_HINT_TEXTFORMATTED 6
120 #define TEXT_HINT_MODIFIED 7
121 #define TEXT_HINT_BLOCKNOTIFICATION_START 8
122 #define TEXT_HINT_BLOCKNOTIFICATION_END 9
123 #define TEXT_HINT_INPUT_START 10
124 #define TEXT_HINT_INPUT_END 11
125
126 #define TEXT_HINT_VIEWSCROLLED 100
127 #define TEXT_HINT_VIEWSELECTIONCHANGED 101
128
129 class SVT_DLLPUBLIC TextHint : public SfxSimpleHint
130 {
131 private:
132 sal_uLong mnValue;
133
134 public:
135 TYPEINFO();
136 TextHint( sal_uLong nId );
137 TextHint( sal_uLong nId, sal_uLong nValue );
138
GetValue() const139 sal_uLong GetValue() const { return mnValue; }
SetValue(sal_uLong n)140 void SetValue( sal_uLong n ) { mnValue = n; }
141 };
142
143 struct TEIMEInfos
144 {
145 String aOldTextAfterStartPos;
146 sal_uInt16* pAttribs;
147 TextPaM aPos;
148 sal_uInt16 nLen;
149 sal_Bool bCursor;
150 sal_Bool bWasCursorOverwrite;
151
152 TEIMEInfos( const TextPaM& rPos, const String& rOldTextAfterStartPos );
153 ~TEIMEInfos();
154
155 void CopyAttribs( const sal_uInt16* pA, sal_uInt16 nL );
156 void DestroyAttribs();
157 };
158
159 // ----------------- Wrapper for old Tools List -------------------
160
161 #ifndef INCLUDED_VECTOR
162 #include <vector>
163 #define INCLUDED_VECTOR
164 #endif
165
166 #ifndef INCLUDED_ALGORITHM
167 #include <algorithm>
168 #define INCLUDED_ALGORITHM
169 #endif
170
171 template <class T> class ToolsList : public ::std::vector< T >
172 {
173 public:
Count() const174 sal_uLong Count() const { return static_cast<sal_uLong>(::std::vector< T >::size()); }
GetPos(T pObject) const175 sal_uLong GetPos( T pObject ) const { return ( ::std::find( this->begin(), this->end(), pObject ) ) - this->begin(); }
GetObject(sal_uLong nIndex) const176 T GetObject( sal_uLong nIndex ) const { return (*this)[nIndex]; }
Insert(T pObject,sal_uLong nPos)177 void Insert( T pObject, sal_uLong nPos ) { ::std::vector< T >::insert( this->begin()+nPos, pObject ); }
Remove(sal_uLong nPos)178 void Remove( sal_uLong nPos ) { ::std::vector< T >::erase( this->begin()+nPos ); }
179 };
180
181 #endif // _TEXTDATA_HXX
182