update dev300-m58
[ooovba.git] / xmloff / source / style / breakhdl.cxx
blobaf781233bbe23c667dcf004d92c1ec30bfbcea2b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: breakhdl.cxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include <breakhdl.hxx>
34 #include <xmloff/xmltoken.hxx>
35 #include <xmloff/xmluconv.hxx>
36 #include <rtl/ustrbuf.hxx>
37 #include <com/sun/star/style/BreakType.hpp>
38 #include <com/sun/star/uno/Any.hxx>
40 #ifndef _XMLOFF_XMLEMENT_HXX
41 #include <xmloff/xmlelement.hxx>
42 #endif
44 using ::rtl::OUString;
45 using ::rtl::OUStringBuffer;
47 using namespace ::com::sun::star;
48 using namespace ::xmloff::token;
50 SvXMLEnumMapEntry pXML_BreakTypes[] =
52 { XML_AUTO, 0 },
53 { XML_COLUMN, 1 },
54 { XML_PAGE, 2 },
55 { XML_EVEN_PAGE, 2 },
56 { XML_ODD_PAGE, 2 },
57 { XML_TOKEN_INVALID, 0}
60 ///////////////////////////////////////////////////////////////////////////////
62 // class XMLFmtBreakBeforePropHdl
65 XMLFmtBreakBeforePropHdl::~XMLFmtBreakBeforePropHdl()
67 // Nothing to do
70 sal_Bool XMLFmtBreakBeforePropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
72 sal_uInt16 nEnum;
73 sal_Bool bRet = SvXMLUnitConverter::convertEnum( nEnum, rStrImpValue, pXML_BreakTypes );
74 if( bRet )
76 style::BreakType eBreak;
77 switch ( nEnum )
79 case 0:
80 eBreak = style::BreakType_NONE;
81 break;
82 case 1:
83 eBreak = style::BreakType_COLUMN_BEFORE;
84 break;
85 default:
86 eBreak = style::BreakType_PAGE_BEFORE;
87 break;
89 rValue <<= eBreak;
92 return bRet;
95 sal_Bool XMLFmtBreakBeforePropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
97 style::BreakType eBreak;
99 if( !( rValue >>= eBreak ) )
101 sal_Int32 nValue = 0;
102 if( !( rValue >>= nValue ) )
103 return sal_False;
105 eBreak = (style::BreakType) nValue;
108 sal_uInt16 nEnum = 0;
109 switch( eBreak )
111 case style::BreakType_COLUMN_BEFORE:
112 nEnum = 1;
113 break;
114 case style::BreakType_PAGE_BEFORE:
115 nEnum = 2;
116 break;
117 case style::BreakType_NONE:
118 nEnum = 0;
119 break;
120 default:
121 return sal_False;
124 OUStringBuffer aOut;
125 /* sal_Bool bOk = */ SvXMLUnitConverter::convertEnum( aOut, nEnum, pXML_BreakTypes );
126 rStrExpValue = aOut.makeStringAndClear();
128 return sal_True;
131 ///////////////////////////////////////////////////////////////////////////////
133 // class XMLFmtBreakBeforePropHdl
136 XMLFmtBreakAfterPropHdl::~XMLFmtBreakAfterPropHdl()
138 // Nothing to do
141 sal_Bool XMLFmtBreakAfterPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
143 sal_uInt16 nEnum;
144 sal_Bool bRet = SvXMLUnitConverter::convertEnum( nEnum, rStrImpValue, pXML_BreakTypes );
145 if( bRet )
147 style::BreakType eBreak;
148 switch ( nEnum )
150 case 0:
151 eBreak = style::BreakType_NONE;
152 break;
153 case 1:
154 eBreak = style::BreakType_COLUMN_AFTER;
155 break;
156 default:
157 eBreak = style::BreakType_PAGE_AFTER;
158 break;
160 rValue <<= eBreak;
163 return bRet;
166 sal_Bool XMLFmtBreakAfterPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
168 style::BreakType eBreak;
170 if( !( rValue >>= eBreak ) )
172 sal_Int32 nValue = 0;
173 if( !( rValue >>= nValue ) )
174 return sal_False;
176 eBreak = (style::BreakType) nValue;
179 sal_uInt16 nEnum = 0;
180 switch( eBreak )
182 case style::BreakType_COLUMN_AFTER:
183 nEnum = 1;
184 break;
185 case style::BreakType_PAGE_AFTER:
186 nEnum = 2;
187 break;
188 case style::BreakType_NONE:
189 nEnum = 0;
190 break;
191 default:
192 return sal_False;
195 OUStringBuffer aOut;
196 /* sal_Bool bOk = */ SvXMLUnitConverter::convertEnum( aOut, nEnum, pXML_BreakTypes );
197 rStrExpValue = aOut.makeStringAndClear();
199 return sal_True;