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.

HSLFComment.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.hslf.usermodel;
  16. import org.apache.poi.hslf.record.Comment2000;
  17. import org.apache.poi.sl.usermodel.Comment;
  18. import org.apache.poi.util.Units;
  19. import java.awt.geom.Point2D;
  20. import java.util.Date;
  21. public final class HSLFComment implements Comment {
  22. private Comment2000 _comment2000;
  23. public HSLFComment(Comment2000 comment2000) {
  24. _comment2000 = comment2000;
  25. }
  26. protected Comment2000 getComment2000() {
  27. return _comment2000;
  28. }
  29. /**
  30. * Get the Author of this comment
  31. */
  32. public String getAuthor() {
  33. return _comment2000.getAuthor();
  34. }
  35. /**
  36. * Set the Author of this comment
  37. */
  38. public void setAuthor(String author) {
  39. _comment2000.setAuthor(author);
  40. }
  41. /**
  42. * Get the Author's Initials of this comment
  43. */
  44. public String getAuthorInitials() {
  45. return _comment2000.getAuthorInitials();
  46. }
  47. /**
  48. * Set the Author's Initials of this comment
  49. */
  50. public void setAuthorInitials(String initials) {
  51. _comment2000.setAuthorInitials(initials);
  52. }
  53. /**
  54. * Get the text of this comment
  55. */
  56. public String getText() {
  57. return _comment2000.getText();
  58. }
  59. /**
  60. * Set the text of this comment
  61. */
  62. public void setText(String text) {
  63. _comment2000.setText(text);
  64. }
  65. @Override
  66. public Date getDate() {
  67. return _comment2000.getComment2000Atom().getDate();
  68. }
  69. @Override
  70. public void setDate(Date date) {
  71. _comment2000.getComment2000Atom().setDate(date);
  72. }
  73. @Override
  74. public Point2D getOffset() {
  75. final double x = Units.masterToPoints(_comment2000.getComment2000Atom().getXOffset());
  76. final double y = Units.masterToPoints(_comment2000.getComment2000Atom().getYOffset());
  77. return new Point2D.Double(x, y);
  78. }
  79. @Override
  80. public void setOffset(Point2D offset) {
  81. final int x = Units.pointsToMaster(offset.getX());
  82. final int y = Units.pointsToMaster(offset.getY());
  83. _comment2000.getComment2000Atom().setXOffset(x);
  84. _comment2000.getComment2000Atom().setYOffset(y);
  85. }
  86. }