ImagemapFilter Class Reference

The imagemap export filter class. More...

#include <filtimag.h>

Inheritance diagram for ImagemapFilter:

HTMLExportFilter Filter ListItem CCObject SimpleCCObject List of all members.

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

ImagemapRenderRegionm_pRegion
DocViewpView
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")

Detailed Description

The imagemap export filter class.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/4/97
This code contained in this class is called when

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.


Constructor & Destructor Documentation

ImagemapFilter::ImagemapFilter  ) 
 

Default constructor.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/4/97

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 }

ImagemapFilter::~ImagemapFilter  ) 
 

Destructor. Deletes the render region pointer.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/4/97

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 }


Member Function Documentation

void ImagemapFilter::BuildMapNamesList CCLexFile pfileSearch,
PathName ppthSearch,
List plstToAdd
[protected]
 

Goes through the file pointed to by pfileSearch.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/5/97
Parameters:
plstToAdd Pointer to the list to add the names to [INPUTS] pfileSearch Pointer to the file to search ppthSearch Pointer to the path of the file to search
Returns:
-
Each time it finds an imagemap tag <MAP name="xxx>">, it adds the value of the NAME parameter into the list pointed to by plstToAdd.

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 }

ImagemapFilter::CC_DECLARE_MEMDUMP ImagemapFilter   )  [private]
 

BOOL ImagemapFilter::CloseImagemapFile CCLexFile pFile  )  [protected]
 

Closes the export file.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/4/97
Parameters:
pFile - the file to close [INPUTS]
Returns:
TRUE if successful (no way of erroring at present)

Definition at line 830 of file filtimag.cpp.

00831 {
00832     if (pFile->isOpen())
00833         pFile->close();
00834 
00835     return TRUE;
00836     
00837 }

BOOL ImagemapFilter::ContainsSameImagemapName CCLexFile pfileSearch  )  [protected]
 

void ImagemapFilter::CopyToClipboard TCHAR pcBuffer = NULL  )  [protected]
 

Puts the text on the clipboard.

> void ImagemapFilter::CopyToClipboard(TCHAR* pcBuffer=NULL)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/4/97
Parameters:
pcBuffer The text to put on the clipboard [INPUTS]

Definition at line 1120 of file filtimag.cpp.

01121 {
01122     //Put the text on the clipboard
01123     InternalClipboard::CopyText(pcBuffer);
01124 }

BOOL ImagemapFilter::DoExport Operation pOp,
CCLexFile pFile,
PathName pPath,
Document pDoc,
BOOL  ShowOptions
[virtual]
 

This function is called when the user has gone to the Export... dialog box, chosen the imagemap filter and clicked the Export button.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/4/97
Returns:
TRUE if the export was OK FALSE if there were any errors
This function simply calls three member functions in turn in order to:

  • Put up a dialog box to get some options from the user
  • Set those options as current within the filter
  • Export the file using those options

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 }

BOOL ImagemapFilter::ExportSelectionOnly BOOL  MaskedRender = FALSE  )  [inline, virtual]
 

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.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/09/95
Returns:
True if this filter wants check if an object is selected or not and so export only the selected items Or False if want to export everything.
See also:
Filter::ExportRender;

Reimplemented from Filter.

Definition at line 171 of file filtimag.h.

00172     {
00173         return (ms_Options.m_stExportArea==SELECTION);
00174     }

void ImagemapFilter::ForceBackgroundRedrawOff DocView pView  )  [protected]
 

Switches background rendering off in pView.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/5/97 - Britain deserves better!
Parameters:
pView [INPUTS]
Returns:
-

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 }

ImagemapFilterOptions ImagemapFilter::GetFilterOptions  ) 
 

Returns the current set of imagemap filter options.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/4/97
Parameters:
- [INPUTS]
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 }

