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

Generated by: LCOV version 1.10