OILFilter Class Reference

This class is used to encapsulate the platform specific features of a filter. Every Filter object has a pointer to an OILFilter object. For example, under Windows, it holds the file extensions that this file understands. More...

#include <oilfltrs.h>

Inheritance diagram for OILFilter:

AccusoftBMPOILFilter AccusoftOILFilter AdobeColourSwatchOILFilter AdobeColourTableOILFilter AI5EPSOILFilter AI8EPSOILFilter AIEPSOILFilter AldusFormatOILFilter ArtWorksEPSOILFilter BMPOILFilter BrookTroutOILFilter CALSOILFilter CamelotEPSOILFilter CDROILFilter CMX16OILFilter CMX32OILFilter CMXImportOILFilter Corel3EPSOILFilter Corel4EPSOILFilter CorelPaletteFileOILFilter DCXOILFilter DrawOILFilter DXFOILFilter EnhancedMetaFileOILFilter FlareTemplateOILFilter FlashOILFilter FreeHandEPSOILFilter GIFOILFilter GX2OILFilter HaloCUTOILFilter HTMLOILFilter IFFOILFilter ImageMagickOILFilter ImagemapOILFilter IMGOILFilter IOCAOILFilter JCWColourOILFilter JPEGExportOILFilter JPEGImportOILFilter JPEGOILFilter KOFAXOILFilter LaserDataOILFilter MacPaintOILFilter MetaFileOILFilter MSIconsOILFilter MSPaintOILFilter MSPaletteOILFilter NativeOILFilter OILFilterFamily PBMOILFilter PCXOILFilter PGMOILFilter PhotoCDOILFilter PhotoShopEPSOILFilter PhotoShopOILFilter PICTOILFilter PluginOILFilter PNGOILFilter PPMOILFilter PSPPaletteOILFilter SpriteOILFilter SUNOILFilter TARGAOILFilter TIFFOILFilter WebOILFilter WPGOILFilter XWindowsOILFilter List of all members.

Public Member Functions

 OILFilter ()
virtual ~OILFilter ()
 OILFilter (Filter *pFilter)
 Initialise an OILFilter object, and link it to its parent Filter.
virtual TCHARConstructFilterString (UINT32 NumberToExport=1)
 Construct a COMMDLG filter definition string to put in the drop-down list of filters in the dialog box.
virtual String_64 GetFilterName (UINT32 NumberToExport)
 Allows derived classes to supply differnt filter names.
BOOL DoesExtensionOfFileMatch (CCLexFile *File)
 Sees if the extension of the given file matches one of the extensions given in the filter extension string. Used for ensuring a good match in filters.cpp.
BOOL DoesExtensionOfPathNameMatch (PathName *Path)
 Sees if the extension of the given pathname matches one of the extensions given in the filter extension string. Used for ensuring a good match in filters.cpp and stuff.
BOOL FixExtensionOfPathName (PathName *Path)
 Replace the extension in the pathname supplied with one for this filter. If more than one extension exists then replace with the first available one.

Static Public Member Functions

static BOOL InitFilters (List &)
 Scans all OILy filters to find out which filters are available for use, and instantiates one of each, and holds them in a list.
static BOOL CreatePluginFilters (List &)
 Creates a filter object for each installed plugin filter.

Public Attributes

String_64 FilterName
String_32 FilterExt
INT32 Position
FilterParent

Private Member Functions

 CC_DECLARE_MEMDUMP (OILFilter)

Detailed Description

This class is used to encapsulate the platform specific features of a filter. Every Filter object has a pointer to an OILFilter object. For example, under Windows, it holds the file extensions that this file understands.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/03/94
See also:
Filter

Definition at line 124 of file oilfltrs.h.


Constructor & Destructor Documentation

OILFilter::OILFilter  )  [inline]
 

Definition at line 129 of file oilfltrs.h.

00129 {}

virtual OILFilter::~OILFilter  )  [inline, virtual]
 

Definition at line 130 of file oilfltrs.h.

00130 { }

OILFilter::OILFilter Filter pFilter  ) 
 

Initialise an OILFilter object, and link it to its parent Filter.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/07/94
Parameters:
pFilter - the filter that this OILFilter object belongs to. [INPUTS]
Returns:
Errors: ENSURe failure if pFilter is NULL
See also:
-

