xref: /AOO41X/main/editeng/source/misc/forbiddencharacterstable.cxx (revision 190118d08a3be86671f4129b3e9a490e144719cd)
1*190118d0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*190118d0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*190118d0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*190118d0SAndrew Rist  * distributed with this work for additional information
6*190118d0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*190118d0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*190118d0SAndrew Rist  * "License"); you may not use this file except in compliance
9*190118d0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*190118d0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*190118d0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*190118d0SAndrew Rist  * software distributed under the License is distributed on an
15*190118d0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*190118d0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*190118d0SAndrew Rist  * specific language governing permissions and limitations
18*190118d0SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*190118d0SAndrew Rist  *************************************************************/
21*190118d0SAndrew Rist 
22*190118d0SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_editeng.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <editeng/forbiddencharacterstable.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
30cdf0e10cSrcweir #include <editeng/unolingu.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33cdf0e10cSrcweir 
SvxForbiddenCharactersTable(::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> xMSF,sal_uInt16 nISize,sal_uInt16 nGrow)34cdf0e10cSrcweir SvxForbiddenCharactersTable::SvxForbiddenCharactersTable( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF, sal_uInt16 nISize, sal_uInt16 nGrow )
35cdf0e10cSrcweir  : SvxForbiddenCharactersTableImpl( nISize, nGrow )
36cdf0e10cSrcweir {
37cdf0e10cSrcweir 	mxMSF = xMSF;
38cdf0e10cSrcweir }
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 
~SvxForbiddenCharactersTable()41cdf0e10cSrcweir SvxForbiddenCharactersTable::~SvxForbiddenCharactersTable()
42cdf0e10cSrcweir {
43cdf0e10cSrcweir 	for ( sal_uLong n = Count(); n; )
44cdf0e10cSrcweir 		delete GetObject( --n );
45cdf0e10cSrcweir }
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 
GetForbiddenCharacters(sal_uInt16 nLanguage,sal_Bool bGetDefault) const49cdf0e10cSrcweir const com::sun::star::i18n::ForbiddenCharacters* SvxForbiddenCharactersTable::GetForbiddenCharacters( sal_uInt16 nLanguage, sal_Bool bGetDefault ) const
50cdf0e10cSrcweir {
51cdf0e10cSrcweir 	ForbiddenCharactersInfo* pInf = Get( nLanguage );
52cdf0e10cSrcweir 	if ( !pInf && bGetDefault && mxMSF.is() )
53cdf0e10cSrcweir 	{
54cdf0e10cSrcweir 		const SvxForbiddenCharactersTableImpl *pConstImpl = dynamic_cast<const SvxForbiddenCharactersTableImpl*>(this);
55cdf0e10cSrcweir 		SvxForbiddenCharactersTableImpl* pImpl = const_cast<SvxForbiddenCharactersTableImpl*>(pConstImpl);
56cdf0e10cSrcweir  		pInf = new ForbiddenCharactersInfo;
57cdf0e10cSrcweir 		pImpl->Insert( nLanguage, pInf );
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 		pInf->bTemporary = sal_True;
60cdf0e10cSrcweir 		LocaleDataWrapper aWrapper( mxMSF, SvxCreateLocale( nLanguage ) );
61cdf0e10cSrcweir 		pInf->aForbiddenChars = aWrapper.getForbiddenCharacters();
62cdf0e10cSrcweir 	}
63cdf0e10cSrcweir 	return pInf ? &pInf->aForbiddenChars : NULL;
64cdf0e10cSrcweir }
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 
SetForbiddenCharacters(sal_uInt16 nLanguage,const com::sun::star::i18n::ForbiddenCharacters & rForbiddenChars)68cdf0e10cSrcweir void SvxForbiddenCharactersTable::SetForbiddenCharacters( sal_uInt16 nLanguage, const com::sun::star::i18n::ForbiddenCharacters& rForbiddenChars )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir 	ForbiddenCharactersInfo* pInf = Get( nLanguage );
71cdf0e10cSrcweir 	if ( !pInf )
72cdf0e10cSrcweir 	{
73cdf0e10cSrcweir 		pInf = new ForbiddenCharactersInfo;
74cdf0e10cSrcweir 		Insert( nLanguage, pInf );
75cdf0e10cSrcweir 	}
76cdf0e10cSrcweir 	pInf->bTemporary = sal_False;
77cdf0e10cSrcweir 	pInf->aForbiddenChars = rForbiddenChars;
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
ClearForbiddenCharacters(sal_uInt16 nLanguage)80cdf0e10cSrcweir void SvxForbiddenCharactersTable::ClearForbiddenCharacters( sal_uInt16 nLanguage )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir 	ForbiddenCharactersInfo* pInf = Get( nLanguage );
83cdf0e10cSrcweir 	if ( pInf )
84cdf0e10cSrcweir 	{
85cdf0e10cSrcweir 		Remove( nLanguage );
86cdf0e10cSrcweir 		delete pInf;
87cdf0e10cSrcweir 	}
88cdf0e10cSrcweir }
89