BOOL ImagemapFilter::GetOptionsFromUser ImagemapFilterOptions pifoDefault,
PathName ppthFile,
CCLexFile pFile
 

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)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/4/97
Parameters:
pifoDefault A set of ImagemapFilterOptions that [INPUTS] will appear in the dialog box when it starts pPath Path to the file we are writing to pFile The file we are writing to
A set of ImagemapFilterOptions from the user [OUTPUTS]
Returns:
FALSE if the dialog was cancelled

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 }   

BOOL ImagemapFilter::Init void   )  [virtual]
 

Initializes the ImagemapFilter.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/4/97
Returns:
TRUE if the filter was initialized ok FALSE otherwise

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 }

BOOL ImagemapFilter::OpenImagemapFile CCLexFile pFile,
PathName pPath
[protected]
 

Opens the export file.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/4/97
Parameters:
pFile,pPath - the file to export to [INPUTS]
Returns:
TRUE if successful FALSE if there was an error

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 }

BOOL ImagemapFilter::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).

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/4/97
Returns:
TRUE if the export was OK FALSE if there were any errors
This function is called by both ImagemapFilter::DoExport and the BaseBitmapFilter class.

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 }

BOOL ImagemapFilter::PrepareData Document pdocToExport  ) 
 

Sets up the imagemap data in the render region.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/4/97
Returns:
TRUE if successful
Does not export that data to the file.

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 }

BOOL ImagemapFilter::PrepareRenderRegion Document pDoc  )  [protected]
 

a. Creates a new render region with the current set of options b. Attaches a device to that render region

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/4/97
Parameters:
pDoc - The document to export [INPUTS]
Returns:
TRUE if successful FALSE if there was an error

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 }

void ImagemapFilter::RestoreBackgroundRedraw DocView pView  )  [protected]
 

Restores pView's background redraw state.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/5/97 - Tough on bugs, tough on the causes of bugs
Parameters:
pView [INPUTS]
Returns:
-

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 }

void ImagemapFilter::SearchFileForImagemaps const PathName pthSearch,
List plstToAdd
 

Goes through the file pointed to by pthSearch.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/7/97
Parameters:
pthSearch The path of the file to search [INPUTS] plstToAdd Pointer to a list to add the map names to
Returns:
-
Each time it finds an imagemap tag <MAP name="xxx>">, it adds the value of the NAME parameter into the list pointed to by plstToAdd.

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 }

void ImagemapFilter::SetFilterOptions ImagemapFilterOptions  ifoOptions  ) 
 

Sets ifoOptions as current within the filter.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/4/97
Parameters:
ifoOptions The options to set as current within the filter [INPUTS]
Returns:
-

Definition at line 593 of file filtimag.cpp.

00594 {
00595     //Simply copy the options into our static member variable
00596     ms_Options=ifoOptions;
00597 }

BOOL ImagemapFilter::WillAcceptExistingFile PathName  pthToReplace  )  [virtual]
 

Checks if the user wants to export to this existing file.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/5/97
Returns:
TRUE if this filter is willing to accept this existing file FALSE otherwise
To do this, we put up a message box with three options: Insert, Overwrite and Cancel.

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 }

void ImagemapFilter::Write CCLexFile pfileToWrite  )  [protected]
 

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)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/4/97
Parameters:
pfileToWrite - The file to write to [INPUTS]
This may be 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> ...

bitmap.gif
</HTML>

<MAP> ... </MAP>

If not, only the portion between the <MAP> tags will be written.

See also:
ImagemapFilter::WriteHelper()

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 }

INT32 ImagemapFilter::WriteBitmapHTML CCLexFile pfileToWrite = NULL,
TCHAR pcBuffer = NULL
[protected]
 

BOOL ImagemapFilter::WriteData  ) 
 

Writes the data in the ImagemapRenderRegion either to a file or to the clipboard, as specified in the ImagemapFilterOptions.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/4/97
Returns:
TRUE if the export was OK FALSE if there were any errors

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 }

