Browse Source

Update documentation

master
Debao Zhang 12 years ago
parent
commit
81316ecf6e
  1. 16
      src/xlsx/xlsxcell.cpp
  2. 3
      src/xlsx/xlsxcellrange.cpp
  3. 96
      src/xlsx/xlsxdatavalidation.cpp
  4. 66
      src/xlsx/xlsxdocument.cpp
  5. 244
      src/xlsx/xlsxformat.cpp
  6. 91
      src/xlsx/xlsxrichstring.cpp
  7. 6
      src/xlsx/xlsxrichstring.h

16
src/xlsx/xlsxcell.cpp

@ -46,6 +46,19 @@ CellPrivate::CellPrivate(Cell *p) :
*/
/*!
\enum Cell::DataType
\value Blank,
\value String,
\value Numeric,
\value Formula,
\value Boolean,
\value Error,
\value InlineString,
\value ArrayFormula
*/
/*!
* \internal
* Created by Worksheet only.
@ -114,6 +127,9 @@ bool Cell::isDateTime() const
return false;
}
/*!
* Return the data time value.
*/
QDateTime Cell::dateTime() const
{
Q_D(const Cell);

3
src/xlsx/xlsxcellrange.cpp

@ -116,6 +116,9 @@ QString CellRange::toString() const
return cell_1 + QLatin1String(":") + cell_2;
}
/*!
* Returns true if the Range is valid.
*/
bool CellRange::isValid() const
{
return left <= right && top <= bottom;

96
src/xlsx/xlsxdatavalidation.cpp

@ -64,6 +64,7 @@ DataValidationPrivate::~DataValidationPrivate()
* \class DataValidation
* \brief Data validation for single cell or a range
* \inmodule QtXlsx
*
* The data validation can be applied to a single cell or a range of cells.
*/
@ -110,7 +111,8 @@ DataValidationPrivate::~DataValidationPrivate()
*/
/*!
* Construct a data validation object
* Construct a data validation object with the given \a type, \a op, \a formula1
* \a formula2, and \a allowBlank.
*/
DataValidation::DataValidation(ValidationType type, ValidationOperator op, const QString &formula1, const QString &formula2, bool allowBlank)
:d(new DataValidationPrivate(type, op, formula1, formula2, allowBlank))
@ -128,7 +130,7 @@ DataValidation::DataValidation()
}
/*!
\internal
Constructs a copy of \a other.
*/
DataValidation::DataValidation(const DataValidation &other)
:d(other.d)
@ -136,6 +138,16 @@ DataValidation::DataValidation(const DataValidation &other)
}
/*!
Assigns \a other to this validation and returns a reference to this validation.
*/
DataValidation &DataValidation::operator=(const DataValidation &other)
{
this->d = other.d;
return *this;
}
/*!
* Destroy the object.
*/
@ -143,86 +155,137 @@ DataValidation::~DataValidation()
{
}
/*!
Returns the validation type.
*/
DataValidation::ValidationType DataValidation::validationType() const
{
return d->validationType;
}
/*!
Returns the validation operator.
*/
DataValidation::ValidationOperator DataValidation::validationOperator() const
{
return d->validationOperator;
}
/*!
Returns the validation error style.
*/
DataValidation::ErrorStyle DataValidation::errorStyle() const
{
return d->errorStyle;
}
/*!
Returns the formula1.
*/
QString DataValidation::formula1() const
{
return d->formula1;
}
/*!
Returns the formula2.
*/
QString DataValidation::formula2() const
{
return d->formula2;
}
/*!
Returns whether blank is allowed.
*/
bool DataValidation::allowBlank() const
{
return d->allowBlank;
}
/*!
Returns the error message.
*/
QString DataValidation::errorMessage() const
{
return d->errorMessage;
}
/*!
Returns the error message title.
*/
QString DataValidation::errorMessageTitle() const
{
return d->errorMessageTitle;
}
/*!
Returns the prompt message.
*/
QString DataValidation::promptMessage() const
{
return d->promptMessage;
}
/*!
Returns the prompt message title.
*/
QString DataValidation::promptMessageTitle() const
{
return d->promptMessageTitle;
}
/*!
Returns the whether prompt message is shown.
*/
bool DataValidation::isPromptMessageVisible() const
{
return d->isPromptMessageVisible;
}
/*!
Returns the whether error message is shown.
*/
bool DataValidation::isErrorMessageVisible() const
{
return d->isErrorMessageVisible;
}
/*!
Returns the ranges on which the validation will be applied.
*/
QList<CellRange> DataValidation::ranges() const
{
return d->ranges;
}
/*!
Sets the validation type to \a type.
*/
void DataValidation::setValidationType(DataValidation::ValidationType type)
{
d->validationType = type;
}
/*!
Sets the validation operator to \a op.
*/
void DataValidation::setValidationOperator(DataValidation::ValidationOperator op)
{
d->validationOperator = op;
}
/*!
Sets the error style to \a es.
*/
void DataValidation::setErrorStyle(DataValidation::ErrorStyle es)
{
d->errorStyle = es;
}
/*!
Sets the formula1 to \a formula.
*/
void DataValidation::setFormula1(const QString &formula)
{
if (formula.startsWith(QLatin1Char('=')))
@ -231,42 +294,61 @@ void DataValidation::setFormula1(const QString &formula)
d->formula1 = formula;
}
/*!
Sets the formulas to \a formula.
*/
void DataValidation::setFormula2(const QString &formula)
{
if (formula.startsWith(QLatin1Char('=')))
d->formula2 = formula.mid(1);
else
d->formula2 = formula;}
d->formula2 = formula;
}
/*!
Sets the error message to \a error with title \a title.
*/
void DataValidation::setErrorMessage(const QString &error, const QString &title)
{
d->errorMessage = error;
d->errorMessageTitle = title;
}
/*!
Sets the prompt message to \a prompt with title \a title.
*/
void DataValidation::setPromptMessage(const QString &prompt, const QString &title)
{
d->promptMessage = prompt;
d->promptMessageTitle = title;
}
/*!
Enable/disabe blank allow based on \a enable.
*/
void DataValidation::setAllowBlank(bool enable)
{
d->allowBlank = enable;
}
/*!
Enable/disabe prompt message visible based on \a visible.
*/
void DataValidation::setPromptMessageVisible(bool visible)
{
d->isPromptMessageVisible = visible;
}
/*!
Enable/disabe error message visible based on \a visible.
*/
void DataValidation::setErrorMessageVisible(bool visible)
{
d->isErrorMessageVisible = visible;
}
/*!
Add the \a cell which the DataValidation will apply to.
Add the \a cell on which the DataValidation will apply to.
*/
void DataValidation::addCell(const QString &cell)
{
@ -275,6 +357,7 @@ void DataValidation::addCell(const QString &cell)
/*!
\overload
Add the cell(\a row, \a col) on which the DataValidation will apply to.
*/
void DataValidation::addCell(int row, int col)
{
@ -282,7 +365,7 @@ void DataValidation::addCell(int row, int col)
}
/*!
Add the \a range which the DataValidation will apply to.
Add the \a range on which the DataValidation will apply to.
*/
void DataValidation::addRange(const QString &range)
{
@ -291,6 +374,8 @@ void DataValidation::addRange(const QString &range)
/*!
\overload
Add the range(\a firstRow, \a firstCol, \a lastRow, \a lastCol) on
which the DataValidation will apply to.
*/
void DataValidation::addRange(int firstRow, int firstCol, int lastRow, int lastCol)
{
@ -299,6 +384,7 @@ void DataValidation::addRange(int firstRow, int firstCol, int lastRow, int lastC
/*!
\overload
Add the \a range on which the DataValidation will apply to.
*/
void DataValidation::addRange(const CellRange &range)
{

66
src/xlsx/xlsxdocument.cpp

@ -121,6 +121,7 @@ int Document::write(int row, int col, const QVariant &value, const Format &forma
/*!
\overload
Returns the contents of the cell \a cell.
*/
QVariant Document::read(const QString &cell) const
{
@ -128,7 +129,7 @@ QVariant Document::read(const QString &cell) const
}
/*!
Return the contents of the cell (\a row, \a column).
Returns the contents of the cell (\a row, \a col).
*/
QVariant Document::read(int row, int col) const
{
@ -136,14 +137,8 @@ QVariant Document::read(int row, int col) const
}
/*!
* \brief Insert an image to current active worksheet.
* \param row
* \param column
* \param image
* \param xOffset
* \param yOffset
* \param xScale
* \param yScale
* \brief Insert an \a image to current active worksheet to the position \a row, \a column with the given
* \a xOffset, \a yOffset, \a xScale and \a yScale.
*/
int Document::insertImage(int row, int column, const QImage &image, double xOffset, double yOffset, double xScale, double yScale)
{
@ -190,8 +185,10 @@ int Document::unmergeCells(const CellRange &range)
}
/*!
Sets row \a height and \a format. Row height measured in point size. If format
equals 0 then format is ignored. \a row is 1-indexed.
Sets the properties of \a row with the given \a height, \a format and \a hidden.
\a row is 1-indexed.
Returns false if failed.
*/
bool Document::setRow(int row, double height, const Format &format, bool hidden)
{
@ -199,10 +196,13 @@ bool Document::setRow(int row, double height, const Format &format, bool hidden)
}
/*!
Sets column width and format for all columns from colFirst to colLast. Column
Sets the column properties for all columns from \a colFirst to \a colLast with
the given \a width, \a format and \a hidden. Column
width measured as the number of characters of the maximum digit width of the
numbers 0, 1, 2, ..., 9 as rendered in the normal style's font. If format
equals 0 then format is ignored. \a colFirst and \a colLast are all 1-indexed.
numbers 0, 1, 2, ..., 9 as rendered in the normal style's font.
\a colFirst and \a colLast are all 1-indexed.
Return false if failed.
*/
bool Document::setColumn(int colFirst, int colLast, double width, const Format &format, bool hidden)
{
@ -210,10 +210,13 @@ bool Document::setColumn(int colFirst, int colLast, double width, const Format &
}
/*!
Sets column width and format for all columns from colFirst to colLast. Column
width measured as the number of characters of the maximum digit width of the
numbers 0, 1, 2, ..., 9 as rendered in the normal style's font. If format
equals 0 then format is ignored. \a colFirst and \a colLast should be "A", "B", "C", ...
\overload
Sets column width and format for all columns from \a colFirst to \a colLast with
the given \a width and \a format. Column
\a width measured as the number of characters of the maximum digit width of the
numbers 0, 1, 2, ..., 9 as rendered in the normal style's font.
\a colFirst and \a colLast should be "A", "B", "C", ...
*/
bool Document::setColumn(const QString &colFirst, const QString &colLast, double width, const Format &format, bool hidden)
{
@ -221,7 +224,8 @@ bool Document::setColumn(const QString &colFirst, const QString &colLast, double
}
/*!
Groups rows from rowFirst to rowLast. Returns false if error occurs.
Groups rows from \a rowFirst to \a rowLast with the given \a collapsed.
Returns false if error occurs.
*/
bool Document::groupRows(int rowFirst, int rowLast, bool collapsed)
{
@ -229,7 +233,8 @@ bool Document::groupRows(int rowFirst, int rowLast, bool collapsed)
}
/*!
Groups columns from colFirst to colLast. Returns false if error occurs.
Groups columns from \a colFirst to \a colLast with the given \a collapsed.
Returns false if error occurs.
*/
bool Document::groupColumns(int colFirst, int colLast, bool collapsed)
{
@ -237,9 +242,7 @@ bool Document::groupColumns(int colFirst, int colLast, bool collapsed)
}
/*!
* \brief Add a data validation rule for current worksheet
* \param validation
* \return
* Add a data \a validation rule for current worksheet. Returns true if successful.
*/
bool Document::addDataValidation(const DataValidation &validation)
{
@ -247,7 +250,7 @@ bool Document::addDataValidation(const DataValidation &validation)
}
/*!
* Returns a Cell object based on the given \a pos.
* Returns a Cell object based on the given \a pos. 0 will be returned if the cell doesn't exist.
*/
Cell *Document::cellAt(const QString &pos) const
{
@ -263,10 +266,11 @@ Cell *Document::cellAt(int row, int col) const
}
/*!
* \brief Create a defined name in the workbook.
* \param name The defined name
* \brief Create a defined name in the workbook with the given \a name, \a formula, \a comment
* and \a scope.
*
* \param name The defined name.
* \param formula The cell or range that the defined name refers to.
* \param comment
* \param scope The name of one worksheet, or empty which means golbal scope.
* \return Return false if the name invalid.
*/
@ -305,7 +309,7 @@ QString Document::documentProperty(const QString &key) const
Office Button -> Prepare -> Properties option in Excel and are also
available to external applications that read or index windows files.
The properties \a key that can be set are:
The \a property \a key that can be set are:
\list
\li title
@ -345,6 +349,7 @@ Workbook *Document::workbook() const
/*!
* Creates and append an document with name \a name.
* Return true if success.
*/
bool Document::addWorksheet(const QString &name)
{
@ -363,7 +368,8 @@ bool Document::insertWorkSheet(int index, const QString &name)
}
/*!
* \brief Rename current worksheet to new \a name.
Rename current worksheet to new \a name.
Returns true if the name defined successful.
*/
bool Document::setSheetName(const QString &name)
{
@ -412,6 +418,7 @@ void Document::setCurrentWorksheet(const QString &name)
/*!
* Save current document to the filesystem. If no name specified when
* the document constructed, a default name "book1.xlsx" will be used.
* Returns true if saved successfully.
*/
bool Document::save()
{
@ -423,6 +430,7 @@ bool Document::save()
/*!
* Saves the document to the file with the given \a name.
* Returns true if saved successfully.
*/
bool Document::saveAs(const QString &name)
{

244
src/xlsx/xlsxformat.cpp

@ -66,6 +66,113 @@ FormatPrivate::~FormatPrivate()
* \brief Providing the methods and properties that are available for formatting cells in Excel.
*/
/*!
* \enum Format::FontScript
*
* The enum type defines the type of font script.
*
* \value FontScriptNormal normal
* \value FontScriptSuper super script
* \value FontScriptSub sub script
*/
/*!
* \enum Format::FontUnderline
*
* The enum type defines the type of font underline.
*
* \value FontUnderlineNone
* \value FontUnderlineSingle
* \value FontUnderlineDouble
* \value FontUnderlineSingleAccounting
* \value FontUnderlineDoubleAccounting
*/
/*!
* \enum Format::HorizontalAlignment
*
* The enum type defines the type of horizontal alignment.
*
* \value AlignHGeneral
* \value AlignLeft
* \value AlignHCenter
* \value AlignRight
* \value AlignHFill
* \value AlignHJustify
* \value AlignHMerge
* \value AlignHDistributed
*/
/*!
* \enum Format::VerticalAlignment
*
* The enum type defines the type of vertical alignment.
*
* \value AlignTop,
* \value AlignVCenter,
* \value AlignBottom,
* \value AlignVJustify,
* \value AlignVDistributed
*/
/*!
* \enum Format::BorderStyle
*
* The enum type defines the type of font underline.
*
* \value BorderNone
* \value BorderThin
* \value BorderMedium
* \value BorderDashed
* \value BorderDotted
* \value BorderThick
* \value BorderDouble
* \value BorderHair
* \value BorderMediumDashed
* \value BorderDashDot
* \value BorderMediumDashDot
* \value BorderDashDotDot
* \value BorderMediumDashDotDot
* \value BorderSlantDashDot
*/
/*!
* \enum Format::DiagonalBorderType
*
* The enum type defines the type of diagonal border.
*
* \value DiagonalBorderNone
* \value DiagonalBorderDown
* \value DiagonalBorderUp
* \value DiagnoalBorderBoth
*/
/*!
* \enum Format::FillPattern
*
* The enum type defines the type of fill.
*
* \value PatternNone
* \value PatternSolid
* \value PatternMediumGray
* \value PatternDarkGray
* \value PatternLightGray
* \value PatternDarkHorizontal
* \value PatternDarkVertical
* \value PatternDarkDown
* \value PatternDarkUp
* \value PatternDarkGrid
* \value PatternDarkTrellis
* \value PatternLightHorizontal
* \value PatternLightVertical
* \value PatternLightDown
* \value PatternLightUp
* \value PatternLightTrellis
* \value PatternGray125
* \value PatternGray0625
* \value PatternLightGrid
*/
/*!
* Creates a new invalid format.
@ -217,7 +324,7 @@ bool Format::fontItalic() const
}
/*!
* Turn on/off the italic font.
* Turn on/off the italic font based on \a italic.
*/
void Format::setFontItalic(bool italic)
{
@ -233,7 +340,7 @@ bool Format::fontStrikeOut() const
}
/*!
* Turn on/off the strikeOut font.
* Turn on/off the strikeOut font based on \a strikeOut.
*/
void Format::setFontStrikeOut(bool strikeOut)
{
@ -273,7 +380,7 @@ bool Format::fontBold() const
}
/*!
* Turn on/off the bold font.
* Turn on/off the bold font based on the given \a bold.
*/
void Format::setFontBold(bool bold)
{
@ -289,7 +396,7 @@ Format::FontScript Format::fontScript() const
}
/*!
* Set the script style of the font.
* Set the script style of the font to \a script.
*/
void Format::setFontScript(FontScript script)
{
@ -305,7 +412,7 @@ Format::FontUnderline Format::fontUnderline() const
}
/*!
* Set the underline style of the font.
* Set the underline style of the font to \a underline.
*/
void Format::setFontUnderline(FontUnderline underline)
{
@ -321,7 +428,7 @@ bool Format::fontOutline() const
}
/*!
* Turn on/off the outline font.
* Turn on/off the outline font based on \a outline.
*/
void Format::setFontOutline(bool outline)
{
@ -337,7 +444,7 @@ QString Format::fontName() const
}
/*!
* Set the name of the font.
* Set the name of the font to \a name.
*/
void Format::setFontName(const QString &name)
{
@ -423,7 +530,7 @@ Format::HorizontalAlignment Format::horizontalAlignment() const
}
/*!
* Set the horizontal alignment.
* Set the horizontal alignment with the given \a align.
*/
void Format::setHorizontalAlignment(HorizontalAlignment align)
{
@ -449,7 +556,7 @@ Format::VerticalAlignment Format::verticalAlignment() const
}
/*!
* Set the vertical alignment.
* Set the vertical alignment with the given \a align.
*/
void Format::setVerticalAlignment(VerticalAlignment align)
{
@ -465,7 +572,7 @@ bool Format::textWrap() const
}
/*!
* Enable the text wrap
* Enable the text wrap if \a wrap is true.
*/
void Format::setTextWarp(bool wrap)
{
@ -484,7 +591,7 @@ int Format::rotation() const
}
/*!
* Set the text roation. Must be in the range [0, 180] or 255.
* Set the text roation with the given \a rotation. Must be in the range [0, 180] or 255.
*/
void Format::setRotation(int rotation)
{
@ -500,7 +607,7 @@ int Format::indent() const
}
/*!
* Set the text indentation level. Must be less than or equal to 15.
* Set the text indentation level with the given \a indent. Must be less than or equal to 15.
*/
void Format::setIndent(int indent)
{
@ -524,7 +631,7 @@ bool Format::shrinkToFit() const
}
/*!
* Turn on/off shrink to fit.
* Turn on/off shrink to fit base on \a shink.
*/
void Format::setShrinkToFit(bool shink)
{
@ -556,7 +663,7 @@ bool Format::hasAlignmentData() const
}
/*!
* Set the border style.
* Set the border style with the given \a style.
*/
void Format::setBorderStyle(BorderStyle style)
{
@ -567,7 +674,7 @@ void Format::setBorderStyle(BorderStyle style)
}
/*!
* Set the border color.
* Sets the border color with the given \a color.
*/
void Format::setBorderColor(const QColor &color)
{
@ -578,7 +685,7 @@ void Format::setBorderColor(const QColor &color)
}
/*!
* Return the left border style
* Returns the left border style
*/
Format::BorderStyle Format::leftBorderStyle() const
{
@ -586,7 +693,7 @@ Format::BorderStyle Format::leftBorderStyle() const
}
/*!
* Set the left border style
* Sets the left border style to \a style
*/
void Format::setLeftBorderStyle(BorderStyle style)
{
@ -594,108 +701,169 @@ void Format::setLeftBorderStyle(BorderStyle style)
}
/*!
* Return the left border color
* Returns the left border color
*/
QColor Format::leftBorderColor() const
{
return colorProperty(FormatPrivate::P_Border_LeftColor);
}
/*!
Sets the left border color to the given \a color
*/
void Format::setLeftBorderColor(const QColor &color)
{
setProperty(FormatPrivate::P_Border_LeftColor, color);
}
/*!
Returns the right border style.
*/
Format::BorderStyle Format::rightBorderStyle() const
{
return static_cast<BorderStyle>(intProperty(FormatPrivate::P_Border_RightStyle));
}
/*!
Sets the right border style to the given \a style.
*/
void Format::setRightBorderStyle(BorderStyle style)
{
setProperty(FormatPrivate::P_Border_RightStyle, style);
}
/*!
Returns the right border color.
*/
QColor Format::rightBorderColor() const
{
return colorProperty(FormatPrivate::P_Border_RightColor);
}
/*!
Sets the right border color to the given \a color
*/
void Format::setRightBorderColor(const QColor &color)
{
setProperty(FormatPrivate::P_Border_RightColor, color);
}
/*!
Returns the top border style.
*/
Format::BorderStyle Format::topBorderStyle() const
{
return static_cast<BorderStyle>(intProperty(FormatPrivate::P_Border_TopStyle));
}
/*!
Sets the top border style to the given \a style.
*/
void Format::setTopBorderStyle(BorderStyle style)
{
setProperty(FormatPrivate::P_Border_TopStyle, style);
}
/*!
Returns the top border color.
*/
QColor Format::topBorderColor() const
{
return colorProperty(FormatPrivate::P_Border_TopColor);
}
/*!
Sets the top border color to the given \a color.
*/
void Format::setTopBorderColor(const QColor &color)
{
setProperty(FormatPrivate::P_Border_TopColor, color);
}
/*!
Returns the bottom border style.
*/
Format::BorderStyle Format::bottomBorderStyle() const
{
return static_cast<BorderStyle>(intProperty(FormatPrivate::P_Border_BottomStyle));
}
/*!
Sets the bottom border style to the given \a style.
*/
void Format::setBottomBorderStyle(BorderStyle style)
{
setProperty(FormatPrivate::P_Border_BottomStyle, style);
}
/*!
Returns the bottom border color.
*/
QColor Format::bottomBorderColor() const
{
return colorProperty(FormatPrivate::P_Border_BottomColor);
}
/*!
Sets the bottom border color to the given \a color.
*/
void Format::setBottomBorderColor(const QColor &color)
{
setProperty(FormatPrivate::P_Border_BottomColor, color);
}
/*!
Return the diagonla border style.
*/
Format::BorderStyle Format::diagonalBorderStyle() const
{
return static_cast<BorderStyle>(intProperty(FormatPrivate::P_Border_DiagonalStyle));
}
/*!
Sets the diagonal border style to the given \a style.
*/
void Format::setDiagonalBorderStyle(BorderStyle style)
{
setProperty(FormatPrivate::P_Border_DiagonalStyle, style);
}
/*!
Returns the diagonal border type.
*/
Format::DiagonalBorderType Format::diagonalBorderType() const
{
return static_cast<DiagonalBorderType>(intProperty(FormatPrivate::P_Border_DiagonalType));
}
/*!
Sets the diagonal border type to the given \a style
*/
void Format::setDiagonalBorderType(DiagonalBorderType style)
{
setProperty(FormatPrivate::P_Border_DiagonalType, style);
}
/*!
Returns the diagonal border color.
*/
QColor Format::diagonalBorderColor() const
{
return colorProperty(FormatPrivate::P_Border_DiagonalColor);
}
/*!
Sets the diagonal border color to the given \a color
*/
void Format::setDiagonalBorderColor(const QColor &color)
{
setProperty(FormatPrivate::P_Border_DiagonalColor, color);
}
/*!
\internal
Returns whether this format has been set valid border index.
*/
bool Format::borderIndexValid() const
{
if (!hasBorderData())
@ -703,6 +871,10 @@ bool Format::borderIndexValid() const
return d->border_index_valid;
}
/*!
\internal
Returns the border index.
*/
int Format::borderIndex() const
{
return d->border_index;
@ -751,21 +923,33 @@ bool Format::hasBorderData() const
return false;
}
/*!
Return the fill pattern.
*/
Format::FillPattern Format::fillPattern() const
{
return static_cast<FillPattern>(intProperty(FormatPrivate::P_Fill_Pattern));
}
/*!
Sets the fill pattern to the given \a pattern.
*/
void Format::setFillPattern(FillPattern pattern)
{
setProperty(FormatPrivate::P_Fill_Pattern, pattern);
}
/*!
Returns the foreground color of the pattern.
*/
QColor Format::patternForegroundColor() const
{
return colorProperty(FormatPrivate::P_Fill_FgColor);
}
/*!
Sets the foreground color of the pattern with the given \a color.
*/
void Format::setPatternForegroundColor(const QColor &color)
{
if (color.isValid() && !hasProperty(FormatPrivate::P_Fill_Pattern))
@ -773,11 +957,17 @@ void Format::setPatternForegroundColor(const QColor &color)
setProperty(FormatPrivate::P_Fill_FgColor, color);
}
/*!
Returns the background color of the pattern.
*/
QColor Format::patternBackgroundColor() const
{
return colorProperty(FormatPrivate::P_Fill_BgColor);
}
/*!
Sets the background color of the pattern with the given \a color.
*/
void Format::setPatternBackgroundColor(const QColor &color)
{
if (color.isValid() && !hasProperty(FormatPrivate::P_Fill_Pattern))
@ -842,21 +1032,33 @@ bool Format::hasFillData() const
return false;
}
/*!
Returns whether the hidden protection property is set to true.
*/
bool Format::hidden() const
{
return boolProperty(FormatPrivate::P_Protection_Hidden);
}
/*!
Sets the hidden protection property with the given \a hidden.
*/
void Format::setHidden(bool hidden)
{
setProperty(FormatPrivate::P_Protection_Hidden, hidden);
}
/*!
Returns whether the locked protection property is set to true.
*/
bool Format::locked() const
{
return boolProperty(FormatPrivate::P_Protection_Locked);
}
/*!
Sets the locked protection property with the given \a locked.
*/
void Format::setLocked(bool locked)
{
setProperty(FormatPrivate::P_Protection_Locked, locked);
@ -952,11 +1154,17 @@ bool Format::dxfIndexValid() const
return d->dxf_indexValid;
}
/*!
Returns ture if the \a format is equal to this format.
*/
bool Format::operator ==(const Format &format) const
{
return this->formatKey() == format.formatKey();
}
/*!
Returns ture if the \a format is not equal to this format.
*/
bool Format::operator !=(const Format &format) const
{
return this->formatKey() != format.formatKey();

91
src/xlsx/xlsxrichstring.cpp

@ -25,6 +25,7 @@
#include "xlsxrichstring.h"
#include "xlsxrichstring_p.h"
#include "xlsxformat_p.h"
#include <QDebug>
QT_BEGIN_NAMESPACE_XLSX
@ -49,31 +50,47 @@ RichStringPrivate::~RichStringPrivate()
/*!
\class RichString
\inmodule QtXlsx
\brief This class add support for the rich text string of the cell.
*/
/*!
Constructs a null string.
*/
RichString::RichString()
:d(new RichStringPrivate)
{
}
/*!
Constructs a plain string with the given \a text.
*/
RichString::RichString(const QString text)
:d(new RichStringPrivate)
{
addFragment(text, Format());
}
/*!
Constructs a copy of \a other.
*/
RichString::RichString(const RichString &other)
:d(other.d)
{
}
/*!
Destructs the string.
*/
RichString::~RichString()
{
}
/*!
Assigns \a other to this string and returns a reference to this string
*/
RichString &RichString::operator =(const RichString &other)
{
this->d = other.d;
@ -88,6 +105,9 @@ RichString::operator QVariant() const
return QVariant(qMetaTypeId<RichString>(), this);
}
/*!
Returns true if this is rich text string.
*/
bool RichString::isRichString() const
{
if (fragmentCount() > 1) //Is this enough??
@ -95,11 +115,30 @@ bool RichString::isRichString() const
return false;
}
bool RichString::isEmtpy() const
/*!
Returns true is this is an Null string.
*/
bool RichString::isNull() const
{
return d->fragmentTexts.size() == 0;
}
/*!
Returns true is this is an empty string.
*/
bool RichString::isEmtpy() const
{
foreach (const QString str, d->fragmentTexts) {
if (!str.isEmpty())
return false;
}
return true;
}
/*!
Converts to plain text string.
*/
QString RichString::toPlainString() const
{
if (isEmtpy())
@ -110,11 +149,17 @@ QString RichString::toPlainString() const
return d->fragmentTexts.join(QString());
}
/*!
Returns fragment count.
*/
int RichString::fragmentCount() const
{
return d->fragmentTexts.size();
}
/*!
Appends a fragment with the given \a text and \a format.
*/
void RichString::addFragment(const QString &text, const Format &format)
{
d->fragmentTexts.append(text);
@ -122,6 +167,9 @@ void RichString::addFragment(const QString &text, const Format &format)
d->_dirty = true;
}
/*!
Returns fragment text at the position \a index.
*/
QString RichString::fragmentText(int index) const
{
if (index < 0 || index >= fragmentCount())
@ -130,6 +178,9 @@ QString RichString::fragmentText(int index) const
return d->fragmentTexts[index];
}
/*!
Returns fragment format at the position \a index.
*/
Format RichString::fragmentFormat(int index) const
{
if (index < 0 || index >= fragmentCount())
@ -166,6 +217,10 @@ QByteArray RichStringPrivate::idKey() const
return _idKey;
}
/*!
Returns true if this string \a rs1 is equal to string \a rs2;
otherwise returns false.
*/
bool operator==(const RichString &rs1, const RichString &rs2)
{
if (rs1.fragmentCount() != rs2.fragmentCount())
@ -174,6 +229,10 @@ bool operator==(const RichString &rs1, const RichString &rs2)
return rs1.d->idKey() == rs2.d->idKey();
}
/*!
Returns true if this string \a rs1 is not equal to string \a rs2;
otherwise returns false.
*/
bool operator!=(const RichString &rs1, const RichString &rs2)
{
if (rs1.fragmentCount() != rs2.fragmentCount())
@ -190,6 +249,11 @@ bool operator<(const RichString &rs1, const RichString &rs2)
return rs1.d->idKey() < rs2.d->idKey();
}
/*!
\overload
Returns true if this string \a rs1 is equal to string \a rs2;
otherwise returns false.
*/
bool operator ==(const RichString &rs1, const QString &rs2)
{
if (rs1.fragmentCount() == 1 && rs1.fragmentText(0) == rs2) //format == 0
@ -198,6 +262,11 @@ bool operator ==(const RichString &rs1, const QString &rs2)
return false;
}
/*!
\overload
Returns true if this string \a rs1 is not equal to string \a rs2;
otherwise returns false.
*/
bool operator !=(const RichString &rs1, const QString &rs2)
{
if (rs1.fragmentCount() == 1 && rs1.fragmentText(0) == rs2) //format == 0
@ -206,11 +275,21 @@ bool operator !=(const RichString &rs1, const QString &rs2)
return true;
}
/*!
\overload
Returns true if this string \a rs1 is equal to string \a rs2;
otherwise returns false.
*/
bool operator ==(const QString &rs1, const RichString &rs2)
{
return rs2 == rs1;
}
/*!
\overload
Returns true if this string \a rs1 is not equal to string \a rs2;
otherwise returns false.
*/
bool operator !=(const QString &rs1, const RichString &rs2)
{
return rs2 != rs1;
@ -221,4 +300,12 @@ uint qHash(const RichString &rs, uint seed) Q_DECL_NOTHROW
return qHash(rs.d->idKey(), seed);
}
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const RichString &rs)
{
dbg.nospace() << "QXlsx::RichString(" << rs.d->fragmentTexts << ")";
return dbg.space();
}
#endif
QT_END_NAMESPACE_XLSX

6
src/xlsx/xlsxrichstring.h

@ -46,6 +46,7 @@ public:
~RichString();
bool isRichString() const;
bool isNull() const;
bool isEmtpy() const;
QString toPlainString() const;
@ -62,6 +63,7 @@ private:
friend Q_XLSX_EXPORT bool operator==(const RichString &rs1, const RichString &rs2);
friend Q_XLSX_EXPORT bool operator!=(const RichString &rs1, const RichString &rs2);
friend Q_XLSX_EXPORT bool operator<(const RichString &rs1, const RichString &rs2);
friend Q_XLSX_EXPORT QDebug operator<<(QDebug dbg, const RichString &rs);
QSharedDataPointer<RichStringPrivate> d;
};
@ -74,6 +76,10 @@ Q_XLSX_EXPORT bool operator==(const QString &rs1, const RichString &rs2);
Q_XLSX_EXPORT bool operator!=(const RichString &rs1, const QString &rs2);
Q_XLSX_EXPORT bool operator!=(const QString &rs1, const RichString &rs2);
#ifndef QT_NO_DEBUG_STREAM
Q_XLSX_EXPORT QDebug operator<<(QDebug dbg, const RichString &rs);
#endif
QT_END_NAMESPACE_XLSX
Q_DECLARE_METATYPE(QXlsx::RichString)

Loading…
Cancel
Save