diff --git a/src/lua/publisher.lua b/src/lua/publisher.lua index 1d4653f8..588f8713 100644 --- a/src/lua/publisher.lua +++ b/src/lua/publisher.lua @@ -929,7 +929,7 @@ function get_colentry_from_name(colorname, default) if colorname then if not colors[colorname] then if default then - err("Color %q is not defined yet.",colorname) + splib.error("Color is not defined yet","name",colorname) else colentry = nil end @@ -2209,7 +2209,7 @@ function shipout(nodelist, pagenumber,dataxml) } if colorname then if not colors[colorname] then - err("Pagetype / defaultcolor: color %q is not defined yet.",colorname) + splib.error("Pagetype / defaultcolor: color is not defined yet.","name",colorname) else local colorindex = colors[colorname].index nodelist = set_color_if_necessary(nodelist,colorindex) @@ -3059,11 +3059,15 @@ function bgtext( box, textstring, angle, colorname, fontfamily, bgsize) end --- Draw a background behind the rectangular (box) object. -function background( box, colorname ) +function background( box, colorname,origin ) -- color '-' means 'no color' if colorname == "-" then return box end if not colors[colorname] then - warning("Background: Color %q is not defined",colorname) + if origin then + splib.log("warn","Background: color is not defined","name",colorname,"from",origin) + else + splib.log("warn","Background: color is not defined","name",colorname) + end return box end local colentry = colors[colorname] @@ -3125,7 +3129,7 @@ function frame(obj) local colentry = get_colentry_from_name(obj.colorname,"black") if not colentry then - err("Color %q is not defined",tostring(obj.colorname)) + splib.error("Color is not defined","name",tostring(obj.colorname)) colentry = colors["black"] end local pdfcolorstring = colentry.pdfstring @@ -4147,7 +4151,7 @@ function dothingsbeforeoutput( thispage,data ) if options.background and options.background ~= '-' then local colentry = get_colentry_from_name(options.background,"white") if not colentry then - err("Color %q is not defined",tostring(options.background)) + splib.error("Color is not defined","name",tostring(options.backgroun)) colentry = colors["white"] end local pdfcolorstring = colentry.pdfstring @@ -7211,7 +7215,7 @@ function get_languagecode( locale_or_name ) end function set_mainlanguage( mainlanguage ) - log("Setting default language to %q",mainlanguage or "?") + splib.log("info","Setting default language","lang",mainlanguage or "?") defaultlanguage = get_languagecode(mainlanguage) end @@ -7315,7 +7319,12 @@ function next_row(rownumber,areaname,rows,dataxml) end local current_row - current_row = grid:find_suitable_row(1,grid:number_of_columns(areaname),rows,areaname) + local noc = grid:number_of_columns(areaname) + if noc == nil then + splib.error("number of columns is not set for area","area",areaname) + return + end + current_row = grid:find_suitable_row(1,noc,rows,areaname) if not current_row then next_area(areaname,nil, dataxml) setup_page(nil,"next_row",dataxml) diff --git a/src/lua/publisher/commands.lua b/src/lua/publisher/commands.lua index a1443da0..0de3c059 100644 --- a/src/lua/publisher/commands.lua +++ b/src/lua/publisher/commands.lua @@ -3517,7 +3517,7 @@ function commands.place_object( layoutxml,dataxml) if background == "full" or css_rules["background-color"] then - object = publisher.background(object,backgroundcolor or css_rules["background-color"]) + object = publisher.background(object,backgroundcolor or css_rules["background-color"],"PlaceObject") end if frame == "solid" then framewidth = rulewidth_sp @@ -3790,6 +3790,20 @@ function commands.positioning_frame( layoutxml, dataxml ) local row = publisher.read_attribute(layoutxml,dataxml,"row" ,"number") local width = publisher.read_attribute(layoutxml,dataxml,"width","number") local height = publisher.read_attribute(layoutxml,dataxml,"height" ,"number") + if row == nil or column == nil or width == nil or height == nil then + if not row then + splib.error("row not set in PositioningFrame") + end + if not column then + splib.error("column not set in PositioningFrame") + end + if not width then + splib.error("width not set in PositioningFrame") + end + if not height then + splib.error("height not set in PositioningFrame") + end + end return { column = column, row = row, @@ -5100,7 +5114,7 @@ function commands.text(layoutxml,dataxml) local colorindex if colorname then if not publisher.colors[colorname] then - err("Color %q is not defined.",colorname) + splib.error("Color is not defined","name",tostring(colorname)) else colorindex = publisher.colors[colorname].index end @@ -5287,7 +5301,7 @@ function commands.textblock( layoutxml,dataxml ) local colorindex if colorname then if not publisher.colors[colorname] then - err("Color %q is not defined.",colorname) + splib.error("Color is not defined","name",tostring(colorname)) else colorindex = publisher.colors[colorname].index end diff --git a/src/lua/publisher/grid.lua b/src/lua/publisher/grid.lua index c9ae012a..c69447ed 100644 --- a/src/lua/publisher/grid.lua +++ b/src/lua/publisher/grid.lua @@ -763,11 +763,13 @@ function draw_grid(self) pdfcolorstring = " 1 0 0 RG " end for _,frame in ipairs(area) do - x = sp_to_bp(( frame.column - 1) * ( self.gridwidth + self.grid_dx) + self.extra_margin + self.margin_left) - y = sp_to_bp(( frame.row - 1) * ( self.gridheight + self.grid_dy) + self.margin_top ) - width = sp_to_bp(frame.width * self.gridwidth + (frame.width - 1) * self.grid_dx) - height = sp_to_bp(frame.height * self.gridheight + (frame.height - 1) * self.grid_dy) - ret[#ret + 1] = string.format("q %s %g w %g %g %g %g re S Q", pdfcolorstring,0.5, x,math.round(paperheight_bp - y,2),width,-height) + if frame.width and frame.height then + x = sp_to_bp(( frame.column - 1) * ( self.gridwidth + self.grid_dx) + self.extra_margin + self.margin_left) + y = sp_to_bp(( frame.row - 1) * ( self.gridheight + self.grid_dy) + self.margin_top ) + width = sp_to_bp(frame.width * self.gridwidth + (frame.width - 1) * self.grid_dx) + height = sp_to_bp(frame.height * self.gridheight + (frame.height - 1) * self.grid_dy) + ret[#ret + 1] = string.format("q %s %g w %g %g %g %g re S Q", pdfcolorstring,0.5, x,math.round(paperheight_bp - y,2),width,-height) + end end end ret[#ret + 1] = "Q"