Update of /cvsroot/objecthandler/ObjectHandler/ohxl
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv23368/ohxl
Modified Files:
callingrange.cpp callingrange.hpp objecthandlerxl.cpp
objecthandlerxl.hpp
Log Message:
support for right-clicking in cell to see error message
Index: objecthandlerxl.cpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/objecthandlerxl.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** objecthandlerxl.cpp 29 Aug 2006 13:47:14 -0000 1.14
--- objecthandlerxl.cpp 31 Aug 2006 11:00:47 -0000 1.15
***************
*** 17,20 ****
--- 17,21 ----
#include <oh/exception.hpp>
+ #include <oh/utilities.hpp>
#include <ohxl/objecthandlerxl.hpp>
#include <ohxl/callingrange.hpp>
***************
*** 40,43 ****
--- 41,45 ----
// so instead we use a static variable
std::map<std::string, boost::shared_ptr<CallingRange> > callingRanges_;
+ typedef std::map<std::string, boost::shared_ptr<CallingRange> >::const_iterator rangeMapIter;
ObjectHandlerXL &ObjectHandlerXL::instance() {
***************
*** 49,58 ****
}
! boost::shared_ptr<CallingRange> ObjectHandlerXL::getCallingRange() {
! // XLOPERs which might need freeing in the event of an exception
XLOPER xOldName;
- XLOPER xValue;
try {
--- 51,59 ----
}
! boost::shared_ptr<CallingRange> ObjectHandlerXL::getCallingRange(bool createIfNone) {
! // XLOPER which might need freeing in the event of an exception
XLOPER xOldName;
try {
***************
*** 69,74 ****
operToScalar(oldKey, xOldName);
Excel(xlFree, 0, 1, &xOldName);
! std::map<std::string, boost::shared_ptr<CallingRange> >::const_iterator i;
! i = callingRanges_.find(oldKey);
if (i == callingRanges_.end()) {
std::ostringstream msg;
--- 70,74 ----
operToScalar(oldKey, xOldName);
Excel(xlFree, 0, 1, &xOldName);
! rangeMapIter i = callingRanges_.find(oldKey);
if (i == callingRanges_.end()) {
std::ostringstream msg;
***************
*** 77,81 ****
} else {
callingRange = i->second;
! //callingRange->update();
}
}
--- 77,85 ----
} else {
callingRange = i->second;
! }
! } else {
! if (createIfNone) {
! callingRange = boost::shared_ptr<CallingRange>(new CallingRange);
! callingRanges_[callingRange->getKey()] = callingRange;
}
}
***************
*** 87,91 ****
// free any memory that may have been allocated
! Excel(xlFree, 0, 2, &xOldName, &xValue);
// propagate the exception
--- 91,95 ----
// free any memory that may have been allocated
! Excel(xlFree, 0, 1, &xOldName);
// propagate the exception
***************
*** 101,111 ****
if (FunctionCall::instance().getCallerType() != Cell)
return;
! boost::shared_ptr<CallingRange> callingRange = getCallingRange();
! if (!callingRange && createIfNone) {
! callingRange = boost::shared_ptr<CallingRange>(new CallingRange);
! callingRanges_[callingRange->getKey()] = callingRange;
! }
! if (callingRange)
! callingRange->update();
}
--- 105,110 ----
if (FunctionCall::instance().getCallerType() != Cell)
return;
! boost::shared_ptr<CallingRange> callingRange = getCallingRange(createIfNone);
! if (callingRange) callingRange->update();
}
***************
*** 170,174 ****
void ObjectHandlerXL::collectGarbage(const bool &deletePermanent) {
! std::map<std::string, boost::shared_ptr<CallingRange> >::const_iterator iter_current, iter_previous;
iter_current = callingRanges_.begin();
while (iter_current != callingRanges_.end()) {
--- 169,173 ----
void ObjectHandlerXL::collectGarbage(const bool &deletePermanent) {
! rangeMapIter iter_current, iter_previous;
iter_current = callingRanges_.begin();
while (iter_current != callingRanges_.end()) {
***************
*** 206,211 ****
} else {
out << std::endl << std::endl;
! std::map < std::string, boost::shared_ptr<CallingRange> >::const_iterator i;
! for (i = callingRanges_.begin(); i != callingRanges_.end(); i++) {
boost::shared_ptr<CallingRange> callingRange = i->second;
out << *callingRange.get();
--- 205,209 ----
} else {
out << std::endl << std::endl;
! for (rangeMapIter i = callingRanges_.begin(); i != callingRanges_.end(); i++) {
boost::shared_ptr<CallingRange> callingRange = i->second;
out << *callingRange.get();
***************
*** 214,216 ****
--- 212,231 ----
}
+ void ObjectHandlerXL::logError(const std::string& message) {
+ logMessage(message, 2);
+ if (FunctionCall::instance().getCallerType() == Cell) {
+ boost::shared_ptr<CallingRange> callingRange = getCallingRange(true);
+ callingRange->setErrorMessage(message);
+ }
+ }
+
+ std::string ObjectHandlerXL::retrieveError(const std::string& address) {
+ for (rangeMapIter i = callingRanges_.begin(); i != callingRanges_.end(); i++) {
+ boost::shared_ptr<CallingRange> callingRange = i->second;
+ if (callingRange->getAddressString() == address)
+ return callingRange->errorMessage();
+ }
+ return "";
+ }
+
}
Index: objecthandlerxl.hpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/objecthandlerxl.hpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** objecthandlerxl.hpp 17 Jul 2006 10:11:40 -0000 1.11
--- objecthandlerxl.hpp 31 Aug 2006 11:00:47 -0000 1.12
***************
*** 55,60 ****
*/
virtual std::string storeObject(std::string objectID,
! const boost::shared_ptr < Object > &object);
! virtual boost::shared_ptr < Object > retrieveObjectImpl(const std::string &objectID) const;
virtual void collectGarbage(const bool &deletePermanent = false);
virtual void deleteAllObjects(const bool &deletePermanent = false);
--- 55,60 ----
*/
virtual std::string storeObject(std::string objectID,
! const boost::shared_ptr<Object> &object);
! virtual boost::shared_ptr<Object> retrieveObjectImpl(const std::string &objectID) const;
virtual void collectGarbage(const bool &deletePermanent = false);
virtual void deleteAllObjects(const bool &deletePermanent = false);
***************
*** 68,75 ****
virtual void dump(std::ostream&);
private:
! boost::shared_ptr < CallingRange > getCallingRange();
virtual std::string generateObjectID();
! void clearCallingRange(boost::shared_ptr < CallingRange > callingRange);
static unsigned long objectIDCount_;
};
--- 68,78 ----
virtual void dump(std::ostream&);
+
+ void logError(const std::string&);
+ std::string retrieveError(const std::string&);
private:
! boost::shared_ptr<CallingRange> getCallingRange(bool createIfNone = false);
virtual std::string generateObjectID();
! void clearCallingRange(boost::shared_ptr<CallingRange> callingRange);
static unsigned long objectIDCount_;
};
Index: callingrange.cpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/callingrange.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** callingrange.cpp 17 Jul 2006 10:11:40 -0000 1.7
--- callingrange.cpp 31 Aug 2006 11:00:47 -0000 1.8
***************
*** 33,37 ****
int CallingRange::keyCount_ = 0;
! CallingRange::CallingRange() : busy_(false), updateCount_(0) {
// name the calling range
--- 33,37 ----
int CallingRange::keyCount_ = 0;
! CallingRange::CallingRange() : busy_(false), updateCount_(0), invocationCount_(0) {
// name the calling range
***************
*** 211,217 ****
static const int COL_WIDTH = 20;
out << std::setw(COL_WIDTH) << "name: "
! << callingRange.key_ << std::endl;
out << std::setw(COL_WIDTH) << "reference: "
<< callingRange.getAddressString() << std::endl;
out << std::setw(COL_WIDTH) << "valid: "
<< std::setiosflags(std::ios_base::boolalpha)
--- 211,219 ----
static const int COL_WIDTH = 20;
out << std::setw(COL_WIDTH) << "name: "
! << callingRange.getKey() << std::endl;
out << std::setw(COL_WIDTH) << "reference: "
<< callingRange.getAddressString() << std::endl;
+ out << std::setw(COL_WIDTH) << "error: "
+ << callingRange.errorMessage() << std::endl;
out << std::setw(COL_WIDTH) << "valid: "
<< std::setiosflags(std::ios_base::boolalpha)
Index: callingrange.hpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/callingrange.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** callingrange.hpp 17 Jul 2006 10:11:40 -0000 1.6
--- callingrange.hpp 31 Aug 2006 11:00:47 -0000 1.7
***************
*** 33,37 ****
~CallingRange();
bool isValid() const;
! const std::string &getKey() {
return key_;
}
--- 33,37 ----
~CallingRange();
bool isValid() const;
! const std::string &getKey() const {
return key_;
}
***************
*** 48,58 ****
return (residentObjects_.size() == 0);
}
private:
static int keyCount_;
static std::string getKeyCount();
std::string key_;
bool busy_;
int updateCount_;
- std::string getAddressString() const;
void setInvocationCount();
int invocationCount_;
--- 48,65 ----
return (residentObjects_.size() == 0);
}
+ void setErrorMessage(const std::string &errorMessage) {
+ errorMessage_ = errorMessage;
+ }
+ const std::string errorMessage() const {
+ return errorMessage_;
+ }
+ std::string getAddressString() const;
private:
static int keyCount_;
static std::string getKeyCount();
std::string key_;
+ std::string errorMessage_;
bool busy_;
int updateCount_;
void setInvocationCount();
int invocationCount_;
|