[poppler] 3 commits - poppler/ViewerPreferences.cc poppler/ViewerPreferences.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 3 17:41:31 UTC 2019


 poppler/ViewerPreferences.cc |   39 +++++++++++++++++++++++++++++++++++++++
 poppler/ViewerPreferences.h  |    9 +++++++++
 2 files changed, 48 insertions(+)

New commits:
commit 9aa0f0aecf9e37f6bb35bab689956d339268a6ef
Author: Marek Kasik <mkasik at redhat.com>
Date:   Thu Feb 21 18:26:33 2019 +0100

    Read PrintPageRange viewer preference
    
    Lookup for PrintPageRange viewer preference
    in constructor of ViewerPreferences and make
    it available via getPrintPageRange() method.
    
    https://gitlab.freedesktop.org/poppler/poppler/issues/290

diff --git a/poppler/ViewerPreferences.cc b/poppler/ViewerPreferences.cc
index 60eb31ca..0ab4523f 100644
--- a/poppler/ViewerPreferences.cc
+++ b/poppler/ViewerPreferences.cc
@@ -108,6 +108,30 @@ ViewerPreferences::ViewerPreferences(Dict *prefDict)
     if (numCopies < 2)
       numCopies = 1;
   }
+
+  obj = prefDict->lookup("PrintPageRange");
+  if (obj.isArray()) {
+    Array *range = obj.getArray();
+    int length = range->getLength();
+    int pageNumber1, pageNumber2;
+
+    if (length % 2 == 1)
+      length--;
+
+    for (int i = 0; i < length; i += 2) {
+      Object obj2 = range->get(i);
+      Object obj3 = range->get(i + 1);
+
+      if (obj2.isInt() && (pageNumber1 = obj2.getInt()) >= 1 &&
+          obj3.isInt() && (pageNumber2 = obj3.getInt()) >= 1 &&
+          pageNumber1 < pageNumber2) {
+        printPageRange.push_back(std::pair<int, int>(pageNumber1, pageNumber2));
+      } else {
+        printPageRange.clear();
+        break;
+      }
+    }
+  }
 }
 
 ViewerPreferences::~ViewerPreferences()
diff --git a/poppler/ViewerPreferences.h b/poppler/ViewerPreferences.h
index 79d63f93..28e9299a 100644
--- a/poppler/ViewerPreferences.h
+++ b/poppler/ViewerPreferences.h
@@ -12,6 +12,8 @@
 #ifndef VIEWERPREFERENCES_H
 #define VIEWERPREFERENCES_H
 
+#include <vector>
+
 class Dict;
 
 //------------------------------------------------------------------------
@@ -57,6 +59,7 @@ public:
   Duplex getDuplex() const { return duplex; }
   bool getPickTrayByPDFSize() const { return pickTrayByPDFSize; }
   int getNumCopies() const { return numCopies; }
+  std::vector<std::pair<int, int> > getPrintPageRange() const { return printPageRange; }
 
 private:
 
@@ -74,6 +77,7 @@ private:
   Duplex duplex;
   bool pickTrayByPDFSize;
   int numCopies;
+  std::vector<std::pair<int, int> > printPageRange;
 };
 
 #endif
commit b6ffc748e7f3fd4864e95ae383e054949bb73f70
Author: Marek Kasik <mkasik at redhat.com>
Date:   Thu Jan 17 14:45:06 2019 +0100

    Read NumCopies viewer preference
    
    Lookup for NumCopies viewer preference
    in constructor of ViewerPreferences and make
    it available via getNumCopies() method.
    
    https://gitlab.freedesktop.org/poppler/poppler/issues/290

diff --git a/poppler/ViewerPreferences.cc b/poppler/ViewerPreferences.cc
index ee0977f9..60eb31ca 100644
--- a/poppler/ViewerPreferences.cc
+++ b/poppler/ViewerPreferences.cc
@@ -101,6 +101,13 @@ ViewerPreferences::ViewerPreferences(Dict *prefDict)
   if (obj.isBool()) {
     pickTrayByPDFSize = obj.getBool();
   }
