00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 #include "camtypes.h"
00109
00110
00111 #include "prnmks.h"
00112
00113 #include "fileutil.h"
00114
00115
00116
00117 #include "nativeop.h"
00118 #include "layer.h"
00119
00120 #include "page.h"
00121
00122 #include "colormgr.h"
00123 #include "prnmkcom.h"
00124 #include "qualattr.h"
00125
00126 #include "dbugtree.h"
00127
00128 #include "cctime.h"
00129 #include "nodetxts.h"
00130 #include "nodetxtl.h"
00131 #include "colplate.h"
00132 #include "printctl.h"
00133 #include "fontman.h"
00134 #include "psrndrgn.h"
00135 #include "psdc.h"
00136
00137 #include <stdlib.h>
00138
00139 CC_IMPLEMENT_MEMDUMP(LoadPrintMarks, LoadDirect);
00140 CC_IMPLEMENT_MEMDUMP(PrintMarksMan, CC_CLASS_MEMDUMP);
00141 CC_IMPLEMENT_MEMDUMP(PrintMarksCache, CC_CLASS_MEMDUMP);
00142 CC_IMPLEMENT_MEMDUMP(PrintMark, CC_CLASS_MEMDUMP);
00143 CC_IMPLEMENT_DYNCREATE(MarkPosition, ListItem);
00144 CC_IMPLEMENT_DYNCREATE(PrintMarkItem, ListItem);
00145 CC_IMPLEMENT_MEMDUMP(MarkFormatRegion, CC_CLASS_MEMDUMP);
00146 CC_IMPLEMENT_DYNCREATE(PageRect, ListItem);
00147 CC_IMPLEMENT_DYNAMIC(PageRectList, List);
00148
00149 DECLARE_SOURCE("$Revision: 1320 $");
00150
00151 #define new CAM_DEBUG_NEW
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 MarkFormat::MarkFormat()
00165 {
00166 Top = Middle = Bottom = FALSE;
00167 Left = Centre = Right = FALSE;
00168 }
00169
00170 BOOL MarkFormat::IsValid() const
00171 {
00172 return (Top || Middle || Bottom || Left || Centre || Right);
00173 }
00174
00175 void MarkFormat::MakeValid()
00176 {
00177 Centre = Middle = TRUE;
00178 Top = Bottom = Left = Right = FALSE;
00179 }
00180
00181 INT32 operator==(const MarkFormat& x, const MarkFormat& y)
00182 {
00183 return ( (x.Centre == y.Centre) &&
00184 (x.Middle == y.Middle) &&
00185 (x.Left == y.Left) &&
00186 (x.Right == y.Right) &&
00187 (x.Top == y.Top) &&
00188 (x.Bottom == y.Bottom)
00189 );
00190 }
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 BYTE MarkFormat::GetAsFlagByte(void)
00211 {
00212 BYTE Flags = 0;
00213
00214 if (Left) Flags |= 0x01;
00215 if (Centre) Flags |= 0x02;
00216 if (Right) Flags |= 0x04;
00217 if (Top) Flags |= 0x08;
00218 if (Middle) Flags |= 0x10;
00219 if (Bottom) Flags |= 0x20;
00220
00221 return(Flags);
00222 }
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 void MarkFormat::SetFromFlagByte(BYTE Flags)
00243 {
00244 Left = (Flags & 0x01) ? TRUE : FALSE;
00245 Centre = (Flags & 0x02) ? TRUE : FALSE;
00246 Right = (Flags & 0x04) ? TRUE : FALSE;
00247 Top = (Flags & 0x08) ? TRUE : FALSE;
00248 Middle = (Flags & 0x10) ? TRUE : FALSE;
00249 Bottom = (Flags & 0x20) ? TRUE : FALSE;
00250 }
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266 MarkPosition::MarkPosition()
00267 {
00268 Initialise();
00269 }
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282 void MarkPosition::Initialise()
00283 {
00284 Region = MarkRegion_TopLeft;
00285 }
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301 BOOL MarkPosition::IsEqualTo(const MarkPosition* pOther) const
00302 {
00303 ERROR2IF(pOther==NULL, FALSE, "NULL pointer passed to MarkPosition::IsEqualTo");
00304 return ( (Region == pOther->Region) &&
00305 (Format == pOther->Format)
00306 );
00307 }
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320 PrintMark::PrintMark()
00321 {
00322 MarkIsCustom = FALSE;
00323 IDByte = 0;
00324 Type = MarkType_Unknown;
00325 Orientation = MO_None;
00326 OnAsDefault = FALSE;
00327 }
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340 PrintMark::~PrintMark()
00341 {
00342 MarkPosition* pMarkPos;
00343 while ((pMarkPos=(MarkPosition*)MarkPositions.RemoveTail()))
00344 delete pMarkPos;
00345 }
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361 void PrintMark::SetMarkMenuText(const String_256* pMenuText)
00362 {
00363 ERROR3IF(pMenuText==NULL,"ERROR ERROR, NULL pointer passed to SetMarkMenuText");
00364 if (pMenuText!=NULL)
00365 MenuText = (*pMenuText);
00366 }
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381 String_256 PrintMark::GetMarkMenuText() const
00382 {
00383 return MenuText;
00384 }
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399 void PrintMark::AddNewPosition(MarkPosition* pNewMarkPos)
00400 {
00401 ERROR3IF(pNewMarkPos==NULL,"NULL MarkPosition pointer passed to AddNewPosition");
00402 if (pNewMarkPos)
00403 {
00404 if (!FindMarkPosition(pNewMarkPos))
00405 MarkPositions.AddTail(pNewMarkPos);
00406 }
00407 }
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429 BOOL PrintMark::FindMarkPosition(const MarkPosition* pSearchMark, MarkPosition** pFoundMark) const
00430 {
00431 ERROR3IF(pSearchMark==NULL,"PrintMark::FindMarkPosition passed a NULL search mark pointer");
00432 if (pSearchMark)
00433 {
00434 MarkPosition* pMarkPos = GetFirstPosition();
00435 while (pMarkPos)
00436 {
00437
00438 if (pSearchMark->IsEqualTo(pMarkPos))
00439 {
00440 if (pFoundMark!=NULL)
00441 (*pFoundMark=pMarkPos);
00442 return TRUE;
00443 }
00444 pMarkPos = GetNextPosition(pMarkPos);
00445 }
00446 }
00447 if (pFoundMark!=NULL)
00448 (*pFoundMark=NULL);
00449 return FALSE;
00450 }
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468 BOOL PrintMark::IsSimilarTo(const PrintMark* pOther) const
00469 {
00470 ERROR2IF(pOther==NULL, FALSE, "NULL PrintMark pointer passed to IsSimilar()");
00471
00472 if (Type == pOther->GetType())
00473 {
00474 if (MenuText == pOther->GetMarkMenuText())
00475 return TRUE;
00476 }
00477 return FALSE;
00478 }
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492 PrintMarkItem::PrintMarkItem()
00493 {
00494 pMarkGlyph = NULL;
00495 Handle = 0;
00496 Saveable = TRUE;
00497 Renderable = TRUE;
00498 }
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511 PrintMarkItem::~PrintMarkItem()
00512 {
00513 RemoveMark();
00514 }
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540 BOOL PrintMarkItem::SetMarkGlyph(NodeGroup* pNewMark, BOOL MakeCopy)
00541 {
00542 ERROR2IF(pNewMark==NULL,FALSE, "NULL mark pointer passed to SetMark");
00543
00544 if (MakeCopy)
00545 {
00546 NodeGroup* pNewGroup = new NodeGroup;
00547 if (pNewGroup==NULL)
00548 return FALSE;
00549
00550 NodeGroup* pNewGroup1 = new NodeGroup;
00551 if (pNewGroup1==NULL)
00552 {
00553 delete pNewGroup;
00554 return FALSE;
00555 }
00556
00557
00558 pNewGroup->AttachNode(pNewMark,NEXT);
00559 pNewGroup1->AttachNode(pNewGroup,FIRSTCHILD);
00560
00561
00562 if (!pNewMark->CopyChildrenTo(pNewGroup1))
00563 {
00564
00565 pNewGroup->CascadeDelete();
00566 delete pNewGroup;
00567 return FALSE;
00568 }
00569
00570
00571 if (!pNewGroup->MakeAttributeComplete(NULL,TRUE,NULL,TRUE))
00572 {
00573 pNewGroup->CascadeDelete();
00574 delete pNewGroup;
00575 return FALSE;
00576 }
00577
00578
00579
00580
00581
00582
00583 pNewGroup->UnlinkNodeFromTree();
00584
00585
00586 if (pMarkGlyph!=NULL)
00587 RemoveMark();
00588
00589 pMarkGlyph = pNewGroup;
00590 }
00591 else
00592 {
00593 if (!pNewMark->MakeAttributeComplete(NULL,TRUE,NULL,TRUE))
00594 return FALSE;
00595
00596 pNewMark->UnlinkNodeFromTree();
00597
00598
00599 if (pMarkGlyph!=NULL)
00600 RemoveMark();
00601
00602 pMarkGlyph = pNewMark;
00603 }
00604
00605 return TRUE;
00606 }
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620 void PrintMarkItem::RemoveMark()
00621 {
00622
00623 if (pMarkGlyph!=NULL)
00624 {
00625 Node* pNode = pMarkGlyph->FindFirstChild();
00626 if (pNode!=NULL)
00627 pMarkGlyph->DeleteChildren(pNode);
00628 }
00629 delete pMarkGlyph;
00630 pMarkGlyph = NULL;
00631 }
00632
00633
00634 INT32 PrintMarkItem::GetWidth() const
00635 {
00636 if (pMarkGlyph!=NULL)
00637 {
00638 DocRect bounds = pMarkGlyph->GetBoundingRect();
00639 return bounds.Width();
00640 }
00641 return 0;
00642 }
00643
00644 INT32 PrintMarkItem::GetHeight() const
00645 {
00646 if (pMarkGlyph!=NULL)
00647 {
00648 DocRect bounds = pMarkGlyph->GetBoundingRect();
00649 return bounds.Height();
00650 }
00651 return 0;
00652 }
00653
00654 DocCoord PrintMarkItem::GetOrigin() const
00655 {
00656 if (pMarkGlyph!=NULL)
00657 {
00658 DocRect bounds = pMarkGlyph->GetBoundingRect();
00659 return bounds.lo;
00660 }
00661 return DocCoord(0,0);
00662 }
00663
00664
00665 MarkOrient PrintMarkItem::GetOrient() const
00666 {
00667 return Mark.GetOrientation();
00668 }
00669
00670
00671 BOOL PrintMarkItem::DefaultsToOn() const
00672 {
00673 return Mark.DefaultsToOn();
00674 }
00675
00676
00677 BOOL PrintMarkItem::NeedsSaving() const
00678 {
00679 return Saveable;
00680 }
00681
00682
00683 void PrintMarkItem::SetSaveable(BOOL savestate)
00684 {
00685 Saveable = savestate;
00686 }
00687
00688 BOOL PrintMarkItem::NeedsToRender() const
00689 {
00690 return Renderable;
00691 }
00692
00693 void PrintMarkItem::SetRenderable(BOOL renderstate)
00694 {
00695 Renderable = renderstate;
00696 }
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714 PrintMarksCache::PrintMarksCache()
00715 {
00716 NextHandle=0;
00717 TextInfoHandle=0;
00718 CropMarkHandle=0;
00719 }
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732 PrintMarksCache::~PrintMarksCache()
00733 {
00734 Invalidate();
00735 }
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752 void PrintMarksCache::Invalidate()
00753 {
00754
00755 PrintMarkItem* pItem;
00756 while ((pItem=(PrintMarkItem*)PrintMarkCache.RemoveTail()))
00757 delete pItem;
00758
00759 CropMarkHandle=0;
00760 TextInfoHandle=0;
00761 }
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777 UINT32 PrintMarksCache::GetUniqueHandle()
00778 {
00779 NextHandle++;
00780 return (NextHandle);
00781 }
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797 PrintMarkItem* PrintMarksCache::GetFirstMark() const
00798 {
00799 return ((PrintMarkItem*)PrintMarkCache.GetHead());
00800 }
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815 PrintMarkItem* PrintMarksCache::GetNextMark(PrintMarkItem* pCurrMark) const
00816 {
00817 return ((PrintMarkItem*)PrintMarkCache.GetNext(pCurrMark));
00818 }
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834 BOOL PrintMarksCache::DoesMarkExist(PrintMark* pCheckMark) const
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 }
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860 PrintMarkItem* PrintMarksCache::FindMark(UINT32 SearchHandle)
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 }
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893 BOOL PrintMarksCache::DecodeCachedLayers(Document* pDocument)
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();
00906 }
00907 pSpread = pSpread->FindNextSpread();
00908 }
00909 return TRUE;
00910 }
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926 BOOL PrintMarksCache::DecodeCachedLayer(Layer* pLayer)
00927 {
00928 ERROR2IF(pLayer==NULL,FALSE,"NULL Layer passed to DecodeCachedLayer");
00929
00930
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")))
00940 IsValid = TRUE;
00941
00942 if (!IsValid && Token == String_16(_T("%CUSTOMMAR")))
00943 {
00944 IsValid = TRUE;
00945 IsCustomMark = TRUE;
00946 }
00947
00948 if (!IsValid)
00949 return FALSE;
00950
00951
00952 NodeGroup* pGroup = (NodeGroup*)pLayer->FindFirstChild(CC_RUNTIME_CLASS(NodeGroup));
00953 if (pGroup==NULL)
00954 return FALSE;
00955
00956
00957 PrintMarkItem* pNewMark = new PrintMarkItem;
00958 if (!pNewMark)
00959 return FALSE;
00960
00961 PrintMark* pMark = pNewMark->GetPrintMark();
00962 pMark->SetCustomOrDefault(IsCustomMark);
00963 if (!DecodeMarkFormat(&Name, pMark))
00964 {
00965 delete pNewMark;
00966 return FALSE;
00967 }
00968
00969
00970
00971
00972
00973
00974 if (DoesMarkExist(pMark))
00975 {
00976 delete pNewMark;
00977 return TRUE;
00978 }
00979
00980
00981 pNewMark->SetHandle(GetUniqueHandle());
00982
00983
00984 if (!pNewMark->SetMarkGlyph(pGroup, TRUE))
00985 {
00986 delete pNewMark;
00987 return FALSE;
00988 }
00989
00990
00991 PrintMarkCache.AddTail(pNewMark);
00992
00993 return TRUE;
00994 }
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012 UINT32 PrintMarksCache::AddNewMark(PrintMarkItem* pNewMark, NodeGroup* pGroup)
01013 {
01014
01015 UINT32 hndle = GetUniqueHandle();
01016 pNewMark->SetHandle(hndle);
01017 pNewMark->pMarkGlyph = pGroup;
01018
01019 PrintMarkCache.AddTail(pNewMark);
01020 return hndle;
01021 }
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037 void PrintMarksCache::UpdateMarkGlyph(PrintMarkItem *pMarkItem, NodeGroup *pGroup)
01038 {
01039 if (pMarkItem!=NULL)
01040 {
01041
01042 pMarkItem->RemoveMark();
01043
01044 pMarkItem->pMarkGlyph = pGroup;
01045 }
01046 }
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068 BOOL PrintMarksCache::DecodeMarkFormat(const String_256 *pFormatString, PrintMark* pMark)
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(',');
01081
01082 const TCHAR QUOTES = TEXT('"');
01083 const TCHAR PLUS = TEXT('+');
01084 const TCHAR SPACE = TEXT(' ');
01085
01086 INT32 pos, pos1;
01087
01088
01089 BOOL AllIsWell = FALSE;
01090
01091
01092 StringBase::EnableExceptionHandler();
01093
01094
01095 {
01096
01097 pos = Name.FindNextChar(QUOTES);
01098 Name.Remove(0,pos+1);
01099
01100
01101 pos = Name.FindNextChar(QUOTES);
01102 Name.Left(&MenuText,pos);
01103 Name.Remove(0,pos+1);
01104
01105
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
01116 pos = Name.SkipComma();
01117 Name.Remove(0,pos);
01118 BOOL Enabled = (Name[0] == TEXT('1'));
01119
01120
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
01127 MarkType actid = (MarkType)DecodeToMarkType(&MenuID);
01128
01129
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
01138 pos = Name.SkipComma();
01139
01140
01141 pMark->SetMarkMenuText(&MenuText);
01142 pMark->SetOrientation(NewOrient);
01143 pMark->SetType(actid);
01144 pMark->SetDefaultState(Enabled);
01145
01146
01147
01148
01149
01150
01151 StringBase::DisableExceptionHandler(FALSE);
01152
01153 INT32 region;
01154
01155 while (pos>0)
01156 {
01157
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
01167
01168
01169 delete pNewMark;
01170 pos = Name.FindNextChar(PLUS, pos);
01171 }
01172 else
01173 {
01174
01175 NewRegion = (MarkRegion)(region-1);
01176 pNewMark->SetRegion(NewRegion);
01177
01178
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
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
01202 if (!NewFormat.IsValid())
01203 NewFormat.MakeValid();
01204
01205
01206 pNewMark->SetFormat(NewFormat);
01207
01208
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
01228
01229 AllIsWell = FALSE;
01230 }
01231 #endif
01232
01233
01234 StringBase::DisableExceptionHandler();
01235
01236 return AllIsWell;
01237 }
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255 UINT32 PrintMarksCache::DecodeToMarkType(const String_256* Name) const
01256 {
01257 ERROR2IF(Name == NULL, MarkType_Unknown, "NULL pointer passed to DecodeToMarkType");
01258
01259 if ((*Name)==String_16(_T("ID_NONE"))) return MarkType_Unknown;
01260 if ((*Name)==String_16(_T("ID_STAR"))) return MarkType_Star;
01261 if ((*Name)==String_16(_T("ID_REGM"))) return MarkType_Registration;
01262 if ((*Name)==String_16(_T("ID_CBAR"))) return MarkType_ColourBar;
01263 if ((*Name)==String_16(_T("ID_GBAR"))) return MarkType_GreyBar;
01264 if ((*Name)==String_16(_T("ID_INFO"))) return MarkType_Information;
01265
01266 return MarkType_Unknown;
01267 }
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282 BOOL PrintMarksCache::CreateCropMark()
01283 {
01284 if (CropMarkHandle>0)
01285 return TRUE;
01286
01287
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
01314 pMarkItem->SetSaveable(FALSE);
01315
01316 pMarkItem->SetRenderable(FALSE);
01317
01318 CropMarkHandle = AddNewMark(pMarkItem, NULL);
01319
01320 return TRUE;
01321 }
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347 BOOL PrintMarksCache::CreateTextInfoMark()
01348 {
01349
01350 if (TextInfoHandle>0)
01351 return TRUE;
01352
01353
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
01382 pMarkItem->SetSaveable(FALSE);
01383
01384 TextInfoHandle = AddNewMark(pMarkItem, NULL);
01385
01386 return TRUE;
01387 }
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413 BOOL PrintMarksCache::UpdateTextInfoMark(Document* pDocument, RenderRegion* pRRegion)
01414 {
01415
01416 if (TextInfoHandle==0)
01417 return FALSE;
01418
01419
01420 PrintMarkItem *pMarkItem = FindMark(TextInfoHandle);
01421 if (!pMarkItem)
01422 return FALSE;
01423
01424
01425 String_256 TextInfo;
01426 BuildTextInfoString(pDocument, pRRegion, &TextInfo);
01427
01428
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
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457 String_64 FontName(_T("Courier New"));
01458 MILLIPOINT FontSize = 9*1000;
01459
01460
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
01471 delete pNewGroup1;
01472 delete pNewGroup;
01473 return FALSE;
01474 }
01475
01476
01477 if (!SetInfoMarkAttributes(pStory,&FontName,FontSize))
01478 {
01479 delete pStory;
01480 delete pNewGroup1;
01481 delete pNewGroup;
01482 return FALSE;
01483 }
01484
01485
01486
01487
01488
01489
01490
01491 pStory->SetPrintingAsShapes(TRUE);
01492
01493
01494 pNewGroup1->AttachNode(pNewGroup,FIRSTCHILD);
01495
01496 pStory->AttachNode(pNewGroup1,FIRSTCHILD);
01497
01498
01499 pDocument->InsertNewNode(pNewGroup,NULL);
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511 if (!pStory->FormatAndChildren())
01512 {
01513 pNewGroup->CascadeDelete();
01514 delete pNewGroup;
01515 return FALSE;
01516 }
01517
01518
01519
01520 NodeGroup* pNGroup = new NodeGroup;
01521 if (pNGroup!=NULL)
01522 {
01523
01524 pNGroup->AttachNode(pNewGroup1,NEXT);
01525
01526 if (pNewGroup1->CopyChildrenAsShapes(pNGroup))
01527 {
01528
01529 pNGroup->UnlinkNodeFromTree();
01530
01531 pNewGroup->CascadeDelete();
01532 delete pNewGroup;
01533
01534
01535
01536 UpdateMarkGlyph(pMarkItem, pNGroup);
01537 return TRUE;
01538 }
01539 pNGroup->CascadeDelete();
01540 delete pNGroup;
01541 }
01542
01543
01544 pNewGroup->UnlinkNodeFromTree();
01545
01546 UpdateMarkGlyph(pMarkItem, pNewGroup);
01547
01548 return TRUE;
01549 }
01550
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574 BOOL PrintMarksCache::SetInfoMarkAttributes(TextStory *pStory, String_64 *pFontName, MILLIPOINT FontSize)
01575 {
01576 BOOL ok;
01577
01578
01579
01580 WORD Handle = FONTMANAGER->CacheNamedFont(pFontName);
01581 if (Handle==ILLEGALFHANDLE)
01582 return FALSE;
01583
01584
01585 TextLine* pTextLine = pStory->FindFirstLine();
01586 if (pTextLine==NULL)
01587 return FALSE;
01588
01589
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
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 }
01605
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619 BOOL PrintMarksCache::DeleteChildAttribute(NodeRenderableInk* pParent, CCRuntimeClass* pReqdAttrib)
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 }
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643
01644
01645 void PrintMarksCache::DestroyTextInfoMark()
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 }
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672 void PrintMarksCache::BuildTextInfoString(Document *pDocument, RenderRegion* pRRegion, String_256 *pString)
01673 {
01674
01675 (*pString) = pDocument->GetTitle();
01676 (*pString) += TEXT(" ");
01677
01678
01679 (*pString) += CachedTime;
01680
01681
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 }
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712
01713 PageRect::PageRect(const DocRect &rect)
01714 {
01715 Rect = rect;
01716 }
01717
01718 PageRectList::~PageRectList()
01719 {
01720 DeleteAll();
01721 }
01722
01723 void PageRectList::DeleteAll()
01724 {
01725 PageRect* pItem;
01726 while ((pItem=((PageRect*)RemoveTail())))
01727 delete pItem;
01728 }
01729
01730 inline PageRect* PageRectList::GetFirstPageRect() const
01731 {
01732 return ((PageRect*)GetHead());
01733 }
01734
01735 inline PageRect* PageRectList::GetNextPageRect(PageRect* pItem) const
01736 {
01737 return ((PageRect*)GetNext(pItem));
01738 }
01739
01740 BOOL PageRectList::AddPageRect(const DocRect &rect)
01741 {
01742 if (FindPageRect(rect)==NULL)
01743 {
01744 PageRect *pRect = new PageRect(rect);
01745 if (pRect)
01746 {
01747 AddTail(pRect);
01748 return TRUE;
01749 }
01750 return FALSE;
01751 }
01752 return TRUE;
01753 }
01754
01755 PageRect* PageRectList::FindPageRect(const DocRect &rect) const
01756 {
01757 PageRect* pItem = GetFirstPageRect();
01758 while (pItem)
01759 {
01760 if (pItem->Rect == rect)
01761 return pItem;
01762 pItem = GetNextPageRect(pItem);
01763 }
01764 return NULL;
01765 }
01766
01767
01768
01769
01770
01771
01772
01773
01774
01775
01776
01777
01778
01779
01780
01781
01782 PrintMarksMan::PrintMarksMan()
01783 {
01784 Bleed = 0;
01785 TemplateCached=FALSE;
01786 EmulsionDown=FALSE;
01787 }
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800 PrintMarksMan::~PrintMarksMan()
01801 {
01802 }
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819 BOOL PrintMarksMan::IsTemplateCached() const
01820 {
01821 return TemplateCached;
01822 }
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850 BOOL PrintMarksMan::ConstructCache()
01851 {
01852
01853 if (TemplateCached)
01854 return TRUE;
01855
01856 BOOL ok=FALSE;
01857
01858 TCHAR SearchFile[] = _T("mrktmpl.xar");
01859
01860 if (1 )
01861 {
01862 LoadPrintMarks LdPrintMark;
01863
01864 StringVar s(CamResource::GetResourceFilePath(SearchFile));
01865 PORTNOTE("other", "Disabled printmark resource file finding")
01866 #ifndef EXCLUDE_FROM_XARALX
01867 ok = FileUtil::FindResourceFile(SearchFile, OutputBuff);
01868 #endif
01869
01870 ok = ok && PMMCache.CreateCropMark();
01871
01872 ok = ok && PMMCache.CreateTextInfoMark();
01873
01874 ok = ok && LdPrintMark.Execute(s);
01875
01876
01877 }
01878
01879 return (TemplateCached=ok);
01880 }
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897 BOOL LoadPrintMarks::OnLoadDocument(Document* pKernelDoc)
01898 {
01899
01900 PrintMarksMan* pPrintMarksMan = GetApplication()->GetMarksManager();
01901 if (pPrintMarksMan==NULL)
01902 return FALSE;
01903
01904
01905 pPrintMarksMan->ConvertAllDocColours(pKernelDoc);
01906
01907
01908
01909 pPrintMarksMan->PMMCache.DecodeCachedLayers(pKernelDoc);
01910
01911
01912 return TRUE;
01913 }
01914
01915
01916
01917
01918
01919
01920
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938 void PrintMarksMan::ConvertAllDocColours(Document* pDoc)
01939 {
01940 ERROR3IF(pDoc==NULL,"No doc pointer during PrintMarksMan::ConvertAllDocColours!");
01941
01942 Node *CurNode = Node::DocFindFirstDepthFirst(pDoc);
01943 Node *NextNode;
01944
01945 while (CurNode !=NULL)
01946 {
01947
01948 NextNode = CurNode->DocFindNextDepthFirst();
01949
01950
01951 UINT32 Context = 0;
01952 DocColour *pColour;
01953
01954 if (CurNode->IsAnAttribute())
01955 {
01956 NodeAttribute *pNodeAttr = (NodeAttribute *) CurNode;
01957
01958
01959 pColour = pNodeAttr->EnumerateColourFields(Context++);
01960
01961 while (pColour != NULL)
01962 {
01963
01964
01965 if (pColour->FindParentIndexedColour() != NULL)
01966 {
01967 ColourGeneric ColDef;
01968 ColourContext *cc = ColourManager::GetColourContext(pColour->GetColourModel());
01969 ERROR3IF(cc == NULL, "Can't find colour context?!");
01970
01971
01972 cc->ConvertColour(pColour->FindParentIndexedColour(), &ColDef);
01973
01974
01975 *pColour = DocColour(pColour->GetColourModel(), &ColDef);
01976 }
01977
01978 pColour = pNodeAttr->EnumerateColourFields(Context++);
01979 }
01980 }
01981 CurNode = NextNode;
01982 }
01983 }
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000 void PrintMarksMan::InvalidateCache()
02001 {
02002
02003 TemplateCached=FALSE;
02004
02005 PMMCache.Invalidate();
02006 }
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024 BOOL PrintMarksMan::AddMarkToDoc(UINT32 MarkHandle, Document* pDocument)
02025 {
02026 ERROR2IF(pDocument==NULL,FALSE,"NULL document pointer passed to AddMarkToDoc!");
02027
02028 if (!PMMCache.FindMark(MarkHandle))
02029 {
02030 ERROR3("Illegal handle given to PrintMarksMan::AddMarkToDoc");
02031 return FALSE;
02032 }
02033
02034
02035 PrintMarksComponent* pComponent =
02036 (PrintMarksComponent*)pDocument->GetDocComponent(CC_RUNTIME_CLASS(PrintMarksComponent));
02037 if (!pComponent)
02038 {
02039 ERROR3("We're stimmied, there's no PrintMarksComponent in this document!");
02040 return FALSE;
02041 }
02042
02043
02044
02045 return pComponent->AddMark(MarkHandle);
02046 }
02047
02048
02049
02050
02051
02052
02053
02054
02055
02056
02057
02058
02059
02060
02061
02062
02063
02064
02065
02066
02067
02068 BOOL PrintMarksMan::RemoveMarkFromDoc(UINT32 MarkHandle, Document* pDocument)
02069 {
02070 ERROR2IF(pDocument==NULL,FALSE,"NULL document pointer passed to AddMarkToDoc!");
02071
02072 PrintMarksComponent* pComponent =
02073 (PrintMarksComponent*)pDocument->GetDocComponent(CC_RUNTIME_CLASS(PrintMarksComponent));
02074 if (!pComponent)
02075 {
02076 ERROR3("We're stimmied, there's no PrintMarksComponent in this document!");
02077 return FALSE;
02078 }
02079
02080
02081
02082 pComponent->RemoveMark(MarkHandle);
02083 return TRUE;
02084 }
02085
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103 BOOL PrintMarksMan::AddDefaultMarksToDoc(Document* pDocument)
02104 {
02105 ERROR3IF(pDocument==NULL,"NULL document pointer passed to AddDefaultMarks()");
02106 BOOL Added=FALSE;
02107 if (pDocument!=NULL)
02108 {
02109
02110 PrintMarksComponent* pMarksComp =
02111 (PrintMarksComponent*)pDocument->GetDocComponent(CC_RUNTIME_CLASS(PrintMarksComponent));
02112 if (pMarksComp && pMarksComp->IsVirgin())
02113 {
02114
02115 PrintMarkItem* pMarkItem = PMMCache.GetFirstMark();
02116 while (pMarkItem)
02117 {
02118
02119 if (pMarkItem->DefaultsToOn())
02120 {
02121
02122 UINT32 handle = pMarkItem->GetHandle();
02123 pMarksComp->AddMark(handle);
02124 }
02125
02126 pMarkItem = PMMCache.GetNextMark(pMarkItem);
02127 }
02128
02129 Added=TRUE;
02130 }
02131 }
02132 return Added;
02133 }
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148
02149
02150
02151
02152
02153
02154
02155
02156
02157
02158
02159
02160
02161 void PrintMarksMan::SetImagesettingRect()
02162 {
02163 ImagesettingRect.MakeEmpty();
02164 PageRect* pRect = PageRects.GetFirstPageRect();
02165 while (pRect)
02166 {
02167 ImagesettingRect = ImagesettingRect.Union(pRect->Rect);
02168 pRect = PageRects.GetNextPageRect(pRect);
02169 }
02170 }
02171
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181
02182
02183
02184
02185
02186
02187
02188
02189 void PrintMarksMan::StartPrinting()
02190 {
02191
02192 PageRects.DeleteAll();
02193 ImagesettingRect.MakeEmpty();
02194 EmulsionDown=FALSE;
02195 Bleed=0;
02196
02197 CCTime MyTime;
02198 PMMCache.CachedTime.Empty();
02199 String_64 TimeFormat(_T("%dy/%mt/%yr %th.%mn %pm"));
02200 MyTime.ConvertStandardDateAndTime(&TimeFormat, &PMMCache.CachedTime);
02201 }
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217
02218 void PrintMarksMan::EndPrinting()
02219 {
02220 PageRects.DeleteAll();
02221 ImagesettingRect.MakeEmpty();
02222 }
02223
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237
02238
02239
02240 void PrintMarksMan::SetBleed(MILLIPOINT bleed)
02241 {
02242 Bleed=bleed;
02243 }
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265 BOOL PrintMarksMan::AddPageRect(const DocRect& rect)
02266 {
02267
02268 return PageRects.AddPageRect(rect);
02269 }
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287 void PrintMarksMan::SetEmulsionDown(BOOL state)
02288 {
02289 EmulsionDown=state;
02290 }
02291
02292
02293
02294
02295
02296
02297
02298
02299
02300
02301
02302
02303
02304
02305 void PrintMarksMan::ResetPageRects()
02306 {
02307 PageRects.DeleteAll();
02308 }
02309
02310
02311
02312
02313
02314
02315
02316
02317
02318
02319
02320
02321
02322
02323
02324 MILLIPOINT PrintMarksMan::AdjustedBleed() const
02325 {
02326 return (Bleed+OUTSIDEBLEEDWIDTH);
02327 }
02328
02329
02330
02331
02332
02333
02334
02335
02336
02337
02338
02339
02340
02341
02342
02343
02344
02345
02346
02347
02348
02349
02350
02351
02352 void PrintMarksMan::RenderPrintMarks(Document *ScopeDoc, BOOL DisplayEm, BOOL UpdateCache)
02353 {
02354 TypesetInfo *pInfo = TypesetInfo::FindTypesetInfoForDoc(ScopeDoc);
02355 if (pInfo != NULL)
02356 pInfo->SetOutputPrintersMarks(DisplayEm);
02357
02358 if (DisplayEm && UpdateCache)
02359 ConstructCache();
02360 }
02361
02362
02363
02364
02365
02366
02367
02368
02369
02370
02371
02372
02373
02374
02375
02376
02377
02378
02379
02380
02381
02382 BOOL PrintMarksMan::ShowPrintMarks(Document *ScopeDoc) const
02383 {
02384 TypesetInfo *pInfo = TypesetInfo::FindTypesetInfoForDoc(ScopeDoc);
02385 if (pInfo != NULL)
02386 return(pInfo->OutputPrintersMarks());
02387
02388 return(FALSE);
02389 }
02390
02391
02392 MILLIPOINT PrintMarksMan::GetCropMarkWidth(Document *ScopeDoc) const
02393 {
02394 if (ShowPrintMarks(ScopeDoc))
02395 return (CROPMARK_LENGTH + OUTSIDEBLEEDWIDTH);
02396 else
02397 return 0;
02398 }
02399
02400
02401
02402
02403
02404
02405
02406
02407
02408
02409
02410
02411
02412
02413
02414
02415
02416
02417
02418
02419
02420 void PrintMarksMan::RenderPrintMarks(PrintMarksComponent *pComp,
02421 RenderRegion* pRRegion,
02422 const Matrix &ViewTrans,
02423 const DocRect &ClipRect,
02424 Spread* pSpread)
02425 {
02426
02427 if (pComp==NULL || pRRegion==NULL || pSpread==NULL)
02428 return;
02429
02430
02431 if ( !ShowPrintMarks( (Document *) (pSpread->FindOwnerDoc()) ) )
02432 return;
02433
02434
02435 if (ImagesettingRect.IsEmpty())
02436 return;
02437
02438
02439 MILLIPOINT adjbleed = AdjustedBleed();
02440
02441
02442 PORTNOTE("printing", "disabled print mark generation use of PrintPSRenderRegion")
02443 #ifndef EXCLUDE_FROM_XARALX
02444 BOOL OldClipState = FALSE;
02445 BOOL IsPostScript = pRRegion->IS_KIND_OF(PrintPSRenderRegion);
02446 PSPrintDC *pPrintDC = NULL;
02447
02448
02449 if (IsPostScript)
02450 {
02451
02452 pPrintDC = (PSPrintDC*)pRRegion->GetRenderDC();
02453 if (pPrintDC==NULL)
02454 return;
02455
02456
02457 OldClipState = pPrintDC->SetClipping(FALSE);
02458 }
02459 #endif
02460
02461
02462 DocPrintMark* pDocMark = pComp->GetFirstMark();
02463 if (pDocMark!=NULL)
02464 {
02465
02466 Document* pDoc = Document::GetSelected();
02467 PMMCache.UpdateTextInfoMark(pDoc, pRRegion);
02468
02469
02470 RenderPrintMarksAroundRect(pComp, pRRegion, NULL, ImagesettingRect, adjbleed);
02471
02472
02473 if (PMMCache.CropMarkHandle>0)
02474 {
02475
02476 if (pComp->FindMark(PMMCache.CropMarkHandle)!=NULL)
02477 RenderCropMarksAroundRect(pRRegion, NULL, ImagesettingRect, adjbleed);
02478 }
02479 }
02480
02481 PORTNOTE("printing", "disabled print mark generation use of PrintPSRenderRegion")
02482 #ifndef EXCLUDE_FROM_XARALX
02483
02484 if (IsPostScript)
02485 {
02486 if (pPrintDC)
02487 {
02488
02489 pPrintDC->SetClipping(TRUE);
02490
02491 pPrintDC->OutputPSClipping();
02492
02493 }
02494 }
02495 #endif
02496 }
02497
02498
02499
02500
02501
02502
02503
02504
02505
02506
02507
02508
02509
02510
02511
02512
02513
02514
02515 void PrintMarksMan::ClipToBleed(RenderRegion* pRRegion,Spread *pSpread)
02516 {
02517
02518 if (pRRegion==NULL)
02519 return;
02520
02521
02522 if (ImagesettingRect.IsEmpty())
02523 return;
02524
02525
02526 if ( !ShowPrintMarks( (Document *) (pSpread->FindOwnerDoc()) ) )
02527 return;
02528
02529 PORTNOTE("printing", "disabled print mark generation use of PrintPSRenderRegion")
02530 #ifndef EXCLUDE_FROM_XARALX
02531
02532 if ( !IS_A(pRRegion, PrintPSRenderRegion) )
02533 return;
02534
02535
02536
02537
02538
02539 MILLIPOINT adjbleed = AdjustedBleed();
02540 DocRect Rect = ImagesettingRect;
02541 Rect.Inflate(adjbleed);
02542 PSPrintDC *pPrintDC = (PSPrintDC*)pRRegion->GetRenderDC();
02543 ((PrintPSRenderRegion*)pRRegion)->WriteClipRegion(pPrintDC, Rect);
02544
02545
02546
02547
02548 #endif
02549 }
02550
02551
02552
02553
02554
02555
02556
02557
02558
02559
02560
02561
02562
02563
02564
02565
02566
02567
02568
02569
02570 void PrintMarksMan::RenderCropMarksAroundRect(RenderRegion* pRRegion,
02571 const Matrix *pTrans,
02572 const DocRect &Rect,
02573 MILLIPOINT bleed)
02574 {
02575
02576 Path CropLine;
02577 if (!CropLine.Initialise())
02578 return;
02579
02580
02581 INT32 ExtraBit = 0;
02582 if (bleed==0)
02583 ExtraBit = 2384;
02584
02585
02586 DocRect TransformedRect(Rect);
02587 TransformedRect.Inflate(bleed+ExtraBit);
02588 if (pTrans)
02589 {
02590 pTrans->transform(&TransformedRect.lo);
02591 pTrans->transform(&TransformedRect.hi);
02592 }
02593
02594 MILLIPOINT Tmp;
02595
02596 if (TransformedRect.lo.x > TransformedRect.hi.x)
02597 {
02598 Tmp = TransformedRect.lo.x;
02599 TransformedRect.lo.x = TransformedRect.hi.x;
02600 TransformedRect.hi.x = Tmp;
02601 }
02602
02603 if (TransformedRect.lo.y > TransformedRect.hi.y)
02604 {
02605 Tmp = TransformedRect.lo.y;
02606 TransformedRect.lo.y = TransformedRect.hi.y;
02607 TransformedRect.hi.y = Tmp;
02608 }
02609
02610
02611
02612 Matrix ViewTrans = pRRegion->GetMatrix();
02613 ViewTrans = ViewTrans.Inverse();
02614
02615
02616 INT32 Length = CROPMARK_LENGTH;
02617 double Thickness = CROPMARK_THICKNESS;
02618
02619
02620
02621
02622 Length -= ExtraBit;
02623 if (Length<1) Length=1;
02624
02625
02626
02627
02628 FIXED16 CurrScale;
02629 ViewTrans.Decompose(&CurrScale);
02630 double scale = CurrScale.MakeDouble();
02631
02632
02633
02634 if (scale<0) scale = -scale;
02635 Thickness = Thickness*scale;
02636 INT32 Thick = (INT32)(Thickness+0.5);
02637 if (Thick<1) Thick=1;
02638
02639
02640 pRRegion->SaveContext();
02641 pRRegion->SetLineColour(COLOUR_BLACK);
02642 pRRegion->SetLineWidth(Thick);
02643
02644
02645 CropLine.AddMoveTo(DocCoord(0,0));
02646 CropLine.AddLineTo(DocCoord(72000,0));
02647
02648 DocCoord *Coords = CropLine.GetCoordArray();
02649
02650
02651 DocCoord iLo = TransformedRect.lo;
02652 DocCoord iHi = TransformedRect.hi;
02653
02654
02655 PageRect *pRect = PageRects.GetFirstPageRect();
02656 DocCoord p0,p1,rLo,rHi;
02657
02658
02659 #define LINEDRAW(p,q) \
02660 ViewTrans.transform(&p); \
02661 ViewTrans.transform(&q); \
02662 Coords[0]=p; \
02663 Coords[1]=q; \
02664 pRRegion->DrawPath(&CropLine);
02665
02666 while (pRect)
02667 {
02668 rLo = pRect->Rect.lo;
02669 rHi = pRect->Rect.hi;
02670
02671 p0.x = iLo.x;
02672 p1.x = iLo.x - Length;
02673 p0.y = p1.y = rLo.y;
02674 LINEDRAW(p0,p1);
02675 p0.x = iLo.x;
02676 p1.x = iLo.x - Length;
02677 p0.y = p1.y = rHi.y;
02678 LINEDRAW(p0,p1);
02679
02680 p0.y = iHi.y;
02681 p1.y = iHi.y + Length;
02682 p0.x = p1.x = rLo.x;
02683 LINEDRAW(p0,p1);
02684 p0.y = iHi.y;
02685 p1.y = iHi.y + Length;
02686 p0.x = p1.x = rHi.x;
02687 LINEDRAW(p0,p1);
02688
02689 p0.x = iHi.x;
02690 p1.x = iHi.x + Length;
02691 p0.y = p1.y = rHi.y;
02692 LINEDRAW(p0,p1);
02693 p0.x = iHi.x;
02694 p1.x = iHi.x + Length;
02695 p0.y = p1.y = rLo.y;
02696 LINEDRAW(p0,p1);
02697
02698 p0.y = iLo.y;
02699 p1.y = iLo.y - Length;
02700 p0.x = p1.x = rHi.x;
02701 LINEDRAW(p0,p1);
02702 p0.y = iLo.y;
02703 p1.y = iLo.y - Length;
02704 p0.x = p1.x = rLo.x;
02705 LINEDRAW(p0,p1);
02706
02707 pRect = PageRects.GetNextPageRect(pRect);
02708 }
02709
02710 #undef LINEDRAW
02711
02712
02713 pRRegion->RestoreContext();
02714 }
02715
02716
02717
02718
02719
02720
02721
02722
02723
02724
02725
02726
02727
02728
02729
02730
02731
02732
02733
02734
02735
02736
02737
02738 void PrintMarksMan::RenderPrintMarksAroundRect(PrintMarksComponent *pComp,
02739 RenderRegion* pRRegion,
02740 const Matrix *pTrans,
02741 const DocRect &Rect,
02742 MILLIPOINT bleed)
02743 {
02744 pRRegion->SaveContext();
02745
02746
02747 DocRect TransformedRect(Rect);
02748 if (pTrans)
02749 {
02750 pTrans->transform(&TransformedRect.lo);
02751 pTrans->transform(&TransformedRect.hi);
02752 }
02753
02754
02755 PageMarkRegions MyPageRegions;
02756 MyPageRegions.Initialise(TransformedRect,bleed);
02757 Matrix OuterTransform;
02758 if (EmulsionDown)
02759 {
02760 DocRect Rect = TransformedRect;
02761 Rect.Inflate(bleed);
02762 INT32 w = Rect.Width();
02763 OuterTransform *= Matrix(-Rect.lo);
02764 OuterTransform *= Matrix(FIXED16(-1), FIXED16(0), FIXED16(0), FIXED16(1), w, 0);
02765 OuterTransform *= Matrix(Rect.lo);
02766 }
02767
02768 for (INT32 i=0; i<MAXPAGEREGIONS; i++)
02769 {
02770 if (MyPageRegions.Region[i].Valid)
02771 {
02772
02773 MFRegion.Empty();
02774 MFRegion.SetPosition(MyPageRegions.Region[i].Pos);
02775 MFRegion.SetOrientation(MyPageRegions.Region[i].OrientX);
02776
02777 CompileMarkRegion(pComp, (MarkRegion)i );
02778 MFRegion.Render(pRRegion,OuterTransform);
02779 }
02780 }
02781
02782 pRRegion->RestoreContext();
02783 }
02784
02785
02786
02787
02788
02789
02790
02791
02792
02793
02794
02795
02796
02797
02798
02799
02800
02801
02802
02803
02804
02805
02806
02807
02808
02809
02810
02811
02812
02813
02814
02815
02816
02817
02818
02819
02820
02821
02822
02823
02824
02825
02826
02827
02828
02829
02830
02831
02832
02833
02834
02835
02836
02837
02838
02839
02840
02841
02842
02843
02844
02845
02846
02847
02848
02849
02850
02851
02852
02853
02854
02855
02856
02857
02858
02859
02860
02861
02862
02863
02864
02865
02866
02867
02868
02869
02870
02871
02872
02873
02874
02875
02876
02877
02878
02879
02880
02881
02882
02883
02884
02885
02886
02887
02888
02889
02890
02891
02892
02893 void PrintMarksMan::CompileMarkRegion(PrintMarksComponent *pComp, MarkRegion CurrRegion)
02894 {
02895 UINT32 handle;
02896
02897 DocPrintMark* pDocMark = pComp->GetFirstMark();
02898 while (pDocMark)
02899 {
02900
02901 handle=pDocMark->GetHandle();
02902
02903
02904 PrintMarkItem* pMarkItem = PMMCache.FindMark(handle);
02905 if (pMarkItem && pMarkItem->NeedsToRender())
02906 {
02907
02908
02909 PrintMark* pPrintMark = pMarkItem->GetPrintMark();
02910 if (pPrintMark)
02911 {
02912 MarkPosition* pMarkPosition = pPrintMark->GetFirstPosition();
02913 while (pMarkPosition!=NULL)
02914 {
02915 if (pMarkPosition->GetRegion()==CurrRegion)
02916 {
02917 MarkFormat LocalFormat = pMarkPosition->GetFormat();
02918 MFRegion.AddMark(pMarkItem, &LocalFormat);
02919 }
02920
02921 pMarkPosition = pPrintMark->GetNextPosition(pMarkPosition);
02922 }
02923 }
02924 }
02925
02926
02927 pDocMark = pComp->GetNextMark(pDocMark);
02928 }
02929 }
02930
02931
02932
02933
02934
02935
02936
02937
02938
02939
02940
02941
02942
02943
02944
02945
02946
02947
02948
02949 PageMarkRegion::PageMarkRegion()
02950 {
02951 OrientX=TRUE;
02952 Valid=FALSE;
02953 }
02954
02955
02956 PageMarkRegions::PageMarkRegions()
02957 {
02958 }
02959
02960
02961 void PageMarkRegions::Initialise(const DocRect& page, INT32 bleed)
02962 {
02963
02964 INT32 blox,bloy,bhix,bhiy;
02965
02966
02967 blox = page.lo.x-bleed;
02968 bloy = page.lo.y-bleed;
02969 bhix = page.hi.x+bleed;
02970 bhiy = page.hi.y+bleed;
02971
02972 INT32 hi = CROPAREA_SIZE;
02973 INT32 spc = CROPAREA_SIZE/4;
02974 INT32 slenx = (page.hi.x-page.lo.x-4*spc)/10;
02975 INT32 sleny = (page.hi.y-page.lo.y-4*spc)/10;
02976 INT32 wlenx = 8*slenx;
02977 INT32 wleny = 8*sleny;
02978 INT32 cx=(page.lo.x+page.hi.x)>>1;
02979 INT32 cy=(page.lo.y+page.hi.y)>>1;
02980
02981
02982 Region[0].Pos = DocRect(blox-hi, bhiy, blox, bhiy+hi);
02983
02984
02985 Region[1].Pos = DocRect(page.lo.x+spc, bhiy, page.lo.x+spc+slenx, bhiy+hi);
02986 Region[2].Pos = DocRect(cx-(wlenx>>1), bhiy, cx+(wlenx>>1), bhiy+hi);
02987 Region[3].Pos = DocRect(page.hi.x-spc-slenx, bhiy, page.hi.x-spc, bhiy+hi);
02988
02989
02990 Region[4].Pos = DocRect(bhix, bhiy, bhix+hi, bhiy+hi);
02991
02992
02993 Region[5].Pos = DocRect(bhix, page.hi.y-spc-sleny, bhix+hi, page.hi.y-spc);
02994 Region[6].Pos = DocRect(bhix, cy-(wleny>>1), bhix+hi, cy+(wleny>>1));
02995 Region[7].Pos = DocRect(bhix, page.lo.y+spc, bhix+hi, page.lo.y+spc+sleny);
02996
02997
02998 Region[8].Pos = DocRect(bhix, bloy-hi, bhix+hi, bloy);
02999
03000
03001 Region[9].Pos = DocRect(page.hi.x-spc-slenx, bloy-hi, page.hi.x-spc, bloy);
03002 Region[10].Pos = DocRect(cx-(wlenx>>1), bloy-hi, cx+(wlenx>>1), bloy);
03003 Region[11].Pos = DocRect(page.lo.x+spc, bloy-hi, page.lo.x+spc+slenx, bloy);
03004
03005
03006 Region[12].Pos = DocRect(blox-hi, bloy-hi, blox, bloy);
03007
03008
03009 Region[13].Pos = DocRect(blox-hi, page.lo.y+spc, blox, page.lo.y+spc+sleny);
03010 Region[14].Pos = DocRect(blox-hi, cy-(wleny>>1), blox, cy+(wleny>>1));
03011 Region[15].Pos = DocRect(blox-hi, page.hi.y-spc-sleny, blox, page.hi.y-spc);
03012
03013 for (INT32 i=0; i<16; i++)
03014 Region[i].Valid=Region[i].OrientX=TRUE;
03015
03016 Region[5].OrientX = FALSE;
03017 Region[6].OrientX = FALSE;
03018 Region[7].OrientX = FALSE;
03019 Region[13].OrientX = FALSE;
03020 Region[14].OrientX = FALSE;
03021 Region[15].OrientX = FALSE;
03022 }
03023
03024
03025
03026 void PageMarkRegions::HideLeft()
03027 {
03028 Region[0].Valid=FALSE;
03029 Region[12].Valid=FALSE;
03030 Region[13].Valid=FALSE;
03031 Region[14].Valid=FALSE;
03032 Region[15].Valid=FALSE;
03033 }
03034
03035 void PageMarkRegions::HideRight()
03036 {
03037 Region[4].Valid=FALSE;
03038 Region[5].Valid=FALSE;
03039 Region[6].Valid=FALSE;
03040 Region[7].Valid=FALSE;
03041 Region[8].Valid=FALSE;
03042 }
03043
03044 void PageMarkRegions::HideTop()
03045 {
03046 Region[0].Valid=FALSE;
03047 Region[1].Valid=FALSE;
03048 Region[2].Valid=FALSE;
03049 Region[3].Valid=FALSE;
03050 Region[4].Valid=FALSE;
03051 }
03052
03053 void PageMarkRegions::HideBottom()
03054 {
03055 Region[9].Valid=FALSE;
03056 Region[10].Valid=FALSE;
03057 Region[11].Valid=FALSE;
03058 Region[12].Valid=FALSE;
03059 Region[13].Valid=FALSE;
03060 }
03061
03062 void PageMarkRegions::ShowLeft()
03063 {
03064 Region[0].Valid=TRUE;
03065 Region[12].Valid=TRUE;
03066 Region[13].Valid=TRUE;
03067 Region[14].Valid=TRUE;
03068 Region[15].Valid=TRUE;
03069 }
03070
03071 void PageMarkRegions::ShowRight()
03072 {
03073 Region[4].Valid=TRUE;
03074 Region[5].Valid=TRUE;
03075 Region[6].Valid=TRUE;
03076 Region[7].Valid=TRUE;
03077 Region[8].Valid=TRUE;
03078 }
03079
03080 void PageMarkRegions::ShowTop()
03081 {
03082 Region[0].Valid=TRUE;
03083 Region[1].Valid=TRUE;
03084 Region[2].Valid=TRUE;
03085 Region[3].Valid=TRUE;
03086 Region[4].Valid=TRUE;
03087 }
03088
03089 void PageMarkRegions::ShowBottom()
03090 {
03091 Region[9].Valid=TRUE;
03092 Region[10].Valid=TRUE;
03093 Region[11].Valid=TRUE;
03094 Region[12].Valid=TRUE;
03095 Region[13].Valid=TRUE;
03096 }
03097
03098
03099
03100
03101
03102
03103
03104
03105
03106
03107
03108 MarkPosType::MarkPosType()
03109 {
03110 pMarkItem=NULL;
03111 rotate=FALSE;
03112 }
03113
03114
03115
03116
03117
03118
03119 MarkList::MarkList()
03120 {
03121 count=size.x=size.y=0;
03122 }
03123
03124
03125
03126
03127
03128
03129
03130 MarkFormatRegion::MarkFormatRegion()
03131 {
03132 Init();
03133 }
03134
03135 MarkFormatRegion::MarkFormatRegion(const DocRect &Position)
03136 {
03137 Init();
03138 SetPosition(Position);
03139 }
03140
03141 MarkFormatRegion::~MarkFormatRegion()
03142 {
03143 Empty();
03144 }
03145
03146 void MarkFormatRegion::Init()
03147 {
03148 OrientX=TRUE;
03149 MkCx = MkCy = 0;
03150 BLeft = BCentre = BRight = NULL;
03151 MLeft = MCentre = MRight = NULL;
03152 TLeft = TCentre = TRight = NULL;
03153 OnRenderFlipX=FALSE;
03154 }
03155
03156 void MarkFormatRegion::Empty()
03157 {
03158 if (BLeft) delete BLeft;
03159 if (BCentre) delete BCentre;
03160 if (BRight) delete BRight;
03161
03162 if (MLeft) delete MLeft;
03163 if (MCentre) delete MCentre;
03164 if (MRight) delete MRight;
03165
03166 if (TLeft) delete TLeft;
03167 if (TCentre) delete TCentre;
03168 if (TRight) delete TRight;
03169
03170 BLeft = BCentre = BRight = NULL;
03171 MLeft = MCentre = MRight = NULL;
03172 TLeft = TCentre = TRight = NULL;
03173 }
03174
03175
03176 void MarkFormatRegion::SetPosition(const DocRect &Position)
03177 {
03178 TheBounds = Position;
03179 MkCx = (TheBounds.lo.x + TheBounds.hi.x)>>1;
03180 MkCy = (TheBounds.lo.y + TheBounds.hi.y)>>1;
03181 }
03182
03183
03184 void MarkFormatRegion::SetOrientation(BOOL orientX)
03185 {
03186 OrientX=orientX;
03187 }
03188
03189 void MarkFormatRegion::SetFlipRender(BOOL flip)
03190 {
03191 OnRenderFlipX=flip;
03192 }
03193
03194
03195
03196
03197
03198
03199
03200
03201
03202
03203
03204
03205
03206 BOOL MarkFormatRegion::AddMark(PrintMarkItem *pMark, MarkFormat *pForm)
03207 {
03208 if (!pMark || !pForm)
03209 return FALSE;
03210
03211 BOOL ok=TRUE;
03212
03213 INT32 w = pMark->GetWidth();
03214 INT32 h = pMark->GetHeight();
03215 BOOL rt;
03216
03217 rt = (( OrientX && pMark->GetOrient()==MO_Vertical) ||
03218 (!OrientX && pMark->GetOrient()==MO_Horizontal) );
03219
03220 if (rt)
03221 {
03222 INT32 Tmp=w; w=h; h=Tmp;
03223 }
03224
03225 if (pForm->Left)
03226 {
03227 if (pForm->Top)
03228 {
03229 DocCoord anchor = DocCoord(TheBounds.lo.x,TheBounds.hi.y);
03230 ok = MakeMark(pMark, anchor, FALSE, FALSE, TRUE, FALSE, 0, h, rt, &TLeft);
03231 }
03232
03233 if (pForm->Middle)
03234 {
03235 DocCoord anchor = DocCoord(TheBounds.lo.x,MkCy);
03236 ok = MakeMark(pMark, anchor, FALSE, TRUE, TRUE, TRUE, 0, h>>1, rt, &MLeft);
03237 }
03238
03239 if (pForm->Bottom)
03240 {
03241 DocCoord anchor = DocCoord(TheBounds.lo.x,TheBounds.lo.y);
03242 ok = MakeMark(pMark, anchor, FALSE, FALSE, TRUE, TRUE, 0, 0, rt, &BLeft);
03243 }
03244 }
03245
03246 if (pForm->Centre)
03247 {
03248 if (pForm->Top)
03249 {
03250 DocCoord anchor = DocCoord(MkCx,TheBounds.hi.y);
03251 ok = MakeMark(pMark, anchor, TRUE, FALSE, TRUE, FALSE, w>>1, h, rt, &TCentre);
03252 }
03253
03254 if (pForm->Middle)
03255 {
03256 DocCoord anchor = DocCoord(MkCx,MkCy);
03257 ok = MakeMark(pMark, anchor, TRUE, TRUE, TRUE, TRUE, w>>1, h>>1, rt, &MCentre);
03258 }
03259
03260 if (pForm->Bottom)
03261 {
03262 DocCoord anchor = DocCoord(MkCx,TheBounds.lo.y);
03263 ok = MakeMark(pMark, anchor, TRUE, FALSE, TRUE, TRUE, w>>1, 0, rt, &BCentre);
03264 }
03265 }
03266
03267 if (pForm->Right)
03268 {
03269 if (pForm->Top)
03270 {
03271 DocCoord anchor = DocCoord(TheBounds.hi.x,TheBounds.hi.y);
03272 ok = MakeMark(pMark, anchor, FALSE, FALSE, FALSE, FALSE, w, h, rt, &TRight);
03273 }
03274
03275 if (pForm->Middle)
03276 {
03277 DocCoord anchor = DocCoord(TheBounds.hi.x,MkCy);
03278 ok = MakeMark(pMark, anchor, FALSE, TRUE, FALSE, TRUE, w, h>>1, rt, &MRight);
03279 }
03280
03281 if (pForm->Bottom)
03282 {
03283 DocCoord anchor = DocCoord(TheBounds.hi.x,TheBounds.lo.y);
03284 ok = MakeMark(pMark, anchor, FALSE, FALSE, FALSE, TRUE, w, 0, rt, &BRight);
03285 }
03286 }
03287
03288 return ok;
03289 }
03290
03291
03292
03293
03294
03295
03296
03297
03298
03299
03300
03301
03302
03303
03304
03305
03306
03307
03308
03309
03310
03311
03312
03313
03314
03315
03316
03317
03318
03319
03320
03321
03322
03323
03324
03325
03326
03327
03328
03329
03330
03331
03332
03333
03334
03335
03336
03337
03338
03339
03340
03341
03342
03343
03344
03345
03346
03347
03348 BOOL MarkFormatRegion::MakeMark(PrintMarkItem *pMark,
03349 DocCoord Anchor,
03350 BOOL cx,
03351 BOOL cy,
03352 BOOL posx,
03353 BOOL posy,
03354 INT32 shiftx,
03355 INT32 shifty,
03356 BOOL rotate,
03357 MarkList **pMarkList)
03358 {
03359 MarkList *pItem = (*pMarkList);
03360
03361 if (pItem==NULL)
03362 {
03363 pItem = new MarkList;
03364 if (pItem==NULL)
03365 return FALSE;
03366
03367 pItem->curpos = Anchor;
03368 }
03369
03370 INT32 width = pMark->GetWidth();
03371 INT32 height = pMark->GetHeight();
03372 if (rotate)
03373 {
03374 INT32 Tmp=width; width=height; height=Tmp;
03375 }
03376
03377 if (pItem->count<MAXREGIONMARKS)
03378 {
03379 pItem->MarkPos[pItem->count].pMarkItem = pMark;
03380 pItem->MarkPos[pItem->count].dim = DocCoord(width,height);
03381 pItem->MarkPos[pItem->count].rotate = rotate;
03382 pItem->count++;
03383
03384 if (OrientX)
03385 {
03386 pItem->MarkPos[pItem->count-1].pos.y = pItem->curpos.y - shifty;
03387 if (cx)
03388 {
03389 pItem->size.x += width;
03390 INT32 x=0;
03391 for (INT32 i=0; i<pItem->count; i++)
03392 {
03393 pItem->MarkPos[i].pos.x = MkCx - ((pItem->size.x)>>1) + x;
03394 x+=pItem->MarkPos[i].dim.x;
03395 }
03396 }
03397 else
03398 {
03399 pItem->MarkPos[pItem->count-1].pos.x = pItem->curpos.x - shiftx;
03400 pItem->curpos.x += ((posx) ? (+width) : (-width));
03401 }
03402 }
03403 else
03404 {
03405 pItem->MarkPos[pItem->count-1].pos.x = pItem->curpos.x - shiftx;
03406 if (cy)
03407 {
03408 pItem->size.y += height;
03409 INT32 y=0;
03410 for (INT32 i=0; i<pItem->count; i++)
03411 {
03412 pItem->MarkPos[i].pos.y = MkCy - ((pItem->size.y)>>1) + y;
03413 y+=pItem->MarkPos[i].dim.y;
03414 }
03415 }
03416 else
03417 {
03418 pItem->MarkPos[pItem->count-1].pos.y = pItem->curpos.y - shifty;
03419 pItem->curpos.y += ((posy) ? (+height) : (-height));
03420 }
03421 }
03422 }
03423
03424 if (*pMarkList==NULL)
03425 *pMarkList=pItem;
03426
03427 return TRUE;
03428 }
03429
03430
03431
03432
03433
03434
03435 void MarkFormatRegion::Render(RenderRegion *pRRegion, const Matrix& Transform)
03436 {
03437 if (BLeft) Render(pRRegion, BLeft, Transform);
03438 if (BCentre) Render(pRRegion, BCentre, Transform);
03439 if (BRight) Render(pRRegion, BRight, Transform);
03440 if (MLeft) Render(pRRegion, MLeft, Transform);
03441 if (MCentre) Render(pRRegion, MCentre, Transform);
03442 if (MRight) Render(pRRegion, MRight, Transform);
03443 if (TLeft) Render(pRRegion, TLeft, Transform);
03444 if (TCentre) Render(pRRegion, TCentre, Transform);
03445 if (TRight) Render(pRRegion, TRight, Transform);
03446 }
03447
03448
03449
03450
03451
03452
03453 void MarkFormatRegion::Render(RenderRegion *pRRegion, MarkList *pMarkLst, const Matrix& OuterTransform)
03454 {
03455 PrintMarkItem* pPMI;
03456 DocRect bounds;
03457 DocCoord pos,pos1;
03458 Trans2DMatrix Trans2DMat;
03459
03460
03461
03462 Matrix ViewTrans = pRRegion->GetMatrix();
03463 ViewTrans = ViewTrans.Inverse();
03464
03465 Matrix Transform;
03466 Matrix ITransform;
03467 Matrix Identity;
03468
03469 for (INT32 i=0; i<pMarkLst->count; i++)
03470 {
03471 pPMI = pMarkLst->MarkPos[i].pMarkItem;
03472 pos = pPMI->GetOrigin();
03473
03474 Transform = Identity;
03475
03476 Transform.SetTranslation(-pos.x, -pos.y);
03477
03478
03479
03480 INT32 w = pPMI->GetWidth();
03481 INT32 h = pPMI->GetHeight();
03482 if (pMarkLst->MarkPos[i].rotate)
03483 {
03484 Transform *= Matrix((ANGLE)270);
03485 Transform *= Matrix(0,w);
03486 }
03487
03488
03489 if (OnRenderFlipX)
03490 {
03491 if (pMarkLst->MarkPos[i].rotate)
03492 Transform *= Matrix(FIXED16(-1), FIXED16(0), FIXED16(0), FIXED16(1), h, 0);
03493 else
03494 Transform *= Matrix(FIXED16(-1), FIXED16(0), FIXED16(0), FIXED16(1), w, 0);
03495 }
03496
03497
03498 Transform = Transform * Matrix(pMarkLst->MarkPos[i].pos);
03499
03500 Transform = Transform * OuterTransform;
03501
03502 Transform = Transform * ViewTrans;
03503
03504 ITransform = Transform.Inverse();
03505
03506
03507 Trans2DMat.SetTransform(Transform);
03508 Trans2DMat.TransLines = TRUE;
03509 pPMI->GetMarkGlyph()->Transform(Trans2DMat);
03510
03511
03512 RenderMark(pRRegion, pPMI);
03513
03514
03515 Trans2DMat.SetTransform(ITransform);
03516 Trans2DMat.TransLines = TRUE;
03517 pPMI->GetMarkGlyph()->Transform(Trans2DMat);
03518 }
03519 }
03520
03521
03522
03523
03524
03525
03526
03527
03528
03529
03530
03531
03532
03533
03534
03535
03536 void MarkFormatRegion::RenderMark(RenderRegion* pRRegion, PrintMarkItem *pMark)
03537 {
03538
03539 Node* pFirstNode = pMark->GetMarkGlyph();
03540 if (pFirstNode!=NULL)
03541 pRRegion->RenderTree(pFirstNode, FALSE, TRUE);
03542 }