From: Fridrich S. <str...@us...> - 2005-08-25 14:34:53
|
Update of /cvsroot/libwpd/libwpd2/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28252/src/lib Modified Files: WP3HLListener.cpp WP3HLListener.h WP42HLListener.cpp WP42HLListener.h WP5HLListener.cpp WP5HLListener.h WP6FileStructure.h WP6HLContentListener.cpp WP6HLContentListener.h WP6HLStylesListener.h WP6TabGroup.cpp WPXHLListener.cpp WPXHLListener.h libwpd_internal.cpp libwpd_internal.h Log Message: Merging fs_refactoring1 to HEAD Index: WP6FileStructure.h =================================================================== RCS file: /cvsroot/libwpd/libwpd2/src/lib/WP6FileStructure.h,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** WP6FileStructure.h 18 Jun 2005 06:52:42 -0000 1.42 --- WP6FileStructure.h 25 Aug 2005 14:34:42 -0000 1.43 *************** *** 33,39 **** #define WP6_NUM_LIST_LEVELS 8 - /* Misc. Junk */ - #define WP6_NUM_EXTRA_WPU 19 - /* header defines */ #define WP6_HEADER_DOCUMENT_SIZE_OFFSET 20 --- 33,36 ---- *************** *** 84,88 **** #define WP6_INDEX_HEADER_OUTLINE_STYLE_LOWERCASE_ROMAN_NUMBERING 3 #define WP6_INDEX_HEADER_OUTLINE_STYLE_UPPERCASE_ROMAN_NUMBERING 4 - #define WP6_NUM_LIST_LEVELS 8 #define WP6_VARIABLE_GROUP_PREFIX_ID_BIT 128 /* bit 7 */ --- 81,84 ---- Index: WP6HLContentListener.h =================================================================== RCS file: /cvsroot/libwpd/libwpd2/src/lib/WP6HLContentListener.h,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** WP6HLContentListener.h 8 Feb 2005 16:02:53 -0000 1.44 --- WP6HLContentListener.h 25 Aug 2005 14:34:42 -0000 1.45 *************** *** 2,5 **** --- 2,6 ---- * Copyright (C) 2002 William Lachance (wil...@sy...) * Copyright (C) 2002 Marc Maurer (j.m...@st...) + * Copyright (C) 2005 Fridrich Strba (fri...@bl...) * * This library is free software; you can redistribute it and/or *************** *** 46,49 **** --- 47,52 ---- BEGIN_AFTER_NUMBERING, STYLE_BODY, STYLE_END }; + enum WP6ListType { ORDERED, UNORDERED }; + const int STATE_MEMORY = 3; class WP6StyleStateSequence *************** *** 78,81 **** --- 81,87 ---- int m_numRemovedParagraphBreaks; + + int m_numListExtraTabs; + bool m_isListReference; WPXTableList m_tableList; *************** *** 84,90 **** std::stack<int> m_listLevelStack; uint16_t m_currentOutlineHash; // probably should replace Hash with Key in these sorts of cases uint8_t m_oldListLevel; - uint8_t m_currentListLevel; WP6StyleStateSequence m_styleStateSequence; bool m_putativeListElementHasParagraphNumber; --- 90,96 ---- std::stack<int> m_listLevelStack; + std::stack<WP6ListType> m_listTypeStack; uint16_t m_currentOutlineHash; // probably should replace Hash with Key in these sorts of cases uint8_t m_oldListLevel; WP6StyleStateSequence m_styleStateSequence; bool m_putativeListElementHasParagraphNumber; *************** *** 187,199 **** //void _handleLineBreakElementBegin(); void _paragraphNumberOn(const uint16_t outlineHash, const uint8_t level); ! void _flushText(const bool fakeText=false); void _handleListChange(const uint16_t outlineHash); ! void _flushList(); private: WP6ParsingState *m_parseState; ! std::map<int,WP6OutlineDefinition *> m_outlineDefineHash; }; --- 193,205 ---- //void _handleLineBreakElementBegin(); void _paragraphNumberOn(const uint16_t outlineHash, const uint8_t level); ! void _flushText(); void _handleListChange(const uint16_t outlineHash); ! void _changeList(); private: WP6ParsingState *m_parseState; ! std::map<uint16_t,WP6OutlineDefinition *> m_outlineDefineHash; }; Index: libwpd_internal.cpp =================================================================== RCS file: /cvsroot/libwpd/libwpd2/src/lib/libwpd_internal.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** libwpd_internal.cpp 21 Jun 2005 10:09:14 -0000 1.16 --- libwpd_internal.cpp 25 Aug 2005 14:34:42 -0000 1.17 *************** *** 825,830 **** uint8_t characterSet, const uint16_t **chars) { - int i; - if (characterSet == 0) { --- 825,828 ---- Index: libwpd_internal.h =================================================================== RCS file: /cvsroot/libwpd/libwpd2/src/lib/libwpd_internal.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** libwpd_internal.h 15 Jun 2005 12:18:28 -0000 1.14 --- libwpd_internal.h 25 Aug 2005 14:34:42 -0000 1.15 *************** *** 93,98 **** enum WPXTextColumnType { NEWSPAPER, NEWSPAPER_VERTICAL_BALANCE, PARALLEL, PARALLEL_PROTECT }; - const float WPX_DEFAULT_LIST_INDENT = 0.2f; // default list indent per level - // ATTRIBUTE bits #define WPX_EXTRA_LARGE_BIT 1 --- 93,96 ---- Index: WP3HLListener.h =================================================================== RCS file: /cvsroot/libwpd/libwpd2/src/lib/WP3HLListener.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** WP3HLListener.h 8 Feb 2005 16:02:49 -0000 1.15 --- WP3HLListener.h 25 Aug 2005 14:34:42 -0000 1.16 *************** *** 78,83 **** private: ! void _flushText(const bool fakeText=false); ! void _flushList() {}; WPXString m_textBuffer; --- 78,83 ---- private: ! void _flushText(); ! void _changeList() {}; WPXString m_textBuffer; Index: WP42HLListener.h =================================================================== RCS file: /cvsroot/libwpd/libwpd2/src/lib/WP42HLListener.h,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** WP42HLListener.h 8 Feb 2005 16:02:50 -0000 1.34 --- WP42HLListener.h 25 Aug 2005 14:34:42 -0000 1.35 *************** *** 71,76 **** private: ! void _flushText(const bool fakeText=false); ! void _flushList() {}; WPXString m_textBuffer; --- 71,76 ---- private: ! void _flushText(); ! void _changeList() {}; WPXString m_textBuffer; Index: WP5HLListener.h =================================================================== RCS file: /cvsroot/libwpd/libwpd2/src/lib/WP5HLListener.h,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** WP5HLListener.h 8 Feb 2005 16:02:51 -0000 1.35 --- WP5HLListener.h 25 Aug 2005 14:34:42 -0000 1.36 *************** *** 78,83 **** private: ! void _flushText(const bool fakeText=false); ! void _flushList() {}; WPXString m_textBuffer; --- 78,83 ---- private: ! void _flushText(); ! void _changeList() {}; WPXString m_textBuffer; Index: WP3HLListener.cpp =================================================================== RCS file: /cvsroot/libwpd/libwpd2/src/lib/WP3HLListener.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** WP3HLListener.cpp 8 Feb 2005 16:02:48 -0000 1.13 --- WP3HLListener.cpp 25 Aug 2005 14:34:42 -0000 1.14 *************** *** 1,5 **** /* libwpd * Copyright (C) 2004 Marc Maurer (j.m...@st...) ! * Copyright (C) 2004 Fridrich Strba (fri...@bl...) * * This library is free software; you can redistribute it and/or --- 1,5 ---- /* libwpd * Copyright (C) 2004 Marc Maurer (j.m...@st...) ! * Copyright (C) 2004-2005 Fridrich Strba (fri...@bl...) * * This library is free software; you can redistribute it and/or *************** *** 58,62 **** --- 58,66 ---- { if (!isUndoOn()) + { + if (!m_ps->m_isSpanOpened) + _openSpan(); appendUCS4(m_textBuffer, (uint32_t)character); + } } *************** *** 65,69 **** if (!isUndoOn()) { ! _flushText(); m_listenerImpl->insertTab(); } --- 69,76 ---- if (!isUndoOn()) { ! if (!m_ps->m_isSpanOpened) ! _openSpan(); ! else ! _flushText(); m_listenerImpl->insertTab(); } *************** *** 72,105 **** void WP3HLListener::insertEOL() { ! if (!isUndoOn()) { ! _flushText(); ! m_ps->m_numDeferredParagraphBreaks++; } } void WP3HLListener::endDocument() { ! // corner case: document ends in a list element ! /*if (m_parseState->m_styleStateSequence.getCurrentState() != NORMAL) ! { ! _flushText(); // flush the list text ! m_parseState->m_styleStateSequence.setCurrentState(NORMAL); ! _flushText(true); // flush the list exterior (forcing a line break, to make _flushText think we've exited a list) ! }*/ ! // corner case: document contains no end of lines ! /*else*/ if (!m_ps->m_isParagraphOpened && !m_ps->m_isParagraphClosed) ! { ! _flushText(); ! } ! // NORMAL(ish) case document ends either inside a paragraph or outside of one, ! // but not inside an object ! else if (!m_ps->m_isParagraphClosed || !m_ps->m_isParagraphOpened) ! { ! _flushText(); ! } ! // the only other possibility is a logical contradiction: a paragraph ! // may not be opened and closed at the same time ! // close the document nice and tight _closeSection(); _closePageSpan(); --- 79,98 ---- void WP3HLListener::insertEOL() { ! if (!isUndoOn()) { ! if (!m_ps->m_isParagraphOpened && !m_ps->m_isListElementOpened) ! _openSpan(); ! if (m_ps->m_isParagraphOpened) ! _closeParagraph(); ! if (m_ps->m_isListElementOpened) ! _closeListElement(); } + } void WP3HLListener::endDocument() { ! _closeSpan(); ! _closeParagraph(); _closeSection(); _closePageSpan(); *************** *** 116,121 **** if (!isUndoOn()) { ! // flush everything which came before this change ! _flushText(); uint32_t textAttributeBit = 0; --- 109,113 ---- if (!isUndoOn()) { ! _closeSpan(); uint32_t textAttributeBit = 0; *************** *** 178,183 **** else m_ps->m_textAttributeBits ^= textAttributeBit; - - m_ps->m_textAttributesChanged = true; } } --- 170,173 ---- *************** *** 236,278 **** *****************************************/ ! void WP3HLListener::_flushText(const bool fakeText) { - // create a new section, and a new paragraph, if our section attributes have changed and we have inserted - // something into the document (or we have forced a break, which assumes the same condition) - if (m_ps->m_sectionAttributesChanged && (m_textBuffer.len() > 0 || m_ps->m_numDeferredParagraphBreaks > 0 /*|| fakeText*/)) - { - _openSection(); - //if (fakeText) - _openParagraph(); - } - - if (m_ps->m_numDeferredParagraphBreaks > 0) - { - if (!m_ps->m_isParagraphOpened //&& - // !(m_parseState->m_isTableOpened && !m_parseState->m_isTableCellOpened) // don't allow paragraphs to be opened when we have already opened a table, but no cell yet. - MARCM (is it really correct, or should this be fixed elsewhere??) - ) - m_ps->m_numDeferredParagraphBreaks++; - - while (m_ps->m_numDeferredParagraphBreaks > 1) - _openParagraph(); - _closeParagraph(); - m_ps->m_numDeferredParagraphBreaks = 0; // compensate for this by requiring a paragraph to be opened - } - else if (m_ps->m_textAttributesChanged && m_textBuffer.len()) - { - _openSpan(); - m_ps->m_textAttributesChanged = false; - } - if (m_textBuffer.len()) - { - if (!m_ps->m_isParagraphOpened) - { - _openParagraph(); - _openSpan(); - } - m_listenerImpl->insertText(m_textBuffer); ! m_textBuffer.clear(); ! } } --- 226,233 ---- *****************************************/ ! void WP3HLListener::_flushText() { if (m_textBuffer.len()) m_listenerImpl->insertText(m_textBuffer); ! m_textBuffer.clear(); } Index: WP5HLListener.cpp =================================================================== RCS file: /cvsroot/libwpd/libwpd2/src/lib/WP5HLListener.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** WP5HLListener.cpp 8 Feb 2005 16:02:50 -0000 1.32 --- WP5HLListener.cpp 25 Aug 2005 14:34:42 -0000 1.33 *************** *** 2,5 **** --- 2,6 ---- * Copyright (C) 2003 William Lachance (wil...@sy...) * Copyright (C) 2003 Marc Maurer (j.m...@st...) + * Copyright (C) 2005 Fridrich Strba (fri...@bl...) * * This library is free software; you can redistribute it and/or *************** *** 57,60 **** --- 58,63 ---- void WP5HLListener::insertCharacter(const uint16_t character) { + if (!m_ps->m_isSpanOpened) + _openSpan(); appendUCS4(m_textBuffer, (uint32_t)character); } *************** *** 62,66 **** void WP5HLListener::insertTab(const uint8_t tabType, const float tabPosition) { ! _flushText(); m_listenerImpl->insertTab(); } --- 65,73 ---- void WP5HLListener::insertTab(const uint8_t tabType, const float tabPosition) { ! if (!m_ps->m_isSpanOpened) ! _openSpan(); ! else ! _flushText(); ! m_listenerImpl->insertTab(); } *************** *** 68,100 **** void WP5HLListener::insertEOL() { ! _flushText(); ! m_ps->m_numDeferredParagraphBreaks++; } void WP5HLListener::endDocument() { ! // corner case: document ends in a list element ! /*if (m_parseState->m_styleStateSequence.getCurrentState() != NORMAL) ! { ! _flushText(); // flush the list text ! m_parseState->m_styleStateSequence.setCurrentState(NORMAL); ! _flushText(true); // flush the list exterior (forcing a line break, to make _flushText think we've exited a list) ! }*/ ! // corner case: document contains no end of lines ! /*else*/ if (!m_ps->m_isParagraphOpened && !m_ps->m_isParagraphClosed) ! { ! _flushText(); ! } ! // NORMAL(ish) case document ends either inside a paragraph or outside of one, ! // but not inside an object ! else if (!m_ps->m_isParagraphClosed || !m_ps->m_isParagraphOpened) ! { ! _flushText(); ! } ! ! // the only other possibility is a logical contradiction: a paragraph ! // may not be opened and closed at the same time ! ! // close the document nice and tight _closeSection(); _closePageSpan(); --- 75,93 ---- void WP5HLListener::insertEOL() { ! if (!isUndoOn()) ! { ! if (!m_ps->m_isParagraphOpened && !m_ps->m_isListElementOpened) ! _openSpan(); ! if (m_ps->m_isParagraphOpened) ! _closeParagraph(); ! if (m_ps->m_isListElementOpened) ! _closeListElement(); ! } } void WP5HLListener::endDocument() { ! _closeSpan(); ! _closeParagraph(); _closeSection(); _closePageSpan(); *************** *** 109,115 **** void WP5HLListener::attributeChange(const bool isOn, const uint8_t attribute) { ! ! // flush everything which came before this change ! _flushText(); uint32_t textAttributeBit = 0; --- 102,106 ---- void WP5HLListener::attributeChange(const bool isOn, const uint8_t attribute) { ! _closeSpan(); uint32_t textAttributeBit = 0; *************** *** 172,177 **** else m_ps->m_textAttributeBits ^= textAttributeBit; - - m_ps->m_textAttributesChanged = true; } --- 163,166 ---- *************** *** 206,248 **** *****************************************/ ! void WP5HLListener::_flushText(const bool fakeText) { - // create a new section, and a new paragraph, if our section attributes have changed and we have inserted - // something into the document (or we have forced a break, which assumes the same condition) - if (m_ps->m_sectionAttributesChanged && (m_textBuffer.len() > 0 || m_ps->m_numDeferredParagraphBreaks > 0/* || fakeText*/)) - { - _openSection(); - //if (fakeText) - _openParagraph(); - } - - if (m_ps->m_numDeferredParagraphBreaks > 0) - { - if (!m_ps->m_isParagraphOpened //&& - // !(m_parseState->m_isTableOpened && !m_parseState->m_isTableCellOpened) // don't allow paragraphs to be opened when we have already opened a table, but no cell yet. - MARCM (is it really correct, or should this be fixed elsewhere??) - ) - m_ps->m_numDeferredParagraphBreaks++; - - while (m_ps->m_numDeferredParagraphBreaks > 1) - _openParagraph(); - _closeParagraph(); - m_ps->m_numDeferredParagraphBreaks = 0; // compensate for this by requiring a paragraph to be opened - } - else if (m_ps->m_textAttributesChanged && m_textBuffer.len()) - { - _openSpan(); - m_ps->m_textAttributesChanged = false; - } - if (m_textBuffer.len()) - { - if (!m_ps->m_isParagraphOpened) - { - _openParagraph(); - _openSpan(); - } - m_listenerImpl->insertText(m_textBuffer); ! m_textBuffer.clear(); ! } } --- 195,203 ---- *****************************************/ ! void WP5HLListener::_flushText() { if (m_textBuffer.len()) m_listenerImpl->insertText(m_textBuffer); ! m_textBuffer.clear(); } + Index: WPXHLListener.cpp =================================================================== RCS file: /cvsroot/libwpd/libwpd2/src/lib/WPXHLListener.cpp,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** WPXHLListener.cpp 6 Apr 2005 07:24:38 -0000 1.61 --- WPXHLListener.cpp 25 Aug 2005 14:34:42 -0000 1.62 *************** *** 39,45 **** #endif ! _WPXParsingState::_WPXParsingState(bool sectionAttributesChanged) : m_textAttributeBits(0), - m_textAttributesChanged(false), m_fontSize(12.0f/*WP6_DEFAULT_FONT_SIZE*/), // FIXME ME!!!!!!!!!!!!!!!!!!! HELP WP6_DEFAULT_FONT_SIZE m_fontName(new WPXString(/*WP6_DEFAULT_FONT_NAME*/"Times New Roman")), // EN PAS DEFAULT FONT AAN VOOR WP5/6/etc --- 39,44 ---- #endif ! _WPXParsingState::_WPXParsingState() : m_textAttributeBits(0), m_fontSize(12.0f/*WP6_DEFAULT_FONT_SIZE*/), // FIXME ME!!!!!!!!!!!!!!!!!!! HELP WP6_DEFAULT_FONT_SIZE m_fontName(new WPXString(/*WP6_DEFAULT_FONT_NAME*/"Times New Roman")), // EN PAS DEFAULT FONT AAN VOOR WP5/6/etc *************** *** 53,65 **** m_tempParagraphJustification(0), m_isSectionOpened(false), m_isPageSpanBreakDeferred(false), m_isParagraphOpened(false), - m_isParagraphClosed(false), m_isListElementOpened(false), - m_isListElementClosed(false), - m_isSpanOpened(false), - m_numDeferredParagraphBreaks(0), m_currentTableCol(0), --- 52,63 ---- m_tempParagraphJustification(0), + m_isDocumentStarted(false), + m_isPageSpanOpened(false), m_isSectionOpened(false), m_isPageSpanBreakDeferred(false), + m_isSpanOpened(false), m_isParagraphOpened(false), m_isListElementOpened(false), m_currentTableCol(0), *************** *** 73,81 **** m_paragraphJustificationBeforeTable(WPX_PARAGRAPH_JUSTIFICATION_LEFT), - m_isPageSpanOpened(false), m_nextPageSpanIndice(0), m_numPagesRemainingInSpan(0), ! m_sectionAttributesChanged(sectionAttributesChanged), m_numColumns(1), m_isTextColumnWithoutParagraph(false), --- 71,78 ---- m_paragraphJustificationBeforeTable(WPX_PARAGRAPH_JUSTIFICATION_LEFT), m_nextPageSpanIndice(0), m_numPagesRemainingInSpan(0), ! m_sectionAttributesChanged(false), m_numColumns(1), m_isTextColumnWithoutParagraph(false), *************** *** 98,115 **** m_leftMarginByTabs(0.0f), m_rightMarginByTabs(0.0f), m_paragraphTextIndent(0.0f), m_textIndentByParagraphIndentChange(0.0f), m_textIndentByTabs(0.0f), - #if 0 m_currentListLevel(0), m_putativeListElementHasParagraphNumber(false), m_putativeListElementHasDisplayReferenceNumber(false), m_noteTextPID(0), - m_inSubDocument(false) #endif m_alignmentCharacter('.'), ! m_isTabPositionRelative(false) { } --- 95,116 ---- m_leftMarginByTabs(0.0f), m_rightMarginByTabs(0.0f), + + m_listReferencePosition(0.0f), + m_listBeginPosition(0.0f), m_paragraphTextIndent(0.0f), m_textIndentByParagraphIndentChange(0.0f), m_textIndentByTabs(0.0f), m_currentListLevel(0), + #if 0 m_putativeListElementHasParagraphNumber(false), m_putativeListElementHasDisplayReferenceNumber(false), m_noteTextPID(0), #endif m_alignmentCharacter('.'), ! m_isTabPositionRelative(false), ! m_inSubDocument(false), ! m_isNote(false) { } *************** *** 138,197 **** void WPXHLListener::startDocument() { ! // FIXME: this is stupid, we should store a property list filled with the relevant metadata ! // and then pass that directly.. ! m_listenerImpl->setDocumentMetaData(m_metaData); ! m_listenerImpl->startDocument(); ! _openPageSpan(); } void WPXHLListener::_openSection() { ! _closeSection(); ! WPXPropertyList propList; ! if (m_ps->m_numColumns > 1) ! { ! propList.insert("fo:margin-bottom", 1.0f); ! propList.insert("text:dont-balance-text-columns", false); ! } ! else ! propList.insert("fo:margin-bottom", 0.0f); ! WPXPropertyListVector columns; ! typedef std::vector<WPXColumnDefinition>::const_iterator CDVIter; ! for (CDVIter iter = m_ps->m_textColumns.begin(); iter != m_ps->m_textColumns.end(); iter++) ! { ! WPXPropertyList column; ! // The "style:rel-width" is expressed in twips (1440 twips per inch) and includes the left and right Gutter ! column.insert("style:rel-width", (*iter).m_width * 1440.0f, TWIP); ! column.insert("fo:margin-left", (*iter).m_leftGutter); ! column.insert("fo:margin-right", (*iter).m_rightGutter); ! columns.append(column); ! } ! m_listenerImpl->openSection(propList, columns); ! m_ps->m_sectionAttributesChanged = false; ! m_ps->m_isSectionOpened = true; } void WPXHLListener::_closeSection() { - _closeParagraph(); if (m_ps->m_isSectionOpened) m_listenerImpl->closeSection(); m_ps->m_isSectionOpened = false; } void WPXHLListener::_openPageSpan() { ! _closePageSpan(); // Hack to be sure that the paragraph margins are consistent even if the page margin changes m_ps->m_leftMarginByPageMarginChange += m_ps->m_pageMarginLeft; m_ps->m_rightMarginByPageMarginChange += m_ps->m_pageMarginRight; if ( !m_pageList || --- 139,222 ---- void WPXHLListener::startDocument() { ! if (!m_ps->m_isDocumentStarted) ! { ! // FIXME: this is stupid, we should store a property list filled with the relevant metadata ! // and then pass that directly.. ! m_listenerImpl->setDocumentMetaData(m_metaData); ! m_listenerImpl->startDocument(); ! } ! ! m_ps->m_isDocumentStarted = true; } void WPXHLListener::_openSection() { ! if (!m_ps->m_isSectionOpened) ! { ! if (!m_ps->m_isPageSpanOpened) ! _openPageSpan(); ! WPXPropertyList propList; ! if (m_ps->m_numColumns > 1) ! { ! propList.insert("fo:margin-bottom", 1.0f); ! propList.insert("text:dont-balance-text-columns", false); ! } ! else ! propList.insert("fo:margin-bottom", 0.0f); ! WPXPropertyListVector columns; ! typedef std::vector<WPXColumnDefinition>::const_iterator CDVIter; ! for (CDVIter iter = m_ps->m_textColumns.begin(); iter != m_ps->m_textColumns.end(); iter++) ! { ! WPXPropertyList column; ! // The "style:rel-width" is expressed in twips (1440 twips per inch) and includes the left and right Gutter ! column.insert("style:rel-width", (*iter).m_width * 1440.0f, TWIP); ! column.insert("fo:margin-left", (*iter).m_leftGutter); ! column.insert("fo:margin-right", (*iter).m_rightGutter); ! columns.append(column); ! } ! if (!m_ps->m_isSectionOpened) ! m_listenerImpl->openSection(propList, columns); ! m_ps->m_sectionAttributesChanged = false; ! m_ps->m_isSectionOpened = true; ! } } void WPXHLListener::_closeSection() { if (m_ps->m_isSectionOpened) + { + if (m_ps->m_isParagraphOpened) + _closeParagraph(); + if (m_ps->m_isListElementOpened) + _closeListElement(); + _changeList(); + m_listenerImpl->closeSection(); + m_ps->m_sectionAttributesChanged = false; + } m_ps->m_isSectionOpened = false; + } void WPXHLListener::_openPageSpan() { ! if (m_ps->m_isPageSpanOpened) ! return; ! ! if (!m_ps->m_isDocumentStarted) ! startDocument(); // Hack to be sure that the paragraph margins are consistent even if the page margin changes m_ps->m_leftMarginByPageMarginChange += m_ps->m_pageMarginLeft; m_ps->m_rightMarginByPageMarginChange += m_ps->m_pageMarginRight; + m_ps->m_listReferencePosition += m_ps->m_pageMarginLeft; + m_ps->m_listBeginPosition += m_ps->m_pageMarginLeft; if ( !m_pageList || *************** *** 221,225 **** propList.insert("fo:margin-bottom", currentPage->getMarginBottom()); ! m_listenerImpl->openPageSpan(propList); m_ps->m_pageFormWidth = currentPage->getFormWidth(); --- 246,253 ---- propList.insert("fo:margin-bottom", currentPage->getMarginBottom()); ! if (!m_ps->m_isPageSpanOpened) ! m_listenerImpl->openPageSpan(propList); ! ! m_ps->m_isPageSpanOpened = true; m_ps->m_pageFormWidth = currentPage->getFormWidth(); *************** *** 231,234 **** --- 259,264 ---- m_ps->m_leftMarginByPageMarginChange -= m_ps->m_pageMarginLeft; m_ps->m_rightMarginByPageMarginChange -= m_ps->m_pageMarginRight; + m_ps->m_listReferencePosition -= m_ps->m_pageMarginLeft; + m_ps->m_listBeginPosition -= m_ps->m_pageMarginLeft; m_ps->m_paragraphMarginLeft = m_ps->m_leftMarginByPageMarginChange + m_ps->m_leftMarginByParagraphMarginChange *************** *** 285,292 **** + m_ps->m_rightMarginByTabs; m_ps->m_numPagesRemainingInSpan = (currentPage->getPageSpan() - 1); m_ps->m_nextPageSpanIndice++; - m_ps->m_isPageSpanOpened = true; - _openSection(); } --- 315,322 ---- + m_ps->m_rightMarginByTabs; + m_ps->m_paragraphTextIndent = m_ps->m_textIndentByParagraphIndentChange + m_ps->m_textIndentByTabs; + m_ps->m_numPagesRemainingInSpan = (currentPage->getPageSpan() - 1); m_ps->m_nextPageSpanIndice++; } *************** *** 295,327 **** if (m_ps->m_isPageSpanOpened) { ! _closeSection(); m_listenerImpl->closePageSpan(); - m_ps->m_isPageSpanOpened = false; } } void WPXHLListener::_openParagraph() { ! if (m_ps->m_isListElementOpened) ! _flushList(); // If we are in a list, we should discontinue it ! else ! _closeParagraph(); ! ! WPXPropertyListVector tabStops; ! _getTabStops(tabStops); ! WPXPropertyList propList; ! _appendParagraphProperties(propList); ! m_listenerImpl->openParagraph(propList, tabStops); ! // this is paragraph-specific (handle breaks differently for ! // lists, which we otherwise treat the same) ! if (m_ps->m_numDeferredParagraphBreaks > 0) ! m_ps->m_numDeferredParagraphBreaks--; ! _resetParagraphState(); ! _openSpan(); } --- 325,365 ---- if (m_ps->m_isPageSpanOpened) { ! if (m_ps->m_isSectionOpened) ! _closeSection(); ! m_listenerImpl->closePageSpan(); } + + m_ps->m_isPageSpanOpened = false; + m_ps->m_isPageSpanBreakDeferred = false; } void WPXHLListener::_openParagraph() { ! if (m_ps->m_isTableOpened && !m_ps->m_isTableCellOpened) ! return; ! ! if (!m_ps->m_isParagraphOpened && !m_ps->m_isListElementOpened) ! { ! if (!m_ps->m_isTableOpened && !m_ps->m_inSubDocument) ! { ! if (m_ps->m_sectionAttributesChanged) ! _closeSection(); ! if (!m_ps->m_isSectionOpened) ! _openSection(); ! } ! WPXPropertyListVector tabStops; ! _getTabStops(tabStops); ! WPXPropertyList propList; ! _appendParagraphProperties(propList); ! if (!m_ps->m_isParagraphOpened) ! m_listenerImpl->openParagraph(propList, tabStops); ! _resetParagraphState(); ! } } *************** *** 345,352 **** m_ps->m_rightMarginByTabs = 0.0f; m_ps->m_paragraphTextIndent = m_ps->m_textIndentByParagraphIndentChange; ! m_ps->m_textIndentByTabs = 0.0f; m_ps->m_isCellWithoutParagraph = false; m_ps->m_isTextColumnWithoutParagraph = false; m_ps->m_tempParagraphJustification = 0; } --- 383,392 ---- m_ps->m_rightMarginByTabs = 0.0f; m_ps->m_paragraphTextIndent = m_ps->m_textIndentByParagraphIndentChange; ! m_ps->m_textIndentByTabs = 0.0f; m_ps->m_isCellWithoutParagraph = false; m_ps->m_isTextColumnWithoutParagraph = false; m_ps->m_tempParagraphJustification = 0; + m_ps->m_listReferencePosition = m_ps->m_paragraphMarginLeft + m_ps->m_paragraphTextIndent; + m_ps->m_listBeginPosition = m_ps->m_paragraphMarginLeft + m_ps->m_paragraphTextIndent; } *************** *** 375,379 **** } ! void WPXHLListener::_appendParagraphProperties(WPXPropertyList &propList) { int justification; --- 415,419 ---- } ! void WPXHLListener::_appendParagraphProperties(WPXPropertyList &propList, const bool isListElement) { int justification; *************** *** 384,394 **** _appendJustification(propList, justification); ! if (m_ps->m_numColumns == 1 && !m_ps->m_isTableOpened) { // these properties are not appropriate inside multiple columns or when ! // a table is opened.. ! propList.insert("fo:margin-left", m_ps->m_paragraphMarginLeft); propList.insert("fo:margin-right", m_ps->m_paragraphMarginRight); - propList.insert("fo:text-indent", m_ps->m_paragraphTextIndent); } propList.insert("fo:margin-top", m_ps->m_paragraphMarginTop); --- 424,442 ---- _appendJustification(propList, justification); ! if (m_ps->m_numColumns <= 1 && !m_ps->m_isTableOpened) { // these properties are not appropriate inside multiple columns or when ! // a table is opened.. ! if (isListElement) ! { ! propList.insert("fo:margin-left", (m_ps->m_listBeginPosition - m_ps->m_paragraphTextIndent)); ! propList.insert("fo:text-indent", m_ps->m_paragraphTextIndent); ! } ! else ! { ! propList.insert("fo:margin-left", m_ps->m_paragraphMarginLeft); ! propList.insert("fo:text-indent", m_ps->m_listReferencePosition - m_ps->m_paragraphMarginLeft); ! } propList.insert("fo:margin-right", m_ps->m_paragraphMarginRight); } propList.insert("fo:margin-top", m_ps->m_paragraphMarginTop); *************** *** 450,483 **** void WPXHLListener::_closeParagraph() { - _closeSpan(); if (m_ps->m_isParagraphOpened) m_listenerImpl->closeParagraph(); m_ps->m_isParagraphOpened = false; } void WPXHLListener::_openListElement() { ! _closeParagraph(); ! _closeListElement(); ! WPXPropertyList propList; ! _appendParagraphProperties(propList); ! WPXPropertyListVector tabStops; ! _getTabStops(tabStops); ! m_listenerImpl->openListElement(propList, tabStops); ! _resetParagraphState(true); ! _openSpan(); } void WPXHLListener::_closeListElement() { - _closeSpan(); if (m_ps->m_isListElementOpened) ! m_listenerImpl->closeListElement(); m_ps->m_isListElementOpened = false; } --- 498,544 ---- void WPXHLListener::_closeParagraph() { if (m_ps->m_isParagraphOpened) + { + if (m_ps->m_isSpanOpened) + _closeSpan(); + m_listenerImpl->closeParagraph(); + } m_ps->m_isParagraphOpened = false; + m_ps->m_currentListLevel = 0; } void WPXHLListener::_openListElement() { ! if (!m_ps->m_isParagraphOpened && !m_ps->m_isListElementOpened) ! { ! if (!m_ps->m_isTableOpened && !m_ps->m_isSectionOpened && !m_ps->m_inSubDocument) ! _openSection(); ! WPXPropertyList propList; ! _appendParagraphProperties(propList, true); ! WPXPropertyListVector tabStops; ! _getTabStops(tabStops); ! if (!m_ps->m_isListElementOpened) ! m_listenerImpl->openListElement(propList, tabStops); ! _resetParagraphState(true); ! } } void WPXHLListener::_closeListElement() { if (m_ps->m_isListElementOpened) ! { ! if (m_ps->m_isSpanOpened) ! _closeSpan(); + m_listenerImpl->closeListElement(); + } + m_ps->m_isListElementOpened = false; + m_ps->m_currentListLevel = 0; } *************** *** 486,490 **** void WPXHLListener::_openSpan() { ! _closeSpan(); // The behaviour of WP6+ is following: if an attribute bit is set in the cell attributes, we cannot // unset it; if it is set, we can set or unset it --- 547,560 ---- void WPXHLListener::_openSpan() { ! if (m_ps->m_isTableOpened && !m_ps->m_isTableCellOpened) ! return; ! ! if (!m_ps->m_isParagraphOpened && !m_ps->m_isListElementOpened) ! _changeList(); ! if (m_ps->m_currentListLevel == 0) ! _openParagraph(); ! else ! _openListElement(); ! // The behaviour of WP6+ is following: if an attribute bit is set in the cell attributes, we cannot // unset it; if it is set, we can set or unset it *************** *** 563,567 **** propList.insert("style:text-background-color", _colorToString(m_ps->m_highlightColor)); ! m_listenerImpl->openSpan(propList); m_ps->m_isSpanOpened = true; --- 633,638 ---- propList.insert("style:text-background-color", _colorToString(m_ps->m_highlightColor)); ! if (!m_ps->m_isSpanOpened) ! m_listenerImpl->openSpan(propList); m_ps->m_isSpanOpened = true; *************** *** 571,576 **** { if (m_ps->m_isSpanOpened) ! m_listenerImpl->closeSpan(); m_ps->m_isSpanOpened = false; } --- 642,651 ---- { if (m_ps->m_isSpanOpened) ! { ! _flushText(); + m_listenerImpl->closeSpan(); + } + m_ps->m_isSpanOpened = false; } *************** *** 579,583 **** { _closeTable(); ! WPXPropertyList propList; switch (m_ps->m_tableDefinition.m_positionBits) --- 654,658 ---- { _closeTable(); ! WPXPropertyList propList; switch (m_ps->m_tableDefinition.m_positionBits) *************** *** 607,610 **** --- 682,693 ---- } + // cater for the possibility to have the column/page break just before the table + if (m_ps->m_isParagraphPageBreak) + propList.insert("fo:break-before", "page"); + else if (m_ps->m_isParagraphColumnBreak) + propList.insert("fo:break-before", "column"); + m_ps->m_isParagraphColumnBreak = false; + m_ps->m_isParagraphPageBreak = false; + float tableWidth = 0.0f; WPXPropertyListVector columns; *************** *** 630,650 **** void WPXHLListener::_closeTable() { - _closeTableRow(); - if (m_ps->m_isTableOpened) { m_listenerImpl->closeTable(); - m_ps->m_currentTableRow = (-1); - m_ps->m_currentTableCol = (-1); } m_ps->m_isTableOpened = false; m_ps->m_wasHeaderRow = false; // handle case where page span is closed in the middle of a table ! if (m_ps->m_isPageSpanBreakDeferred) ! { ! _closePageSpan(); ! m_ps->m_isPageSpanBreakDeferred = false; ! } } --- 713,740 ---- void WPXHLListener::_closeTable() { if (m_ps->m_isTableOpened) { + if (m_ps->m_isTableRowOpened) + _closeTableRow(); + m_listenerImpl->closeTable(); } + + m_ps->m_currentTableRow = (-1); + m_ps->m_currentTableCol = (-1); m_ps->m_isTableOpened = false; m_ps->m_wasHeaderRow = false; + + _closeParagraph(); + _closeListElement(); + _changeList(); + // handle case where a section attributes changed in the middle of the table + if (m_ps->m_sectionAttributesChanged && !m_ps->m_inSubDocument) + _closeSection(); + // handle case where page span is closed in the middle of a table ! if (m_ps->m_isPageSpanBreakDeferred && !m_ps->m_inSubDocument) ! _closePageSpan(); } *************** *** 652,655 **** --- 742,746 ---- { _closeTableRow(); + m_ps->m_currentTableCol = 0; *************** *** 678,685 **** void WPXHLListener::_closeTableRow() { - _closeTableCell(); - if (m_ps->m_isTableRowOpened) m_listenerImpl->closeTableRow(); m_ps->m_isTableRowOpened = false; } --- 769,778 ---- void WPXHLListener::_closeTableRow() { if (m_ps->m_isTableRowOpened) + { + if (m_ps->m_isTableCellOpened) + _closeTableCell(); m_listenerImpl->closeTableRow(); + } m_ps->m_isTableRowOpened = false; } *************** *** 763,773 **** void WPXHLListener::_closeTableCell() { - if (m_ps->m_isCellWithoutParagraph) - _openParagraph(); - _closeParagraph(); - m_ps->m_cellAttributeBits = 0x00000000; if (m_ps->m_isTableCellOpened) ! m_listenerImpl->closeTableCell(); m_ps->m_isTableCellOpened = false; } --- 856,870 ---- void WPXHLListener::_closeTableCell() { if (m_ps->m_isTableCellOpened) ! { ! if (m_ps->m_isCellWithoutParagraph) ! _openSpan(); ! _closeParagraph(); ! _closeListElement(); ! _changeList(); ! m_ps->m_cellAttributeBits = 0x00000000; + m_listenerImpl->closeTableCell(); + } m_ps->m_isTableCellOpened = false; } *************** *** 781,785 **** // save our old parsing state on our "stack" WPXParsingState *oldPS = m_ps; ! m_ps = new WPXParsingState(false); // false: don't open a new section unless we must inside this type of sub-document // BEGIN: copy page properties into the new parsing state m_ps->m_pageFormWidth = oldPS->m_pageFormWidth; --- 878,882 ---- // save our old parsing state on our "stack" WPXParsingState *oldPS = m_ps; ! m_ps = new WPXParsingState(); // BEGIN: copy page properties into the new parsing state m_ps->m_pageFormWidth = oldPS->m_pageFormWidth; *************** *** 788,791 **** --- 885,889 ---- m_ps->m_subDocumentTextPIDs = oldPS->m_subDocumentTextPIDs; // END: copy page properties into the new parsing state + m_ps->m_inSubDocument = true; // Check whether the document is calling its own TextPID if ((m_ps->m_subDocumentTextPIDs.find(textPID) == m_ps->m_subDocumentTextPIDs.end()) || (!textPID)) *************** *** 805,823 **** if (!isUndoOn()) { - _flushText(); switch (breakType) { case WPX_COLUMN_BREAK: ! if (m_ps->m_isTextColumnWithoutParagraph) ! { ! _openParagraph(); // handle a case where two column breaks are following each other ! _flushText(); ! } ! m_ps->m_numDeferredParagraphBreaks++; m_ps->m_isParagraphColumnBreak = true; m_ps->m_isTextColumnWithoutParagraph = true; break; case WPX_PAGE_BREAK: ! m_ps->m_numDeferredParagraphBreaks++; m_ps->m_isParagraphPageBreak = true; break; --- 903,921 ---- if (!isUndoOn()) { switch (breakType) { case WPX_COLUMN_BREAK: ! if (m_ps->m_isParagraphOpened) ! _closeParagraph(); ! if (m_ps->m_isListElementOpened) ! _closeListElement(); m_ps->m_isParagraphColumnBreak = true; m_ps->m_isTextColumnWithoutParagraph = true; break; case WPX_PAGE_BREAK: ! if (m_ps->m_isParagraphOpened) ! _closeParagraph(); ! if (m_ps->m_isListElementOpened) ! _closeListElement(); m_ps->m_isParagraphPageBreak = true; break; *************** *** 833,837 **** { if (!m_ps->m_isTableOpened) ! _openPageSpan(); else m_ps->m_isPageSpanBreakDeferred = true; --- 931,935 ---- { if (!m_ps->m_isTableOpened) ! _closePageSpan(); else m_ps->m_isPageSpanBreakDeferred = true; Index: WP6HLStylesListener.h =================================================================== RCS file: /cvsroot/libwpd/libwpd2/src/lib/WP6HLStylesListener.h,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** WP6HLStylesListener.h 6 Apr 2005 07:24:38 -0000 1.38 --- WP6HLStylesListener.h 25 Aug 2005 14:34:42 -0000 1.39 *************** *** 100,107 **** virtual void _handleSubDocument(uint16_t textPID, const bool isHeaderFooter, WPXTableList tableList, int nextTableIndice = 0); ! virtual void _flushText(const bool fakeText=false) {} virtual void _openParagraph() {} virtual void _openPageSpan() { /* FIXME: REMOVE ME WHEN IMPLEMENTED IN WPXHLListener */ }; ! virtual void _flushList() {} private: --- 100,107 ---- virtual void _handleSubDocument(uint16_t textPID, const bool isHeaderFooter, WPXTableList tableList, int nextTableIndice = 0); ! virtual void _flushText() {} virtual void _openParagraph() {} virtual void _openPageSpan() { /* FIXME: REMOVE ME WHEN IMPLEMENTED IN WPXHLListener */ }; ! virtual void _changeList() {} private: Index: WPXHLListener.h =================================================================== RCS file: /cvsroot/libwpd/libwpd2/src/lib/WPXHLListener.h,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** WPXHLListener.h 6 Apr 2005 07:24:38 -0000 1.61 --- WPXHLListener.h 25 Aug 2005 14:34:42 -0000 1.62 *************** *** 2,5 **** --- 2,6 ---- * Copyright (C) 2002 William Lachance (wil...@sy...) * Copyright (C) 2002 Marc Maurer (j.m...@st...) + * Copyright (C) 2005 Fridrich Strba (fri...@bl...) * * This library is free software; you can redistribute it and/or *************** *** 60,64 **** struct _WPXParsingState { ! _WPXParsingState(bool sectionAttributesChanged=true); ~_WPXParsingState(); --- 61,65 ---- struct _WPXParsingState { ! _WPXParsingState(); ~_WPXParsingState(); *************** *** 72,76 **** #endif uint32_t m_textAttributeBits; - bool m_textAttributesChanged; float m_fontSize; WPXString *m_fontName; --- 73,76 ---- *************** *** 84,96 **** float m_paragraphLineSpacing; bool m_isSectionOpened; bool m_isPageSpanBreakDeferred; bool m_isParagraphOpened; - bool m_isParagraphClosed; bool m_isListElementOpened; - bool m_isListElementClosed; - bool m_isSpanOpened; - int m_numDeferredParagraphBreaks; WPXTableDefinition m_tableDefinition; --- 84,95 ---- float m_paragraphLineSpacing; + bool m_isDocumentStarted; + bool m_isPageSpanOpened; bool m_isSectionOpened; bool m_isPageSpanBreakDeferred; + bool m_isSpanOpened; bool m_isParagraphOpened; bool m_isListElementOpened; WPXTableDefinition m_tableDefinition; *************** *** 106,110 **** uint8_t m_paragraphJustificationBeforeTable; - bool m_isPageSpanOpened; int m_nextPageSpanIndice; int m_numPagesRemainingInSpan; --- 105,108 ---- *************** *** 132,138 **** float m_rightMarginByTabs; // only part of the margin that is reset at the end of a paragraph float m_paragraphTextIndent; // resulting first line indent that is one of the paragraph properties float m_textIndentByParagraphIndentChange; // part of the indent due to the PARAGRAPH indent (WP6???) ! float m_textIndentByTabs; // part of the indent due to the "Back Tab" #if 0 --- 130,141 ---- float m_rightMarginByTabs; // only part of the margin that is reset at the end of a paragraph + float m_listReferencePosition; // position from the left page margin of the list number/bullet + float m_listBeginPosition; // position from the left page margin of the beginning of the list + float m_paragraphTextIndent; // resulting first line indent that is one of the paragraph properties float m_textIndentByParagraphIndentChange; // part of the indent due to the PARAGRAPH indent (WP6???) ! float m_textIndentByTabs; // part of the indent due to the "Back Tab" or "Left Tab" ! ! uint8_t m_currentListLevel; #if 0 *************** *** 140,144 **** uint16_t m_currentOutlineHash; // probably should replace Hash with Key in these sorts of cases uint8_t m_oldListLevel; - uint8_t m_currentListLevel; WP6StyleStateSequence m_styleStateSequence; bool m_putativeListElementHasParagraphNumber; --- 143,146 ---- *************** *** 152,155 **** --- 154,160 ---- std::set <int> m_subDocumentTextPIDs; + + bool m_inSubDocument; + bool m_isNote; }; *************** *** 173,178 **** protected: virtual void _handleSubDocument(uint16_t textPID, const bool isHeaderFooter, WPXTableList tableList, int nextTableIndice) = 0; ! virtual void _flushText(const bool fakeText=false) = 0; ! virtual void _flushList() = 0; void _openSection(); --- 178,183 ---- protected: virtual void _handleSubDocument(uint16_t textPID, const bool isHeaderFooter, WPXTableList tableList, int nextTableIndice) = 0; ! virtual void _flushText() = 0; ! virtual void _changeList() = 0; void _openSection(); *************** *** 182,186 **** void _closePageSpan(); ! void _appendParagraphProperties(WPXPropertyList &propList); void _getTabStops(WPXPropertyListVector &tabStops); void _appendJustification(WPXPropertyList &propList, int justification); --- 187,191 ---- void _closePageSpan(); ! void _appendParagraphProperties(WPXPropertyList &propList, const bool isListElement=false); void _getTabStops(WPXPropertyListVector &tabStops); void _appendJustification(WPXPropertyList &propList, int justification); *************** *** 190,194 **** void _openListElement(); ! void _closeListElement(); void _openSpan(); --- 195,199 ---- void _openListElement(); ! void _closeListElement(); void _openSpan(); Index: WP6HLContentListener.cpp =================================================================== RCS file: /cvsroot/libwpd/libwpd2/src/lib/WP6HLContentListener.cpp,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** WP6HLContentListener.cpp 22 Jun 2005 09:12:44 -0000 1.80 --- WP6HLContentListener.cpp 25 Aug 2005 14:34:42 -0000 1.81 *************** *** 221,230 **** m_numRemovedParagraphBreaks(0), m_tableList(tableList), m_currentTable(NULL), m_nextTableIndice(nextTableIndice), ! m_currentListLevel(0), m_putativeListElementHasParagraphNumber(false), m_putativeListElementHasDisplayReferenceNumber(false), [...1185 lines suppressed...] ! void WP6HLContentListener::_flushList() { ! _closeListElement(); ! m_parseState->m_currentListLevel = 0; _handleListChange(m_parseState->m_currentOutlineHash); } --- 1417,1429 ---- m_parseState->m_textAfterDisplayReference.clear(); m_parseState->m_textAfterNumber.clear(); ! #endif } ! void WP6HLContentListener::_changeList() { ! if (m_ps->m_isParagraphOpened) ! _closeParagraph(); ! if (m_ps->m_isListElementOpened) ! _closeListElement(); _handleListChange(m_parseState->m_currentOutlineHash); } Index: WP6TabGroup.cpp =================================================================== RCS file: /cvsroot/libwpd/libwpd2/src/lib/WP6TabGroup.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** WP6TabGroup.cpp 11 Aug 2004 09:43:37 -0000 1.17 --- WP6TabGroup.cpp 25 Aug 2005 14:34:42 -0000 1.18 *************** *** 2,6 **** * Copyright (C) 2002 William Lachance (wil...@sy...) * Copyright (C) 2002 Marc Maurer (j.m...@st...) ! * Copyright (C) 2004 Fridrich Strba (fri...@bl...) * * This library is free software; you can redistribute it and/or --- 2,6 ---- * Copyright (C) 2002 William Lachance (wil...@sy...) * Copyright (C) 2002 Marc Maurer (j.m...@st...) ! * Copyright (C) 2004-2005 Fridrich Strba (fri...@bl...) * * This library is free software; you can redistribute it and/or *************** *** 45,49 **** m_ignoreFunction = true; } ! if ((getSize() >= 12) & (getSize() <= 18)) // Minimum size of the function if the position information is present { input->seek((getSize() - 12), WPX_SEEK_CUR); --- 45,61 ---- m_ignoreFunction = true; } ! ! /* What follows is a result of reverse-engineering of undocumented information contained in the functions of the ! * Tab Group. It is result of adjustment by trials and errors and can be wrong in certain cases */ ! ! if ((getSubGroup() & 0xC0) == 0x00) ! /* Left aligned tabs contain the position of the tab as a word (uint16_t) in WPUs ! * from left edge of the paper just after the size of "non-deletable" */ ! { ! tempPosition = readU16(input); ! } ! else if ((getSize() >= 12) & (getSize() <= 18)) // Minimum size of the function if the position information is present ! /* This case might be fully included in the previous condition, but I am not sure; ! * so leaving it in for the while */ { input->seek((getSize() - 12), WPX_SEEK_CUR); Index: WP42HLListener.cpp =================================================================== RCS file: /cvsroot/libwpd/libwpd2/src/lib/WP42HLListener.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** WP42HLListener.cpp 8 Feb 2005 16:02:50 -0000 1.28 --- WP42HLListener.cpp 25 Aug 2005 14:34:42 -0000 1.29 *************** *** 2,5 **** --- 2,6 ---- * Copyright (C) 2003 William Lachance (wil...@sy...) * Copyright (C) 2003-2004 Marc Maurer (j.m...@st...) + * Copyright (C) 2005 Fridrich Strba (fri...@bl...) * * This library is free software; you can redistribute it and/or *************** *** 41,44 **** --- 42,47 ---- void WP42HLListener::insertCharacter(const uint16_t character) { + if (m_ps->m_isSpanOpened) + _openSpan(); appendUCS4(m_textBuffer, (uint32_t)character); } *************** *** 46,84 **** void WP42HLListener::insertTab(const uint8_t tabType, const float tabPosition) { ! _flushText(); ! m_listenerImpl->insertTab(); } void WP42HLListener::insertEOL() { ! _flushText(); ! m_ps->m_numDeferredParagraphBreaks++; } void WP42HLListener::endDocument() { ! // corner case: document ends in a list element ! /*if (m_parseState->m_styleStateSequence.getCurrentState() != NORMAL) ! { ! _flushText(); // flush the list text ! m_parseState->m_styleStateSequence.setCurrentState(NORMAL); ! _flushText(true); // flush the list exterior (forcing a line break, to make _flushText think we've exited a list) ! }*/ ! // corner case: document contains no end of lines ! /*else*/ if (!m_ps->m_isParagraphOpened && !m_ps->m_isParagraphClosed) ! { ! _flushText(); ! } ! // NORMAL(ish) case document ends either inside a paragraph or outside of one, ! // but not inside an object ! else if (!m_ps->m_isParagraphClosed || !m_ps->m_isParagraphOpened) ! { ! _flushText(); ! } ! ! // the only other possibility is a logical contradiction: a paragraph ! // may not be opened and closed at the same time ! ! // close the document nice and tight _closeSection(); _closePageSpan(); --- 49,80 ---- void WP42HLListener::insertTab(const uint8_t tabType, const float tabPosition) { ! if (!isUndoOn()) ! { ! if (!m_ps->m_isSpanOpened) ! _openSpan(); ! else ! _flushText(); ! ! m_listenerImpl->insertTab(); ! } } void WP42HLListener::insertEOL() { ! if (!isUndoOn()) ! { ! if (!m_ps->m_isParagraphOpened && !m_ps->m_isListElementOpened) ! _openSpan(); ! if (m_ps->m_isParagraphOpened) ! _closeParagraph(); ! if (m_ps->m_isListElementOpened) ! _closeListElement(); ! } } void WP42HLListener::endDocument() { ! _closeSpan(); ! _closeParagraph(); _closeSection(); _closePageSpan(); *************** *** 93,99 **** void WP42HLListener::attributeChange(const bool isOn, const uint8_t attribute) { ! ! // flush everything which came before this change ! _flushText(); uint32_t textAttributeBit = 0; --- 89,93 ---- void WP42HLListener::attributeChange(const bool isOn, const uint8_t attribute) { ! _closeSpan(); uint32_t textAttributeBit = 0; *************** *** 138,143 **** else m_ps->m_textAttributeBits ^= textAttributeBit; - - m_ps->m_textAttributesChanged = true; } --- 132,135 ---- *************** *** 146,191 **** *****************************************/ ! /* ! TODO: this function needs to be fleshed out ! */ ! void WP42HLListener::_flushText(const bool fakeText) { - // create a new section, and a new paragraph, if our section attributes have changed and we have inserted - // something into the document (or we have forced a break, which assumes the same condition) - if (m_ps->m_sectionAttributesChanged && (m_textBuffer.len() > 0 || m_ps->m_numDeferredParagraphBreaks > 0/* || fakeText*/)) - { - _openSection(); - //if (fakeText) - _openParagraph(); - } - - if (m_ps->m_numDeferredParagraphBreaks > 0) - { - if (!m_ps->m_isParagraphOpened //&& - // !(m_parseState->m_isTableOpened && !m_parseState->m_isTableCellOpened) // don't allow paragraphs to be opened when we have already opened a table, but no cell yet. - MARCM (is it really correct, or should this be fixed elsewhere??) - ) - m_ps->m_numDeferredParagraphBreaks++; - - while (m_ps->m_numDeferredParagraphBreaks > 1) - _openParagraph(); - _closeParagraph(); - m_ps->m_numDeferredParagraphBreaks = 0; // compensate for this by requiring a paragraph to be opened - } - else if (m_ps->m_textAttributesChanged && m_textBuffer.len()) - { - _openSpan(); - m_ps->m_textAttributesChanged = false; - } - if (m_textBuffer.len()) - { - if (!m_ps->m_isParagraphOpened) - { - _openParagraph(); - _openSpan(); - } - m_listenerImpl->insertText(m_textBuffer); ! m_textBuffer.clear(); ! } } --- 138,145 ---- *****************************************/ ! void WP42HLListener::_flushText() { if (m_textBuffer.len()) m_listenerImpl->insertText(m_textBuffer); ! m_textBuffer.clear(); } |