Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : */
9 : #include "caret.hxx"
10 :
11 : /////////////////////////////// SmCaretPosGraph
12 :
13 157 : SmCaretPosGraphEntry* SmCaretPosGraphIterator::Next(){
14 157 : if(nOffset >= pGraph->nOffset){
15 3 : if(pGraph->pNext){
16 0 : pGraph = pGraph->pNext;
17 0 : nOffset = 0;
18 0 : pEntry = Next();
19 : }else
20 3 : pEntry = NULL;
21 : }else
22 154 : pEntry = pGraph->Graph + nOffset++;
23 157 : return pEntry;
24 : }
25 :
26 136 : SmCaretPosGraphEntry* SmCaretPosGraph::Add(SmCaretPosGraphEntry entry){
27 136 : if(nOffset >= SmCaretPosGraphSize){
28 0 : if(!pNext)
29 0 : pNext = new SmCaretPosGraph();
30 0 : return pNext->Add(entry);
31 : }else{
32 : //Set Left and Right to point to the entry itself if they are NULL
33 136 : entry.Left = entry.Left ? entry.Left : Graph + nOffset;
34 136 : entry.Right = entry.Right ? entry.Right : Graph + nOffset;
35 : //Save the entry
36 136 : Graph[nOffset] = entry;
37 136 : return Graph + nOffset++;
38 : }
39 : }
40 :
41 20 : SmCaretPosGraph::~SmCaretPosGraph(){
42 20 : delete pNext;
43 20 : pNext = NULL;
44 62 : }
45 :
46 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|