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 <csmaphdl.hxx>
21 : #include <xmloff/xmltoken.hxx>
22 : #include <xmloff/xmluconv.hxx>
23 : #include <rtl/ustrbuf.hxx>
24 : #include <com/sun/star/style/CaseMap.hpp>
25 : #include <com/sun/star/uno/Any.hxx>
26 :
27 : using ::rtl::OUString;
28 : using ::rtl::OUStringBuffer;
29 :
30 : using namespace ::com::sun::star;
31 : using namespace ::xmloff::token;
32 :
33 : static SvXMLEnumMapEntry pXML_Casemap_Enum[] =
34 : {
35 : { XML_NONE, style::CaseMap::NONE },
36 : { XML_CASEMAP_LOWERCASE, style::CaseMap::LOWERCASE },
37 : { XML_CASEMAP_UPPERCASE, style::CaseMap::UPPERCASE },
38 : { XML_CASEMAP_CAPITALIZE, style::CaseMap::TITLE },
39 : { XML_TOKEN_INVALID, 0 }
40 : };
41 :
42 : ///////////////////////////////////////////////////////////////////////////////
43 : //
44 : // class XMLPosturePropHdl
45 : //
46 :
47 962 : XMLCaseMapPropHdl::~XMLCaseMapPropHdl()
48 : {
49 : // nothing to do
50 962 : }
51 :
52 0 : sal_Bool XMLCaseMapPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
53 : {
54 : sal_uInt16 nVal;
55 : sal_Bool bRet = SvXMLUnitConverter::convertEnum(
56 0 : nVal, rStrImpValue, pXML_Casemap_Enum );
57 0 : if( ( bRet ) )
58 0 : rValue <<= nVal;
59 :
60 0 : return bRet;
61 : }
62 :
63 0 : sal_Bool XMLCaseMapPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
64 : {
65 0 : sal_Bool bRet = sal_False;
66 0 : sal_uInt16 nValue = sal_uInt16();
67 0 : OUStringBuffer aOut;
68 :
69 0 : if( rValue >>= nValue )
70 : {
71 : bRet = SvXMLUnitConverter::convertEnum(
72 0 : aOut, nValue, pXML_Casemap_Enum );
73 0 : if( bRet )
74 0 : rStrExpValue = aOut.makeStringAndClear();
75 : }
76 :
77 0 : return bRet;
78 : }
79 :
80 : ///////////////////////////////////////////////////////////////////////////////
81 : //
82 : // class XMLCaseMapVariantHdl
83 : //
84 :
85 962 : XMLCaseMapVariantHdl::~XMLCaseMapVariantHdl()
86 : {
87 : // nothing to do
88 962 : }
89 :
90 0 : sal_Bool XMLCaseMapVariantHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
91 : {
92 0 : sal_Bool bRet = sal_False;
93 :
94 0 : if( IsXMLToken( rStrImpValue, XML_CASEMAP_SMALL_CAPS ) )
95 : {
96 0 : rValue <<= (sal_Int16)style::CaseMap::SMALLCAPS;
97 0 : bRet = sal_True;
98 : }
99 0 : else if( IsXMLToken( rStrImpValue, XML_CASEMAP_NORMAL ) )
100 : {
101 0 : rValue <<= (sal_Int16)style::CaseMap::NONE;
102 0 : bRet = sal_True;
103 : }
104 :
105 0 : return bRet;
106 : }
107 :
108 0 : sal_Bool XMLCaseMapVariantHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
109 : {
110 0 : sal_uInt16 nValue = sal_uInt16();
111 0 : OUStringBuffer aOut;
112 :
113 0 : if( rValue >>= nValue )
114 : {
115 0 : switch( nValue )
116 : {
117 : case style::CaseMap::NONE:
118 0 : aOut.append( GetXMLToken(XML_CASEMAP_NORMAL) );
119 0 : break;
120 : case style::CaseMap::SMALLCAPS:
121 0 : aOut.append( GetXMLToken(XML_CASEMAP_SMALL_CAPS) );
122 0 : break;
123 : }
124 : }
125 :
126 0 : rStrExpValue = aOut.makeStringAndClear();
127 0 : return !rStrExpValue.isEmpty();
128 : }
129 :
130 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|