[poppler] 3 commits - CMakeLists.txt poppler/Catalog.cc poppler/Catalog.h poppler/Makefile.am poppler/ViewerPreferences.cc poppler/ViewerPreferences.h

Pino Toscano pino at kemper.freedesktop.org
Mon Mar 28 14:21:07 PDT 2011


 CMakeLists.txt               |    2 
 poppler/Catalog.cc           |   23 ++++++++++
 poppler/Catalog.h            |    4 +
 poppler/Makefile.am          |    2 
 poppler/ViewerPreferences.cc |   97 +++++++++++++++++++++++++++++++++++++++++++
 poppler/ViewerPreferences.h  |   62 +++++++++++++++++++++++++++
 6 files changed, 190 insertions(+)

New commits:
commit cf84a05ae524aa9b266463cc23cccc3860ff1ba3
Author: Pino Toscano <pino at kde.org>
Date:   Mon Mar 28 23:18:02 2011 +0200

    viewer preferences: read NonFullScreenPageMode and Direction

diff --git a/poppler/ViewerPreferences.cc b/poppler/ViewerPreferences.cc
index 1a183f6..1c38582 100644
--- a/poppler/ViewerPreferences.cc
+++ b/poppler/ViewerPreferences.cc
@@ -54,6 +54,30 @@ ViewerPreferences::ViewerPreferences(Dict *prefDict)
     centerWindow = obj.getBool();
   }
   obj.free();
+
+  if (prefDict->lookup("NonFullScreenPageMode", &obj)->isName()) {
+    const char *mode = obj.getName();
+    if (!strcmp(mode, "UseNone")) {
+      nonFullScreenPageMode = nfpmUseNone;
+    } else if (!strcmp(mode, "UseOutlines")) {
+      nonFullScreenPageMode = nfpmUseOutlines;
+    } else if (!strcmp(mode, "UseThumbs")) {
+      nonFullScreenPageMode = nfpmUseThumbs;
+    } else if (!strcmp(mode, "UseOC")) {
+      nonFullScreenPageMode = nfpmUseOC;
+    }
+  }
+  obj.free();
+
+  if (prefDict->lookup("Direction", &obj)->isName()) {
+    const char *dir = obj.getName();
+    if (!strcmp(dir, "L2R")) {
+      direction = directionL2R;
+    } else if (!strcmp(dir, "R2L")) {
+      direction = directionR2L;
+    }
+  }
+  obj.free();
 }
 
 ViewerPreferences::~ViewerPreferences()
@@ -68,4 +92,6 @@ void ViewerPreferences::init()
   fitWindow = gFalse;
   centerWindow = gFalse;
   displayDocTitle = gFalse;
+  nonFullScreenPageMode = nfpmUseNone;
+  direction = directionL2R;
 }
diff --git a/poppler/ViewerPreferences.h b/poppler/ViewerPreferences.h
index 9753086..147e999 100644
--- a/poppler/ViewerPreferences.h
+++ b/poppler/ViewerPreferences.h
@@ -22,6 +22,17 @@ class Dict;
 class ViewerPreferences {
 public:
 
+  enum NonFullScreenPageMode {
+    nfpmUseNone,
+    nfpmUseOutlines,
+    nfpmUseThumbs,
+    nfpmUseOC
+  };
+  enum Direction {
+    directionL2R,
+    directionR2L
+  };
+
   ViewerPreferences(Dict *prefDict);
   ~ViewerPreferences();
 
@@ -31,6 +42,8 @@ public:
   GBool getFitWindow() const { return fitWindow; }
   GBool getCenterWindow() const { return centerWindow; }
   GBool getDisplayDocTitle() const { return displayDocTitle; }
+  NonFullScreenPageMode getNonFullScreenPageMode() const { return nonFullScreenPageMode; }
+  Direction getDirection() const { return direction; }
 
 private:
 
@@ -42,6 +55,8 @@ private:
   GBool fitWindow;
   GBool centerWindow;
   GBool displayDocTitle;
+  NonFullScreenPageMode nonFullScreenPageMode;
+  Direction direction;
 };
 
 #endif
commit 460253a6705a227ff7c36e9c31cceb93cce4d78b
Author: Pino Toscano <pino at kde.org>
Date:   Mon Mar 28 22:37:54 2011 +0200

    read some boolean viewer preferences
    
    - HideToolbar
    - HideMenubar
    - HideWindowUI
    - FitWindow
    - CenterWindow
    - DisplayDocTitle

