2000-09-18 16:07:07 +00:00
|
|
|
|
/*************************************************************************
|
|
|
|
|
*
|
2008-04-10 21:03:27 +00:00
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:07:07 +00:00
|
|
|
|
*
|
2008-04-10 21:03:27 +00:00
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
|
*
|
2008-04-10 21:03:27 +00:00
|
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
|
*
|
2008-04-10 21:03:27 +00:00
|
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
|
*
|
2008-04-10 21:03:27 +00:00
|
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:07:07 +00:00
|
|
|
|
*
|
2008-04-10 21:03:27 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:07:07 +00:00
|
|
|
|
*
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
2006-09-17 14:26:47 +00:00
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
|
#include "precompiled_svtools.hxx"
|
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
|
#ifndef _SVSTDARR_HXX
|
|
|
|
|
#define _SVSTDARR_ULONGS
|
2009-10-16 00:05:16 +02:00
|
|
|
|
#include <svl/svstdarr.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2007-06-27 21:00:38 +00:00
|
|
|
|
#include <svtools/parhtml.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
#include "htmltokn.h"
|
|
|
|
|
#include "htmlkywd.hxx"
|
|
|
|
|
|
|
|
|
|
/* */
|
|
|
|
|
|
|
|
|
|
// Tabellen zum Umwandeln von Options-Werten in Strings
|
|
|
|
|
|
|
|
|
|
static HTMLOptionEnum __READONLY_DATA aScriptLangOptEnums[] =
|
|
|
|
|
{
|
2009-04-27 11:24:10 +00:00
|
|
|
|
{ OOO_STRING_SVTOOLS_HTML_LG_starbasic, HTML_SL_STARBASIC },
|
|
|
|
|
{ OOO_STRING_SVTOOLS_HTML_LG_javascript, HTML_SL_JAVASCRIPT },
|
|
|
|
|
{ OOO_STRING_SVTOOLS_HTML_LG_javascript11,HTML_SL_JAVASCRIPT },
|
|
|
|
|
{ OOO_STRING_SVTOOLS_HTML_LG_livescript, HTML_SL_JAVASCRIPT },
|
|
|
|
|
// { OOO_STRING_SVTOOLS_HTML_LG_unused_javascript, HTML_SL_UNUSEDJS },
|
|
|
|
|
// { OOO_STRING_SVTOOLS_HTML_LG_vbscript, HTML_SL_VBSCRIPT },
|
|
|
|
|
// { OOO_STRING_SVTOOLS_HTML_LG_starone, HTML_SL_STARONE },
|
2000-09-18 16:07:07 +00:00
|
|
|
|
{ 0, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
2005-01-11 12:13:16 +00:00
|
|
|
|
BOOL HTMLParser::ParseScriptOptions( String& rLangString, const String& rBaseURL,
|
2000-09-18 16:07:07 +00:00
|
|
|
|
HTMLScriptLanguage& rLang,
|
|
|
|
|
String& rSrc,
|
|
|
|
|
String& rLibrary,
|
|
|
|
|
String& rModule )
|
|
|
|
|
{
|
2006-06-19 20:26:03 +00:00
|
|
|
|
const HTMLOptions *pScriptOptions = GetOptions();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
|
rLangString.Erase();
|
|
|
|
|
rLang = HTML_SL_JAVASCRIPT;
|
|
|
|
|
rSrc.Erase();
|
|
|
|
|
rLibrary.Erase();
|
|
|
|
|
rModule.Erase();
|
|
|
|
|
|
2006-06-19 20:26:03 +00:00
|
|
|
|
for( USHORT i = pScriptOptions->Count(); i; )
|
2000-09-18 16:07:07 +00:00
|
|
|
|
{
|
2006-06-19 20:26:03 +00:00
|
|
|
|
const HTMLOption *pOption = (*pScriptOptions)[ --i ];
|
2000-09-18 16:07:07 +00:00
|
|
|
|
switch( pOption->GetToken() )
|
|
|
|
|
{
|
|
|
|
|
case HTML_O_LANGUAGE:
|
|
|
|
|
{
|
|
|
|
|
rLangString = pOption->GetString();
|
|
|
|
|
USHORT nLang;
|
|
|
|
|
if( pOption->GetEnum( nLang, aScriptLangOptEnums ) )
|
|
|
|
|
rLang = (HTMLScriptLanguage)nLang;
|
|
|
|
|
else
|
|
|
|
|
rLang = HTML_SL_UNKNOWN;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case HTML_O_SRC:
|
2005-01-11 12:13:16 +00:00
|
|
|
|
rSrc = INetURLObject::GetAbsURL( rBaseURL, pOption->GetString() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
break;
|
|
|
|
|
case HTML_O_SDLIBRARY:
|
|
|
|
|
rLibrary = pOption->GetString();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case HTML_O_SDMODULE:
|
|
|
|
|
rModule = pOption->GetString();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HTMLParser::RemoveSGMLComment( String &rString, BOOL bFull )
|
|
|
|
|
{
|
2004-06-16 09:29:57 +00:00
|
|
|
|
sal_Unicode c = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
while( rString.Len() &&
|
2006-10-12 14:27:55 +00:00
|
|
|
|
( ' '==(c=rString.GetChar(0)) || '\t'==c || '\r'==c || '\n'==c ) )
|
|
|
|
|
rString.Erase( 0, 1 );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
|
while( rString.Len() &&
|
2006-10-12 14:27:55 +00:00
|
|
|
|
( ' '==(c=rString.GetChar( rString.Len()-1))
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|| '\t'==c || '\r'==c || '\n'==c ) )
|
2006-10-12 14:27:55 +00:00
|
|
|
|
rString.Erase( rString.Len()-1 );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SGML-Kommentare entfernen
|
2006-10-12 14:27:55 +00:00
|
|
|
|
if( rString.Len() >= 4 &&
|
|
|
|
|
rString.CompareToAscii( "<!--", 4 ) == COMPARE_EQUAL )
|
2000-09-18 16:07:07 +00:00
|
|
|
|
{
|
2006-10-12 14:27:55 +00:00
|
|
|
|
xub_StrLen nPos = 3;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
if( bFull )
|
|
|
|
|
{
|
|
|
|
|
// die gesamte Zeile !
|
2006-10-12 14:27:55 +00:00
|
|
|
|
nPos = 4;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
while( nPos < rString.Len() &&
|
|
|
|
|
( ( c = rString.GetChar( nPos )) != '\r' && c != '\n' ) )
|
|
|
|
|
++nPos;
|
2006-10-12 14:27:55 +00:00
|
|
|
|
if( c == '\r' && nPos+1 < rString.Len() &&
|
|
|
|
|
'\n' == rString.GetChar( nPos+1 ))
|
2000-09-18 16:07:07 +00:00
|
|
|
|
++nPos;
|
|
|
|
|
else if( c != '\n' )
|
2006-10-12 14:27:55 +00:00
|
|
|
|
nPos = 3;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
}
|
2006-10-12 14:27:55 +00:00
|
|
|
|
rString.Erase( 0, ++nPos );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-10-12 14:27:55 +00:00
|
|
|
|
if( rString.Len() >=3 &&
|
|
|
|
|
rString.Copy(rString.Len()-3).CompareToAscii("-->")
|
2000-09-18 16:07:07 +00:00
|
|
|
|
== COMPARE_EQUAL )
|
|
|
|
|
{
|
2006-10-12 14:27:55 +00:00
|
|
|
|
rString.Erase( rString.Len()-3 );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
if( bFull )
|
|
|
|
|
{
|
|
|
|
|
// auch noch ein "//" oder "'" und ggf CR/LF davor
|
|
|
|
|
rString.EraseTrailingChars();
|
2006-10-12 14:27:55 +00:00
|
|
|
|
xub_StrLen nDel = 0, nLen = rString.Len();
|
|
|
|
|
if( nLen >= 2 &&
|
|
|
|
|
rString.Copy(nLen-2).CompareToAscii("//") == COMPARE_EQUAL )
|
2000-09-18 16:07:07 +00:00
|
|
|
|
{
|
2006-10-12 14:27:55 +00:00
|
|
|
|
nDel = 2;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
}
|
2006-10-12 14:27:55 +00:00
|
|
|
|
else if( nLen && '\'' == rString.GetChar(nLen-1) )
|
2000-09-18 16:07:07 +00:00
|
|
|
|
{
|
2006-10-12 14:27:55 +00:00
|
|
|
|
nDel = 1;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
}
|
2006-10-12 14:27:55 +00:00
|
|
|
|
if( nDel && nLen >= nDel+1 )
|
2000-09-18 16:07:07 +00:00
|
|
|
|
{
|
2006-10-12 14:27:55 +00:00
|
|
|
|
c = rString.GetChar( nLen-(nDel+1) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
if( '\r'==c || '\n'==c )
|
|
|
|
|
{
|
|
|
|
|
nDel++;
|
2006-10-12 14:27:55 +00:00
|
|
|
|
if( '\n'==c && nLen >= nDel+1 &&
|
|
|
|
|
'\r'==rString.GetChar( nLen-(nDel+1) ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
|
nDel++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
rString.Erase( nLen-nDel );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|