BOOL ImagemapFilter::WriteDataToExistingFile CCLexFile pFile,
PathName pPath
[protected]
 

Writes the data in the imagemap region into an existing file and/or to the clipboard.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/4/97
Returns:
TRUE if the export was OK FALSE if there were any errors

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 }

BOOL ImagemapFilter::WriteDataToNewFile CCLexFile pFile,
PathName pPath
[protected]
 

Writes the data in the imagemap region into a new file and/or to the clipboard.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/4/97
Returns:
TRUE if the export was OK FALSE if there were any errors
matt - 25/08/2000 - added the following to ensure HTML has height and width data matt - 04/09/2000 - OK, this only works when the image is not resized during export

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 }

BOOL ImagemapFilter::WriteExistingDataHelper CCLexFile pfileTo,
CCLexFile pfileFrom,
PathName ppathFrom
[protected]
 

This function does most of the hard work in writing an imagemap into an existing file.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/4/97
Parameters:
pfileTo Ptr to the file to copy to [INPUTS] pfileFrom Ptr to the file to copy from ppathFrom Ptr to a pathname of the file to copy from
Returns:
TRUE if OK FALSE if there were any errors
It takes the data from pfileFrom, parses it and writes it to pfileTo, but inserting the imagemap data in an appropriate place.

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 = 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;

Definition at line 1304 of file filtimag.cpp.

