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 #ifndef _RSCTREE_HXX 28 #define _RSCTREE_HXX 29 30 #include <tools/link.hxx> 31 #include <rsctools.hxx> 32 33 /****************** C L A S S E S ****************************************/ 34 class BiNode 35 { 36 protected: 37 BiNode* pLeft; // left subtree 38 BiNode* pRight; // right subtree 39 40 public: 41 42 // Wandelt eine doppelt verkettete Liste in 43 // einen binaeren Baum um 44 BiNode * ChangeDLListBTree( BiNode * pList ); 45 46 BiNode(); 47 virtual ~BiNode(); 48 49 50 // Wandelt einen binaeren Baum in eine doppelt 51 // verkettete Liste um 52 BiNode* ChangeBTreeDLList(); 53 54 BiNode * Left() const { return pLeft ; }; 55 BiNode * Right() const{ return pRight ; }; 56 void EnumNodes( Link aLink ) const; 57 }; 58 59 /*************************************************************************/ 60 class NameNode : public BiNode 61 { 62 void SubOrderTree( NameNode * pOrderNode ); 63 64 protected: 65 // pCmp ist Zeiger auf Namen 66 NameNode* Search( const void * pCmp ) const; 67 68 public: 69 NameNode* Left() const { return (NameNode *)pLeft ; }; 70 NameNode* Right() const{ return (NameNode *)pRight ; }; 71 NameNode* Search( const NameNode * pName ) const; 72 // insert a new node in the b-tree 73 sal_Bool Insert( NameNode * pTN, sal_uInt32 * nDepth ); 74 sal_Bool Insert( NameNode* pTN ); 75 virtual COMPARE Compare( const NameNode * ) const; 76 virtual COMPARE Compare( const void * ) const; 77 NameNode* SearchParent( const NameNode * ) const; 78 // return ist neue Root 79 NameNode* Remove( NameNode * ); 80 void OrderTree(); 81 sal_Bool IsOrderTree() const; 82 83 }; 84 85 /*************************************************************************/ 86 class IdNode : public NameNode 87 { 88 virtual COMPARE Compare( const NameNode * ) const; 89 virtual COMPARE Compare( const void * ) const; 90 protected: 91 using NameNode::Search; 92 93 public: 94 95 IdNode* Search( sal_uInt32 nTypName ) const; 96 virtual sal_uInt32 GetId() const; 97 }; 98 99 /*************************************************************************/ 100 class StringNode : public NameNode 101 { 102 virtual COMPARE Compare( const NameNode * ) const; 103 virtual COMPARE Compare( const void * ) const; 104 105 protected: 106 using NameNode::Search; 107 108 ByteString aName; 109 110 public: 111 StringNode(){}; 112 StringNode( const ByteString & rStr ) { aName = rStr; } 113 114 StringNode* Search( const char * ) const; 115 ByteString GetName() const { return aName; } 116 }; 117 118 #endif // _RSCTREE_HXX 119