Struct Class
Struct classes represent a UNO structure.
Static
Struct classes in ooo.lo
and ooo.csslo
namespaces are static classes.
- Example static:
from ooo.csslo.awt import Rectangle rect1 = Rectangle(X=100, Y=200, Width=50, Height=1) assert rect1.X == 100 assert rect1.Height == 1 rect1.Width == 250 assert rect1.Width == 250 rect2 = Rectangle() rect2.X = 122 rect2.Y = 240 assert rect2.X == 122 assert rect2.Y == 240
Struct classes in ooo.lo
and ooo.csslo
namespaces are the same classes.
- Example:
from ooo.lo.awt.rectangle import Rectangle as LoRectangle from ooo.csslo.awt import Rectangle as CssRectangle from ooo.cssdyn.awt import Rectangle as DynRectangle same = LoRectangle is CssRectangle assert same == True same = LoRectangle is DynRectangle assert same == False
Dynamic
Struct classes in ooo.dyn
and ooo.cssdyn
namespaces are dynamic classes
and are changed to UNO classes at runtime.
- Example dynamic:
from ooo.cssdyn.awt import Rectangle from com.sun.star.awt import Rectangle as URectangle rect1 = Rectangle(X=100, Y=200, Width=50, Height=1) assert isinstance(rect1, URectangle) assert rect1.X == 100 assert rect1.Height == 1 rect1.Width == 250 assert rect1.Width == 250 rect2 = Rectangle() rect2.X = 122 rect2.Y = 240 assert rect2.X == 122 assert rect2.Y == 240
General
Struct classes can accept keyword or positional arguments.
- Example keyword and positional:
from ooo.cssdyn.awt import Rectangle rect1 = Rectangle(X=100, Y=200, Width=50, Height=1) rect2 = Rectangle(100, 200, 50, 1) assert rect1.X == rect2.X assert rect1.Y == rect2.Y assert rect1.Width == rect2.Width assert rect1.Height == rect2.Height
Struct classes can be constructed by another struct of the same type:
- Example construct from other struct:
from ooo.cssdyn.awt import Rectangle rect1 = Rectangle(100, 200, 50, 1) rect2 = Rectangle(rect1) assert rect1.X == rect2.X assert rect1.Y == rect2.Y assert rect1.Width == rect2.Width assert rect1.Height == rect2.Height