Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

XSSFBHeaderFooter.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.binary;
  16. import org.apache.poi.util.Internal;
  17. import org.apache.poi.xssf.usermodel.helpers.HeaderFooterHelper;
  18. @Internal
  19. class XSSFBHeaderFooter {
  20. private final String headerFooterTypeLabel;
  21. private final boolean isHeader;
  22. private String rawString;
  23. private HeaderFooterHelper headerFooterHelper = new HeaderFooterHelper();
  24. XSSFBHeaderFooter(String headerFooterTypeLabel, boolean isHeader) {
  25. this.headerFooterTypeLabel = headerFooterTypeLabel;
  26. this.isHeader = isHeader;
  27. }
  28. String getHeaderFooterTypeLabel() {
  29. return headerFooterTypeLabel;
  30. }
  31. String getRawString() {
  32. return rawString;
  33. }
  34. String getString() {
  35. StringBuilder sb = new StringBuilder();
  36. String left = headerFooterHelper.getLeftSection(rawString);
  37. String center = headerFooterHelper.getCenterSection(rawString);
  38. String right = headerFooterHelper.getRightSection(rawString);
  39. if (left != null && left.length() > 0) {
  40. sb.append(left);
  41. }
  42. if (center != null && center.length() > 0) {
  43. if (sb.length() > 0) {
  44. sb.append(" ");
  45. }
  46. sb.append(center);
  47. }
  48. if (right != null && right.length() > 0) {
  49. if (sb.length() > 0) {
  50. sb.append(" ");
  51. }
  52. sb.append(right);
  53. }
  54. return sb.toString();
  55. }
  56. void setRawString(String rawString) {
  57. this.rawString = rawString;
  58. }
  59. boolean isHeader() {
  60. return isHeader;
  61. }
  62. }