Issue 37213 - should not move them to topleft for which does not have (0,0) in svg:d or draw:points
Summary: should not move them to topleft for which does not have (0,0) in svg:d or dra...
Status: ACCEPTED
Alias: None
Product: Draw
Classification: Application
Component: viewing (show other issues)
Version: 680m60
Hardware: All All
: P3 Trivial with 4 votes (vote)
Target Milestone: AOO Later
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
: 37500 (view as issue list)
Depends on:
Blocks: 2497 37210
  Show dependency tree
 
Reported: 2004-11-16 03:17 UTC by wind.li
Modified: 2017-05-20 10:44 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
bugdoc (21.42 KB, application/x-compressed)
2004-11-16 03:19 UTC, wind.li
no flags Details
wordml format bug doc (2.58 KB, application/x-compressed)
2004-12-17 07:18 UTC, wind.li
no flags Details
polygon to (0,0) is only needed when we are doing exporting (1.40 KB, patch)
2005-02-16 10:05 UTC, wind.li
no flags Details | Diff
Document that changes when it is being saved again with OOoffice. The bezier path moves to the top left corner of the document during save. The document content.xml is created manually by inserting the results of a svg2draw filter operation. (7.55 KB, application/vnd.oasis.opendocument.graphics)
2005-05-22 13:30 UTC, haui
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description wind.li 2004-11-16 03:17:21 UTC
Currently, we will recalc draw:points and svg:d and reduce them values by their
bound. But unfortunately, we do not move it to correction the coordinate.
Comment 1 wind.li 2004-11-16 03:19:26 UTC
Created attachment 19350 [details]
bugdoc
Comment 2 wolframgarten 2004-11-16 07:43:06 UTC
Can you please attach a step by step desscription of what to do with your
attachment? Thanks in advance.
Comment 3 wind.li 2004-11-16 08:07:35 UTC
They are a same graphic in different format.
You can open triangle.ood derectly.
Or you can use an flat filter to import "flat format.food".
Or you can use the svg xslt filter attached to i2497 to import triangle.svg.
According to their declare, they should look like "excepted look like.png" I think.
But OOo move all shapes to the topleft of the page.
I can resolve it by remove this line:
http://so-doc.germany.sun.com:8080/lxr/source/svx/source/svdraw/svdopath.cxx?v=SRC680.m62#3322

But I think it also can be releated to this line:
http://so-doc.germany.sun.com:8080/lxr/source/svx/source/svdraw/svdopath.cxx?v=SRC680.m62#3378
Comment 4 wolframgarten 2004-11-17 14:59:32 UTC
Reassigned to Sven. Can you have a look at this please ? Thanks.
Comment 5 sven.jacobi 2004-11-17 16:19:34 UTC
Hello, I checked your triangle.oop document and find out that the shape is
positioned via svg:x and svg:y attribute at (0/0), so there is nothing wrong
with the code you mentioned.

Here an extraction of your the file:
<draw:polygon draw:style-name="gr1" svg:viewBox="29200 15600 14200 13900"
svg:x="0cm" svg:y="0cm" svg:width="14.0272cm" svg:height="13.7297cm"
draw:points="33536.480,17625.640 31209.660,27493.050 41425.720,23359.360
33536.480,17625.640 "/>

If you have any further problems, then please take a look at the specification
for the svg:path element.
Comment 6 wind.li 2004-11-18 02:16:20 UTC
I known the specification, but suppose I have a polygon like this:

<draw:polygon draw:style-name="gr1" svg:viewBox="0 0 100 100"
svg:x="0cm" svg:y="0cm" svg:width="14.0272cm" svg:height="13.7297cm"
draw:points="30,30 70,30 50,70"/>

Where the polygon should be? I suggest since we had define a viewBox, we had
better to defer to it.

Comment 7 wind.li 2004-11-19 03:04:43 UTC
To make it clean. I mean
The following two polygons should not be treat as the same one:
<draw:polygon draw:style-name="gr1" svg:viewBox="0 0 100 100"
svg:x="0cm" svg:y="0cm" svg:width="14.0272cm" svg:height="13.7297cm"
draw:points="30,30 70,30 50,70"/>
<draw:polygon draw:style-name="gr1" svg:viewBox="0 0 100 100"
svg:x="0cm" svg:y="0cm" svg:width="14.0272cm" svg:height="13.7297cm"
draw:points="0,0 40,0 20,40"/>
Comment 8 sven.jacobi 2004-11-19 11:06:27 UTC
sj->windly: Yes, you are right, in my understanding the poylgon points have to
be scaled to the ViewBox first and then to the size of the corresponding
position/shape.

Nothing of them is done yet, the size of the viewbox and also the size of the
shape does not matter, instead the points of the polygon itself makes up the
destination position/size of the shape.

To precise this, the XML export of OOo is creating a correct Polygon shape, only
the import does not pay attention to ViewBox and Size/Pos of a shape, this has
to be fixed.

(As a workaround to create polygon objects that can be read properly by the
current and future OOo versions, the Polygon points and viewBox should be in
absolute coordinates, the position and size of the shape as intended)

SJ->CL: This is a XML import propblem, can you please take over.
Comment 9 wind.li 2004-12-15 10:42:38 UTC
I will fix it in wordmlfilter01
Comment 10 wind.li 2004-12-15 10:45:49 UTC
start
Comment 11 wind.li 2004-12-15 10:46:55 UTC
.
Comment 12 wind.li 2004-12-17 07:18:36 UTC
Created attachment 20602 [details]
wordml format bug doc
Comment 13 wind.li 2004-12-17 07:22:38 UTC
The reason is that aMatrix3D is ignored here
http://so-doc.germany.sun.com:8080/lxr/source/svx/source/unodraw/unoshape.cxx?v=SRC680.m62#1669
Comment 14 wind.li 2004-12-17 07:23:00 UTC
fixed in wordmlfilter01
Comment 15 wind.li 2004-12-20 03:58:22 UTC
reopen to reassign
Comment 16 wind.li 2004-12-20 03:59:46 UTC
assign to qa
Comment 17 wind.li 2004-12-20 05:16:58 UTC
fixed in wordmlfilter01
Comment 18 jack.warchold 2005-01-03 14:12:29 UTC
seen good in cws wordmlfilter01
could not verify this against an older SO version, because we could not display this 
objects. but i verified this against ms-office and the file looks equal.
set to verified
Comment 19 jack.warchold 2005-02-02 13:34:50 UTC
seen good in src680_m76 closing ->
Comment 20 wind.li 2005-02-16 10:03:03 UTC
fixed but failr
Comment 21 wind.li 2005-02-16 10:05:54 UTC
Created attachment 22690 [details]
polygon to (0,0) is only needed when we are doing exporting
Comment 22 wind.li 2005-02-16 10:16:39 UTC
Hi,Christian
  Could you please have a look at the last patch I had attathed?
  
Thanks
Comment 23 clippka 2005-02-16 11:01:37 UTC
Armin, can you please have an in depth look into this patch?

As I understand the patch the path is now written without translation, so what
with existing files, are they imported incorrectly?

windly, do not integrate this patch without the aproval from armin and me, this
is a very delicate piece of code.

NOTE TO QA: If this bug is ever to be verified, do extensive testing of loading
and saving of shapes in all applications and with current and past xml formats!

Comment 24 wind.li 2005-02-17 03:06:46 UTC
In svx/source/svdraw/svdopath.cxx, aRect is calculated from rPolyPolygon at
runtime. And the points in rPolyPolygon are the absolute coordinates. So when
you draw a polygon,you get a point lists, such as this:
  1000,1000 2000,3000 3000,2000 then your aRect={1cm,1cm,3cm,3cm}. We cann't
save them out directly, because when save to files the points should be in
opposite coordinates defined by viewbox. So we need a
rPolyPolygon.Move(-aRectangle.Left(), -aRectangle.Top()). But currently we call
rPolyPolygon.Move in SdrPathObj::TRGetBaseGeometry which will be called at both
import and export time. The result is when you import a shape with this points
(1000,1000 2000,3000 3000,2000), you will get a (0,0 1000,2000 2000,1000), its
moved to the topleft.
In this patch I move the justify code to SvxShapePolyPolygon::getPropertyValue
which will be called only at export time. Thus we can keep the points as them
should be at import time.
Comment 25 Armin Le Grand 2005-02-25 21:55:07 UTC
AW: I will investigate.
First thing: When OOo/SO is exporting a polygon, it always creates fitting pairs
of svg:width, svg:height, svg:viewBox and draw:points. E.g. a triangle at pos
(2,2) and with width and height of (5,5) creates:
    svg:width="5cm" svg:height="5cm" 
    svg:x="2.xxcm" svg:y="2.yycm" 
    svg:viewBox="0 0 5501 5001" 
    draw:points="0,0 5500,0 0,5000"