Definition at line 176 of file oilfltrs.cpp.

00177 {
00178     ENSURE(pFilter != NULL, "No parent filter for OILFilter object");
00179 
00180     Position = -1; 
00181     Parent = pFilter;
00182 }


Member Function Documentation

OILFilter::CC_DECLARE_MEMDUMP OILFilter   )  [private]
 

TCHAR * OILFilter::ConstructFilterString UINT32  NumberToExport = 1  )  [virtual]
 

Construct a COMMDLG filter definition string to put in the drop-down list of filters in the dialog box.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/07/94
Parameters:
NumberToExport - The number of files being exported (allows different names) [INPUTS]
Returns:
Pointer to the string for this filter. This is a pointer to a static buffer, so it should be used immediately, and the caller should not attempt to deallocate this string.
See also:
OILFilter; OpMenuImport; OpMenuExport

Reimplemented in OILFilterFamily.

Definition at line 455 of file oilfltrs.cpp.

00456 {
00457     // Load in the filter name and extensions...
00458     static String_128 FilterStr;
00459     String_32 Extensions;
00460 
00461     FilterStr = GetFilterName(NumberToExport);
00462 
00463     // Construct the filter string from these two strings:
00464     FilterStr += _T(" (");
00465 
00466     // Extract each extension and see if we need to add it
00467     String_32 ExtStr;
00468     ExtStr = FilterExt;
00469 
00470     TCHAR*  pPointer;
00471     TCHAR*  pExt = camStrtok( (TCHAR*)ExtStr, _T(","), &pPointer );
00472     BOOL NoneFound = TRUE;
00473 
00474     while (pExt != NULL)
00475     {
00476         if (camStrstr((TCHAR *) Extensions, pExt) == NULL)
00477         {
00478             // Not already present - add the string.
00479             if (!NoneFound)
00480                 // Don't add a semi-colon if this is the first one we find.
00481                 Extensions += _T(";");
00482             
00483             String_16 Ext( pExt );
00484             Extensions += _T("*.");
00485             Ext.toLower();
00486             Extensions += Ext;
00487             
00488             Extensions += _T(";*.");
00489             Ext.toUpper();
00490             Extensions += Ext;
00491 
00492             NoneFound = FALSE;
00493         }
00494 
00495         pExt = camStrtok( NULL, _T(","), &pPointer );
00496     }
00497 
00498     FilterStr += Extensions;
00499     FilterStr += _T(")|");
00500     FilterStr += Extensions;
00501 
00502     // Return a pointer to the string.
00503     return (TCHAR *) FilterStr;
00504 }

BOOL OILFilter::CreatePluginFilters List FilterList  )  [static]
 

Creates a filter object for each installed plugin filter.

Author:
Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/01/2005
Parameters:
FilterList - [INPUTS]
Returns:
TRUE if ok, FALSE if bother

Definition at line 341 of file oilfltrs.cpp.