diff --git a/poppler/ViewerPreferences.cc b/poppler/ViewerPreferences.cc
index c9ff935..1a183f6 100644
--- a/poppler/ViewerPreferences.cc
+++ b/poppler/ViewerPreferences.cc
@@ -19,6 +19,41 @@ ViewerPreferences::ViewerPreferences(Dict *prefDict)
 {
   init();
 
+  if (!prefDict) {
+    return;
+  }
+
+  Object obj;
+
+  if (prefDict->lookup("HideToolbar", &obj)->isBool()) {
+    hideToolbar = obj.getBool();
+  }
+  obj.free();
+
+  if (prefDict->lookup("HideMenubar", &obj)->isBool()) {
+    hideMenubar = obj.getBool();
+  }
+  obj.free();
+
+  if (prefDict->lookup("HideWindowUI", &obj)->isBool()) {
+    hideWindowUI = obj.getBool();
+  }
+  obj.free();
+
+  if (prefDict->lookup("FitWindow", &obj)->isBool()) {
+    fitWindow = obj.getBool();
+  }
+  obj.free();
+
+  if (prefDict->lookup("CenterWindow", &obj)->isBool()) {
+    centerWindow = obj.getBool();
+  }
+  obj.free();
+
+  if (prefDict->lookup("DisplayDocTitle", &obj)->isBool()) {
+    centerWindow = obj.getBool();
+  }
+  obj.free();
 }
 
 ViewerPreferences::~ViewerPreferences()
@@ -27,4 +62,10 @@ ViewerPreferences::~ViewerPreferences()
 
 void ViewerPreferences::init()
 {
+  hideToolbar = gFalse;
+  hideMenubar = gFalse;
+  hideWindowUI = gFalse;
+  fitWindow = gFalse;
+  centerWindow = gFalse;
+  displayDocTitle = gFalse;
 }
diff --git a/poppler/ViewerPreferences.h b/poppler/ViewerPreferences.h
index 69f0db9..9753086 100644
--- a/poppler/ViewerPreferences.h
+++ b/poppler/ViewerPreferences.h
@@ -25,10 +25,23 @@ public:
   ViewerPreferences(Dict *prefDict);
   ~ViewerPreferences();
 
+  GBool getHideToolbar() const { return hideToolbar; }
+  GBool getHideMenubar() const { return hideMenubar; }
+  GBool getHideWindowUI() const { return hideWindowUI; }
+  GBool getFitWindow() const { return fitWindow; }
+  GBool getCenterWindow() const { return centerWindow; }
+  GBool getDisplayDocTitle() const { return displayDocTitle; }
+
 private:
 
   void init();
 
+  GBool hideToolbar;
+  GBool hideMenubar;
+  GBool hideWindowUI;
+  GBool fitWindow;
+  GBool centerWindow;
+  GBool displayDocTitle;
 };
 
 #endif
