HI everyone,
as promised here is an updated Luke Jordan list patch that
applies cleanly against version 0.79. This patch need lots of work before
it is ready for production release but it provides a good basis to start
from. This does nothing that Lukes orginal patch didn't do. It has none of
the many bugs fixed. It merely applies and compiles cleanly against 0.79.
I want emphasize the importance of getting an updated fields
infrastructure. Lists, auto-numbering of headings and sections and
footnotes, page numbers and auto-updating dates all need a working fields
implementation. It is imperative that this is done as soon as possible so
that these other useful features can be added. To provide an additional
spur I will work on a unix version of "Insert Fields" which I will
maintain as the underlying field infrastructure is changed.
So you XML experts (you know who you are) please get the infrastructure in
place so grunt hackers like me can help put these features in place.
Cheers
Martin
diff -Naur --exclude=CVS --exclude=Linux* abi/src/text/fmt/xp/Makefile
abi-new/src/text/fmt/xp/Makefile
--- abi/src/text/fmt/xp/Makefile Sat Apr 29 20:53:44 2000
+++ abi-new/src/text/fmt/xp/Makefile Sat Apr 29 20:29:29 2000
@@ -31,6 +31,7 @@
fl_DocListener.cpp \
fl_Layout.cpp \
fl_SectionLayout.cpp \
+ fl_AutoNum.cpp \
fp_Column.cpp \
fp_Line.cpp \
fp_Page.cpp \
diff -Naur --exclude=CVS --exclude=Linux* abi/src/text/fmt/xp/fl_AutoNum.cpp
abi-new/src/text/fmt/xp/fl_AutoNum.cpp
--- abi/src/text/fmt/xp/fl_AutoNum.cpp Thu Jan 1 10:00:00 1970
+++ abi-new/src/text/fmt/xp/fl_AutoNum.cpp Sat Apr 29 20:29:29 2000
@@ -0,0 +1,280 @@
+/* AbiWord
+ * Copyright (C) 1998,1999 AbiSource, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "fl_AutoNum.h"
+#include "fl_Layout.h"
+
+#include "ut_string.h"
+#include "ut_assert.h"
+#include "ut_debugmsg.h"
+
+fl_AutoNum::fl_AutoNum(UT_uint32 id, UT_uint32 start, const XML_Char * format,
+fl_Layout * pFirst, fl_AutoNum * pParent)
+{
+ m_iID = id;
+ m_iStartValue = start;
+ m_pszFormat = format;
+ m_iAsciiOffset = 0;
+ m_bUpdatingItems = UT_FALSE;
+
+ m_pParent = pParent;
+ if (m_pParent) {
+ m_iLevel = m_pParent->getLevel() + 1;
+ } else {
+ m_iLevel = 1;
+ }
+
+ m_pItems.addItem(pFirst);
+
+ _calculateLabelStr();
+
+}
+
+void fl_AutoNum::_calculateLabelStr(void)
+{
+ UT_ASSERT(m_pszFormat);
+
+ UT_uint32 num_fchars, i;
+ num_fchars = 0;
+
+ if (m_pParent)
+ m_pParent->_calculateLabelStr();
+
+ for (i = 0; i < UT_XML_strlen(m_pszFormat); i++)
+ if (m_pszFormat[i] == '%')
+ num_fchars++;
+
+ XML_Char * p;
+ if (!UT_cloneString((char *&)p, m_pszFormat))
+ {
+ // TODO out of mem
+ }
+ UT_ASSERT(p);
+
+ fl_AutoNum * pCurr = this;
+
+ i = 0;
+ XML_Char ** f_strs = new XML_Char * [num_fchars];
+ XML_Char * curr_str = strtok(p, "%");
+
+ while (curr_str)
+ {
+ f_strs[i] = curr_str;
+ curr_str = strtok(NULL, "%");
+ i++;
+ }
+ UT_ASSERT(i == num_fchars);
+
+ curr_str = new XML_Char[30];
+ while (pCurr)
+ {
+ i--;
+ sprintf(curr_str, "%%%s", f_strs[i]);
+ switch(curr_str[1])
+ {
+ case 'd':
+ curr_str[1] = 'i';
+ if (pCurr != this)
+ sprintf(curr_str, curr_str, _getLevelValue(pCurr));
+ break;
+ case 'b':
+ XML_Char * tmp;
+ UT_XML_cloneString(*&tmp, curr_str);
+ tmp[1] = 'x';
+ sprintf(curr_str, tmp, UCS_BULLET);
+ free(tmp);
+ break;
+ case 'A':
+ curr_str[1] = 'c';
+ if (pCurr != this)
+ sprintf(curr_str, curr_str, _getLevelValue(pCurr) +
+64);
+ else
+ m_iAsciiOffset = 64;
+ break;
+ case 'a':
+ curr_str[1] = 'c';
+ if (pCurr != this)
+ sprintf(curr_str, curr_str, _getLevelValue(pCurr) +
+96);
+ else
+ m_iAsciiOffset = 96;
+ break;
+ case '*':
+ curr_str[1] = 's';
+ UT_ASSERT(pCurr == getParent());
+ curr_str = pCurr->getLabel(getFirstItem());
+ pCurr = NULL;
+ break;
+ }
+ if (pCurr)
+ pCurr = pCurr->getParent();
+ UT_XML_cloneString(*&f_strs[i], curr_str);
+ }
+ free(p);
+
+ XML_Char buf[100] = { "" };
+
+ if (!getParent())
+ {
+ sprintf(buf, "%s", f_strs[num_fchars - 1]);
+ }
+ else
+ {
+ for (i = 0; i < num_fchars; i++)
+ {
+ sprintf(buf, "%s%s", buf, f_strs[i]);
+ }
+ }
+
+ UT_XML_cloneString(*&m_pszLabelStr, buf);
+ UT_DEBUGMSG(("[fl_AutoNum::_calculateLabelStr] List Label: %s\n",
+m_pszLabelStr));
+}
+
+fl_AutoNum::~fl_AutoNum()
+{
+ if (m_pParent && m_pParent->isEmpty())
+ DELETEP(m_pParent);
+}
+
+XML_Char * fl_AutoNum::getLabel(fl_Layout * pItem) const
+{
+ XML_Char * label = new XML_Char [100];
+ UT_ASSERT(m_pszLabelStr);
+ UT_XML_cloneString(*&label, m_pszLabelStr);
+
+ UT_sint32 place = m_pItems.findItem(pItem);
+ UT_ASSERT(place != -1);
+
+ sprintf(label, label, place + m_iStartValue + m_iAsciiOffset);
+ return label;
+}
+
+UT_uint32 fl_AutoNum::getValue(fl_Layout * pItem) const
+{
+ return m_pItems.findItem(pItem) + m_iStartValue;
+}
+
+void fl_AutoNum::setFormat(const XML_Char * format)
+{
+ UT_ASSERT(format);
+ m_pszFormat = format;
+ _calculateLabelStr();
+ _updateItems(0);
+}
+
+void fl_AutoNum::setStartValue(UT_uint32 start)
+{
+ m_iStartValue = start;
+ _updateItems(0);
+}
+
+void fl_AutoNum::insertItem(fl_Layout * pItem, fl_Layout * pPrev)
+{
+ UT_sint32 ndx;
+ UT_ASSERT(pItem);
+
+ ndx = m_pItems.findItem(pPrev) + 1;
+ m_pItems.insertItemAt(pItem, ndx);
+
+ _updateItems(ndx + 1);
+}
+
+void fl_AutoNum::removeItem(fl_Layout * pItem)
+{
+ UT_sint32 ndx = m_pItems.findItem(pItem);
+ UT_ASSERT(ndx != -1);
+
+ m_pItems.deleteNthItem(ndx);
+
+ if ((ndx == 0) && (m_pParent))
+ {
+ UT_ASSERT(m_pParent->isItem(pItem));
+ if (m_pItems.getItemCount() > 0)
+ m_pParent->insertItem(getFirstItem(), pItem);
+ m_pParent->removeItem(pItem);
+ }
+
+ _updateItems(ndx);
+}
+
+UT_Bool fl_AutoNum::isItem(fl_Layout * pItem) const
+{
+ if (m_pItems.findItem(pItem) == -1)
+ return UT_FALSE;
+ else
+ return UT_TRUE;
+}
+
+UT_Bool fl_AutoNum::isEmpty() const
+{
+ if (m_pItems.getItemCount() > 0)
+ return UT_FALSE;
+ else
+ return UT_TRUE;
+}
+
+void fl_AutoNum::setParent(fl_AutoNum * pParent)
+{
+ m_pParent = pParent;
+}
+
+void fl_AutoNum::update(UT_uint32 start)
+{
+ _calculateLabelStr();
+ _updateItems(start);
+ if (m_pParent && !m_pParent->isUpdating())
+ {
+ UT_uint32 ndx = m_pParent->m_pItems.findItem(getFirstItem());
+ m_pParent->update(ndx + 1);
+ }
+}
+
+inline void fl_AutoNum::_updateItems(UT_uint32 start)
+{
+ m_bUpdatingItems = UT_TRUE;
+ for (UT_uint32 i = start; i < m_pItems.getItemCount(); i++)
+ {
+ fl_Layout * pTmp = (fl_Layout *)m_pItems.getNthItem(i);
+ pTmp->listUpdate();
+ }
+ m_bUpdatingItems = UT_FALSE;
+}
+
+inline UT_uint32 fl_AutoNum::_getLevelValue(fl_AutoNum * pAutoNum)
+{
+ fl_Layout * pBlock = getFirstItem();
+ fl_AutoNum * pCurr = this;
+
+ while (1)
+ {
+ if (pAutoNum->isItem(pBlock))
+ {
+ break;
+ }
+ else
+ {
+ pCurr = pCurr->getParent();
+ pBlock = pCurr->getFirstItem();
+ }
+ }
+
+ return pAutoNum->getValue(pBlock);
+}
diff -Naur --exclude=CVS --exclude=Linux* abi/src/text/fmt/xp/fl_AutoNum.h
abi-new/src/text/fmt/xp/fl_AutoNum.h
--- abi/src/text/fmt/xp/fl_AutoNum.h Thu Jan 1 10:00:00 1970
+++ abi-new/src/text/fmt/xp/fl_AutoNum.h Sat Apr 29 20:29:29 2000
@@ -0,0 +1,77 @@
+/* Copyright etc. */
+/* AbiWord
+ * Copyright (C) 1998,1999 AbiSource, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef FL_AUTONUM_H
+#define FL_AUTONUM_H
+
+#include "ut_types.h"
+#include "ut_misc.h"
+#include "ut_vector.h"
+
+class fl_Layout;
+
+class fl_AutoNum
+{
+public:
+ fl_AutoNum(UT_uint32 id, UT_uint32 start, const XML_Char * format, fl_Layout *
+pItem, fl_AutoNum * pParent);
+ ~fl_AutoNum();
+
+ XML_Char * getLabel(fl_Layout *) const;
+ UT_uint32 getValue(fl_Layout *) const;
+ UT_uint32 getLevel(void) const { return m_iLevel; }
+ void setFormat(const XML_Char * format);
+
+ UT_uint16 getStartValue(void) const { return m_iStartValue; }
+ void setStartValue(UT_uint32 start);
+
+ void insertItem(fl_Layout * pItem, fl_Layout * pBefore);
+ void removeItem(fl_Layout * pItem);
+
+ UT_Bool isItem(fl_Layout * pItem) const;
+ UT_Bool isEmpty(void) const;
+ inline fl_Layout * getFirstItem(void) const { return (fl_Layout
+*)m_pItems.getFirstItem(); }
+
+ fl_AutoNum * getParent(void) const { return m_pParent; }
+ void setParent(fl_AutoNum *);
+
+ void update(UT_uint32 start);
+ inline UT_Bool isUpdating(void) const { return m_bUpdatingItems; }
+
+ inline UT_uint32 getID(void) const { return m_iID; }
+
+protected:
+ void _calculateLabelStr(void);
+ inline void _updateItems(UT_uint32 start);
+ inline UT_uint32 _getLevelValue(fl_AutoNum * pAutoNum);
+
+ fl_AutoNum * m_pParent;
+
+ UT_Vector m_pItems;
+
+ UT_uint32 m_iID;
+ UT_uint32 m_iLevel;
+ const XML_Char * m_pszFormat;
+ XML_Char * m_pszLabelStr;
+ UT_uint32 m_iStartValue;
+ UT_uint16 m_iAsciiOffset;
+ UT_Bool m_bUpdatingItems;
+};
+
+#endif
diff -Naur --exclude=CVS --exclude=Linux* abi/src/text/fmt/xp/fl_BlockLayout.cpp
abi-new/src/text/fmt/xp/fl_BlockLayout.cpp
--- abi/src/text/fmt/xp/fl_BlockLayout.cpp Sat Apr 29 20:53:45 2000
+++ abi-new/src/text/fmt/xp/fl_BlockLayout.cpp Sat Apr 29 20:29:29 2000
@@ -26,6 +26,7 @@
#include "fl_Layout.h"
#include "fl_DocLayout.h"
#include "fl_SectionLayout.h"
+#include "fl_AutoNum.h"
#include "fb_LineBreaker.h"
#include "fb_Alignment.h"
#include "fp_Column.h"
@@ -78,20 +79,23 @@
m_pFirstRun = NULL;
m_pFirstLine = NULL;
m_pLastLine = NULL;
+ m_pAutoNum = NULL;
m_bNeedsReformat = UT_TRUE;
m_bNeedsRedraw = UT_FALSE;
m_bFixCharWidths = UT_FALSE;
m_bKeepTogether = UT_FALSE;
m_bKeepWithNext = UT_FALSE;
+ m_bListItem = UT_FALSE;
+ m_bStartList = UT_FALSE;
+ m_bStopList = UT_FALSE;
+ m_bListLabelCreated = UT_FALSE;
m_pLayout = m_pSectionLayout->getDocLayout();
m_pDoc = m_pLayout->getDocument();
setAttrPropIndex(indexAP);
- _lookupProperties();
-
m_pPrev = pPrev;
if (m_pPrev)
{
@@ -108,6 +112,7 @@
m_pNext->m_pPrev = this;
}
+ _lookupProperties();
}
fl_TabStop::fl_TabStop()
@@ -393,6 +398,79 @@
m_dLineSpacing = m_dLineSpacingLayoutUnits =
UT_convertDimensionless(pszSpacing);
}
}
+
+ const PP_AttrProp * pBlockAP = NULL;
+ getAttrProp(&pBlockAP);
+ const XML_Char * szLid, * szLevel;
+ UT_uint32 id, last_id, level, last_level, curr_level;
+
+ if (!pBlockAP || !pBlockAP->getAttribute(PT_LISTID_ATTRIBUTE_NAME, szLid))
+ szLid = NULL;
+ if (szLid)
+ id = atoi(szLid);
+ else id = 0;
+ if (m_pPrev && m_pPrev->isListItem())
+ last_id = m_pPrev->getAutoNum()->getID();
+ else last_id = 0;
+
+ if (!pBlockAP || !pBlockAP->getAttribute(PT_LEVEL_ATTRIBUTE_NAME, szLevel))
+ szLevel = NULL;
+ if (szLevel)
+ level = atoi(szLevel);
+ else level = 0;
+ if (m_pPrev)
+ last_level = m_pPrev->getLevel();
+ else last_level = 0;
+
+ if (id != last_id)
+ {
+ if ((level > last_level) && !m_bStartList)
+ {
+ if (last_level > 0 && !m_bListItem && !m_bStopList)
+ _addBlockToPrevList();
+
+ if (m_pAutoNum)
+ curr_level = m_pAutoNum->getLevel();
+ else curr_level = 0;
+
+ while (curr_level != level)
+ {
+ _startList(id);
+ curr_level++;
+ }
+ }
+ else if ((level == last_level))
+ {
+ /* For now, stop-list then start list */
+ if (!m_bStopList)
+ {
+ if (!m_pAutoNum)
+ _addBlockToPrevList();
+ _stopList();
+ }
+ _startList(id);
+ }
+ else if ((level < last_level) && (!m_bStopList))
+ {
+ if (!m_pAutoNum)
+ _addBlockToPrevList();
+
+ if (m_pAutoNum)
+ curr_level = m_pAutoNum->getLevel();
+ else curr_level = 0;
+
+ while (curr_level != level)
+ {
+ _stopList();
+ curr_level--;
+ }
+ }
+ }
+ else if ((id > 0) && !m_bListItem)
+ {
+ _addBlockToPrevList();
+ m_bListItem = UT_TRUE;
+ }
}
fl_BlockLayout::~fl_BlockLayout()
@@ -403,6 +481,13 @@
UT_VECTOR_PURGEALL(fl_TabStop *, m_vecTabs);
DELETEP(m_pAlignment);
+
+ if (m_pAutoNum)
+ {
+ m_pAutoNum->removeItem(this);
+ if (m_pAutoNum->isEmpty())
+ DELETEP(m_pAutoNum);
+ }
}
void fl_BlockLayout::clearScreen(GR_Graphics* /* pG */)
@@ -3512,4 +3597,137 @@
pView->updateScreen();
pView->_drawInsertionPoint();
}
+}
+
+////////////////////////////////////////////////////////////////////////////
+//List Item Stuff
+///////////////////////////////////////////////////////////////////////////
+
+void fl_BlockLayout::_startList(UT_uint32 id)
+{
+ const XML_Char * format = getProperty("format");
+ UT_uint32 start = atoi(getProperty("start-value"));
+
+ m_pAutoNum = new fl_AutoNum(id, start, format, this, m_pAutoNum);
+ m_bListItem = UT_TRUE;
+ m_bStartList = UT_TRUE;
+}
+
+void fl_BlockLayout::_stopList()
+{
+ fl_AutoNum * pAutoNum;
+
+ UT_ASSERT(m_pAutoNum);
+ m_pAutoNum->removeItem(this);
+
+ if (m_pAutoNum->getParent())
+ {
+ pAutoNum = m_pAutoNum->getParent();
+ if (!pAutoNum->isItem(this))
+ {
+ pAutoNum->insertItem(this, m_pAutoNum->getFirstItem());
+ }
+ }
+ else
+ {
+ if (m_bListLabelCreated)
+ _deleteListLabel();
+ m_bListItem = UT_FALSE;
+ pAutoNum = NULL;
+ }
+
+ m_bStopList = UT_TRUE;
+
+ if (m_pAutoNum->isEmpty())
+ {
+ DELETEP(m_pAutoNum);
+ m_bStopList = UT_FALSE;
+ }
+
+ m_pAutoNum = pAutoNum;
+}
+
+void fl_BlockLayout::listUpdate(void)
+{
+ if (!m_pAutoNum)
+ return;
+
+ if (m_bStartList)
+ m_pAutoNum->update(1);
+
+ if (!m_bListLabelCreated)
+ _createListLabel();
+
+ recalculateFields();
+}
+
+void fl_BlockLayout::transferListFlags(void)
+{
+ UT_ASSERT(m_pNext);
+ if (m_pNext->isListItem())
+ {
+ if (!m_pNext->m_bStartList)
+ m_pNext->m_bStartList = m_bStartList;
+ if (!m_pNext->m_bStopList)
+ m_pNext->m_bStopList = m_bStopList;
+ }
+}
+
+void fl_BlockLayout::_createListLabel(void)
+{
+/* This is a temporary hack, we need to find out more about the field */
+ if ((m_pFirstRun->getType() == FPRUN_FIELD))
+ {
+ m_bListLabelCreated = UT_TRUE;
+ return;
+ }
+
+ UT_ASSERT(m_pAutoNum);
+ const XML_Char * attributes[] = { "type", "list_label",
+ NULL, NULL,
+ NULL, NULL };
+ PD_Document * pDoc = m_pLayout->getDocument();
+ pDoc->insertObject(getPosition(), PTO_Field, attributes, NULL);
+ UT_UCSChar c = UCS_TAB;
+ pDoc->insertSpan(getPosition() + 1, &c, 1);
+ m_bListLabelCreated = UT_TRUE;
+}
+
+void fl_BlockLayout::_deleteListLabel(void)
+{
+ PD_Document * pDoc = m_pLayout->getDocument();
+ UT_uint32 posBlock = getPosition();
+ pDoc->deleteSpan(posBlock, posBlock + 2);
+ m_bListLabelCreated = UT_FALSE;
+}
+
+XML_Char * fl_BlockLayout::getListLabel(void)
+{
+ UT_ASSERT(m_pAutoNum);
+ return m_pAutoNum->getLabel(this);
+}
+
+inline void fl_BlockLayout::_addBlockToPrevList(void)
+{
+
+ UT_ASSERT(m_pPrev->getAutoNum());
+ m_pAutoNum = m_pPrev->getAutoNum();
+ m_pAutoNum->insertItem(this, m_pPrev);
+}
+
+inline UT_uint32 fl_BlockLayout::getLevel(void)
+{
+ if (!m_pAutoNum)
+ return 0;
+ else return m_pAutoNum->getLevel();
+}
+
+inline void fl_BlockLayout::setStarting(void)
+{
+ m_bStartList = UT_FALSE;
+}
+
+inline void fl_BlockLayout::setStopping(void)
+{
+ m_bStopList = UT_FALSE;
}
diff -Naur --exclude=CVS --exclude=Linux* abi/src/text/fmt/xp/fl_BlockLayout.h
abi-new/src/text/fmt/xp/fl_BlockLayout.h
--- abi/src/text/fmt/xp/fl_BlockLayout.h Sat Apr 29 20:53:45 2000
+++ abi-new/src/text/fmt/xp/fl_BlockLayout.h Sat Apr 29 20:29:29 2000
@@ -55,6 +55,7 @@
class PX_ChangeRecord_Strux;
class PX_ChangeRecord_StruxChange;
class fl_PartOfBlock;
+class fl_AutoNum;
class fl_CharWidths
{
@@ -161,6 +162,16 @@
inline fp_Run* getFirstRun(void) const { return m_pFirstRun; }
+ inline UT_Bool isListItem(void) const { return m_bListItem; }
+ inline fl_AutoNum * getAutoNum(void) const { return m_pAutoNum; }
+
+ virtual void listUpdate(void);
+ XML_Char * getListLabel(void);
+ void transferListFlags(void);
+ inline UT_uint32 getLevel(void);
+ inline void setStarting(void);
+ inline void setStopping(void);
+
void findSquigglesForRun(fp_Run* pRun);
UT_uint32 canSlurp(fp_Line* pLine) const;
@@ -311,6 +322,12 @@
void _stuffAllRunsOnALine(void);
void _insertFakeTextRun(void);
+ void _startList(UT_uint32 id);
+ void _stopList(void);
+ void _createListLabel(void);
+ void _deleteListLabel(void);
+ inline void _addBlockToPrevList();
+
UT_Bool m_bNeedsReformat;
UT_Bool m_bNeedsRedraw;
UT_Bool m_bFixCharWidths;
@@ -354,6 +371,12 @@
UT_Bool m_bKeepTogether;
UT_Bool m_bKeepWithNext;
const XML_Char * m_szStyle;
+
+ fl_AutoNum * m_pAutoNum;
+ UT_Bool m_bListItem;
+ UT_Bool m_bStartList;
+ UT_Bool m_bStopList;
+ UT_Bool m_bListLabelCreated;
// spell check stuff
UT_Vector m_vecSquiggles;
diff -Naur --exclude=CVS --exclude=Linux* abi/src/text/fmt/xp/fl_Layout.h
abi-new/src/text/fmt/xp/fl_Layout.h
--- abi/src/text/fmt/xp/fl_Layout.h Sat Apr 29 20:53:45 2000
+++ abi-new/src/text/fmt/xp/fl_Layout.h Sat Apr 29 20:29:29 2000
@@ -48,6 +48,8 @@
UT_Bool getAttrProp(const PP_AttrProp ** ppAP) const;
UT_Bool getSpanAttrProp(UT_uint32 offset, UT_Bool
bLeftSide, const PP_AttrProp ** ppAP) const;
+ virtual void listUpdate(void) { return; }
+
inline PD_Document * getDocument(void) const { return m_pDoc; };
protected:
diff -Naur --exclude=CVS --exclude=Linux* abi/src/text/fmt/xp/fl_SectionLayout.cpp
abi-new/src/text/fmt/xp/fl_SectionLayout.cpp
--- abi/src/text/fmt/xp/fl_SectionLayout.cpp Sat Apr 29 20:53:45 2000
+++ abi-new/src/text/fmt/xp/fl_SectionLayout.cpp Sat Apr 29 20:29:29 2000
@@ -202,6 +202,7 @@
if (pBL->getNext())
{
pBL->getNext()->setPrev(pBL->getPrev());
+ pBL->transferListFlags();
}
if (pBL == m_pFirstBlock)
@@ -243,13 +244,13 @@
void fl_SectionLayout::_purgeLayout()
{
- fl_BlockLayout* pBL = m_pFirstBlock;
+ fl_BlockLayout* pBL = m_pLastBlock;
while (pBL)
{
fl_BlockLayout* pNuke = pBL;
- pBL = pBL->getNext();
+ pBL = pBL->getPrev();
delete pNuke;
}
diff -Naur --exclude=CVS --exclude=Linux* abi/src/text/fmt/xp/fp_Fields.h
abi-new/src/text/fmt/xp/fp_Fields.h
--- abi/src/text/fmt/xp/fp_Fields.h Sat Apr 29 20:53:46 2000
+++ abi-new/src/text/fmt/xp/fp_Fields.h Sat Apr 29 20:29:29 2000
@@ -22,3 +22,4 @@
_FIELDTYPE(NUMBERS, "Numbers")
_FIELD(NUMBERS, "Page number", page_number)
_FIELD(NUMBERS, "Number of pages", page_count)
+_FIELD(NUMBERS, "List Label", list_label)
diff -Naur --exclude=CVS --exclude=Linux* abi/src/text/fmt/xp/fp_Run.cpp
abi-new/src/text/fmt/xp/fp_Run.cpp
--- abi/src/text/fmt/xp/fp_Run.cpp Sat Apr 29 20:53:46 2000
+++ abi-new/src/text/fmt/xp/fp_Run.cpp Sat Apr 29 20:29:29 2000
@@ -782,6 +782,13 @@
UT_UCS_strcpy_char(sz_ucs_FieldValue, szFieldValue);
break;
}
+ case FPFIELD_list_label:
+ {
+ char szFieldValue[FPFIELD_MAX_LENGTH + 1];
+
+ UT_UCS_strcpy_char(sz_ucs_FieldValue, m_pBL->getListLabel());
+ break;
+ }
default:
UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
return UT_FALSE;
@@ -832,6 +839,7 @@
m_pFontLayout = pLayout->findFont(pSpanAP,pBlockAP,pSectionAP,
FL_DocLayout::FIND_FONT_AT_LAYOUT_RESOLUTION),
UT_parseColor(PP_evalProperty("color",pSpanAP,pBlockAP,pSectionAP,
m_pBL->getDocument(), UT_TRUE), m_colorFG);
+ UT_parseColor(PP_evalProperty("field-color",pSpanAP,pBlockAP,pSectionAP,
+m_pBL->getDocument(), UT_TRUE), m_colorBG);
m_pG->setFont(m_pFont);
m_iAscent = m_pG->getFontAscent();
@@ -931,7 +939,6 @@
*/
UT_RGBColor clrSelBackground(112, 112, 112);
- UT_RGBColor clrNormalBackground(220, 220, 220);
UT_sint32 iFillHeight = m_pLine->getHeight();
UT_sint32 iFillTop = pDA->yoff - m_pLine->getAscent();
@@ -954,7 +961,7 @@
}
else
{
- m_pG->fillRect(clrNormalBackground, pDA->xoff, iFillTop,
m_iWidth, iFillHeight);
+ m_pG->fillRect(m_colorBG, pDA->xoff, iFillTop, m_iWidth,
+iFillHeight);
}
}
diff -Naur --exclude=CVS --exclude=Linux* abi/src/text/fmt/xp/fp_Run.h
abi-new/src/text/fmt/xp/fp_Run.h
--- abi/src/text/fmt/xp/fp_Run.h Sat Apr 29 20:53:46 2000
+++ abi-new/src/text/fmt/xp/fp_Run.h Sat Apr 29 20:29:29 2000
@@ -292,6 +292,9 @@
#define FPFIELD_TIME 1
#define FPFIELD_PAGE_NUMBER 2
#define FPFIELD_PAGE_COUNT 3
+<<<<<<< fp_Run.h
+#define FPFIELD_LIST_LABEL 4
+=======
*/
#define _FIELD(type,desc,tag) /*nothing*/
@@ -356,6 +359,7 @@
GR_Font* m_pFont;
GR_Font* m_pFontLayout;
UT_RGBColor m_colorFG;
+ UT_RGBColor m_colorBG;
UT_UCSChar m_sFieldValue[FPFIELD_MAX_LENGTH];
fp_FieldsEnum m_iFieldType;
};
diff -Naur --exclude=CVS --exclude=Linux* abi/src/text/fmt/xp/fv_View.cpp
abi-new/src/text/fmt/xp/fv_View.cpp
--- abi/src/text/fmt/xp/fv_View.cpp Sat Apr 29 20:53:47 2000
+++ abi-new/src/text/fmt/xp/fv_View.cpp Sat Apr 29 20:29:29 2000
@@ -34,6 +34,7 @@
#include "fl_DocLayout.h"
#include "fl_BlockLayout.h"
#include "fl_SectionLayout.h"
+#include "fl_AutoNum.h"
#include "fp_Page.h"
#include "fp_Column.h"
#include "fp_Line.h"
@@ -1067,6 +1068,7 @@
// as the previous (or none if the first paragraph in the section).
m_pDoc->insertStrux(getPoint(), PTX_Block);
+ _findGetCurrentBlock()->listUpdate();
if (bDidGlob)
m_pDoc->endUserAtomicGlob();
@@ -1570,6 +1572,70 @@
_fixInsertionPointCoords();
_drawInsertionPoint();
}
+
+ return bRet;
+}
+
+UT_Bool FV_View::cmdStartList(const XML_Char * style)
+{
+ XML_Char lid[15], buf[5];
+ UT_Bool bRet;
+ UT_uint32 id;
+
+ id = rand();
+ sprintf(lid, "%i", id);
+
+ fl_BlockLayout * pBlock = _findBlockAtPosition(getPoint());
+ UT_uint32 currLevel = pBlock->getLevel();
+ currLevel++;
+ sprintf(buf, "%i", currLevel);
+
+ const XML_Char * attribs[] = { "listid", lid,
+ "level", buf,
+ "style", style, 0 };
+
+ pBlock->setStarting();
+ bRet = m_pDoc->changeStruxFmt(PTC_AddFmt, getPoint(), getPoint(), attribs,
+NULL, PTX_Block);
+ pBlock->listUpdate();
+
+ _generalUpdate();
+
+ return bRet;
+}
+
+UT_Bool FV_View::cmdStopList(void)
+{
+ XML_Char lid[15], buf[5];
+ UT_Bool bRet;
+ UT_uint32 id;
+
+ fl_BlockLayout * pBlock = _findBlockAtPosition(getPoint());
+
+ UT_uint32 currLevel = pBlock->getLevel();
+ UT_ASSERT(currLevel > 0);
+ currLevel--;
+ sprintf(buf, "%i", currLevel);
+
+ if (currLevel == 0)
+ {
+ setStyle("Normal");
+ id = 0;
+ }
+ else
+ {
+ id = pBlock->getAutoNum()->getParent()->getID();
+ }
+ sprintf(lid, "%i", id);
+
+ const XML_Char * attribs[] = { "listid", lid,
+ "level", buf, 0 };
+
+ pBlock->setStopping();
+ bRet = m_pDoc->changeStruxFmt(PTC_AddFmt, getPoint(), getPoint(), attribs,
+NULL, PTX_Block);
+ if (currLevel != 0)
+ pBlock->listUpdate();
+
+ _generalUpdate();
return bRet;
}
diff -Naur --exclude=CVS --exclude=Linux* abi/src/text/fmt/xp/fv_View.h
abi-new/src/text/fmt/xp/fv_View.h
--- abi/src/text/fmt/xp/fv_View.h Sat Apr 29 20:53:47 2000
+++ abi-new/src/text/fmt/xp/fv_View.h Sat Apr 29 20:29:29 2000
@@ -158,6 +158,9 @@
UT_Bool setBlockFormat(const XML_Char * properties[]);
UT_Bool getBlockFormat(const XML_Char *** properties,UT_Bool
bExpandStyles=UT_TRUE);
+ UT_Bool cmdStartList(const XML_Char * style);
+ UT_Bool cmdStopList(void);
+
UT_Bool setCharFormat(const XML_Char * properties[]);
UT_Bool getCharFormat(const XML_Char *** properties,UT_Bool
bExpandStyles=UT_TRUE);
diff -Naur --exclude=CVS --exclude=Linux* abi/src/text/ptbl/xp/pp_Property.cpp
abi-new/src/text/ptbl/xp/pp_Property.cpp
--- abi/src/text/ptbl/xp/pp_Property.cpp Sat Apr 29 20:53:48 2000
+++ abi-new/src/text/ptbl/xp/pp_Property.cpp Sat Apr 29 20:29:29 2000
@@ -40,6 +40,7 @@
static PP_Property _props[] =
{
{ "color", "000000",
1},
+ { "field-color", "dcdcdc", 1},
{ "font-family", "Times New Roman", 1}, //
TODO this is Win32-specific. must fix!
{ "font-size", "14pt", 1},
// MS word defaults to 10pt, but it just seems too small
{ "font-stretch", "normal", 1},
@@ -55,6 +56,9 @@
{ "margin-right", "0in", 0},
{ "text-indent", "0in", 0},
{ "text-align", "left", 1},
+
+ { "start-value", "1", 1},
+ { "format", "%*%d.", 1},
{ "width", "",
0},
{ "height", "",
0},
diff -Naur --exclude=CVS --exclude=Linux* abi/src/text/ptbl/xp/pt_PT_Styles.cpp
abi-new/src/text/ptbl/xp/pt_PT_Styles.cpp
--- abi/src/text/ptbl/xp/pt_PT_Styles.cpp Sat Apr 29 20:53:49 2000
+++ abi-new/src/text/ptbl/xp/pt_PT_Styles.cpp Sat Apr 29 20:29:29 2000
@@ -49,6 +49,8 @@
_s("Heading 3", "P", "Normal", "Normal", "font-family:Arial; font-size:14pt;
margin-top:14pt; margin-bottom:3pt; keep-with-next:1");
_s("Plain Text","P", "Normal", "Plain Text", "font-family:Courier New");
_s("Block Text","P", "Normal", "Block Text", "margin-left:1in;
margin-right:1in; margin-bottom:6pt");
+ _s("Numbered List","P", "Normal", "Numbered List", "format:%*%d.;
+start-value:1; margin-left:0.25in; text-indent:-0.2500in; field-color: ffffff");
+ _s("Bulleted List", "P", "Numbered List", "Bulleted List", "format:%b");
return UT_TRUE;
diff -Naur --exclude=CVS --exclude=Linux* abi/src/text/ptbl/xp/pt_Types.h
abi-new/src/text/ptbl/xp/pt_Types.h
--- abi/src/text/ptbl/xp/pt_Types.h Sat Apr 29 20:53:49 2000
+++ abi-new/src/text/ptbl/xp/pt_Types.h Sat Apr 29 20:29:29 2000
@@ -75,6 +75,8 @@
#define PT_PROPS_ATTRIBUTE_NAME ((const XML_Char *)"props")
#define PT_STYLE_ATTRIBUTE_NAME ((const XML_Char *)"style")
+#define PT_LEVEL_ATTRIBUTE_NAME ((const XML_Char *)"level")
+#define PT_LISTID_ATTRIBUTE_NAME ((const XML_Char *)"listid")
#define PT_NAME_ATTRIBUTE_NAME ((const XML_Char *)"name")
#define PT_TYPE_ATTRIBUTE_NAME ((const XML_Char *)"type")
#define PT_BASEDON_ATTRIBUTE_NAME ((const XML_Char *)"basedon")
diff -Naur --exclude=CVS --exclude=Linux* abi/src/wp/ap/xp/ap_EditMethods.cpp
abi-new/src/wp/ap/xp/ap_EditMethods.cpp
--- abi/src/wp/ap/xp/ap_EditMethods.cpp Sat Apr 29 20:54:01 2000
+++ abi-new/src/wp/ap/xp/ap_EditMethods.cpp Sat Apr 29 20:29:29 2000
@@ -355,6 +355,10 @@
static EV_EditMethod_Fn viCmd_yw;
static EV_EditMethod_Fn viCmd_yy;
+ static EV_EditMethod_Fn listStartNumbered;
+ static EV_EditMethod_Fn listStartBulleted;
+ static EV_EditMethod_Fn listStop;
+
static EV_EditMethod_Fn noop;
// Test routines
@@ -634,6 +638,10 @@
EV_EditMethod(NF(viCmd_yb), 0, ""),
EV_EditMethod(NF(viCmd_yw), 0, ""),
EV_EditMethod(NF(viCmd_yy), 0, ""),
+
+ EV_EditMethod(NF(listStartNumbered), 0, ""),
+ EV_EditMethod(NF(listStartBulleted), 0, ""),
+ EV_EditMethod(NF(listStop), 0, ""),
EV_EditMethod(NF(noop), 0, ""),
@@ -4705,4 +4713,22 @@
{
//copy current line
return ( EX(warpInsPtBOL) && EX(extSelEOL) && EX(copy) );
+}
+
+Defun1(listStartNumbered)
+{
+ ABIWORD_VIEW;
+ return pView->cmdStartList("Numbered List");
+}
+
+Defun1(listStartBulleted)
+{
+ ABIWORD_VIEW;
+ return pView->cmdStartList("Bulleted List");
+}
+
+Defun1(listStop)
+{
+ ABIWORD_VIEW;
+ return pView->cmdStopList();
}
diff -Naur --exclude=CVS --exclude=Linux* abi/src/wp/ap/xp/ap_Menu_ActionSet.cpp
abi-new/src/wp/ap/xp/ap_Menu_ActionSet.cpp
--- abi/src/wp/ap/xp/ap_Menu_ActionSet.cpp Sat Apr 29 20:54:01 2000
+++ abi-new/src/wp/ap/xp/ap_Menu_ActionSet.cpp Sat Apr 29 20:29:29 2000
@@ -172,6 +172,9 @@
// ... add others here ...
+ _s(AP_MENU_ID_FMT_STARTLIST, 0,0,0, "listStartNumbered", NULL, NULL);
+ _s(AP_MENU_ID_FMT_STOPLIST, 0,0,0, "listStop", NULL, NULL);
+
_s(AP_MENU_ID__BOGUS2__, 0,0,0, NULL,
NULL, NULL);
#undef _s
diff -Naur --exclude=CVS --exclude=Linux* abi/src/wp/ap/xp/ap_Menu_Id.h
abi-new/src/wp/ap/xp/ap_Menu_Id.h
--- abi/src/wp/ap/xp/ap_Menu_Id.h Sat Apr 29 20:54:01 2000
+++ abi-new/src/wp/ap/xp/ap_Menu_Id.h Sat Apr 29 20:29:29 2000
@@ -145,6 +145,9 @@
/* ... add others here ... */
+ AP_MENU_ID_FMT_STARTLIST,
+ AP_MENU_ID_FMT_STOPLIST,
+
AP_MENU_ID__BOGUS2__ /* must be last */
};
diff -Naur --exclude=CVS --exclude=Linux* abi/src/wp/ap/xp/ap_Menu_LabelSet_en-US.h
abi-new/src/wp/ap/xp/ap_Menu_LabelSet_en-US.h
--- abi/src/wp/ap/xp/ap_Menu_LabelSet_en-US.h Sat Apr 29 20:54:01 2000
+++ abi-new/src/wp/ap/xp/ap_Menu_LabelSet_en-US.h Sat Apr 29 20:42:50 2000
@@ -144,6 +144,9 @@
// ... add others here ...
+ MenuLabel(AP_MENU_ID_FMT_STARTLIST, "Start List", "Temp")
+ MenuLabel(AP_MENU_ID_FMT_STOPLIST, "Stop List", "Temp")
+
MenuLabel(AP_MENU_ID__BOGUS2__, NULL,
NULL)
EndSet()
diff -Naur --exclude=CVS --exclude=Linux* abi/src/wp/ap/xp/ap_Menu_Layouts_MainMenu.h
abi-new/src/wp/ap/xp/ap_Menu_Layouts_MainMenu.h
--- abi/src/wp/ap/xp/ap_Menu_Layouts_MainMenu.h Sat Apr 29 20:54:01 2000
+++ abi-new/src/wp/ap/xp/ap_Menu_Layouts_MainMenu.h Sat Apr 29 20:29:29 2000
@@ -112,6 +112,9 @@
MenuItem(AP_MENU_ID_ALIGN_JUSTIFY)
EndSubMenu()
MenuItem(AP_MENU_ID_FMT_STYLE)
+ Separator()
+ MenuItem(AP_MENU_ID_FMT_STARTLIST)
+ MenuItem(AP_MENU_ID_FMT_STOPLIST)
EndSubMenu()
BeginSubMenu(AP_MENU_ID_TOOLS)