Commit 1ec59c299d2e78554bf79cd6e28fbf2ad79777b2
1 parent
909daf95
Refactor write_output
Showing
1 changed file
with
12 additions
and
7 deletions
qpdf/qpdf.cc
| ... | ... | @@ -1871,14 +1871,8 @@ static void set_encryption_options(QPDF& pdf, Options& o, QPDFWriter& w) |
| 1871 | 1871 | } |
| 1872 | 1872 | } |
| 1873 | 1873 | |
| 1874 | -static void write_outfile(QPDF& pdf, Options& o) | |
| 1874 | +static void set_writer_options(QPDF& pdf, Options& o, QPDFWriter& w) | |
| 1875 | 1875 | { |
| 1876 | - QPDF encryption_pdf; | |
| 1877 | - if (strcmp(o.outfilename, "-") == 0) | |
| 1878 | - { | |
| 1879 | - o.outfilename = 0; | |
| 1880 | - } | |
| 1881 | - QPDFWriter w(pdf, o.outfilename); | |
| 1882 | 1876 | if (o.qdf_mode) |
| 1883 | 1877 | { |
| 1884 | 1878 | w.setQDFMode(true); |
| ... | ... | @@ -1925,6 +1919,7 @@ static void write_outfile(QPDF& pdf, Options& o) |
| 1925 | 1919 | } |
| 1926 | 1920 | if (o.copy_encryption) |
| 1927 | 1921 | { |
| 1922 | + QPDF encryption_pdf; | |
| 1928 | 1923 | encryption_pdf.processFile( |
| 1929 | 1924 | o.encryption_file, o.encryption_file_password); |
| 1930 | 1925 | w.copyEncryptionParameters(encryption_pdf); |
| ... | ... | @@ -1955,6 +1950,16 @@ static void write_outfile(QPDF& pdf, Options& o) |
| 1955 | 1950 | parse_version(o.force_version, version, extension_level); |
| 1956 | 1951 | w.forcePDFVersion(version, extension_level); |
| 1957 | 1952 | } |
| 1953 | +} | |
| 1954 | + | |
| 1955 | +static void write_outfile(QPDF& pdf, Options& o) | |
| 1956 | +{ | |
| 1957 | + if (strcmp(o.outfilename, "-") == 0) | |
| 1958 | + { | |
| 1959 | + o.outfilename = 0; | |
| 1960 | + } | |
| 1961 | + QPDFWriter w(pdf, o.outfilename); | |
| 1962 | + set_writer_options(pdf, o, w); | |
| 1958 | 1963 | w.write(); |
| 1959 | 1964 | } |
| 1960 | 1965 | ... | ... |