00342 {
00343     PORTNOTETRACE("filters","OILFilter::CreatePluginFilters - bodged");
00344 #if 0
00345     PluginNativeFilter* pFilter = new PluginNativeFilter;
00346     if (pFilter == NULL)
00347         return FALSE;
00348 
00349     if (pFilter->Init( (xmlNode*)NULL ))
00350         FilterList.AddTail(pFilter);
00351     else
00352         delete pFilter;
00353 #endif
00354 
00355     // Check the config dir exists, if not bomb out
00356     wxString    strConfigPath( (TCHAR*)CCamApp::GetResourceDirectory() );
00357     strConfigPath += _T("/filters");
00358     TRACEUSER( "jlh92", _T("Using filter discovery directory \"%s\"\n"), PCTSTR(strConfigPath) );
00359     if( !wxDir::Exists( strConfigPath ) )
00360     {
00361         // We'll try default location under debug to make life easier
00362 #if defined(_DEBUG)
00363         strConfigPath = _T("/usr/share/xaralx/filters");
00364         if( !wxDir::Exists( strConfigPath ) )
00365 #endif
00366             return TRUE;
00367     }
00368 
00369     TRACEUSER( "luke", _T("Using %s as filter store\n"), PCTSTR(strConfigPath) );
00370 
00371     // Setup the directory scan
00372     wxDir   dir( strConfigPath );
00373     if( !dir.IsOpened() )
00374     {
00375         // wxDir is susposed to explain why this failed, so we can just 
00376         // bomb-out
00377         return FALSE;
00378     }
00379     
00380     // Scan all files in directory
00381     wxString    strFilename;
00382     bool        fOk = dir.GetFirst( &strFilename, _T("*"), wxDIR_FILES );
00383     while( fOk )
00384     {
00385         strFilename = strConfigPath + _T("/") + strFilename;
00386         
00387         // Convert the filename to ASCII
00388         size_t  cchFile = strFilename.Length();
00389         PSTR    pszFile = (PSTR)alloca( sizeof(char) * ( cchFile + 1 ) );
00390         camWcstombs( pszFile, (PCTSTR)strFilename, cchFile );
00391         pszFile[cchFile] = '\0';
00392         
00393         // Open the xml file
00394         xmlDoc*     pDoc = xmlReadFile( pszFile, NULL, 0 );
00395         if( NULL != pDoc )
00396         {
00397             // Scan the root elements for FilterConfig element
00398             xmlNode* pRootElement = xmlDocGetRootElement( pDoc );
00399             xmlNode* pConfigElem  = NULL;
00400             for( xmlNode* pNode = pRootElement; NULL != pNode; pNode = pNode->next )
00401             {
00402                 if( XML_ELEMENT_NODE == pNode->type &&
00403                     0 == strcmp( "FilterConfig", PCSTR(pNode->name) ) )
00404                 {
00405                     pConfigElem = pNode;
00406                     break;
00407                 }
00408             }
00409             
00410             if( NULL != pConfigElem )
00411             {
00412                 // Scan the elements below FilterConfig for filters
00413                 for( xmlNode* pNode = pConfigElem->children; NULL != pNode; pNode = pNode->next )
00414                 {
00415                     if( XML_ELEMENT_NODE == pNode->type &&
00416                         0 == strcmp( "Filter", PCSTR(pNode->name) ) )
00417                     {
00418                         // Create a new filter, Init it and add to list if success
00419                         // Note will be auto deleted if not added
00420                         std::auto_ptr<PluginNativeFilter> pFilter( new PluginNativeFilter );
00421                         if( pFilter->Init( pNode ) )
00422                             FilterList.AddTail( pFilter.release() );
00423                     }
00424                 }
00425             }
00426 
00427             xmlFreeDoc( pDoc );
00428             pDoc = NULL;
00429         }
00430         
00431         fOk = dir.GetNext( &strFilename );
00432     }
00433     
00434     return TRUE;
00435 }

BOOL OILFilter::DoesExtensionOfFileMatch CCLexFile File  ) 
 

Sees if the extension of the given file matches one of the extensions given in the filter extension string. Used for ensuring a good match in filters.cpp.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/03/95

Definition at line 649 of file oilfltrs.cpp.

00650 {
00651     ERROR2IF(File == NULL,FALSE,"OILFilter::DoesExtensionOfFileMatch File supplied is null");
00652 
00653 TRACEUSER( "Ben", _T("Checking extension for filter %s\n"), (TCHAR *)FilterName);
00654     if(File->IsKindOf(CC_RUNTIME_CLASS(CCDiskFile)))
00655     {
00656         // check the filename
00657         CCDiskFile *pDiskFile = (CCDiskFile *)File;
00658         PathName Path;
00659 
00660         Path = pDiskFile->GetPathName();
00661 
00662         return DoesExtensionOfPathNameMatch(&Path);
00663     }
00664 
00665     return FALSE;
00666 }

BOOL OILFilter::DoesExtensionOfPathNameMatch PathName Path  ) 
 

Sees if the extension of the given pathname matches one of the extensions given in the filter extension string. Used for ensuring a good match in filters.cpp and stuff.

