LibreOffice Module svgio (master) 1
SvgNumber.hxx
Go to the documentation of this file.
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#pragma once
21
23#include <vector>
24
25namespace svgio::svgreader
26{
27
28enum class NumberType
29{
32 length
33};
34
36{
37public:
38 virtual ~InfoProvider() {}
41 virtual double getCurrentFontSizeInherited() const = 0;
43 virtual double getCurrentXHeightInherited() const = 0;
44};
45
46enum class SvgUnit
47{
48 em = 0, // relative to current font size
49 ex, // relative to current x-height
50
51 px, // 'user unit'
52 pt, // points, 1/72 in
53 pc, // 1/6 in
54 cm,
55 mm,
56 in,
57
58 percent, // relative to range
59 none // for stroke-miterlimit, which has no unit
60};
61
63{
64private:
65 double mfNumber;
67
68 bool mbSet : 1;
69
70public:
72 : mfNumber(0.0),
74 mbSet(false)
75 {
76 }
77
78 SvgNumber(double fNum, SvgUnit aSvgUnit = SvgUnit::px, bool bSet = true)
79 : mfNumber(fNum),
80 meUnit(aSvgUnit),
81 mbSet(bSet)
82 {
83 }
84
85 double getNumber() const
86 {
87 return mfNumber;
88 }
89
91 {
92 return meUnit;
93 }
94
95 bool isSet() const
96 {
97 return mbSet;
98 }
99
100 bool isPositive() const
101 {
103 }
104
105 // Only usable in cases, when the unit is not SvgUnit::percent, otherwise use method solve
106 double solveNonPercentage(const InfoProvider& rInfoProvider) const;
107
108 double solve(const InfoProvider& rInfoProvider, NumberType aNumberType = NumberType::length) const;
109};
110
111typedef std::vector<SvgNumber> SvgNumberVector;
112
113} // end of namespace svgio::svgreader
114
115/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual double getCurrentFontSizeInherited() const =0
return font size of node inherited from parents
virtual double getCurrentXHeightInherited() const =0
return xheight of node inherited from parents
virtual basegfx::B2DRange getCurrentViewPort() const =0
SvgNumber(double fNum, SvgUnit aSvgUnit=SvgUnit::px, bool bSet=true)
Definition: SvgNumber.hxx:78
SvgUnit getUnit() const
Definition: SvgNumber.hxx:90
double solveNonPercentage(const InfoProvider &rInfoProvider) const
Definition: SvgNumber.cxx:28
double solve(const InfoProvider &rInfoProvider, NumberType aNumberType=NumberType::length) const
Definition: SvgNumber.cxx:69
double getNumber() const
Definition: SvgNumber.hxx:85
bool moreOrEqual(const T &rfValA, const T &rfValB)
none
std::vector< SvgNumber > SvgNumberVector
Definition: SvgNumber.hxx:111