? 6347.patch ? abi-gsf.patch ? ac-helpers/abi-gsf.m4 ? src/wp/impexp/xp/diff ? test/wp/BillOfRights.abw.SAVED Index: configure.ac =================================================================== RCS file: /cvsroot/abi/configure.ac,v retrieving revision 1.178 diff -u -p -u -p -r1.178 configure.ac --- configure.ac 30 Jan 2006 18:49:49 -0000 1.178 +++ configure.ac 20 Feb 2006 19:33:55 -0000 @@ -181,6 +181,7 @@ dnl some other places ABI_GNOME_QUICK ABI_GUCHARMAP ABI_XFT_QUICK +ABI_GSF abi_build_shared=yes abi_build_static=no @@ -387,8 +388,7 @@ ABI_XML_PARSER dnl check for wv -ABI_NEED_WV="yes" -ABI_WV($abi_rootdir/wv) +ABI_WV dnl check for zlib. ABI_ZLIB Index: includes.mk =================================================================== RCS file: /cvsroot/abi/includes.mk,v retrieving revision 1.61 diff -u -p -u -p -r1.61 includes.mk --- includes.mk 30 Jan 2006 12:56:36 -0000 1.61 +++ includes.mk 20 Feb 2006 19:33:55 -0000 @@ -112,7 +112,7 @@ ABI_CFLAGS=@WARNING_CFLAGS@ @DEBUG_CFLAG @PROFILE_CFLAGS@ @XML_CFLAGS@ @SCRIPT_CFLAGS@ @PLUGIN_CFLAGS@ @FRIBIDI_CFLAGS@ \ @WV_CFLAGS@ @LIBPOPT_CFLAGS@ @XFT_CFLAGS@ @FREETYPE_CFLAGS@ \ @LIBPNG_CFLAGS@ @ZLIB_CFLAGS@ @THREAD_CFLAGS@ @ABI_FEATURE_DEFS@ @ABITYPES_CFLAGS@ \ - @PRINT_CFLAGS@ + @PRINT_CFLAGS@ @GSF_CFLAGS@ if WITH_WIN32 @@ -145,7 +145,7 @@ ABI_BE = @ABI_BE@ ABI_GNOME_PREFIX = Gnome OTHER_LIBS=@SPELL_LIBS@ @XML_LIBS@ @SCRIPT_LIBS@ @PLUGIN_LIBS@ @FRIBIDI_LIBS@ \ - @WV_LIBS@ @GLIB_LIBS@ @ICONV_LIBS@ @LIBPNG_LIBS@ @ZLIB_LIBS@ \ + @WV_LIBS@ @GSF_LIBS@ @GLIB_LIBS@ @ICONV_LIBS@ @LIBPNG_LIBS@ @ZLIB_LIBS@ \ @LIBPOPT_LIBS@ @XFT_LIBS@ @FREETYPE_LIBS@ @THREAD_LIBS@ # BiDi needs a specific lib Index: src/af/ev/unix/ev_UnixToolbar.cpp =================================================================== RCS file: /cvsroot/abi/src/af/ev/unix/ev_UnixToolbar.cpp,v retrieving revision 1.141 diff -u -p -u -p -r1.141 ev_UnixToolbar.cpp --- src/af/ev/unix/ev_UnixToolbar.cpp 5 Jul 2005 14:08:19 -0000 1.141 +++ src/af/ev/unix/ev_UnixToolbar.cpp 20 Feb 2006 19:33:57 -0000 @@ -763,11 +763,8 @@ bool EV_UnixToolbar::synthesize(void) // GtkWidget * abi_table = abi_table_new(); gtk_widget_show(abi_table); - UT_DEBUGMSG(("SEVIOR: Made insert table widget \n")); g_signal_connect(abi_table, "selected", - G_CALLBACK (_wd::s_new_table), static_cast(wd)); - - UT_DEBUGMSG(("SEVIOR: Made connected to callback \n")); + G_CALLBACK (_wd::s_new_table), static_cast(wd)); abi_table_embed_on_toolbar(ABI_TABLE(abi_table), GTK_TOOLBAR(m_wToolbar)); gtk_widget_show_all(abi_table); gtk_widget_hide(ABI_TABLE(abi_table)->label); Index: src/af/gr/xp/gr_Graphics.cpp =================================================================== RCS file: /cvsroot/abi/src/af/gr/xp/gr_Graphics.cpp,v retrieving revision 1.154 diff -u -p -u -p -r1.154 gr_Graphics.cpp --- src/af/gr/xp/gr_Graphics.cpp 4 Dec 2005 09:32:36 -0000 1.154 +++ src/af/gr/xp/gr_Graphics.cpp 20 Feb 2006 19:33:58 -0000 @@ -123,8 +123,7 @@ GR_CharWidths* GR_Font::newFontWidths(vo } GR_Graphics::GR_Graphics() - : m_pApp(NULL), - m_iZoomPercentage(100), + : m_iZoomPercentage(100), m_iFontAllocNo(0), m_pRect(NULL), m_bHave3DColors(false), @@ -1220,8 +1219,8 @@ bool GR_Graphics::canBreak(GR_RenderInfo UT_return_val_if_fail(ri.m_pText->getStatus() == UTIter_OK, false); // Fetch a pointer to the Encoding manager. - UT_return_val_if_fail(getApp(), false); - const XAP_EncodingManager *encMan = getApp()->getEncodingManager(); + UT_return_val_if_fail(XAP_App::getApp(), false); + const XAP_EncodingManager *encMan = XAP_App::getApp()->getEncodingManager(); UT_return_val_if_fail(encMan, false); // Set up c[] appropriately depending on whether we're looking Index: src/af/gr/xp/gr_Graphics.h =================================================================== RCS file: /cvsroot/abi/src/af/gr/xp/gr_Graphics.h,v retrieving revision 1.153 diff -u -p -u -p -r1.153 gr_Graphics.h --- src/af/gr/xp/gr_Graphics.h 4 Dec 2005 09:32:36 -0000 1.153 +++ src/af/gr/xp/gr_Graphics.h 20 Feb 2006 19:33:59 -0000 @@ -751,8 +751,6 @@ class ABI_EXPORT GR_Graphics virtual GR_Image * genImageFromRectangle(const UT_Rect & r) = 0; - XAP_App * getApp() const {return m_pApp;} - private: virtual bool _setTransform(const GR_Transform & tr) { @@ -778,7 +776,6 @@ class ABI_EXPORT GR_Graphics UT_uint32 m_iRasterPosition; protected: - XAP_App * m_pApp; UT_uint32 m_iZoomPercentage; UT_uint32 m_iFontAllocNo; Index: src/af/util/unix/ut_debugmsg.cpp =================================================================== RCS file: /cvsroot/abi/src/af/util/unix/ut_debugmsg.cpp,v retrieving revision 1.10 diff -u -p -u -p -r1.10 ut_debugmsg.cpp --- src/af/util/unix/ut_debugmsg.cpp 17 Oct 2004 00:40:30 -0000 1.10 +++ src/af/util/unix/ut_debugmsg.cpp 20 Feb 2006 19:33:59 -0000 @@ -28,7 +28,7 @@ void _UT_OutputMessage(const char *s, ...) { -#ifdef UT_DEBUG +#if 0 char sBuf[20*1024]; va_list marker; Index: src/af/util/unix/ut_unixAssert.cpp =================================================================== RCS file: /cvsroot/abi/src/af/util/unix/ut_unixAssert.cpp,v retrieving revision 1.1 diff -u -p -u -p -r1.1 ut_unixAssert.cpp --- src/af/util/unix/ut_unixAssert.cpp 12 Nov 1998 16:05:33 -0000 1.1 +++ src/af/util/unix/ut_unixAssert.cpp 20 Feb 2006 19:33:59 -0000 @@ -27,6 +27,7 @@ void UT_UnixAssertMsg(const char * szMsg, const char * szFile, int iLine) { +#if 0 static int count = 0; printf("\n"); @@ -58,6 +59,7 @@ void UT_UnixAssertMsg(const char * szMsg break; // ?? ask them again } } +#endif } #endif // NDEBUG Index: src/af/util/xp/ut_bytebuf.cpp =================================================================== RCS file: /cvsroot/abi/src/af/util/xp/ut_bytebuf.cpp,v retrieving revision 1.15 diff -u -p -u -p -r1.15 ut_bytebuf.cpp --- src/af/util/xp/ut_bytebuf.cpp 4 Feb 2003 09:39:40 -0000 1.15 +++ src/af/util/xp/ut_bytebuf.cpp 20 Feb 2006 19:33:59 -0000 @@ -26,6 +26,9 @@ #include "ut_types.h" #include "ut_bytebuf.h" +#include +#include + #define DEFAULT_CHUNK 1024 #define MIN_CHUNK 256 @@ -189,6 +192,26 @@ void UT_ByteBuf::truncate(UT_uint32 posi } } +bool UT_ByteBuf::insertFromURI(UT_uint32 iPosition, const char *szURI) +{ + GsfInput *fp = go_file_open(szURI, NULL); + if(!fp) + return false; + + UT_uint32 iLengthOfFile = gsf_input_size(fp); + + // create a lot of space initialized to 0s + this->ins (iPosition, iLengthOfFile); + + UT_Byte *pBuf = m_pBuf + iPosition; + + gsf_input_read(fp, iLengthOfFile, pBuf); + + g_object_unref(G_OBJECT(fp)); + return true; +} + + bool UT_ByteBuf::insertFromFile(UT_uint32 iPosition, FILE * fp) { UT_uint32 iLengthOfFile = ftell (fp); Index: src/af/util/xp/ut_bytebuf.h =================================================================== RCS file: /cvsroot/abi/src/af/util/xp/ut_bytebuf.h,v retrieving revision 1.12 diff -u -p -u -p -r1.12 ut_bytebuf.h --- src/af/util/xp/ut_bytebuf.h 2 Dec 2002 16:59:48 -0000 1.12 +++ src/af/util/xp/ut_bytebuf.h 20 Feb 2006 19:33:59 -0000 @@ -66,6 +66,7 @@ public: const UT_Byte * getPointer(UT_uint32 position) const; /* temporary use only */ bool writeToFile(const char* pszFileName) const; bool insertFromFile(UT_uint32 iPosition, const char* pszFilename); + bool insertFromURI(UT_uint32 iPosition, const char* pszURI); bool insertFromFile(UT_uint32 iPosition, FILE * fp); private: Index: src/af/xap/unix/xap_UnixApp.cpp =================================================================== RCS file: /cvsroot/abi/src/af/xap/unix/xap_UnixApp.cpp,v retrieving revision 1.108 diff -u -p -u -p -r1.108 xap_UnixApp.cpp --- src/af/xap/unix/xap_UnixApp.cpp 30 Jan 2006 12:57:49 -0000 1.108 +++ src/af/xap/unix/xap_UnixApp.cpp 20 Feb 2006 19:34:00 -0000 @@ -56,6 +56,12 @@ #include "gr_UnixGraphics.h" #include "gr_UnixPangoGraphics.h" +#include + +#ifdef HAVE_GNOME +#include +#endif + #define _USE_PANGO UnixNull_Graphics * abi_unixnullgraphics_instance = 0; @@ -173,6 +179,12 @@ bool XAP_UnixApp::initialize(const char XAP_App::initialize(szKeyBindingsKey, szKeyBindingsDefaultValue); + gsf_init(); + +#ifdef HAVE_GNOME + gnome_vfs_init(); +#endif + /*******************************/ // load the font stuff from the font directory Index: src/af/xap/unix/xap_UnixDlg_FileOpenSaveAs.cpp =================================================================== RCS file: /cvsroot/abi/src/af/xap/unix/xap_UnixDlg_FileOpenSaveAs.cpp,v retrieving revision 1.135 diff -u -p -u -p -r1.135 xap_UnixDlg_FileOpenSaveAs.cpp --- src/af/xap/unix/xap_UnixDlg_FileOpenSaveAs.cpp 26 Jan 2006 12:48:44 -0000 1.135 +++ src/af/xap/unix/xap_UnixDlg_FileOpenSaveAs.cpp 20 Feb 2006 19:34:00 -0000 @@ -195,7 +195,6 @@ bool XAP_UnixDialog_FileOpenSaveAs::_run char * szFinalPathnameCopy = NULL; // one to mangle when looking for dirs, etc. char * pLastSlash; - struct stat buf; int err; // if m_bSave is not set, we're looking to OPEN a file. @@ -208,7 +207,7 @@ bool XAP_UnixDialog_FileOpenSaveAs::_run if (m_answer == a_CANCEL) // The easy way out return false; - UT_cloneString(m_szFinalPathnameCandidate, gtk_file_chooser_get_filename(m_FC)); + UT_cloneString(m_szFinalPathnameCandidate, gtk_file_chooser_get_uri(m_FC)); UT_ASSERT(m_szFinalPathnameCandidate); return (m_answer == a_OK); } @@ -223,7 +222,7 @@ bool XAP_UnixDialog_FileOpenSaveAs::_run // Give us a filename we can mangle - UT_cloneString(szDialogFilename, gtk_file_chooser_get_filename(m_FC)); + UT_cloneString(szDialogFilename, gtk_file_chooser_get_uri(m_FC)); if (!szDialogFilename) continue; @@ -267,10 +266,14 @@ bool XAP_UnixDialog_FileOpenSaveAs::_run UT_DEBUGMSG(("UseSuffix: %d\n", wantSuffix)); +#if 0 + struct stat buf; + // do not want suffix for directory names err = stat(szDialogFilename, &buf); if (S_ISDIR(buf.st_mode)) wantSuffix = false; +#endif // if the file doesn't have a suffix already, and the file type // is normal (special types are negative, like auto detect), @@ -307,8 +310,10 @@ bool XAP_UnixDialog_FileOpenSaveAs::_run FREEP(szDialogFilename); } - UT_cloneString(szFinalPathnameCopy, szFinalPathname); - + UT_cloneString(m_szFinalPathnameCandidate, szFinalPathname); + goto ReturnTrue; + +#if 0 err = stat(szFinalPathnameCopy, &buf); UT_ASSERT(err == 0 || err == -1); @@ -373,6 +378,7 @@ bool XAP_UnixDialog_FileOpenSaveAs::_run UT_cloneString(m_szFinalPathnameCandidate, szFinalPathname); goto ReturnTrue; } +#endif // complain about write permission on the directory. // lop off ugly trailing slash only if we don't have @@ -435,7 +441,7 @@ void XAP_UnixDialog_FileOpenSaveAs::file { return; } - UT_String sFileName = gtk_file_chooser_get_filename(m_FC); + UT_String sFileName = gtk_file_chooser_get_uri(m_FC); UT_String sSuffix = m_szSuffixes[nFileType-1]; sSuffix = sSuffix.substr(1,sSuffix.length()-1); UT_sint32 i = 0; @@ -605,6 +611,7 @@ void XAP_UnixDialog_FileOpenSaveAs::runM GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, (gchar*)NULL) ); + gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER(m_FC), FALSE); #endif abiSetupModalDialog(GTK_DIALOG(m_FC), pFrame, this, GTK_RESPONSE_ACCEPT); @@ -623,6 +630,7 @@ void XAP_UnixDialog_FileOpenSaveAs::runM gtk_widget_show(pulldown_hbox); gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(m_FC), pulldown_hbox); +#if 0 if (m_id == XAP_DIALOG_ID_INSERT_PICTURE) { GtkWidget * preview = createDrawingArea (); @@ -646,6 +654,7 @@ void XAP_UnixDialog_FileOpenSaveAs::runM g_signal_connect (preview, "expose_event", G_CALLBACK (s_preview_exposed), static_cast(this)); } +#endif // pulldown label GtkWidget * filetypes_label = gtk_label_new(szFileTypeLabel.utf8_str()); @@ -828,7 +837,7 @@ void XAP_UnixDialog_FileOpenSaveAs::runM } } } - gtk_file_chooser_set_filename(m_FC, m_szInitialPathname); + gtk_file_chooser_set_uri(m_FC, m_szInitialPathname); } else { @@ -890,7 +899,7 @@ gint XAP_UnixDialog_FileOpenSaveAs::prev GR_UnixAllocInfo ai(m_preview->window, unixapp->getFontManager(), m_pApp); GR_UnixGraphics* pGr = (GR_UnixGraphics*) XAP_App::getApp()->newGraphics(ai); - const gchar * file_name = gtk_file_chooser_get_filename (m_FC); + const gchar * file_name = gtk_file_chooser_get_uri (m_FC); GR_Font * fnt = pGr->findFont("Times New Roman", "normal", "", "normal", "", "12pt"); pGr->setFont(fnt); Index: src/text/ptbl/xp/pd_Document.cpp =================================================================== RCS file: /cvsroot/abi/src/text/ptbl/xp/pd_Document.cpp,v retrieving revision 1.380 diff -u -p -u -p -r1.380 pd_Document.cpp --- src/text/ptbl/xp/pd_Document.cpp 11 Dec 2005 10:06:44 -0000 1.380 +++ src/text/ptbl/xp/pd_Document.cpp 20 Feb 2006 19:34:08 -0000 @@ -68,6 +68,9 @@ #include "fl_DocListener.h" #include "fl_DocLayout.h" +#include +#include + // our currently used DTD #define ABIWORD_FILEFORMAT_VERSION "1.1" @@ -430,6 +433,7 @@ UT_Error PD_Document::readFromFile(const return UT_INVALIDFILENAME; } +#if 0 if ( !UT_isRegularFile(szFilename) ) { UT_DEBUGMSG (("PD_Document::readFromFile -- file (%s) is not plain file\n",szFilename)); @@ -441,6 +445,7 @@ UT_Error PD_Document::readFromFile(const UT_DEBUGMSG(("PD_Document::readFromFile -- file (%s) is empty\n",szFilename)); return UT_IE_BOGUSDOCUMENT; } +#endif m_pPieceTable = new pt_PieceTable(this); if (!m_pPieceTable) @@ -457,8 +462,11 @@ UT_Error PD_Document::readFromFile(const buildTemplateList (template_list, "normal.awt"); bool success = false; - for (UT_uint32 i = 0; i < 6 && !success; i++) - success = (importStyles(template_list[i].c_str(), ieft, true) == UT_OK); + for (UT_uint32 i = 0; i < 6 && !success; i++) { + char * uri = go_filename_to_uri (template_list[i].c_str()); + success = (importStyles(uri, ieft, true) == UT_OK); + g_free (uri); + } // don't worry if this fails } @@ -624,8 +632,11 @@ UT_Error PD_Document::newDocument(void) bool success = false; - for (UT_uint32 i = 0; i < 6 && !success; i++) - success = (importFile (template_list[i].c_str(), IEFT_Unknown, true, false) == UT_OK); + for (UT_uint32 i = 0; i < 6 && !success; i++) { + char * uri = go_filename_to_uri (template_list[i].c_str()); + success = (importFile (uri, IEFT_Unknown, true, false) == UT_OK); + g_free (uri); + } if (!success) { m_pPieceTable = new pt_PieceTable(this); @@ -1857,7 +1868,7 @@ bool PD_Document::isEndFootnoteAtPos(PT_ { pf = pf->getPrev(); } - if(pf->getPos() < pos) + if(!pf || (pf->getPos() < pos)) { return false; } Index: src/text/ptbl/xp/pp_AttrProp.cpp =================================================================== RCS file: /cvsroot/abi/src/text/ptbl/xp/pp_AttrProp.cpp,v retrieving revision 1.102 diff -u -p -u -p -r1.102 pp_AttrProp.cpp --- src/text/ptbl/xp/pp_AttrProp.cpp 1 Dec 2005 12:16:37 -0000 1.102 +++ src/text/ptbl/xp/pp_AttrProp.cpp 20 Feb 2006 19:34:08 -0000 @@ -987,7 +987,7 @@ void PP_AttrProp::_clearEmptyProperties( { const PropertyPair* p = pEntry; - if(*(p->first()) == 0) + if(p->first() && *(p->first()) == 0) { XML_Char* tmp = const_cast(p->first()); Index: src/wp/ap/xp/ap_App.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_App.cpp,v retrieving revision 1.14 diff -u -p -u -p -r1.14 ap_App.cpp --- src/wp/ap/xp/ap_App.cpp 21 Jun 2005 17:32:59 -0000 1.14 +++ src/wp/ap/xp/ap_App.cpp 20 Feb 2006 19:34:09 -0000 @@ -56,8 +56,10 @@ bool AP_App::openCmdLineFiles(AP_Args * while ((file = poptGetArg (poptcon)) != NULL) { XAP_Frame * pFrame = newFrame(); - UT_Error error = pFrame->loadDocument - (file, IEFT_Unknown, true); + char * uri = go_shell_arg_to_uri (file); + UT_Error error = pFrame->loadDocument (uri, IEFT_Unknown, true); + g_free (uri); + if (!error) { kWindowsOpened++; Index: src/wp/ap/xp/ap_Args.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Args.cpp,v retrieving revision 1.34 diff -u -p -u -p -r1.34 ap_Args.cpp --- src/wp/ap/xp/ap_Args.cpp 16 Oct 2005 14:03:19 -0000 1.34 +++ src/wp/ap/xp/ap_Args.cpp 20 Feb 2006 19:34:09 -0000 @@ -45,7 +45,6 @@ int AP_Args::m_iDumpstrings = 0; #endif const char * AP_Args::m_sGeometry = NULL; const char * AP_Args::m_sTo = NULL; -int AP_Args::m_iToPNG = 0; const char * AP_Args::m_sPrintTo = NULL; int AP_Args::m_iVerbose = 1; const char * AP_Args::m_sPlugin = NULL; @@ -169,23 +168,10 @@ bool AP_Args::doWindowlessArgs() return false; } - if (m_iToPNG) { - AP_Convert * conv = new AP_Convert(); - conv->setVerbose(m_iVerbose); -// this has the problem that it calls the convertToPNG method on -// ie_impGraphicPNG, which perhaps doesn't like you freeing the -// returned buffer. - while ((m_sFile = poptGetArg (poptcon)) != NULL) - conv->convertToPNG(m_sFile); - delete conv; - - return false; - } - if (!m_pApp->doWindowlessArgs(this)) return false; - if (m_sTo || m_iToPNG || m_sPrintTo || m_iNosplash || m_sPlugin) + if (m_sTo || m_sPrintTo || m_iNosplash || m_sPlugin) { m_bShowSplash = false; } @@ -205,7 +191,6 @@ const struct poptOption AP_Args::const_o {"dumpstrings", 'd', POPT_ARG_NONE, &m_iDumpstrings, 0, "Dump strings to file", NULL}, #endif {"to", 't', POPT_ARG_STRING, &m_sTo, 0, "Target format of the file (abw, zabw, rtf, txt, utf8, html, latex)", "FORMAT"}, - {"to-png", '\0', POPT_ARG_NONE, &m_iToPNG, 0, "Convert incoming file to a PNG image", ""}, {"verbose", 'v', POPT_ARG_INT, &m_iVerbose, 0, "Set verbosity level (0, 1, 2)", "LEVEL"}, #ifdef WIN32 {"print", 'p',POPT_ARG_STRING,&m_sPrintTo,0,"Print this file to printer","'Printer name' or '-' for default printer"}, Index: src/wp/ap/xp/ap_Convert.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Convert.cpp,v retrieving revision 1.34 diff -u -p -u -p -r1.34 ap_Convert.cpp --- src/wp/ap/xp/ap_Convert.cpp 16 Oct 2005 04:20:48 -0000 1.34 +++ src/wp/ap/xp/ap_Convert.cpp 20 Feb 2006 19:34:09 -0000 @@ -209,7 +209,9 @@ void AP_Convert::convertTo(const char * PD_Document * pNewDoc = new PD_Document(XAP_App::getApp()); UT_return_if_fail(pNewDoc); - error = pNewDoc->readFromFile(szSourceFilename, sourceFormat, m_impProps.utf8_str()); + char * uri = go_shell_arg_to_uri (szSourceFilename); + error = pNewDoc->readFromFile(uri, sourceFormat, m_impProps.utf8_str()); + g_free (uri); if (error != UT_OK) { switch (error) { @@ -233,11 +235,19 @@ void AP_Convert::convertTo(const char * } if (m_mergeSource.size()) { - IE_MailMerge::IE_MailMerge_Listener * listener = new Save_MailMerge_Listener (pNewDoc, szTargetFilename, targetFormat, m_expProps); - handleMerge (m_mergeSource.utf8_str(), *listener); + uri = go_shell_arg_to_uri (szTargetFilename); + IE_MailMerge::IE_MailMerge_Listener * listener = new Save_MailMerge_Listener (pNewDoc, uri, targetFormat, m_expProps); + g_free(uri); + + uri = go_shell_arg_to_uri (m_mergeSource.utf8_str()); + handleMerge (uri, *listener); + g_free (uri); DELETEP(listener); } else { - error = pNewDoc->saveAs(szTargetFilename, targetFormat, m_expProps.utf8_str()); + uri = go_shell_arg_to_uri (szTargetFilename); + error = pNewDoc->saveAs(uri, targetFormat, m_expProps.utf8_str()); + g_free(uri); + switch (error) { case UT_OK: if (m_iVerbose > 1) @@ -308,64 +318,17 @@ void AP_Convert::setVerbose(int level) m_iVerbose = level; } -void AP_Convert::convertToPNG ( const char * szSourceFileName ) -{ - // can't allocate src statically and then DELETEP. - // note that src goes into dest (shouldn't that be documented?) - // for consistency, we allocate UT_ByteBuf explicitly. - UT_ByteBuf *src = new UT_ByteBuf(); - UT_ByteBuf *dest = NULL ; - - if (szSourceFileName && src->insertFromFile (0, szSourceFileName)) - { - IE_ImpGraphic * pGraphic = NULL; - - if (UT_OK == IE_ImpGraphic::constructImporter (src, - IEGFT_Unknown, - &pGraphic)) - { - if (UT_OK == pGraphic->convertGraphic (src, &dest)) - { - // generate new filename with .png extension - char * fileDup = UT_strdup (szSourceFileName); - char * tmp = strrchr(fileDup, '.'); - if (tmp != NULL) - *tmp = '\0'; - - UT_String szDestFileName (fileDup); - szDestFileName += ".png"; - - FREEP(fileDup); - - if ( dest->writeToFile ( szDestFileName.c_str() ) ) - { - // success - DELETEP(dest); - DELETEP(pGraphic); - return; - } - } - } - - DELETEP (pGraphic); - } - - // failure - DELETEP (dest); - - printf ("Conversion to PNG failed\n"); -} - - void AP_Convert::print(const char * szFile, GR_Graphics * pGraphics, const char * szFileExtension) { // get the current document PD_Document *pDoc = new PD_Document(XAP_App::getApp()); UT_Error err; + char * uri = go_shell_arg_to_uri (szFile); if( !szFileExtension ) - err = pDoc->readFromFile(szFile, IEFT_Unknown, m_impProps.utf8_str()); + err = pDoc->readFromFile(uri, IEFT_Unknown, m_impProps.utf8_str()); else - err = pDoc->readFromFile(szFile, IE_Imp::fileTypeForSuffix(szFileExtension), m_impProps.utf8_str()); + err = pDoc->readFromFile(uri, IE_Imp::fileTypeForSuffix(szFileExtension), m_impProps.utf8_str()); + g_free (uri); if( err != UT_OK) { @@ -376,7 +339,9 @@ void AP_Convert::print(const char * szFi if (m_mergeSource.size()){ IE_MailMerge::IE_MailMerge_Listener * listener = new Print_MailMerge_Listener(pDoc, pGraphics, szFile); - handleMerge (m_mergeSource.utf8_str(), *listener); + uri = go_shell_arg_to_uri (szFile); + handleMerge (uri, *listener); + g_free (uri); DELETEP(listener); } else { Index: src/wp/ap/xp/ap_Convert.h =================================================================== RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Convert.h,v retrieving revision 1.14 diff -u -p -u -p -r1.14 ap_Convert.h --- src/wp/ap/xp/ap_Convert.h 6 Jun 2005 23:15:14 -0000 1.14 +++ src/wp/ap/xp/ap_Convert.h 20 Feb 2006 19:34:09 -0000 @@ -42,8 +42,6 @@ class ABI_EXPORT AP_Convert void convertTo(const char * szSourceFilename, const char * szTargetSuffixOrFilename); - void convertToPNG ( const char * szSourceFileName ) ; - void setVerbose(int level); void setMergeSource (const char * source); Index: src/wp/impexp/xp/ie_exp.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_exp.cpp,v retrieving revision 1.80 diff -u -p -u -p -r1.80 ie_exp.cpp --- src/wp/impexp/xp/ie_exp.cpp 30 Sep 2005 07:22:06 -0000 1.80 +++ src/wp/impexp/xp/ie_exp.cpp 20 Feb 2006 19:34:10 -0000 @@ -130,7 +130,7 @@ void IE_Exp::setProps (const char * prop m_props_map.parse_properties (props); } -bool IE_Exp::_openFile(const char * szFilename) +GsfOutput* IE_Exp::_openFile(const char * szFilename) { UT_return_val_if_fail(!m_fp, false); UT_return_val_if_fail(szFilename, false); @@ -138,11 +138,7 @@ bool IE_Exp::_openFile(const char * szFi m_szFileName = new char[strlen(szFilename) + 1]; strcpy(m_szFileName, szFilename); - // TODO add code to make a backup of the original file, if it exists. - - // Open file in binary mode or UCS-2 output will be mangled. - m_fp = fopen(szFilename,"wb+"); - return (m_fp != 0); + return go_file_create(szFilename, NULL); } UT_uint32 IE_Exp::_writeBytes(const UT_Byte * pBytes, UT_uint32 length) @@ -150,7 +146,8 @@ UT_uint32 IE_Exp::_writeBytes(const UT_B if(!pBytes || !length) return 0; - return fwrite(pBytes,sizeof(UT_Byte),length,m_fp); + gsf_output_write(m_fp, length, pBytes); + return length; } bool IE_Exp::_writeBytes(const UT_Byte * sz) @@ -161,8 +158,10 @@ bool IE_Exp::_writeBytes(const UT_Byte * bool IE_Exp::_closeFile(void) { - if (m_fp) - fclose(m_fp); + if (m_fp) { + gsf_output_close(m_fp); + g_object_unref(G_OBJECT(m_fp)); + } m_fp = 0; return true; } @@ -196,7 +195,7 @@ UT_Error IE_Exp::writeFile(const char * m_bCancelled = false; - if (!_openFile(szFilename)) + if (!(m_fp = _openFile(szFilename))) return m_bCancelled ? UT_SAVE_CANCELLED : UT_IE_COULDNOTWRITE; UT_Error error = _writeDocument(); Index: src/wp/impexp/xp/ie_exp.h =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_exp.h,v retrieving revision 1.42 diff -u -p -u -p -r1.42 ie_exp.h --- src/wp/impexp/xp/ie_exp.h 4 Oct 2004 12:50:58 -0000 1.42 +++ src/wp/impexp/xp/ie_exp.h 20 Feb 2006 19:34:10 -0000 @@ -28,6 +28,9 @@ #include "ut_AbiObject.h" #include "ie_types.h" +#include +#include + class PD_Document; class PD_DocumentRange; class UT_ByteBuf; @@ -145,7 +148,7 @@ protected: // derived classes should use these to open/close // and write data to the actual file. this will // let us handle file backups, etc. - virtual bool _openFile(const char * szFilename); + virtual GsfOutput* _openFile(const char * szFilename); virtual UT_uint32 _writeBytes(const UT_Byte * pBytes, UT_uint32 length); virtual bool _writeBytes(const UT_Byte * sz); virtual bool _closeFile(void); @@ -168,7 +171,7 @@ private: PD_DocumentRange * m_pDocRange; UT_ByteBuf * m_pByteBuf; char * m_szFileName; - FILE * m_fp; + GsfOutput * m_fp; bool m_bCancelled; Index: src/wp/impexp/xp/ie_exp_GZipAbiWord.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_exp_GZipAbiWord.cpp,v retrieving revision 1.20 diff -u -p -u -p -r1.20 ie_exp_GZipAbiWord.cpp --- src/wp/impexp/xp/ie_exp_GZipAbiWord.cpp 9 Jul 2004 05:11:27 -0000 1.20 +++ src/wp/impexp/xp/ie_exp_GZipAbiWord.cpp 20 Feb 2006 19:34:10 -0000 @@ -18,21 +18,13 @@ */ -#include #include "string.h" #include "ie_exp_GZipAbiWord.h" #include "ut_assert.h" #include "ut_string.h" -IE_Exp_GZipAbiWord::IE_Exp_GZipAbiWord(PD_Document * pDocument) - : IE_Exp_AbiWord_1(pDocument), m_gzfp(0) -{ -} - -IE_Exp_GZipAbiWord::~IE_Exp_GZipAbiWord() -{ -} +#include /*****************************************************************/ /*****************************************************************/ @@ -51,8 +43,7 @@ bool IE_Exp_GZipAbiWord_Sniffer::recogni UT_Error IE_Exp_GZipAbiWord_Sniffer::constructExporter(PD_Document * pDocument, IE_Exp ** ppie) { - IE_Exp_GZipAbiWord * p = new IE_Exp_GZipAbiWord(pDocument); - *ppie = p; + *ppie = new IE_Exp_GZipAbiWord(pDocument); return UT_OK; } @@ -75,28 +66,20 @@ bool IE_Exp_GZipAbiWord_Sniffer::getDlgL /*****************************************************************/ /*****************************************************************/ -bool IE_Exp_GZipAbiWord::_openFile(const char * szFilename) +IE_Exp_GZipAbiWord::IE_Exp_GZipAbiWord(PD_Document * pDocument) + : IE_Exp_AbiWord_1(pDocument) { - UT_return_val_if_fail(!m_gzfp, false); - - m_gzfp = static_cast(gzopen(szFilename, "wb6")); - return (m_gzfp != 0); } -UT_uint32 IE_Exp_GZipAbiWord::_writeBytes(const UT_Byte * pBytes, UT_uint32 length) +IE_Exp_GZipAbiWord::~IE_Exp_GZipAbiWord() { - UT_return_val_if_fail(m_gzfp, 0); - UT_return_val_if_fail(pBytes, 0); - UT_return_val_if_fail(length, 0); - - return gzwrite(m_gzfp, const_cast(static_cast(pBytes)), sizeof(UT_Byte) * length); } -bool IE_Exp_GZipAbiWord::_closeFile(void) +GsfOutput* IE_Exp_GZipAbiWord::_openFile(const char * szFilename) { - if (m_gzfp) - gzclose(m_gzfp); + GsfOutput * output = go_file_create(szFilename, NULL); + if(!output) + return NULL; - m_gzfp = 0; - return true; + return gsf_output_gzip_new(output, NULL); } Index: src/wp/impexp/xp/ie_exp_GZipAbiWord.h =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_exp_GZipAbiWord.h,v retrieving revision 1.8 diff -u -p -u -p -r1.8 ie_exp_GZipAbiWord.h --- src/wp/impexp/xp/ie_exp_GZipAbiWord.h 20 Nov 2002 17:03:41 -0000 1.8 +++ src/wp/impexp/xp/ie_exp_GZipAbiWord.h 20 Feb 2006 19:34:10 -0000 @@ -21,7 +21,6 @@ #ifndef IE_EXP_GZIPABIWORD_1_H #define IE_EXP_GZIPABIWORD_1_H -#include #include "ie_exp_AbiWord_1.h" // The exporter/writer for GZipped AbiWord file format. @@ -50,13 +49,7 @@ public: virtual ~IE_Exp_GZipAbiWord(); protected: - virtual bool _openFile(const char * szFilename); - virtual UT_uint32 _writeBytes(const UT_Byte * pBytes, UT_uint32 length); - virtual bool _closeFile(void); - -private: - - gzFile m_gzfp; + virtual GsfOutput* _openFile(const char * szFilename); }; Index: src/wp/impexp/xp/ie_exp_HTML.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_exp_HTML.cpp,v retrieving revision 1.306 diff -u -p -u -p -r1.306 ie_exp_HTML.cpp --- src/wp/impexp/xp/ie_exp_HTML.cpp 12 Jan 2006 19:20:33 -0000 1.306 +++ src/wp/impexp/xp/ie_exp_HTML.cpp 20 Feb 2006 19:34:14 -0000 @@ -6575,7 +6575,7 @@ UT_Error IE_Exp_HTML::_writeDocument (bo return UT_IE_COULDNOTWRITE; } -bool IE_Exp_HTML::_openFile (const char * szFilename) +GsfOutput* IE_Exp_HTML::_openFile (const char * szFilename) { #ifdef HTML_DIALOG_OPTIONS XAP_Frame * pFrame = getDoc()->getApp()->getLastFocussedFrame (); @@ -6619,7 +6619,7 @@ bool IE_Exp_HTML::_openFile (const char if (!bSave) { _cancelExport (); - return false; + return NULL; } #endif return IE_Exp::_openFile (szFilename); Index: src/wp/impexp/xp/ie_exp_HTML.h =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_exp_HTML.h,v retrieving revision 1.35 diff -u -p -u -p -r1.35 ie_exp_HTML.h --- src/wp/impexp/xp/ie_exp_HTML.h 22 Jan 2005 20:22:30 -0000 1.35 +++ src/wp/impexp/xp/ie_exp_HTML.h 20 Feb 2006 19:34:14 -0000 @@ -194,7 +194,7 @@ private: void _buildStyleTree (); void _buildTOC (); protected: - virtual bool _openFile (const char * szFilename); + virtual GsfOutput* _openFile (const char * szFilename); virtual UT_Error _writeDocument (); public: virtual UT_Error _writeDocument (bool bClipBoard, bool bTemplateBody); Index: src/wp/impexp/xp/ie_exp_Text.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_exp_Text.cpp,v retrieving revision 1.68 diff -u -p -u -p -r1.68 ie_exp_Text.cpp --- src/wp/impexp/xp/ie_exp_Text.cpp 3 Nov 2005 03:22:41 -0000 1.68 +++ src/wp/impexp/xp/ie_exp_Text.cpp 20 Feb 2006 19:34:14 -0000 @@ -250,7 +250,7 @@ UT_Error IE_Exp_Text::_writeDocument(voi Open the file to export to \param szFilename File to open */ -bool IE_Exp_Text::_openFile(const char * szFilename) +GsfOutput* IE_Exp_Text::_openFile(const char * szFilename) { // Don't call base method if user cancels encoding dialog if (!m_bIsEncoded || m_bExplicitlySetEncoding || _doEncodingDialog(m_szEncoding)) @@ -258,7 +258,7 @@ bool IE_Exp_Text::_openFile(const char * else { _cancelExport (); - return false; + return NULL; } } Index: src/wp/impexp/xp/ie_exp_Text.h =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_exp_Text.h,v retrieving revision 1.23 diff -u -p -u -p -r1.23 ie_exp_Text.h --- src/wp/impexp/xp/ie_exp_Text.h 6 Aug 2004 02:27:01 -0000 1.23 +++ src/wp/impexp/xp/ie_exp_Text.h 20 Feb 2006 19:34:15 -0000 @@ -78,7 +78,7 @@ public: protected: virtual PL_Listener * _constructListener(void); virtual UT_Error _writeDocument(void); - virtual bool _openFile(const char * szFilename); + virtual GsfOutput* _openFile(const char * szFilename); bool _doEncodingDialog(const char *szEncoding); void _setEncoding(const char *szEncoding); Index: src/wp/impexp/xp/ie_imp.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp.cpp,v retrieving revision 1.89 diff -u -p -u -p -r1.89 ie_imp.cpp --- src/wp/impexp/xp/ie_imp.cpp 30 Sep 2005 07:22:06 -0000 1.89 +++ src/wp/impexp/xp/ie_imp.cpp 20 Feb 2006 19:34:15 -0000 @@ -522,15 +522,15 @@ static UT_Confidence_t s_confidence_heur This function should closely match IE_Exp::contructExporter() */ UT_Error IE_Imp::constructImporter(PD_Document * pDocument, - const char * szFilename, - IEFileType ieft, - IE_Imp ** ppie, - IEFileType * pieft) + const char * szURI, + IEFileType ieft, + IE_Imp ** ppie, + IEFileType * pieft) { bool bUseGuesswork = (ieft != IEFT_Unknown); UT_return_val_if_fail(pDocument, UT_ERROR); - UT_return_val_if_fail(ieft != IEFT_Unknown || (szFilename && *szFilename), UT_ERROR); + UT_return_val_if_fail(ieft != IEFT_Unknown || (szURI && *szURI), UT_ERROR); UT_return_val_if_fail(ppie, UT_ERROR); UT_uint32 nrElements = getImporterCount(); @@ -539,18 +539,19 @@ UT_Error IE_Imp::constructImporter(PD_Do // from the contents of the file or the filename suffix // the importer to use and assign that back to ieft. // Give precedence to the file contents - if (ieft == IEFT_Unknown && szFilename && *szFilename) + if (ieft == IEFT_Unknown && szURI && *szURI) { char szBuf[4097] = ""; // 4096+nul ought to be enough UT_uint32 iNumbytes = 0; - FILE *f = NULL; + GsfInput *f = NULL; // we must open in binary mode for UCS-2 compatibility - if ( ( f = fopen( szFilename, "rb" ) ) != static_cast(0) ) + if ( ( f = go_file_open(szURI, NULL)) != NULL ) { - iNumbytes = fread(szBuf, 1, sizeof(szBuf)-1, f); + iNumbytes = UT_MIN(4096, gsf_input_size(f)); + gsf_input_read(f, iNumbytes, (guint8 *)(szBuf)); szBuf[iNumbytes] = '\0'; - fclose(f); + g_object_unref (G_OBJECT(f)); } UT_Confidence_t best_confidence = UT_CONFIDENCE_ZILCH; @@ -566,10 +567,10 @@ UT_Error IE_Imp::constructImporter(PD_Do if ( iNumbytes > 0 ) content_confidence = s->recognizeContents(szBuf, iNumbytes); - const char * suffix = UT_pathSuffix(szFilename) ; + const char * suffix = UT_pathSuffix(szURI) ; if ( suffix != NULL ) { - suffix_confidence = s->recognizeSuffix(UT_pathSuffix(szFilename)); + suffix_confidence = s->recognizeSuffix(suffix); } UT_Confidence_t confidence = s_confidence_heuristic ( content_confidence, @@ -593,7 +594,7 @@ UT_Error IE_Imp::constructImporter(PD_Do { // maybe they're trying to open an image directly? IE_ImpGraphic *pIEG; - UT_Error errorCode = IE_ImpGraphic::constructImporter(szFilename, IEGFT_Unknown, &pIEG); + UT_Error errorCode = IE_ImpGraphic::constructImporter(szURI, IEGFT_Unknown, &pIEG); if (!errorCode && pIEG) { // tell the caller the type of importer they got Index: src/wp/impexp/xp/ie_imp.h =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp.h,v retrieving revision 1.49 diff -u -p -u -p -r1.49 ie_imp.h --- src/wp/impexp/xp/ie_imp.h 4 Jun 2004 14:45:25 -0000 1.49 +++ src/wp/impexp/xp/ie_imp.h 20 Feb 2006 19:34:15 -0000 @@ -30,6 +30,9 @@ #include "ut_string_class.h" #include "pd_Document.h" +#include +#include + class PD_Document; class IE_Imp; Index: src/wp/impexp/xp/ie_impGraphic.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_impGraphic.cpp,v retrieving revision 1.24 diff -u -p -u -p -r1.24 ie_impGraphic.cpp --- src/wp/impexp/xp/ie_impGraphic.cpp 6 Jan 2005 23:06:15 -0000 1.24 +++ src/wp/impexp/xp/ie_impGraphic.cpp 20 Feb 2006 19:34:15 -0000 @@ -25,6 +25,9 @@ #include "ut_bytebuf.h" #include "ut_vector.h" +#include +#include + /*****************************************************************/ /*****************************************************************/ @@ -256,11 +259,12 @@ UT_Error IE_ImpGraphic::constructImporte UT_return_val_if_fail(szFilename && *szFilename, UT_ERROR); char szBuf[4096] = ""; UT_uint32 iNumbytes = 0; - FILE *f = NULL; - if ( ( f= fopen( szFilename, "rb" ) ) != static_cast(0) ) + GsfInput *f = NULL; + if ( ( f= go_file_open( szFilename, NULL ) ) != NULL ) { - iNumbytes = fread(szBuf, 1, sizeof(szBuf), f); - fclose(f); + iNumbytes = UT_MIN(sizeof(szBuf), gsf_input_size(f)); + gsf_input_read(f, iNumbytes, (guint8*)szBuf); + g_object_unref(G_OBJECT(f)); } UT_Confidence_t best_confidence = UT_CONFIDENCE_ZILCH; @@ -316,7 +320,7 @@ UT_Error IE_ImpGraphic::importGraphic(co if (pBB == NULL) return UT_IE_NOMEMORY; - if (!pBB->insertFromFile(0, szFilename)) + if (!pBB->insertFromURI(0, szFilename)) { DELETEP(pBB); return UT_IE_FILENOTFOUND; Index: src/wp/impexp/xp/ie_imp_GZipAbiWord.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_GZipAbiWord.cpp,v retrieving revision 1.23 diff -u -p -u -p -r1.23 ie_imp_GZipAbiWord.cpp --- src/wp/impexp/xp/ie_imp_GZipAbiWord.cpp 9 Jul 2004 05:11:27 -0000 1.23 +++ src/wp/impexp/xp/ie_imp_GZipAbiWord.cpp 20 Feb 2006 19:34:15 -0000 @@ -84,7 +84,7 @@ UT_Confidence_t IE_Imp_GZipAbiWord_Sniff UT_Error IE_Imp_GZipAbiWord_Sniffer::constructImporter(PD_Document * pDocument, IE_Imp ** ppie) { - *ppie = new IE_Imp_GZipAbiWord(pDocument);; + *ppie = new IE_Imp_AbiWord_1(pDocument);; return UT_OK; } @@ -101,41 +101,3 @@ bool IE_Imp_GZipAbiWord_Sniffer::getDlgL *ft = getFileType(); return true; } - -/*****************************************************************/ -/*****************************************************************/ - -bool IE_Imp_GZipAbiWord::openFile (const char * szFilename) -{ - UT_return_val_if_fail (m_gzfp == 0, false); - - m_gzfp = gzopen (szFilename, "rb"); - return (m_gzfp != NULL); -} - -UT_uint32 IE_Imp_GZipAbiWord::readBytes (char * buffer, UT_uint32 length) -{ - UT_return_val_if_fail (m_gzfp, 0); - - return gzread (m_gzfp, buffer, length); -} - -void IE_Imp_GZipAbiWord::closeFile(void) -{ - if (m_gzfp) { - gzclose (m_gzfp); - m_gzfp = 0; - } -} - -IE_Imp_GZipAbiWord::~IE_Imp_GZipAbiWord() -{ - if (m_gzfp) gzclose (m_gzfp); -} - -IE_Imp_GZipAbiWord::IE_Imp_GZipAbiWord(PD_Document * pDocument) - : IE_Imp_AbiWord_1(pDocument), - m_gzfp(0) -{ - setReader (this); // IE_Imp_GZipAbiWord derives from UT_XML::Reader -} Index: src/wp/impexp/xp/ie_imp_GZipAbiWord.h =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_GZipAbiWord.h,v retrieving revision 1.13 diff -u -p -u -p -r1.13 ie_imp_GZipAbiWord.h --- src/wp/impexp/xp/ie_imp_GZipAbiWord.h 20 Nov 2002 17:03:44 -0000 1.13 +++ src/wp/impexp/xp/ie_imp_GZipAbiWord.h 20 Feb 2006 19:34:15 -0000 @@ -22,7 +22,6 @@ #define IE_IMP_GZIPABIWORD_H #include -#include #include "ie_imp_AbiWord_1.h" // The importer/reader for GZipped AbiWord file format version 1. @@ -48,20 +47,4 @@ public: }; -class ABI_EXPORT IE_Imp_GZipAbiWord : public IE_Imp_AbiWord_1, public UT_XML::Reader -{ -public: - IE_Imp_GZipAbiWord(PD_Document * pDocument); - ~IE_Imp_GZipAbiWord(); - - /* Implementation of UT_XML::Reader - */ - virtual bool openFile (const char * szFilename); - virtual UT_uint32 readBytes (char * buffer, UT_uint32 length); - virtual void closeFile (void); - -private: - gzFile m_gzfp; -}; - #endif /* IE_IMP_GZIPABIWORD_H */ Index: src/wp/impexp/xp/ie_imp_MsWord_97.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_MsWord_97.cpp,v retrieving revision 1.343 diff -u -p -u -p -r1.343 ie_imp_MsWord_97.cpp --- src/wp/impexp/xp/ie_imp_MsWord_97.cpp 15 Nov 2005 03:44:04 -0000 1.343 +++ src/wp/impexp/xp/ie_imp_MsWord_97.cpp 20 Feb 2006 19:34:19 -0000 @@ -933,11 +933,12 @@ static void _errorMessage (XAP_Frame * p } #endif -UT_Error IE_Imp_MsWord_97::importFile(const char * szFilename) +UT_Error IE_Imp_MsWord_97::importFile(const char * szURI) { wvParseStruct ps; + GsfInput *fp = go_file_open(szURI, NULL); - int ret = wvInitParser (&ps, const_cast(szFilename)); + int ret = wvInitParser_gsf(&ps, fp); const char * password = NULL; if (ret & 0x8000) /* Password protected? */ Index: src/wp/impexp/xp/ie_imp_RTF.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_RTF.cpp,v retrieving revision 1.402 diff -u -p -u -p -r1.402 ie_imp_RTF.cpp --- src/wp/impexp/xp/ie_imp_RTF.cpp 20 Oct 2005 22:14:05 -0000 1.402 +++ src/wp/impexp/xp/ie_imp_RTF.cpp 20 Feb 2006 19:34:26 -0000 @@ -1484,21 +1484,21 @@ IE_Imp_RTF::~IE_Imp_RTF() FREEP (m_szFileDirName); } -UT_Error IE_Imp_RTF::importFile(const char * szFilename) +UT_Error IE_Imp_RTF::importFile(const char * szURI) { m_newParaFlagged = true; m_newSectionFlagged = true; - m_szFileDirName = UT_strdup (szFilename); + m_szFileDirName = UT_strdup (szURI); // UT_basename returns a point INSIDE the passed string. // the trick is to truncate the string by setting the char pointed // by tmp to NULL. This IS useful code. (2 LOC) char * tmp = const_cast(UT_basename (m_szFileDirName)); *tmp = 0; - FILE *fp = fopen(szFilename, "r"); + GsfInput *fp = go_file_open(szURI, NULL); if (!fp) { - UT_DEBUGMSG(("Could not open file %s\n",szFilename)); + UT_DEBUGMSG(("Could not open file %s\n",szURI)); return UT_errnoToUTError (); } @@ -1511,7 +1511,7 @@ UT_Error IE_Imp_RTF::importFile(const ch _appendHdrFtr (); } - fclose(fp); + g_object_unref(G_OBJECT(fp)); // check if the doc is empty or not if (getDoc()->getLastFrag() == NULL) @@ -1524,7 +1524,7 @@ UT_Error IE_Imp_RTF::importFile(const ch } -UT_Error IE_Imp_RTF::_writeHeader(FILE * /*fp*/) +UT_Error IE_Imp_RTF::_writeHeader(GsfInput * /*fp*/) { return UT_OK; } @@ -2468,7 +2468,8 @@ UT_Error IE_Imp_RTF::_isBidiDocument() char buff[8192 + 1]; char * token = NULL; - size_t iBytes = fread((void*)&buff[0], 1, sizeof(buff) - 1, m_pImportFile); + size_t iBytes = UT_MIN(8192, gsf_input_remaining(m_pImportFile)); + gsf_input_read(m_pImportFile, iBytes, (guint8*)buff); UT_DEBUGMSG(("IE_Imp_RTF::_isBidiDocument: looking for RTL tokens\n")); while (iBytes) @@ -2487,8 +2488,9 @@ UT_Error IE_Imp_RTF::_isBidiDocument() token = strstr(buff, "rtlch"); if(token) break; - - iBytes = fread((void*)&buff[0], 1, sizeof(buff) - 1, m_pImportFile); + + iBytes = UT_MIN(8192, gsf_input_remaining(m_pImportFile)); + gsf_input_read(m_pImportFile, iBytes, (guint8*)buff); } if(token) @@ -2504,7 +2506,7 @@ UT_Error IE_Imp_RTF::_isBidiDocument() // reset the file pointer to the beginning - if(fseek(m_pImportFile, 0, SEEK_SET)) + if(gsf_input_seek(m_pImportFile, 0, G_SEEK_SET)) return UT_ERROR; UT_DEBUGMSG(("IE_Imp_RTF::_isBidiDocument: looking for RTL tokens -- done\n")); @@ -2513,7 +2515,7 @@ UT_Error IE_Imp_RTF::_isBidiDocument() -UT_Error IE_Imp_RTF::_parseFile(FILE* fp) +UT_Error IE_Imp_RTF::_parseFile(GsfInput* fp) { m_pImportFile = fp; @@ -3025,7 +3027,7 @@ bool IE_Imp_RTF::ReadCharFromFileWithCRL if (m_pImportFile) // if we are reading a file { - if (fread(pCh, 1, sizeof(unsigned char), m_pImportFile) > 0) + if (gsf_input_read(m_pImportFile, 1, pCh) != NULL) { ok = true; } @@ -3105,7 +3107,7 @@ bool IE_Imp_RTF::SkipBackChar(unsigned c if (m_pImportFile) // if we are reading a file { // TODO - I've got a sneaking suspicion that this doesn't work on the Macintosh - return (ungetc(ch, m_pImportFile) != EOF); + return (!gsf_input_seek(m_pImportFile, -1, G_SEEK_CUR)); } else // else we are pasting from a buffer { Index: src/wp/impexp/xp/ie_imp_RTF.h =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_RTF.h,v retrieving revision 1.144 diff -u -p -u -p -r1.144 ie_imp_RTF.h --- src/wp/impexp/xp/ie_imp_RTF.h 16 Aug 2005 10:28:23 -0000 1.144 +++ src/wp/impexp/xp/ie_imp_RTF.h 20 Feb 2006 19:34:27 -0000 @@ -560,8 +560,8 @@ public: }; protected: - UT_Error _parseFile(FILE * fp); - UT_Error _writeHeader(FILE * fp); + UT_Error _parseFile(GsfInput * fp); + UT_Error _writeHeader(GsfInput * fp); UT_Error _parseHdrFtr (); UT_Error _parseText(); @@ -854,7 +854,7 @@ private: bool m_bParaHasRTFList; bool m_bParaHasRTFContinue; - FILE* m_pImportFile; + GsfInput* m_pImportFile; const unsigned char * m_pPasteBuffer; UT_uint32 m_lenPasteBuffer; Index: src/wp/impexp/xp/ie_imp_Text.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_Text.cpp,v retrieving revision 1.74 diff -u -p -u -p -r1.74 ie_imp_Text.cpp --- src/wp/impexp/xp/ie_imp_Text.cpp 6 Aug 2004 02:27:01 -0000 1.74 +++ src/wp/impexp/xp/ie_imp_Text.cpp 20 Feb 2006 19:34:28 -0000 @@ -139,7 +139,7 @@ bool ImportStream::getRawChar(UT_UCSChar Construct ImportStreamFile from FILE pointer \param pFile File to read from */ -ImportStreamFile::ImportStreamFile(FILE *pFile) : +ImportStreamFile::ImportStreamFile(GsfInput *pFile) : m_pFile(pFile) { } @@ -156,7 +156,7 @@ bool ImportStreamFile::_getByte(unsigned { UT_return_val_if_fail(m_pFile, false); - return fread(&b, 1, sizeof(b), m_pFile) > 0; + return (gsf_input_read(m_pFile, 1, &b) != NULL); } /*! @@ -619,13 +619,13 @@ bool IE_Imp_EncodedText_Sniffer::getDlgL Each line terminator is taken to be a paragraph break */ -UT_Error IE_Imp_Text::importFile(const char * szFilename) +UT_Error IE_Imp_Text::importFile(const char * szURI) { // We must open in binary mode for UCS-2 compatibility. - FILE *fp = fopen(szFilename, "rb"); + GsfInput *fp = go_file_open(szURI, NULL); if (!fp) { - UT_DEBUGMSG(("Could not open file %s\n",szFilename)); + UT_DEBUGMSG(("Could not open file %s\n",szURI)); return UT_IE_FILENOTFOUND; } @@ -649,7 +649,7 @@ UT_Error IE_Imp_Text::importFile(const c Cleanup: delete pStream; - fclose(fp); + g_object_unref(G_OBJECT(fp)); return error; } @@ -728,13 +728,14 @@ IE_Imp_Text::~IE_Imp_Text () Supports UTF-8 and UCS-2 big and little endian CJK encodings could be added */ -UT_Error IE_Imp_Text::_recognizeEncoding(FILE * fp) +UT_Error IE_Imp_Text::_recognizeEncoding(GsfInput * fp) { char szBuf[4096]; // 4096 ought to be enough UT_sint32 iNumbytes; - iNumbytes = fread(szBuf, 1, sizeof(szBuf), fp); - fseek(fp, 0, SEEK_SET); + iNumbytes = UT_MIN(4096, gsf_input_remaining(fp)); + gsf_input_read(fp, iNumbytes, (guint8 *)szBuf); + gsf_input_seek(fp, 0, G_SEEK_SET); return _recognizeEncoding(szBuf, iNumbytes); } @@ -775,7 +776,7 @@ UT_Error IE_Imp_Text::_recognizeEncoding Override this virtual function to derive from the text importer */ -UT_Error IE_Imp_Text::_constructStream(ImportStream *& pStream, FILE * fp) +UT_Error IE_Imp_Text::_constructStream(ImportStream *& pStream, GsfInput * fp) { return (pStream = new ImportStreamFile(fp)) ? UT_OK : UT_IE_NOMEMORY; } @@ -785,7 +786,7 @@ UT_Error IE_Imp_Text::_constructStream(I Writes the minimum needed Section and Block before we begin import */ -UT_Error IE_Imp_Text::_writeHeader(FILE * /* fp */) +UT_Error IE_Imp_Text::_writeHeader(GsfInput * /* fp */) { // text gets applied in the Normal style const XML_Char * propsArray[3]; Index: src/wp/impexp/xp/ie_imp_Text.h =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_Text.h,v retrieving revision 1.32 diff -u -p -u -p -r1.32 ie_imp_Text.h --- src/wp/impexp/xp/ie_imp_Text.h 6 Aug 2004 02:27:01 -0000 1.32 +++ src/wp/impexp/xp/ie_imp_Text.h 20 Feb 2006 19:34:28 -0000 @@ -61,13 +61,13 @@ class ABI_EXPORT ImportStream class ABI_EXPORT ImportStreamFile : public ImportStream { public: - ImportStreamFile(FILE *pFile); + ImportStreamFile(GsfInput *pFile); ~ImportStreamFile(); bool getChar(); protected: bool _getByte(unsigned char &b); private: - FILE *m_pFile; + GsfInput *m_pFile; }; // Clipboard stream class @@ -154,10 +154,10 @@ public: const unsigned char * pData, UT_uint32 lenData, const char * szEncoding = 0); protected: - UT_Error _recognizeEncoding(FILE * fp); + UT_Error _recognizeEncoding(GsfInput * fp); UT_Error _recognizeEncoding(const char *szBuf, UT_uint32 iNumbytes); - virtual UT_Error _constructStream(ImportStream *& pStream, FILE * fp); - UT_Error _writeHeader(FILE * fp); + virtual UT_Error _constructStream(ImportStream *& pStream, GsfInput * fp); + UT_Error _writeHeader(GsfInput * fp); UT_Error _parseStream(ImportStream * pStream); bool _doEncodingDialog(const char *szEncoding); void _setEncoding(const char *szEncoding); Index: src/wp/impexp/xp/ie_imp_XML.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_imp_XML.cpp,v retrieving revision 1.69 diff -u -p -u -p -r1.69 ie_imp_XML.cpp --- src/wp/impexp/xp/ie_imp_XML.cpp 15 Jul 2005 13:09:24 -0000 1.69 +++ src/wp/impexp/xp/ie_imp_XML.cpp 20 Feb 2006 19:34:28 -0000 @@ -108,16 +108,29 @@ UT_Error IE_Imp_XML::importFile(const ch parser->setListener (this); if (m_pReader) parser->setReader (m_pReader); - UT_Error err = parser->parse (szFilename); + GsfInput * input = go_file_open(szFilename, NULL); + if(input) { + input = gsf_input_uncompress(input); + + // hack!!! + size_t num_bytes = gsf_input_size(input); + char * bytes = (char *)gsf_input_read(input, num_bytes, NULL); + + UT_Error err = parser->parse (bytes, num_bytes); + + if ((err != UT_OK) && (err != UT_IE_SKIPINVALID)) + m_error = UT_IE_BOGUSDOCUMENT; + + if (m_error != UT_OK) + { + UT_DEBUGMSG(("Problem reading document\n")); + if(m_error != UT_IE_SKIPINVALID) + m_szFileName = 0; + } - if ((err != UT_OK) && (err != UT_IE_SKIPINVALID)) + g_object_unref(G_OBJECT(input)); + } else { m_error = UT_IE_BOGUSDOCUMENT; - - if (m_error != UT_OK) - { - UT_DEBUGMSG(("Problem reading document\n")); - if(m_error != UT_IE_SKIPINVALID) - m_szFileName = 0; } return m_error; Index: src/wp/impexp/xp/ie_mailmerge.cpp =================================================================== RCS file: /cvsroot/abi/src/wp/impexp/xp/ie_mailmerge.cpp,v retrieving revision 1.12 diff -u -p -u -p -r1.12 ie_mailmerge.cpp --- src/wp/impexp/xp/ie_mailmerge.cpp 18 May 2005 19:32:32 -0000 1.12 +++ src/wp/impexp/xp/ie_mailmerge.cpp 20 Feb 2006 19:34:28 -0000 @@ -25,6 +25,9 @@ #include "ut_assert.h" #include "ut_debugmsg.h" +#include +#include + static const UT_uint32 merge_size_guess = 3; static UT_GenericVector m_sniffers (merge_size_guess); @@ -301,14 +304,15 @@ UT_Error IE_MailMerge::constructMerger(c { char szBuf[4097] = ""; // 4096 ought to be enough UT_uint32 iNumbytes = 0; - FILE *f = NULL; + GsfInput *f = NULL; // we must open in binary mode for UCS-2 compatibility - if ( ( f = fopen( szFilename, "rb" ) ) != static_cast(0) ) + if ( ( f = go_file_open( szFilename, NULL ) ) != NULL ) { - iNumbytes = fread(szBuf, 1, sizeof(szBuf)-1, f); - fclose(f); - szBuf[iNumbytes] = '\0'; + iNumbytes = UT_MIN(sizeof(szBuf) - 1, gsf_input_size(f)); + gsf_input_read(f, iNumbytes, (guint8*)szBuf); + g_object_unref(G_OBJECT(f)); + szBuf[iNumbytes] = '\0'; } UT_Confidence_t best_confidence = UT_CONFIDENCE_ZILCH; @@ -592,7 +596,7 @@ public: UT_uint32 lineno = 0; bool cont = true; - FILE * fp = fopen(szFilename, "rb"); + GsfInput * fp = go_file_open(szFilename, NULL); if (!fp) return UT_ERROR; @@ -604,7 +608,7 @@ public: // line 1 == Headings/titles // line 2..n == Data - while (cont && (1 == fread (&ch, 1, 1, fp))){ + while (cont && (NULL != gsf_input_read (fp, 1, &ch))){ if (ch == '\r') continue; else if (ch == '\n') { @@ -623,7 +627,7 @@ public: item.append(&ch, 1); } - fclose (fp); + g_object_unref (G_OBJECT(fp)); return UT_OK; } @@ -634,7 +638,7 @@ public: UT_Byte ch; - FILE * fp = fopen(szFilename, "rb"); + GsfInput * fp = go_file_open (szFilename, NULL); if (!fp) return UT_ERROR; @@ -644,7 +648,7 @@ public: // line 1 == Headings/titles // line 2..n == Data - while ((1 == fread (&ch, 1, 1, fp))){ + while (NULL != gsf_input_read (fp, 1, &ch)) { if (ch == '\r') continue; else if (ch == '\n') { @@ -659,7 +663,7 @@ public: item.append (&ch, 1); } - fclose (fp); + g_object_unref (G_OBJECT(fp)); for (UT_uint32 i = 0; i < m_headers.size(); i++) { UT_UTF8String * clone = new UT_UTF8String (*(UT_UTF8String *)m_headers[i]);