bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / source / style / breakhdl.cxx
blob09152ddd7e2a7e811f0127220da1c5dc0b7cc8dc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <breakhdl.hxx>
21 #include <xmloff/xmltoken.hxx>
22 #include <xmloff/xmluconv.hxx>
23 #include <rtl/ustrbuf.hxx>
24 #include <com/sun/star/style/BreakType.hpp>
25 #include <com/sun/star/uno/Any.hxx>
27 using namespace ::com::sun::star;
28 using namespace ::xmloff::token;
30 SvXMLEnumMapEntry pXML_BreakTypes[] =
32 { XML_AUTO, 0 },
33 { XML_COLUMN, 1 },
34 { XML_PAGE, 2 },
35 { XML_EVEN_PAGE, 2 },
36 { XML_ODD_PAGE, 2 },
37 { XML_TOKEN_INVALID, 0}
41 // class XMLFmtBreakBeforePropHdl
44 XMLFmtBreakBeforePropHdl::~XMLFmtBreakBeforePropHdl()
46 // Nothing to do
49 bool XMLFmtBreakBeforePropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
51 sal_uInt16 nEnum;
52 bool bRet = SvXMLUnitConverter::convertEnum( nEnum, rStrImpValue, pXML_BreakTypes );
53 if( bRet )
55 style::BreakType eBreak;
56 switch ( nEnum )
58 case 0:
59 eBreak = style::BreakType_NONE;
60 break;
61 case 1:
62 eBreak = style::BreakType_COLUMN_BEFORE;
63 break;
64 default:
65 eBreak = style::BreakType_PAGE_BEFORE;
66 break;
68 rValue <<= eBreak;
71 return bRet;
74 bool XMLFmtBreakBeforePropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
76 style::BreakType eBreak;
78 if( !( rValue >>= eBreak ) )
80 sal_Int32 nValue = 0;
81 if( !( rValue >>= nValue ) )
82 return false;
84 eBreak = (style::BreakType) nValue;
87 sal_uInt16 nEnum = 0;
88 switch( eBreak )
90 case style::BreakType_COLUMN_BEFORE:
91 nEnum = 1;
92 break;
93 case style::BreakType_PAGE_BEFORE:
94 nEnum = 2;
95 break;
96 case style::BreakType_NONE:
97 nEnum = 0;
98 break;
99 default:
100 return false;
103 OUStringBuffer aOut;
104 /* bool bOk = */ SvXMLUnitConverter::convertEnum( aOut, nEnum, pXML_BreakTypes );
105 rStrExpValue = aOut.makeStringAndClear();
107 return true;
111 // class XMLFmtBreakBeforePropHdl
114 XMLFmtBreakAfterPropHdl::~XMLFmtBreakAfterPropHdl()
116 // Nothing to do
119 bool XMLFmtBreakAfterPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
121 sal_uInt16 nEnum;
122 bool bRet = SvXMLUnitConverter::convertEnum( nEnum, rStrImpValue, pXML_BreakTypes );
123 if( bRet )
125 style::BreakType eBreak;
126 switch ( nEnum )
128 case 0:
129 eBreak = style::BreakType_NONE;
130 break;
131 case 1:
132 eBreak = style::BreakType_COLUMN_AFTER;
133 break;
134 default:
135 eBreak = style::BreakType_PAGE_AFTER;
136 break;
138 rValue <<= eBreak;
141 return bRet;
144 bool XMLFmtBreakAfterPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
146 style::BreakType eBreak;
148 if( !( rValue >>= eBreak ) )
150 sal_Int32 nValue = 0;
151 if( !( rValue >>= nValue ) )
152 return false;
154 eBreak = (style::BreakType) nValue;
157 sal_uInt16 nEnum = 0;
158 switch( eBreak )
160 case style::BreakType_COLUMN_AFTER:
161 nEnum = 1;
162 break;
163 case style::BreakType_PAGE_AFTER:
164 nEnum = 2;
165 break;
166 case style::BreakType_NONE:
167 nEnum = 0;
168 break;
169 default:
170 return false;
173 OUStringBuffer aOut;
174 /* bool bOk = */ SvXMLUnitConverter::convertEnum( aOut, nEnum, pXML_BreakTypes );
175 rStrExpValue = aOut.makeStringAndClear();
177 return true;
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */