* 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:
@@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -470,65 +470,64 @@ SudokuView::SaveTo(BDataIO& stream, uint32 exportAs)
|
|||||||
status_t
|
status_t
|
||||||
SudokuView::CopyToClipboard()
|
SudokuView::CopyToClipboard()
|
||||||
{
|
{
|
||||||
status_t status = B_ERROR;
|
|
||||||
if (!be_clipboard->Lock())
|
if (!be_clipboard->Lock())
|
||||||
return status;
|
return B_ERROR;
|
||||||
|
|
||||||
be_clipboard->Clear();
|
be_clipboard->Clear();
|
||||||
|
|
||||||
BMessage* clip = be_clipboard->Data();
|
BMessage* clip = be_clipboard->Data();
|
||||||
if (clip == NULL) {
|
if (clip == NULL) {
|
||||||
be_clipboard->Unlock();
|
be_clipboard->Unlock();
|
||||||
return status;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// As BBitmap
|
// As BBitmap
|
||||||
BMallocIO mio;
|
BMallocIO mallocIO;
|
||||||
status = SaveTo(mio, kExportAsBitmap);
|
status_t status = SaveTo(mallocIO, kExportAsBitmap);
|
||||||
if (status >= B_OK) {
|
if (status >= B_OK) {
|
||||||
mio.Seek(0LL, SEEK_SET);
|
mallocIO.Seek(0LL, SEEK_SET);
|
||||||
// ShowImage, ArtPaint & WonderBrush use that
|
// ShowImage, ArtPaint & WonderBrush use that
|
||||||
status = clip->AddData("image/bitmap", B_MESSAGE_TYPE,
|
status = clip->AddData("image/bitmap", B_MESSAGE_TYPE,
|
||||||
mio.Buffer(), mio.BufferLength());
|
mallocIO.Buffer(), mallocIO.BufferLength());
|
||||||
// Becasso uses that ?
|
// Becasso uses that ?
|
||||||
clip->AddData("image/x-be-bitmap", B_MESSAGE_TYPE, mio.Buffer(),
|
clip->AddData("image/x-be-bitmap", B_MESSAGE_TYPE, mallocIO.Buffer(),
|
||||||
mio.BufferLength());
|
mallocIO.BufferLength());
|
||||||
// Gobe Productive uses that...
|
// Gobe Productive uses that...
|
||||||
// QuickRes as well, with a rect field.
|
// QuickRes as well, with a rect field.
|
||||||
clip->AddData("image/x-vnd.Be-bitmap", B_MESSAGE_TYPE, mio.Buffer(),
|
clip->AddData("image/x-vnd.Be-bitmap", B_MESSAGE_TYPE,
|
||||||
mio.BufferLength());
|
mallocIO.Buffer(), mallocIO.BufferLength());
|
||||||
}
|
}
|
||||||
mio.Seek(0LL, SEEK_SET);
|
mallocIO.Seek(0LL, SEEK_SET);
|
||||||
mio.SetSize(0LL);
|
mallocIO.SetSize(0LL);
|
||||||
|
|
||||||
// As HTML
|
// As HTML
|
||||||
if (status >= B_OK)
|
if (status >= B_OK)
|
||||||
status = SaveTo(mio, kExportAsHTML);
|
status = SaveTo(mallocIO, kExportAsHTML);
|
||||||
if (status >= B_OK) {
|
if (status >= B_OK) {
|
||||||
status = clip->AddData("text/html", B_MIME_TYPE, mio.Buffer(),
|
status = clip->AddData("text/html", B_MIME_TYPE, mallocIO.Buffer(),
|
||||||
mio.BufferLength());
|
mallocIO.BufferLength());
|
||||||
}
|
}
|
||||||
mio.Seek(0LL, SEEK_SET);
|
mallocIO.Seek(0LL, SEEK_SET);
|
||||||
mio.SetSize(0LL);
|
mallocIO.SetSize(0LL);
|
||||||
|
|
||||||
// As plain text
|
// As plain text
|
||||||
if (status >= B_OK)
|
if (status >= B_OK)
|
||||||
SaveTo(mio, kExportAsText);
|
SaveTo(mallocIO, kExportAsText);
|
||||||
if (status >= B_OK) {
|
if (status >= B_OK) {
|
||||||
status = clip->AddData("text/plain", B_MIME_TYPE, mio.Buffer(),
|
status = clip->AddData("text/plain", B_MIME_TYPE, mallocIO.Buffer(),
|
||||||
mio.BufferLength());
|
mallocIO.BufferLength());
|
||||||
}
|
}
|
||||||
mio.Seek(0LL, SEEK_SET);
|
mallocIO.Seek(0LL, SEEK_SET);
|
||||||
mio.SetSize(0LL);
|
mallocIO.SetSize(0LL);
|
||||||
|
|
||||||
// As flattened BPicture, anyone handles that ?
|
// As flattened BPicture, anyone handles that?
|
||||||
if (status >= B_OK)
|
if (status >= B_OK)
|
||||||
status = SaveTo(mio, kExportAsPicture);
|
status = SaveTo(mallocIO, kExportAsPicture);
|
||||||
if (status >= B_OK) {
|
if (status >= B_OK) {
|
||||||
status = clip->AddData("image/x-vnd.Be-picture", B_MIME_TYPE,
|
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->Commit();
|
||||||
be_clipboard->Unlock();
|
be_clipboard->Unlock();
|
||||||
|
|||||||
Reference in New Issue
Block a user