Changeset 561 for trunk/src/gui/text/qtextodfwriter.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/text/qtextodfwriter.cpp
r2 r561 2 2 ** 3 3 ** 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) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** 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. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 175 175 case QTextListFormat::ListUpperAlpha: 176 176 return QString::fromLatin1("A"); 177 case QTextListFormat::ListLowerRoman: 178 return QString::fromLatin1("i"); 179 case QTextListFormat::ListUpperRoman: 180 return QString::fromLatin1("I"); 177 181 default: 178 182 case QTextListFormat::ListStyleUndefined: … … 296 300 .arg(frag.fragment().charFormatIndex())); 297 301 bool escapeNextSpace = true; 298 int precedingSpaces = 0 , precedingTabs = 0;302 int precedingSpaces = 0; 299 303 int exportedIndex = 0; 300 304 for (int i=0; i <= fragmentText.count(); ++i) { 301 bool isTab = false, isSpace = false; 302 if (i < fragmentText.count()) { 305 bool isSpace = false; 303 306 QChar character = fragmentText[i]; 304 isTab = character.unicode() == '\t';305 307 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 320 309 // find more than one space. -> <text:s text:c="2" /> 321 310 if (!isSpace && escapeNextSpace && precedingSpaces > 1) { … … 330 319 exportedIndex = i; 331 320 } 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 } 340 341 } 341 if (!isSpace && !isTab)342 precedingSpaces = 0;343 342 } 344 343 … … 449 448 450 449 if (format.hasProperty(QTextFormat::BlockAlignment)) { 450 const Qt::Alignment alignment = format.alignment() & Qt::AlignHorizontal_Mask; 451 451 QString value; 452 if ( format.alignment()== Qt::AlignLeading)452 if (alignment == Qt::AlignLeading) 453 453 value = QString::fromLatin1("start"); 454 else if ( format.alignment()== Qt::AlignTrailing)454 else if (alignment == Qt::AlignTrailing) 455 455 value = QString::fromLatin1("end"); 456 else if ( format.alignment()== (Qt::AlignLeft | Qt::AlignAbsolute))456 else if (alignment == (Qt::AlignLeft | Qt::AlignAbsolute)) 457 457 value = QString::fromLatin1("left"); 458 else if ( format.alignment()== (Qt::AlignRight | Qt::AlignAbsolute))458 else if (alignment == (Qt::AlignRight | Qt::AlignAbsolute)) 459 459 value = QString::fromLatin1("right"); 460 else if ( format.alignment()== Qt::AlignHCenter)460 else if (alignment == Qt::AlignHCenter) 461 461 value = QString::fromLatin1("center"); 462 else if ( format.alignment()== Qt::AlignJustify)462 else if (alignment == Qt::AlignJustify) 463 463 value = QString::fromLatin1("justify"); 464 464 else … … 478 478 writer.writeAttribute(foNS, QString::fromLatin1("margin-right"), pixelToPoint(qMax(qreal(0.), format.rightMargin())) ); 479 479 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())); 481 481 if (format.hasProperty(QTextFormat::PageBreakPolicy)) { 482 482 if (format.pageBreakPolicy() & QTextFormat::PageBreak_AlwaysBefore) … … 484 484 if (format.pageBreakPolicy() & QTextFormat::PageBreak_AlwaysAfter) 485 485 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()); 486 490 } 487 491 if (format.hasProperty(QTextFormat::BlockNonBreakableLines)) … … 552 556 } 553 557 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())); 555 559 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())); 557 561 if (format.hasProperty(QTextFormat::FontUnderline)) 558 562 writer.writeAttribute(styleNS, QString::fromLatin1("text-underline-type"), … … 611 615 if (format.hasProperty(QTextFormat::ForegroundBrush)) { 612 616 QBrush brush = format.foreground(); 613 // TODO614 617 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()); 615 622 } 616 623 … … 625 632 QTextListFormat::Style style = format.style(); 626 633 if (style == QTextListFormat::ListDecimal || style == QTextListFormat::ListLowerAlpha 627 || style == QTextListFormat::ListUpperAlpha) { 634 || style == QTextListFormat::ListUpperAlpha 635 || style == QTextListFormat::ListLowerRoman 636 || style == QTextListFormat::ListUpperRoman) { 628 637 writer.writeStartElement(textNS, QString::fromLatin1("list-level-style-number")); 629 638 writer.writeAttribute(styleNS, QString::fromLatin1("num-format"), bulletChar(style));
Note:
See TracChangeset
for help on using the changeset viewer.