Author:
Ben_Summers (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/05/95

Definition at line 681 of file oilfltrs.cpp.

00682 {
00683     ERROR2IF(Path == NULL,FALSE,"OILFilter::DoesExtensionOfPathNameMatch Path supplied is null");
00684 
00685     String_256 Ext;
00686     TCHAR *fe;
00687     TCHAR *pex;
00688     TCHAR ex[256];
00689 
00690     Ext = Path->GetType();
00691 
00692     // Retrieve a copy of the filter extension(s) defined to this filter 
00693     fe = FilterExt;
00694     pex = Ext;
00695 
00696     INT32 l = 0;
00697     while(pex[l] != _T('\0'))
00698     {
00699         ex[l] = camTolower(pex[l]);
00700         l++;
00701     }
00702     ex[l] = _T('\0');
00703 
00704 TRACEUSER( "Ben", _T("Checking extension matches, of file = '%s', supported = '%s'\nLard\n"), (TCHAR *)ex, fe);
00705     if(ex[0] == _T('\0'))
00706     {
00707         // it's a blank extension. It can't match then, can it?
00708 TRACEUSER( "Ben", _T("File didn't have an extension\n"));
00709         return FALSE;
00710     }
00711 
00712     // see if the extension is in the list of supported extensions in the filter
00713     if(camStrstr(fe, (ex[0] == _T('.'))?(ex + 1):ex) != NULL)
00714         return TRUE;
00715 
00716     return FALSE;
00717 }

BOOL OILFilter::FixExtensionOfPathName PathName Path  ) 
 

Replace the extension in the pathname supplied with one for this filter. If more than one extension exists then replace with the first available one.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
04/01/96
Parameters:
Path the pathname of the file to be fixed [OUTPUTS]
Returns:
True if replace the extension ok, False otherwise.

Definition at line 733 of file oilfltrs.cpp.

00734 {
00735     ERROR2IF(Path == NULL,FALSE,"OILFilter::FixExtensionOfPathName Path supplied is null");
00736 
00737     // Retrieve a copy of the filter extension(s) defined to this filter 
00738     String_256 ExtStr = FilterExt;
00739         
00740     // If there is no filter extension string then all we can do is return False
00741     if (ExtStr.IsEmpty())
00742         return FALSE;
00743 
00744     // Filters might have multiple extensions listed separated by commas
00745     // so use first e.g. AI eps filter has ai and eps.
00746     // Work out the position of the first separator character, - 1 if none
00747     INT32   Position;
00748     String_8 SepMark = _T(",");
00749     Position = ExtStr.Sub(SepMark);
00750     // If comma separator was found use up to the separator 
00751     if (Position > 0)
00752         ExtStr.Left(&ExtStr, Position);
00753 
00754     // Put the found extension string in the path we were told to fix
00755     Path->SetType(ExtStr);
00756     
00757     return FALSE;
00758 }

String_64 OILFilter::GetFilterName UINT32  NumberToExport  )  [virtual]
 

Allows derived classes to supply differnt filter names.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/6/96
Parameters:
NumberToExport - the number of files being exported. [INPUTS]
Returns:
The name of the filter

Reimplemented in GIFOILFilter.

Definition at line 517 of file oilfltrs.cpp.

00518 {
00519     return FilterName;
00520 }

BOOL OILFilter::InitFilters List FilterList  )  [static]
 

Scans all OILy filters to find out which filters are available for use, and instantiates one of each, and holds them in a list.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/02/94
Parameters:
The list of filters to which the OILy filters should be added. [INPUTS]
The updated list of filters. [OUTPUTS]
Returns:
TRUE if initialised ok, FALSE if not.

Errors: Out of memory (if a filter fails to initialise for other reasons then an error is reported, but Camelot will still start up ok, i.e. TRUE is returned).

See also:
Filter::InitFilters

Definition at line 222 of file oilfltrs.cpp.

