Commit 901f1a788c6dcb5291539fe4edc271cf53d85a2a
1 parent
05eb5826
Enhance QPDFMatrix API
Showing
4 changed files
with
35 additions
and
3 deletions
ChangeLog
| 1 | +2021-02-21 Jay Berkenbilt <ejb@ql.org> | |
| 2 | + | |
| 3 | + * Allow QPDFObjectHandle::newArray and | |
| 4 | + QPDFObjectHandle::newFromMatrix take QPDFMatrix as well as | |
| 5 | + QPDFObjectHandle::Matrix | |
| 6 | + | |
| 7 | + * Make member variables a--f of QPDFMatrix public | |
| 8 | + | |
| 1 | 9 | 2021-02-20 Jay Berkenbilt <ejb@ql.org> |
| 2 | 10 | |
| 3 | 11 | * Allow --rotate=0 to clear rotation from a page. | ... | ... |
include/qpdf/QPDFMatrix.hh
include/qpdf/QPDFObjectHandle.hh
| ... | ... | @@ -47,6 +47,7 @@ class QPDF_Array; |
| 47 | 47 | class QPDFTokenizer; |
| 48 | 48 | class QPDFExc; |
| 49 | 49 | class Pl_QPDFTokenizer; |
| 50 | +class QPDFMatrix; | |
| 50 | 51 | |
| 51 | 52 | class QPDFObjectHandle |
| 52 | 53 | { |
| ... | ... | @@ -522,6 +523,8 @@ class QPDFObjectHandle |
| 522 | 523 | QPDF_DLL |
| 523 | 524 | static QPDFObjectHandle newArray(Matrix const&); |
| 524 | 525 | QPDF_DLL |
| 526 | + static QPDFObjectHandle newArray(QPDFMatrix const&); | |
| 527 | + QPDF_DLL | |
| 525 | 528 | static QPDFObjectHandle newDictionary(); |
| 526 | 529 | QPDF_DLL |
| 527 | 530 | static QPDFObjectHandle newDictionary( |
| ... | ... | @@ -535,6 +538,8 @@ class QPDFObjectHandle |
| 535 | 538 | // form of newArray. |
| 536 | 539 | QPDF_DLL |
| 537 | 540 | static QPDFObjectHandle newFromMatrix(Matrix const&); |
| 541 | + QPDF_DLL | |
| 542 | + static QPDFObjectHandle newFromMatrix(QPDFMatrix const&); | |
| 538 | 543 | |
| 539 | 544 | // Create a new stream and associate it with the given qpdf |
| 540 | 545 | // object. A subsequent call must be made to replaceStreamData() | ... | ... |
libqpdf/QPDFObjectHandle.cc
| ... | ... | @@ -19,6 +19,7 @@ |
| 19 | 19 | #include <qpdf/QPDFExc.hh> |
| 20 | 20 | #include <qpdf/QPDFPageObjectHelper.hh> |
| 21 | 21 | #include <qpdf/SparseOHArray.hh> |
| 22 | +#include <qpdf/QPDFMatrix.hh> | |
| 22 | 23 | |
| 23 | 24 | #include <qpdf/QTC.hh> |
| 24 | 25 | #include <qpdf/QUtil.hh> |
| ... | ... | @@ -2567,15 +2568,34 @@ QPDFObjectHandle::newArray(Matrix const& matrix) |
| 2567 | 2568 | } |
| 2568 | 2569 | |
| 2569 | 2570 | QPDFObjectHandle |
| 2571 | +QPDFObjectHandle::newArray(QPDFMatrix const& matrix) | |
| 2572 | +{ | |
| 2573 | + std::vector<QPDFObjectHandle> items; | |
| 2574 | + items.push_back(newReal(matrix.a)); | |
| 2575 | + items.push_back(newReal(matrix.b)); | |
| 2576 | + items.push_back(newReal(matrix.c)); | |
| 2577 | + items.push_back(newReal(matrix.d)); | |
| 2578 | + items.push_back(newReal(matrix.e)); | |
| 2579 | + items.push_back(newReal(matrix.f)); | |
| 2580 | + return newArray(items); | |
| 2581 | +} | |
| 2582 | + | |
| 2583 | +QPDFObjectHandle | |
| 2570 | 2584 | QPDFObjectHandle::newFromRectangle(Rectangle const& rect) |
| 2571 | 2585 | { |
| 2572 | 2586 | return newArray(rect); |
| 2573 | 2587 | } |
| 2574 | 2588 | |
| 2575 | 2589 | QPDFObjectHandle |
| 2576 | -QPDFObjectHandle::newFromMatrix(Matrix const& rect) | |
| 2590 | +QPDFObjectHandle::newFromMatrix(Matrix const& m) | |
| 2577 | 2591 | { |
| 2578 | - return newArray(rect); | |
| 2592 | + return newArray(m); | |
| 2593 | +} | |
| 2594 | + | |
| 2595 | +QPDFObjectHandle | |
| 2596 | +QPDFObjectHandle::newFromMatrix(QPDFMatrix const& m) | |
| 2597 | +{ | |
| 2598 | + return newArray(m); | |
| 2579 | 2599 | } |
| 2580 | 2600 | |
| 2581 | 2601 | QPDFObjectHandle | ... | ... |