Update ooo320-m1
[ooovba.git] / xmloff / source / style / chrlohdl.cxx
blob0c653907873d87cac867db3d73ed9421852cd479
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: chrlohdl.cxx,v $
10 * $Revision: 1.10 $
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"
35 #include <chrlohdl.hxx>
36 #include <xmloff/xmltoken.hxx>
37 #include <xmloff/xmluconv.hxx>
38 #include <rtl/ustrbuf.hxx>
39 #include <com/sun/star/uno/Any.hxx>
41 #ifndef _XMLOFF_XMLEMENT_HXX
42 #include <xmloff/xmlelement.hxx>
43 #endif
44 #include <com/sun/star/lang/Locale.hpp>
46 using ::rtl::OUString;
47 using ::rtl::OUStringBuffer;
49 using namespace ::com::sun::star;
50 using namespace ::xmloff::token;
52 // this is a copy of defines in svx/inc/escpitem.hxx
53 #define DFLT_ESC_PROP 58
54 #define DFLT_ESC_AUTO_SUPER 101
55 #define DFLT_ESC_AUTO_SUB -101
57 ///////////////////////////////////////////////////////////////////////////////
59 // class XMLEscapementPropHdl
62 XMLCharLanguageHdl::~XMLCharLanguageHdl()
64 // nothing to do
67 bool XMLCharLanguageHdl::equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const
69 sal_Bool bRet = sal_False;
70 lang::Locale aLocale1, aLocale2;
72 if( ( r1 >>= aLocale1 ) && ( r2 >>= aLocale2 ) )
73 bRet = ( aLocale1.Language == aLocale2.Language );
75 return bRet;
78 sal_Bool XMLCharLanguageHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
80 lang::Locale aLocale;
82 rValue >>= aLocale;
84 if( !IsXMLToken(rStrImpValue, XML_NONE) )
85 aLocale.Language = rStrImpValue;
87 rValue <<= aLocale;
88 return sal_True;
91 sal_Bool XMLCharLanguageHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
93 lang::Locale aLocale;
94 if(!(rValue >>= aLocale))
95 return sal_False;
97 rStrExpValue = aLocale.Language;
99 if( !rStrExpValue.getLength() )
100 rStrExpValue = GetXMLToken( XML_NONE );
102 return sal_True;
105 ///////////////////////////////////////////////////////////////////////////////
107 // class XMLEscapementHeightPropHdl
110 XMLCharCountryHdl::~XMLCharCountryHdl()
112 // nothing to do
115 bool XMLCharCountryHdl::equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const
117 sal_Bool bRet = sal_False;
118 lang::Locale aLocale1, aLocale2;
120 if( ( r1 >>= aLocale1 ) && ( r2 >>= aLocale2 ) )
121 bRet = ( aLocale1.Country == aLocale2.Country );
123 return bRet;
126 sal_Bool XMLCharCountryHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
128 lang::Locale aLocale;
130 rValue >>= aLocale;
132 if( !IsXMLToken( rStrImpValue, XML_NONE ) )
133 aLocale.Country = rStrImpValue;
135 rValue <<= aLocale;
136 return sal_True;
139 sal_Bool XMLCharCountryHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
141 lang::Locale aLocale;
142 if(!(rValue >>= aLocale))
143 return sal_False;
145 rStrExpValue = aLocale.Country;
147 if( !rStrExpValue.getLength() )
148 rStrExpValue = GetXMLToken( XML_NONE );
150 return sal_True;