Ignore:
Timestamp:
Dec 30, 2009, 7:13:45 PM (11 years ago)
Author:
rbri
Message:

PDF plugin: Poppler library updated to version 0.12.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/poppler/mypoppler/poppler/TextOutputDev.cc

    r261 r277  
    1919// Copyright (C) 2008 Koji Otani <sho@bbr.jp>
    2020// Copyright (C) 2008 Albert Astals Cid <aacid@kde.org>
     21// Copyright (C) 2008 Pino Toscano <pino@kde.org>
     22// Copyright (C) 2008 Hib Eris <hib@hiberis.nl>
     23// Copyright (C) 2009 Ross Moore <ross@maths.mq.edu.au>
     24// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net>
    2125//
    2226// To see a description of the changes please see the Changelog file that
     
    3640#include <math.h>
    3741#include <ctype.h>
    38 #ifdef WIN32
     42#ifdef _WIN32
    3943#include <fcntl.h> // for O_BINARY
    4044#include <io.h>    // for setmode
     
    17731777  int rot;
    17741778
     1779  refCnt = 1;
    17751780  rawOrder = rawOrderA;
    17761781  curWord = NULL;
     
    18091814  deleteGooList(underlines, TextUnderline);
    18101815  deleteGooList(links, TextLink);
     1816}
     1817
     1818void TextPage::incRefCnt() {
     1819  refCnt++;
     1820}
     1821
     1822void TextPage::decRefCnt() {
     1823  if (--refCnt == 0)
     1824    delete this;
    18111825}
    18121826
     
    38013815      if (begin == NULL)
    38023816        begin = p;
    3803     if ((selection->x1 > p->xMin && selection->y1 > p->yMin ||
    3804          selection->x2 > p->xMin && selection->y2 > p->yMin) && (begin != NULL)) {
     3817    if (((selection->x1 > p->xMin && selection->y1 > p->yMin) ||
     3818         (selection->x2 > p->xMin && selection->y2 > p->yMin)) && (begin != NULL)) {
    38053819      end = p->next;
    38063820      current = p;
     
    38863900    }
    38873901
    3888     if ((selection->x1 > p->xMin && selection->y1 > p->yMin ||
    3889         selection->x2 > p->xMin && selection->y2 > p->yMin) && (begin != NULL))
     3902    if (((selection->x1 > p->xMin && selection->y1 > p->yMin) ||
     3903         (selection->x2 > p->xMin && selection->y2 > p->yMin))
     3904        && (begin != NULL))
    38903905      end = p->next;
    38913906  }
     
    39643979    }
    39653980
    3966     if (selection->x1 > b->xMin && selection->y1 > b->yMin ||
    3967         selection->x2 > b->xMin && selection->y2 > b->yMin)
     3981    if ((selection->x1 > b->xMin && selection->y1 > b->yMin) ||
     3982        (selection->x2 > b->xMin && selection->y2 > b->yMin))
    39683983      end = i + 1;
    39693984  }
     
    44854500
    44864501//------------------------------------------------------------------------
    4487 // TextOutputDev
     4502// ActualText
    44884503//------------------------------------------------------------------------
    4489 
    4490 static void TextOutputDev_outputToFile(void *stream, char *text, int len) {
    4491   fwrite(text, 1, len, (FILE *)stream);
    4492 }
    4493 
    4494 TextOutputDev::TextOutputDev(char *fileName, GBool physLayoutA,
    4495                              GBool rawOrderA, GBool append) {
    4496   text = NULL;
    4497   physLayout = physLayoutA;
    4498   rawOrder = rawOrderA;
    4499   doHTML = gFalse;
    4500   ok = gTrue;
    4501 
    4502   // open file
    4503   needClose = gFalse;
    4504   if (fileName) {
    4505     if (!strcmp(fileName, "-")) {
    4506       outputStream = stdout;
    4507 #ifdef WIN32
    4508       // keep DOS from munging the end-of-line characters
    4509       setmode(fileno(stdout), O_BINARY);
    4510 #endif
    4511     } else if ((outputStream = fopen(fileName, append ? "ab" : "wb"))) {
    4512       needClose = gTrue;
    4513     } else {
    4514       error(-1, "Couldn't open text file '%s'", fileName);
    4515       ok = gFalse;
    4516       return;
    4517     }
    4518     outputFunc = &TextOutputDev_outputToFile;
    4519   } else {
    4520     outputStream = NULL;
    4521   }
    4522 
    4523   // set up text object
    4524   text = new TextPage(rawOrderA);
     4504ActualText::ActualText(TextPage *out) {
     4505  out->incRefCnt();
     4506  text = out;
     4507  actualText = NULL;
    45254508  actualTextBMCLevel = 0;
    45264509}
    45274510
    4528 TextOutputDev::TextOutputDev(TextOutputFunc func, void *stream,
    4529                              GBool physLayoutA, GBool rawOrderA) {
    4530   outputFunc = func;
    4531   outputStream = stream;
    4532   needClose = gFalse;
    4533   physLayout = physLayoutA;
    4534   rawOrder = rawOrderA;
    4535   doHTML = gFalse;
    4536   text = new TextPage(rawOrderA);
    4537   ok = gTrue;
    4538   actualTextBMCLevel = 0;
    4539 }
    4540 
    4541 TextOutputDev::~TextOutputDev() {
    4542   if (needClose) {
    4543 #ifdef MACOS
    4544     ICS_MapRefNumAndAssign((short)((FILE *)outputStream)->handle);
    4545 #endif
    4546     fclose((FILE *)outputStream);
    4547   }
    4548   if (text) {
    4549     delete text;
    4550   }
    4551 }
    4552 
    4553 void TextOutputDev::startPage(int pageNum, GfxState *state) {
    4554   text->startPage(state);
    4555 }
    4556 
    4557 void TextOutputDev::endPage() {
    4558   text->endPage();
    4559   text->coalesce(physLayout, doHTML);
    4560   if (outputStream) {
    4561     text->dump(outputStream, outputFunc, physLayout);
    4562   }
    4563 }
    4564 
    4565 void TextOutputDev::updateFont(GfxState *state) {
    4566   text->updateFont(state);
    4567 }
    4568 
    4569 void TextOutputDev::beginString(GfxState *state, GooString *s) {
    4570 }
    4571 
    4572 void TextOutputDev::endString(GfxState *state) {
    4573 }
    4574 
    4575 void TextOutputDev::drawChar(GfxState *state, double x, double y,
    4576                              double dx, double dy,
    4577                              double originX, double originY,
    4578                              CharCode c, int nBytes, Unicode *u, int uLen) {
     4511ActualText::~ActualText() {
     4512  if (actualText)
     4513    delete actualText;
     4514  text->decRefCnt();
     4515}
     4516
     4517void ActualText::addChar(GfxState *state, double x, double y,
     4518                         double dx, double dy,
     4519                         CharCode c, int nBytes, Unicode *u, int uLen) {
    45794520  if (actualTextBMCLevel == 0) {
    45804521    text->addChar(state, x, y, dx, dy, c, nBytes, u, uLen);
     
    46004541}
    46014542
    4602 void TextOutputDev::beginMarkedContent(char *name, Dict *properties)
    4603 {
    4604   Object obj;
    4605 
     4543void ActualText::beginMC(Dict *properties) {
    46064544  if (actualTextBMCLevel > 0) {
    46074545    // Already inside a ActualText span.
     
    46104548  }
    46114549
     4550  Object obj;
    46124551  if (properties->lookup("ActualText", &obj)) {
    46134552    if (obj.isString()) {
     
    46194558}
    46204559
    4621 void TextOutputDev::endMarkedContent(GfxState *state)
    4622 {
     4560void ActualText::endMC(GfxState *state) {
    46234561  char *uniString = NULL;
    46244562  Unicode *uni;
     
    46584596      uni = new Unicode[length];
    46594597      for (i = 0 ; i < length; i++)
    4660         uni[i] = (uniString[2 + i*2]<<8) + uniString[2 + i*2+1];
     4598        uni[i] = ((uniString[2 + i*2] & 0xff)<<8)|(uniString[3 + i*2] & 0xff);
    46614599
    46624600      text->addChar(state,
     
    46694607        delete [] uniString;
    46704608      delete actualText;
    4671     }
    4672   }
     4609      actualText = NULL;
     4610    }
     4611  }
     4612}
     4613
     4614//------------------------------------------------------------------------
     4615// TextOutputDev
     4616//------------------------------------------------------------------------
     4617
     4618static void TextOutputDev_outputToFile(void *stream, char *text, int len) {
     4619  fwrite(text, 1, len, (FILE *)stream);
     4620}
     4621
     4622TextOutputDev::TextOutputDev(char *fileName, GBool physLayoutA,
     4623                             GBool rawOrderA, GBool append) {
     4624  text = NULL;
     4625  physLayout = physLayoutA;
     4626  rawOrder = rawOrderA;
     4627  doHTML = gFalse;
     4628  ok = gTrue;
     4629
     4630  // open file
     4631  needClose = gFalse;
     4632  if (fileName) {
     4633    if (!strcmp(fileName, "-")) {
     4634      outputStream = stdout;
     4635#ifdef _WIN32
     4636      // keep DOS from munging the end-of-line characters
     4637      setmode(fileno(stdout), O_BINARY);
     4638#endif
     4639    } else if ((outputStream = fopen(fileName, append ? "ab" : "wb"))) {
     4640      needClose = gTrue;
     4641    } else {
     4642      error(-1, "Couldn't open text file '%s'", fileName);
     4643      ok = gFalse;
     4644      return;
     4645    }
     4646    outputFunc = &TextOutputDev_outputToFile;
     4647  } else {
     4648    outputStream = NULL;
     4649  }
     4650
     4651  // set up text object
     4652  text = new TextPage(rawOrderA);
     4653  actualText = new ActualText(text);
     4654}
     4655
     4656TextOutputDev::TextOutputDev(TextOutputFunc func, void *stream,
     4657                             GBool physLayoutA, GBool rawOrderA) {
     4658  outputFunc = func;
     4659  outputStream = stream;
     4660  needClose = gFalse;
     4661  physLayout = physLayoutA;
     4662  rawOrder = rawOrderA;
     4663  doHTML = gFalse;
     4664  text = new TextPage(rawOrderA);
     4665  actualText = new ActualText(text);
     4666  ok = gTrue;
     4667}
     4668
     4669TextOutputDev::~TextOutputDev() {
     4670  if (needClose) {
     4671#ifdef MACOS
     4672    ICS_MapRefNumAndAssign((short)((FILE *)outputStream)->handle);
     4673#endif
     4674    fclose((FILE *)outputStream);
     4675  }
     4676  if (text) {
     4677    text->decRefCnt();
     4678  }
     4679  delete actualText;
     4680}
     4681
     4682void TextOutputDev::startPage(int pageNum, GfxState *state) {
     4683  text->startPage(state);
     4684}
     4685
     4686void TextOutputDev::endPage() {
     4687  text->endPage();
     4688  text->coalesce(physLayout, doHTML);
     4689  if (outputStream) {
     4690    text->dump(outputStream, outputFunc, physLayout);
     4691  }
     4692}
     4693
     4694void TextOutputDev::updateFont(GfxState *state) {
     4695  text->updateFont(state);
     4696}
     4697
     4698void TextOutputDev::beginString(GfxState *state, GooString *s) {
     4699}
     4700
     4701void TextOutputDev::endString(GfxState *state) {
     4702}
     4703
     4704void TextOutputDev::drawChar(GfxState *state, double x, double y,
     4705                             double dx, double dy,
     4706                             double originX, double originY,
     4707                             CharCode c, int nBytes, Unicode *u, int uLen) {
     4708  actualText->addChar(state, x, y, dx, dy, c, nBytes, u, uLen);
     4709}
     4710
     4711void TextOutputDev::beginMarkedContent(char *name, Dict *properties)
     4712{
     4713  actualText->beginMC(properties);
     4714}
     4715
     4716void TextOutputDev::endMarkedContent(GfxState *state)
     4717{
     4718  actualText->endMC(state);
    46734719}
    46744720
Note: See TracChangeset for help on using the changeset viewer.