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