diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/editeng/LatinLookupTree.hxx | 74 | ||||
-rw-r--r-- | include/editeng/LatinTreeNode.hxx | 48 | ||||
-rw-r--r-- | include/editeng/LookupTree.hxx | 95 | ||||
-rw-r--r-- | include/editeng/Node.hxx | 102 | ||||
-rw-r--r-- | include/editeng/TreeHead.hxx | 49 |
5 files changed, 0 insertions, 368 deletions
diff --git a/include/editeng/LatinLookupTree.hxx b/include/editeng/LatinLookupTree.hxx deleted file mode 100644 index e35d62bec0b6..000000000000 --- a/include/editeng/LatinLookupTree.hxx +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_EDITENG_LATINLOOKUPTREE_HXX -#define INCLUDED_EDITENG_LATINLOOKUPTREE_HXX - -#include <editeng/LookupTree.hxx> -#include <editeng/TreeHead.hxx> -#include <editeng/editengdllapi.h> - -/** - * LatinLookupTree implements a tree that is optimized for storing and looking - * up words that mainly consist of roman characters, although any other - * language can be handled, too. - */ -class EDITENG_DLLPUBLIC LatinLookupTree : public LookupTree, public TreeHead -{ -public: - - explicit LatinLookupTree(OUString sLanguage); - ~LatinLookupTree(); - - - /* =================== Implemented Virtuals From LookupTree =================== */ - void returnToRoot(); - void gotoNode(OUString sNode); - void advance(const sal_Unicode a); - void goBack(); - void insert(OUString sKey, const int nProbability = 1); - void insert(const int nProbability = 1); - void remove(OUString sKey); - OUString suggestAutoCompletion() const; - void clear(); - - /* =================== Implemented Virtuals From Node =================== */ - bool isSeparatedlyHandled(const sal_Unicode cKey) const; - Node*& getChildRef(const sal_Unicode cKey, bool bCreatePlaceholder = false); - void evaluateSeparateStorage(int& nSuggest, Node*& pSuggest) const; - void freeMemory(); - - - /* =================== Implemented Virtual From TreeHead =================== */ - Node* newNode(Node* pParent, const sal_Unicode cKey, const int nProbability = 0); - - /* =================== Member Variables =================== */ - // position of lower case letter 'a' within the selected char encoding. - static const unsigned int our_nLowerCaseA; - - // position of upper case letter 'A' within the selected char encoding. - static const unsigned int our_nUpperCaseA; - -private: - Node* m_pLeaves[52]; // handles [a-z] and [A-Z] -}; - -#endif // INCLUDED_EDITENG_LATINLOOKUPTREE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/editeng/LatinTreeNode.hxx b/include/editeng/LatinTreeNode.hxx deleted file mode 100644 index 09a82f8b67e8..000000000000 --- a/include/editeng/LatinTreeNode.hxx +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_EDITENG_LATINTREENODE_HXX -#define INCLUDED_EDITENG_LATINTREENODE_HXX - -#include <editeng/Node.hxx> - -/** - * LatinTreeNode represents a node within a LatinLookupTree. As en external - * caller, you should never have to do anything with this class directly. - * Use the class LatinLookupTree instead for constructing a new tree. - */ -class LatinTreeNode : public Node -{ -public: - explicit LatinTreeNode(TreeHead *pHead, Node* pParent, const sal_Unicode cKey, const int nProbability = 0); - ~LatinTreeNode(); - - /* =================== Implemented Virtuals From Node =================== */ - bool isSeparatedlyHandled(const sal_Unicode cKey) const; - Node*& getChildRef(const sal_Unicode cKey, bool bCreatePlaceholder = false); - void evaluateSeparateStorage(int& nSuggest, Node*& pSuggest) const; - void freeMemory(); - -private: - Node* m_pLeaves[26]; // handles [a-z] -}; - -#endif // INCLUDED_EDITENG_LATINTREENODE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/editeng/LookupTree.hxx b/include/editeng/LookupTree.hxx deleted file mode 100644 index c961d1194c26..000000000000 --- a/include/editeng/LookupTree.hxx +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_EDITENG_LOOKUPTREE_HXX -#define INCLUDED_EDITENG_LOOKUPTREE_HXX - -#include <sal/types.h> -#include <rtl/ustring.hxx> -#include <editeng/editengdllapi.h> - -/** LookupTree is an interface class that allows for unified access to tree - * structures used for storing dictionnary words as well as their respective - * probabilities. - * It allows you to insert or remove words from the tree, navigate threw the - * tree along its branches and request for a suggestion for autocompletion - * according to the position within the tree. - * It also allows you to attribute a specific language to each tree so that - * it is possible to serve the correct auto completions even within a document - * that contains content in more than one language. - */ -class EDITENG_DLLPUBLIC LookupTree -{ -public: - explicit inline LookupTree(OUString sLanguage); - virtual ~LookupTree() {} - - inline OUString language() const; - - // Resets the current item to root. - virtual void returnToRoot() = 0; - - // Advances from the root position key by key towards the node keyed with - // the last char of sKey. - virtual void gotoNode(OUString sNode) = 0; - - // Advances from the current position towards the node keyed with cKey. - virtual void advance(const sal_Unicode cKey) = 0; - - // Sets the focus to the parent of the current node. Removes the current - // node if it is invalid. - virtual void goBack() = 0; - - // Inserts a complete keyword starting from the root node of the tree. - // Does not change the current position within the tree. - virtual void insert(OUString sKey, const int nProbability = 1) = 0; - - // Inserts a keyword with the given probability at the current position - // within the tree. Does not change the current position within the tree. - virtual void insert(const int nProbability = 1) = 0; - - // Removes a complete keyword starting from the root node of the tree. - // Does not change the current position within the tree. - virtual void remove(OUString sKey) = 0; - - // Returns the suggested autocompletion for the current location within - // the tree. - virtual OUString suggestAutoCompletion() const = 0; - - // Clears the tree and removes any information it contains. - virtual void clear() = 0; - - -private: - const OUString m_sLanguage; // language handled by this tree -}; - -LookupTree::LookupTree(OUString sLanguage) : - m_sLanguage( sLanguage ) -{ -} - -OUString LookupTree::language() const -{ - return m_sLanguage; -} - -#endif // INCLUDED_EDITENG_LOOKUPTREE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/editeng/Node.hxx b/include/editeng/Node.hxx deleted file mode 100644 index 62e775d818b3..000000000000 --- a/include/editeng/Node.hxx +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_EDITENG_NODE_HXX -#define INCLUDED_EDITENG_NODE_HXX - -#include <sal/types.h> -#include <rtl/ustring.hxx> -#include <list> - -class TreeHead; - -/** - * Node represents a node within a LookupTree. As en external caller, you - * should never have to do anything with this class directly. - * Use any of the classes derived from LookupTree instead for constructing a - * new tree. - */ -class Node -{ -public: - //explicit Node(TreeHead* const pHead); - explicit Node(TreeHead* const pHead, Node* const pParent = NULL, - const sal_Unicode cKey = 0, const int nProbability = 0); - - virtual ~Node(); - - // Removes the specified child from this node. Make sure you may remove it - // before doing so. - void removeChild(Node*& pChild); - - // Inserts a complete keyword starting from this node of the tree. - void insertKey(OUString sKey, const int nProbability); - // Removes a complete keyword starting from this node of the tree. - void removeKey(OUString sKey); - - // Returns the child node keyed with cKey. - Node* advanceKey(const sal_Unicode cKey); - - // Use this to inform a parent about its child having changed. - // Call this only with nProbability = 0 if you have made sure the node can - // be removed. - void childHasChanged(Node* pChild, const int nProbability, bool bAllowRemoval = false); - - // Rechose the node that is suggested for auto-completion - void reevaluateSuggestion(bool& bNodeProbabilityChanged); - - - /* =================== Virtuals =================== */ - virtual bool isSeparatedlyHandled(const sal_Unicode cKey) const = 0; - - // Returns a reference to the pointer to the child node for the requested - // char. Returns NULL if no such child could be found. - // IMPORTANT: In the latter case, you may NOT overwrite the return value, - // if you did not set bCreatePlaceholder to true. - virtual Node*& getChildRef(const sal_Unicode cKey, bool bCreatePlaceholder = false) = 0; - - // Sets nSuggest to the highest probability within the subtree and pSuggest - // to point to the (first) node with this probability. - virtual void evaluateSeparateStorage(int& nSuggest, Node*& pSuggest) const = 0; - - // Removes all child nodes and clears all memory. - virtual void freeMemory() = 0; - - /* =================== Member Variables =================== */ - const sal_Unicode m_cKey; // the char represented by this node - int m_nKeyProbability; // the number of occurrences of this key - - // the highest KeyProbability in the tree sprouting from this node - int m_nHighestProbaInSubtree; - - Node* const m_pParent; // the parent of this node - Node* m_pSuggest; // next node in chain to the suggested autocompletion - - TreeHead* const m_pHead; // head of the tree - - unsigned short m_nChildren; // the number of children of the node - std::list<Node*> m_lChildren; // all chars not handled by array - - // Allows returning a reference to a valid Null pointer. May NOT be overwritten. - static Node* our_pNodeNullPointer; -}; - -#endif // INCLUDED_EDITENG_NODE_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/editeng/TreeHead.hxx b/include/editeng/TreeHead.hxx deleted file mode 100644 index f36aff5f112f..000000000000 --- a/include/editeng/TreeHead.hxx +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_EDITENG_TREEHEAD_HXX -#define INCLUDED_EDITENG_TREEHEAD_HXX - -#include <editeng/Node.hxx> - -/** - * Represents the root node of a LookupTree. - */ -class TreeHead : public Node -{ -public: - explicit inline TreeHead(); - virtual ~TreeHead() {} - - /* =================== Virtuals =================== */ - virtual Node* newNode(Node* pParent, const sal_Unicode cKey, const int nProbability = 0) = 0; - - /* =================== Member Variables =================== */ - Node* m_pCurrent; // current location within the tree -}; - -TreeHead::TreeHead() : - Node( this ), - m_pCurrent( this ) -{ -} - -#endif // INCLUDED_EDITENG_TREEHEAD_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |