Enlightenment CVS committal
Author : doursse
Project : e17
Module : proto
Dir : e17/proto/epdf/src/lib
Modified Files:
esmart_pdf.c esmart_pdf.h etk_pdf.c etk_pdf.h ewl_pdf.c
ewl_pdf.h poppler_enum.h poppler_page.cpp poppler_page.h
Log Message:
orientation and scaling support. Various fixes
===================================================================
RCS file: /cvs/e/e17/proto/epdf/src/lib/esmart_pdf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- esmart_pdf.c 15 Feb 2006 21:45:08 -0000 1.1
+++ esmart_pdf.c 16 Apr 2006 21:48:04 -0000 1.2
@@ -262,6 +262,31 @@
return sp->pdf_index;
}
+void
+poppler_pdf_orientation_set (Evas_Object *obj,
+ Evas_Poppler_Page_Orientation o)
+{
+ Smart_Pdf *sp;
+
+ E_SMART_OBJ_GET(sp, obj, E_OBJ_NAME);
+
+ if (o == sp->orientation)
+ return;
+
+ sp->orientation = o;
+ _smart_page_render (obj);
+}
+
+Evas_Poppler_Page_Orientation
+poppler_pdf_orientation_get (Evas_Object *obj)
+{
+ Smart_Pdf *sp;
+
+ E_SMART_OBJ_GET_RETURN(sp, obj, E_OBJ_NAME,
EVAS_POPPLER_PAGE_ORIENTATION_PORTRAIT);
+
+ return sp->orientation;
+}
+
/*******************************************/
/* Internal smart object required routines */
@@ -477,7 +502,9 @@
if (sp->obj)
{
sp->pdf_page = evas_poppler_document_page_get (sp->pdf_document,
sp->page);
- evas_poppler_page_render (sp->pdf_page, sp->obj, 0, 0, 0, 0, 72.0,
72.0);
+ evas_poppler_page_render (sp->pdf_page, sp->obj, sp->orientation,
+ 0, 0, -1, -1,
+ 1.0, 1.0);
}
evas_object_show (sp->obj);
}
===================================================================
RCS file: /cvs/e/e17/proto/epdf/src/lib/esmart_pdf.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- esmart_pdf.h 19 Feb 2006 13:29:17 -0000 1.2
+++ esmart_pdf.h 16 Apr 2006 21:48:04 -0000 1.3
@@ -15,6 +15,7 @@
Evas_Poppler_Document *pdf_document;
Evas_Poppler_Page *pdf_page;
Ecore_List *pdf_index;
+ Evas_Poppler_Page_Orientation orientation;
};
Evas_Object *poppler_object_add (Evas *evas);
@@ -26,5 +27,7 @@
Evas_Poppler_Document *poppler_pdf_document_get (Evas_Object *obj);
Evas_Poppler_Page *poppler_pdf_page_get (Evas_Object *obj);
Ecore_List *poppler_pdf_index_get (Evas_Object *obj);
+void poppler_pdf_orientation_set (Evas_Object *obj,
Evas_Poppler_Page_Orientation o);
+Evas_Poppler_Page_Orientation poppler_pdf_orientation_get (Evas_Object *obj);
#endif /* __ESMART_PDF_H__ */
===================================================================
RCS file: /cvs/e/e17/proto/epdf/src/lib/etk_pdf.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- etk_pdf.c 15 Mar 2006 21:12:24 -0000 1.2
+++ etk_pdf.c 16 Apr 2006 21:48:04 -0000 1.3
@@ -196,16 +196,18 @@
void etk_pdf_size_get(Etk_Pdf *pdf, int *width, int *height)
{
if (!pdf)
- return;
-
- if (!pdf)
{
if (width)
*width = 0;
if (height)
*height = 0;
}
- else
+ else {
+ if (width)
+ *width = evas_poppler_page_width_get (pdf->pdf_page);
+ if (height)
+ *height = evas_poppler_page_height_get (pdf->pdf_page);
+ }
evas_object_image_size_get(pdf->pdf_object, width, height);
}
@@ -215,7 +217,7 @@
if (!pdf)
return;
- if ((!text) ||
+ if ((!text) ||
(pdf->search.text &&
strcmp (text, pdf->search.text) == 0))
return;
@@ -283,7 +285,7 @@
ecore_list_goto_first (pdf->search.list);
evas_poppler_page_delete (page);
}
-
+
/* an already existing list or a netky one */
if (pdf->search.list) {
Rectangle *rect;
@@ -324,6 +326,55 @@
return ETK_TRUE;
}
+void etk_pdf_orientation_set (Etk_Pdf *pdf, Evas_Poppler_Page_Orientation o)
+{
+ if (!pdf || !pdf->pdf_page || (pdf->orientation == o))
+ return;
+
+ printf ("orientation %d\n", o);
+ pdf->orientation = o;
+ _etk_pdf_load (pdf);
+}
+
+Evas_Poppler_Page_Orientation etk_pdf_orientation_get (Etk_Pdf *pdf)
+{
+ if (!pdf || !pdf->pdf_page)
+ return EVAS_POPPLER_PAGE_ORIENTATION_PORTRAIT;
+
+ return evas_poppler_page_orientation_get (pdf->pdf_page);
+}
+
+void etk_pdf_scale_set (Etk_Pdf *pdf, double hscale, double vscale)
+{
+ if (!pdf)
+ return;
+
+ if (hscale != pdf->hscale)
+ pdf->hscale = hscale;
+
+ if (vscale != pdf->vscale)
+ pdf->vscale = vscale;
+ _etk_pdf_load (pdf);
+}
+
+void etk_pdf_sacle_get (Etk_Pdf *pdf, double *hscale, double *vscale)
+{
+ if (!pdf) {
+ if (hscale)
+ *hscale = 1.0;
+
+ if (vscale)
+ *vscale = 1.0;
+ }
+ else {
+ if (hscale)
+ *hscale = pdf->hscale;
+
+ if (vscale)
+ *vscale = pdf->vscale;
+ }
+}
+
/**************************
*
* Etk specific functions
@@ -346,6 +397,10 @@
pdf->pdf_page = NULL;
pdf->pdf_index = NULL;
+ pdf->orientation = EVAS_POPPLER_PAGE_ORIENTATION_PORTRAIT;
+ pdf->hscale = 1.0;
+ pdf->vscale = 1.0;
+
pdf->search.o = NULL;
pdf->search.text = NULL;
pdf->search.list = NULL;
@@ -522,7 +577,10 @@
if (pdf->pdf_object)
{
pdf->pdf_page = evas_poppler_document_page_get (pdf->pdf_document,
pdf->page);
- evas_poppler_page_render (pdf->pdf_page, pdf->pdf_object, 0, 0, 0, 0,
72.0, 72.0);
+ evas_poppler_page_render (pdf->pdf_page, pdf->pdf_object,
+ pdf->orientation,
+ 0, 0, -1, -1,
+ pdf->hscale, pdf->vscale);
}
evas_object_show(pdf->pdf_object);
}
===================================================================
RCS file: /cvs/e/e17/proto/epdf/src/lib/etk_pdf.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- etk_pdf.h 15 Mar 2006 21:12:24 -0000 1.3
+++ etk_pdf.h 16 Apr 2006 21:48:04 -0000 1.4
@@ -36,6 +36,9 @@
Evas_Poppler_Document *pdf_document;
Evas_Poppler_Page *pdf_page;
Ecore_List *pdf_index;
+ Evas_Poppler_Page_Orientation orientation;
+ double hscale;
+ double vscale;
struct {
Evas_Object *o;
@@ -57,9 +60,16 @@
Evas_Poppler_Document *etk_pdf_pdf_document_get (Etk_Pdf *pdf);
Evas_Poppler_Page *etk_pdf_pdf_page_get (Etk_Pdf *pdf);
Ecore_List *etk_pdf_pdf_index_get (Etk_Pdf *pdf);
+void etk_pdf_size_get (Etk_Pdf *pdf, int *width, int
*height);
void etk_pdf_search_text_set (Etk_Pdf *pdf, const char
*text);
void etk_pdf_search_is_case_sensitive (Etk_Pdf *pdf, int
is_case_sensitive);
int etk_pdf_search_next (Etk_Pdf *pdf);
+
+void etk_pdf_orientation_set (Etk_Pdf *pdf,
Evas_Poppler_Page_Orientation o);
+Evas_Poppler_Page_Orientation etk_pdf_orientation_get (Etk_Pdf *pdf);
+
+void etk_pdf_scale_set (Etk_Pdf *pdf, double hscale, double
vscale);
+void etk_pdf_scale_get (Etk_Pdf *pdf, double *hscale, double
*vscale);
/** @} */
===================================================================
RCS file: /cvs/e/e17/proto/epdf/src/lib/ewl_pdf.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_pdf.c 15 Mar 2006 21:12:24 -0000 1.3
+++ ewl_pdf.c 16 Apr 2006 21:48:04 -0000 1.4
@@ -82,6 +82,10 @@
pdf->pdf_page = NULL;
pdf->pdf_index = NULL;
+ pdf->orientation = EVAS_POPPLER_PAGE_ORIENTATION_PORTRAIT;
+ pdf->hscale = 1.0;
+ pdf->vscale = 1.0;
+
pdf->search.o = NULL;
pdf->search.text = NULL;
pdf->search.list = NULL;
@@ -227,6 +231,31 @@
DRETURN_PTR(pdf->pdf_index, DLEVEL_STABLE);
}
+/**
+ * @param pdf: the pdf widget to get the size of
+ * @param width width of the current page
+ * @param height height of the current page
+ * @brief get the poppler size of the pdf @p pdf. If @p pdf is NULL,
+ * return a width equal to 0 and a height equal to 0
+ */
+void ewl_pdf_pdf_size_get (Ewl_Pdf *pdf, int *width, int *height)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("pdf", pdf);
+ DCHECK_TYPE("pdf", pdf, "pdf");
+
+ if (!pdf) {
+ if (width) *width = 0;
+ if (height) *height = 0;
+ }
+ else {
+ if (width) *width = evas_poppler_page_width_get (pdf->pdf_page);
+ if (height) *height = evas_poppler_page_height_get
(pdf->pdf_page);
+ }
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
void
ewl_pdf_search_text_set (Ewl_Pdf *pdf, const char *text)
{
@@ -234,7 +263,7 @@
DCHECK_PARAM_PTR("pdf", pdf);
DCHECK_TYPE("pdf", pdf, "pdf");
- if ((!text) ||
+ if ((!text) ||
(pdf->search.text &&
strcmp (text, pdf->search.text) == 0))
DRETURN(DLEVEL_STABLE);
@@ -309,7 +338,7 @@
ecore_list_goto_first (pdf->search.list);
evas_poppler_page_delete (page);
}
-
+
/* an already existing list or a newly one */
if (pdf->search.list) {
Rectangle *rect;
@@ -349,6 +378,69 @@
}
void
+ewl_pdf_orientation_set (Ewl_Pdf *pdf, Evas_Poppler_Page_Orientation o)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("pdf", pdf);
+ DCHECK_TYPE("pdf", pdf, "pdf");
+
+ if (!pdf || !pdf->pdf_page || (pdf->orientation == o))
+ return;
+
+ pdf->orientation = o;
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+Evas_Poppler_Page_Orientation
+ewl_pdf_orientation_get (Ewl_Pdf *pdf)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR_RET("pdf", pdf, FALSE);
+ DCHECK_TYPE_RET("pdf", pdf, "pdf", 0);
+
+ if (!pdf || !pdf->pdf_page)
+ return EVAS_POPPLER_PAGE_ORIENTATION_PORTRAIT;
+
+ DRETURN_INT(evas_poppler_page_orientation_get (pdf->pdf_page),
DLEVEL_STABLE);
+}
+
+void
+ewl_pdf_scale_set (Ewl_Pdf *pdf, double hscale, double vscale)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("pdf", pdf);
+ DCHECK_TYPE("pdf", pdf, "pdf");
+
+ if (!pdf)
+ return;
+
+ if (hscale != pdf->hscale) pdf->hscale = hscale;
+ if (vscale != pdf->vscale) pdf->vscale = vscale;
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+void
+ewl_pdf_scale_get (Ewl_Pdf *pdf, double *hscale, double *vscale)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("pdf", pdf);
+ DCHECK_TYPE("pdf", pdf, "pdf");
+
+ if (!pdf) {
+ if (hscale) *hscale = 1.0;
+ if (vscale) *vscale = 1.0;
+ }
+ else {
+ if (hscale) *hscale = pdf->hscale;
+ if (vscale) *vscale = pdf->vscale;
+ }
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+void
ewl_pdf_reveal_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
void *user_data __UNUSED__)
{
@@ -378,7 +470,10 @@
if (pdf->pdf_page)
evas_poppler_page_delete (pdf->pdf_page);
pdf->pdf_page = evas_poppler_document_page_get
(pdf->pdf_document, pdf->page);
- evas_poppler_page_render (pdf->pdf_page, i->image, 0, 0, 0, 0,
72.0, 72.0);
+ evas_poppler_page_render (pdf->pdf_page, i->image,
+ pdf->orientation,
+ 0, 0, -1, -1,
+ pdf->hscale, pdf->vscale);
}
evas_object_image_size_get(i->image, &i->ow, &i->oh);
===================================================================
RCS file: /cvs/e/e17/proto/epdf/src/lib/ewl_pdf.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_pdf.h 8 Mar 2006 18:25:30 -0000 1.3
+++ ewl_pdf.h 16 Apr 2006 21:48:04 -0000 1.4
@@ -29,18 +29,21 @@
Ewl_Image image;
int page;
- Evas_Poppler_Document *pdf_document;
- Evas_Poppler_Page *pdf_page;
- Ecore_List *pdf_index;
+ Evas_Poppler_Document *pdf_document;
+ Evas_Poppler_Page *pdf_page;
+ Ecore_List *pdf_index;
+ Evas_Poppler_Page_Orientation orientation;
+ double hscale;
+ double vscale;
- struct {
- Evas_Object *o;
- char *text;
- Ecore_List *list;
- int page;
- int is_case_sensitive;
- int is_circular;
- }search;
+ struct {
+ Evas_Object *o;
+ char *text;
+ Ecore_List *list;
+ int page;
+ int is_case_sensitive;
+ int is_circular;
+ }search;
};
@@ -52,9 +55,16 @@
Evas_Poppler_Document *ewl_pdf_pdf_document_get (Ewl_Pdf *pdf);
Evas_Poppler_Page *ewl_pdf_pdf_page_get (Ewl_Pdf *pdf);
Ecore_List *ewl_pdf_pdf_index_get (Ewl_Pdf *pdf);
+void ewl_pdf_size_get (Ewl_Pdf *pdf, int *width, int
*height);
void ewl_pdf_search_text_set (Ewl_Pdf *pdf, const char
*text);
void ewl_pdf_search_is_case_sensitive (Ewl_Pdf *pdf, int
is_case_sensitive);
int ewl_pdf_search_next (Ewl_Pdf *pdf);
+
+void ewl_pdf_orientation_set (Ewl_Pdf *pdf,
Evas_Poppler_Page_Orientation o);
+Evas_Poppler_Page_Orientation ewl_pdf_orientation_get (Ewl_Pdf *pdf);
+
+void ewl_pdf_scale_set (Ewl_Pdf *pdf, double hscale, double
vscale);
+void ewl_pdf_scale_get (Ewl_Pdf *pdf, double *hscale, double
*vscale);
/*
* Internally used callbacks, override at your own risk.
===================================================================
RCS file: /cvs/e/e17/proto/epdf/src/lib/poppler_enum.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- poppler_enum.h 15 Feb 2006 21:45:08 -0000 1.1
+++ poppler_enum.h 16 Apr 2006 21:48:04 -0000 1.2
@@ -44,10 +44,10 @@
typedef enum
{
- EVAS_POPPLER_PAGE_ORIENTATION_LANDSCAPE, /**< Landscape orientation */
EVAS_POPPLER_PAGE_ORIENTATION_PORTRAIT, /**< Portrait orientation */
- EVAS_POPPLER_PAGE_ORIENTATION_SEASCAPE, /**< Seascape orientation */
- EVAS_POPPLER_PAGE_ORIENTATION_UPSIDEDOWN /**< Upside-down orientation
*/
+ EVAS_POPPLER_PAGE_ORIENTATION_LANDSCAPE, /**< Landscape orientation */
+ EVAS_POPPLER_PAGE_ORIENTATION_UPSIDEDOWN, /**< Upside-down orientation
*/
+ EVAS_POPPLER_PAGE_ORIENTATION_SEASCAPE /**< Seascape orientation */
}Evas_Poppler_Page_Orientation;
typedef enum
===================================================================
RCS file: /cvs/e/e17/proto/epdf/src/lib/poppler_page.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- poppler_page.cpp 6 Apr 2006 07:16:41 -0000 1.4
+++ poppler_page.cpp 16 Apr 2006 21:48:04 -0000 1.5
@@ -59,7 +59,7 @@
}
void
-evas_poppler_page_render (Evas_Poppler_Page *page, Evas_Object *o, int x, int
y, int w, int h, double xres, double yres)
+evas_poppler_page_render (Evas_Poppler_Page *page, Evas_Object *o,
Evas_Poppler_Page_Orientation orientation, int x, int y, int w, int h, double
hscale, double vscale)
{
SplashOutputDev *output_dev;
SplashColor white;
@@ -68,6 +68,7 @@
unsigned int *m = NULL;
unsigned int val;
int offset = 0;
+ int rotate;
int width;
int height;
@@ -79,10 +80,29 @@
output_dev = new SplashOutputDev(splashModeRGB8, 4, gFalse, white);
output_dev->startDoc(doc->pdfdoc->getXRef ());
- printf ("PAGE : %d\n", page->index + 1);
- doc->pdfdoc->displayPageSlice(output_dev, page->index + 1, xres, yres,
- 0, false, false, false, -1, -1, -1, -1);
+ switch (orientation) {
+ case EVAS_POPPLER_PAGE_ORIENTATION_LANDSCAPE:
+ rotate = 90;
+ break;
+ case EVAS_POPPLER_PAGE_ORIENTATION_UPSIDEDOWN:
+ rotate = 180;
+ break;
+ case EVAS_POPPLER_PAGE_ORIENTATION_SEASCAPE:
+ rotate = 270;
+ break;
+ case EVAS_POPPLER_PAGE_ORIENTATION_PORTRAIT:
+ default:
+ rotate = 0;
+ break;
+ }
+ page->page->displaySlice (output_dev, 72.0 * hscale, 72.0 * vscale,
+ rotate,
+ false, false,
+ x, y, w, h,
+ NULL,
+ doc->pdfdoc->getCatalog ());
color_ptr = output_dev->getBitmap ()->getDataPtr ();
+
width = output_dev->getBitmap()->getWidth();
height = output_dev->getBitmap()->getHeight();
===================================================================
RCS file: /cvs/e/e17/proto/epdf/src/lib/poppler_page.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- poppler_page.h 15 Feb 2006 21:45:08 -0000 1.1
+++ poppler_page.h 16 Apr 2006 21:48:04 -0000 1.2
@@ -51,26 +51,29 @@
*
* @param page The page
* @param o The Evas_Object on which the page is rendered
- * @param x The x coordinate
- * @param y The y coordinate
- * @param w The width
- * @param h The height
- * @param xres The x resolution
- * @param yres The y resolution
+ * @param x The x coordinate of the upper-left corner
+ * @param y The y coordinate of the upper-left corner
+ * @param w The width of rectangle to render
+ * @param h The height of rectangle to render
+ * @param hscale The horizontal scale specified as pixels per point
+ * @param vscale The vertical scale specified as pixels per point
*
* Render a rectangle of the page @p page on the Evas_Object @p o. The
* upper-left corner of the rectangle has the coordinates (@px, @py),
- * its width is @pw and its height is @p h. @p xres and @p yres are
- * respectively the x and y resolution used to render the rectangle
+ * its width is @pw and its height is @p h. @p hscale and @p vscale are
+ * respectively the horizontal and vertical scales, in pixel per
+ * points to render the rectangle. A value of 1.0 and 1.0 (resp.)
+ * means that the original size of the document is choosen.
*/
void evas_poppler_page_render (Evas_Poppler_Page *page,
Evas_Object *o,
+ Evas_Poppler_Page_Orientation orientation,
int x,
int y,
int w,
int h,
- double xres,
- double yres);
+ double hscale,
+ double vscale);
/**
* Return the page number
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs