LCOV - code coverage report
Current view: top level - xml2cmp/source/xcd - cr_html.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 118 0.8 %
Date: 2012-08-25 Functions: 2 18 11.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 46 4.3 %

           Branch data     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                 :            : #include <fstream>
      21                 :            : #include "cr_html.hxx"
      22                 :            : #include "xmltree.hxx"
      23                 :            : #include "../support/syshelp.hxx"
      24                 :            : 
      25                 :            : 
      26                 :            : 
      27                 :            : 
      28                 :            : char C_sHtmlFileHeader1[] =
      29                 :            :     "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n"
      30                 :            :     "<HTML>\n"
      31                 :            :     "<HEAD>\n"
      32                 :            :     "   <TITLE>";
      33                 :            : 
      34                 :            : char C_sHtmlFileHeader2[] =
      35                 :            :         "</TITLE>\n"
      36                 :            :     "       <META NAME=\"GENERATOR\" CONTENT=\"xml2cmp\">\n"
      37                 :            :     "</HEAD>\n"
      38                 :            :     "<BODY BGCOLOR=\"#ffffff\">\n<P><BR></P>";
      39                 :            : 
      40                 :            : 
      41                 :            : char C_sHtmlFileFoot[] = "</BODY>\n</HTML>\n";
      42                 :            : 
      43                 :            : 
      44                 :          0 : HtmlCreator::HtmlCreator( const char *              i_pOutputFileName,
      45                 :            :                           const XmlElement &        i_rDocument,
      46                 :            :                           const Simstr &            i_sIDL_BaseDirectory )
      47                 :            :     :   aFile(i_pOutputFileName, std::ios::out
      48                 :            : #if defined(WNT)
      49                 :            :                                                | std::ios::binary
      50                 :            : #endif
      51                 :            :                                                              ),
      52                 :            :         rDocument(i_rDocument),
      53         [ #  # ]:          0 :         sIdl_BaseDirectory(i_sIDL_BaseDirectory)
      54                 :            : {
      55 [ #  # ][ #  # ]:          0 :     if ( !aFile )
      56                 :            :     {
      57 [ #  # ][ #  # ]:          0 :         std::cerr << "Error: " << i_pOutputFileName << " could not be created." << std::endl;
         [ #  # ][ #  # ]
      58                 :          0 :         exit(0);
      59                 :            :     }
      60                 :          0 : }
      61                 :            : 
      62         [ #  # ]:          0 : HtmlCreator::~HtmlCreator()
      63                 :            : {
      64         [ #  # ]:          0 :     aFile.close();
      65                 :          0 : }
      66                 :            : 
      67                 :            : void
      68                 :          0 : HtmlCreator::Run()
      69                 :            : {
      70                 :          0 :     WriteStr( C_sHtmlFileHeader1 );
      71                 :          0 :     WriteStr( "ModuleDescription" );
      72                 :          0 :     WriteStr( C_sHtmlFileHeader2 );
      73                 :            : 
      74                 :          0 :     rDocument.Write2Html(*this);
      75                 :            : 
      76                 :          0 :     WriteStr( "<P><BR><BR></P>\n" );
      77                 :          0 :     WriteStr( C_sHtmlFileFoot );
      78                 :          0 : }
      79                 :            : 
      80                 :            : void
      81                 :          0 : HtmlCreator::StartTable()
      82                 :            : {
      83                 :          0 :     WriteStr( "<P><BR></P>\n" );
      84                 :            :     WriteStr(
      85                 :            :             "<TABLE WIDTH=95% BORDER=1 CELLSPACING=0 CELLPADDING=4>\n"
      86                 :          0 :             "   <TBODY>\n"  );
      87                 :          0 : }
      88                 :            : 
      89                 :            : void
      90                 :          0 : HtmlCreator::FinishTable()
      91                 :            : {
      92                 :            :     WriteStr( " </TBODY>\n"
      93                 :          0 :               "</TABLE>\n\n" );
      94                 :          0 : }
      95                 :            : 
      96                 :            : void
      97                 :          0 : HtmlCreator::StartBigCell( const char * i_sTitle )
      98                 :            : {
      99                 :            :     WriteStr( "<TR><TD COLSPAN=2>\n"
     100                 :          0 :               "<H4><BR>" );
     101                 :          0 :     WriteStr( i_sTitle );
     102                 :          0 :     WriteStr( "</H4>\n" );
     103                 :            : 
     104                 :          0 : }
     105                 :            : 
     106                 :            : void
     107                 :          0 : HtmlCreator::FinishBigCell()
     108                 :            : {
     109                 :          0 :     WriteStr( "</TD><TR>\n" );
     110                 :          0 : }
     111                 :            : 
     112                 :            : void
     113                 :          0 : HtmlCreator::Write_SglTextElement( const SglTextElement &  i_rElement,
     114                 :            :                                    bool                    i_bStrong )
     115                 :            : {
     116                 :          0 :     StartRow();
     117                 :            : 
     118                 :          0 :     WriteElementName( i_rElement.Name(), i_bStrong );
     119                 :            : 
     120                 :          0 :     StartCell( "77%");
     121         [ #  # ]:          0 :     if (i_bStrong)
     122                 :            :     {
     123                 :          0 :         WriteStr( "<H4><A NAME=\"" );
     124                 :          0 :         unsigned nLen = strlen(i_rElement.Data());
     125         [ #  # ]:          0 :         if ( i_rElement.IsReversedName())
     126                 :            :         {
     127                 :          0 :             const char * pEnd = strchr(i_rElement.Data(), ' ');
     128                 :          0 :             nLen = (unsigned)( pEnd - i_rElement.Data() );
     129                 :            :         }
     130                 :          0 :         aFile.write( i_rElement.Data(), (int) nLen );
     131                 :          0 :         WriteStr( "\">" );
     132                 :            :     }
     133                 :            : 
     134                 :          0 :     WriteName( aFile, sIdl_BaseDirectory, i_rElement.Data(),
     135         [ #  # ]:          0 :                i_bStrong ? lt_nolink : i_rElement.LinkType() );
     136                 :            : 
     137         [ #  # ]:          0 :     if (i_bStrong)
     138                 :          0 :         WriteStr( "</A></H4>" );
     139                 :          0 :     FinishCell();
     140                 :            : 
     141                 :          0 :     FinishRow();
     142                 :          0 : }
     143                 :            : 
     144                 :            : void
     145                 :          0 : HtmlCreator::Write_MultiTextElement( const MultipleTextElement &    i_rElement )
     146                 :            : {
     147                 :          0 :     StartRow();
     148                 :            : 
     149                 :          0 :     WriteElementName( i_rElement.Name(), false );
     150                 :            : 
     151                 :          0 :     StartCell( "77%");
     152                 :          0 :     unsigned i_max = i_rElement.Size();
     153         [ #  # ]:          0 :     for ( unsigned i = 0; i < i_max; ++i )
     154                 :            :     {
     155         [ #  # ]:          0 :         if (i > 0)
     156                 :          0 :             WriteStr( "<BR>\n" );
     157                 :          0 :         WriteName( aFile, sIdl_BaseDirectory, i_rElement.Data(i), i_rElement.LinkType() );
     158                 :            :     }   // end for
     159                 :          0 :     FinishCell();
     160                 :            : 
     161                 :          0 :     FinishRow();
     162                 :          0 : }
     163                 :            : 
     164                 :            : void
     165                 :          0 : HtmlCreator::Write_SglText( const Simstr &      i_sName,
     166                 :            :                             const Simstr &      i_sValue )
     167                 :            : {
     168                 :          0 :     StartRow();
     169                 :            : 
     170                 :          0 :     WriteElementName( i_sName, false );
     171                 :            : 
     172                 :          0 :     StartCell( "77%");
     173                 :          0 :     WriteStr( i_sValue );
     174                 :          0 :     FinishCell();
     175                 :            : 
     176                 :          0 :     FinishRow();
     177                 :          0 : }
     178                 :            : 
     179                 :            : void
     180                 :          0 : HtmlCreator::Write_ReferenceDocu( const Simstr &      i_sName,
     181                 :            :                                   const Simstr &      i_sRef,
     182                 :            :                                   const Simstr &      i_sRole,
     183                 :            :                                   const Simstr &      i_sTitle )
     184                 :            : {
     185                 :          0 :     StartRow();
     186                 :            : 
     187                 :          0 :     StartCell( "23%" );
     188                 :          0 :     WriteStr(i_sName);
     189                 :          0 :     FinishCell();
     190                 :            : 
     191                 :          0 :     StartCell( "77%" );
     192         [ #  # ]:          0 :     if ( !i_sRef.is_empty() )
     193                 :            :     {
     194                 :          0 :         WriteStr("<A href=\"");
     195                 :          0 :         WriteStr(i_sRef);
     196                 :          0 :         WriteStr("\">");
     197         [ #  # ]:          0 :         if ( !i_sTitle.is_empty() )
     198                 :          0 :             WriteStr( i_sTitle );
     199                 :            :         else
     200                 :          0 :             WriteStr(i_sRef);
     201                 :          0 :         WriteStr("</A><BR>\n");
     202                 :            :     }
     203         [ #  # ]:          0 :     else if ( !i_sTitle.is_empty() )
     204                 :            :     {
     205                 :          0 :         WriteStr("Title: ");
     206                 :          0 :         WriteStr( i_sTitle );
     207                 :          0 :         WriteStr("<BR>\n");
     208                 :            :     }
     209         [ #  # ]:          0 :     if ( !i_sRole.is_empty() )
     210                 :            :     {
     211                 :          0 :         WriteStr("Role: ");
     212                 :          0 :         WriteStr( i_sRole );
     213                 :            :     }
     214                 :          0 :     FinishCell();
     215                 :            : 
     216                 :          0 :     FinishRow();
     217                 :          0 : }
     218                 :            : 
     219                 :            : 
     220                 :            : void
     221                 :          0 : HtmlCreator::StartRow()
     222                 :            : {
     223                 :          0 :     WriteStr( "     <TR VALIGN=TOP>\n" );
     224                 :          0 : }
     225                 :            : 
     226                 :            : void
     227                 :          0 : HtmlCreator::FinishRow()
     228                 :            : {
     229                 :          0 :     WriteStr( "     </TR>\n" );
     230                 :          0 : }
     231                 :            : 
     232                 :            : void
     233                 :          0 : HtmlCreator::StartCell( const char * i_pWidth)
     234                 :            : {
     235                 :          0 :     WriteStr( "         <TD WIDTH=" );
     236                 :          0 :     WriteStr( i_pWidth );
     237                 :          0 :     WriteStr( ">\n              <P>" );
     238                 :          0 : }
     239                 :            : 
     240                 :            : void
     241                 :          0 : HtmlCreator::FinishCell()
     242                 :            : {
     243                 :          0 :     WriteStr( "</P>\n           </TD>\n" );
     244                 :          0 : }
     245                 :            : 
     246                 :            : void
     247                 :          0 : HtmlCreator::WriteElementName( const Simstr & i_sName,
     248                 :            :                                bool           i_bStrong )
     249                 :            : {
     250                 :          0 :     StartCell( "23%" );
     251         [ #  # ]:          0 :     if (i_bStrong)
     252                 :          0 :         WriteStr( "<H4>" );
     253                 :          0 :     WriteStr(i_sName);
     254         [ #  # ]:          0 :     if (i_bStrong)
     255                 :          0 :         WriteStr( "</H4>" );
     256                 :          0 :     FinishCell();
     257 [ +  - ][ +  - ]:          6 : }
     258                 :            : 
     259                 :            : 
     260                 :            : 
     261                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10