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 <rtl/ustring.hxx>
30 : : #include "xmlitmap.hxx"
31 : :
32 : : using rtl::OUString;
33 : : using ::xmloff::token::IsXMLToken;
34 : : using ::xmloff::token::XML_TOKEN_INVALID;
35 : :
36 : : // TODO: optimize this!
37 : :
38 : : class SvXMLItemMapEntries_impl
39 : : {
40 : : public:
41 : : SvXMLItemMapEntry* mpEntries;
42 : : sal_uInt16 mnCount;
43 : : };
44 : :
45 : 1716 : SvXMLItemMapEntries::SvXMLItemMapEntries( SvXMLItemMapEntry* pEntries )
46 : : {
47 [ + - ]: 1716 : mpImpl = new SvXMLItemMapEntries_impl;
48 : 1716 : mpImpl->mpEntries = pEntries;
49 : :
50 : 1716 : mpImpl->mnCount = 0;
51 [ + + ]: 23308 : while( pEntries->eLocalName != XML_TOKEN_INVALID )
52 : : {
53 : 21592 : pEntries++;
54 : 21592 : mpImpl->mnCount++;
55 : : }
56 : 1716 : }
57 : :
58 : 1716 : SvXMLItemMapEntries::~SvXMLItemMapEntries()
59 : : {
60 : 1716 : delete mpImpl;
61 [ - + ]: 3432 : }
62 : :
63 : 250 : SvXMLItemMapEntry* SvXMLItemMapEntries::getByName( sal_uInt16 nNameSpace,
64 : : const OUString& rString,
65 : : SvXMLItemMapEntry* pStartAt /* = NULL */ ) const
66 : : {
67 : : SvXMLItemMapEntry* pMap =
68 : : (pStartAt && (pStartAt->eLocalName!=XML_TOKEN_INVALID)) ?
69 [ - + ][ # # ]: 250 : &(pStartAt[1]) : mpImpl->mpEntries;
70 [ + - ][ + - ]: 2320 : while( pMap && (pMap->eLocalName != XML_TOKEN_INVALID) )
[ + - ]
71 : : {
72 [ + + + + ]: 3300 : if( pMap->nNameSpace == nNameSpace &&
[ + + ]
73 : 980 : IsXMLToken( rString, pMap->eLocalName ) )
74 : 250 : break;
75 : 2070 : pMap++;
76 : : }
77 : :
78 [ + - ][ + - ]: 250 : return (pMap && (pMap->eLocalName != XML_TOKEN_INVALID)) ? pMap : NULL;
79 : : }
80 : :
81 : 0 : SvXMLItemMapEntry* SvXMLItemMapEntries::getByIndex( sal_uInt16 nIndex ) const
82 : : {
83 : 0 : return &mpImpl->mpEntries[nIndex];
84 : : }
85 : :
86 : 0 : sal_uInt16 SvXMLItemMapEntries::getCount() const
87 : : {
88 : 0 : return mpImpl->mnCount;
89 : : }
90 : :
91 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|