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
24 #include <rtl/textenc.h>
25 #include <tools/gen.hxx>
26 #include <tools/color.hxx>
27 #include <boost/ptr_container/ptr_vector.hpp>
28 #include <boost/scoped_ptr.hpp>
30 #include "expbase.hxx"
40 enum class SvtScriptType
;
41 namespace editeng
{ class SvxBorderLine
; }
44 { // Defaults aus StyleSheet
45 Color aBackgroundColor
;
46 OUString aFontFamilyName
;
47 sal_uInt32 nFontHeight
; // Item-Value
48 sal_uInt16 nFontSizeNumber
; // HTML value 1-7
49 SvtScriptType nDefaultScriptType
; // Font values are valid for the default script type
59 const ScHTMLStyle
& operator=( const ScHTMLStyle
& rScHTMLStyle
)
61 aBackgroundColor
= rScHTMLStyle
.aBackgroundColor
;
62 aFontFamilyName
= rScHTMLStyle
.aFontFamilyName
;
63 nFontHeight
= rScHTMLStyle
.nFontHeight
;
64 nFontSizeNumber
= rScHTMLStyle
.nFontSizeNumber
;
65 nDefaultScriptType
= rScHTMLStyle
.nDefaultScriptType
;
66 bInitialized
= rScHTMLStyle
.bInitialized
;
71 struct ScHTMLGraphEntry
73 ScRange aRange
; // mapped range
74 Size aSize
; // size in pixels
75 Size aSpace
; // spacing in pixels
77 bool bInCell
; // if output is in cell
80 ScHTMLGraphEntry( SdrObject
* pObj
, const ScRange
& rRange
,
81 const Size
& rSize
, bool bIn
, const Size
& rSpace
) :
91 #define SC_HTML_FONTSIZES 7
92 const short nIndentMax
= 23;
94 class ScHTMLExport
: public ScExportBase
96 // default HtmlFontSz[1-7]
97 static const sal_uInt16 nDefaultFontSize
[SC_HTML_FONTSIZES
];
98 // HtmlFontSz[1-7] in s*3.ini [user]
99 static sal_uInt16 nFontSize
[SC_HTML_FONTSIZES
];
100 static const char* pFontSizeCss
[SC_HTML_FONTSIZES
];
101 static const sal_uInt16 nCellSpacing
;
102 static const sal_Char sIndentSource
[];
104 typedef boost::scoped_ptr
<std::map
<OUString
, OUString
> > FileNameMapPtr
;
105 typedef boost::ptr_vector
<ScHTMLGraphEntry
> GraphEntryList
;
107 GraphEntryList aGraphList
;
108 ScHTMLStyle aHTMLStyle
;
110 OUString aStreamPath
;
111 OUString aFilterOptions
;
112 OUString aCId
; // Content-Id for Mail-Export
113 VclPtr
<OutputDevice
> pAppWin
; // for Pixel-work
114 FileNameMapPtr pFileNameMap
; // for CopyLocalFileToINet
115 OUString aNonConvertibleChars
; // collect nonconvertible characters
116 rtl_TextEncoding eDestEnc
;
119 sal_Char sIndent
[nIndentMax
+1];
120 bool bAll
; // whole document
121 bool bTabHasGraphics
;
122 bool bTabAlignedLeft
;
124 bool bCopyLocalFileToINet
;
125 bool bTableDataWidth
;
126 bool bTableDataHeight
;
128 /// If HTML header and footer should be written as well, or just the content itself.
129 bool mbSkipHeaderFooter
;
131 const SfxItemSet
& PageDefaults( SCTAB nTab
);
135 void WriteOverview();
137 void WriteCell( SCCOL nCol
, SCROW nRow
, SCTAB nTab
);
138 void WriteGraphEntry( ScHTMLGraphEntry
* );
139 void WriteImage( OUString
& rLinkName
,
140 const Graphic
&, const OString
& rImgOptions
,
141 sal_uLong nXOutFlags
= 0 );
142 // nXOutFlags for XOutBitmap::WriteGraphic
144 // write to stream if and only if URL fields in edit cell
145 bool WriteFieldText( const EditTextObject
* pData
);
147 // copy a local file to internet if needed
148 bool CopyLocalFileToINet( OUString
& rFileNm
, const OUString
& rTargetNm
, bool bFileToFile
= false );
151 return !aCId
.isEmpty();
153 void MakeCIdURL( OUString
& rURL
);
155 void PrepareGraphics( ScDrawLayer
*, SCTAB nTab
,
156 SCCOL nStartCol
, SCROW nStartRow
,
157 SCCOL nEndCol
, SCROW nEndRow
);
159 void FillGraphList( const SdrPage
*, SCTAB nTab
,
160 SCCOL nStartCol
, SCROW nStartRow
,
161 SCCOL nEndCol
, SCROW nEndRow
);
163 static OString
BorderToStyle(const char* pBorderName
,
164 const editeng::SvxBorderLine
* pLine
,
165 bool& bInsertSemicolon
);
167 static sal_uInt16
GetFontSizeNumber( sal_uInt16 nHeight
);
168 static const char* GetFontSizeCss( sal_uInt16 nHeight
);
169 sal_uInt16
ToPixel( sal_uInt16 nTwips
);
170 Size
MMToPixel( const Size
& r100thMMSize
);
171 void IncIndent( short nVal
);
173 const sal_Char
* GetIndentStr()
179 ScHTMLExport( SvStream
&, const OUString
&, ScDocument
*, const ScRange
&,
180 bool bAll
, const OUString
& aStreamPath
, const OUString
& rFilterOptions
);
181 virtual ~ScHTMLExport();
183 const OUString
& GetNonConvertibleChars() const
185 return aNonConvertibleChars
;
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */