コード例 #1
0
ファイル: Bookmark.cpp プロジェクト: AmirAbrams/haiku
void Bookmark::CreateBookmarks() {
	char optList[256];
	fOutlines.SortItems(AscendingByStart);

	for (int i = 0; i < fOutlines.CountItems(); i++) {
		BString ucs2;

		Outline* o = fOutlines.ItemAt(i);		
		REPORT(kInfo, fWriter->fPage, "Bookmark '%s' at level %d", o->Text(), o->Level());

		sprintf(optList, "type=fixed left=%f top=%f", o->Start().x, o->Start().y + o->Height());
		PDF_set_parameter(fWriter->fPdf, "bookmarkdest", optList);
		
		fWriter->ToPDFUnicode(o->Text(), ucs2);

		int open = o->Expanded() ? 1 : 0;
		int bookmark = PDF_add_bookmark(fWriter->fPdf, ucs2.String(), fLevels[o->Level()-1], open);
		
		if (bookmark < 0) bookmark = 0;
		
		for (int i = o->Level(); i < kMaxBookmarkLevels; i ++) {
			fLevels[i] = bookmark;
		} 
	}
	// reset to default
	PDF_set_parameter(fWriter->fPdf, "bookmarkdest", "type=fitwindow");

	fOutlines.MakeEmpty();
}
コード例 #2
0
XojPopplerIter * XojPopplerDocument::getContentsIter() {
	XOJ_CHECK_TYPE(XojPopplerDocument);

	if (this->data == NULL) {
		return NULL;
	}

	Outline * outline = this->data->doc->getOutline();
	if (outline == NULL) {
		return NULL;
	}

	GooList *items = outline->getItems();
	if (items == NULL) {
		return NULL;
	}

	return new XojPopplerIter(*this, items);
}
コード例 #3
0
Ecore_List *
epdf_index_new (const Epdf_Document *document)
{
  Outline    *outline;
  GooList    *gitems;
  Ecore_List *index = NULL;

  if (!document)
    return index;

  outline = document->pdfdoc->getOutline ();
  if (outline == NULL)
    return index;

  gitems = outline->getItems ();
  if (gitems == NULL)
    return index;

  index = ecore_list_new ();
  epdf_index_fill (index, gitems);

  return index;
}
コード例 #4
0
ファイル: main.cpp プロジェクト: pocketbook-free/pdfviewer
int main(int argc, char** argv)
{
        argc_main = argc;
        argv_main = argv;
	SplashColor paperColor;
	GooString* filename, *password;
	char* spwd;
	FILE* f = NULL;
	bookinfo* bi;
	char buf[1024];
	int i;

	mkdir(CACHEDIR, 0777);
	chmod(CACHEDIR, 0777);

	spwd = GetDeviceKey();

	if (setgid(102) != 0) fprintf(stderr, "warning: cannot set gid\n");
	if (setuid(102) != 0) fprintf(stderr, "warning: cannot set uid\n");

	if (spwd)
	{
		//fprintf(stderr, "password: %s\n", spwd);
		password = new GooString(spwd);
	}
	else
	{
		fprintf(stderr, "warning: cannot read password\n");
		password = NULL;
	}

	OpenScreen();

	signal(SIGFPE, sigfpe_handler);
	signal(SIGSEGV, sigsegv_handler);

	clock_left = GetThemeInt("panel.clockleft", 0);
	bmk_flag = GetResource("bmk_flag", NULL);

	if (argc < 2)
	{
		Message(ICON_WARNING, "PDF Viewer", "@Cant_open_file", 2000);
		return 0;
	}

	OriginalName = FileName = argv[1];
	bi = GetBookInfo(FileName);
	if (bi->title) book_title = strdup(bi->title);

	// read config file
	globalParams = new GlobalParams();

	globalParams->setEnableFreeType("yes");
	globalParams->setAntialias((char*)(ivstate.antialiasing ? "yes" : "no"));
	globalParams->setVectorAntialias("no");

	filename = new GooString(FileName);
	doc = new PDFDoc(filename, NULL, NULL);
	if (!doc->isOk())
	{
		int err = doc->getErrorCode();
		delete doc;
		if (err == 4)   // encrypted file
		{
			filename = new GooString(FileName);
			doc = new PDFDoc(filename, NULL, password);
			if (!doc->isOk())
			{
				delete doc;
				spwd = query_password();
				password = new GooString(spwd);
				filename = new GooString(FileName);
				doc = new PDFDoc(filename, NULL, password);
				if (!doc->isOk())
				{
					Message(ICON_WARNING, "PDF Viewer", "@Cant_open_file", 2000);
					return 0;
				}
			}
		}
		else
		{
			Message(ICON_WARNING, "PDF Viewer", "@Cant_open_file", 2000);
			return 0;
		}
	}

	npages = doc->getNumPages();
	paperColor[0] = 255;
	paperColor[1] = 255;
	paperColor[2] = 255;
	splashOut = new MySplashOutputDev(USE4 ? splashModeMono4 : splashModeMono8, 4, gFalse, paperColor);
	splashOut->startDoc(doc->getXRef());

	Outline* outline = doc->getOutline();
	if (outline && outline->getItems())
	{

		GooList* items = outline->getItems();
		if (items->getLength() == 1)
		{
			OutlineItem* first = (OutlineItem*)items->get(0);
			first->open();
			items = first->getKids();
			update_toc(items, 0);
			first->close();
		}
		else if (items->getLength() > 1)
		{
			update_toc(items, 0);
		}

	}

	DataFile = GetAssociatedFile(FileName, 0);
	f = fopen(DataFile, "rb");
	if (f == NULL || fread(&docstate, 1, sizeof(tdocstate), f) != sizeof(tdocstate) || docstate.magic != 0x9751)
	{
		docstate.magic = 0x9751;
		docstate.page = 1;
		docstate.offx = 0;
		docstate.offy = 0;
		docstate.scale = 100;
		docstate.rscale = 150;
		docstate.orient = 0;
		docstate.nbmk = 0;
	}
	if (f != NULL) fclose(f);

	cpage = docstate.page;
	subpage = docstate.subpage;
	offx = docstate.offx;
	offy = docstate.offy;
	if (docstate.scale == 0)
	{
		scale = get_fit_scale();
		ScaleZoomType = ZoomTypeFitWidth;
	}
	else
	{
		scale = docstate.scale;
	}
	rscale = docstate.rscale;
	reflow_mode = (docstate.orient & 0x80) ? 1 : 0;

	gcfg = GetGlobalConfig();
//	ko = ReadInt(gcfg, "keeporient", 0);
	ko = -1;
	if (GetGlobalOrientation() == -1 || ko == 0)
	{
		orient = GetOrientation();
	}
	else
	{
		orient = docstate.orient & 0x7f;
		SetOrientation(orient);
	}

	if (argc >= 3)
	{
		if (argv[2][0] == '=')
		{
#ifdef USESYNOPSIS
			long long position;
			TSynopsisItem::PositionToLong(argv[2] + 1, &position);
			cpage = position_to_page(position >> 40);
#else
//			cpage = atoi(position_to_page(argv[2] + 1));
			cpage = atoi(argv[2] + 1);
#endif
		}
		else
		{