-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add suport of print area and page setup #31
base: master
Are you sure you want to change the base?
Conversation
To set print area of sheet use bool setPrintArea(const CellRange &range, const QString &sheetName=QString()); To set page scaling to percent use bool setPageSetup(double percent, QPageSize::PageSizeId size, QPageLayout::Orientation orientation); To set page scaling to number of pages use bool setPageSetup(int fitToWidth, int fitToHeight, QPageSize::PageSizeId size, QPageLayout::Orientation orientation);
- support of manual row breaks and column breaks - better multiline text format
Page breaks and multiline text
- 0 is valid value for fitToWidth and fitToHeight, which means "Auto"
Fix PageSetup
sheet); | ||
} | ||
|
||
bool Document::setPageSetup(double percent, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the public methods x2
@@ -228,13 +228,23 @@ void SharedStrings::saveToXmlFile(QIODevice *device) const | |||
writer.writeStartElement(QStringLiteral("si")); | |||
if (string.isRichString()) { | |||
//Rich text string | |||
Format lastNotEmptyFragmentFormat; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is unrelated to the pull request. Not a big deal but next time please try to keep them separated
/*! | ||
* Add manual page break above the specified row \a row (1-indexed) | ||
*/ | ||
void Worksheet::addRowBreak(int row) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to clearer method name. I'd suggest addPageBreakRow
and addPageBreakColumn
.
{ | ||
writer.writeStartElement(QStringLiteral("pageSetup")); | ||
writer.writeAttribute(QStringLiteral("paperSize"), QString::number(d->pageSetup.xlsxPageSize())); | ||
if (d->pageSetup.isScale()) writer.writeAttribute(QStringLiteral("scale"), QString::number(d->pageSetup.scale)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: put statements in the if and else blocks to a new line
writer.writeStartElement(QStringLiteral("rowBreaks")); | ||
writer.writeAttribute(QStringLiteral("count"), QString::number(d->rowBreaks.count())); | ||
writer.writeAttribute(QStringLiteral("manualBreakCount"), QString::number(d->rowBreaks.count())); | ||
QList<int> sortedBreaks = d->rowBreaks.toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: why the indent?
@@ -2181,7 +2267,7 @@ void WorksheetPrivate::loadXmlHyperlinks(QXmlStreamReader &reader) | |||
Q_ASSERT(reader.name() == QLatin1String("hyperlinks")); | |||
|
|||
while (!reader.atEnd() && !(reader.name() == QLatin1String("hyperlinks") | |||
&& reader.tokenType() == QXmlStreamReader::EndElement)) { | |||
&& reader.tokenType() == QXmlStreamReader::EndElement)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert spacing change
Q_ASSERT(reader.name() == QLatin1String("sheetPr")); | ||
|
||
while (!reader.atEnd() && !(reader.name() == QLatin1String("sheetPr") | ||
&& reader.tokenType() == QXmlStreamReader::EndElement)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too much white space
@@ -2341,4 +2457,101 @@ SharedStrings *WorksheetPrivate::sharedStrings() const | |||
return workbook->sharedStrings(); | |||
} | |||
|
|||
WorksheetPrivate::PageSetup::PageSetup(): | |||
scale(0), | |||
fitToWidth(-1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra white space
QPageSize::PageSizeId _pageSize, | ||
QPageLayout::Orientation _orientation) : | ||
scale(_scale), | ||
fitToWidth(-1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra white space
|
||
QPageLayout::Orientation WorksheetPrivate::PageSetup::fromOrientationString(const QString& str) | ||
{ | ||
if (!str.compare(QStringLiteral("landscape"), Qt::CaseInsensitive)) return QPageLayout::Landscape; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
statements after if to new line. remove the else as required by Qt style guide
To set print area of sheet use
bool setPrintArea(const CellRange &range, const QString &sheetName=QString());
To set page scaling to percent use
bool setPageSetup(double percent,
QPageSize::PageSizeId size,
QPageLayout::Orientation orientation);
To set page scaling to number of pages use
bool setPageSetup(int fitToWidth,
int fitToHeight,
QPageSize::PageSizeId size,
QPageLayout::Orientation orientation);
Autoformatting in Qt Creator insert some extra spaces in old code, that's why so many lines has changes