Base: Rename Base::freecad_dynamic_cast into freecad_cast

This is to make it shorter and easier to use. QT does the same thing
with their qobject_cast.
This commit is contained in:
Kacper Donat
2025-03-28 23:15:04 +01:00
committed by Chris Hennes
parent 5fb6638b7f
commit 9d97d1c895
73 changed files with 302 additions and 315 deletions

View File

@@ -250,14 +250,14 @@ bool Cell::getStringContent(std::string& s, bool persistent) const
if (expression->hasComponent()) {
s = "=" + expression->toString(persistent);
}
else if (freecad_dynamic_cast<App::StringExpression>(expression.get())) {
else if (freecad_cast<App::StringExpression>(expression.get())) {
s = static_cast<App::StringExpression*>(expression.get())->getText();
s = "'" + s;
}
else if (freecad_dynamic_cast<App::ConstantExpression>(expression.get())) {
else if (freecad_cast<App::ConstantExpression>(expression.get())) {
s = "=" + expression->toString();
}
else if (freecad_dynamic_cast<App::NumberExpression>(expression.get())) {
else if (freecad_cast<App::NumberExpression>(expression.get())) {
s = expression->toString();
}
else {
@@ -274,7 +274,7 @@ bool Cell::getStringContent(std::string& s, bool persistent) const
void Cell::afterRestore()
{
auto expr = freecad_dynamic_cast<StringExpression>(expression.get());
auto expr = freecad_cast<StringExpression>(expression.get());
if (expr) {
setContent(expr->getText().c_str());
}
@@ -331,13 +331,10 @@ void Cell::setContent(const char* value)
try {
ExpressionPtr parsedExpr(App::ExpressionParser::parse(owner->sheet(), value));
if (const auto fraction =
freecad_dynamic_cast<OperatorExpression>(parsedExpr.get())) {
if (const auto fraction = freecad_cast<OperatorExpression>(parsedExpr.get())) {
if (fraction->getOperator() == OperatorExpression::UNIT) {
const auto left =
freecad_dynamic_cast<NumberExpression>(fraction->getLeft());
const auto right =
freecad_dynamic_cast<UnitExpression>(fraction->getRight());
const auto left = freecad_cast<NumberExpression>(fraction->getLeft());
const auto right = freecad_cast<UnitExpression>(fraction->getRight());
if (left && right) {
newExpr = std::move(parsedExpr);
}
@@ -348,23 +345,22 @@ void Cell::setContent(const char* value)
// check for numbers in (de)nominator
const bool isNumberNom =
freecad_dynamic_cast<NumberExpression>(fraction->getLeft());
freecad_cast<NumberExpression>(fraction->getLeft());
const bool isNumberDenom =
freecad_dynamic_cast<NumberExpression>(fraction->getRight());
freecad_cast<NumberExpression>(fraction->getRight());
// check for numbers with units in (de)nominator
const auto opNom =
freecad_dynamic_cast<OperatorExpression>(fraction->getLeft());
freecad_cast<OperatorExpression>(fraction->getLeft());
const auto opDenom =
freecad_dynamic_cast<OperatorExpression>(fraction->getRight());
freecad_cast<OperatorExpression>(fraction->getRight());
const bool isQuantityNom =
opNom && opNom->getOperator() == OperatorExpression::UNIT;
const bool isQuantityDenom =
opDenom && opDenom->getOperator() == OperatorExpression::UNIT;
// check for units in denomainator
const auto uDenom =
freecad_dynamic_cast<UnitExpression>(fraction->getRight());
const auto uDenom = freecad_cast<UnitExpression>(fraction->getRight());
const bool isUnitDenom = uDenom && uDenom->is<UnitExpression>();
const bool isNomValid = isNumberNom || isQuantityNom;
@@ -375,8 +371,7 @@ void Cell::setContent(const char* value)
}
}
}
else if (const auto number =
freecad_dynamic_cast<NumberExpression>(parsedExpr.get())) {
else if (const auto number = freecad_cast<NumberExpression>(parsedExpr.get())) {
// NumbersExpressions can accept more than can be parsed with strtod.
// Example: 12.34 and 12,34 are both valid NumberExpressions
newExpr = std::move(parsedExpr);

View File

@@ -378,7 +378,7 @@ void PropertySheet::Paste(const Property& from)
if (!spanChanges.empty()) {
mergedCells = froms.mergedCells;
if (auto sheet = Base::freecad_dynamic_cast<Sheet>(getContainer())) {
if (auto sheet = freecad_cast<Sheet>(getContainer())) {
for (const auto& addr : spanChanges) {
sheet->cellSpanChanged(addr);
}
@@ -1476,7 +1476,7 @@ void PropertySheet::recomputeDependants(const App::DocumentObject* owner, const
// Check for hidden reference. Because a hidden reference is not
// protected by cyclic dependency checking, we need to take special
// care to prevent it from misbehave.
Sheet* sheet = Base::freecad_dynamic_cast<Sheet>(getContainer());
Sheet* sheet = freecad_cast<Sheet>(getContainer());
if (!sheet || sheet->testStatus(App::ObjectStatus::Recompute2) || !owner
|| owner->testStatus(App::ObjectStatus::Recompute2)) {
return;
@@ -2078,8 +2078,7 @@ PropertySheet::BindingType PropertySheet::getBinding(const Range& range,
if (expr->getFunction() == FunctionExpression::TUPLE && expr->getArgs().size() == 3) {
if (pTarget) {
if (auto e =
Base::freecad_dynamic_cast<VariableExpression>(expr->getArgs()[0])) {
if (auto e = freecad_cast<VariableExpression>(expr->getArgs()[0])) {
*pTarget = e->getPath();
}
}
@@ -2118,8 +2117,7 @@ void PropertySheet::setPathValue(const ObjectIdentifier& path, const boost::any&
&& Py::Object(seq[1].ptr()).isString() && Py::Object(seq[2].ptr()).isString()) {
AtomicPropertyChange signaller(*this, false);
auto other = static_cast<PropertySheetPy*>(seq[0].ptr())->getPropertySheetPtr();
auto otherOwner =
Base::freecad_dynamic_cast<App::DocumentObject>(other->getContainer());
auto otherOwner = freecad_cast<App::DocumentObject>(other->getContainer());
if (!otherOwner) {
FC_THROWM(Base::RuntimeError,
"Invalid binding of '" << other->getFullName() << " in "
@@ -2289,7 +2287,7 @@ void PropertySheet::getLinksTo(std::vector<App::ObjectIdentifier>& identifiers,
auto subObject = objT.getSubObject();
auto subElement = objT.getOldElementName();
auto owner = Base::freecad_dynamic_cast<App::DocumentObject>(getContainer());
auto owner = freecad_cast<App::DocumentObject>(getContainer());
for (const auto& [cellName, cellExpression] : data) {
if (auto expr = cellExpression->getExpression()) {
const auto& deps = expr->getDeps(option);

View File

@@ -344,18 +344,16 @@ bool Sheet::exportToFile(const std::string& filename,
std::stringstream field;
using Base::freecad_dynamic_cast;
if (auto p = freecad_dynamic_cast<PropertyQuantity>(prop)) {
if (auto p = freecad_cast<PropertyQuantity>(prop)) {
field << p->getValue();
}
else if (auto p = freecad_dynamic_cast<PropertyFloat>(prop)) {
else if (auto p = freecad_cast<PropertyFloat>(prop)) {
field << p->getValue();
}
else if (auto p = freecad_dynamic_cast<PropertyInteger>(prop)) {
else if (auto p = freecad_cast<PropertyInteger>(prop)) {
field << p->getValue();
}
else if (auto p = freecad_dynamic_cast<PropertyString>(prop)) {
else if (auto p = freecad_cast<PropertyString>(prop)) {
field << p->getValue();
}
else {
@@ -595,7 +593,7 @@ Property* Sheet::setFloatProperty(CellAddress key, double value)
this->removeDynamicProperty(name.c_str());
propAddress.erase(prop);
}
floatProp = freecad_dynamic_cast<PropertyFloat>(
floatProp = freecad_cast<PropertyFloat>(
addDynamicProperty("App::PropertyFloat",
name.c_str(),
nullptr,
@@ -623,7 +621,7 @@ Property* Sheet::setIntegerProperty(CellAddress key, long value)
this->removeDynamicProperty(name.c_str());
propAddress.erase(prop);
}
intProp = freecad_dynamic_cast<PropertyInteger>(
intProp = freecad_cast<PropertyInteger>(
addDynamicProperty("App::PropertyInteger",
name.c_str(),
nullptr,
@@ -668,7 +666,7 @@ Property* Sheet::setQuantityProperty(CellAddress key, double value, const Base::
nullptr,
nullptr,
Prop_ReadOnly | Prop_Hidden | Prop_NoPersist);
quantityProp = freecad_dynamic_cast<PropertySpreadsheetQuantity>(p);
quantityProp = freecad_cast<PropertySpreadsheetQuantity>(p);
}
else {
quantityProp = static_cast<PropertySpreadsheetQuantity*>(prop);
@@ -697,14 +695,14 @@ Property* Sheet::setStringProperty(CellAddress key, const std::string& value)
{
std::string name = key.toString(CellAddress::Cell::ShowRowColumn);
Property* prop = props.getDynamicPropertyByName(name.c_str());
PropertyString* stringProp = freecad_dynamic_cast<PropertyString>(prop);
PropertyString* stringProp = freecad_cast<PropertyString>(prop);
if (!stringProp) {
if (prop) {
this->removeDynamicProperty(name.c_str());
propAddress.erase(prop);
}
stringProp = freecad_dynamic_cast<PropertyString>(
stringProp = freecad_cast<PropertyString>(
addDynamicProperty("App::PropertyString",
name.c_str(),
nullptr,
@@ -722,14 +720,14 @@ Property* Sheet::setObjectProperty(CellAddress key, Py::Object object)
{
std::string name = key.toString(CellAddress::Cell::ShowRowColumn);
Property* prop = props.getDynamicPropertyByName(name.c_str());
PropertyPythonObject* pyProp = freecad_dynamic_cast<PropertyPythonObject>(prop);
PropertyPythonObject* pyProp = freecad_cast<PropertyPythonObject>(prop);
if (!pyProp) {
if (prop) {
this->removeDynamicProperty(name.c_str());
propAddress.erase(prop);
}
pyProp = freecad_dynamic_cast<PropertyPythonObject>(
pyProp = freecad_cast<PropertyPythonObject>(
addDynamicProperty("App::PropertyPythonObject",
name.c_str(),
nullptr,
@@ -796,10 +794,10 @@ void Sheet::updateProperty(CellAddress key)
/* Eval returns either NumberExpression or StringExpression, or
* PyObjectExpression objects */
auto number = freecad_dynamic_cast<NumberExpression>(output.get());
auto number = freecad_cast<NumberExpression>(output.get());
if (number) {
long l;
auto constant = freecad_dynamic_cast<ConstantExpression>(output.get());
auto constant = freecad_cast<ConstantExpression>(output.get());
if (constant && !constant->isNumber()) {
Base::PyGILStateLocker lock;
setObjectProperty(key, constant->getPyValue());
@@ -815,13 +813,13 @@ void Sheet::updateProperty(CellAddress key)
}
}
else {
auto str_expr = freecad_dynamic_cast<StringExpression>(output.get());
auto str_expr = freecad_cast<StringExpression>(output.get());
if (str_expr) {
setStringProperty(key, str_expr->getText().c_str());
}
else {
Base::PyGILStateLocker lock;
auto py_expr = freecad_dynamic_cast<PyObjectExpression>(output.get());
auto py_expr = freecad_cast<PyObjectExpression>(output.get());
if (py_expr) {
setObjectProperty(key, py_expr->getPyValue());
}

View File

@@ -71,7 +71,7 @@ void CmdSpreadsheetMergeCells::activated(int iMsg)
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet* sheet = sheetView->getSheet();
@@ -101,7 +101,7 @@ bool CmdSpreadsheetMergeCells::isActive()
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
return (sheetView->selectedIndexesRaw().size() > 1);
@@ -132,7 +132,7 @@ void CmdSpreadsheetSplitCell::activated(int iMsg)
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet* sheet = sheetView->getSheet();
@@ -157,7 +157,7 @@ bool CmdSpreadsheetSplitCell::isActive()
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
QModelIndex current = sheetView->currentIndex();
@@ -246,7 +246,7 @@ void CmdSpreadsheetExport::activated(int iMsg)
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet* sheet = sheetView->getSheet();
@@ -263,7 +263,7 @@ bool CmdSpreadsheetExport::isActive()
{
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
if (activeWindow && freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow)) {
if (activeWindow && freecad_cast<SpreadsheetGui::SheetView>(activeWindow)) {
return true;
}
}
@@ -292,7 +292,7 @@ void CmdSpreadsheetAlignLeft::activated(int iMsg)
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet* sheet = sheetView->getSheet();
@@ -320,7 +320,7 @@ bool CmdSpreadsheetAlignLeft::isActive()
{
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
if (activeWindow && freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow)) {
if (activeWindow && freecad_cast<SpreadsheetGui::SheetView>(activeWindow)) {
return true;
}
}
@@ -349,7 +349,7 @@ void CmdSpreadsheetAlignCenter::activated(int iMsg)
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet* sheet = sheetView->getSheet();
@@ -377,7 +377,7 @@ bool CmdSpreadsheetAlignCenter::isActive()
{
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
if (activeWindow && freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow)) {
if (activeWindow && freecad_cast<SpreadsheetGui::SheetView>(activeWindow)) {
return true;
}
}
@@ -406,7 +406,7 @@ void CmdSpreadsheetAlignRight::activated(int iMsg)
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet* sheet = sheetView->getSheet();
@@ -434,7 +434,7 @@ bool CmdSpreadsheetAlignRight::isActive()
{
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
if (activeWindow && freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow)) {
if (activeWindow && freecad_cast<SpreadsheetGui::SheetView>(activeWindow)) {
return true;
}
}
@@ -463,7 +463,7 @@ void CmdSpreadsheetAlignTop::activated(int iMsg)
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet* sheet = sheetView->getSheet();
@@ -491,7 +491,7 @@ bool CmdSpreadsheetAlignTop::isActive()
{
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
if (activeWindow && freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow)) {
if (activeWindow && freecad_cast<SpreadsheetGui::SheetView>(activeWindow)) {
return true;
}
}
@@ -520,7 +520,7 @@ void CmdSpreadsheetAlignBottom::activated(int iMsg)
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet* sheet = sheetView->getSheet();
@@ -548,7 +548,7 @@ bool CmdSpreadsheetAlignBottom::isActive()
{
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
if (activeWindow && freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow)) {
if (activeWindow && freecad_cast<SpreadsheetGui::SheetView>(activeWindow)) {
return true;
}
}
@@ -577,7 +577,7 @@ void CmdSpreadsheetAlignVCenter::activated(int iMsg)
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet* sheet = sheetView->getSheet();
@@ -605,7 +605,7 @@ bool CmdSpreadsheetAlignVCenter::isActive()
{
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
if (activeWindow && freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow)) {
if (activeWindow && freecad_cast<SpreadsheetGui::SheetView>(activeWindow)) {
return true;
}
}
@@ -635,7 +635,7 @@ void CmdSpreadsheetStyleBold::activated(int iMsg)
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet* sheet = sheetView->getSheet();
@@ -689,7 +689,7 @@ bool CmdSpreadsheetStyleBold::isActive()
{
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
if (activeWindow && freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow)) {
if (activeWindow && freecad_cast<SpreadsheetGui::SheetView>(activeWindow)) {
return true;
}
}
@@ -719,7 +719,7 @@ void CmdSpreadsheetStyleItalic::activated(int iMsg)
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet* sheet = sheetView->getSheet();
@@ -773,7 +773,7 @@ bool CmdSpreadsheetStyleItalic::isActive()
{
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
if (activeWindow && freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow)) {
if (activeWindow && freecad_cast<SpreadsheetGui::SheetView>(activeWindow)) {
return true;
}
}
@@ -803,7 +803,7 @@ void CmdSpreadsheetStyleUnderline::activated(int iMsg)
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet* sheet = sheetView->getSheet();
@@ -857,7 +857,7 @@ bool CmdSpreadsheetStyleUnderline::isActive()
{
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
if (activeWindow && freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow)) {
if (activeWindow && freecad_cast<SpreadsheetGui::SheetView>(activeWindow)) {
return true;
}
}
@@ -887,7 +887,7 @@ void CmdSpreadsheetSetAlias::activated(int iMsg)
if (getActiveGuiDocument()) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet* sheet = sheetView->getSheet();
@@ -921,7 +921,7 @@ bool CmdSpreadsheetSetAlias::isActive()
if (activeWindow) {
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
QModelIndexList selection = sheetView->selectedIndexes();

View File

@@ -168,10 +168,10 @@ void DlgBindSheet::accept()
if (!doc) {
FC_THROWM(Base::RuntimeError, "Cannot find document " << docname);
}
obj = Base::freecad_dynamic_cast<Sheet>(doc->getObject(sep + 1));
obj = freecad_cast<Sheet>(doc->getObject(sep + 1));
}
else {
obj = Base::freecad_dynamic_cast<Sheet>(sheet->getDocument()->getObject(ref));
obj = freecad_cast<Sheet>(sheet->getDocument()->getObject(ref));
}
if (!obj) {
FC_THROWM(Base::RuntimeError, "Cannot find Spreadsheet '" << ref << "'");

View File

@@ -140,7 +140,7 @@ App::Property* DlgSheetConf::prepare(CellAddress& from,
if (cell && cell->getExpression()) {
auto expr = cell->getExpression();
if (expr->isDerivedFrom<FunctionExpression>()) {
auto fexpr = Base::freecad_dynamic_cast<FunctionExpression>(cell->getExpression());
auto fexpr = freecad_cast<FunctionExpression>(cell->getExpression());
if (fexpr
&& (fexpr->getFunction() == FunctionExpression::HREF
|| fexpr->getFunction() == FunctionExpression::HIDDENREF)
@@ -148,12 +148,11 @@ App::Property* DlgSheetConf::prepare(CellAddress& from,
expr = fexpr->getArgs().front();
}
}
auto vexpr = Base::freecad_dynamic_cast<VariableExpression>(expr);
auto vexpr = freecad_cast<VariableExpression>(expr);
if (vexpr) {
auto prop =
Base::freecad_dynamic_cast<PropertyEnumeration>(vexpr->getPath().getProperty());
auto prop = freecad_cast<PropertyEnumeration>(vexpr->getPath().getProperty());
if (prop) {
auto obj = Base::freecad_dynamic_cast<DocumentObject>(prop->getContainer());
auto obj = freecad_cast<DocumentObject>(prop->getContainer());
if (obj && prop->hasName()) {
path = ObjectIdentifier(sheet);
path.setDocumentObjectName(obj, true);

View File

@@ -146,7 +146,7 @@ void ViewProviderSheet::setupContextMenu(QMenu* menu, QObject* receiver, const c
Sheet* ViewProviderSheet::getSpreadsheetObject() const
{
return freecad_dynamic_cast<Sheet>(pcObject);
return freecad_cast<Sheet>(pcObject);
}
void ViewProviderSheet::beforeDelete()

View File

@@ -129,7 +129,7 @@ void WorkbenchHelper::setForegroundColor(const QColor& color)
if (doc) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet* sheet = sheetView->getSheet();
@@ -163,7 +163,7 @@ void WorkbenchHelper::setBackgroundColor(const QColor& color)
if (doc) {
Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
SpreadsheetGui::SheetView* sheetView =
freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);
freecad_cast<SpreadsheetGui::SheetView>(activeWindow);
if (sheetView) {
Sheet* sheet = sheetView->getSheet();