Expression/ObjectIdentifier: changed return type of renameDocumentObject and renameDocument,
to be able to signal that a rename actually took place.
This commit is contained in:
parent
83d221e161
commit
65a610d1cb
|
@ -1090,14 +1090,14 @@ void VariableExpression::setPath(const ObjectIdentifier &path)
|
||||||
var = path;
|
var = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VariableExpression::renameDocumentObject(const std::string &oldName, const std::string &newName)
|
bool VariableExpression::renameDocumentObject(const std::string &oldName, const std::string &newName)
|
||||||
{
|
{
|
||||||
var.renameDocumentObject(oldName, newName);
|
return var.renameDocumentObject(oldName, newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VariableExpression::renameDocument(const std::string &oldName, const std::string &newName)
|
bool VariableExpression::renameDocument(const std::string &oldName, const std::string &newName)
|
||||||
{
|
{
|
||||||
var.renameDocument(oldName, newName);
|
return var.renameDocument(oldName, newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -349,9 +349,9 @@ public:
|
||||||
|
|
||||||
void setPath(const ObjectIdentifier & path);
|
void setPath(const ObjectIdentifier & path);
|
||||||
|
|
||||||
void renameDocumentObject(const std::string & oldName, const std::string & newName);
|
bool renameDocumentObject(const std::string & oldName, const std::string & newName);
|
||||||
|
|
||||||
void renameDocument(const std::string &oldName, const std::string &newName);
|
bool renameDocument(const std::string &oldName, const std::string &newName);
|
||||||
|
|
||||||
const App::Property *getProperty() const;
|
const App::Property *getProperty() const;
|
||||||
|
|
||||||
|
|
|
@ -316,21 +316,30 @@ std::string ObjectIdentifier::toEscapedString() const
|
||||||
* @param newName New name of document object
|
* @param newName New name of document object
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ObjectIdentifier::renameDocumentObject(const std::string &oldName, const std::string &newName)
|
bool ObjectIdentifier::renameDocumentObject(const std::string &oldName, const std::string &newName)
|
||||||
{
|
{
|
||||||
if (documentObjectNameSet && documentObjectName == oldName) {
|
if (oldName == newName)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (documentObjectNameSet && documentObjectName == oldName) {
|
||||||
if (ExpressionParser::isTokenAnIndentifier(newName))
|
if (ExpressionParser::isTokenAnIndentifier(newName))
|
||||||
documentObjectName = newName;
|
documentObjectName = newName;
|
||||||
else
|
else
|
||||||
documentObjectName = ObjectIdentifier::String(newName, true);
|
documentObjectName = ObjectIdentifier::String(newName, true);
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (propertyIndex == 1 && documentObjectName == oldName) {
|
else if (propertyIndex == 1 && documentObjectName == oldName) {
|
||||||
if (ExpressionParser::isTokenAnIndentifier(newName))
|
if (ExpressionParser::isTokenAnIndentifier(newName))
|
||||||
components[0].name = newName;
|
components[0].name = newName;
|
||||||
else
|
else
|
||||||
components[0].name = ObjectIdentifier::String(newName, true);
|
components[0].name = ObjectIdentifier::String(newName, true);
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
resolve();
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -339,13 +348,18 @@ void ObjectIdentifier::renameDocumentObject(const std::string &oldName, const st
|
||||||
* @param newName New name of document
|
* @param newName New name of document
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ObjectIdentifier::renameDocument(const std::string &oldName, const std::string &newName)
|
bool ObjectIdentifier::renameDocument(const std::string &oldName, const std::string &newName)
|
||||||
{
|
{
|
||||||
|
if (oldName == newName)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (documentName == oldName) {
|
if (documentName == oldName) {
|
||||||
documentName = newName;
|
documentName = newName;
|
||||||
|
resolve();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve();
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -186,9 +186,9 @@ public:
|
||||||
|
|
||||||
const String getDocumentObjectName() const;
|
const String getDocumentObjectName() const;
|
||||||
|
|
||||||
void renameDocumentObject(const std::string & oldName, const std::string & newName);
|
bool renameDocumentObject(const std::string & oldName, const std::string & newName);
|
||||||
|
|
||||||
void renameDocument(const std::string &oldName, const std::string &newName);
|
bool renameDocument(const std::string &oldName, const std::string &newName);
|
||||||
|
|
||||||
App::Document *getDocument(String name = String()) const;
|
App::Document *getDocument(String name = String()) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user