01305 {
01306     ERROR2IF(pfileTo == NULL,FALSE,"Bad params - pfileTo");
01307     ERROR2IF(pfileFrom == NULL,FALSE,"Bad params - pfileFrom");
01308     ERROR2IF(ppathFrom == NULL,FALSE,"Bad params - ppathFrom");
01309 
01310     //Set up some strings which we will search for
01311     String_256 strMap("MAP");
01312     String_256 strCloseMap("/MAP");
01313     String_256 strName("NAME");
01314     String_256 strCloseBody("/BODY");
01315 
01316     String_256 strImagemapName=ms_Options.GetImagemapName();
01317     strImagemapName.toUpper();
01318 
01319     //First we're going to do a first pass through the file
01320 
01321     //This will determine two things: one, if the file contains an existing image map
01322     //with the same name as the one we were about to write out. If it does,
01323     //we will overwrite it
01324 
01325     //Two, if the file contains a closing </BODY> tag. If it does, and if 
01326     //there is no existing image map in the file with the same name
01327     //as the one we were about to write out, we will write the imagemap
01328     //before that closing tag
01329 
01330     //Start off by assuming we're not going to overwrite an existing imagemap
01331     //and we're not going to insert the imagemap before the closing body tag
01332     BOOL fOverwriteExistingImageMap=FALSE;
01333     BOOL fInsertBeforeBodyTag=FALSE;
01334         
01335     //So open the file for reading
01336     CCDiskFile* pdiskfileFrom=(CCDiskFile*) pfileFrom;
01337 
01338     pdiskfileFrom->open(*ppathFrom, ios::in | ios::binary);
01339         
01340     //Initialise the HTML Lexer
01341     pfileFrom->InitLexer();
01342 
01343     //And until we reach the end of the file
01344     while(!pfileFrom->IsEndOfHTMLFile())
01345     {
01346         //Get the next HTML token in the file
01347         //This will either be a tag <xxxxxx>
01348         //or text (where text is in between tags)
01349         pfileFrom->GetHTMLToken(FALSE, FALSE);
01350 
01351         //Is that string a <MAP> tag with the same name as the
01352         //imagemap we are about to write out?
01353         if (pfileFrom->GetHTMLTagName()==strMap 
01354             && pfileFrom->GetHTMLParameterValue(strName)==strImagemapName)
01355         {
01356             //Yes. So remember that we want to overwrite the
01357             //existing image map
01358             fOverwriteExistingImageMap=TRUE;
01359         }
01360 
01361         //Is that string a </BODY> tag?
01362         if (pfileFrom->GetHTMLTagName()==strCloseBody)
01363         {
01364             //Yes. So remember that we want to insert before the
01365             //closing body tag
01366             fInsertBeforeBodyTag=TRUE;
01367         }
01368     }
01369 
01370     //Finally, close the file and deinit the lexer
01371     pdiskfileFrom->close();
01372     pfileFrom->DeinitLexer();
01373 
01374     //Now go through the file again, and insert the imagemap in the correct place
01375                               
01376     //So open the file for reading
01377     pdiskfileFrom->open(*ppathFrom, ios::in | ios::binary);
01378         
01379     //Initialise the HTML Lexer
01380     pfileFrom->InitLexer();
01381 
01382     //And until we reach the end of the file
01383     while(!pfileFrom->IsEndOfHTMLFile())
01384     {
01385         //Get the next HTML token in the file
01386         //This will either be a tag <xxxxxx>
01387         //or text (where text is in between tags)
01388         pfileFrom->GetHTMLToken(FALSE, FALSE);
01389 
01390         //Now, if that tag is a closing BODY tag, and we should be inserting
01391         //the imagemap before that closing body tag, and we are not replacing
01392         //an existing imagemap
01393         if (pfileFrom->GetHTMLTagName()==strCloseBody 
01394             && fInsertBeforeBodyTag
01395             && !fOverwriteExistingImageMap) 
01396         {
01397             //Then write out our imagemap & image details now - Matt 31/08/2000
01398             String_256 Temp = "<img src=\"file:///";
01399             *pfileTo << Temp;
01400             *pfileTo << ms_Options.m_GraphicPath.GetPath(); // the path and file name of the graphic
01401             Temp = "\"";
01402             *pfileTo << Temp;
01403 
01404 /*****************************************************************************************************
01405             // Get the dimensions of the image map area
01406             DocRect rectDocRect;
01407             rectDocRect = ms_Options.GetSizeOfExportArea(ms_Options.m_stExportArea);
01408 
01409             // use the matrix to work out the pixel values of height and width
01410             Matrix Identity;
01411             WinRect rectWinRect = OSRenderRegion::BitmapDocRectToWin( Identity, rectDocRect, 96.0 );
01412 
01413             // save the width and height data
01414             Temp = " width=\"";
01415             *pfileTo << Temp;
01416             INT32 lToWrite = rectWinRect.right - rectWinRect.left;
01417             HTMLExportFilter::WriteNumber(lToWrite, pfileTo, NULL);
01418             Temp = "\"";
01419             *pfileTo << Temp;
01420             Temp = " height=\"";
01421             *pfileTo << Temp;
01422             lToWrite = rectWinRect.bottom - rectWinRect.top;
01423             HTMLExportFilter::WriteNumber(lToWrite, pfileTo, NULL);
01424             Temp = "\"";
01425             *pfileTo << Temp;
01426 *************************************************************************************************/
01427 
01428             //Now write the remaining details
01429             Temp = " usemap=\"#";
01430             *pfileTo << Temp;
01431             *pfileTo << ms_Options.GetImagemapName();
01432             Temp = "\" border=\"0\">\r\n";
01433             *pfileTo << Temp;
01434 
01435             
01436             
01437             Write(pfileTo);
01438         }
01439 
01440         //If the tag is a MAP tag with the same
01441         //name as the map we are about to write out, and we should
01442         //be writing the imagemap in place of the existing imagemap
01443         if (pfileFrom->GetHTMLTagName()==strMap 
01444             && pfileFrom->GetHTMLParameterValue(strName)==strImagemapName
01445             && fOverwriteExistingImageMap)
01446         {
01447             //Then write out our imagemap
01448             Write(pfileTo);
01449             
01450             //Now we want to carry on copying the file we are reading from, 
01451             //starting from the closing </MAP> tag. So we must find that closing map
01452             //tag.
01453 
01454             //So read HTML tokens from the file until either we
01455             //find a </MAP> tag or we reach the end of the file
01456             while (pfileFrom->GetHTMLTagName()!=strCloseMap && !pfileFrom->IsEndOfHTMLFile())
01457             {
01458                 //Get the next HTML token
01459                 pfileFrom->GetHTMLToken(FALSE, FALSE);
01460             }
01461 
01462             //And if we haven't reached the end of the file, get another token,
01463             //which we will write out
01464             if (!pfileFrom->IsEndOfHTMLFile())
01465                 pfileFrom->GetHTMLToken(FALSE, FALSE);
01466         }
01467 
01468         //Then get a pointer to the last HTML token we read
01469         char* pcBufferToWrite=pfileFrom->GetHTMLTokenBuffer();
01470 
01471         //And write it out
01472         if (pcBufferToWrite)
01473             pfileTo->write(pcBufferToWrite, strlen(pcBufferToWrite));
01474     }
01475 
01476     //Now, if we haven't inserted an imagemap before a closing body tag,
01477     //and we haven't replaced an existing image map, then we must write
01478     //out the imagemap now
01479     if (!fOverwriteExistingImageMap && !fInsertBeforeBodyTag)
01480     {
01481         //Then write out the imagemap now
01482         String_256 Temp = "<img src=\"file:///";
01483         *pfileTo << Temp;
01484         *pfileTo << ms_Options.m_GraphicPath.GetPath(); // the path and file name of the graphic
01485         Temp = "\"";
01486         *pfileTo << Temp;
01487 
01488 /*****************************************************************************************************
01489         // Get the dimensions of the image map area
01490         DocRect rectDocRect;
01491         rectDocRect = ms_Options.GetSizeOfExportArea(ms_Options.m_stExportArea);
01492 
01493         // use the matrix to work out the pixel values of height and width
01494         Matrix Identity;
01495         WinRect rectWinRect = OSRenderRegion::BitmapDocRectToWin( Identity, rectDocRect, 96.0 );
01496 
01497         // save the width and height data
01498         Temp = " width=\"";
01499         *pfileTo << Temp;
01500         INT32 lToWrite = rectWinRect.right - rectWinRect.left;
01501         HTMLExportFilter::WriteNumber(lToWrite, pfileTo, NULL);
01502         Temp = "\"";
01503         *pfileTo << Temp;
01504         Temp = " height=\"";
01505         *pfileTo << Temp;
01506         lToWrite = rectWinRect.bottom - rectWinRect.top;
01507         HTMLExportFilter::WriteNumber(lToWrite, pfileTo, NULL);
01508         Temp = "\"";
01509         *pfileTo << Temp;
01510 ******************************************************************************************************/
01511 
01512         //Now write the remaining details
01513         Temp = " usemap=\"#";
01514         *pfileTo << Temp;
01515         *pfileTo << ms_Options.GetImagemapName();
01516         Temp = "\" border=\"0\">\r\n";
01517         *pfileTo << Temp;
01518 
01519 
01520 
01521         Write(pfileTo);
01522     }
01523 
01524     //And finally close the file and deinit the lexer
01525     pdiskfileFrom->close();
01526     pfileFrom->DeinitLexer();
01527 
01528     
01529     return TRUE;
01530 }