00223 {
00224     // Find the OILy filters
00225     Filter *pFilter;
00226 
00227 #if !defined(EXCLUDE_FROM_RALPH)
00228 
00229     if (!CreatePluginFilters(FilterList))
00230     {
00231         // Error has already been set
00232         return(FALSE);
00233     }
00234 
00235 #if !defined(EXCLUDE_FROM_XARALX)
00236     // Create, initialise and install the Windows MetaFile import filter
00237     ADD_FILTER(MetaFileFilter)
00238 
00239     // If the OS can do enhanced metafiles then do them
00240     if (IsWin32NT() || IsWin32c())
00241     {
00242         ADD_FILTER(EnhancedMetaFilter)
00243     }
00244 
00245     ADD_FILTER(MSPaletteFilter)
00246     ADD_FILTER(PaintShopProPaletteFilter)
00247 
00248 //  AldusFormatFilter::InitAll(FilterList);
00249 
00250     // Call the init function of the main external filters class so that the Accusoft DLL
00251     // gets loaded. Acts as a dummy filter that can neither import nor export.
00252     // If it gets the DLL then it initialises each of the filters otherwise it will exit
00253     // from the function immediately.
00254 
00255     // WEBSTER-Martin-19/12/96 no Accusoft
00256 #ifndef WEBSTER
00257     ADD_FILTER(AccusoftFilters)
00258 
00259     // Create, initialise and install the external filters supplied by the Accusoft software.
00260     // These are at present supplied in the Intel and Mac directories as we have Intel versions
00261     // but no MAC versions. The Mac versions just do nothing at present except return FALSE.
00262     // Hence the first filter will fail and we will immediately return TRUE to the caller.
00263     ADD_FILTER(AccusoftBMPFilter)                   // Mac version fails and returns here
00264     ADD_FILTER(BrookTroutFilter)                    
00265     ADD_FILTER(CALSFilter)
00266     ADD_FILTER(DCXFilter)
00267     ADD_FILTER(GX2Filter)
00268     ADD_FILTER(IFFFilter)
00269     ADD_FILTER(IMGFilter)
00270     ADD_FILTER(IOCAFilter)
00271     ADD_FILTER(HaloCUTFilter)
00272     ADD_FILTER(KOFAXFilter)
00273     ADD_FILTER(LaserDataFilter)
00274     ADD_FILTER(MacPaintFilter)
00275     ADD_FILTER(MSIconsFilter)               
00276     ADD_FILTER(MSPaintFilter)
00277     ADD_FILTER(PCXFilter)
00278     ADD_FILTER(PICTFilter)
00279     ADD_FILTER(PhotoCDFilter)
00280     ADD_FILTER(PhotoShopFilter)
00281     ADD_FILTER(SUNFilter)
00282     ADD_FILTER(TARGAFilter)
00283     ADD_FILTER(WPGFilter)
00284     ADD_FILTER(XWindowsFilter)
00285 
00286     // Preview filters
00287     ADD_FILTER(AccPreviewFilter)
00288     ADD_FILTER(PreviewFilterTIFF)   //this is still an Accusoft filter
00289 
00290 #endif //WEBSTER
00291 
00292 #endif  // EXCLUDE_FROM_XARALX
00293 
00294     ADD_FILTER(PPMFilter)
00295     ADD_FILTER(PGMFilter)
00296     ADD_FILTER(PBMFilter)
00297 #if !defined(EXCLUDE_FROM_XARALX)
00298     ADD_FILTER(SpriteFilter)
00299 #endif
00300 
00301 //WEBSTER-Martin-19/12/96
00302 // possibly these next ones should now be in Filter::InitFilters as it's native code now
00303 
00304 #if defined(EXCLUDE_FROM_XARALX)
00305     ADD_FILTER(JPEGImportFilter)
00306 #endif
00307 
00308     // Add the Preview Bitmap Filter
00309     // Tricky one this. Don't really need this any more (14/3/97)- its only use is the 
00310     // PreviewFilter::PreviewBitmapSize static that has historically been used all over the place
00311     ADD_FILTER(PreviewFilter)
00312 
00313     // Add the preview bitmap filters that we can use in the new native/web format
00314     ADD_FILTER(PreviewFilterBMP)
00315     ADD_FILTER(PreviewFilterGIF)
00316     ADD_FILTER(PreviewFilterJPEG)
00317     ADD_FILTER(PreviewFilterPNG)
00318     ADD_FILTER(ThumbnailFilterPNG)
00319 
00320 #endif
00321 
00322     // All ok
00323     return TRUE;
00324 }


Member Data Documentation

String_32 OILFilter::FilterExt
 

Definition at line 135 of file oilfltrs.h.

String_64 OILFilter::FilterName
 

Definition at line 134 of file oilfltrs.h.

Filter* OILFilter::Parent
 

Definition at line 141 of file oilfltrs.h.

INT32 OILFilter::Position
 

Definition at line 139 of file oilfltrs.h.


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