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	_SWGRAMMARMARKUP_HXX
29 #define	_SWGRAMMARMARKUP_HXX
30 
31 #include <wrong.hxx>
32 #include <vector>
33 
34 /* SwGrammarMarkUp extends the functionality of a "normal" SwWrongList by memorizing
35    the start positions of sentences in the paragraph
36 
37    The whole class is only a temporary solution without usage of virtual functions.
38    At the end the whole SwWrongList stuff should be reworked and replaced by interfaces
39    to deal with all the different wronglists like
40     spell, grammar, smarttag, sentence...
41    "MarkUpList" would be a better name than WrongList.
42 */
43 
44 class SwGrammarMarkUp : public SwWrongList
45 {
46     std::vector< xub_StrLen > maSentence;
47 public:
48     SwGrammarMarkUp() : SwWrongList( WRONGLIST_GRAMMAR ) {}
49     SwGrammarMarkUp( const SwGrammarMarkUp* );
50 
51     virtual ~SwGrammarMarkUp();
52     virtual SwWrongList* Clone();
53     virtual void CopyFrom( const SwWrongList& rCopy );
54 
55     /* SwWrongList::Move() + handling of maSentence */
56     void MoveGrammar( xub_StrLen nPos, long nDiff );
57     /* SwWrongList::SplitList() + handling of maSentence */
58     SwGrammarMarkUp* SplitGrammarList( xub_StrLen nSplitPos );
59     /* SwWrongList::JoinList() + handling of maSentence */
60     void JoinGrammarList( SwGrammarMarkUp* pNext, xub_StrLen nInsertPos );
61     /* SwWrongList::ClearList() + handling of maSentence */
62     void ClearGrammarList( xub_StrLen nSentenceEnd = STRING_LEN );
63     /* setSentence to define the start positionof a sentence,
64        at the moment the end position is given by the next start position */
65     void setSentence( xub_StrLen nStart );
66     /* getSentenceStart returns the last start position of a sentence
67        which is lower or equal to the given parameter */
68     xub_StrLen getSentenceStart( xub_StrLen nPos );
69     /* getSentenceEnd returns the first start position of a sentence
70        which is greater than the given parameter */
71     xub_StrLen getSentenceEnd( xub_StrLen nPos );
72 };
73 
74 #endif
75