PrintMarksCache Class Reference

The print marks cache. This class contains a list of cached printmarks kept by the print marks manager. It is split into its own class here to avoid complications will the mark managers handling of cache marks and document component marks. More...

#include <prnmks.h>

List of all members.

Public Member Functions

 PrintMarksCache ()
 Construct the PrintMarksCache object. This used to be part of the print marks manager but I've now split it into its own class to prevent confusion with the handling of cache marks and document marks. Various functions do similar things so it could become confusing without a scope resolution operator PMMCache::FindMark as opposed to Doc::FindMark.
 ~PrintMarksCache ()
 Destroys the cached marks completely.
PrintMarkItemGetFirstMark () const
 Return a pointer to the first cached mark.
PrintMarkItemGetNextMark (PrintMarkItem *pCurrItem) const
 Returns the next print mark item beyond pCurrMark.
PrintMarkItemFindMark (UINT32 SearchHandle)
 Try to find a print mark in the cache, using its handle.

Private Member Functions

 CC_DECLARE_MEMDUMP (PrintMarksCache)
BOOL DecodeCachedLayers (Document *pDocument)
 Given a document, we scan each layer in the document. For each layer we check the loaded layer name. If the layer name contains a % at the begining (meaning its a format string) and the format is PRINTMARK, we take the first group in the layer (+ all its contents) and assign a new print mark item to this group. This group object will (if successfully) loaded, become a new print mark.
BOOL DecodeCachedLayer (Layer *pLayer)
 Given a layer, if the layer contains a print mark, strip the print mark out and try to add it to the PrintMarksMan cache.
BOOL DecodeMarkFormat (const String_256 *pFormatString, PrintMark *pMark)
 Decode the string pointed to by pFormatString, placing each format identifier into the output mark.
UINT32 DecodeToMarkType (const String_256 *Name) const
 Have a look at the string passed in and check to see it matches any of the known mark type names. If so return the proper mark type enum, otherwise 'Unkown' is returned.
BOOL DoesMarkExist (PrintMark *pCheckMark) const
 Try to find a print mark in the cache.
UINT32 AddNewMark (PrintMarkItem *pCheckMark, NodeGroup *pGroup)
 A simple way of adding a prebuilt mark to the list. The mark must be in a renderable format, in that it should be a group with all needed attrs as children, followed by a child group containing all the ink objects.
void UpdateMarkGlyph (PrintMarkItem *pMarkItem, NodeGroup *pGroup)
 Change the mark glyph to this new mark.
BOOL CreateTextInfoMark ()
 This function creates a text information mark which will describe the current print job. As this will be created and destroyed on each print it should be reasonably fast to execute. We include the following information in the text....
BOOL CreateCropMark ()
BOOL UpdateTextInfoMark (Document *pDocument, RenderRegion *pRRegion)
 This function creates a text information mark which will describe the current print job. As this will be created and destroyed on each print it should be reasonably fast to execute. We include the following information in the text....
void DestroyTextInfoMark ()
 Throw away any cached print information mark.
void BuildTextInfoString (Document *pDocument, RenderRegion *pRegion, String_256 *pString)
BOOL SetInfoMarkAttributes (TextStory *pStory, String_64 *pFontName, MILLIPOINT FontSize)
 This function creates a text information mark which will describe the current print job. As this will be created and destroyed on each print it should be reasonably fast to execute. We include the following information in the text....
BOOL DeleteChildAttribute (NodeRenderableInk *pParent, CCRuntimeClass *pReqdAttrib)
 Delete a child attribute of a specified type from this parent.
UINT32 GetUniqueHandle ()
 Generate a unique print mark handle. All handles will be >=1 and hence an illegal handle is given the value 0.
void Invalidate ()
 Invalidate the cache list. If we do this, all the mark references in existing document will reference nothing. As we create new marks new handles will be built, so it might be necessary to delete references made in all doc components. Use with care.

Private Attributes

UINT32 NextHandle
UINT32 TextInfoHandle
UINT32 CropMarkHandle
List PrintMarkCache
String_256 CachedTime

Friends

class PrintMarksMan
class LoadPrintMarks
class PrintMarksComponent


Detailed Description

The print marks cache. This class contains a list of cached printmarks kept by the print marks manager. It is split into its own class here to avoid complications will the mark managers handling of cache marks and document component marks.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/07/96
See also:

Definition at line 647 of file prnmks.h.


Constructor & Destructor Documentation

PrintMarksCache::PrintMarksCache  ) 
 

Construct the PrintMarksCache object. This used to be part of the print marks manager but I've now split it into its own class to prevent confusion with the handling of cache marks and document marks. Various functions do similar things so it could become confusing without a scope resolution operator PMMCache::FindMark as opposed to Doc::FindMark.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/07/96

