Fix build with wxUSE_FFILE=0.
Add the missing "#if wxUSE_FFILE" checks and add fallbacks to wxFile if it's available. Closes #15353. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74596 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -560,6 +560,10 @@ Major new features in this release
|
|||||||
3.0: (released 2013-09-??)
|
3.0: (released 2013-09-??)
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
|
All:
|
||||||
|
|
||||||
|
- Fix build with wxUSE_FFILE==0 (jroemmler).
|
||||||
|
|
||||||
All (GUI):
|
All (GUI):
|
||||||
|
|
||||||
- Fix crash in wxHTML on mal-formed <area> elements (LukasK).
|
- Fix crash in wxHTML on mal-formed <area> elements (LukasK).
|
||||||
|
@@ -4842,23 +4842,41 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void ResetAndClearCommands();
|
virtual void ResetAndClearCommands();
|
||||||
|
|
||||||
|
#if wxUSE_FFILE && wxUSE_STREAMS
|
||||||
//@{
|
//@{
|
||||||
/**
|
/**
|
||||||
Loads content from a stream or file.
|
Loads content from a file.
|
||||||
Not all handlers will implement file loading.
|
Not all handlers will implement file loading.
|
||||||
*/
|
*/
|
||||||
virtual bool LoadFile(const wxString& filename, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
|
virtual bool LoadFile(const wxString& filename, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
|
||||||
|
//@}
|
||||||
|
|
||||||
|
//@{
|
||||||
|
/**
|
||||||
|
Saves content to a file.
|
||||||
|
Not all handlers will implement file saving.
|
||||||
|
*/
|
||||||
|
virtual bool SaveFile(const wxString& filename, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
|
||||||
|
//@}
|
||||||
|
#endif // wxUSE_FFILE
|
||||||
|
|
||||||
|
#if wxUSE_STREAMS
|
||||||
|
//@{
|
||||||
|
/**
|
||||||
|
Loads content from a stream.
|
||||||
|
Not all handlers will implement loading from a stream.
|
||||||
|
*/
|
||||||
virtual bool LoadFile(wxInputStream& stream, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
|
virtual bool LoadFile(wxInputStream& stream, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
/**
|
/**
|
||||||
Saves content to a stream or file.
|
Saves content to a stream.
|
||||||
Not all handlers will implement file saving.
|
Not all handlers will implement saving to a stream.
|
||||||
*/
|
*/
|
||||||
virtual bool SaveFile(const wxString& filename, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
|
|
||||||
virtual bool SaveFile(wxOutputStream& stream, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
|
virtual bool SaveFile(wxOutputStream& stream, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
|
||||||
//@}
|
//@}
|
||||||
|
#endif // wxUSE_STREAMS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the handler flags, controlling loading and saving.
|
Sets the handler flags, controlling loading and saving.
|
||||||
|
@@ -573,6 +573,7 @@ public:
|
|||||||
int type = wxRICHTEXT_TYPE_ANY);
|
int type = wxRICHTEXT_TYPE_ANY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_FFILE && wxUSE_STREAMS
|
||||||
/**
|
/**
|
||||||
Helper function for LoadFile(). Loads content into the control's buffer using the given type.
|
Helper function for LoadFile(). Loads content into the control's buffer using the given type.
|
||||||
|
|
||||||
@@ -582,6 +583,7 @@ public:
|
|||||||
This function looks for a suitable wxRichTextFileHandler object.
|
This function looks for a suitable wxRichTextFileHandler object.
|
||||||
*/
|
*/
|
||||||
virtual bool DoLoadFile(const wxString& file, int fileType);
|
virtual bool DoLoadFile(const wxString& file, int fileType);
|
||||||
|
#endif // wxUSE_FFILE && wxUSE_STREAMS
|
||||||
|
|
||||||
#ifdef DOXYGEN
|
#ifdef DOXYGEN
|
||||||
/**
|
/**
|
||||||
@@ -596,6 +598,7 @@ public:
|
|||||||
int type = wxRICHTEXT_TYPE_ANY);
|
int type = wxRICHTEXT_TYPE_ANY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_FFILE && wxUSE_STREAMS
|
||||||
/**
|
/**
|
||||||
Helper function for SaveFile(). Saves the buffer content using the given type.
|
Helper function for SaveFile(). Saves the buffer content using the given type.
|
||||||
|
|
||||||
@@ -606,6 +609,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool DoSaveFile(const wxString& file = wxEmptyString,
|
virtual bool DoSaveFile(const wxString& file = wxEmptyString,
|
||||||
int fileType = wxRICHTEXT_TYPE_ANY);
|
int fileType = wxRICHTEXT_TYPE_ANY);
|
||||||
|
#endif // wxUSE_FFILE && wxUSE_STREAMS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets flags that change the behaviour of loading or saving.
|
Sets flags that change the behaviour of loading or saving.
|
||||||
|
@@ -165,11 +165,15 @@ public:
|
|||||||
virtual ~wxRichTextPrinting();
|
virtual ~wxRichTextPrinting();
|
||||||
|
|
||||||
/// Preview the file or buffer
|
/// Preview the file or buffer
|
||||||
|
#if wxUSE_FFILE && wxUSE_STREAMS
|
||||||
bool PreviewFile(const wxString& richTextFile);
|
bool PreviewFile(const wxString& richTextFile);
|
||||||
|
#endif
|
||||||
bool PreviewBuffer(const wxRichTextBuffer& buffer);
|
bool PreviewBuffer(const wxRichTextBuffer& buffer);
|
||||||
|
|
||||||
/// Print the file or buffer
|
/// Print the file or buffer
|
||||||
|
#if wxUSE_FFILE && wxUSE_STREAMS
|
||||||
bool PrintFile(const wxString& richTextFile, bool showPrintDialog = true);
|
bool PrintFile(const wxString& richTextFile, bool showPrintDialog = true);
|
||||||
|
#endif
|
||||||
bool PrintBuffer(const wxRichTextBuffer& buffer, bool showPrintDialog = true);
|
bool PrintBuffer(const wxRichTextBuffer& buffer, bool showPrintDialog = true);
|
||||||
|
|
||||||
/// Shows page setup dialog
|
/// Shows page setup dialog
|
||||||
|
@@ -33,8 +33,12 @@
|
|||||||
#if wxUSE_DEBUGREPORT && wxUSE_XML
|
#if wxUSE_DEBUGREPORT && wxUSE_XML
|
||||||
|
|
||||||
#include "wx/debugrpt.h"
|
#include "wx/debugrpt.h"
|
||||||
|
#if wxUSE_FFILE
|
||||||
#include "wx/ffile.h"
|
#include "wx/ffile.h"
|
||||||
|
#elif wxUSE_FILE
|
||||||
|
#include "wx/file.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "wx/filename.h"
|
#include "wx/filename.h"
|
||||||
#include "wx/dir.h"
|
#include "wx/dir.h"
|
||||||
#include "wx/dynlib.h"
|
#include "wx/dynlib.h"
|
||||||
@@ -288,17 +292,25 @@ wxDebugReport::AddText(const wxString& filename,
|
|||||||
const wxString& text,
|
const wxString& text,
|
||||||
const wxString& description)
|
const wxString& description)
|
||||||
{
|
{
|
||||||
|
#if wxUSE_FFILE || wxUSE_FILE
|
||||||
wxASSERT_MSG( !wxFileName(filename).IsAbsolute(),
|
wxASSERT_MSG( !wxFileName(filename).IsAbsolute(),
|
||||||
wxT("filename should be relative to debug report directory") );
|
wxT("filename should be relative to debug report directory") );
|
||||||
|
|
||||||
wxFileName fn(GetDirectory(), filename);
|
const wxString fullPath = wxFileName(GetDirectory(), filename).GetFullPath();
|
||||||
wxFFile file(fn.GetFullPath(), wxT("w"));
|
#if wxUSE_FFILE
|
||||||
if ( !file.IsOpened() || !file.Write(text) )
|
wxFFile file(fullPath, wxT("w"));
|
||||||
|
#elif wxUSE_FILE
|
||||||
|
wxFile file(fullPath, wxFile::write);
|
||||||
|
#endif
|
||||||
|
if ( !file.IsOpened() || !file.Write(text, wxConvAuto()) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
AddFile(filename, description);
|
AddFile(filename, description);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#else // !wxUSE_FFILE && !wxUSE_FILE
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDebugReport::RemoveFile(const wxString& name)
|
void wxDebugReport::RemoveFile(const wxString& name)
|
||||||
@@ -614,6 +626,8 @@ void wxDebugReportCompress::SetCompressedFileBaseName(const wxString& name)
|
|||||||
|
|
||||||
bool wxDebugReportCompress::DoProcess()
|
bool wxDebugReportCompress::DoProcess()
|
||||||
{
|
{
|
||||||
|
#define HAS_FILE_STREAMS (wxUSE_STREAMS && (wxUSE_FILE || wxUSE_FFILE))
|
||||||
|
#if HAS_FILE_STREAMS
|
||||||
const size_t count = GetFilesCount();
|
const size_t count = GetFilesCount();
|
||||||
if ( !count )
|
if ( !count )
|
||||||
return false;
|
return false;
|
||||||
@@ -630,7 +644,14 @@ bool wxDebugReportCompress::DoProcess()
|
|||||||
fn.SetExt("zip");
|
fn.SetExt("zip");
|
||||||
|
|
||||||
// create the streams
|
// create the streams
|
||||||
wxFFileOutputStream os(fn.GetFullPath(), wxT("wb"));
|
const wxString ofullPath = fn.GetFullPath();
|
||||||
|
#if wxUSE_FFILE
|
||||||
|
wxFFileOutputStream os(ofullPath, wxT("wb"));
|
||||||
|
#elif wxUSE_FILE
|
||||||
|
wxFileOutputStream os(ofullPath);
|
||||||
|
#endif
|
||||||
|
if ( !os.IsOk() )
|
||||||
|
return false;
|
||||||
wxZipOutputStream zos(os, 9);
|
wxZipOutputStream zos(os, 9);
|
||||||
|
|
||||||
// add all files to the ZIP one
|
// add all files to the ZIP one
|
||||||
@@ -645,8 +666,12 @@ bool wxDebugReportCompress::DoProcess()
|
|||||||
if ( !zos.PutNextEntry(ze) )
|
if ( !zos.PutNextEntry(ze) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const wxFileName filename(GetDirectory(), name);
|
const wxString ifullPath = wxFileName(GetDirectory(), name).GetFullPath();
|
||||||
wxFFileInputStream is(filename.GetFullPath());
|
#if wxUSE_FFILE
|
||||||
|
wxFFileInputStream is(ifullPath);
|
||||||
|
#elif wxUSE_FILE
|
||||||
|
wxFileInputStream is(ifullPath);
|
||||||
|
#endif
|
||||||
if ( !is.IsOk() || !zos.Write(is).IsOk() )
|
if ( !is.IsOk() || !zos.Write(is).IsOk() )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -654,9 +679,12 @@ bool wxDebugReportCompress::DoProcess()
|
|||||||
if ( !zos.Close() )
|
if ( !zos.Close() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_zipfile = fn.GetFullPath();
|
m_zipfile = ofullPath;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif // HAS_FILE_STREAMS
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -915,6 +915,8 @@ bool wxTextAreaBase::DoLoadFile(const wxString& filename, int WXUNUSED(fileType)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
(void)filename; // avoid compiler warning about unreferenced parameter
|
||||||
#endif // wxUSE_FFILE
|
#endif // wxUSE_FFILE
|
||||||
|
|
||||||
wxLogError(_("File couldn't be loaded."));
|
wxLogError(_("File couldn't be loaded."));
|
||||||
@@ -936,6 +938,8 @@ bool wxTextAreaBase::DoSaveFile(const wxString& filename, int WXUNUSED(fileType)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
(void)filename; // avoid compiler warning about unreferenced parameter
|
||||||
#endif // wxUSE_FFILE
|
#endif // wxUSE_FFILE
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@@ -39,7 +39,11 @@
|
|||||||
#endif // WX_PRECOMP
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
#include "wx/filename.h"
|
#include "wx/filename.h"
|
||||||
|
#ifdef wxUSE_FFILE
|
||||||
#include "wx/ffile.h"
|
#include "wx/ffile.h"
|
||||||
|
#else
|
||||||
|
#include "wx/file.h"
|
||||||
|
#endif
|
||||||
#include "wx/mimetype.h"
|
#include "wx/mimetype.h"
|
||||||
|
|
||||||
#include "wx/statline.h"
|
#include "wx/statline.h"
|
||||||
@@ -432,7 +436,12 @@ void wxDebugReportDialog::OnView(wxCommandEvent& )
|
|||||||
wxFileName fn(m_dbgrpt.GetDirectory(), m_files[sel]);
|
wxFileName fn(m_dbgrpt.GetDirectory(), m_files[sel]);
|
||||||
wxString str;
|
wxString str;
|
||||||
|
|
||||||
wxFFile file(fn.GetFullPath());
|
const wxString& fullPath = fn.GetFullPath();
|
||||||
|
#if wxUSE_FFILE
|
||||||
|
wxFFile file(fullPath);
|
||||||
|
#elif wxUSE_FILE
|
||||||
|
wxFile file(fullPath);
|
||||||
|
#endif
|
||||||
if ( file.IsOpened() && file.ReadAll(&str) )
|
if ( file.IsOpened() && file.ReadAll(&str) )
|
||||||
{
|
{
|
||||||
wxDumpPreviewDlg dlg(this, m_files[sel], str);
|
wxDumpPreviewDlg dlg(this, m_files[sel], str);
|
||||||
|
@@ -8317,6 +8317,7 @@ wxString wxRichTextBuffer::GetExtWildcard(bool combine, bool save, wxArrayInt* t
|
|||||||
return wildcard;
|
return wildcard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_FFILE && wxUSE_STREAMS
|
||||||
/// Load a file
|
/// Load a file
|
||||||
bool wxRichTextBuffer::LoadFile(const wxString& filename, wxRichTextFileType type)
|
bool wxRichTextBuffer::LoadFile(const wxString& filename, wxRichTextFileType type)
|
||||||
{
|
{
|
||||||
@@ -8345,7 +8346,9 @@ bool wxRichTextBuffer::SaveFile(const wxString& filename, wxRichTextFileType typ
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_FFILE && wxUSE_STREAMS
|
||||||
|
|
||||||
|
#if wxUSE_STREAMS
|
||||||
/// Load from a stream
|
/// Load from a stream
|
||||||
bool wxRichTextBuffer::LoadFile(wxInputStream& stream, wxRichTextFileType type)
|
bool wxRichTextBuffer::LoadFile(wxInputStream& stream, wxRichTextFileType type)
|
||||||
{
|
{
|
||||||
@@ -8374,6 +8377,7 @@ bool wxRichTextBuffer::SaveFile(wxOutputStream& stream, wxRichTextFileType type)
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_STREAMS
|
||||||
|
|
||||||
/// Copy the range to the clipboard
|
/// Copy the range to the clipboard
|
||||||
bool wxRichTextBuffer::CopyToClipboard(const wxRichTextRange& range)
|
bool wxRichTextBuffer::CopyToClipboard(const wxRichTextRange& range)
|
||||||
|
@@ -2665,7 +2665,7 @@ bool wxRichTextCtrl::RecreateBuffer(const wxSize& size)
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// file IO functions
|
// file IO functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
#if wxUSE_FFILE && wxUSE_STREAMS
|
||||||
bool wxRichTextCtrl::DoLoadFile(const wxString& filename, int fileType)
|
bool wxRichTextCtrl::DoLoadFile(const wxString& filename, int fileType)
|
||||||
{
|
{
|
||||||
SetFocusObject(& GetBuffer(), true);
|
SetFocusObject(& GetBuffer(), true);
|
||||||
@@ -2707,6 +2707,7 @@ bool wxRichTextCtrl::DoSaveFile(const wxString& filename, int fileType)
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_FFILE && wxUSE_STREAMS
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxRichTextCtrl specific functionality
|
// wxRichTextCtrl specific functionality
|
||||||
|
@@ -506,6 +506,7 @@ void wxRichTextPrinting::SetRichTextBufferPreview(wxRichTextBuffer* buf)
|
|||||||
m_richTextBufferPreview = buf;
|
m_richTextBufferPreview = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_FFILE && wxUSE_STREAMS
|
||||||
bool wxRichTextPrinting::PreviewFile(const wxString& richTextFile)
|
bool wxRichTextPrinting::PreviewFile(const wxString& richTextFile)
|
||||||
{
|
{
|
||||||
SetRichTextBufferPreview(new wxRichTextBuffer);
|
SetRichTextBufferPreview(new wxRichTextBuffer);
|
||||||
@@ -525,6 +526,7 @@ bool wxRichTextPrinting::PreviewFile(const wxString& richTextFile)
|
|||||||
p2->SetRichTextBuffer(m_richTextBufferPrinting);
|
p2->SetRichTextBuffer(m_richTextBufferPrinting);
|
||||||
return DoPreview(p1, p2);
|
return DoPreview(p1, p2);
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_FFILE && wxUSE_STREAMS
|
||||||
|
|
||||||
bool wxRichTextPrinting::PreviewBuffer(const wxRichTextBuffer& buffer)
|
bool wxRichTextPrinting::PreviewBuffer(const wxRichTextBuffer& buffer)
|
||||||
{
|
{
|
||||||
@@ -540,6 +542,7 @@ bool wxRichTextPrinting::PreviewBuffer(const wxRichTextBuffer& buffer)
|
|||||||
return DoPreview(p1, p2);
|
return DoPreview(p1, p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_FFILE && wxUSE_STREAMS
|
||||||
bool wxRichTextPrinting::PrintFile(const wxString& richTextFile, bool showPrintDialog)
|
bool wxRichTextPrinting::PrintFile(const wxString& richTextFile, bool showPrintDialog)
|
||||||
{
|
{
|
||||||
SetRichTextBufferPrinting(new wxRichTextBuffer);
|
SetRichTextBufferPrinting(new wxRichTextBuffer);
|
||||||
@@ -557,6 +560,7 @@ bool wxRichTextPrinting::PrintFile(const wxString& richTextFile, bool showPrintD
|
|||||||
delete p;
|
delete p;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_FFILE && wxUSE_STREAMS
|
||||||
|
|
||||||
bool wxRichTextPrinting::PrintBuffer(const wxRichTextBuffer& buffer, bool showPrintDialog)
|
bool wxRichTextPrinting::PrintBuffer(const wxRichTextBuffer& buffer, bool showPrintDialog)
|
||||||
{
|
{
|
||||||
|
@@ -50,7 +50,7 @@
|
|||||||
#if wxUSE_FFILE
|
#if wxUSE_FFILE
|
||||||
#include "wx/ffile.h"
|
#include "wx/ffile.h"
|
||||||
#elif wxUSE_FILE
|
#elif wxUSE_FILE
|
||||||
#include "wx/ffile.h"
|
#include "wx/file.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
|
Reference in New Issue
Block a user