spreadsheet_intelligence.converters.drawing package#
Subpackages#
- spreadsheet_intelligence.converters.drawing.drawing_raw_converters package
- Submodules
- spreadsheet_intelligence.converters.drawing.drawing_raw_converters.base_drawing_raw_converter module
- spreadsheet_intelligence.converters.drawing.drawing_raw_converters.connector_raw_converter module
ConnectorConverter
ConnectorConverter.anchor
ConnectorConverter.drawing
ConnectorConverter.refined
ConnectorConverter.theme
ConnectorConverter.id_counter
ConnectorConverter.convert_length_unit()
ConnectorConverter.convert_angle_unit()
ConnectorConverter.convert_units()
ConnectorConverter.calc_endpoints_pos()
ConnectorConverter.extract_line_style()
ConnectorConverter.extract_arrow_type()
ConnectorConverter.convert()
ConnectorConverter._abc_impl
StraightConnector1Converter
BentConnector3Converter
- spreadsheet_intelligence.converters.drawing.drawing_raw_converters.shape_raw_converter module
- Module contents
Module contents#
- class spreadsheet_intelligence.converters.drawing.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.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.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.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