CStyle.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. /****************************************************************
  2. ** Licensed Materials - Property of IBM
  3. **
  4. ** BI and PM: qs
  5. **
  6. ** (C) Copyright IBM Corp. 2001, 2015
  7. **
  8. ** US Government Users Restricted Rights - Use, duplication or
  9. ** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *****************************************************************/
  11. // Copyright (C) 2008 Cognos ULC, an IBM Company. All Rights Reserved.
  12. // Cognos and the Cognos logo are trademarks of Cognos ULC (formerly Cognos Incorporated) in the United States and/or other countries. IBM and the IBM logo are trademarks of International Business Machines Corporation in the United States, or other countries, or both. Other company, product, or service names may be trademarks or service marks of others.
  13. function CStyle()
  14. {
  15. };
  16. CStyle.prototype = new AFeatureObject();
  17. CStyle.prototype.setup = function (aFeatureParams)
  18. {
  19. };
  20. function updateCommandBuffer(cmd)
  21. {
  22. var gcf = getConfigFrame();
  23. if ((getCommandBuffer() == null) || (getCommandBuffer() == ""))
  24. {
  25. gcf.cfgSet("commandBuffer",cmd);
  26. }
  27. else
  28. {
  29. var newCommandBuffer = getCommandBuffer() + ";" + cmd;
  30. gcf.cfgSet("commandBuffer",newCommandBuffer);
  31. }
  32. };
  33. function getCommandBuffer()
  34. {
  35. return getConfigFrame().cfgGet("commandBuffer");
  36. };
  37. function clearCommandBuffer()
  38. {
  39. getConfigFrame().cfgSet("commandBuffer","");
  40. };
  41. function sendBufferedCommands()
  42. {
  43. addColumnsForReselection();
  44. cmd = getCommandBuffer();
  45. if (cmd != "")
  46. {
  47. getConfigFrame().sendCmd(cmd, "", true);
  48. }
  49. };
  50. function toggleStyleCommand(s)
  51. {
  52. var cssAttribute = s;
  53. var cmd = "";
  54. var selectionController = goApplicationManager.getSelectionController();
  55. var reportSelectionController = getReportFrame().g_reportSelectionController;
  56. if (selectionController && (typeof selectionController != 'undefined' && selectionController.getSelections().length == 0) && (typeof reportSelectionController != 'undefined' && reportSelectionController.getSelections().length == 0))
  57. {
  58. dlgShowMessage("STYLE_DIALOG_TEXT_TITLE", "", "STYLE_NO_SELECTION");
  59. return;
  60. }
  61. if (selectionController && typeof selectionController != 'undefined')
  62. {
  63. var selections = selectionController.getSelections();
  64. if (selections.length != 0)
  65. {
  66. for (var i=0; i < selections.length; i++)
  67. {
  68. var queryIdString = "";
  69. var tag = selections[i].getTag()
  70. if (tag != "footertag")
  71. {
  72. queryIdString = selections[i].getColumnName();
  73. if (queryIdString == "")
  74. continue;
  75. }
  76. var type = "";
  77. var levelId = "";
  78. var intersectId = "";
  79. var measureId = "";
  80. var oColSpecialProperties = getColSpecialPropertiesFromSelectionObject(selections[i]);
  81. if (oColSpecialProperties.forcedType)
  82. {
  83. type = oColSpecialProperties.forcedType;
  84. }
  85. if (type == "")
  86. {
  87. var selectionType = selections[i].getCellRef().getAttribute("qsc").substring(0,2);
  88. type = getType(selectionType);
  89. if (type == "")
  90. {
  91. continue;
  92. }
  93. }
  94. if (oColSpecialProperties.levelId)
  95. {
  96. levelId = oColSpecialProperties.levelId;
  97. }
  98. if (oColSpecialProperties.intersectId)
  99. {
  100. intersectId = oColSpecialProperties.intersectId;
  101. }
  102. measureId = getColRefIdFromSelectionObject(selections[i]);
  103. if (i > 0)
  104. {
  105. cmd += ";";
  106. }
  107. if (tag != "footertag")
  108. {
  109. if (levelId == "")
  110. levelId = "none";
  111. if (intersectId == "")
  112. intersectId = "none";
  113. if (measureId == "")
  114. measureId = "none";
  115. cmd += getConfigFrame().createCommand("Z","Z", new Array( escapeParam(queryIdString) , escapeParam(type), escapeParam(cssAttribute), escapeParam(levelId), escapeParam(intersectId), escapeParam(measureId)));
  116. }
  117. else
  118. cmd += getConfigFrame().createCommand("Z","Y", new Array( escapeParam(type), escapeParam(cssAttribute)));
  119. }
  120. }
  121. }
  122. if (typeof reportSelectionController != 'undefined')
  123. {
  124. var selections = reportSelectionController.getSelections();
  125. var bFilterFlag = false;
  126. if (selections.length != 0)
  127. {
  128. for (var i=0; i < selections.length; i++)
  129. {
  130. var type = selections[i].getType();
  131. if (type != "FilterStyle" || bFilterFlag == false)
  132. {
  133. if (cmd != "")
  134. {
  135. cmd += ";";
  136. }
  137. cmd += getConfigFrame().createCommand("Z","Y", new Array( escapeParam(type), escapeParam(cssAttribute)));
  138. }
  139. if (type == "FilterStyle")
  140. bFilterFlag = true;
  141. }
  142. }
  143. }
  144. if (cmd != "")
  145. {
  146. updateCommandBuffer(cmd);
  147. sendBufferedCommands();
  148. }
  149. };
  150. function alignStyleToCSS(alignStyle)
  151. {
  152. var cssVerticalAlign = "vertical-align\:";
  153. var cssTextAlign = "text-align\:";
  154. if (alignStyle != "")
  155. {
  156. switch(alignStyle) {
  157. case "TL":
  158. cssVerticalAlign += "top";
  159. cssTextAlign += "left";
  160. break;
  161. case "TC":
  162. cssVerticalAlign += "top";
  163. cssTextAlign += "center";
  164. break;
  165. case "TR":
  166. cssVerticalAlign += "top";
  167. cssTextAlign += "right";
  168. break;
  169. case "ML":
  170. cssVerticalAlign += "middle";
  171. cssTextAlign += "left";
  172. break;
  173. case "MC":
  174. cssVerticalAlign += "middle";
  175. cssTextAlign += "center";
  176. break;
  177. case "MR":
  178. cssVerticalAlign += "middle";
  179. cssTextAlign += "right";
  180. break;
  181. case "BL":
  182. cssVerticalAlign += "bottom";
  183. cssTextAlign += "left";
  184. break;
  185. case "BC":
  186. cssVerticalAlign += "bottom";
  187. cssTextAlign += "center";
  188. break;
  189. case "BR":
  190. cssVerticalAlign += "bottom";
  191. cssTextAlign += "right";
  192. break;
  193. default:
  194. break;
  195. }
  196. }
  197. return cssVerticalAlign + ";" + cssTextAlign;
  198. };
  199. function alignStyleCommand(s)
  200. {
  201. var cssString = alignStyleToCSS(s);
  202. sendStyleCommand(cssString);
  203. };
  204. function selectStyleCommand(cssAttribute, o)
  205. {
  206. var cssString = cssAttribute + "\:";
  207. if (o.selectedIndex != -1)
  208. {
  209. var style = o.options[o.selectedIndex].value;
  210. cssString += style;
  211. sendStyleCommand(cssString);
  212. o.selectedIndex = 0;
  213. }
  214. };
  215. function textStyleCommand(cssAttribute, cssAttributeValue)
  216. {
  217. var cssString = cssAttribute + "\:" + cssAttributeValue;
  218. sendStyleCommand(cssString);
  219. };
  220. function colorStyleCommand(s)
  221. {
  222. textStyleCommand(COLOR, s);
  223. };
  224. function backgroundColorStyleCommand(s)
  225. {
  226. textStyleCommand(BACKGROUND_COLOR, s);
  227. };
  228. function sendStyleCommand(cssString, bSendCmd)
  229. {
  230. if (typeof bSendCmd == "undefined" || bSendCmd == null)
  231. {
  232. bSendCmd = true;
  233. }
  234. var cmd = "";
  235. var groupCols = new Array();
  236. var selectionController = goApplicationManager.getSelectionController();
  237. var reportSelectionController = goApplicationManager.getReportFrame().g_reportSelectionController;
  238. if (selectionController)
  239. {
  240. var selections = selectionController.getSelections();
  241. if ((typeof selectionController != 'undefined' && selections.length == 0) && (typeof reportSelectionController != 'undefined' && reportSelectionController.getSelections().length == 0))
  242. {
  243. dlgShowMessage("STYLE_DIALOG_TEXT_TITLE", "", "STYLE_NO_SELECTION");
  244. return;
  245. }
  246. for (var i=0; i < selections.length; i++)
  247. {
  248. var queryIdString = "";
  249. var tag = selections[i].getTag();
  250. if (tag != "footertag")
  251. {
  252. queryIdString = selections[i].getColumnName();
  253. if (queryIdString == "")
  254. continue;
  255. }
  256. var type = "";
  257. var levelId = "";
  258. var intersectId = "";
  259. var measureId = "";
  260. var oColSpecialProperties = getColSpecialPropertiesFromSelectionObject(selections[i]);
  261. if (oColSpecialProperties.forcedType)
  262. {
  263. type = oColSpecialProperties.forcedType;
  264. }
  265. if (type == "")
  266. {
  267. var selectionType = selections[i].getCellRef().getAttribute("qsc").substring(0,2);
  268. type = getType(selectionType);
  269. if (type == "")
  270. {
  271. continue;
  272. }
  273. }
  274. if (oColSpecialProperties.levelId)
  275. {
  276. levelId = oColSpecialProperties.levelId;
  277. }
  278. if (oColSpecialProperties.intersectId)
  279. {
  280. intersectId = oColSpecialProperties.intersectId;
  281. }
  282. measureId = getColRefIdFromSelectionObject(selections[i]);
  283. if (i > 0)
  284. {
  285. cmd += ";";
  286. }
  287. if (tag != "footertag")
  288. {
  289. if (levelId == "")
  290. levelId = "none";
  291. if (intersectId == "")
  292. intersectId = "none";
  293. if (measureId == "")
  294. measureId = "none";
  295. if (cssString != "" && cssString != null)
  296. cmd += getConfigFrame().createCommand("Z","C", new Array( escapeParam(queryIdString) , escapeParam(cssString), escapeParam(type), escapeParam(levelId), escapeParam(intersectId), escapeParam(measureId)));
  297. else
  298. cmd += getConfigFrame().createCommand("Z","D", new Array( escapeParam(queryIdString) , escapeParam(type), escapeParam(levelId), escapeParam(intersectId), escapeParam(measureId)));
  299. }
  300. else
  301. {
  302. if (cssString != "" && cssString != null)
  303. cmd += getConfigFrame().createCommand("Z","H", new Array( escapeParam(cssString) , escapeParam(type)));
  304. else
  305. cmd += getConfigFrame().createCommand("Z","I", new Array(escapeParam(type)));
  306. }
  307. }
  308. }
  309. if (typeof reportSelectionController != 'undefined')
  310. {
  311. selections = reportSelectionController.getSelections();
  312. if (selections.length != 0)
  313. {
  314. for (var i=0; i < selections.length; i++)
  315. {
  316. var type = selections[i].getType();
  317. if (cmd != "")
  318. {
  319. cmd += ";";
  320. }
  321. if (cssString != "" && cssString != null)
  322. cmd += getConfigFrame().createCommand("Z","H", new Array( escapeParam(cssString) , escapeParam(type)));
  323. else
  324. cmd += getConfigFrame().createCommand("Z","I", new Array(escapeParam(type)));
  325. }
  326. }
  327. }
  328. if (cmd != "")
  329. {
  330. updateCommandBuffer(cmd);
  331. addColumnsForReselection();
  332. if (bSendCmd)
  333. sendBufferedCommands();
  334. }
  335. };
  336. function sendBorderStyleCommand(cssString, type, bSendCmd)
  337. {
  338. if (typeof bSendCmd == "undefined" || bSendCmd == null)
  339. bSendCmd = true;
  340. var cmd = getConfigFrame().createCommand("Z","B", new Array( escapeParam(cssString) , escapeParam(type)));
  341. updateCommandBuffer(cmd);
  342. if (bSendCmd)
  343. sendBufferedCommands();
  344. };
  345. function getType(selectionType)
  346. {
  347. var type;
  348. if (typeof selectionType == "undefined" || selectionType == null || selectionType == "")
  349. return "";
  350. selectionType = selectionType.substring(0,2);
  351. switch (selectionType)
  352. {
  353. case "sh":
  354. type = COLUMN_SECTION_STYLE;
  355. break;
  356. case "lt":
  357. case "ml":
  358. case "xm":
  359. type = COLUMN_TITLE_STYLE;
  360. break;
  361. case "lc":
  362. case "mv":
  363. type = COLUMN_STYLE;
  364. break;
  365. case "if":
  366. case "il":
  367. type = COLUMN_GROUP_FOOTER_LABEL_STYLE;
  368. break;
  369. case "is":
  370. case "iv":
  371. type = COLUMN_GROUP_FOOTER_VALUE_STYLE;
  372. break;
  373. case "sf":
  374. type = COLUMN_SECTION_FOOTER_LABEL_STYLE;
  375. break;
  376. case "ss":
  377. type = COLUMN_SECTION_FOOTER_VALUE_STYLE;
  378. break;
  379. case "of":
  380. case "ol":
  381. type = COLUMN_FOOTER_LABEL_STYLE;
  382. break;
  383. case "os":
  384. case "ov":
  385. type = COLUMN_FOOTER_VALUE_STYLE;
  386. break;
  387. default:
  388. type = "";
  389. }
  390. return type;
  391. };
  392. function isTitleAreaStyle(style)
  393. {
  394. return (style == TITLE_STYLE ||
  395. style == SUBTITLE_STYLE ||
  396. style == FILTER_STYLE);
  397. };
  398. function isOverallSummaryStyle(style)
  399. {
  400. return (style == COLUMN_FOOTER_LABEL_STYLE);
  401. };
  402. function sendStyleAllCommand(cssString, selectionType, bSendCmd)
  403. {
  404. var oMQMgr = goApplicationManager.getMiniQueryManager();
  405. if (typeof bSendCmd == "undefined" || bSendCmd == null)
  406. bSendCmd = true;
  407. var gcf = getConfigFrame();
  408. var cmd ="";
  409. var groups = new Array();
  410. for (var i = 0; i < oMQMgr.getAllColumns().length; i++)
  411. {
  412. if (oMQMgr.getColumnRole(i) === MINI_QUERY_GROUP_LIST || oMQMgr.getColumnRole(i) === MINI_QUERY_GROUP_SECTION)
  413. {
  414. groups[groups.length] = oMQMgr.getColumnId(i);
  415. }
  416. }
  417. if (isTitleAreaStyle(selectionType) || isOverallSummaryStyle(selectionType))
  418. {
  419. if (cssString != "" && cssString != null)
  420. cmd = getConfigFrame().createCommand("Z","H", new Array( escapeParam(cssString) , escapeParam(selectionType)));
  421. else
  422. cmd = getConfigFrame().createCommand("Z","I", new Array(escapeParam(selectionType)));
  423. }
  424. else
  425. {
  426. for (var i = 0; i < oMQMgr.getAllColumns().length; i++)
  427. {
  428. if (cmd != "")
  429. {
  430. cmd += ";";
  431. }
  432. var queryIdString = oMQMgr.getColumnId(i);
  433. if (selectionType == COLUMN_GROUP_FOOTER_VALUE_STYLE || selectionType == COLUMN_SECTION_FOOTER_VALUE_STYLE)
  434. {
  435. for (var j = 0; j < groups.length; j++)
  436. {
  437. if (cssString != "" && cssString != null)
  438. cmd += getConfigFrame().createCommand("Z","C", new Array( escapeParam(queryIdString), escapeParam(cssString), escapeParam(selectionType), escapeParam(groups[j])));
  439. else
  440. cmd += getConfigFrame().createCommand("Z","D", new Array( escapeParam(queryIdString), escapeParam(selectionType), escapeParam(groups[j])));
  441. if (j+1 < groups.length)
  442. {
  443. cmd += ";";
  444. }
  445. }
  446. }
  447. else
  448. {
  449. if (cssString != "" && cssString != null)
  450. cmd += getConfigFrame().createCommand("Z","C", new Array( escapeParam(queryIdString), escapeParam(cssString), escapeParam(selectionType)));
  451. else
  452. cmd += getConfigFrame().createCommand("Z","D", new Array( escapeParam(queryIdString), escapeParam(selectionType)));
  453. }
  454. }
  455. }
  456. if (cmd != "")
  457. {
  458. updateCommandBuffer(cmd);
  459. if (bSendCmd)
  460. sendBufferedCommands();
  461. }
  462. };
  463. var COLUMN_SECTION_STYLE = "SectionStyle";
  464. var COLUMN_TITLE_STYLE = "ColumnTitleStyle";
  465. var COLUMN_STYLE = "ColumnStyle";
  466. var COLUMN_GROUP_FOOTER_LABEL_STYLE = "ColumnGroupFooterLabelStyle";
  467. var COLUMN_GROUP_FOOTER_VALUE_STYLE = "ColumnGroupFooterValueStyle";
  468. var COLUMN_SECTION_FOOTER_LABEL_STYLE = "ColumnSectionFooterLabelStyle";
  469. var COLUMN_SECTION_FOOTER_VALUE_STYLE = "ColumnSectionFooterValueStyle";
  470. var COLUMN_FOOTER_LABEL_STYLE = "ColumnFooterLabelStyle";
  471. var COLUMN_FOOTER_VALUE_STYLE = "ColumnFooterValueStyle";
  472. var TITLE_STYLE = "TitleStyle";
  473. var SUBTITLE_STYLE = "SubtitleStyle";
  474. var FILTER_STYLE = "FilterStyle";
  475. var SELECTED_STYLE = COLUMN_STYLE;
  476. var FONT_FAMILY = "font-family";
  477. var FONT_SIZE = "font-size";
  478. var COLOR = "color";
  479. var BACKGROUND_COLOR = "background-color";