INT32 ImagemapFilter::WriteHelper CCLexFile pfileToWrite = NULL,
TCHAR pcBuffer = NULL
[protected]
 

This function will be called twice:.

> INT32 ImagemapFilter::WriteHelper(CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/4/97
Parameters:
pfileToWrite - The file to write to [INPUTS] pcBuffer - Pointer to a text buffer to write to
Either of the above may be NULL.

Returns:
The number of TCHARs written.
a. First with all parameters NULL, simply to calculate how INT32 the text buffer for the imagemap must be

b. Secondly with the parameters pointing to a file, or a text buffer or both, to actually write the imagemap out.

It's assumed that the text buffer is long enough for the imagemap.

This function simply iterates through the list and calls on the members to write themselves out.

See also:
ImagemapFilter::WriteHelper()

Definition at line 986 of file filtimag.cpp.

00987 {
00988     //Set up a variable to remember how many chars we have written
00989     INT32 lCharsWritten=0;
00990     
00991     //Write the imagemap HTML
00992     lCharsWritten+=WriteImagemapHTML(pfileToWrite, pcBuffer);
00993 
00994     //And return the number of characters written
00995     return lCharsWritten;                                                             
00996         
00997 }

INT32 ImagemapFilter::WriteImagemapHTML CCLexFile pfileToWrite = NULL,
TCHAR pcBuffer = NULL
[protected]
 

Writes the bitmap HTML.Writes the imagemap HTML.

> INT32 ImagemapFilter::WriteImagemapHTML(CCLexFile* pfileToWrite=NULL, TCHAR* pcBuffer=NULL)

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/4/97
Parameters:
pfileToWrite - The file to write to [INPUTS] pcBuffer - Pointer to a text buffer to write to
Either of the above may be NULL.

Returns:
The number of TCHARs written.
See also:
ImagemapFilter::WriteHelper(), ImagemapRenderRegion::Write()

Definition at line 1072 of file filtimag.cpp.

01073 {
01074     //Keep a count of the characters we write out
01075     INT32 lCharsWritten=0;
01076 
01077 PORTNOTETRACE("other","ImagemapFilter::WriteImagemapHTML - Do nothing");
01078 #ifndef EXCLUDE_FROM_XARALX
01079     //Do we have an imagemap render region member?
01080     if (m_pRegion)
01081     {
01082         //Yes. So we write out the imagemap
01083 
01084         //First write out <MAP NAME="MyMap">
01085         lCharsWritten+=WriteStartOfTag(_R(IDS_HTMLEXPORT_MAP), pfileToWrite, pcBuffer);
01086 
01087         lCharsWritten+=WriteParameterInQuotes(_R(IDS_HTMLEXPORT_NAME), ms_Options.m_strName, pfileToWrite, pcBuffer);
01088 
01089         lCharsWritten+=WriteEndOfTag(pfileToWrite, pcBuffer);
01090 
01091         lCharsWritten+=WriteEOL(pfileToWrite,pcBuffer);
01092 
01093         //And write the imagemap itself
01094         lCharsWritten+=m_pRegion->Write(pfileToWrite, pcBuffer);
01095 
01096         //Then write out </MAP>
01097         lCharsWritten+=WriteCloseTag(_R(IDS_HTMLEXPORT_MAP), pfileToWrite, pcBuffer);
01098 
01099         //And a new line
01100         //lCharsWritten+=WriteEOL(pfileToWrite, pcBuffer);
01101     }
01102 #endif  
01103     
01104     //And return the number of characters written
01105     return lCharsWritten;
01106 }

INT32 ImagemapFilter::WritePreamble TCHAR pcBuffer  )  [protected]
 

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.

