#include <xpfilter.h>
Inheritance diagram for PluginNativeFilter:
Public Member Functions | |
PluginNativeFilter () | |
Constructor for the Native save/load filter. | |
~PluginNativeFilter () | |
Tidies up when the filter is destroyed. | |
BOOL | Init (xmlNode *pFilterNode) |
Initalises the Filter ready for use. Will fail if it can not get enough memory to work with. | |
virtual INT32 | HowCompatible (PathName &Filename, ADDR HeaderStart, UINT32 HeaderSize, UINT32 FileSize) |
virtual BOOL | DoImport (SelOperation *, CCLexFile *, Document *, BOOL AutoChosen=FALSE, ImportPosition *Pos=NULL, KernelBitmap **ppImportedBitmap=NULL, DocCoord *pPosTranslate=NULL, String_256 *=NULL) |
Read the data from the specified file. | |
virtual BOOL | DoExport (Operation *, CCLexFile *, PathName *, Document *, BOOL) |
Exports the current document out to file. Uses the virtual functions of this class. Do not override unless really necessary. | |
virtual BOOL | StartCompression () |
Function to turn Compression on when we are writing to the file. It asks the underlying CCFile and CXaraFile to start the compression process up. | |
virtual BOOL | StopCompression () |
Function to turn Compression off when we are writing to the file. It asks the underlying CCFile and CXaraFile to stop the compression process. | |
virtual BOOL | GetExportOptions (WebPrefsDlgParam *pPrefs) |
Overrides base class so we can do our own thing. | |
virtual BOOL | IsWebFilter () |
virtual BOOL | IsCompactNativeFilter () |
virtual INT32 | GetBitmapCompression () |
Public access to the current bitmap compression which the user has requested to use when saving bitmaps in the web format. 0 means maximum compression e.g. use JPEG filter at 0% lossy compression 100 means minimum compression e.g. use JPEG filter at 100% lossy compression 101 - 200 means lossless compression e.g. us PNG filter. Could use the no bitmap compression at all e.g. use BMP filter. Unused at present. (Very much like the JPEG compression percentage). Note: This overrides the baseclass version to save in the proper native state. | |
virtual BOOL | GetPreviewBitmapExport () |
Public access to the current export preview bitmap which the user has requested to use when saving bitmaps in the web format. True means export a preview bitmap, False means do not. Note: This overrides the baseclass version to save in the proper native state. | |
virtual BOOL | GetConvertTextToOutlines () |
Public access to the current convert text to outlines which the user has requested to use when saving in the web format. True means convert text to outlines, False means do not. Note: This overrides the baseclass version to save in the proper native state. | |
virtual BOOL | GetRemoveInvisibleLayers () |
Public access to the current remove invisible layers which the user has requested to use when saving in the web format. True means remove invisible layers, False means do not. Note: This overrides the baseclass version to save in the proper native state. | |
virtual BOOL | GetRemoveUnusedColours () |
Public access to the current remove unused colours which the user has requested to use when saving in the web format. True means remove unused colours, False means do not. Note: This overrides the baseclass version to save in the proper native state. | |
virtual BOOL | GetSaveXPEBitmaps () |
virtual BOOL | SetSaveXPEBitmaps (BOOL NewSaveXPEBitmaps) |
virtual INT32 | HowCompatibleIsFileType (char *pFileType) |
virtual double | GetSimilarPathTolerance (NodePath *pPath) |
virtual INT32 | GetMaxPathLookUp () |
The max number pf paths that should be looked at by the function FindSimilarPath(). | |
virtual WebPrefsDlgParam * | GetCachedExportOptions () |
virtual BOOL | WriteSpecificRegularShapes () |
virtual BoundsWriteLevel | GetBoundsWriteLevel () |
BOOL | SetProgressBarCount (UINT32 n) |
void | AddBitmapToList (KernelBitmap *pBmp) |
String_256 | GetNewBitmapName () |
Protected Member Functions | |
virtual char * | GetExportFileType () |
BOOL | GenerateExportData (CapabilityTree *pPlugCaps) |
BOOL | DoConversionPassN (CapabilityTree *pPlugCaps, INT32 ConvertPass) |
BOOL | DoBitmapResamplePass (CapabilityTree *pPlugCaps) |
virtual Node * | GetExportNode () |
Returns a pointer to the first node to export. | |
virtual BOOL | BeginDocumentExport () |
Creates the relevant NULL filter Scope: Protected.This function is called just before document-related records are written out to the file. | |
virtual BOOL | EndDocumentExport () |
This function is called after document-related records have been are written out to the file. BeginDocumentExport() is called before the doc records are saved. | |
virtual BOOL | WriteCurrentAttributes () |
Write out all current attributes. | |
Protected Attributes | |
UINT32 | FilterNameID |
UINT32 | FilterInfoID |
UINT32 | ExportingMsgID |
Node * | m_pNewTree |
UINT32 | m_ProgressOffset |
BOOL | m_bSaveXPEBitmaps |
BOOL | m_bPreviewBitmap |
BoundsWriteLevel | m_BoundsLevel |
INT32 | m_BitmapCompression |
List | m_BitmapList |
INT32 | m_BitmapCount |
Private Member Functions | |
CC_DECLARE_DYNAMIC (PluginNativeFilter) |
Definition at line 119 of file xpfilter.h.
|
Constructor for the Native save/load filter.
Definition at line 140 of file xpfilter.cpp. 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 }
|
|
Tidies up when the filter is destroyed.
Definition at line 164 of file xpfilter.cpp.
|
|
Definition at line 189 of file xpfilter.h. 00190 { 00191 KernelBmpListItem* pItem = new KernelBmpListItem(pBmp); 00192 if (pItem) 00193 m_BitmapList.AddTail(pItem); 00194 }
|
|
Creates the relevant NULL filter Scope: Protected.This function is called just before document-related records are written out to the file.
Reimplemented from CamelotNativeFilter. Definition at line 1153 of file xpfilter.cpp. 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 }
|
|
|
|
Definition at line 731 of file xpfilter.cpp. 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 }
|
|
Definition at line 657 of file xpfilter.cpp. 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 }
|
|
Exports the current document out to file. Uses the virtual functions of this class. Do not override unless really necessary.
Reimplemented from BaseCamelotFilter. Definition at line 345 of file xpfilter.cpp. 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 }
|
|
Read the data from the specified file.
Reimplemented from BaseCamelotFilter. Definition at line 285 of file xpfilter.cpp. 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 }
|
|
This function is called after document-related records have been are written out to the file. BeginDocumentExport() is called before the doc records are saved.
Reimplemented from CamelotNativeFilter. Definition at line 1183 of file xpfilter.cpp. 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 }
|
|
Definition at line 485 of file xpfilter.cpp. 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 }
|
|
Public access to the current bitmap compression which the user has requested to use when saving bitmaps in the web format. 0 means maximum compression e.g. use JPEG filter at 0% lossy compression 100 means minimum compression e.g. use JPEG filter at 100% lossy compression 101 - 200 means lossless compression e.g. us PNG filter. Could use the no bitmap compression at all e.g. use BMP filter. Unused at present. (Very much like the JPEG compression percentage). Note: This overrides the baseclass version to save in the proper native state.
Reimplemented from CamelotNativeFilter. Definition at line 988 of file xpfilter.cpp. 00989 { 00990 // Always use a lossless format such as PNG in native files 00991 return m_BitmapCompression; 00992 }
|
|
Reimplemented from BaseCamelotFilter. Definition at line 185 of file xpfilter.h. 00185 { return(m_BoundsLevel); }
|
|
Reimplemented from CamelotNativeFilter. Definition at line 179 of file xpfilter.h. 00179 { return NULL; }
|
|
Public access to the current convert text to outlines which the user has requested to use when saving in the web format. True means convert text to outlines, False means do not. Note: This overrides the baseclass version to save in the proper native state.
Reimplemented from CamelotNativeFilter. Definition at line 1030 of file xpfilter.cpp. 01031 { 01032 // In native files ensure text is not converted to outlines 01033 return FALSE; 01034 }
|
|
Reimplemented from CamelotNativeFilter. Definition at line 1203 of file xpfilter.cpp. 01204 { 01205 return EXPORT_FILETYPE_NATIVE; 01206 }
|
|
Returns a pointer to the first node to export.
Reimplemented from BaseCamelotFilter. Definition at line 935 of file xpfilter.cpp. 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 }
|
|
Overrides base class so we can do our own thing.
Reimplemented from BaseCamelotFilter. Definition at line 961 of file xpfilter.cpp. 00962 { 00963 // May want to call PrepareExport here 00964 00965 return TRUE; 00966 }
|
|
The max number pf paths that should be looked at by the function FindSimilarPath().
Reimplemented from CamelotNativeFilter. Definition at line 1228 of file xpfilter.cpp.
|
|
Definition at line 1291 of file xpfilter.cpp. 01292 { 01293 String_256 Str; 01294 Str._MakeMsg(_T("#1%d"), ++m_BitmapCount); 01295 return(Str); 01296 }
|
|
Public access to the current export preview bitmap which the user has requested to use when saving bitmaps in the web format. True means export a preview bitmap, False means do not. Note: This overrides the baseclass version to save in the proper native state.
Reimplemented from CamelotNativeFilter. Definition at line 1009 of file xpfilter.cpp. 01010 { 01011 // Return TRUE if the plugin wants a preview bitmap and FALSE otherwise 01012 return m_bPreviewBitmap; 01013 }
|
|
Public access to the current remove invisible layers which the user has requested to use when saving in the web format. True means remove invisible layers, False means do not. Note: This overrides the baseclass version to save in the proper native state.
Reimplemented from CamelotNativeFilter. Definition at line 1051 of file xpfilter.cpp. 01052 { 01053 // In native files retain inivisible layers 01054 return FALSE; 01055 }
|
|
Public access to the current remove unused colours which the user has requested to use when saving in the web format. True means remove unused colours, False means do not. Note: This overrides the baseclass version to save in the proper native state.
Reimplemented from CamelotNativeFilter. Definition at line 1072 of file xpfilter.cpp. 01073 { 01074 // In native files retain unused colours 01075 return FALSE; 01076 }
|
|
Reimplemented from BaseCamelotFilter. Definition at line 1090 of file xpfilter.cpp. 01091 { 01092 // In native files retain unused colours 01093 return m_bSaveXPEBitmaps; 01094 }
|
|
Reimplemented from CamelotNativeFilter. Definition at line 1208 of file xpfilter.cpp.
|
|
Reimplemented from BaseCamelotFilter. Definition at line 236 of file xpfilter.cpp. 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 }
|
|
Reimplemented from CamelotNativeFilter. Definition at line 1195 of file xpfilter.cpp. 01196 { 01197 if (strcmp(pFileType,GetExportFileType()) == 0) 01198 return 10; 01199 else 01200 return 9; 01201 }
|
|
Initalises the Filter ready for use. Will fail if it can not get enough memory to work with.
Definition at line 180 of file xpfilter.cpp. 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 }
|
|
Reimplemented from CamelotNativeFilter. Definition at line 152 of file xpfilter.h. 00152 { return FALSE; }
|
|
Reimplemented from CamelotNativeFilter. Definition at line 151 of file xpfilter.h. 00151 { return FALSE; }
|
|
Definition at line 1266 of file xpfilter.cpp. 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 }
|
|
Reimplemented from BaseCamelotFilter. Definition at line 1108 of file xpfilter.cpp. 01109 { 01110 BOOL bOld = m_bSaveXPEBitmaps; 01111 m_bSaveXPEBitmaps = NewSaveXPEBitmaps; 01112 return bOld; 01113 }
|
|
Function to turn Compression on when we are writing to the file. It asks the underlying CCFile and CXaraFile to start the compression process up.
Reimplemented from BaseCamelotFilter. Definition at line 146 of file xpfilter.h. 00146 { return(TRUE); }
|
|
Function to turn Compression off when we are writing to the file. It asks the underlying CCFile and CXaraFile to stop the compression process.
Reimplemented from BaseCamelotFilter. Definition at line 147 of file xpfilter.h. 00147 { return(TRUE); }
|
|
Write out all current attributes.
Reimplemented from CamelotNativeFilter. Definition at line 1251 of file xpfilter.cpp. 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 }
|
|
Reimplemented from BaseCamelotFilter. Definition at line 181 of file xpfilter.h. 00181 { return(TRUE); }
|
|
Reimplemented from CamelotNativeFilter. Definition at line 218 of file xpfilter.h. |
|
Reimplemented from CamelotNativeFilter. Definition at line 213 of file xpfilter.h. |
|
Reimplemented from CamelotNativeFilter. Definition at line 212 of file xpfilter.h. |
|
Definition at line 227 of file xpfilter.h. |
|
Definition at line 230 of file xpfilter.h. |
|
Definition at line 229 of file xpfilter.h. |
|
Definition at line 226 of file xpfilter.h. |
|
Definition at line 224 of file xpfilter.h. |
|
Definition at line 223 of file xpfilter.h. |
|
Definition at line 220 of file xpfilter.h. |
|
Definition at line 222 of file xpfilter.h. |