API.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. /**
  2. Licensed Materials - Property of IBM
  3. IBM Cognos Products: DOCS
  4. (C) Copyright IBM Corp. 2005, 2010
  5. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
  6. IBM Corp.
  7. */
  8. /**
  9. *
  10. * API.java
  11. *
  12. * Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  13. * Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  14. *
  15. * This class is used by a DOM parser to add the appropriate element
  16. * tags to a new report.
  17. */
  18. import java.io.ByteArrayInputStream;
  19. import java.util.List;
  20. import java.util.Vector;
  21. import org.dom4j.Document;
  22. import org.dom4j.DocumentHelper;
  23. import org.dom4j.Element;
  24. import org.dom4j.QName;
  25. import org.dom4j.io.SAXReader;
  26. public class API /* implements ReportBuilder */
  27. {
  28. private String sReportSpec;
  29. public static final String sREPORT = "report";
  30. private Document oDocument;
  31. public API(String sReportSpec)
  32. {
  33. try
  34. {
  35. // when creating a dom document, temporarily remove the default
  36. // namespace from the XML otherwise selecting nodes will fail.
  37. String start = null;
  38. String end = null;
  39. int index = sReportSpec.indexOf("xmlns=", 0);
  40. if (index >= 0)
  41. {
  42. start = sReportSpec.substring(0, index);
  43. end = sReportSpec.substring(sReportSpec.indexOf(
  44. "http://developer.cognos.com/schemas/report/15.0/") + 49);
  45. sReportSpec = start + end;
  46. }
  47. //load the spec into the DOM
  48. SAXReader xmlReader = new SAXReader();
  49. ByteArrayInputStream bais = new ByteArrayInputStream(sReportSpec
  50. .getBytes("UTF-8"));
  51. oDocument = xmlReader.read(bais);
  52. } catch (Exception e) {
  53. e.printStackTrace();
  54. }
  55. }
  56. public API() {
  57. Element reportElement = DocumentHelper.createElement("report");
  58. // In dom4j 1.6.1, can no longer add xmlns with addAttribute
  59. reportElement.addNamespace("", "http://developer.cognos.com/schemas/report/15.0/");
  60. reportElement.addAttribute("expressionLocale", "en-us");
  61. oDocument = DocumentHelper.createDocument(reportElement);
  62. }
  63. public void updateXMLNS() {
  64. Element e = oDocument.getRootElement();
  65. // In dom4j 1.6.1, can no longer add xmlns with addAttribute
  66. e.addNamespace("", "http://developer.cognos.com/schemas/report/15.0/");
  67. }
  68. public String getXML() {
  69. String strXML = oDocument.asXML();
  70. //strip out extraneous empty xmlns attributes added by use of addAttribute
  71. strXML = strXML.replaceAll(" xmlns=\"\"","");
  72. return strXML;
  73. }
  74. public void addLayouts() {
  75. Element e = DocumentHelper.createElement("layouts");
  76. oDocument.getRootElement().add(e);
  77. }
  78. public void addLayout() {
  79. Element n = (Element) oDocument.selectSingleNode("/report/layouts");
  80. if (n == null) {
  81. addLayouts();
  82. n = (Element) oDocument.selectSingleNode("/report/layouts");
  83. }
  84. Element e = DocumentHelper.createElement("layout");
  85. n.add(e);
  86. }
  87. public void addReportPages() {
  88. Element n = (Element) oDocument
  89. .selectSingleNode("/report/layouts/layout");
  90. if (n == null) {
  91. addLayout();
  92. n = (Element) oDocument.selectSingleNode("/report/layouts/layout");
  93. }
  94. Element e = DocumentHelper.createElement("reportPages");
  95. n.add(e);
  96. }
  97. public void addPage(String p_sName) {
  98. Element n = (Element) oDocument
  99. .selectSingleNode("/report/layouts/layout/reportPages");
  100. if (n == null) {
  101. addReportPages();
  102. n = (Element) oDocument
  103. .selectSingleNode("/report/layouts/layout/reportPages");
  104. }
  105. Element e = DocumentHelper.createElement("page");
  106. Element eStyle = buildStyle("pg");
  107. e.addAttribute("name", p_sName);
  108. e.add(eStyle);
  109. n.add(e);
  110. }
  111. public void addPageBody() {
  112. Element n = (Element) oDocument
  113. .selectSingleNode("/report/layouts/layout/reportPages/page");
  114. if (n == null) {
  115. addPage("Page1");
  116. n = (Element) oDocument
  117. .selectSingleNode("/report/layouts/layout/reportPages/page");
  118. }
  119. Element e = DocumentHelper.createElement("pageBody");
  120. Element eStyle = buildStyle("pb");
  121. e.add(eStyle);
  122. n.add(e);
  123. }
  124. public void addPageBodyContents() {
  125. Element n = (Element) oDocument
  126. .selectSingleNode("/report/layouts/layout/reportPages/page/pageBody");
  127. if (n == null) {
  128. addPageBody();
  129. n = (Element) oDocument
  130. .selectSingleNode("/report/layouts/layout/reportPages/page/pageBody");
  131. }
  132. Element e = DocumentHelper.createElement("contents");
  133. n.add(e);
  134. }
  135. public void addList()
  136. {
  137. addList("Query1");
  138. }
  139. public void addList(String p_sName) {
  140. Element n = (Element) oDocument
  141. .selectSingleNode("/report/layouts/layout/reportPages/page/pageBody/contents");
  142. if (n == null) {
  143. addPageBodyContents();
  144. n = (Element) oDocument
  145. .selectSingleNode("/report/layouts/layout/reportPages/page/pageBody/contents");
  146. }
  147. Element e = DocumentHelper.createElement("list");
  148. Element eStyle = buildStyle("ls");
  149. e.addAttribute("refQuery", p_sName);
  150. e.add(eStyle);
  151. n.add(e);
  152. }
  153. public void addStyle() {
  154. addStyle("Query1");
  155. }
  156. public void addStyle(String p_sName) {
  157. String sName = p_sName;
  158. String quotChar = "\'";
  159. if (sName.indexOf(quotChar) >= 0) {
  160. quotChar = "\"";
  161. }
  162. String elementString = "/report/layouts/layout/reportPages/page/pageBody/contents/list[@refQuery="
  163. + quotChar + sName + quotChar + "]";
  164. Element n = (Element) oDocument.selectSingleNode(elementString);
  165. if (n == null) {
  166. addList(p_sName);
  167. n = (Element) oDocument.selectSingleNode(elementString);
  168. }
  169. Element e = DocumentHelper.createElement("style");
  170. n.add(e);
  171. }
  172. public void addCSS(String p_sName) {
  173. Element n = (Element) oDocument
  174. .selectSingleNode("/report/layouts/layout/reportPages/page/pageBody/contents/list/style");
  175. if (n == null) {
  176. addStyle();
  177. n = (Element) oDocument
  178. .selectSingleNode("/report/layouts/layout/reportPages/page/pageBody/contents/list/style");
  179. }
  180. Element e = DocumentHelper.createElement("CSS");
  181. e.addAttribute("value", p_sName);
  182. n.add(e);
  183. }
  184. public void addQueries() {
  185. Element e = DocumentHelper.createElement("queries");
  186. oDocument.getRootElement().add(e);
  187. }
  188. public Element buildStyle(String sName) {
  189. Element eStyle = DocumentHelper.createElement("style");
  190. Element eDefaultStyles = DocumentHelper.createElement("defaultStyles");
  191. Element eDefinedStyle = DocumentHelper.createElement("defaultStyle");
  192. eDefinedStyle.addAttribute("refStyle", sName);
  193. eDefaultStyles.add(eDefinedStyle);
  194. eStyle.add(eDefaultStyles);
  195. return eStyle;
  196. }
  197. public void getQueries() {
  198. List n = (List) oDocument.selectSingleNode("/report/queries/query");
  199. if (n != null) {
  200. for (int i = 0; i < n.size(); i++) {
  201. String x = ((Element) n.get(i)).getName();
  202. System.out.println(x);
  203. }
  204. }
  205. }
  206. public void addQuery()
  207. {
  208. addQuery("Query1");
  209. }
  210. public void addQuery(String p_sName) {
  211. Element n = (Element) oDocument.selectSingleNode("/report/queries");
  212. if (n == null)
  213. {
  214. addQueries();
  215. n = (Element) oDocument.selectSingleNode("/report/queries");
  216. }
  217. Element eModel = DocumentHelper.createElement("model");
  218. Element eSource = DocumentHelper.createElement("source");
  219. Element e = DocumentHelper.createElement("query");
  220. eSource.add(eModel);
  221. e.add(eSource);
  222. e.addAttribute("name", p_sName);
  223. n.add(e);
  224. }
  225. public void addSelection()
  226. {
  227. Element n = (Element) oDocument.selectSingleNode("/report/queries/query");
  228. if (n == null)
  229. {
  230. addQuery();
  231. n = (Element) oDocument.selectSingleNode("/report/queries/query");
  232. }
  233. Element eSelection = DocumentHelper.createElement("selection");
  234. n.add(eSelection);
  235. }
  236. /**
  237. * addDataItem
  238. *
  239. * @param p_sName
  240. * @param p_sExpression
  241. */
  242. public void addDataItem(String p_sName, String p_sExpression)
  243. {
  244. addDataItem(p_sName, p_sExpression, false);
  245. }
  246. public void addDataItem(String p_sName, String p_sExpression,
  247. boolean p_bAggregate)
  248. {
  249. addDataItem(p_sName, p_sExpression, p_bAggregate, null);
  250. }
  251. public void addDataItem(String p_sName, String p_sExpression,
  252. boolean p_bAggregate, String p_sSort)
  253. {
  254. Element nSelection = (Element) oDocument.selectSingleNode(
  255. "/report/queries/query/selection");
  256. if (nSelection == null)
  257. {
  258. addSelection();
  259. nSelection = (Element) oDocument.selectSingleNode(
  260. "/report/queries/query/selection");
  261. }
  262. //Create the dataItem element
  263. Element eDataItem = DocumentHelper.createElement("dataItem");
  264. eDataItem.addAttribute("name", p_sName);
  265. //Add an aggregation element, if necessary
  266. if (p_bAggregate) {
  267. eDataItem.addAttribute("aggregate", "true");
  268. }
  269. //Add the expression for the dataItem
  270. Element eExpression = DocumentHelper.createElement("expression");
  271. eExpression.setText(p_sExpression);
  272. eDataItem.add(eExpression);
  273. //Add the dataItem to the selection element
  274. nSelection.add(eDataItem);
  275. //add the sort item to the report, if necessary
  276. if (p_sSort != null && !p_sSort.equals(""))
  277. {
  278. addDataItemSort(p_sName, p_sSort);
  279. }
  280. }
  281. public void addModelPath(String p_sName)
  282. {
  283. Element n = (Element) oDocument.getRootElement();
  284. Element eModelPath = DocumentHelper.createElement("modelPath");
  285. eModelPath.setText(p_sName + "/model[@name='model']");
  286. n.add(eModelPath);
  287. }
  288. public void addModel()
  289. {
  290. Element n = (Element) oDocument.selectSingleNode(
  291. "/report/queries/query");
  292. if (n == null)
  293. {
  294. addQuery();
  295. n = (Element) oDocument.selectSingleNode(
  296. "/report/queries/query");
  297. }
  298. Element e = DocumentHelper.createElement("model");
  299. n.add(e);
  300. }
  301. public void addListColumnRowSpan(String p_sName)
  302. {
  303. String sName = p_sName;
  304. String quotChar = "\'";
  305. if (sName.indexOf(quotChar) >= 0) {
  306. quotChar = "\"";
  307. }
  308. //Need to find the column corresponding to the referenced data item
  309. String elementString =
  310. "/report/layouts/layout/reportPages/page/pageBody/contents/list/"
  311. + "listColumns/listColumn/listColumnBody/contents/textItem/dataSource/"
  312. + "dataItemValue[@refDataItem="
  313. + quotChar
  314. + sName
  315. + quotChar
  316. + "]";
  317. Element n = (Element) oDocument.selectSingleNode(elementString);
  318. //Need to add a listColumnRowSpan node to listColumnBody for that
  319. // column (4 levels up)
  320. Element eColumnBody = n.getParent().getParent().getParent().getParent();
  321. Element eListColumnRowSpan = DocumentHelper
  322. .createElement("listColumnRowSpan");
  323. eListColumnRowSpan.addAttribute("refDataItem", sName);
  324. }
  325. public void addListGroups()
  326. {
  327. Element n = (Element) oDocument.selectSingleNode(
  328. "/report/layouts/layout/reportPages/page/pageBody/contents/list/");
  329. if (n == null)
  330. {
  331. addList();
  332. n = (Element) oDocument.selectSingleNode(
  333. "/report/layouts/layout/reportPages/page/pageBody/contents/list/");
  334. }
  335. Element eListGroups = DocumentHelper.createElement("listGroups");
  336. n.add(eListGroups);
  337. }
  338. public void addListGroup(String p_sName) {
  339. Element n = (Element) oDocument.selectSingleNode(
  340. "/report/layouts/layout/reportPages/page/pageBody/contents/list/"
  341. + "listColumns/listGroups");
  342. if (n == null)
  343. {
  344. addListGroups();
  345. n = (Element) oDocument.selectSingleNode(
  346. "/report/layouts/layout/reportPages/page/pageBody/contents/list/"
  347. + "listColumns/listGroups");
  348. }
  349. //Add the listGroup node to listGroups
  350. Element eListGroup = DocumentHelper.createElement("listGroup");
  351. n.addAttribute("refDataItem", p_sName);
  352. n.add(eListGroup);
  353. }
  354. public void removeColumn(String sColumnReference, String sColumnExpression,
  355. String sColumnTitle) {
  356. Element nDataItem = null;
  357. Element nRefItem = null;
  358. Element nColumn = null;
  359. String quotChar = "\'";
  360. if (sColumnExpression.indexOf(quotChar) >= 0) {
  361. quotChar = "\"";
  362. }
  363. nDataItem = (Element) (oDocument.selectSingleNode(
  364. "/report/queries/query/selection/dataItem[@name="
  365. + quotChar
  366. + sColumnReference
  367. + quotChar
  368. + "]"));
  369. if (nDataItem != null) {
  370. nDataItem.detach();
  371. } else {
  372. System.out.println("Remove column failed for column "
  373. + sColumnExpression);
  374. //return;
  375. }
  376. quotChar = "\'";
  377. if (sColumnReference.indexOf(quotChar) >= 0) {
  378. quotChar = "\"";
  379. }
  380. quotChar = "\'";
  381. if (sColumnReference.indexOf(quotChar) >= 0) {
  382. quotChar = "\"";
  383. }
  384. // remove the list column
  385. nColumn = (Element) oDocument.selectSingleNode(
  386. "/report/layouts/layout/reportPages/page/pageBody/contents/"
  387. + "list/listColumns/listColumn/listColumnTitle/contents/textItem/"
  388. + "dataSource/dataItemLabel[@refDataItem="
  389. + quotChar
  390. + sColumnReference
  391. + quotChar
  392. + "]");
  393. if (nColumn != null) {
  394. nColumn.getParent().getParent().getParent().getParent().getParent().detach();
  395. } else {
  396. System.out.println(
  397. "Remove list column failed for columnReference: " + sColumnReference);
  398. }
  399. }
  400. public void addDetailFilter()
  401. {
  402. Element n = (Element) oDocument.selectSingleNode(
  403. "/report/queries/query");
  404. if (n == null)
  405. {
  406. addQuery();
  407. n = (Element) oDocument.selectSingleNode(
  408. "/report/queries/query");
  409. }
  410. Element eDetailFilter = DocumentHelper.createElement(
  411. "detailFilter");
  412. n.add(eDetailFilter);
  413. }
  414. public void addFilter() {
  415. Element n = (Element) oDocument.selectSingleNode(
  416. "/report/queries/query/detailFilter");
  417. if (n == null) {
  418. addDetailFilter();
  419. n = (Element) oDocument.selectSingleNode(
  420. "/report/queries/query/detailFilter");
  421. }
  422. Element eFilter = DocumentHelper.createElement("filter");
  423. eFilter.addAttribute("use", "required");
  424. n.add(eFilter);
  425. }
  426. public void addFilterExpression(String filter)
  427. {
  428. Element n = (Element) oDocument.selectSingleNode(
  429. "/report/queries/query/detailFilter/filter");
  430. if (n == null)
  431. {
  432. addFilter();
  433. n = (Element) oDocument.selectSingleNode(
  434. "/report/queries/query/detailFilter/filter");
  435. }
  436. Element eFilterExpression = DocumentHelper.createElement("filterExpression");
  437. eFilterExpression.setText(filter);
  438. n.add(eFilterExpression);
  439. }
  440. public void addSortList()
  441. {
  442. Element n = (Element) oDocument.selectSingleNode(
  443. "/report/layouts/layout/reportPages/page/pageBody/contents/list");
  444. if (n == null)
  445. {
  446. addList();
  447. n = (Element) oDocument.selectSingleNode(
  448. "/report/layouts/layout/reportPages/page/pageBody/contents/list");
  449. }
  450. Element eSortList = DocumentHelper.createElement("sortList");
  451. n.add(eSortList);
  452. }
  453. public void addDataItemSort(String p_sElementName, String p_sSort)
  454. {
  455. Element n = (Element) oDocument.selectSingleNode(
  456. "/report/layouts/layout/reportPages/page/pageBody/contents/list/sortList");
  457. if (n == null) {
  458. addSortList();
  459. n = (Element) oDocument.selectSingleNode(
  460. "/report/layouts/layout/reportPages/page/pageBody/contents/list/sortList");
  461. }
  462. Element eSort = DocumentHelper.createElement("sortItem");
  463. eSort.addAttribute("refDataItem", p_sElementName);
  464. eSort.addAttribute("sortOrder", p_sSort);
  465. n.add(eSort);
  466. }
  467. public Vector getDataItemReferences() {
  468. Vector columnsList = new Vector();
  469. Vector fullNameColumnsList = new Vector();
  470. List columnList = (List) oDocument.selectNodes(
  471. "/report/queries/query/selection/dataItem[@name]");
  472. for (int i = 0; i < columnList.size(); i++) {
  473. Element eColumn = (Element) columnList.get(i);
  474. String sColumn = eColumn.attributeValue("name");
  475. columnsList.add(sColumn);
  476. }
  477. return columnsList;
  478. }
  479. public Vector getDataItemExpressions() {
  480. Vector fullNameColumnsList = new Vector();
  481. List columnList = (List) oDocument.selectNodes(
  482. "/report/queries/query/selection/dataItem/expression");
  483. for (int i = 0; i < columnList.size(); i++) {
  484. Element eColumn = (Element) columnList.get(i);
  485. String sColumn = eColumn.getText();
  486. fullNameColumnsList.add(sColumn);
  487. }
  488. return fullNameColumnsList;
  489. }
  490. public Vector getColumnTitles() {
  491. Vector columnTitles = new Vector();
  492. //Check for column titles based on dataItemLabel
  493. List columnTitleList = (List) oDocument.selectNodes(
  494. "/report/layouts/layout/reportPages/page/pageBody/contents/"
  495. + "list/listColumns/listColumn/listColumnTitle/"
  496. + "contents/textItem/dataSource/dataItemLabel");
  497. for (int i = 0; i < columnTitleList.size(); i++)
  498. {
  499. Element e = (Element) columnTitleList.get(i);
  500. String sColumnTitle = null;
  501. sColumnTitle = e.attributeValue(new QName("refDataItem"));
  502. columnTitles.add(sColumnTitle);
  503. }
  504. //Check for columnTitles base on staticValue
  505. List columnStaticTitleList = (List) oDocument.selectNodes(
  506. "/report/layouts/layout/reportPages/page/pageBody/contents/"
  507. + "list/listColumns/listColumn/listColumnTitle/"
  508. + "contents/textItem/dataSource/staticValue");
  509. for (int i = 0; i < columnStaticTitleList.size(); i++)
  510. {
  511. Element e = (Element) columnStaticTitleList.get(i);
  512. String sColumnTitle = null;
  513. sColumnTitle = e.getText();
  514. columnTitles.add(sColumnTitle);
  515. }
  516. return columnTitles;
  517. }
  518. public void modifyTitle(String title, String newTitle)
  519. {
  520. Element n = null;
  521. String quotChar = "\'";
  522. if (title.indexOf(quotChar) >= 0)
  523. {
  524. quotChar = "\"";
  525. }
  526. String nodeDataItemTitle =
  527. "/report/layouts/layout/reportPages/page/pageBody/contents/list/listColumns/"
  528. + "listColumn/listColumnTitle/contents/textItem/dataSource/dataItemLabel[@refDataItem="
  529. + quotChar
  530. + title
  531. + quotChar
  532. + "]";
  533. String nodeStaticTitle =
  534. "/report/layouts/layout/reportPages/page/pageBody/contents/list/listColumns/"
  535. + "listColumn/listColumnTitle/contents/textItem/dataSource/staticValue";
  536. n = (Element) oDocument.selectSingleNode(nodeDataItemTitle);
  537. if (n == null)
  538. {
  539. n = (Element) oDocument.selectSingleNode(nodeStaticTitle);
  540. if (n == null)
  541. {
  542. System.out.println("Modify column title failed for "
  543. + title
  544. + " title not found.");
  545. return;
  546. }
  547. }
  548. Element nDataSource = n.getParent();
  549. n.detach();
  550. Element eTitle = DocumentHelper.createElement("staticValue");
  551. eTitle.setText(newTitle);
  552. nDataSource.add(eTitle);
  553. }
  554. /**
  555. * addListColumn
  556. *
  557. * @param p_sName
  558. * @param position
  559. * (to insert in the default position pass 0 to this method)
  560. * (default position = insert after the last child element.)
  561. */
  562. public void addListColumn(String p_sName, int position) {
  563. Element n = null;
  564. n = (Element) oDocument.selectSingleNode(
  565. "/report/layouts/layout/reportPages/page/pageBody/contents"
  566. + "/list/listColumns");
  567. //Create an empty column node
  568. Element eCol = DocumentHelper.createElement("listColumn");
  569. // Prepare all the bits to contain the column title
  570. Element eTitle = DocumentHelper.createElement("listColumnTitle");
  571. Element eStyleTitle = buildStyle("lt");
  572. Element eTContents = DocumentHelper.createElement("contents");
  573. Element eTText = DocumentHelper.createElement("textItem");
  574. Element eTSrc = DocumentHelper.createElement("dataSource");
  575. Element eLabel = DocumentHelper.createElement("dataItemLabel");
  576. eLabel.addAttribute("refDataItem", p_sName);
  577. //Prepare all the bits to contain the column data
  578. Element eBody = DocumentHelper.createElement("listColumnBody");
  579. Element eStyle = buildStyle("lm");
  580. Element eBContents = DocumentHelper.createElement("contents");
  581. Element eBText = DocumentHelper.createElement("textItem");
  582. Element eBSrc = DocumentHelper.createElement("dataSource");
  583. Element eValue = DocumentHelper.createElement("dataItemValue");
  584. eValue.addAttribute("refDataItem", p_sName);
  585. //Piece the Title together in the right order
  586. eTSrc.add(eLabel);
  587. eTText.add(eTSrc);
  588. eTContents.add(eTText);
  589. eTitle.add(eStyleTitle);
  590. eTitle.add(eTContents);
  591. //Piece the Body together
  592. eBSrc.add(eValue);
  593. eBText.add(eBSrc);
  594. eBContents.add(eBText);
  595. eBody.add(eStyle);
  596. eBody.add(eBContents);
  597. //Add the title and body to the column
  598. eCol.add(eTitle);
  599. eCol.add(eBody);
  600. if (position > 0) {
  601. n.content().add(position - 1, eCol);
  602. } else {
  603. n.add(eCol);
  604. }
  605. }
  606. public void addListColumns() {
  607. Element n = (Element) oDocument
  608. .selectSingleNode("/report/layouts/layout/reportPages/page/pageBody/contents/list");
  609. Element e = DocumentHelper.createElement("listColumns");
  610. n.add(e);
  611. }
  612. }