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.

XSSFHeaderFooterProperties.java 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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.util.Internal;
  17. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
  18. /**
  19. * <p>
  20. * All Header/Footer properties for a sheet are scoped to the sheet. This includes Different First Page,
  21. * and Different Even/Odd. These properties can be set or unset explicitly in this class. Note that while
  22. * Scale With Document and Align With Margins default to unset, Different First, and Different Even/Odd
  23. * are updated automatically as headers and footers are added and removed.
  24. * </p>
  25. */
  26. public class XSSFHeaderFooterProperties {
  27. private final CTHeaderFooter headerFooter;
  28. /**
  29. * Create an instance of XSSFHeaderFooterProperties from the supplied XML bean
  30. */
  31. public XSSFHeaderFooterProperties(CTHeaderFooter headerFooter) {
  32. this.headerFooter = headerFooter;
  33. }
  34. /**
  35. * Returns the underlying CTHeaderFooter xml bean
  36. *
  37. * @return the underlying CTHeaderFooter xml bean
  38. */
  39. @Internal
  40. public CTHeaderFooter getHeaderFooter() {
  41. return this.headerFooter;
  42. }
  43. /**
  44. * returns alignWithMargins attribute
  45. */
  46. public boolean getAlignWithMargins() {
  47. return getHeaderFooter().isSetAlignWithMargins() && getHeaderFooter().getAlignWithMargins();
  48. }
  49. /**
  50. * returns differentFirst attribute
  51. */
  52. public boolean getDifferentFirst() {
  53. return getHeaderFooter().isSetDifferentFirst() && getHeaderFooter().getDifferentFirst();
  54. }
  55. /**
  56. * returns differentOddEven attribute
  57. */
  58. public boolean getDifferentOddEven() {
  59. return getHeaderFooter().isSetDifferentOddEven() && getHeaderFooter().getDifferentOddEven();
  60. }
  61. /**
  62. * returns scaleWithDoc attribute
  63. */
  64. public boolean getScaleWithDoc() {
  65. return getHeaderFooter().isSetScaleWithDoc() && getHeaderFooter().getScaleWithDoc();
  66. }
  67. /**
  68. * set alignWithMargins attribute
  69. */
  70. public void setAlignWithMargins(boolean flag) {
  71. getHeaderFooter().setAlignWithMargins(flag);
  72. }
  73. /**
  74. * set differentFirst attribute
  75. */
  76. public void setDifferentFirst(boolean flag) {
  77. getHeaderFooter().setDifferentFirst(flag);
  78. }
  79. /**
  80. * set differentOddEven attribute
  81. */
  82. public void setDifferentOddEven(boolean flag) {
  83. getHeaderFooter().setDifferentOddEven(flag);
  84. }
  85. /**
  86. * set scaleWithDoc attribute
  87. */
  88. public void setScaleWithDoc(boolean flag) {
  89. getHeaderFooter().setScaleWithDoc(flag);
  90. }
  91. /**
  92. * remove alignWithMargins attribute
  93. */
  94. public void removeAlignWithMargins() {
  95. if (getHeaderFooter().isSetAlignWithMargins()) {
  96. getHeaderFooter().unsetAlignWithMargins();
  97. }
  98. }
  99. /**
  100. * remove differentFirst attribute
  101. */
  102. public void removeDifferentFirst() {
  103. if (getHeaderFooter().isSetDifferentFirst()) {
  104. getHeaderFooter().unsetDifferentFirst();
  105. }
  106. }
  107. /**
  108. * remove differentOddEven attribute
  109. */
  110. public void removeDifferentOddEven() {
  111. if (getHeaderFooter().isSetDifferentOddEven()) {
  112. getHeaderFooter().unsetDifferentOddEven();
  113. }
  114. }
  115. /**
  116. * remove scaleWithDoc attribute
  117. */
  118. public void removeScaleWithDoc() {
  119. if (getHeaderFooter().isSetScaleWithDoc()) {
  120. getHeaderFooter().unsetScaleWithDoc();
  121. }
  122. }
  123. }