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 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <rtl/ustring.hxx>
21 : #include "xmlitmap.hxx"
22 :
23 : using rtl::OUString;
24 : using ::xmloff::token::IsXMLToken;
25 : using ::xmloff::token::XML_TOKEN_INVALID;
26 :
27 : // TODO: optimize this!
28 :
29 : class SvXMLItemMapEntries_impl
30 : {
31 : public:
32 : SvXMLItemMapEntry* mpEntries;
33 : sal_uInt16 mnCount;
34 : };
35 :
36 308 : SvXMLItemMapEntries::SvXMLItemMapEntries( SvXMLItemMapEntry* pEntries )
37 : {
38 308 : mpImpl = new SvXMLItemMapEntries_impl;
39 308 : mpImpl->mpEntries = pEntries;
40 :
41 308 : mpImpl->mnCount = 0;
42 4392 : while( pEntries->eLocalName != XML_TOKEN_INVALID )
43 : {
44 3776 : pEntries++;
45 3776 : mpImpl->mnCount++;
46 : }
47 308 : }
48 :
49 924 : SvXMLItemMapEntries::~SvXMLItemMapEntries()
50 : {
51 308 : delete mpImpl;
52 616 : }
53 :
54 50 : SvXMLItemMapEntry* SvXMLItemMapEntries::getByName( sal_uInt16 nNameSpace,
55 : const OUString& rString,
56 : SvXMLItemMapEntry* pStartAt /* = NULL */ ) const
57 : {
58 : SvXMLItemMapEntry* pMap =
59 : (pStartAt && (pStartAt->eLocalName!=XML_TOKEN_INVALID)) ?
60 50 : &(pStartAt[1]) : mpImpl->mpEntries;
61 514 : while( pMap && (pMap->eLocalName != XML_TOKEN_INVALID) )
62 : {
63 660 : if( pMap->nNameSpace == nNameSpace &&
64 196 : IsXMLToken( rString, pMap->eLocalName ) )
65 50 : break;
66 414 : pMap++;
67 : }
68 :
69 50 : return (pMap && (pMap->eLocalName != XML_TOKEN_INVALID)) ? pMap : NULL;
70 : }
71 :
72 0 : SvXMLItemMapEntry* SvXMLItemMapEntries::getByIndex( sal_uInt16 nIndex ) const
73 : {
74 0 : return &mpImpl->mpEntries[nIndex];
75 : }
76 :
77 0 : sal_uInt16 SvXMLItemMapEntries::getCount() const
78 : {
79 0 : return mpImpl->mnCount;
80 : }
81 :
82 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|