Definition at line 714 of file prnmks.cpp.

00715 {
00716     NextHandle=0;
00717     TextInfoHandle=0;
00718     CropMarkHandle=0;
00719 }

PrintMarksCache::~PrintMarksCache  ) 
 

Destroys the cached marks completely.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/07/96

Definition at line 732 of file prnmks.cpp.

00733 {
00734     Invalidate();
00735 }


Member Function Documentation

UINT32 PrintMarksCache::AddNewMark PrintMarkItem pNewMark,
NodeGroup pGroup
[private]
 

A simple way of adding a prebuilt mark to the list. The mark must be in a renderable format, in that it should be a group with all needed attrs as children, followed by a child group containing all the ink objects.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/07/96
Parameters:
pNewMark = a pointer to the new mark to add [INPUTS] pGroup = a pointer to the glyph to use.
Returns:
The handle of the newly added mark

Definition at line 1012 of file prnmks.cpp.

01013 {
01014     // Add a handle to this mark
01015     UINT32 hndle = GetUniqueHandle();
01016     pNewMark->SetHandle(hndle);
01017     pNewMark->pMarkGlyph = pGroup;
01018     // Hey hey, we've finally done it! cool!
01019     PrintMarkCache.AddTail(pNewMark);
01020     return hndle;
01021 }

void PrintMarksCache::BuildTextInfoString Document pDocument,
RenderRegion pRRegion,
String_256 pString
[private]
 

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/08/96
Parameters:
pMark = a print mark item pointer [INPUTS] pForm = a mark format object pointer

Definition at line 1672 of file prnmks.cpp.

01673 {
01674     // First add the doc title to the string
01675     (*pString) = pDocument->GetTitle();
01676     (*pString) += TEXT("  ");
01677 
01678     // now add the date and time (set up by StartPrinting above)
01679     (*pString) += CachedTime;
01680 
01681     // ok add the plate name of the plate we're rendering
01682     ColourPlate *pColPlate = pRRegion->GetRenderView()->GetColourPlate();
01683     if (pColPlate!=NULL)
01684     {
01685         String_64 PlateName;
01686         
01687         pColPlate->GetDescription(&PlateName);
01688         (*pString) += TEXT("  (");
01689         (*pString) += PlateName;
01690         (*pString) += TEXT(")");
01691     }
01692 }

PrintMarksCache::CC_DECLARE_MEMDUMP PrintMarksCache   )  [private]
 

BOOL PrintMarksCache::CreateCropMark  )  [private]
 

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/08/96
Parameters:
[INPUTS] 
Returns:
-

Definition at line 1282 of file prnmks.cpp.

01283 {
01284     if (CropMarkHandle>0)
01285         return TRUE;
01286 
01287     // Create a particular mark structure for this crop mark
01288     PrintMarkItem* pMarkItem = new PrintMarkItem;
01289     if (pMarkItem==NULL)
01290         return FALSE;
01291 
01292     MarkPosition* pPosition = new MarkPosition;
01293     if (pPosition==NULL)
01294     {
01295         delete pMarkItem;
01296         return FALSE;
01297     }
01298 
01299     MarkFormat format;
01300     pPosition->SetRegion(MarkRegion_Top1);
01301     pPosition->SetFormat(format);
01302     String_256 MenuText(_R(IDS_PRINTMARK_CROPMARKS));
01303 
01304     PrintMark* pMark = pMarkItem->GetPrintMark();
01305     pMark->SetCustomOrDefault(FALSE);
01306     pMark->SetIDByte(PRINTMARK_CROPMARKID);
01307     pMark->SetType(MarkType_Crop);
01308     pMark->SetMarkMenuText(&MenuText);
01309     pMark->SetOrientation(MO_Horizontal);
01310     pMark->SetDefaultState(TRUE);
01311     pMark->AddNewPosition(pPosition);
01312 
01313     // we don't want to save this mark
01314     pMarkItem->SetSaveable(FALSE);
01315     // we render this without formatting in a different way
01316     pMarkItem->SetRenderable(FALSE);
01317     // finally stick the thing in our cache!
01318     CropMarkHandle = AddNewMark(pMarkItem, NULL);
01319     
01320     return TRUE;
01321 }

BOOL PrintMarksCache::CreateTextInfoMark  )  [private]
 

This function creates a text information mark which will describe the current print job. As this will be created and destroyed on each print it should be reasonably fast to execute. We include the following information in the text....

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/08/96
Parameters:
pComp = the document component containing the print marks [INPUTS] CurrRegion = the current region we're formatting marks in
Returns:
-
Document title Date Time Page number? Plate name

Definition at line 1347 of file prnmks.cpp.

