123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490 |
- function getStylesFromAllSelectedCols()
- {
- var currentStyle = new Array();
- var selectionController = null;
- if (typeof goApplicationManager == "object")
- {
- selectionController = goApplicationManager.getSelectionController();
- }
- else if (typeof goDialogManager == "object")
- {
- selectionController = goDialogManager.getSelectionController();
- }
- else
- {
- return currentStyle;
- }
- var selections = selectionController.getSelections();
- var cf = getConfigFrame();
-
- if (selections.length)
- {
- var queryIds = new Array();
- var types = new Array();
-
-
- var i;
- for (i = 0; i < selections.length; i++)
- {
- queryIds[queryIds.length] = selections[i].getColumnName();
- var cellRef = selections[i].getCellRef();
- var oColSpecialProperties = cf.getColSpecialPropertiesFromSelectionObject(selections[i]);
- var sForcedType = "";
- if (oColSpecialProperties.forcedType)
- {
- sForcedType = oColSpecialProperties.forcedType;
- }
- if (cellRef !== null)
- {
- types[types.length] = (sForcedType == "" ? cf.getType(cellRef.getAttribute("qsc")) : sForcedType);
- }
- else
- {
- types[types.length] = null;
- }
- }
- if (types.length == queryIds.length)
- {
-
- if (typeof cf !== "undefined")
- {
- var MQ = cf.goApplicationManager.getMiniQueryManager();
- var columns = MQ.getElementsByTagName("Column");
- for (var j = 0; j < queryIds.length; j++)
- {
- var column = null;
- for (i = 0; i < columns.length; i++)
- {
- var sId = columns[i].getAttribute("id");
- if (sId && sId == queryIds[j])
- {
- column = columns[i];
- break;
- }
- }
- if (column !== null && types[j] !== null)
- {
- var styleNodes = column.getElementsByTagName(types[j]);
- if (styleNodes !== null)
- {
- for (var k = 0; k < styleNodes.length; k++)
- {
-
-
-
-
- currentStyle[currentStyle.length] = styleNodes[k].getAttribute("style").replace(/'/gi, "'");
- }
- }
- }
- }
- }
- }
- }
- return currentStyle;
- };
- function getStylesFromAllSelectedReportElements()
- {
- var cf = getConfigFrame();
- var currentStyle = new Array();
- var selectionController = null;
- try
- {
- selectionController = getReportFrame().g_reportSelectionController;
- }
- catch (e)
- {
- return currentStyle;
- }
- var selections = selectionController.getSelections();
- if (selections.length)
- {
-
- var styleTypes = new Array();
- var i;
- for (i = 0; i < selections.length; i++)
- {
- styleTypes[styleTypes.length] = selections[i].getType();
- }
-
- if (typeof cf != "undefined")
- {
- var MQ = cf.goApplicationManager.getMiniQueryManager();
- var titleArea = MQ.getElementsByTagName("TitleArea");
- if (titleArea !== null && titleArea.length)
- {
- for (i = 0; i < styleTypes.length; i++)
- {
- var styleList = titleArea[0].getElementsByTagName(styleTypes[i]);
- if (styleList !== null && styleList.length)
- {
- currentStyle[currentStyle.length] = styleList[0].getAttribute("style").replace(/'/gi, "'");
- }
- }
- }
- }
- }
- return currentStyle;
- };
- function mergeStyles(stylesArray, returnAsArray)
- {
- var commonStyles = new Array();
- if (stylesArray.length === 0)
- {
- if (typeof returnAsArray != "undefined" && returnAsArray === true)
- {
- return commonStyles;
- }
- return "";
- }
-
- commonStyles[0] = getCSSValue(stylesArray[0], 'font-weight');
- commonStyles[1] = getCSSValue(stylesArray[0], 'font-style');
- commonStyles[2] = getCSSValue(stylesArray[0], 'font-family');
- commonStyles[3] = getCSSValue(stylesArray[0], 'font-size');
- commonStyles[4] = getCSSValue(stylesArray[0], 'color');
- commonStyles[5] = getCSSValue(stylesArray[0], 'background-color');
- var textDecoration = getCSSValue(stylesArray[0], 'text-decoration');
- commonStyles[6] = textDecoration.toLowerCase().indexOf('underline') >= 0 ? true : -1;
- commonStyles[7] = textDecoration.toLowerCase().indexOf('overline') >= 0 ? true : -1;
- commonStyles[8] = textDecoration.toLowerCase().indexOf('line-through') >= 0 ? true : -1;
- commonStyles[9] = getCSSValue(stylesArray[0], 'text-align');
- commonStyles[10] = getCSSValue(stylesArray[0], 'vertical-align');
- var i;
-
- for (i = 1; i < stylesArray.length; i++)
- {
- if (commonStyles[0] !== -1 && commonStyles[0] != getCSSValue(stylesArray[i], 'font-weight'))
- {
- commonStyles[0] = -1;
- }
- if (commonStyles[1] !== -1 && commonStyles[1] != getCSSValue(stylesArray[i], 'font-style'))
- {
- commonStyles[1] = -1;
- }
- if (commonStyles[2] !== -1 && commonStyles[2] != getCSSValue(stylesArray[i], 'font-family'))
- {
- commonStyles[2] = -1;
- }
- if (commonStyles[3] !== -1 && commonStyles[3] != getCSSValue(stylesArray[i], 'font-size'))
- {
- commonStyles[3] = -1;
- }
- if (commonStyles[4] !== -1 && commonStyles[4] != getCSSValue(stylesArray[i], 'color'))
- {
- commonStyles[4] = -1;
- }
- if (commonStyles[5] !== -1 && commonStyles[5] != getCSSValue(stylesArray[i], 'background-color'))
- {
- commonStyles[5] = -1;
- }
- textDecoration = getCSSValue(stylesArray[i], 'text-decoration');
- if (commonStyles[6] !== -1)
- {
- commonStyles[6] = textDecoration.toLowerCase().indexOf('underline') >= 0 ? true : -1;
- }
- if (commonStyles[7] !== -1)
- {
- commonStyles[7] = textDecoration.toLowerCase().indexOf('overline') >= 0 ? true : -1;
- }
- if (commonStyles[8] !== -1)
- {
- commonStyles[8] = textDecoration.toLowerCase().indexOf('line-through') >= 0 ? true : -1;
- }
- if (commonStyles[9] !== -1 && commonStyles[9] != getCSSValue(stylesArray[i], 'text-align'))
- {
- commonStyles[9] = -1;
- }
- if (commonStyles[10] !== -1 && commonStyles[10] != getCSSValue(stylesArray[i], 'vertical-align'))
- {
- commonStyles[10] = -1;
- }
- }
- if (typeof returnAsArray != "undefined" && returnAsArray === true)
- {
- return commonStyles;
- }
-
- if (commonStyles[0] !== -1 && commonStyles[0] !== "")
- {
- commonStyles[0] = 'font-weight:' + commonStyles[0];
- }
- if (commonStyles[1] !== -1 && commonStyles[1] !== "")
- {
- commonStyles[1] = 'font-style:' + commonStyles[1];
- }
- if (commonStyles[2] !== -1 && commonStyles[2] !== "")
- {
- commonStyles[2] = 'font-family:' + commonStyles[2];
- }
- if (commonStyles[3] !== -1 && commonStyles[3] !== "")
- {
- commonStyles[3] = 'font-size:' + commonStyles[3];
- }
- if (commonStyles[4] !== -1 && commonStyles[4] !== "")
- {
- commonStyles[4] = 'color:' + commonStyles[4];
- }
- if (commonStyles[5] !== -1 && commonStyles[5] !== "")
- {
- commonStyles[5] = 'background-color:' + commonStyles[5];
- }
- textDecoration = "";
- if (commonStyles[6] !== -1 && commonStyles[6] !== "")
- {
- textDecoration = "underline ";
- }
- if (commonStyles[7] !== -1 && commonStyles[7] !== "")
- {
- textDecoration += "overline ";
- }
- if (commonStyles[8] !== -1 && commonStyles[8] !== "")
- {
- textDecoration += "line-through";
- }
- commonStyles[6] = -1;
- commonStyles[7] = -1;
- if (textDecoration !== "")
- {
- commonStyles[8] = "text-decoration:" + textDecoration;
- }
- else
- {
- commonStyles[8] = -1;
- }
- if (commonStyles[9] !== -1 && commonStyles[9] !== "")
- {
- commonStyles[9] = 'text-align:' + commonStyles[9];
- }
- if (commonStyles[10] !== -1 && commonStyles[10] !== "")
- {
- commonStyles[10] = 'vertical-align:' + commonStyles[10];
- }
-
- var currentStyleStr = "";
- for (i = 0; i < commonStyles.length; i++)
- {
- if (commonStyles[i] !== -1)
- {
- currentStyleStr += addSeparator(commonStyles[i]);
- }
- }
- return currentStyleStr;
- };
- function addSeparator(cssString, separator)
- {
- if (cssString !== "")
- {
- if (typeof separator != "undefined")
- {
- cssString += separator;
- }
- else
- {
- cssString += ";";
- }
- }
- return cssString;
- };
- function initTextStyles(css, elementsArray, formArray)
- {
-
- if (typeof formArray[6] != "undefined")
- {
- setCombo(formArray[6], getCSSValue(css, 'font-family'));
- }
-
- if (typeof formArray[7] != "undefined")
- {
- setCombo(formArray[7], getCSSValue(css, 'font-size'));
- }
-
- if (typeof formArray[8] != "undefined")
- {
- setCombo(formArray[8], getCSSValue(css, 'font-weight'));
- }
-
- if (typeof formArray[9] != "undefined")
- {
- setCombo(formArray[9], getCSSValue(css, 'font-style'));
- }
-
- var forecolor = getCSSValue(css, 'color');
- if (typeof formArray[0] != "undefined")
- {
- formArray[0].value = forecolor;
- }
- if (typeof elementsArray[0] != "undefined")
- {
- elementsArray[0].style.backgroundColor = forecolor;
- }
- if (typeof elementsArray[3] != "undefined")
- {
- elementsArray[3].setColor(forecolor);
- }
-
- var backcolor = getCSSValue(css, 'background-color');
- if (typeof formArray[1] != "undefined")
- {
- formArray[1].value = backcolor;
- }
- if (typeof elementsArray[1] != "undefined")
- {
- elementsArray[1].style.backgroundColor = backcolor;
- }
- if (typeof elementsArray[4] != "undefined")
- {
- elementsArray[4].setColor(backcolor);
- }
-
- var textDecoration = getCSSValue(css, 'text-decoration');
- if (typeof formArray[2] != "undefined")
- {
- formArray[2].checked = (/underline/gi).test(textDecoration);
- }
- if (typeof formArray[3] != "undefined")
- {
- formArray[3].checked = (/overline/gi).test(textDecoration);
- }
- if (typeof formArray[4] != "undefined")
- {
- formArray[4].checked = (/line-through/gi).test(textDecoration);
- }
-
- var vertAlign = getCSSValue(css, 'vertical-align');
- var horizAlign = getCSSValue(css, 'text-align');
- var align = cssToAlignCode(horizAlign, vertAlign);
- if (typeof formArray[5] != "undefined")
- {
- formArray[5].value = align;
- }
- if (typeof elementsArray[2] != "undefined")
- {
- elementsArray[2].setAlignment(align);
- }
- };
- function cssToAlignCode(horizAlign, vertAlign)
- {
- var align = "";
- if (vertAlign !== "" && horizAlign !== "")
- {
- switch (vertAlign)
- {
- case "top":
- align = "T";
- break;
- case "middle":
- align = "M";
- break;
- case "bottom":
- align = "B";
- break;
- }
- switch (horizAlign)
- {
- case "left":
- align += "L";
- break;
- case "center":
- align += "C";
- break;
- case "right":
- align += "R";
- break;
- }
- }
- return align;
- };
- function setCombo(selectObj, cssValue)
- {
- if (cssValue !== "")
- {
- for (var i = 0; i < selectObj.options.length; i++)
- {
- if (selectObj.options[i].value == cssValue)
- {
- selectObj.options[i].selected = true;
- break;
- }
- }
- }
- else
- {
- selectObj.options[0].selected = true;
- }
- };
- function getCSSValue(css, attribute)
- {
- var reAttr = new RegExp('^([^:]*)');
- var reValue = new RegExp(':\s*(.*)');
- var reAttrName = new RegExp('^\s*' + attribute + '\s*$', 'i');
- var value = "";
- var cssLines = css.split(";");
- if (cssLines)
- {
- for (var i = 0; i < cssLines.length; i++)
- {
- var cssLine = cssLines[i].replace(/^\s*/,"").replace(/\s*$/, "");
- if ( reAttr.test(cssLine) )
- {
- if ( reAttrName.test(RegExp.$1) && reValue.test(cssLine) )
- {
- value = RegExp.$1;
- break;
- }
- }
- }
- }
- return value;
- };
|