1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <rtl/textenc.h>
23 #include <tools/gen.hxx>
24 #include <tools/color.hxx>
25 #include <vcl/vclptr.hxx>
29 #include <svx/xoutbmp.hxx>
31 #include "expbase.hxx"
41 enum class SvtScriptType
;
42 namespace editeng
{ class SvxBorderLine
; }
45 struct ColumnBlockPosition
;
49 { // Defaults from stylesheet
50 Color aBackgroundColor
;
51 OUString aFontFamilyName
;
52 sal_uInt32 nFontHeight
; // Item-Value
53 sal_uInt16 nFontSizeNumber
; // HTML value 1-7
54 SvtScriptType nDefaultScriptType
; // Font values are valid for the default script type
64 const ScHTMLStyle
& operator=( const ScHTMLStyle
& rScHTMLStyle
)
66 aBackgroundColor
= rScHTMLStyle
.aBackgroundColor
;
67 aFontFamilyName
= rScHTMLStyle
.aFontFamilyName
;
68 nFontHeight
= rScHTMLStyle
.nFontHeight
;
69 nFontSizeNumber
= rScHTMLStyle
.nFontSizeNumber
;
70 nDefaultScriptType
= rScHTMLStyle
.nDefaultScriptType
;
71 bInitialized
= rScHTMLStyle
.bInitialized
;
76 struct ScHTMLGraphEntry
78 ScRange aRange
; // mapped range
79 Size aSize
; // size in pixels
80 Size aSpace
; // spacing in pixels
82 bool bInCell
; // if output is in cell
85 ScHTMLGraphEntry( SdrObject
* pObj
, const ScRange
& rRange
,
86 const Size
& rSize
, bool bIn
, const Size
& rSpace
) :
96 #define SC_HTML_FONTSIZES 7
97 const short nIndentMax
= 23;
99 class ScHTMLExport
: public ScExportBase
101 // default HtmlFontSz[1-7]
102 static const sal_uInt16 nDefaultFontSize
[SC_HTML_FONTSIZES
];
103 // HtmlFontSz[1-7] in s*3.ini [user]
104 static sal_uInt16 nFontSize
[SC_HTML_FONTSIZES
];
105 static const char* pFontSizeCss
[SC_HTML_FONTSIZES
];
106 static const sal_uInt16 nCellSpacing
;
107 static const char sIndentSource
[];
109 typedef std::unique_ptr
<std::map
<OUString
, OUString
> > FileNameMapPtr
;
110 typedef std::vector
<ScHTMLGraphEntry
> GraphEntryList
;
112 GraphEntryList aGraphList
;
113 ScHTMLStyle aHTMLStyle
;
115 OUString aStreamPath
;
116 VclPtr
<OutputDevice
> pAppWin
; // for Pixel-work
117 FileNameMapPtr pFileNameMap
; // for CopyLocalFileToINet
118 OUString aNonConvertibleChars
; // collect nonconvertible characters
119 rtl_TextEncoding eDestEnc
;
122 char sIndent
[nIndentMax
+1];
123 bool bAll
; // whole document
124 bool bTabHasGraphics
;
125 bool bTabAlignedLeft
;
127 bool bCopyLocalFileToINet
;
128 bool bTableDataHeight
;
130 /// If HTML header and footer should be written as well, or just the content itself.
131 bool mbSkipHeaderFooter
;
133 const SfxItemSet
& PageDefaults( SCTAB nTab
);
137 void WriteOverview();
139 void WriteCell( sc::ColumnBlockPosition
& rBlockPos
, SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
140 void WriteGraphEntry( ScHTMLGraphEntry
* );
141 void WriteImage( OUString
& rLinkName
,
142 const Graphic
&, std::string_view rImgOptions
,
143 XOutFlags nXOutFlags
= XOutFlags::NONE
);
144 // nXOutFlags for XOutBitmap::WriteGraphic
146 // write to stream if and only if URL fields in edit cell
147 bool WriteFieldText( const EditTextObject
* pData
);
149 // copy a local file to internet if needed
150 void CopyLocalFileToINet( OUString
& rFileNm
, const OUString
& rTargetNm
);
152 void PrepareGraphics( ScDrawLayer
*, SCTAB nTab
,
153 SCCOL nStartCol
, SCROW nStartRow
,
154 SCCOL nEndCol
, SCROW nEndRow
);
156 void FillGraphList( const SdrPage
*, SCTAB nTab
,
157 SCCOL nStartCol
, SCROW nStartRow
,
158 SCCOL nEndCol
, SCROW nEndRow
);
160 static OString
BorderToStyle(const char* pBorderName
,
161 const editeng::SvxBorderLine
* pLine
,
162 bool& bInsertSemicolon
);
164 static sal_uInt16
GetFontSizeNumber( sal_uInt16 nHeight
);
165 static const char* GetFontSizeCss( sal_uInt16 nHeight
);
166 sal_uInt16
ToPixel( sal_uInt16 nTwips
);
167 Size
MMToPixel( const Size
& r100thMMSize
);
168 void IncIndent( short nVal
);
170 const char* GetIndentStr() const
176 ScHTMLExport( SvStream
&, const OUString
&, ScDocument
*, const ScRange
&,
177 bool bAll
, const OUString
& aStreamPath
, std::u16string_view rFilterOptions
);
178 virtual ~ScHTMLExport() override
;
180 const OUString
& GetNonConvertibleChars() const
182 return aNonConvertibleChars
;
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */