1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef INCLUDED_SLIDESHOW_DOCTREENODE_HXX 29*cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_DOCTREENODE_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <sal/types.h> 32*cdf0e10cSrcweir #include <vector> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir /* Definition of DocTreeNode class */ 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir namespace slideshow 38*cdf0e10cSrcweir { 39*cdf0e10cSrcweir namespace internal 40*cdf0e10cSrcweir { 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir /** This class represents kind of a DOM tree node for shape 43*cdf0e10cSrcweir text 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir In order to animate subsets of shape text, we need 46*cdf0e10cSrcweir information about the logical and formatting structure of 47*cdf0e10cSrcweir that text (lines, paragraphs, words etc.). This is 48*cdf0e10cSrcweir represented in a tree structure, with DocTreeNodes as the 49*cdf0e10cSrcweir nodes. Instances of this class can be queried from the 50*cdf0e10cSrcweir DocTreeNodeSupplier interface. 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir This class has nothing to do with the Draw document tree. 53*cdf0e10cSrcweir */ 54*cdf0e10cSrcweir class DocTreeNode 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir public: 57*cdf0e10cSrcweir /// Type of shape entity represented by this node 58*cdf0e10cSrcweir enum NodeType 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir NODETYPE_INVALID=0, 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir /// This node represents a full shape 63*cdf0e10cSrcweir NODETYPE_FORMATTING_SHAPE=1, 64*cdf0e10cSrcweir /// This node represents a line 65*cdf0e10cSrcweir NODETYPE_FORMATTING_LINE=2, 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir /// This node represents a full shape 68*cdf0e10cSrcweir NODETYPE_LOGICAL_SHAPE=128, 69*cdf0e10cSrcweir /// This node represents a paragraph 70*cdf0e10cSrcweir NODETYPE_LOGICAL_PARAGRAPH=129, 71*cdf0e10cSrcweir /// This node represents a sentence 72*cdf0e10cSrcweir NODETYPE_LOGICAL_SENTENCE=130, 73*cdf0e10cSrcweir /// This node represents a word 74*cdf0e10cSrcweir NODETYPE_LOGICAL_WORD=131, 75*cdf0e10cSrcweir /// This node represents a character 76*cdf0e10cSrcweir NODETYPE_LOGICAL_CHARACTER_CELL=132 77*cdf0e10cSrcweir }; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir // classificators for above text entity types 80*cdf0e10cSrcweir static bool isLogicalNodeType( NodeType eType ) { return eType > 127; } 81*cdf0e10cSrcweir static bool isFormattingNodeType( NodeType eType ) { return eType > 0 && eType < 128; } 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir /** Create empty tree node 84*cdf0e10cSrcweir */ 85*cdf0e10cSrcweir DocTreeNode() : 86*cdf0e10cSrcweir mnStartIndex(-1), 87*cdf0e10cSrcweir mnEndIndex(-1), 88*cdf0e10cSrcweir meType(NODETYPE_INVALID) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir /** Create tree node from start and end index. 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir Create a tree node for the given range and type. 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir @param nStartIndex 97*cdf0e10cSrcweir Start index 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir @param nEndIndex 100*cdf0e10cSrcweir End index (exclusive) 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir @param eType 103*cdf0e10cSrcweir Node type 104*cdf0e10cSrcweir */ 105*cdf0e10cSrcweir DocTreeNode( sal_Int32 nStartIndex, 106*cdf0e10cSrcweir sal_Int32 nEndIndex, 107*cdf0e10cSrcweir NodeType eType ) : 108*cdf0e10cSrcweir mnStartIndex(nStartIndex), 109*cdf0e10cSrcweir mnEndIndex(nEndIndex), 110*cdf0e10cSrcweir meType(eType) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir bool isEmpty() const { return mnStartIndex == mnEndIndex; } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir sal_Int32 getStartIndex() const { return mnStartIndex; } 117*cdf0e10cSrcweir sal_Int32 getEndIndex() const { return mnEndIndex; } 118*cdf0e10cSrcweir void setStartIndex( sal_Int32 nIndex ) { mnStartIndex = nIndex; } 119*cdf0e10cSrcweir void setEndIndex( sal_Int32 nIndex ) { mnEndIndex = nIndex; } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir NodeType getType() const { return meType; } 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir void reset() 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir mnStartIndex = -1; 126*cdf0e10cSrcweir mnEndIndex = -1; 127*cdf0e10cSrcweir meType = NODETYPE_INVALID; 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir private: 131*cdf0e10cSrcweir sal_Int32 mnStartIndex; 132*cdf0e10cSrcweir sal_Int32 mnEndIndex; 133*cdf0e10cSrcweir NodeType meType; 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir }; 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir typedef ::std::vector< DocTreeNode > VectorOfDocTreeNodes; 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_DOCTREENODE_HXX */ 142