Index: abi/src/wp/ap/xp/ap_Dialog_Replace.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Dialog_Replace.cpp,v retrieving revision 1.42 diff -u -r1.42 ap_Dialog_Replace.cpp --- abi/src/wp/ap/xp/ap_Dialog_Replace.cpp 6 May 2003 22:57:48 -0000 1.42 +++ abi/src/wp/ap/xp/ap_Dialog_Replace.cpp 22 May 2003 09:46:24 -0000 @@ -47,10 +47,10 @@ m_pView = NULL; m_pFrame = NULL; - m_findString = NULL; - m_replaceString = NULL; - m_matchCase = false; + UT_DEBUGMSG(("AP_dlg_replace::AP_dlg_replace()\n")); + persist_reverseFind = false; + persist_wholeWord = false; m_didSomething = false; // is this used? @@ -63,8 +63,7 @@ { // UT_ASSERT(!m_bInUse); - FREEP(m_findString); - FREEP(m_replaceString); + UT_DEBUGMSG(("AP_dlg_replace::~AP_dlg_Replace()\n")); FREEP(persist_findString); FREEP(persist_replaceString); @@ -89,14 +88,6 @@ { UT_DEBUGMSG(("AP_Dialog_Replace::useStart(void) I've been called\n")); - // restore from persistent storage - if (persist_findString) - UT_UCS4_cloneString(&m_findString, persist_findString); - if (persist_replaceString) - UT_UCS4_cloneString(&m_replaceString, persist_replaceString); - - m_matchCase = persist_matchCase; - } void AP_Dialog_Replace::useEnd(void) @@ -108,14 +99,13 @@ if (m_didSomething) { FREEP(persist_findString); - if (m_findString) - UT_UCS4_cloneString(&persist_findString, m_findString); - + UT_UCS4_cloneString(&persist_findString, getFindString()); FREEP(persist_replaceString); - if (m_replaceString) - UT_UCS4_cloneString(&persist_replaceString, m_replaceString); + UT_UCS4_cloneString(&persist_replaceString, getReplaceString()); - persist_matchCase = m_matchCase; + persist_matchCase = getMatchCase(); + persist_reverseFind = getReverseFind(); + persist_wholeWord = getWholeWord(); } } @@ -183,23 +173,28 @@ bool AP_Dialog_Replace::setFindString(const UT_UCSChar * string) { - if (string && m_findString && UT_UCS4_strcmp(string, m_findString) != 0) + UT_DEBUGMSG(("AP_dlg_replace::setFindString()\n")); + + if (string && getFvView()->findGetFindString() && UT_UCS4_strcmp(string, getFvView()->findGetFindString()) != 0) { // When search parameters change, clear any existing selection to // avoid replacement of the previous search string. getFvView()->cmdUnselectSelection(); } - FREEP(m_findString); - return UT_UCS4_cloneString(&m_findString, string); + + return getFvView()->findSetFindString(string); } UT_UCSChar * AP_Dialog_Replace::getFindString(void) + { + UT_DEBUGMSG(("AP_dlg_replace::getFindString()\n")); + UT_UCSChar * string = NULL; - if (m_findString) + if (getFvView()->findGetFindString()) { - if (UT_UCS4_cloneString(&string, m_findString)) + if (UT_UCS4_cloneString(&string, getFvView()->findGetFindString())) return string; } else @@ -212,16 +207,20 @@ bool AP_Dialog_Replace::setReplaceString(const UT_UCSChar * string) { - FREEP(m_replaceString); - return UT_UCS4_cloneString(&m_replaceString, string); + UT_DEBUGMSG(("AP_dlg_replace::setReplaceString()\n")); + + return getFvView()->findSetReplaceString(string); } UT_UCSChar * AP_Dialog_Replace::getReplaceString(void) { + UT_DEBUGMSG(("AP_dlg_replace::getReplaceString()\n")); + UT_UCSChar * string = NULL; - if (m_replaceString) + + if (getFvView()->findGetReplaceString()) { - if (UT_UCS4_cloneString(&string, m_replaceString)) + if (UT_UCS4_cloneString(&string, getFvView()->findGetReplaceString())) return string; } else @@ -235,7 +234,9 @@ bool AP_Dialog_Replace::setMatchCase(bool match) { - if (match != m_matchCase) + UT_DEBUGMSG(("AP_dlg_replace::setMatchCase()\n")); + + if (match != getFvView()->findGetMatchCase()) { // When search parameters change, clear any existing selection to // avoid replacement of the previous search string. @@ -243,24 +244,67 @@ getFvView()->cmdUnselectSelection(); } - m_matchCase = match; - return true; + return getFvView()->findSetMatchCase(match); } bool AP_Dialog_Replace::getMatchCase(void) { - return m_matchCase; + UT_DEBUGMSG(("AP_dlg_replace::getMatchCase()\n")); + return getFvView()->findGetMatchCase(); +} + +bool AP_Dialog_Replace::setReverseFind(bool newValue) +{ + UT_DEBUGMSG(("AP_dlg_replace::setReverseFind()\n")); + + return getFvView()->findSetReverseFind(newValue); +} + +bool AP_Dialog_Replace::getReverseFind(void) +{ + UT_DEBUGMSG(("AP_dlg_replace::getReverseFind()\n")); + + return getFvView()->findGetReverseFind(); +} + +bool AP_Dialog_Replace::setWholeWord(bool newValue) +{ + UT_DEBUGMSG(("AP_dlg_replace::setWholeWord()\n")); + + return getFvView()->findSetWholeWord(newValue); +} + +bool AP_Dialog_Replace::getWholeWord(void) +{ + UT_DEBUGMSG(("AP_dlg_replace::getWholeWord()\n")); + + return getFvView()->findGetWholeWord(); } // --------------------------- Action Functions ----------------------------- -bool AP_Dialog_Replace::findNext() +bool AP_Dialog_Replace::findPrev() { - UT_ASSERT(m_findString); - //UT_ASSERT(m_replaceString); + UT_DEBUGMSG(("AP_dlg_replace::findPrev()\n")); + // so we save our attributes to persistent storage + m_didSomething = true; + + bool bDoneEntireDocument = false; + + // call view to do the work + bool result = getFvView()->findPrev(bDoneEntireDocument); + + if (bDoneEntireDocument == true) + _messageFinishedFind(); + + return result; +} + +bool AP_Dialog_Replace::findNext() +{ // manage the list of find strings - if (_manageList(&m_findList, m_findString)) + if (_manageList(&m_findList, getFindString())) { _updateLists(); } @@ -269,13 +313,29 @@ m_didSomething = true; bool bDoneEntireDocument = false; + + // call view to do the work + bool result = getFvView()->findNext(bDoneEntireDocument); + + if (bDoneEntireDocument == true) + _messageFinishedFind(); + + return result; +} + +bool AP_Dialog_Replace::findReplaceReverse() +{ + + // so we save our attributes to persistent storage + m_didSomething = true; - // update the view's automatic "find next" string - getFvView()->findSetNextString(m_findString, m_matchCase); + bool bDoneEntireDocument = false; + UT_DEBUGMSG(("AP_dlg_replace::findReplaceReverse()\n")); + // call view to do the work - bool result = getFvView()->findNext(m_findString, m_matchCase, - bDoneEntireDocument); + bool result = getFvView()->findReplaceReverse(bDoneEntireDocument); + if (bDoneEntireDocument == true) _messageFinishedFind(); @@ -302,12 +362,8 @@ bool bDoneEntireDocument = false; - // update the view's automatic "find next" string - getFvView()->findSetNextString(m_findString, m_matchCase); - // call view to do the work - bool result = getFvView()->findReplace(m_findString, m_replaceString, - m_matchCase, bDoneEntireDocument); + bool result = getFvView()->findReplace(bDoneEntireDocument); if (bDoneEntireDocument == true) _messageFinishedFind(); @@ -318,8 +374,8 @@ bool AP_Dialog_Replace::findReplaceAll() { - UT_ASSERT(m_findString); - UT_ASSERT(m_replaceString); +// UT_ASSERT(m_findString); +// UT_ASSERT(m_replaceString); // manage the list of find & replace strings bool var1 = _manageList(&m_findList, m_findString); @@ -332,13 +388,8 @@ // so we save our attributes to persistent storage m_didSomething = true; - // update the view's automatic "find next" string - getFvView()->findSetNextString(m_findString, m_matchCase); - // call view to do the work - UT_uint32 numReplaced = getFvView()->findReplaceAll(m_findString, - m_replaceString, - m_matchCase); + UT_uint32 numReplaced = getFvView()->findReplaceAll(); _messageFinishedReplace(numReplaced);