update dev300-m58
[ooovba.git] / sw / source / filter / xml / xmlitmpr.cxx
blobc231e41b3821e089227fbc3f19c311c6926db908
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlitmpr.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <rtl/ustring.hxx>
34 #include "xmlitmap.hxx"
36 using rtl::OUString;
37 using ::xmloff::token::IsXMLToken;
38 using ::xmloff::token::XML_TOKEN_INVALID;
40 // TODO: optimize this!
42 class SvXMLItemMapEntries_impl
44 public:
45 SvXMLItemMapEntry* mpEntries;
46 sal_uInt16 mnCount;
49 SvXMLItemMapEntries::SvXMLItemMapEntries( SvXMLItemMapEntry* pEntries )
51 mpImpl = new SvXMLItemMapEntries_impl;
52 mpImpl->mpEntries = pEntries;
54 mpImpl->mnCount = 0;
55 while( pEntries->eLocalName != XML_TOKEN_INVALID )
57 pEntries++;
58 mpImpl->mnCount++;
62 SvXMLItemMapEntries::~SvXMLItemMapEntries()
64 delete mpImpl;
67 SvXMLItemMapEntry* SvXMLItemMapEntries::getByName( sal_uInt16 nNameSpace,
68 const OUString& rString,
69 SvXMLItemMapEntry* pStartAt /* = NULL */ ) const
71 SvXMLItemMapEntry* pMap =
72 (pStartAt && (pStartAt->eLocalName!=XML_TOKEN_INVALID)) ?
73 &(pStartAt[1]) : mpImpl->mpEntries;
74 while( pMap && (pMap->eLocalName != XML_TOKEN_INVALID) )
76 if( pMap->nNameSpace == nNameSpace &&
77 IsXMLToken( rString, pMap->eLocalName ) )
78 break;
79 pMap++;
82 return (pMap->eLocalName != XML_TOKEN_INVALID) ? pMap : NULL;
85 SvXMLItemMapEntry* SvXMLItemMapEntries::getByIndex( UINT16 nIndex ) const
87 return &mpImpl->mpEntries[nIndex];
90 UINT16 SvXMLItemMapEntries::getCount() const
92 return mpImpl->mnCount;