01348 {
01349     // is it already created?
01350     if (TextInfoHandle>0)
01351         return TRUE;
01352 
01353     // Create a particular mark structure for this info
01354     PrintMarkItem* pMarkItem = new PrintMarkItem;
01355     if (pMarkItem==NULL)
01356         return FALSE;
01357 
01358     MarkPosition* pPosition = new MarkPosition;
01359     if (pPosition==NULL)
01360     {
01361         delete pMarkItem;
01362         return FALSE;
01363     }
01364 
01365     MarkFormat format;
01366     format.Middle = TRUE;
01367     format.Left = TRUE;
01368     pPosition->SetRegion(MarkRegion_Top2);
01369     pPosition->SetFormat(format);
01370 
01371     String_256 MenuText(_R(IDS_PRINTMARK_PLATEINFO));
01372     PrintMark* pMark = pMarkItem->GetPrintMark();
01373     pMark->SetCustomOrDefault(FALSE);
01374     pMark->SetIDByte(PRINTMARK_INFOMARKID);
01375     pMark->SetType(MarkType_Information);
01376     pMark->SetMarkMenuText(&MenuText);
01377     pMark->SetOrientation(MO_Horizontal);
01378     pMark->SetDefaultState(TRUE);
01379     pMark->AddNewPosition(pPosition);
01380 
01381     // we don't want to save this mark
01382     pMarkItem->SetSaveable(FALSE);
01383     // finally stick the thing in our cache!
01384     TextInfoHandle = AddNewMark(pMarkItem, NULL);
01385     
01386     return TRUE;
01387 }

BOOL PrintMarksCache::DecodeCachedLayer Layer pLayer  )  [private]
 

Given a layer, if the layer contains a print mark, strip the print mark out and try to add it to the PrintMarksMan cache.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/07/96
Parameters:
pLayer = a pointer to a layer [INPUTS]
Returns:
TRUE if the layer has been processed

Definition at line 926 of file prnmks.cpp.

00927 {
00928     ERROR2IF(pLayer==NULL,FALSE,"NULL Layer passed to DecodeCachedLayer");
00929 
00930     // Read in the layer name
00931     String_256 Name;
00932     String_16 Token;
00933 
00934     Name = pLayer->GetLayerID();
00935     Name.Left(&Token, 10);
00936 
00937     BOOL IsValid = FALSE;
00938     BOOL IsCustomMark = FALSE;
00939     if (Token == String_16(_T("%PRINTMARK")))               // This text must not be internationalised
00940         IsValid = TRUE;
00941 
00942     if (!IsValid && Token == String_16(_T("%CUSTOMMAR")))   // This text must not be internationalised
00943     {
00944         IsValid = TRUE;
00945         IsCustomMark = TRUE;
00946     }
00947 
00948     if (!IsValid)
00949         return FALSE;
00950 
00951     // find the first renderable group in this layer.
00952     NodeGroup* pGroup = (NodeGroup*)pLayer->FindFirstChild(CC_RUNTIME_CLASS(NodeGroup));
00953     if (pGroup==NULL)
00954         return FALSE;
00955 
00956     // Create a new mark structure to put the decoded data into
00957     PrintMarkItem* pNewMark = new PrintMarkItem;
00958     if (!pNewMark)
00959         return FALSE;
00960 
00961     PrintMark* pMark = pNewMark->GetPrintMark();
00962     pMark->SetCustomOrDefault(IsCustomMark);        // Remember if it's a custom or default mark
00963     if (!DecodeMarkFormat(&Name, pMark))
00964     {
00965         delete pNewMark;
00966         return FALSE;
00967     }
00968 
00969     // Right we have a new print mark descriptor, 
00970     // we simply merge the mark into the
00971     // cache. It would be faster, before copying the subtree, to check whether we
00972     // dont already have this mark cached in the print mark manager.
00973 
00974     if (DoesMarkExist(pMark))
00975     {
00976         delete pNewMark;
00977         return TRUE;
00978     }
00979 
00980     // Add a handle to this mark
00981     pNewMark->SetHandle(GetUniqueHandle());
00982 
00983     // ok the mark does not exist, so now look for that first group
00984     if (!pNewMark->SetMarkGlyph(pGroup, TRUE))
00985     {
00986         delete pNewMark;
00987         return FALSE;
00988     }
00989 
00990     // Hey hey, we've finally done it! cool!
00991     PrintMarkCache.AddTail(pNewMark);
00992 
00993     return TRUE;
00994 }

BOOL PrintMarksCache::DecodeCachedLayers Document pDocument  )  [private]
 

Given a document, we scan each layer in the document. For each layer we check the loaded layer name. If the layer name contains a % at the begining (meaning its a format string) and the format is PRINTMARK, we take the first group in the layer (+ all its contents) and assign a new print mark item to this group. This group object will (if successfully) loaded, become a new print mark.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/07/96
Parameters:
pDocument = a pointer to a document [INPUTS]
Returns:
TRUE if the document has been processed

