Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <chrlohdl.hxx>
21 : #include <xmloff/xmltoken.hxx>
22 : #include <xmloff/xmluconv.hxx>
23 : #include <rtl/ustrbuf.hxx>
24 : #include <com/sun/star/uno/Any.hxx>
25 : #include <com/sun/star/lang/Locale.hpp>
26 :
27 :
28 : using namespace ::com::sun::star;
29 : using namespace ::xmloff::token;
30 :
31 : ///////////////////////////////////////////////////////////////////////////////
32 : //
33 : // class XMLEscapementPropHdl
34 : //
35 :
36 3862 : XMLCharLanguageHdl::~XMLCharLanguageHdl()
37 : {
38 : // nothing to do
39 3862 : }
40 :
41 4 : bool XMLCharLanguageHdl::equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const
42 : {
43 4 : sal_Bool bRet = sal_False;
44 8 : lang::Locale aLocale1, aLocale2;
45 :
46 4 : if( ( r1 >>= aLocale1 ) && ( r2 >>= aLocale2 ) )
47 4 : bRet = ( aLocale1.Language == aLocale2.Language );
48 :
49 8 : return bRet;
50 : }
51 :
52 676 : sal_Bool XMLCharLanguageHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
53 : {
54 676 : lang::Locale aLocale;
55 :
56 676 : rValue >>= aLocale;
57 :
58 676 : if( !IsXMLToken(rStrImpValue, XML_NONE) )
59 628 : aLocale.Language = rStrImpValue;
60 :
61 676 : rValue <<= aLocale;
62 676 : return sal_True;
63 : }
64 :
65 163 : sal_Bool XMLCharLanguageHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
66 : {
67 163 : lang::Locale aLocale;
68 163 : if(!(rValue >>= aLocale))
69 0 : return sal_False;
70 :
71 163 : rStrExpValue = aLocale.Language;
72 :
73 163 : if( rStrExpValue.isEmpty() )
74 0 : rStrExpValue = GetXMLToken( XML_NONE );
75 :
76 163 : return sal_True;
77 : }
78 :
79 : ///////////////////////////////////////////////////////////////////////////////
80 : //
81 : // class XMLEscapementHeightPropHdl
82 : //
83 :
84 3862 : XMLCharCountryHdl::~XMLCharCountryHdl()
85 : {
86 : // nothing to do
87 3862 : }
88 :
89 4 : bool XMLCharCountryHdl::equals( const ::com::sun::star::uno::Any& r1, const ::com::sun::star::uno::Any& r2 ) const
90 : {
91 4 : sal_Bool bRet = sal_False;
92 8 : lang::Locale aLocale1, aLocale2;
93 :
94 4 : if( ( r1 >>= aLocale1 ) && ( r2 >>= aLocale2 ) )
95 4 : bRet = ( aLocale1.Country == aLocale2.Country );
96 :
97 8 : return bRet;
98 : }
99 :
100 676 : sal_Bool XMLCharCountryHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
101 : {
102 676 : lang::Locale aLocale;
103 :
104 676 : rValue >>= aLocale;
105 :
106 676 : if( !IsXMLToken( rStrImpValue, XML_NONE ) )
107 583 : aLocale.Country = rStrImpValue;
108 :
109 676 : rValue <<= aLocale;
110 676 : return sal_True;
111 : }
112 :
113 163 : sal_Bool XMLCharCountryHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
114 : {
115 163 : lang::Locale aLocale;
116 163 : if(!(rValue >>= aLocale))
117 0 : return sal_False;
118 :
119 163 : rStrExpValue = aLocale.Country;
120 :
121 163 : if( rStrExpValue.isEmpty() )
122 8 : rStrExpValue = GetXMLToken( XML_NONE );
123 :
124 163 : return sal_True;
125 : }
126 :
127 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|