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 0 : SmCaretPosGraphEntry* SmCaretPosGraphIterator::Next(){
14 0 : if(nOffset >= pGraph->nOffset){
15 0 : if(pGraph->pNext){
16 0 : pGraph = pGraph->pNext;
17 0 : nOffset = 0;
18 0 : pEntry = Next();
19 : }else
20 0 : pEntry = NULL;
21 : }else
22 0 : pEntry = pGraph->Graph + nOffset++;
23 0 : return pEntry;
24 : }
25 :
26 0 : SmCaretPosGraphEntry* SmCaretPosGraph::Add(SmCaretPosGraphEntry entry){
27 0 : 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 0 : entry.Left = entry.Left ? entry.Left : Graph + nOffset;
34 0 : entry.Right = entry.Right ? entry.Right : Graph + nOffset;
35 : //Save the entry
36 0 : Graph[nOffset] = entry;
37 0 : return Graph + nOffset++;
38 : }
39 : }
40 :
41 0 : SmCaretPosGraph::~SmCaretPosGraph(){
42 0 : delete pNext;
43 0 : pNext = NULL;
44 0 : }
45 :
46 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|