Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef SC_HTMLEXP_HXX
30 : : #define SC_HTMLEXP_HXX
31 : :
32 : : #include "global.hxx"
33 : : #include <rtl/textenc.h>
34 : : #include <tools/gen.hxx>
35 : : #include <tools/color.hxx>
36 : : #include <boost/ptr_container/ptr_vector.hpp>
37 : : #include <boost/scoped_ptr.hpp>
38 : :
39 : : #include "expbase.hxx"
40 : :
41 : :
42 : : class ScDocument;
43 : : class SfxItemSet;
44 : : class SdrPage;
45 : : class Graphic;
46 : : class SdrObject;
47 : : class OutputDevice;
48 : : class ScDrawLayer;
49 : : class ScEditCell;
50 : :
51 : : namespace editeng { class SvxBorderLine; }
52 : :
53 : 0 : struct ScHTMLStyle
54 : : { // Defaults aus StyleSheet
55 : : Color aBackgroundColor;
56 : : String aFontFamilyName;
57 : : sal_uInt32 nFontHeight; // Item-Value
58 : : sal_uInt16 nFontSizeNumber; // HTML value 1-7
59 : : sal_uInt8 nDefaultScriptType; // Font values are valid for the default script type
60 : : sal_Bool bInitialized;
61 : :
62 : 0 : ScHTMLStyle() : nFontHeight(0), nFontSizeNumber(2), nDefaultScriptType(0),
63 : 0 : bInitialized(0) {}
64 : :
65 : : const ScHTMLStyle& operator=( const ScHTMLStyle& r )
66 : : {
67 : : aBackgroundColor = r.aBackgroundColor;
68 : : aFontFamilyName = r.aFontFamilyName;
69 : : nFontHeight = r.nFontHeight;
70 : : nFontSizeNumber = r.nFontSizeNumber;
71 : : nDefaultScriptType = r.nDefaultScriptType;
72 : : bInitialized = r.bInitialized;
73 : : return *this;
74 : : }
75 : : };
76 : :
77 : : struct ScHTMLGraphEntry
78 : : {
79 : : ScRange aRange; // ueberlagerter Zellbereich
80 : : Size aSize; // Groesse in Pixeln
81 : : Size aSpace; // Spacing in Pixeln
82 : : SdrObject* pObject;
83 : : sal_Bool bInCell; // ob in Zelle ausgegeben wird
84 : : sal_Bool bWritten;
85 : :
86 : 0 : ScHTMLGraphEntry( SdrObject* pObj, const ScRange& rRange,
87 : : const Size& rSize, sal_Bool bIn, const Size& rSpace ) :
88 : : aRange( rRange ), aSize( rSize ), aSpace( rSpace ),
89 : 0 : pObject( pObj ), bInCell( bIn ), bWritten( false ) {}
90 : : };
91 : :
92 : :
93 : : #define SC_HTML_FONTSIZES 7
94 : : const short nIndentMax = 23;
95 : :
96 : : class ScHTMLExport : public ScExportBase
97 : : {
98 : : // default HtmlFontSz[1-7]
99 : : static const sal_uInt16 nDefaultFontSize[SC_HTML_FONTSIZES];
100 : : // HtmlFontSz[1-7] in s*3.ini [user]
101 : : static sal_uInt16 nFontSize[SC_HTML_FONTSIZES];
102 : : static const char* pFontSizeCss[SC_HTML_FONTSIZES];
103 : : static const sal_uInt16 nCellSpacing;
104 : : static const sal_Char sIndentSource[];
105 : :
106 : : boost::ptr_vector< ScHTMLGraphEntry > aGraphList;
107 : : ScHTMLStyle aHTMLStyle;
108 : : String aBaseURL;
109 : : String aStreamPath;
110 : : String aCId; // Content-Id fuer Mail-Export
111 : : OutputDevice* pAppWin; // fuer Pixelei
112 : : boost::scoped_ptr< std::map<String, String> > pFileNameMap; // fuer CopyLocalFileToINet
113 : : String aNonConvertibleChars; // collect nonconvertible characters
114 : : rtl_TextEncoding eDestEnc;
115 : : SCTAB nUsedTables;
116 : : short nIndent;
117 : : sal_Char sIndent[nIndentMax+1];
118 : : sal_Bool bAll; // ganzes Dokument
119 : : sal_Bool bTabHasGraphics;
120 : : sal_Bool bTabAlignedLeft;
121 : : sal_Bool bCalcAsShown;
122 : : sal_Bool bCopyLocalFileToINet;
123 : : sal_Bool bTableDataWidth;
124 : : sal_Bool bTableDataHeight;
125 : :
126 : : const SfxItemSet& PageDefaults( SCTAB nTab );
127 : :
128 : : void WriteBody();
129 : : void WriteHeader();
130 : : void WriteOverview();
131 : : void WriteTables();
132 : : void WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab );
133 : : void WriteGraphEntry( ScHTMLGraphEntry* );
134 : : void WriteImage( String& rLinkName,
135 : : const Graphic&, const rtl::OString& rImgOptions,
136 : : sal_uLong nXOutFlags = 0 );
137 : : // nXOutFlags fuer XOutBitmap::WriteGraphic
138 : :
139 : : // write to stream if and only if URL fields in edit cell
140 : : sal_Bool WriteFieldText( const ScEditCell* pCell );
141 : :
142 : : // kopiere ggfs. eine lokale Datei ins Internet
143 : : sal_Bool CopyLocalFileToINet( String& rFileNm,
144 : : const String& rTargetNm, sal_Bool bFileToFile = false );
145 : 0 : sal_Bool HasCId() { return aCId.Len() > 0; }
146 : : void MakeCIdURL( String& rURL );
147 : :
148 : : void PrepareGraphics( ScDrawLayer*, SCTAB nTab,
149 : : SCCOL nStartCol, SCROW nStartRow,
150 : : SCCOL nEndCol, SCROW nEndRow );
151 : : void FillGraphList( const SdrPage*, SCTAB nTab,
152 : : SCCOL nStartCol, SCROW nStartRow,
153 : : SCCOL nEndCol, SCROW nEndRow );
154 : :
155 : : rtl::OString BorderToStyle(const char* pBorderName,
156 : : const ::editeng::SvxBorderLine* pLine, bool& bInsertSemicolon);
157 : :
158 : : sal_uInt16 GetFontSizeNumber( sal_uInt16 nHeight );
159 : : const char* GetFontSizeCss( sal_uInt16 nHeight );
160 : : sal_uInt16 ToPixel( sal_uInt16 nTwips );
161 : : Size MMToPixel( const Size& r100thMMSize );
162 : : void IncIndent( short nVal );
163 : 0 : const sal_Char* GetIndentStr() { return sIndent; }
164 : :
165 : : public:
166 : : ScHTMLExport( SvStream&, const String&, ScDocument*, const ScRange&,
167 : : sal_Bool bAll, const String& aStreamPath );
168 : : virtual ~ScHTMLExport();
169 : : sal_uLong Write();
170 : 0 : const String& GetNonConvertibleChars() const
171 : 0 : { return aNonConvertibleChars; }
172 : : };
173 : :
174 : : #endif
175 : :
176 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|