Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "ring.hxx"
30 : :
31 : 500030 : Ring::Ring( Ring *pObj )
32 : : {
33 [ + + ]: 500030 : if( !pObj )
34 : : {
35 : 499326 : pNext = this, pPrev = this;
36 : : }
37 : : else
38 : : {
39 : 704 : pNext = pObj;
40 : 704 : pPrev = pObj->pPrev;
41 : 704 : pObj->pPrev = this;
42 : 704 : pPrev->pNext = this;
43 : : }
44 : 500030 : }
45 : :
46 : 500561 : Ring::~Ring()
47 : : {
48 : 500561 : pNext->pPrev = pPrev;
49 : 500561 : pPrev->pNext = pNext;
50 [ - + ]: 500561 : }
51 : :
52 : 210 : void Ring::MoveTo(Ring *pDestRing)
53 : : {
54 : : // delete from "old"
55 : 210 : pNext->pPrev = pPrev;
56 : 210 : pPrev->pNext = pNext;
57 : :
58 : : // insert into "new"
59 [ + + ]: 210 : if( pDestRing )
60 : : {
61 : 70 : pNext = pDestRing;
62 : 70 : pPrev = pDestRing->pPrev;
63 : 70 : pDestRing->pPrev = this;
64 : 70 : pPrev->pNext = this;
65 : : }
66 : : else
67 : : {
68 : 140 : pNext = pPrev = this;
69 : : }
70 : :
71 : 210 : }
72 : :
73 : 8 : void Ring::MoveRingTo(Ring *pDestRing)
74 : : {
75 : : // insert the whole ring into DestRing
76 : 8 : Ring* pMyPrev = pPrev;
77 : 8 : Ring* pDestPrev = pDestRing->pPrev;
78 : :
79 : 8 : pMyPrev->pNext = pDestRing;
80 : 8 : pDestPrev->pNext = this;
81 : 8 : pDestRing->pPrev = pMyPrev;
82 : 8 : pPrev = pDestPrev;
83 : 8 : }
84 : :
85 : 0 : sal_uInt32 Ring::numberOf() const
86 : : {
87 : 0 : sal_uInt32 nRet = 1;
88 : 0 : const Ring* pNxt = pNext;
89 [ # # ]: 0 : while( pNxt != this )
90 : : {
91 : 0 : ++nRet;
92 : 0 : pNxt = pNxt->GetNext();
93 : : }
94 : 0 : return nRet;
95 : : }
96 : :
97 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|