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 INCLUDED_SLIDESHOW_DOCTREENODE_HXX
29 #define INCLUDED_SLIDESHOW_DOCTREENODE_HXX
30 
31 #include <sal/types.h>
32 #include <vector>
33 
34 
35 /* Definition of DocTreeNode class */
36 
37 namespace slideshow
38 {
39     namespace internal
40     {
41 
42         /** This class represents kind of a DOM tree node for shape
43             text
44 
45 			In order to animate subsets of shape text, we need
46 			information about the logical and formatting structure of
47 			that text (lines, paragraphs, words etc.). This is
48 			represented in a tree structure, with DocTreeNodes as the
49 			nodes. Instances of this class can be queried from the
50 			DocTreeNodeSupplier interface.
51 
52 			This class has nothing to do with the Draw document tree.
53          */
54         class DocTreeNode
55         {
56         public:
57             /// Type of shape entity represented by this node
58             enum NodeType
59             {
60                 NODETYPE_INVALID=0,
61 
62                 /// This node represents a full shape
63                 NODETYPE_FORMATTING_SHAPE=1,
64                 /// This node represents a line
65                 NODETYPE_FORMATTING_LINE=2,
66 
67                 /// This node represents a full shape
68                 NODETYPE_LOGICAL_SHAPE=128,
69                 /// This node represents a paragraph
70                 NODETYPE_LOGICAL_PARAGRAPH=129,
71                 /// This node represents a sentence
72                 NODETYPE_LOGICAL_SENTENCE=130,
73                 /// This node represents a word
74                 NODETYPE_LOGICAL_WORD=131,
75                 /// This node represents a character
76                 NODETYPE_LOGICAL_CHARACTER_CELL=132
77             };
78 
79             // classificators for above text entity types
80             static bool isLogicalNodeType( NodeType eType ) { return eType > 127; }
81             static bool isFormattingNodeType( NodeType eType ) { return eType > 0 && eType < 128; }
82 
83             /** Create empty tree node
84              */
85             DocTreeNode() :
86                 mnStartIndex(-1),
87                 mnEndIndex(-1),
88                 meType(NODETYPE_INVALID)
89             {
90             }
91 
92             /** Create tree node from start and end index.
93 
94             	Create a tree node for the given range and type.
95 
96                 @param nStartIndex
97                 Start index
98 
99                 @param nEndIndex
100                 End index (exclusive)
101 
102                 @param eType
103                 Node type
104              */
105             DocTreeNode( sal_Int32 nStartIndex,
106                          sal_Int32 nEndIndex,
107                          NodeType  eType ) :
108                 mnStartIndex(nStartIndex),
109                 mnEndIndex(nEndIndex),
110                 meType(eType)
111             {
112             }
113 
114             bool 				isEmpty() const { return mnStartIndex == mnEndIndex; }
115 
116             sal_Int32 			getStartIndex() const { return mnStartIndex; }
117             sal_Int32 			getEndIndex() const { return mnEndIndex; }
118             void 				setStartIndex( sal_Int32 nIndex ) { mnStartIndex = nIndex; }
119             void 				setEndIndex( sal_Int32 nIndex ) { mnEndIndex = nIndex; }
120 
121             NodeType			getType() const { return meType; }
122 
123             void                reset()
124             {
125                 mnStartIndex = -1;
126                 mnEndIndex   = -1;
127                 meType = NODETYPE_INVALID;
128             }
129 
130         private:
131             sal_Int32	mnStartIndex;
132             sal_Int32	mnEndIndex;
133             NodeType 	meType;
134 
135         };
136 
137         typedef ::std::vector< DocTreeNode > VectorOfDocTreeNodes;
138     }
139 }
140 
141 #endif /* INCLUDED_SLIDESHOW_DOCTREENODE_HXX */
142