| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#ifndef _COLORCHANGER_H_ |
| 22 |
#define _COLORCHANGER_H_ |
| 23 |
|
| 24 |
#include <string> |
| 25 |
#include <vector> |
| 26 |
#include <podofo/podofo.h> |
| 27 |
|
| 28 |
class IConverter; |
| 29 |
class GraphicsStack; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
class ColorChanger |
| 36 |
{ |
| 37 |
public: |
| 38 |
enum EKeywordType |
| 39 |
{ |
| 40 |
eKeyword_GraphicsStack_Push, |
| 41 |
eKeyword_GraphicsStack_Pop, |
| 42 |
|
| 43 |
eKeyword_SelectGray_Stroking, |
| 44 |
eKeyword_SelectRGB_Stroking, |
| 45 |
eKeyword_SelectCMYK_Stroking, |
| 46 |
|
| 47 |
eKeyword_SelectGray_NonStroking, |
| 48 |
eKeyword_SelectRGB_NonStroking, |
| 49 |
eKeyword_SelectCMYK_NonStroking, |
| 50 |
|
| 51 |
eKeyword_SelectColorSpace_Stroking, |
| 52 |
eKeyword_SelectColorSpace_NonStroking, |
| 53 |
|
| 54 |
eKeyword_SelectColor_Stroking, |
| 55 |
eKeyword_SelectColor_NonStroking, |
| 56 |
|
| 57 |
eKeyword_SelectColor_Stroking2, |
| 58 |
eKeyword_SelectColor_NonStroking2, |
| 59 |
|
| 60 |
eKeyword_Undefined = 0xffff |
| 61 |
}; |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
struct KWInfo |
| 68 |
{ |
| 69 |
ColorChanger::EKeywordType eKeywordType; |
| 70 |
|
| 71 |
const char pszText[6]; |
| 72 |
|
| 73 |
int nNumArguments; |
| 74 |
|
| 75 |
const char* pszDescription; |
| 76 |
}; |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
ColorChanger(IConverter* convert, const std::string_view& input, const std::string_view& output); |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
void start(); |
| 90 |
|
| 91 |
private: |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
void ReplaceColorsInPage(PoDoFo::PdfCanvas& page); |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
const KWInfo* FindKeyWordByName(const std::string_view& keyword); |
| 104 |
|
| 105 |
PoDoFo::PdfColor GetColorFromStack(int argCount, std::vector<PoDoFo::PdfVariant>& args); |
| 106 |
void PutColorOnStack(const PoDoFo::PdfColor& color, std::vector<PoDoFo::PdfVariant> |
| 107 |
& args); |
| 108 |
|
| 109 |
const char* ProcessColor(EKeywordType keywordType, int numArgs, std::vector<PoDoFo::PdfVariant>& args, GraphicsStack& graphicsStack); |
| 110 |
|
| 111 |
const char* GetKeywordForColor(const PoDoFo::PdfColor& color, bool isStroking); |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
void WriteArgumentsAndKeyword(std::vector<PoDoFo::PdfVariant>& args, const std::string_view& keyword, PoDoFo::OutputStreamDevice& stream); |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
PoDoFo::PdfColorSpace GetColorSpaceForName(const PoDoFo::PdfName& name, PoDoFo::PdfCanvas& page); |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
PoDoFo::PdfColorSpace GetColorSpaceForArray(const PoDoFo::PdfArray& arr, PoDoFo::PdfCanvas& page); |
| 131 |
private: |
| 132 |
IConverter* m_converter; |
| 133 |
std::string m_input; |
| 134 |
std::string m_output; |
| 135 |
}; |
| 136 |
|
| 137 |
#endif |