(the xx and yy is the page offset to the page frame). So, the polygon is
unrotated, unsheared and untranslated, but scaled. The ViewBox just describes
the polygon dimensions. That's how all OOo/SO created files look.
Now for the import...
Comment 26 Armin Le Grand 2005-02-28 15:39:22 UTC
AW: Anonther save note: When saving a rotated or skewed object, the svg:x/svg:y
is left out and an draw:transform containing the translation is generated. The
svg:width/svg:height, svg:viewBox and draw:points always stays the same for the
same triangle. In principle, the svg:viewBox is not necessary for export.
AW: Now for the import, looking at the code in XMLOFF...
Comment 27 Armin Le Grand 2005-02-28 16:03:23 UTC
AW: Okay, 
- ObjectSize is inited with viewBox width/height, if svg:width/svg:height is not
zero, it will replace ObjectSize.
- ObjectPosition is inited by viewBox:x,y
- bool bScale is true, if ObjectSize != viewBox:width/height
- bool bTranslate is true, if viewBox:x,y != 0L
- xIn: point from draw:points
- xOut: point for returing pointSequence

xOut = ObjectPos.x + (((xIn - viewBox:x) * ObjectSize.width)/viewBox.width)
yOut = ObjectPos.y + (((yIn - viewBox:y) * ObjectSize.height)/viewBox.height)

That poly is the feeded to SdrPathObj::TRSetBaseGeometry.
Comment 28 Armin Le Grand 2005-02-28 16:27:25 UTC
AW: After that, a transformation is prepared with scaling of
svg:width/svg:height and translation of svg:x/svg:y (if exists). That is then
applied to the object using SdrPathObj::TRSetBaseGeometry again.

So my imression is that svg:viewBox is just used to desribe the input polygons
dimensions to allow using another svg polygon inside the draw object easily.
Let's see what the OASIS file format description says, next.
Comment 29 Armin Le Grand 2005-02-28 19:39:50 UTC
AW: Here is the excerpt from the OASIS XML file formtat OOo definiton:

The svg:viewBox attribute establishes a user coordinate system inside the
physical coordinate system of the shape specified by the position and size
attributes. This user coordinate system is used by the <draw:enhanced-path> element.
The syntax for using this attribute is the same as the [SVG] syntax. The value
of the attribute are four numbers separated by white spaces, which define the
left, top, right, and bottom dimensions of the user coordinate system.

So, when specifying a user coordinate system 'inside' the phys. coordinate
system of the shape (which is :x, :y, :width, :height) this seems to fit. This
means that the shape's pos and size is fix and not changeable by the viewBox
attribute. I will test with examples.
Comment 30 Armin Le Grand 2005-02-28 21:34:02 UTC
AW: Moving the code to SvxShapePolyPolygon::getPropertyValue is not valid. That
code is for API command to set the object transformation matrix, so there is no
way to save the current object's translation there (!). This needs to be removed
instantly.

AW: I think the core sentence is >a user coordinate system inside the physical
coordinate system of the shape specified by the position and size attributes<.
On the other hand a polygon object cannot be smaller or bigger tha it's
contained polygon. Also, the TRSet/GetBaseGeometry methods assume the transfered
polygon to be relative to the object, unrotated and unsheared.
AW: So, to set the object's transformation matrix, the correct steps are to call
TRGetBaseGeometry to get the current polygon, and then call TRSetBaseGeometry
with the new transformation and the saved geometry (the polygon).
AW: All the current definitions taken together, the svg:viewBox does not have
much sense at all. It is not intended to work like in SVG (this is not SVG). It
would be enough to read in the polygon, scale it to the object's size and make
it relative (move it to (0,0)). That's what is implied with 'embedded' user
coordinate system and the fact that object pos/size and polygon pos/size need to
be identical internally. Everey other use would no longer be an 'embedded' user
coordinate system, but change the position and size of the object, so overriding
:x, :y, :width and :height settings -> no embedding, not allowed.

