Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/text/qtextdocument.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    6565#include "qtextdocument_p.h"
    6666#include <private/qprinter_p.h>
     67#include <private/qabstracttextdocumentlayout_p.h>
    6768
    6869#include <limits.h>
     
    141142/*!
    142143    Converts the plain text string \a plain to a HTML string with
    143     HTML metacharacters \c{<}, \c{>}, and \c{&} replaced by HTML
     144    HTML metacharacters \c{<}, \c{>}, \c{&}, and \c{"} replaced by HTML
    144145    entities.
    145146
     
    163164        else if (plain.at(i) == QLatin1Char('&'))
    164165            rich += QLatin1String("&amp;");
     166        else if (plain.at(i) == QLatin1Char('"'))
     167            rich += QLatin1String("&quot;");
    165168        else
    166169            rich += plain.at(i);
     
    248251    viewed and edited using a QTextEdit.
    249252
    250     \ingroup text
    251     \mainclass
     253    \ingroup richtext-processing
     254
    252255
    253256    QTextDocument is a container for structured rich text documents, providing
     
    288291    system.
    289292
    290     \sa QTextCursor QTextEdit \link richtext.html Rich Text Processing\endlink
     293    \sa QTextCursor, QTextEdit, \link richtext.html Rich Text Processing\endlink , {Text Object Example}
    291294*/
    292295
     
    957960/*!
    958961    Returns true if undo is available; otherwise returns false.
     962
     963    \sa isRedoAvailable(), availableUndoSteps()
    959964*/
    960965bool QTextDocument::isUndoAvailable() const
     
    966971/*!
    967972    Returns true if redo is available; otherwise returns false.
     973
     974    \sa isUndoAvailable(), availableRedoSteps()
    968975*/
    969976bool QTextDocument::isRedoAvailable() const
     
    973980}
    974981
     982/*! \since 4.6
     983
     984    Returns the number of available undo steps.
     985
     986    \sa isUndoAvailable()
     987*/
     988int QTextDocument::availableUndoSteps() const
     989{
     990    Q_D(const QTextDocument);
     991    return d->availableUndoSteps();
     992}
     993
     994/*! \since 4.6
     995
     996    Returns the number of available redo steps.
     997
     998    \sa isRedoAvailable()
     999*/
     1000int QTextDocument::availableRedoSteps() const
     1001{
     1002    Q_D(const QTextDocument);
     1003    return d->availableRedoSteps();
     1004}
    9751005
    9761006/*! \since 4.4
     
    9861016{
    9871017    Q_D(const QTextDocument);
    988     return d->undoState;
     1018    return d->revision;
    9891019}
    9901020
     
    10971127    bool previousState = d->isUndoRedoEnabled();
    10981128    d->enableUndoRedo(false);
     1129    d->beginEditBlock();
    10991130    d->clear();
    11001131    QTextCursor(this).insertText(text);
     1132    d->endEditBlock();
    11011133    d->enableUndoRedo(previousState);
    11021134}
     
    11241156    bool previousState = d->isUndoRedoEnabled();
    11251157    d->enableUndoRedo(false);
     1158    d->beginEditBlock();
    11261159    d->clear();
    11271160    QTextHtmlImporter(this, html, QTextHtmlImporter::ImportToDocument).import();
     1161    d->endEditBlock();
    11281162    d->enableUndoRedo(previousState);
    11291163}
     
    16901724        layout->setPaintDevice(p.device());
    16911725
     1726        // copy the custom object handlers
     1727        layout->d_func()->handlers = documentLayout()->d_func()->handlers;
     1728
    16921729        int dpiy = p.device()->logicalDpiY();
    16931730        int margin = 0;
     
    17301767    fromPage = qMax(1, fromPage);
    17311768    toPage = qMin(doc->pageCount(), toPage);
     1769
     1770    if (toPage < fromPage) {
     1771        // if the user entered a page range outside the actual number
     1772        // of printable pages, just return
     1773        return;
     1774    }
    17321775
    17331776    if (printer->pageOrder() == QPrinter::LastPageFirst) {
     
    20352078    html += QLatin1String(attribute);
    20362079    html += QLatin1String("=\"");
    2037     html += value;
     2080    html += Qt::escape(value);
    20382081    html += QLatin1Char('"');
    20392082}
     
    22022245        html += QLatin1String("%\"");
    22032246    else
    2204         html += QLatin1String("\"");
     2247        html += QLatin1Char('\"');
    22052248}
    22062249
     
    22992342    html += QLatin1String(" font-family:");
    23002343
    2301     QLatin1Char quote('\'');
    2302     if (family.contains(quote))
    2303         quote = QLatin1Char('\"');
     2344    QLatin1String quote("\'");
     2345    if (family.contains(QLatin1Char('\'')))
     2346        quote = QLatin1String("&quot;");
    23042347
    23052348    html += quote;
    2306     html += family;
     2349    html += Qt::escape(family);
    23072350    html += quote;
    23082351    html += QLatin1Char(';');
     
    23382381        if (!name.isEmpty()) {
    23392382            html += QLatin1String("<a name=\"");
    2340             html += name;
     2383            html += Qt::escape(name);
    23412384            html += QLatin1String("\"></a>");
    23422385        }
     
    23442387        if (!href.isEmpty()) {
    23452388            html += QLatin1String("<a href=\"");
    2346             html += href;
     2389            html += Qt::escape(href);
    23472390            html += QLatin1String("\">");
    23482391            closeAnchor = true;
     
    24172460{
    24182461    return style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha
    2419            || style == QTextListFormat::ListUpperAlpha;
     2462           || style == QTextListFormat::ListUpperAlpha
     2463           || style == QTextListFormat::ListUpperRoman
     2464           || style == QTextListFormat::ListLowerRoman
     2465           ;
    24202466}
    24212467
     
    25142560                case QTextListFormat::ListLowerAlpha: html += QLatin1String("<ol type=\"a\""); break;
    25152561                case QTextListFormat::ListUpperAlpha: html += QLatin1String("<ol type=\"A\""); break;
     2562                case QTextListFormat::ListLowerRoman: html += QLatin1String("<ol type=\"i\""); break;
     2563                case QTextListFormat::ListUpperRoman: html += QLatin1String("<ol type=\"I\""); break;
    25162564                default: html += QLatin1String("<ul"); // ### should not happen
    25172565            }
    25182566
     2567            html += QLatin1String(" style=\"margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px;");
     2568
    25192569            if (format.hasProperty(QTextFormat::ListIndent)) {
    2520                 html += QLatin1String(" style=\"-qt-list-indent: ");
     2570                html += QLatin1String(" -qt-list-indent: ");
    25212571                html += QString::number(format.indent());
    2522                 html += QLatin1String(";\"");
     2572                html += QLatin1Char(';');
    25232573            }
    25242574
    2525             html += QLatin1Char('>');
     2575            html += QLatin1String("\">");
    25262576        }
    25272577
Note: See TracChangeset for help on using the changeset viewer.