Definition at line 893 of file prnmks.cpp.

00894 {
00895     ERROR2IF(pDocument==NULL,FALSE,"NULL Layer passed to DecodeCachedLayer");
00896     
00897     Spread* pSpread = pDocument->FindFirstSpread();
00898     Layer* pLayer;
00899     while (pSpread!=NULL)
00900     {
00901         pLayer = pSpread->FindFirstLayer();
00902         while (pLayer!=NULL)
00903         {
00904             DecodeCachedLayer(pLayer);
00905             pLayer = pLayer->FindNextLayer(); // Find next layer
00906         }
00907         pSpread = pSpread->FindNextSpread();
00908     }
00909     return TRUE;
00910 }

BOOL PrintMarksCache::DecodeMarkFormat const String_256 pFormatString,
PrintMark pMark
[private]
 

Decode the string pointed to by pFormatString, placing each format identifier into the output mark.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/07/96
Parameters:
pFormatString [INPUTS]
pMark [OUTPUTS]
Returns:
TRUE if the format string was valid.
Special tag Mark name ID On/off Type Position(s) PRINTMARK = "Registration mark", 3, 1, _R(ID_STAR), 3MCS + 7MC + 11MCS + 15MC CUSTOMMARK = "User registration mark", 0, 1, _R(ID_STAR), 3MCS + 7MC + 11MCS + 15MC

Definition at line 1068 of file prnmks.cpp.

01069 {
01070     ERROR2IF(pFormatString == NULL, FALSE, "NULL pointer passed to DecodeMarkFormat");
01071     ERROR2IF(pMark == NULL, FALSE, "NULL mark pointer passed to DecodeMarkFormat");
01072 
01073     String_256 Name(*pFormatString);
01074     String_256 MenuText;
01075     String_256 MenuID;
01076     MarkFormat NewFormat;
01077     MarkRegion NewRegion;
01078     MarkOrient NewOrient;
01079 
01080     const TCHAR COMMA   = TEXT(',');        // This text must not be internationalised
01081 //  const TCHAR EQUALS  = TEXT('=');
01082     const TCHAR QUOTES  = TEXT('"');
01083     const TCHAR PLUS    = TEXT('+');
01084     const TCHAR SPACE   = TEXT(' ');
01085 
01086     INT32 pos, pos1;
01087 
01088     // Everything is hunky dory at the moment! ER NOT!
01089     BOOL AllIsWell = FALSE;
01090 
01091     // Turn on the exceptions function in the string reading class
01092     StringBase::EnableExceptionHandler();
01093 
01094     //try 
01095     {
01096         // toast everything up to the first quote
01097         pos = Name.FindNextChar(QUOTES);
01098         Name.Remove(0,pos+1);
01099 
01100         // now find the last quote of the first string
01101         pos = Name.FindNextChar(QUOTES);
01102         Name.Left(&MenuText,pos);
01103         Name.Remove(0,pos+1);
01104 
01105         // skip over the first comma onto the ID field
01106         pos  = Name.SkipComma();
01107         Name.Remove(0,pos);
01108         pos = 0;
01109         INT32 ID = Name.ConvertToInteger(pos);
01110         Name.Remove(0,pos);
01111         if (ID < 0 || ID > 255)
01112             ID = 0;
01113         pMark->SetIDByte((BYTE)ID);
01114 
01115         // skip over the next comma onto the enable/disable state
01116         pos  = Name.SkipComma();
01117         Name.Remove(0,pos);
01118         BOOL Enabled = (Name[0] == TEXT('1'));
01119 
01120         // skip comma to next field
01121         pos  = Name.SkipComma();
01122         pos1 = Name.FindNextChar(COMMA, pos+1);
01123         Name.Mid(&MenuID, pos, (pos1-pos));
01124         Name.Remove(0,pos1+1);
01125 
01126         // turn the menu id into a type of mark if we recognise it
01127         MarkType actid = (MarkType)DecodeToMarkType(&MenuID);
01128 
01129         // skip the orientation field
01130         pos=Name.FindNextChar();
01131         NewOrient=MO_None;
01132         if (Name[pos] == TEXT('H'))
01133             NewOrient=MO_Horizontal;
01134         else if (Name[pos] == TEXT('V'))
01135             NewOrient=MO_Vertical;
01136 
01137         // remove the orientation bit
01138         pos = Name.SkipComma();
01139 
01140         // Add what we have so far
01141         pMark->SetMarkMenuText(&MenuText);
01142         pMark->SetOrientation(NewOrient);
01143         pMark->SetType(actid);
01144         pMark->SetDefaultState(Enabled);
01145 
01146         // The remainder of this string is a format list
01147 //      BOOL format=FALSE;
01148 //      BOOL eos=FALSE;
01149 
01150         // Turn our exception handler off but don't pop it.
01151         StringBase::DisableExceptionHandler(FALSE);
01152 
01153         INT32 region;
01154 
01155         while (pos>0)
01156         {
01157             // Try to create a new mark to add
01158             MarkPosition* pNewMark = new MarkPosition;
01159 
01160             if (pNewMark!=NULL)
01161             {
01162                 region = Name.ConvertToInteger(pos);
01163 
01164                 if (region<1 || region>MAXPAGEREGIONS)
01165                 {
01166                     // Ok, the region number is out of range so lets
01167                     // skip to the next one (if there is one!)
01168                     // we need to find the next +
01169                     delete pNewMark;
01170                     pos = Name.FindNextChar(PLUS, pos);
01171                 }
01172                 else
01173                 {
01174                     // store this type of region
01175                     NewRegion = (MarkRegion)(region-1);
01176                     pNewMark->SetRegion(NewRegion);
01177                                 
01178                     // if we haven't run off the end of the string
01179                     while ( Name.IsLegal(pos) && (Name[pos]!=PLUS) )
01180                     {
01181                         TCHAR c = Name[pos];
01182                         
01183                         switch (c)
01184                         {
01185                             case TEXT('T'): NewFormat.Top=TRUE;     break;
01186                             case TEXT('M'): NewFormat.Middle=TRUE;  break;
01187                             case TEXT('B'): NewFormat.Bottom=TRUE;  break;
01188                             case TEXT('L'): NewFormat.Left=TRUE;    break;
01189                             case TEXT('C'): NewFormat.Centre=TRUE;  break;
01190                             case TEXT('R'): NewFormat.Right=TRUE;   break;
01191                             default:
01192                                 // unknown token, just ignore it!
01193                                 if (c != SPACE)
01194                                     TRACEUSER( "Mike", _T("Unknown format character during PrintMarksMan::DecodeMarkFormat"));
01195                                 break;
01196                         }
01197                         
01198                         pos = Name.FindNextChar(pos+1);
01199                     }
01200 
01201                     // make sure the format is ok
01202                     if (!NewFormat.IsValid())
01203                         NewFormat.MakeValid();
01204                     
01205                     // and set it in the structure.
01206                     pNewMark->SetFormat(NewFormat);
01207 
01208                     // Add the new mark position to the list.
01209                     pMark->AddNewPosition(pNewMark);
01210 
01211                     AllIsWell=TRUE;
01212 
01213                     if (Name.IsLegal(pos))
01214                         pos = Name.FindNextChar(pos+1);
01215                 }
01216             }
01217             else
01218             {
01219                 pos = -1;
01220             }
01221         }
01222     }
01223 PORTNOTE("other", "Disabled random use of MFC CUserException in Kernel code")
01224 #ifndef EXCLUDE_FROM_XARALX
01225     catch (CUserException)
01226     {
01227         // An exception has been thrown which means
01228         // we failed to parse this string, so simply report failure
01229         AllIsWell = FALSE;
01230     }
01231 #endif
01232 
01233     // Switch off the exception state finally, (and of course pop it)!
01234     StringBase::DisableExceptionHandler();
01235 
01236     return AllIsWell;
01237 }

