tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / xmloff / source / style / breakhdl.cxx
blobd1490881f38fc40d09952c507773887658e71ed8
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 <xmloff/xmlement.hxx>
24 #include <rtl/ustrbuf.hxx>
25 #include <com/sun/star/style/BreakType.hpp>
26 #include <com/sun/star/uno/Any.hxx>
28 using namespace ::com::sun::star;
29 using namespace ::xmloff::token;
31 SvXMLEnumMapEntry<sal_uInt16> const pXML_BreakTypes[] =
33 { XML_AUTO, 0 },
34 { XML_COLUMN, 1 },
35 { XML_PAGE, 2 },
36 { XML_EVEN_PAGE, 2 },
37 { XML_ODD_PAGE, 2 },
38 { XML_TOKEN_INVALID, 0}
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 = static_cast<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;
113 XMLFmtBreakAfterPropHdl::~XMLFmtBreakAfterPropHdl()
115 // Nothing to do
118 bool XMLFmtBreakAfterPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
120 sal_uInt16 nEnum;
121 bool bRet = SvXMLUnitConverter::convertEnum( nEnum, rStrImpValue, pXML_BreakTypes );
122 if( bRet )
124 style::BreakType eBreak;
125 switch ( nEnum )
127 case 0:
128 eBreak = style::BreakType_NONE;
129 break;
130 case 1:
131 eBreak = style::BreakType_COLUMN_AFTER;
132 break;
133 default:
134 eBreak = style::BreakType_PAGE_AFTER;
135 break;
137 rValue <<= eBreak;
140 return bRet;
143 bool XMLFmtBreakAfterPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
145 style::BreakType eBreak;
147 if( !( rValue >>= eBreak ) )
149 sal_Int32 nValue = 0;
150 if( !( rValue >>= nValue ) )
151 return false;
153 eBreak = static_cast<style::BreakType>(nValue);
156 sal_uInt16 nEnum = 0;
157 switch( eBreak )
159 case style::BreakType_COLUMN_AFTER:
160 nEnum = 1;
161 break;
162 case style::BreakType_PAGE_AFTER:
163 nEnum = 2;
164 break;
165 case style::BreakType_NONE:
166 nEnum = 0;
167 break;
168 default:
169 return false;
172 OUStringBuffer aOut;
173 /* bool bOk = */ SvXMLUnitConverter::convertEnum( aOut, nEnum, pXML_BreakTypes );
174 rStrExpValue = aOut.makeStringAndClear();
176 return true;
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */