fix cannot get word box in last page of a chapter

pull/682/head
chrox 10 years ago
parent 248b7c99e6
commit fd1bb86514

@ -137,18 +137,27 @@ end
function CreDocument:getWordFromPosition(pos) function CreDocument:getWordFromPosition(pos)
local word_box = self._document:getWordFromPosition(pos.x, pos.y) local word_box = self._document:getWordFromPosition(pos.x, pos.y)
DEBUG("CreDocument: get word box", word_box)
local text_range = self._document:getTextFromPositions(pos.x, pos.y, pos.x, pos.y) local text_range = self._document:getTextFromPositions(pos.x, pos.y, pos.x, pos.y)
DEBUG("CreDocument: get text range", text_range)
local wordbox = {
word = text_range.text == "" and word_box.word or text_range.text,
page = self._document:getCurrentPage(),
}
if word_box.word then if word_box.word then
return { wordbox.sbox = Geom:new{
word = text_range.text == "" and word_box.word or text_range.text, x = word_box.x0, y = word_box.y0,
page = self._document:getCurrentPage(), w = word_box.x1 - word_box.x0,
sbox = Geom:new{ h = word_box.y1 - word_box.y0,
x = word_box.x0, y = word_box.y0, }
w = word_box.x1 - word_box.x0, else
h = word_box.y1 - word_box.y0, -- dummy word box
} wordbox.sbox = Geom:new{
x = pos.x, y = pos.y,
w = 20, h = 20,
} }
end end
return wordbox
end end
function CreDocument:getTextFromPositions(pos0, pos1) function CreDocument:getTextFromPositions(pos0, pos1)

Loading…
Cancel
Save