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 : : #include "scitems.hxx"
30 : : #include <comphelper/string.hxx>
31 : : #include <editeng/eeitem.hxx>
32 : :
33 : : #include <rtl/tencinfo.h>
34 : :
35 : : #include <vcl/svapp.hxx>
36 : : #include <svx/algitem.hxx>
37 : : #include <editeng/boxitem.hxx>
38 : : #include <editeng/brshitem.hxx>
39 : : #include <editeng/colritem.hxx>
40 : : #include <editeng/fhgtitem.hxx>
41 : : #include <editeng/fontitem.hxx>
42 : : #include <editeng/postitem.hxx>
43 : : #include <editeng/udlnitem.hxx>
44 : : #include <editeng/wghtitem.hxx>
45 : : #include <editeng/justifyitem.hxx>
46 : : #include <svx/xoutbmp.hxx>
47 : : #include <editeng/editeng.hxx>
48 : : #include <svtools/htmlcfg.hxx>
49 : : #include <sfx2/docfile.hxx>
50 : : #include <sfx2/frmhtmlw.hxx>
51 : : #include <sfx2/objsh.hxx>
52 : : #include <svl/stritem.hxx>
53 : : #include <svl/urihelper.hxx>
54 : : #include <svl/zforlist.hxx>
55 : : #include <svtools/htmlkywd.hxx>
56 : : #include <svtools/htmlout.hxx>
57 : : #include <svtools/parhtml.hxx>
58 : : #include <vcl/outdev.hxx>
59 : : #include <stdio.h>
60 : :
61 : : #include "htmlexp.hxx"
62 : : #include "filter.hxx"
63 : : #include "global.hxx"
64 : : #include "document.hxx"
65 : : #include "attrib.hxx"
66 : : #include "patattr.hxx"
67 : : #include "stlpool.hxx"
68 : : #include "scresid.hxx"
69 : : #include "cell.hxx"
70 : : #include "cellform.hxx"
71 : : #include "docoptio.hxx"
72 : : #include "editutil.hxx"
73 : : #include "ftools.hxx"
74 : :
75 : :
76 : : #include <editeng/flditem.hxx>
77 : : #include <editeng/borderline.hxx>
78 : : #include <unotools/syslocale.hxx>
79 : :
80 : :
81 : : // ohne sc.hrc: error C2679: binary '=' : no operator defined which takes a
82 : : // right-hand operand of type 'const class String (__stdcall *)(class ScResId)'
83 : : // bei
84 : : // const String aStrTable( ScResId( SCSTR_TABLE ) ); aStrOut = aStrTable;
85 : : // ?!???
86 : : #include "sc.hrc"
87 : : #include "globstr.hrc"
88 : :
89 : : #include <com/sun/star/uno/Reference.h>
90 : : #include <com/sun/star/document/XDocumentProperties.hpp>
91 : : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
92 : : #include <rtl/strbuf.hxx>
93 : :
94 : :
95 : : using ::editeng::SvxBorderLine;
96 : : using namespace ::com::sun::star;
97 : :
98 : : //========================================================================
99 : :
100 : : const static sal_Char sMyBegComment[] = "<!-- ";
101 : : const static sal_Char sMyEndComment[] = " -->";
102 : : const static sal_Char sFontFamily[] = "font-family:";
103 : : const static sal_Char sFontSize[] = "font-size:";
104 : :
105 : : const sal_uInt16 ScHTMLExport::nDefaultFontSize[SC_HTML_FONTSIZES] =
106 : : {
107 : : HTMLFONTSZ1_DFLT, HTMLFONTSZ2_DFLT, HTMLFONTSZ3_DFLT, HTMLFONTSZ4_DFLT,
108 : : HTMLFONTSZ5_DFLT, HTMLFONTSZ6_DFLT, HTMLFONTSZ7_DFLT
109 : : };
110 : :
111 : : sal_uInt16 ScHTMLExport::nFontSize[SC_HTML_FONTSIZES] = { 0 };
112 : :
113 : : const char* ScHTMLExport::pFontSizeCss[SC_HTML_FONTSIZES] =
114 : : {
115 : : "xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"
116 : : };
117 : :
118 : : const sal_uInt16 ScHTMLExport::nCellSpacing = 0;
119 : : const sal_Char ScHTMLExport::sIndentSource[nIndentMax+1] =
120 : : "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
121 : :
122 : : //========================================================================
123 : : // Makros fuer HTML-Export
124 : : //========================================================================
125 : : #define TAG_ON( tag ) HTMLOutFuncs::Out_AsciiTag( rStrm, tag )
126 : : #define TAG_OFF( tag ) HTMLOutFuncs::Out_AsciiTag( rStrm, tag, false )
127 : : #define OUT_STR( str ) HTMLOutFuncs::Out_String( rStrm, str, eDestEnc, &aNonConvertibleChars )
128 : : #define OUT_LF() rStrm << ScExportBase::sNewLine << GetIndentStr()
129 : : #define TAG_ON_LF( tag ) (TAG_ON( tag ) << ScExportBase::sNewLine << GetIndentStr())
130 : : #define TAG_OFF_LF( tag ) (TAG_OFF( tag ) << ScExportBase::sNewLine << GetIndentStr())
131 : : #define OUT_HR() TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_horzrule )
132 : : #define OUT_COMMENT( comment ) (rStrm << sMyBegComment, OUT_STR( comment ) \
133 : : << sMyEndComment << ScExportBase::sNewLine \
134 : : << GetIndentStr())
135 : :
136 : : #define OUT_SP_CSTR_ASS( s ) rStrm << ' ' << s << '='
137 : : #define APPEND_SPACE( s ) s.AppendAscii(" ")
138 : :
139 : : #define GLOBSTR(id) ScGlobal::GetRscString( id )
140 : :
141 : :
142 : :
143 : : //========================================================================
144 : :
145 : 0 : FltError ScFormatFilterPluginImpl::ScExportHTML( SvStream& rStrm, const String& rBaseURL, ScDocument* pDoc,
146 : : const ScRange& rRange, const CharSet /*eNach*/, bool bAll,
147 : : const String& rStreamPath, String& rNonConvertibleChars )
148 : : {
149 [ # # ]: 0 : ScHTMLExport aEx( rStrm, rBaseURL, pDoc, rRange, bAll, rStreamPath );
150 [ # # ]: 0 : FltError nErr = aEx.Write();
151 [ # # ]: 0 : rNonConvertibleChars = aEx.GetNonConvertibleChars();
152 [ # # ]: 0 : return nErr;
153 : : }
154 : :
155 : :
156 : 0 : static rtl::OString lcl_getColGroupString(sal_Int32 nSpan, sal_Int32 nWidth)
157 : : {
158 : 0 : rtl::OStringBuffer aByteStr(OOO_STRING_SVTOOLS_HTML_colgroup);
159 [ # # ]: 0 : aByteStr.append(' ');
160 [ # # ]: 0 : if( nSpan > 1 )
161 : : {
162 [ # # ]: 0 : aByteStr.append(OOO_STRING_SVTOOLS_HTML_O_span);
163 [ # # ]: 0 : aByteStr.append(RTL_CONSTASCII_STRINGPARAM("=\""));
164 [ # # ]: 0 : aByteStr.append(nSpan);
165 [ # # ]: 0 : aByteStr.append(RTL_CONSTASCII_STRINGPARAM("\" "));
166 : : }
167 [ # # ]: 0 : aByteStr.append(OOO_STRING_SVTOOLS_HTML_O_width);
168 [ # # ]: 0 : aByteStr.append(RTL_CONSTASCII_STRINGPARAM("=\""));
169 [ # # ]: 0 : aByteStr.append(nWidth);
170 [ # # ]: 0 : aByteStr.append('"');
171 : 0 : return aByteStr.makeStringAndClear();
172 : : }
173 : :
174 : :
175 : 0 : static void lcl_AddStamp( String& rStr, const String& rName,
176 : : const ::com::sun::star::util::DateTime& rDateTime,
177 : : const LocaleDataWrapper& rLoc )
178 : : {
179 : 0 : Date aD(rDateTime.Day, rDateTime.Month, rDateTime.Year);
180 : : Time aT(rDateTime.Hours, rDateTime.Minutes, rDateTime.Seconds,
181 [ # # ]: 0 : rDateTime.HundredthSeconds);
182 [ # # ]: 0 : DateTime aDateTime(aD,aT);
183 : :
184 [ # # ][ # # ]: 0 : String aStrDate = rLoc.getDate( aDateTime );
185 [ # # ][ # # ]: 0 : String aStrTime = rLoc.getTime( aDateTime );
186 : :
187 [ # # ][ # # ]: 0 : rStr += GLOBSTR( STR_BY );
188 [ # # ]: 0 : APPEND_SPACE( rStr );
189 [ # # ]: 0 : if (rName.Len())
190 [ # # ]: 0 : rStr += rName;
191 : : else
192 [ # # ]: 0 : rStr.AppendAscii( "???" );
193 [ # # ]: 0 : APPEND_SPACE( rStr );
194 [ # # ][ # # ]: 0 : rStr += GLOBSTR( STR_ON );
195 [ # # ]: 0 : APPEND_SPACE( rStr );
196 [ # # ]: 0 : if (aStrDate.Len())
197 [ # # ]: 0 : rStr += aStrDate;
198 : : else
199 [ # # ]: 0 : rStr.AppendAscii( "???" );
200 [ # # ]: 0 : rStr.AppendAscii( ", " );
201 [ # # ]: 0 : if (aStrTime.Len())
202 [ # # ]: 0 : rStr += aStrTime;
203 : : else
204 [ # # ][ # # ]: 0 : rStr.AppendAscii( "???" );
[ # # ]
205 : 0 : }
206 : :
207 : :
208 : 0 : static rtl::OString lcl_makeHTMLColorTriplet(const Color& rColor)
209 : : {
210 [ # # ]: 0 : rtl::OStringBuffer aStr(RTL_CONSTASCII_STRINGPARAM("\"#"));
211 : : // <font COLOR="#00FF40">hallo</font>
212 : : sal_Char buf[64];
213 : 0 : sal_Char* p = buf;
214 : 0 : p += sprintf( p, "%02X", rColor.GetRed() );
215 : 0 : p += sprintf( p, "%02X", rColor.GetGreen() );
216 : 0 : p += sprintf( p, "%02X", rColor.GetBlue() );
217 [ # # ]: 0 : aStr.append(buf);
218 [ # # ]: 0 : aStr.append('\"');
219 : 0 : return aStr.makeStringAndClear();
220 : : }
221 : :
222 : : //////////////////////////////////////////////////////////////////////////////
223 : :
224 : 0 : ScHTMLExport::ScHTMLExport( SvStream& rStrmP, const String& rBaseURL, ScDocument* pDocP,
225 : : const ScRange& rRangeP,
226 : : sal_Bool bAllP, const String& rStreamPathP ) :
227 : : ScExportBase( rStrmP, pDocP, rRangeP ),
228 : : aBaseURL( rBaseURL ),
229 : : aStreamPath( rStreamPathP ),
230 [ # # ]: 0 : pAppWin( Application::GetDefaultDevice() ),
231 : : nUsedTables( 0 ),
232 : : nIndent( 0 ),
233 : : bAll( bAllP ),
234 : : bTabHasGraphics( false ),
235 [ # # ]: 0 : bCalcAsShown( pDocP->GetDocOptions().IsCalcAsShown() ),
236 : : bTableDataWidth( sal_True ),
237 [ # # ][ # # ]: 0 : bTableDataHeight( sal_True )
[ # # ][ # # ]
[ # # ][ # # ]
238 : : {
239 : 0 : strcpy( sIndent, sIndentSource );
240 : 0 : sIndent[0] = 0;
241 : :
242 : : // set HTML configuration
243 [ # # ]: 0 : SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
244 [ # # ][ # # ]: 0 : eDestEnc = (pDoc->IsClipOrUndo() ? RTL_TEXTENCODING_UTF8 : rHtmlOptions.GetTextEncoding());
245 [ # # ]: 0 : bCopyLocalFileToINet = rHtmlOptions.IsSaveGraphicsLocal();
246 [ # # ]: 0 : for ( sal_uInt16 j=0; j < SC_HTML_FONTSIZES; j++ )
247 : : {
248 [ # # ]: 0 : sal_uInt16 nSize = rHtmlOptions.GetFontSize( j );
249 : : // remember in Twips, like our SvxFontHeightItem
250 [ # # ]: 0 : if ( nSize )
251 : 0 : nFontSize[j] = nSize * 20;
252 : : else
253 : 0 : nFontSize[j] = nDefaultFontSize[j] * 20;
254 : : }
255 : :
256 [ # # ]: 0 : const SCTAB nCount = pDoc->GetTableCount();
257 [ # # ]: 0 : for ( SCTAB nTab = 0; nTab < nCount; nTab++ )
258 : : {
259 [ # # ][ # # ]: 0 : if ( !IsEmptyTable( nTab ) )
260 : 0 : nUsedTables++;
261 : : }
262 : :
263 : : // Content-Id fuer Mail-Export?
264 : 0 : SfxObjectShell* pDocSh = pDoc->GetDocumentShell();
265 [ # # ]: 0 : if ( pDocSh )
266 : : {
267 [ # # ]: 0 : const SfxPoolItem* pItem = pDocSh->GetItem( SID_ORIGURL );
268 [ # # ]: 0 : if( pItem )
269 : : {
270 [ # # ]: 0 : aCId = ((const SfxStringItem *)pItem)->GetValue();
271 : : OSL_ENSURE( aCId.Len(), "CID ohne Laenge!" );
272 : : }
273 : : }
274 : 0 : }
275 : :
276 : :
277 [ # # ][ # # ]: 0 : ScHTMLExport::~ScHTMLExport()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
278 : : {
279 [ # # ]: 0 : aGraphList.clear();
280 [ # # ]: 0 : }
281 : :
282 : :
283 : 0 : sal_uInt16 ScHTMLExport::GetFontSizeNumber( sal_uInt16 nHeight )
284 : : {
285 : 0 : sal_uInt16 nSize = 1;
286 [ # # ]: 0 : for ( sal_uInt16 j=SC_HTML_FONTSIZES-1; j>0; j-- )
287 : : {
288 [ # # ]: 0 : if( nHeight > (nFontSize[j] + nFontSize[j-1]) / 2 )
289 : : { // der naechstgelegene
290 : 0 : nSize = j+1;
291 : 0 : break;
292 : : }
293 : : }
294 : 0 : return nSize;
295 : : }
296 : :
297 : 0 : const char* ScHTMLExport::GetFontSizeCss( sal_uInt16 nHeight )
298 : : {
299 : 0 : sal_uInt16 nSize = GetFontSizeNumber( nHeight );
300 : 0 : return pFontSizeCss[ nSize-1 ];
301 : : }
302 : :
303 : :
304 : 0 : sal_uInt16 ScHTMLExport::ToPixel( sal_uInt16 nVal )
305 : : {
306 [ # # ]: 0 : if( nVal )
307 : : {
308 : : nVal = (sal_uInt16)pAppWin->LogicToPixel(
309 [ # # ]: 0 : Size( nVal, nVal ), MapMode( MAP_TWIP ) ).Width();
310 [ # # ]: 0 : if( !nVal ) // wo ein Twip ist sollte auch ein Pixel sein
311 : 0 : nVal = 1;
312 : : }
313 : 0 : return nVal;
314 : : }
315 : :
316 : :
317 : 0 : Size ScHTMLExport::MMToPixel( const Size& rSize )
318 : : {
319 : 0 : Size aSize( rSize );
320 [ # # ]: 0 : aSize = pAppWin->LogicToPixel( rSize, MapMode( MAP_100TH_MM ) );
321 : : // wo etwas ist sollte auch ein Pixel sein
322 [ # # ][ # # ]: 0 : if ( !aSize.Width() && rSize.Width() )
[ # # ]
323 : 0 : aSize.Width() = 1;
324 [ # # ][ # # ]: 0 : if ( !aSize.Height() && rSize.Height() )
[ # # ]
325 : 0 : aSize.Height() = 1;
326 : 0 : return aSize;
327 : : }
328 : :
329 : :
330 : 0 : sal_uLong ScHTMLExport::Write()
331 : : {
332 : 0 : rStrm << '<' << OOO_STRING_SVTOOLS_HTML_doctype << ' ' << OOO_STRING_SVTOOLS_HTML_doctype32 << '>'
333 : 0 : << sNewLine << sNewLine;
334 : 0 : TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_html );
335 : 0 : WriteHeader();
336 : 0 : OUT_LF();
337 : 0 : WriteBody();
338 : 0 : OUT_LF();
339 : 0 : TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_html );
340 : :
341 : 0 : return rStrm.GetError();
342 : : }
343 : :
344 : :
345 : 0 : void ScHTMLExport::WriteHeader()
346 : : {
347 : 0 : IncIndent(1); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_head );
348 : :
349 [ # # ]: 0 : if ( pDoc->IsClipOrUndo() )
350 : : { // no real DocInfo available, but some META information like charset needed
351 [ # # ]: 0 : SfxFrameHTMLWriter::Out_DocInfo( rStrm, aBaseURL, NULL, sIndent, eDestEnc, &aNonConvertibleChars );
352 : : }
353 : : else
354 : : {
355 : : using namespace ::com::sun::star;
356 : : uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
357 [ # # ][ # # ]: 0 : pDoc->GetDocumentShell()->GetModel(), uno::UNO_QUERY_THROW);
358 : : uno::Reference<document::XDocumentProperties> xDocProps
359 [ # # ][ # # ]: 0 : = xDPS->getDocumentProperties();
360 : : SfxFrameHTMLWriter::Out_DocInfo( rStrm, aBaseURL, xDocProps,
361 [ # # ]: 0 : sIndent, eDestEnc, &aNonConvertibleChars );
362 [ # # ][ # # ]: 0 : OUT_LF();
363 : :
364 : : //----------------------------------------------------------
365 [ # # ][ # # ]: 0 : if (!xDocProps->getPrintedBy().isEmpty())
[ # # ]
366 : : {
367 [ # # ][ # # ]: 0 : OUT_COMMENT( GLOBSTR( STR_DOC_INFO ) );
[ # # ][ # # ]
[ # # ][ # # ]
368 [ # # ][ # # ]: 0 : String aStrOut( GLOBSTR( STR_DOC_PRINTED ) );
369 [ # # ]: 0 : aStrOut.AppendAscii( ": " );
370 [ # # ]: 0 : lcl_AddStamp( aStrOut, xDocProps->getPrintedBy(),
371 [ # # ][ # # ]: 0 : xDocProps->getPrintDate(), *ScGlobal::pLocaleData );
[ # # ][ # # ]
[ # # ][ # # ]
372 [ # # ][ # # ]: 0 : OUT_COMMENT( aStrOut );
[ # # ][ # # ]
[ # # ][ # # ]
373 : 0 : }
374 : : //----------------------------------------------------------
375 : : }
376 : 0 : OUT_LF();
377 : :
378 : : // CSS1 StyleSheet
379 [ # # ]: 0 : PageDefaults( bAll ? 0 : aRange.aStart.Tab() );
380 : 0 : IncIndent(1); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_style );
381 : 0 : rStrm << sMyBegComment; OUT_LF();
382 : 0 : rStrm << OOO_STRING_SVTOOLS_HTML_body << "," << OOO_STRING_SVTOOLS_HTML_division << "," << OOO_STRING_SVTOOLS_HTML_table << ","
383 : 0 : << OOO_STRING_SVTOOLS_HTML_thead << "," << OOO_STRING_SVTOOLS_HTML_tbody << "," << OOO_STRING_SVTOOLS_HTML_tfoot << ","
384 : 0 : << OOO_STRING_SVTOOLS_HTML_tablerow << "," << OOO_STRING_SVTOOLS_HTML_tableheader << ","
385 : 0 : << OOO_STRING_SVTOOLS_HTML_tabledata << "," << OOO_STRING_SVTOOLS_HTML_parabreak << " { " << sFontFamily;
386 [ # # ]: 0 : xub_StrLen nFonts = comphelper::string::getTokenCount(aHTMLStyle.aFontFamilyName, ';');
387 [ # # ]: 0 : if ( nFonts == 1 )
388 : : {
389 : 0 : rStrm << '\"';
390 : 0 : OUT_STR( aHTMLStyle.aFontFamilyName );
391 : 0 : rStrm << '\"';
392 : : }
393 : : else
394 : : { // Fontliste, VCL: Semikolon als Separator,
395 : : // CSS1: Komma als Separator und jeder einzelne Fontname quoted
396 : 0 : const String& rList = aHTMLStyle.aFontFamilyName;
397 [ # # ]: 0 : for ( xub_StrLen j = 0, nPos = 0; j < nFonts; j++ )
398 : : {
399 [ # # ]: 0 : rStrm << '\"';
400 [ # # ][ # # ]: 0 : OUT_STR( rList.GetToken( 0, ';', nPos ) );
[ # # ]
401 [ # # ]: 0 : rStrm << '\"';
402 [ # # ]: 0 : if ( j < nFonts-1 )
403 [ # # ]: 0 : rStrm << ", ";
404 : : }
405 : : }
406 : 0 : rStrm << "; " << sFontSize
407 : 0 : << GetFontSizeCss( ( sal_uInt16 ) aHTMLStyle.nFontHeight ) << " }";
408 : 0 : OUT_LF();
409 : 0 : rStrm << sMyEndComment;
410 : 0 : IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_style );
411 : :
412 : 0 : IncIndent(-1); OUT_LF(); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_head );
413 : 0 : }
414 : :
415 : :
416 : 0 : void ScHTMLExport::WriteOverview()
417 : : {
418 [ # # ]: 0 : if ( nUsedTables > 1 )
419 : : {
420 : 0 : IncIndent(1);
421 [ # # ][ # # ]: 0 : OUT_HR();
[ # # ]
422 [ # # ][ # # ]: 0 : IncIndent(1); TAG_ON( OOO_STRING_SVTOOLS_HTML_parabreak ); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_center );
[ # # ][ # # ]
423 [ # # ]: 0 : TAG_ON( OOO_STRING_SVTOOLS_HTML_head1 );
424 [ # # ][ # # ]: 0 : OUT_STR( ScGlobal::GetRscString( STR_OVERVIEW ) );
425 [ # # ][ # # ]: 0 : TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_head1 );
[ # # ]
426 : :
427 : 0 : rtl::OUString aStr;
428 : :
429 [ # # ]: 0 : const SCTAB nCount = pDoc->GetTableCount();
430 [ # # ]: 0 : for ( SCTAB nTab = 0; nTab < nCount; nTab++ )
431 : : {
432 [ # # ][ # # ]: 0 : if ( !IsEmptyTable( nTab ) )
433 : : {
434 [ # # ]: 0 : pDoc->GetName( nTab, aStr );
435 [ # # ]: 0 : rStrm << "<A HREF=\"#table"
436 [ # # ]: 0 : << rtl::OString::valueOf(static_cast<sal_Int32>(nTab)).getStr()
437 [ # # ]: 0 : << "\">";
438 [ # # ][ # # ]: 0 : OUT_STR( aStr );
[ # # ]
439 [ # # ]: 0 : rStrm << "</A>";
440 [ # # ][ # # ]: 0 : TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_linebreak );
[ # # ]
441 : : }
442 : : }
443 : :
444 [ # # ][ # # ]: 0 : IncIndent(-1); OUT_LF();
445 [ # # ][ # # ]: 0 : IncIndent(-1); TAG_OFF( OOO_STRING_SVTOOLS_HTML_center ); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_parabreak );
[ # # ][ # # ]
446 : : }
447 : 0 : }
448 : :
449 : :
450 : 0 : const SfxItemSet& ScHTMLExport::PageDefaults( SCTAB nTab )
451 : : {
452 : 0 : SfxStyleSheetBasePool* pStylePool = pDoc->GetStyleSheetPool();
453 : 0 : SfxStyleSheetBase* pStyleSheet = NULL;
454 : : OSL_ENSURE( pStylePool, "StylePool not found! :-(" );
455 : :
456 : : // remember defaults for compare in WriteCell
457 [ # # ]: 0 : if ( !aHTMLStyle.bInitialized )
458 : : {
459 : 0 : pStylePool->SetSearchMask( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL );
460 : : pStyleSheet = pStylePool->Find(
461 : 0 : ScGlobal::GetRscString(STR_STYLENAME_STANDARD),
462 : 0 : SFX_STYLE_FAMILY_PARA );
463 : : OSL_ENSURE( pStyleSheet, "ParaStyle not found! :-(" );
464 [ # # ]: 0 : if (!pStyleSheet)
465 : 0 : pStyleSheet = pStylePool->First();
466 : 0 : const SfxItemSet& rSetPara = pStyleSheet->GetItemSet();
467 : :
468 : 0 : aHTMLStyle.nDefaultScriptType = ScGlobal::GetDefaultScriptType();
469 : : aHTMLStyle.aFontFamilyName = ((const SvxFontItem&)(rSetPara.Get(
470 : : ScGlobal::GetScriptedWhichID(
471 : : aHTMLStyle.nDefaultScriptType, ATTR_FONT
472 : 0 : )))).GetFamilyName();
473 : : aHTMLStyle.nFontHeight = ((const SvxFontHeightItem&)(rSetPara.Get(
474 : : ScGlobal::GetScriptedWhichID(
475 : : aHTMLStyle.nDefaultScriptType, ATTR_FONT_HEIGHT
476 : 0 : )))).GetHeight();
477 : 0 : aHTMLStyle.nFontSizeNumber = GetFontSizeNumber( static_cast< sal_uInt16 >( aHTMLStyle.nFontHeight ) );
478 : : }
479 : :
480 : : // Page style sheet printer settings, e.g. for background graphics.
481 : : // There's only one background graphic in HTML!
482 : 0 : pStylePool->SetSearchMask( SFX_STYLE_FAMILY_PAGE, SFXSTYLEBIT_ALL );
483 [ # # ][ # # ]: 0 : pStyleSheet = pStylePool->Find( pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE );
[ # # ]
484 : : OSL_ENSURE( pStyleSheet, "PageStyle not found! :-(" );
485 [ # # ]: 0 : if (!pStyleSheet)
486 : 0 : pStyleSheet = pStylePool->First();
487 : 0 : const SfxItemSet& rSet = pStyleSheet->GetItemSet();
488 [ # # ]: 0 : if ( !aHTMLStyle.bInitialized )
489 : : {
490 : 0 : const SvxBrushItem* pBrushItem = (const SvxBrushItem*)&rSet.Get( ATTR_BACKGROUND );
491 : 0 : aHTMLStyle.aBackgroundColor = pBrushItem->GetColor();
492 : 0 : aHTMLStyle.bInitialized = sal_True;
493 : : }
494 : 0 : return rSet;
495 : : }
496 : :
497 : :
498 : 0 : rtl::OString ScHTMLExport::BorderToStyle(const char* pBorderName,
499 : : const SvxBorderLine* pLine, bool& bInsertSemicolon)
500 : : {
501 : 0 : rtl::OStringBuffer aOut;
502 : :
503 [ # # ]: 0 : if ( pLine )
504 : : {
505 [ # # ]: 0 : if ( bInsertSemicolon )
506 [ # # ]: 0 : aOut.append(RTL_CONSTASCII_STRINGPARAM("; "));
507 : :
508 : : // which border
509 [ # # ]: 0 : aOut.append(RTL_CONSTASCII_STRINGPARAM("border-")).
510 [ # # ][ # # ]: 0 : append(pBorderName).append(RTL_CONSTASCII_STRINGPARAM(": "));
511 : :
512 : : // thickness
513 : 0 : int nWidth = pLine->GetWidth();
514 : : int nPxWidth = (nWidth > 0) ?
515 [ # # ][ # # ]: 0 : std::max(int(nWidth / TWIPS_PER_PIXEL), 1) : 0;
[ # # ]
[ # # # # ]
[ # # ]
516 [ # # ]: 0 : aOut.append(static_cast<sal_Int32>(nPxWidth)).
517 [ # # ]: 0 : append(RTL_CONSTASCII_STRINGPARAM("px "));
518 [ # # # # : 0 : switch (pLine->GetBorderLineStyle())
# # # #
# ]
519 : : {
520 : : case table::BorderLineStyle::SOLID:
521 [ # # ]: 0 : aOut.append(RTL_CONSTASCII_STRINGPARAM("solid"));
522 : 0 : break;
523 : : case table::BorderLineStyle::DOTTED:
524 [ # # ]: 0 : aOut.append(RTL_CONSTASCII_STRINGPARAM("dotted"));
525 : 0 : break;
526 : : case table::BorderLineStyle::DASHED:
527 [ # # ]: 0 : aOut.append(RTL_CONSTASCII_STRINGPARAM("dashed"));
528 : 0 : break;
529 : : case table::BorderLineStyle::DOUBLE:
530 : : case table::BorderLineStyle::THINTHICK_SMALLGAP:
531 : : case table::BorderLineStyle::THINTHICK_MEDIUMGAP:
532 : : case table::BorderLineStyle::THINTHICK_LARGEGAP:
533 : : case table::BorderLineStyle::THICKTHIN_SMALLGAP:
534 : : case table::BorderLineStyle::THICKTHIN_MEDIUMGAP:
535 : : case table::BorderLineStyle::THICKTHIN_LARGEGAP:
536 [ # # ]: 0 : aOut.append(RTL_CONSTASCII_STRINGPARAM("double"));
537 : 0 : break;
538 : : case table::BorderLineStyle::EMBOSSED:
539 [ # # ]: 0 : aOut.append(RTL_CONSTASCII_STRINGPARAM("ridge"));
540 : 0 : break;
541 : : case table::BorderLineStyle::ENGRAVED:
542 [ # # ]: 0 : aOut.append(RTL_CONSTASCII_STRINGPARAM("groove"));
543 : 0 : break;
544 : : case table::BorderLineStyle::OUTSET:
545 [ # # ]: 0 : aOut.append(RTL_CONSTASCII_STRINGPARAM("outset"));
546 : 0 : break;
547 : : case table::BorderLineStyle::INSET:
548 [ # # ]: 0 : aOut.append(RTL_CONSTASCII_STRINGPARAM("inset"));
549 : 0 : break;
550 : : default:
551 [ # # ]: 0 : aOut.append(RTL_CONSTASCII_STRINGPARAM("hidden"));
552 : : }
553 [ # # ]: 0 : aOut.append(RTL_CONSTASCII_STRINGPARAM(" #"));
554 : :
555 : : // color
556 : : char hex[7];
557 : 0 : snprintf( hex, 7, "%06x", static_cast< unsigned int >( pLine->GetColor().GetRGBColor() ) );
558 : 0 : hex[6] = 0;
559 : :
560 [ # # ]: 0 : aOut.append(hex);
561 : :
562 : 0 : bInsertSemicolon = true;
563 : : }
564 : :
565 : 0 : return aOut.makeStringAndClear();
566 : : }
567 : :
568 : 0 : void ScHTMLExport::WriteBody()
569 : : {
570 [ # # ]: 0 : const SfxItemSet& rSet = PageDefaults( bAll ? 0 : aRange.aStart.Tab() );
571 : 0 : const SvxBrushItem* pBrushItem = (const SvxBrushItem*)&rSet.Get( ATTR_BACKGROUND );
572 : :
573 : : // default Textfarbe schwarz
574 : 0 : rStrm << '<' << OOO_STRING_SVTOOLS_HTML_body << ' ' << OOO_STRING_SVTOOLS_HTML_O_text << "=\"#000000\"";
575 : :
576 [ # # ][ # # ]: 0 : if ( bAll && GPOS_NONE != pBrushItem->GetGraphicPos() )
[ # # ]
577 : : {
578 : 0 : const String* pLink = pBrushItem->GetGraphicLink();
579 [ # # ]: 0 : String aGrfNm;
580 : :
581 : : // embeddete Grafik -> via WriteGraphic schreiben
582 [ # # ]: 0 : if( !pLink )
583 : : {
584 [ # # ]: 0 : const Graphic* pGrf = pBrushItem->GetGraphic();
585 [ # # ]: 0 : if( pGrf )
586 : : {
587 : : // Grafik als (JPG-)File speichern
588 [ # # ]: 0 : aGrfNm = aStreamPath;
589 : : sal_uInt16 nErr = XOutBitmap::WriteGraphic( *pGrf, aGrfNm,
590 [ # # ][ # # ]: 0 : CREATE_STRING( "JPG" ), XOUTBMP_USE_NATIVE_IF_POSSIBLE );
[ # # ]
591 [ # # ]: 0 : if( !nErr ) // fehlerhaft, da ist nichts auszugeben
592 : : {
593 : : aGrfNm = URIHelper::SmartRel2Abs(
594 : : INetURLObject(aBaseURL),
595 [ # # ][ # # ]: 0 : aGrfNm, URIHelper::GetMaybeFileHdl(), true, false);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
596 [ # # ]: 0 : if ( HasCId() )
597 [ # # ]: 0 : MakeCIdURL( aGrfNm );
598 : 0 : pLink = &aGrfNm;
599 : : }
600 : : }
601 : : }
602 : : else
603 : : {
604 [ # # ]: 0 : aGrfNm = *pLink;
605 [ # # ][ # # ]: 0 : if( bCopyLocalFileToINet || HasCId() )
[ # # ]
606 : : {
607 [ # # ]: 0 : CopyLocalFileToINet( aGrfNm, aStreamPath );
608 [ # # ]: 0 : if ( HasCId() )
609 [ # # ]: 0 : MakeCIdURL( aGrfNm );
610 : : }
611 : : else
612 : : aGrfNm = URIHelper::SmartRel2Abs(
613 : : INetURLObject(aBaseURL),
614 [ # # ][ # # ]: 0 : aGrfNm, URIHelper::GetMaybeFileHdl(), true, false);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
615 : 0 : pLink = &aGrfNm;
616 : : }
617 [ # # ]: 0 : if( pLink )
618 : : {
619 [ # # ][ # # ]: 0 : rStrm << ' ' << OOO_STRING_SVTOOLS_HTML_O_background << "=\"";
[ # # ]
620 [ # # ][ # # ]: 0 : OUT_STR( URIHelper::simpleNormalizedMakeRelative(
[ # # ][ # # ]
[ # # ][ # # ]
621 : : aBaseURL,
622 [ # # ]: 0 : *pLink ) ) << '\"';
623 [ # # ]: 0 : }
624 : : }
625 [ # # ]: 0 : if ( !aHTMLStyle.aBackgroundColor.GetTransparency() )
626 : : { // A transparent background color should always result in default
627 : : // background of the browser. Also, HTMLOutFuncs::Out_Color() writes
628 : : // black #000000 for COL_AUTO which is the same as white #ffffff with
629 : : // transparency set to 0xff, our default background.
630 : 0 : OUT_SP_CSTR_ASS( OOO_STRING_SVTOOLS_HTML_O_bgcolor );
631 : 0 : HTMLOutFuncs::Out_Color( rStrm, aHTMLStyle.aBackgroundColor );
632 : : }
633 : :
634 : 0 : rStrm << '>'; OUT_LF();
635 : :
636 [ # # ]: 0 : if ( bAll )
637 : 0 : WriteOverview();
638 : :
639 : 0 : WriteTables();
640 : :
641 : 0 : TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_body );
642 : 0 : }
643 : :
644 : :
645 : 0 : void ScHTMLExport::WriteTables()
646 : : {
647 [ # # ]: 0 : const SCTAB nTabCount = pDoc->GetTableCount();
648 [ # # ][ # # ]: 0 : const String aStrTable( ScResId( SCSTR_TABLE ) );
649 : 0 : rtl::OUString aStr;
650 [ # # ]: 0 : String aStrOut;
651 : : SCCOL nStartCol;
652 : : SCROW nStartRow;
653 : : SCTAB nStartTab;
654 : : SCCOL nEndCol;
655 : : SCROW nEndRow;
656 : : SCTAB nEndTab;
657 : 0 : SCCOL nStartColFix = 0;
658 : 0 : SCROW nStartRowFix = 0;
659 : 0 : SCCOL nEndColFix = 0;
660 : 0 : SCROW nEndRowFix = 0;
661 [ # # ]: 0 : ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
662 [ # # ]: 0 : if ( bAll )
663 : : {
664 : 0 : nStartTab = 0;
665 : 0 : nEndTab = nTabCount - 1;
666 : : }
667 : : else
668 : : {
669 : 0 : nStartCol = nStartColFix = aRange.aStart.Col();
670 : 0 : nStartRow = nStartRowFix = aRange.aStart.Row();
671 : 0 : nStartTab = aRange.aStart.Tab();
672 : 0 : nEndCol = nEndColFix = aRange.aEnd.Col();
673 : 0 : nEndRow = nEndRowFix = aRange.aEnd.Row();
674 : 0 : nEndTab = aRange.aEnd.Tab();
675 : : }
676 : 0 : SCTAB nTableStrNum = 1;
677 [ # # ]: 0 : for ( SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++ )
678 : : {
679 [ # # ][ # # ]: 0 : if ( !pDoc->IsVisible( nTab ) )
680 : 0 : continue; // for
681 : :
682 [ # # ]: 0 : if ( bAll )
683 : : {
684 [ # # ][ # # ]: 0 : if ( !GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow ) )
685 : 0 : continue; // for
686 : :
687 [ # # ]: 0 : if ( nUsedTables > 1 )
688 : : {
689 [ # # ]: 0 : aStrOut = aStrTable;
690 [ # # ]: 0 : aStrOut.AppendAscii( " " );
691 [ # # ][ # # ]: 0 : aStrOut += String::CreateFromInt32( nTableStrNum++ );
[ # # ]
692 [ # # ]: 0 : aStrOut.AppendAscii( ": " );
693 : :
694 [ # # ][ # # ]: 0 : OUT_HR();
[ # # ]
695 : :
696 : : // Anker festlegen:
697 [ # # ]: 0 : rStrm << "<A NAME=\"table"
698 [ # # ]: 0 : << rtl::OString::valueOf(static_cast<sal_Int32>(nTab)).getStr()
699 [ # # ]: 0 : << "\">";
700 [ # # ]: 0 : TAG_ON( OOO_STRING_SVTOOLS_HTML_head1 );
701 [ # # ]: 0 : OUT_STR( aStrOut );
702 [ # # ]: 0 : TAG_ON( OOO_STRING_SVTOOLS_HTML_emphasis );
703 : :
704 [ # # ]: 0 : pDoc->GetName( nTab, aStr );
705 [ # # ][ # # ]: 0 : OUT_STR( aStr );
[ # # ]
706 : :
707 [ # # ]: 0 : TAG_OFF( OOO_STRING_SVTOOLS_HTML_emphasis );
708 [ # # ]: 0 : TAG_OFF( OOO_STRING_SVTOOLS_HTML_head1 );
709 [ # # ][ # # ]: 0 : rStrm << "</A>"; OUT_LF();
[ # # ]
710 : : }
711 : : }
712 : : else
713 : : {
714 : 0 : nStartCol = nStartColFix;
715 : 0 : nStartRow = nStartRowFix;
716 : 0 : nEndCol = nEndColFix;
717 : 0 : nEndRow = nEndRowFix;
718 [ # # ][ # # ]: 0 : if ( !TrimDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow ) )
719 : 0 : continue; // for
720 : : }
721 : :
722 : : // <TABLE ...>
723 : 0 : rtl::OStringBuffer aByteStrOut(OOO_STRING_SVTOOLS_HTML_table);
724 : :
725 : 0 : bTabHasGraphics = bTabAlignedLeft = false;
726 [ # # ][ # # ]: 0 : if ( bAll && pDrawLayer )
727 : : PrepareGraphics( pDrawLayer, nTab, nStartCol, nStartRow,
728 [ # # ]: 0 : nEndCol, nEndRow );
729 : :
730 : : // more <TABLE ...>
731 [ # # ]: 0 : if ( bTabAlignedLeft )
732 : : {
733 [ # # ][ # # ]: 0 : aByteStrOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_align).
734 [ # # ]: 0 : append(RTL_CONSTASCII_STRINGPARAM("=\"")).
735 [ # # ][ # # ]: 0 : append(OOO_STRING_SVTOOLS_HTML_AL_left).append('"');
736 : : }
737 : : // ALIGN=LEFT allow text and graphics to flow around
738 : : // CELLSPACING
739 [ # # ][ # # ]: 0 : aByteStrOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_cellspacing).
740 [ # # ]: 0 : append(RTL_CONSTASCII_STRINGPARAM("=\"")).
741 [ # # ][ # # ]: 0 : append(static_cast<sal_Int32>(nCellSpacing)).append('"');
742 : : // COLS=n
743 : 0 : SCCOL nColCnt = 0;
744 : : SCCOL nCol;
745 [ # # ]: 0 : for ( nCol=nStartCol; nCol<=nEndCol; nCol++ )
746 : : {
747 [ # # ][ # # ]: 0 : if ( !pDoc->ColHidden(nCol, nTab) )
748 : 0 : ++nColCnt;
749 : : }
750 [ # # ][ # # ]: 0 : aByteStrOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_cols).
751 [ # # ]: 0 : append(RTL_CONSTASCII_STRINGPARAM("=\"")).
752 [ # # ][ # # ]: 0 : append(static_cast<sal_Int32>(nColCnt)).append('"');
753 : :
754 : : // BORDER=0, we do the styling of the cells in <TD>
755 [ # # ][ # # ]: 0 : aByteStrOut.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_border).
756 [ # # ]: 0 : append(RTL_CONSTASCII_STRINGPARAM("=\"0\""));
757 [ # # ][ # # ]: 0 : IncIndent(1); TAG_ON_LF( aByteStrOut.makeStringAndClear().getStr() );
[ # # ]
758 : :
759 : : // --- <COLGROUP> ----
760 : : {
761 : 0 : nCol = nStartCol;
762 : 0 : sal_Int32 nWidth = 0;
763 : 0 : sal_Int32 nSpan = 0;
764 [ # # ]: 0 : while( nCol <= nEndCol )
765 : : {
766 [ # # ][ # # ]: 0 : if( pDoc->ColHidden(nCol, nTab) )
767 : : {
768 : 0 : ++nCol;
769 : 0 : continue;
770 : : }
771 : :
772 [ # # ][ # # ]: 0 : if( nWidth != ToPixel( pDoc->GetColWidth( nCol, nTab ) ) )
[ # # ]
773 : : {
774 [ # # ]: 0 : if( nSpan != 0 )
775 : : {
776 [ # # ][ # # ]: 0 : TAG_ON(lcl_getColGroupString(nSpan, nWidth).getStr());
777 [ # # ][ # # ]: 0 : TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_colgroup );
[ # # ]
778 : : }
779 [ # # ][ # # ]: 0 : nWidth = ToPixel( pDoc->GetColWidth( nCol, nTab ) );
780 : 0 : nSpan = 1;
781 : : }
782 : : else
783 : 0 : nSpan++;
784 : 0 : nCol++;
785 : : }
786 [ # # ]: 0 : if( nSpan )
787 : : {
788 [ # # ][ # # ]: 0 : TAG_ON(lcl_getColGroupString(nSpan, nWidth).getStr());
789 [ # # ][ # # ]: 0 : TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_colgroup );
[ # # ]
790 : : }
791 : : }
792 : :
793 : : // -------------------
794 : :
795 : : // <TBODY> // Re-enable only when THEAD and TFOOT are exported
796 : : // IncIndent(1); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tbody );
797 : : // At least old (3.x, 4.x?) Netscape doesn't follow <TABLE COLS=n> and
798 : : // <COL WIDTH=x> specified, but needs a width at every column.
799 : 0 : bTableDataWidth = sal_True; // widths in first row
800 [ # # ]: 0 : bool bHasHiddenRows = pDoc->HasHiddenRows(nStartRow, nEndRow, nTab);
801 [ # # ]: 0 : for ( SCROW nRow=nStartRow; nRow<=nEndRow; nRow++ )
802 : : {
803 [ # # ][ # # ]: 0 : if ( bHasHiddenRows && pDoc->RowHidden(nRow, nTab) )
[ # # ][ # # ]
804 : : {
805 [ # # ]: 0 : nRow = pDoc->FirstVisibleRow(nRow+1, nEndRow, nTab);
806 : 0 : --nRow;
807 : 0 : continue; // for
808 : : }
809 : :
810 [ # # ][ # # ]: 0 : IncIndent(1); TAG_ON_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
[ # # ]
811 : 0 : bTableDataHeight = sal_True; // height at every first cell of each row
812 [ # # ]: 0 : for ( SCCOL nCol2=nStartCol; nCol2<=nEndCol; nCol2++ )
813 : : {
814 [ # # ][ # # ]: 0 : if ( pDoc->ColHidden(nCol2, nTab) )
815 : 0 : continue; // for
816 : :
817 [ # # ]: 0 : if ( nCol2 == nEndCol )
818 : 0 : IncIndent(-1);
819 [ # # ]: 0 : WriteCell( nCol2, nRow, nTab );
820 : 0 : bTableDataHeight = false;
821 : : }
822 : 0 : bTableDataWidth = false; // widths only in first row
823 : :
824 [ # # ]: 0 : if ( nRow == nEndRow )
825 : 0 : IncIndent(-1);
826 [ # # ][ # # ]: 0 : TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tablerow );
[ # # ]
827 : : }
828 : : // Uncomment later
829 : : // IncIndent(-1); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tbody );
830 : :
831 [ # # ][ # # ]: 0 : IncIndent(-1); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_table );
[ # # ]
832 : :
833 [ # # ]: 0 : if ( bTabHasGraphics )
834 : : {
835 : : // the rest that is not in a cell
836 : 0 : size_t ListSize = aGraphList.size();
837 [ # # ]: 0 : for ( size_t i = 0; i < ListSize; ++i )
838 : : {
839 [ # # ]: 0 : ScHTMLGraphEntry* pE = &aGraphList[ i ];
840 [ # # ]: 0 : if ( !pE->bWritten )
841 [ # # ]: 0 : WriteGraphEntry( pE );
842 : : }
843 [ # # ]: 0 : aGraphList.clear();
844 [ # # ]: 0 : if ( bTabAlignedLeft )
845 : : {
846 : : // clear <TABLE ALIGN=LEFT> with <BR CLEAR=LEFT>
847 [ # # ]: 0 : aByteStrOut.append(OOO_STRING_SVTOOLS_HTML_linebreak);
848 [ # # ]: 0 : aByteStrOut.append(' ').
849 [ # # ][ # # ]: 0 : append(OOO_STRING_SVTOOLS_HTML_O_clear).append('=').
850 [ # # ]: 0 : append(OOO_STRING_SVTOOLS_HTML_AL_left);
851 [ # # ][ # # ]: 0 : TAG_ON_LF( aByteStrOut.makeStringAndClear().getStr() );
[ # # ]
852 : : }
853 : : }
854 : :
855 [ # # ]: 0 : if ( bAll )
856 [ # # ][ # # ]: 0 : OUT_COMMENT( CREATE_STRING( "**************************************************************************" ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
857 [ # # ][ # # ]: 0 : }
858 : 0 : }
859 : :
860 : :
861 : 0 : void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
862 : : {
863 [ # # ]: 0 : const ScPatternAttr* pAttr = pDoc->GetPattern( nCol, nRow, nTab );
864 [ # # ]: 0 : const SfxItemSet* pCondItemSet = pDoc->GetCondResult( nCol, nRow, nTab );
865 : :
866 [ # # ]: 0 : const ScMergeFlagAttr& rMergeFlagAttr = (const ScMergeFlagAttr&) pAttr->GetItem( ATTR_MERGE_FLAG, pCondItemSet );
867 [ # # ]: 0 : if ( rMergeFlagAttr.IsOverlapped() )
868 : : return ;
869 : :
870 : 0 : ScAddress aPos( nCol, nRow, nTab );
871 : 0 : ScHTMLGraphEntry* pGraphEntry = NULL;
872 [ # # ]: 0 : if ( bTabHasGraphics )
873 : : {
874 : 0 : size_t ListSize = aGraphList.size();
875 [ # # ]: 0 : for ( size_t i = 0; i < ListSize; ++i )
876 : : {
877 [ # # ]: 0 : ScHTMLGraphEntry* pE = &aGraphList[ i ];
878 [ # # ][ # # ]: 0 : if ( pE->bInCell && pE->aRange.In( aPos ) )
[ # # ]
879 : : {
880 [ # # ]: 0 : if ( pE->aRange.aStart == aPos )
881 : : {
882 : 0 : pGraphEntry = pE;
883 : 0 : break; // for
884 : : }
885 : : else
886 : : return ; // ist ein Col/RowSpan, Overlapped
887 : : }
888 : : }
889 : : }
890 : :
891 [ # # ]: 0 : ScBaseCell* pCell = pDoc->GetCell( aPos );
892 [ # # ]: 0 : sal_uLong nFormat = pAttr->GetNumberFormat( pFormatter );
893 : : sal_Bool bValueData;
894 : : sal_uInt8 nScriptType;
895 [ # # ]: 0 : if ( pCell )
896 : : {
897 [ # # ]: 0 : bValueData = pCell->HasValueData();
898 [ # # ]: 0 : nScriptType = pDoc->GetScriptType( nCol, nRow, nTab, pCell );
899 : : }
900 : : else
901 : : {
902 : 0 : bValueData = false;
903 : 0 : nScriptType = 0;
904 : : }
905 [ # # ]: 0 : if ( nScriptType == 0 )
906 : 0 : nScriptType = aHTMLStyle.nDefaultScriptType;
907 : :
908 : 0 : rtl::OStringBuffer aStrTD(OOO_STRING_SVTOOLS_HTML_tabledata);
909 : :
910 : : // border of the cells
911 [ # # ]: 0 : SvxBoxItem* pBorder = (SvxBoxItem*) pDoc->GetAttr( nCol, nRow, nTab, ATTR_BORDER );
912 [ # # ][ # # ]: 0 : if ( pBorder && (pBorder->GetTop() || pBorder->GetBottom() || pBorder->GetLeft() || pBorder->GetRight()) )
[ # # ][ # # ]
[ # # ][ # # ]
913 : : {
914 [ # # ][ # # ]: 0 : aStrTD.append(' ').append(OOO_STRING_SVTOOLS_HTML_style).
915 [ # # ]: 0 : append(RTL_CONSTASCII_STRINGPARAM("=\""));
916 : :
917 : 0 : bool bInsertSemicolon = false;
918 : : aStrTD.append(BorderToStyle("top", pBorder->GetTop(),
919 [ # # ][ # # ]: 0 : bInsertSemicolon));
920 : : aStrTD.append(BorderToStyle("bottom", pBorder->GetBottom(),
921 [ # # ][ # # ]: 0 : bInsertSemicolon));
922 : : aStrTD.append(BorderToStyle("left", pBorder->GetLeft(),
923 [ # # ][ # # ]: 0 : bInsertSemicolon));
924 : : aStrTD.append(BorderToStyle("right", pBorder->GetRight(),
925 [ # # ][ # # ]: 0 : bInsertSemicolon));
926 : :
927 [ # # ]: 0 : aStrTD.append('"');
928 : : }
929 : :
930 : : const sal_Char* pChar;
931 : : sal_uInt16 nHeightPixel;
932 : :
933 [ # # ]: 0 : const ScMergeAttr& rMergeAttr = (const ScMergeAttr&) pAttr->GetItem( ATTR_MERGE, pCondItemSet );
934 [ # # ][ # # ]: 0 : if ( pGraphEntry || rMergeAttr.IsMerged() )
[ # # ]
935 : : {
936 : : SCCOL nC, jC;
937 : : SCROW nR;
938 : : sal_uLong v;
939 [ # # ]: 0 : if ( pGraphEntry )
940 : 0 : nC = Max( SCCOL(pGraphEntry->aRange.aEnd.Col() - nCol + 1),
941 : 0 : SCCOL(rMergeAttr.GetColMerge()) );
942 : : else
943 : 0 : nC = rMergeAttr.GetColMerge();
944 [ # # ]: 0 : if ( nC > 1 )
945 : : {
946 [ # # ][ # # ]: 0 : aStrTD.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_colspan).
947 [ # # ][ # # ]: 0 : append('=').append(static_cast<sal_Int32>(nC));
948 : 0 : nC = nC + nCol;
949 [ # # ]: 0 : for ( jC=nCol, v=0; jC<nC; jC++ )
950 [ # # ]: 0 : v += pDoc->GetColWidth( jC, nTab );
951 : : }
952 : :
953 [ # # ]: 0 : if ( pGraphEntry )
954 : 0 : nR = Max( SCROW(pGraphEntry->aRange.aEnd.Row() - nRow + 1),
955 : 0 : SCROW(rMergeAttr.GetRowMerge()) );
956 : : else
957 : 0 : nR = rMergeAttr.GetRowMerge();
958 [ # # ]: 0 : if ( nR > 1 )
959 : : {
960 [ # # ][ # # ]: 0 : aStrTD.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_rowspan).
961 [ # # ][ # # ]: 0 : append('=').append(static_cast<sal_Int32>(nR));
962 : 0 : nR += nRow;
963 [ # # ]: 0 : v = pDoc->GetRowHeight( nRow, nR-1, nTab );
964 [ # # ]: 0 : nHeightPixel = ToPixel( static_cast< sal_uInt16 >( v ) );
965 : : }
966 : : else
967 [ # # ][ # # ]: 0 : nHeightPixel = ToPixel( pDoc->GetRowHeight( nRow, nTab ) );
968 : : }
969 : : else
970 [ # # ][ # # ]: 0 : nHeightPixel = ToPixel( pDoc->GetRowHeight( nRow, nTab ) );
971 : :
972 [ # # ]: 0 : if ( bTableDataHeight )
973 : : {
974 [ # # ][ # # ]: 0 : aStrTD.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_height).
975 [ # # ]: 0 : append(RTL_CONSTASCII_STRINGPARAM("=\"")).
976 [ # # ][ # # ]: 0 : append(static_cast<sal_Int32>(nHeightPixel)).append('"');
977 : : }
978 : :
979 : : const SvxFontItem& rFontItem = (const SvxFontItem&) pAttr->GetItem(
980 [ # # ]: 0 : ScGlobal::GetScriptedWhichID( nScriptType, ATTR_FONT),
981 [ # # ]: 0 : pCondItemSet);
982 : :
983 : : const SvxFontHeightItem& rFontHeightItem = (const SvxFontHeightItem&)
984 : : pAttr->GetItem( ScGlobal::GetScriptedWhichID( nScriptType,
985 [ # # ][ # # ]: 0 : ATTR_FONT_HEIGHT), pCondItemSet);
986 : :
987 : : const SvxWeightItem& rWeightItem = (const SvxWeightItem&) pAttr->GetItem(
988 [ # # ]: 0 : ScGlobal::GetScriptedWhichID( nScriptType, ATTR_FONT_WEIGHT),
989 [ # # ]: 0 : pCondItemSet);
990 : :
991 : : const SvxPostureItem& rPostureItem = (const SvxPostureItem&)
992 : : pAttr->GetItem( ScGlobal::GetScriptedWhichID( nScriptType,
993 [ # # ][ # # ]: 0 : ATTR_FONT_POSTURE), pCondItemSet);
994 : :
995 : : const SvxUnderlineItem& rUnderlineItem = (const SvxUnderlineItem&)
996 [ # # ]: 0 : pAttr->GetItem( ATTR_FONT_UNDERLINE, pCondItemSet );
997 : :
998 : : const SvxColorItem& rColorItem = (const SvxColorItem&) pAttr->GetItem(
999 [ # # ]: 0 : ATTR_FONT_COLOR, pCondItemSet );
1000 : :
1001 : : const SvxHorJustifyItem& rHorJustifyItem = (const SvxHorJustifyItem&)
1002 [ # # ]: 0 : pAttr->GetItem( ATTR_HOR_JUSTIFY, pCondItemSet );
1003 : :
1004 : : const SvxVerJustifyItem& rVerJustifyItem = (const SvxVerJustifyItem&)
1005 [ # # ]: 0 : pAttr->GetItem( ATTR_VER_JUSTIFY, pCondItemSet );
1006 : :
1007 : : const SvxBrushItem& rBrushItem = (const SvxBrushItem&) pAttr->GetItem(
1008 [ # # ]: 0 : ATTR_BACKGROUND, pCondItemSet );
1009 : :
1010 : 0 : Color aBgColor;
1011 [ # # ]: 0 : if ( rBrushItem.GetColor().GetTransparency() == 255 )
1012 : 0 : aBgColor = aHTMLStyle.aBackgroundColor; // keine ungewollte Hintergrundfarbe
1013 : : else
1014 : 0 : aBgColor = rBrushItem.GetColor();
1015 : :
1016 : 0 : sal_Bool bBold = ( WEIGHT_BOLD <= rWeightItem.GetWeight() );
1017 : 0 : sal_Bool bItalic = ( ITALIC_NONE != rPostureItem.GetPosture() );
1018 : 0 : sal_Bool bUnderline = ( UNDERLINE_NONE != rUnderlineItem.GetLineStyle() );
1019 : 0 : sal_Bool bSetFontColor = ( COL_AUTO != rColorItem.GetValue().GetColor() ); // default is AUTO now
1020 [ # # ]: 0 : sal_Bool bSetFontName = ( aHTMLStyle.aFontFamilyName != rFontItem.GetFamilyName() );
1021 : 0 : sal_uInt16 nSetFontSizeNumber = 0;
1022 : 0 : sal_uInt32 nFontHeight = rFontHeightItem.GetHeight();
1023 [ # # ]: 0 : if ( nFontHeight != aHTMLStyle.nFontHeight )
1024 : : {
1025 : 0 : nSetFontSizeNumber = GetFontSizeNumber( (sal_uInt16) nFontHeight );
1026 [ # # ]: 0 : if ( nSetFontSizeNumber == aHTMLStyle.nFontSizeNumber )
1027 : 0 : nSetFontSizeNumber = 0; // no difference, don't set
1028 : : }
1029 : :
1030 [ # # ][ # # ]: 0 : sal_Bool bSetFont = (bSetFontColor || bSetFontName || nSetFontSizeNumber);
[ # # ]
1031 : :
1032 : : //! TODO: we could entirely use CSS1 here instead, but that would exclude
1033 : : //! Netscape 3.0 and Netscape 4.x without JavaScript enabled.
1034 : : //! Do we want that?
1035 : :
1036 [ # # # # : 0 : switch( rHorJustifyItem.GetValue() )
# ]
1037 : : {
1038 : : case SVX_HOR_JUSTIFY_STANDARD:
1039 [ # # ]: 0 : pChar = (bValueData ? OOO_STRING_SVTOOLS_HTML_AL_right : OOO_STRING_SVTOOLS_HTML_AL_left);
1040 : 0 : break;
1041 : 0 : case SVX_HOR_JUSTIFY_CENTER: pChar = OOO_STRING_SVTOOLS_HTML_AL_center; break;
1042 : 0 : case SVX_HOR_JUSTIFY_BLOCK: pChar = OOO_STRING_SVTOOLS_HTML_AL_justify; break;
1043 : 0 : case SVX_HOR_JUSTIFY_RIGHT: pChar = OOO_STRING_SVTOOLS_HTML_AL_right; break;
1044 : : case SVX_HOR_JUSTIFY_LEFT:
1045 : : case SVX_HOR_JUSTIFY_REPEAT:
1046 : 0 : default: pChar = OOO_STRING_SVTOOLS_HTML_AL_left; break;
1047 : : }
1048 : :
1049 [ # # ][ # # ]: 0 : aStrTD.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_align).
1050 [ # # ][ # # ]: 0 : append(RTL_CONSTASCII_STRINGPARAM("=\"")).append(pChar).append('"');
[ # # ]
1051 : :
1052 [ # # # # ]: 0 : switch( rVerJustifyItem.GetValue() )
1053 : : {
1054 : 0 : case SVX_VER_JUSTIFY_TOP: pChar = OOO_STRING_SVTOOLS_HTML_VA_top; break;
1055 : 0 : case SVX_VER_JUSTIFY_CENTER: pChar = OOO_STRING_SVTOOLS_HTML_VA_middle; break;
1056 : 0 : case SVX_VER_JUSTIFY_BOTTOM: pChar = OOO_STRING_SVTOOLS_HTML_VA_bottom; break;
1057 : : case SVX_VER_JUSTIFY_STANDARD:
1058 : 0 : default: pChar = NULL;
1059 : : }
1060 [ # # ]: 0 : if ( pChar )
1061 : : {
1062 [ # # ][ # # ]: 0 : aStrTD.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_valign).
1063 [ # # ][ # # ]: 0 : append('=').append(pChar);
1064 : : }
1065 : :
1066 [ # # ]: 0 : if ( aHTMLStyle.aBackgroundColor != aBgColor )
1067 : : {
1068 [ # # ][ # # ]: 0 : aStrTD.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_bgcolor).
1069 [ # # ]: 0 : append('=');
1070 [ # # ][ # # ]: 0 : aStrTD.append(lcl_makeHTMLColorTriplet(aBgColor));
1071 : : }
1072 : :
1073 : 0 : double fVal = 0.0;
1074 [ # # ]: 0 : if ( bValueData )
1075 : : {
1076 [ # # ]: 0 : if ( pCell )
1077 : : {
1078 [ # # # ]: 0 : switch ( pCell->GetCellType() )
1079 : : {
1080 : : case CELLTYPE_VALUE:
1081 : 0 : fVal = ((ScValueCell*)pCell)->GetValue();
1082 [ # # ][ # # ]: 0 : if ( bCalcAsShown && fVal != 0.0 )
1083 [ # # ]: 0 : fVal = pDoc->RoundValueAsShown( fVal, nFormat );
1084 : 0 : break;
1085 : : case CELLTYPE_FORMULA:
1086 [ # # ][ # # ]: 0 : fVal = ((ScFormulaCell*)pCell)->GetValue();
1087 [ # # ]: 0 : if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
1088 : : nFormat = ScGlobal::GetStandardFormat( fVal, *pFormatter,
1089 [ # # ][ # # ]: 0 : nFormat, ((ScFormulaCell*)pCell)->GetFormatType() );
1090 : 0 : break;
1091 : : default:
1092 : : OSL_FAIL( "value data with unsupported cell type" );
1093 : : }
1094 : : }
1095 : : }
1096 : :
1097 : : aStrTD.append(HTMLOutFuncs::CreateTableDataOptionsValNum(bValueData, fVal,
1098 [ # # ][ # # ]: 0 : nFormat, *pFormatter, eDestEnc, &aNonConvertibleChars));
1099 : :
1100 [ # # ]: 0 : TAG_ON(aStrTD.makeStringAndClear().getStr());
1101 : :
1102 [ # # ][ # # ]: 0 : if ( bBold ) TAG_ON( OOO_STRING_SVTOOLS_HTML_bold );
1103 [ # # ][ # # ]: 0 : if ( bItalic ) TAG_ON( OOO_STRING_SVTOOLS_HTML_italic );
1104 [ # # ][ # # ]: 0 : if ( bUnderline ) TAG_ON( OOO_STRING_SVTOOLS_HTML_underline );
1105 : :
1106 : :
1107 [ # # ]: 0 : if ( bSetFont )
1108 : : {
1109 : 0 : rtl::OStringBuffer aStr(OOO_STRING_SVTOOLS_HTML_font);
1110 [ # # ]: 0 : if ( bSetFontName )
1111 : : {
1112 [ # # ][ # # ]: 0 : aStr.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_face).
1113 [ # # ]: 0 : append(RTL_CONSTASCII_STRINGPARAM("=\""));
1114 [ # # ][ # # ]: 0 : xub_StrLen nFonts = comphelper::string::getTokenCount(rFontItem.GetFamilyName(), ';');
1115 [ # # ]: 0 : if ( nFonts == 1 )
1116 : : {
1117 : : rtl::OString aTmpStr = HTMLOutFuncs::ConvertStringToHTML(
1118 [ # # ]: 0 : rFontItem.GetFamilyName(), eDestEnc, &aNonConvertibleChars);
1119 [ # # ]: 0 : aStr.append(aTmpStr);
1120 : : }
1121 : : else
1122 : : { // Fontliste, VCL: Semikolon als Separator, HTML: Komma
1123 : 0 : const String& rList = rFontItem.GetFamilyName();
1124 [ # # ]: 0 : for ( xub_StrLen j = 0, nPos = 0; j < nFonts; j++ )
1125 : : {
1126 : : rtl::OString aTmpStr = HTMLOutFuncs::ConvertStringToHTML(
1127 : : rList.GetToken( 0, ';', nPos ), eDestEnc,
1128 [ # # ][ # # ]: 0 : &aNonConvertibleChars);
[ # # ]
1129 [ # # ]: 0 : aStr.append(aTmpStr);
1130 [ # # ]: 0 : if ( j < nFonts-1 )
1131 [ # # ]: 0 : aStr.append(',');
1132 : 0 : }
1133 : : }
1134 [ # # ]: 0 : aStr.append('\"');
1135 : : }
1136 [ # # ]: 0 : if ( nSetFontSizeNumber )
1137 : : {
1138 [ # # ][ # # ]: 0 : aStr.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_size).
1139 [ # # ][ # # ]: 0 : append('=').append(static_cast<sal_Int32>(nSetFontSizeNumber));
1140 : : }
1141 [ # # ]: 0 : if ( bSetFontColor )
1142 : : {
1143 : 0 : Color aColor = rColorItem.GetValue();
1144 : :
1145 : : // always export automatic text color as black
1146 [ # # ]: 0 : if ( aColor.GetColor() == COL_AUTO )
1147 : 0 : aColor.SetColor( COL_BLACK );
1148 : :
1149 [ # # ][ # # ]: 0 : aStr.append(' ').append(OOO_STRING_SVTOOLS_HTML_O_color).
1150 [ # # ][ # # ]: 0 : append('=').append(lcl_makeHTMLColorTriplet(aColor));
[ # # ]
1151 : : }
1152 [ # # ]: 0 : TAG_ON(aStr.makeStringAndClear().getStr());
1153 : : }
1154 : :
1155 : 0 : rtl::OUString aStrOut;
1156 : 0 : sal_Bool bFieldText = false;
1157 [ # # ]: 0 : if ( pCell )
1158 : : { // cell content
1159 : : Color* pColor;
1160 [ # # # ]: 0 : switch ( pCell->GetCellType() )
1161 : : {
1162 : : case CELLTYPE_NOTE :
1163 : : // nothing
1164 : 0 : break;
1165 : : case CELLTYPE_EDIT :
1166 [ # # ]: 0 : bFieldText = WriteFieldText( (const ScEditCell*) pCell );
1167 [ # # ]: 0 : if ( bFieldText )
1168 : 0 : break;
1169 : : //! else: fallthru
1170 : : default:
1171 [ # # ]: 0 : ScCellFormat::GetString( pCell, nFormat, aStrOut, &pColor, *pFormatter );
1172 : : }
1173 : : }
1174 [ # # ]: 0 : if ( !bFieldText )
1175 : : {
1176 [ # # ]: 0 : if ( aStrOut.isEmpty() )
1177 : : {
1178 [ # # ]: 0 : TAG_ON( OOO_STRING_SVTOOLS_HTML_linebreak ); // keine komplett leere Zelle
1179 : : }
1180 : : else
1181 : : {
1182 [ # # ]: 0 : String aStr = aStrOut;
1183 [ # # ]: 0 : xub_StrLen nPos = aStr.Search( _LF );
1184 [ # # ]: 0 : if ( nPos == STRING_NOTFOUND )
1185 : : {
1186 [ # # ][ # # ]: 0 : OUT_STR( aStrOut );
[ # # ]
1187 : : }
1188 : : else
1189 : : {
1190 : 0 : xub_StrLen nStartPos = 0;
1191 [ # # ][ # # ]: 0 : do
1192 : : {
1193 [ # # ]: 0 : String aSingleLine( aStr, nStartPos, nPos - nStartPos );
1194 [ # # ]: 0 : OUT_STR( aSingleLine );
1195 [ # # ]: 0 : TAG_ON( OOO_STRING_SVTOOLS_HTML_linebreak );
1196 [ # # ]: 0 : nStartPos = nPos + 1;
1197 : : }
1198 : 0 : while( ( nPos = aStr.Search( _LF, nStartPos ) ) != STRING_NOTFOUND );
1199 [ # # ]: 0 : String aSingleLine( aStr, nStartPos, aStr.Len() - nStartPos );
1200 [ # # ][ # # ]: 0 : OUT_STR( aSingleLine );
1201 [ # # ]: 0 : }
1202 : : }
1203 : : }
1204 [ # # ]: 0 : if ( pGraphEntry )
1205 [ # # ]: 0 : WriteGraphEntry( pGraphEntry );
1206 : :
1207 [ # # ][ # # ]: 0 : if ( bSetFont ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_font );
1208 [ # # ][ # # ]: 0 : if ( bUnderline ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_underline );
1209 [ # # ][ # # ]: 0 : if ( bItalic ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_italic );
1210 [ # # ][ # # ]: 0 : if ( bBold ) TAG_OFF( OOO_STRING_SVTOOLS_HTML_bold );
1211 : :
1212 [ # # ][ # # ]: 0 : TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_tabledata );
[ # # ]
1213 : : }
1214 : :
1215 : :
1216 : 0 : sal_Bool ScHTMLExport::WriteFieldText( const ScEditCell* pCell )
1217 : : {
1218 : 0 : sal_Bool bFields = false;
1219 : : const EditTextObject* pData;
1220 [ # # ]: 0 : pCell->GetData( pData );
1221 : : // text and anchor of URL fields, Doc-Engine is a ScFieldEditEngine
1222 [ # # ]: 0 : EditEngine& rEngine = pDoc->GetEditEngine();
1223 [ # # ]: 0 : rEngine.SetText( *pData );
1224 [ # # ]: 0 : sal_uInt16 nParas = rEngine.GetParagraphCount();
1225 [ # # ]: 0 : if ( nParas )
1226 : : {
1227 [ # # ]: 0 : ESelection aSel( 0, 0, nParas-1, rEngine.GetTextLen( nParas-1 ) );
1228 [ # # ]: 0 : SfxItemSet aSet( rEngine.GetAttribs( aSel ) );
1229 [ # # ]: 0 : SfxItemState eFieldState = aSet.GetItemState( EE_FEATURE_FIELD, false );
1230 [ # # ][ # # ]: 0 : if ( eFieldState == SFX_ITEM_DONTCARE || eFieldState == SFX_ITEM_SET )
1231 [ # # ]: 0 : bFields = sal_True;
1232 : : }
1233 [ # # ]: 0 : if ( bFields )
1234 : : {
1235 [ # # ]: 0 : sal_Bool bOldUpdateMode = rEngine.GetUpdateMode();
1236 [ # # ]: 0 : rEngine.SetUpdateMode( sal_True ); // no portions if not formatted
1237 [ # # ]: 0 : for ( sal_uInt16 nPar=0; nPar < nParas; nPar++ )
1238 : : {
1239 [ # # ]: 0 : if ( nPar > 0 )
1240 [ # # ]: 0 : TAG_ON( OOO_STRING_SVTOOLS_HTML_linebreak );
1241 [ # # ]: 0 : std::vector<sal_uInt16> aPortions;
1242 [ # # ]: 0 : rEngine.GetPortions( nPar, aPortions );
1243 : 0 : sal_uInt16 nStart = 0;
1244 [ # # ][ # # ]: 0 : for ( std::vector<sal_uInt16>::const_iterator it(aPortions.begin()); it != aPortions.end(); ++it )
[ # # ][ # # ]
1245 : : {
1246 [ # # ]: 0 : sal_uInt16 nEnd = *it;
1247 : 0 : ESelection aSel( nPar, nStart, nPar, nEnd );
1248 : 0 : sal_Bool bUrl = false;
1249 : : // fields are single characters
1250 [ # # ]: 0 : if ( nEnd == nStart+1 )
1251 : : {
1252 : : const SfxPoolItem* pItem;
1253 [ # # ]: 0 : SfxItemSet aSet = rEngine.GetAttribs( aSel );
1254 [ # # ][ # # ]: 0 : if ( aSet.GetItemState( EE_FEATURE_FIELD, false, &pItem ) == SFX_ITEM_ON )
1255 : : {
1256 : 0 : const SvxFieldData* pField = ((const SvxFieldItem*)pItem)->GetField();
1257 [ # # ][ # # ]: 0 : if ( pField && pField->ISA(SvxURLField) )
[ # # ][ # # ]
[ # # ]
1258 : : {
1259 : 0 : bUrl = sal_True;
1260 : 0 : const SvxURLField* pURLField = (const SvxURLField*)pField;
1261 : : // String aFieldText = rEngine.GetText( aSel );
1262 [ # # ][ # # ]: 0 : rStrm << '<' << OOO_STRING_SVTOOLS_HTML_anchor << ' ' << OOO_STRING_SVTOOLS_HTML_O_href << "=\"";
[ # # ][ # # ]
[ # # ]
1263 [ # # ][ # # ]: 0 : OUT_STR( pURLField->GetURL() );
[ # # ]
1264 [ # # ]: 0 : rStrm << "\">";
1265 [ # # ][ # # ]: 0 : OUT_STR( pURLField->GetRepresentation() );
[ # # ]
1266 [ # # ][ # # ]: 0 : rStrm << "</" << OOO_STRING_SVTOOLS_HTML_anchor << '>';
[ # # ]
1267 : : }
1268 [ # # ]: 0 : }
1269 : : }
1270 [ # # ]: 0 : if ( !bUrl )
1271 [ # # ][ # # ]: 0 : OUT_STR( rEngine.GetText( aSel ) );
[ # # ]
1272 : 0 : nStart = nEnd;
1273 : : }
1274 : 0 : }
1275 [ # # ]: 0 : rEngine.SetUpdateMode( bOldUpdateMode );
1276 : : }
1277 : 0 : return bFields;
1278 : : }
1279 : :
1280 : :
1281 : 0 : sal_Bool ScHTMLExport::CopyLocalFileToINet( String& rFileNm,
1282 : : const String& rTargetNm, sal_Bool bFileToFile )
1283 : : {
1284 : 0 : sal_Bool bRet = false;
1285 [ # # ][ # # ]: 0 : INetURLObject aFileUrl, aTargetUrl;
1286 [ # # ][ # # ]: 0 : aFileUrl.SetSmartURL( rFileNm );
1287 [ # # ][ # # ]: 0 : aTargetUrl.SetSmartURL( rTargetNm );
1288 [ # # # # ]: 0 : if( INET_PROT_FILE == aFileUrl.GetProtocol() &&
[ # # # #
# # # # ]
[ # # ][ # # ]
1289 : 0 : ( (bFileToFile && INET_PROT_FILE == aTargetUrl.GetProtocol()) ||
1290 : 0 : (!bFileToFile && INET_PROT_FILE != aTargetUrl.GetProtocol() &&
1291 : 0 : INET_PROT_FTP <= aTargetUrl.GetProtocol() &&
1292 : 0 : INET_PROT_NEWS >= aTargetUrl.GetProtocol()) ) )
1293 : : {
1294 [ # # ]: 0 : if( pFileNameMap )
1295 : : {
1296 : : // wurde die Datei schon verschoben
1297 [ # # ]: 0 : std::map<String, String>::iterator it = pFileNameMap->find( rFileNm );
1298 [ # # ][ # # ]: 0 : if( it != pFileNameMap->end() )
1299 : : {
1300 [ # # ][ # # ]: 0 : rFileNm = it->second;
1301 : 0 : return sal_True;
1302 : : }
1303 : : }
1304 : : else
1305 : : {
1306 [ # # ][ # # ]: 0 : pFileNameMap.reset( new std::map<String, String>() );
[ # # ]
1307 : : }
1308 : :
1309 [ # # ][ # # ]: 0 : SvFileStream aTmp( aFileUrl.PathToFileName(), STREAM_READ );
[ # # ][ # # ]
1310 : :
1311 [ # # ]: 0 : String aSrc = rFileNm;
1312 [ # # ][ # # ]: 0 : String aDest = aTargetUrl.GetPartBeforeLastName();
1313 [ # # ][ # # ]: 0 : aDest += String(aFileUrl.GetName());
[ # # ][ # # ]
1314 : :
1315 [ # # ]: 0 : if( bFileToFile )
1316 : : {
1317 [ # # ][ # # ]: 0 : INetURLObject aCpyURL( aDest );
1318 [ # # ][ # # ]: 0 : SvFileStream aCpy( aCpyURL.PathToFileName(), STREAM_WRITE );
[ # # ][ # # ]
1319 [ # # ]: 0 : aCpy << aTmp;
1320 : :
1321 [ # # ]: 0 : aCpy.Close();
1322 [ # # ][ # # ]: 0 : bRet = SVSTREAM_OK == aCpy.GetError();
1323 : : }
1324 : : else
1325 : : {
1326 [ # # ]: 0 : SfxMedium aMedium( aDest, STREAM_WRITE | STREAM_SHARE_DENYNONE );
1327 : :
1328 : : {
1329 [ # # ][ # # ]: 0 : SvFileStream aCpy( aMedium.GetPhysicalName(), STREAM_WRITE );
[ # # ][ # # ]
1330 [ # # ][ # # ]: 0 : aCpy << aTmp;
1331 : : }
1332 : :
1333 : : // uebertragen
1334 [ # # ]: 0 : aMedium.Close();
1335 [ # # ]: 0 : aMedium.Commit();
1336 : :
1337 [ # # ][ # # ]: 0 : bRet = 0 == aMedium.GetError();
1338 : : }
1339 : :
1340 [ # # ]: 0 : if( bRet )
1341 : : {
1342 [ # # ][ # # ]: 0 : pFileNameMap->insert( std::make_pair( aSrc, aDest ) );
[ # # ]
1343 [ # # ]: 0 : rFileNm = aDest;
1344 [ # # ][ # # ]: 0 : }
[ # # ]
1345 : : }
1346 : :
1347 [ # # ][ # # ]: 0 : return bRet;
1348 : : }
1349 : :
1350 : :
1351 : 0 : void ScHTMLExport::MakeCIdURL( String& rURL )
1352 : : {
1353 [ # # ]: 0 : if( !aCId.Len() )
1354 : : return;
1355 : :
1356 [ # # ][ # # ]: 0 : INetURLObject aURLObj( rURL );
1357 [ # # ]: 0 : if( INET_PROT_FILE != aURLObj.GetProtocol() )
1358 : : return;
1359 : :
1360 [ # # ][ # # ]: 0 : String aLastName( aURLObj.GetLastName() );
1361 : : OSL_ENSURE( aLastName.Len(), "Dateiname ohne Laenge!" );
1362 [ # # ]: 0 : aLastName.ToLowerAscii();
1363 : :
1364 [ # # ]: 0 : rURL.AssignAscii( "cid:" );
1365 [ # # ]: 0 : rURL += aLastName;
1366 [ # # ]: 0 : rURL.AppendAscii( "." );
1367 [ # # ][ # # ]: 0 : rURL += aCId;
[ # # ][ # # ]
1368 : : }
1369 : :
1370 : :
1371 : 0 : void ScHTMLExport::IncIndent( short nVal )
1372 : : {
1373 : 0 : sIndent[nIndent] = '\t';
1374 : 0 : nIndent = nIndent + nVal;
1375 [ # # ]: 0 : if ( nIndent < 0 )
1376 : 0 : nIndent = 0;
1377 [ # # ]: 0 : else if ( nIndent > nIndentMax )
1378 : 0 : nIndent = nIndentMax;
1379 : 0 : sIndent[nIndent] = 0;
1380 : 0 : }
1381 : :
1382 : :
1383 : :
1384 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|