1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "rfindlst.hxx"
21 #include <tools/debug.hxx>
23 // STATIC DATA -----------------------------------------------------------
25 #define SC_RANGECOLORS 8
27 static const ColorData aColNames
[SC_RANGECOLORS
] =
28 { COL_LIGHTBLUE
, COL_LIGHTRED
, COL_LIGHTMAGENTA
, COL_GREEN
,
29 COL_BLUE
, COL_RED
, COL_MAGENTA
, COL_BROWN
};
31 ScRangeFindList::ScRangeFindList(const OUString
& rName
) :
38 ColorData
ScRangeFindList::Insert( const ScRangeFindData
&rNew
)
40 std::vector
<ScRangeFindData
>::iterator it
=maEntries
.begin();
41 for( ; it
!=maEntries
.end(); ++it
)
43 if(it
->aRef
== rNew
.aRef
)
46 ScRangeFindData
insertData(rNew
);
47 insertData
.nColorData
= ( it
!= maEntries
.end() ? it
->nColorData
:
48 ScRangeFindList::GetColorName( maEntries
.size() ) );
49 maEntries
.push_back(insertData
);
50 nIndexColor
= maEntries
.size() - 1;
51 return insertData
.nColorData
;
54 ColorData
ScRangeFindList::GetColorName( const size_t nIndex
)
56 return aColNames
[nIndex
% SC_RANGECOLORS
];
59 ColorData
ScRangeFindList::FindColor( const ScRange
& rRef
, const size_t nIndex
)
61 sal_Int32 nOldCntr
= 0;
62 sal_Int32 nNewCntr
= 0;
63 ColorData nOldColor
= 0;
64 ColorData nNewColor
= 0;
66 DBG_ASSERT( (nIndex
< maEntries
.size()), "nIndex out of range!" );
68 nOldColor
= maEntries
[nIndex
].nColorData
;
69 nNewColor
= ScRangeFindList::GetColorName( nIndex
);
71 std::vector
<ScRangeFindData
>::iterator it
=maEntries
.begin();
72 for( ;it
!=maEntries
.end(); ++it
)
77 if (it
->nColorData
== nOldColor
)
80 if (it
->nColorData
== nNewColor
)
84 if ( it
!= maEntries
.end() )
85 return it
->nColorData
;
91 return ScRangeFindList::GetColorName( ++nIndexColor
);
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */