コード例 #1
0
ファイル: Outline.cpp プロジェクト: DineshIT/android-pdf
OutlineItem::OutlineItem(Dict *dict, XRef *xrefA) {
  Object obj1;
  GooString *s;
  int i;

  xref = xrefA;
  title = NULL;
  action = NULL;
  kids = NULL;

  if (dict->lookup("Title", &obj1)->isString()) {
    s = obj1.getString();
    if ((s->getChar(0) & 0xff) == 0xfe &&
	(s->getChar(1) & 0xff) == 0xff) {
      titleLen = (s->getLength() - 2) / 2;
      title = (Unicode *)gmallocn(titleLen, sizeof(Unicode));
      for (i = 0; i < titleLen; ++i) {
	title[i] = ((s->getChar(2 + 2*i) & 0xff) << 8) |
	           (s->getChar(3 + 2*i) & 0xff);
      }
    } else {
      titleLen = s->getLength();
      title = (Unicode *)gmallocn(titleLen, sizeof(Unicode));
      for (i = 0; i < titleLen; ++i) {
	title[i] = pdfDocEncoding[s->getChar(i) & 0xff];
      }
    }
  } else {
    titleLen = 0;
  }
  obj1.free();

  if (!dict->lookup("Dest", &obj1)->isNull()) {
    action = LinkAction::parseDest(&obj1);
  } else {
      obj1.free();
    if (!dict->lookup("A", &obj1)->isNull()) {
        action = LinkAction::parseAction(&obj1);
  }
  }
  obj1.free();

  dict->lookupNF("First", &firstRef);
  dict->lookupNF("Last", &lastRef);
  dict->lookupNF("Next", &nextRef);

  startsOpen = gFalse;
  if (dict->lookup("Count", &obj1)->isInt()) {
    if (obj1.getInt() > 0) {
      startsOpen = gTrue;
    }
  }
  obj1.free();
}
コード例 #2
0
Eina_List *
epdf_page_text_find (const Epdf_Page *page,
                     const char      *text,
                     unsigned char    is_case_sensitive)
{
    Epdf_Rectangle *match;
    TextOutputDev  *output_dev;
    Eina_List      *matches = NULL;
    double          xMin, yMin, xMax, yMax;
    int             length;
    int             height;


    if (!page || !text)
        return NULL;

    GooString tmp (text);
    Unicode *s;

    {
        length = tmp.getLength();
        s = (Unicode *)gmallocn(length, sizeof(Unicode));
        bool anyNonEncoded = false;
        for (int j = 0; j < length && !anyNonEncoded; ++j) {
            s[j] = pdfDocEncoding[tmp.getChar(j) & 0xff];
            if (!s[j]) anyNonEncoded = true;
        }
        if ( anyNonEncoded )
        {
            for (int j = 0; j < length; ++j) {
                s[j] = tmp.getChar(j);
            }
        }
    }

    length = strlen (text);

    output_dev = new TextOutputDev (NULL, 1, 0, 0);

    epdf_page_size_get (page, NULL, &height);
    page->page->display (output_dev, 72, 72, 0, false,
                         true, false,
                         page->doc->pdfdoc->getCatalog());

    xMin = 0;
    yMin = 0;
#warning you probably want to add backwards as parameters
    while (output_dev->findText (s, tmp.getLength (),
                                 0, 1, // startAtTop, stopAtBottom
                                 1, 0, // startAtLast, stopAtLast
                                 is_case_sensitive, 0, // caseSensitive, backwards
                                 &xMin, &yMin, &xMax, &yMax)) {
        match = (Epdf_Rectangle *)malloc (sizeof (Epdf_Rectangle));
        match->x1 = xMin;
        match->y1 = yMin;//height - yMax;
        match->x2 = xMax;
        match->y2 = yMax;//height - yMin;
        matches = eina_list_append (matches, match);
    }

    delete output_dev;

    return matches;
}