[haiku-commits] r37122 - haiku/trunk/src/apps/sudoku

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 12 Jun 2010 20:06:27 +0200 (CEST)

Author: stippi
Date: 2010-06-12 20:06:27 +0200 (Sat, 12 Jun 2010)
New Revision: 37122
Changeset: http://dev.haiku-os.org/changeset/37122/haiku

Modified:
   haiku/trunk/src/apps/sudoku/SudokuView.cpp
Log:
 * Fixed coding style violations in CopyToClipboard.
 * Fixed compiler warnings.


Modified: haiku/trunk/src/apps/sudoku/SudokuView.cpp
===================================================================
--- haiku/trunk/src/apps/sudoku/SudokuView.cpp  2010-06-12 17:55:52 UTC (rev 
37121)
+++ haiku/trunk/src/apps/sudoku/SudokuView.cpp  2010-06-12 18:06:27 UTC (rev 
37122)
@@ -470,48 +470,69 @@
 status_t
 SudokuView::CopyToClipboard()
 {
-       status_t status = EINVAL;
-       BMessage *clip;
-       if (be_clipboard->Lock()) {
-               BMallocIO mio;
-               be_clipboard->Clear();
-               clip = be_clipboard->Data();
-               if (clip) {
-                       // first as bitmap as we need to archive to the message
-                       if (SaveTo(mio, kExportAsBitmap) >= B_OK) {
-                               mio.Seek(0LL, SEEK_SET);
-                               // ShowImage, ArtPaint & WonderBrush use that
-                               clip->AddData("image/bitmap", B_MESSAGE_TYPE, 
mio.Buffer(), mio.BufferLength());
-                               // Becasso uses that ?
-                               clip->AddData("image/x-be-bitmap", 
B_MESSAGE_TYPE, mio.Buffer(), mio.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());
-                       }
-                       mio.Seek(0LL, SEEK_SET);
-                       mio.SetSize(0LL);
-                       
-                       if (SaveTo(mio, kExportAsHTML) >= B_OK)
-                               clip->AddData("text/html", B_MIME_TYPE, 
mio.Buffer(), mio.BufferLength());
-                       mio.Seek(0LL, SEEK_SET);
-                       mio.SetSize(0LL);
-                       
-                       if (SaveTo(mio, kExportAsText) >= B_OK)
-                               clip->AddData("text/plain", B_MIME_TYPE, 
mio.Buffer(), mio.BufferLength());
-                       mio.Seek(0LL, SEEK_SET);
-                       mio.SetSize(0LL);
+       status_t status = B_ERROR;
+       if (!be_clipboard->Lock())
+               return status;
 
-                       // flattened BPicture, anyone handles that ?
-                       if (SaveTo(mio, kExportAsPicture) >= B_OK) {
-                               clip->AddData("image/x-vnd.Be-picture", 
B_MIME_TYPE, mio.Buffer(), mio.BufferLength());
-                               
-                       }
-                       mio.SetSize(0LL);
+       be_clipboard->Clear();
 
-                       be_clipboard->Commit();
-               }
+       BMessage* clip = be_clipboard->Data();
+       if (clip == NULL) {
                be_clipboard->Unlock();
+               return status;
        }
+
+       // As BBitmap
+       BMallocIO mio;
+       status = SaveTo(mio, kExportAsBitmap);
+       if (status >= B_OK) {
+               mio.Seek(0LL, SEEK_SET);
+               // ShowImage, ArtPaint & WonderBrush use that
+               status = clip->AddData("image/bitmap", B_MESSAGE_TYPE,
+                       mio.Buffer(), mio.BufferLength());
+               // Becasso uses that ?
+               clip->AddData("image/x-be-bitmap", B_MESSAGE_TYPE, mio.Buffer(),
+                       mio.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());
+       }
+       mio.Seek(0LL, SEEK_SET);
+       mio.SetSize(0LL);
+
+       // As HTML
+       if (status >= B_OK)
+               status = SaveTo(mio, kExportAsHTML);
+       if (status >= B_OK) {
+               status = clip->AddData("text/html", B_MIME_TYPE, mio.Buffer(),
+                       mio.BufferLength());
+       }
+       mio.Seek(0LL, SEEK_SET);
+       mio.SetSize(0LL);
+
+       // As plain text
+       if (status >= B_OK)
+               SaveTo(mio, kExportAsText);
+       if (status >= B_OK) {
+               status = clip->AddData("text/plain", B_MIME_TYPE, mio.Buffer(),
+                       mio.BufferLength());
+       }
+       mio.Seek(0LL, SEEK_SET);
+       mio.SetSize(0LL);
+
+       // As flattened BPicture, anyone handles that ?
+       if (status >= B_OK)
+               status = SaveTo(mio, kExportAsPicture);
+       if (status >= B_OK) {
+               status = clip->AddData("image/x-vnd.Be-picture", B_MIME_TYPE,
+                       mio.Buffer(), mio.BufferLength());
+       }
+       mio.SetSize(0LL);
+
+       be_clipboard->Commit();
+       be_clipboard->Unlock();
+
        return status;
 }
 
@@ -789,7 +810,7 @@
        uint32 field = x + y * fField->Size();
        _PushUndo();
 
-       if (clicks == 2 && fLastHintValue == value && fLastField == field
+       if ((clicks == 2 && fLastHintValue == value && fLastField == field)
                || (buttons & (B_SECONDARY_MOUSE_BUTTON
                                | B_TERTIARY_MOUSE_BUTTON)) != 0) {
                // double click or other buttons set a value
@@ -852,7 +873,7 @@
        }
        if (!isField
                || (fField->FlagsAt(x, y) & kInitialValue) != 0
-               || !fShowCursor && fField->ValueAt(x, y) != 0) {
+               || (!fShowCursor && fField->ValueAt(x, y) != 0)) {
                _RemoveHint();
                return;
        }
@@ -1184,9 +1205,9 @@
 
        for (uint32 y = 0; y < size; y++) {
                for (uint32 x = 0; x < size; x++) {
-                       if ((fShowCursor && x == fShowHintX && y == fShowHintY
-                                       || fShowKeyboardFocus && x == fKeyboardX
-                                               && y == fKeyboardY)
+                       if (((fShowCursor && x == fShowHintX && y == fShowHintY)
+                                       || (fShowKeyboardFocus && x == 
fKeyboardX
+                                               && y == fKeyboardY))
                                && (fField->FlagsAt(x, y) & kInitialValue) == 
0) {
                                //SetLowColor(tint_color(ViewColor(), 
B_DARKEN_1_TINT));
                                SetLowColor(255, 255, 210);


Other related posts:

  • » [haiku-commits] r37122 - haiku/trunk/src/apps/sudoku - superstippi