Patch: More filetype work


Subject: Patch: More filetype work
From: Andrew Dunbar (hippietrail@yahoo.com)
Date: Thu Jun 21 2001 - 10:58:55 CDT


I've removed all cases of this idiom:
#define IEFT_AbiWord_1 IE_Imp::fileTypeForSuffix(".abw")
since it hides the fact that import and export filetypes are not
interchangeable. It's not hard to type it the long way and
remember - #defines are evil (:

I haven't made it persistent in the dialog so please tell me if
you think that would be a better way.

I've also made the file dialog default to the last used filetype.
Load an RTF and when you do SaveAs, RTF will be set initially.

Andrew Dunbar.

-- 
http://linguaphile.sourceforge.net

Index: src/text/ptbl/xp/pd_Document.h =================================================================== RCS file: /cvsroot/abi/src/text/ptbl/xp/pd_Document.h,v retrieving revision 1.89 diff -u -r1.89 pd_Document.h --- src/text/ptbl/xp/pd_Document.h 2001/06/21 07:46:30 1.89 +++ src/text/ptbl/xp/pd_Document.h 2001/06/21 15:16:12 @@ -189,6 +189,7 @@ const char * getFileName() { return m_szFilename; } UT_uint32 getLastSavedAsType() { return m_lastSavedAsType; } + UT_uint32 getLastOpenedType() { return m_lastOpenedType; } XAP_App * getApp() { return m_pApp; } bool updateFields(void); bool getField(PL_StruxDocHandle sdh, Index: src/wp/ap/qnx/ap_QNXDialog_New.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/qnx/ap_QNXDialog_New.cpp,v retrieving revision 1.4 diff -u -r1.4 ap_QNXDialog_New.cpp --- src/wp/ap/qnx/ap_QNXDialog_New.cpp 2001/06/18 12:56:06 1.4 +++ src/wp/ap/qnx/ap_QNXDialog_New.cpp 2001/06/21 15:16:16 @@ -36,8 +36,6 @@ #include "xap_Dlg_FileOpenSaveAs.h" #include "ie_imp.h" -#define IEFT_AbiWord_1 IE_Imp::fileTypeForSuffix(".abw") - /*************************************************************************/ XAP_Dialog * AP_QNXDialog_New::static_constructor(XAP_DialogFactory * pFactory, @@ -169,7 +167,7 @@ pDialog->setFileTypeList(szDescList, szSuffixList, (const UT_sint32 *) nTypeList); - pDialog->setDefaultFileType(IEFT_AbiWord_1); + pDialog->setDefaultFileType(IE_Imp::fileTypeForSuffix(".abw")); pDialog->runModal(m_pFrame); Index: src/wp/ap/unix/ap_UnixDialog_New.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/unix/ap_UnixDialog_New.cpp,v retrieving revision 1.3 diff -u -r1.3 ap_UnixDialog_New.cpp --- src/wp/ap/unix/ap_UnixDialog_New.cpp 2001/05/26 03:14:47 1.3 +++ src/wp/ap/unix/ap_UnixDialog_New.cpp 2001/06/21 15:16:19 @@ -39,8 +39,6 @@ #include "xap_Dlg_FileOpenSaveAs.h" #include "ie_imp.h" -#define IEFT_AbiWord_1 IE_Imp::fileTypeForSuffix(".abw") - /*************************************************************************/ XAP_Dialog * AP_UnixDialog_New::static_constructor(XAP_DialogFactory * pFactory, @@ -162,7 +160,7 @@ pDialog->setFileTypeList(szDescList, szSuffixList, (const UT_sint32 *) nTypeList); - pDialog->setDefaultFileType(IEFT_AbiWord_1); + pDialog->setDefaultFileType(IE_Imp::fileTypeForSuffix(".abw")); pDialog->runModal(m_pFrame); Index: src/wp/ap/xp/ap_EditMethods.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_EditMethods.cpp,v retrieving revision 1.351 diff -u -r1.351 ap_EditMethods.cpp --- src/wp/ap/xp/ap_EditMethods.cpp 2001/06/20 14:58:27 1.351 +++ src/wp/ap/xp/ap_EditMethods.cpp 2001/06/21 15:16:45 @@ -906,7 +906,7 @@ Defun1(toggleAutoSpell) { - XAP_Frame * pFrame = static_cast<XAP_Frame *> ( pAV_View->getParentData()); + XAP_Frame * pFrame = static_cast<XAP_Frame *> ( pAV_View->getParentData()); UT_ASSERT(pFrame); XAP_App * pApp = pFrame->getApp(); @@ -1520,7 +1520,7 @@ UT_ASSERT(pFrame); char * pNewFile = NULL; - IEFileType ieft = IEFT_Bogus; + IEFileType ieft = static_cast<PD_Document *>(pFrame->getCurrentDoc())->getLastOpenedType(); bool bOK = s_AskForPathname(pFrame,false,NULL,&pNewFile,&ieft); if (!bOK || !pNewFile) @@ -1608,7 +1608,7 @@ UT_ASSERT(pFrame); char * pNewFile = NULL; - IEFileType ieft = IEFT_Bogus; + IEFileType ieft = static_cast<PD_Document *>(pFrame->getCurrentDoc())->getLastOpenedType(); bool bOK = s_AskForPathname(pFrame,false,NULL,&pNewFile,&ieft); if (!bOK || !pNewFile) @@ -1662,7 +1662,7 @@ XAP_Frame * pFrame = static_cast<XAP_Frame *> ( pAV_View->getParentData()); UT_ASSERT(pFrame); - IEFileType ieft = IEFT_Bogus; + IEFileType ieft = static_cast<PD_Document *>(pFrame->getCurrentDoc())->getLastSavedAsType(); char * pNewFile = NULL; bool bOK = s_AskForPathname(pFrame,true,NULL,&pNewFile,&ieft); @@ -1713,7 +1713,7 @@ UT_ASSERT(pFrame); char * pNewFile = NULL; - IEFileType ieft = IEFT_Bogus; + IEFileType ieft = static_cast<PD_Document *>(pFrame->getCurrentDoc())->getLastOpenedType(); bool bOK = s_AskForPathname(pFrame,false,NULL,&pNewFile,&ieft); if (!bOK || !pNewFile) @@ -1779,11 +1779,9 @@ UT_Error errSaved = UT_OK; - #define IEFT_HTML IE_Exp::fileTypeForSuffix(".html") - // we do this because we don't want to change the default // document extension or rename what we're working on - errSaved = pAV_View->cmdSaveAs(szTempFileName, IEFT_HTML, false); + errSaved = pAV_View->cmdSaveAs(szTempFileName, IE_Exp::fileTypeForSuffix(".html"), false); if(errSaved != UT_OK) { @@ -5288,7 +5286,7 @@ // don't do anything if fullscreen if (pFrameData->m_bIsFullScreen) - return false; + return false; // toggle the ruler bit pFrameData->m_bShowBar[0] = ! pFrameData->m_bShowBar[0]; Index: src/wp/impexp/xp/ie_exp.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_exp.cpp,v retrieving revision 1.51 diff -u -r1.51 ie_exp.cpp --- src/wp/impexp/xp/ie_exp.cpp 2001/06/21 07:46:36 1.51 +++ src/wp/impexp/xp/ie_exp.cpp 2001/06/21 15:16:49 @@ -36,8 +36,6 @@ #include "pd_Document.h" -#define IEFT_AbiWord_1 IE_Exp::fileTypeForSuffix(".abw") - static UT_Vector m_sniffers(20); /*****************************************************************/ @@ -291,7 +289,7 @@ IEFileType IE_Exp::fileTypeForSuffix(const char * szSuffix) { if (!szSuffix) - return IEFT_AbiWord_1; + return IE_Exp::fileTypeForSuffix(".abw"); // we have to construct the loop this way because a // given filter could support more than one file type, @@ -313,13 +311,13 @@ // Hm... an exporter has registered for the given suffix, // bug refuses to support any file type we request. // Default to native format. - return IEFT_AbiWord_1; + return IE_Exp::fileTypeForSuffix(".abw"); } } // No filter is registered for that extension, try native format // for default export. - return IEFT_AbiWord_1; + return IE_Exp::fileTypeForSuffix(".abw"); } @@ -412,7 +410,7 @@ // if that fails, just give up. *ppie = new IE_Exp_AbiWord_1(pDocument); if (pieft != NULL) - *pieft = IEFT_AbiWord_1; + *pieft = IE_Exp::fileTypeForSuffix(".abw"); return ((*ppie) ? UT_OK : UT_IE_NOMEMORY); } Index: src/wp/impexp/xp/ie_imp.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp.cpp,v retrieving revision 1.47 diff -u -r1.47 ie_imp.cpp --- src/wp/impexp/xp/ie_imp.cpp 2001/06/21 07:46:36 1.47 +++ src/wp/impexp/xp/ie_imp.cpp 2001/06/21 15:16:57 @@ -30,8 +30,6 @@ #include "ie_imp_GraphicAsDocument.h" #include "pd_Document.h" -#define IEFT_Text ((IEFileType)(IE_Imp::fileTypeForSuffix(".txt"))) - static UT_Vector m_sniffers (20); /*****************************************************************/ @@ -272,7 +270,7 @@ else { // as a last resort, just try importing it as text :( - ieft = IEFT_Text ; + ieft = IE_Imp::fileTypeForSuffix(".txt"); } }

_________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com



This archive was generated by hypermail 2b25 : Thu Jun 21 2001 - 10:57:02 CDT