Core: Generation of Spreadsheet interface bindings (#22624)

* Initial commit of spreadsheet

---------

Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
This commit is contained in:
Ian Abreu
2025-07-22 19:34:42 -04:00
committed by GitHub
parent 081f24c694
commit bb2ee82990
8 changed files with 296 additions and 6 deletions

View File

@@ -45,6 +45,11 @@ generate_from_xml(PropertySheetPy)
generate_from_xml(PropertyColumnWidthsPy)
generate_from_xml(PropertyRowHeightsPy)
generate_from_py_(SheetPy)
generate_from_py_(PropertySheetPy)
generate_from_py_(PropertyColumnWidthsPy)
generate_from_py_(PropertyRowHeightsPy)
if(FREECAD_USE_PCH)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${Spreadsheet_SRCS})

View File

@@ -0,0 +1,18 @@
from Base.Metadata import export
from Base.Persistence import Persistence
@export(
Father="PersistencePy",
Name="PropertyColumnWidthsPy",
Twin="PropertyColumnWidths",
TwinPointer="PropertyColumnWidths",
Include="Mod/Spreadsheet/App/PropertyColumnWidths.h",
Namespace="Spreadsheet",
FatherInclude="Base/PersistencePy.h",
FatherNamespace="Base",
Constructor=True,
)
class PropertyColumnWidthsPy(Persistence):
"""
Internal spreadsheet object
"""

View File

@@ -0,0 +1,18 @@
from Base.Metadata import export
from Base.Persistence import Persistence
@export(
Father="PersistencePy",
Name="PropertyRowHeightsPy",
Twin="PropertyRowHeights",
TwinPointer="PropertyRowHeights",
Include="Mod/Spreadsheet/App/PropertyRowHeights.h",
Namespace="Spreadsheet",
FatherInclude="Base/PersistencePy.h",
FatherNamespace="Base",
Constructor=True,
)
class PropertyRowHeightsPy(Persistence):
"""
Internal spreadsheet object
"""

View File

@@ -0,0 +1,21 @@
from Base.Metadata import export, sequence_protocol
from Base.Persistence import Persistence
@export(
Father="PersistencePy",
Name="PropertySheetPy",
Twin="PropertySheet",
TwinPointer="PropertySheet",
Include="Mod/Spreadsheet/App/PropertySheet.h",
Namespace="Spreadsheet",
FatherInclude="Base/PersistencePy.h",
FatherNamespace="Base",
Constructor=True,
)
@sequence_protocol(
mp_subscript="true",
)
class PropertySheetPy(Persistence):
"""
Internal spreadsheet object
"""

View File

