Example #1
0
QStringList FilePrinter::pages( QPrinter &printer, PageSelectPolicy pageSelectPolicy, const QString &pageRange,
                                    bool useCupsOptions, const QString &version )
{
    if ( pageSelectPolicy == FilePrinter::SystemSelectsPages ) {

        if ( printer.printRange() == QPrinter::Selection && ! pageRange.isEmpty() ) {

            if ( version == QLatin1String("lp") ) {
                return QStringList(QStringLiteral("-P")) << pageRange ;
            }

            if ( version.startsWith( QLatin1String("lpr") ) && useCupsOptions ) {
                return QStringList(QStringLiteral("-o")) << QStringLiteral("page-ranges=%1").arg( pageRange );
            }

        }

        if ( printer.printRange() == QPrinter::PageRange ) {

            if ( version == QLatin1String("lp") ) {
                return QStringList(QStringLiteral("-P")) << QStringLiteral("%1-%2").arg( printer.fromPage() )
                                                            .arg( printer.toPage() );
            }

            if ( version.startsWith( QLatin1String("lpr") ) && useCupsOptions ) {
                return QStringList(QStringLiteral("-o")) << QStringLiteral("page-ranges=%1-%2").arg( printer.fromPage() )
                                                                        .arg( printer.toPage() );
            }

        }

    }

    return QStringList(); // AllPages
}
Example #2
0
QList<int> FilePrinter::pageList( QPrinter &printer, int lastPage,
                                  int currentPage, const QList<int> &selectedPageList )
{
    if ( printer.printRange() == QPrinter::Selection) {
        return selectedPageList;
    }

    int startPage, endPage;
    QList<int> list;

    if ( printer.printRange() == QPrinter::PageRange ) {
        startPage = printer.fromPage();
        endPage = printer.toPage();
#if QT_VERSION >= KDE_MAKE_VERSION(4,7,0)
    } else if ( printer.printRange() == QPrinter::CurrentPage) {
        startPage = currentPage;
        endPage = currentPage;
#endif
    } else { //AllPages
        startPage = 1;
        endPage = lastPage;
    }

    for (int i = startPage; i <= endPage; i++ ) {
        list << i;
    }

    return list;
}
Example #3
0
QString FilePrinter::pageRange( QPrinter &printer, int lastPage, const QList<int> &selectedPageList )
{
    if ( printer.printRange() == QPrinter::Selection) {
        return pageListToPageRange( selectedPageList );
    }

    if ( printer.printRange() == QPrinter::PageRange ) {
        return QString("%1-%2").arg(printer.fromPage()).arg(printer.toPage());
    }

    return QString("1-%2").arg( lastPage );
}
Example #4
0
QPrinter::PrintRange QPrinterProto::printRange() const
{
  QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject());
  if (item)
    return item->printRange();
  return QPrinter::AllPages;
}
Example #5
0
int PrintJob::Private::setupPages(const QPrinter& printer, bool forceRecreation)
{
    // Create the list of sheet, that should be printed.
    selectedSheets.clear();
    if (printer.printRange() == QPrinter::Selection)
        selectedSheets.append(view->activeSheet());
    else if (sheetSelectPage->allSheetsButton->isChecked())
        selectedSheets = view->doc()->map()->sheetList();
    else if (sheetSelectPage->activeSheetButton->isChecked())
        selectedSheets.append(view->activeSheet());
    else if (sheetSelectPage->selectedSheetsButton->isChecked())
    {
        const QStringList sheetNames = sheetSelectPage->selectedSheets();
        for (int i = 0; i < sheetNames.count(); ++i)
        {
            Sheet* sheet = view->doc()->map()->findSheet(sheetNames[i]);
            if (sheet == 0)
            {
                kWarning(36005) << i18n("Sheet %1 could not be found for printing", sheetNames[i]);
                continue;
            }
            selectedSheets.append(sheet);
        }
    }

    // (Re-)Create the pages of the sheets.
    int pageCount = 0;
    for (int i = 0; i < selectedSheets.count(); ++i)
    {
        PrintSettings settings = *selectedSheets[i]->printSettings();
        // Set the print region, if the selection should be painted.
        if (printer.printRange() == QPrinter::Selection)
            settings.setPrintRegion(*view->selection());
        printManager(selectedSheets[i])->setPrintSettings(settings, forceRecreation);
        pageCount += printManager(selectedSheets[i])->pageCount();
    }
    return pageCount;
}
Example #6
0
int Printer::printRange(lua_State * L) // const : PrintRange 
{
	QPrinter* lhs = ValueBinding<MyQPrinter>::check( L, 1 );
	Util::push( L, lhs->printRange() );
	return 1; 
}