Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef LOOKUPTREE_H
21 : #define LOOKUPTREE_H
22 :
23 : #include <sal/types.h>
24 : #include <rtl/ustring.hxx>
25 : #include <editeng/editengdllapi.h>
26 :
27 : /** LookupTree is an interface class that allows for unified access to tree
28 : * structures used for storing dictionnary words as well as their respective
29 : * probabilities.
30 : * It allows you to insert or remove words from the tree, navigate threw the
31 : * tree along its branches and request for a suggestion for autocompletion
32 : * according to the position within the tree.
33 : * It also allows you to attribute a specific language to each tree so that
34 : * it is possible to serve the correct auto completions even within a document
35 : * that contains content in more than one language.
36 : */
37 : class EDITENG_DLLPUBLIC LookupTree
38 : {
39 : public:
40 : explicit inline LookupTree(OUString sLanguage);
41 1 : virtual ~LookupTree() {}
42 :
43 : inline OUString language() const;
44 :
45 : // Resets the current item to root.
46 : virtual void returnToRoot() = 0;
47 :
48 : // Advances from the root position key by key towards the node keyed with
49 : // the last char of sKey.
50 : virtual void gotoNode(OUString sNode) = 0;
51 :
52 : // Advances from the current position towards the node keyed with cKey.
53 : virtual void advance(const sal_Unicode cKey) = 0;
54 :
55 : // Sets the focus to the parent of the current node. Removes the current
56 : // node if it is invalid.
57 : virtual void goBack() = 0;
58 :
59 : // Inserts a complete keyword starting from the root node of the tree.
60 : // Does not change the current position within the tree.
61 : virtual void insert(OUString sKey, const int nProbability = 1) = 0;
62 :
63 : // Inserts a keyword with the given probability at the current position
64 : // within the tree. Does not change the current position within the tree.
65 : virtual void insert(const int nProbability = 1) = 0;
66 :
67 : // Removes a complete keyword starting from the root node of the tree.
68 : // Does not change the current position within the tree.
69 : virtual void remove(OUString sKey) = 0;
70 :
71 : // Returns the suggested autocompletion for the current location within
72 : // the tree.
73 : virtual OUString suggestAutoCompletion() const = 0;
74 :
75 : // Clears the tree and removes any information it contains.
76 : virtual void clear() = 0;
77 :
78 :
79 : private:
80 : const OUString m_sLanguage; // language handled by this tree
81 : };
82 :
83 1 : LookupTree::LookupTree(OUString sLanguage) :
84 1 : m_sLanguage( sLanguage )
85 : {
86 1 : }
87 :
88 : OUString LookupTree::language() const
89 : {
90 : return m_sLanguage;
91 : }
92 :
93 : #endif // LOOKUPTREE_H
94 :
95 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|