UINT32 PrintMarksCache::DecodeToMarkType const String_256 Name  )  const [private]
 

Have a look at the string passed in and check to see it matches any of the known mark type names. If so return the proper mark type enum, otherwise 'Unkown' is returned.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/07/96
Parameters:
Name = a pointer to a string describing the mark type [INPUTS]
Returns:
A unsigned integer describing the mark type (see MarkType for instances)

Definition at line 1255 of file prnmks.cpp.

01256 {
01257     ERROR2IF(Name == NULL, MarkType_Unknown, "NULL pointer passed to DecodeToMarkType");
01258     
01259     if ((*Name)==String_16(_T("ID_NONE")))  return MarkType_Unknown; /*NORESOURCEFIX*/
01260     if ((*Name)==String_16(_T("ID_STAR")))  return MarkType_Star; /*NORESOURCEFIX*/ 
01261     if ((*Name)==String_16(_T("ID_REGM")))  return MarkType_Registration; /*NORESOURCEFIX*/
01262     if ((*Name)==String_16(_T("ID_CBAR")))  return MarkType_ColourBar; /*NORESOURCEFIX*/
01263     if ((*Name)==String_16(_T("ID_GBAR")))  return MarkType_GreyBar; /*NORESOURCEFIX*/
01264     if ((*Name)==String_16(_T("ID_INFO")))  return MarkType_Information; /*NORESOURCEFIX*/
01265     
01266     return MarkType_Unknown;
01267 }

BOOL PrintMarksCache::DeleteChildAttribute NodeRenderableInk pParent,
CCRuntimeClass pReqdAttrib
[private]
 

