1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: edtspell.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include <svx/svxbox.hxx>
35 #include <svx/svxenum.hxx>
36 #include <svx/splwrap.hxx>
37 #include <svx/svxacorr.hxx>
38 #include <com/sun/star/uno/Reference.h>
39 #include "svx/svxdllapi.h"
41 namespace com
{ namespace sun
{ namespace star
{ namespace linguistic2
{
50 class EditSpellWrapper
: public SvxSpellWrapper
57 virtual void SpellStart( SvxSpellArea eArea
);
58 virtual BOOL
SpellContinue(); // Bereich pruefen
59 virtual void ReplaceAll( const String
&rNewText
, INT16 nLanguage
);
60 virtual void SpellEnd();
61 virtual BOOL
SpellMore();
62 virtual BOOL
HasOtherCnt();
63 virtual void ScrollArea();
64 virtual void ChangeWord( const String
& rNewWord
, const USHORT nLang
);
65 virtual void ChangeThesWord( const String
& rNewWord
);
66 virtual void AutoCorrect( const String
& rOldWord
, const String
& rNewWord
);
69 EditSpellWrapper( Window
* pWin
,
70 ::com::sun::star::uno::Reference
<
71 ::com::sun::star::linguistic2::XSpellChecker1
> &xChecker
,
73 BOOL bIsAllRight
, EditView
* pView
);
83 WrongRange( USHORT nS
, USHORT nE
) { nStart
= nS
; nEnd
= nE
; }
86 SV_DECL_VARARR( WrongRanges
, WrongRange
, 4, 4 )
87 #define NOT_INVALID 0xFFFF
89 class WrongList
: private WrongRanges
95 BOOL
DbgIsBuggy() const;
101 BOOL
IsInvalid() const { return nInvalidStart
!= NOT_INVALID
; }
102 void SetValid() { nInvalidStart
= NOT_INVALID
; nInvalidEnd
= 0; }
103 void MarkInvalid( USHORT nS
, USHORT nE
)
105 if ( ( nInvalidStart
== NOT_INVALID
) || ( nInvalidStart
> nS
) )
107 if ( nInvalidEnd
< nE
)
111 USHORT
Count() const { return WrongRanges::Count(); }
113 // Wenn man weiss was man tut:
114 WrongRange
& GetObject( USHORT n
) const { return WrongRanges::GetObject( n
); }
115 void InsertWrong( const WrongRange
& rWrong
, USHORT nPos
);
117 USHORT
GetInvalidStart() const { return nInvalidStart
; }
118 USHORT
& GetInvalidStart() { return nInvalidStart
; }
120 USHORT
GetInvalidEnd() const { return nInvalidEnd
; }
121 USHORT
& GetInvalidEnd() { return nInvalidEnd
; }
123 void TextInserted( USHORT nPos
, USHORT nChars
, BOOL bPosIsSep
);
124 void TextDeleted( USHORT nPos
, USHORT nChars
);
126 void ResetRanges() { Remove( 0, Count() ); }
127 BOOL
HasWrongs() const { return Count() != 0; }
128 void InsertWrong( USHORT nStart
, USHORT nEnd
, BOOL bClearRange
);
129 BOOL
NextWrong( USHORT
& rnStart
, USHORT
& rnEnd
) const;
130 BOOL
HasWrong( USHORT nStart
, USHORT nEnd
) const;
131 BOOL
HasAnyWrong( USHORT nStart
, USHORT nEnd
) const;
132 void ClearWrongs( USHORT nStart
, USHORT nEnd
, const ContentNode
* pNode
);
133 void MarkWrongsInvalid();
135 WrongList
* Clone() const;
138 bool operator==(const WrongList
& rCompare
) const;
141 inline void WrongList::InsertWrong( const WrongRange
& rWrong
, USHORT nPos
)
143 WrongRanges::Insert( rWrong
, nPos
);
145 DBG_ASSERT( !DbgIsBuggy(), "Insert: WrongList kaputt!" );
151 class SVX_DLLPUBLIC EdtAutoCorrDoc
: public SvxAutoCorrDoc
153 ImpEditEngine
* pImpEE
;
154 ContentNode
* pCurNode
;
157 BOOL bAllowUndoAction
;
161 void ImplStartUndoAction();
164 EdtAutoCorrDoc( ImpEditEngine
* pImpEE
, ContentNode
* pCurNode
, USHORT nCrsr
, xub_Unicode cIns
);
167 virtual BOOL
Delete( USHORT nStt
, USHORT nEnd
);
168 virtual BOOL
Insert( USHORT nPos
, const String
& rTxt
);
169 virtual BOOL
Replace( USHORT nPos
, const String
& rTxt
);
171 virtual BOOL
SetAttr( USHORT nStt
, USHORT nEnd
, USHORT nSlotId
, SfxPoolItem
& );
172 virtual BOOL
SetINetAttr( USHORT nStt
, USHORT nEnd
, const String
& rURL
);
174 virtual BOOL
HasSymbolChars( USHORT nStt
, USHORT nEnd
);
176 virtual const String
* GetPrevPara( BOOL bAtNormalPos
);
178 virtual BOOL
ChgAutoCorrWord( USHORT
& rSttPos
, USHORT nEndPos
,
179 SvxAutoCorrect
& rACorrect
, const String
** ppPara
);
181 virtual LanguageType
GetLanguage( USHORT nPos
, BOOL bPrevPara
= FALSE
) const;
183 USHORT
GetCursor() const { return nCursor
; }