Commit 901f1a788c6dcb5291539fe4edc271cf53d85a2a

Authored by Jay Berkenbilt
1 parent 05eb5826

Enhance QPDFMatrix API

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 2021-02-20 Jay Berkenbilt <ejb@ql.org> 9 2021-02-20 Jay Berkenbilt <ejb@ql.org>
2 10
3 * Allow --rotate=0 to clear rotation from a page. 11 * Allow --rotate=0 to clear rotation from a page.
include/qpdf/QPDFMatrix.hh
@@ -90,7 +90,6 @@ class QPDFMatrix @@ -90,7 +90,6 @@ class QPDFMatrix
90 QPDFObjectHandle::Rectangle transformRectangle( 90 QPDFObjectHandle::Rectangle transformRectangle(
91 QPDFObjectHandle::Rectangle r); 91 QPDFObjectHandle::Rectangle r);
92 92
93 - private:  
94 double a; 93 double a;
95 double b; 94 double b;
96 double c; 95 double c;
include/qpdf/QPDFObjectHandle.hh
@@ -47,6 +47,7 @@ class QPDF_Array; @@ -47,6 +47,7 @@ class QPDF_Array;
47 class QPDFTokenizer; 47 class QPDFTokenizer;
48 class QPDFExc; 48 class QPDFExc;
49 class Pl_QPDFTokenizer; 49 class Pl_QPDFTokenizer;
  50 +class QPDFMatrix;
50 51
51 class QPDFObjectHandle 52 class QPDFObjectHandle
52 { 53 {
@@ -522,6 +523,8 @@ class QPDFObjectHandle @@ -522,6 +523,8 @@ class QPDFObjectHandle
522 QPDF_DLL 523 QPDF_DLL
523 static QPDFObjectHandle newArray(Matrix const&); 524 static QPDFObjectHandle newArray(Matrix const&);
524 QPDF_DLL 525 QPDF_DLL
  526 + static QPDFObjectHandle newArray(QPDFMatrix const&);
  527 + QPDF_DLL
525 static QPDFObjectHandle newDictionary(); 528 static QPDFObjectHandle newDictionary();
526 QPDF_DLL 529 QPDF_DLL
527 static QPDFObjectHandle newDictionary( 530 static QPDFObjectHandle newDictionary(
@@ -535,6 +538,8 @@ class QPDFObjectHandle @@ -535,6 +538,8 @@ class QPDFObjectHandle
535 // form of newArray. 538 // form of newArray.
536 QPDF_DLL 539 QPDF_DLL
537 static QPDFObjectHandle newFromMatrix(Matrix const&); 540 static QPDFObjectHandle newFromMatrix(Matrix const&);
  541 + QPDF_DLL
  542 + static QPDFObjectHandle newFromMatrix(QPDFMatrix const&);
538 543
539 // Create a new stream and associate it with the given qpdf 544 // Create a new stream and associate it with the given qpdf
540 // object. A subsequent call must be made to replaceStreamData() 545 // object. A subsequent call must be made to replaceStreamData()
libqpdf/QPDFObjectHandle.cc
@@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
19 #include <qpdf/QPDFExc.hh> 19 #include <qpdf/QPDFExc.hh>
20 #include <qpdf/QPDFPageObjectHelper.hh> 20 #include <qpdf/QPDFPageObjectHelper.hh>
21 #include <qpdf/SparseOHArray.hh> 21 #include <qpdf/SparseOHArray.hh>
  22 +#include <qpdf/QPDFMatrix.hh>
22 23
23 #include <qpdf/QTC.hh> 24 #include <qpdf/QTC.hh>
24 #include <qpdf/QUtil.hh> 25 #include <qpdf/QUtil.hh>
@@ -2567,15 +2568,34 @@ QPDFObjectHandle::newArray(Matrix const&amp; matrix) @@ -2567,15 +2568,34 @@ QPDFObjectHandle::newArray(Matrix const&amp; matrix)
2567 } 2568 }
2568 2569
2569 QPDFObjectHandle 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 QPDFObjectHandle::newFromRectangle(Rectangle const& rect) 2584 QPDFObjectHandle::newFromRectangle(Rectangle const& rect)
2571 { 2585 {
2572 return newArray(rect); 2586 return newArray(rect);
2573 } 2587 }
2574 2588
2575 QPDFObjectHandle 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 QPDFObjectHandle 2601 QPDFObjectHandle