Public Types | Public Member Functions | Static Public Member Functions | Public Attributes

Celartem::DjVu::TextZone Class Reference

#include <djv_text.h>

Inheritance diagram for Celartem::DjVu::TextZone:
Inheritance graph
[legend]

List of all members.

Public Types

enum  Type {
  Invalid = 0, Page = 1, Column = 2, Region = 3,
  Paragraph = 4, Line = 5, Word = 6, Character = 7
}

Public Member Functions

virtual void encode (Stream *inStream, const PageInfo &inPageInfo) const =0
virtual AutoPtr< ChunkencodeTXTzChunk (const PageInfo &inPageInfo) const =0
virtual AutoPtr< ChunkencodeTXTaChunk (const PageInfo &inPageInfo) const =0
virtual Rotation getRotation () const =0
virtual void setRotation (Rotation inRotation)=0
virtual Rect getMinimumRectRequired () const =0
virtual String getFullText () const =0
virtual AutoPtr< TextSearchercreateTextSearcher () const =0

Static Public Member Functions

static AutoPtr< TextZonecreate (const PageInfo &inPageInfo)
static AutoPtr< TextZonecreate (Type inType=Page)
static AutoPtr< TextZonecreate (const String &inText, Type inType, ssize_t inLeft, ssize_t inTop, ssize_t inWidth, ssize_t inHeight)
static AutoPtr< TextZonecreate (const String &inText, Type inType, const Rect &inRect)
static AutoPtr< TextZonedecode (Stream *inStream, const PageInfo &inPageInfo)
static AutoPtr< TextZonedecode (const Chunk *inChunk, const PageInfo &inPageInfo)
static Rect calcUnionRect (const AutoPtr< const TextZone > *inZones, size_t inCount)
static Rect calcUnionRect (const AutoPtr< TextZone > *inZones, size_t inCount)
static Rect calcUnionRect (const TextZone *const *inZones, size_t inCount)

Public Attributes

Type type
 The type of the text block.
Rect rect
 The rectangle of the text block in pixels.
String text
 Text of the text block.
String heading
 Heading text.
SimpleArray< AutoPtr< TextZone > > children
 Child text blocks.

Detailed Description

This structure represents a text block.
Unlike the DjVu file format, the coordinations used by the structure are all in left-to-right, top-to-bottom order and the origin (0,0) is the left-top most of the image.
Please note that this structure should not be initialized as auto variable; all the instances may be referenced by AutoPtr and you don't have to manage the lifetime. All the instance should be initialized via create function.

See also:
TextSearcher

Member Enumeration Documentation

This enumeration is used to specify the type of TextZone.

Enumerator:
Invalid 

Invalid; reserved.

Page 

Page.

Column 

Column.

Region 

Region.

Paragraph 

Paragraph.

Line 

Line.

Word 

Word.

Character 

Character.


Member Function Documentation

static Rect Celartem::DjVu::TextZone::calcUnionRect ( const AutoPtr< const TextZone > *  inZones,
size_t  inCount 
) [static]

Calculate the union rectangle of the specified TextZone instances.

Parameters:
inZones An array of pointers to TextZone instances.
inCount The count of TextZone instances in the array.
static Rect Celartem::DjVu::TextZone::calcUnionRect ( const AutoPtr< TextZone > *  inZones,
size_t  inCount 
) [static]

Calculate the union rectangle of the specified TextZone instances.

Parameters:
inZones An array of pointers to TextZone instances.
inCount The count of TextZone instances in the array.
static Rect Celartem::DjVu::TextZone::calcUnionRect ( const TextZone *const *  inZones,
size_t  inCount 
) [static]

Calculate the union rectangle of the specified TextZone instances.

Parameters:
inZones An array of pointers to TextZone instances.
inCount The count of TextZone instances in the array.
static AutoPtr<TextZone> Celartem::DjVu::TextZone::create ( const String inText,
Type  inType,
const Rect inRect 
) [inline, static]

Create the instance with the specified parameters.

Parameters:
inText Text stored in this text block.
inType The type of the text block.
inRect The position of the text block.
Returns:
Pointer to the newly created TextZone instance.
static AutoPtr<TextZone> Celartem::DjVu::TextZone::create ( Type  inType = Page  )  [static]

Create the instance with the default values.

Parameters:
inType Type of this TextZone instance.
Returns:
Pointer to the newly created TextZone instance.
static AutoPtr<TextZone> Celartem::DjVu::TextZone::create ( const PageInfo inPageInfo  )  [static]

Create the instance with the specified PageInfo.

Parameters:
inPageInfo A PageInfo instance which describes the page which manages the newly created TextZone.
Returns:
Pointer to the newly created TextZone instance.

Referenced by create().

