LCOV - code coverage report
Current view: top level - svtools/source/svhtml - htmlsupp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 63 0.0 %
Date: 2012-08-25 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 125 0.0 %

           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                 :            : 
      30                 :            : #include <ctype.h>
      31                 :            : #include <stdio.h>
      32                 :            : #include <comphelper/string.hxx>
      33                 :            : #include <svtools/parhtml.hxx>
      34                 :            : #include <svtools/htmltokn.h>
      35                 :            : #include <svtools/htmlkywd.hxx>
      36                 :            : #include <tools/urlobj.hxx>
      37                 :            : 
      38                 :            : // Table for converting option values into strings
      39                 :            : static HTMLOptionEnum const aScriptLangOptEnums[] =
      40                 :            : {
      41                 :            :     { OOO_STRING_SVTOOLS_HTML_LG_starbasic, HTML_SL_STARBASIC   },
      42                 :            :     { OOO_STRING_SVTOOLS_HTML_LG_javascript,    HTML_SL_JAVASCRIPT  },
      43                 :            :     { OOO_STRING_SVTOOLS_HTML_LG_javascript11,HTML_SL_JAVASCRIPT    },
      44                 :            :     { OOO_STRING_SVTOOLS_HTML_LG_livescript,    HTML_SL_JAVASCRIPT  },
      45                 :            :     { 0,                    0                   }
      46                 :            : };
      47                 :            : 
      48                 :          0 : bool HTMLParser::ParseScriptOptions( String& rLangString, const String& rBaseURL,
      49                 :            :                                      HTMLScriptLanguage& rLang,
      50                 :            :                                      String& rSrc,
      51                 :            :                                      String& rLibrary,
      52                 :            :                                      String& rModule )
      53                 :            : {
      54                 :          0 :     const HTMLOptions& aScriptOptions = GetOptions();
      55                 :            : 
      56                 :          0 :     rLangString.Erase();
      57                 :          0 :     rLang = HTML_SL_JAVASCRIPT;
      58                 :          0 :     rSrc.Erase();
      59                 :          0 :     rLibrary.Erase();
      60                 :          0 :     rModule.Erase();
      61                 :            : 
      62         [ #  # ]:          0 :     for( size_t i = aScriptOptions.size(); i; )
      63                 :            :     {
      64                 :          0 :         const HTMLOption& aOption = aScriptOptions[--i];
      65   [ #  #  #  #  :          0 :         switch( aOption.GetToken() )
                      # ]
      66                 :            :         {
      67                 :            :         case HTML_O_LANGUAGE:
      68                 :            :             {
      69         [ #  # ]:          0 :                 rLangString = aOption.GetString();
      70                 :            :                 sal_uInt16 nLang;
      71 [ #  # ][ #  # ]:          0 :                 if( aOption.GetEnum( nLang, aScriptLangOptEnums ) )
      72                 :          0 :                     rLang = (HTMLScriptLanguage)nLang;
      73                 :            :                 else
      74                 :          0 :                     rLang = HTML_SL_UNKNOWN;
      75                 :            :             }
      76                 :          0 :             break;
      77                 :            : 
      78                 :            :         case HTML_O_SRC:
      79 [ #  # ][ #  # ]:          0 :             rSrc = INetURLObject::GetAbsURL( rBaseURL, aOption.GetString() );
                 [ #  # ]
      80                 :          0 :             break;
      81                 :            :         case HTML_O_SDLIBRARY:
      82                 :          0 :             rLibrary = aOption.GetString();
      83                 :          0 :             break;
      84                 :            : 
      85                 :            :         case HTML_O_SDMODULE:
      86                 :          0 :             rModule = aOption.GetString();
      87                 :          0 :             break;
      88                 :            :         }
      89                 :            :     }
      90                 :            : 
      91                 :          0 :     return true;
      92                 :            : }
      93                 :            : 
      94                 :          0 : void HTMLParser::RemoveSGMLComment( String &rString, sal_Bool bFull )
      95                 :            : {
      96                 :          0 :     sal_Unicode c = 0;
      97 [ #  # ][ #  # ]:          0 :     while( rString.Len() &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      98                 :            :            ( ' '==(c=rString.GetChar(0)) || '\t'==c || '\r'==c || '\n'==c ) )
      99                 :          0 :         rString.Erase( 0, 1 );
     100                 :            : 
     101   [ #  #  #  # ]:          0 :     while( rString.Len() &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     102                 :          0 :            ( ' '==(c=rString.GetChar( rString.Len()-1))
     103                 :            :            || '\t'==c || '\r'==c || '\n'==c ) )
     104                 :          0 :         rString.Erase( rString.Len()-1 );
     105                 :            : 
     106                 :            : 
     107                 :            :     // remove SGML comments
     108   [ #  #  #  # ]:          0 :     if( rString.Len() >= 4 &&
                 [ #  # ]
     109                 :          0 :         rString.CompareToAscii( "<!--", 4 ) == COMPARE_EQUAL )
     110                 :            :     {
     111                 :          0 :         xub_StrLen nPos = 3;
     112         [ #  # ]:          0 :         if( bFull )
     113                 :            :         {
     114                 :            :             // the whole line
     115                 :          0 :             nPos = 4;
     116 [ #  # ][ #  # ]:          0 :             while( nPos < rString.Len() &&
         [ #  # ][ #  # ]
     117                 :          0 :                 ( ( c = rString.GetChar( nPos )) != '\r' && c != '\n' ) )
     118                 :          0 :                 ++nPos;
     119         [ #  # ]:          0 :             if( c == '\r' && nPos+1 < rString.Len() &&
           [ #  #  #  # ]
                 [ #  # ]
     120                 :          0 :                 '\n' == rString.GetChar( nPos+1 ))
     121                 :          0 :                 ++nPos;
     122         [ #  # ]:          0 :             else if( c != '\n' )
     123                 :          0 :                 nPos = 3;
     124                 :            :         }
     125                 :          0 :         rString.Erase( 0, ++nPos );
     126                 :            :     }
     127                 :            : 
     128 [ #  # ][ #  # ]:          0 :     if( rString.Len() >=3 &&
                 [ #  # ]
     129 [ #  # ][ #  # ]:          0 :         rString.Copy(rString.Len()-3).CompareToAscii("-->")
         [ #  # ][ #  # ]
     130                 :            :             == COMPARE_EQUAL )
     131                 :            :     {
     132                 :          0 :         rString.Erase( rString.Len()-3 );
     133         [ #  # ]:          0 :         if( bFull )
     134                 :            :         {
     135                 :            :             // "//" or "'", maybe preceding CR/LF
     136 [ #  # ][ #  # ]:          0 :             rString = comphelper::string::stripEnd(rString, ' ');
     137                 :          0 :             xub_StrLen nDel = 0, nLen = rString.Len();
     138 [ #  # ][ #  # ]:          0 :             if( nLen >= 2 &&
                 [ #  # ]
     139 [ #  # ][ #  # ]:          0 :                 rString.Copy(nLen-2).CompareToAscii("//") == COMPARE_EQUAL )
         [ #  # ][ #  # ]
     140                 :            :             {
     141                 :          0 :                 nDel = 2;
     142                 :            :             }
     143 [ #  # ][ #  # ]:          0 :             else if( nLen && '\'' == rString.GetChar(nLen-1) )
                 [ #  # ]
     144                 :            :             {
     145                 :          0 :                 nDel = 1;
     146                 :            :             }
     147 [ #  # ][ #  # ]:          0 :             if( nDel && nLen >= nDel+1 )
     148                 :            :             {
     149                 :          0 :                 c = rString.GetChar( nLen-(nDel+1) );
     150 [ #  # ][ #  # ]:          0 :                 if( '\r'==c || '\n'==c )
     151                 :            :                 {
     152                 :          0 :                     nDel++;
     153         [ #  # ]:          0 :                     if( '\n'==c && nLen >= nDel+1 &&
           [ #  #  #  # ]
                 [ #  # ]
     154                 :          0 :                         '\r'==rString.GetChar( nLen-(nDel+1) ) )
     155                 :          0 :                         nDel++;
     156                 :            :                 }
     157                 :            :             }
     158                 :          0 :             rString.Erase( nLen-nDel );
     159                 :            :         }
     160                 :            :     }
     161                 :          0 : }
     162                 :            : 
     163                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10