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 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_HTMLEXP_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_HTMLEXP_HXX
23 #include <rtl/textenc.h>
24 #include <tools/gen.hxx>
25 #include <tools/color.hxx>
26 #include <vcl/vclptr.hxx>
30 #include <svx/xoutbmp.hxx>
32 #include "expbase.hxx"
42 enum class SvtScriptType
;
43 namespace editeng
{ class SvxBorderLine
; }
46 struct ColumnBlockPosition
;
50 { // Defaults from stylesheet
51 Color aBackgroundColor
;
52 OUString aFontFamilyName
;
53 sal_uInt32 nFontHeight
; // Item-Value
54 sal_uInt16 nFontSizeNumber
; // HTML value 1-7
55 SvtScriptType nDefaultScriptType
; // Font values are valid for the default script type
65 const ScHTMLStyle
& operator=( const ScHTMLStyle
& rScHTMLStyle
)
67 aBackgroundColor
= rScHTMLStyle
.aBackgroundColor
;
68 aFontFamilyName
= rScHTMLStyle
.aFontFamilyName
;
69 nFontHeight
= rScHTMLStyle
.nFontHeight
;
70 nFontSizeNumber
= rScHTMLStyle
.nFontSizeNumber
;
71 nDefaultScriptType
= rScHTMLStyle
.nDefaultScriptType
;
72 bInitialized
= rScHTMLStyle
.bInitialized
;
77 struct ScHTMLGraphEntry
79 ScRange
const aRange
; // mapped range
80 Size
const aSize
; // size in pixels
81 Size
const aSpace
; // spacing in pixels
82 SdrObject
* const pObject
;
83 bool const bInCell
; // if output is in cell
86 ScHTMLGraphEntry( SdrObject
* pObj
, const ScRange
& rRange
,
87 const Size
& rSize
, bool bIn
, const Size
& rSpace
) :
97 #define SC_HTML_FONTSIZES 7
98 const short nIndentMax
= 23;
100 class ScHTMLExport
: public ScExportBase
102 // default HtmlFontSz[1-7]
103 static const sal_uInt16 nDefaultFontSize
[SC_HTML_FONTSIZES
];
104 // HtmlFontSz[1-7] in s*3.ini [user]
105 static sal_uInt16 nFontSize
[SC_HTML_FONTSIZES
];
106 static const char* pFontSizeCss
[SC_HTML_FONTSIZES
];
107 static const sal_uInt16 nCellSpacing
;
108 static const sal_Char sIndentSource
[];
110 typedef std::unique_ptr
<std::map
<OUString
, OUString
> > FileNameMapPtr
;
111 typedef std::vector
<ScHTMLGraphEntry
> GraphEntryList
;
113 GraphEntryList aGraphList
;
114 ScHTMLStyle aHTMLStyle
;
116 OUString
const aStreamPath
;
117 VclPtr
<OutputDevice
> pAppWin
; // for Pixel-work
118 FileNameMapPtr pFileNameMap
; // for CopyLocalFileToINet
119 OUString aNonConvertibleChars
; // collect nonconvertible characters
120 rtl_TextEncoding eDestEnc
;
123 sal_Char sIndent
[nIndentMax
+1];
124 bool const bAll
; // whole document
125 bool bTabHasGraphics
;
126 bool bTabAlignedLeft
;
127 bool const bCalcAsShown
;
128 bool bCopyLocalFileToINet
;
129 bool bTableDataHeight
;
131 /// If HTML header and footer should be written as well, or just the content itself.
132 bool mbSkipHeaderFooter
;
134 const SfxItemSet
& PageDefaults( SCTAB nTab
);
138 void WriteOverview();
140 void WriteCell( sc::ColumnBlockPosition
& rBlockPos
, SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
141 void WriteGraphEntry( ScHTMLGraphEntry
* );
142 void WriteImage( OUString
& rLinkName
,
143 const Graphic
&, const OString
& rImgOptions
,
144 XOutFlags nXOutFlags
= XOutFlags::NONE
);
145 // nXOutFlags for XOutBitmap::WriteGraphic
147 // write to stream if and only if URL fields in edit cell
148 bool WriteFieldText( const EditTextObject
* pData
);
150 // copy a local file to internet if needed
151 void CopyLocalFileToINet( OUString
& rFileNm
, const OUString
& rTargetNm
);
153 void PrepareGraphics( ScDrawLayer
*, SCTAB nTab
,
154 SCCOL nStartCol
, SCROW nStartRow
,
155 SCCOL nEndCol
, SCROW nEndRow
);
157 void FillGraphList( const SdrPage
*, SCTAB nTab
,
158 SCCOL nStartCol
, SCROW nStartRow
,
159 SCCOL nEndCol
, SCROW nEndRow
);
161 static OString
BorderToStyle(const char* pBorderName
,
162 const editeng::SvxBorderLine
* pLine
,
163 bool& bInsertSemicolon
);
165 static sal_uInt16
GetFontSizeNumber( sal_uInt16 nHeight
);
166 static const char* GetFontSizeCss( sal_uInt16 nHeight
);
167 sal_uInt16
ToPixel( sal_uInt16 nTwips
);
168 Size
MMToPixel( const Size
& r100thMMSize
);
169 void IncIndent( short nVal
);
171 const sal_Char
* GetIndentStr() const
177 ScHTMLExport( SvStream
&, const OUString
&, ScDocument
*, const ScRange
&,
178 bool bAll
, const OUString
& aStreamPath
, const OUString
& rFilterOptions
);
179 virtual ~ScHTMLExport() override
;
181 const OUString
& GetNonConvertibleChars() const
183 return aNonConvertibleChars
;
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */