kspread Library API Documentation

KSpread::StyleCluster Class Reference

The StyleCluster class is an owner of a Quad tree made up of StyleClusterQuad's. More...

#include <stylecluster.h>

Inheritance diagram for KSpread::StyleCluster:

Inheritance graph
[legend]
Collaboration diagram for KSpread::StyleCluster:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 StyleCluster (KSpreadSheet *sheet)
void setStyle (int x, int y, KSpreadStyle *style)
void setStyle (const KSpreadRange &range, KSpreadStyle *style)
const KSpreadStyle & lookup (int x, int y)

Protected Member Functions

void simplify (QValueStack< StyleClusterQuad ** > &path)
StyleClusterQuad * lookupNode (int x, int y)
void stepDownOne (StyleClusterQuad **&current_node, int x, int &x_offset, int y, int &y_offset, int &quad_size)

Protected Attributes

StyleClusterQuad * m_topQuad
KSpreadSheet * m_sheet

Friends

class StyleClusterTester

Detailed Description

The StyleCluster class is an owner of a Quad tree made up of StyleClusterQuad's.

It contains various functions to search the quad tree and insert a new style for a cell at a given x,y.

Internally it always maintains the quad tree at a minimum size possible. Note that inserting ( setStyle ) can be fairly expensive, creating and deleting up to 8 objects in total. So use the (yet to be written) insert range functions to change large amounts of styles at a time.

Note that the style returned here is not necessarily the final style for the cell, because the whole column and whole row may have a style that need to be applied first. Any settings in those styles override the settings here.

See the StyleClusterQuad class for more implementation details.

Testing ======= If you make any changes to the code, make sure to run the test suite. To do this, run kspread and make a new empty document. Then press ctrl+shift+T and chose "cell style test". Run that, and check that all the tests pass.

If you add functionality, make sure to add new tests to the StyleclusterTest class

Manager ======= To be done - write a manager for this class for easier mass insertion.

See also:
StyleClusterQuad

StyleClusterTester

Author:
John Tapsell

Raphael Langerhorst

Definition at line 75 of file stylecluster.h.


Member Function Documentation

void KSpread::StyleCluster::simplify QValueStack< StyleClusterQuad ** > &  path  )  [protected]
 

An internally used function.

Takes a list of quads, each one being a child of the one underneath it, with the last one being a pointer to m_topQuad. Then it goes up this list and checks whether it can be simplified, and does so if it's possible.

Parameters:
path This stack will be destroyed in this function. Make a copy if you want to keep it.

Definition at line 300 of file stylecluster.cc.

Referenced by setStyle().

StyleClusterQuad * KSpread::StyleCluster::lookupNode int  x,
int  y
[protected]
 

Return the quad being used at x,y.

Definition at line 392 of file stylecluster.cc.

References stepDownOne().

Referenced by lookup().

void KSpread::StyleCluster::stepDownOne StyleClusterQuad **&  current_node,
int  x,
int &  x_offset,
int  y,
int &  y_offset,
int &  quad_size
[protected]
 

Steps down one quad.

The returned current_node will be a child of taken current_node. Modifies current_node, x_offset and y_offset variables.

Definition at line 368 of file stylecluster.cc.

Referenced by lookupNode(), and setStyle().

void KSpread::StyleCluster::setStyle int  x,
int  y,
KSpreadStyle *  style
 

Example usage: A cell should be changed to bold.

First, the current style is looked up with lookup(), then a new KSpreadStyle is created based on the returned style and set to bold. Then the style should be checked against existing styles (use existing one and delete your created one). Now use your style to insert it into x,y.

Parameters:
x zero-indexed column of the cell to set the style for
y zero-indexed row of the cell to set the style for
style The style to set it to. Must be non-null. To 'remove' a style, set the style to the sheet default style or something.

Definition at line 231 of file stylecluster.cc.

References simplify(), and stepDownOne().

void KSpread::StyleCluster::setStyle const KSpreadRange &  range,
KSpreadStyle *  style
 

Practically same usage as above, but use a range to apply the style.

See also:
setStyle( int x, int y, KSpreadStyle * style)

Definition at line 188 of file stylecluster.cc.

References stepDownOne().

const KSpreadStyle & KSpread::StyleCluster::lookup int  x,
int  y
 

If you intend to modify this returned style, create a new one based on the returned style.

Parameters:
x zero-indexed column of the cell to set the style for
y zero-indexed row of the cell to set the style for
Returns:
The style that this cell is using. Note that this may not be the ultimate style that the cell is using because you have any column style and row style overrides this.
See also:
insert

Definition at line 364 of file stylecluster.cc.

References lookupNode().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kspread Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:43:50 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003