diff options
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/lua/lepdflib.cc')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/lua/lepdflib.cc | 242 |
1 files changed, 121 insertions, 121 deletions
diff --git a/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc b/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc index b26f268feb4..00e27863a2c 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc +++ b/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc @@ -153,17 +153,17 @@ static int l_open_MemStreamPDFDoc(lua_State * L) docstream = luaL_checkstring(L, 1); // stream as Lua string break; case LUA_TLIGHTUSERDATA: - docstream = (const char *) lua_touserdata(L, 1); // stream as sequence of bytes + docstream = (const char *) lua_touserdata(L, 1); // stream as sequence of bytes break; default: - luaL_error(L, "bad argument: string or lightuserdata expected"); + luaL_error(L, "bad argument: string or lightuserdata expected"); } - if (docstream==NULL) - luaL_error(L, "bad document"); + if (docstream==NULL) + luaL_error(L, "bad document"); stream_size = (unsigned long long) luaL_checkint(L, 2);// size of the stream file_id = luaL_checkstring(L, 3); // a symbolic name for this stream, mandatory if (file_id == NULL) - luaL_error(L, "PDFDoc has an invalid id"); + luaL_error(L, "PDFDoc has an invalid id"); if (strlen(file_id) >STREAM_FILE_ID_LEN ) // a limit to the length of the string luaL_error(L, "PDFDoc has a too long id"); docstream_usr = (char *)gmalloc((unsigned) (stream_size + 1)); @@ -183,7 +183,7 @@ static int l_open_MemStreamPDFDoc(lua_State * L) lua_pushnil(L); } else { - if (!(globalParams)) // globalParams could be already created + if (!(globalParams)) // globalParams could be already created globalParams = new GlobalParams(); uout = new_PDFDoc_userdata(L); uout->d = d; @@ -243,20 +243,20 @@ static int l_new_Attribute(lua_State * L) uout->pc = uobj->pc; uout->pd = uobj->pd; } else - lua_pushnil(L); + lua_pushnil(L); return 1; } #define ATTRIBUTE_TYPE_ENTRY(name) \ lua_pushstring(L, #name); \ lua_pushinteger(L, Attribute::name); \ - lua_settable(L,-3) + lua_settable(L,-3) #define STRUCTELEMENT_TYPE_ENTRY(name) \ lua_pushstring(L, #name); \ lua_pushinteger(L, StructElement::name); \ - lua_settable(L,-3) + lua_settable(L,-3) static int l_Attribute_Type(lua_State * L) { @@ -308,74 +308,74 @@ static int l_Attribute_Type(lua_State * L) { static int l_StructElement_Type(lua_State * L) { lua_createtable (L, 0, 50); - STRUCTELEMENT_TYPE_ENTRY(Document); - STRUCTELEMENT_TYPE_ENTRY(Part); - STRUCTELEMENT_TYPE_ENTRY(Art); - STRUCTELEMENT_TYPE_ENTRY(Sect); - STRUCTELEMENT_TYPE_ENTRY(Div); - STRUCTELEMENT_TYPE_ENTRY(BlockQuote); - STRUCTELEMENT_TYPE_ENTRY(Caption); - STRUCTELEMENT_TYPE_ENTRY(NonStruct); - STRUCTELEMENT_TYPE_ENTRY(Index); - STRUCTELEMENT_TYPE_ENTRY(Private); - STRUCTELEMENT_TYPE_ENTRY(Span); - STRUCTELEMENT_TYPE_ENTRY(Quote); - STRUCTELEMENT_TYPE_ENTRY(Note); - STRUCTELEMENT_TYPE_ENTRY(Reference); - STRUCTELEMENT_TYPE_ENTRY(BibEntry); - STRUCTELEMENT_TYPE_ENTRY(Code); - STRUCTELEMENT_TYPE_ENTRY(Link); - STRUCTELEMENT_TYPE_ENTRY(Annot); - STRUCTELEMENT_TYPE_ENTRY(Ruby); - STRUCTELEMENT_TYPE_ENTRY(RB); - STRUCTELEMENT_TYPE_ENTRY(RT); - STRUCTELEMENT_TYPE_ENTRY(RP); - STRUCTELEMENT_TYPE_ENTRY(Warichu); - STRUCTELEMENT_TYPE_ENTRY(WT); - STRUCTELEMENT_TYPE_ENTRY(WP); - STRUCTELEMENT_TYPE_ENTRY(P); - STRUCTELEMENT_TYPE_ENTRY(H); - STRUCTELEMENT_TYPE_ENTRY(H1); - STRUCTELEMENT_TYPE_ENTRY(H2); - STRUCTELEMENT_TYPE_ENTRY(H3); - STRUCTELEMENT_TYPE_ENTRY(H4); - STRUCTELEMENT_TYPE_ENTRY(H5); - STRUCTELEMENT_TYPE_ENTRY(H6); - STRUCTELEMENT_TYPE_ENTRY(L); - STRUCTELEMENT_TYPE_ENTRY(LI); - STRUCTELEMENT_TYPE_ENTRY(Lbl); - STRUCTELEMENT_TYPE_ENTRY(LBody); - STRUCTELEMENT_TYPE_ENTRY(Table); - STRUCTELEMENT_TYPE_ENTRY(TR); - STRUCTELEMENT_TYPE_ENTRY(TH); - STRUCTELEMENT_TYPE_ENTRY(TD); - STRUCTELEMENT_TYPE_ENTRY(THead); - STRUCTELEMENT_TYPE_ENTRY(TFoot); - STRUCTELEMENT_TYPE_ENTRY(TBody); - STRUCTELEMENT_TYPE_ENTRY(Figure); - STRUCTELEMENT_TYPE_ENTRY(Formula); - STRUCTELEMENT_TYPE_ENTRY(Form); - STRUCTELEMENT_TYPE_ENTRY(TOC); - STRUCTELEMENT_TYPE_ENTRY(TOCI); + STRUCTELEMENT_TYPE_ENTRY(Document); + STRUCTELEMENT_TYPE_ENTRY(Part); + STRUCTELEMENT_TYPE_ENTRY(Art); + STRUCTELEMENT_TYPE_ENTRY(Sect); + STRUCTELEMENT_TYPE_ENTRY(Div); + STRUCTELEMENT_TYPE_ENTRY(BlockQuote); + STRUCTELEMENT_TYPE_ENTRY(Caption); + STRUCTELEMENT_TYPE_ENTRY(NonStruct); + STRUCTELEMENT_TYPE_ENTRY(Index); + STRUCTELEMENT_TYPE_ENTRY(Private); + STRUCTELEMENT_TYPE_ENTRY(Span); + STRUCTELEMENT_TYPE_ENTRY(Quote); + STRUCTELEMENT_TYPE_ENTRY(Note); + STRUCTELEMENT_TYPE_ENTRY(Reference); + STRUCTELEMENT_TYPE_ENTRY(BibEntry); + STRUCTELEMENT_TYPE_ENTRY(Code); + STRUCTELEMENT_TYPE_ENTRY(Link); + STRUCTELEMENT_TYPE_ENTRY(Annot); + STRUCTELEMENT_TYPE_ENTRY(Ruby); + STRUCTELEMENT_TYPE_ENTRY(RB); + STRUCTELEMENT_TYPE_ENTRY(RT); + STRUCTELEMENT_TYPE_ENTRY(RP); + STRUCTELEMENT_TYPE_ENTRY(Warichu); + STRUCTELEMENT_TYPE_ENTRY(WT); + STRUCTELEMENT_TYPE_ENTRY(WP); + STRUCTELEMENT_TYPE_ENTRY(P); + STRUCTELEMENT_TYPE_ENTRY(H); + STRUCTELEMENT_TYPE_ENTRY(H1); + STRUCTELEMENT_TYPE_ENTRY(H2); + STRUCTELEMENT_TYPE_ENTRY(H3); + STRUCTELEMENT_TYPE_ENTRY(H4); + STRUCTELEMENT_TYPE_ENTRY(H5); + STRUCTELEMENT_TYPE_ENTRY(H6); + STRUCTELEMENT_TYPE_ENTRY(L); + STRUCTELEMENT_TYPE_ENTRY(LI); + STRUCTELEMENT_TYPE_ENTRY(Lbl); + STRUCTELEMENT_TYPE_ENTRY(LBody); + STRUCTELEMENT_TYPE_ENTRY(Table); + STRUCTELEMENT_TYPE_ENTRY(TR); + STRUCTELEMENT_TYPE_ENTRY(TH); + STRUCTELEMENT_TYPE_ENTRY(TD); + STRUCTELEMENT_TYPE_ENTRY(THead); + STRUCTELEMENT_TYPE_ENTRY(TFoot); + STRUCTELEMENT_TYPE_ENTRY(TBody); + STRUCTELEMENT_TYPE_ENTRY(Figure); + STRUCTELEMENT_TYPE_ENTRY(Formula); + STRUCTELEMENT_TYPE_ENTRY(Form); + STRUCTELEMENT_TYPE_ENTRY(TOC); + STRUCTELEMENT_TYPE_ENTRY(TOCI); lua_pushstring(L, "Unknown"); - lua_pushinteger(L, 0); + lua_pushinteger(L, 0); lua_settable(L,-3); return 1; } static int l_AttributeOwner_Type(lua_State * L) { lua_createtable (L, 0, 12); - lua_pushstring(L, "XML-1.00"); lua_pushinteger(L, Attribute::XML_1_00); lua_settable(L,-3); - lua_pushstring(L, "HTML-3.20"); lua_pushinteger(L, Attribute::HTML_3_20); lua_settable(L,-3); - lua_pushstring(L, "HTML-4.01"); lua_pushinteger(L, Attribute::HTML_4_01); lua_settable(L,-3); - lua_pushstring(L, "OEB-1.00"); lua_pushinteger(L, Attribute::OEB_1_00); lua_settable(L,-3); - lua_pushstring(L, "RTF-1.05"); lua_pushinteger(L, Attribute::RTF_1_05); lua_settable(L,-3); - lua_pushstring(L, "CSS-1.00"); lua_pushinteger(L, Attribute::CSS_1_00); lua_settable(L,-3); - lua_pushstring(L, "CSS-2.00"); lua_pushinteger(L, Attribute::CSS_2_00); lua_settable(L,-3); - lua_pushstring(L, "Layout"); lua_pushinteger(L, Attribute::Layout); lua_settable(L,-3); - lua_pushstring(L, "PrintField"); lua_pushinteger(L, Attribute::PrintField); lua_settable(L,-3); - lua_pushstring(L, "Table"); lua_pushinteger(L, Attribute::Table); lua_settable(L,-3); - lua_pushstring(L, "List"); lua_pushinteger(L, Attribute::List); lua_settable(L,-3); + lua_pushstring(L, "XML-1.00"); lua_pushinteger(L, Attribute::XML_1_00); lua_settable(L,-3); + lua_pushstring(L, "HTML-3.20"); lua_pushinteger(L, Attribute::HTML_3_20); lua_settable(L,-3); + lua_pushstring(L, "HTML-4.01"); lua_pushinteger(L, Attribute::HTML_4_01); lua_settable(L,-3); + lua_pushstring(L, "OEB-1.00"); lua_pushinteger(L, Attribute::OEB_1_00); lua_settable(L,-3); + lua_pushstring(L, "RTF-1.05"); lua_pushinteger(L, Attribute::RTF_1_05); lua_settable(L,-3); + lua_pushstring(L, "CSS-1.00"); lua_pushinteger(L, Attribute::CSS_1_00); lua_settable(L,-3); + lua_pushstring(L, "CSS-2.00"); lua_pushinteger(L, Attribute::CSS_2_00); lua_settable(L,-3); + lua_pushstring(L, "Layout"); lua_pushinteger(L, Attribute::Layout); lua_settable(L,-3); + lua_pushstring(L, "PrintField"); lua_pushinteger(L, Attribute::PrintField); lua_settable(L,-3); + lua_pushstring(L, "Table"); lua_pushinteger(L, Attribute::Table); lua_settable(L,-3); + lua_pushstring(L, "List"); lua_pushinteger(L, Attribute::List); lua_settable(L,-3); lua_pushstring(L, "UserProperties"); lua_pushinteger(L, Attribute::UserProperties);lua_settable(L,-3); return 1; } @@ -496,7 +496,7 @@ static int m_##in##_##function(lua_State * L) \ } #define m_poppler_get_UINT(in, function) \ -m_poppler_get_GUINT(in, function) +m_poppler_get_GUINT(in, function) @@ -509,7 +509,7 @@ static int m_##in##_##function(lua_State * L) \ if (uin->pd != NULL && uin->pd->pc != uin->pc) \ pdfdoc_changed_error(L); \ d = (double) ((in *) uin->d)->function(); \ - lua_pushnumber(L, d); \ + lua_pushnumber(L, d); /* float */ \ return 1; \ } @@ -1619,7 +1619,7 @@ static int m_Object_getInt(lua_State * L) if (uin->pd != NULL && uin->pd->pc != uin->pc) pdfdoc_changed_error(L); if (((Object *) uin->d)->isInt()) - lua_pushnumber(L, ((Object *) uin->d)->getInt()); + lua_pushinteger(L, ((Object *) uin->d)->getInt()); else lua_pushnil(L); return 1; @@ -1632,7 +1632,7 @@ static int m_Object_getReal(lua_State * L) if (uin->pd != NULL && uin->pd->pc != uin->pc) pdfdoc_changed_error(L); if (((Object *) uin->d)->isReal()) - lua_pushnumber(L, ((Object *) uin->d)->getReal()); + lua_pushnumber(L, ((Object *) uin->d)->getReal()); /* float */ else lua_pushnil(L); return 1; @@ -1645,7 +1645,7 @@ static int m_Object_getNum(lua_State * L) if (uin->pd != NULL && uin->pd->pc != uin->pc) pdfdoc_changed_error(L); if (((Object *) uin->d)->isNum()) - lua_pushnumber(L, ((Object *) uin->d)->getNum()); + lua_pushnumber(L, ((Object *) uin->d)->getNum()); /* integer or float */ else lua_pushnil(L); return 1; @@ -1798,7 +1798,7 @@ static int m_Object_arrayGetLength(lua_State * L) pdfdoc_changed_error(L); if (((Object *) uin->d)->isArray()) { len = ((Object *) uin->d)->arrayGetLength(); - lua_pushnumber(L, len); + lua_pushinteger(L, len); } else lua_pushnil(L); return 1; @@ -1877,7 +1877,7 @@ static int m_Object_dictGetLength(lua_State * L) pdfdoc_changed_error(L); if (((Object *) uin->d)->isDict()) { len = ((Object *) uin->d)->dictGetLength(); - lua_pushnumber(L, len); + lua_pushinteger(L, len); } else lua_pushnil(L); return 1; @@ -2385,7 +2385,7 @@ static int m_PDFDoc_##function(lua_State * L) \ pages = ((PdfDocument *) uin->d)->doc->getNumPages(); \ if (i > 0 && i <= pages) { \ d = (double) ((PdfDocument *) uin->d)->doc->function(i); \ - lua_pushnumber(L, d); \ + lua_pushnumber(L, d); /* float */ \ } else \ lua_pushnil(L); \ return 1; \ @@ -2618,16 +2618,16 @@ static int m_PDFRectangle__index(lua_State * L) if (strlen(s) == 2) { if (s[0] == 'x') { if (s[1] == '1') - lua_pushnumber(L, ((PDFRectangle *) uin->d)->x1); + lua_pushnumber(L, ((PDFRectangle *) uin->d)->x1); /* float */ else if (s[1] == '2') - lua_pushnumber(L, ((PDFRectangle *) uin->d)->x2); + lua_pushnumber(L, ((PDFRectangle *) uin->d)->x2); /* float */ else lua_pushnil(L); } else if (s[0] == 'y') { if (s[1] == '1') - lua_pushnumber(L, ((PDFRectangle *) uin->d)->y1); + lua_pushnumber(L, ((PDFRectangle *) uin->d)->y1); /* float */ else if (s[1] == '2') - lua_pushnumber(L, ((PDFRectangle *) uin->d)->y2); + lua_pushnumber(L, ((PDFRectangle *) uin->d)->y2); /* float */ else lua_pushnil(L); } else @@ -2792,7 +2792,7 @@ static const struct luaL_Reg Stream_m[] = { //********************************************************************** // TextSpan -m_poppler_get_GOOSTRING(TextSpan, getText); +m_poppler_get_GOOSTRING(TextSpan, getText); m_poppler__tostring(TextSpan); static const struct luaL_Reg TextSpan_m[] = { @@ -2858,7 +2858,7 @@ static int m_Attribute_getDefaultValue(lua_State * L) pdfdoc_changed_error(L); t = (Attribute::Type) luaL_checkint(L, 2); uout = new_Object_userdata(L); - uout->d = ((Attribute *)uin->d)->getDefaultValue(t) ; + uout->d = ((Attribute *)uin->d)->getDefaultValue(t) ; //uout->atype = ALLOC_LEPDF; uout->pc = uin->pc; uout->pd = uin->pd; @@ -2977,12 +2977,12 @@ m_poppler_get_INT(StructElement, getNumChildren); m_poppler_get_GUINT(StructElement,getRevision); m_poppler_get_UINT(StructElement,getNumAttributes); -m_poppler_get_GOOSTRING(StructElement, getID); -m_poppler_get_GOOSTRING(StructElement, getLanguage); -m_poppler_get_GOOSTRING(StructElement, getTitle); +m_poppler_get_GOOSTRING(StructElement, getID); +m_poppler_get_GOOSTRING(StructElement, getLanguage); +m_poppler_get_GOOSTRING(StructElement, getTitle); m_poppler_get_GOOSTRING(StructElement, getExpandedAbbr); -m_poppler_get_GOOSTRING(StructElement, getAltText); -m_poppler_get_GOOSTRING(StructElement, getActualText); +m_poppler_get_GOOSTRING(StructElement, getAltText); +m_poppler_get_GOOSTRING(StructElement, getActualText); m_poppler_get_poppler(StructElement, StructTreeRoot, getStructTreeRoot); m_poppler__tostring(StructElement); @@ -3021,7 +3021,7 @@ static int m_StructElement_getParentRef(lua_State * L) return 1; } -// Not exactly as the header: +// Not exactly as the header: // Ref = StructElement:getPageRef() // Ref is false if the C++ functione return false static int m_StructElement_getPageRef(lua_State * L) @@ -3073,17 +3073,17 @@ static int m_StructElement_setRevision(lua_State * L) static int m_StructElement_getText(lua_State * L) { GBool i; - GooString *gs; + GooString *gs; udstruct *uin; uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); if (uin->pd != NULL && uin->pd->pc != uin->pc) pdfdoc_changed_error(L); i = (GBool) lua_toboolean(L, 2); gs = ((StructElement *) uin->d)->getText(i); - if (gs != NULL) - lua_pushlstring(L, gs->getCString(), gs->getLength()); - else - lua_pushnil(L); + if (gs != NULL) + lua_pushlstring(L, gs->getCString(), gs->getLength()); + else + lua_pushnil(L); return 1; } @@ -3098,15 +3098,15 @@ static int m_StructElement_getChild(lua_State * L) pdfdoc_changed_error(L); i = (int) luaL_checkint(L, 2); c = ((StructElement *) uin->d)->getChild(i-1); - if (c != NULL) { + if (c != NULL) { uout = new_StructElement_userdata(L); uout->d = c ; //uout->atype = ALLOC_LEPDF; uout->pc = uin->pc; uout->pd = uin->pd; - } - else - lua_pushnil(L); + } + else + lua_pushnil(L); return 1; } @@ -3135,14 +3135,14 @@ static int m_StructElement_getAttribute(lua_State * L) pdfdoc_changed_error(L); i = (int) luaL_checkint(L, 2); a = ((StructElement *) uin->d)->getAttribute(i-1); - if (a != NULL) { + if (a != NULL) { uout = new_Attribute_userdata(L); uout->d = a ; uout->pc = uin->pc; uout->pd = uin->pd; - } - else - lua_pushnil(L); + } + else + lua_pushnil(L); return 1; } @@ -3177,15 +3177,15 @@ static int m_StructElement_findAttribute(lua_State * L) o = (Attribute::Owner) luaL_checkint(L,2); g = (GBool) lua_toboolean(L, 3); a = ((StructElement *) uin->d)->findAttribute(t,g,o); - + if (a!=NULL){ uout = new_Attribute_userdata(L); uout->d = new Attribute(a->getType(),a->getValue()); uout->atype = ALLOC_LEPDF; uout->pc = uin->pc; uout->pd = uin->pd; - } else - lua_pushnil(L); + } else + lua_pushnil(L); return 1; } @@ -3193,14 +3193,14 @@ static int m_StructElement_findAttribute(lua_State * L) static int m_StructElement_getTextSpans(lua_State * L) { int i ; - udstruct *uin, *uout; + udstruct *uin, *uout; uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - + if (uin->pd != NULL && uin->pd->pc != uin->pc) + pdfdoc_changed_error(L); + if ((((StructElement *) uin->d)->getTextSpans()).size()>0) { - lua_createtable (L, - (int) (((StructElement *) uin->d)->getTextSpans()).size(), + lua_createtable (L, + (int) (((StructElement *) uin->d)->getTextSpans()).size(), 0); for(i=0;i<(int) (((StructElement *) uin->d)->getTextSpans()).size(); i++){ uout = new_TextSpan_userdata(L); @@ -3209,9 +3209,9 @@ static int m_StructElement_getTextSpans(lua_State * L) uout->pc = uin->pc; uout->pd = uin->pd; lua_rawseti(L,-2,i+1); - } - } else - lua_pushnil(L); + } + } else + lua_pushnil(L); return 1; } @@ -3268,8 +3268,8 @@ static int m_StructTreeRoot_getChild(lua_State * L) unsigned int i; udstruct *uin, *uout; StructElement *child ; - StructTreeRoot *root ; - + StructTreeRoot *root ; + uin = (udstruct *) luaL_checkudata(L, 1, M_StructTreeRoot); if (uin->pd != NULL && uin->pd->pc != uin->pc) pdfdoc_changed_error(L); @@ -3291,7 +3291,7 @@ static int m_StructTreeRoot_appendChild(lua_State * L) { udstruct *uin, *uin_child; StructElement *child ; - StructTreeRoot *root ; + StructTreeRoot *root ; uin = (udstruct *) luaL_checkudata(L, 1, M_StructTreeRoot); if (uin->pd != NULL && uin->pd->pc != uin->pc) pdfdoc_changed_error(L); @@ -3310,8 +3310,8 @@ static int m_StructTreeRoot_findParentElement(lua_State * L) unsigned int i; udstruct *uin, *uout; const StructElement *parent ; - StructTreeRoot *root ; - + StructTreeRoot *root ; + uin = (udstruct *) luaL_checkudata(L, 1, M_StructTreeRoot); if (uin->pd != NULL && uin->pd->pc != uin->pc) pdfdoc_changed_error(L); @@ -3324,7 +3324,7 @@ static int m_StructTreeRoot_findParentElement(lua_State * L) uout->atype = ALLOC_LEPDF; uout->pc = uin->pc; uout->pd = uin->pd; - } else + } else lua_pushnil(L); return 1; } |