xpfilter.cpp

Go to the documentation of this file.
00001 // $Id: xpfilter.cpp 1771 2007-06-17 20:14:43Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 //
00099 // The Native file format for Camelot first version.
00100 // This should be the true all singing replacement for the bodge EPS form.
00101 
00102 /*
00103 */
00104 
00105 #include "camtypes.h"
00106 #include "xpfilter.h"
00107 //#include "xpfres.h"
00108 #include "xpoilflt.h"
00109 #include "xpfrgn.h"
00110 #include "xpfcaps.h"
00111 #include "cxftags.h"
00112 #include "chapter.h"
00113 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 //#include "filtrres.h"
00115 #include "nodedoc.h"
00116 #include "progress.h"
00117 
00118 #include "camprocess.h"
00119 #include "bmpcomp.h"
00120 #include "grndbmp.h"
00121 
00122 // An implement to match the Declare in the .h file.
00123 CC_IMPLEMENT_DYNAMIC(PluginNativeFilter, CamelotNativeFilter);
00124 
00125 // This will get Camelot to display the filename and linenumber of any memory allocations
00126 // that are not released at program exit
00127 #define new CAM_DEBUG_NEW
00128 
00129 
00130 /********************************************************************************************
00131 
00132 >   PluginNativeFilter::PluginNativeFilter()
00133 
00134     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00135     Created:    25/5/96
00136     Purpose:    Constructor for the Native save/load filter.
00137 
00138 ********************************************************************************************/
00139 
00140 PluginNativeFilter::PluginNativeFilter()
00141 {
00142     m_pNewTree = NULL;
00143     m_ProgressOffset = 0;
00144     m_bSaveXPEBitmaps = TRUE;   // For now we will default this to saving out the bitmaps
00145     m_bPreviewBitmap = FALSE;
00146     m_BoundsLevel = BWL_NONE;
00147     m_BitmapCompression = 200;      // Default to full PNG quality
00148     m_BitmapCount = 0;
00149 }
00150 
00151 
00152 
00153 
00154 /********************************************************************************************
00155 
00156 >   PluginNativeFilter::~PluginNativeFilter()
00157 
00158     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00159     Created:    25/5/96
00160     Purpose:    Tidies up when the filter is destroyed.
00161 
00162 ********************************************************************************************/
00163 
00164 PluginNativeFilter::~PluginNativeFilter()
00165 {
00166 }
00167 
00168 /********************************************************************************************
00169 
00170 >   BOOL PluginNativeFilter::Init(const CLSID& rCLSID)
00171 
00172     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00173     Created:    25/5/96
00174     Returns:    TRUE if it worked, FALSE if it failed
00175     Purpose:    Initalises the Filter ready for use. Will fail if it can not get enough
00176                 memory to work with.
00177 
00178 ********************************************************************************************/
00179 
00180 BOOL PluginNativeFilter::Init( xmlNode* pFilterNode )
00181 {
00182     // Get the OILFilter object
00183     PluginOILFilter* pPluginOILFilter = new PluginOILFilter(this);
00184     pOILFilter = pPluginOILFilter;
00185     if (pOILFilter == NULL)
00186         return FALSE;
00187 
00188     if (!pPluginOILFilter->Init( pFilterNode ))
00189         return(FALSE);
00190 
00191     Flags.CanImport = pPluginOILFilter->IsImport();
00192     Flags.CanExport = pPluginOILFilter->IsExport();
00193 
00194     // Load the description strings
00195     FilterName = pPluginOILFilter->FilterName;
00196     FilterInfo = _T("Temp Info String");
00197 
00198     BOOL ok = CreateRecordHandlers();
00199 
00200 /*  if (Camelot.DeclareSection("Filters", 10))
00201     {
00202         // Preference to turn native file compression on or off
00203         Camelot.DeclarePref( NULL, "CompressV2Format", &BaseCamelotFilter::CompressNative, 0, 1 );
00204         // Preference to turn xpe bitmap saving on or off
00205         Camelot.DeclarePref( NULL, "SaveXPEBitmaps", &BaseCamelotFilter::SaveXPEBitmaps, 0, 1 );
00206         // Preference to decide what bitmap format to use for preview bitmaps 
00207         Camelot.DeclarePref( NULL, "PreviewBitmapFilterType", &BaseCamelotFilter::PreviewBitmapFilterType, 0, 4 );
00208         // Preference for the optional export as web pathname when native saving
00209         Camelot.DeclarePref( NULL, "DefaultWebExportFilterPath", &BaseCamelotFilter::DefaultExportPath);
00210         // Preference to turn native file checking for similar paths on or off
00211         Camelot.DeclarePref( NULL, "NativeCheckSimilarPaths", &BaseCamelotFilter::NativeCheckSimilarPaths, 0, 1 );
00212     }*/
00213 
00214     return ok;
00215 }
00216 
00217 
00218 /********************************************************************************************
00219 
00220 >   virtual INT32 PluginNativeFilter::HowCompatible( PathName& Filename, ADDR  HeaderStart,
00221                                                     UINT32 HeaderSize,
00222                                                     UINT32 FileSize )
00223     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
00224     Created:    28/01/2005
00225     Inputs:     FileName    The name of the file being imported
00226                 HeaderStart The address of the start of the data from the file which needs checking
00227                 HeaderSize  The size of this data that we should check
00228                 FileSize    The total size of the file
00229     Returns:    10 if the file is fully recognised or 0 otherwise
00230     Purpose:    returns value in range 0 to 10 which indicates how much we like this file:
00231                     0 => "Definitely Not"
00232                     10 => "Yes Sir, that's my file format"
00233 
00234 ********************************************************************************************/
00235 
00236 INT32 PluginNativeFilter::HowCompatible( PathName& Filename, ADDR HeaderStart, UINT32 HeaderSize,
00237                            UINT32 FileSize )
00238 {
00239     // We ignore the passed in buffer and just pass the filename to the external object
00240     INT32 HowCompatible = 0;
00241 
00242     // If we don't have a filename then don't bother for now    
00243     String_256 sFilename = Filename.GetPath();
00244     if (!sFilename.IsEmpty())
00245     {
00246         PluginOILFilter* pPluginOILFilter = (PluginOILFilter*)pOILFilter;
00247         HowCompatible = pPluginOILFilter->HowCompatible(Filename);
00248     }
00249 
00250     // Return the found value to the caller.
00251     TRACEUSER( "Gerry", _T("PluginNativeFilter::HowCompatible returning = %d\n"), HowCompatible);
00252     return HowCompatible;
00253 }
00254 
00255 
00256 
00257 /********************************************************************************************
00258 
00259 >   virtual BOOL PluginNativeFilter::DoImport(SelOperation* pOp, CCLexFile* pFile, Document* pDestDoc, 
00260                       BOOL AutoChosen, ImportPosition* pPos,
00261                       KernelBitmap** ppImportedBitmap,
00262                       DocCoord* pPosTranslate, String_256* URL)
00263 
00264     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
00265     Created:    27/01/2005
00266     Inputs:     Op - pointer to the operation that this input process is associated with.
00267                 pFile - The file that we should load the document from
00268                 DestDoc - The Document object which should hold the data read in from
00269                           the file.
00270                 AutoChosen - 
00271                 pPos - 
00272                 Pos -
00273                 ppImportedBitmap - this is used mainly in the bitfltr.cpp for the HTML
00274                 import filter. HTMLFilter::DoImport() needs a pointer to a kernel bitmap
00275                 to set the background bitmap up into Camelot.
00276                 pPosTranslate - This is used too by the HTMLFilter in order to do a formatting.
00277     Returns:    TRUE if the input operation worked ok, FALSE if not.
00278     Purpose:    Read the data from the specified file. 
00279     Errors:     Fails (returns FALSE) if the document structure is incorrect, or if there
00280                 is a problem with the file.
00281                 Assumes the caller will fail and end the operation if False is returned.
00282 
00283 ********************************************************************************************/
00284 
00285 BOOL PluginNativeFilter::DoImport(SelOperation* pOp, CCLexFile* pFile, Document* pDestDoc, 
00286                                  BOOL AutoChosen, ImportPosition* pPos,
00287                                  KernelBitmap** ppImportedBitmap,
00288                                  DocCoord* pPosTranslate, String_256* URL)
00289 {
00290     ERROR2IF(FALSE, pOp == NULL,"PluginNativeFilter::DoImport null operation!");
00291     ERROR2IF(FALSE, pFile == NULL,"PluginNativeFilter::DoImport null file!");
00292     ERROR2IF(FALSE, pDestDoc == NULL,"PluginNativeFilter::DoImport null document!");
00293 
00294     TRACEUSER( "Gerry", _T("PluginNativeFilter::DoImport"));
00295 
00296     PluginOILFilter* pPluginOILFilter = (PluginOILFilter*)pOILFilter;
00297 
00298     // Make sure the OIL filter gets cleaned up on exit
00299     AutoCleanOILFilter TidyFilter(pPluginOILFilter);
00300 
00301     // Call OIL layer to create a new CCLexFile derived object containing the 
00302     // translated data
00303     CCLexFile* pNewFile = NULL;
00304     if (!pPluginOILFilter->GetImportFile(pFile, &pNewFile))
00305     {
00306         TRACEUSER( "Gerry", _T("Failed to get import file\n"));
00307         return(FALSE);
00308     }
00309 
00310     // Make sure the new file object gets deleted on exit
00311     AutoDeleteCCObject TidyFile(pNewFile);
00312 
00313     TRACEUSER( "Gerry", _T("Calling CamelotNativeFilter::DoImport\n"));
00314 
00315     // Call the baseclass DoImport method passing the new file
00316     if (!CamelotNativeFilter::DoImport(pOp, pNewFile, pDestDoc, AutoChosen, pPos, ppImportedBitmap, pPosTranslate, URL))
00317     {
00318         TRACEUSER( "Gerry", _T("Failed in baseclass DoImport\n"));
00319         return(FALSE);
00320     }
00321 
00322     return(TRUE);
00323 }
00324 
00325 
00326 /********************************************************************************************
00327 
00328 >   virtual BOOL PluginNativeFilter::DoExport(Operation *pOp, CCLexFile* pFile,
00329                                                PathName * pPath, Document *pDoc)
00330 
00331     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
00332     Created:    27/01/2005
00333     Inputs:     pOp - the operation that started the export off
00334                 pFile - the file to put the exported data into
00335                 pPath - the pathname of the file to be exported to
00336                 pDoc - the document to export
00337                 ShowOptions - Are the export options needed?
00338     Returns:    TRUE if worked, FALSE if failed.
00339     Purpose:    Exports the current document out to file. Uses the virtual functions of this
00340                 class. Do not override unless really necessary.
00341     SeeAlso:    GetExportOptions; PrepareToExport; CleanUpAfterExport;
00342 
00343 ********************************************************************************************/
00344 
00345 BOOL PluginNativeFilter::DoExport ( Operation* pOp, CCLexFile* pFile, PathName* pPath,
00346                                    Document* pDoc, BOOL ShowOptions )
00347 {
00348     ERROR2IF(pOp == NULL, FALSE,"PluginNativeFilter::DoExport no export operation");
00349     ERROR2IF(pFile == NULL, FALSE,"PluginNativeFilter::DoExport no file to export to");
00350     ERROR2IF(pPath == NULL, FALSE,"PluginNativeFilter::DoExport no export pathname");
00351     ERROR2IF(pDoc == NULL, FALSE,"PluginNativeFilter::DoExport no document to export");
00352 
00353     // Set up document pointer in the baseclass
00354     // This is required so that GetExportNode will work
00355     TheDocument = pDoc;
00356 
00357     PluginOILFilter* pPluginOILFilter = (PluginOILFilter*)pOILFilter;
00358 
00359     // Make sure the OIL filter gets cleaned up on exit
00360     AutoCleanOILFilter TidyFilter(pPluginOILFilter);
00361 
00362     // Call OIL layer to get a new CCLexFile derived object that the Xar data
00363     // must be exported to
00364     CCLexFile* pNewFile = NULL;
00365     if (!pPluginOILFilter->GetExportFile(pPath, &pNewFile))
00366     {
00367         TRACEUSER( "Gerry", _T("Failed to get an output file\n"));
00368         return(FALSE);
00369     }
00370 
00371     // Make sure the new file object gets deleted on exit
00372     AutoDeleteCCObject TidyFile(pNewFile);
00373 
00374     CapabilityTree PlugCaps;
00375 
00376     // Call OIL layer to set up the capabilities control object
00377     if (!pPluginOILFilter->GetCapabilities(pFile, pPath, &PlugCaps))
00378     {
00379         TRACEUSER( "Gerry", _T("Failed to get capabilities object\n"));
00380         return(FALSE);
00381     }
00382 
00383     // Make sure the bitmap list is empty
00384     m_BitmapList.DeleteAll();
00385 
00386     // Update our bounds write level
00387     m_BoundsLevel = PlugCaps.GetBoundsLevel();
00388 
00389     // Update our bitmap compression setting
00390     m_BitmapCompression = PlugCaps.GetBitmapCompression();
00391 
00392     // Update the preview bitmap setting
00393     m_bPreviewBitmap = PlugCaps.GetPreviewBitmap();
00394 
00395     KernelBitmap::SetCreateTracker(&m_BitmapList);
00396 
00397     // Convert the document according to the capabilites
00398     BOOL ok = GenerateExportData(&PlugCaps);
00399 
00400     KernelBitmap::SetCreateTracker(NULL);
00401 
00402     if (!ok)
00403     {
00404         TRACEUSER( "Gerry", _T("Failed to generate export data\n"));
00405 
00406         // Clean up any partial tree we have created
00407         if (m_pNewTree)
00408         {
00409             m_pNewTree->CascadeDelete();
00410             delete m_pNewTree;
00411             m_pNewTree = NULL;
00412         }
00413         return(FALSE);
00414     }
00415 
00416     // Reset the max progress bar limit to an approximation of the size of the Xar data
00417     SetTotalProgressBarCount(256*1024);
00418 
00419     ForceStatusExportMessage(_R(IDS_SAVING_XAR_DATA));
00420 
00421     // Call the baseclass DoExport method passing the new file object
00422     // This will call the GetExportData virtual function to get the 
00423     // document tree to be exported
00424     ok = CamelotNativeFilter::DoExport(pOp, pNewFile, pPath, pDoc, FALSE);
00425 
00426     UnforceStatusExportMessage();
00427 
00428     // Now cleanup the copy of the document
00429     if (m_pNewTree)
00430     {
00431         m_pNewTree->CascadeDelete();
00432         delete m_pNewTree;
00433         m_pNewTree = NULL;
00434     }
00435 
00436     // Now we must clean up the bitmap list
00437     // First we remove the head item
00438     KernelBmpListItem* pItem = (KernelBmpListItem*)m_BitmapList.RemoveHead();
00439     while (pItem)
00440     {
00441         // Delete the KernelBitmap to remove it from the document's list
00442         // and remove the reference on the OILBitmap
00443         if (pItem->m_pBmp)
00444             delete pItem->m_pBmp;
00445 
00446         // Delete the ListItem
00447         delete pItem;
00448 
00449         // Remove the next item from the list
00450         pItem = (KernelBmpListItem*)m_BitmapList.RemoveHead();
00451     }
00452 
00453     // Free up any unused bitmaps in the global list
00454     // (just deleting the KernelBitmaps doesn't seem to do it)
00455     Camelot.GetGlobalBitmapList()->DeleteAllUnusedBitmaps();
00456 
00457     // Make sure this is closed
00458     if (pNewFile->isOpen())
00459         pNewFile->close();
00460 
00461     if (!ok)
00462     {
00463         TRACEUSER( "Gerry", _T("Failed in baseclass DoExport\n"));
00464         return(FALSE);
00465     }
00466 
00467     String_64 Str(_R(IDS_EXPORTING_DOCUMENT));
00468     StartProgressBar(&Str);
00469     SetProgressBarCount(0);
00470     SetTotalProgressBarCount(100);
00471 
00472     // Call OIL layer to do the translation
00473     if (!pPluginOILFilter->DoExport(pNewFile, pPath))
00474     {
00475         TRACEUSER( "Gerry", _T("Failed to translate exported data\n"));
00476         return(FALSE);
00477     }
00478 
00479     EndProgressBar();
00480 
00481     return(TRUE);
00482 }
00483 
00484 
00485 BOOL PluginNativeFilter::GenerateExportData(CapabilityTree* pPlugCaps)
00486 {
00487     BOOL ok = TRUE;
00488 
00489     // Reset the count for GetNewBitmapName
00490     m_BitmapCount = 0;
00491 
00492     // Disable bitmap caching but remember the old state so we can set it back
00493     ScopedFlagSetter fsBitmapCacheing(NodeRenderableBounded::bEnableCacheing, FALSE);
00494 
00495     String_64 Str(_R(IDS_CONVERTING_DOCUMENT));
00496     StartProgressBar(&Str);
00497     SetTotalProgressBarCount(600);
00498     m_ProgressOffset = 0;
00499 
00500 //  UINT32 ThisPassCount = 0;
00501 //  UINT32 ThisPassTotal = 0;
00502 //  UINT32 NextPassCount = 0;
00503 
00504     // First we create a copy of the chapter node
00505     Node* pChapter = CamelotNativeFilter::GetExportNode();
00506     ERROR2IF(!IS_A(pChapter, Chapter), FALSE, "Export node is not a Chapter");
00507 
00508     Node* pParent = pChapter->FindParent();
00509     ERROR2IF(!IS_A(pParent, NodeDocument), FALSE, "Parent is not a NodeDocument");
00510 
00511     // Copy the NodeDocument as the root of our new tree
00512     m_pNewTree = pParent->PublicCopy();
00513 
00514     // Copy all of the children upto pChapter
00515     Node* pNode = pParent->FindFirstChild();
00516     while (pNode && pNode != pChapter)
00517     {
00518         pNode->CopyNode(m_pNewTree, LASTCHILD);
00519         pNode = pNode->FindNext();
00520     }
00521 
00522     Node* pNewChapter = pChapter->PublicCopy();
00523     if (pNewChapter)
00524         pNewChapter->AttachNode(m_pNewTree, LASTCHILD);
00525 
00526     XPFView* pXPFView = new XPFView();
00527     if (!pXPFView || !pXPFView->Init(pPlugCaps->GetRasteriseDPI()))
00528     {
00529         TRACEUSER( "Gerry", _T("Failed to create or init XPFView\n"));
00530         return(FALSE);
00531     }
00532 
00533     // Remember the current view and set the new view as current
00534     View* pOldView = View::GetCurrent();
00535     if (!pXPFView->SetCurrent())
00536     {
00537         TRACEUSER( "Gerry", _T("Failed to set XPFView as current\n"));
00538         return(FALSE);
00539     }
00540 
00541     View *pView = View::GetCurrent();
00542     if (pView)
00543     {
00544         // Must force background rendering off as otherwise we might get a partly
00545         // rendered drawing or object if it is complex.
00546 //      ForceBackgroundRedrawOff(pView);
00547     }
00548     else
00549     {
00550         ERROR2(FALSE, "PluginNativeFilter::GenerateExportData no current view");
00551     }
00552 
00553     // Then we loop through each spread
00554 //  BOOL bFirstSpread = TRUE;
00555     Node* pChild = pChapter->FindFirstChild();
00556     while (pChild)
00557     {
00558         if (IS_A(pChild, Spread))
00559         {
00560             Spread* pSpread = (Spread*)pChild;
00561 //          Spread* pNewSpread = NULL;
00562 
00563             // If spreads are being converted to bitmap then render a bitmap
00564             // and build a NodeBitmap to represent it
00565 
00566             // If spreads are being done natively then handle via XPFRenderRegion
00567 
00568             // Create and set up a new XPFRenderRegion
00569             XPFRenderRegion XPFRegion(this, pPlugCaps);
00570 
00571             // Attach a device to the scanning render region
00572             // Since this rr does no real rendering, it does not need a Device context
00573             XPFRegion.AttachDevice(pView, NULL, pSpread);
00574 
00575             // Get it ready to render
00576 //          XPFRegion.SetMatrix(ViewTrans);
00577 //          XPFRegion.SetClipRect(ClipRect);
00578             
00579             // Start the render region and return if it fails
00580             if (XPFRegion.StartRender())
00581             {           
00582                 XPFRenderCallback XPFCallback(this, &XPFRegion, pPlugCaps, 1);
00583                 XPFCallback.SetAttachContext(pNewChapter, LASTCHILD);
00584 
00585                 // Call RenderTree to do the rendering
00586                 XPFRegion.RenderTree(pSpread, FALSE, FALSE, &XPFCallback);
00587 
00588                 // Thats all the nodes rendered, so stop rendering
00589                 XPFRegion.StopRender();
00590             }
00591         }
00592         else
00593         {
00594             ok = pChild->CopyNode(pNewChapter, LASTCHILD);
00595         }
00596 
00597         // Get the next child node of the chapter
00598         pChild = pChild->FindNext();
00599     }
00600 
00601     if (ok)
00602     {
00603         // Now handle conversion pass 2 for the stroked conversion type
00604         m_ProgressOffset = 100;
00605         SetProgressBarCount(0);
00606         ok = DoConversionPassN(pPlugCaps, 2);
00607     }
00608 
00609     if (ok)
00610     {
00611         // Now handle conversion pass 3 for the bitmapfill conversion type
00612         m_ProgressOffset = 200;
00613         SetProgressBarCount(0);
00614         ok = DoConversionPassN(pPlugCaps, 3);
00615     }
00616 
00617     if (ok)
00618     {
00619         // Now handle conversion pass 4 for the bitmap conversion type
00620         m_ProgressOffset = 300;
00621         SetProgressBarCount(0);
00622         ok = DoConversionPassN(pPlugCaps, 4);
00623     }
00624 
00625     if (ok)
00626     {
00627         // Now handle conversion pass 5 for the bitmapspan conversion type
00628         m_ProgressOffset = 400;
00629         SetProgressBarCount(0);
00630         ok = DoConversionPassN(pPlugCaps, 5);
00631     }
00632 
00633     if (ok)
00634     {
00635         // Now handle the bitmap resampling pass
00636         m_ProgressOffset = 500;
00637         SetProgressBarCount(0);
00638         ok = DoBitmapResamplePass(pPlugCaps);
00639     }
00640 
00641     SetProgressBarCount(100);
00642 
00643     EndProgressBar();                   // Kill progess bar
00644 
00645     // Reset this so that the progress bar works for the rest of the export
00646     m_ProgressOffset = 0;
00647 
00648     if (pOldView)
00649         pOldView->SetCurrent();
00650 
00651     delete pXPFView;
00652 
00653     return(ok);
00654 }
00655 
00656 
00657 BOOL PluginNativeFilter::DoConversionPassN(CapabilityTree* pPlugCaps, INT32 ConvertPass)
00658 {
00659     TRACE( _T("DoConversionPassN(%d)\n"), ConvertPass);
00660 
00661     // Run a render loop and get the render callback to 
00662     // check the attrs in the render region for each renderable object 
00663     // and add any that require the bitmapfill conversion 
00664 
00665     View *pView = View::GetCurrent();
00666     ERROR2IF(pView == NULL, FALSE, "No current DocView in DoConversionPassN");
00667 
00668     Node* pChapter = m_pNewTree->FindFirstChild(CC_RUNTIME_CLASS(Chapter));
00669     ERROR2IF(pChapter == NULL, FALSE, "No chapter node in DoConversionPassN");
00670 
00671     // Loop through each spread
00672     Node* pChild = pChapter->FindFirstChild();
00673     while (pChild)
00674     {
00675         if (IS_A(pChild, Spread))
00676         {
00677             Spread* pSpread = (Spread*)pChild;
00678 
00679             // Create and set up a new XPFRenderRegion
00680             XPFRenderRegion XPFRegion(this, pPlugCaps);
00681 
00682             // Attach a device to the scanning render region
00683             // Since this rr does no real rendering, it does not need a Device context
00684             XPFRegion.AttachDevice(pView, NULL, pSpread);
00685 
00686             // Start the render region and return if it fails
00687             if (XPFRegion.StartRender())
00688             {           
00689                 // Create a render callback object to do the tricky stuff
00690                 XPFRenderCallback XPFCallback(this, &XPFRegion, pPlugCaps, ConvertPass);
00691 
00692                 // Call RenderTree to do the rendering
00693                 XPFRegion.RenderTree(pSpread, FALSE, FALSE, &XPFCallback);
00694 
00695                 // Thats all the nodes rendered, so stop rendering
00696                 XPFRegion.StopRender();
00697 
00698                 // Now we need to convert all the nodes in the list
00699                 if (!XPFCallback.ConvertNodes())
00700                 {
00701                     return(FALSE);
00702                 }
00703             }
00704             else
00705             {
00706                 ERROR2(FALSE, "StartRender failed");
00707             }
00708         }
00709 
00710         // Get the next child node of the chapter
00711         pChild = pChild->FindNext();
00712     }
00713 
00714     return(TRUE);
00715 }
00716 
00717 
00718 /****************************************************************************
00719 
00720 >   BOOL PluginNativeFilter::DoBitmapResamplePass(CapabilityTree* pPlugCaps)
00721 
00722     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
00723     Created:    04/08/2006
00724 
00725     Inputs:     pPlugCaps   - pointer to a CapabilityTree
00726     Returns:    TRUE if ok, FALSE if bother
00727     Purpose:
00728 
00729 ****************************************************************************/
00730 
00731 BOOL PluginNativeFilter::DoBitmapResamplePass(CapabilityTree* pPlugCaps)
00732 {
00733     if (!pPlugCaps->GetBitmapResample())
00734         return(TRUE);
00735 
00736     TRACE(_T("DoBitmapResamplePass"));
00737 
00738     Document* pDoc = Document::GetCurrent();
00739     ERROR2IF(pDoc == NULL, FALSE, "No current document in DoBitmapResamplePass");
00740 
00741     BitmapList* pBmpList = pDoc->GetBitmapList();
00742     ERROR2IF(pDoc == NULL, FALSE, "No bitmap list in DoBitmapResamplePass");
00743 
00744     // For each bitmap in the document's bitmap list
00745     KernelBitmap* pBitmap = (KernelBitmap*)(pBmpList->GetHead());
00746 
00747     while (pBitmap)
00748     {
00749         double MinDPI = 1e9;
00750 
00751         List NodeList;
00752 
00753         // Scan through new document tree finding all uses of the bitmap
00754         Node* pNode = m_pNewTree->FindFirstDepthFirst();
00755         while (pNode)
00756         {
00757             UINT32 Count = 0;
00758             BOOL bAdd = FALSE;
00759             KernelBitmap* pTestBitmap = pNode->EnumerateBitmaps(Count);
00760             while (pTestBitmap)
00761             {
00762                 if (pTestBitmap == pBitmap)
00763                 {
00764                     bAdd = TRUE;        // Add this node to the list
00765                     double DPI = pNode->GetEffectiveBitmapMinDPI(pTestBitmap);
00766                     if (DPI < MinDPI)
00767                         MinDPI = DPI;
00768                 }
00769 
00770                 // Get the next bitmap from the node
00771                 Count++;
00772                 pTestBitmap = pNode->EnumerateBitmaps(Count);
00773             }
00774 
00775             if (bAdd)
00776             {
00777                 NodeListItem* pItem = new NodeListItem(pNode);
00778                 if (pItem)
00779                     NodeList.AddTail(pItem);
00780             }
00781 
00782             // Get the next node
00783             pNode = pNode->FindNextDepthFirst(m_pNewTree);
00784         }
00785 
00786         // If a minimum has been found for this bitmap
00787         if (MinDPI < 1e9)
00788         {
00789             TRACE(_T("MinDPI = %f"), MinDPI);
00790 
00791             double ratio = pPlugCaps->GetRasteriseDPI() / MinDPI;
00792             // If the minimum dpi is above the resample dpi then
00793             if (ratio < 0.9)
00794             {
00795                 TRACE(_T("Resample bitmap"));
00796                 // Generate new bitmap with size so that minimum dpi is resample dpi
00797 
00798                 TRACE(_T("Actual size = (%d, %d)"), pBitmap->GetWidth(), pBitmap->GetHeight());
00799 
00800                 INT32 OutWidth = (INT32)(((double)pBitmap->GetWidth() * ratio) + 0.5);
00801                 INT32 OutHeight = (INT32)(((double)pBitmap->GetHeight() * ratio) + 0.5);
00802                 TRACE(_T("Needed size = (%d, %d)"), OutWidth, OutHeight);
00803 
00804                 KernelBitmap* pNewBitmap = NULL;
00805                 {
00806                     View* pView = View::GetCurrent();
00807                     Spread* pSpread = NULL;
00808                     BOOL bAlpha = pBitmap->IsTransparent();
00809                     Matrix ViewTrans;
00810                     FIXED16 TempScale(1.0);
00811                     double Dpi = 96.0;
00812                     DocRect BoundsRect(0, 0, OutWidth * 750, OutHeight * 750);
00813 
00814                     GRenderBitmap BitmapRR(BoundsRect, ViewTrans, TempScale, 32, Dpi);
00815                     if (bAlpha)
00816                         BitmapRR.m_DoCompression = TRUE;
00817                     BitmapRR.SetUsingSmoothedBitmaps(TRUE);     // Make sure we do high quality
00818                     BitmapRR.AttachDevice(pView, NULL, pSpread);
00819 
00820                     // Start rendering into the bitmap
00821                     if (!BitmapRR.StartRender())
00822                     {
00823                         ERROR2(FALSE, "StartRender failed in DoBitmapResamplePass");
00824                     }
00825 
00826                     BitmapRR.SaveContext();
00827 
00828                     // Best quality please
00829                     QualityAttribute *pQualAttr = new QualityAttribute();
00830                     pQualAttr->QualityValue.SetQuality(QUALITY_MAX);
00831                     BitmapRR.SetQuality(pQualAttr, TRUE);
00832 
00833                     // Simple bitmap fill which fills the whole shape
00834                     BitmapFillAttribute* pBitmapAttr = new BitmapFillAttribute;
00835                     pBitmapAttr->GetBitmapRef()->SetBitmap(pBitmap);
00836                     pBitmapAttr->StartPoint = BoundsRect.lo;
00837                     pBitmapAttr->EndPoint   = DocCoord(BoundsRect.hi.x, BoundsRect.lo.y);
00838                     pBitmapAttr->EndPoint2  = DocCoord(BoundsRect.lo.x, BoundsRect.hi.y);
00839 
00840                     // Set bitmap attribute, and get the render region to throw it away when it's finished
00841                     // with (hence the TRUE parameter).
00842                     BitmapRR.SetFillGeometry(pBitmapAttr, TRUE);
00843 
00844                     BitmapRR.SetLineColour(COLOUR_NONE);
00845 
00846                     Path RectPath;
00847                     if (RectPath.Initialise())
00848                     {
00849                         // Start at bottom left corner
00850                         RectPath.InsertMoveTo(BoundsRect.lo);
00851                         RectPath.InsertLineTo(DocCoord(BoundsRect.hi.x, BoundsRect.lo.y));
00852                         RectPath.InsertLineTo(BoundsRect.hi);
00853                         RectPath.InsertLineTo(DocCoord(BoundsRect.lo.x, BoundsRect.hi.y));
00854                         RectPath.InsertLineTo(BoundsRect.lo);
00855 
00856                         // Close the path properly
00857                         RectPath.CloseSubPath();
00858                         RectPath.IsFilled = TRUE;
00859                         RectPath.IsStroked = FALSE;
00860                         BitmapRR.DrawPath(&RectPath);
00861                     }
00862 
00863                     BitmapRR.RestoreContext();
00864 
00865                     // Stop rendering
00866                     BitmapRR.StopRender();
00867 
00868                     OILBitmap* pFullBitmap = BitmapRR.ExtractBitmap();
00869                     String_256 sName = GetNewBitmapName();
00870                     pFullBitmap->SetName(sName);
00871                     pNewBitmap = KernelBitmap::MakeKernelBitmap(pFullBitmap);
00872 
00873                     // Attach the bitmap to this document or a copy will be created when
00874                     // it is used in the attribute
00875                     BitmapList* pBmpList = NULL;
00876                     Document* pCurDoc = Document::GetCurrent();
00877                     if (pCurDoc)
00878                         pBmpList = pCurDoc->GetBitmapList();
00879 
00880                     // and then attach the bitmap (doesn't matter if BmpList is NULL)
00881                     pNewBitmap->Attach(pBmpList);
00882 
00883                     // Make sure we preserve the lossy flag
00884                     pNewBitmap->SetAsLossy(pBitmap->IsLossy());
00885                 }
00886 
00887                 if (pNewBitmap)
00888                 {
00889                     TRACE(_T("New bitmap = (%d, %d)"), pNewBitmap->GetWidth(), pNewBitmap->GetHeight());
00890 
00891                     // Loop through NodeList asking each node to replace the
00892                     // specified bitmap with this new one
00893 
00894                     NodeListItem* pItem = (NodeListItem*)(NodeList.GetHead());
00895                     while (pItem)
00896                     {
00897                         if (pItem->pNode)
00898                         {
00899                             if (!pItem->pNode->ReplaceBitmap(pBitmap, pNewBitmap))
00900                             {
00901                                 TRACE(_T("Failed to replace bitmap"));
00902                             }
00903                         }
00904 
00905                         pItem = (NodeListItem*)(NodeList.GetNext(pItem));
00906                     }
00907                 }
00908                 else
00909                 {
00910                     TRACE(_T("Failed to create new bitmap"));
00911                 }
00912             }
00913         }
00914 
00915         NodeList.DeleteAll();
00916         pBitmap = (KernelBitmap*)(pBmpList->GetNext(pBitmap));
00917     }
00918 
00919     return(TRUE);
00920 }
00921 
00922 
00923 /****************************************************************************
00924 
00925 >   virtual Node* PluginNativeFilter::GetExportNode()
00926 
00927     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
00928     Created:    01/02/2005
00929 
00930     Returns:    NULL in times of grief
00931     Purpose:    Returns a pointer to the first node to export
00932 
00933 ****************************************************************************/
00934 
00935 Node* PluginNativeFilter::GetExportNode()
00936 {
00937     if (m_pNewTree)
00938     {
00939         Node* pChapter = m_pNewTree->FindFirstChild(CC_RUNTIME_CLASS(Chapter));
00940         if (pChapter)
00941             return(pChapter);
00942     }
00943 
00944     return(CamelotNativeFilter::GetExportNode());
00945 }
00946 
00947 
00948 /****************************************************************************
00949 
00950 >   BOOL PluginNativeFilter::GetExportOptions( WebPrefsDlgParam *pPrefs )
00951 
00952     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
00953     Created:    26/01/2005
00954 
00955     Inputs:     pPrefs      - pointer to a WebPrefsDlgParam 
00956     Returns:    TRUE if ok, FALSE if bother
00957     Purpose:    Overrides base class so we can do our own thing
00958 
00959 ****************************************************************************/
00960 
00961 BOOL PluginNativeFilter::GetExportOptions( WebPrefsDlgParam *pPrefs )
00962 {
00963     // May want to call PrepareExport here
00964     
00965     return TRUE;
00966 }
00967 
00968 
00969 /********************************************************************************************
00970 
00971 >   virtual INT32 PluginNativeFilter::GetBitmapCompression()
00972 
00973     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00974     Created:    15/8/96
00975     Inputs:     -
00976     Returns:    The current state of the bitmap compression.
00977     Purpose:    Public access to the current bitmap compression which the user has requested
00978                 to use when saving bitmaps in the web format.
00979                 0 means maximum compression e.g. use JPEG filter at 0% lossy compression
00980                 100 means minimum compression e.g. use JPEG filter at 100% lossy compression
00981                 101 - 200 means lossless compression e.g. us PNG filter.
00982                 Could use the no bitmap compression at all e.g. use BMP filter. Unused at present.
00983                 (Very much like the JPEG compression percentage).
00984     Note:       This overrides the baseclass version to save in the proper native state
00985 
00986 ********************************************************************************************/
00987 
00988 INT32 PluginNativeFilter::GetBitmapCompression()
00989 {
00990     // Always use a lossless format such as PNG in native files
00991     return m_BitmapCompression;
00992 }
00993 
00994 /********************************************************************************************
00995 
00996 >   virtual BOOL PluginNativeFilter::GetPreviewBitmapExport()
00997 
00998     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00999     Created:    15/8/96
01000     Inputs:     -
01001     Returns:    The current state of the export preview bitmap.
01002     Purpose:    Public access to the current export preview bitmap which the user has requested
01003                 to use when saving bitmaps in the web format.
01004                 True means export a preview bitmap, False means do not.
01005     Note:       This overrides the baseclass version to save in the proper native state
01006 
01007 ********************************************************************************************/
01008 
01009 BOOL PluginNativeFilter::GetPreviewBitmapExport()
01010 {
01011     // Return TRUE if the plugin wants a preview bitmap and FALSE otherwise
01012     return m_bPreviewBitmap;
01013 }
01014 
01015 /********************************************************************************************
01016 
01017 >   virtual BOOL PluginNativeFilter::GetConvertTextToOutlines()
01018 
01019     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01020     Created:    15/8/96
01021     Inputs:     -
01022     Returns:    The current state of the convert text to outlines.
01023     Purpose:    Public access to the current convert text to outlines which the user has requested
01024                 to use when saving in the web format.
01025                 True means convert text to outlines, False means do not.
01026     Note:       This overrides the baseclass version to save in the proper native state
01027 
01028 ********************************************************************************************/
01029 
01030 BOOL PluginNativeFilter::GetConvertTextToOutlines()
01031 {
01032     // In native files ensure text is not converted to outlines
01033     return FALSE;
01034 }
01035 
01036 /********************************************************************************************
01037 
01038 >   virtual BOOL PluginNativeFilter::GetRemoveInvisibleLayers()
01039 
01040     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01041     Created:    15/8/96
01042     Inputs:     -
01043     Returns:    The current state of the remove invisible layers.
01044     Purpose:    Public access to the current remove invisible layers which the user has requested
01045                 to use when saving in the web format.
01046                 True means remove invisible layers, False means do not.
01047     Note:       This overrides the baseclass version to save in the proper native state
01048 
01049 ********************************************************************************************/
01050 
01051 BOOL PluginNativeFilter::GetRemoveInvisibleLayers()
01052 {
01053     // In native files retain inivisible layers
01054     return FALSE;
01055 }
01056 
01057 /********************************************************************************************
01058 
01059 >   virtual BOOL PluginNativeFilter::GetRemoveUnusedColours()
01060 
01061     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01062     Created:    15/8/96
01063     Inputs:     -
01064     Returns:    The current state of the remove unused colours.
01065     Purpose:    Public access to the current remove unused colours which the user has requested
01066                 to use when saving in the web format.
01067                 True means remove unused colours, False means do not.
01068     Note:       This overrides the baseclass version to save in the proper native state
01069 
01070 ********************************************************************************************/
01071 
01072 BOOL PluginNativeFilter::GetRemoveUnusedColours()
01073 {
01074     // In native files retain unused colours
01075     return FALSE;
01076 }
01077 
01078 /********************************************************************************************
01079 
01080 >   virtual BOOL PluginNativeFilter::GetSaveXPEBitmaps()
01081 
01082     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
01083     Created:    13/09/05
01084     Inputs:     -
01085     Returns:    The current state of the save XPE bitmaps.
01086     Purpose:    
01087 
01088 ********************************************************************************************/
01089 
01090 BOOL PluginNativeFilter::GetSaveXPEBitmaps()
01091 {
01092     // In native files retain unused colours
01093     return m_bSaveXPEBitmaps;
01094 }
01095 
01096 /********************************************************************************************
01097 
01098 >   virtual BOOL PluginNativeFilter::SetSaveXPEBitmaps(BOOL NewSaveXPEBitmaps)
01099 
01100     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
01101     Created:    13/09/05
01102     Inputs:     NewSaveXPEBitmaps   - New value
01103     Returns:    The previous state of the save XPE bitmaps.
01104     Purpose:    
01105 
01106 ********************************************************************************************/
01107 
01108 BOOL PluginNativeFilter::SetSaveXPEBitmaps(BOOL NewSaveXPEBitmaps)
01109 {
01110     BOOL bOld = m_bSaveXPEBitmaps;
01111     m_bSaveXPEBitmaps = NewSaveXPEBitmaps;
01112     return bOld;
01113 }
01114 
01115 /********************************************************************************************
01116 
01117 >   virtual BaseCamelotFilter* PluginNativeFilter::CreateNULLFilter(Document* pDocument)
01118 
01119     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01120     Created:    4/6/96
01121     Inputs:     pDocument = ptr to the document
01122     Returns:    ptr to a filter that can be used to count the number of exported bytes
01123                 NULL if there's an error
01124     Purpose:    Creates the relevant NULL filter
01125     Scope:      Protected.
01126 
01127 ********************************************************************************************/
01128 
01129 //BaseCamelotFilter* PluginNativeFilter::CreateNULLFilter(Document* pDocument)
01130 //{
01131 //  return NULL;
01132 //}
01133 
01134 /********************************************************************************************
01135 
01136 >   virtual BOOL PluginNativeFilter::BeginDocumentExport()
01137 
01138     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01139     Created:    30/7/96
01140     Inputs:     -
01141     Returns:    TRUE if successful, FALSE otherwise
01142     Purpose:    This function is called just before document-related records are written out
01143                 to the file.
01144 
01145                 The native filter writes out a TAG_DOCUMENT record to signify the start of
01146                 the document.
01147 
01148     SeeAlso:    CamelotNativeFilter::EndDocumentExport()
01149     Scope:      Protected
01150 
01151 ********************************************************************************************/
01152 
01153 BOOL PluginNativeFilter::BeginDocumentExport()
01154 {
01155     BOOL ok = TRUE;
01156 
01157     // Writes out a document rec followed by a down rec
01158     // This will ensure that all doc-related records appear as a child of the doc record
01159     if (ok) ok = WriteZeroSizedRecord(TAG_DOCUMENT);
01160     if (ok) ok = WriteZeroSizedRecord(TAG_DOWN);
01161 
01162     return ok;
01163 }
01164 
01165 /********************************************************************************************
01166 
01167 >   virtual BOOL PluginNativeFilter::EndDocumentExport()
01168 
01169     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01170     Created:    30/7/96
01171     Inputs:     -
01172     Returns:    TRUE if successful, FALSE otherwise
01173     Purpose:    This function is called after document-related records have been are written out
01174                 to the file.  BeginDocumentExport() is called before the doc records are saved
01175 
01176                 This should be called for each document that is saved out to the file.
01177 
01178     SeeAlso:    CamelotNativeFilter::BeginDocumentExport()
01179     Scope:      Protected
01180 
01181 ********************************************************************************************/
01182 
01183 BOOL PluginNativeFilter::EndDocumentExport()
01184 {
01185     BOOL ok = TRUE;
01186 
01187     // Writes out an up rec
01188     // This will ensure that all doc-related records appear as a child of the doc record
01189     // by matching the down rec written out by BeginDocumentExport()
01190     if (ok) ok = WriteZeroSizedRecord(TAG_UP);
01191 
01192     return ok;
01193 }
01194 
01195 INT32 PluginNativeFilter::HowCompatibleIsFileType(char* pFileType)
01196 {
01197     if (strcmp(pFileType,GetExportFileType()) == 0)
01198         return 10;
01199     else
01200         return 9;
01201 }
01202 
01203 char* PluginNativeFilter::GetExportFileType()
01204 {
01205     return EXPORT_FILETYPE_NATIVE;
01206 }
01207 
01208 double PluginNativeFilter::GetSimilarPathTolerance(NodePath* pPath)
01209 {
01210     return 0.0;
01211 }
01212 
01213 /********************************************************************************************
01214 
01215 >   INT32 PluginNativeFilter::GetMaxPathLookUp()
01216 
01217     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01218     Created:    19/9/96
01219     Inputs:     -
01220     Returns:    100 always
01221     Purpose:    The max number pf paths that should be looked at by the function FindSimilarPath().
01222 
01223     SeeAlso:    BaseCamelotFilter::GetMaxPathLookUp;
01224     Scope:      Protected
01225 
01226 ********************************************************************************************/
01227 
01228 INT32 PluginNativeFilter::GetMaxPathLookUp()
01229 {
01230     return -1;//100;
01231 }
01232 
01233 
01234 
01235 
01236 /********************************************************************************************
01237 
01238 >   BOOL PluginNativeFilter::WriteCurrentAttributes()
01239 
01240     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01241     Created:    19/03/2004
01242     Inputs:     -
01243     Outputs:    -
01244     Returns:    TRUE if worked, FALSE otherwise
01245     Purpose:    Write out all current attributes
01246     Errors:     -
01247     SeeAlso:    -
01248 
01249 ********************************************************************************************/
01250 
01251 BOOL PluginNativeFilter::WriteCurrentAttributes()
01252 {
01253     BOOL ok = TRUE;
01254     
01255     if (ok && TheDocument)
01256     {
01257         AttributeManager* pAttrMgr = &(TheDocument->GetAttributeMgr());
01258         if (pAttrMgr)
01259             ok = pAttrMgr->WriteCurrentAttributes(this);
01260     }
01261 
01262     return (ok);
01263 }
01264 
01265 
01266 BOOL PluginNativeFilter::SetProgressBarCount(UINT32 n)
01267 {
01268     TRACE( _T("PluginNativeFilter::SetProgressBarCount(%d)\n"), n);
01269 
01270     TRACE(_T("Offset = %d"), m_ProgressOffset);
01271     TRACE(_T("pProgress = 0x%08x"), pProgress);
01272     TRACE(_T("Total = %d"), TotalProgressBarCount);
01273 
01274     ProgressBarCount =  m_ProgressOffset + n;
01275 
01276     if (pProgress != NULL && TotalProgressBarCount > 0)
01277     {
01278         if (ProgressBarCount > TotalProgressBarCount)
01279             ProgressBarCount = TotalProgressBarCount;
01280 
01281         INT32 Percentage = INT32((ProgressBarCount*100) / TotalProgressBarCount);
01282 //      TRACE( _T("Setting progress to %d\n"), Percentage);
01283         EscapePressed = !pProgress->Update(Percentage);
01284         return !EscapePressed;
01285     }
01286 
01287     return TRUE;
01288 }
01289 
01290 
01291 String_256 PluginNativeFilter::GetNewBitmapName()
01292 {
01293     String_256 Str;
01294     Str._MakeMsg(_T("#1%d"), ++m_BitmapCount);
01295     return(Str);
01296 }

Generated on Sat Nov 10 03:47:25 2007 for Camelot by  doxygen 1.4.4