Author:
Priestley (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/8/2000
Parameters:
pcBuffer The text buffer to write to (may be NULL) [INPUTS]
Returns:
The number of TCHARs written to the text buffer
If this function is called with pcBuffer as NULL, it will return the length of text buffer required to write the current preamble information

Notes: pcBuffer is assumed to be null terminated

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 );

Image Width and Height... nChars = camStrlen(pcBuffer); camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T(" width=\""));

INT32 tempLong = rectWinRect.right - rectWinRect.left; nChars = camStrlen(pcBuffer);

Format the INT32 as a string temp.MakeMsg(_R(IDS_HTMLEXPORT_NUMBERFORMAT), tempLong); camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T(temp));

nChars = camStrlen(pcBuffer); camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T("\""));

nChars = camStrlen(pcBuffer); camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T(" height=\""));

tempLong = rectWinRect.bottom - rectWinRect.top; nChars = camStrlen(pcBuffer);

Format the INT32 as a string temp.MakeMsg(_R(IDS_HTMLEXPORT_NUMBERFORMAT), tempLong); camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T(temp));

nChars = camStrlen(pcBuffer); camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T("\""));

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 );

Image Width and Height... nChars += camStrlen(_T(" width=\"")); INT32 tempLong = rectWinRect.right - rectWinRect.left;

