Closed pr-apes closed 1 year ago
@pgundlach,
here you have a patch for <PlaceObject vreference="middle">
:
diff -ru ../old-spp/sw/lua/publisher/commands.lua sw/lua/publisher/commands.lua
--- ../old-spp/sw/lua/publisher/commands.lua 2022-08-25 14:39:43.000000000 +0200
+++ sw/lua/publisher/commands.lua 2022-08-26 14:18:31.893119200 +0200
@@ -2716,6 +2737,8 @@
options.ht_max = areaheight
if vreference == "bottom" then
options.current_height = areaheight
+ elseif vreference == "middle" then
+ options.current_height = areaheight
else
options.current_height = math.min(current_grid:remaining_height_sp(row,area,tonumber(column)),areaheight)
end
@@ -2813,6 +2836,8 @@
local top = row + current_grid.extra_margin
if vreference == "bottom" then
top = top - object.height
+ elseif vreference == "middle" then
+ top = top - object.height / 2
end
publisher.output_absolute_position({
nodelist = object,
@@ -2840,6 +2865,8 @@
if row then
if vreference == "bottom" then
current_row = row - height_in_gridcells + 1
+ elseif vreference == "middle" then
+ current_row = row - math.round (height_in_gridcells / 2,0) + 1
else
current_row = row
end
I have just replicated what was available for hreference
.
BTW, I'm afraid that I couldn't solve the value with the condition publisher.current_group == nil
(I have just copied it).
I don't know which are the conditions there (all grid typesetting is too complex for me). This is still pending.
Just in case it helps.
Not sure about the semantics when in grid positioning. See this example:
<Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en">
<Trace grid="yes"/>
<Record element="data">
<PlaceObject row="5" vreference="middle">
<Image file="_samplea.pdf" width="4"></Image>
</PlaceObject>
</Record>
</Layout>
I am not sure if this is the expected behaviour or if the start should be at row 4.5
@pgundlach,
if grid typesetting forces the placement of every element starting in a new row or column (sorry for my poor wording, but grid is not my thing), then starting at a decimal row/column value is not an option (only integer values are allowed, if I'm getting this right).
Another question would be how the decimal values should be rounded (only .5-.9
should increase the row/column in one unit).
Just in case it might help.
@pgundlach,
just in case it might help:
<Layout xmlns="urn:speedata.de:2009/publisher/en"
xmlns:sd="urn:speedata:2009/publisher/functions/en">
<Trace grid="yes"/>
<Record element="data">
<PlaceObject column="5" hreference="center">
<Image file="_samplea.pdf" width="5"></Image>
</PlaceObject>
</Record>
</Layout>
I think grid positioning should behave following the same patterns in horizontal and in vertical centering.
Rounding values is also not considered for horizontal centering.
Just in case it might help.
I am not sure if I am happy with it. left/right and top/bottom are easy but this leads to decisions that are not intuitively "correct".
Perhaps it was a mistake to allow hreference="center". This is only good if the width of the object is a) an integer value and b) an odd number.
See this:
<Layout xmlns="urn:speedata.de:2009/publisher/en" xmlns:sd="urn:speedata:2009/publisher/functions/en">
<Trace grid="yes" />
<Pageformat height="8cm" width="8cm" />
<Record element="data">
<PlaceObject column="2" hreference="center">
<Image file="_samplea.pdf" width="1" />
</PlaceObject>
<PlaceObject column="2" hreference="center">
<Image file="_samplea.pdf" width="2" />
</PlaceObject>
<PlaceObject column="2" hreference="center">
<Image file="_samplea.pdf" width="2.5" />
</PlaceObject>
</Record>
</Layout>
I am not sure if I am happy with it. left/right and top/bottom are easy but this leads to decisions that are not intuitively "correct".
Perhaps it was a mistake to allow hreference="center". This is only good if the width of the object is a) an integer value and b) an odd number.
I have just read in https://doc.speedata.de/publisher/en/commandreference/placeobject/ about hreference
:
center
The column determines the center of the object. Works only with absolute positioning.
So, no need to extend vreference="middle"
to grid. Only for absolute positioning makes total sense (and it would be consistent with hreference="center"
.
I should read the documentation.... Thank you for the link
Will be included in the next version
Great to read that!
@pgundlach,
in some cases (also with rotation), the object needs a middle vertical reference to get properly placed.
I know I have to translate all code from ConTeXt to Publisher. So I’m closing the issue now.
Once I will need it (because I would make use of it), I’ll reopen it.
Many thanks for your help.