1*d119d52dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*d119d52dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*d119d52dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*d119d52dSAndrew Rist * distributed with this work for additional information 6*d119d52dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*d119d52dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*d119d52dSAndrew Rist * "License"); you may not use this file except in compliance 9*d119d52dSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*d119d52dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*d119d52dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*d119d52dSAndrew Rist * software distributed under the License is distributed on an 15*d119d52dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*d119d52dSAndrew Rist * KIND, either express or implied. See the License for the 17*d119d52dSAndrew Rist * specific language governing permissions and limitations 18*d119d52dSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*d119d52dSAndrew Rist *************************************************************/ 21*d119d52dSAndrew Rist 22*d119d52dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sfx2.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <tools/urlobj.hxx> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <sfx2/objsh.hxx> 30cdf0e10cSrcweir #include <sfx2/docfile.hxx> 31cdf0e10cSrcweir #include "openflag.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <svtools/htmlkywd.hxx> 34cdf0e10cSrcweir #include <svtools/htmltokn.h> 35cdf0e10cSrcweir #include <svtools/imap.hxx> 36cdf0e10cSrcweir #include <svtools/imapcirc.hxx> 37cdf0e10cSrcweir #include <svtools/imapobj.hxx> 38cdf0e10cSrcweir #include <svtools/imappoly.hxx> 39cdf0e10cSrcweir #include <svtools/imaprect.hxx> 40cdf0e10cSrcweir #ifndef _SVSTDARR_ULONGS_DECL 41cdf0e10cSrcweir #define _SVSTDARR_ULONGS 42cdf0e10cSrcweir #include <svl/svstdarr.hxx> 43cdf0e10cSrcweir #endif 44cdf0e10cSrcweir #include <svl/zforlist.hxx> 45cdf0e10cSrcweir #include <rtl/tencinfo.h> 46cdf0e10cSrcweir #include <tools/tenccvt.hxx> 47cdf0e10cSrcweir 48cdf0e10cSrcweir #include <sfx2/sfxhtml.hxx> 49cdf0e10cSrcweir 50cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyContainer.hpp> 51cdf0e10cSrcweir 52cdf0e10cSrcweir 53cdf0e10cSrcweir using namespace ::com::sun::star; 54cdf0e10cSrcweir 55cdf0e10cSrcweir 56cdf0e10cSrcweir sal_Char __FAR_DATA sHTML_MIME_text[] = "text/"; 57cdf0e10cSrcweir sal_Char __FAR_DATA sHTML_MIME_application[] = "application/"; 58cdf0e10cSrcweir sal_Char __FAR_DATA sHTML_MIME_experimental[] = "x-"; 59cdf0e10cSrcweir 60cdf0e10cSrcweir // <INPUT TYPE=xxx> 61cdf0e10cSrcweir static HTMLOptionEnum __READONLY_DATA aAreaShapeOptEnums[] = 62cdf0e10cSrcweir { 63cdf0e10cSrcweir { OOO_STRING_SVTOOLS_HTML_SH_rect, IMAP_OBJ_RECTANGLE }, 64cdf0e10cSrcweir { OOO_STRING_SVTOOLS_HTML_SH_rectangle, IMAP_OBJ_RECTANGLE }, 65cdf0e10cSrcweir { OOO_STRING_SVTOOLS_HTML_SH_circ, IMAP_OBJ_CIRCLE }, 66cdf0e10cSrcweir { OOO_STRING_SVTOOLS_HTML_SH_circle, IMAP_OBJ_CIRCLE }, 67cdf0e10cSrcweir { OOO_STRING_SVTOOLS_HTML_SH_poly, IMAP_OBJ_POLYGON }, 68cdf0e10cSrcweir { OOO_STRING_SVTOOLS_HTML_SH_polygon, IMAP_OBJ_POLYGON }, 69cdf0e10cSrcweir { 0, 0 } 70cdf0e10cSrcweir }; 71cdf0e10cSrcweir 72cdf0e10cSrcweir SfxHTMLParser::SfxHTMLParser( SvStream& rStream, sal_Bool bIsNewDoc, 73cdf0e10cSrcweir SfxMedium *pMed ) : 74cdf0e10cSrcweir HTMLParser( rStream, bIsNewDoc ), 75cdf0e10cSrcweir pMedium( pMed ), pDLMedium( 0 ), 76cdf0e10cSrcweir nMetaTags( 0 ) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir DBG_ASSERT( RTL_TEXTENCODING_DONTKNOW == GetSrcEncoding( ), 79cdf0e10cSrcweir "SfxHTMLParser::SfxHTMLParser: Wo kommt der ZS her?" ); 80cdf0e10cSrcweir DBG_ASSERT( !IsSwitchToUCS2(), 81cdf0e10cSrcweir "SfxHTMLParser::SfxHTMLParser: Switch to UCS2?" ); 82cdf0e10cSrcweir 83cdf0e10cSrcweir // Altough the real default encoding is ISO8859-1, we use MS-1252 84cdf0e10cSrcweir // als default encoding. 85cdf0e10cSrcweir SetSrcEncoding( GetExtendedCompatibilityTextEncoding( RTL_TEXTENCODING_ISO_8859_1 ) ); 86cdf0e10cSrcweir 87cdf0e10cSrcweir // If the file starts with a BOM, switch to UCS2. 88cdf0e10cSrcweir SetSwitchToUCS2( sal_True ); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir __EXPORT SfxHTMLParser::~SfxHTMLParser() 92cdf0e10cSrcweir { 93cdf0e10cSrcweir DBG_ASSERT( !pDLMedium, "Da ist ein File-Download stehengeblieben" ); 94cdf0e10cSrcweir delete pDLMedium; 95cdf0e10cSrcweir } 96cdf0e10cSrcweir 97cdf0e10cSrcweir sal_Bool SfxHTMLParser::ParseMapOptions(ImageMap * pImageMap, 98cdf0e10cSrcweir const HTMLOptions * pOptions) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir DBG_ASSERT( pImageMap, "ParseMapOptions: keine Image-Map" ); 101cdf0e10cSrcweir DBG_ASSERT( pOptions, "ParseMapOptions: keine Optionen" ); 102cdf0e10cSrcweir 103cdf0e10cSrcweir String aName; 104cdf0e10cSrcweir 105cdf0e10cSrcweir for( sal_uInt16 i=pOptions->Count(); i; ) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir const HTMLOption *pOption = (*pOptions)[--i]; 108cdf0e10cSrcweir switch( pOption->GetToken() ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir case HTML_O_NAME: 111cdf0e10cSrcweir aName = pOption->GetString(); 112cdf0e10cSrcweir break; 113cdf0e10cSrcweir } 114cdf0e10cSrcweir } 115cdf0e10cSrcweir 116cdf0e10cSrcweir if( aName.Len() ) 117cdf0e10cSrcweir pImageMap->SetName( aName ); 118cdf0e10cSrcweir 119cdf0e10cSrcweir return aName.Len() > 0; 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir sal_Bool SfxHTMLParser::ParseAreaOptions(ImageMap * pImageMap, const String& rBaseURL, 123cdf0e10cSrcweir const HTMLOptions * pOptions, 124cdf0e10cSrcweir sal_uInt16 nEventMouseOver, 125cdf0e10cSrcweir sal_uInt16 nEventMouseOut ) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir DBG_ASSERT( pImageMap, "ParseAreaOptions: keine Image-Map" ); 128cdf0e10cSrcweir DBG_ASSERT( pOptions, "ParseAreaOptions: keine Optionen" ); 129cdf0e10cSrcweir 130cdf0e10cSrcweir sal_uInt16 nShape = IMAP_OBJ_RECTANGLE; 131cdf0e10cSrcweir SvULongs aCoords; 132cdf0e10cSrcweir String aName, aHRef, aAlt, aTarget, sEmpty; 133cdf0e10cSrcweir sal_Bool bNoHRef = sal_False; 134cdf0e10cSrcweir SvxMacroTableDtor aMacroTbl; 135cdf0e10cSrcweir 136cdf0e10cSrcweir for( sal_uInt16 i=pOptions->Count(); i; ) 137cdf0e10cSrcweir { 138cdf0e10cSrcweir sal_uInt16 nEvent = 0; 139cdf0e10cSrcweir ScriptType eScrpType = STARBASIC; 140cdf0e10cSrcweir const HTMLOption *pOption = (*pOptions)[--i]; 141cdf0e10cSrcweir switch( pOption->GetToken() ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir case HTML_O_NAME: 144cdf0e10cSrcweir aName = pOption->GetString(); 145cdf0e10cSrcweir break; 146cdf0e10cSrcweir case HTML_O_SHAPE: 147cdf0e10cSrcweir pOption->GetEnum( nShape, aAreaShapeOptEnums ); 148cdf0e10cSrcweir break; 149cdf0e10cSrcweir case HTML_O_COORDS: 150cdf0e10cSrcweir pOption->GetNumbers( aCoords, sal_True ); 151cdf0e10cSrcweir break; 152cdf0e10cSrcweir case HTML_O_HREF: 153cdf0e10cSrcweir aHRef = INetURLObject::GetAbsURL( rBaseURL, pOption->GetString() ); 154cdf0e10cSrcweir break; 155cdf0e10cSrcweir case HTML_O_NOHREF: 156cdf0e10cSrcweir bNoHRef = sal_True; 157cdf0e10cSrcweir break; 158cdf0e10cSrcweir case HTML_O_ALT: 159cdf0e10cSrcweir aAlt = pOption->GetString(); 160cdf0e10cSrcweir break; 161cdf0e10cSrcweir case HTML_O_TARGET: 162cdf0e10cSrcweir aTarget = pOption->GetString(); 163cdf0e10cSrcweir break; 164cdf0e10cSrcweir 165cdf0e10cSrcweir case HTML_O_ONMOUSEOVER: 166cdf0e10cSrcweir eScrpType = JAVASCRIPT; 167cdf0e10cSrcweir case HTML_O_SDONMOUSEOVER: 168cdf0e10cSrcweir nEvent = nEventMouseOver; 169cdf0e10cSrcweir goto IMAPOBJ_SETEVENT; 170cdf0e10cSrcweir 171cdf0e10cSrcweir case HTML_O_ONMOUSEOUT: 172cdf0e10cSrcweir eScrpType = JAVASCRIPT; 173cdf0e10cSrcweir case HTML_O_SDONMOUSEOUT: 174cdf0e10cSrcweir nEvent = nEventMouseOut; 175cdf0e10cSrcweir goto IMAPOBJ_SETEVENT; 176cdf0e10cSrcweir IMAPOBJ_SETEVENT: 177cdf0e10cSrcweir if( nEvent ) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir String sTmp( pOption->GetString() ); 180cdf0e10cSrcweir if( sTmp.Len() ) 181cdf0e10cSrcweir { 182cdf0e10cSrcweir sTmp.ConvertLineEnd(); 183cdf0e10cSrcweir aMacroTbl.Insert( nEvent, 184cdf0e10cSrcweir new SvxMacro( sTmp, sEmpty, eScrpType )); 185cdf0e10cSrcweir } 186cdf0e10cSrcweir } 187cdf0e10cSrcweir break; 188cdf0e10cSrcweir } 189cdf0e10cSrcweir } 190cdf0e10cSrcweir 191cdf0e10cSrcweir if( bNoHRef ) 192cdf0e10cSrcweir aHRef.Erase(); 193cdf0e10cSrcweir 194cdf0e10cSrcweir sal_Bool bNewArea = sal_True; 195cdf0e10cSrcweir switch( nShape ) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir case IMAP_OBJ_RECTANGLE: 198cdf0e10cSrcweir if( aCoords.Count() >=4 ) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir Rectangle aRec( aCoords[0], aCoords[1], 201cdf0e10cSrcweir aCoords[2], aCoords[3] ); 202cdf0e10cSrcweir IMapRectangleObject aMapRObj( aRec, aHRef, aAlt, String(), aTarget, aName, 203cdf0e10cSrcweir !bNoHRef ); 204cdf0e10cSrcweir if( aMacroTbl.Count() ) 205cdf0e10cSrcweir aMapRObj.SetMacroTable( aMacroTbl ); 206cdf0e10cSrcweir pImageMap->InsertIMapObject( aMapRObj ); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir break; 209cdf0e10cSrcweir case IMAP_OBJ_CIRCLE: 210cdf0e10cSrcweir if( aCoords.Count() >=3 ) 211cdf0e10cSrcweir { 212cdf0e10cSrcweir Point aPoint( aCoords[0], aCoords[1] ); 213cdf0e10cSrcweir IMapCircleObject aMapCObj( aPoint, aCoords[2],aHRef, aAlt, String(), 214cdf0e10cSrcweir aTarget, aName, !bNoHRef ); 215cdf0e10cSrcweir if( aMacroTbl.Count() ) 216cdf0e10cSrcweir aMapCObj.SetMacroTable( aMacroTbl ); 217cdf0e10cSrcweir pImageMap->InsertIMapObject( aMapCObj ); 218cdf0e10cSrcweir } 219cdf0e10cSrcweir break; 220cdf0e10cSrcweir case IMAP_OBJ_POLYGON: 221cdf0e10cSrcweir if( aCoords.Count() >=6 ) 222cdf0e10cSrcweir { 223cdf0e10cSrcweir sal_uInt16 nCount = aCoords.Count() / 2; 224cdf0e10cSrcweir Polygon aPoly( nCount ); 225cdf0e10cSrcweir for( sal_uInt16 i=0; i<nCount; i++ ) 226cdf0e10cSrcweir aPoly[i] = Point( aCoords[2*i], aCoords[2*i+1] ); 227cdf0e10cSrcweir IMapPolygonObject aMapPObj( aPoly, aHRef, aAlt, String(), aTarget, aName, 228cdf0e10cSrcweir !bNoHRef ); 229cdf0e10cSrcweir if( aMacroTbl.Count() ) 230cdf0e10cSrcweir aMapPObj.SetMacroTable( aMacroTbl ); 231cdf0e10cSrcweir pImageMap->InsertIMapObject( aMapPObj ); 232cdf0e10cSrcweir } 233cdf0e10cSrcweir break; 234cdf0e10cSrcweir default: 235cdf0e10cSrcweir bNewArea = sal_False; 236cdf0e10cSrcweir } 237cdf0e10cSrcweir 238cdf0e10cSrcweir return bNewArea; 239cdf0e10cSrcweir } 240cdf0e10cSrcweir 241cdf0e10cSrcweir 242cdf0e10cSrcweir void SfxHTMLParser::StartFileDownload( const String& rURL, int nToken, 243cdf0e10cSrcweir SfxObjectShell *pSh ) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir DBG_ASSERT( !pDLMedium, "StartFileDwonload bei aktivem Download" ); 246cdf0e10cSrcweir if( pDLMedium ) 247cdf0e10cSrcweir return; 248cdf0e10cSrcweir 249cdf0e10cSrcweir pDLMedium = new SfxMedium( rURL, SFX_STREAM_READONLY, sal_False ); 250cdf0e10cSrcweir if( pSh ) 251cdf0e10cSrcweir { 252cdf0e10cSrcweir // Medium registrieren, damit abgebrochen werden kann 253cdf0e10cSrcweir pSh->RegisterTransfer( *pDLMedium ); 254cdf0e10cSrcweir 255cdf0e10cSrcweir // Target-Frame uebertragen, damit auch javascript:-URLs 256cdf0e10cSrcweir // "geladen" werden koennen. 257cdf0e10cSrcweir //const SfxMedium *pShMedium = pSh->GetMedium(); 258cdf0e10cSrcweir //if( pShMedium ) 259cdf0e10cSrcweir // pDLMedium->SetLoadTargetFrame( pShMedium->GetLoadTargetFrame() ); 260cdf0e10cSrcweir } 261cdf0e10cSrcweir 262cdf0e10cSrcweir // Download anstossen (Achtung: Kann auch synchron sein). 263cdf0e10cSrcweir if ( sal_True /*pMedium->GetDoneLink() == Link()*/ ) 264cdf0e10cSrcweir pDLMedium->DownLoad(); 265cdf0e10cSrcweir else 266cdf0e10cSrcweir { 267cdf0e10cSrcweir // Downloading-Flag auf sal_True setzen. Es werden dann auch 268cdf0e10cSrcweir // Data-Available-Links, wenn wir in den Pending-Staus gelangen. 269cdf0e10cSrcweir SetDownloadingFile( sal_True ); 270cdf0e10cSrcweir pDLMedium->DownLoad( STATIC_LINK( this, SfxHTMLParser, FileDownloadDone ) ); 271cdf0e10cSrcweir 272cdf0e10cSrcweir // Wenn das Dowsnloading-Flag noch gesetzt ist erfolgt der Download 273cdf0e10cSrcweir // asynchron. Wir gehen dann in den Pedning-Staus und warten dort. 274cdf0e10cSrcweir // Solange sind alle Aufrufe des Data-Avaialble-Link gesperrt. 275cdf0e10cSrcweir if( IsDownloadingFile() ) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir // Den aktuellen Zustand einfrieren und in den Pending-Status gehen. 278cdf0e10cSrcweir // Wenn der Download beendet oder abgebrochen wurde, wird ueber 279cdf0e10cSrcweir // NewDataRead ein Continue mit dem uebergeben Token angesteossen. 280cdf0e10cSrcweir SaveState( nToken ); 281cdf0e10cSrcweir eState = SVPAR_PENDING; 282cdf0e10cSrcweir } 283cdf0e10cSrcweir } 284cdf0e10cSrcweir } 285cdf0e10cSrcweir 286cdf0e10cSrcweir sal_Bool SfxHTMLParser::GetFileDownloadMIME( String& rMIME ) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir return pDLMedium && pDLMedium->GetErrorCode()==0 && 289cdf0e10cSrcweir pDLMedium->GetMIMEAndRedirect(rMIME)==0; 290cdf0e10cSrcweir } 291cdf0e10cSrcweir 292cdf0e10cSrcweir sal_Bool SfxHTMLParser::FinishFileDownload( String& rStr ) 293cdf0e10cSrcweir { 294cdf0e10cSrcweir String aStr; 295cdf0e10cSrcweir 296cdf0e10cSrcweir sal_Bool bOK = pDLMedium && pDLMedium->GetErrorCode()==0; 297cdf0e10cSrcweir if( bOK ) 298cdf0e10cSrcweir { 299cdf0e10cSrcweir SvStream* pStream = pDLMedium->GetInStream(); 300cdf0e10cSrcweir DBG_ASSERT( pStream, "Kein In-Stream vom Medium erhalten" ); 301cdf0e10cSrcweir 302cdf0e10cSrcweir SvMemoryStream aStream; 303cdf0e10cSrcweir if( pStream ) // HACK wegen #65563# 304cdf0e10cSrcweir aStream << *pStream; 305cdf0e10cSrcweir 306cdf0e10cSrcweir aStream.Seek( STREAM_SEEK_TO_END ); 307cdf0e10cSrcweir DBG_ASSERT( aStream.Tell() < STRING_MAXLEN, 308cdf0e10cSrcweir "File zu lang fuer einen String, Ende abgeschnitten" ); 309cdf0e10cSrcweir xub_StrLen nLen = aStream.Tell() < STRING_MAXLEN 310cdf0e10cSrcweir ? (xub_StrLen)aStream.Tell() 311cdf0e10cSrcweir : STRING_MAXLEN; 312cdf0e10cSrcweir 313cdf0e10cSrcweir // TODO: untested!!! 314cdf0e10cSrcweir rtl_TextEncoding eEnc = 315cdf0e10cSrcweir GetExtendedCompatibilityTextEncoding( RTL_TEXTENCODING_ISO_8859_1 ); 316cdf0e10cSrcweir String sMime; 317cdf0e10cSrcweir if( pDLMedium->GetMIMEAndRedirect( sMime ) == 0 ) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir rtl_TextEncoding eMimeEnc = GetEncodingByMIME( sMime ); 320cdf0e10cSrcweir if( RTL_TEXTENCODING_DONTKNOW != eMimeEnc ) 321cdf0e10cSrcweir eEnc = eMimeEnc; 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir ByteString sBuffer; 325cdf0e10cSrcweir sal_Char* pBuffer = sBuffer.AllocBuffer(nLen); 326cdf0e10cSrcweir aStream.Seek( 0 ); 327cdf0e10cSrcweir aStream.Read((void*)pBuffer, nLen); 328cdf0e10cSrcweir rStr = String( S2U(pBuffer) ); 329cdf0e10cSrcweir } 330cdf0e10cSrcweir 331cdf0e10cSrcweir delete pDLMedium; 332cdf0e10cSrcweir pDLMedium = 0; 333cdf0e10cSrcweir 334cdf0e10cSrcweir return bOK; 335cdf0e10cSrcweir } 336cdf0e10cSrcweir 337cdf0e10cSrcweir IMPL_STATIC_LINK( SfxHTMLParser, FileDownloadDone, void*, EMPTYARG ) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir // Der Download ist jetzt abgeschlossen. Ausserdem muss/darf der 340cdf0e10cSrcweir // Data-Available-Link wieder durchgelassen werden. 341cdf0e10cSrcweir pThis->SetDownloadingFile( sal_False ); 342cdf0e10cSrcweir 343cdf0e10cSrcweir // ... und einmal aufrufen, damit weitergelesen wird. 344cdf0e10cSrcweir pThis->CallAsyncCallLink(); 345cdf0e10cSrcweir 346cdf0e10cSrcweir return 0; 347cdf0e10cSrcweir } 348cdf0e10cSrcweir 349cdf0e10cSrcweir void SfxHTMLParser::GetScriptType_Impl( SvKeyValueIterator *pHTTPHeader ) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir aScriptType = DEFINE_CONST_UNICODE(SVX_MACRO_LANGUAGE_JAVASCRIPT); 352cdf0e10cSrcweir eScriptType = JAVASCRIPT; 353cdf0e10cSrcweir if( pHTTPHeader ) 354cdf0e10cSrcweir { 355cdf0e10cSrcweir SvKeyValue aKV; 356cdf0e10cSrcweir for( sal_Bool bCont = pHTTPHeader->GetFirst( aKV ); bCont; 357cdf0e10cSrcweir bCont = pHTTPHeader->GetNext( aKV ) ) 358cdf0e10cSrcweir { 359cdf0e10cSrcweir if( aKV.GetKey().EqualsIgnoreCaseAscii( 360cdf0e10cSrcweir OOO_STRING_SVTOOLS_HTML_META_content_script_type ) ) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir if( aKV.GetValue().Len() ) 363cdf0e10cSrcweir { 364cdf0e10cSrcweir String aTmp( aKV.GetValue() ); 365cdf0e10cSrcweir if( aTmp.EqualsIgnoreCaseAscii( sHTML_MIME_text, 0, 5 ) ) 366cdf0e10cSrcweir aTmp.Erase( 0, 5 ); 367cdf0e10cSrcweir else if( aTmp.EqualsIgnoreCaseAscii( sHTML_MIME_application, 368cdf0e10cSrcweir 0, 12 ) ) 369cdf0e10cSrcweir aTmp.Erase( 0, 12 ); 370cdf0e10cSrcweir else 371cdf0e10cSrcweir break; 372cdf0e10cSrcweir 373cdf0e10cSrcweir if( aTmp.EqualsIgnoreCaseAscii( sHTML_MIME_experimental, 0, 374cdf0e10cSrcweir 2 ) ) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir aTmp.Erase( 0, 2 ); 377cdf0e10cSrcweir } 378cdf0e10cSrcweir 379cdf0e10cSrcweir if( aTmp.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_LG_starbasic ) ) 380cdf0e10cSrcweir { 381cdf0e10cSrcweir eScriptType = STARBASIC; 382cdf0e10cSrcweir aScriptType = DEFINE_CONST_UNICODE(SVX_MACRO_LANGUAGE_STARBASIC); 383cdf0e10cSrcweir } 384cdf0e10cSrcweir if( !aTmp.EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_LG_javascript ) ) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir eScriptType = EXTENDED_STYPE; 387cdf0e10cSrcweir aScriptType = aTmp; 388cdf0e10cSrcweir } 389cdf0e10cSrcweir } 390cdf0e10cSrcweir break; 391cdf0e10cSrcweir } 392cdf0e10cSrcweir } 393cdf0e10cSrcweir } 394cdf0e10cSrcweir } 395cdf0e10cSrcweir 396cdf0e10cSrcweir ScriptType SfxHTMLParser::GetScriptType( SvKeyValueIterator *pHTTPHeader ) const 397cdf0e10cSrcweir { 398cdf0e10cSrcweir if( !aScriptType.Len() ) 399cdf0e10cSrcweir ((SfxHTMLParser *)this)->GetScriptType_Impl( pHTTPHeader ); 400cdf0e10cSrcweir 401cdf0e10cSrcweir return eScriptType; 402cdf0e10cSrcweir } 403cdf0e10cSrcweir 404cdf0e10cSrcweir const String& SfxHTMLParser::GetScriptTypeString( 405cdf0e10cSrcweir SvKeyValueIterator *pHTTPHeader ) const 406cdf0e10cSrcweir { 407cdf0e10cSrcweir if( !aScriptType.Len() ) 408cdf0e10cSrcweir ((SfxHTMLParser *)this)->GetScriptType_Impl( pHTTPHeader ); 409cdf0e10cSrcweir 410cdf0e10cSrcweir return aScriptType; 411cdf0e10cSrcweir } 412cdf0e10cSrcweir 413cdf0e10cSrcweir double SfxHTMLParser::GetTableDataOptionsValNum( sal_uInt32& nNumForm, 414cdf0e10cSrcweir LanguageType& eNumLang, const String& aValStr, const String& aNumStr, 415cdf0e10cSrcweir SvNumberFormatter& rFormatter ) 416cdf0e10cSrcweir { 417cdf0e10cSrcweir LanguageType eParseLang = (LanguageType )aNumStr.ToInt32(); 418cdf0e10cSrcweir sal_uInt32 nParseForm = 419cdf0e10cSrcweir rFormatter.GetFormatForLanguageIfBuiltIn( 0, eParseLang ); 420cdf0e10cSrcweir double fVal; 421cdf0e10cSrcweir rFormatter.IsNumberFormat( aValStr, nParseForm, fVal ); 422cdf0e10cSrcweir if ( aNumStr.GetTokenCount( ';' ) > 2 ) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir eNumLang = (LanguageType)aNumStr.GetToken( 1, ';' ).ToInt32(); 425cdf0e10cSrcweir xub_StrLen nPos = aNumStr.Search( ';' ); 426cdf0e10cSrcweir nPos = aNumStr.Search( ';', nPos + 1 ); 427cdf0e10cSrcweir String aFormat( aNumStr.Copy( nPos + 1 ) ); 428cdf0e10cSrcweir xub_StrLen nCheckPos; 429cdf0e10cSrcweir short nType; 430cdf0e10cSrcweir if ( eNumLang != LANGUAGE_SYSTEM ) 431cdf0e10cSrcweir rFormatter.PutEntry( aFormat, nCheckPos, nType, nNumForm, eNumLang ); 432cdf0e10cSrcweir else 433cdf0e10cSrcweir rFormatter.PutandConvertEntry( aFormat, nCheckPos, nType, nNumForm, 434cdf0e10cSrcweir eParseLang, eNumLang ); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir else 437cdf0e10cSrcweir { 438cdf0e10cSrcweir eNumLang = LANGUAGE_SYSTEM; 439cdf0e10cSrcweir nNumForm = rFormatter.GetFormatForLanguageIfBuiltIn( 0, eNumLang ); 440cdf0e10cSrcweir } 441cdf0e10cSrcweir return fVal; 442cdf0e10cSrcweir } 443cdf0e10cSrcweir 444