Delete a child attribute of a specified type from this parent.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/08/96
Parameters:
- [INPUTS]

Definition at line 1619 of file prnmks.cpp.

01620 {
01621     ERROR2IF(pParent==NULL || pReqdAttrib==NULL, FALSE, "NULL parameter");
01622     NodeAttribute* pAppliedAttr = pParent->GetChildAttrOfType(pReqdAttrib);
01623     if (!pAppliedAttr)
01624         return FALSE;
01625 
01626     pAppliedAttr->CascadeDelete();
01627     delete pAppliedAttr;
01628     return TRUE;
01629 }

void PrintMarksCache::DestroyTextInfoMark  )  [private]
 

Throw away any cached print information mark.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/08/96
Parameters:
- [INPUTS]

Definition at line 1645 of file prnmks.cpp.

01646 {
01647     if (TextInfoHandle>0)
01648     {
01649         PrintMarkItem *pItem = FindMark(TextInfoHandle);
01650         if (pItem!=NULL)
01651         {
01652             pItem = (PrintMarkItem*)PrintMarkCache.RemoveItem(pItem);
01653             if (pItem) delete pItem;
01654         }
01655     }
01656     TextInfoHandle=0;
01657 }

BOOL PrintMarksCache::DoesMarkExist PrintMark pCheckMark  )  const [private]
 

Try to find a print mark in the cache.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/07/96
Parameters:
A pointer to a print mark [INPUTS]
Returns:
TRUE if this mark already exists in the cache FALSE if not

Definition at line 834 of file prnmks.cpp.

00835 {
00836     PrintMarkItem* pItem = GetFirstMark();
00837     while (pItem)
00838     {
00839         PrintMark* pCurrMark = pItem->GetPrintMark();
00840         if (pCheckMark->IsSimilarTo(pCurrMark))
00841             return TRUE;
00842         pItem = GetNextMark(pItem);
00843     }
00844     return FALSE;
00845 }

PrintMarkItem * PrintMarksCache::FindMark UINT32  SearchHandle  ) 
 

Try to find a print mark in the cache, using its handle.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/07/96
Parameters:
SearchHandle = the handle of the mark to search for [INPUTS]
Returns:
A pointer to the print mark described by this handle (NULL if none)

Definition at line 860 of file prnmks.cpp.

00861 {
00862     PrintMarkItem* pItem = GetFirstMark();
00863     while (pItem)
00864     {
00865         if (pItem->GetHandle() == SearchHandle)
00866             return pItem;
00867         pItem = GetNextMark(pItem);
00868     }
00869     return NULL;
00870 }

PrintMarkItem * PrintMarksCache::GetFirstMark  )  const
 

Return a pointer to the first cached mark.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/07/96
Parameters:
- [INPUTS]
Returns:
A pointer to the first cached mark

Definition at line 797 of file prnmks.cpp.

00798 {
00799     return ((PrintMarkItem*)PrintMarkCache.GetHead()); 
00800 }

PrintMarkItem * PrintMarksCache::GetNextMark PrintMarkItem pCurrMark  )  const
 

Returns the next print mark item beyond pCurrMark.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/07/96
Parameters:
A pointer to a print mark item [INPUTS]
Returns:
A pointer to the next print mark item after this

Definition at line 815 of file prnmks.cpp.

00816 {
00817     return ((PrintMarkItem*)PrintMarkCache.GetNext(pCurrMark));
00818 }

UINT32 PrintMarksCache::GetUniqueHandle  )  [private]
 

Generate a unique print mark handle. All handles will be >=1 and hence an illegal handle is given the value 0.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/07/96
Parameters:
- [INPUTS]
Returns:
A handle used to reference a unique print mark

Definition at line 777 of file prnmks.cpp.

00778 {
00779     NextHandle++;
00780     return (NextHandle);
00781 }

void PrintMarksCache::Invalidate  )  [private]
 

Invalidate the cache list. If we do this, all the mark references in existing document will reference nothing. As we create new marks new handles will be built, so it might be necessary to delete references made in all doc components. Use with care.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/07/96

Definition at line 752 of file prnmks.cpp.

00753 {
00754     // destroy all marks in the cache.
00755     PrintMarkItem* pItem;
00756     while ((pItem=(PrintMarkItem*)PrintMarkCache.RemoveTail())) // assignment
00757         delete pItem;
00758     // Make sure the crop and text info handles don't reference anything
00759     CropMarkHandle=0;
00760     TextInfoHandle=0;
00761 }

BOOL PrintMarksCache::SetInfoMarkAttributes TextStory pStory,
String_64 pFontName,
MILLIPOINT  FontSize
[private]
 

