1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: i18nmap.cxx,v $
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_xmloff.hxx"
33 #include <rtl/ustring.hxx>
34 #include <tools/debug.hxx>
35 #include <svtools/svarray.hxx>
36 #include "i18nmap.hxx"
40 class SvI18NMapEntry_Impl
48 const OUString
& GetNewName() const { return aNewName
; }
50 SvI18NMapEntry_Impl( USHORT nKnd
, const OUString
& rName
,
51 const OUString
& rNewName
) :
57 SvI18NMapEntry_Impl( USHORT nKnd
, const OUString
& rName
) :
62 BOOL
operator==( const SvI18NMapEntry_Impl
& r
) const
64 return nKind
== r
.nKind
&&
68 BOOL
operator<( const SvI18NMapEntry_Impl
& r
) const
70 return nKind
< r
.nKind
||
76 typedef SvI18NMapEntry_Impl
*SvI18NMapEntry_ImplPtr
;
77 SV_DECL_PTRARR_SORT_DEL( SvI18NMap_Impl
, SvI18NMapEntry_ImplPtr
, 20, 5 )
78 SV_IMPL_OP_PTRARR_SORT( SvI18NMap_Impl
, SvI18NMapEntry_ImplPtr
)
80 // ---------------------------------------------------------------------
82 SvI18NMapEntry_Impl
*SvI18NMap::_Find( USHORT nKind
,
83 const OUString
& rName
) const
85 SvI18NMapEntry_Impl
*pRet
= 0;
86 SvI18NMapEntry_Impl
aTst( nKind
, rName
);
89 if( pImpl
->Seek_Entry( &aTst
, &nPos
) )
91 pRet
= (*pImpl
)[nPos
];
97 SvI18NMap::SvI18NMap() :
100 pImpl
= new SvI18NMap_Impl
;
103 SvI18NMap::~SvI18NMap()
108 void SvI18NMap::Add( USHORT nKind
, const OUString
& rName
,
109 const OUString
& rNewName
)
111 SvI18NMapEntry_Impl
*pEntry
= _Find( nKind
, rName
);
112 DBG_ASSERT( !pEntry
, "SvI18NMap::Add: item registered already" );
115 pEntry
= new SvI18NMapEntry_Impl( nKind
, rName
, rNewName
);
116 pImpl
->Insert( pEntry
);
120 const OUString
& SvI18NMap::Get( USHORT nKind
, const OUString
& rName
) const
122 SvI18NMapEntry_Impl
*pEntry
= _Find( nKind
, rName
);
124 return pEntry
->GetNewName();