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/qtextodfwriter.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**
     
    175175    case QTextListFormat::ListUpperAlpha:
    176176        return QString::fromLatin1("A");
     177    case QTextListFormat::ListLowerRoman:
     178        return QString::fromLatin1("i");
     179    case QTextListFormat::ListUpperRoman:
     180        return QString::fromLatin1("I");
    177181    default:
    178182    case QTextListFormat::ListStyleUndefined:
     
    296300            .arg(frag.fragment().charFormatIndex()));
    297301        bool escapeNextSpace = true;
    298         int precedingSpaces = 0, precedingTabs = 0;
     302        int precedingSpaces = 0;
    299303        int exportedIndex = 0;
    300304        for (int i=0; i <= fragmentText.count(); ++i) {
    301             bool isTab = false, isSpace = false;
    302             if (i < fragmentText.count()) {
     305            bool isSpace = false;
    303306                QChar character = fragmentText[i];
    304                 isTab = character.unicode() == '\t';
    305307                isSpace = character.unicode() == ' ';
    306                 if (character.unicode() == 0x2028) { // soft-return
    307                     writer.writeCharacters(fragmentText.mid(exportedIndex, i));
    308                     writer.writeEmptyElement(textNS, QString::fromLatin1("line-break"));
    309                     exportedIndex = i+1;
    310                     continue;
    311                 }
    312                 if (isSpace) {
    313                     ++precedingSpaces;
    314                     escapeNextSpace = true;
    315                 }
    316                 else if (isTab) {
    317                     precedingTabs++;
    318                 }
    319             }
     308
    320309            // find more than one space. -> <text:s text:c="2" />
    321310            if (!isSpace && escapeNextSpace && precedingSpaces > 1) {
     
    330319                exportedIndex = i;
    331320            }
    332             // find tabs.   ->  <text:tab text:tab-ref="3" />  or <text:tab/>
    333             if (!isTab && precedingTabs) {
    334                 writer.writeCharacters(fragmentText.mid(exportedIndex, i - precedingTabs - exportedIndex));
    335                 writer.writeEmptyElement(textNS, QString::fromLatin1("tab"));
    336                 if (precedingTabs > 1)
    337                     writer.writeAttribute(textNS, QString::fromLatin1("tab-ref"), QString::number(precedingTabs));
    338                 precedingTabs = 0;
    339                 exportedIndex = i;
     321
     322            if (i < fragmentText.count()) {
     323                if (character.unicode() == 0x2028) { // soft-return
     324                    //if (exportedIndex < i)
     325                        writer.writeCharacters(fragmentText.mid(exportedIndex, i - exportedIndex));
     326                    writer.writeEmptyElement(textNS, QString::fromLatin1("line-break"));
     327                    exportedIndex = i+1;
     328                    continue;
     329                } else if (character.unicode() == '\t') { // Tab
     330                    //if (exportedIndex < i)
     331                        writer.writeCharacters(fragmentText.mid(exportedIndex, i - exportedIndex));
     332                    writer.writeEmptyElement(textNS, QString::fromLatin1("tab"));
     333                    exportedIndex = i+1;
     334                    precedingSpaces = 0;
     335                } else if (isSpace) {
     336                    ++precedingSpaces;
     337                    escapeNextSpace = true;
     338                } else if (!isSpace) {
     339                    precedingSpaces = 0;
     340                }
    340341            }
    341             if (!isSpace && !isTab)
    342                 precedingSpaces = 0;
    343342        }
    344343
     
    449448
    450449    if (format.hasProperty(QTextFormat::BlockAlignment)) {
     450        const Qt::Alignment alignment = format.alignment() & Qt::AlignHorizontal_Mask;
    451451        QString value;
    452         if (format.alignment() == Qt::AlignLeading)
     452        if (alignment == Qt::AlignLeading)
    453453            value = QString::fromLatin1("start");
    454         else if (format.alignment() == Qt::AlignTrailing)
     454        else if (alignment == Qt::AlignTrailing)
    455455            value = QString::fromLatin1("end");
    456         else if (format.alignment() == (Qt::AlignLeft | Qt::AlignAbsolute))
     456        else if (alignment == (Qt::AlignLeft | Qt::AlignAbsolute))
    457457            value = QString::fromLatin1("left");
    458         else if (format.alignment() == (Qt::AlignRight | Qt::AlignAbsolute))
     458        else if (alignment == (Qt::AlignRight | Qt::AlignAbsolute))
    459459            value = QString::fromLatin1("right");
    460         else if (format.alignment() == Qt::AlignHCenter)
     460        else if (alignment == Qt::AlignHCenter)
    461461            value = QString::fromLatin1("center");
    462         else if (format.alignment() == Qt::AlignJustify)
     462        else if (alignment == Qt::AlignJustify)
    463463            value = QString::fromLatin1("justify");
    464464        else
     
    478478        writer.writeAttribute(foNS, QString::fromLatin1("margin-right"), pixelToPoint(qMax(qreal(0.), format.rightMargin())) );
    479479    if (format.hasProperty(QTextFormat::TextIndent))
    480         writer.writeAttribute(foNS, QString::fromLatin1("text-indent"), QString::number(format.textIndent()));
     480        writer.writeAttribute(foNS, QString::fromLatin1("text-indent"), pixelToPoint(format.textIndent()));
    481481    if (format.hasProperty(QTextFormat::PageBreakPolicy)) {
    482482        if (format.pageBreakPolicy() & QTextFormat::PageBreak_AlwaysBefore)
     
    484484        if (format.pageBreakPolicy() & QTextFormat::PageBreak_AlwaysAfter)
    485485            writer.writeAttribute(foNS, QString::fromLatin1("break-after"), QString::fromLatin1("page"));
     486    }
     487    if (format.hasProperty(QTextFormat::BackgroundBrush)) {
     488        QBrush brush = format.background();
     489        writer.writeAttribute(foNS, QString::fromLatin1("background-color"), brush.color().name());
    486490    }
    487491    if (format.hasProperty(QTextFormat::BlockNonBreakableLines))
     
    552556    }
    553557    if (format.hasProperty(QTextFormat::FontLetterSpacing))
    554         writer.writeAttribute(foNS, QString::fromLatin1("letter-spacing"), pixelToPoint(format.fontLetterSpacing()) );
     558        writer.writeAttribute(foNS, QString::fromLatin1("letter-spacing"), pixelToPoint(format.fontLetterSpacing()));
    555559    if (format.hasProperty(QTextFormat::FontWordSpacing))
    556         writer.writeAttribute(foNS, QString::fromLatin1("letter-spacing"), pixelToPoint(format.fontWordSpacing()) );
     560        writer.writeAttribute(foNS, QString::fromLatin1("word-spacing"), pixelToPoint(format.fontWordSpacing()));
    557561    if (format.hasProperty(QTextFormat::FontUnderline))
    558562        writer.writeAttribute(styleNS, QString::fromLatin1("text-underline-type"),
     
    611615    if (format.hasProperty(QTextFormat::ForegroundBrush)) {
    612616        QBrush brush = format.foreground();
    613         // TODO
    614617        writer.writeAttribute(foNS, QString::fromLatin1("color"), brush.color().name());
     618    }
     619    if (format.hasProperty(QTextFormat::BackgroundBrush)) {
     620        QBrush brush = format.background();
     621        writer.writeAttribute(foNS, QString::fromLatin1("background-color"), brush.color().name());
    615622    }
    616623
     
    625632    QTextListFormat::Style style = format.style();
    626633    if (style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha
    627             || style == QTextListFormat::ListUpperAlpha) {
     634            || style == QTextListFormat::ListUpperAlpha
     635            || style == QTextListFormat::ListLowerRoman
     636            || style == QTextListFormat::ListUpperRoman) {
    628637        writer.writeStartElement(textNS, QString::fromLatin1("list-level-style-number"));
    629638        writer.writeAttribute(styleNS, QString::fromLatin1("num-format"), bulletChar(style));
Note: See TracChangeset for help on using the changeset viewer.