diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2024-06-01 19:50:47 +0200 |
---|---|---|
committer | Regina Henschel <rb.henschel@t-online.de> | 2024-06-11 10:29:17 +0200 |
commit | 567dbcf68711402736f65f4a0a47ef57549fe50f (patch) | |
tree | 934b9bd3650598d6a04f69a85c2754ef7c878989 /xmloff/inc | |
parent | a2b6ce5d21b7f5c84ced8485f5af279f1bf8135f (diff) |
tdf#161327 Interpret angle units in dr3d:end-angle ..
.. and draw:rotation in <draw:hatch> element.
ODF 1.1 has not specified the syntax of datatype 'angle'. Since ODF 1.2
it is specified as double with unit "deg", "grad" or "rad", or without
unit. The unit-less value is specified to be in degrees. But OOo, AOO
and all LO versions had written the value unit-less in 1/10th of a
degree in some cases.
To fix it, LibreOffic will be enabled to read units. When then the
active versions are able to read units, starting with the then actual
version, LibreOffice will write angles with unit 'deg'.
This has already be done for gradients, see tdf#89475. This patch
starts the first step to make LibreOffice able to read units for
dr3d:end-angle (UNO D3DEndAngle) and for draw:rotation (UNO
FillHatch.Angle). I have not found further cases of writing 1/10deg.
The patch still writes unit-less 1/10th of a degree for export to
ODF 1.3 and earlier. When it is time to write unit degree or when
LibreOffice supports the next ODF versions, some places need to be
adapted. They are marked.
The converter convertAngle is renamed to convert10thDegAngle() to
indicate, that it is special. The parts, which were specific to
gradients are moved to the gradients, so that it is now usable for
dr3d:angle and draw:rotation too.
I intend to write next a patch that enables LibreOffice to read angle
units for cases where LibreOffice already writes unit-less values in
degree. That is not so urgent, but to bring LibreOffice nearer to ODF,
reading angle units should be implemented nevertheless.
The file xmlbahdl.hxx is moved from xmloff/source/style to xmloff/inc
to have access to it from xmloff/source/draw.
Change-Id: I8ffc2735f8bcfefb86efa80eb05f900c32403f31
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168336
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'xmloff/inc')
-rw-r--r-- | xmloff/inc/xmlbahdl.hxx | 314 | ||||
-rw-r--r-- | xmloff/inc/xmlsdtypes.hxx | 1 |
2 files changed, 315 insertions, 0 deletions
diff --git a/xmloff/inc/xmlbahdl.hxx b/xmloff/inc/xmlbahdl.hxx new file mode 100644 index 000000000000..09e392d6cc6b --- /dev/null +++ b/xmloff/inc/xmlbahdl.hxx @@ -0,0 +1,314 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <xmloff/xmlprhdl.hxx> +#include <xmloff/xmltoken.hxx> + + +/** + PropertyHandler for the XML-data-type: XML_TYPE_NUMBER +*/ +class XMLNumberPropHdl : public XMLPropertyHandler +{ + sal_Int8 nBytes; + +public: + explicit XMLNumberPropHdl( sal_Int8 nB ) : nBytes( nB ) {} + virtual ~XMLNumberPropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_NUMBER_NONE +*/ +class XMLNumberNonePropHdl : public XMLPropertyHandler +{ + OUString sZeroStr; + sal_Int8 nBytes; +public: + explicit XMLNumberNonePropHdl( sal_Int8 nB = 4 ); + XMLNumberNonePropHdl( enum ::xmloff::token::XMLTokenEnum eZeroString, sal_Int8 nB ); + virtual ~XMLNumberNonePropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_MEASURE +*/ +class XMLMeasurePropHdl : public XMLPropertyHandler +{ + sal_Int8 nBytes; +public: + explicit XMLMeasurePropHdl( sal_Int8 nB ) : nBytes( nB ) {} + virtual ~XMLMeasurePropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_PERCENT +*/ +class XMLPercentPropHdl : public XMLPropertyHandler +{ + sal_Int8 nBytes; +public: + explicit XMLPercentPropHdl( sal_Int8 nB ) : nBytes( nB ) {} + virtual ~XMLPercentPropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_PERCENT + that is mapped on a double from 0.0 to 1.0 +*/ +class XMLDoublePercentPropHdl : public XMLPropertyHandler +{ + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/// Maps between XML percentage and our 100th percent ints. +class XML100thPercentPropHdl : public XMLPropertyHandler +{ + virtual bool importXML(const OUString& rStrImpValue, css::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter) const override; + virtual bool exportXML(OUString& rStrExpValue, const css::uno::Any& rValue, + const SvXMLUnitConverter& rUnitConverter) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_NEG_PERCENT +*/ +class XMLNegPercentPropHdl : public XMLPropertyHandler +{ + sal_Int8 nBytes; +public: + explicit XMLNegPercentPropHdl( sal_Int8 nB ) : nBytes( nB ) {} + virtual ~XMLNegPercentPropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_PERCENT +*/ +class XMLMeasurePxPropHdl : public XMLPropertyHandler +{ + sal_Int8 nBytes; +public: + explicit XMLMeasurePxPropHdl( sal_Int8 nB ) : nBytes( nB ) {} + virtual ~XMLMeasurePxPropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_BOOL +*/ +class XMLBoolPropHdl : public XMLPropertyHandler +{ +public: + virtual ~XMLBoolPropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +class XMLBoolFalsePropHdl : public XMLBoolPropHdl +{ +public: + virtual ~XMLBoolFalsePropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_COLOR +*/ +class XMLColorPropHdl : public XMLPropertyHandler +{ +public: + virtual ~XMLColorPropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_HEX +*/ +class XMLHexPropHdl : public XMLPropertyHandler +{ +public: + virtual ~XMLHexPropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_STRING +*/ +class XMLStringPropHdl : public XMLPropertyHandler +{ +public: + virtual ~XMLStringPropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_STYLENAME +*/ +class XMLStyleNamePropHdl : public XMLStringPropHdl +{ +public: + virtual ~XMLStyleNamePropHdl() override; + + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + + +/** + PropertyHandler for the XML-data-type: XML_TYPE_DOUBLE +*/ +class XMLDoublePropHdl : public XMLPropertyHandler +{ +public: + virtual ~XMLDoublePropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_NBOOL +*/ +class XMLNBoolPropHdl : public XMLPropertyHandler +{ +public: + virtual ~XMLNBoolPropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_COLORTRANSPARENT +*/ +class XMLColorTransparentPropHdl : public XMLPropertyHandler +{ + const OUString sTransparent; + +public: + explicit XMLColorTransparentPropHdl( enum ::xmloff::token::XMLTokenEnum eTransparent = xmloff::token::XML_TOKEN_INVALID ); + virtual ~XMLColorTransparentPropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_ISTRANSPARENT +*/ +class XMLIsTransparentPropHdl : public XMLPropertyHandler +{ + const OUString sTransparent; + bool bTransPropValue; + +public: + XMLIsTransparentPropHdl( enum ::xmloff::token::XMLTokenEnum eTransparent = xmloff::token::XML_TOKEN_INVALID, + bool bTransPropValue = true ); + virtual ~XMLIsTransparentPropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_COLORAUTO +*/ +class XMLColorAutoPropHdl : public XMLPropertyHandler +{ +public: + XMLColorAutoPropHdl(); + virtual ~XMLColorAutoPropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_COLORISAUTO +*/ +class XMLIsAutoColorPropHdl : public XMLPropertyHandler +{ +public: + XMLIsAutoColorPropHdl(); + virtual ~XMLIsAutoColorPropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + + +/** + PropertyHandler for properties that cannot make use of importXML + and exportXML methods, but can make use of the default comparison +*/ +class XMLCompareOnlyPropHdl : public XMLPropertyHandler +{ +public: + virtual ~XMLCompareOnlyPropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/** + PropertyHandler for the XML-data-type: XML_TYPE_NUMBER_NO_ZERO + Reads/writes numeric properties, but fails for the value zero + (i.e., a value 0 property will not be written) +*/ +class XMLNumberWithoutZeroPropHdl : public XMLPropertyHandler +{ + sal_Int8 nBytes; +public: + explicit XMLNumberWithoutZeroPropHdl( sal_Int8 nB ); + virtual ~XMLNumberWithoutZeroPropHdl() override; + + virtual bool importXML( const OUString& rStrImpValue, css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; + virtual bool exportXML( OUString& rStrExpValue, const css::uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/inc/xmlsdtypes.hxx b/xmloff/inc/xmlsdtypes.hxx index c6e0ad315e22..42bf8b865f81 100644 --- a/xmloff/inc/xmlsdtypes.hxx +++ b/xmloff/inc/xmlsdtypes.hxx @@ -119,6 +119,7 @@ #define XML_SD_TYPE_CELL_ROTATION_ANGLE (XML_SD_TYPES_START + 79 ) #define XML_SD_TYPE_WRITINGMODE2 (XML_SD_TYPES_START + 80 ) +#define XML_SD_TYPE_LATHE_ENDANGLE (XML_SD_TYPES_START + 81 ) #define CTF_NUMBERINGRULES 1000 #define CTF_CONTROLWRITINGMODE 1001 |