您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

TestShapes.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * ====================================================================
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. * ====================================================================
  18. */
  19. package org.apache.poi.hssf.model;
  20. import junit.framework.TestCase;
  21. import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
  22. import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
  23. import org.apache.poi.hssf.usermodel.HSSFComment;
  24. import org.apache.poi.hssf.usermodel.HSSFPicture;
  25. import org.apache.poi.hssf.usermodel.HSSFTextbox;
  26. /**
  27. *
  28. * @author Yegor Kozlov
  29. */
  30. public final class TestShapes extends TestCase {
  31. /**
  32. * Test generator of ids for the CommonObjectDataSubRecord record.
  33. *
  34. * See Bug 51332
  35. */
  36. @SuppressWarnings("deprecation")
  37. public void testShapeId(){
  38. HSSFClientAnchor anchor = new HSSFClientAnchor();
  39. AbstractShape shape;
  40. CommonObjectDataSubRecord cmo;
  41. shape = new TextboxShape(new HSSFTextbox(null, anchor), 1025);
  42. cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
  43. assertEquals(1, cmo.getObjectId());
  44. shape = new PictureShape(new HSSFPicture(null, anchor), 1026);
  45. cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
  46. assertEquals(2, cmo.getObjectId());
  47. shape = new CommentShape(new HSSFComment(null, anchor), 1027);
  48. cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
  49. assertEquals(1027, cmo.getObjectId());
  50. }
  51. }