Line data Source code
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 SC_HTMLEXP_HXX
21 : #define SC_HTMLEXP_HXX
22 :
23 : #include "global.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>
29 :
30 : #include "expbase.hxx"
31 :
32 :
33 : class ScDocument;
34 : class SfxItemSet;
35 : class SdrPage;
36 : class Graphic;
37 : class SdrObject;
38 : class OutputDevice;
39 : class ScDrawLayer;
40 : class EditTextObject;
41 :
42 : namespace editeng { class SvxBorderLine; }
43 :
44 0 : struct ScHTMLStyle
45 : { // Defaults aus StyleSheet
46 : Color aBackgroundColor;
47 : OUString aFontFamilyName;
48 : sal_uInt32 nFontHeight; // Item-Value
49 : sal_uInt16 nFontSizeNumber; // HTML value 1-7
50 : sal_uInt8 nDefaultScriptType; // Font values are valid for the default script type
51 : bool bInitialized;
52 :
53 0 : ScHTMLStyle() : nFontHeight(0), nFontSizeNumber(2), nDefaultScriptType(0),
54 0 : bInitialized(false) {}
55 :
56 : const ScHTMLStyle& operator=( const ScHTMLStyle& r )
57 : {
58 : aBackgroundColor = r.aBackgroundColor;
59 : aFontFamilyName = r.aFontFamilyName;
60 : nFontHeight = r.nFontHeight;
61 : nFontSizeNumber = r.nFontSizeNumber;
62 : nDefaultScriptType = r.nDefaultScriptType;
63 : bInitialized = r.bInitialized;
64 : return *this;
65 : }
66 : };
67 :
68 : struct ScHTMLGraphEntry
69 : {
70 : ScRange aRange; // ueberlagerter Zellbereich
71 : Size aSize; // Groesse in Pixeln
72 : Size aSpace; // Spacing in Pixeln
73 : SdrObject* pObject;
74 : bool bInCell; // ob in Zelle ausgegeben wird
75 : bool bWritten;
76 :
77 0 : ScHTMLGraphEntry( SdrObject* pObj, const ScRange& rRange,
78 : const Size& rSize, bool bIn, const Size& rSpace ) :
79 : aRange( rRange ), aSize( rSize ), aSpace( rSpace ),
80 0 : pObject( pObj ), bInCell( bIn ), bWritten( false ) {}
81 : };
82 :
83 :
84 : #define SC_HTML_FONTSIZES 7
85 : const short nIndentMax = 23;
86 :
87 : class ScHTMLExport : public ScExportBase
88 : {
89 : // default HtmlFontSz[1-7]
90 : static const sal_uInt16 nDefaultFontSize[SC_HTML_FONTSIZES];
91 : // HtmlFontSz[1-7] in s*3.ini [user]
92 : static sal_uInt16 nFontSize[SC_HTML_FONTSIZES];
93 : static const char* pFontSizeCss[SC_HTML_FONTSIZES];
94 : static const sal_uInt16 nCellSpacing;
95 : static const sal_Char sIndentSource[];
96 :
97 : boost::ptr_vector< ScHTMLGraphEntry > aGraphList;
98 : ScHTMLStyle aHTMLStyle;
99 : OUString aBaseURL;
100 : OUString aStreamPath;
101 : OUString aCId; // Content-Id fuer Mail-Export
102 : OutputDevice* pAppWin; // fuer Pixelei
103 : boost::scoped_ptr< std::map<OUString, OUString> > pFileNameMap; // fuer CopyLocalFileToINet
104 : OUString aNonConvertibleChars; // collect nonconvertible characters
105 : rtl_TextEncoding eDestEnc;
106 : SCTAB nUsedTables;
107 : short nIndent;
108 : sal_Char sIndent[nIndentMax+1];
109 : bool bAll; // ganzes Dokument
110 : bool bTabHasGraphics;
111 : bool bTabAlignedLeft;
112 : bool bCalcAsShown;
113 : bool bCopyLocalFileToINet;
114 : bool bTableDataWidth;
115 : bool bTableDataHeight;
116 :
117 : const SfxItemSet& PageDefaults( SCTAB nTab );
118 :
119 : void WriteBody();
120 : void WriteHeader();
121 : void WriteOverview();
122 : void WriteTables();
123 : void WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab );
124 : void WriteGraphEntry( ScHTMLGraphEntry* );
125 : void WriteImage( OUString& rLinkName,
126 : const Graphic&, const OString& rImgOptions,
127 : sal_uLong nXOutFlags = 0 );
128 : // nXOutFlags fuer XOutBitmap::WriteGraphic
129 :
130 : // write to stream if and only if URL fields in edit cell
131 : bool WriteFieldText( const EditTextObject* pData );
132 :
133 : // kopiere ggfs. eine lokale Datei ins Internet
134 : bool CopyLocalFileToINet( OUString& rFileNm,
135 : const OUString& rTargetNm, bool bFileToFile = false );
136 0 : bool HasCId() { return !aCId.isEmpty(); }
137 : void MakeCIdURL( OUString& rURL );
138 :
139 : void PrepareGraphics( ScDrawLayer*, SCTAB nTab,
140 : SCCOL nStartCol, SCROW nStartRow,
141 : SCCOL nEndCol, SCROW nEndRow );
142 : void FillGraphList( const SdrPage*, SCTAB nTab,
143 : SCCOL nStartCol, SCROW nStartRow,
144 : SCCOL nEndCol, SCROW nEndRow );
145 :
146 : OString BorderToStyle(const char* pBorderName,
147 : const ::editeng::SvxBorderLine* pLine, bool& bInsertSemicolon);
148 :
149 : sal_uInt16 GetFontSizeNumber( sal_uInt16 nHeight );
150 : const char* GetFontSizeCss( sal_uInt16 nHeight );
151 : sal_uInt16 ToPixel( sal_uInt16 nTwips );
152 : Size MMToPixel( const Size& r100thMMSize );
153 : void IncIndent( short nVal );
154 0 : const sal_Char* GetIndentStr() { return sIndent; }
155 :
156 : public:
157 : ScHTMLExport( SvStream&, const OUString&, ScDocument*, const ScRange&,
158 : bool bAll, const OUString& aStreamPath );
159 : virtual ~ScHTMLExport();
160 : sal_uLong Write();
161 0 : const OUString& GetNonConvertibleChars() const
162 0 : { return aNonConvertibleChars; }
163 : };
164 :
165 : #endif
166 :
167 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|