This function creates a text information mark which will describe the current print job. As this will be created and destroyed on each print it should be reasonably fast to execute. We include the following information in the text....

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/08/96
Parameters:
pComp = the document component containing the print marks [INPUTS] CurrRegion = the current region we're formatting marks in
Returns:
-
Document title Date Time Page number? Plate name

Definition at line 1574 of file prnmks.cpp.

01575 {
01576     BOOL ok;
01577 
01578     // Ensure the font is cached. The fontmangler will return a replace font if
01579     // it can't find the required one.
01580     WORD Handle = FONTMANAGER->CacheNamedFont(pFontName);
01581     if (Handle==ILLEGALFHANDLE)
01582         return FALSE;
01583 
01584     // find the first line in this story
01585     TextLine* pTextLine = pStory->FindFirstLine();
01586     if (pTextLine==NULL)
01587         return FALSE;
01588 
01589     // Delete the current instances of the attribute first
01590     ok = DeleteChildAttribute(pTextLine, CC_RUNTIME_CLASS(AttrTxtFontTypeface));
01591     if (!ok) ok = DeleteChildAttribute(pStory, CC_RUNTIME_CLASS(AttrTxtFontTypeface));
01592 
01593     ok = DeleteChildAttribute(pTextLine, CC_RUNTIME_CLASS(AttrTxtFontSize));
01594     if (!ok) ok = DeleteChildAttribute(pStory, CC_RUNTIME_CLASS(AttrTxtFontSize));
01595     
01596     // now create new ones
01597     TxtFontTypefaceAttribute FontAttr(Handle);
01598     TxtFontSizeAttribute     SizeAttr(FontSize);
01599 
01600             ok = ((AttributeValue*)&FontAttr)->MakeNode(pTextLine,PREV) != NULL;
01601     if (ok) ok = ((AttributeValue*)&SizeAttr)->MakeNode(pTextLine,PREV) != NULL;
01602 
01603     return ok;
01604 }

void PrintMarksCache::UpdateMarkGlyph PrintMarkItem pMarkItem,
NodeGroup pGroup
[private]
 

Change the mark glyph to this new mark.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/07/96
Parameters:
pMarkItem = a pointer to an existing cached mark [INPUTS] pGroup = a pointer to a new glyph to use.
Returns:
-

Definition at line 1037 of file prnmks.cpp.

01038 {
01039     if (pMarkItem!=NULL)
01040     {
01041         // Make sure there's nothing in there at the mo.
01042         pMarkItem->RemoveMark();
01043         // now set the new mark glyph
01044         pMarkItem->pMarkGlyph = pGroup;
01045     }
01046 }

BOOL PrintMarksCache::UpdateTextInfoMark Document pDocument,
RenderRegion pRRegion
[private]
 

This function creates a text information mark which will describe the current print job. As this will be created and destroyed on each print it should be reasonably fast to execute. We include the following information in the text....

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/08/96
Parameters:
pComp = the document component containing the print marks [INPUTS] CurrRegion = the current region we're formatting marks in
Returns:
-
Document title Date Time Page number? Plate name

Definition at line 1413 of file prnmks.cpp.

