Update of /cvsroot/objecthandler/ObjectHandler/ohxl
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28347/ohxl
Modified Files:
conversions.hpp functioncall.cpp functioncall.hpp
Log Message:
format vector according to dimensions of calling range
Index: functioncall.cpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/functioncall.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** functioncall.cpp 6 Jun 2006 14:12:40 -0000 1.4
--- functioncall.cpp 8 Jun 2006 09:37:27 -0000 1.5
***************
*** 32,36 ****
FunctionCall::FunctionCall(const std::string functionName)
! : functionName_(functionName) {
if (instance_)
throw Exception("Multiple attempts to initialize global FunctionCall object");
--- 32,36 ----
FunctionCall::FunctionCall(const std::string functionName)
! : functionName_(functionName), callerDimensions_(Uninitialized) {
if (instance_)
throw Exception("Multiple attempts to initialize global FunctionCall object");
***************
*** 140,142 ****
--- 140,160 ----
}
+ CallerDimensions FunctionCall::getCallerDimensions() {
+ // determine dimensions of calling range
+ // at present we're only interested in row vs column
+ // this could be extended to detect scalar / matrix
+ if (callerDimensions_ == Uninitialized) {
+ const XLOPER *xRef = getCallerReference();
+ // xRef might be xltypeRef/xltypeSRef so coerce it to xltypeMulti
+ XLOPER xMulti;
+ Excel(xlCoerce, &xMulti, 2, xRef, TempInt(xltypeMulti));
+ if (xMulti.val.array.rows == 1 && xMulti.val.array.columns > 1)
+ callerDimensions_ = Row;
+ else
+ callerDimensions_ = Column;
+ Excel(xlFree, 0, 1, &xMulti);
+ }
+ return callerDimensions_;
+ }
+
}
Index: functioncall.hpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/functioncall.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** functioncall.hpp 1 Jun 2006 10:52:08 -0000 1.2
--- functioncall.hpp 8 Jun 2006 09:37:27 -0000 1.3
***************
*** 30,33 ****
--- 30,35 ----
namespace ObjHandler {
+ enum CallerDimensions { Uninitialized, Row, Column, /* Matrix, Scalar */ };
+
//! Singleton encapsulating state relating to Excel function call.
/*! An instance of this object is instantiated on the heap when the
***************
*** 46,49 ****
--- 48,52 ----
const std::string &getFormula();
bool outerFunction();
+ CallerDimensions getCallerDimensions();
private:
static FunctionCall *instance_;
***************
*** 53,56 ****
--- 56,60 ----
std::string formula_;
std::string functionName_;
+ CallerDimensions callerDimensions_;
};
Index: conversions.hpp
===================================================================
RCS file: /cvsroot/objecthandler/ObjectHandler/ohxl/conversions.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** conversions.hpp 1 Jun 2006 13:59:47 -0000 1.4
--- conversions.hpp 8 Jun 2006 09:37:27 -0000 1.5
***************
*** 21,24 ****
--- 21,25 ----
#include <oh/objhandlerdefines.hpp>
#include <xlsdk/xlsdkdefines.hpp>
+ #include <ohxl/functioncall.hpp>
#include <vector>
#include <string>
***************
*** 50,55 ****
}
xVector.xltype = xltypeMulti | xlbitDLLFree;
! xVector.val.array.rows = v.size();
! xVector.val.array.columns = 1;
xVector.val.array.lparray = new XLOPER[v.size()];
if (!xVector.val.array.lparray)
--- 51,61 ----
}
xVector.xltype = xltypeMulti | xlbitDLLFree;
! if (FunctionCall::instance().getCallerDimensions() == Row) {
! xVector.val.array.columns = v.size();
! xVector.val.array.rows = 1;
! } else {
! xVector.val.array.rows = v.size();
! xVector.val.array.columns = 1;
! }
xVector.val.array.lparray = new XLOPER[v.size()];
if (!xVector.val.array.lparray)
|