static AutoPtr<TextZone> Celartem::DjVu::TextZone::create ( const String inText,
Type  inType,
ssize_t  inLeft,
ssize_t  inTop,
ssize_t  inWidth,
ssize_t  inHeight 
) [static]

Create the instance with the specified parameters.

Parameters:
inText Text stored in this text block.
inType The type of the text block.
inLeft Left of the text block in pixels.
inTop Top of the text block in pixels.
inWidth Width of the text block in pixels.
inHeight Height of the text block in pixels.
Returns:
Pointer to the newly created TextZone instance.
virtual AutoPtr<TextSearcher> Celartem::DjVu::TextZone::createTextSearcher (  )  const [pure virtual]

Create a new instance of TextSearcher.

Returns:
Pointer to the newly created TextSearcher instance.
static AutoPtr<TextZone> Celartem::DjVu::TextZone::decode ( Stream inStream,
const PageInfo inPageInfo 
) [static]

Decode the DjVu's TXTa block.
To decode TXTz chunk, you should firstly decompress the chunk using InflateStream. This method is for advanced purpose and for normal purpose, you had better use decode(const Chunk*).

Parameters:
inStream The stream which contains TXTa block.
inPageInfo The dimensions and rotation status of the page is used during decoding the TXTa string.
Returns:
Pointer to TextZone instance which contains decoded TXTa block.
static AutoPtr<TextZone> Celartem::DjVu::TextZone::decode ( const Chunk inChunk,
const PageInfo inPageInfo 
) [static]

Decode the DjVu's TXTa or TXTz block.

Parameters:
inChunk The stream which contains TXTa block.
inPageInfo The dimensions and rotation status of the page is used during decoding the TXT* string.
Returns:
Pointer to TextZone instance which contains decoded TXT* block.
virtual void Celartem::DjVu::TextZone::encode ( Stream inStream,
const PageInfo inPageInfo 
) const [pure virtual]

Encode the instance to the DjVu's TXTa block.
This method is for advanced purpose and for normal purpose, you had better use encodeTXTzChunk or encodeTXTaChunk. To encode TXTz chunk, you should compress the returned data using DeflateStream.

Parameters:
inStream The stream to write on.
inPageInfo The dimensions and rotation status of the page is used during encoding the TXTa string.
See also:
encodeTXTzChunk, encodeTXTaChunk
virtual AutoPtr<Chunk> Celartem::DjVu::TextZone::encodeTXTaChunk ( const PageInfo inPageInfo  )  const [pure virtual]

Encode the instance to the DjVu's TXTa chunk.

Parameters:
inPageInfo The dimensions and rotation status of the page is used during encoding the TXTa string.
Returns:
TXTa Chunk.
virtual AutoPtr<Chunk> Celartem::DjVu::TextZone::encodeTXTzChunk ( const PageInfo inPageInfo  )  const [pure virtual]

Encode the instance to the DjVu's TXTz chunk.

Parameters:
inPageInfo The dimensions and rotation status of the page is used during encoding the TXTz string.
Returns:
TXTz Chunk.
virtual String Celartem::DjVu::TextZone::getFullText (  )  const [pure virtual]

Get the full text in this TextZone.
If the TextZone does not have any children, return the text member variable directly. Otherwise, if it has any children, return the concatenated full text.

Returns:
The full text of this TextZone.
virtual Rect Celartem::DjVu::TextZone::getMinimumRectRequired (  )  const [pure virtual]

Calculate and sets the minimum rectangle which is required to this TextZone.
This method simply returns the rect member if the TextZone does not have any children.

virtual Rotation Celartem::DjVu::TextZone::getRotation (  )  const [pure virtual]

Get the current rotation angle.

Returns:
The current rotation angle.
virtual void Celartem::DjVu::TextZone::setRotation ( Rotation  inRotation  )  [pure virtual]

Rotate the TextZone instance.
Please note that this may take long if there're many TextZone instances.

Parameters:
inRotation The resulting rotation angle.
Please note that this is NOT the degrees to rotate but the absolute rotation destination.

Member Data Documentation

Child text blocks.

Child text blocks.
text should be empty when the text block has child text blocks (children has any element).

Heading text.

Heading text.
This text is used to combine words into a line. For example, "Mr. Brown" is actually separated into two TextZones; "Mr." and "Brown" but there should be a separating space between them and heading of the second TextZone ("Brown") is the space.

The rectangle of the text block in pixels.

If the text block has child text blocks, this variable is not used and you had better use getMinimumRectRequired method to get the actual rectangle.

Text of the text block.

Text of the text block.
It should be empty when the text block has child text blocks. To get full text of the subsidiary TextZones instances, use getFullText method.
To search some text from the tree structured TextZone instances, use TextSearcher. It provides a simple interface to deal with searchs.

The type of the text block.


The documentation for this class was generated from the following file:

This document is made with doxygen 1.7.1 at Thu Feb 17 2011 15:40:21.
Caminova Logo