/src/libreoffice/xmloff/source/style/breakhdl.cxx
Line | Count | Source |
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 "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> |
27 | | |
28 | | using namespace ::com::sun::star; |
29 | | using namespace ::xmloff::token; |
30 | | |
31 | | SvXMLEnumMapEntry<sal_uInt16> const pXML_BreakTypes[] = |
32 | | { |
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} |
39 | | }; |
40 | | |
41 | | |
42 | | |
43 | | |
44 | | XMLFmtBreakBeforePropHdl::~XMLFmtBreakBeforePropHdl() |
45 | 99.7k | { |
46 | | // Nothing to do |
47 | 99.7k | } |
48 | | |
49 | | bool XMLFmtBreakBeforePropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const |
50 | 166 | { |
51 | 166 | sal_uInt16 nEnum; |
52 | 166 | bool bRet = SvXMLUnitConverter::convertEnum( nEnum, rStrImpValue, pXML_BreakTypes ); |
53 | 166 | if( bRet ) |
54 | 163 | { |
55 | 163 | style::BreakType eBreak; |
56 | 163 | switch ( nEnum ) |
57 | 163 | { |
58 | 1 | case 0: |
59 | 1 | eBreak = style::BreakType_NONE; |
60 | 1 | break; |
61 | 15 | case 1: |
62 | 15 | eBreak = style::BreakType_COLUMN_BEFORE; |
63 | 15 | break; |
64 | 147 | default: |
65 | 147 | eBreak = style::BreakType_PAGE_BEFORE; |
66 | 147 | break; |
67 | 163 | } |
68 | 163 | rValue <<= eBreak; |
69 | 163 | } |
70 | | |
71 | 166 | return bRet; |
72 | 166 | } |
73 | | |
74 | | bool XMLFmtBreakBeforePropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const |
75 | 0 | { |
76 | 0 | style::BreakType eBreak; |
77 | |
|
78 | 0 | if( !( rValue >>= eBreak ) ) |
79 | 0 | { |
80 | 0 | sal_Int32 nValue = 0; |
81 | 0 | if( !( rValue >>= nValue ) ) |
82 | 0 | return false; |
83 | | |
84 | 0 | eBreak = static_cast<style::BreakType>(nValue); |
85 | 0 | } |
86 | | |
87 | 0 | sal_uInt16 nEnum = 0; |
88 | 0 | switch( eBreak ) |
89 | 0 | { |
90 | 0 | case style::BreakType_COLUMN_BEFORE: |
91 | 0 | nEnum = 1; |
92 | 0 | break; |
93 | 0 | case style::BreakType_PAGE_BEFORE: |
94 | 0 | nEnum = 2; |
95 | 0 | break; |
96 | 0 | case style::BreakType_NONE: |
97 | 0 | nEnum = 0; |
98 | 0 | break; |
99 | 0 | default: |
100 | 0 | return false; |
101 | 0 | } |
102 | | |
103 | 0 | OUStringBuffer aOut; |
104 | 0 | /* bool bOk = */ SvXMLUnitConverter::convertEnum( aOut, nEnum, pXML_BreakTypes ); |
105 | 0 | rStrExpValue = aOut.makeStringAndClear(); |
106 | |
|
107 | 0 | return true; |
108 | 0 | } |
109 | | |
110 | | |
111 | | |
112 | | |
113 | | XMLFmtBreakAfterPropHdl::~XMLFmtBreakAfterPropHdl() |
114 | 99.7k | { |
115 | | // Nothing to do |
116 | 99.7k | } |
117 | | |
118 | | bool XMLFmtBreakAfterPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const |
119 | 0 | { |
120 | 0 | sal_uInt16 nEnum; |
121 | 0 | bool bRet = SvXMLUnitConverter::convertEnum( nEnum, rStrImpValue, pXML_BreakTypes ); |
122 | 0 | if( bRet ) |
123 | 0 | { |
124 | 0 | style::BreakType eBreak; |
125 | 0 | switch ( nEnum ) |
126 | 0 | { |
127 | 0 | case 0: |
128 | 0 | eBreak = style::BreakType_NONE; |
129 | 0 | break; |
130 | 0 | case 1: |
131 | 0 | eBreak = style::BreakType_COLUMN_AFTER; |
132 | 0 | break; |
133 | 0 | default: |
134 | 0 | eBreak = style::BreakType_PAGE_AFTER; |
135 | 0 | break; |
136 | 0 | } |
137 | 0 | rValue <<= eBreak; |
138 | 0 | } |
139 | | |
140 | 0 | return bRet; |
141 | 0 | } |
142 | | |
143 | | bool XMLFmtBreakAfterPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const |
144 | 0 | { |
145 | 0 | style::BreakType eBreak; |
146 | |
|
147 | 0 | if( !( rValue >>= eBreak ) ) |
148 | 0 | { |
149 | 0 | sal_Int32 nValue = 0; |
150 | 0 | if( !( rValue >>= nValue ) ) |
151 | 0 | return false; |
152 | | |
153 | 0 | eBreak = static_cast<style::BreakType>(nValue); |
154 | 0 | } |
155 | | |
156 | 0 | sal_uInt16 nEnum = 0; |
157 | 0 | switch( eBreak ) |
158 | 0 | { |
159 | 0 | case style::BreakType_COLUMN_AFTER: |
160 | 0 | nEnum = 1; |
161 | 0 | break; |
162 | 0 | case style::BreakType_PAGE_AFTER: |
163 | 0 | nEnum = 2; |
164 | 0 | break; |
165 | 0 | case style::BreakType_NONE: |
166 | 0 | nEnum = 0; |
167 | 0 | break; |
168 | 0 | default: |
169 | 0 | return false; |
170 | 0 | } |
171 | | |
172 | 0 | OUStringBuffer aOut; |
173 | 0 | /* bool bOk = */ SvXMLUnitConverter::convertEnum( aOut, nEnum, pXML_BreakTypes ); |
174 | 0 | rStrExpValue = aOut.makeStringAndClear(); |
175 | |
|
176 | 0 | return true; |
177 | 0 | } |
178 | | |
179 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |