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 #include "camtypes.h"
00101 #include "cmxexdc.h"
00102 #include "cmxrendr.h"
00103 #include "cmxform.h"
00104
00105
00106
00107 #include "colcontx.h"
00108
00109
00110 #include "fillramp.h"
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 BOOL CMXExportDC::WriteBlankAttributes(INT32 Tag)
00127 {
00128
00129 if(Tag != -1)
00130 if(!StartTag(Tag))
00131 return FALSE;
00132
00133
00134 WriteByte(0);
00135
00136
00137 if(Tag != -1)
00138 if(!EndTag())
00139 return FALSE;
00140
00141 return TRUE;
00142 }
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 BOOL CMXExportDC::WriteAttributes(CMXRenderRegion *pReg, INT32 Tag, DocCoord *Coords, INT32 NumCoords, BOOL ForceNoFill)
00159 {
00160
00161 BOOL WasLens = FALSE;
00162 if(!WriteAttrCheckLens(pReg, Tag, Coords, NumCoords, &WasLens))
00163 return FALSE;
00164
00165
00166 if(WasLens)
00167 return TRUE;
00168
00169
00170 if(Tag != -1)
00171 if(!StartTag(Tag))
00172 return FALSE;
00173
00174
00175 WriteByte((ForceNoFill?0:cmxRENDATTRMASK_FILL) | cmxRENDATTRMASK_OUTLINE);
00176
00177
00178 if(!ForceNoFill)
00179 if(!WriteFillSpec(pReg, Coords, NumCoords, ForceNoFill))
00180 return FALSE;
00181
00182
00183 if(!WriteOutlineSpec(pReg))
00184 return FALSE;
00185
00186
00187 if(Tag != -1)
00188 if(!EndTag())
00189 return FALSE;
00190
00191 return TRUE;
00192 }
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207 BOOL CMXExportDC::WriteFillType(WORD FillID)
00208 {
00209 ExportFile->write(&FillID, sizeof(FillID));
00210
00211 return TRUE;
00212 }
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227 BOOL CMXExportDC::WriteFillSpec(CMXRenderRegion *pReg, DocCoord *Coords, INT32 NumCoords, BOOL NoFill)
00228 {
00229
00230 if(!StartNestedTag(cmxTAG_RenderAttr_FillSpec))
00231 return FALSE;
00232
00233 if(NoFill)
00234 {
00235 if(!WriteFillType(cmxFILLID_NONE))
00236 return FALSE;
00237 }
00238 else
00239 {
00240
00241 FillGeometryAttribute *pFillGeometry
00242 = (FillGeometryAttribute *)pReg->GetCurrentAttribute(ATTR_FILLGEOMETRY);
00243
00244
00245 ERROR2IF(pFillGeometry == 0, FALSE, "No fill geometry");
00246 ERROR3IF(!pFillGeometry->IsKindOf(CC_RUNTIME_CLASS(FillGeometryAttribute)), "not one of them there fill geometries");
00247
00248
00249 if(pFillGeometry->IsAFlatFill())
00250 {
00251
00252 DocColour *pCol = pFillGeometry->GetStartColour();
00253 ERROR2IF(pCol == NULL, FALSE, "not one of your earth colours");
00254 if(pCol->IsTransparent())
00255 {
00256
00257 if(!WriteFillType(cmxFILLID_NONE))
00258 return FALSE;
00259 }
00260 else
00261 {
00262
00263 if(!WriteFillType(cmxFILLID_UNIFORM)
00264 || !WriteFillSpecFlat(pReg, pFillGeometry))
00265 return FALSE;
00266 }
00267 }
00268 else if(pFillGeometry->IsAKindOfBitmapFill())
00269 {
00270
00271 if(!WriteFillType(9)
00272 || !WriteFillSpecBitmap(pReg, pFillGeometry, Coords, NumCoords))
00273 return FALSE;
00274 }
00275 else if(pFillGeometry->IsAGradFill())
00276 {
00277
00278 if(!WriteFillType(cmxFILLID_FOUNTAIN)
00279 || !WriteFillSpecGrad(pReg, pFillGeometry, Coords, NumCoords))
00280 return FALSE;
00281 }
00282 else
00283 {
00284
00285 if(!WriteFillType(cmxFILLID_NONE))
00286 return FALSE;
00287 }
00288 }
00289
00290
00291 if(!EndNestedTag())
00292 return FALSE;
00293
00294
00295 if(!WriteMinEndTag())
00296 return FALSE;
00297
00298 return TRUE;
00299 }
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313 BOOL CMXExportDC::WriteFillSpecFlat(CMXRenderRegion *pReg, FillGeometryAttribute *pFill)
00314 {
00315
00316 DocColour *pFillColour = pFill->GetStartColour();
00317 ERROR2IF(pFillColour == NULL, FALSE, "Wibble. No fill colour on this here flat fill");
00318
00319
00320 WORD FillReference = GetColourReference(pFillColour);
00321
00322
00323 struct {
00324 WORD FillReference;
00325 WORD ScreenReference;
00326 } filldef = {FillReference, cmxSCREENREFERENCE};
00327
00328 if(!WriteNestedTag(cmxTAG_RenderAttr_FillSpec_Uniform, &filldef, sizeof(filldef))
00329 || !WriteMinEndTag())
00330 return FALSE;
00331
00332 return TRUE;
00333 }
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351 BOOL CMXExportDC::WriteFillSpecGrad ( CMXRenderRegion *pReg,
00352 FillGeometryAttribute *pFill,
00353 DocCoord *Coords,
00354 INT32 NumCoords )
00355 {
00356 DocColour StartColour;
00357 DocColour EndColour;
00358 DocColour MidColour;
00359 BOOL Radial = FALSE;
00360 BOOL FourColour = FALSE;
00361
00362
00363 if ( pFill->IsARadialFill () )
00364 {
00365
00366
00367 StartColour = *( pFill->GetEndColour () );
00368 EndColour = *( pFill->GetStartColour () );
00369
00370 Radial = TRUE;
00371 }
00372 else if ( pFill->IsAConicalFill () || pFill->IsASquareFill () )
00373 {
00374
00375 StartColour = *( pFill->GetStartColour () );
00376 EndColour = *( pFill->GetEndColour () );
00377
00378 Radial = TRUE;
00379 }
00380 else if ( pFill->IsAFourColFill () )
00381 {
00382
00383
00384 StartColour = *( pFill->GetStartColour () );
00385 EndColour = *( pFill->GetEndColour3 () );
00386 MidColour.Mix ( pFill->GetEndColour (), pFill->GetEndColour2 (), 0.5f, NULL, FALSE, NULL );
00387
00388
00389 FourColour = TRUE;
00390 }
00391 else if ( pFill->IsAThreeColFill () )
00392 {
00393
00394
00395 StartColour = *( pFill->GetStartColour () );
00396 EndColour.Mix ( pFill->GetEndColour (), pFill->GetEndColour2 (), 0.5f, NULL, FALSE, NULL );
00397 }
00398 else
00399 {
00400
00401 StartColour = *( pFill->GetStartColour () );
00402 EndColour = *( pFill->GetEndColour () );
00403 }
00404
00405
00406 WORD StartColReference = GetColourReference ( &StartColour );
00407 WORD EndColReference = GetColourReference ( &EndColour );
00408 WORD MidColReference = 0;
00409 WORD FillMode = cmxFILLMODE_RGB;
00410
00411
00412
00413 if ( FourColour )
00414 {
00415 MidColReference = GetColourReference ( &MidColour );
00416 }
00417
00418
00419 FillEffectAttribute *pFillEff =
00420 (FillEffectAttribute *)pReg->GetCurrentAttribute(ATTR_FILLEFFECT);
00421 ERROR2IF(pFillEff == NULL || !pFillEff->IsKindOf(CC_RUNTIME_CLASS(FillEffectAttribute)), FALSE, "not a fill effect");
00422 BOOL Rainbow = FALSE, Alt = FALSE;
00423 if(IS_A(pFillEff, FillEffectRainbowAttribute))
00424 Rainbow = TRUE;
00425 if(IS_A(pFillEff, FillEffectAltRainbowAttribute))
00426 Rainbow = Alt = TRUE;
00427
00428 if(Rainbow)
00429 {
00430
00431
00432 ColourContext *Conv = ColourContext::GetGlobalDefault(COLOURMODEL_HSVT);
00433
00434 ColourHSVT StartC;
00435 ColourHSVT EndC;
00436
00437 Conv->ConvertColour( &StartColour, (ColourGeneric *)&StartC);
00438 Conv->ConvertColour( &EndColour, (ColourGeneric *)&EndC);
00439
00440
00441 double Difference = (EndC.Hue.MakeDouble()) - (StartC.Hue.MakeDouble());
00442
00443 BOOL ClockWise = (Difference < 0);
00444
00445 if(fabs(Difference) >= 0.5)
00446 ClockWise = !ClockWise;
00447
00448 if(Alt = TRUE)
00449 ClockWise = !ClockWise;
00450
00451
00452 if(ClockWise)
00453 FillMode = cmxFILLMODE_HSB_CW;
00454 else
00455 FillMode = cmxFILLMODE_HSB_CCW;
00456 }
00457
00458
00459 DocCoord StartPoint = *( pFill->GetStartPoint() );
00460 DocCoord EndPoint;
00461
00462
00463 if ( pFill->IsAFourColFill () )
00464 {
00465
00466 EndPoint = *( pFill->GetEndPoint3 () );
00467 }
00468 else if ( pFill->IsAThreeColFill () )
00469 {
00470
00471 EndPoint = *( pFill->GetEndPoint () ) +
00472 *( pFill->GetEndPoint2 () ) -
00473 *( pFill->GetStartPoint () );
00474 }
00475 else
00476 {
00477
00478 EndPoint = *( pFill->GetEndPoint () );
00479 }
00480
00481
00482
00483 DocRect cBBox;
00484 CalcCorelBBox(Coords, NumCoords, &cBBox);
00485
00486
00487 if ( StartPoint == EndPoint || cBBox.Width () == 0 || cBBox.Height () == 0 )
00488 return WriteFillSpecFlat(pReg, pFill);
00489
00490
00491 DocCoord Centre;
00492 Centre.x = cBBox.lo.x + cBBox.Width() / 2;
00493 Centre.y = cBBox.lo.y + cBBox.Height() / 2;
00494
00495
00496
00497
00498 double dx = EndPoint.x - StartPoint.x;
00499 double dy = EndPoint.y - StartPoint.y;
00500 double PointDist = sqrt(((dx * dx) + (dy * dy)));
00501
00502
00503 double Angle = atan2(dy, dx);
00504
00505
00506
00507 INT32 StartPercent;
00508 INT32 EndPercent;
00509
00510 cmxFillBase1 fb1;
00511 fb1.Padding = 0;
00512 cmxFillBase2 fb2;
00513 fb2.XOffset = 0;
00514 fb2.YOffset = 0;
00515
00516 if(Radial)
00517 {
00518
00519
00520
00521
00522 DocCoord dCentre = StartPoint - Centre;
00523 fb2.XOffset = (dCentre.x * 100) / cBBox.Width();
00524 fb2.YOffset = (dCentre.y * 100) / cBBox.Height();
00525
00526 if(fb2.XOffset > 100) fb2.XOffset = 100;
00527 if(fb2.XOffset < -100) fb2.XOffset = -100;
00528 if(fb2.YOffset > 100) fb2.YOffset = 100;
00529 if(fb2.YOffset < -100) fb2.YOffset = -100;
00530
00531
00532
00533 double w = cBBox.Width(), h = cBBox.Height();
00534 double bboxdiagonal = sqrt(w*w + h*h);
00535 double cdx = dCentre.x, cdy = dCentre.y;
00536 double cendist = sqrt(cdx*cdx + cdy*cdy);
00537 double BodgeFactor = 1 + (cendist / (bboxdiagonal / 2));
00538 double targetradius = PointDist / BodgeFactor;
00539 double Pad = 50 * (1 - (2 * targetradius) / bboxdiagonal);
00540
00541 if(Pad < 0) Pad = 0;
00542 if(Pad > 44) Pad = 44;
00543
00544 fb1.Padding = (WORD)Pad;
00545
00546
00547 StartPercent = 0;
00548 EndPercent = 0;
00549
00550
00551 if(pFill->IsASquareFill())
00552 {
00553 WORD t = StartColReference;
00554 StartColReference = EndColReference;
00555 EndColReference = t;
00556 }
00557 }
00558
00559 else
00560 {
00561
00562
00563
00564
00565
00566
00567 double cAngle = Angle;
00568 INT32 cAR = 0;
00569 while(cAngle > (PI/2))
00570 {
00571 cAngle -= PI/2;
00572 cAR++;
00573 }
00574
00575
00576
00577 INT32 qdx = cBBox.Width() / 2;
00578 INT32 qdy = cBBox.Height() / 2;
00579 if((cAR & 1) != 0)
00580 {
00581
00582 INT32 t = qdy;
00583 qdy = qdx;
00584 qdx = t;
00585 }
00586 DocCoord i;
00587 if(qdy == 0)
00588 {
00589
00590 i.x = qdx;
00591 i.y = 0;
00592 }
00593 else
00594 {
00595 double predqdy = qdx * tan(cAngle);
00596 if(predqdy > qdy)
00597 {
00598
00599 i.x = (INT32)(((double)qdy) / tan(cAngle));
00600 i.y = qdy;
00601 }
00602 else
00603 {
00604
00605 i.x = qdx;
00606 i.y = (INT32)(((double)qdx) * tan(cAngle));
00607 }
00608 }
00609
00610
00611
00612
00613
00614
00615
00616 INT32 linelength = (INT32)sqrt(((double)(i.x) * (double)(i.x)) + ((double)(i.y) * (double)(i.y)));
00617
00618 if(linelength == 0)
00619 return WriteFillSpecFlat(pReg, pFill);
00620
00621
00622 DocCoord dStartPoint = StartPoint - Centre;
00623 DocCoord dEndPoint = EndPoint - Centre;
00624
00625
00626
00627 Matrix Mat(((- Angle) * 360.0) / (2*PI));
00628 Mat.transform(&dStartPoint);
00629 Mat.transform(&dEndPoint);
00630
00631
00632 INT32 dStart = dStartPoint.x + linelength;
00633 INT32 dEnd = linelength - dEndPoint.x;
00634 if(dStart < 0) dStart = 0;
00635 if(dEnd < 0) dEnd = 0;
00636 INT32 dPad;
00637 if(dStart < dEnd)
00638 dPad = dStart;
00639 else
00640 dPad = dEnd;
00641
00642 INT32 padval = (dPad * 100) / (linelength * 2);
00643 if(padval < 0) padval = 0;
00644 if(padval > 44) padval = 44;
00645 fb1.Padding = (WORD)padval;
00646
00647
00648 linelength -= dPad;
00649
00650
00651
00652 StartPercent = (INT32)((dStartPoint.x + linelength) * 100);
00653 EndPercent = (INT32)((dEndPoint.x + linelength) * 100);
00654 StartPercent /= (linelength * 2);
00655 EndPercent /= (linelength * 2);
00656
00657
00658 if(StartPercent < 0) StartPercent = 0;
00659 if(StartPercent > 100) StartPercent = 100;
00660 if(EndPercent < 0) EndPercent = 0;
00661 if(EndPercent > 100) EndPercent = 100;
00662 if(EndPercent < StartPercent)
00663 {
00664 INT32 t = StartPercent;
00665 StartPercent = EndPercent;
00666 EndPercent = t;
00667 }
00668 }
00669
00670
00671
00672 if(!StartNestedTag(cmxTAG_RenderAttr_FillSpec_Fountain_Base))
00673 return FALSE;
00674
00675 if(pFill->IsARadialFill())
00676 fb1.Type = cmxFOUNTAINTYPE_RADIAL;
00677 else if(pFill->IsASquareFill())
00678 fb1.Type = cmxFOUNTAINTYPE_SQUARE;
00679 else if(pFill->IsAConicalFill())
00680 fb1.Type = cmxFOUNTAINTYPE_CONICAL;
00681 else
00682 fb1.Type = cmxFOUNTAINTYPE_LINEAR;
00683 fb1.Screen = cmxSCREENREFERENCE;
00684
00685
00686
00687 fb2.StepCount = 0;
00688 fb2.FillMode = FillMode;
00689 fb2.RateMethod = 0;
00690 fb2.RateValue = 50;
00691
00692 if(!Radial)
00693 {
00694 if(FillMode == cmxFILLMODE_RGB)
00695 {
00696
00697
00698
00699 fb2.FillMode = cmxFILLMODE_CUSTOM;
00700 }
00701 else
00702 {
00703
00704
00705
00706 StartPercent = 0;
00707 EndPercent = 0;
00708 }
00709 }
00710
00711
00712 ExportFile->write(&fb1, sizeof(fb1));
00713
00714 WriteAngle(Angle);
00715
00716 if(ThirtyTwoBit)
00717 {
00718 ExportFile->write(&fb2, sizeof(fb2));
00719 }
00720 else
00721 {
00722
00723 cmxFillBase2_16 b = {0, (SWORD)fb2.XOffset, (SWORD)fb2.YOffset,
00724 fb2.StepCount, fb2.FillMode};
00725
00726 ExportFile->write(&b, sizeof(b));
00727 }
00728
00729
00730 if(!EndNestedTag())
00731 return FALSE;
00732
00733
00734 if(!StartNestedTag(cmxTAG_RenderAttr_FillSpec_Fountain_Color))
00735 return FALSE;
00736
00737 cmxGradFillColour col;
00738 ColourRamp *pRamp = pFill->GetColourRamp ();
00739 WORD NCol = 2 + ( ( StartPercent != 0 ) ? 1 : 0 ) +
00740 ( ( EndPercent != 100 ) ? 1 : 0 ) + ( FourColour ? 1 : 0 );
00741
00742
00743 if ( pRamp != NULL )
00744 {
00745 UINT32 FirstIndex = 0;
00746 UINT32 LastIndex = 0;
00747
00748
00749
00750 pRamp->GetIndexRange ( &FirstIndex, &LastIndex );
00751
00752
00753
00754
00755
00756 NCol += 1 + LastIndex - FirstIndex;
00757 }
00758
00759
00760 ExportFile->write ( &NCol, sizeof ( NCol ) );
00761
00762
00763 if(StartPercent != 0)
00764 {
00765 col.ColRef = StartColReference;
00766 col.ColPos = 0;
00767 ExportFile->write(&col, sizeof(col));
00768 }
00769
00770 col.ColRef = StartColReference;
00771 col.ColPos = (WORD)StartPercent;
00772 ExportFile->write(&col, sizeof(col));
00773
00774
00775 if ( FourColour )
00776 {
00777 col.ColRef = MidColReference;
00778 col.ColPos = ( WORD ) ( ( StartPercent + EndPercent ) / 2 );
00779 ExportFile->write ( &col, sizeof ( col ) );
00780 }
00781
00782
00783 if ( pRamp != NULL )
00784 {
00785 ColRampItem *pColour = pRamp->GetFirstCol ();
00786
00787
00788 while ( pColour != NULL )
00789 {
00790 cmxGradFillColour RampColour;
00791
00792
00793 RampColour.ColPos = ( WORD ) ( 100.0f * pColour->GetPosition () );
00794 RampColour.ColRef = GetColourReference ( &( pColour->GetColour () ) );
00795
00796
00797 ExportFile->write ( &RampColour, sizeof ( RampColour ) );
00798
00799
00800 pColour = pRamp->GetNextCol ( pColour );
00801 }
00802 }
00803
00804
00805 col.ColRef = EndColReference;
00806 col.ColPos = (WORD)EndPercent;
00807 ExportFile->write(&col, sizeof(col));
00808
00809 if(EndPercent != 100)
00810 {
00811 col.ColPos = 100;
00812 ExportFile->write(&col, sizeof(col));
00813 }
00814
00815 if(!EndNestedTag())
00816 return FALSE;
00817
00818
00819 if(!WriteMinEndTag())
00820 return FALSE;
00821
00822 return TRUE;
00823 }
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838 BOOL CMXExportDC::WriteFillSpecBitmap(CMXRenderRegion *pReg, FillGeometryAttribute *pFill, DocCoord *Coords, INT32 NumCoords)
00839 {
00840
00841 BitmapFillAttribute *pBFillAttr = (BitmapFillAttribute *)pFill;
00842 ERROR3IF(!pBFillAttr->IsKindOf(CC_RUNTIME_CLASS(BitmapFillAttribute)), "not a bitmap fill attr");
00843
00844
00845 DocColour *pStartColour = 0;
00846 DocColour *pEndColour = 0;
00847 EFFECTTYPE Effect = EFFECT_RGB;
00848
00849
00850 pStartColour = pFill->GetStartColour();
00851 pEndColour = pFill->GetEndColour();
00852 if(pStartColour == 0 || pEndColour == 0
00853 || pStartColour->IsTransparent()
00854 || pEndColour->IsTransparent())
00855 {
00856 pStartColour = 0;
00857 pEndColour = 0;
00858 }
00859
00860 if(pStartColour != 0)
00861 {
00862
00863 Effect = pReg->GetFillEffect();
00864 }
00865
00866
00867 KernelBitmap *pBitmap = pBFillAttr->BitmapRef.GetBitmap();
00868 WORD BitmapRef = GetBitmapReference(pBitmap, pStartColour, pEndColour, Effect);
00869
00870
00871 CMXReferBitmapFill *pBFill = new CMXReferBitmapFill(this);
00872 if(pBFill == 0)
00873 return FALSE;
00874 pBFill->Set(BitmapRef);
00875
00876
00877 ReferList.AddTail(pBFill);
00878
00879
00880 WORD BitmapFillProcReference = GetProcedureReference(pBFill);
00881
00882
00883 if(!StartNestedTag(cmxTAG_RenderAttr_FillSpec_ColorBM))
00884 return FALSE;
00885
00886 ExportFile->write(&BitmapFillProcReference, sizeof(BitmapFillProcReference));
00887
00888
00889 if(!StartNestedTag(cmxTAG_Tiling))
00890 return FALSE;
00891
00892
00893 DocCoord *Start = pFill->GetStartPoint();
00894 DocCoord *End1 = pFill->GetEndPoint();
00895 DocCoord *End2 = pFill->GetEndPoint2();
00896
00897
00898 cmxTilingEnd tile;
00899
00900
00901
00902
00903
00904 DocRect cBBox;
00905 double TileWidth = Start->Distance ( *End1 );
00906 double TileHeight = Start->Distance ( *End2 );
00907
00908
00909 CalcCorelBBox(Coords, NumCoords, &cBBox);
00910
00911
00912
00913 if ( ThirtyTwoBit )
00914 {
00915 cmxTilingBegin32 Tile32;
00916 Tile32.Width = static_cast<DWORD> ( Round ( TileWidth * ScaleFactor ) );
00917 Tile32.Height = static_cast<DWORD> ( Round ( TileHeight * ScaleFactor ) );
00918
00919 WriteData ( &Tile32, sizeof ( Tile32 ) );
00920 }
00921 else
00922 {
00923 cmxTilingBegin16 Tile16;
00924 Tile16.Width = static_cast<WORD> ( Round ( TileWidth * ScaleFactor ) );
00925 Tile16.Height = static_cast<WORD> ( Round ( TileHeight * ScaleFactor ) );
00926
00927 WriteData ( &Tile16, sizeof ( Tile16 ) );
00928 }
00929
00930
00931 double dX = static_cast<double> ( Start->x - cBBox.lo.x );
00932 double dY = static_cast<double> ( cBBox.hi.y - Start->y );
00933
00934
00935 tile.XOffset = ( static_cast<WORD> ( Round ( ( dX * 100.0 ) / TileWidth ) ) ) % 100;
00936 tile.YOffset = ( static_cast<WORD> ( Round ( ( dY * 100.0 ) / TileHeight ) ) ) % 100;
00937
00938 tile.InterTileOffset = tile.TilingFlags = 0;
00939
00940
00941 ExportFile->write(&tile, sizeof(tile));
00942 if(!EndNestedTag() || !WriteMinEndTag())
00943 return FALSE;
00944
00945
00946 DocRect bbox = DocRect(0, 0, cmxBITMAPFILLTILESIZE_X, cmxBITMAPFILLTILESIZE_Y);
00947
00948 if(!WriteBBox(&bbox, FALSE))
00949 return FALSE;
00950
00951 if(!EndNestedTag() || !WriteMinEndTag())
00952 return FALSE;
00953
00954 return TRUE;
00955 }
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973 BOOL CMXExportDC::WritePath ( DocCoord *Coords,
00974 PathVerb *Verbs,
00975 INT32 NumCoords,
00976 BOOL Filled )
00977 {
00978
00979
00980
00981
00982 BOOL ForceNoFill = TRUE;
00983 for(INT32 p = 0; p < NumCoords; p++)
00984 {
00985 if((Verbs[p] & PT_CLOSEFIGURE) != 0)
00986 ForceNoFill = FALSE;
00987 }
00988 if(!Filled)
00989 ForceNoFill = TRUE;
00990
00991
00992 if(!StartCommand(cmxINSTR_PolyCurve))
00993 return FALSE;
00994
00995
00996 if(!WriteAttributes(pRenderRegion, cmxTAG_PolyCurve_RenderingAttr, Coords, NumCoords, ForceNoFill))
00997 return FALSE;
00998
00999
01000 if(!StartTag(cmxTAG_PolyCurve_PointList))
01001 return FALSE;
01002
01003
01004
01005 DocRect bb;
01006 DocCoord fc = Coords[0];
01007 pMatrix->transform(&fc);
01008 bb.lo = fc;
01009 bb.hi = fc;
01010
01011
01012 WORD Count = (WORD)NumCoords;
01013 ExportFile->write(&Count, sizeof(Count));
01014
01015
01016 INT32 l;
01017 TRACEUSER( "Ben", _T("\nPath\n"));
01018 for(l = 0; l < NumCoords; l++)
01019 {
01020 DocCoord Coord = Coords[l];
01021 pMatrix->transform(&Coord);
01022
01023
01024 if(ThirtyTwoBit)
01025 {
01026 cmxPoint32 p = {Coord.x, Coord.y};
01027 ExportFile->write(&p, sizeof(p));
01028 }
01029 else
01030 {
01031 TRACEUSER( "Ben", _T("Coord %d %d\n"), Coord.x, Coord.y);
01032 cmxPoint16 p = {(SWORD)Coord.x, (SWORD)Coord.y};
01033 ExportFile->write(&p, sizeof(p));
01034 }
01035
01036
01037 if(Coord.x < bb.lo.x) bb.lo.x = Coord.x;
01038 if(Coord.y < bb.lo.y) bb.lo.y = Coord.y;
01039 if(Coord.x > bb.hi.x) bb.hi.x = Coord.x;
01040 if(Coord.y > bb.hi.y) bb.hi.y = Coord.y;
01041 }
01042
01043
01044 INT32 BezCount = 0;
01045 for(l = 0; l < NumCoords; l++)
01046 {
01047 BYTE Type;
01048
01049 switch(Verbs[l] & (PT_LINETO | PT_MOVETO | PT_BEZIERTO))
01050 {
01051 case PT_MOVETO:
01052 {
01053 Type = CMXNODETYPE_TYPE_MOVE | CMXNODETYPE_USER;
01054
01055
01056 for(INT32 lp = l + 1; lp < NumCoords; lp++)
01057 {
01058
01059 if((Verbs[lp] & (PT_LINETO | PT_MOVETO | PT_BEZIERTO)) == PT_MOVETO)
01060 break;
01061
01062
01063 if((Verbs[lp] & PT_CLOSEFIGURE) != 0)
01064 {
01065 Type |= CMXNODETYPE_CLOSED;
01066 break;
01067 }
01068 }
01069 }
01070 BezCount = 0;
01071 break;
01072
01073 case PT_LINETO:
01074 Type = CMXNODETYPE_TYPE_LINE | CMXNODETYPE_USER;
01075 BezCount = 0;
01076 break;
01077
01078 case PT_BEZIERTO:
01079
01080
01081 if(BezCount == 2)
01082 {
01083 Type = CMXNODETYPE_TYPE_CURVE | CMXNODETYPE_USER;
01084 }
01085 else
01086 {
01087 Type = CMXNODETYPE_TYPE_ARC;
01088 }
01089 BezCount++;
01090 if(BezCount > 2)
01091 BezCount = 0;
01092 break;
01093
01094 default:
01095 ERROR3("Unknown node type");
01096 break;
01097 }
01098
01099 if((Verbs[l] & PT_CLOSEFIGURE) != 0)
01100 {
01101 Type |= CMXNODETYPE_CLOSED;
01102 }
01103
01104 ExportFile->write(&Type, sizeof(Type));
01105 }
01106
01107
01108 if(!EndTag())
01109 return FALSE;
01110
01111
01112 if(!StartTag(cmxTAG_PolyCurve_BoundingBox)
01113 || !WriteBBox(&bb, FALSE)
01114 || !EndTag())
01115 return FALSE;
01116
01117
01118 if(!WriteMinEndTag()
01119 || !EndCommand())
01120 return FALSE;
01121
01122
01123
01124 return TRUE;
01125 }
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140 WORD CMXExportDC::GetColourReference(DocColour *pTheLovelyColour)
01141 {
01142
01143
01144
01145
01146
01147
01148 INT32 Ref = 0;
01149
01150
01151 CMXReferListItem *pEn = (CMXReferListItem *)ReferList.GetHead();
01152 while(pEn != 0)
01153 {
01154 ERROR3IF(!pEn->IsKindOf(CC_RUNTIME_CLASS(CMXReferListItem)), "unexpected type of entry in refer list");
01155
01156 if(pEn->IsInWhichDesc() == cmxDESC_COLOUR)
01157 {
01158 Ref++;
01159
01160 CMXReferColour *pLC = (CMXReferColour *)pEn;
01161 ERROR3IF(!pLC->IsKindOf(CC_RUNTIME_CLASS(CMXReferColour)), "not a refer colour, when it said it was");
01162
01163
01164 if(pLC->AreYouThisColour(pTheLovelyColour))
01165 {
01166
01167 return Ref;
01168 }
01169 }
01170
01171 pEn = (CMXReferListItem *)ReferList.GetNext(pEn);
01172 }
01173
01174
01175 CMXReferColour *pNewRefCol = new CMXReferColour(this);
01176 if(pNewRefCol == 0)
01177 return 0;
01178
01179 pNewRefCol->SetColour(pTheLovelyColour);
01180
01181 ReferList.AddTail(pNewRefCol);
01182
01183
01184 return (WORD)Ref + 1;
01185 }
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201 WORD CMXExportDC::GetArrowReference(ArrowRec *pArrow)
01202 {
01203
01204 if(pArrow->IsNullArrow())
01205 return 0;
01206
01207
01208 INT32 Ref = 0;
01209
01210
01211 CMXReferListItem *pEn = (CMXReferListItem *)ReferList.GetHead();
01212 while(pEn != 0)
01213 {
01214 ERROR3IF(!pEn->IsKindOf(CC_RUNTIME_CLASS(CMXReferListItem)), "unexpected type of entry in refer list");
01215
01216 if(pEn->IsInWhichDesc() == cmxDESC_ARROW)
01217 {
01218 Ref++;
01219
01220 CMXReferArrow *pAr = (CMXReferArrow *)pEn;
01221 ERROR3IF(!pAr->IsKindOf(CC_RUNTIME_CLASS(CMXReferArrow)), "not an arrow, when it said it was");
01222
01223
01224 if(pAr->AreYouThisArrow(pArrow))
01225 {
01226
01227 return Ref;
01228 }
01229 }
01230
01231 pEn = (CMXReferListItem *)ReferList.GetNext(pEn);
01232 }
01233
01234
01235 CMXReferArrow *pNewArrow = new CMXReferArrow(this);
01236 if(pNewArrow == 0)
01237 return 0;
01238
01239 pNewArrow->Set(pArrow);
01240
01241 ReferList.AddTail(pNewArrow);
01242
01243
01244 return (WORD)Ref + 1;
01245 }
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261 WORD CMXExportDC::GetBitmapReference(KernelBitmap *pTheLovelyBitmap, DocColour *pStartCol,
01262 DocColour *pEndCol, EFFECTTYPE Effect, CMXReferBitmap **ppRB)
01263 {
01264