01414 {
01415     // We should at least have one of these.
01416     if (TextInfoHandle==0)
01417         return FALSE;
01418 
01419     // find it in the cache
01420     PrintMarkItem *pMarkItem = FindMark(TextInfoHandle);
01421     if (!pMarkItem)
01422         return FALSE;
01423 
01424     // first put all the information we need to display in a string.
01425     String_256 TextInfo;
01426     BuildTextInfoString(pDocument, pRRegion, &TextInfo);
01427 
01428     // create a proper mark structure to fit this mark in
01429     NodeGroup* pNewGroup = new NodeGroup;
01430     if (pNewGroup==NULL)
01431         return FALSE;
01432 
01433     NodeGroup* pNewGroup1 = new NodeGroup;
01434     if (pNewGroup1==NULL)
01435     {
01436         delete pNewGroup;
01437         return FALSE;
01438     }
01439 /*
01440     // Make a text style LOGFONT to describe the text information
01441     LOGFONT Style;
01442     Style.lfHeight          =0x08;      // 8pt text
01443     Style.lfWidth           =0x05;
01444     Style.lfEscapement      =0x00;
01445     Style.lfOrientation     =0x00;
01446     Style.lfWeight          =0x190;
01447     Style.lfItalic          =0x00;
01448     Style.lfUnderline       =0x00;
01449     Style.lfStrikeOut       =0x00;
01450     Style.lfCharSet         =0x00;
01451     Style.lfOutPrecision    =0x03;
01452     Style.lfClipPrecision   =0x02;
01453     Style.lfQuality         =0x01;
01454     Style.lfPitchAndFamily  =0x12;
01455     camStrncpy(Style.lfFaceName, TEXT("Times New Roman\0"), 16);
01456 */
01457     String_64 FontName(_T("Courier New"));
01458     MILLIPOINT FontSize = 9*1000;
01459 
01460     // now create the text story to put in the mark.
01461     TextStory *pStory;
01462     DocColour TextCol(COLOUR_BLACK);
01463 #ifdef _UNICODE
01464     pStory = TextStory::CreateFromChars(DocCoord(0,0), NULL, (TCHAR *)TextInfo, pDocument, NULL, FALSE, &TextCol);
01465 #else
01466     pStory = TextStory::CreateFromChars(DocCoord(0,0), (char *)TextInfo, NULL, pDocument, NULL, FALSE, &TextCol);
01467 #endif
01468     if (pStory==NULL)
01469     {
01470         // deleting this will delete the mark position
01471         delete pNewGroup1;
01472         delete pNewGroup;
01473         return FALSE;
01474     }
01475 
01476     // ok make sure the attributes are set nicely
01477     if (!SetInfoMarkAttributes(pStory,&FontName,FontSize))
01478     {
01479         delete pStory;
01480         delete pNewGroup1;
01481         delete pNewGroup;
01482         return FALSE;
01483     }
01484 
01485     // Turn the print as shapes on. This means we will render it rather
01486     // than GDI rendering it. It also means the text goes out after our header
01487     // which sets things like Negative transfer. If we don't render the
01488     // text we wont have put out our header yet..... Hence the text has a habit
01489     // of vanishing on 'Negative' prints, black on black n all that. We could
01490     // set the colour of the text of course, hmm maybe? This is quicker for now.
01491     pStory->SetPrintingAsShapes(TRUE);
01492 
01493     // attach this new group to the tree
01494     pNewGroup1->AttachNode(pNewGroup,FIRSTCHILD);
01495     // attach the story to the group
01496     pStory->AttachNode(pNewGroup1,FIRSTCHILD);
01497 
01498     // We need to attach this structure to the tree, at the insertion node and makeattributes complete on it.
01499     pDocument->InsertNewNode(pNewGroup,NULL);
01500 
01501 /*
01502     // make sure we have all the attributes we're gonna need
01503     if (!pNewGroup->MakeAttributeComplete(NULL,TRUE,NULL,TRUE))
01504     {
01505         pNewGroup->CascadeDelete();
01506         delete pNewGroup;
01507         return FALSE;
01508     }
01509 */
01510     // time to format the story into shape.
01511     if (!pStory->FormatAndChildren())
01512     {
01513         pNewGroup->CascadeDelete();
01514         delete pNewGroup;
01515         return FALSE;
01516     }
01517 
01518     // ok this is silly, but here we go, make the text into shapes so
01519     // it bloomin well prints properly.
01520     NodeGroup* pNGroup = new NodeGroup;
01521     if (pNGroup!=NULL)
01522     {
01523         // stuff it in the tree
01524         pNGroup->AttachNode(pNewGroup1,NEXT);
01525         // copy all children as shapes
01526         if (pNewGroup1->CopyChildrenAsShapes(pNGroup))
01527         {
01528             // rip the node out of the tree and stick it in our cache.
01529             pNGroup->UnlinkNodeFromTree();
01530             // destroy the first group we created
01531             pNewGroup->CascadeDelete();
01532             delete pNewGroup;
01533             // finally stick the thing in our cache!
01534             // rip the node out of the tree and stick it in our cache.
01535             // finally stick the thing in our cache!
01536             UpdateMarkGlyph(pMarkItem, pNGroup);
01537             return TRUE;
01538         }
01539         pNGroup->CascadeDelete();
01540         delete pNGroup;
01541     }
01542 
01543     // rip the node out of the tree and stick it in our cache.
01544     pNewGroup->UnlinkNodeFromTree();
01545     // finally stick the thing in our cache!
01546     UpdateMarkGlyph(pMarkItem, pNewGroup);
01547 
01548     return TRUE;
01549 }


Friends And Related Function Documentation

friend class LoadPrintMarks [friend]
 

Definition at line 652 of file prnmks.h.

friend class PrintMarksComponent [friend]
 

Definition at line 653 of file prnmks.h.

friend class PrintMarksMan [friend]
 

Definition at line 651 of file prnmks.h.


Member Data Documentation

String_256 PrintMarksCache::CachedTime [private]
 

Definition at line 688 of file prnmks.h.

UINT32 PrintMarksCache::CropMarkHandle [private]
 

Definition at line 685 of file prnmks.h.

UINT32 PrintMarksCache::NextHandle [private]
 

Definition at line 683 of file prnmks.h.

List PrintMarksCache::PrintMarkCache [private]
 

Definition at line 686 of file prnmks.h.

UINT32 PrintMarksCache::TextInfoHandle [private]
 

Definition at line 684 of file prnmks.h.


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