AW: Maybe this should be changed, but then the definitions need to be changed,
too. At the moment the error is that the initial polygon which is set at the
object is not relative to the object (not (0,0) aligned). So this needs to be
changed.
AW: Luckily this may be changed in later versions since all written files
contain a svg:viewBox which completely describes the polygon dimensions. But i
see no chance to change the OASIS specification for SO8.
Comment 31 wind.li 2005-03-01 02:13:25 UTC
>That's what is implied with 'embedded' user
>coordinate system and the fact that object pos/size and polygon pos/size need to
>be identical internally. Everey other use would no longer be an 'embedded' user
>coordinate system, but change the position and size of the object, so overriding
>:x, :y, :width and :height settings -> no embedding, not allowed.
Could you please point me where can I find this in OASIS specification for SO8.
>But i
see no chance to change the OASIS specification for SO8.
Sorry. I could not find out where should be change in OASIS specification. The
spec just defines that users can use svg:viewBox to attribute establishes a user
coordinate system inside the physical coordinate system. It does not deny us to
use any thing in the user coordinate system. For example, we can set
svg:viewBox="100 100 200 200". I cann't any words in the OASIS specification
deny us using this. And as I know the svg:points and draw:path can use any point
s within the user coordinate system. 
But I think once we define a user coordinate system, we should respect to it.
For example, if we set svg:viewBox="0 0 100 100" then svg:points="40 40 60 40 60
60 40 60 40 40" should draw a square inside the draw element no matter what are
the values of :x, :y, :width, :height. 
I think the problem here is not the OASIS specification, but the current
implementation. It assumes that the points of the polygon is (0,0) aligned.
Comment 32 wind.li 2005-03-01 02:21:34 UTC
As you also said, the logic of viewBox should be:
xOut = ObjectPos.x + (((xIn - viewBox:x) * ObjectSize.width)/viewBox.width)
yOut = ObjectPos.y + (((yIn - viewBox:y) * ObjectSize.height)/viewBox.height)

