From: Fridrich S. <str...@us...> - 2005-08-17 13:53:39
|
Update of /cvsroot/libwpd/writerperfect/filter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19540/filter Modified Files: Tag: fs_refactoring1 ListStyle.cxx ListStyle.hxx WordPerfectCollector.cxx Log Message: Getting the list styles right even in weird cases Index: WordPerfectCollector.cxx =================================================================== RCS file: /cvsroot/libwpd/writerperfect/filter/WordPerfectCollector.cxx,v retrieving revision 1.19.2.1 retrieving revision 1.19.2.2 diff -C2 -d -r1.19.2.1 -r1.19.2.2 *** WordPerfectCollector.cxx 31 Jul 2005 06:38:53 -0000 1.19.2.1 --- WordPerfectCollector.cxx 17 Aug 2005 13:53:24 -0000 1.19.2.2 *************** *** 568,576 **** if (mpCurrentListStyle && mpCurrentListStyle->getListID() == id) pOrderedListStyle = static_cast<OrderedListStyle *>(mpCurrentListStyle); // FIXME: using a dynamic cast here causes oo to crash?! // this rather appalling conditional makes sure we only start a new list (rather than continue an old ! // one) iff: (1) we have no prior list OR (2) the prior list is actually definitively different // from the list that is just being defined (listIDs differ) OR (3) we can tell that the user actually // is starting a new list at level 1 (and only level 1) ! if (pOrderedListStyle == NULL || pOrderedListStyle->getListID() != id || (propList["libwpd:level"] && propList["libwpd:level"]->getInt()==1 && (propList["text:start-value"] && propList["text:start-value"]->getInt() != (miLastListNumber+1)))) --- 568,577 ---- if (mpCurrentListStyle && mpCurrentListStyle->getListID() == id) pOrderedListStyle = static_cast<OrderedListStyle *>(mpCurrentListStyle); // FIXME: using a dynamic cast here causes oo to crash?! + // this rather appalling conditional makes sure we only start a new list (rather than continue an old ! // one) if: (1) we have no prior list OR (2) the prior list is actually definitively different // from the list that is just being defined (listIDs differ) OR (3) we can tell that the user actually // is starting a new list at level 1 (and only level 1) ! if (pOrderedListStyle == NULL || pOrderedListStyle->getListID() != id || (propList["libwpd:level"] && propList["libwpd:level"]->getInt()==1 && (propList["text:start-value"] && propList["text:start-value"]->getInt() != (miLastListNumber+1)))) *************** *** 589,593 **** mbListContinueNumbering = true; ! pOrderedListStyle->updateListLevel(miCurrentListLevel, propList); } --- 590,601 ---- mbListContinueNumbering = true; ! // Iterate through ALL list styles with the same WordPerfect list id and define a level if it is not already defined ! // This solves certain problems with lists that start and finish without reaching certain levels and then begin again ! // and reach those levels. See gradguide0405_PC.wpd in the regression suite ! for (std::vector<ListStyle *>::iterator iterOrderedListStyles = mListStyles.begin(); iterOrderedListStyles != mListStyles.end(); iterOrderedListStyles++) ! { ! if ((* iterOrderedListStyles)->getListID() == propList["libwpd:id"]->getInt()) ! (* iterOrderedListStyles)->updateListLevel((propList["libwpd:level"]->getInt() - 1), propList); ! } } *************** *** 610,614 **** mpCurrentListStyle = static_cast<ListStyle *>(pUnorderedListStyle); } ! pUnorderedListStyle->updateListLevel(miCurrentListLevel, propList); } --- 618,628 ---- mpCurrentListStyle = static_cast<ListStyle *>(pUnorderedListStyle); } ! ! // See comment in WordPerfectCollector::defineOrderedListLevel ! for (std::vector<ListStyle *>::iterator iterUnorderedListStyles = mListStyles.begin(); iterUnorderedListStyles != mListStyles.end(); iterUnorderedListStyles++) ! { ! if ((* iterUnorderedListStyles)->getListID() == propList["libwpd:id"]->getInt()) ! (* iterUnorderedListStyles)->updateListLevel((propList["libwpd:level"]->getInt() - 1), propList); ! } } Index: ListStyle.hxx =================================================================== RCS file: /cvsroot/libwpd/writerperfect/filter/ListStyle.hxx,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** ListStyle.hxx 8 Dec 2004 05:03:56 -0000 1.2 --- ListStyle.hxx 17 Aug 2005 13:53:24 -0000 1.2.2.1 *************** *** 65,68 **** --- 65,69 ---- ListStyle(const char *psName, const int iListID); virtual ~ListStyle(); + virtual void updateListLevel(const int iLevel, const WPXPropertyList &xPropList) = 0; virtual void write(DocumentHandler &xHandler) const; const int getListID() { return miListID; } Index: ListStyle.cxx =================================================================== RCS file: /cvsroot/libwpd/writerperfect/filter/ListStyle.cxx,v retrieving revision 1.5.2.1 retrieving revision 1.5.2.2 diff -C2 -d -r1.5.2.1 -r1.5.2.2 *** ListStyle.cxx 8 Aug 2005 15:43:41 -0000 1.5.2.1 --- ListStyle.cxx 17 Aug 2005 13:53:24 -0000 1.5.2.2 *************** *** 36,39 **** --- 36,41 ---- void OrderedListStyle::updateListLevel(const int iLevel, const WPXPropertyList &xPropList) { + if (iLevel < 0) + return; if (!isListLevelDefined(iLevel)) setListLevel(iLevel, new OrderedListLevelStyle(xPropList)); *************** *** 78,81 **** --- 80,85 ---- void UnorderedListStyle::updateListLevel(const int iLevel, const WPXPropertyList &xPropList) { + if (iLevel < 0) + return; if (!isListLevelDefined(iLevel)) setListLevel(iLevel, new UnorderedListLevelStyle(xPropList)); |