* Renamed "mio" to mallocIO.

* Don't define status in CopyToClipboard() before it's actually used.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37124 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-06-13 10:48:09 +00:00
parent 30dabe8cd9
commit fd43517b2c
+26 -27
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2008, Axel Dörfler, [email protected]. All rights reserved.
* Copyright 2007-2010, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
@@ -470,65 +470,64 @@ SudokuView::SaveTo(BDataIO& stream, uint32 exportAs)
status_t
SudokuView::CopyToClipboard()
{
status_t status = B_ERROR;
if (!be_clipboard->Lock())
return status;
return B_ERROR;
be_clipboard->Clear();
BMessage* clip = be_clipboard->Data();
if (clip == NULL) {
be_clipboard->Unlock();
return status;
return B_ERROR;
}
// As BBitmap
BMallocIO mio;
status = SaveTo(mio, kExportAsBitmap);
BMallocIO mallocIO;
status_t status = SaveTo(mallocIO, kExportAsBitmap);
if (status >= B_OK) {
mio.Seek(0LL, SEEK_SET);
mallocIO.Seek(0LL, SEEK_SET);
// ShowImage, ArtPaint & WonderBrush use that
status = clip->AddData("image/bitmap", B_MESSAGE_TYPE,
mio.Buffer(), mio.BufferLength());
mallocIO.Buffer(), mallocIO.BufferLength());
// Becasso uses that ?
clip->AddData("image/x-be-bitmap", B_MESSAGE_TYPE, mio.Buffer(),
mio.BufferLength());
clip->AddData("image/x-be-bitmap", B_MESSAGE_TYPE, mallocIO.Buffer(),
mallocIO.BufferLength());
// Gobe Productive uses that...
// QuickRes as well, with a rect field.
clip->AddData("image/x-vnd.Be-bitmap", B_MESSAGE_TYPE, mio.Buffer(),
mio.BufferLength());
clip->AddData("image/x-vnd.Be-bitmap", B_MESSAGE_TYPE,
mallocIO.Buffer(), mallocIO.BufferLength());
}
mio.Seek(0LL, SEEK_SET);
mio.SetSize(0LL);
mallocIO.Seek(0LL, SEEK_SET);
mallocIO.SetSize(0LL);
// As HTML
if (status >= B_OK)
status = SaveTo(mio, kExportAsHTML);
status = SaveTo(mallocIO, kExportAsHTML);
if (status >= B_OK) {
status = clip->AddData("text/html", B_MIME_TYPE, mio.Buffer(),
mio.BufferLength());
status = clip->AddData("text/html", B_MIME_TYPE, mallocIO.Buffer(),
mallocIO.BufferLength());
}
mio.Seek(0LL, SEEK_SET);
mio.SetSize(0LL);
mallocIO.Seek(0LL, SEEK_SET);
mallocIO.SetSize(0LL);
// As plain text
if (status >= B_OK)
SaveTo(mio, kExportAsText);
SaveTo(mallocIO, kExportAsText);
if (status >= B_OK) {
status = clip->AddData("text/plain", B_MIME_TYPE, mio.Buffer(),
mio.BufferLength());
status = clip->AddData("text/plain", B_MIME_TYPE, mallocIO.Buffer(),
mallocIO.BufferLength());
}
mio.Seek(0LL, SEEK_SET);
mio.SetSize(0LL);
mallocIO.Seek(0LL, SEEK_SET);
mallocIO.SetSize(0LL);
// As flattened BPicture, anyone handles that?
if (status >= B_OK)
status = SaveTo(mio, kExportAsPicture);
status = SaveTo(mallocIO, kExportAsPicture);
if (status >= B_OK) {
status = clip->AddData("image/x-vnd.Be-picture", B_MIME_TYPE,
mio.Buffer(), mio.BufferLength());
mallocIO.Buffer(), mallocIO.BufferLength());
}
mio.SetSize(0LL);
mallocIO.SetSize(0LL);
be_clipboard->Commit();
be_clipboard->Unlock();