187 lines
4.8 KiB
Java
Raw Normal View History

/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.usermodel;
import org.apache.poi.ss.usermodel.RichTextString;
/**
* A textbox is a shape that may hold a rich text string.
*
* @author Glen Stampoultzis (glens at apache.org)
*/
public class HSSFTextbox
extends HSSFSimpleShape
{
public final static short OBJECT_TYPE_TEXT = 6;
/**
* How to align text horizontally
*/
public final static short HORIZONTAL_ALIGNMENT_LEFT = 1;
public final static short HORIZONTAL_ALIGNMENT_CENTERED = 2;
public final static short HORIZONTAL_ALIGNMENT_RIGHT = 3;
public final static short HORIZONTAL_ALIGNMENT_JUSTIFIED = 4;
public final static short HORIZONTAL_ALIGNMENT_DISTRIBUTED = 7;
/**
* How to align text vertically
*/
public final static short VERTICAL_ALIGNMENT_TOP = 1;
public final static short VERTICAL_ALIGNMENT_CENTER = 2;
public final static short VERTICAL_ALIGNMENT_BOTTOM = 3;
public final static short VERTICAL_ALIGNMENT_JUSTIFY = 4;
public final static short VERTICAL_ALIGNMENT_DISTRIBUTED= 7;
int marginLeft, marginRight, marginTop, marginBottom;
short halign, valign;
HSSFRichTextString string = new HSSFRichTextString("");
/**
* Construct a new textbox with the given parent and anchor.
* @param parent
* @param anchor One of HSSFClientAnchor or HSSFChildAnchor
*/
public HSSFTextbox( HSSFShape parent, HSSFAnchor anchor )
{
super( parent, anchor );
setShapeType(OBJECT_TYPE_TEXT);
halign = HORIZONTAL_ALIGNMENT_LEFT;
valign = VERTICAL_ALIGNMENT_TOP;
}
/**
* @return the rich text string for this textbox.
*/
public HSSFRichTextString getString()
{
return string;
}
/**
* @param string Sets the rich text string used by this object.
*/
public void setString( RichTextString string )
{
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-650914,650916-650920 via svnmerge from https://svn.apache.org:443/repos/asf/poi/trunk ........ r648589 | yegor | 2008-04-16 08:47:16 +0100 (Wed, 16 Apr 2008) | 1 line bug #41071 is fixed in trunk. Added a unit test and resolved. ........ r648623 | yegor | 2008-04-16 09:43:08 +0100 (Wed, 16 Apr 2008) | 1 line Rich text in HSSFTextbox must have at least one format run. Make sure it is so and apply th default fopnt if no formats were applied. ........ r648624 | yegor | 2008-04-16 09:44:07 +0100 (Wed, 16 Apr 2008) | 1 line Misc improvements in Freeform shape ........ r648674 | yegor | 2008-04-16 12:57:15 +0100 (Wed, 16 Apr 2008) | 1 line Support for getting OLE object data from slide show ........ r649142 | yegor | 2008-04-17 16:06:01 +0100 (Thu, 17 Apr 2008) | 1 line added a unit test and closed bug #28774 ........ r649143 | yegor | 2008-04-17 16:08:03 +0100 (Thu, 17 Apr 2008) | 1 line initial support for rendering powerpoint slides into images ........ r649145 | yegor | 2008-04-17 16:09:37 +0100 (Thu, 17 Apr 2008) | 1 line updated the list of changes ........ r649557 | yegor | 2008-04-18 15:57:07 +0100 (Fri, 18 Apr 2008) | 1 line improved rendering of text ........ r649796 | yegor | 2008-04-19 12:09:59 +0100 (Sat, 19 Apr 2008) | 1 line Support for getting embedded sounds from slide show ........ r649797 | yegor | 2008-04-19 12:16:53 +0100 (Sat, 19 Apr 2008) | 1 line properly set shapeId for new shapes ........ r649798 | yegor | 2008-04-19 12:17:37 +0100 (Sat, 19 Apr 2008) | 1 line misc improvements in slide rendering ........ r649800 | yegor | 2008-04-19 12:52:36 +0100 (Sat, 19 Apr 2008) | 1 line updated the docs ........ r649911 | yegor | 2008-04-20 12:17:48 +0100 (Sun, 20 Apr 2008) | 1 line more improvements in slide rendering ........ r649914 | yegor | 2008-04-20 12:58:08 +0100 (Sun, 20 Apr 2008) | 1 line set version.id=3.0.3-beta1 ........ r650129 | yegor | 2008-04-21 13:51:47 +0100 (Mon, 21 Apr 2008) | 1 line more improvements in slide rendering ........ r650130 | yegor | 2008-04-21 13:52:23 +0100 (Mon, 21 Apr 2008) | 1 line a couple of HSLF examples ........ r650133 | yegor | 2008-04-21 14:10:33 +0100 (Mon, 21 Apr 2008) | 1 line update current version to 3.1-beta1 ........ r650138 | yegor | 2008-04-21 14:29:59 +0100 (Mon, 21 Apr 2008) | 1 line unfinished release guide. It would be nice to have a html version. ........ r650139 | yegor | 2008-04-21 14:31:53 +0100 (Mon, 21 Apr 2008) | 1 line unfinished release guide. It would be nice to have a html version. ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@650938 13f79535-47bb-0310-9956-ffa450edef68
2008-04-23 16:49:18 +00:00
HSSFRichTextString rtr = (HSSFRichTextString)string;
// If font is not set we must set the default one
if (rtr.numFormattingRuns() == 0) rtr.applyFont((short)0);
this.string = rtr;
}
/**
* @return Returns the left margin within the textbox.
*/
public int getMarginLeft()
{
return marginLeft;
}
/**
* Sets the left margin within the textbox.
*/
public void setMarginLeft( int marginLeft )
{
this.marginLeft = marginLeft;
}
/**
* @return returns the right margin within the textbox.
*/
public int getMarginRight()
{
return marginRight;
}
/**
* Sets the right margin within the textbox.
*/
public void setMarginRight( int marginRight )
{
this.marginRight = marginRight;
}
/**
* @return returns the top margin within the textbox.
*/
public int getMarginTop()
{
return marginTop;
}
/**
* Sets the top margin within the textbox.
*/
public void setMarginTop( int marginTop )
{
this.marginTop = marginTop;
}
/**
* Gets the bottom margin within the textbox.
*/
public int getMarginBottom()
{
return marginBottom;
}
/**
* Sets the bottom margin within the textbox.
*/
public void setMarginBottom( int marginBottom )
{
this.marginBottom = marginBottom;
}
/**
* Gets the horizontal alignment.
*/
public short getHorizontalAlignment()
{
return halign;
}
/**
* Sets the horizontal alignment.
*/
public void setHorizontalAlignment( short align )
{
this.halign = align;
}
/**
* Gets the vertical alignment.
*/
public short getVerticalAlignment()
{
return valign;
}
/**
* Sets the vertical alignment.
*/
public void setVerticalAlignment( short align )
{
this.valign = align;
}
}