- str << wxT("data:");
- str << GetMimeType(image->GetImageBlock().GetImageType());
- str << wxT(";base64,");
-
- if (image->GetImage().Ok() && !image->GetImageBlock().GetData())
- image->MakeBlock();
-
- wxChar* data = b64enc( image->GetImageBlock().GetData(), image->GetImageBlock().GetDataSize() );
- str << data;
-
- delete[] data;
-
+
+#if wxUSE_FILESYSTEM
+ if (GetFlags() & wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY)
+ {
+ if (!image->GetImage().Ok() && image->GetImageBlock().GetData())
+ image->LoadFromBlock();
+ if (image->GetImage().Ok() && !image->GetImageBlock().GetData())
+ image->MakeBlock();
+
+ if (image->GetImage().Ok())
+ {
+ wxString ext(image->GetImageBlock().GetExtension());
+ wxString tempFilename(wxString::Format(wxT("image%d.%s"), sm_fileCounter, ext));
+ wxMemoryFSHandler::AddFile(tempFilename, image->GetImage(), image->GetImageBlock().GetImageType());
+
+ m_imageLocations.Add(tempFilename);
+
+ str << wxT("memory:") << tempFilename;
+ }
+ else
+ str << wxT("memory:?");
+
+ sm_fileCounter ++;
+ }
+ else if (GetFlags() & wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_FILES)
+ {
+ if (!image->GetImage().Ok() && image->GetImageBlock().GetData())
+ image->LoadFromBlock();
+ if (image->GetImage().Ok() && !image->GetImageBlock().GetData())
+ image->MakeBlock();
+
+ if (image->GetImage().Ok())
+ {
+ wxString tempDir(GetTempDir());
+ if (tempDir.IsEmpty())
+ tempDir = wxFileName::GetTempDir();
+
+ wxString ext(image->GetImageBlock().GetExtension());
+ wxString tempFilename(wxString::Format(wxT("%s/image%d.%s"), tempDir, sm_fileCounter, ext));
+ image->GetImageBlock().Write(tempFilename);
+
+ m_imageLocations.Add(tempFilename);
+
+ str << wxFileSystem::FileNameToURL(tempFilename);
+ }
+ else
+ str << wxT("file:?");
+
+ sm_fileCounter ++;
+ }
+ else // if (GetFlags() & wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64) // this is implied
+#endif
+ {
+ str << wxT("data:");
+ str << GetMimeType(image->GetImageBlock().GetImageType());
+ str << wxT(";base64,");
+
+ if (image->GetImage().Ok() && !image->GetImageBlock().GetData())
+ image->MakeBlock();
+
+ wxChar* data = b64enc( image->GetImageBlock().GetData(), image->GetImageBlock().GetDataSize() );
+ str << data;
+
+ delete[] data;
+ }
+