summaryrefslogtreecommitdiff
path: root/backend/dvi/dvi-document.c
diff options
context:
space:
mode:
authorLaurent Napias <[email protected]>2019-06-29 10:43:23 +0200
committerraveit65 <[email protected]>2019-07-01 17:07:40 +0200
commitaa24676651f8bd3e8b434f72d5aac98e84c0867d (patch)
tree37693766ecb4733c6061dcc2ddc26954fab5ca01 /backend/dvi/dvi-document.c
parent6741c5db1e5c48c01b25bb7900dc40d48552925d (diff)
downloadatril-aa24676651f8bd3e8b434f72d5aac98e84c0867d.tar.bz2
atril-aa24676651f8bd3e8b434f72d5aac98e84c0867d.tar.xz
Remove trailing whitespaces
Diffstat (limited to 'backend/dvi/dvi-document.c')
-rw-r--r--backend/dvi/dvi-document.c108
1 files changed, 54 insertions, 54 deletions
diff --git a/backend/dvi/dvi-document.c b/backend/dvi/dvi-document.c
index 6051b7b1..1a84fe72 100644
--- a/backend/dvi/dvi-document.c
+++ b/backend/dvi/dvi-document.c
@@ -54,11 +54,11 @@ struct _DviDocument
DviContext *context;
DviPageSpec *spec;
DviParams *params;
-
+
/* To let document scale we should remember width and height */
double base_width;
double base_height;
-
+
gchar *uri;
/* PDF exporter */
@@ -87,11 +87,11 @@ dvi_document_load (EvDocument *document,
{
gchar *filename;
DviDocument *dvi_document = DVI_DOCUMENT(document);
-
+
filename = g_filename_from_uri (uri, NULL, error);
if (!filename)
return FALSE;
-
+
g_mutex_lock (&dvi_context_mutex);
if (dvi_document->context)
mdvi_destroy_context (dvi_document->context);
@@ -99,7 +99,7 @@ dvi_document_load (EvDocument *document,
dvi_document->context = mdvi_init_context(dvi_document->params, dvi_document->spec, filename);
g_mutex_unlock (&dvi_context_mutex);
g_free (filename);
-
+
if (!dvi_document->context) {
g_set_error_literal (error,
EV_DOCUMENT_ERROR,
@@ -107,19 +107,19 @@ dvi_document_load (EvDocument *document,
_("DVI document has incorrect format"));
return FALSE;
}
-
+
mdvi_cairo_device_init (&dvi_document->context->device);
-
-
- dvi_document->base_width = dvi_document->context->dvi_page_w * dvi_document->context->params.conv
+
+
+ dvi_document->base_width = dvi_document->context->dvi_page_w * dvi_document->context->params.conv
+ 2 * unit2pix(dvi_document->params->dpi, MDVI_HMARGIN) / dvi_document->params->hshrink;
-
- dvi_document->base_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv
+
+ dvi_document->base_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv
+ 2 * unit2pix(dvi_document->params->vdpi, MDVI_VMARGIN) / dvi_document->params->vshrink;
-
+
g_free (dvi_document->uri);
dvi_document->uri = g_strdup (uri);
-
+
return TRUE;
}
@@ -138,7 +138,7 @@ static int
dvi_document_get_n_pages (EvDocument *document)
{
DviDocument *dvi_document = DVI_DOCUMENT (document);
-
+
return dvi_document->context->npages;
}
@@ -148,7 +148,7 @@ dvi_document_get_page_size (EvDocument *document,
double *width,
double *height)
{
- DviDocument *dvi_document = DVI_DOCUMENT (document);
+ DviDocument *dvi_document = DVI_DOCUMENT (document);
*width = dvi_document->base_width;
*height = dvi_document->base_height;;
@@ -165,15 +165,15 @@ dvi_document_render (EvDocument *document,
gint proposed_width, proposed_height;
gint xmargin = 0, ymargin = 0;
- /* We should protect our context since it's not
- * thread safe. The work to the future -
+ /* We should protect our context since it's not
+ * thread safe. The work to the future -
* let context render page independently
*/
g_mutex_lock (&dvi_context_mutex);
-
+
mdvi_setpage (dvi_document->context, rc->page->index);
-
- mdvi_set_shrink (dvi_document->context,
+
+ mdvi_set_shrink (dvi_document->context,
(int)((dvi_document->params->hshrink - 1) / rc->scale) + 1,
(int)((dvi_document->params->vshrink - 1) / rc->scale) + 1);
@@ -181,12 +181,12 @@ dvi_document_render (EvDocument *document,
required_height = dvi_document->base_height * rc->scale + 0.5;
proposed_width = dvi_document->context->dvi_page_w * dvi_document->context->params.conv;
proposed_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv;
-
+
if (required_width >= proposed_width)
xmargin = (required_width - proposed_width) / 2;
if (required_height >= proposed_height)
ymargin = (required_height - proposed_height) / 2;
-
+
mdvi_cairo_device_set_margins (&dvi_document->context->device, xmargin, ymargin);
mdvi_cairo_device_set_scale (&dvi_document->context->device, rc->scale);
mdvi_cairo_device_render (dvi_document->context);
@@ -196,18 +196,18 @@ dvi_document_render (EvDocument *document,
rotated_surface = ev_document_misc_surface_rotate_and_scale (surface,
required_width,
- required_height,
+ required_height,
rc->rotation);
cairo_surface_destroy (surface);
-
+
return rotated_surface;
}
static void
dvi_document_finalize (GObject *object)
-{
+{
DviDocument *dvi_document = DVI_DOCUMENT(object);
-
+
g_mutex_lock (&dvi_context_mutex);
if (dvi_document->context) {
mdvi_cairo_device_free (&dvi_document->context->device);
@@ -220,12 +220,12 @@ dvi_document_finalize (GObject *object)
if (dvi_document->exporter_filename)
g_free (dvi_document->exporter_filename);
-
+
if (dvi_document->exporter_opts)
g_string_free (dvi_document->exporter_opts, TRUE);
g_free (dvi_document->uri);
-
+
G_OBJECT_CLASS (dvi_document_parent_class)->finalize (object);
}
@@ -258,10 +258,10 @@ dvi_document_class_init (DviDocumentClass *klass)
static void
dvi_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
- EvRenderContext *rc,
+ EvRenderContext *rc,
gint *width,
gint *height)
-{
+{
DviDocument *dvi_document = DVI_DOCUMENT (document);
gdouble page_width = dvi_document->base_width;
gdouble page_height = dvi_document->base_height;
@@ -277,7 +277,7 @@ dvi_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
static GdkPixbuf *
dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
- EvRenderContext *rc,
+ EvRenderContext *rc,
gboolean border)
{
DviDocument *dvi_document = DVI_DOCUMENT (document);
@@ -291,24 +291,24 @@ dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
thumb_height = (gint) (dvi_document->base_height * rc->scale);
g_mutex_lock (&dvi_context_mutex);
-
+
mdvi_setpage (dvi_document->context, rc->page->index);
- mdvi_set_shrink (dvi_document->context,
+ mdvi_set_shrink (dvi_document->context,
(int)dvi_document->base_width * dvi_document->params->hshrink / thumb_width,
(int)dvi_document->base_height * dvi_document->params->vshrink / thumb_height);
proposed_width = dvi_document->context->dvi_page_w * dvi_document->context->params.conv;
proposed_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv;
-
+
if (border) {
- mdvi_cairo_device_set_margins (&dvi_document->context->device,
+ mdvi_cairo_device_set_margins (&dvi_document->context->device,
MAX (thumb_width - proposed_width, 0) / 2,
- MAX (thumb_height - proposed_height, 0) / 2);
+ MAX (thumb_height - proposed_height, 0) / 2);
} else {
- mdvi_cairo_device_set_margins (&dvi_document->context->device,
+ mdvi_cairo_device_set_margins (&dvi_document->context->device,
MAX (thumb_width - proposed_width - 2, 0) / 2,
- MAX (thumb_height - proposed_height - 2, 0) / 2);
+ MAX (thumb_height - proposed_height - 2, 0) / 2);
}
mdvi_cairo_device_set_scale (&dvi_document->context->device, rc->scale);
@@ -345,11 +345,11 @@ dvi_document_file_exporter_begin (EvFileExporter *exporter,
EvFileExporterContext *fc)
{
DviDocument *dvi_document = DVI_DOCUMENT(exporter);
-
+
if (dvi_document->exporter_filename)
- g_free (dvi_document->exporter_filename);
+ g_free (dvi_document->exporter_filename);
dvi_document->exporter_filename = g_strdup (fc->filename);
-
+
if (dvi_document->exporter_opts) {
g_string_free (dvi_document->exporter_opts, TRUE);
}
@@ -372,16 +372,16 @@ dvi_document_file_exporter_end (EvFileExporter *exporter)
gint exit_stat;
GError *err = NULL;
gboolean success;
-
+
DviDocument *dvi_document = DVI_DOCUMENT(exporter);
gchar* quoted_filename = g_shell_quote (dvi_document->context->filename);
-
+
command_line = g_strdup_printf ("dvipdfm %s -o %s %s", /* dvipdfm -s 1,2,.., -o exporter_filename dvi_filename */
dvi_document->exporter_opts->str,
dvi_document->exporter_filename,
quoted_filename);
g_free (quoted_filename);
-
+
success = g_spawn_command_line_sync (command_line,
NULL,
NULL,
@@ -469,7 +469,7 @@ hsb2rgb (float h, float s, float v, guchar *red, guchar *green, guchar *blue)
*red = (guchar)floor(r * 255.0);
*green = (guchar)floor(g * 255.0);
*blue = (guchar)floor(b * 255.0);
-
+
return TRUE;
}
@@ -498,7 +498,7 @@ dvi_document_do_color_special (DviContext *dvi, const char *prefix, const char *
} else if (strncmp (arg, "push", 4) == 0) {
/* Find color source: Named, CMYK or RGB */
const char *tmp = arg + 4;
-
+
while (isspace (*tmp)) tmp++;
if (!strncmp ("rgb", tmp, 3)) {
@@ -506,7 +506,7 @@ dvi_document_do_color_special (DviContext *dvi, const char *prefix, const char *
guchar red, green, blue;
parse_color (tmp + 4, rgb, 3);
-
+
red = 255 * rgb[0];
green = 255 * rgb[1];
blue = 255 * rgb[2];
@@ -517,14 +517,14 @@ dvi_document_do_color_special (DviContext *dvi, const char *prefix, const char *
guchar red, green, blue;
parse_color (tmp + 4, hsb, 3);
-
+
if (hsb2rgb (hsb[0], hsb[1], hsb[2], &red, &green, &blue))
mdvi_push_color (dvi, RGB2ULONG (red, green, blue), 0xFFFFFFFF);
} else if (!strncmp ("cmyk", tmp, 4)) {
gdouble cmyk[4];
double r, g, b;
guchar red, green, blue;
-
+
parse_color (tmp + 5, cmyk, 4);
r = 1.0 - cmyk[0] - cmyk[3];
@@ -540,7 +540,7 @@ dvi_document_do_color_special (DviContext *dvi, const char *prefix, const char *
red = r * 255 + 0.5;
green = g * 255 + 0.5;
blue = b * 255 + 0.5;
-
+
mdvi_push_color (dvi, RGB2ULONG (red, green, blue), 0xFFFFFFFF);
} else if (!strncmp ("gray ", tmp, 5)) {
gdouble gray;
@@ -553,7 +553,7 @@ dvi_document_do_color_special (DviContext *dvi, const char *prefix, const char *
mdvi_push_color (dvi, RGB2ULONG (rgb, rgb, rgb), 0xFFFFFFFF);
} else {
GdkColor color;
-
+
if (gdk_color_parse (tmp, &color)) {
guchar red, green, blue;
@@ -569,8 +569,8 @@ dvi_document_do_color_special (DviContext *dvi, const char *prefix, const char *
static void
dvi_document_init_params (DviDocument *dvi_document)
-{
- dvi_document->params = g_new0 (DviParams, 1);
+{
+ dvi_document->params = g_new0 (DviParams, 1);
dvi_document->params->dpi = MDVI_DPI;
dvi_document->params->vdpi = MDVI_VDPI;
@@ -585,7 +585,7 @@ dvi_document_init_params (DviDocument *dvi_document)
dvi_document->params->orientation = MDVI_ORIENT_TBLR;
dvi_document->spec = NULL;
-
+
dvi_document->params->bg = 0xffffffff;
dvi_document->params->fg = 0xff000000;
}