1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _TEXTDATA_HXX 29 #define _TEXTDATA_HXX 30 31 #include "svtools/svtdllapi.h" 32 #include <svl/brdcst.hxx> 33 #include <svl/smplhint.hxx> 34 #include <tools/string.hxx> 35 36 // Fuer Notify, wenn alle Absaetze geloescht wurden... 37 #define TEXT_PARA_ALL 0xFFFFFFFF 38 39 class TextPaM 40 { 41 private: 42 sal_uLong mnPara; 43 sal_uInt16 mnIndex; 44 45 public: 46 TextPaM() { mnPara = 0, mnIndex = 0; } 47 TextPaM( sal_uLong nPara, sal_uInt16 nIndex ) { mnPara = nPara, mnIndex = nIndex; } 48 49 sal_uLong GetPara() const { return mnPara; } 50 sal_uLong& GetPara() { return mnPara; } 51 52 sal_uInt16 GetIndex() const { return mnIndex; } 53 sal_uInt16& GetIndex() { return mnIndex; } 54 55 inline sal_Bool operator == ( const TextPaM& rPaM ) const; 56 inline sal_Bool operator != ( const TextPaM& rPaM ) const; 57 inline sal_Bool operator < ( const TextPaM& rPaM ) const; 58 inline sal_Bool operator > ( const TextPaM& rPaM ) const; 59 }; 60 61 inline sal_Bool TextPaM::operator == ( const TextPaM& rPaM ) const 62 { 63 return ( ( mnPara == rPaM.mnPara ) && ( mnIndex == rPaM.mnIndex ) ) ? sal_True : sal_False; 64 } 65 66 inline sal_Bool TextPaM::operator != ( const TextPaM& rPaM ) const 67 { 68 return !( *this == rPaM ); 69 } 70 71 inline sal_Bool TextPaM::operator < ( const TextPaM& rPaM ) const 72 { 73 return ( ( mnPara < rPaM.mnPara ) || 74 ( ( mnPara == rPaM.mnPara ) && mnIndex < rPaM.mnIndex ) ) ? sal_True : sal_False; 75 } 76 77 inline sal_Bool TextPaM::operator > ( const TextPaM& rPaM ) const 78 { 79 return ( ( mnPara > rPaM.mnPara ) || 80 ( ( mnPara == rPaM.mnPara ) && mnIndex > rPaM.mnIndex ) ) ? sal_True : sal_False; 81 } 82 83 class SVT_DLLPUBLIC TextSelection 84 { 85 private: 86 TextPaM maStartPaM; 87 TextPaM maEndPaM; 88 89 public: 90 TextSelection(); 91 TextSelection( const TextPaM& rPaM ); 92 TextSelection( const TextPaM& rStart, const TextPaM& rEnd ); 93 94 const TextPaM& GetStart() const { return maStartPaM; } 95 TextPaM& GetStart() { return maStartPaM; } 96 97 const TextPaM& GetEnd() const { return maEndPaM; } 98 TextPaM& GetEnd() { return maEndPaM; } 99 100 void Justify(); 101 102 sal_Bool HasRange() const { return maStartPaM != maEndPaM; } 103 104 inline sal_Bool operator == ( const TextSelection& rSel ) const; 105 inline sal_Bool operator != ( const TextSelection& rSel ) const; 106 }; 107 108 inline sal_Bool TextSelection::operator == ( const TextSelection& rSel ) const 109 { 110 return ( ( maStartPaM == rSel.maStartPaM ) && ( maEndPaM == rSel.maEndPaM ) ); 111 } 112 113 inline sal_Bool TextSelection::operator != ( const TextSelection& rSel ) const 114 { 115 return !( *this == rSel ); 116 } 117 118 #define TEXT_HINT_PARAINSERTED 1 119 #define TEXT_HINT_PARAREMOVED 2 120 #define TEXT_HINT_PARACONTENTCHANGED 3 121 #define TEXT_HINT_TEXTHEIGHTCHANGED 4 122 #define TEXT_HINT_FORMATPARA 5 123 #define TEXT_HINT_TEXTFORMATTED 6 124 #define TEXT_HINT_MODIFIED 7 125 #define TEXT_HINT_BLOCKNOTIFICATION_START 8 126 #define TEXT_HINT_BLOCKNOTIFICATION_END 9 127 #define TEXT_HINT_INPUT_START 10 128 #define TEXT_HINT_INPUT_END 11 129 130 #define TEXT_HINT_VIEWSCROLLED 100 131 #define TEXT_HINT_VIEWSELECTIONCHANGED 101 132 133 class SVT_DLLPUBLIC TextHint : public SfxSimpleHint 134 { 135 private: 136 sal_uLong mnValue; 137 138 public: 139 TYPEINFO(); 140 TextHint( sal_uLong nId ); 141 TextHint( sal_uLong nId, sal_uLong nValue ); 142 143 sal_uLong GetValue() const { return mnValue; } 144 void SetValue( sal_uLong n ) { mnValue = n; } 145 }; 146 147 struct TEIMEInfos 148 { 149 String aOldTextAfterStartPos; 150 sal_uInt16* pAttribs; 151 TextPaM aPos; 152 sal_uInt16 nLen; 153 sal_Bool bCursor; 154 sal_Bool bWasCursorOverwrite; 155 156 TEIMEInfos( const TextPaM& rPos, const String& rOldTextAfterStartPos ); 157 ~TEIMEInfos(); 158 159 void CopyAttribs( const sal_uInt16* pA, sal_uInt16 nL ); 160 void DestroyAttribs(); 161 }; 162 163 // ----------------- Wrapper for old Tools List ------------------- 164 165 #ifndef INCLUDED_VECTOR 166 #include <vector> 167 #define INCLUDED_VECTOR 168 #endif 169 170 #ifndef INCLUDED_ALGORITHM 171 #include <algorithm> 172 #define INCLUDED_ALGORITHM 173 #endif 174 175 template <class T> class ToolsList : public ::std::vector< T > 176 { 177 public: 178 sal_uLong Count() const { return static_cast<sal_uLong>(::std::vector< T >::size()); } 179 sal_uLong GetPos( T pObject ) const { return ( ::std::find( this->begin(), this->end(), pObject ) ) - this->begin(); } 180 T GetObject( sal_uLong nIndex ) const { return (*this)[nIndex]; } 181 void Insert( T pObject, sal_uLong nPos ) { ::std::vector< T >::insert( this->begin()+nPos, pObject ); } 182 void Remove( sal_uLong nPos ) { ::std::vector< T >::erase( this->begin()+nPos ); } 183 }; 184 185 #endif // _TEXTDATA_HXX 186