No others.
Comment 33 Armin Le Grand 2005-03-01 16:05:09 UTC
AW: OASIS specification: OASIS Open Office XML Format Technical Committee
(http://www.oasis-open.org/committees/office/). Should be well-known now.

AW: From Your last answer:
>But I think once we define a user coordinate system, we should respect to it.
>For example, if we set svg:viewBox="0 0 100 100" then svg:points="40 40 60 40 60
>60 40 60 40 40" should draw a square inside the draw element no matter what are
>the values of :x, :y, :width, :height. 

That's exactly the question. Does 'embedded' mean:
(a) the values of :x, :y, :width, :height may be overridden from polygon
specification
(b) the values of :x, :y, :width, :height always define the shape
In my opinion, 'embedded' means (b), so at the moment there would be no way to
change object definition from 'embedded' user coordinate system. I think users
would write bugs if the polygon definition would overwrite their :x, :y, :width,
:height value definitions.

You also wrote:
>As you also said, the logic of viewBox should be:
>xOut = ObjectPos.x + (((xIn - viewBox:x) * ObjectSize.width)/viewBox.width)
>yOut = ObjectPos.y + (((yIn - viewBox:y) * ObjectSize.height)/viewBox.height)
No, i did not say it 'should be', this is an analysis of the existing code. So
it looks like it was intended to do it this way, but it's not completely
implemented at the moment. The implementation handles the polygon that way, but
does not change :x, :y, :width and :height when the polygon definition is
different from that. At the moment it does neither correct the polygon to (0,0)
alignment inside the shape.
So, for correcting this there is solution
(a) change :x, :y, :width, :height
(b) align polygon to (0,0) and object size
corresponding to (a,b) from above. I think to do (a) the OASIS specification
would NEED TO DOCUMENTATE that the embedded polygon data may change object width
and height definitions. That's not the case, so i think the fix needs to be (b)
as long as that is not mentioned/documented.
Comment 34 wind.li 2005-03-02 02:20:18 UTC
>AW: OASIS specification: OASIS Open Office XML Format Technical Committee
>(http://www.oasis-open.org/committees/office/). Should be well-known now.
Yes .I know. Thanks.

>That's exactly the question. Does 'embedded' mean:
>(a) the values of :x, :y, :width, :height may be overridden from polygon
>specification
>(b) the values of :x, :y, :width, :height always define the shape
>In my opinion, 'embedded' means (b), so at the moment there would be no way to
>change object definition from 'embedded' user coordinate system. I think users
>would write bugs if the polygon definition would overwrite their :x, :y, :width,
>:height value definitions.

1. I am not wanting to changing the object defines. In my opinion users define a
viewBox to avoid using percent. In my last example, I actually want 
svg:points="40% 40% 60% 40% 60% 60% 40% 60% 40% 40%". And please have a look at
this two polylines:
svg:points="40 40 60 40 60 60 40 60 40 40"
svg:points="0 0 40 40 60 40 60 60 40 60 40 40"
If they have the same :x, :y, :width, :height and viewBox, what do you want they
look like?
2. There is not an 'embedded' as you said defined in OASIS specification. 
3. There is not "align polygon to (0,0)" in OASIS specification. 
4. But there is "The svg:viewBox attribute establishes a user coordinate system
inside the physical coordinate system of the shape specified by the position and
size attributes." So once users define a viewBox, we should *respect* to it in
my opinion. 
5. If the objects have to be aligned to (0,0) please add it to OASIS specification. 
6. And please change the viewBox define from (left top right bottom) to (width
height) in OASIS specification. Since the objects have to aligned to (0,0), why
do we need define left and top in viewBox, they are alway 0,0!
Comment 35 wind.li 2005-03-02 02:55:08 UTC
Solution 1:
>(a) change :x, :y, :width, :height
>(b) align polygon to (0,0) and object size
There is another solution 2:
(a) keep the :x, :y, :width, :height
(b) render the polygons as user wanted

And as I know, we are talking about some thing else another then the problem we
meet here. The problem is:
When importing, we convert the points from user coordinate system to physical
coordinate system. If the polygon is not (0,0) aligned, then we:
 1. align it to (0,0)
 2. Using a Translate to compensate the change. You can find the code in
SdrPathObj::TRGetBaseGeometry in svx/source/svdraw/svdopath.cxx.
But unfortunately the step (1) effects the polygon's points list immediately,
but the translate gets lost at svx/source/unodraw/unoshape.cxx#L1646
The code is:
  pObj->TRGetBaseGeometry(aMatrix3D, aEmptyPolygon);
  aMatrix3D[0] = Point3D( aMatrix.Line1.Column1.... );
  aMatrix3D[1] = Point3D( aMatrix.Line2.Column1.... );
  aMatrix3D[2] = Point3D( aMatrix.Line3.Column1.... );
  pObj->TRSetBaseGeometry(aMatrix3D, aEmptyPolygon);
Comment 36 Armin Le Grand 2005-03-02 14:44:10 UTC
1, It's not what i want (i would prefer to let them look differently) but what
is possible here. As i described, both is possible, but (a) will OVERRIDE user's
definitions of :x :y :width and :height. Who will decide if the user used that 4
values by purpose or the viewBox?
2, embedded -> 'establishes a user coordinate system inside...'
3, also no 'this will override Your :x :y :width :height attribute'
4, Yes, this is a good argument, but is it enough to *ignore* :x :y :width
:height definitions?
5, This might be implied by 'The position attributes svg:x and svg:y specify the
x and y coordinates of the start position of the drawing shape.' and 'The
attributes svg:width and svg:height specify the width and height of the drawing
shape', see OASIS specification. It is also mentioned in the viewBox description
'Some implementations may ignore the view box attribute. The implied coordinate
system then has its origin at the left, top corner of the shape, without any
scaling relative to the shape.'.
6, Yes, itis is a description error in OASIS, but usage is width/height.

>2. Using a Translate to compensate the change.
No, this is exactly what would OVERRIDE the :x :y settings. Also, an extra scale
would be necessary, too (You do not want to have the polygons scaled to original
object size defined by :width and :height if polygon starts 4 cm right and below
:x, :y, do You?). Together this would be a scale and a translate, effectively
changing :x :y :width :height -> exactly solution (b).
The translation does not get 'lost' with TRGetBaseGeometry/TRSetBaseGeometry.
Thoise methods are core interface and are designed to exchange the
transformation and the geometry data in the form of a unrotated, unsheared,
(0,0) aligned polygon, they work as intended. The fix needs to be done where
those methods are used to feed them what is intended.
So back to the problem: What is intended? I repeat the possibilities:

(a) change :x, :y, :width, :height -> polygon will define new :x :y :width and
:height if different from given ones
disadvantages: user's definitions of :x, :y, :width, :height will be *ignored*
advantages: free polygon definitions which may leave the embedded user
coordinate system

(b) align polygon to (0,0) and object size -> polygon will be scaled to :width
:height, translated to (0,0) and set at the object
disadvantages: svg:viewBox would have the only meaning to be able to define the
polygon using another coordinate system (maybe handy when copying from svg
files), advantages: user's definitions of :x, :y, :width, :height will be kept

With both systems You can import whatever You want: With (a) You simply use
svg:viewBox and thge path data, with (b) you will also need to adjust :x :y
:width and :height. Since You can do every polygon import with both methods,
this applies no restrictions in that area. This means the decision what to do
does not depend on that argument.

So the most important argument in my opinion is that user's definitions of :x,
:y, :width, :height may be *overriden* ro *ignored* -> i think solution (b)
should be used.
Comment 37 Armin Le Grand 2005-03-02 17:24:37 UTC
AW: I discussed with CL, and his interpretation of the usage of svg:viewBox is
that it is there to support user coordinate systems by hiding the measurement
system from the polygon definition (like in svg). All 4 values of x,y,width and
height may be in different measurement units, so that's where the viewBox comes
into play. It allows to define the polygon data itself without measurement
units. In svg, it also clips the polygon data, but we cannot do that in OOo/SO.
This still opens the problem when the viewBox range is not fully used, e.g.
viweBox(0,0,100,100) and a line (50,50 100,100). Since the draw object has to be
the same size as the polygon data, this may make a modification of the object
psoition and size valid.
When the polygon data is overlapping the viewBox range, clipping would be
necessary to do it like svg. Since we cannot do display clipping here, it would
be geometric clipping -> changes polygon definition and produces edges at the
object bounds. Also not good.
So, maybe for all involved stuff, (a) maybe indeed best.
Comment 38 Armin Le Grand 2005-03-10 13:56:28 UTC
AW: Set to PP1
Comment 39 Armin Le Grand 2005-03-23 10:18:37 UTC
*** Issue 37500 has been marked as a duplicate of this issue. ***
Comment 40 haui 2005-05-22 13:25:31 UTC
Is this a problem during import or export? I created (by fiddling around with
the svg2draw filter) a perfectly looking draw document (after being loaded) that
is corrupted when saved again with OOoffice (1.9m100).

The "perfectly looking" is relative, because when clicking on the bezier path in
the middle (I'll attach the document), the handle point that denote the selected
object are outside the bounds of the path elements. Such graphics object cannot
be created within OOoffice itself. 

What's going on during save is some sort of (broken) normalization process. The
result of it is the bezier path being moved with its left upper bounds to the
top left of the document.

The summary of this issue is not much helpful for helping to find it -- before
reporting a duplicate.
Comment 41 haui 2005-05-22 13:30:14 UTC
Created attachment 26420 [details]
Document that changes when it is being saved again with OOoffice. The bezier path moves to the top left corner of the document during save. The document content.xml is created manually by inserting the results of a svg2draw filter operation.
Comment 42 Armin Le Grand 2005-05-27 14:12:12 UTC
AW: Shifted due to workload
Comment 43 goel_veenu 2009-11-24 06:58:39 UTC
I am having sma issues. When I create Polygon or polyline it shifts to top 
left corner. If we have any solution to that.
Comment 44 Marcus 2017-05-20 10:44:20 UTC
Reset the assignee to the default "issues@openoffice.apache.org".