Format our INT32 temp.MakeMsg(_R(IDS_HTMLEXPORT_NUMBERFORMAT), tempLong);

nChars += camStrlen(temp); nChars += camStrlen(_T("\""));

nChars += camStrlen(_T(" height=\"")); tempLong = rectWinRect.bottom - rectWinRect.top;

Format our INT32 temp.MakeMsg(_R(IDS_HTMLEXPORT_NUMBERFORMAT), tempLong);

nChars += camStrlen(temp); nChars += camStrlen(_T("\""));

Definition at line 1624 of file filtimag.cpp.

01625 {
01626     String_256 temp;
01627     INT32 nChars = 0;
01628 
01629     temp = "<!-- HINT : The next line describes the file used for this image map. It can be deleted if you have already included this information in your HTML page. -->\r\n";
01630 
01631     if (pcBuffer)
01632     {
01633         //Hint line for novice users
01634         nChars = camStrlen(pcBuffer);
01635         camStrcpy(pcBuffer+nChars*sizeof(TCHAR), temp);
01636 
01637         //Image Path and filename...
01638         nChars = camStrlen(pcBuffer);
01639         camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T("<img src=\"file:///"));
01640 
01641         nChars = camStrlen(pcBuffer);
01642         camStrcpy(pcBuffer+nChars*sizeof(TCHAR), ms_Options.m_GraphicPath.GetPath() ); // the path and file name of the graphic
01643 
01644         nChars = camStrlen(pcBuffer);
01645         camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T("\""));
01646 
01647 /*******************************************************************************************************************************
01648         // Get the dimensions of the image map area
01649         DocRect rectDocRect;
01650         rectDocRect = ms_Options.GetSizeOfExportArea(ms_Options.m_stExportArea);
01651 
01652         // use the matrix to work out the pixel values of height and width
01653         Matrix Identity;
01654         WinRect rectWinRect = OSRenderRegion::BitmapDocRectToWin( Identity, rectDocRect, 96.0 );
01655 
01656         //Image Width and Height...
01657         nChars = camStrlen(pcBuffer);
01658         camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T(" width=\""));
01659 
01660         INT32 tempLong = rectWinRect.right - rectWinRect.left;
01661         nChars = camStrlen(pcBuffer);
01662 
01663         //Format the INT32 as a string
01664         temp.MakeMsg(_R(IDS_HTMLEXPORT_NUMBERFORMAT), tempLong);
01665         camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T(temp));
01666 
01667         nChars = camStrlen(pcBuffer);
01668         camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T("\""));
01669 
01670 
01671         nChars = camStrlen(pcBuffer);
01672         camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T(" height=\""));
01673 
01674         tempLong = rectWinRect.bottom - rectWinRect.top;
01675         nChars = camStrlen(pcBuffer);
01676 
01677         //Format the INT32 as a string
01678         temp.MakeMsg(_R(IDS_HTMLEXPORT_NUMBERFORMAT), tempLong);
01679         camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T(temp));
01680 
01681         nChars = camStrlen(pcBuffer);
01682         camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T("\""));
01683 
01684 ************************************************************************************************************/
01685 
01686         //Now the remaining details...
01687         nChars = camStrlen(pcBuffer);
01688         camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T(" usemap=\"#"));
01689 
01690         nChars = camStrlen(pcBuffer);
01691         camStrcpy(pcBuffer+nChars*sizeof(TCHAR), ms_Options.GetImagemapName() );
01692 
01693         nChars = camStrlen(pcBuffer);
01694         camStrcpy(pcBuffer+nChars*sizeof(TCHAR), _T("\" border=\"0\">\r\n"));
01695 
01696 
01697         nChars = camStrlen(pcBuffer);
01698 
01699         return nChars;
01700     }
01701 
01702     //Hint line for novice users
01703     nChars += camStrlen(temp);
01704 
01705     //Image Path and filename...
01706     nChars += camStrlen(_T("<img src=\"file:///"));
01707     nChars += camStrlen( ms_Options.m_GraphicPath.GetPath() ); // the path and file name of the graphic
01708     nChars += camStrlen(_T("\""));
01709 
01710 /************************************************************************************
01711     // Get the dimensions of the image map area
01712     DocRect rectDocRect;
01713     rectDocRect = ms_Options.GetSizeOfExportArea(ms_Options.m_stExportArea);
01714 
01715     // use the matrix to work out the pixel values of height and width
01716     Matrix Identity;
01717     WinRect rectWinRect = OSRenderRegion::BitmapDocRectToWin( Identity, rectDocRect, 96.0 );
01718 
01719     //Image Width and Height...
01720     nChars += camStrlen(_T(" width=\""));
01721     INT32 tempLong = rectWinRect.right - rectWinRect.left;
01722 
01723 
01724     //Format our INT32
01725     temp.MakeMsg(_R(IDS_HTMLEXPORT_NUMBERFORMAT), tempLong);
01726 
01727     nChars += camStrlen(temp);
01728     nChars += camStrlen(_T("\""));
01729 
01730     nChars += camStrlen(_T(" height=\""));
01731     tempLong = rectWinRect.bottom - rectWinRect.top;
01732 
01733 
01734     //Format our INT32
01735     temp.MakeMsg(_R(IDS_HTMLEXPORT_NUMBERFORMAT), tempLong);
01736 
01737     nChars += camStrlen(temp);
01738     nChars += camStrlen(_T("\""));
01739 
01740 ************************************************************************************/
01741 
01742     //Now the remaining details...
01743     nChars += camStrlen(_T(" usemap=\"#"));
01744     nChars += camStrlen( ms_Options.GetImagemapName() );
01745     nChars += camStrlen(_T("\" border=\"0\">\r\n"));
01746 
01747     return nChars*sizeof(TCHAR);
01748 }


