xref: /aoo42x/main/xmloff/source/style/chrlohdl.cxx (revision 63bba73c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 
27 
28 #include <chrlohdl.hxx>
29 #include <xmloff/xmltoken.hxx>
30 #include <xmloff/xmluconv.hxx>
31 #include <rtl/ustrbuf.hxx>
32 #include <com/sun/star/uno/Any.hxx>
33 #include <com/sun/star/lang/Locale.hpp>
34 
35 using ::rtl::OUString;
36 using ::rtl::OUStringBuffer;
37 
38 using namespace ::com::sun::star;
39 using namespace ::xmloff::token;
40 
41 // this is a copy of defines in svx/inc/escpitem.hxx
42 #define DFLT_ESC_PROP	 58
43 #define DFLT_ESC_AUTO_SUPER	101
44 #define DFLT_ESC_AUTO_SUB  -101
45 
46 ///////////////////////////////////////////////////////////////////////////////
47 //
48 // class XMLEscapementPropHdl
49 //
50 
~XMLCharLanguageHdl()51 XMLCharLanguageHdl::~XMLCharLanguageHdl()
52 {
53 	// nothing to do
54 }
55 
equals(const::com::sun::star::uno::Any & r1,const::com::sun::star::uno::Any & r2) const56 bool XMLCharLanguageHdl::equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const
57 {
58 	sal_Bool bRet = sal_False;
59 	lang::Locale aLocale1, aLocale2;
60 
61 	if( ( r1 >>= aLocale1 ) && ( r2 >>= aLocale2 ) )
62 		bRet = ( aLocale1.Language == aLocale2.Language );
63 
64 	return bRet;
65 }
66 
importXML(const OUString & rStrImpValue,uno::Any & rValue,const SvXMLUnitConverter &) const67 sal_Bool XMLCharLanguageHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
68 {
69 	lang::Locale aLocale;
70 
71 	rValue >>= aLocale;
72 
73 	if( !IsXMLToken(rStrImpValue, XML_NONE) )
74 		aLocale.Language = rStrImpValue;
75 
76 	rValue <<= aLocale;
77 	return sal_True;
78 }
79 
exportXML(OUString & rStrExpValue,const uno::Any & rValue,const SvXMLUnitConverter &) const80 sal_Bool XMLCharLanguageHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
81 {
82 	lang::Locale aLocale;
83 	if(!(rValue >>= aLocale))
84 		return sal_False;
85 
86 	rStrExpValue = aLocale.Language;
87 
88 	if( !rStrExpValue.getLength() )
89 		rStrExpValue = GetXMLToken( XML_NONE );
90 
91 	return sal_True;
92 }
93 
94 ///////////////////////////////////////////////////////////////////////////////
95 //
96 // class XMLEscapementHeightPropHdl
97 //
98 
~XMLCharCountryHdl()99 XMLCharCountryHdl::~XMLCharCountryHdl()
100 {
101 	// nothing to do
102 }
103 
equals(const::com::sun::star::uno::Any & r1,const::com::sun::star::uno::Any & r2) const104 bool XMLCharCountryHdl::equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const
105 {
106 	sal_Bool bRet = sal_False;
107 	lang::Locale aLocale1, aLocale2;
108 
109 	if( ( r1 >>= aLocale1 ) && ( r2 >>= aLocale2 ) )
110 		bRet = ( aLocale1.Country == aLocale2.Country );
111 
112 	return bRet;
113 }
114 
importXML(const OUString & rStrImpValue,uno::Any & rValue,const SvXMLUnitConverter &) const115 sal_Bool XMLCharCountryHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
116 {
117 	lang::Locale aLocale;
118 
119 	rValue >>= aLocale;
120 
121 	if( !IsXMLToken( rStrImpValue, XML_NONE ) )
122 		aLocale.Country = rStrImpValue;
123 
124 	rValue <<= aLocale;
125 	return sal_True;
126 }
127 
exportXML(OUString & rStrExpValue,const uno::Any & rValue,const SvXMLUnitConverter &) const128 sal_Bool XMLCharCountryHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
129 {
130 	lang::Locale aLocale;
131 	if(!(rValue >>= aLocale))
132 		return sal_False;
133 
134 	rStrExpValue = aLocale.Country;
135 
136 	if( !rStrExpValue.getLength() )
137 		rStrExpValue = GetXMLToken( XML_NONE );
138 
139 	return sal_True;
140 }
141