You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

XSSFTableStyleInfo.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.xssf.usermodel;
  16. import org.apache.poi.ss.usermodel.TableStyle;
  17. import org.apache.poi.ss.usermodel.TableStyleInfo;
  18. import org.apache.poi.xssf.model.StylesTable;
  19. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableStyleInfo;
  20. /**
  21. * Wrapper for the CT class, to cache values and add style lookup
  22. */
  23. public class XSSFTableStyleInfo implements TableStyleInfo {
  24. private final CTTableStyleInfo styleInfo;
  25. private final StylesTable stylesTable;
  26. private TableStyle style;
  27. private boolean columnStripes;
  28. private boolean rowStripes;
  29. private boolean firstColumn;
  30. private boolean lastColumn;
  31. public XSSFTableStyleInfo(StylesTable stylesTable, CTTableStyleInfo tableStyleInfo) {
  32. this.columnStripes = tableStyleInfo.getShowColumnStripes();
  33. this.rowStripes = tableStyleInfo.getShowRowStripes();
  34. this.firstColumn = tableStyleInfo.getShowFirstColumn();
  35. this.lastColumn = tableStyleInfo.getShowLastColumn();
  36. this.style = stylesTable.getTableStyle(tableStyleInfo.getName());
  37. this.stylesTable = stylesTable;
  38. this.styleInfo = tableStyleInfo;
  39. }
  40. @Override
  41. public boolean isShowColumnStripes() {
  42. return columnStripes;
  43. }
  44. public void setShowColumnStripes(boolean show) {
  45. this.columnStripes = show;
  46. styleInfo.setShowColumnStripes(show);
  47. }
  48. @Override
  49. public boolean isShowRowStripes() {
  50. return rowStripes;
  51. }
  52. public void setShowRowStripes(boolean show) {
  53. this.rowStripes = show;
  54. styleInfo.setShowRowStripes(show);
  55. }
  56. @Override
  57. public boolean isShowFirstColumn() {
  58. return firstColumn;
  59. }
  60. public void setFirstColumn(boolean showFirstColumn) {
  61. this.firstColumn = showFirstColumn;
  62. styleInfo.setShowFirstColumn(showFirstColumn);
  63. }
  64. @Override
  65. public boolean isShowLastColumn() {
  66. return lastColumn;
  67. }
  68. public void setLastColumn(boolean showLastColumn) {
  69. this.lastColumn = showLastColumn;
  70. styleInfo.setShowLastColumn(showLastColumn);
  71. }
  72. @Override
  73. public String getName() {
  74. return style.getName();
  75. }
  76. public void setName(String name) {
  77. styleInfo.setName(name);
  78. style = stylesTable.getTableStyle(name);
  79. }
  80. @Override
  81. public TableStyle getStyle() {
  82. return style;
  83. }
  84. }