#include <htmlfltr.h>
Public Member Functions | |
HTMLFilter () | |
Constructor. Initialises member variables and load ressources. | |
~HTMLFilter () | |
Destructor. Frees memory and cleans up. | |
INT32 | Init () |
Initialisation of the filter. | |
virtual BOOL | PreHowCompatible () |
Allows a filter or set of filters to take some action or set up variables before being called by HowCompatible. A group of filters which share common code may require some variable set up before being asked to check the type. Base class does nothing and so works for all filters which do not require it. | |
virtual INT32 | HowCompatible (PathName &Filename, ADDR HeaderStart, UINT32 HeaderSize, UINT32 FileSize) |
check whether the file is HTML or not I've considered that the file is HTML as soon as there is one HTML tags. | |
virtual BOOL | DoImport (SelOperation *, CCLexFile *, Document *, BOOL AutoChosen=FALSE, ImportPosition *Pos=NULL, KernelBitmap **ppImportedBitmap=NULL, DocCoord *pPosTranslate=NULL, String_256 *URL=NULL) |
BOOL | ScanListAndImport (HTMLFileList *HTMLList, String_256 *Address, Document *DestDoc, SelOperation *Op, PathName pthImportFile) |
scan the list and call DoImportBitmap() | |
BOOL | ParseHTMLFile (CCLexFile *pFile, HTMLFileList *HTMLList) |
Parse the html file then create the list of bitmaps and finally call ImportBitmap. | |
BOOL | GetTag (TCHAR *, TCHAR *, const TCHAR *TokenBuffer) |
extract the TAGNAME from the tokenbuf (e.g.: will extract 'img' from 'img src=image.gif') | |
BOOL | GetAttribute (const TCHAR *AttrName, const TCHAR *, TCHAR *) |
Extract the attribute from the tag. | |
TCHAR * | SearchStr (const char *A, const char *B) |
Search for string B in string A. | |
virtual BOOL | IsDefaultDocRequired (const TCHAR *pcszPathName) |
virtual BOOL | DoExport (Operation *, CCLexFile *, PathName *, Document *, BOOL) |
Static Public Member Functions | |
static BOOL | DoImportBitmap (INT32 TagId, SelOperation *Op, Document *DestDoc, PathName Path, INT32 FileNum, INT32 FileNumber, DocCoord &PosTranslate, BOOL IsCentre, String_256 *NewName) |
how to import (bitmap background or formatting bitmap) | |
static BOOL | ImportBitmap (SelOperation *Op, PathName &Path, KernelBitmap **ppImportedBitmap, DocCoord *pPosTranslate, INT32 FileNum, INT32 FileNumber, String_256 *NewName) |
Static Public Attributes | |
static BOOL | ImportingHTML = FALSE |
Protected Member Functions | |
DocCoord | GetImportPosition (Document *pdocTarget, INT32 iPosNum) |
Finds the offset by which to offset the iPosNumber-th bitmap imported. | |
Protected Attributes | |
String_256 | m_WarningsString |
Definition at line 121 of file htmlfltr.h.
|
Constructor. Initialises member variables and load ressources.
Definition at line 229 of file htmlfltr.cpp. 00230 { 00231 // Set up filter descriptions. 00232 FilterName.Load(_R(IDS_FILTERNAME_HTML)); 00233 FilterInfo.Load(_R(IDS_FILTERINFO_HTML)); 00234 FilterID = FILTERID_HTML; 00235 00236 #ifndef STANDALONE 00237 Flags.CanImport = TRUE; 00238 Flags.CanExport = FALSE; 00239 #else 00240 Flags.CanImport = FALSE; 00241 Flags.CanExport = FALSE; 00242 #endif 00243 00244 m_WarningsString.Empty(); 00245 }
|
|
Destructor. Frees memory and cleans up.
Definition at line 254 of file htmlfltr.cpp.
|
|
Definition at line 172 of file htmlfltr.h. 00172 { return TRUE; }
|
|
Definition at line 404 of file htmlfltr.cpp. 00406 { 00407 ERROR2IF(Op == NULL, FALSE, "HTMLFilter::DoImportNULL operation supplied"); 00408 ERROR2IF(DestDoc == NULL, FALSE, "HTMLFilter::DoImportNULL document supplied"); 00409 00410 // Blank our warnings string 00411 m_WarningsString.Empty(); 00412 00413 HTMLFileList* HTMLList = new HTMLFileList; 00414 00415 // Parse the file and add bitmap names in the list 00416 BOOL ok = ParseHTMLFile(pFile, HTMLList); 00417 00418 //Now let's get the path to the file we are importing 00419 PathName pthImport=pFile->GetPathName(); 00420 00421 if (URL == NULL) 00422 { 00423 String_256 URLTemp = ""; 00424 // import each bitmap 00425 ok = ScanListAndImport(HTMLList, &URLTemp, DestDoc, Op, pthImport); 00426 } 00427 else 00428 ok = ScanListAndImport(HTMLList, URL, DestDoc, Op, pthImport); 00429 00430 // empty the list 00431 if ( HTMLList->GetCount()) 00432 HTMLList->DeleteAll(); 00433 delete HTMLList; 00434 00435 // Now check the warning about problem data string 00436 // If it has anything in then warn the user about the problem 00437 if (ok && !m_WarningsString.IsEmpty()) 00438 { 00439 Error::SetError(0, m_WarningsString, 0); 00440 InformWarning(); 00441 } 00442 00443 // All ok 00444 return ok; 00445 }
|
|
how to import (bitmap background or formatting bitmap)
Definition at line 656 of file htmlfltr.cpp. 00659 { 00660 BOOL ok = FALSE; 00661 KernelBitmap* pKernelBitmap = NULL; 00662 00663 if (TagId == HTMLTAG_BODY) 00664 { 00665 // if it's body background then 00666 if (!ImportBitmap(Op, Path, &pKernelBitmap, NULL, FileNum+1, FileNumber, NewName)) 00667 return FALSE; 00668 00669 Spread *pSpread = NULL; 00670 PORTNOTE("spread", "Multi-spread warning!") 00671 pSpread = GetFirstSpread(DestDoc); 00672 00673 // can't be NULL 00674 if (!pSpread && !pKernelBitmap) 00675 return FALSE; 00676 00677 // call the background op 00678 OpBackground::MakePageBackground(Op, pSpread, pKernelBitmap); 00679 return TRUE; 00680 } 00681 else 00682 { 00683 //Taken out by Graham 12/6/97 00684 /*if (IsCentre) 00685 { 00686 // formatting, arbitrary position :-( 00687 PosTranslate.x = 288000; 00688 //PosTranslate.y = -(72000*0.2)*i; 00689 00690 } */ 00691 00692 //Modified by Graham 30/5/97 so it *doesn't* leak every bitmap it tries 00693 //to import! 8-) 00694 if (!ImportBitmap(Op, Path, &pKernelBitmap, &PosTranslate, FileNum+1, FileNumber, NewName)) 00695 return FALSE; 00696 00697 } 00698 00699 //And finally, set the name of the bitmap to our new name 00700 if (pKernelBitmap && NewName) 00701 pKernelBitmap->SetName(*NewName); 00702 00703 return TRUE; 00704 }
|
|
Extract the attribute from the tag.
Definition at line 1057 of file htmlfltr.cpp. 01058 { 01059 // they shouldn't be NULL 01060 if (AttrName == NULL && pTokenBuf == NULL && pTagAttrib == NULL) 01061 return FALSE; 01062 01063 // e.g. : 'img src=image.gif' 01064 // we move the pointer until 'src' 01065 const TCHAR* TokenBufTmp = pTokenBuf; 01066 TCHAR* TagAttribute = pTagAttrib; 01067 while (TRUE) 01068 { 01069 const TCHAR* AttrNameTmp = AttrName; 01070 // find the first occurence of the first letter of AttrName 01071 TokenBufTmp = strchr(TokenBufTmp, (INT32)(*AttrName)); 01072 if (TokenBufTmp == NULL) 01073 return FALSE; 01074 01075 // extract "AttrName" from TokenBuf 01076 while ( *TokenBufTmp == *AttrNameTmp && *AttrNameTmp!=NULL && *TokenBufTmp!=NULL) 01077 { 01078 TokenBufTmp++; 01079 AttrNameTmp++; 01080 } 01081 if (*TokenBufTmp == NULL) 01082 return FALSE; 01083 if (*AttrNameTmp == NULL) 01084 break; 01085 } 01086 01087 // move the pointer to reach the first letter 01088 while ( (*TokenBufTmp=='=' || *TokenBufTmp==' ' || 01089 *TokenBufTmp=='\t' || *TokenBufTmp=='\"') && 01090 *TokenBufTmp!=NULL) 01091 { 01092 TokenBufTmp++; 01093 } 01094 if (*TokenBufTmp == NULL) 01095 return FALSE; 01096 01097 // extract the attribute 01098 while ( *TokenBufTmp!='\"' && *TokenBufTmp!=' ' && *TokenBufTmp!='\t' && *TokenBufTmp!=NULL) 01099 { 01100 *(TagAttribute++) = *(TokenBufTmp++); 01101 } 01102 01103 *TagAttribute = '\0'; 01104 01105 return TRUE; 01106 }
|
|
Finds the offset by which to offset the iPosNumber-th bitmap imported.
Then the next bitmap is offset by the standard offset which the duplication operation uses. And so on: the offset of the Nth bitmap equals the offset of the (N-1)th bitmap plus the duplication offset. This carries on until the offset is such so that the offset of the Mth bitmap would place it off the spread. Instead, then, the offset of the Mth bitmap is the horizontal component of the duplication offset. And then we go back to the general iterative rule. Not very well explained I'm afraid but I've got to get this done.
Definition at line 1167 of file htmlfltr.cpp. 01168 { 01169 //First check our parameter 01170 ERROR2IF(pdocTarget==NULL, DocCoord(-1,-1), "HTMLFilter::GetFirstImportPosition - NULL parameter"); 01171 01172 //This variable will remember how many times we have returned the import position 01173 //back to the top left hand corner 01174 INT32 iReturned=0; 01175 01176 //Now get the first spread in the document 01177 PORTNOTE("spread", "Multi-spread warning!") 01178 Spread* psprFirst=pdocTarget->FindFirstSpread(); 01179 01180 //Do some checking 01181 ERROR2IF(psprFirst==NULL, DocCoord(-1, -1), "HTMLFilter::GetFirstImportPosition - no spread in document"); 01182 01183 //And get its bounding rectangle 01184 DocRect rectBounding; 01185 psprFirst->GetPagesRect(&rectBounding); 01186 01187 //Now translate that rectangle so that its top left hand corner is at 01188 //0,0 01189 DocCoord dcTopLeft(rectBounding.lo.x, rectBounding.hi.y); 01190 01191 rectBounding.Translate(-dcTopLeft.x, -dcTopLeft.y); 01192 01193 //Now, the first bitmap will be imported at 0,0 01194 DocCoord dcThisPosition(0, 0); 01195 01196 //And this is the standard duplication offset 01197 // DocCoord dcOffset(OpDuplicate::DuplicatePlacementX, OpDuplicate::DuplicatePlacementY); 01198 DocCoord dcOffset = pdocTarget->GetDuplicationOffset(); 01199 01200 01201 01202 //Do the following a number of times equal to the number 01203 //of the bitmaps we are importing 01204 for (INT32 i=0; i<iPosNumber; i++) 01205 { 01206 //Increase dcThisPosition by dcOffset 01207 dcThisPosition.x=dcThisPosition.x+dcOffset.x; 01208 dcThisPosition.y=dcThisPosition.y+dcOffset.y; 01209 01210 //Now, if that import position is outside the spread 01211 if (!rectBounding.ContainsRectCoord(dcThisPosition)) 01212 { 01213 //Then set the import position back to the top left hand corner of the 01214 //spread 01215 dcThisPosition=DocCoord(rectBounding.lo.x, rectBounding.hi.y); 01216 01217 //And increase our count of the number of times we have set the 01218 //import position back to the top left hand corner 01219 iReturned++; 01220 01221 //And offset the import position by the horizontal component 01222 //of the duplication distance, a number of times equal to 01223 //the number of times we have reset the import position 01224 dcThisPosition.x+=dcOffset.x*iReturned; 01225 01226 //Now, if *that* import position is outside the spread 01227 if (!rectBounding.ContainsRectCoord(dcThisPosition)) 01228 { 01229 //Then go back to the very first import position 01230 //and set iReturned to zero 01231 dcThisPosition=DocCoord(rectBounding.lo.x, rectBounding.hi.y); 01232 01233 iReturned=0; 01234 } 01235 } 01236 01237 } 01238 01239 //And return our calculated import position 01240 return dcThisPosition; 01241 }
|
|
extract the TAGNAME from the tokenbuf (e.g.: will extract 'img' from 'img src=image.gif')
Definition at line 1011 of file htmlfltr.cpp. 01012 { 01013 if (TokenBuffer == NULL) 01014 return FALSE; 01015 01016 // convert to lower case 01017 camStrcpy(pTokenBuf, TokenBuffer); 01018 pTokenBuf = _strlwr(pTokenBuf); 01019 01020 // all known HTML tags 01021 for (INT32 i=0;i<HTMLNUM_TAGS;i++) 01022 { 01023 const TCHAR* TokenBufTmp = pTokenBuf; 01024 *pTagName = '\0'; 01025 TCHAR* TagNameTmp = pTagName; 01026 TCHAR* HTML_Tag = HTML_Table[i].tag; 01027 01028 while(*TokenBufTmp == *HTML_Tag && *TokenBufTmp!=NULL && *HTML_Tag!=NULL) 01029 { 01030 *(TagNameTmp++) = *(TokenBufTmp++); 01031 HTML_Tag++; 01032 } 01033 if (*HTML_Tag == NULL) 01034 { 01035 *TagNameTmp = '\0'; 01036 break; 01037 } 01038 } 01039 01040 return TRUE; 01041 }
|
|
check whether the file is HTML or not I've considered that the file is HTML as soon as there is one HTML tags.
Definition at line 324 of file htmlfltr.cpp. 00325 { 00326 PORTNOTE("byteorder", "TODO: Check byte ordering") 00327 if (FileSize == 0 || pOILFilter == NULL) 00328 return 0; 00329 00330 INT32 IsCompatible = 0; 00331 INT32 MaxCompatible = 0; 00332 00333 // If this file doesn't have the right extension, then claim with a value lower than 10. 00334 // If we don't check the extension, this function will return 10 if it finds any HTML tag ID 00335 // within the buffer, even if the string is not contained within "<>" 00336 // 00337 // The header could be the text part on an EPS file (e.g. v1.1 native file format), so without 00338 // the extension match, this filter may try and import it, instead of leaving it to the EPS filter. 00339 // 00340 // Really, this function should be vamped up so that it spots real HTML tags, rather than just the tag ID 00341 // string. (Markn & Neville 7/8/97) 00342 // Reduced the 6 to 4 as most EPS filters return 5 if the %!Adobe is at the start of the file 00343 // Neville 27/10/97 00344 if (pOILFilter->DoesExtensionOfPathNameMatch(&Filename)) 00345 MaxCompatible = 10; 00346 else 00347 MaxCompatible = 4; 00348 00349 // Convert to lower case 00350 // CAN NOT do this on the main buffer as this would screw up all filters in the 00351 // chain below us. So take a copy of the buffer and then lower case that 00352 char * CopyFilterBuf = (char *) CCMalloc(HeaderSize); 00353 if (CopyFilterBuf == NULL) 00354 return 0; 00355 00356 // Take a copy of the buffer 00357 memcpy(CopyFilterBuf, HeaderStart, HeaderSize); 00358 // and now finally, lower case it 00359 CopyFilterBuf = _strlwr(CopyFilterBuf); 00360 00361 // all known HTML tags 00362 for (INT32 i=0;i<HTMLNUM_TAGS;i++) 00363 { 00364 /* TCHAR* Tag = new TCHAR[camStrlen(HTML_Table[i].tag)+3]; 00365 *Tag = '\0'; 00366 camStrcat(Tag, "<"); 00367 camStrcat(Tag, HTML_Table[i].tag); 00368 */ 00369 00370 // is there an occurence of the string 'HTML_Table[i].tag' in the string 'HeaderStart' 00371 if ( SearchStr(CopyFilterBuf, HTML_Table[i].tag) != NULL ) 00372 { 00373 IsCompatible = MaxCompatible; 00374 // delete [] Tag; 00375 break; 00376 00377 } 00378 // delete [] Tag; 00379 } 00380 00381 CCFree(CopyFilterBuf); 00382 00383 return IsCompatible; 00384 }
|
|
Definition at line 899 of file htmlfltr.cpp. 00901 { 00902 BOOL ok = FALSE; 00903 00904 if (!SGLibOil::FileExists(&Path)) 00905 return FALSE; 00906 00907 // which filter to use ? 00908 Filter *pFilter = Filter::GetFirst(); 00909 while (pFilter != NULL) 00910 { 00911 // what kind of bitmap is it ? 00912 UINT32 Size = 1024; 00913 INT32 FileSize; 00914 ADDR FilterBuf = pFilter->LoadInitialSegment(Path, &Size, &FileSize); 00915 00916 // If there has been a problem in the load initial segment then fail now. 00917 if (FilterBuf == NULL) 00918 { 00919 ok = FALSE; 00920 break; 00921 } 00922 00923 // Inform any filters that we are about to do a HowCompatible call. 00924 // This would allow a set of filters which have common functionality hidden in a 00925 // filter that cannot import and cannot export handle this call and hence set 00926 // itself up. This would allow it to maybe cache a result which should only be 00927 // checked by the first filter in the group. 00928 pFilter->PreHowCompatible(); 00929 00930 // Change this to be less than 8 as the filters like the Accusoft forms return 00931 // 8 and 9 to make sure that they are last in the chain. 00932 if (pFilter->HowCompatible(Path, FilterBuf, Size, FileSize) > 8) 00933 { 00934 ok = TRUE; 00935 CCFree(FilterBuf); 00936 // This is the filter! 00937 break; 00938 } 00939 00940 //Free the initial segment 00941 CCFree(FilterBuf); 00942 00943 // Try the next filter 00944 pFilter = Filter::GetNext(pFilter); 00945 } 00946 00947 // filter found ? 00948 if (pFilter == NULL || !ok) 00949 return FALSE; // no filter found 00950 00951 // now import bitmap 00952 00953 // First off, we have to try and open the file 00954 CCDiskFile DiskFile(1024, FALSE, TRUE); 00955 00956 // Get pointer to current doc 'cos we'll need it several times... 00957 Document* pCurDoc = Document::GetCurrent(); 00958 00959 // open the file 00960 if (!DiskFile.open(Path, ios::in | ios::binary)) 00961 return FALSE; 00962 00963 //Graham 15/7/97: Now, we want to import into the top left hand corner of the view 00964 DocView* pDocView=DocView::GetCurrent(); 00965 00966 ERROR2IF(pDocView==NULL, FALSE, "HTMLFilter::DoImport - no current view"); 00967 00968 ImportPosition posImport=pDocView->GetCentreImportPosition(); 00969 00970 //And add on the amount by which to translate the bitmap 00971 if (pPosTranslate) 00972 { 00973 posImport.Position.x+=pPosTranslate->x; 00974 posImport.Position.y+=pPosTranslate->y; 00975 } 00976 00977 // then import the file 00978 if (!pFilter->DoImport(Op, &DiskFile, pCurDoc, FALSE, NULL, ppImportedBitmap, pPosTranslate, NULL)) 00979 { 00980 // Close the file again 00981 if (DiskFile.isOpen()) 00982 DiskFile.close(); 00983 00984 Error::ClearError(); // remove the error so it won't get reported 00985 00986 return FALSE; 00987 } 00988 00989 // Close the file again 00990 if (DiskFile.isOpen()) 00991 DiskFile.close(); 00992 00993 return TRUE; 00994 }
|
|
Initialisation of the filter.
Definition at line 271 of file htmlfltr.cpp. 00272 { 00273 // allocate memory for member variables 00274 //if (!Init1()) 00275 // return FALSE; 00276 00277 // Get the OILFilter object 00278 pOILFilter = new HTMLOILFilter(this); 00279 if (pOILFilter == NULL) 00280 return FALSE; 00281 00282 // init the Bitmap download operation 00283 if(!OpBitmapDownload::Init()) 00284 return FALSE; 00285 00286 // All ok 00287 return TRUE; 00288 }
|
|
Definition at line 169 of file htmlfltr.h. 00169 { return TRUE; }
|
|
Parse the html file then create the list of bitmaps and finally call ImportBitmap.
Definition at line 724 of file htmlfltr.cpp. 00725 { 00726 //First check our parameters 00727 ERROR2IF(pFile == NULL, FALSE, "HTMLFilter::ParseHTMLFile NULL diskfile supplied"); 00728 ERROR2IF(HTMLList == NULL, FALSE, "HTMLFile::PArseHTMLFile NULL HTMLList supplied"); 00729 00730 // Set up some variables 00731 BOOL IsCenter = FALSE; // this is used for formatting 00732 TCHAR* pTagName = new TCHAR[MAXTAGLENGTH]; 00733 TCHAR* pTagAttrib = new TCHAR[MAXTAGLENGTH]; 00734 TCHAR* pTokenBuf = new TCHAR[MAXTAGLENGTH]; 00735 00736 //First initialise the lexer 00737 pFile->InitLexer(FALSE, TRUE); 00738 00739 HTMLTAG_TYPE Token = HTMLTAG_UNKNOWN; 00740 00741 BOOL ok = TRUE; 00742 00743 //And now do the parsing until we reach the end of the file 00744 while (!pFile->IsEndOfHTMLFile()) 00745 { 00746 //First get an HTML token. This token will either be 00747 //a tag "<xxxx>" or text "xxxx". 00748 //The two parameters mean that we want to ignore any EOL characters 00749 //but we do not want the case to be corrected to upper case 00750 pFile->GetHTMLToken(TRUE, FALSE); 00751 00752 //Now, if the HTML token is a tag 00753 if (pFile->IsHTMLTag()) 00754 { 00755 //Then get the name of the tag 00756 String_256 szTagName=pFile->GetHTMLTagName(); 00757 00758 //Now try and find our token in the HTML table 00759 Token = FindTagId(szTagName); 00760 00761 switch (Token) 00762 { 00763 case HTMLTAG_IMGSRC: 00764 { 00765 //It's an IMG tag. 00766 //Get the value of the SRC parameter. The "FALSE" indicates we shouldn't 00767 //correct the case of the value 00768 String_256 szValue=pFile->GetHTMLParameterValue(String_256("SRC"), FALSE); 00769 00770 //And, if we found an SRC parameter value 00771 if (!szValue.IsEmpty()) 00772 { 00773 //Create a new HTMLFileListItem 00774 HTMLFileListItem* NewItem = new HTMLFileListItem((TCHAR*) szValue, Token, FALSE); 00775 00776 //And try to add it to the list 00777 //If it doesn't get added, delete it 00778 if (!HTMLList->Add(NewItem)) 00779 delete NewItem; 00780 } 00781 00782 } 00783 break; 00784 00785 case HTMLTAG_EMBED: 00786 { 00787 //It's an EMBED tag. 00788 //Get the value of the SRC parameter. The "FALSE" indicates we shouldn't 00789 //correct the case of the value 00790 String_256 szValue=pFile->GetHTMLParameterValue(String_256("SRC"), FALSE); 00791 00792 //And, if we found an SRC parameter value 00793 if (!szValue.IsEmpty()) 00794 { 00795 //Create a new HTMLFileListItem 00796 HTMLFileListItem* NewItem = new HTMLFileListItem((TCHAR*) szValue, Token, FALSE); 00797 00798 //And try to add it to the list 00799 //If it doesn't get added, delete it 00800 if (!HTMLList->Add(NewItem)) 00801 delete NewItem; 00802 } 00803 00804 } 00805 break; 00806 00807 case HTMLTAG_BODY: 00808 { 00809 // It's a BODY tag 00810 00811 //Get the value of the BACKGROUND parameter, if any 00812 String_256 szValue=pFile->GetHTMLParameterValue(String_256("BACKGROUND"), FALSE); 00813 00814 //And if we found a value 00815 if (!szValue.IsEmpty()) 00816 { 00817 //Create a new HTMLFileListItem 00818 HTMLFileListItem* NewItem = new HTMLFileListItem((TCHAR*) szValue, Token, FALSE); 00819 00820 //And try to add it to the list 00821 //If it doesn't get added, delete it 00822 if (!HTMLList->Add(NewItem)) 00823 delete NewItem; 00824 } 00825 } 00826 break; 00827 00828 case HTMLTAG_INPUT: // e.g. : <input type=image src="image.gif"> 00829 { 00830 //It's an input tag 00831 00832 //Get the value of the TYPE parameter, if any 00833 String_256 szTypeValue=pFile->GetHTMLParameterValue(String_256("TYPE"), FALSE); 00834 00835 //And if we found a TYPE parameter and its value was 00836 //IMAGE 00837 if (camStricmp(szTypeValue, "image")==0) 00838 { 00839 // Then look for an "SRC" parameter 00840 String_256 szSRCValue=pFile->GetHTMLParameterValue(String_256("SRC"), FALSE); 00841 00842 //And if we found an SRC parameter value 00843 if (!szSRCValue.IsEmpty()) 00844 { 00845 //Then create a new HTMLFileListItem 00846 HTMLFileListItem* NewItem = new HTMLFileListItem((TCHAR*) szSRCValue, Token, FALSE); 00847 00848 //And try to add it to the list 00849 //If it doesn't get added, delete it 00850 if (!HTMLList->Add(NewItem)) 00851 delete NewItem; 00852 } 00853 } 00854 } 00855 break; 00856 00857 case HTMLTAG_UNUSED: 00858 case HTMLTAG_UNKNOWN: 00859 default: 00860 break; 00861 } 00862 } 00863 00864 Token = HTMLTAG_UNKNOWN; 00865 } 00866 00867 // We are now finished with the lexer 00868 pFile->DeinitLexer(); 00869 00870 delete [] pTagName; 00871 delete [] pTagAttrib; 00872 delete [] pTokenBuf; 00873 00874 // All ok 00875 return TRUE; 00876 }
|
|
Allows a filter or set of filters to take some action or set up variables before being called by HowCompatible. A group of filters which share common code may require some variable set up before being asked to check the type. Base class does nothing and so works for all filters which do not require it.
Definition at line 305 of file htmlfltr.cpp. 00306 { 00307 return TRUE; 00308 }
|
|
scan the list and call DoImportBitmap()
Definition at line 462 of file htmlfltr.cpp. 00463 { 00464 ERROR2IF(DestDoc == NULL, FALSE, "HTMLFilter::ScanListAndImport NULL document supplied"); 00465 ERROR2IF(HTMLList == NULL, FALSE, "HTMLFilter::ScanListAndImport NULL list supplied"); 00466 ERROR2IF(URL == NULL, FALSE, "HTMLFilter::ScanListAndImport NULL URL supplied"); 00467 00468 // make sure there is at least one file in the list 00469 INT32 FileNumber = HTMLList->GetCount(); 00470 00471 //If there were no files in the list, tell the user 00472 ERROR1IF(FileNumber==0, TRUE, _R(IDE_HTMLIMPORT_NOIMAGESINFILE)); 00473 00474 // current file 00475 INT32 FileNum = 0; 00476 //Get the first position at which to import a bitmap 00477 DocCoord PosTranslate=GetImportPosition(DestDoc, FileNum); 00478 00479 00480 // first, get a pointer to the first element 00481 HTMLFileListItem* ListBitmaps = (HTMLFileListItem*)HTMLList->GetHead(); 00482 String_256 NewName; 00483 00484 // scan the list 00485 while(ListBitmaps != NULL) 00486 { 00487 // get the Tag ID associated with the bitmap 00488 HTMLTAG_TYPE TagId = ListBitmaps->GetTagId(); 00489 00490 //Get the name of the bitmap 00491 NewName= ListBitmaps->GetFileName(); 00492 00493 // if only it's a web address then I call the bitmap download operation 00494 if (WebAddress::IsHTTP(*URL) || WebAddress::IsHTTP(ListBitmaps->GetFileName())) 00495 { 00496 00497 // create the webaddress according base and relative URL 00498 WebAddress WebFileName(ListBitmaps->GetFileName()); 00499 WebFileName.Combine(*URL); // combine the existing URL with the filename 00500 00501 // reconstitute the web address 00502 String_256 WebPath = WebFileName.GetWebAddress(); 00503 00504 // call the bitmap download op 00505 //Graham 30/5/97: When the asynchronous download op completes, 00506 //it will delete this object 00507 BitmapDownloadParam* Param=new BitmapDownloadParam; 00508 00509 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_OPBITMAPDOWNLOAD); 00510 00511 if (pOpDesc != NULL) 00512 { 00513 // get the temporary dir 00514 TCHAR TempDir[MAX_PATH]; 00515 FileUtil::GetTemporaryPath(MAX_PATH,TempDir); 00516 // get temp file name 00517 TCHAR TempFileName[256]; 00518 TCHAR Prefix[] = "BMP"; // the first three letters of the new file name 00519 FileUtil::GetTemporaryFileName(TempDir,Prefix,0,TempFileName); 00520 00521 // extract the original filename 00522 INT32 lg = WebPath.Length()+1; 00523 char* TmpPath = new char[lg]; 00524 char* TmpPath2=TmpPath; 00525 ReverseString(WebPath, TmpPath); 00526 char* RevFileName = new char [lg]; 00527 char* FileNameTmp = RevFileName; 00528 while (*TmpPath2!='\\' && *TmpPath2!='/' && *TmpPath2!=NULL) 00529 *(FileNameTmp++) = *(TmpPath2++); 00530 *FileNameTmp = '\0'; 00531 00532 // we download only if there is a file to download 00533 if (*RevFileName != '\0') 00534 { 00535 String_256 StrRevFileName(RevFileName); 00536 char* FileName = new char[lg]; 00537 ReverseString(StrRevFileName, FileName); 00538 //delete [] OutPath; 00539 String_256 StrFileName(TempDir); 00540 StrFileName += String_256(FileName); 00541 00542 // fill in the struct (minimum necessary information) 00543 Param->type = TYPE_BITMAP; 00544 Param->priority = AsynchDownload::PRIORITY_NORMAL; 00545 Param->file = String_256(TempFileName); // temporary file name 00546 //Param->file = StrFileName; // temporary file name 00547 Param->strURL = WebPath; 00548 //Param->strDescription = "Bitmap file Download"; 00549 BOOL ok = TRUE; 00550 Param->Output = &ok; 00551 00552 // other information relative to the filter 00553 //Param->m_Op = Op; // I need the Op 00554 Param->m_FileName = FileName; // original filename 00555 Param->m_DestDoc = DestDoc; // I also need the document 00556 Param->m_TagId = (INT32)TagId; // Id of tag associated with the bitmap 00557 Param->m_FileNum = FileNum; // current file 00558 Param->m_FileNumber = FileNumber; // number of files 00559 Param->m_PosTranslate = PosTranslate; // coordinates of the bitmap in the document 00560 Param->m_IsCenter = FALSE; 00561 00562 // Invoke the operation 00563 pOpDesc->Invoke((OpParam*) Param); 00564 00565 //Graham 2/6/97: Delete FileName 00566 delete [] FileName; 00567 } 00568 00569 //Graham 2/6/97: And delete everything we need to delete 00570 delete [] TmpPath; 00571 delete [] RevFileName; 00572 00573 } 00574 else 00575 return FALSE; 00576 } 00577 else // we can directly call the DoImportBitmap as the file is not a URL 00578 { 00579 //Rewritten by Graham 2/6/97 00580 00581 //First get the name of the file we're going to import 00582 String_256 szFileName = ListBitmaps->GetFileName(); 00583 00584 //Then make a copy of the path of the file we are importing 00585 PathName Path=pthImportFile; 00586 00587 //And set the file name of that path to the file name we are going 00588 //to import. 00589 Path.SetFileNameAndType(szFileName); 00590 00591 //And import the bitmap 00592 if (!DoImportBitmap(TagId, Op, DestDoc, Path, FileNum, FileNumber, PosTranslate, FALSE, &NewName)) 00593 { 00594 // Make up an error string adding a default 'Problem loading images. This includes' and 00595 // then add the pathname. 00596 if (m_WarningsString.IsEmpty()) 00597 { 00598 m_WarningsString = String_256(_R(IDE_HTMLIMPORT_BADIMAGESINFILE)); 00599 } 00600 00601 String_256 Sep(_R(IDS_TAG_ERROR_LIST_SEP)); 00602 String_256 Temp = Path.GetPath(); 00603 // Only add it if there is enough room to fit it all in 00604 if (Sep.Length() + Temp.Length() + m_WarningsString.Length() < m_WarningsString.MaxLength()) 00605 { 00606 m_WarningsString += Sep; 00607 m_WarningsString += Temp; 00608 } 00609 else 00610 { 00611 // Try using the filename plus extension only 00612 Temp = Path.GetFileName(); 00613 if (Sep.Length() + Temp.Length() + m_WarningsString.Length() < m_WarningsString.MaxLength()) 00614 { 00615 m_WarningsString += Sep; 00616 m_WarningsString += Temp; 00617 } 00618 } 00619 } 00620 } 00621 00622 FileNum++; 00623 00624 // Update the import position translation 00625 PosTranslate=GetImportPosition(DestDoc, FileNum); 00626 00627 // Get the next element in the list 00628 ListBitmaps = (HTMLFileListItem*)HTMLList->GetNext(ListBitmaps); 00629 } 00630 00631 return TRUE; 00632 }
|
|
Search for string B in string A.
Definition at line 1125 of file htmlfltr.cpp. 01126 { 01127 if (A==NULL || B==NULL) 01128 return NULL; 01129 01130 return ((TCHAR*)strstr(A, B)); 01131 }
|
|
Definition at line 176 of file htmlfltr.h. |
|
Definition at line 183 of file htmlfltr.h. |