cdrapp.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #include "cdrapp.h"
  2. // sr.ApplyUniformFill CreateCMYKColor(0, 100, 100, 0)
  3. bool fill_red(corel *cdr)
  4. {
  5. auto sr = cdr->ActiveSelectionRange;
  6. auto red = cdr->CreateCMYKColor(0, 100, 100, 0);
  7. sr->ApplyUniformFill(red);
  8. return true;
  9. }
  10. bool cql_OutlineColor(corel *cdr)
  11. {
  12. auto col = cdr->CreateCMYKColor(0, 100, 100, 0);
  13. auto s = cdr->ActiveShape;
  14. col-> CopyAssign(s->Outline->Color);
  15. col->ConvertToRGB();
  16. auto r = col->RGBRed;
  17. auto g = col->RGBGreen;
  18. auto b = col->RGBBlue;
  19. char buf[256] = { 0 };
  20. sprintf(buf, "@Outline.Color.rgb[.r='%d' And .g='%d' And .b='%d']", r, g, b);
  21. auto cql = _bstr_t(buf);
  22. // MessageBox(NULL, cql, "cql 轮廓颜色", MB_ICONSTOP);
  23. auto sr = cdr->ActivePage->Shapes->FindShapes(_bstr_t(), cdrNoShape, VARIANT_TRUE, cql);
  24. sr->CreateSelection();
  25. strcpy(infobuf , buf);
  26. return true;
  27. }
  28. bool cql_FillColor(corel *cdr)
  29. {
  30. auto col = cdr->CreateCMYKColor(0, 100, 100, 0);
  31. auto s = cdr->ActiveShape;
  32. col-> CopyAssign(s->Fill->UniformColor);
  33. col->ConvertToRGB();
  34. auto r = col->RGBRed;
  35. auto g = col->RGBGreen;
  36. auto b = col->RGBBlue;
  37. char buf[256] = { 0 };
  38. sprintf(buf, "@Fill.Color.rgb[.r='%d' And .g='%d' And .b='%d']", r, g, b);
  39. auto cql = _bstr_t(buf);
  40. auto sr = cdr->ActivePage->Shapes->FindShapes(_bstr_t(), cdrNoShape, VARIANT_TRUE, cql);
  41. sr->CreateSelection();
  42. strcpy(infobuf , buf);
  43. return true;
  44. }
  45. bool cql_SameSize(corel *cdr, double exp)
  46. {
  47. cdr->ActiveDocument->Unit = cdrMillimeter;
  48. auto s = cdr->ActiveShape;
  49. exp += 0.01;
  50. char buf[256] = { 0 };
  51. sprintf(buf, "(@com.SizeWidth - %lf).abs() < %lf and (@com.SizeHeight - %lf).abs() < %lf", s->SizeWidth, exp, s->SizeHeight, exp);
  52. auto cql = _bstr_t(buf);
  53. // MessageBox(NULL, cql, "cql 尺寸相同", MB_ICONSTOP);
  54. auto sr = cdr->ActivePage->Shapes->FindShapes(_bstr_t(), cdrNoShape, VARIANT_TRUE, cql);
  55. sr->CreateSelection();
  56. strcpy(infobuf , buf);
  57. return true;
  58. }
  59. bool Shapes_Filp(corel *cdr)
  60. {
  61. BeginOpt(cdr);
  62. auto sr = cdr->ActiveSelectionRange;
  63. // CorelDRAW Shapes 物件 Item 编号从1开始
  64. for (auto i = 0; i != sr->Count; i++)
  65. sr->Shapes->Item[i + 1]->Flip(VGCore::cdrFlipHorizontal);
  66. EndOpt(cdr);
  67. return true;
  68. }
  69. bool Clear_Fill(corel *cdr)
  70. {
  71. cdr->ActiveSelection->Fill->ApplyNoFill();
  72. return true;
  73. }