commit 9fa9ac3546674120532bb512b82af6471cbebf01
Author: Pino Toscano <pino at kde.org>
Date:   Mon Mar 28 19:58:16 2011 +0200

    add skeleton for ViewerPreferences
    
    a small class for handling the ViewerPreferences dictionary of a Catalog,
    created on demand and in any occasion (so defaults are in one place only)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 92b0a31..5fb4e52 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -269,6 +269,7 @@ set(poppler_SRCS
   poppler/StdinCachedFile.cc
   poppler/StdinPDFDocBuilder.cc
   poppler/Sound.cc
+  poppler/ViewerPreferences.cc
   poppler/XpdfPluginAPI.cc
   poppler/Movie.cc
   poppler/Rendition.cc
@@ -413,6 +414,7 @@ if(ENABLE_XPDF_HEADERS)
     poppler/UnicodeCClassTables.h
     poppler/UnicodeCompTables.h
     poppler/UnicodeDecompTables.h
+    poppler/ViewerPreferences.h
     poppler/XRef.h
     poppler/CharTypes.h
     poppler/CompactFontTables.h
diff --git a/poppler/Catalog.cc b/poppler/Catalog.cc
index 860e789..68bb8fc 100644
--- a/poppler/Catalog.cc
+++ b/poppler/Catalog.cc
@@ -50,6 +50,7 @@
 #include "Catalog.h"
 #include "Form.h"
 #include "OptionalContent.h"
+#include "ViewerPreferences.h"
 
 //------------------------------------------------------------------------
 // Catalog
@@ -75,6 +76,7 @@ Catalog::Catalog(XRef *xrefA) {
   destNameTree = NULL;
   embeddedFileNameTree = NULL;
   jsNameTree = NULL;
+  viewerPreferences = NULL;
 
   pagesList = NULL;
   pagesRefList = NULL;
@@ -160,6 +162,7 @@ Catalog::~Catalog() {
   delete pageLabelInfo;
   delete form;
   delete optContent;
+  delete viewerPreferences;
   metadata.free();
   structTreeRoot.free();
   outline.free();
@@ -961,6 +964,26 @@ Form *Catalog::getForm()
   return form;
 }
 
+ViewerPreferences *Catalog::getViewerPreferences()
+{
+  if (!viewerPreferences) {
+    Object catDict;
+    Dict *d = NULL;
+
+    xref->getCatalog(&catDict);
+    if (catDict.isDict()) {
+      d = catDict.getDict();
+    } else {
+      error(-1, "Catalog object is wrong type (%s)", catDict.getTypeName());
+    }
+    viewerPreferences = new ViewerPreferences(d);
+
+    catDict.free();
+  }
+
+  return viewerPreferences;
+}
+
 Object *Catalog::getNames()
 {
   if (names.isNone())
diff --git a/poppler/Catalog.h b/poppler/Catalog.h
index cea808c..fb12850 100644
--- a/poppler/Catalog.h
+++ b/poppler/Catalog.h
@@ -44,6 +44,7 @@ class LinkDest;
 class PageLabelInfo;
 class Form;
 class OCGs;
+class ViewerPreferences;
 
 //------------------------------------------------------------------------
 // NameTree
@@ -202,6 +203,8 @@ public:
 
   Form* getForm();
 
+  ViewerPreferences *getViewerPreferences();
+
   enum PageMode {
     pageModeNone,
     pageModeOutlines,
@@ -240,6 +243,7 @@ private:
   std::vector<PageAttrs *> *attrsList;
   std::vector<int> *kidsIdxList;
   Form *form;
+  ViewerPreferences *viewerPreferences;
   int numPages;			// number of pages
   int pagesSize;		// size of pages array
   Object dests;			// named destination dictionary
diff --git a/poppler/Makefile.am b/poppler/Makefile.am
index 1eea50a..9f0eb04 100644
--- a/poppler/Makefile.am
+++ b/poppler/Makefile.am
@@ -236,6 +236,7 @@ poppler_include_HEADERS =	\
 	UnicodeCClassTables.h	\
 	UnicodeCompTables.h	\
 	UnicodeDecompTables.h	\
+	ViewerPreferences.h	\
 	XRef.h			\
 	CharTypes.h		\
 	CompactFontTables.h	\
@@ -310,6 +311,7 @@ libpoppler_la_SOURCES =		\
 	strtok_r.cpp		\
 	UnicodeMap.cc		\
 	UnicodeTypeTable.cc	\
+	ViewerPreferences.cc	\
 	XRef.cc			\
 	PSOutputDev.cc		\
 	TextOutputDev.cc	\
diff --git a/poppler/ViewerPreferences.cc b/poppler/ViewerPreferences.cc
new file mode 100644
index 0000000..c9ff935
--- /dev/null
+++ b/poppler/ViewerPreferences.cc
@@ -0,0 +1,30 @@
+//========================================================================
+//
+// ViewerPreferences.cc
+//
+// This file is licensed under the GPLv2 or later
+//
+// Copyright 2011 Pino Toscano <pino at kde.org>
+//
+//========================================================================
+
+#include <config.h>
+
+#include "ViewerPreferences.h"
+
+#include "Object.h"
+#include "Dict.h"
+
+ViewerPreferences::ViewerPreferences(Dict *prefDict)
+{
+  init();
+
+}
+
+ViewerPreferences::~ViewerPreferences()
+{
+}
+
+void ViewerPreferences::init()
+{
+}
diff --git a/poppler/ViewerPreferences.h b/poppler/ViewerPreferences.h
new file mode 100644
index 0000000..69f0db9
--- /dev/null
+++ b/poppler/ViewerPreferences.h
@@ -0,0 +1,34 @@
+//========================================================================
+//
+// ViewerPreferences.h
+//
+// This file is licensed under the GPLv2 or later
+//
+// Copyright 2011 Pino Toscano <pino at kde.org>
+//
+//========================================================================
+
+#ifndef VIEWERPREFERENCES_H
+#define VIEWERPREFERENCES_H
+
+#include "goo/gtypes.h"
+
+class Dict;
+
+//------------------------------------------------------------------------
+// Hints
+//------------------------------------------------------------------------
+
+class ViewerPreferences {
+public:
+
+  ViewerPreferences(Dict *prefDict);
+  ~ViewerPreferences();
+
+private:
+
+  void init();
+
+};
+
+#endif


More information about the poppler mailing list