Trouble with SdrMeasureObj (dimension line)

Regina Henschel rb.henschel at
Wed Nov 18 22:56:01 UTC 2020

Hi all,

I have wondered why a SdrMeasureObj, which is anchored "to cell (resize 
with cell), does not work in Calc (e.g. tdf#137576).
Problems detected so far:

(A) TRGetBaseGeometry does not include a rotation angle. So a chain of 
TRGetBaseGeometry followed by TRSetBaseGeometry does not work. I'm going 
to change ScXMLExport::WriteShapes so that is does not use matrices. I 
think, a fix for TR*BaseGeometry is a larger effort.

(B) Neither "drag create", nor ctor, nor "create default" set maRect. 
Because SdrMeasureObj has no own NbcGetLogicRect it uses the inherited 
one from SdrTextObj, which simple results maRect. Thus Calc uses in some 
cases an empty rectangle, when it calculates NonRotatedAnchor. The 
latter is used when saving the document.

(C) Setting start or end point does not update maRect. The method 
includes SetRectsDirty(). A call to GetSnapRect() will then trigger 
RecalSnapRect(), but that does not affect maRect.

(D) Both NbcSetLogicRect and NbcSetSnapRect use the inherited one from 
SdrTextObj and therefor do not set start and end point. Fixing that 
looks like a larger effort to me too.

TakeUnrotatedSnapRect can calculate a logic rectangle of the current 
state of a SdrMeasureObj. I can add this to 
FuConstRectangle::CreateDefaultObject, which is responsible for a 
default SdrMeasureObj (used for accessibility), and to 
SdrMeasureObj::EndCreate. That will work for creating measure lines in 
the UI of Calc.

Implementing a SdrMeasureObj::GetLogicRect(), which recalculates maRect, 
is not possible because of const-ness.

Should I add TakeUnrotatedSnapRect to other places too? Candidates are
ctor SdrMeasureObj::SdrMeasureObj(SdrModel& rSdrModel, const Point& 
rPt1, const Point& rPt2)
SdrMeasureObj::NbcSetPoint(const Point& rPnt, sal_uInt32 i)

Do you know other places which need to be changed, or which are sensible 
and need testing?

Do you have better ideas?

Do you have a suggestion for the order, things to do?

Do you know examples for unit tests with "drag create" and for unit 
tests with "create default objects"?

Kind regards

More information about the LibreOffice mailing list