1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
|
/* This file is part of the KDE project
Copyright 2008 Stefan Nikolaus <stefan.nikolaus@kdemail.net>
Copyright 2005 Raphael Langerhorst <raphael.langerhorst@kdemail.net>
Copyright 2003 Philipp Müller <philipp.mueller@gmx.de>
Copyright 1998, 1999 Torben Weis <weis@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// Local
#include "PrintSettings.h"
// Sheets
#include "calligra_sheets_limits.h"
#include "Region.h"
// Calligra
#include <KoPageLayout.h>
#include <KoUnit.h>
// Qt
#include <QSize>
using namespace Calligra::Sheets;
class Q_DECL_HIDDEN PrintSettings::Private
{
public:
KoPageLayout pageLayout;
bool printGrid : 1;
bool printCharts : 1;
bool printObjects : 1;
bool printGraphics : 1;
bool printCommentIndicator : 1;
bool printFormulaIndicator : 1;
bool printHeaders : 1;
bool printZeroValues : 1;
bool centerHorizontally : 1;
bool centerVertically : 1;
PageOrder pageOrder;
Region printRegion;
double zoom;
QSize pageLimits;
QPair<int, int> repeatedColumns;
QPair<int, int> repeatedRows;
public:
void calculatePageDimensions();
};
void PrintSettings::Private::calculatePageDimensions()
{
if (pageLayout.format != KoPageFormat::CustomSize) {
pageLayout.width = MM_TO_POINT(KoPageFormat::width(pageLayout.format, pageLayout.orientation));
pageLayout.height = MM_TO_POINT(KoPageFormat::height(pageLayout.format, pageLayout.orientation));
}
}
PrintSettings::PrintSettings()
: d(new Private)
{
d->printGrid = false;
d->printCharts = true;
d->printObjects = true;
d->printGraphics = true;
d->printCommentIndicator = false;
d->printFormulaIndicator = false;
d->printHeaders = true;
d->printZeroValues = false;
d->centerHorizontally = false;
d->centerVertically = false;
d->pageOrder = LeftToRight;
d->printRegion = Region(1, 1, KS_colMax, KS_rowMax);
d->zoom = 1.0;
}
PrintSettings::PrintSettings(const PrintSettings& other)
: d(new Private)
{
d->pageLayout = other.d->pageLayout;
d->printGrid = other.d->printGrid;
d->printCharts = other.d->printCharts;
d->printObjects = other.d->printObjects;
d->printGraphics = other.d->printGraphics;
d->printCommentIndicator = other.d->printCommentIndicator;
d->printFormulaIndicator = other.d->printFormulaIndicator;
d->printHeaders = other.d->printHeaders;
d->printZeroValues = other.d->printZeroValues;
d->centerHorizontally = other.d->centerHorizontally;
d->centerVertically = other.d->centerVertically;
d->pageOrder = other.d->pageOrder;
d->printRegion = other.d->printRegion;
d->zoom = other.d->zoom;
d->pageLimits = other.d->pageLimits;
d->repeatedColumns = other.d->repeatedColumns;
d->repeatedRows = other.d->repeatedRows;
}
PrintSettings::~PrintSettings()
{
delete d;
}
const KoPageLayout& PrintSettings::pageLayout() const
{
return d->pageLayout;
}
void PrintSettings::setPageLayout(const KoPageLayout& pageLayout)
{
d->pageLayout = pageLayout;
}
void PrintSettings::setPageFormat(KoPageFormat::Format format)
{
d->pageLayout.format = format;
d->calculatePageDimensions();
}
void PrintSettings::setPageOrientation(KoPageFormat::Orientation orientation)
{
d->pageLayout.orientation = orientation;
d->calculatePageDimensions();
}
QString PrintSettings::paperFormatString() const
{
if (d->pageLayout.format == KoPageFormat::CustomSize) {
QString tmp;
tmp.sprintf("%fx%f", d->pageLayout.width, d->pageLayout.height);
return tmp;
}
return KoPageFormat::formatString(d->pageLayout.format);
}
QString PrintSettings::orientationString() const
{
switch (d->pageLayout.orientation) {
case QPrinter::Portrait:
default:
return "Portrait";
case QPrinter::Landscape:
return "Landscape";
}
}
double PrintSettings::printWidth() const
{
return d->pageLayout.width - d->pageLayout.leftMargin - d->pageLayout.rightMargin;
}
double PrintSettings::printHeight() const
{
return d->pageLayout.height - d->pageLayout.topMargin - d->pageLayout.bottomMargin;
}
PrintSettings::PageOrder PrintSettings::pageOrder() const
{
return d->pageOrder;
}
void PrintSettings::setPageOrder(PageOrder order)
{
d->pageOrder = order;
}
bool PrintSettings::printGrid() const
{
return d->printGrid;
}
void PrintSettings::setPrintGrid(bool printGrid)
{
d->printGrid = printGrid;
}
bool PrintSettings::printCharts() const
{
return d->printCharts;
}
void PrintSettings::setPrintCharts(bool printCharts)
{
d->printCharts = printCharts;
}
bool PrintSettings::printObjects() const
{
return d->printObjects;
}
void PrintSettings::setPrintObjects(bool printObjects)
{
d->printObjects = printObjects;
}
bool PrintSettings::printGraphics() const
{
return d->printGraphics;
}
void PrintSettings::setPrintGraphics(bool printGraphics)
{
d->printGraphics = printGraphics;
}
bool PrintSettings::printCommentIndicator() const
{
return d->printCommentIndicator;
}
void PrintSettings::setPrintCommentIndicator(bool printCommentIndicator)
{
d->printCommentIndicator = printCommentIndicator;
}
bool PrintSettings::printFormulaIndicator() const
{
return d->printFormulaIndicator;
}
void PrintSettings::setPrintFormulaIndicator(bool printFormulaIndicator)
{
d->printFormulaIndicator = printFormulaIndicator;
}
bool PrintSettings::printHeaders() const
{
return d->printHeaders;
}
void PrintSettings::setPrintHeaders(bool printHeaders)
{
d->printHeaders = printHeaders;
}
bool PrintSettings::printZeroValues() const
{
return d->printZeroValues;
}
void PrintSettings::setPrintZeroValues(bool printZeroValues)
{
d->printZeroValues = printZeroValues;
}
bool PrintSettings::centerHorizontally() const
{
return d->centerHorizontally;
}
void PrintSettings::setCenterHorizontally(bool center)
{
d->centerHorizontally = center;
}
bool PrintSettings::centerVertically() const
{
return d->centerVertically;
}
void PrintSettings::setCenterVertically(bool center)
{
d->centerVertically = center;
}
const Calligra::Sheets::Region& PrintSettings::printRegion() const
{
return d->printRegion;
}
void PrintSettings::setPrintRegion(const Region& region)
{
d->printRegion = region;
}
void PrintSettings::addPrintRange(const QRect& range)
{
d->printRegion.add(range);
}
void PrintSettings::removePrintRange(const QRect& range)
{
d->printRegion.sub(range, 0);
}
double PrintSettings::zoom() const
{
return d->zoom;
}
void PrintSettings::setZoom(double zoom)
{
d->zoom = zoom;
}
const QSize& PrintSettings::pageLimits() const
{
return d->pageLimits;
}
void PrintSettings::setPageLimits(const QSize& pageLimits)
{
d->pageLimits = pageLimits;
}
const QPair<int, int>& PrintSettings::repeatedColumns() const
{
return d->repeatedColumns;
}
void PrintSettings::setRepeatedColumns(const QPair<int, int>& repeatedColumns)
{
d->repeatedColumns = repeatedColumns;
debugSheets << repeatedColumns;
}
const QPair<int, int>& PrintSettings::repeatedRows() const
{
return d->repeatedRows;
}
void PrintSettings::setRepeatedRows(const QPair<int, int>& repeatedRows)
{
d->repeatedRows = repeatedRows;
}
void PrintSettings::operator=(const PrintSettings & other)
{
d->pageLayout = other.d->pageLayout;
d->printGrid = other.d->printGrid;
d->printCharts = other.d->printCharts;
d->printObjects = other.d->printObjects;
d->printGraphics = other.d->printGraphics;
d->printCommentIndicator = other.d->printCommentIndicator;
d->printFormulaIndicator = other.d->printFormulaIndicator;
d->printHeaders = other.d->printHeaders;
d->printZeroValues = other.d->printZeroValues;
d->centerHorizontally = other.d->centerHorizontally;
d->centerVertically = other.d->centerVertically;
d->pageOrder = other.d->pageOrder;
d->printRegion = other.d->printRegion;
d->zoom = other.d->zoom;
d->pageLimits = other.d->pageLimits;
d->repeatedColumns = other.d->repeatedColumns;
d->repeatedRows = other.d->repeatedRows;
}
bool PrintSettings::operator==(const PrintSettings& other) const
{
if (d->pageLayout != other.d->pageLayout)
return false;
if (d->printGrid != other.d->printGrid)
return false;
if (d->printCharts != other.d->printCharts)
return false;
if (d->printObjects != other.d->printObjects)
return false;
if (d->printGraphics != other.d->printGraphics)
return false;
if (d->printCommentIndicator != other.d->printCommentIndicator)
return false;
if (d->printFormulaIndicator != other.d->printFormulaIndicator)
return false;
if (d->printHeaders != other.d->printHeaders)
return false;
if (d->printZeroValues != other.d->printZeroValues)
return false;
if (d->centerHorizontally != other.d->centerHorizontally)
return false;
if (d->centerVertically != other.d->centerVertically)
return false;
if (d->pageOrder != other.d->pageOrder)
return false;
if (d->printRegion != other.d->printRegion)
return false;
if (d->zoom != other.d->zoom)
return false;
if (d->pageLimits != other.d->pageLimits)
return false;
if (d->repeatedColumns != other.d->repeatedColumns)
return false;
if (d->repeatedRows != other.d->repeatedRows)
return false;
return true;
}
|