ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/clip_macosx.cpp
(Generate patch)

Comparing BasiliskII/src/MacOSX/clip_macosx.cpp (file contents):
Revision 1.5 by gbeauche, 2006-03-21T06:43:02Z vs.
Revision 1.6 by asvitkine, 2007-02-18T21:11:41Z

# Line 34 | Line 34
34   static bool we_put_this_data = false;
35  
36  
37 + static void SwapScrapData(uint32 type, void *data, int32 length, int from_host) {
38 + #if BYTE_ORDER != BIG_ENDIAN
39 +        if (type == kScrapFlavorTypeTextStyle) {
40 +                uint16 *sdata = (uint16 *) data;
41 +                // the first short stores the number of runs
42 +                uint16 runs = sdata[0];
43 +                sdata[0] = htons(sdata[0]);
44 +                if (from_host)
45 +                        runs = sdata[0];
46 +                sdata++;
47 +                // loop through each run
48 +                for (int i = 0; i < runs; i++) {
49 +                        struct style_data {
50 +                                uint32 offset;
51 +                                uint16 line_height;
52 +                                uint16 line_ascent;
53 +                                uint16 font_family;
54 +                                uint16 character_style; // not swapped
55 +                                uint16 point_size;
56 +                                uint16 red;
57 +                                uint16 green;
58 +                                uint16 blue;
59 +                        } *style = (struct style_data *) (sdata + i*10);
60 +                        style->offset = htonl(style->offset);
61 +                        style->line_height = htons(style->line_height);
62 +                        style->line_ascent = htons(style->line_ascent);
63 +                        style->font_family = htons(style->font_family);
64 +                        style->point_size = htons(style->point_size);
65 +                        style->red = htons(style->red);
66 +                        style->green = htons(style->green);
67 +                        style->blue = htons(style->blue);
68 +                }
69 +        } else {
70 +                // add byteswapping code for other flavor types here ...
71 +        }
72 + #endif
73 + }
74 +
75 +
76   /*
77   *  Initialization
78   */
# Line 79 | Line 118 | void GetScrap(void **handle, uint32 type
118                  if (scrap_area) {
119                          uint8 * const data = Mac2HostAddr(scrap_area);
120                          if (GetScrapFlavorData(theScrap, type, &byteCount, data) == noErr) {
121 <
121 >                                SwapScrapData(type, data, byteCount, FALSE);
122                                  // Add new data to clipboard
123                                  static uint8 proc[] = {
124                                          0x59, 0x8f,                                     // subq.l       #4,sp
# Line 137 | Line 176 | void PutScrap(uint32 type, void *scrap,
176                  return;
177          }
178  
179 +        SwapScrapData(type, scrap, length, TRUE);
180          if (PutScrapFlavor(theScrap, type, kScrapFlavorMaskNone, length, scrap) != noErr) {
181                  D(bug(" could not put to scrap\n"));
182                  return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines