LibreOffice Module sc (master)  1
htmlexp.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 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_HTMLEXP_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_HTMLEXP_HXX
22 
23 #include <rtl/textenc.h>
24 #include <tools/gen.hxx>
25 #include <tools/color.hxx>
26 #include <vcl/vclptr.hxx>
27 #include <vector>
28 #include <memory>
29 #include <map>
30 #include <svx/xoutbmp.hxx>
31 
32 #include "expbase.hxx"
33 
34 class ScDocument;
35 class SfxItemSet;
36 class SdrPage;
37 class Graphic;
38 class SdrObject;
39 class OutputDevice;
40 class ScDrawLayer;
41 class EditTextObject;
42 enum class SvtScriptType;
43 namespace editeng { class SvxBorderLine; }
44 
45 namespace sc {
46 struct ColumnBlockPosition;
47 }
48 
50 { // Defaults from stylesheet
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
57 
59  nFontHeight(0),
60  nFontSizeNumber(2),
61  nDefaultScriptType(),
62  bInitialized(false)
63  {}
64 
65  const ScHTMLStyle& operator=( const ScHTMLStyle& rScHTMLStyle )
66  {
67  aBackgroundColor = rScHTMLStyle.aBackgroundColor;
68  aFontFamilyName = rScHTMLStyle.aFontFamilyName;
69  nFontHeight = rScHTMLStyle.nFontHeight;
70  nFontSizeNumber = rScHTMLStyle.nFontSizeNumber;
71  nDefaultScriptType = rScHTMLStyle.nDefaultScriptType;
72  bInitialized = rScHTMLStyle.bInitialized;
73  return *this;
74  }
75 };
76 
78 {
79  ScRange aRange; // mapped range
80  Size aSize; // size in pixels
81  Size aSpace; // spacing in pixels
83  bool bInCell; // if output is in cell
84  bool bWritten;
85 
86  ScHTMLGraphEntry( SdrObject* pObj, const ScRange& rRange,
87  const Size& rSize, bool bIn, const Size& rSpace ) :
88  aRange( rRange ),
89  aSize( rSize ),
90  aSpace( rSpace ),
91  pObject( pObj ),
92  bInCell( bIn ),
93  bWritten( false )
94  {}
95 };
96 
97 #define SC_HTML_FONTSIZES 7
98 const short nIndentMax = 23;
99 
101 {
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 char sIndentSource[];
109 
110  typedef std::unique_ptr<std::map<OUString, OUString> > FileNameMapPtr;
111  typedef std::vector<ScHTMLGraphEntry> GraphEntryList;
112 
113  GraphEntryList aGraphList;
115  OUString aBaseURL;
116  OUString aStreamPath;
117  VclPtr<OutputDevice> pAppWin; // for Pixel-work
118  FileNameMapPtr pFileNameMap; // for CopyLocalFileToINet
119  OUString aNonConvertibleChars; // collect nonconvertible characters
120  rtl_TextEncoding eDestEnc;
122  short nIndent;
124  bool bAll; // whole document
133 
134  const SfxItemSet& PageDefaults( SCTAB nTab );
135 
136  void WriteBody();
137  void WriteHeader();
138  void WriteOverview();
139  void WriteTables();
140  void WriteCell( sc::ColumnBlockPosition& rBlockPos, SCCOL nCol, SCROW nRow, SCTAB nTab );
142  void WriteImage( OUString& rLinkName,
143  const Graphic&, const OString& rImgOptions,
144  XOutFlags nXOutFlags = XOutFlags::NONE );
145  // nXOutFlags for XOutBitmap::WriteGraphic
146 
147  // write to stream if and only if URL fields in edit cell
148  bool WriteFieldText( const EditTextObject* pData );
149 
150  // copy a local file to internet if needed
151  void CopyLocalFileToINet( OUString& rFileNm, const OUString& rTargetNm );
152 
153  void PrepareGraphics( ScDrawLayer*, SCTAB nTab,
154  SCCOL nStartCol, SCROW nStartRow,
155  SCCOL nEndCol, SCROW nEndRow );
156 
157  void FillGraphList( const SdrPage*, SCTAB nTab,
158  SCCOL nStartCol, SCROW nStartRow,
159  SCCOL nEndCol, SCROW nEndRow );
160 
161  static OString BorderToStyle(const char* pBorderName,
162  const editeng::SvxBorderLine* pLine,
163  bool& bInsertSemicolon);
164 
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 );
170 
171  const char* GetIndentStr() const
172  {
173  return sIndent;
174  }
175 
176 public:
177  ScHTMLExport( SvStream&, const OUString&, ScDocument*, const ScRange&,
178  bool bAll, const OUString& aStreamPath, std::u16string_view rFilterOptions );
179  virtual ~ScHTMLExport() override;
180  void Write();
181  const OUString& GetNonConvertibleChars() const
182  {
183  return aNonConvertibleChars;
184  }
185 };
186 
187 #endif
188 
189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SCTAB nUsedTables
Definition: htmlexp.hxx:121
static const char sIndentSource[]
Definition: htmlexp.hxx:108
static const sal_uInt16 nDefaultFontSize[SC_HTML_FONTSIZES]
Definition: htmlexp.hxx:103
ScHTMLStyle aHTMLStyle
Definition: htmlexp.hxx:114
const short nIndentMax
Definition: htmlexp.hxx:98
virtual ~ScHTMLExport() override
Definition: htmlexp.cxx:246
FileNameMapPtr pFileNameMap
Definition: htmlexp.hxx:118
sal_uInt16 nFontSizeNumber
Definition: htmlexp.hxx:54
SdrObject * pObject
Definition: htmlexp.hxx:82
void WriteGraphEntry(ScHTMLGraphEntry *)
Definition: htmlexp2.cxx:114
void WriteBody()
Definition: htmlexp.cxx:553
std::unique_ptr< std::map< OUString, OUString > > FileNameMapPtr
Definition: htmlexp.hxx:110
void IncIndent(short nVal)
Definition: htmlexp.cxx:1324
bool mbSkipImages
Definition: htmlexp.hxx:130
Store position data for column array storage.
bool bCalcAsShown
Definition: htmlexp.hxx:127
void WriteImage(OUString &rLinkName, const Graphic &, const OString &rImgOptions, XOutFlags nXOutFlags=XOutFlags::NONE)
Definition: htmlexp2.cxx:173
sal_uInt16 ToPixel(sal_uInt16 nTwips)
Definition: htmlexp.cxx:271
Color aBackgroundColor
Definition: htmlexp.hxx:51
bool bTabAlignedLeft
Definition: htmlexp.hxx:126
SvtScriptType nDefaultScriptType
Definition: htmlexp.hxx:55
sal_uInt32 nFontHeight
Definition: htmlexp.hxx:53
static const char * GetFontSizeCss(sal_uInt16 nHeight)
Definition: htmlexp.cxx:265
const ScHTMLStyle & operator=(const ScHTMLStyle &rScHTMLStyle)
Definition: htmlexp.hxx:65
void WriteHeader()
Definition: htmlexp.cxx:310
void CopyLocalFileToINet(OUString &rFileNm, const OUString &rTargetNm)
Definition: htmlexp.cxx:1271
#define SC_HTML_FONTSIZES
Definition: htmlexp.hxx:97
GraphEntryList aGraphList
Definition: htmlexp.hxx:113
bool mbSkipHeaderFooter
If HTML header and footer should be written as well, or just the content itself.
Definition: htmlexp.hxx:132
bool bTabHasGraphics
Definition: htmlexp.hxx:125
const char * GetIndentStr() const
Definition: htmlexp.hxx:171
SvtScriptType
Size MMToPixel(const Size &r100thMMSize)
Definition: htmlexp.cxx:283
OUString aFontFamilyName
Definition: htmlexp.hxx:52
sal_Int16 SCCOL
Definition: types.hxx:22
bool WriteFieldText(const EditTextObject *pData)
Definition: htmlexp.cxx:1212
OUString aNonConvertibleChars
Definition: htmlexp.hxx:119
bool bTableDataHeight
Definition: htmlexp.hxx:129
sal_Int32 SCROW
Definition: types.hxx:18
ScHTMLGraphEntry(SdrObject *pObj, const ScRange &rRange, const Size &rSize, bool bIn, const Size &rSpace)
Definition: htmlexp.hxx:86
XOutFlags
OUString aStreamPath
Definition: htmlexp.hxx:116
ScRange aRange
Definition: htmlexp.hxx:79
static const char * pFontSizeCss[SC_HTML_FONTSIZES]
Definition: htmlexp.hxx:106
std::vector< ScHTMLGraphEntry > GraphEntryList
Definition: htmlexp.hxx:111
short nIndent
Definition: htmlexp.hxx:122
static sal_uInt16 GetFontSizeNumber(sal_uInt16 nHeight)
Definition: htmlexp.cxx:251
bool bCopyLocalFileToINet
Definition: htmlexp.hxx:128
bool bInitialized
Definition: htmlexp.hxx:56
rtl_TextEncoding eDestEnc
Definition: htmlexp.hxx:120
void WriteCell(sc::ColumnBlockPosition &rBlockPos, SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: htmlexp.cxx:833
static const sal_uInt16 nCellSpacing
Definition: htmlexp.hxx:107
const OUString & GetNonConvertibleChars() const
Definition: htmlexp.hxx:181
void FillGraphList(const SdrPage *, SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow)
Definition: htmlexp2.cxx:64
void Write()
Definition: htmlexp.cxx:294
VclPtr< OutputDevice > pAppWin
Definition: htmlexp.hxx:117
OUString aBaseURL
Definition: htmlexp.hxx:115
ScHTMLExport(SvStream &, const OUString &, ScDocument *, const ScRange &, bool bAll, const OUString &aStreamPath, std::u16string_view rFilterOptions)
Definition: htmlexp.cxx:194
void WriteOverview()
Definition: htmlexp.cxx:403
void WriteTables()
Definition: htmlexp.cxx:632
void PrepareGraphics(ScDrawLayer *, SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow)
Definition: htmlexp2.cxx:40
static OString BorderToStyle(const char *pBorderName, const editeng::SvxBorderLine *pLine, bool &bInsertSemicolon)
Definition: htmlexp.cxx:481
char sIndent[nIndentMax+1]
Definition: htmlexp.hxx:123
const SfxItemSet & PageDefaults(SCTAB nTab)
Definition: htmlexp.cxx:436
static sal_uInt16 nFontSize[SC_HTML_FONTSIZES]
Definition: htmlexp.hxx:105
sal_Int16 SCTAB
Definition: types.hxx:23