1*aaef562fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*aaef562fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*aaef562fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*aaef562fSAndrew Rist * distributed with this work for additional information 6*aaef562fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*aaef562fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*aaef562fSAndrew Rist * "License"); you may not use this file except in compliance 9*aaef562fSAndrew Rist * with the License. You may obtain a copy of the License at 10*aaef562fSAndrew Rist * 11*aaef562fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*aaef562fSAndrew Rist * 13*aaef562fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*aaef562fSAndrew Rist * software distributed under the License is distributed on an 15*aaef562fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*aaef562fSAndrew Rist * KIND, either express or implied. See the License for the 17*aaef562fSAndrew Rist * specific language governing permissions and limitations 18*aaef562fSAndrew Rist * under the License. 19*aaef562fSAndrew Rist * 20*aaef562fSAndrew Rist *************************************************************/ 21*aaef562fSAndrew Rist 22*aaef562fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef INCLUDED_SLIDESHOW_DOCTREENODE_HXX 25cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_DOCTREENODE_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <sal/types.h> 28cdf0e10cSrcweir #include <vector> 29cdf0e10cSrcweir 30cdf0e10cSrcweir 31cdf0e10cSrcweir /* Definition of DocTreeNode class */ 32cdf0e10cSrcweir 33cdf0e10cSrcweir namespace slideshow 34cdf0e10cSrcweir { 35cdf0e10cSrcweir namespace internal 36cdf0e10cSrcweir { 37cdf0e10cSrcweir 38cdf0e10cSrcweir /** This class represents kind of a DOM tree node for shape 39cdf0e10cSrcweir text 40cdf0e10cSrcweir 41cdf0e10cSrcweir In order to animate subsets of shape text, we need 42cdf0e10cSrcweir information about the logical and formatting structure of 43cdf0e10cSrcweir that text (lines, paragraphs, words etc.). This is 44cdf0e10cSrcweir represented in a tree structure, with DocTreeNodes as the 45cdf0e10cSrcweir nodes. Instances of this class can be queried from the 46cdf0e10cSrcweir DocTreeNodeSupplier interface. 47cdf0e10cSrcweir 48cdf0e10cSrcweir This class has nothing to do with the Draw document tree. 49cdf0e10cSrcweir */ 50cdf0e10cSrcweir class DocTreeNode 51cdf0e10cSrcweir { 52cdf0e10cSrcweir public: 53cdf0e10cSrcweir /// Type of shape entity represented by this node 54cdf0e10cSrcweir enum NodeType 55cdf0e10cSrcweir { 56cdf0e10cSrcweir NODETYPE_INVALID=0, 57cdf0e10cSrcweir 58cdf0e10cSrcweir /// This node represents a full shape 59cdf0e10cSrcweir NODETYPE_FORMATTING_SHAPE=1, 60cdf0e10cSrcweir /// This node represents a line 61cdf0e10cSrcweir NODETYPE_FORMATTING_LINE=2, 62cdf0e10cSrcweir 63cdf0e10cSrcweir /// This node represents a full shape 64cdf0e10cSrcweir NODETYPE_LOGICAL_SHAPE=128, 65cdf0e10cSrcweir /// This node represents a paragraph 66cdf0e10cSrcweir NODETYPE_LOGICAL_PARAGRAPH=129, 67cdf0e10cSrcweir /// This node represents a sentence 68cdf0e10cSrcweir NODETYPE_LOGICAL_SENTENCE=130, 69cdf0e10cSrcweir /// This node represents a word 70cdf0e10cSrcweir NODETYPE_LOGICAL_WORD=131, 71cdf0e10cSrcweir /// This node represents a character 72cdf0e10cSrcweir NODETYPE_LOGICAL_CHARACTER_CELL=132 73cdf0e10cSrcweir }; 74cdf0e10cSrcweir 75cdf0e10cSrcweir // classificators for above text entity types isLogicalNodeType(NodeType eType)76cdf0e10cSrcweir static bool isLogicalNodeType( NodeType eType ) { return eType > 127; } isFormattingNodeType(NodeType eType)77cdf0e10cSrcweir static bool isFormattingNodeType( NodeType eType ) { return eType > 0 && eType < 128; } 78cdf0e10cSrcweir 79cdf0e10cSrcweir /** Create empty tree node 80cdf0e10cSrcweir */ DocTreeNode()81cdf0e10cSrcweir DocTreeNode() : 82cdf0e10cSrcweir mnStartIndex(-1), 83cdf0e10cSrcweir mnEndIndex(-1), 84cdf0e10cSrcweir meType(NODETYPE_INVALID) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir } 87cdf0e10cSrcweir 88cdf0e10cSrcweir /** Create tree node from start and end index. 89cdf0e10cSrcweir 90cdf0e10cSrcweir Create a tree node for the given range and type. 91cdf0e10cSrcweir 92cdf0e10cSrcweir @param nStartIndex 93cdf0e10cSrcweir Start index 94cdf0e10cSrcweir 95cdf0e10cSrcweir @param nEndIndex 96cdf0e10cSrcweir End index (exclusive) 97cdf0e10cSrcweir 98cdf0e10cSrcweir @param eType 99cdf0e10cSrcweir Node type 100cdf0e10cSrcweir */ DocTreeNode(sal_Int32 nStartIndex,sal_Int32 nEndIndex,NodeType eType)101cdf0e10cSrcweir DocTreeNode( sal_Int32 nStartIndex, 102cdf0e10cSrcweir sal_Int32 nEndIndex, 103cdf0e10cSrcweir NodeType eType ) : 104cdf0e10cSrcweir mnStartIndex(nStartIndex), 105cdf0e10cSrcweir mnEndIndex(nEndIndex), 106cdf0e10cSrcweir meType(eType) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir } 109cdf0e10cSrcweir isEmpty() const110cdf0e10cSrcweir bool isEmpty() const { return mnStartIndex == mnEndIndex; } 111cdf0e10cSrcweir getStartIndex() const112cdf0e10cSrcweir sal_Int32 getStartIndex() const { return mnStartIndex; } getEndIndex() const113cdf0e10cSrcweir sal_Int32 getEndIndex() const { return mnEndIndex; } setStartIndex(sal_Int32 nIndex)114cdf0e10cSrcweir void setStartIndex( sal_Int32 nIndex ) { mnStartIndex = nIndex; } setEndIndex(sal_Int32 nIndex)115cdf0e10cSrcweir void setEndIndex( sal_Int32 nIndex ) { mnEndIndex = nIndex; } 116cdf0e10cSrcweir getType() const117cdf0e10cSrcweir NodeType getType() const { return meType; } 118cdf0e10cSrcweir reset()119cdf0e10cSrcweir void reset() 120cdf0e10cSrcweir { 121cdf0e10cSrcweir mnStartIndex = -1; 122cdf0e10cSrcweir mnEndIndex = -1; 123cdf0e10cSrcweir meType = NODETYPE_INVALID; 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir private: 127cdf0e10cSrcweir sal_Int32 mnStartIndex; 128cdf0e10cSrcweir sal_Int32 mnEndIndex; 129cdf0e10cSrcweir NodeType meType; 130cdf0e10cSrcweir 131cdf0e10cSrcweir }; 132cdf0e10cSrcweir 133cdf0e10cSrcweir typedef ::std::vector< DocTreeNode > VectorOfDocTreeNodes; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_DOCTREENODE_HXX */ 138