summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/pdfmanagement-testphase/colorspace-patches-tmp-ltx.sty
blob: 95a0b0a61204d2c654431e3765ac2f68ed4b733c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
%% This is file `colorspace-patches-tmp-ltx.sty"
% Copyright (C) 2019-2022 The LaTeX Project
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version.  The latest version
% of this license is in the file
%
%    https://www.latex-project.org/lppl.txt
%
% This file is part of the "pdfmanagement bundle" (The Work in LPPL)
% and all files in that bundle must be distributed together.
%
% -----------------------------------------------------------------------
%
% The development version of the bundle can be found at
%
%    https://github.com/latex3/pdfresources
%
% for those people who are interested.
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\ProvidesExplPackage{colorspace-patches-tmp-ltx}{2024-05-23}{0.96i}
  {temporay patches to for the colorspace package to test pdfresource management ... UF}

% colorspace can define more models, that l3color can't yet handle.
\cs_set_protected:Npn \expl@color@set@@nnn #1#2#3
 {
   \cs_if_exist:cT { __color_parse_model_ #2 :w }
    { \color_set:nnn{#1}{#2}{#3} }
 }


\hook_gput_code:nnn {begindocument} {pdf}
  {
    \tl_if_exist:NT \spc@op
      {
        \def\spc@Pageresources#1{}
      }
  }

\hook_gput_code:nnn {begindocument/end} {pdf}
  {
    \tl_if_exist:NT \spc@op
      {
        \pdf_object_new:n  {__spc_extgstate_op_false}
        \pdf_object_write:nnn
          {__spc_extgstate_op_false}{dict}
          {/Type /ExtGState~/op~false~/OP~false}
        \pdfmanagement_add:nnn
          {Page/Resources/ExtGState}
          {SPCko}
          {\pdf_object_ref:n {__spc_extgstate_op_false}}
        \pdf_object_new:n  {__spc_extgstate_op_true0}
        \pdf_object_write:nnn
          {__spc_extgstate_op_true0}{dict}
          {/Type /ExtGState~/op~true~/OP~true~/OPM~0}%
        \pdfmanagement_add:nnn
          {Page/Resources/ExtGState}
          {SPCmz}
          {\pdf_object_ref:n {__spc_extgstate_op_true0}}
        \pdf_object_new:n  {__spc_extgstate_op_true1}
        \pdf_object_write:nnn
          {__spc_extgstate_op_true1}{dict}
          {/Type /ExtGState~/op~true~/OP~true~/OPM~1}%
         \pdfmanagement_add:nnn
          {Page/Resources/ExtGState}
          {SPCop}
          {\pdf_object_ref:n {__spc_extgstate_op_true1}}
      }
  }

\RemoveFromHook{begindocument}[colorspace]

\hook_gput_code:nnn {enddocument} {pdf}
 {
  \def\spc@elt#1#2
   {
    \str_set_eq:Nc\l_tmpa_str {spc@ir@#2}
    \seq_set_split:NnV \l_tmpa_seq {~}\l_tmpa_str
    \seq_get_left:NN\l_tmpa_seq\l_tmpa_str
    %remove spaces
    \exp_args:NNe
    \str_replace_all:Nnn\l_tmpa_str {\c_hash_str20}{~}
    %remove slash
    \str_set:Ne\l_tmpa_str{\str_tail:N\l_tmpa_str}
    \pdfmanagement_add:nee
      {Page/Resources/ColorSpace}{\l_tmpa_str}{\seq_item:Nn\l_tmpa_seq{2}~0~R}
   }
   \spc@csall
 }

\endinput