Commit 989b2632 authored by Thorsten Zachmann's avatar Thorsten Zachmann
Browse files

Fix 275376 - Indent of first line in list wrong

Thanks to Matus Uzak for providing the updates to the mswords filter
which are part of the patch.

BUG: 275376
parent 8410a5c8
......@@ -581,16 +581,20 @@ void Paragraph::applyParagraphProperties(const wvWare::ParagraphProperties& prop
//dxaLeft = indent from left margin (signed)
//dxaRight = indent from right margin (signed)
if (!refPap || refPap->dxaLeft != pap.dxaLeft) {
// apply twip -> pt conversion
style->addPropertyPt("fo:margin-left", (double)pap.dxaLeft / 20.0, KoGenStyle::ParagraphType);
// apply twip -> pt conversion, only if not in a list
if (pap.ilfo == 0) {
style->addPropertyPt("fo:margin-left", (double)pap.dxaLeft / 20.0, KoGenStyle::ParagraphType);
}
}
if (!refPap || refPap->dxaRight != pap.dxaRight) {
// apply twip -> pt conversion
style->addPropertyPt("fo:margin-right", (double)pap.dxaRight / 20.0, KoGenStyle::ParagraphType);
}
if (!refPap || refPap->dxaLeft1 != pap.dxaLeft1) {
// apply twip -> pt conversion
style->addPropertyPt("fo:text-indent", (double)pap.dxaLeft1 / 20.0, KoGenStyle::ParagraphType);
// apply twip -> pt conversion, only if not in a list
if (pap.ilfo == 0) {
style->addPropertyPt("fo:text-indent", (double)pap.dxaLeft1 / 20.0, KoGenStyle::ParagraphType);
}
}
//dyaBefore = vertical spacing before paragraph (unsigned)
......@@ -716,9 +720,9 @@ void Paragraph::applyParagraphProperties(const wvWare::ParagraphProperties& prop
//TODO: introduce diff for tabs too like in: if(!refPap || refPap->fKeep != pap
// Tabulators
//itbdMac = number of tabs stops defined for paragraph. Must be >= 0 and <= 64.
if (pap.itbdMac) {
// Tabulators, only if not in a list. itbdMac = number of tabs stops
// defined for paragraph. Must be >= 0 and <= 64.
if (pap.itbdMac && (pap.ilfo == 0)) {
kDebug(30513) << "processing tab stops";
//looks like we need to write these out with an xmlwriter
QBuffer buf;
......
......@@ -52,10 +52,17 @@ public:
void addRunOfText(QString text, wvWare::SharedPtr<const wvWare::Word97::CHP> chp, QString fontName, const wvWare::StyleSheet& styles, bool addCompleteElement=false);
void openInnerParagraph();
void closeInnerParagraph();
void setParagraphProperties(wvWare::SharedPtr<const wvWare::ParagraphProperties> properties);
// Set the general named style that applies to this paragraph
/**
* Set the named style from the stylesheet that applies to this paragraph.
*/
void setParagraphStyle(const wvWare::Style* paragraphStyle);
/**
* Set the paragraph properties (PAP) that apply to this paragraph.
*/
void setParagraphProperties(wvWare::SharedPtr<const wvWare::ParagraphProperties> properties);
KoGenStyle* getOdfParagraphStyle();
bool containsPageNumberField() const {
return m_containsPageNumberField;
......
......@@ -826,7 +826,8 @@ void KWordTextHandler::paragraphStart(wvWare::SharedPtr<const wvWare::ParagraphP
}
//lists related logic
if (paragraphProperties->pap().ilfo == 0) {
qint16 ilfo = paragraphProperties->pap().ilfo;
if (ilfo == 0) {
// Not in a list at all in the word document, so check if we need to
// close one in the odt.
......@@ -836,7 +837,7 @@ void KWordTextHandler::paragraphStart(wvWare::SharedPtr<const wvWare::ParagraphP
//kDebug(30513) << "closing list " << m_currentListID;
closeList();
}
} else if (paragraphProperties->pap().ilfo > 0) {
} else if (ilfo > 0) {
// We're in a list in the word document.
//
......@@ -1995,10 +1996,33 @@ void KWordTextHandler::updateListStyle(const QString& textStyleName) throw(Inval
listStyleWriter.startElement("style:list-level-properties");
listStyleWriter.addAttribute("text:list-level-position-and-space-mode", "label-alignment");
listStyleWriter.startElement("style:list-level-label-alignment");
//fo:margin-left
listStyleWriter.addAttributePt("fo:margin-left", (double)pap.dxaLeft/20.0);
//fo:text-indent
listStyleWriter.addAttributePt("fo:text-indent", (double)pap.dxaLeft1/20.0);
// if (listInfo->indent()) {
// NOTE: According to lists.h, this should be the indent before the
// label. Sounds like fo:margin-left.
// listStyleWriter.addAttributePt("text:text-indent", listInfo->indent()/20.0);
// }
// if (listInfo->space()) {
// NOTE: This produces wrong results (see the document attached to KDE
// bug 244411 and it's not clear why that is so. The specs say that
// the dxaSpace is the "minimum space between number and paragraph"
// and as such following should be right but it is not. So, we
// disabled it for now till someone has an idea why that is so.
// listStyleWriter.addAttributePt("text:min-label-distance", listInfo->space()/20.0);
// }
//text:label-followed-by
switch (listInfo->followingChar()) {
case 0:
listStyleWriter.addAttribute("text:label-followed-by", "listtab");
//text:list-tab-stop-position
#if 0 // as we already save the fo:margin-left this is wrong and should not be used.
listStyleWriter.addAttribute("text:list-tab-stop-position", (double)pap.dxaLeft/20.0);
#endif
break;
case 1:
listStyleWriter.addAttribute("text:label-followed-by", "nothing");
......@@ -2010,17 +2034,6 @@ void KWordTextHandler::updateListStyle(const QString& textStyleName) throw(Inval
break;
}
if (listInfo->space()) {
// This produces wrong results (see the document attached to KDE
// bug 244411 and it's not clear why that is so. The specs say that
// the dxaSpace is the "minimum space between number and paragraph"
// and as such following should be right but it is not. So, we
// disabled it for now till someone has an idea why that is so.
// listStyleWriter.addAttributePt("text:min-label-distance", listInfo->space()/20.0);
}
if (listInfo->indent()) {
listStyleWriter.addAttributePt("text:text-indent", listInfo->indent()/20.0);
}
listStyleWriter.endElement(); //style:list-level-label-alignment
listStyleWriter.endElement(); //style:list-level-properties
//close element
......@@ -2149,10 +2162,18 @@ void KWordTextHandler::updateListStyle(const QString& textStyleName) throw(Inval
}
listStyleWriter.startElement("style:list-level-label-alignment");
//fo:margin-left
listStyleWriter.addAttributePt("fo:margin-left", (double)pap.dxaLeft/20.0);
//fo:text-indent
listStyleWriter.addAttributePt("fo:text-indent", (double)pap.dxaLeft1/20.0);
//text:label-followed-by
switch (listInfo->followingChar()) {
case 0:
listStyleWriter.addAttribute("text:label-followed-by", "listtab");
//text:list-tab-stop-position
#if 0 // as we already save the fo:margin-left this is wrong and should not be used.
listStyleWriter.addAttribute("text:list-tab-stop-position", (double)pap.dxaLeft/20.0);
#endif
break;
case 1:
listStyleWriter.addAttribute("text:label-followed-by", "nothing");
......@@ -2164,13 +2185,14 @@ void KWordTextHandler::updateListStyle(const QString& textStyleName) throw(Inval
break;
}
if (listInfo->space()) {
// Disabled for now. Have a look at the comment at the other text:min-label-distance above to see why.
//listStyleWriter.addAttributePt("text:min-label-distance", listInfo->space()/20.0);
}
if (listInfo->indent()) {
listStyleWriter.addAttributePt("text:text-indent", listInfo->indent()/20.0);
}
//NOTE: Disabled for now. Have a look at the comment at the other
//text:min-label-distance and text-indent above to see why.
// if (listInfo->space()) {
// listStyleWriter.addAttributePt("text:min-label-distance", listInfo->space()/20.0);
// }
// if (listInfo->indent()) {
// listStyleWriter.addAttributePt("text:text-indent", listInfo->indent()/20.0);
// }
listStyleWriter.endElement(); //style:list-level-label-alignment
listStyleWriter.endElement(); //style:list-level-properties
//close element
......
......@@ -670,9 +670,13 @@ void KoListLevelProperties::loadOdf(KoShapeLoadingContext& scontext, const KoXml
setLabelFollowedBy(KoListStyle::ListTab);
// list tab position is evaluated only if label is followed by listtab
// the it is only evaluated if there is a list-tab-stop-position specified
// if not specified use the fo:margin-left:
QString tabStop(p.attributeNS(KoXmlNS::text, "list-tab-stop-position"));
qreal tabStopPos = tabStop.isEmpty() ? 0 : KoUnit::parseValue(tabStop);
setTabStopPosition(qMax<qreal>(0.0, tabStopPos));
if (!tabStop.isEmpty()) {
qreal tabStopPos = KoUnit::parseValue(tabStop);
setTabStopPosition(qMax<qreal>(0.0, tabStopPos));
}
}else if(labelFollowedBy.compare("nothing",Qt::CaseInsensitive)==0) {
......
......@@ -856,25 +856,30 @@ bool KoTextLayoutArea::layoutBlock(FrameIterator *cursor)
if (textList && textList->format().boolProperty(KoListStyle::AlignmentMode)) {
if (block.blockFormat().intProperty(KoListStyle::LabelFollowedBy) == KoListStyle::ListTab) {
qreal listTab = textList->format().doubleProperty(KoListStyle::TabStopPosition);
if (!m_documentLayout->relativeTabs()) {
listTab += leftMargin + m_indent;
} else {
listTab -= leftMargin + m_indent; // express it relatively like other tabs
}
if (textList->format().hasProperty(KoListStyle::TabStopPosition)) {
qreal listTab = textList->format().doubleProperty(KoListStyle::TabStopPosition);
if (!m_documentLayout->relativeTabs()) {
listTab += leftMargin + m_indent;
} else {
listTab -= leftMargin + m_indent; // express it relatively like other tabs
}
foreach(KoText::Tab tab, tabs) {
qreal position = tab.position * 72. / qt_defaultDpiY();
if (position > listLabelIndent) {
// found the relevant normal tab
if (position > listTab && listTab > listLabelIndent) {
// But special tab is more relevant
position = listTab;
foreach(KoText::Tab tab, tabs) {
qreal position = tab.position * 72. / qt_defaultDpiY();
if (position > listLabelIndent) {
// found the relevant normal tab
if (position > listTab && listTab > listLabelIndent) {
// But special tab is more relevant
position = listTab;
}
m_indent += position;
break;
}
m_indent += position;
break;
}
}
else {
m_indent = 0;
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment