/src/libreoffice/include/oox/export/utils.hxx
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 | | #ifndef INCLUDED_OOX_EXPORT_UTILS_HXX |
21 | | #define INCLUDED_OOX_EXPORT_UTILS_HXX |
22 | | |
23 | | #include <sal/config.h> |
24 | | |
25 | | #include <o3tl/unit_conversion.hxx> |
26 | | #include <rtl/strbuf.hxx> |
27 | | #include <rtl/string.hxx> |
28 | | #include <sal/types.h> |
29 | | |
30 | | #include <cmath> |
31 | | |
32 | | // Only used to output rgb colors as hex |
33 | | inline OString I32SHEX(sal_Int32 x) |
34 | 0 | { |
35 | 0 | assert(x <= 0xffffff); |
36 | 0 | rtl::OStringBuffer aRes(6); |
37 | 0 | aRes.setLength(6); |
38 | 0 | sal_Int32 n = 0; |
39 | 0 | for (int nShift = 24-4; nShift >=0; nShift -= 4) |
40 | 0 | { |
41 | 0 | char nDigit = static_cast<char>((x >> nShift) & 0xf); |
42 | 0 | if ( nDigit > 9 ) |
43 | 0 | aRes[n] = (nDigit-10) + 'A'; |
44 | 0 | else |
45 | 0 | aRes[n] = (nDigit + '0'); |
46 | 0 | n++; |
47 | 0 | } |
48 | 0 | return aRes.makeStringAndClear(); |
49 | 0 | } |
50 | | |
51 | | /** |
52 | | * @return const char* literal "true" for true value, or literal "false" |
53 | | * for false value. |
54 | | */ |
55 | | static constexpr const char* ToPsz(bool b) |
56 | 0 | { |
57 | 0 | return b ? "true" : "false"; |
58 | 0 | } Unexecuted instantiation: xeroot.cxx:ToPsz(bool) Unexecuted instantiation: xestyle.cxx:ToPsz(bool) Unexecuted instantiation: excdoc.cxx:ToPsz(bool) Unexecuted instantiation: excrecds.cxx:ToPsz(bool) Unexecuted instantiation: xecontent.cxx:ToPsz(bool) Unexecuted instantiation: xedbdata.cxx:ToPsz(bool) Unexecuted instantiation: xeescher.cxx:ToPsz(bool) Unexecuted instantiation: xeextlst.cxx:ToPsz(bool) Unexecuted instantiation: xename.cxx:ToPsz(bool) Unexecuted instantiation: xepage.cxx:ToPsz(bool) Unexecuted instantiation: xepivotxml.cxx:ToPsz(bool) Unexecuted instantiation: xerecord.cxx:ToPsz(bool) Unexecuted instantiation: xestream.cxx:ToPsz(bool) Unexecuted instantiation: xetable.cxx:ToPsz(bool) Unexecuted instantiation: xeview.cxx:ToPsz(bool) Unexecuted instantiation: SparklineExt.cxx:ToPsz(bool) Unexecuted instantiation: XclExpChangeTrack.cxx:ToPsz(bool) Unexecuted instantiation: xcl97esc.cxx:ToPsz(bool) Unexecuted instantiation: xcl97rec.cxx:ToPsz(bool) Unexecuted instantiation: xechart.cxx:ToPsz(bool) Unexecuted instantiation: chartexport.cxx:ToPsz(bool) Unexecuted instantiation: shape.cxx:ToPsz(bool) Unexecuted instantiation: textbodycontext.cxx:ToPsz(bool) Unexecuted instantiation: drawingml.cxx:ToPsz(bool) Unexecuted instantiation: shapes.cxx:ToPsz(bool) Unexecuted instantiation: vmlexport.cxx:ToPsz(bool) Unexecuted instantiation: ThemeExport.cxx:ToPsz(bool) Unexecuted instantiation: imexport.cxx:ToPsz(bool) Unexecuted instantiation: DMLPresetShapeExport.cxx:ToPsz(bool) Unexecuted instantiation: unodoc.cxx:ToPsz(bool) Unexecuted instantiation: unofilter.cxx:ToPsz(bool) Unexecuted instantiation: unomodel.cxx:ToPsz(bool) Unexecuted instantiation: utility.cxx:ToPsz(bool) Unexecuted instantiation: view.cxx:ToPsz(bool) Unexecuted instantiation: mathmlexport.cxx:ToPsz(bool) Unexecuted instantiation: mathmlimport.cxx:ToPsz(bool) Unexecuted instantiation: accessibility.cxx:ToPsz(bool) Unexecuted instantiation: cursor.cxx:ToPsz(bool) Unexecuted instantiation: dialog.cxx:ToPsz(bool) Unexecuted instantiation: document.cxx:ToPsz(bool) Unexecuted instantiation: edit.cxx:ToPsz(bool) Unexecuted instantiation: ooxmlexport.cxx:ToPsz(bool) Unexecuted instantiation: smdll.cxx:ToPsz(bool) Unexecuted instantiation: smmod.cxx:ToPsz(bool) Unexecuted instantiation: action.cxx:ToPsz(bool) Unexecuted instantiation: rtfdocumentimpl.cxx:ToPsz(bool) Unexecuted instantiation: DomainMapper_Impl.cxx:ToPsz(bool) Unexecuted instantiation: GraphicImport.cxx:ToPsz(bool) Unexecuted instantiation: wrtw8sty.cxx:ToPsz(bool) Unexecuted instantiation: docxattributeoutput.cxx:ToPsz(bool) Unexecuted instantiation: docxexport.cxx:ToPsz(bool) Unexecuted instantiation: docxsdrexport.cxx:ToPsz(bool) Unexecuted instantiation: docxtableexport.cxx:ToPsz(bool) Unexecuted instantiation: rtfattributeoutput.cxx:ToPsz(bool) Unexecuted instantiation: OOXMLFastContextHandler.cxx:ToPsz(bool) Unexecuted instantiation: drviews3.cxx:ToPsz(bool) Unexecuted instantiation: eppt.cxx:ToPsz(bool) Unexecuted instantiation: pptx-epptooxml.cxx:ToPsz(bool) Unexecuted instantiation: pptx-animations.cxx:ToPsz(bool) |
59 | | |
60 | | /** |
61 | | * @return literal "1" for true value, or literal "0" for false value. |
62 | | */ |
63 | | static constexpr const char* ToPsz10(bool b) |
64 | 0 | { |
65 | | // xlsx seems to use "1" or "0" for boolean values. I wonder it ever uses |
66 | | // the "true" "false" variant. |
67 | 0 | return b ? "1" : "0"; |
68 | 0 | } Unexecuted instantiation: xeroot.cxx:ToPsz10(bool) Unexecuted instantiation: xestyle.cxx:ToPsz10(bool) Unexecuted instantiation: excdoc.cxx:ToPsz10(bool) Unexecuted instantiation: excrecds.cxx:ToPsz10(bool) Unexecuted instantiation: xecontent.cxx:ToPsz10(bool) Unexecuted instantiation: xedbdata.cxx:ToPsz10(bool) Unexecuted instantiation: xeescher.cxx:ToPsz10(bool) Unexecuted instantiation: xeextlst.cxx:ToPsz10(bool) Unexecuted instantiation: xename.cxx:ToPsz10(bool) Unexecuted instantiation: xepage.cxx:ToPsz10(bool) Unexecuted instantiation: xepivotxml.cxx:ToPsz10(bool) Unexecuted instantiation: xerecord.cxx:ToPsz10(bool) Unexecuted instantiation: xestream.cxx:ToPsz10(bool) Unexecuted instantiation: xetable.cxx:ToPsz10(bool) Unexecuted instantiation: xeview.cxx:ToPsz10(bool) Unexecuted instantiation: SparklineExt.cxx:ToPsz10(bool) Unexecuted instantiation: XclExpChangeTrack.cxx:ToPsz10(bool) Unexecuted instantiation: xcl97esc.cxx:ToPsz10(bool) Unexecuted instantiation: xcl97rec.cxx:ToPsz10(bool) Unexecuted instantiation: xechart.cxx:ToPsz10(bool) Unexecuted instantiation: chartexport.cxx:ToPsz10(bool) Unexecuted instantiation: shape.cxx:ToPsz10(bool) Unexecuted instantiation: textbodycontext.cxx:ToPsz10(bool) Unexecuted instantiation: drawingml.cxx:ToPsz10(bool) Unexecuted instantiation: shapes.cxx:ToPsz10(bool) Unexecuted instantiation: vmlexport.cxx:ToPsz10(bool) Unexecuted instantiation: ThemeExport.cxx:ToPsz10(bool) Unexecuted instantiation: imexport.cxx:ToPsz10(bool) Unexecuted instantiation: DMLPresetShapeExport.cxx:ToPsz10(bool) Unexecuted instantiation: unodoc.cxx:ToPsz10(bool) Unexecuted instantiation: unofilter.cxx:ToPsz10(bool) Unexecuted instantiation: unomodel.cxx:ToPsz10(bool) Unexecuted instantiation: utility.cxx:ToPsz10(bool) Unexecuted instantiation: view.cxx:ToPsz10(bool) Unexecuted instantiation: mathmlexport.cxx:ToPsz10(bool) Unexecuted instantiation: mathmlimport.cxx:ToPsz10(bool) Unexecuted instantiation: accessibility.cxx:ToPsz10(bool) Unexecuted instantiation: cursor.cxx:ToPsz10(bool) Unexecuted instantiation: dialog.cxx:ToPsz10(bool) Unexecuted instantiation: document.cxx:ToPsz10(bool) Unexecuted instantiation: edit.cxx:ToPsz10(bool) Unexecuted instantiation: ooxmlexport.cxx:ToPsz10(bool) Unexecuted instantiation: smdll.cxx:ToPsz10(bool) Unexecuted instantiation: smmod.cxx:ToPsz10(bool) Unexecuted instantiation: action.cxx:ToPsz10(bool) Unexecuted instantiation: rtfdocumentimpl.cxx:ToPsz10(bool) Unexecuted instantiation: DomainMapper_Impl.cxx:ToPsz10(bool) Unexecuted instantiation: GraphicImport.cxx:ToPsz10(bool) Unexecuted instantiation: wrtw8sty.cxx:ToPsz10(bool) Unexecuted instantiation: docxattributeoutput.cxx:ToPsz10(bool) Unexecuted instantiation: docxexport.cxx:ToPsz10(bool) Unexecuted instantiation: docxsdrexport.cxx:ToPsz10(bool) Unexecuted instantiation: docxtableexport.cxx:ToPsz10(bool) Unexecuted instantiation: rtfattributeoutput.cxx:ToPsz10(bool) Unexecuted instantiation: OOXMLFastContextHandler.cxx:ToPsz10(bool) Unexecuted instantiation: drviews3.cxx:ToPsz10(bool) Unexecuted instantiation: eppt.cxx:ToPsz10(bool) Unexecuted instantiation: pptx-epptooxml.cxx:ToPsz10(bool) Unexecuted instantiation: pptx-animations.cxx:ToPsz10(bool) |
69 | | |
70 | | static constexpr sal_Int64 PPTtoEMU( sal_Int32 nPPT ) |
71 | 0 | { |
72 | 0 | return o3tl::convert(nPPT, o3tl::Length::master, o3tl::Length::emu); |
73 | 0 | } Unexecuted instantiation: xeroot.cxx:PPTtoEMU(int) Unexecuted instantiation: xestyle.cxx:PPTtoEMU(int) Unexecuted instantiation: excdoc.cxx:PPTtoEMU(int) Unexecuted instantiation: excrecds.cxx:PPTtoEMU(int) Unexecuted instantiation: xecontent.cxx:PPTtoEMU(int) Unexecuted instantiation: xedbdata.cxx:PPTtoEMU(int) Unexecuted instantiation: xeescher.cxx:PPTtoEMU(int) Unexecuted instantiation: xeextlst.cxx:PPTtoEMU(int) Unexecuted instantiation: xename.cxx:PPTtoEMU(int) Unexecuted instantiation: xepage.cxx:PPTtoEMU(int) Unexecuted instantiation: xepivotxml.cxx:PPTtoEMU(int) Unexecuted instantiation: xerecord.cxx:PPTtoEMU(int) Unexecuted instantiation: xestream.cxx:PPTtoEMU(int) Unexecuted instantiation: xetable.cxx:PPTtoEMU(int) Unexecuted instantiation: xeview.cxx:PPTtoEMU(int) Unexecuted instantiation: SparklineExt.cxx:PPTtoEMU(int) Unexecuted instantiation: XclExpChangeTrack.cxx:PPTtoEMU(int) Unexecuted instantiation: xcl97esc.cxx:PPTtoEMU(int) Unexecuted instantiation: xcl97rec.cxx:PPTtoEMU(int) Unexecuted instantiation: xechart.cxx:PPTtoEMU(int) Unexecuted instantiation: chartexport.cxx:PPTtoEMU(int) Unexecuted instantiation: shape.cxx:PPTtoEMU(int) Unexecuted instantiation: textbodycontext.cxx:PPTtoEMU(int) Unexecuted instantiation: drawingml.cxx:PPTtoEMU(int) Unexecuted instantiation: shapes.cxx:PPTtoEMU(int) Unexecuted instantiation: vmlexport.cxx:PPTtoEMU(int) Unexecuted instantiation: ThemeExport.cxx:PPTtoEMU(int) Unexecuted instantiation: imexport.cxx:PPTtoEMU(int) Unexecuted instantiation: DMLPresetShapeExport.cxx:PPTtoEMU(int) Unexecuted instantiation: unodoc.cxx:PPTtoEMU(int) Unexecuted instantiation: unofilter.cxx:PPTtoEMU(int) Unexecuted instantiation: unomodel.cxx:PPTtoEMU(int) Unexecuted instantiation: utility.cxx:PPTtoEMU(int) Unexecuted instantiation: view.cxx:PPTtoEMU(int) Unexecuted instantiation: mathmlexport.cxx:PPTtoEMU(int) Unexecuted instantiation: mathmlimport.cxx:PPTtoEMU(int) Unexecuted instantiation: accessibility.cxx:PPTtoEMU(int) Unexecuted instantiation: cursor.cxx:PPTtoEMU(int) Unexecuted instantiation: dialog.cxx:PPTtoEMU(int) Unexecuted instantiation: document.cxx:PPTtoEMU(int) Unexecuted instantiation: edit.cxx:PPTtoEMU(int) Unexecuted instantiation: ooxmlexport.cxx:PPTtoEMU(int) Unexecuted instantiation: smdll.cxx:PPTtoEMU(int) Unexecuted instantiation: smmod.cxx:PPTtoEMU(int) Unexecuted instantiation: action.cxx:PPTtoEMU(int) Unexecuted instantiation: rtfdocumentimpl.cxx:PPTtoEMU(int) Unexecuted instantiation: DomainMapper_Impl.cxx:PPTtoEMU(int) Unexecuted instantiation: GraphicImport.cxx:PPTtoEMU(int) Unexecuted instantiation: wrtw8sty.cxx:PPTtoEMU(int) Unexecuted instantiation: docxattributeoutput.cxx:PPTtoEMU(int) Unexecuted instantiation: docxexport.cxx:PPTtoEMU(int) Unexecuted instantiation: docxsdrexport.cxx:PPTtoEMU(int) Unexecuted instantiation: docxtableexport.cxx:PPTtoEMU(int) Unexecuted instantiation: rtfattributeoutput.cxx:PPTtoEMU(int) Unexecuted instantiation: OOXMLFastContextHandler.cxx:PPTtoEMU(int) Unexecuted instantiation: drviews3.cxx:PPTtoEMU(int) Unexecuted instantiation: eppt.cxx:PPTtoEMU(int) Unexecuted instantiation: pptx-epptooxml.cxx:PPTtoEMU(int) Unexecuted instantiation: pptx-animations.cxx:PPTtoEMU(int) |
74 | | |
75 | | static constexpr sal_Int64 TwipsToEMU( sal_Int32 nTwips ) |
76 | 0 | { |
77 | 0 | return o3tl::convert(nTwips, o3tl::Length::twip, o3tl::Length::emu); |
78 | 0 | } Unexecuted instantiation: xeroot.cxx:TwipsToEMU(int) Unexecuted instantiation: xestyle.cxx:TwipsToEMU(int) Unexecuted instantiation: excdoc.cxx:TwipsToEMU(int) Unexecuted instantiation: excrecds.cxx:TwipsToEMU(int) Unexecuted instantiation: xecontent.cxx:TwipsToEMU(int) Unexecuted instantiation: xedbdata.cxx:TwipsToEMU(int) Unexecuted instantiation: xeescher.cxx:TwipsToEMU(int) Unexecuted instantiation: xeextlst.cxx:TwipsToEMU(int) Unexecuted instantiation: xename.cxx:TwipsToEMU(int) Unexecuted instantiation: xepage.cxx:TwipsToEMU(int) Unexecuted instantiation: xepivotxml.cxx:TwipsToEMU(int) Unexecuted instantiation: xerecord.cxx:TwipsToEMU(int) Unexecuted instantiation: xestream.cxx:TwipsToEMU(int) Unexecuted instantiation: xetable.cxx:TwipsToEMU(int) Unexecuted instantiation: xeview.cxx:TwipsToEMU(int) Unexecuted instantiation: SparklineExt.cxx:TwipsToEMU(int) Unexecuted instantiation: XclExpChangeTrack.cxx:TwipsToEMU(int) Unexecuted instantiation: xcl97esc.cxx:TwipsToEMU(int) Unexecuted instantiation: xcl97rec.cxx:TwipsToEMU(int) Unexecuted instantiation: xechart.cxx:TwipsToEMU(int) Unexecuted instantiation: chartexport.cxx:TwipsToEMU(int) Unexecuted instantiation: shape.cxx:TwipsToEMU(int) Unexecuted instantiation: textbodycontext.cxx:TwipsToEMU(int) Unexecuted instantiation: drawingml.cxx:TwipsToEMU(int) Unexecuted instantiation: shapes.cxx:TwipsToEMU(int) Unexecuted instantiation: vmlexport.cxx:TwipsToEMU(int) Unexecuted instantiation: ThemeExport.cxx:TwipsToEMU(int) Unexecuted instantiation: imexport.cxx:TwipsToEMU(int) Unexecuted instantiation: DMLPresetShapeExport.cxx:TwipsToEMU(int) Unexecuted instantiation: unodoc.cxx:TwipsToEMU(int) Unexecuted instantiation: unofilter.cxx:TwipsToEMU(int) Unexecuted instantiation: unomodel.cxx:TwipsToEMU(int) Unexecuted instantiation: utility.cxx:TwipsToEMU(int) Unexecuted instantiation: view.cxx:TwipsToEMU(int) Unexecuted instantiation: mathmlexport.cxx:TwipsToEMU(int) Unexecuted instantiation: mathmlimport.cxx:TwipsToEMU(int) Unexecuted instantiation: accessibility.cxx:TwipsToEMU(int) Unexecuted instantiation: cursor.cxx:TwipsToEMU(int) Unexecuted instantiation: dialog.cxx:TwipsToEMU(int) Unexecuted instantiation: document.cxx:TwipsToEMU(int) Unexecuted instantiation: edit.cxx:TwipsToEMU(int) Unexecuted instantiation: ooxmlexport.cxx:TwipsToEMU(int) Unexecuted instantiation: smdll.cxx:TwipsToEMU(int) Unexecuted instantiation: smmod.cxx:TwipsToEMU(int) Unexecuted instantiation: action.cxx:TwipsToEMU(int) Unexecuted instantiation: rtfdocumentimpl.cxx:TwipsToEMU(int) Unexecuted instantiation: DomainMapper_Impl.cxx:TwipsToEMU(int) Unexecuted instantiation: GraphicImport.cxx:TwipsToEMU(int) Unexecuted instantiation: wrtw8sty.cxx:TwipsToEMU(int) Unexecuted instantiation: docxattributeoutput.cxx:TwipsToEMU(int) Unexecuted instantiation: docxexport.cxx:TwipsToEMU(int) Unexecuted instantiation: docxsdrexport.cxx:TwipsToEMU(int) Unexecuted instantiation: docxtableexport.cxx:TwipsToEMU(int) Unexecuted instantiation: rtfattributeoutput.cxx:TwipsToEMU(int) Unexecuted instantiation: OOXMLFastContextHandler.cxx:TwipsToEMU(int) Unexecuted instantiation: drviews3.cxx:TwipsToEMU(int) Unexecuted instantiation: eppt.cxx:TwipsToEMU(int) Unexecuted instantiation: pptx-epptooxml.cxx:TwipsToEMU(int) Unexecuted instantiation: pptx-animations.cxx:TwipsToEMU(int) |
79 | | |
80 | | template <typename T> |
81 | | OString write1000thOfAPercent(T number) |
82 | 0 | { |
83 | 0 | return OString::number( lround(number * 1000.0) ); |
84 | 0 | } |
85 | | |
86 | | namespace oox::drawingml { |
87 | | enum DocumentType { DOCUMENT_DOCX, DOCUMENT_PPTX, DOCUMENT_XLSX }; |
88 | | } |
89 | | |
90 | | #endif |
91 | | |
92 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |