xref: /trunk/main/xmloff/source/style/chrlohdl.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_xmloff.hxx"
30 
31 
32 #include <chrlohdl.hxx>
33 #include <xmloff/xmltoken.hxx>
34 #include <xmloff/xmluconv.hxx>
35 #include <rtl/ustrbuf.hxx>
36 #include <com/sun/star/uno/Any.hxx>
37 #include <com/sun/star/lang/Locale.hpp>
38 
39 using ::rtl::OUString;
40 using ::rtl::OUStringBuffer;
41 
42 using namespace ::com::sun::star;
43 using namespace ::xmloff::token;
44 
45 // this is a copy of defines in svx/inc/escpitem.hxx
46 #define DFLT_ESC_PROP	 58
47 #define DFLT_ESC_AUTO_SUPER	101
48 #define DFLT_ESC_AUTO_SUB  -101
49 
50 ///////////////////////////////////////////////////////////////////////////////
51 //
52 // class XMLEscapementPropHdl
53 //
54 
55 XMLCharLanguageHdl::~XMLCharLanguageHdl()
56 {
57 	// nothing to do
58 }
59 
60 bool XMLCharLanguageHdl::equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const
61 {
62 	sal_Bool bRet = sal_False;
63 	lang::Locale aLocale1, aLocale2;
64 
65 	if( ( r1 >>= aLocale1 ) && ( r2 >>= aLocale2 ) )
66 		bRet = ( aLocale1.Language == aLocale2.Language );
67 
68 	return bRet;
69 }
70 
71 sal_Bool XMLCharLanguageHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
72 {
73 	lang::Locale aLocale;
74 
75 	rValue >>= aLocale;
76 
77 	if( !IsXMLToken(rStrImpValue, XML_NONE) )
78 		aLocale.Language = rStrImpValue;
79 
80 	rValue <<= aLocale;
81 	return sal_True;
82 }
83 
84 sal_Bool XMLCharLanguageHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
85 {
86 	lang::Locale aLocale;
87 	if(!(rValue >>= aLocale))
88 		return sal_False;
89 
90 	rStrExpValue = aLocale.Language;
91 
92 	if( !rStrExpValue.getLength() )
93 		rStrExpValue = GetXMLToken( XML_NONE );
94 
95 	return sal_True;
96 }
97 
98 ///////////////////////////////////////////////////////////////////////////////
99 //
100 // class XMLEscapementHeightPropHdl
101 //
102 
103 XMLCharCountryHdl::~XMLCharCountryHdl()
104 {
105 	// nothing to do
106 }
107 
108 bool XMLCharCountryHdl::equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const
109 {
110 	sal_Bool bRet = sal_False;
111 	lang::Locale aLocale1, aLocale2;
112 
113 	if( ( r1 >>= aLocale1 ) && ( r2 >>= aLocale2 ) )
114 		bRet = ( aLocale1.Country == aLocale2.Country );
115 
116 	return bRet;
117 }
118 
119 sal_Bool XMLCharCountryHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
120 {
121 	lang::Locale aLocale;
122 
123 	rValue >>= aLocale;
124 
125 	if( !IsXMLToken( rStrImpValue, XML_NONE ) )
126 		aLocale.Country = rStrImpValue;
127 
128 	rValue <<= aLocale;
129 	return sal_True;
130 }
131 
132 sal_Bool XMLCharCountryHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
133 {
134 	lang::Locale aLocale;
135 	if(!(rValue >>= aLocale))
136 		return sal_False;
137 
138 	rStrExpValue = aLocale.Country;
139 
140 	if( !rStrExpValue.getLength() )
141 		rStrExpValue = GetXMLToken( XML_NONE );
142 
143 	return sal_True;
144 }
145