+
+  obj = prefDict->lookup("NumCopies");
+  if (obj.isInt()) {
+    numCopies = obj.getInt();
+    if (numCopies < 2)
+      numCopies = 1;
+  }
 }
 
 ViewerPreferences::~ViewerPreferences()
@@ -120,4 +127,5 @@ void ViewerPreferences::init()
   printScaling = printScalingAppDefault;
   duplex = duplexNone;
   pickTrayByPDFSize = false;
+  numCopies = 1;
 }
diff --git a/poppler/ViewerPreferences.h b/poppler/ViewerPreferences.h
index 346222ac..79d63f93 100644
--- a/poppler/ViewerPreferences.h
+++ b/poppler/ViewerPreferences.h
@@ -56,6 +56,7 @@ public:
   PrintScaling getPrintScaling() const { return printScaling; }
   Duplex getDuplex() const { return duplex; }
   bool getPickTrayByPDFSize() const { return pickTrayByPDFSize; }
+  int getNumCopies() const { return numCopies; }
 
 private:
 
@@ -72,6 +73,7 @@ private:
   PrintScaling printScaling;
   Duplex duplex;
   bool pickTrayByPDFSize;
+  int numCopies;
 };
 
 #endif
commit b12aafcddff19bc80fab18a0a243dd17b25614d0
Author: Marek Kasik <mkasik at redhat.com>
Date:   Tue Jan 22 15:50:31 2019 +0100

    Read PickTrayByPDFSize viewer preference
    
    Lookup for PickTrayByPDFSize viewer preference
    in constructor of ViewerPreferences and make
    it available via getPickTrayByPDFSize() method.
    
    https://gitlab.freedesktop.org/poppler/poppler/issues/290

diff --git a/poppler/ViewerPreferences.cc b/poppler/ViewerPreferences.cc
index 35a2f7d1..ee0977f9 100644
--- a/poppler/ViewerPreferences.cc
+++ b/poppler/ViewerPreferences.cc
@@ -6,6 +6,7 @@
 //
 // Copyright 2011 Pino Toscano <pino at kde.org>
 // Copyright 2017 Albert Astals Cid <aacid at kde.org>
+// Copyright 2019 Marek Kasik <mkasik at redhat.com>
 //
 //========================================================================
 
@@ -95,6 +96,11 @@ ViewerPreferences::ViewerPreferences(Dict *prefDict)
       duplex = duplexDuplexFlipLongEdge;
     }
   }
+
+  obj = prefDict->lookup("PickTrayByPDFSize");
+  if (obj.isBool()) {
+    pickTrayByPDFSize = obj.getBool();
+  }
 }
 
 ViewerPreferences::~ViewerPreferences()
@@ -113,4 +119,5 @@ void ViewerPreferences::init()
   direction = directionL2R;
   printScaling = printScalingAppDefault;
   duplex = duplexNone;
+  pickTrayByPDFSize = false;
 }
diff --git a/poppler/ViewerPreferences.h b/poppler/ViewerPreferences.h
index fead9921..346222ac 100644
--- a/poppler/ViewerPreferences.h
+++ b/poppler/ViewerPreferences.h
@@ -5,6 +5,7 @@
 // This file is licensed under the GPLv2 or later
 //
 // Copyright 2011 Pino Toscano <pino at kde.org>
+// Copyright 2019 Marek Kasik <mkasik at redhat.com>
 //
 //========================================================================
 
@@ -54,6 +55,7 @@ public:
   Direction getDirection() const { return direction; }
   PrintScaling getPrintScaling() const { return printScaling; }
   Duplex getDuplex() const { return duplex; }
+  bool getPickTrayByPDFSize() const { return pickTrayByPDFSize; }
 
 private:
 
@@ -69,6 +71,7 @@ private:
   Direction direction;
   PrintScaling printScaling;
   Duplex duplex;
+  bool pickTrayByPDFSize;
 };
 
 #endif


More information about the poppler mailing list