Member Data Documentation

BOOL ImagemapFilter::BackgroundRedrawState [protected]
 

Definition at line 222 of file filtimag.h.

BOOL ImagemapFilter::BackgroundRedrawStateSet [protected]
 

Definition at line 221 of file filtimag.h.

ImagemapRenderRegion* ImagemapFilter::m_pRegion [protected]
 

Definition at line 217 of file filtimag.h.

ImagemapFilterOptions ImagemapFilter::ms_Options = ImagemapFilterOptions() [static, protected]
 

Definition at line 214 of file filtimag.h.

TCHAR ImagemapFilter::ms_strAllRectangles = _T("ExportImagemap\\AllRectangles") [static, private]
 

Definition at line 228 of file filtimag.h.

TCHAR ImagemapFilter::ms_strApprox = _T("ExportImagemap\\CurveApproximation") [static, private]
 

Definition at line 227 of file filtimag.h.

TCHAR ImagemapFilter::ms_strClipboard = _T("ExportImagemap\\Clipboard") [static, private]
 

Definition at line 229 of file filtimag.h.

TCHAR ImagemapFilter::ms_strFile = _T("ExportImagemap\\File") [static, private]
 

Definition at line 230 of file filtimag.h.

TCHAR ImagemapFilter::ms_strInsert = _T("ExportImagemap\\Insert") [static, private]
 

Definition at line 231 of file filtimag.h.

DocView* ImagemapFilter::pView [protected]
 

Definition at line 220 of file filtimag.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:55:23 2007 for Camelot by  doxygen 1.4.4