spreadsheet_intelligence.converters.drawing.drawing_raw_converters package#
Submodules#
spreadsheet_intelligence.converters.drawing.drawing_raw_converters.base_drawing_raw_converter module#
- class spreadsheet_intelligence.converters.drawing.drawing_raw_converters.base_drawing_raw_converter.BaseDrawingConverter(raw: ShapeAnchorRaw | ConnectorAnchorRaw)[source]#
Bases:
ABC
Base abstract class for drawing converters.
- drawing#
The raw drawing data.
- Type:
- refined#
The refined drawing data after conversion.
- Type:
Optional[BaseDrawingRaw]
- static _convert_one_color(scheme_clr: SchemeClr | None, srgb_clr: SrgbClr | None, style_base_ref: StyleBaseRef, theme: Theme) Color [source]#
Converts color information to a Color object.
- Parameters:
scheme_clr (Optional[SchemeClr]) – The scheme color.
srgb_clr (Optional[SrgbClr]) – The sRGB color.
style_base_ref (StyleBaseRef) – The style base reference.
theme (Theme) – The theme used for color conversion.
- Returns:
The converted color object.
- Return type:
- Raises:
ValueError – If the color type is invalid.
- _validate_drawing(drawing: BaseDrawingRaw)[source]#
Validates if the drawing is the expected input for the converter.
- Parameters:
drawing (BaseDrawingRaw) – The drawing to validate.
- Returns:
True if the drawing is valid, False otherwise.
- Return type:
bool
- abstractmethod convert()[source]#
Abstract method to convert the drawing.
This method should be implemented by subclasses.
- _abc_impl = <_abc._abc_data object>#
spreadsheet_intelligence.converters.drawing.drawing_raw_converters.connector_raw_converter module#
- class spreadsheet_intelligence.converters.drawing.drawing_raw_converters.connector_raw_converter.ConnectorConverter(connector_anchor_raw: ConnectorAnchorRaw, theme: Theme, id_counter: int)[source]#
Bases:
BaseDrawingConverter
,ABC
Abstract base class for converting connector drawings.
- drawing#
The raw drawing data of the connector.
- Type:
- id_counter#
A counter for generating unique IDs.
- Type:
int
- convert_length_unit(raw_unit: int) float [source]#
Converts length from EMU to centimeters.
- Parameters:
raw_unit (int) – The length in EMU.
- Returns:
The length in centimeters.
- Return type:
float
- convert_angle_unit(raw_unit: int) float [source]#
Converts angle from raw units to degrees.
- Parameters:
raw_unit (int) – The angle in raw units.
- Returns:
The angle in degrees.
- Return type:
float
- convert_units() tuple [source]#
Converts the drawing’s position, size, and rotation units.
- Returns:
A tuple containing the converted x, y, width, height, and rotation.
- Return type:
tuple
- calc_endpoints_pos(x: float, y: float, w: float, h: float, rotation: float, flip_h: bool, flip_v: bool) tuple [source]#
Calculates the positions of the connector’s endpoints.
- Parameters:
x (float) – The x-coordinate of the drawing.
y (float) – The y-coordinate of the drawing.
w (float) – The width of the drawing.
h (float) – The height of the drawing.
rotation (float) – The rotation of the drawing.
flip_h (bool) – Whether the drawing is flipped horizontally.
flip_v (bool) – Whether the drawing is flipped vertically.
- Returns:
A tuple containing the rotated and flipped head and tail positions.
- Return type:
tuple
- extract_line_style() LineType [source]#
Extracts the line style from the drawing.
- Returns:
The line style as a LineType enum.
- Return type:
- Raises:
ValueError – If the line style is invalid.
- extract_arrow_type() ArrowType [source]#
Extracts the arrow type from the drawing.
- Returns:
The arrow type as an ArrowType enum.
- Return type:
- Raises:
ValueError – If the arrow type is invalid.
- _abc_impl = <_abc._abc_data object>#
- class spreadsheet_intelligence.converters.drawing.drawing_raw_converters.connector_raw_converter.StraightConnector1Converter(connector_anchor_raw: ConnectorAnchorRaw, theme: Theme, id_counter: int)[source]#
Bases:
ConnectorConverter
Converter for StraightConnector1 drawings.
- drawing: ConnectorRaw#
- refined: StraightConnector1 | None#
- _validate_drawing(drawing: ConnectorRaw)[source]#
Validates that the drawing is of type StraightConnector1.
- Parameters:
drawing – The raw drawing data.
- Raises:
ValueError – If the drawing type is not StraightConnector1.
- convert() StraightConnector1 [source]#
Converts the raw drawing to a StraightConnector1 object.
- Returns:
A StraightConnector1 object.
- _abc_impl = <_abc._abc_data object>#
- class spreadsheet_intelligence.converters.drawing.drawing_raw_converters.connector_raw_converter.BentConnector3Converter(connector_anchor_raw: ConnectorAnchorRaw, theme: Theme, id_counter: int)[source]#
Bases:
ConnectorConverter
Converter for BentConnector3 drawings.
- drawing: ConnectorRaw#
- refined: BentConnector3 | None#
- _validate_drawing(drawing: ConnectorRaw)[source]#
Validates that the drawing is of type BentConnector3 and has a valid rotation.
- Parameters:
drawing – The raw drawing data.
- Raises:
ValueError – If the drawing type is not BentConnector3 or the rotation is invalid.
- convert_angle_unit(raw_unit: int) int [source]#
Converts angle from raw units to degrees.
- Parameters:
raw_unit – The angle in raw units.
- Returns:
The angle in degrees.
- extract_endpoints_direction(rotation, flip_h, flip_v, interm_ln_pos)[source]#
Extracts the directions of the arrowheads at both ends.
- Parameters:
rotation – The rotation of the drawing.
flip_h – Whether the drawing is flipped horizontally.
flip_v – Whether the drawing is flipped vertically.
interm_ln_pos – The position of the intermediate line.
- Returns:
A tuple containing the directions of the head and tail.
- convert() BentConnector3 [source]#
Converts the raw drawing to a BentConnector3 object.
- Returns:
A BentConnector3 object.
- _abc_impl = <_abc._abc_data object>#
spreadsheet_intelligence.converters.drawing.drawing_raw_converters.shape_raw_converter module#
- class spreadsheet_intelligence.converters.drawing.drawing_raw_converters.shape_raw_converter.ShapeConverter(shape_anchor_raw: ShapeAnchorRaw, theme: Theme, id_counter: int)[source]#
Bases:
BaseDrawingConverter
Converter for shape drawings.
- id_counter#
A counter for generating unique IDs.
- Type:
int
TODO: - Text parsing is not implemented when the text contains multiple formats.
- extract_shape_type() ShapeType [source]#
Extracts the shape type from the raw drawing data.
- Returns:
The type of the shape.
- Return type:
- Raises:
ValueError – If the shape type is invalid.
- convert_unit(raw_unit: int) float [source]#
Converts a raw unit to centimeters.
- Parameters:
raw_unit (int) – The raw unit to be converted.
- Returns:
The converted unit in centimeters.
- Return type:
float
TODO: Allow unit conversion method to be specified globally in settings.
- calc_shape_bbox() tuple [source]#
Calculates the bounding box of the shape after unit conversion.
- Returns:
A tuple containing the x, y coordinates and width, height of the shape.
- Return type:
tuple
- convert() Shape [source]#
Converts the raw shape data into a Shape object.
- Returns:
The converted shape object.
- Return type:
- _abc_impl = <_abc._abc_data object>#
Module contents#
- class spreadsheet_intelligence.converters.drawing.drawing_raw_converters.BentConnector3Converter(connector_anchor_raw: ConnectorAnchorRaw, theme: Theme, id_counter: int)[source]#
Bases:
ConnectorConverter
Converter for BentConnector3 drawings.
- _abc_impl = <_abc._abc_data object>#
- _validate_drawing(drawing: ConnectorRaw)[source]#
Validates that the drawing is of type BentConnector3 and has a valid rotation.
- Parameters:
drawing – The raw drawing data.
- Raises:
ValueError – If the drawing type is not BentConnector3 or the rotation is invalid.
- convert() BentConnector3 [source]#
Converts the raw drawing to a BentConnector3 object.
- Returns:
A BentConnector3 object.
- convert_angle_unit(raw_unit: int) int [source]#
Converts angle from raw units to degrees.
- Parameters:
raw_unit – The angle in raw units.
- Returns:
The angle in degrees.
- extract_endpoints_direction(rotation, flip_h, flip_v, interm_ln_pos)[source]#
Extracts the directions of the arrowheads at both ends.
- Parameters:
rotation – The rotation of the drawing.
flip_h – Whether the drawing is flipped horizontally.
flip_v – Whether the drawing is flipped vertically.
interm_ln_pos – The position of the intermediate line.
- Returns:
A tuple containing the directions of the head and tail.
- drawing: ConnectorRaw#
- refined: BentConnector3 | None#
- class spreadsheet_intelligence.converters.drawing.drawing_raw_converters.StraightConnector1Converter(connector_anchor_raw: ConnectorAnchorRaw, theme: Theme, id_counter: int)[source]#
Bases:
ConnectorConverter
Converter for StraightConnector1 drawings.
- _abc_impl = <_abc._abc_data object>#
- _validate_drawing(drawing: ConnectorRaw)[source]#
Validates that the drawing is of type StraightConnector1.
- Parameters:
drawing – The raw drawing data.
- Raises:
ValueError – If the drawing type is not StraightConnector1.
- convert() StraightConnector1 [source]#
Converts the raw drawing to a StraightConnector1 object.
- Returns:
A StraightConnector1 object.
- drawing: ConnectorRaw#
- refined: StraightConnector1 | None#
- class spreadsheet_intelligence.converters.drawing.drawing_raw_converters.ShapeConverter(shape_anchor_raw: ShapeAnchorRaw, theme: Theme, id_counter: int)[source]#
Bases:
BaseDrawingConverter
Converter for shape drawings.
- id_counter#
A counter for generating unique IDs.
- Type:
int
TODO: - Text parsing is not implemented when the text contains multiple formats.
- _abc_impl = <_abc._abc_data object>#
- calc_shape_bbox() tuple [source]#
Calculates the bounding box of the shape after unit conversion.
- Returns:
A tuple containing the x, y coordinates and width, height of the shape.
- Return type:
tuple
- convert() Shape [source]#
Converts the raw shape data into a Shape object.
- Returns:
The converted shape object.
- Return type:
- convert_unit(raw_unit: int) float [source]#
Converts a raw unit to centimeters.
- Parameters:
raw_unit (int) – The raw unit to be converted.
- Returns:
The converted unit in centimeters.
- Return type:
float
TODO: Allow unit conversion method to be specified globally in settings.
- class spreadsheet_intelligence.converters.drawing.drawing_raw_converters.BaseDrawingConverter(raw: ShapeAnchorRaw | ConnectorAnchorRaw)[source]#
Bases:
ABC
Base abstract class for drawing converters.
- drawing#
The raw drawing data.
- Type:
- refined#
The refined drawing data after conversion.
- Type:
Optional[BaseDrawingRaw]
- _abc_impl = <_abc._abc_data object>#
- static _convert_one_color(scheme_clr: SchemeClr | None, srgb_clr: SrgbClr | None, style_base_ref: StyleBaseRef, theme: Theme) Color [source]#
Converts color information to a Color object.
- Parameters:
scheme_clr (Optional[SchemeClr]) – The scheme color.
srgb_clr (Optional[SrgbClr]) – The sRGB color.
style_base_ref (StyleBaseRef) – The style base reference.
theme (Theme) – The theme used for color conversion.
- Returns:
The converted color object.
- Return type:
- Raises:
ValueError – If the color type is invalid.
- _validate_drawing(drawing: BaseDrawingRaw)[source]#
Validates if the drawing is the expected input for the converter.
- Parameters:
drawing (BaseDrawingRaw) – The drawing to validate.
- Returns:
True if the drawing is valid, False otherwise.
- Return type:
bool