#include <prnmkcom.h>
Inheritance diagram for PrintMarksComponent:
Public Member Functions | |
PrintMarksComponent () | |
virtual | ~PrintMarksComponent () |
BOOL | AddMark (UINT32 handle) |
Adds a print mark reference to our component list. | |
void | RemoveMark (UINT32 handle) |
Remove a print marks component from the list. | |
void | RemoveAllMarks () |
Empty the list of all marks. | |
BOOL | IsVirgin () const |
Is this a virgin print marks component, ie has it never had a print mark added to it? | |
DocPrintMark * | FindMark (UINT32 SearchHandle) const |
Try to find a print mark in the doc component, using the print mark handle. | |
DocPrintMark * | GetFirstMark () const |
DocPrintMark * | GetNextMark (DocPrintMark *pItem) const |
virtual BOOL | StartImport (BaseCamelotFilter *pFilter) |
virtual BOOL | EndImport (BaseCamelotFilter *pFilter, BOOL Success) |
virtual BOOL | StartExport (BaseCamelotFilter *pFilter) |
virtual BOOL | EndExport (BaseCamelotFilter *pFilter, BOOL Success) |
void | ImportDefaultPrintMark (CXaraFileRecord *Rec) |
To import a default print mark. | |
void | StartImportCustomPrintMark (CamelotRecordHandler *pHandler, CXaraFileRecord *Rec) |
To start import of a custom print mark This is called when a TAG_PRINTMARKCUSTOM is found in the importing file. The tag is followed by a subtree (beginning with a NodeGroup). | |
void | EndImportCustomPrintMark (CamelotRecordHandler *pHandler) |
To end the import a custom print mark - see the SeeAlso for details. | |
Private Member Functions | |
BOOL | ExportPrintMark (BaseCamelotFilter *pFilter, PrintMarkItem *pMarkItem) |
To export a print mark. | |
Private Attributes | |
Node * | CustomPreviousContext |
Node * | CustomCurrentContext |
PrintMarkItem * | pNewMark |
DocPrintMarkList | DocMarks |
Definition at line 235 of file prnmkcom.h.
|
Definition at line 331 of file prnmkcom.cpp. 00332 { 00333 CustomPreviousContext = NULL; 00334 CustomCurrentContext = NULL; 00335 pNewMark = NULL; 00336 }
|
|
Definition at line 349 of file prnmkcom.cpp.
|
|
Adds a print mark reference to our component list.
Definition at line 366 of file prnmkcom.cpp. 00367 { 00368 // it may well be there already! 00369 if (DocMarks.FindMark(handle)) 00370 return TRUE; 00371 return DocMarks.AddMark(handle); 00372 }
|
|
Reimplemented from DocComponent. Definition at line 577 of file prnmkcom.cpp. 00578 { 00579 BOOL ok = TRUE; 00580 00581 // WEBSTER - markn 14/2/97 00582 // No print records needed in Webster 00583 #ifndef WEBSTER 00584 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) 00585 if (pFilter == NULL) 00586 { 00587 ERROR3("PrintMarksComponent::EndExport filter is null!"); 00588 return(ok); 00589 } 00590 00591 if (!Success || pFilter->IsWebFilter()) // Don't export to web files, or if we have failed 00592 return(ok); 00593 00594 00595 // Find the Print mark manager and it's PrintMark cache 00596 PrintMarksMan* pMarksMan = GetApplication()->GetMarksManager(); 00597 if (pMarksMan == NULL) 00598 return(ok); 00599 00600 // Export the list of marks 00601 DocPrintMark *pItem = DocMarks.GetFirstMark(); 00602 while (ok && pItem != NULL) 00603 { 00604 // From our item, find the actual PrintMark definition in the PMM cache 00605 PrintMarkItem *pMarkItem = pMarksMan->PMMCache.FindMark(pItem->GetHandle()); 00606 if (pMarkItem != NULL) 00607 ok = ExportPrintMark(pFilter, pMarkItem); 00608 00609 pItem = DocMarks.GetNextMark(pItem); 00610 } 00611 #endif 00612 #endif // WEBSTER 00613 return ok; 00614 }
|
|
Reimplemented from DocComponent. Definition at line 504 of file prnmkcom.cpp. 00505 { 00506 /* 00507 if (pFilter==NULL) 00508 { 00509 ERROR3("PrintMarksComponent::EndImport filter is null!"); 00510 return TRUE; 00511 } 00512 00513 if (Success) 00514 { 00515 00516 } 00517 else 00518 { 00519 00520 } 00521 */ 00522 CustomPreviousContext = NULL; 00523 CustomCurrentContext = NULL; 00524 pNewMark = NULL; 00525 00526 return TRUE; 00527 }
|
|
To end the import a custom print mark - see the SeeAlso for details.
Definition at line 909 of file prnmkcom.cpp. 00910 { 00911 PORTNOTETRACE("print","PrintMarksComponent::EndImportCustomPrintMark - do nothing"); 00912 #ifndef EXCLUDE_FROM_XARALX 00913 ERROR3IF(CustomCurrentContext == NULL || pNewMark == NULL, "EndImportCustomPrintMark - StartImportCustomMark not called/failed"); 00914 00915 // Find the Print mark manager and it's PrintMark cache 00916 PrintMarksMan* pMarksMan = GetApplication()->GetMarksManager(); 00917 if (pMarksMan == NULL) 00918 return; 00919 00920 // Restore the previous import context node 00921 pHandler->SetInsertContextNode(CustomPreviousContext); 00922 00923 // Complete the mark and add it to the PMM cache 00924 NodeGroup *Glyph = (NodeGroup *)CustomCurrentContext->FindFirstChild(); 00925 ERROR3IF(Glyph == NULL, "Import of custom mark subtree must have failed"); 00926 if (Glyph != NULL) 00927 { 00928 ERROR3IF(!Glyph->IsKindOf(CC_RUNTIME_CLASS(NodeGroup)), "Imported print mark doesn't start with a group"); 00929 00930 Glyph->UnlinkNodeFromTree(NULL); 00931 UINT32 MarkHandle = pMarksMan->PMMCache.AddNewMark(pNewMark, Glyph); 00932 00933 // Add a reference to the mark to ourself, so the mark is enabled 00934 AddMark(MarkHandle); 00935 } 00936 else 00937 { 00938 // Try not to leak too much! 00939 delete pNewMark; 00940 } 00941 00942 // Tidy up 00943 pNewMark = NULL; 00944 CustomPreviousContext = NULL; 00945 delete CustomCurrentContext; 00946 CustomCurrentContext = NULL; 00947 #endif 00948 }
|
|
To export a print mark.
Print marks are saved in 2 formats: TAG_PRINTMARKDEFAULT - Default (built in) marks - a 1-byte record indicates which mark to use by quoting its ID byte. TAG_PRINTMARKCUSTOM - User (custom) marks - The record is zero length, but is followed by a TAG_DOWN, a clipart tree, and a TAG_UP. NOTE that custom marks are currently not handled. Definition at line 646 of file prnmkcom.cpp. 00647 { 00648 BOOL ok = TRUE; 00649 00650 PORTNOTETRACE("print","PrintMarksComponent::ExportPrintMark - do nothing"); 00651 #ifndef EXCLUDE_FROM_XARALX 00652 ERROR3IF(pFilter == NULL || pMarkItem == NULL, "Illegal NULL params"); 00653 00654 PrintMark *pMarkInfo = pMarkItem->GetPrintMark(); 00655 if (pMarkInfo == NULL) 00656 { 00657 ERROR3("PrintMarkItem with no PrintMark"); 00658 return(FALSE); 00659 } 00660 00661 if (pMarkInfo->IsCustom()) 00662 { 00663 // A custom mark consists of a PrintMarkCustom record, defining where the 00664 // mark goes, what it's called, etc, followed records for the clipart subtree 00665 CXaraFileRecord Rec(TAG_PRINTMARKCUSTOM, TAG_PRINTMARKCUSTOM_SIZE); 00666 if (ok) ok = Rec.Init(); 00667 00668 // Write out the print mark info 00669 // Type (bitmap ID), menu text string, orientation, positions 00670 if (ok) ok = Rec.WriteBYTE((BYTE) pMarkInfo->GetType()); 00671 if (ok) ok = Rec.WriteBYTE((BYTE) pMarkInfo->GetOrientation()); 00672 00673 if (ok) 00674 { 00675 MarkPosition *Pos = pMarkInfo->GetFirstPosition(); 00676 while (ok && Pos != NULL) 00677 { 00678 ok = Rec.WriteBYTE((BYTE) Pos->GetRegion()); // Write the region 00679 if (ok) ok = Rec.WriteBYTE(Pos->GetFormat().GetAsFlagByte()); // Write the format 00680 00681 Pos = pMarkInfo->GetNextPosition(Pos); 00682 } 00683 00684 if (ok) ok = Rec.WriteBYTE(MarkRegion_FileFormatTerminator); // Terminate the list 00685 } 00686 00687 if (ok) ok = Rec.WriteUnicode(pMarkInfo->GetMarkMenuText()); // Write the mark name 00688 00689 // Finish off this record 00690 if (ok) pFilter->Write(&Rec); 00691 00692 00693 // OK, now write the print mark "clipart" subtree to the file... 00694 if (ok) ok = pFilter->WriteZeroSizedRecord(TAG_DOWN); 00695 00696 // BLOCK 00697 { 00698 // Find the Glyph subtree. We could strip off the default attributes 00699 // that Mike keeps around, but they only add a tiny amount (100 bytes 00700 // or so) to the file, and save a lot of problems getting attribute-completeness 00701 // when reloading the mark. 00702 Node *GlyphRoot = pMarkItem->GetMarkGlyph(); 00703 if (GlyphRoot == NULL) 00704 { 00705 ERROR3("Custom printers mark with no glyph"); 00706 ok = FALSE; 00707 } 00708 00709 if (ok) ok = pFilter->WriteNodes(GlyphRoot); 00710 } 00711 if (ok) ok = pFilter->WriteZeroSizedRecord(TAG_UP); 00712 } 00713 else 00714 { 00715 // --- Write the record 00716 CXaraFileRecord Rec(TAG_PRINTMARKDEFAULT, TAG_PRINTMARKDEFAULT_SIZE); 00717 if (ok) ok = Rec.Init(); 00718 00719 if (ok) ok = Rec.WriteBYTE(pMarkInfo->GetIDByte()); 00720 00721 // --- Finally, output the record 00722 if (ok) 00723 pFilter->Write(&Rec); 00724 } 00725 #endif 00726 return(ok); 00727 }
|
|
Try to find a print mark in the doc component, using the print mark handle.
Definition at line 424 of file prnmkcom.cpp.
|
|
Definition at line 281 of file prnmkcom.h. 00282 { 00283 return DocMarks.GetFirstMark(); 00284 }
|
|
Definition at line 286 of file prnmkcom.h. 00287 { 00288 return DocMarks.GetNextMark(pItem); 00289 }
|
|
To import a default print mark.
Definition at line 744 of file prnmkcom.cpp. 00745 { 00746 PORTNOTETRACE("print","PrintMarksComponent::ExportPrintMark - do nothing"); 00747 #ifndef EXCLUDE_FROM_XARALX 00748 ERROR3IF(Rec == NULL, "Illegal NULL params"); 00749 BYTE ID = 0; 00750 BOOL ok = Rec->ReadBYTE(&ID); 00751 00752 if (!ok) 00753 return; 00754 00755 // Find the Print mark manager and it's PrintMark cache 00756 PrintMarksMan* pMarksMan = GetApplication()->GetMarksManager(); 00757 if (pMarksMan == NULL) 00758 return; 00759 00760 // Search the PMMCache list for a PrintMark with the given ID byte 00761 UINT32 Handle = 0; 00762 BOOL Found = FALSE; 00763 PrintMarkItem *pItem = pMarksMan->PMMCache.GetFirstMark(); 00764 while (pItem != NULL) 00765 { 00766 PrintMark *pMark = pItem->GetPrintMark(); 00767 if (pMark != NULL && pMark->GetIDByte() == ID) 00768 { 00769 Handle = pItem->GetHandle(); 00770 Found = TRUE; 00771 break; 00772 } 00773 00774 pItem = pMarksMan->PMMCache.GetNextMark(pItem); 00775 } 00776 00777 // If we found a mark, then Handle is its PMM handle - Add an entry to our 00778 // list of Enabled marks. 00779 if (Found) 00780 AddMark(Handle); 00781 #endif 00782 }
|
|
Is this a virgin print marks component, ie has it never had a print mark added to it?
Definition at line 443 of file prnmkcom.cpp.
|
|
Empty the list of all marks.
Definition at line 404 of file prnmkcom.cpp. 00405 { 00406 DocMarks.RemoveAllMarks(); 00407 }
|
|
Remove a print marks component from the list.
Definition at line 387 of file prnmkcom.cpp. 00388 { 00389 DocMarks.RemoveMark(handle); 00390 }
|
|
Reimplemented from DocComponent. Definition at line 545 of file prnmkcom.cpp. 00546 { 00547 #if !defined(EXCLUDE_FROM_RALPH) 00548 /* 00549 if (pFilter == NULL) 00550 { 00551 ERROR3("PrintMarksComponent::StartExport filter is null!"); 00552 return TRUE; 00553 } 00554 00555 */ 00556 #endif 00557 return TRUE; 00558 }
|
|
Reimplemented from DocComponent. Definition at line 463 of file prnmkcom.cpp. 00464 { 00465 if (pFilter == NULL) 00466 { 00467 ERROR3("PrintMarksComponent::StartImport filter is null!"); 00468 return TRUE; 00469 } 00470 00471 CustomPreviousContext = NULL; 00472 CustomCurrentContext = NULL; 00473 pNewMark = NULL; 00474 00475 // If we're importing into an existing document, we ignore all printer mark 00476 // information in the file being imported. 00477 if (pFilter->IsImporting()) 00478 return(TRUE); 00479 00480 // Before importing, we delete all existing marks, so that the loaded file overrides 00481 // the settings already present in the document. 00482 RemoveAllMarks(); 00483 00484 return TRUE; 00485 }
|
|
To start import of a custom print mark This is called when a TAG_PRINTMARKCUSTOM is found in the importing file. The tag is followed by a subtree (beginning with a NodeGroup).
Definition at line 809 of file prnmkcom.cpp. 00810 { 00811 PORTNOTETRACE("print","PrintMarksComponent::StartImportCustomPrintMark - do nothing"); 00812 #ifndef EXCLUDE_FROM_XARALX 00813 ERROR3IF(CustomCurrentContext != NULL || CustomPreviousContext != NULL || 00814 pNewMark != NULL, "StartImportCustomPrintMark called while importing another custom mark?!"); 00815 00816 // Find the Print mark manager and it's PrintMark cache 00817 PrintMarksMan* pMarksMan = GetApplication()->GetMarksManager(); 00818 if (pMarksMan == NULL) 00819 return; 00820 00821 // Create a PrintMark encapsulating all the data in this record 00822 pNewMark = new PrintMarkItem; 00823 if (!pNewMark) 00824 return; 00825 00826 PrintMark *pMarkInfo = pNewMark->GetPrintMark(); 00827 pMarkInfo->SetCustomOrDefault(TRUE); // This is a custom mark 00828 00829 00830 // --- Now read the print mark info 00831 BOOL ok = TRUE; 00832 BYTE Temp; 00833 00834 if (ok) ok = Rec->ReadBYTE(&Temp); 00835 if (ok) pMarkInfo->SetType((MarkType) Temp); 00836 00837 if (ok) ok = Rec->ReadBYTE(&Temp); 00838 if (ok) pMarkInfo->SetOrientation((MarkOrient) Temp); 00839 00840 while (ok) // Read all format positions 00841 { 00842 ok = Rec->ReadBYTE(&Temp); 00843 if (ok) 00844 { 00845 if (Temp == (BYTE) MarkRegion_FileFormatTerminator) // End of list - break out of loop 00846 break; 00847 00848 MarkPosition *NewPos = new MarkPosition; // New position 00849 if (NewPos == NULL) 00850 ok = FALSE; 00851 else 00852 { 00853 NewPos->Initialise(); 00854 NewPos->SetRegion((MarkRegion) Temp); // Set region from first byte 00855 00856 ok = Rec->ReadBYTE(&Temp); 00857 if (ok) 00858 { 00859 MarkFormat NewFormat; 00860 NewFormat.SetFromFlagByte(Temp); // Set format from second byte 00861 00862 NewPos->SetFormat(NewFormat); 00863 00864 pMarkInfo->AddNewPosition(NewPos); // And add to the mark's positions 00865 } 00866 else 00867 delete NewPos; 00868 } 00869 } 00870 } 00871 00872 String_256 MenuName; 00873 if (ok) ok = Rec->ReadUnicode((TCHAR *)MenuName, 255); // Read the mark name 00874 if (ok) pMarkInfo->SetMarkMenuText(&MenuName); 00875 00876 if (ok) 00877 { 00878 // --- Finally, prepare for import of the following clipart subtree 00879 // Remember the current import context node 00880 CustomPreviousContext = pHandler->GetInsertContextNode(); 00881 00882 // Create a layer and set up the import system to import the mark into it 00883 // If this fails, then it'll just find somewhere "sensible" to import into 00884 CustomCurrentContext = new Layer; 00885 pHandler->SetInsertContextNode(CustomCurrentContext); 00886 } 00887 00888 // And now sit back and wait for the End call... 00889 #endif 00890 }
|
|
Definition at line 264 of file prnmkcom.h. |
|
Definition at line 263 of file prnmkcom.h. |
|
Definition at line 271 of file prnmkcom.h. |
|
Definition at line 265 of file prnmkcom.h. |