#include <filtimag.h>
Inheritance diagram for ImagemapFilter:

Public Member Functions | |
| ImagemapFilter () | |
| Default constructor. | |
| virtual BOOL | Init () |
| Initializes the ImagemapFilter. | |
| ~ImagemapFilter () | |
| Destructor. Deletes the render region pointer. | |
| virtual BOOL | DoExport (Operation *pOp, CCLexFile *pFile, PathName *pPath, Document *pDoc, BOOL ShowOptions) |
| This function is called when the user has gone to the Export... dialog box, chosen the imagemap filter and clicked the Export button. | |
| BOOL | PrepareAndWriteData (Document *pDoc) |
| Calculates an imagemap based on the file pDoc and the current set of ImagemapFilterOptions. Then writes this out to either a file or the clipboard (as specified in the options). | |
| BOOL | PrepareData (Document *pDoc) |
| Sets up the imagemap data in the render region. | |
| BOOL | WriteData () |
| Writes the data in the ImagemapRenderRegion either to a file or to the clipboard, as specified in the ImagemapFilterOptions. | |
| BOOL | GetOptionsFromUser (ImagemapFilterOptions *pifoDefault, PathName *ppthFile, CCLexFile *pFile) |
| Puts up the Export Options... dialog box to get a set of ImagemapFilterOptions from the user. | |
| BOOL | WillAcceptExistingFile (PathName pthToReplace) |
| Checks if the user wants to export to this existing file. | |
| void | SearchFileForImagemaps (const PathName &pthSearch, List *plstToAdd) |
| Goes through the file pointed to by pthSearch. | |
| void | SetFilterOptions (ImagemapFilterOptions ifoOptions) |
| Sets ifoOptions as current within the filter. | |
| ImagemapFilterOptions | GetFilterOptions () |
| Returns the current set of imagemap filter options. | |
| BOOL | ExportSelectionOnly (BOOL MaskedRender=FALSE) |
| Determines if the filter wants to export only selected items. In the filters baseclass version the default action will be to export all objects by default Only used by bitmap export and in particular masked gif rendering at present. | |
Protected Member Functions | |
| void | Write (CCLexFile *pfileToWrite) |
| Writes out the imagemap to a file or a text buffer or both. This works as follows:. | |
| BOOL | PrepareRenderRegion (Document *pDoc) |
| a. Creates a new render region with the current set of options b. Attaches a device to that render region | |
| void | ForceBackgroundRedrawOff (DocView *pView) |
| Switches background rendering off in pView. | |
| void | RestoreBackgroundRedraw (DocView *pView) |
| Restores pView's background redraw state. | |
| BOOL | OpenImagemapFile (CCLexFile *pFile, PathName *pPath) |
| Opens the export file. | |
| BOOL | CloseImagemapFile (CCLexFile *pFile) |
| Closes the export file. | |
| INT32 | WriteHelper (CCLexFile *pfileToWrite=NULL, TCHAR *pcBuffer=NULL) |
| This function will be called twice:. | |
| INT32 | WriteBitmapHTML (CCLexFile *pfileToWrite=NULL, TCHAR *pcBuffer=NULL) |
| INT32 | WriteImagemapHTML (CCLexFile *pfileToWrite=NULL, TCHAR *pcBuffer=NULL) |
| Writes the bitmap HTML.Writes the imagemap HTML. | |
| INT32 | WritePreamble (TCHAR *pcBuffer) |
| Helper for writing imagemaps - this function will write the 'preamble' to pcBuffer. The 'preamble' consists of the image source, dimensions, which map it is bound to, and a tag indicating the border has 0 width. | |
| void | CopyToClipboard (TCHAR *pcBuffer=NULL) |
| Puts the text on the clipboard. | |
| BOOL | WriteDataToExistingFile (CCLexFile *pFile, PathName *pPath) |
| Writes the data in the imagemap region into an existing file and/or to the clipboard. | |
| BOOL | WriteDataToNewFile (CCLexFile *pFile, PathName *pPath) |
| Writes the data in the imagemap region into a new file and/or to the clipboard. | |
| BOOL | WriteExistingDataHelper (CCLexFile *pfileTo, CCLexFile *pfileFrom, PathName *pPath) |
| This function does most of the hard work in writing an imagemap into an existing file. | |
| BOOL | ContainsSameImagemapName (CCLexFile *pfileSearch) |
| void | BuildMapNamesList (CCLexFile *pfileSearch, PathName *ppthSearch, List *plstToAdd) |
| Goes through the file pointed to by pfileSearch. | |
Protected Attributes | |
| ImagemapRenderRegion * | m_pRegion |
| DocView * | pView |
| BOOL | BackgroundRedrawStateSet |
| BOOL | BackgroundRedrawState |
Static Protected Attributes | |
| static ImagemapFilterOptions | ms_Options = ImagemapFilterOptions() |
Private Member Functions | |
| CC_DECLARE_MEMDUMP (ImagemapFilter) | |
Static Private Attributes | |
| static TCHAR | ms_strApprox [] = _T("ExportImagemap\\CurveApproximation") |
| static TCHAR | ms_strAllRectangles [] = _T("ExportImagemap\\AllRectangles") |
| static TCHAR | ms_strClipboard [] = _T("ExportImagemap\\Clipboard") |
| static TCHAR | ms_strFile [] = _T("ExportImagemap\\File") |
| static TCHAR | ms_strInsert [] = _T("ExportImagemap\\Insert") |
a. The user selects the Imagemap filter class in the Export... dialog box.
b. The user tells one of the bitmap filters to export an imagemap at the same time as it exports the bitmap
Definition at line 129 of file filtimag.h.
|
|
Default constructor.
Definition at line 159 of file filtimag.cpp. 00160 { 00161 //First set up the members of the filter class 00162 ExportMsgID = _R(IDS_EXPORTMSG_IMAGEMAP); 00163 00164 Flags.CanImport = FALSE; 00165 Flags.CanExport = TRUE; 00166 00167 Flags.CanExportMultipleImages = FALSE; 00168 Flags.ShowFilter = TRUE; 00169 00170 FilterID = FILTERID_IMAGEMAP; 00171 00172 //Set the pointer to our render region as NULL 00173 m_pRegion=NULL; 00174 00175 //And set up our options to a set of default values 00176 ImagemapFilter::ms_Options=ImagemapFilterOptions(); 00177 00178 BackgroundRedrawStateSet=FALSE; 00179 BackgroundRedrawState=FALSE; 00180 }
|
|
|
Destructor. Deletes the render region pointer.
Definition at line 235 of file filtimag.cpp. 00236 { 00237 //Delete our render region pointer if it's pointing to something 00238 m_pRegion=NULL; 00239 00240 }
|
|
||||||||||||||||
|
Goes through the file pointed to by pfileSearch.
This may seem a strange function to be an "entry point" to the filter, but it's here so that the file parsing code is available to BaseBitmapFilter. Definition at line 1557 of file filtimag.cpp. 01558 { 01559 PORTNOTETRACE("other","ImagemapFilter::BuildMapNamesList - Do nothing"); 01560 #ifndef EXCLUDE_FROM_XARALX 01561 //First we must open the file for reading 01562 CCDiskFile* pDiskFile=(CCDiskFile*) pfileSearch; 01563 01564 pDiskFile->open(*ppthSearch, ios::in | ios::binary); 01565 01566 //Initialise the HTML lexer 01567 pfileSearch->InitLexer(); 01568 01569 //Set up two strings which we will search for 01570 String_256 strMap("MAP"); 01571 String_256 strName("NAME"); 01572 01573 //And until we reach the end of the file 01574 while(!pfileSearch->IsEndOfHTMLFile()) 01575 { 01576 //Get the next HTML token in the file 01577 pfileSearch->GetHTMLToken(TRUE, FALSE); 01578 01579 //And if the token is an HTML MAP tag 01580 if (pfileSearch->GetHTMLTagName()==strMap) 01581 { 01582 //Then add the value of the NAME parameter to the list 01583 String_256 strToAdd=pfileSearch->GetHTMLParameterValue(strName, FALSE); 01584 01585 StringListItem* psliToAdd=new StringListItem(strToAdd); 01586 01587 plstToAdd->AddTail(psliToAdd); 01588 } 01589 01590 } 01591 01592 //And deinitialise the lexer 01593 pfileSearch->DeinitLexer(); 01594 01595 //Then close the file 01596 pDiskFile->close(); 01597 #endif 01598 }
|
|
|
|
|
|
Closes the export file.
Definition at line 830 of file filtimag.cpp.
|
|
|
|
|
|
Puts the text on the clipboard. > void ImagemapFilter::CopyToClipboard(TCHAR* pcBuffer=NULL)
Definition at line 1120 of file filtimag.cpp. 01121 { 01122 //Put the text on the clipboard 01123 InternalClipboard::CopyText(pcBuffer); 01124 }
|
|
||||||||||||||||||||||||
|
This function is called when the user has gone to the Export... dialog box, chosen the imagemap filter and clicked the Export button.
Reimplemented from Filter. Definition at line 275 of file filtimag.cpp. 00280 { 00281 //First we need to get some ImagemapFilterOptions from the user 00282 //To do this, create a blank set of ImagemapFilterOptions 00283 ImagemapFilterOptions ifoNew=ms_Options; 00284 00285 //And specify within those options that we want to 00286 //export to a file 00287 ifoNew.m_fFile=TRUE; 00288 00289 //And specify the name of that file as being the path we have been given 00290 ifoNew.m_pthFile=*pPath; 00291 00292 //And specify a pointer to that file 00293 ifoNew.m_pfileFile=pFile; 00294 00295 //And remember we're reporting errors 00296 ifoNew.m_fReportErrors=TRUE; 00297 00298 //And call up the dialog box to fill them in 00299 //If this function returns FALSE, the user has cancelled the dialog 00300 if (GetOptionsFromUser(&ifoNew, pPath, pFile)) 00301 { 00302 00303 //Set those options as current within the filter 00304 SetFilterOptions(ifoNew); 00305 00306 //And export to the file using those options 00307 return PrepareAndWriteData(pDoc); 00308 } 00309 else 00310 //If the user has cancelled the dialog, return TRUE anyway 00311 return TRUE; 00312 }
|
|
|
Determines if the filter wants to export only selected items. In the filters baseclass version the default action will be to export all objects by default Only used by bitmap export and in particular masked gif rendering at present.
Reimplemented from Filter. Definition at line 171 of file filtimag.h. 00172 { 00173 return (ms_Options.m_stExportArea==SELECTION); 00174 }
|
|
|
Switches background rendering off in pView.
Definition at line 753 of file filtimag.cpp. 00754 { 00755 // We wan't to make sure we only remember the old state once ... 00756 if (!BackgroundRedrawStateSet) 00757 { 00758 BackgroundRedrawState = pView->GetForeBackMode(); 00759 BackgroundRedrawStateSet = TRUE; // So we don't do this more than once 00760 } 00761 00762 pView->SetForeBackMode(FALSE); 00763 }
|
|
|
Returns the current set of imagemap filter options.
Definition at line 612 of file filtimag.cpp. 00613 { 00614 //Return the filter options 00615 return ms_Options; 00616 }
|
|
||||||||||||||||
|
Puts up the Export Options... dialog box to get a set of ImagemapFilterOptions from the user. BOOL ImagemapFilter::GetOptionsFromUser(ImagemapFilterOptions* pifoDefault, PathName* pPath, CCLexFile* pFile)
Definition at line 646 of file filtimag.cpp. 00647 { 00648 ERROR2IF (pifoDefault==NULL, FALSE, "ImagemapFilter::GetOptionsFromUser - NULL parameter"); 00649 00650 PORTNOTETRACE("other","ImagemapFilter::GetOptionsFromUser - Do nothing"); 00651 #ifndef EXCLUDE_FROM_XARALX 00652 //Now, if the file we are writing to exists already, and if 00653 //we are writing to that file 00654 if (SGLibOil::FileExists(ppthFile) && ms_Options.Insert()) 00655 { 00656 //Then we want to create a list of all the imagemap names in the existing file 00657 //This variable will hold the list 00658 List lstNames; 00659 00660 //Then go through the file and get a list of all the imagemap names 00661 //in the file 00662 BuildMapNamesList(pFile, ppthFile, &lstNames); 00663 00664 //Then put up the modal dialog with that list of names shown 00665 //in the map name combo box 00666 BOOL ok=ImagemapDlg::InvokeDialog(pifoDefault, &lstNames); 00667 00668 //Delete the list of names 00669 lstNames.DeleteAll(); 00670 00671 //And return 00672 return ok; 00673 } 00674 else 00675 { 00676 //Put up the dialog box with nothing shown in the map name 00677 //combo box 00678 //The dialog will start with the inital values of pifoReturn 00679 //in it. When the dialog closes, it will put the values that the user 00680 //chose back into *pifoDefault 00681 return ImagemapDlg::InvokeDialog(pifoDefault); 00682 } 00683 #endif 00684 00685 return FALSE; 00686 }
|
|
|
Initializes the ImagemapFilter.
Implements Filter. Definition at line 193 of file filtimag.cpp. 00194 { 00195 // Set up our associated oil filter 00196 pOILFilter = new ImagemapOILFilter(this); 00197 00198 //If we failed to set it up, return FALSE 00199 if (pOILFilter==NULL) 00200 return FALSE; 00201 00202 // Load the description strings 00203 FilterName.Load(_R(IDS_FILTERNAME_IMAGEMAP)); 00204 FilterInfo.Load(_R(IDS_FILTERINFO_IMAGEMAP)); 00205 00206 //And declare those variables which we want to save in the registry 00207 if (DeclareFilterPreferenceSection()) 00208 { 00209 Camelot.DeclarePref( NULL, ms_strApprox, (INT32*) &ms_Options.m_ffApprox, FF_VERYCLOSELY, FF_NOTATALL); 00210 Camelot.DeclarePref( NULL, ms_strAllRectangles, &ms_Options.m_fAllRectangles, FALSE, TRUE); 00211 Camelot.DeclarePref( NULL, ms_strClipboard, &ms_Options.m_fClipboard, FALSE, TRUE); 00212 Camelot.DeclarePref( NULL, ms_strFile, &ms_Options.m_fFile, FALSE, TRUE); 00213 Camelot.DeclarePref( NULL, ms_strInsert, &ms_Options.m_fInsert, FALSE, TRUE); 00214 } 00215 00216 PORTNOTE("other","Remove ImagemapDlg usage - not defined yet"); 00217 #ifndef EXCLUDE_FROM_XARALX 00218 //Initialise the ExportOptions dialog 00219 ImagemapDlg::Init(); 00220 #endif 00221 00222 //And return 00223 return TRUE; 00224 }
|
|
||||||||||||
|
Opens the export file.
Definition at line 797 of file filtimag.cpp. 00798 { 00799 BOOL ok; 00800 if (!pFile->isOpen()) 00801 { 00802 if (pFile->IsKindOf(CC_RUNTIME_CLASS(CCDiskFile))) 00803 { 00804 ok = OpenExportFile((CCDiskFile*) pFile, pPath); 00805 if (!ok) return FALSE; 00806 } 00807 else 00808 { 00809 TRACEUSER( "JustinF", _T("Tried to open non-CCDiskFile in ImagemapFilter::DoExport\n")); 00810 return FALSE; 00811 } 00812 } 00813 00814 return TRUE; 00815 }
|
|
|
Calculates an imagemap based on the file pDoc and the current set of ImagemapFilterOptions. Then writes this out to either a file or the clipboard (as specified in the options).
Definition at line 334 of file filtimag.cpp. 00335 { 00336 //This variable will keep track of any problems 00337 BOOL ok=TRUE; 00338 00339 //First set up the data to export 00340 ok=PrepareData(pDoc); 00341 00342 // if there was a problem, or the region is empty 00343 if (!ok || m_pRegion->IsEmpty()) 00344 { 00345 //delete the render region 00346 if (m_pRegion) 00347 delete m_pRegion; 00348 m_pRegion = NULL; 00349 00350 //If there was a problem, return FALSE 00351 if (!ok) 00352 return FALSE; 00353 00354 //If there is no data, and we are reporting errors, put up a message box to say so 00355 if (ms_Options.m_fReportErrors) 00356 { 00357 ERROR1(TRUE, _R(IDE_IMAGEMAP_NODATA)); 00358 } 00359 else 00360 return TRUE; 00361 } 00362 00363 //Otherwise, export the data 00364 ok=WriteData(); 00365 00366 //And delete the render region 00367 if (m_pRegion) 00368 delete m_pRegion; 00369 m_pRegion = NULL; 00370 00371 return ok; 00372 00373 }
|
|
|
Sets up the imagemap data in the render region.
Definition at line 389 of file filtimag.cpp. 00390 { 00391 //Set up the render region 00392 BOOL ok=PrepareRenderRegion(pdocToExport); 00393 00394 //If that worked... 00395 if (ok) 00396 { 00397 //Render into our ImagemapRenderRegion 00398 //to set the data 00399 ExportRender(m_pRegion); 00400 00401 //Restore the settings of the render region 00402 RestoreBackgroundRedraw(pView); 00403 } 00404 00405 //And return 00406 return ok; 00407 }
|
|
|
a. Creates a new render region with the current set of options b. Attaches a device to that render region
Definition at line 711 of file filtimag.cpp. 00712 { 00713 PORTNOTETRACE("other","ImagemapFilter::PrepareRenderRegion - Do nothing"); 00714 #ifndef EXCLUDE_FROM_XARALX 00715 // First, create the render region from our current options 00716 if (m_pRegion) 00717 delete m_pRegion; 00718 00719 m_pRegion = new ImagemapRenderRegion(ms_Options); 00720 00721 //Now we must attach a device to our render region 00722 //For this, we must find the current view and spread 00723 00724 pView = DocView::GetCurrent(); 00725 Spread* pSpread = Filter::GetFirstSpread(pDoc); 00726 00727 ERROR2IF(pView==NULL, FALSE, "ImagemapFilter::PrepareToExport - no current view!"); 00728 ERROR2IF(pSpread==NULL, FALSE, "ImagemapFilter::PrepareToExport - no current spread!"); 00729 00730 //And attach the device to our render region 00731 //The middle parameter is the device context, which we set as NULL 00732 m_pRegion->AttachDevice(pView, NULL, pSpread); 00733 00734 //We also need to switch background rendering off in the view 00735 ForceBackgroundRedrawOff(pView); 00736 #endif 00737 00738 return TRUE; 00739 }
|
|
|
Restores pView's background redraw state.
Definition at line 778 of file filtimag.cpp. 00779 { 00780 // We wan't to make sure we only remember the old state once ... 00781 pView->SetForeBackMode(BackgroundRedrawState); 00782 }
|
|
||||||||||||
|
Goes through the file pointed to by pthSearch.
It does this all by calling the function BuildMapNamesList. See Also: ImagemapFilter::BuildMapNamesList(); Definition at line 552 of file filtimag.cpp. 00553 { 00554 //First create a disk file 00555 CCDiskFile fileOpen(1024, FALSE, TRUE); 00556 00557 //Create a copy of the path name we've been given 00558 PathName pthOpen=pthSearch; 00559 00560 //And call BuildMapNamesList to do all the work 00561 BuildMapNamesList(&fileOpen, &pthOpen, plstToAdd); 00562 00563 }
|
|
|
Sets ifoOptions as current within the filter.
Definition at line 593 of file filtimag.cpp. 00594 { 00595 //Simply copy the options into our static member variable 00596 ms_Options=ifoOptions; 00597 }
|
|
|
Checks if the user wants to export to this existing file.
Reimplemented from Filter. Definition at line 487 of file filtimag.cpp. 00488 { 00489 //So first get the truncated path name 00490 String_256 strToReplace = pthToReplace.GetTruncatedPath(50); 00491 00492 //Now create a string to put our error message in 00493 String_256 strError; 00494 00495 //And make the error message up using the file name 00496 strError.MakeMsg(_R(IDM_IMAGEMAP_INSERT), &strToReplace); 00497 00498 //Now, set that error message as the next one to display 00499 Error::SetError( 0, strError, 0 ); 00500 00501 //And set up the message help context 00502 SetNextMsgHelpContext(_R(IDM_IMAGEMAP_INSERT)); 00503 00504 //Now set up the buttons 00505 ErrorInfo Info; 00506 Info.Button[0] = _R(IDB_IMAGEMAP_INSERT); 00507 Info.Button[1] = _R(IDB_IMAGEMAP_REPLACE); 00508 Info.Button[2] = _R(IDS_CANCEL); 00509 00510 //Make Insert the default 00511 //and Cancel the cancel button 00512 Info.OK = 1; 00513 Info.Cancel = 3; 00514 00515 //And put the error box up 00516 const UINT32 uResult = AskQuestion( &Info ); 00517 if( uResult == _R(IDB_IMAGEMAP_INSERT) ) 00518 ms_Options.m_fInsert=TRUE; 00519 else 00520 if( uResult == _R(IDB_IMAGEMAP_REPLACE) ) 00521 ms_Options.m_fInsert=FALSE; 00522 else 00523 if( uResult ==_R(IDS_CANCEL) ) 00524 return FALSE; 00525 00526 return TRUE; 00527 }
|
|
|
Writes out the imagemap to a file or a text buffer or both. This works as follows:. > void ImagemapFilter::Write(CCLexFile* pfileToWrite, TCHAR** ppcBuffer=NULL)
If pfileToWrite is not NULL, this function will write the imagemap to that file. If ms_Options.fClipboard is TRUE, this function will also set up a text buffer, write the imagemap to that text buffer and then copy the text buffer to the clipboard. This function calls our toolkit function WriteHelper to do most of the work. But what is actually written out? The only thing that will ever be written to the text buffer is the imagemap itself: <MAP> <AREA SHAPE=RECTANGLE ...> <AREA SHAPE=POLYGON ...> </MAP> What is written to the file depends on whether we have told that this imagemap is associated with a particular bitmap file. In other words, it depends on whether the Path To Bitmap File member variable of our ImagemapFilterOptions member variable is valid. If we have been given a bitmap file, then an entire HTML file embedding the bitmap will be written to the imagemap file: <HTML> ...
<MAP> ... </MAP> If not, only the portion between the <MAP> tags will be written.
Definition at line 896 of file filtimag.cpp. 00897 { 00898 //If we need to copy the imagemap to the clipboard, this variable 00899 //will point to a text buffer to store the string in. 00900 TCHAR* pBuffer=NULL; 00901 00902 //Now, do we need to copy the imagemap to the clipboard? 00903 if (ms_Options.m_fClipboard) 00904 { 00905 //Yes. So we need to set up a text buffer. 00906 00907 //First find out the length of this buffer by calling our helper 00908 //function with no parameters 00909 INT32 lBufferLength=WriteHelper(); 00910 00911 //And set up a buffer of that length + length of hint line (determined by 00912 //calling WritePreamble()) - Matt 31/08/2000 00913 if (lBufferLength>0) 00914 { 00915 lBufferLength += WritePreamble(NULL); 00916 00917 pBuffer=new TCHAR[lBufferLength+1]; 00918 00919 //And NULL terminate the buffer at the first character 00920 *pBuffer=0; 00921 00922 //If we have a text buffer, then write to it 00923 if (pBuffer) 00924 { 00925 //Write to the buffer our hint... 00926 WritePreamble(pBuffer); 00927 } 00928 } 00929 00930 } 00931 00932 //And write the imagemap out to both the file and, if necessary, the 00933 //text buffer 00934 WriteHelper(pfileToWrite, pBuffer); 00935 00936 //And finally, if we have a text buffer 00937 if (pBuffer) 00938 { 00939 //Copy it to the clipboard 00940 CopyToClipboard(pBuffer); 00941 00942 //Then delete it 00943 delete pBuffer; 00944 } 00945 00946 }
|
|
||||||||||||
|
|
|
|
Writes the data in the ImagemapRenderRegion either to a file or to the clipboard, as specified in the ImagemapFilterOptions.
Definition at line 424 of file filtimag.cpp. 00425 { 00426 //And this variable will keep track of errors 00427 BOOL ok=TRUE; 00428 00429 //Now, should we be writing to a file? 00430 if (ms_Options.m_fFile) 00431 { 00432 //Yes, we should. So we should have been passed a path name 00433 //and a pointer to that file. So retrieve them. 00434 PathName pthExportFile=ms_Options.m_pthFile; 00435 CCLexFile* pfileExportFile=ms_Options.m_pfileFile; 00436 00437 //Now, does this path name refer to an existing file? And if 00438 //it does refer to an existing file, then have we been told to insert 00439 //our imagemap into that file? 00440 if (SGLibOil::FileExists(&pthExportFile) && ms_Options.Insert()) 00441 { 00442 //Yes. So insert the data into the file 00443 ok=WriteDataToExistingFile(pfileExportFile, &pthExportFile); 00444 } 00445 else 00446 { 00447 //No, either it's a new file or we haven't been told to 00448 //insert our data into the file. So write to a new file 00449 //(and if the file does exist, it will be overwritten). 00450 ok=WriteDataToNewFile(pfileExportFile, &pthExportFile); 00451 } 00452 } 00453 else 00454 { 00455 //No. So should we be writing to the clipboard? 00456 if (ms_Options.m_fClipboard) 00457 { 00458 //Yes. So do that now. 00459 ok=WriteDataToNewFile(NULL, NULL); 00460 } 00461 } 00462 00463 //And delete the render region 00464 if (m_pRegion) 00465 delete m_pRegion; 00466 m_pRegion=NULL; 00467 00468 //And return 00469 return ok; 00470 }
|
|
||||||||||||
|
Writes the data in the imagemap region into an existing file and/or to the clipboard.
Definition at line 1140 of file filtimag.cpp. 01141 { 01142 //Check parameters 01143 ERROR2IF (pFile==NULL || pPath==NULL, FALSE, "ImagemapFilter::WriteDataToExistingFile - null parameter"); 01144 01145 PORTNOTETRACE("other","ImagemapFilter::WriteDataToExistingFile - Do nothing"); 01146 #ifndef EXCLUDE_FROM_XARALX 01147 //Now let's create a new Xara temporary file 01148 PathName pthTemp=FileUtil::GetTemporaryPathName(); 01149 01150 //And open that temporary file for writing 01151 CCDiskFile fileTemp(1024, FALSE, TRUE); 01152 01153 OpenImagemapFile(&fileTemp, &pthTemp); 01154 01155 //Now write our existing file across to our temporary file, 01156 //parsing it as we do so, and inserting the imagemap data 01157 //in the appropriate position 01158 WriteExistingDataHelper(&fileTemp, pFile, pPath); 01159 01160 //And close the files 01161 fileTemp.close(); 01162 01163 //Finally, delete our existing file 01164 BOOL ok=SGLibOil::FileDelete(pPath); 01165 01166 //Copy our temporary file across 01167 if (ok) 01168 SGLibOil::FileCopy(&pthTemp, pPath); 01169 01170 //Then delete our temporary file 01171 if (ok) 01172 ok=SGLibOil::FileDelete(&pthTemp); 01173 01174 //And return 01175 return ok; 01176 #endif 01177 01178 return TRUE; 01179 }
|
|
||||||||||||
|
Writes the data in the imagemap region into a new file and/or to the clipboard.
Get the dimensions of the image map area DocRect rectDocRect; rectDocRect = ms_Options.GetSizeOfExportArea(ms_Options.m_stExportArea); use the matrix to work out the pixel values of height and width Matrix Identity; WinRect rectWinRect = OSRenderRegion::BitmapDocRectToWin( Identity, rectDocRect, 96.0 ); save the width and height data Temp = " width=\""; pFile << Temp; INT32 lToWrite = rectWinRect.right - rectWinRect.left; HTMLExportFilter::WriteNumber(lToWrite, pFile, NULL); Temp = "\""; pFile << Temp; Temp = " height=\""; pFile << Temp; lToWrite = rectWinRect.bottom - rectWinRect.top; HTMLExportFilter::WriteNumber(lToWrite, pFile, NULL); Temp = "\""; pFile << Temp; Definition at line 1195 of file filtimag.cpp. 01196 { 01197 //Have we been passed a file to write to? 01198 if (pFile!=NULL) 01199 { 01200 //Yes. So open it. 01201 if (!OpenImagemapFile(pFile, pPath)) 01202 return FALSE; 01203 } 01204 01205 01206 // add a header to the new file so that if a 01207 // dumb user looks at it it will show the image 01208 // this isn't in the "replace an image map" code 01209 // since that will already have an image file indicated 01210 // Note that it is valid for this function to be called with 2 NULL arguments ( exporting 01211 // to the clipboard only ). So, no use in testing for NULL arguments. 01212 // ASSERT(pPath); 01213 if( pFile != NULL ) // Only write information out to pFile if it exists. 01214 { 01215 String_256 Temp = "<img src=\"file:///"; 01216 *pFile << Temp; 01217 *pFile << ms_Options.m_GraphicPath.GetPath(); // the path and file name of the graphic 01218 Temp = "\""; 01219 *pFile << Temp; 01220 01221 /********************************************************************************************* 01222 // matt - 25/08/2000 - added the following to ensure HTML has height and width data 01223 // matt - 04/09/2000 - OK, this only works when the image is not resized during export 01224 01225 // Get the dimensions of the image map area 01226 DocRect rectDocRect; 01227 rectDocRect = ms_Options.GetSizeOfExportArea(ms_Options.m_stExportArea); 01228 01229 // use the matrix to work out the pixel values of height and width 01230 Matrix Identity; 01231 WinRect rectWinRect = OSRenderRegion::BitmapDocRectToWin( Identity, rectDocRect, 96.0 ); 01232 01233 // save the width and height data 01234 Temp = " width=\""; 01235 *pFile << Temp; 01236 INT32 lToWrite = rectWinRect.right - rectWinRect.left; 01237 HTMLExportFilter::WriteNumber(lToWrite, pFile, NULL); 01238 Temp = "\""; 01239 *pFile << Temp; 01240 Temp = " height=\""; 01241 *pFile << Temp; 01242 lToWrite = rectWinRect.bottom - rectWinRect.top; 01243 HTMLExportFilter::WriteNumber(lToWrite, pFile, NULL); 01244 Temp = "\""; 01245 *pFile << Temp; 01246 **************************************************************************************************/ 01247 01248 01249 //Now write the remaining details 01250 01251 Temp = " usemap=\"#"; 01252 *pFile << Temp; 01253 *pFile << ms_Options.GetImagemapName(); 01254 Temp = "\" border=\"0\">\r\n"; 01255 *pFile << Temp; 01256 01257 } 01258 01259 //Write the imagemap to the file and/or to the clipboard 01260 Write(pFile); 01261 01262 //If we have been passed a file to write to 01263 if (pFile!=NULL) 01264 { 01265 //Then close it. 01266 CloseImagemapFile(pFile); 01267 } 01268 01269 //Delete the render region 01270 delete m_pRegion; 01271 m_pRegion=NULL; 01272 01273 return TRUE; 01274 }
|
|
||||||||||||||||
|
This function does most of the hard work in writing an imagemap into an existing file.
The appropriate place is, in order of preference: 1. In place of an imagemap in pfileFrom that has the same map name as the imagemap we are writing 2. Before the </BODY> tag of pfileFrom has been written 3. After all the data from pfileFrom has been written Get the dimensions of the image map area DocRect rectDocRect; rectDocRect = ms_Options.GetSizeOfExportArea(ms_Options.m_stExportArea); use the matrix to work out the pixel values of height and width Matrix Identity; WinRect rectWinRect = OSRenderRegion::BitmapDocRectToWin( Identity, rectDocRect, 96.0 ); save the width and height data Temp = " width=\""; pfileTo << Temp; INT32 lToWrite = rectWinRect.right - rectWinRect.left; HTMLExportFilter::WriteNumber(lToWrite, pfileTo, NULL); Temp = "\""; pfileTo << Temp; Temp = " height=\""; pfileTo << Temp; lToWrite = rectWinRect.bottom - rectWinRect.top; HTMLExportFilter::WriteNumber(lToWrite, pfileTo, NULL); Temp = "\""; pfileTo << Temp; Get the dimensions of the image map area DocRect rectDocRect; rectDocRect = ms_Options.GetSizeOfExportArea(ms_Options.m_stExportArea); use the matrix to work out the pixel values of height and width Matrix Identity; WinRect rectWinRect = |