~ubuntu-branches/ubuntu/gutsy/dvipdfmx/gutsy

« back to all changes in this revision

Viewing changes to src/pdfdoc.c

  • Committer: Bazaar Package Importer
  • Author(s): Yu Guanghui
  • Date: 2007-02-23 20:48:19 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070223204819-nn9zf1lrvr94zzqh
Tags: 1:20061211-2
update pdfdoc.c to CVS 1.45. Fixed half-timezone bug. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.c,v 1.41 2005/08/31 08:01:05 chofchof Exp $
 
1
/*  $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.c,v 1.45 2006/12/21 02:36:55 chofchof Exp $
2
2
 
3
3
    This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
4
4
 
484
484
  return;
485
485
}
486
486
 
 
487
/* auxiliary function to compute timezone offset on
 
488
   systems that do not support the tm_gmtoff in struct tm,
 
489
   or have a timezone variable.  Such as i386-solaris.  */
 
490
 
 
491
static long
 
492
compute_timezone_offset()
 
493
{
 
494
  const time_t now = time(NULL);
 
495
  struct tm tm;
 
496
  struct tm local;
 
497
  time_t gmtoff;
 
498
 
 
499
  localtime_r(&now, &local);
 
500
  gmtime_r(&now, &tm);
 
501
  return (mktime(&local) - mktime(&tm));
 
502
}
 
503
 
487
504
/*
488
505
 * Docinfo
489
506
 */
490
507
static long
491
508
asn_date (char *date_string)
492
509
{
 
510
#ifndef HAVE_TIMEZONE
 
511
# ifdef HAVE_TM_GMTOFF
 
512
#  define timezone (-bd_time->tm_gmtoff)
 
513
# else
 
514
#  define timezone (-compute_timezone_offset())
 
515
# endif /* not HAVE_TM_GMTOFF */
 
516
#endif  /* not HAVE_TIMEZONE */
493
517
  time_t      current_time;
494
518
  struct tm  *bd_time;
495
 
#ifndef HAVE_TIMEZONE
496
 
  #ifdef TM_GM_TOFF
497
 
     #define timezone (bdtime->gm_toff)
498
 
  #else
499
 
     #define timezone 0l
500
 
  #endif /* TM_GM_TOFF */
501
 
#endif /* HAVE_TIMEZONE */
502
519
 
503
520
  time(&current_time);
504
521
  bd_time = localtime(&current_time);
505
522
  sprintf(date_string, "D:%04d%02d%02d%02d%02d%02d%+03ld'%02ld'",
506
523
          bd_time->tm_year + 1900, bd_time->tm_mon + 1, bd_time->tm_mday,
507
524
          bd_time->tm_hour, bd_time->tm_min, bd_time->tm_sec,
508
 
          -timezone/3600, timezone % 3600);
 
525
          (-timezone / 3600), (timezone % 3600) / 60);
509
526
 
510
527
  return strlen(date_string);
511
528
}
1991
2008
{
1992
2009
  pdf_doc  *p = &pdoc;
1993
2010
  pdf_page *currentpage;
1994
 
  pdf_obj  *contents;
1995
 
  char     *pending_tbuf;
1996
 
  int       tbuf_len;
1997
 
 
1998
 
  currentpage = LASTPAGE(p);
1999
 
  contents = (p->pending_forms ?
2000
 
              p->pending_forms->form.contents : currentpage->contents);
2001
 
 
2002
 
  tbuf_len = pdf_dev_flushtmatrix(&pending_tbuf);
2003
 
  if (tbuf_len > 0) {
2004
 
    pdf_add_stream(contents, pending_tbuf, tbuf_len);
 
2011
 
 
2012
  if (p->pending_forms) {
 
2013
    pdf_add_stream(p->pending_forms->form.contents, buffer, length);
 
2014
  } else {
 
2015
    currentpage = LASTPAGE(p);
 
2016
    pdf_add_stream(currentpage->contents, buffer, length);
2005
2017
  }
2006
 
  pdf_add_stream(contents, buffer, length);
2007
2018
 
2008
2019
  return;
2009
2020
}
2215
2226
                                      PDF_XOBJECT_TYPE_FORM,
2216
2227
                                      &info, pdf_ref_obj(form->contents));
2217
2228
 
2218
 
  /* Must call pdf_dev_flushtmatrix(). */
2219
 
  pdf_doc_add_page_content(NULL, 0);
2220
 
 
2221
2229
  p->pending_forms = fnode;
2222
2230
 
2223
2231
  /*
2246
2254
  fnode = p->pending_forms;
2247
2255
  form  = &fnode->form;
2248
2256
 
2249
 
  /* Must call pdf_dev_flushtmatrix(). */
2250
 
  pdf_doc_add_page_content(NULL, 0);
2251
 
 
2252
2257
  pdf_dev_grestore_to(fnode->q_depth);
2253
2258
 
2254
2259
  /*