Well guys, I think this may be the first ZAPPED POW of the new
millenium. The url to the original POW announcement is
http://www.abisource.com/mailinglists/abiword-dev/01/January/0198.html.
Martin, would you be so kind as to check to see if this is what you
wanted? Everyone else, let me know what you think, and how it works.
Some notes: I changed one int to an unsigned int (you can see it in the
patch), because the compiler was complaining about comparison between
signed and unsigned. Shouldn't be a problem.
To actually do the zapping, though, what I did was create a new function
in AV_View base class to check whether the given *_View object was the
currently active/focused one. I believe this correctly belongs in the
base class because the functionality is generic across applications. To
do this, I also had to #include "xap_Frame.h" in xav_View.cpp, which I
also think makes sense (unless xap_Frame.h is alternately included
elsewhere).
Anything else? Oh yeah, there's a broken image on our homepage. :)
Next goal?
Take care,
John
Index: abi/src/af/xap/xp/xav_View.cpp
===================================================================
RCS file: /cvsroot/abi/src/af/xap/xp/xav_View.cpp,v
retrieving revision 1.15
diff -u -r1.15 xav_View.cpp
--- abi/src/af/xap/xp/xav_View.cpp 2000/11/12 14:45:19 1.15
+++ abi/src/af/xap/xp/xav_View.cpp 2001/01/25 04:41:28
@@ -21,6 +21,7 @@
#include "ut_types.h"
#include "xav_View.h"
#include "xav_Listener.h"
+#include "xap_Frame.h"
#include"ut_debugmsg.h"
AV_View::AV_View(XAP_App * pApp, void* pParentData)
@@ -131,6 +132,16 @@
}
return UT_TRUE;
+}
+
+UT_Bool AV_View::isActive(void) const
+{
+ AV_View* pActiveView = NULL;
+ XAP_Frame* lff = getApp()->getLastFocussedFrame();
+ if(lff) pActiveView = lff->getCurrentView();
+ else pActiveView = this;
+
+ return pActiveView == this;
}
UT_uint32 AV_View::getTick(void)
Index: abi/src/af/xap/xp/xav_View.h
===================================================================
RCS file: /cvsroot/abi/src/af/xap/xp/xav_View.h,v
retrieving revision 1.29
diff -u -r1.29 xav_View.h
--- abi/src/af/xap/xp/xav_View.h 2001/01/18 14:43:23 1.29
+++ abi/src/af/xap/xp/xav_View.h 2001/01/25 04:41:28
@@ -100,6 +100,7 @@
UT_Bool addListener(AV_Listener * pListener, AV_ListenerId *
pListenerId);
UT_Bool removeListener(AV_ListenerId listenerId);
+ UT_Bool isActive(void) const;
virtual UT_Bool notifyListeners(const AV_ChangeMask hint) = 0;
virtual UT_Bool canDo(UT_Bool bUndo) const = 0;
Index: abi/src/text/fmt/xp/fl_BlockLayout.cpp
===================================================================
RCS file: /cvsroot/abi/src/text/fmt/xp/fl_BlockLayout.cpp,v
retrieving revision 1.237
diff -u -r1.237 fl_BlockLayout.cpp
--- abi/src/text/fmt/xp/fl_BlockLayout.cpp 2001/01/24 17:28:29 1.237
+++ abi/src/text/fmt/xp/fl_BlockLayout.cpp 2001/01/25 04:41:32
@@ -371,7 +371,7 @@
{ "margin-right", &m_iRightMargin,
&m_iRightMarginLayoutUnits },
{ "text-indent", &m_iTextIndent,
&m_iTextIndentLayoutUnits }
};
- for (int iRg = 0; iRg < NrElements(rgProps); ++iRg)
+ for (unsigned int iRg = 0; iRg < NrElements(rgProps); ++iRg)
{
const MarginAndIndent_t& mai = rgProps[iRg];
const char* pszProp = getProperty((XML_Char*)mai.szProp);
@@ -2847,11 +2847,13 @@
UT_ASSERT(_validateBlockForPoint());
FV_View* pView = m_pLayout->getView();
- if (pView)
+ if (pView && pView->isActive())
{
- pView->_setPoint(pcrs->getPosition()+len);
+ pView->_setPoint(pcrs->getPosition() + len);
pView->notifyListeners(AV_CHG_FMTCHAR); // TODO verify that this is
necessary.
}
+ else if(pView && pView->getPoint() > pcrs->getPosition())
+ pView->_setPoint(pView->getPoint() + len);
if (m_pLayout->hasBackgroundCheckReason(FL_DocLayout::bgcrSmartQuotes))
{
@@ -3020,10 +3022,16 @@
setNeedsReformat();
FV_View* pView = m_pLayout->getView();
- if (pView)
+ if (pView && pView->isActive())
{
pView->_resetSelection();
- pView->_setPoint(pcrs->getPosition());
+ pView->_setPoint(pcrs->getPosition());
+ }
+ else if(pView && pView->getPoint() > pcrs->getPosition())
+ {
+ if(pView->getPoint() <= pcrs->getPosition() + len)
+ pView->_setPoint(pcrs->getPosition());
+ else pView->_setPoint(pView->getPoint() - len);
}
if (m_pLayout->getAutoSpellCheck())
@@ -3323,10 +3331,10 @@
m_pLayout->dequeueBlockForBackgroundCheck(this);
FV_View* pView = pSL->getDocLayout()->getView();
- if (pView)
- {
+ if (pView && pView->isActive())
pView->_setPoint(pcrx->getPosition());
- }
+ else if(pView && pView->getPoint() > pcrx->getPosition())
+ pView->_setPoint(pView->getPoint() - 1);
delete this; // TODO whoa! this construct is VERY
dangerous.
@@ -3400,10 +3408,9 @@
setNeedsReformat();
FV_View* pView = m_pLayout->getView();
- if (pView)
- {
+ if (pView && pView->isActive())
pView->_setPoint(pcrx->getPosition());
- }
+ else if (pView) pView->_setPoint(pView->getPoint() + fl_BLOCK_STRUX_OFFSET);
return UT_TRUE;
}
@@ -3567,10 +3574,10 @@
pNewBL->setNeedsReformat();
FV_View* pView = m_pLayout->getView();
- if (pView)
- {
+ if (pView && pView->isActive())
pView->_setPoint(pcrx->getPosition() + fl_BLOCK_STRUX_OFFSET);
- }
+ else if(pView && pView->getPoint() > pcrx->getPosition())
+ pView->_setPoint(pView->getPoint() + fl_BLOCK_STRUX_OFFSET);
#ifdef FASTSQUIGGLE
if (m_pLayout->getAutoSpellCheck() && m_vecSquiggles.getItemCount() > 0)
@@ -3649,10 +3656,14 @@
pOldSL->deleteEmptyColumns();
FV_View* pView = m_pLayout->getView();
- if (pView)
+ if (pView && pView->isActive())
{
pView->_setPoint(pcrx->getPosition() + fl_BLOCK_STRUX_OFFSET +
fl_BLOCK_STRUX_OFFSET);
}
+ else if(pView && pView->getPoint() > pcrx->getPosition())
+ {
+ pView->_setPoint(pView->getPoint() + fl_BLOCK_STRUX_OFFSET +
+fl_BLOCK_STRUX_OFFSET);
+ }
return UT_TRUE;
}
@@ -3772,11 +3783,10 @@
setNeedsReformat();
FV_View* pView = m_pLayout->getView();
- if (pView)
- {
- pView->_resetSelection();
+ if (pView && pView->isActive())
pView->_setPoint(pcro->getPosition() + 1);
- }
+ else if(pView && pView->getPoint() > pcro->getPosition())
+ pView->_setPoint(pView->getPoint() + 1);
if (m_pLayout->getAutoSpellCheck())
_insertSquiggles(blockOffset, 1); // TODO: are objects always
one wide?
@@ -3826,11 +3836,13 @@
setNeedsReformat();
FV_View* pView = m_pLayout->getView();
- if (pView)
+ if (pView && pView->isActive())
{
pView->_resetSelection();
pView->_setPoint(pcro->getPosition());
}
+ else if(pView && pView->getPoint() > pcro->getPosition())
+ pView->_setPoint(pView->getPoint() - 1);
if (m_pLayout->getAutoSpellCheck())
_deleteSquiggles(blockOffset, 1); // TODO: are objects always
one wide?
@@ -3883,7 +3895,7 @@
done:
setNeedsReformat();
- if (pView)
+ if (pView && pView->isActive())
{
pView->_resetSelection();
pView->_setPoint(pcroc->getPosition());
@@ -4125,10 +4137,12 @@
setNeedsReformat();
FV_View* pView = m_pLayout->getView();
+ if (pView && pView->isActive())
+ pView->_setPoint(pcrfm->getPosition());
+
if (pView)
{
pView->_resetSelection();
- pView->_setPoint(pcrfm->getPosition());
pView->notifyListeners(AV_CHG_FMTCHAR);
}
@@ -4153,7 +4167,7 @@
setNeedsReformat();
FV_View* pView = m_pLayout->getView();
- if (pView)
+ if (pView && pView->isActive())
{
pView->_resetSelection();
pView->_setPoint(pcrfm->getPosition());
@@ -4249,7 +4263,7 @@
setNeedsReformat();
FV_View* pView = m_pLayout->getView();
- if (pView)
+ if (pView && pView->isActive())
{
pView->_resetSelection();
pView->_setPoint(pcrfmc->getPosition());
Index: abi/src/text/fmt/xp/fl_DocListener.cpp
===================================================================
RCS file: /cvsroot/abi/src/text/fmt/xp/fl_DocListener.cpp,v
retrieving revision 1.93
diff -u -r1.93 fl_DocListener.cpp
--- abi/src/text/fmt/xp/fl_DocListener.cpp 2001/01/20 15:49:47 1.93
+++ abi/src/text/fmt/xp/fl_DocListener.cpp 2001/01/25 04:41:34
@@ -610,7 +610,7 @@
case PX_ChangeRecord::PXT_ChangePoint:
{
FV_View* pView = m_pLayout->getView();
- if (pView)
+ if (pView && pView->isActive())
pView->_setPoint(pcr->getPosition());
goto finish_up;
}