////////////////////////////////////////////////////////////////////////////
// (c) Copyright 2000 - 2001, i2 Technologies, Inc. (formerly Intellection)//
// ALL RIGHTS RESERVED. //
// //
// This UNPUBLISHED PROPRIETARY software is subject to the full copyright //
// notice in the COPYRIGHT file in this directory. //
/////////////////////////////////////////////////////////////////////////////
/* support for editable table, spreadsheet and pivot */
// colors here vs style sheet
var PivotCellColor = "#eceef8";
var PivotCellTotalColor = "#f7f8fd";
var PivotLabelColor = "#d1d6f0";
var PivotFontFamily = "verdana"; // only get 1 choice here
/* item names that are too long will cause problems in the pivot */
var maxItemNameLength = 22;
var xmlDom = null;
var XAXISDELIMITER = ":"; // was \\n
// pivot 1-sum, 2-count, 3-min, 4-max, 5-avg, 6-stddev, 7-variance
var showAsValues = new Array();
showAsValues["sum"] = 1;
showAsValues["count"] = 2;
showAsValues["min"] = 3;
showAsValues["max"] = 4;
showAsValues["avg"] = 5;
showAsValues["stddev"] = 6;
showAsValues["variance"] = 7;
function i2uiDetectEditableTable(objname)
{
return i2uiDetectSpreadsheet(objname);
}
function i2uiDetectSpreadsheet(objname)
{
var ssobj = document.getElementById(objname+"Spreadsheet");
if (ssobj == null)
return 1;
if (ssobj.HTMLData == null || ssobj.HTMLData == "")
return 2;
return 0;
}
function i2uiInitEditableTable(objname, ownername, mode, col, height, width)
{
if (!i2uiCheckVersion(objname+"Spreadsheet"))
return false;
var tbl2obj = null;
var tblobj = document.getElementById(objname+"_header");
if (tblobj == null)
tblobj = document.getElementById(objname);
else
tbl2obj = document.getElementById(objname+"_data");
var ssobj = document.getElementById(objname+"Spreadsheet");
if (col == null)
col = 0;
ssobj.setAttribute("editablecolumn",col);
document.getElementById(objname+"EditAction").style.display="none";
document.getElementById(objname+"CancelAction").style.display="";
document.getElementById(objname+"SaveAction").style.display="";
i2uiBuildSpreadsheet(objname, tblobj, tbl2obj, ssobj, col, false, 2);
// if unlock editable area here and large number of cells to become unlocked
// then component will render a black, unusable region on the page !!
// delay until i2uiStartTableEdit
// var range = i2uiBuildRange(2,col+1,tblobj.rows.length+1,tblobj.rows(0).cells.length);
// ssobj.activeSheet.Range(range).Locked = false;
// ssobj.activeSheet.Range(range).Interior.Color = "white";
ssobj.activeSheet.Protection.Enabled = true;
i2uiCreateNamedRanges(objname, tblobj, ssobj);
if (mode == null)
i2uiSaveTableEdit(objname);
else
i2uiCancelTableEdit(objname);
i2uiResizeSpreadsheet(objname, ownername, true, height);
}
function i2uiProtectSpreadsheet(objname, flag)
{
var ssobj = document.getElementById(objname+"Spreadsheet");
if (ssobj != null)
ssobj.activeSheet.Protection.Enabled = flag;
}
function i2uiInitSpreadsheet(objname, ownername, col, height, width, autofit, numExtraRows)
{
if (!i2uiCheckVersion(objname+"Spreadsheet"))
return false;
var ssobj = document.getElementById(objname+"Spreadsheet");
var tblobj = document.getElementById(objname+"Spreadsheet_xml");
if (tblobj == null)
tblobj = document.getElementById(objname);
if (tblobj.tagName.toLowerCase() == "xml")
{
ssobj.xmlData = tblobj.xml;
var rows = tblobj.selectNodes("//Worksheet/Table/Row").length;
var ssheight = (ssobj.activeSheet.Cells.RowHeight * (rows + 2)) + 95;
if (height == null)
height = ssheight;
else
height = Math.min(height, ssheight);
i2uiResizeSpreadsheet(objname, ownername, true, height);
return;
}
if (col == null)
col = 0;
ssobj.setAttribute("editablecolumn",col);
i2uiBuildSpreadsheet(objname, tblobj, null, ssobj, col, true, numExtraRows);
// if unlock editable area here and large number of cells to become unlocked
// then component will render a black, unusable region on the page !!
// delay until i2uiStartTableEdit
// var range = i2uiBuildRange(2,col+1,tblobj.rows.length+1,tblobj.rows(0).cells.length);
// ssobj.activeSheet.Range(range).Locked = false;
// ssobj.activeSheet.Range(range).Interior.Color = "white";
ssobj.activeSheet.Protection.Enabled = true;
i2uiCreateNamedRanges(objname, tblobj, ssobj);
var ssheight = (ssobj.activeSheet.Cells.RowHeight * (tblobj.rows.length + 2)) + 95;
if (height == null)
height = ssheight;
else
height = Math.min(height, ssheight);
i2uiResizeSpreadsheet(objname, ownername, true, height);
// if spreadsheet wider than allowed width, invoke autofit
if (autofit == null)
autofit = false;
var sum = tblobj.rows(0).cells.length * ssobj.Columns.ColumnWidth;
if (sum > ssobj.width)
autofit = true;
i2uiFirstEdit(objname, tblobj, ssobj, tblobj.rows.length, autofit, numExtraRows);
}
function i2uiResizeSpreadsheet(objname, ownername, bypass, h, w)
{
var tblobj = document.getElementById(objname+"Spreadsheet_xml");
if (tblobj == null)
tblobj = document.getElementById(objname);
var ssobj = document.getElementById(objname+"Spreadsheet");
var ownerobj = document.getElementById(ownername);
var tabletop = i2uiComputeTop(objname);
var ownertop = i2uiComputeTop(ownername);
if (h == null)
ssobj.height = Math.max(20, ownerobj.clientHeight-50-(tabletop-ownertop));
else
ssobj.height = h;
if (w == null)
ssobj.width = Math.max(ownerobj.clientWidth-3,340);
else
ssobj.width = w;
if (bypass == null || bypass==false)
ssobj.HTMLData = i2uiAlignSpreadsheet(objname, tblobj, ssobj);
}
function i2uiAlignSpreadsheet(objname, tblobj, ssobj, defn)
{
if (defn == null)
defn = ssobj.HTMLData;
var at1 = defn.indexOf("
";
var newdefn = defn.substring(0,at1-1) + newcols + defn.substring(at2);
return(newdefn);
}
function i2uiBuildSpreadsheetColumnWidths(objname, tblobj, ssobj, owner)
{
try
{
var objCol;
var objColAttr;
var numcols = tblobj.rows(0).cells.length;
var rowobj = tblobj.rows(0);
for(var j=0; j";
for (var i=1; i";
for (var j=0; j"+tblobj.rows[i].cells[ids[j]].innerText+""+names[j]+">";
}
catch(e){}
}
result += "";
}
result += ""+objname+">";
return(result);
}
function i2uiExtractSpreadsheet(objname, cols, names, action)
{
var range;
var cellvalue;
var tblobj = document.getElementById(objname);
var ssobj = document.getElementById(objname+"Spreadsheet");
var len3 = 0;
var ids = new Array();
var len2 = 0;
if (cols != null)
{
ids = cols.split(",");
len2 = ids.length;
}
else
{
len2 = tblobj.rows(0).cells.length;
for (var i=0; i";
if (action == null || action == "table" || action == "all")
{
for (var i=1; i";
for (var j=0; j"+cellvalue+""+names[j]+">";
}
result += "";
}
}
if (action == "all" || action == "new")
{
// process all rows here
var last = ssobj.activesheet.UsedRange.EntireRow.Count;
window.status = last;
for (var i=len; i";
var rowempty = true;
for (var j=0; j"+cellvalue+""+names[j]+">";
}
if (!rowempty)
result += rowresult+"";
}
}
if (action == "highlighted")
{
var first = ssobj.activesheet.application.selection.row;
var len = first + ssobj.activesheet.application.selection.rows.count;
for (var i=first; i";
for (var j=0; j"+cellvalue+""+names[j]+">";
}
result += "";
}
}
result += ""+objname+">";
return(result);
}
function i2uiBuildSpreadsheet(objname, tblobj, tbl2obj, ssobj, col, autofit, numExtraRows)
{
var formula;
var at;
var unlockedColumns = new Array();
var lockedColumns = new Array();
var defn = ssobj.HTMLData;
// add our styles
at = defn.indexOf("");
if (at != -1)
{
var extraStyles = "";
extraStyles += ".header{background-color:#d1d6f0;border-top:solid #999999 1px;border-left:solid #999999 1px;border-right:solid #999999 1px;border-bottom:solid #999999 1px;}";
extraStyles += ".cellodd{background-color:#f7f8fd;border-top:solid #999999 1px;border-left:solid #999999 1px;border-right:solid #999999 1px;border-bottom:solid #999999 1px;}";
extraStyles += ".celleven{background-color:#eceef8;border-top:solid #999999 1px;border-left:solid #999999 1px;border-right:solid #999999 1px;border-bottom:solid #999999 1px;}";
extraStyles += ".readwrite {background-color:white;}";
defn = defn.substring(0,at)+extraStyles+defn.substring(at);
}
objDom = new ActiveXObject("Microsoft.XMLDOM");
objDom.preserveWhiteSpace = true;
var objRoot = objDom.createElement("table");
objDom.appendChild(objRoot);
i2uiBuildSpreadsheetColumnWidths(objname, tblobj, ssobj, objRoot);
var numrows = tblobj.rows.length;
var numcols = tblobj.rows(0).cells.length;
var value;
var readonly = new Array("celleven","cellodd");
var rowdefn;
var objRow;
var objRowAttr;
var objCell;
var objCellAttr;
var rowobj;
var cellobj;
for (var i=0; i= col)
unlockedColumns[unlockedColumns.length] = j;
objCell.text = cellobj.innerText;
}
}
else
if (tagName == "INPUT")
{
objCellAttr = objDom.createAttribute("class");
objCellAttr.text = "readwrite";
objCell.setAttributeNode(objCellAttr);
objCell.text = cellobj.childNodes[0].getAttribute("value");
if (i == 1)
unlockedColumns[unlockedColumns.length] = j;
}
else
if (tagName == "SELECT")
{
var selectobj = cellobj.childNodes[0];
objCell.text = selectobj.options[selectobj.selectedIndex].text;
}
else
{
if (i == 1 && j >= col)
unlockedColumns[unlockedColumns.length] = j;
objCell.text = cellobj.innerText;
}
}
catch(e)
{
try
{
if ((formula = cellobj.getAttribute("x:fmla")) != null)
{
objCellAttr = objDom.createAttribute("x:fmla");
objCellAttr.text = formula;
objCell.setAttributeNode(objCellAttr);
if (i == 1)
lockedColumns[lockedColumns.length] = j;
}
else
{
if (i == 1 && j >= col)
unlockedColumns[unlockedColumns.length] = j;
objCell.text = cellobj.innerText;
}
}
catch(e){}
}
}
}
if (tbl2obj != null)
{
numrows = tbl2obj.rows.length;
for (var i=0; i= col)
unlockedColumns[unlockedColumns.length] = j;
objCell.text = cellobj.innerText;
}
}
else
if (tagName == "INPUT")
{
objCellAttr = objDom.createAttribute("class");
objCellAttr.text = "readwrite";
objCell.setAttributeNode(objCellAttr);
objCell.text = cellobj.childNodes[0].getAttribute("value");
if (i == 0)
unlockedColumns[unlockedColumns.length] = j;
}
else
if (tagName == "SELECT")
{
var selectobj = cellobj.childNodes[0];
objCell.text = selectobj.options[selectobj.selectedIndex].text;
}
else
{
if (i == 0 && j >= col)
unlockedColumns[unlockedColumns.length] = j;
objCell.text = cellobj.innerText;
}
}
catch(e)
{
if ((formula = cellobj.getAttribute("x:fmla")) != null)
{
objCellAttr = objDom.createAttribute("x:fmla");
objCellAttr.text = formula;
objCell.setAttributeNode(objCellAttr);
if (i == 0)
lockedColumns[lockedColumns.length] = j;
}
else
{
if (i == 0 && j >= col)
unlockedColumns[unlockedColumns.length] = j;
objCell.text = cellobj.innerText;
}
}
}
}
}
at = defn.indexOf(" 0)
{
tagName = rowobj.cells(j).childNodes[0].tagName;
if (tagName == "INPUT")
cellvalue = rowobj.cells(j).childNodes[0].getAttribute("value");
else
if (tagName == "SELECT")
{
var selectobj = rowobj.cells(j).childNodes[0];
cellvalue = selectobj.options[selectobj.selectedIndex].text;
}
else
if (j < col ||
rowobj.cells(j).getAttribute("x:fmla") != null)
continue;
else
cellvalue = rowobj.cells(j).innerText;
}
else
{
tagName == "";
if (j < col ||
rowobj.cells(j).getAttribute("x:fmla") != null)
continue;
else
cellvalue = rowobj.cells(j).innerText;
}
try
{
var numExtraRows = 0;
range = i2uiBuildRange(i+numExtraRows-firstrow,j+1);
if (j < col && (tagName == "INPUT" || tagName == "SELECT"))
ssobj.ActiveSheet.Range(range).Locked = false;
ssobj.ActiveSheet.Range(range).Value = cellvalue;
}
catch(e){}
}
}
// reenable calculation
//ssobj.activeSheet.EnableAutoCalculate = true;
try {ssobj.activeSheet.Application.ScreenUpdating = true;}catch(e){}
}
function i2uiCreateNamedRanges(objname, tblobj, ssobj)
{
try{
if (tblobj == null)
tblobj = document.getElementById(objname);
if (ssobj == null)
ssobj = document.getElementById(objname+"Spreadsheet");
var numrows = tblobj.rows.length;
var numcols = tblobj.rows(0).cells.length;
for (var j=0; j 0)
view.ColumnAxis.FieldSets(len-1).Fields(0).Expanded = false;
len = view.RowAxis.FieldSets.Count;
for (i=0; i 0)
view.RowAxis.FieldSets(len-1).Fields(0).Expanded = false;
}
function i2uiLayoutPivot(pivot, view)
{
var rc = false;
view.AutoLayout();
activePivot = pivot;
// retain style info
pivot.chartColorInfo = new Array();
pivot.chartStyleInfo = new Array();
pivot.chartTypeInfo = new Array();
pivot.seriesColor = new Array();
pivot.seriesColorCount = 0;
pivot.seriesStyle = new Array();
pivot.seriesStyleCount = 0;
pivot.editableColumns = new Array();
pivot.proportionalEditColumns = new Array();
pivot.lockedColumns = new Array();
var customSort = new Array();
try
{
pivot.coloring = 1*xmlDom.selectSingleNode("/pivot/chart").getAttribute("coloring");
}
catch(e)
{
pivot.coloring = 2;
}
i2uiPivotAsofName = null;
i2uiPivotAsofCaption = null;
i2uiPivotAsofValue = null;
i2uiPivotAsofColor = null;
try
{
i2uiPivotAsofName = xmlDom.selectSingleNode("/pivot/chart").getAttribute("asofname");
i2uiPivotAsofValue = xmlDom.selectSingleNode("/pivot/chart").getAttribute("asofvalue");
i2uiPivotAsofColor = xmlDom.selectSingleNode("/pivot/chart").getAttribute("asofcolor");
} catch(e){}
try
{
i2uiPivotAsofCaption = xmlDom.selectSingleNode("/pivot/chart").getAttribute("asofcaption");
var len = i2uiPivotAsofCaption.length;
} catch(e){i2uiPivotAsofCaption="Asof";}
try
{
pivot.chartThreshold = xmlDom.selectSingleNode("/pivot/chart/threshhold").xml;
} catch(e){pivot.chartThreshold="";}
var stylenodes = xmlDom.selectNodes("/pivot/chart/*");
if (stylenodes.length == 0) stylenodes = xmlDom.selectNodes("/PIVOT/CHART/*");
pivot.chartColorInfo[0] = stylenodes.length;
for (var i=0; i maxItemNameLength)
view.FieldSets(itemName).Fields(0).Caption = itemnodes[i].text;
// handle unsorted data
if (itemnodes[i].getAttribute("sorted") == "no")
view.FieldSets(itemName.substring(0,maxItemNameLength)).Fields(0).SortDirection = pivot.Constants.plSortDirectionCustom;
// set initial filtering
var filter;
var filterArray;
var filterSeparator = itemnodes[i].getAttribute("separator");
if (filterSeparator == null)
filterSeparator = ",";
filter = itemnodes[i].getAttribute("include");
if (filter == null)
{
try
{
filter = pivot.retainincludes[itemName].join(filterSeparator);
}
catch(e)
{filter=null;}
}
if (filter != null)
{
filterArray = filter.split(filterSeparator);
view.FieldSets(itemName).Fields(0).IncludedMembers = filterArray;
}
filter = itemnodes[i].getAttribute("exclude");
if (filter == null)
{
try
{
filter = pivot.retainexcludes[itemName].join(filterSeparator);
}
catch(e)
{filter=null;}
}
if (filter != null)
{
filterArray = filter.split(filterSeparator);
view.FieldSets(itemName).Fields(0).ExcludedMembers = filterArray;
}
// set initial formating
if ((numberformat = itemnodes[i].getAttribute("numberformat")) != null)
{
view.FieldSets(itemName).Fields(0).NumberFormat = numberformat;
}
}
var cleanup = new Array();
// create totals for data axis
for (var i=0; i 0)
subField.AddCustomGroupMember(theFieldSet.Name,
members,
membernodes[j].getAttribute("caption"));
}
catch(e)
{
}
}
}
var len = cleanup.length;
for (var i=0; i 0)
{
var j = 0;
var value;
for (var k=0; k 0)
{
view.FieldSets(displayName).Fields(0).OrderedMembers = sourceOrder;
view.FieldSets(displayName).Fields(0).SortDirection = pivot.Constants.plSortDirectionCustom;
}
}
else
if (itemnode.getAttribute("sort") == "lifo")
{
var itemName = itemnode.getAttribute("name");
var sourceOrder = i2uiBuildCustomOrder(itemName, displayName);
if (sourceOrder.length > 0)
{
view.FieldSets(displayName).Fields(0).OrderedMembers = sourceOrder.reverse();
view.FieldSets(displayName).Fields(0).SortDirection = pivot.Constants.plSortDirectionCustom;
}
}
else
if (itemnode.getAttribute("sort") == "descending")
view.FieldSets(displayName).Fields(0).SortDirection = pivot.Constants.plSortDirectionDescending;
else
if (itemnode.getAttribute("sort") == "ascending")
view.FieldSets(displayName).Fields(0).SortDirection = pivot.Constants.plSortDirectionAscending;
}
}
}
catch(e){}
}
function i2uiBuildAppMenu(pivot, measureName)
{
var menus = new Array();
var xpath = "/pivot/view"+pivot.viewname+"/item[text()='"+measureName+"']";
var itemnode = xmlDom.selectSingleNode(xpath);
if (itemnode == null)
{
xpath = "/pivot/item[text()='"+measureName+"']";
itemnode = xmlDom.selectSingleNode(xpath);
}
if (itemnode != null)
{
xpath = "/pivot/menu[@owner='"+itemnode.getAttribute("name")+"']";
var menunodes = xmlDom.selectNodes(xpath);
var len = menunodes.length;
for (var i=0; i 0)
filter += " and ";
filter += "not(@"+attr.text+")";
}
else
if (render == "nonblank")
{
if (filter.length > 0)
filter += " and ";
filter += "@"+attr.text;
}
}
attributeTypeNode.setAttributeNode(attr);
var dataTypeNode = pivotDom.createElement("s:datatype");
var dataType = itemnodes[i].getAttribute("type");
pivot.fieldTypes[fieldname] = dataType;
if (dataType == null || dataType.length == 0)
{
if (itemnodes[i].getAttribute("axis") == "data")
{
attr = pivotDom.createAttribute("dt:type");
attr.text = "float";
pivot.fieldTypes[fieldname] = "float";
}
else
{
attr = pivotDom.createAttribute("dt:maxLength");
attr.text = 255;
pivot.fieldTypes[fieldname] = "string";
}
}
else
{
attr = pivotDom.createAttribute("dt:type");
attr.text = dataType;
pivot.fieldTypes[fieldname] = dataType;
}
dataTypeNode.setAttributeNode(attr);
attributeTypeNode.appendChild(dataTypeNode);
schemaNode.appendChild(attributeTypeNode);
}
var dataNode = pivotDom.createElement("rs:data");
cacheNode.appendChild(dataNode);
var endItems2 = new Date();
var flatdatanode = pivotnode.selectSingleNode("flatdata");
if (flatdatanode != null)
{
// if pivot is dirty, merge changed rows
if (pivot.dirty)
{
//alert("new view with unsaved changed data");
i2uiInternallyPersistPivotEdits(pivot, flatdatanode);
}
if (filter.length > 0)
filter = "["+filter+"]";
var rownodes = flatdatanode.selectNodes("z:row"+filter);
//var rownodes = flatdatanode.selectNodes("*"+filter);
var rowlen = rownodes.length;
for (var i=0; i 1)
for (var i=0; i 0 && detailNumCols > 0)
{
var detailCell;
// find proper column
for (var j=0; j 0)
details = i2uiUpdatePivotDetail(details, pivot, mbr, lowestColMbr, targetMeasure, oldValues);
}
return details;
}
function i2uiLocatePivotDetail(pivot, totaledMbr, lowestColMbr, targetMeasure, bookmarks)
{
var numImpacted = totaledMbr.ChildMembers.Count;
var data = pivot.ActiveData;
for (var i=0; i 0 && detailNumCols > 0)
{
var detailCell;
// find proper column
for (var j=0; j 0)
i2uiLocatePivotDetail(pivot, mbr, lowestColMbr, targetMeasure, bookmarks);
}
}
function i2uiEditPivotCell(id)
{
//alert(foo.bar.zed());
var obj = document.getElementById(id+"PivotEdit");
var temp = obj.value;
if (obj.value == null ||
obj.value.length == 0 ||
temp != obj.value)
{
if (obj.value != null)
obj.readOnly = true;
return;
}
var desiredValue = obj.value;
var pivot = document.getElementById(id+"Pivot");
var validedit = false;
var editname;
var editrownum;
if (pivot.SelectionType == "PivotDetailRange")
{
validedit = true;
editname = pivot.Selection.TopLeft.Field.BaseName;
try
{
editrownum = pivot.Selection.TopLeft.Bookmark-1;
}
catch(e){}
}
else
if (pivot.SelectionType == "PivotAggregates")
{
if (pivot.Selection.Item(0).Cell.RowMember.UniqueName == "Total" ||
pivot.Selection.Item(0).Cell.RowMember.UniqueName == "Grand Total")
{
var oldWay = false;
var xmlDom2 = new ActiveXObject(domid);
if (xmlDom2.loadXML(pivot.xmlData2))
{
try
{
xmlDom2.setProperty("SelectionLanguage", "XPath");
xmlDom2.setProperty("SelectionNamespaces", pivotSchemas);
var factor = null;
if (pivot.oldTotalValue != 0)
factor = 1 + (obj.value - pivot.oldTotalValue)/pivot.oldTotalValue;
//alert("edit a total. old="+pivot.oldTotalValue+" new="+obj.value+" factor="+factor);
var cell = pivot.Selection.Item(0);
var details = "UPDATING "+cell.Name+"="+cell.Value;
var targetMeasure = cell.Name;
cell = cell.Cell;
if (oldWay)
{
var editrownum = cell.Recordset.Bookmark-1;
var coreXpath = "//z:row";
details += " where on ROW ";
var mbr, totaledMbr = null;
mbr = cell.RowMember;
try
{
while (mbr != null)
{
if (mbr.Value=="Total")
totaledMbr = mbr.ParentMember;
else
{
details += mbr.Field.Name+"="+mbr.Value+" ";
coreXpath += '[@'+pivot.MeasureToAttribute[mbr.Field.Name]+'="'+mbr.Value+'"]';
}
mbr = mbr.ParentMember;
}
}
catch(e){}
details += " and on COL ";
mbr = cell.ColumnMember;
var lowestColMbr = mbr;
try
{
while (mbr != null)
{
if (mbr.Value=="Total")
totaledMbr = mbr.ParentMember;
else
{
details += mbr.Field.Name+"="+mbr.Value+" ";
coreXpath += '[@'+pivot.MeasureToAttribute[mbr.Field.Name]+'="'+mbr.Value+'"]';
}
mbr = mbr.ParentMember;
}
}
catch(e){}
var miniXpath;
details += " IMPACTING ";
var numImpacted = totaledMbr.ChildMembers.Count;
var data = pivot.object.ActiveData;
for (var i=0; i";
var pivot = document.getElementById(id+"Pivot");
i2uiApplyPivotEdits(id, pivot);
if (pivot.dirty)
{
var xmlDom2 = new ActiveXObject(domid);
xmlDom2.setProperty("SelectionLanguage", "XPath");
xmlDom2.setProperty("SelectionNamespaces", pivotSchemas);
if (xmlDom2.loadXML(pivot.xmlData2))
{
var datanodes = xmlDom2.selectNodes("//z:row[@i2uidirty=1]");
var len = datanodes.length;
for (var i=0; i";
pivot.dirty = false;
return result;
}
function i2uiDetermineSeriesType(seriesname, view, pivot)
{
var at = Math.max(-1, seriesname.lastIndexOf(":"));
var lastSeries = seriesname.substring(at+1);
return pivot.chartTypeInfo[lastSeries];
}
function i2uiDetermineSeriesClass(seriesname, view, pivot)
{
var classinfo = "";
if (pivot.multichart)
{
var primarykey1 = "*";
var len = view.ColumnAxis.FieldSets.Count;
if (len > 1)
primarykey1 = view.ColumnAxis.FieldSets(1).Name;
var at = Math.max(0, seriesname.indexOf(":"));
// for multi-attribute coloring
var subkey1 = seriesname.substring(at+1);
if (len == 1)
{
primarykey1 = subkey1;
subkey1 = "*";
}
else
if (len == 0)
{
primarykey1 = seriesname;
subkey1 = "*";
}
// for single attribute coloring
if (pivot.coloring == 1 || pivot.chartColorInfo[0] > 0)
{
at = Math.max(0, subkey1.indexOf(":"));
if (at == -1)
at = seriesname.length;
subkey1 = subkey1.substring(0,at);
}
var at = Math.max(-1, seriesname.lastIndexOf(":"));
var subkey2 = seriesname.substring(at+1);
var substyle = i2uiDetermineSeriesStyle(subkey2+"_*",pivot);
if (pivot.chartTypeInfo[subkey2] == "line" ||
pivot.chartTypeInfo[subkey2] == "inferstep")
pivot.chartSubstyle[subkey2] = substyle;
classinfo = 'classindex="'+i2uiDetermineSeriesColor(primarykey1+"_"+subkey1,pivot)+'" substyle="dash'+substyle+'" ';
}
else
{
if (pivot.chartColorInfo[0] > 0)
{
var at = Math.max(0, seriesname.indexOf(":"));
if (at == -1)
at = seriesname.length;
var primarykey = seriesname.substring(0,at);
var secondName = "*";
var tempNames = seriesname.split(":");
if (tempNames.length > 1)
secondName = tempNames[1];
var at = Math.max(-1, seriesname.lastIndexOf(":"));
var subkey2 = seriesname.substring(at+1);
var fieldvalue;
try
{
fieldvalue = view.ColumnAxis.FieldSets(0).Name;
}
catch(e)
{
fieldvalue = seriesname;
}
if (pivot.coloring == 3)
primarykey += "_"+secondName;
var substyle = i2uiDetermineSeriesStyle(subkey2+"_*",pivot);
if (pivot.chartTypeInfo[subkey2] == "line" ||
pivot.chartTypeInfo[subkey2] == "inferstep")
pivot.chartSubstyle[subkey2] = substyle;
classinfo = 'classindex="'+i2uiDetermineSeriesColor(fieldvalue+"_"+primarykey, pivot)+'" substyle="dash'+substyle+'" ';
}
}
return classinfo;
}
function i2uiDetermineSeriesColor(id, pivot)
{
if (pivot.seriesColor[id] == null)
{
// see if xml provided color info
pivot.seriesColor[id] = pivot.chartColorInfo[id];
if (pivot.seriesColor[id] == null)
{
// check for default value
var at = id.indexOf("_");
if (at != -1)
{
var id2 = id.substring(0,at+1)+"*";
pivot.seriesColor[id] = pivot.chartColorInfo[id2];
}
}
if (pivot.seriesColor[id] == null)
pivot.seriesColor[id] = seriesColorCount++;
}
return pivot.seriesColor[id];
}
function i2uiDetermineSeriesStyle(id, pivot)
{
if (pivot.seriesStyle[id] == null)
{
// see if xml provided style exists
pivot.seriesStyle[id] = pivot.chartStyleInfo[id];
if (pivot.seriesStyle[id] == null)
pivot.seriesStyle[id] = "";
// can't increment styles w/o regard to max style
//pivot.seriesStyle[id] = seriesStyleCount++;
}
return pivot.seriesStyle[id];
}
function i2uiDateValue(dateString)
{
var dateFields = dateString.split("/");
var mm = dateFields[0]*1-1;
var dd = dateFields[1];
var yyyy = dateFields[2];
var hh = 0;
var min = 0;
var timeFields = yyyy.split(" ");
if (timeFields.length > 1)
{
yyyy = timeFields[0];
timeFields = timeFields[1].split(":");
hh = timeFields[0]*1-1;
min = timeFields[1];
}
return new Date(yyyy,mm,dd,hh,min).valueOf();
}
var i2uiChartXAxisName;
var i2uiChartXAxis;
var i2uiChartSeriesName;
var i2uiChartSeriesValues;
var i2uiChartExtraSeries = new Array();
var i2uiChartSeries;
var i2uiChartRowMembers;
var i2uiChartColumnMembers;
var i2uiChartLastSeriesType;
// recurse hierarchy of columns
// at bottom, process all related rows
function i2uiChartPivotColumns(data, columnMember, style)
{
if (columnMember.caption != "Column")
i2uiChartSeriesName.push(columnMember.caption);
var childCount = columnMember.childmembers.count;
if (childCount == 0)
{
// determine number of measures in data axis
// make a series per data axis measure appending name to series if multiple
var firstCell = data.cells(i2uiChartRowMembers[0], columnMember);
// warning : only valid if totaling for data. otherwise must look at orientation
// to determine whether to use
var seriesType;
var len = 1;
//LPM works only if total=yes for measures in data area
try{len = firstCell.aggregates.count;}catch(e){}
if (debuger)alert(len);
for (i=0; i 0)
i2uiChartSeriesName.push(firstCell.aggregates.item(i).name);
var seriesName = i2uiChartSeriesName.join(":");
if (style == null || style =="null")
seriesType = i2uiDetermineSeriesType(seriesName, data.view, activePivot);
else
seriesType = style;
if (seriesType == null)
seriesType="line";
if (seriesType == "stackbar" &&
i2uiChartLastSeriesType != "bar" &&
i2uiChartLastSeriesType != "stackbar")
seriesType = "bar";
i2uiChartLastSeriesType = seriesType;
var classinfo = i2uiDetermineSeriesClass(seriesName, data.view, activePivot);
i2uiChartSeries.push(""+i2uiChartSeriesValues.join("|")+"");
if (len > 0)
i2uiChartSeriesName.pop();
}
}
else
{
for (var i=0; i';
}
var extra = "";
if (i2uiChartExtraSeries.length > 0)
{
extra = ""+i2uiChartExtraSeries.join("|")+""
}
var full = result+">"+i2uiChartXAxis.join("|")+""+i2uiChartSeries.join("")+substyle+extra+pivot.chartThreshold+"";
return full;
}
function i2uiBuildPivotXpath(pivot, view)
{
var rowlen = view.RowAxis.FieldSets.Count;
var collen = view.ColumnAxis.FieldSets.Count;
var datalen = view.DataAxis.FieldSets.Count;
var filterlen = view.FilterAxis.FieldSets.Count;
var rowFieldNames = new Array();
for (var i=0; i 0)
rowFieldNames[i] = name(0).getAttribute("name");
else
rowFieldNames[i] = view.RowAxis.FieldSets(i).Name;
}
var colFieldNames = new Array();
for (var i=0; i 0)
colFieldNames[i] = name(0).getAttribute("name");
else
colFieldNames[i] = view.ColumnAxis.FieldSets(i).Name;
}
var filterFieldNames = new Array();
for (var i=0; i 0)
filterFieldNames[i] = name(0).getAttribute("name");
else
filterFieldNames[i] = view.FilterAxis.FieldSets(i).Name;
}
var dataFieldNames = new Array();
for (var i=0; i 0)
dataFieldNames[i] = name(0).getAttribute("name");
else
{
dataFieldNames[i] = view.DataAxis.FieldSets(i).Name;
}
}
catch(e){}
}
var xpath = "";
for (var j=0; j 0)
xpath += " or ";
xpath += "@"+colFieldNames[j]+"='"+includedArray[x].name+"'";
}
if (!bFirst)
xpath += "]";
}
}
//alert("after include cols. xpath="+xpath);
for (var j=0; j 0)
xpath += " or ";
xpath += "@"+filterFieldNames[j]+"='"+includedArray[x].name+"'";
}
if (!bFirst)
xpath += "]";
}
}
//alert("after include filters. xpath="+xpath);
for (var j=0; j 0)
xpath += " or ";
xpath += "@"+rowFieldNames[j]+"='"+includedArray[x].name+"'";
}
if (!bFirst)
xpath += "]";
}
}
//alert("after rows. xpath="+xpath);
for (var j=0; j 0)
xpath += " or ";
xpath += "@"+dataFieldNames[j]+"='"+includedArray[x].name+"'";
}
if (!bFirst)
xpath += "]";
}
}
//alert("pre-retains xpath "+xpath);
// here to consider filtering within groups
pivot.retainincludes = new Array();
pivot.retainexcludes = new Array();
if (pivot.retainFilters)
i2uiBuildPivotRetains(pivot, view);
for (name in pivot.retainincludes)
{
// change name to xml attribute name
var name2 = pivot.MeasureToAttribute[name];
var len = pivot.retainincludes[name].length;
for (var i=0; i 0)
{
var arrayCount = filteredArray.length;
if (pivot.retainexcludes[fieldName] == null)
pivot.retainexcludes[fieldName]= new Array();
else
{
if (obj.name == obj.caption) // skip if leaf
arrayCount = 0;
}
obj2 = pivot.retainexcludes[fieldName];
for (var x=0; x 0)
{
var arrayCount = filteredArray.length;
if (pivot.retainincludes[fieldName] == null)
pivot.retainincludes[fieldName]= new Array();
else
{
if (obj.name == obj.caption) // skip if leaf
arrayCount = 0;
}
obj2 = pivot.retainincludes[fieldName];
for (var x=0; x 0)
{
if (pivot.retainexcludes[fieldName] == null)
pivot.retainexcludes[fieldName] = new Array();
obj = pivot.retainexcludes[fieldName];
var arrayCount = filteredArray.length;
for (var x=0; x 0)
{
if (pivot.retainincludes[fieldName] == null)
pivot.retainincludes[fieldName] = new Array();
obj = pivot.retainincludes[fieldName];
var arrayCount = filteredArray.length;
for (var x=0; x obj2.key)
return 1;
else
return 0;
}
function i2uiDelayedPivotDataChange(id, pivot)
{
try
{
// update any related visible chart
try
{
if (pivot==null)
pivot=document.getElementById(id);
if (pivot.componentShowing=="pivotchart" ||
pivot.componentShowing=="chart")
{
var obj = document.getElementById(id+"Chart_xml");
var obj2 = document.getElementById(id+"Chart");
if (obj != null && obj2 != null)
{
var id2 = id.substring(0,id.length-5);
obj.loadXML(i2uiChartPivot(id2,obj2.height,obj2.width,false));
obj2.window.i2uiProcessChart();
}
}
else
if (pivot.componentShowing=="multichart")
{
var obj = document.getElementById(id+"Chart_xml");
var obj2 = document.getElementById(id+"Chart");
if (obj != null && obj2 != null)
{
var id2 = id.substring(0,id.length-5);
obj.loadXML(i2uiChartPivot(id2,obj2.height,obj2.width,true));
obj2.window.i2uiProcessChart();
}
}
}
catch(e){}
// inform application
i2uiPivotChangeCallback(id);
}
catch(e){}
}
function i2uiGetPivotCalculationsXML(id, pivot)
{
var xml = "";
if (pivot == null)
pivot = document.getElementById(id+"Pivot");
var view = pivot.ActiveView;
var axis = view.DataAxis;
var len = axis.FieldSets.Count;
for (var i=0; i';
}
xml += ""
return(xml);
}
function i2uiSetPivotCalculations(id, xml, pivot)
{
//alert(xml);
if (pivot == null)
pivot = document.getElementById(id+"Pivot");
var view = pivot.ActiveView;
var axis = view.DataAxis;
var calcdom = new ActiveXObject(domid);
if (calcdom.loadXML(xml))
{
calcdom.setProperty("SelectionLanguage", "XPath");
calcdom.setProperty("SelectionNamespaces", pivotSchemas);
var fields = calcdom.selectNodes("/pivotcalculations/field");
var len = fields.length;
//alert(foo.bar.zed());
for (var i=0; i"+names+"";
else
xml += ""+names+"";
var axis = view.ColumnAxis;
var names = new Array();
var len = axis.FieldSets.Count;
for (var i=0; i"+names+"";
else
xml += ""+names+"";
var axis = view.FilterAxis;
var names = new Array();
var len = axis.FieldSets.Count;
for (var i=0; i"+names+"";
// need to include the none axis
xml += ""
return xml;
}
function i2uiSetPivotLayout(id, which, itemNames)
{
var pivot = document.getElementById(id+"Pivot");
var view = pivot.ActiveView;
var axis = null;
if (which == "rows")
{
axis = view.RowAxis;
}
else
if (which == "columns")
{
axis = view.ColumnAxis;
}
else
if (which == "filters")
{
axis = view.FilterAxis;
}
if (axis != null)
{
var names = itemNames.split(",");
var len = names.length;
for (var i=0; i |
');
result = xmldoc.transformNode(xsldoc);
return result;
}
}
// this version produces spreadsheet in pivot order
// uses raw data values and not totaled numbers
// display order is not necessarily the same as pivot
function i2uiPivotToSpreadsheet(id)
{
var pivot = document.getElementById(id+"Pivot");
var xpath = i2uiBuildPivotXpath(pivot, pivot.ActiveView);
var xmldoc = new ActiveXObject(domid);
var xsldoc = new ActiveXObject(domid);
if (xmldoc != null && xsldoc != null)
{
xmldoc.setProperty("SelectionNamespaces", pivotSchemas);
var axis = new Array("filters","rows","columns","data");
var axislen = axis.length;
var xslprefix = ''+
''+
''+
''+
''+
''+
''+
'';
var xslrowprefix = '';
var xslrowsuffix = '
';
var xslsuffix = '';
var names;
var nameslen;
var xmlname;
xmldoc.loadXML(pivot.xmlData2);
var xslEvery = "";
var xslStyle = "";
var styleinfo;
pivot.spreadsheetColumnNames = new Array();
pivot.editedRow = new Array();
pivot.editedColumn = new Array();
pivot.editedValue = new Array();
for (var i=0; i';
xslStyle += '';
}
}
var xsl = xslprefix+xslStyle+xslprefix2+xslrowprefix+xslEvery+xslrowsuffix+xslsuffix;
xsldoc.loadXML(xsl);
return xmldoc.transformNode(xsldoc);
}
}
function i2uiPivotShowPivot(id)
{
var pivot = document.getElementById(id+"Pivot");
pivot.componentShowing = "pivot";
i2uiToggleItemVisibility(id+"Pivot", "show");
i2uiToggleItemVisibility(id+"PivotEdit", "show");
i2uiToggleItemVisibility(id+"PivotChart", "hide");
i2uiToggleItemVisibility(id+"PivotSpreadsheet", "hide");
i2uiToggleItemVisibility(id+"showPivot", "hide");
i2uiToggleItemVisibility(id+"flipPivot", "show");
i2uiToggleItemVisibility(id+"stretchPivot", "show");
i2uiToggleItemVisibility(id+"showChart", "show");
i2uiToggleItemVisibility(id+"showBoth", "show");
i2uiToggleItemVisibility(id+"showMultichart", "show");
i2uiToggleItemVisibility(id+"showSpreadsheet", "show");
var h = document.body.offsetHeight - 110;
var w = document.body.offsetWidth - 70;
var obj3 = document.getElementById(id+"Container");
if (obj3 != null)
{
h = Math.max(50,obj3.clientHeight-30);
w = Math.max(50,obj3.clientWidth-40);
}
i2uiApplyPivotEdits(id, pivot);
i2uiBestFitPivot(id,h-10,w);
}
function i2uiPivotFlipPivot(id) // transpose measures in rows and columns
{
var pivot = document.getElementById(id+"Pivot");
var layout = i2uiGetPivotLayoutXML(id, true);
i2uiSetPivotLayoutXML(id, layout);
// apply bestfit
var h = document.body.offsetHeight - 110;
var w = document.body.offsetWidth - 70;
var obj3 = document.getElementById(id+"Container");
if (obj3 != null)
{
h = Math.max(50,obj3.clientHeight-30);
w = Math.max(50,obj3.clientWidth-40);
}
if (pivot.componentShowing == "pivotchart")
w = w/2;
i2uiBestFitPivot(id);
}
function i2uiPivotShowChart(id)
{
var pivot = document.getElementById(id+"Pivot");
i2uiToggleItemVisibility(id+"Pivot", "hide");
i2uiToggleItemVisibility(id+"PivotEdit", "hide");
i2uiToggleItemVisibility(id+"PivotChart", "show");
i2uiToggleItemVisibility(id+"PivotSpreadsheet", "hide");
i2uiToggleItemVisibility(id+"showPivot", "show");
i2uiToggleItemVisibility(id+"stretchPivot", "hide");
i2uiToggleItemVisibility(id+"showChart", "hide");
i2uiToggleItemVisibility(id+"showBoth", "show");
i2uiToggleItemVisibility(id+"showMultichart", "show");
i2uiToggleItemVisibility(id+"showSpreadsheet", "show");
i2uiToggleItemVisibility(id+"PivotEditForm","hide");
i2uiToggleItemVisibility(id+"PivotMassEditForm","hide");
var obj = document.getElementById(id+"PivotChart_xml");
var obj2 = document.getElementById(id+"PivotChart");
if (obj != null && obj2 != null)
{
var h = document.body.offsetHeight - 110;
var w = (document.body.offsetWidth - 70);
var obj3 = document.getElementById(id+"Container");
if (obj3 != null)
{
h = Math.max(50,obj3.clientHeight-50);
w = Math.max(50,obj3.clientWidth-50);
}
if (pivot.componentShowing == "pivotchart")
{
obj2.window.i2uiResizeChart(h,w,true);
}
else
{
i2uiApplyPivotEdits(id, pivot);
var chartXML = i2uiChartPivot(id,h,w,false);
obj.loadXML(chartXML);
obj2.window.i2uiProcessChart();
}
}
pivot.componentShowing = "chart";
}
function i2uiPivotShowBoth(id)
{
var pivot = document.getElementById(id+"Pivot");
i2uiToggleItemVisibility(id+"Pivot", "show");
i2uiToggleItemVisibility(id+"PivotEdit", "show");
i2uiToggleItemVisibility(id+"PivotChart", "show");
i2uiToggleItemVisibility(id+"PivotSpreadsheet", "hide");
i2uiToggleItemVisibility(id+"showPivot", "show");
i2uiToggleItemVisibility(id+"stretchPivot", "show");
i2uiToggleItemVisibility(id+"showChart", "show");
i2uiToggleItemVisibility(id+"showBoth", "hide");
i2uiToggleItemVisibility(id+"showMultichart", "show");
i2uiToggleItemVisibility(id+"showSpreadsheet", "show");
i2uiToggleItemVisibility(id+"PivotEditForm","hide");
i2uiToggleItemVisibility(id+"PivotMassEditForm","hide");
var obj = document.getElementById(id+"PivotChart_xml");
var obj2 = document.getElementById(id+"PivotChart");
if (obj != null && obj2 != null)
{
var h = document.body.offsetHeight - 110;
var w = (document.body.offsetWidth - 70)/2;
var obj3 = document.getElementById(id+"Container");
if (obj3 != null)
{
h = Math.max(50,obj3.clientHeight-55);
w = Math.max(50,(obj3.clientWidth-40)/2);
}
i2uiBestFitPivot(id,h-10,w);
if (pivot.componentShowing == "chart")
{
obj2.window.i2uiResizeChart(h,w,true);
}
else
{
i2uiApplyPivotEdits(id, pivot);
var chartXML = i2uiChartPivot(id,h,w,false);
//LPM alert(chartXML);
obj.loadXML(chartXML);
obj2.window.i2uiProcessChart();
}
}
pivot.componentShowing = "pivotchart";
}
function i2uiPivotShowMultichart(id)
{
var pivot = document.getElementById(id+"Pivot");
pivot.componentShowing = "multichart";
i2uiToggleItemVisibility(id+"Pivot", "hide");
i2uiToggleItemVisibility(id+"PivotEdit", "hide");
i2uiToggleItemVisibility(id+"PivotChart", "show");
i2uiToggleItemVisibility(id+"PivotSpreadsheet", "hide");
i2uiToggleItemVisibility(id+"showPivot", "show");
i2uiToggleItemVisibility(id+"st