1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: htmlsupp.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
36 #include <tools/urlobj.hxx>
38 #define _SVSTDARR_ULONGS
39 #include <svtools/svstdarr.hxx>
42 #include <svtools/parhtml.hxx>
44 #include "htmlkywd.hxx"
48 // Tabellen zum Umwandeln von Options-Werten in Strings
50 static HTMLOptionEnum __READONLY_DATA aScriptLangOptEnums
[] =
52 { OOO_STRING_SVTOOLS_HTML_LG_starbasic
, HTML_SL_STARBASIC
},
53 { OOO_STRING_SVTOOLS_HTML_LG_javascript
, HTML_SL_JAVASCRIPT
},
54 { OOO_STRING_SVTOOLS_HTML_LG_javascript11
,HTML_SL_JAVASCRIPT
},
55 { OOO_STRING_SVTOOLS_HTML_LG_livescript
, HTML_SL_JAVASCRIPT
},
56 // { OOO_STRING_SVTOOLS_HTML_LG_unused_javascript, HTML_SL_UNUSEDJS },
57 // { OOO_STRING_SVTOOLS_HTML_LG_vbscript, HTML_SL_VBSCRIPT },
58 // { OOO_STRING_SVTOOLS_HTML_LG_starone, HTML_SL_STARONE },
62 BOOL
HTMLParser::ParseScriptOptions( String
& rLangString
, const String
& rBaseURL
,
63 HTMLScriptLanguage
& rLang
,
68 const HTMLOptions
*pScriptOptions
= GetOptions();
71 rLang
= HTML_SL_JAVASCRIPT
;
76 for( USHORT i
= pScriptOptions
->Count(); i
; )
78 const HTMLOption
*pOption
= (*pScriptOptions
)[ --i
];
79 switch( pOption
->GetToken() )
83 rLangString
= pOption
->GetString();
85 if( pOption
->GetEnum( nLang
, aScriptLangOptEnums
) )
86 rLang
= (HTMLScriptLanguage
)nLang
;
88 rLang
= HTML_SL_UNKNOWN
;
93 rSrc
= INetURLObject::GetAbsURL( rBaseURL
, pOption
->GetString() );
95 case HTML_O_SDLIBRARY
:
96 rLibrary
= pOption
->GetString();
100 rModule
= pOption
->GetString();
108 void HTMLParser::RemoveSGMLComment( String
&rString
, BOOL bFull
)
111 while( rString
.Len() &&
112 ( ' '==(c
=rString
.GetChar(0)) || '\t'==c
|| '\r'==c
|| '\n'==c
) )
113 rString
.Erase( 0, 1 );
115 while( rString
.Len() &&
116 ( ' '==(c
=rString
.GetChar( rString
.Len()-1))
117 || '\t'==c
|| '\r'==c
|| '\n'==c
) )
118 rString
.Erase( rString
.Len()-1 );
121 // SGML-Kommentare entfernen
122 if( rString
.Len() >= 4 &&
123 rString
.CompareToAscii( "<!--", 4 ) == COMPARE_EQUAL
)
128 // die gesamte Zeile !
130 while( nPos
< rString
.Len() &&
131 ( ( c
= rString
.GetChar( nPos
)) != '\r' && c
!= '\n' ) )
133 if( c
== '\r' && nPos
+1 < rString
.Len() &&
134 '\n' == rString
.GetChar( nPos
+1 ))
139 rString
.Erase( 0, ++nPos
);
142 if( rString
.Len() >=3 &&
143 rString
.Copy(rString
.Len()-3).CompareToAscii("-->")
146 rString
.Erase( rString
.Len()-3 );
149 // auch noch ein "//" oder "'" und ggf CR/LF davor
150 rString
.EraseTrailingChars();
151 xub_StrLen nDel
= 0, nLen
= rString
.Len();
153 rString
.Copy(nLen
-2).CompareToAscii("//") == COMPARE_EQUAL
)
157 else if( nLen
&& '\'' == rString
.GetChar(nLen
-1) )
161 if( nDel
&& nLen
>= nDel
+1 )
163 c
= rString
.GetChar( nLen
-(nDel
+1) );
164 if( '\r'==c
|| '\n'==c
)
167 if( '\n'==c
&& nLen
>= nDel
+1 &&
168 '\r'==rString
.GetChar( nLen
-(nDel
+1) ) )
172 rString
.Erase( nLen
-nDel
);