@@ -0,0 +1,183 @@
from typing import Any
from Base.Metadata import export
from App.DocumentObject import DocumentObject
@export(
Father="DocumentObjectPy",
Name="SheetPy",
Twin="Sheet",
TwinPointer="Sheet",
Include="Mod/Spreadsheet/App/Sheet.h",
Namespace="Spreadsheet",
FatherInclude="App/DocumentObjectPy.h",
FatherNamespace="App",
Constructor=True,
)
class SheetPy(DocumentObject):
"""
With this object you can manipulate spreadsheets
"""
def set(self) -> Any:
"""Set data into a cell"""
...
def get(self) -> Any:
"""Get evaluated cell contents"""
...
def getContents(self) -> Any:
"""Get cell contents"""
...
def clear(self) -> Any:
"""Clear a cell"""
...
def clearAll(self) -> Any:
"""Clear all cells in the spreadsheet"""
...
def importFile(self) -> Any:
"""Import file into spreadsheet"""
...
def exportFile(self) -> Any:
"""Export file from spreadsheet"""
...
def mergeCells(self) -> Any:
"""Merge given cell area into one cell"""
...
def splitCell(self) -> Any:
"""Split a previously merged cell"""
...
def insertColumns(self) -> Any:
"""Insert a given number of columns into the spreadsheet."""
...
def removeColumns(self) -> Any:
"""Remove a given number of columns from the spreadsheet."""
...
def insertRows(self) -> Any:
"""Insert a given number of rows into the spreadsheet."""
...
def removeRows(self) -> Any:
"""Remove a given number of rows from the spreadsheet."""
...
def setAlignment(self) -> Any:
"""Set alignment of the cell"""
...
def getAlignment(self) -> Any:
"""Get alignment of the cell"""
...
def setStyle(self) -> Any:
"""Set style of the cell"""
...
def getStyle(self) -> Any:
"""Get style of the cell"""
...
def setDisplayUnit(self) -> Any:
"""Set display unit for cell"""
...
def setAlias(self) -> Any:
"""Set alias for cell address"""
...
def getAlias(self) -> Any:
"""Get alias for cell address"""
...
def getCellFromAlias(self) -> Any:
"""Get cell address given an alias"""
...
def getDisplayUnit(self) -> Any:
"""Get display unit for cell"""
...
def setForeground(self) -> Any:
"""Set foreground color of the cell"""
...
def getForeground(self) -> Any:
"""Get foreground color of the cell"""
...
def setBackground(self) -> Any:
"""Set background color of the cell"""
...
def getBackground(self) -> Any:
"""Get background color of the cell"""
...
def setColumnWidth(self) -> Any:
"""Set given spreadsheet column to given width"""
...
def getColumnWidth(self) -> Any:
"""Get given spreadsheet column width"""
...
def setRowHeight(self) -> Any:
"""Set given spreadsheet row to given height"""
...
def getRowHeight(self) -> Any:
"""Get given spreadsheet row height"""
...
def touchCells(self) -> Any:
"""touchCells(from, to=None): touch cells in the given range"""
...
def recomputeCells(self) -> Any:
"""recomputeCells(from, to=None)
Manually recompute cells in the given range with the given order without
following dependency order."""
...
def getUsedCells(self) -> Any:
"""getUsedCells()
Get a list of the names of all cells that are marked as used. These cells may
or may not have a non-empty string content."""
...
def getNonEmptyCells(self) -> Any:
"""getNonEmptyCells()
Get a list of the names of all cells with data in them."""
...
def getUsedRange(self) -> Any:
"""getUsedRange()
Get a the total range of the used cells in a sheet, as a pair of strings
representing the lowest row and column that are used, and the highest row and
column that are used (inclusive). Note that the actual first and last cell
of the block are not necessarily used."""
...
def getNonEmptyRange(self) -> Any:
"""getNonEmptyRange()
Get a the total range of the used cells in a sheet, as a pair of cell addresses
representing the lowest row and column that contain data, and the highest row and
column that contain data (inclusive). Note that the actual first and last cell
of the block do not necessarily contain anything."""
...

View File

@@ -4,6 +4,7 @@ include_directories(
)
generate_from_xml(ViewProviderSpreadsheetPy)
generate_from_py_(ViewProviderSpreadsheetPy)
# The XML files
set(SpreadsheetGui_XML_SRCS

View File

@@ -0,0 +1,44 @@
from typing import Any
from Base.Metadata import export
from Gui.ViewProviderDocumentObject import ViewProviderDocumentObject
@export(
Father="ViewProviderDocumentObjectPy",
Name="ViewProviderSpreadsheetPy",
Twin="ViewProviderSheet",
TwinPointer="ViewProviderSheet",
Include="Mod/Spreadsheet/Gui/ViewProviderSpreadsheet.h",
Namespace="SpreadsheetGui",
FatherInclude="Gui/ViewProviderDocumentObjectPy.h",
FatherNamespace="Gui",
)
class ViewProviderSpreadsheetPy(ViewProviderDocumentObject):
"""
ViewProviderSheet class
"""
def getView(self) -> Any:
"""Get access to the sheet view"""
...
def showSheetMdi(self) -> Any:
"""
Create (if necessary) and switch to the Spreadsheet MDI.
showSheetMdi()
Returns: None
"""
...
def exportAsFile(self) -> Any:
"""
Export the sheet as a file.
exportAsFile()
Returns: None
"""
...

View File

@@ -23,22 +23,22 @@
<Methode Name="showSheetMdi">
<Documentation>
<UserDocu>
Create (if necessary) and switch to the Spreadsheet MDI.
Create (if necessary) and switch to the Spreadsheet MDI.
showSheetMdi()
showSheetMdi()
Returns: None
Returns: None
</UserDocu>
</Documentation>
</Methode>
<Methode Name="exportAsFile">
<Documentation>
<UserDocu>
Export the sheet as a file.
Export the sheet as a file.
exportAsFile()
exportAsFile()
Returns: None
Returns: None
</UserDocu>
</Documentation>
</Methode>