LCOV - code coverage report
Current view: top level - sc/source/filter/inc - htmlexp.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 13 13 100.0 %
Date: 2015-06-13 12:38:46 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          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 INCLUDED_SC_SOURCE_FILTER_INC_HTMLEXP_HXX
      21             : #define INCLUDED_SC_SOURCE_FILTER_INC_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             : class ScDocument;
      33             : class SfxItemSet;
      34             : class SdrPage;
      35             : class Graphic;
      36             : class SdrObject;
      37             : class OutputDevice;
      38             : class ScDrawLayer;
      39             : class EditTextObject;
      40             : enum class SvtScriptType;
      41             : namespace editeng { class SvxBorderLine; }
      42             : 
      43           3 : struct ScHTMLStyle
      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
      50             :     bool                bInitialized;
      51             : 
      52           3 :     ScHTMLStyle() :
      53             :         nFontHeight(0),
      54             :         nFontSizeNumber(2),
      55             :         nDefaultScriptType(),
      56           3 :         bInitialized(false)
      57           3 :     {}
      58             : 
      59             :     const ScHTMLStyle& operator=( const ScHTMLStyle& rScHTMLStyle )
      60             :     {
      61             :         aBackgroundColor   = rScHTMLStyle.aBackgroundColor;
      62             :         aFontFamilyName    = rScHTMLStyle.aFontFamilyName;
      63             :         nFontHeight        = rScHTMLStyle.nFontHeight;
      64             :         nFontSizeNumber    = rScHTMLStyle.nFontSizeNumber;
      65             :         nDefaultScriptType = rScHTMLStyle.nDefaultScriptType;
      66             :         bInitialized       = rScHTMLStyle.bInitialized;
      67             :         return *this;
      68             :     }
      69             : };
      70             : 
      71             : struct ScHTMLGraphEntry
      72             : {
      73             :     ScRange             aRange;         // mapped range
      74             :     Size                aSize;          // size in pixels
      75             :     Size                aSpace;         // spacing in pixels
      76             :     SdrObject*          pObject;
      77             :     bool                bInCell;        // if output is in cell
      78             :     bool                bWritten;
      79             : 
      80           2 :     ScHTMLGraphEntry( SdrObject* pObj, const ScRange& rRange,
      81             :                       const Size& rSize,  bool bIn, const Size& rSpace ) :
      82             :         aRange( rRange ),
      83             :         aSize( rSize ),
      84             :         aSpace( rSpace ),
      85             :         pObject( pObj ),
      86             :         bInCell( bIn ),
      87           2 :         bWritten( false )
      88           2 :     {}
      89             : };
      90             : 
      91             : #define SC_HTML_FONTSIZES 7
      92             : const short nIndentMax = 23;
      93             : 
      94             : class ScHTMLExport : public ScExportBase
      95             : {
      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[];
     103             : 
     104             :     typedef boost::scoped_ptr<std::map<OUString, OUString> > FileNameMapPtr;
     105             :     typedef boost::ptr_vector<ScHTMLGraphEntry> GraphEntryList;
     106             : 
     107             :     GraphEntryList   aGraphList;
     108             :     ScHTMLStyle      aHTMLStyle;
     109             :     OUString         aBaseURL;
     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;
     117             :     SCTAB            nUsedTables;
     118             :     short            nIndent;
     119             :     sal_Char         sIndent[nIndentMax+1];
     120             :     bool             bAll;           // whole document
     121             :     bool             bTabHasGraphics;
     122             :     bool             bTabAlignedLeft;
     123             :     bool             bCalcAsShown;
     124             :     bool             bCopyLocalFileToINet;
     125             :     bool             bTableDataWidth;
     126             :     bool             bTableDataHeight;
     127             :     bool             mbSkipImages;
     128             :     /// If HTML header and footer should be written as well, or just the content itself.
     129             :     bool             mbSkipHeaderFooter;
     130             : 
     131             :     const SfxItemSet& PageDefaults( SCTAB nTab );
     132             : 
     133             :     void WriteBody();
     134             :     void WriteHeader();
     135             :     void WriteOverview();
     136             :     void WriteTables();
     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
     143             : 
     144             :     // write to stream if and only if URL fields in edit cell
     145             :     bool WriteFieldText( const EditTextObject* pData );
     146             : 
     147             :     // copy a local file to internet if needed
     148             :     bool CopyLocalFileToINet( OUString& rFileNm, const OUString& rTargetNm, bool bFileToFile = false );
     149           1 :     bool HasCId()
     150             :     {
     151           1 :         return !aCId.isEmpty();
     152             :     }
     153             :     void MakeCIdURL( OUString& rURL );
     154             : 
     155             :     void PrepareGraphics( ScDrawLayer*, SCTAB nTab,
     156             :                           SCCOL nStartCol, SCROW nStartRow,
     157             :                           SCCOL nEndCol, SCROW nEndRow );
     158             : 
     159             :     void FillGraphList( const SdrPage*, SCTAB nTab,
     160             :                         SCCOL nStartCol, SCROW nStartRow,
     161             :                         SCCOL nEndCol, SCROW nEndRow );
     162             : 
     163             :     static OString BorderToStyle(const char* pBorderName,
     164             :                           const editeng::SvxBorderLine* pLine,
     165             :                           bool& bInsertSemicolon);
     166             : 
     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 );
     172             : 
     173         153 :     const sal_Char* GetIndentStr()
     174             :     {
     175         153 :         return sIndent;
     176             :     }
     177             : 
     178             : public:
     179             :                         ScHTMLExport( SvStream&, const OUString&, ScDocument*, const ScRange&,
     180             :                                       bool bAll, const OUString& aStreamPath, const OUString& rFilterOptions );
     181             :     virtual             ~ScHTMLExport();
     182             :     sal_uLong           Write();
     183           3 :     const OUString&     GetNonConvertibleChars() const
     184             :     {
     185           3 :         return aNonConvertibleChars;
     186             :     }
     187             : };
     188             : 
     189             : #endif
     190             : 
     191             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11