OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 180 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 180 Rev 182
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
9
 * language governing permissions and limitations under the License.
Line 11... Line 11...
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.openoffice.style.data;
14
 package org.openconcerto.openoffice.style.data;
15
 
15
 
-
 
16
import org.openconcerto.openoffice.Feature;
16
import org.openconcerto.openoffice.Log;
17
import org.openconcerto.openoffice.Log;
17
import org.openconcerto.openoffice.ODEpoch;
18
import org.openconcerto.openoffice.ODEpoch;
18
import org.openconcerto.openoffice.ODPackage;
19
import org.openconcerto.openoffice.ODPackage;
19
import org.openconcerto.openoffice.ODValueType;
20
import org.openconcerto.openoffice.ODValueType;
20
import org.openconcerto.openoffice.OOUtils;
21
import org.openconcerto.openoffice.OOUtils;
Line 262... Line 263...
262
            addStringLiteral(numberSB, decReplacement);
263
            addStringLiteral(numberSB, decReplacement);
263
        } else {
264
        } else {
264
            decSeparatorAlwaysShown = false;
265
            decSeparatorAlwaysShown = false;
265
            // see 19.343.2
266
            // see 19.343.2
266
            final String decPlacesAttr = elem.getAttributeValue("decimal-places", numberNS, "");
267
            final String decPlacesAttr = elem.getAttributeValue("decimal-places", numberNS, "");
267
            final String minDecPlacesAttr = elem.getAttributeValue("min-decimal-places", numberNS, "");
-
 
268
            final int forcedPlaces, nonZeroPlaces;
268
            final int forcedPlaces, nonZeroPlaces;
269
            if (!decPlacesAttr.isEmpty()) {
269
            if (!decPlacesAttr.isEmpty()) {
270
                final int decPlaces = parsePositive(decPlacesAttr, lenient);
270
                final int decPlaces = parsePositive(decPlacesAttr, lenient);
-
 
271
 
-
 
272
                final String officeVers = this.getPackage().getFormatVersion().getOfficeVersion();
-
 
273
                final Feature minDecFeature;
-
 
274
                if (officeVers.equals("1.2")) {
-
 
275
                    minDecFeature = Feature.EXTENSION;
-
 
276
                } else if (officeVers.equals("1.0") || officeVers.equals("1.1")) {
-
 
277
                    minDecFeature = Feature.UNSUPPORTED;
-
 
278
                } else {
-
 
279
                    minDecFeature = Feature.SUPPORTED;
-
 
280
                }
-
 
281
 
-
 
282
                if (minDecFeature == Feature.UNSUPPORTED) {
-
 
283
                    forcedPlaces = decPlaces;
-
 
284
                    nonZeroPlaces = 0;
-
 
285
                } else {
-
 
286
                    final Namespace minDecNS = minDecFeature == Feature.EXTENSION ? this.getNS().getNS("loext") : numberNS;
-
 
287
                    final String minDecPlacesAttr = elem.getAttributeValue("min-decimal-places", minDecNS, "");
271
                if (minDecPlacesAttr.isEmpty()) {
288
                    if (minDecPlacesAttr.isEmpty()) {
-
 
289
                        // - minDecFeature == Feature.SUPPORTED is from observation (and if a 1.2
-
 
290
                        // document w/o "min-decimal-places" is saved by LO, then the attribute is
-
 
291
                        // explicitly added with a value equal to "decimal-places")
-
 
292
                        // - for the rest of the condition, see 19.356.2 & 3 of v1.3
-
 
293
                        if (minDecFeature == Feature.SUPPORTED && decReplacement.isEmpty() && elem.getName().equals("number")) {
-
 
294
                            forcedPlaces = 0;
-
 
295
                            nonZeroPlaces = decPlaces;
-
 
296
                        } else {
272
                    forcedPlaces = decPlaces;
297
                            forcedPlaces = decPlaces;
273
                    nonZeroPlaces = 0;
298
                            nonZeroPlaces = 0;
-
 
299
                        }
274
                } else {
300
                    } else {
275
                    forcedPlaces = parsePositive(minDecPlacesAttr, lenient);
301
                        forcedPlaces = parsePositive(minDecPlacesAttr, lenient);
276
                    if (forcedPlaces > decPlaces) {
302
                        if (forcedPlaces > decPlaces) {
277
                        DataStyle.reportError("min-decimal-places greater than decimal-places : " + minDecPlacesAttr + " > " + decPlacesAttr, lenient);
303
                            DataStyle.reportError("min-decimal-places greater than decimal-places : " + minDecPlacesAttr + " > " + decPlacesAttr, lenient);
278
                        nonZeroPlaces = 0;
304
                            nonZeroPlaces = 0;
279
                    } else {
305
                        } else {
280
                        nonZeroPlaces = decPlaces - forcedPlaces;
306
                            nonZeroPlaces = decPlaces - forcedPlaces;
281
                    }
307
                        }
282
                }
308
                    }
-
 
309
                }
283
            } else {
310
            } else {
284
                // default style specifies the maximum
311
                // default style specifies the maximum
285
                forcedPlaces = 0;
312
                forcedPlaces = 0;
286
                nonZeroPlaces = getDecimalPlaces(defaultStyle);
313
                nonZeroPlaces = getDecimalPlaces(defaultStyle);
287
            }
314
            }