diff --git a/src/Mod/Spreadsheet/App/AppSpreadsheet.cpp b/src/Mod/Spreadsheet/App/AppSpreadsheet.cpp index 7aebf3c8a0..6c2d124348 100644 --- a/src/Mod/Spreadsheet/App/AppSpreadsheet.cpp +++ b/src/Mod/Spreadsheet/App/AppSpreadsheet.cpp @@ -17,7 +17,7 @@ #include #include "Sheet.h" -#include "Expression.h" +#include "SpreadsheetExpression.h" /* registration table */ diff --git a/src/Mod/Spreadsheet/App/CMakeLists.txt b/src/Mod/Spreadsheet/App/CMakeLists.txt index 92777373a8..7ab5f20fd6 100644 --- a/src/Mod/Spreadsheet/App/CMakeLists.txt +++ b/src/Mod/Spreadsheet/App/CMakeLists.txt @@ -17,8 +17,8 @@ set(Spreadsheet_LIBS ) set(Spreadsheet_SRCS - Expression.cpp - Expression.h + SpreadsheetExpression.cpp + SpreadsheetExpression.h Cell.cpp Cell.h DisplayUnit.h diff --git a/src/Mod/Spreadsheet/App/Cell.cpp b/src/Mod/Spreadsheet/App/Cell.cpp index 32700c4779..65b1474fb1 100644 --- a/src/Mod/Spreadsheet/App/Cell.cpp +++ b/src/Mod/Spreadsheet/App/Cell.cpp @@ -30,7 +30,7 @@ #include #include #include -#include "Expression.h" +#include "SpreadsheetExpression.h" #include "Sheet.h" #include @@ -38,7 +38,7 @@ #define __func__ __FUNCTION__ #endif -using namespace App; +using namespace Base; using namespace Spreadsheet; const int Cell::EXPRESSION_SET = 1; @@ -183,7 +183,7 @@ const Expression *Cell::getExpression() const bool Cell::getStringContent(std::string & s) const { if (expression) { - if (Spreadsheet::freecad_dynamic_cast(expression)) { + if (freecad_dynamic_cast(expression)) { s = static_cast(expression)->getText(); char * end; errno = 0; @@ -192,9 +192,9 @@ bool Cell::getStringContent(std::string & s) const if (!*end && errno == 0) s = "'" + s; } - else if (Spreadsheet::freecad_dynamic_cast(expression)) + else if (freecad_dynamic_cast(expression)) s = "=" + expression->toString(); - else if (Spreadsheet::freecad_dynamic_cast(expression)) + else if (freecad_dynamic_cast(expression)) s = expression->toString(); else s = "=" + expression->toString(); @@ -307,7 +307,7 @@ bool Cell::getStyle(std::set & _style) const * */ -void Cell::setForeground(const Color &color) +void Cell::setForeground(const App::Color &color) { if (color != foregroundColor) { PropertySheet::Signaller signaller(*owner); @@ -322,7 +322,7 @@ void Cell::setForeground(const Color &color) * */ -bool Cell::getForeground(Color &color) const +bool Cell::getForeground(App::Color &color) const { color = foregroundColor; return isUsed(FOREGROUND_COLOR_SET); @@ -333,7 +333,7 @@ bool Cell::getForeground(Color &color) const * */ -void Cell::setBackground(const Color &color) +void Cell::setBackground(const App::Color &color) { if (color != backgroundColor) { PropertySheet::Signaller signaller(*owner); @@ -350,7 +350,7 @@ void Cell::setBackground(const Color &color) * */ -bool Cell::getBackground(Color &color) const +bool Cell::getBackground(App::Color &color) const { color = backgroundColor; return isUsed(BACKGROUND_COLOR_SET); @@ -569,12 +569,12 @@ void Cell::restore(Base::XMLReader &reader) setAlignment(alignmentCode); } if (foregroundColor) { - Color color = decodeColor(foregroundColor, Color(0, 0, 0, 1)); + App::Color color = decodeColor(foregroundColor, App::Color(0, 0, 0, 1)); setForeground(color); } if (backgroundColor) { - Color color = decodeColor(backgroundColor, Color(1, 1, 1, 1)); + App::Color color = decodeColor(backgroundColor, App::Color(1, 1, 1, 1)); setBackground(color); } @@ -609,7 +609,7 @@ void Cell::save(Base::Writer &writer) const std::string content; getStringContent(content); - writer.Stream() << "content=\"" << Property::encodeAttribute(content) << "\" "; + writer.Stream() << "content=\"" << App::Property::encodeAttribute(content) << "\" "; } if (isUsed(ALIGNMENT_SET)) @@ -625,10 +625,10 @@ void Cell::save(Base::Writer &writer) const writer.Stream() << "backgroundColor=\"" << encodeColor(backgroundColor) << "\" "; if (isUsed(DISPLAY_UNIT_SET)) - writer.Stream() << "displayUnit=\"" << Property::encodeAttribute(displayUnit.stringRep) << "\" "; + writer.Stream() << "displayUnit=\"" << App::Property::encodeAttribute(displayUnit.stringRep) << "\" "; if (isUsed(ALIAS_SET)) - writer.Stream() << "alias=\"" << Property::encodeAttribute(alias) << "\" "; + writer.Stream() << "alias=\"" << App::Property::encodeAttribute(alias) << "\" "; if (isUsed(SPANS_SET)) { writer.Stream() << "rowSpan=\"" << rowSpan<< "\" "; @@ -759,7 +759,7 @@ std::string Cell::encodeAlignment(int alignment) * */ -std::string Cell::encodeColor(const Color & color) +std::string Cell::encodeColor(const App::Color & color) { std::stringstream tmp; @@ -807,10 +807,10 @@ std::string Cell::encodeStyle(const std::set & style) * */ -Color Cell::decodeColor(const std::string & color, const Color & defaultColor) +App::Color Cell::decodeColor(const std::string & color, const App::Color & defaultColor) { if (color.size() == 7 || color.size() == 9) { - Color c; + App::Color c; if (color[0] != '#') return defaultColor; diff --git a/src/Mod/Spreadsheet/App/ExpressionParser.tab.h b/src/Mod/Spreadsheet/App/ExpressionParser.tab.h new file mode 100644 index 0000000000..f671e8df6e --- /dev/null +++ b/src/Mod/Spreadsheet/App/ExpressionParser.tab.h @@ -0,0 +1,74 @@ +/* A Bison parser, made by GNU Bison 2.5. */ + +/* Bison interface for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + FUNC = 258, + NUM = 259, + IDENTIFIER = 260, + UNIT = 261, + INTEGER = 262, + CONSTANT = 263, + CELLADDRESS = 264, + EQ = 265, + NEQ = 266, + LT = 267, + GT = 268, + GTE = 269, + LTE = 270, + STRING = 271, + MINUSSIGN = 272, + PROPERTY_REF = 273, + DOCUMENT = 274, + OBJECT = 275, + EXPONENT = 276, + NEG = 277, + POS = 278 + }; +#endif + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + +extern YYSTYPE yylval; + + diff --git a/src/Mod/Spreadsheet/App/PreCompiled.h b/src/Mod/Spreadsheet/App/PreCompiled.h index 767e0fca10..af4d260d86 100644 --- a/src/Mod/Spreadsheet/App/PreCompiled.h +++ b/src/Mod/Spreadsheet/App/PreCompiled.h @@ -1,5 +1,6 @@ /*************************************************************************** * Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 * + * Copyright (c) Eivind Kvedalen (eivind@kvedalen.name) 2015 * * * * This file is part of the FreeCAD CAx development system. * * * @@ -21,41 +22,58 @@ ***************************************************************************/ -#ifndef __PRECOMPILED__ -#define __PRECOMPILED__ +#ifndef SPREADSHEET_PRECOMPILED_H +#define SPREADSHEET_PRECOMPILED_H #include -// Exporting of App classes +// Importing of App classes #ifdef FC_OS_WIN32 # define SpreadsheetExport __declspec(dllexport) +# define SpreadsheetGuiExport __declspec(dllexport) #else // for Linux # define SpreadsheetExport +# define SpreadsheetGuiExport #endif -/// here get the warnings of to long specifieres disabled (needed for VC6) + +// here get the warnings of too long specifiers disabled (needed for VC6) #ifdef _MSC_VER -# pragma warning( disable : 4251 ) -# pragma warning( disable : 4275 ) -# pragma warning( disable : 4503 ) -# pragma warning( disable : 4786 ) // specifier longer then 255 chars +# pragma warning( disable : 4251 ) +# pragma warning( disable : 4503 ) +# pragma warning( disable : 4786 ) // specifier longer then 255 chars #endif #ifdef _PreComp_ -// standard -#include -#include -#include -#include -#include -#include -#include -#include -#include - +// Python #include -#endif // _PreComp_ +// standard +#include +#include +#include + +// STL +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef FC_OS_WIN32 +# include #endif +// Qt Toolkit +#ifndef __Qt4All__ +# include +#endif + +#endif //_PreComp_ + +#endif // SPREADSHEET_PRECOMPILED_H diff --git a/src/Mod/Spreadsheet/App/PropertyColumnWidths.cpp b/src/Mod/Spreadsheet/App/PropertyColumnWidths.cpp index cba0ecd20f..2d3be00c41 100644 --- a/src/Mod/Spreadsheet/App/PropertyColumnWidths.cpp +++ b/src/Mod/Spreadsheet/App/PropertyColumnWidths.cpp @@ -31,7 +31,6 @@ #include "Utils.h" #include -using namespace App; using namespace Spreadsheet; const int PropertyColumnWidths::defaultWidth = 100; diff --git a/src/Mod/Spreadsheet/App/PropertyRowHeights.cpp b/src/Mod/Spreadsheet/App/PropertyRowHeights.cpp index 9b5aa53cff..8796a6d6d6 100644 --- a/src/Mod/Spreadsheet/App/PropertyRowHeights.cpp +++ b/src/Mod/Spreadsheet/App/PropertyRowHeights.cpp @@ -31,7 +31,6 @@ #include "Utils.h" #include -using namespace App; using namespace Spreadsheet; const int PropertyRowHeights::defaultHeight = 20; @@ -46,7 +45,7 @@ PropertyRowHeights::PropertyRowHeights(const PropertyRowHeights &other) { } -Property *PropertyRowHeights::Copy() const +App::Property *PropertyRowHeights::Copy() const { PropertyRowHeights * prop = new PropertyRowHeights(*this); diff --git a/src/Mod/Spreadsheet/App/PropertySheet.cpp b/src/Mod/Spreadsheet/App/PropertySheet.cpp index f1ab243e3f..2b61971db7 100644 --- a/src/Mod/Spreadsheet/App/PropertySheet.cpp +++ b/src/Mod/Spreadsheet/App/PropertySheet.cpp @@ -38,18 +38,20 @@ #include #include "PropertySheet.h" #include "Sheet.h" -#include "Expression.h" +#include "SpreadsheetExpression.h" #include "Utils.h" #include -using namespace App; +using namespace Base; using namespace Spreadsheet; +namespace Spreadsheet { + class ResolveExpressionVisitor : public ExpressionVisitor { public: void visit(Expression * node) { - VariableExpression *expr = Spreadsheet::freecad_dynamic_cast(node); + VariableExpression *expr = freecad_dynamic_cast(node); if (expr) expr->resolve(); @@ -66,7 +68,7 @@ public: } void visit(Expression * node) { - VariableExpression *expr = Spreadsheet::freecad_dynamic_cast(node); + VariableExpression *expr = freecad_dynamic_cast(node); if (expr) expr->renameDocumentObject(oldName, newName); @@ -80,19 +82,19 @@ private: class BuildDocDepsExpressionVisitor : public ExpressionVisitor { public: - BuildDocDepsExpressionVisitor(std::set & _docDeps) + BuildDocDepsExpressionVisitor(std::set & _docDeps) : docDeps(_docDeps) { } void visit(Expression * node) { - VariableExpression *expr = Spreadsheet::freecad_dynamic_cast(node); + VariableExpression *expr = freecad_dynamic_cast(node); if (expr) { try { const App::Property * prop = expr->getProperty(); - App::DocumentObject * docObj = Spreadsheet::freecad_dynamic_cast(prop->getContainer()); + App::DocumentObject * docObj = freecad_dynamic_cast(prop->getContainer()); if (docObj) docDeps.insert(docObj); @@ -117,7 +119,7 @@ public: } void visit(Expression * node) { - VariableExpression *expr = Spreadsheet::freecad_dynamic_cast(node); + VariableExpression *expr = freecad_dynamic_cast(node); if (expr) expr->renameDocument(oldName, newName); @@ -128,6 +130,8 @@ private: std::string newName; }; +} + TYPESYSTEM_SOURCE(Spreadsheet::PropertySheet , App::Property); void PropertySheet::clear() @@ -224,7 +228,7 @@ PropertySheet::~PropertySheet() clear(); } -Property *PropertySheet::Copy(void) const +App::Property *PropertySheet::Copy(void) const { return new PropertySheet(*this); } @@ -410,13 +414,13 @@ void PropertySheet::setStyle(CellAddress address, const std::set &_ nonNullCellAt(address)->setStyle(_style); } -void PropertySheet::setForeground(CellAddress address, const Color &color) +void PropertySheet::setForeground(CellAddress address, const App::Color &color) { assert(nonNullCellAt(address) != 0); nonNullCellAt(address)->setForeground(color); } -void PropertySheet::setBackground(CellAddress address, const Color &color) +void PropertySheet::setBackground(CellAddress address, const App::Color &color) { assert(nonNullCellAt(address) != 0); nonNullCellAt(address)->setBackground(color); @@ -555,8 +559,8 @@ public: bool changed() const { return mChanged; } void visit(Expression * node) { - VariableExpression *varExpr = Spreadsheet::freecad_dynamic_cast(node); - RangeExpression *rangeExpr = Spreadsheet::freecad_dynamic_cast(node); + VariableExpression *varExpr = freecad_dynamic_cast(node); + RangeExpression *rangeExpr = freecad_dynamic_cast(node); if (varExpr) { @@ -880,8 +884,8 @@ void PropertySheet::addDependencies(CellAddress key) std::set::const_iterator i = expressionDeps.begin(); while (i != expressionDeps.end()) { const Property * prop = i->getProperty(); - const DocumentObject * docObj = i->getDocumentObject(); - Document * doc = i->getDocument(); + const App::DocumentObject * docObj = i->getDocumentObject(); + App::Document * doc = i->getDocument(); std::string docName = doc ? doc->Label.getValue() : i->getDocumentName().getString(); std::string docObjName = docName + "#" + (docObj ? docObj->getNameInDocument() : i->getDocumentObjectName().getString()); @@ -890,7 +894,7 @@ void PropertySheet::addDependencies(CellAddress key) if (!prop) cell->setResolveException("Unresolved dependency"); else { - DocumentObject * docObject = Spreadsheet::freecad_dynamic_cast(prop->getContainer()); + App::DocumentObject * docObject = freecad_dynamic_cast(prop->getContainer()); documentObjectName[docObject] = docObject->Label.getValue(); documentName[docObject->getDocument()] = docObject->getDocument()->Label.getValue(); @@ -986,7 +990,7 @@ void PropertySheet::removeDependencies(CellAddress key) void PropertySheet::recomputeDependants(const Property *prop) { - DocumentObject * owner = Spreadsheet::freecad_dynamic_cast(prop->getContainer()); + App::DocumentObject * owner = freecad_dynamic_cast(prop->getContainer()); const char * name = owner->getPropertyName(prop); assert(name != 0); @@ -1014,7 +1018,7 @@ void PropertySheet::recomputeDependants(const Property *prop) } } -void PropertySheet::invalidateDependants(const DocumentObject *docObj) +void PropertySheet::invalidateDependants(const App::DocumentObject *docObj) { const char * docName = docObj->getDocument()->Label.getValue(); const char * docObjName = docObj->getNameInDocument(); @@ -1042,7 +1046,7 @@ void PropertySheet::invalidateDependants(const DocumentObject *docObj) } } -void PropertySheet::renamedDocumentObject(const DocumentObject * docObj) +void PropertySheet::renamedDocumentObject(const App::DocumentObject * docObj) { // Touch to force recompute touch(); @@ -1063,7 +1067,7 @@ void PropertySheet::renamedDocumentObject(const DocumentObject * docObj) } } -void PropertySheet::renamedDocument(const Document * doc) +void PropertySheet::renamedDocument(const App::Document * doc) { // Touch to force recompute touch(); @@ -1090,7 +1094,7 @@ void PropertySheet::documentSet() documentName[owner->getDocument()] = owner->getDocument()->Label.getValue(); } -void PropertySheet::recomputeDependants(const DocumentObject *docObj) +void PropertySheet::recomputeDependants(const App::DocumentObject *docObj) { const char * docName = docObj->getDocument()->Label.getValue(); const char * docObjName = docObj->getNameInDocument(); diff --git a/src/Mod/Spreadsheet/App/Sheet.cpp b/src/Mod/Spreadsheet/App/Sheet.cpp index 8012826ff0..586748a4e3 100644 --- a/src/Mod/Spreadsheet/App/Sheet.cpp +++ b/src/Mod/Spreadsheet/App/Sheet.cpp @@ -37,7 +37,7 @@ #include #include #include -#include "Expression.h" +#include "SpreadsheetExpression.h" #include "Sheet.h" #include "SheetObserver.h" #include "Utils.h" @@ -51,8 +51,8 @@ #include #include +using namespace Base; using namespace Spreadsheet; -using namespace App; PROPERTY_SOURCE(Spreadsheet::Sheet, App::DocumentObject) @@ -229,7 +229,7 @@ bool Sheet::exportToFile(const std::string &filename, char delimiter, char quote std::set::const_iterator i = usedCells.begin(); while (i != usedCells.end()) { - Property * prop = getProperty(*i); + App::Property * prop = getProperty(*i); if (prevRow != -1 && prevRow != i->row()) { for (int j = prevRow; j < i->row(); ++j) @@ -243,12 +243,12 @@ bool Sheet::exportToFile(const std::string &filename, char delimiter, char quote std::stringstream field; - if (prop->isDerivedFrom((PropertyQuantity::getClassTypeId()))) - field << static_cast(prop)->getValue(); - else if (prop->isDerivedFrom((PropertyFloat::getClassTypeId()))) - field << static_cast(prop)->getValue(); - else if (prop->isDerivedFrom((PropertyString::getClassTypeId()))) - field << static_cast(prop)->getValue(); + if (prop->isDerivedFrom((App::PropertyQuantity::getClassTypeId()))) + field << static_cast(prop)->getValue(); + else if (prop->isDerivedFrom((App::PropertyFloat::getClassTypeId()))) + field << static_cast(prop)->getValue(); + else if (prop->isDerivedFrom((App::PropertyString::getClassTypeId()))) + field << static_cast(prop)->getValue(); else assert(0); @@ -391,12 +391,12 @@ PyObject *Sheet::getPyObject(void) * */ -Property * Sheet::getProperty(CellAddress key) const +App::Property * Sheet::getProperty(CellAddress key) const { return props.getDynamicPropertyByName(key.toString().c_str()); } -Property * Sheet::getProperty(const char * addr) const +App::Property * Sheet::getProperty(const char * addr) const { return props.getDynamicPropertyByName(addr); } @@ -407,7 +407,7 @@ Property * Sheet::getProperty(const char * addr) const * */ -void Sheet::getCellAddress(const Property *prop, CellAddress & address) +void Sheet::getCellAddress(const App::Property *prop, CellAddress & address) { std::map::const_iterator i = propAddress.find(prop); @@ -460,21 +460,21 @@ void Sheet::onSettingDocument() * */ -Property * Sheet::setFloatProperty(CellAddress key, double value) +App::Property * Sheet::setFloatProperty(CellAddress key, double value) { - Property * prop = props.getPropertyByName(key.toString().c_str()); - PropertyFloat * floatProp; + App::Property * prop = props.getPropertyByName(key.toString().c_str()); + App::PropertyFloat * floatProp; - if (!prop || prop->getTypeId() != PropertyFloat::getClassTypeId()) { + if (!prop || prop->getTypeId() != App::PropertyFloat::getClassTypeId()) { if (prop) { props.removeDynamicProperty(key.toString().c_str()); propAddress.erase(prop); } - floatProp = Spreadsheet::freecad_dynamic_cast(props.addDynamicProperty("App::PropertyFloat", key.toString().c_str(), 0, 0, Prop_ReadOnly | Prop_Transient, true, true)); + floatProp = freecad_dynamic_cast(props.addDynamicProperty("App::PropertyFloat", key.toString().c_str(), 0, 0, App::Prop_ReadOnly | App::Prop_Transient, true, true)); floatProp->StatusBits.set(3); } else - floatProp = static_cast(prop); + floatProp = static_cast(prop); propAddress[floatProp] = key; floatProp->setValue(value); @@ -492,9 +492,9 @@ Property * Sheet::setFloatProperty(CellAddress key, double value) * */ -Property * Sheet::setQuantityProperty(CellAddress key, double value, const Base::Unit & unit) +App::Property * Sheet::setQuantityProperty(CellAddress key, double value, const Base::Unit & unit) { - Property * prop = props.getPropertyByName(key.toString().c_str()); + App::Property * prop = props.getPropertyByName(key.toString().c_str()); PropertySpreadsheetQuantity * quantityProp; if (!prop || prop->getTypeId() != PropertySpreadsheetQuantity::getClassTypeId()) { @@ -502,8 +502,8 @@ Property * Sheet::setQuantityProperty(CellAddress key, double value, const Base: props.removeDynamicProperty(key.toString().c_str()); propAddress.erase(prop); } - Property * p = props.addDynamicProperty("Spreadsheet::PropertySpreadsheetQuantity", key.toString().c_str(), 0, 0, Prop_ReadOnly | Prop_Transient, true, true); - quantityProp = Spreadsheet::freecad_dynamic_cast(p); + App::Property * p = props.addDynamicProperty("Spreadsheet::PropertySpreadsheetQuantity", key.toString().c_str(), 0, 0, App::Prop_ReadOnly | App::Prop_Transient, true, true); + quantityProp = freecad_dynamic_cast(p); quantityProp->StatusBits.set(3); } else @@ -527,17 +527,17 @@ Property * Sheet::setQuantityProperty(CellAddress key, double value, const Base: * */ -Property * Sheet::setStringProperty(CellAddress key, const std::string & value) +App::Property * Sheet::setStringProperty(CellAddress key, const std::string & value) { - Property * prop = props.getPropertyByName(key.toString().c_str()); - PropertyString * stringProp = Spreadsheet::freecad_dynamic_cast(prop); + App::Property * prop = props.getPropertyByName(key.toString().c_str()); + App::PropertyString * stringProp = freecad_dynamic_cast(prop); if (!stringProp) { if (prop) { props.removeDynamicProperty(key.toString().c_str()); propAddress.erase(prop); } - stringProp = Spreadsheet::freecad_dynamic_cast(props.addDynamicProperty("App::PropertyString", key.toString().c_str(), 0, 0, Prop_ReadOnly | Prop_Transient, true, true)); + stringProp = freecad_dynamic_cast(props.addDynamicProperty("App::PropertyString", key.toString().c_str(), 0, 0, App::Prop_ReadOnly | App::Prop_Transient, true, true)); stringProp->StatusBits.set(3); } @@ -550,7 +550,7 @@ Property * Sheet::setStringProperty(CellAddress key, const std::string & value) void Sheet::updateAlias(CellAddress key) { std::string alias; - Property * prop = props.getDynamicPropertyByName(key.toString().c_str()); + App::Property * prop = props.getDynamicPropertyByName(key.toString().c_str()); if (!prop) return; @@ -570,7 +570,7 @@ void Sheet::updateAlias(CellAddress key) } if (!aliasProp) - aliasProp = props.addDynamicProperty(prop->getTypeId().getName(), alias.c_str(), 0, 0, Prop_ReadOnly | Prop_Transient, true, true); + aliasProp = props.addDynamicProperty(prop->getTypeId().getName(), alias.c_str(), 0, 0, App::Prop_ReadOnly | App::Prop_Transient, true, true); aliasProp->Paste(*prop); } @@ -604,7 +604,7 @@ void Sheet::updateProperty(CellAddress key) } /* Eval returns either NumberExpression or StringExpression objects */ - if (Spreadsheet::freecad_dynamic_cast(output)) { + if (freecad_dynamic_cast(output)) { NumberExpression * number = static_cast(output); if (number->getUnit().isEmpty()) setFloatProperty(key, number->getValue()); @@ -612,7 +612,7 @@ void Sheet::updateProperty(CellAddress key) setQuantityProperty(key, number->getValue(), number->getUnit()); } else - setStringProperty(key, Spreadsheet::freecad_dynamic_cast(output)->getText().c_str()); + setStringProperty(key, freecad_dynamic_cast(output)->getText().c_str()); delete output; } @@ -631,9 +631,9 @@ void Sheet::updateProperty(CellAddress key) * */ -Property *Sheet::getPropertyByName(const char* name) const +App::Property *Sheet::getPropertyByName(const char* name) const { - Property * prop = getProperty(name); + App::Property * prop = getProperty(name); if (prop) return prop; @@ -641,7 +641,7 @@ Property *Sheet::getPropertyByName(const char* name) const return DocumentObject::getPropertyByName(name); } -const char *Sheet::getPropertyName(const Property *prop) const +const char *Sheet::getPropertyName(const App::Property *prop) const { const char * name = props.getPropertyName(prop); @@ -811,7 +811,7 @@ App::DocumentObjectExecReturn *Sheet::execute(void) if (cellErrors.size() == 0) return App::DocumentObject::StdReturn; else - return new DocumentObjectExecReturn("One or more cells failed contains errors.", this); + return new App::DocumentObjectExecReturn("One or more cells failed contains errors.", this); } /** @@ -845,7 +845,7 @@ void Sheet::clear(CellAddress address, bool all) { Cell * cell = getCell(address); std::string addr = address.toString(); - Property * prop = props.getDynamicPropertyByName(addr.c_str()); + App::Property * prop = props.getDynamicPropertyByName(addr.c_str()); // Remove alias, if defined std::string aliasStr; @@ -1005,12 +1005,12 @@ void Sheet::setStyle(CellAddress address, const std::set &_style) cells.setStyle(address, _style); } -void Sheet::setForeground(CellAddress address, const Color &color) +void Sheet::setForeground(CellAddress address, const App::Color &color) { cells.setForeground(address, color); } -void Sheet::setBackground(CellAddress address, const Color &color) +void Sheet::setBackground(CellAddress address, const App::Color &color) { cells.setBackground(address, color); } @@ -1087,17 +1087,17 @@ void Sheet::onDocumentRestored() execute(); } -void Sheet::onRelabledDocument(const Document &document) +void Sheet::onRelabledDocument(const App::Document &document) { cells.renamedDocument(&document); cells.purgeTouched(); } -void Sheet::onRenamedDocument(const Document &document) +void Sheet::onRenamedDocument(const App::Document &document) { } -void Sheet::observeDocument(Document * document) +void Sheet::observeDocument(App::Document * document) { ObserverMap::const_iterator it = observers.find(document->getName()); @@ -1115,7 +1115,7 @@ void Sheet::observeDocument(Document * document) TYPESYSTEM_SOURCE(Spreadsheet::PropertySpreadsheetQuantity, App::PropertyQuantity); -Property *PropertySpreadsheetQuantity::Copy() const +App::Property *PropertySpreadsheetQuantity::Copy() const { PropertySpreadsheetQuantity * obj = new PropertySpreadsheetQuantity(); diff --git a/src/Mod/Spreadsheet/App/Expression.cpp b/src/Mod/Spreadsheet/App/SpreadsheetExpression.cpp similarity index 93% rename from src/Mod/Spreadsheet/App/Expression.cpp rename to src/Mod/Spreadsheet/App/SpreadsheetExpression.cpp index 21d1973eec..8e2d4e48d7 100644 --- a/src/Mod/Spreadsheet/App/Expression.cpp +++ b/src/Mod/Spreadsheet/App/SpreadsheetExpression.cpp @@ -41,7 +41,7 @@ #include #include #include -#include "Expression.h" +#include "SpreadsheetExpression.h" #include #include #include "Utils.h" @@ -65,7 +65,6 @@ #endif using namespace Base; -using namespace App; using namespace Spreadsheet; Path::Path(const App::DocumentObject * _owner, const std::string & property) @@ -141,7 +140,7 @@ int Path::numComponents() const return components.size(); } -Path Path::parse(const DocumentObject * docObj, const char *expr) +Path Path::parse(const App::DocumentObject * docObj, const char *expr) { return Path(); } @@ -173,17 +172,17 @@ std::string Path::toString() const std::string Path::getPythonAccessor() const { - const Property * prop = getProperty(); + const App::Property * prop = getProperty(); if (!prop) throw Exception(std::string("Property '") + getPropertyName() + std::string("' not found.")); - const DocumentObject * docObj = Spreadsheet::freecad_dynamic_cast(prop->getContainer()); + const App::DocumentObject * docObj = freecad_dynamic_cast(prop->getContainer()); if (!docObj) throw Exception("Document object not found"); - const Document * doc = docObj->getDocument(); + const App::Document * doc = docObj->getDocument(); return "App.getDocument('" + std::string(doc->getName()) + "')." + @@ -296,7 +295,7 @@ std::string Path::Component::toString() const TYPESYSTEM_SOURCE_ABSTRACT(Spreadsheet::Expression, Base::BaseClass); -Expression::Expression(const DocumentObject *_owner) +Expression::Expression(const App::DocumentObject *_owner) : owner(_owner) { @@ -306,7 +305,7 @@ Expression::~Expression() { } -Expression * Expression::parse(const DocumentObject *owner, const std::string &buffer) +Expression * Expression::parse(const App::DocumentObject *owner, const std::string &buffer) { return ExpressionParser::parse(owner, buffer.c_str()); } @@ -317,7 +316,7 @@ Expression * Expression::parse(const DocumentObject *owner, const std::string &b TYPESYSTEM_SOURCE(Spreadsheet::UnitExpression, Spreadsheet::Expression); -UnitExpression::UnitExpression(const DocumentObject *_owner, const Base::Quantity & _quantity, const std::string &_unitStr) +UnitExpression::UnitExpression(const App::DocumentObject *_owner, const Base::Quantity & _quantity, const std::string &_unitStr) : Expression(_owner) , quantity(_quantity) , unitStr(_unitStr) @@ -386,7 +385,7 @@ Expression *UnitExpression::copy() const TYPESYSTEM_SOURCE(Spreadsheet::NumberExpression, Spreadsheet::Expression); -NumberExpression::NumberExpression(const DocumentObject *_owner, const Quantity &_quantity) +NumberExpression::NumberExpression(const App::DocumentObject *_owner, const Quantity &_quantity) : UnitExpression(_owner, _quantity) { } @@ -483,8 +482,8 @@ Expression * OperatorExpression::eval() const NumberExpression * v2; NumberExpression * output = 0; - v1 = Spreadsheet::freecad_dynamic_cast(e1.get()); - v2 = Spreadsheet::freecad_dynamic_cast(e2.get()); + v1 = freecad_dynamic_cast(e1.get()); + v2 = freecad_dynamic_cast(e2.get()); if (v1 == 0 || v2 == 0) throw Exception("Invalid expression"); @@ -567,7 +566,7 @@ Expression *OperatorExpression::simplify() const Expression * v2 = right->simplify(); // Both arguments reduced to numerics? Then evaluate and return answer - if (Spreadsheet::freecad_dynamic_cast(v1) && Spreadsheet::freecad_dynamic_cast(v2)) { + if (freecad_dynamic_cast(v1) && freecad_dynamic_cast(v2)) { delete v1; delete v2; return eval(); @@ -718,7 +717,7 @@ void OperatorExpression::visit(ExpressionVisitor &v) TYPESYSTEM_SOURCE(Spreadsheet::FunctionExpression, Spreadsheet::UnitExpression); -FunctionExpression::FunctionExpression(const DocumentObject *_owner, Function _f, std::vector _args) +FunctionExpression::FunctionExpression(const App::DocumentObject *_owner, Function _f, std::vector _args) : UnitExpression(_owner) , f(_f) , args(_args) @@ -785,7 +784,7 @@ Expression * FunctionExpression::eval() const case MIN: case MAX: { - RangeExpression * v = Spreadsheet::freecad_dynamic_cast(args[0]); + RangeExpression * v = freecad_dynamic_cast(args[0]); Quantity q; Quantity mean; Quantity M2; @@ -799,17 +798,17 @@ Expression * FunctionExpression::eval() const Range range(v->getRange()); do { - Property * p = owner->getPropertyByName(range.address().c_str()); - PropertyQuantity * qp; - PropertyFloat * fp; + App::Property * p = owner->getPropertyByName(range.address().c_str()); + App::PropertyQuantity * qp; + App::PropertyFloat * fp; Quantity value; if (!p) continue; - if ( (qp = Spreadsheet::freecad_dynamic_cast(p)) ) + if ( (qp = freecad_dynamic_cast(p)) ) value = qp->getQuantityValue(); - else if ( (fp = Spreadsheet::freecad_dynamic_cast(p)) ) + else if ( (fp = freecad_dynamic_cast(p)) ) value = fp->getValue(); else throw Exception("Invalid property type for aggregate"); @@ -875,8 +874,8 @@ Expression * FunctionExpression::eval() const std::auto_ptr e1(args[0]->eval()); std::auto_ptr e2(args.size() > 1 ? args[1]->eval() : 0); - NumberExpression * v1 = Spreadsheet::freecad_dynamic_cast(e1.get()); - NumberExpression * v2 = Spreadsheet::freecad_dynamic_cast(e2.get()); + NumberExpression * v1 = freecad_dynamic_cast(e1.get()); + NumberExpression * v2 = freecad_dynamic_cast(e2.get()); double output = 0; Unit unit; double scaler = 1; @@ -1055,7 +1054,7 @@ Expression *FunctionExpression::simplify() const Expression * v1 = args[0]->simplify(); // Argument simplified to numeric expression? Then return evaluate and return - if (Spreadsheet::freecad_dynamic_cast(v1)) { + if (freecad_dynamic_cast(v1)) { switch (f) { case ATAN2: case MOD: @@ -1063,7 +1062,7 @@ Expression *FunctionExpression::simplify() const { Expression * v2 = args[1]->simplify(); - if (Spreadsheet::freecad_dynamic_cast(v2)) { + if (freecad_dynamic_cast(v2)) { delete v1; delete v2; return eval(); @@ -1199,7 +1198,7 @@ void FunctionExpression::visit(ExpressionVisitor &v) TYPESYSTEM_SOURCE(Spreadsheet::VariableExpression, Spreadsheet::UnitExpression); -VariableExpression::VariableExpression(const DocumentObject *_owner, Path _var) +VariableExpression::VariableExpression(const App::DocumentObject *_owner, Path _var) : UnitExpression(_owner) , var(_var) { @@ -1228,11 +1227,11 @@ bool VariableExpression::isTouched() const const App::DocumentObject * Path::getDocumentObject(const App::Document * doc, const std::string & name) const { - DocumentObject * o1 = 0; - DocumentObject * o2 = 0; - std::vector docObjects = doc->getObjects(); + App::DocumentObject * o1 = 0; + App::DocumentObject * o2 = 0; + std::vector docObjects = doc->getObjects(); - for (std::vector::iterator j = docObjects.begin(); j != docObjects.end(); ++j) { + for (std::vector::iterator j = docObjects.begin(); j != docObjects.end(); ++j) { if (strcmp((*j)->Label.getValue(), name.c_str()) == 0) { // Found object with matching label if (o1 != 0) @@ -1323,7 +1322,7 @@ void Path::resolve() } } -Document * Path::getDocument() const +App::Document * Path::getDocument() const { App::Document * doc = 0; const std::vector docs = App::GetApplication().getDocuments(); @@ -1339,7 +1338,7 @@ Document * Path::getDocument() const return doc; } -const DocumentObject *Path::getDocumentObject() const +const App::DocumentObject *Path::getDocumentObject() const { const App::Document * doc = getDocument(); @@ -1349,7 +1348,7 @@ const DocumentObject *Path::getDocumentObject() const return getDocumentObject(doc, documentObjectName); } -const Property *Path::getProperty() const +const App::Property *Path::getProperty() const { const App::Document * doc = getDocument(); @@ -1376,12 +1375,12 @@ const Property *Path::getProperty() const * @returns The Property object if it is derived from either PropertyInteger, PropertyFloat, or PropertyString. */ -const Property * VariableExpression::getProperty() const +const App::Property * VariableExpression::getProperty() const { #ifdef FULL_EXPRESSION_SUPPORT const Property * prop = docObject->getPropertyByPath(var); #else - const Property * prop = var.getProperty(); + const App::Property * prop = var.getProperty(); #endif if (prop) return prop; @@ -1523,7 +1522,7 @@ void VariableExpression::renameDocument(const std::string &oldName, const std::s TYPESYSTEM_SOURCE(Spreadsheet::StringExpression, Spreadsheet::Expression); -StringExpression::StringExpression(const DocumentObject *_owner, const std::string &_text) +StringExpression::StringExpression(const App::DocumentObject *_owner, const std::string &_text) : Expression(_owner) , text(_text) { @@ -1563,7 +1562,7 @@ Expression *StringExpression::copy() const TYPESYSTEM_SOURCE(Spreadsheet::ConditionalExpression, Spreadsheet::Expression); -ConditionalExpression::ConditionalExpression(const DocumentObject *_owner, Expression *_condition, Expression *_trueExpr, Expression *_falseExpr) +ConditionalExpression::ConditionalExpression(const App::DocumentObject *_owner, Expression *_condition, Expression *_trueExpr, Expression *_falseExpr) : Expression(_owner) , condition(_condition) , trueExpr(_trueExpr) @@ -1586,7 +1585,7 @@ bool ConditionalExpression::isTouched() const Expression *ConditionalExpression::eval() const { std::auto_ptr e(condition->eval()); - NumberExpression * v = Spreadsheet::freecad_dynamic_cast(e.get()); + NumberExpression * v = freecad_dynamic_cast(e.get()); if (v == 0) throw Exception("Invalid expression"); @@ -1600,7 +1599,7 @@ Expression *ConditionalExpression::eval() const Expression *ConditionalExpression::simplify() const { std::auto_ptr e(condition->simplify()); - NumberExpression * v = Spreadsheet::freecad_dynamic_cast(e.get()); + NumberExpression * v = freecad_dynamic_cast(e.get()); if (v == 0) return new ConditionalExpression(owner, condition->simplify(), trueExpr->simplify(), falseExpr->simplify()); @@ -1643,7 +1642,7 @@ void ConditionalExpression::visit(ExpressionVisitor &v) TYPESYSTEM_SOURCE(Spreadsheet::ConstantExpression, Spreadsheet::NumberExpression); -ConstantExpression::ConstantExpression(const DocumentObject *_owner, std::string _name, const Quantity & _quantity) +ConstantExpression::ConstantExpression(const App::DocumentObject *_owner, std::string _name, const Quantity & _quantity) : NumberExpression(_owner, _quantity) , name(_name) { @@ -1702,15 +1701,19 @@ static std::stack labels; /**< Label string primitiv static std::map registered_functions; /**< Registerd functions */ // show the parser the lexer method +#undef YYTOKENTYPE +#undef YYSTYPE +#undef YYSTYPE_ISDECLARED #define yylex ExpressionParserlex int ExpressionParserlex(void); // Parser, defined in ExpressionParser.y -#include "ExpressionParser.tab.c" +#include +#include #ifndef DOXYGEN_SHOULD_SKIP_THIS // Scanner, defined in ExpressionParser.l -#include "lex.ExpressionParser.c" +#include #endif // DOXYGEN_SHOULD_SKIP_THIS #ifdef _MSC_VER # define strdup _strdup @@ -1776,7 +1779,7 @@ std::string Path::String::toString() const TYPESYSTEM_SOURCE(Spreadsheet::RangeExpression, Spreadsheet::Expression); -RangeExpression::RangeExpression(const DocumentObject *_owner, const std::string &begin, const std::string &end) +RangeExpression::RangeExpression(const App::DocumentObject *_owner, const std::string &begin, const std::string &end) : Expression(_owner) , range((begin + ":" + end).c_str()) { @@ -1787,7 +1790,7 @@ bool RangeExpression::isTouched() const Range i(range); do { - Property * prop = owner->getPropertyByName(i.address().c_str()); + App::Property * prop = owner->getPropertyByName(i.address().c_str()); if (prop && prop->isTouched()) return true; @@ -1895,13 +1898,13 @@ UnitExpression * ExpressionParser::parseUnit(const App::DocumentObject *owner, c delete ScanResult; if (unitExpression) { - NumberExpression * num = Spreadsheet::freecad_dynamic_cast(simplified); + NumberExpression * num = freecad_dynamic_cast(simplified); if (num) { simplified = new UnitExpression(num->getOwner(), num->getQuantity()); delete num; } - return Spreadsheet::freecad_dynamic_cast(simplified); + return freecad_dynamic_cast(simplified); } else { delete simplified; diff --git a/src/Mod/Spreadsheet/App/Expression.h b/src/Mod/Spreadsheet/App/SpreadsheetExpression.h similarity index 99% rename from src/Mod/Spreadsheet/App/Expression.h rename to src/Mod/Spreadsheet/App/SpreadsheetExpression.h index b55857f5a1..17b4228c4e 100644 --- a/src/Mod/Spreadsheet/App/Expression.h +++ b/src/Mod/Spreadsheet/App/SpreadsheetExpression.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef EXPRESSION_H -#define EXPRESSION_H +#ifndef SPREADSHEET_EXPRESSION_H +#define SPREADSHEET_EXPRESSION_H #include #include diff --git a/src/Mod/Spreadsheet/App/Utils.h b/src/Mod/Spreadsheet/App/Utils.h index 411f8b54ea..ec411865a4 100644 --- a/src/Mod/Spreadsheet/App/Utils.h +++ b/src/Mod/Spreadsheet/App/Utils.h @@ -28,6 +28,7 @@ #include #include #include +#include "PreCompiled.h" namespace Spreadsheet { @@ -82,14 +83,6 @@ protected: short _col; }; -template T * freecad_dynamic_cast(Base::BaseClass * t) -{ - if (t && t->isDerivedFrom(T::getClassTypeId())) - return static_cast(t); - else - return 0; -} - } #endif // UTILS_H diff --git a/src/Mod/Spreadsheet/Gui/Command.cpp b/src/Mod/Spreadsheet/Gui/Command.cpp index 0970cccdc1..20e06f86a7 100644 --- a/src/Mod/Spreadsheet/Gui/Command.cpp +++ b/src/Mod/Spreadsheet/Gui/Command.cpp @@ -43,6 +43,7 @@ using namespace SpreadsheetGui; using namespace Spreadsheet; +using namespace Base; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -64,7 +65,7 @@ void CmdSpreadsheetMergeCells::activated(int iMsg) { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { Sheet * sheet = sheetView->getSheet(); @@ -91,7 +92,7 @@ bool CmdSpreadsheetMergeCells::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && Spreadsheet::freecad_dynamic_cast(activeWindow)) + if (activeWindow && freecad_dynamic_cast(activeWindow)) return true; } @@ -118,7 +119,7 @@ void CmdSpreadsheetSplitCell::activated(int iMsg) { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { Sheet * sheet = sheetView->getSheet(); @@ -140,7 +141,7 @@ bool CmdSpreadsheetSplitCell::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { QModelIndex current = sheetView->currentIndex(); @@ -180,7 +181,7 @@ void CmdSpreadsheetImport::activated(int iMsg) &selectedFilter); if (!fileName.isEmpty()) { std::string FeatName = getUniqueObjectName("Spreadsheet"); - Sheet * sheet = Spreadsheet::freecad_dynamic_cast(App::GetApplication().getActiveDocument()->addObject("Spreadsheet::Sheet", FeatName.c_str())); + Sheet * sheet = freecad_dynamic_cast(App::GetApplication().getActiveDocument()->addObject("Spreadsheet::Sheet", FeatName.c_str())); sheet->importFromFile(fileName.toStdString(), '\t', '"', '\\'); sheet->execute(); @@ -212,7 +213,7 @@ void CmdSpreadsheetExport::activated(int iMsg) { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { Sheet * sheet = sheetView->getSheet(); @@ -233,7 +234,7 @@ bool CmdSpreadsheetExport::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && Spreadsheet::freecad_dynamic_cast(activeWindow)) + if (activeWindow && freecad_dynamic_cast(activeWindow)) return true; } @@ -260,7 +261,7 @@ void CmdSpreadsheetAlignLeft::activated(int iMsg) { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { Sheet * sheet = sheetView->getSheet(); @@ -284,7 +285,7 @@ bool CmdSpreadsheetAlignLeft::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && Spreadsheet::freecad_dynamic_cast(activeWindow)) + if (activeWindow && freecad_dynamic_cast(activeWindow)) return true; } @@ -311,7 +312,7 @@ void CmdSpreadsheetAlignCenter::activated(int iMsg) { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { Sheet * sheet = sheetView->getSheet(); @@ -335,7 +336,7 @@ bool CmdSpreadsheetAlignCenter::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && Spreadsheet::freecad_dynamic_cast(activeWindow)) + if (activeWindow && freecad_dynamic_cast(activeWindow)) return true; } @@ -362,7 +363,7 @@ void CmdSpreadsheetAlignRight::activated(int iMsg) { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { Sheet * sheet = sheetView->getSheet(); @@ -386,7 +387,7 @@ bool CmdSpreadsheetAlignRight::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && Spreadsheet::freecad_dynamic_cast(activeWindow)) + if (activeWindow && freecad_dynamic_cast(activeWindow)) return true; } @@ -413,7 +414,7 @@ void CmdSpreadsheetAlignTop::activated(int iMsg) { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { Sheet * sheet = sheetView->getSheet(); @@ -437,7 +438,7 @@ bool CmdSpreadsheetAlignTop::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && Spreadsheet::freecad_dynamic_cast(activeWindow)) + if (activeWindow && freecad_dynamic_cast(activeWindow)) return true; } @@ -464,7 +465,7 @@ void CmdSpreadsheetAlignBottom::activated(int iMsg) { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { Sheet * sheet = sheetView->getSheet(); @@ -488,7 +489,7 @@ bool CmdSpreadsheetAlignBottom::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && Spreadsheet::freecad_dynamic_cast(activeWindow)) + if (activeWindow && freecad_dynamic_cast(activeWindow)) return true; } @@ -515,7 +516,7 @@ void CmdSpreadsheetAlignVCenter::activated(int iMsg) { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { Sheet * sheet = sheetView->getSheet(); @@ -539,7 +540,7 @@ bool CmdSpreadsheetAlignVCenter::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && Spreadsheet::freecad_dynamic_cast(activeWindow)) + if (activeWindow && freecad_dynamic_cast(activeWindow)) return true; } @@ -566,7 +567,7 @@ void CmdSpreadsheetStyleBold::activated(int iMsg) { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { Sheet * sheet = sheetView->getSheet(); @@ -612,7 +613,7 @@ bool CmdSpreadsheetStyleBold::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && Spreadsheet::freecad_dynamic_cast(activeWindow)) + if (activeWindow && freecad_dynamic_cast(activeWindow)) return true; } @@ -639,7 +640,7 @@ void CmdSpreadsheetStyleItalic::activated(int iMsg) { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { Sheet * sheet = sheetView->getSheet(); @@ -685,7 +686,7 @@ bool CmdSpreadsheetStyleItalic::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && Spreadsheet::freecad_dynamic_cast(activeWindow)) + if (activeWindow && freecad_dynamic_cast(activeWindow)) return true; } @@ -712,7 +713,7 @@ void CmdSpreadsheetStyleUnderline::activated(int iMsg) { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { Sheet * sheet = sheetView->getSheet(); @@ -758,7 +759,7 @@ bool CmdSpreadsheetStyleUnderline::isActive() { if (getActiveGuiDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - if (activeWindow && Spreadsheet::freecad_dynamic_cast(activeWindow)) + if (activeWindow && freecad_dynamic_cast(activeWindow)) return true; } diff --git a/src/Mod/Spreadsheet/Gui/PreCompiled.h b/src/Mod/Spreadsheet/Gui/PreCompiled.h index 59e66e414b..26ace30bca 100644 --- a/src/Mod/Spreadsheet/Gui/PreCompiled.h +++ b/src/Mod/Spreadsheet/Gui/PreCompiled.h @@ -1,5 +1,6 @@ /*************************************************************************** * Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2002 * + * Copyright (c) Eivind Kvedalen (eivind@kvedalen.name) 2015 * * * * This file is part of the FreeCAD CAx development system. * * * @@ -21,8 +22,8 @@ ***************************************************************************/ -#ifndef __PRECOMPILED_GUI__ -#define __PRECOMPILED_GUI__ +#ifndef SPREADSHEET_PRECOMPILED_H +#define SPREADSHEET_PRECOMPILED_H #include @@ -76,4 +77,4 @@ #endif //_PreComp_ -#endif // __PRECOMPILED_GUI__ +#endif // SPREADSHEET_PRECOMPILED_H diff --git a/src/Mod/Spreadsheet/Gui/PropertiesDialog.cpp b/src/Mod/Spreadsheet/Gui/PropertiesDialog.cpp index 58fa3097d8..920580e9e0 100644 --- a/src/Mod/Spreadsheet/Gui/PropertiesDialog.cpp +++ b/src/Mod/Spreadsheet/Gui/PropertiesDialog.cpp @@ -22,7 +22,7 @@ #include "PropertiesDialog.h" #include -#include +#include #include #include #include "ui_PropertiesDialog.h" diff --git a/src/Mod/Spreadsheet/Gui/SheetModel.cpp b/src/Mod/Spreadsheet/Gui/SheetModel.cpp index ebcacb8199..6b015aa6da 100644 --- a/src/Mod/Spreadsheet/Gui/SheetModel.cpp +++ b/src/Mod/Spreadsheet/Gui/SheetModel.cpp @@ -29,7 +29,7 @@ #endif #include "SheetModel.h" -#include +#include #include #include "../App/Sheet.h" #include diff --git a/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp b/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp index 4465d08cf8..6ae10c4519 100644 --- a/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp +++ b/src/Mod/Spreadsheet/Gui/SpreadsheetView.cpp @@ -37,7 +37,7 @@ #include "SpreadsheetView.h" #include "SpreadsheetDelegate.h" -#include +#include #include #include #include diff --git a/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheet.cpp b/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheet.cpp index 9745c3cf3a..36df390572 100644 --- a/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheet.cpp +++ b/src/Mod/Spreadsheet/Gui/ViewProviderSpreadsheet.cpp @@ -46,6 +46,7 @@ #include #include +using namespace Base; using namespace Gui; using namespace SpreadsheetGui; using namespace Spreadsheet; @@ -137,7 +138,7 @@ void ViewProviderSheet::setupContextMenu(QMenu * menu, QObject *receiver, const Sheet *ViewProviderSheet::getSpreadsheetObject() const { - return Spreadsheet::freecad_dynamic_cast(pcObject); + return freecad_dynamic_cast(pcObject); } bool ViewProviderSheet::onDelete(const std::vector &) @@ -149,7 +150,7 @@ bool ViewProviderSheet::onDelete(const std::vector &) // View is not closed, delete cell contents instead if it is active if (Gui::Application::Instance->activeDocument()) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { Sheet * sheet = sheetView->getSheet(); diff --git a/src/Mod/Spreadsheet/Gui/Workbench.cpp b/src/Mod/Spreadsheet/Gui/Workbench.cpp index f1348a8815..bc77824c22 100644 --- a/src/Mod/Spreadsheet/Gui/Workbench.cpp +++ b/src/Mod/Spreadsheet/Gui/Workbench.cpp @@ -40,6 +40,7 @@ #include "Mod/Spreadsheet/App/Range.h" #include "Mod/Spreadsheet/Gui/SpreadsheetView.h" +using namespace Base; using namespace SpreadsheetGui; using namespace Spreadsheet; @@ -107,7 +108,7 @@ void WorkbenchHelper::setForegroundColor(const QColor & color) if (doc) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { Sheet * sheet = sheetView->getSheet(); @@ -134,7 +135,7 @@ void WorkbenchHelper::setBackgroundColor(const QColor & color) if (doc) { Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow(); - SpreadsheetGui::SheetView * sheetView = Spreadsheet::freecad_dynamic_cast(activeWindow); + SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast(activeWindow); if (sheetView) { Sheet * sheet = sheetView->getSheet();