tablescrap.c

Go to the documentation of this file.
00001 
00002 /*  $Id: tablescrap.c 1203 2006-04-05 22:58:09Z karstenw $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 #include "frontier.h"
00029 #include "standard.h"
00030 
00031 #include "memory.h"
00032 #include "dialogs.h"
00033 #include "kb.h"
00034 #include "scrap.h"
00035 #include "strings.h"
00036 #include "shell.rsrc.h"
00037 #include "shellundo.h"
00038 #include "lang.h"
00039 #include "langexternal.h"
00040 #include "op.h"
00041 #include "opinternal.h"
00042 #include "menueditor.h"
00043 #include "wpengine.h"
00044 #include "wpverbs.h"
00045 #include "scripts.h"
00046 #include "shell.rsrc.h"
00047 #include "claybrowser.h"
00048 #include "claybrowserstruc.h"
00049 #include "tableinternal.h"
00050 #include "tablestructure.h"
00051 #include "tableverbs.h"
00052 
00053 
00054 typedef struct tytablescrap {
00055 
00056     Handle hpacked;
00057     
00058     bigstring bspath;
00059     } tytablescrap, *ptrtablescrap, **hdltablescrap;
00060 
00061 
00062 #if 0
00063 
00064 static boolean tablegetscrapvaluetype (Handle hscrap, tyvaluetype *type) {
00065     
00066     register Handle h;
00067     long ix;
00068     OSType typeid;
00069     
00070     h = hscrap; /*copy into register*/
00071     
00072     ix = stringlength ((ptrstring) *h) + 1;
00073     
00074     if (!loadfromhandle (h, &ix, longsizeof (typeid), &typeid))
00075         return (false);
00076     
00077     *type = langgetvaluetype (typeid);
00078     
00079     return (true);
00080     } /*tablegetscrapvaluetype*/
00081 
00082 #endif
00083 
00084 
00085 static boolean tableexpandtodotparams (bigstring bspath, hdlhashtable *htable, bigstring bsname) {
00086     
00087     pushhashtable (roottable);
00088     
00089     if (!langexpandtodotparams (bspath, htable, bsname))
00090         *htable = nil;
00091     
00092     pophashtable ();
00093     
00094     return (*htable != nil);
00095     } /*tableexpandtodotparams*/
00096 
00097 
00098 static boolean tablegetscrapvalue (Handle hscrap, tyvaluerecord *val, hdlhashtable *htable, bigstring bsname) {
00099     
00100     register Handle h;
00101     register boolean fl;
00102     bigstring bspath;
00103     
00104     *htable = nil;
00105     
00106     if (!copyhandle (hscrap, &hscrap))
00107         return (false);
00108     
00109     h = hscrap; /*copy into register*/
00110     
00111     pullfromhandle (h, 0L, stringlength ((ptrstring) *h) + 1, bspath);
00112     
00113     disablelangerror ();
00114     
00115     tableexpandtodotparams (bspath, htable, bsname);
00116     
00117     enablelangerror ();
00118     
00119     fl = langunpackvalue (h, val);
00120     
00121     disposehandle (h);
00122     
00123     return (fl);
00124     } /*tablegetscrapvalue*/
00125 
00126 
00127 static boolean tableexporttextscrap (const tyvaluerecord *scrapval, Handle *hexport) {
00128     
00129     /*
00130     7/19/91 dmb: don't prepend value name in exported text
00131     
00132     4/29/93 dmb: don't limit scalar values to 255 chars
00133     */
00134     
00135     tyvaluerecord val;
00136     register boolean fl;
00137     
00138     val = *scrapval;
00139     
00140     *hexport = nil;
00141 
00142     if (val.valuetype == externalvaluetype) {
00143         
00144         fl = newemptyhandle (hexport);
00145         
00146         if (fl)
00147             fl = langexternalpacktotext ((hdlexternalvariable) val.data.externalvalue, *hexport);
00148         }
00149     else {
00150         
00151         fl = copyvaluerecord (val, &val) && coercetostring (&val);
00152         
00153         if (fl) {
00154             
00155             fl = copyhandle (val.data.stringvalue, hexport);
00156             
00157             disposevaluerecord (val, false);
00158             }
00159         }
00160     
00161     if (fl)
00162         return (true);
00163     
00164     disposehandle (*hexport);
00165     
00166     *hexport = nil;
00167     
00168     return (false);
00169     } /*tableexporttextscrap*/
00170 
00171 
00172 
00173 static tyvaluetype langgetexternalvaluetype (const tyvaluerecord *val) {
00174     
00175     /*
00176     5.0b9 dmb: a missing bit of langexternal functionality
00177     */
00178 
00179     if ((*val).valuetype != externalvaluetype)
00180         return (novaluetype);
00181     
00182     return (tyvaluetype) (outlinevaluetype + langexternalgettype (*val));
00183     } /*langgetexternalvaluetype*/
00184 
00185 
00186 static boolean tableexportoutlinescrap (const tyvaluerecord *scrapval, Handle *hexport) {
00187     
00188     /*
00189     convert the given table scrap value to an outline/script/menubar
00190     
00191     7/21/91 dmb: see comment in pastetooutline about poor data encapsulation 
00192     techniques being practiced here (or not...)
00193     */
00194     
00195     tyvaluetype type;
00196     tyvaluerecord val;
00197     register hdlexternalvariable hv;
00198     register hdloutlinerecord ho;
00199     
00200     *hexport = nil;
00201     
00202     type = langgetexternalvaluetype (scrapval);
00203     
00204     switch (type) { /*find out if our value has an outline*/
00205         
00206         case outlinevaluetype:
00207         case scriptvaluetype:
00208         case menuvaluetype:
00209             break;
00210         
00211         default:
00212             return (false);
00213         }
00214     
00215     if (!copyvaluerecord (*scrapval, &val) || !copyvaluedata (&val))
00216         return (false);
00217     
00218     /*
00219     find the value's outline and steal it be nilling out the field
00220     */
00221     
00222     hv = (hdlexternalvariable) val.data.externalvalue;
00223     
00224     if (type == menuvaluetype) {
00225         
00226         ho = (**(hdlmenurecord) (**hv).variabledata).menuoutline;
00227         
00228         (**(hdlmenurecord) (**hv).variabledata).menuoutline = nil; /*we've consumed it*/
00229         }
00230     else {
00231         
00232         ho = (hdloutlinerecord) (**hv).variabledata;
00233         
00234         (**hv).variabledata = 0L; /*we've consumed it*/
00235         }
00236     
00237     *hexport = (Handle) ho;
00238     
00239     disposevaluerecord (val, false);
00240     
00241     return (true);
00242     } /*tableexportoutlinescrap*/
00243 
00244 
00245 static boolean tableexportwpscrap (const tyvaluerecord *scrapval, Handle *hexport) {
00246     
00247     /*
00248     convert the given table scrap value to a wp scrap
00249     */
00250     
00251     tyvaluerecord val;
00252     register boolean fl;
00253     register hdlexternalvariable hv;
00254     register hdlwprecord hwp;
00255     
00256     *hexport = nil;
00257     
00258     if (langgetexternalvaluetype (scrapval) != wordvaluetype)
00259         return (false);
00260     
00261     fl = copyvaluerecord (*scrapval, &val) && copyvaluedata (&val);
00262     
00263     if (!fl)
00264         return (false);
00265     
00266     hv = (hdlexternalvariable) val.data.externalvalue;
00267     
00268     fl = wpverbinmemory (hv);
00269     
00270     if (fl) {
00271         
00272         hwp = (hdlwprecord) (**hv).variabledata;
00273         
00274         *hexport = (Handle) (**hwp).wpbuffer;
00275         
00276         (**hwp).wpbuffer = nil; /*we've consumed it*/
00277         }
00278     
00279     disposevaluerecord (val, false);
00280     
00281     return (fl);
00282     } /*tableexportwpscrap*/
00283 
00284 
00285 boolean tableexportscrapvalue (const tyvaluerecord *scrapval, tyscraptype totype, Handle *hexport, boolean *fltempscrap) {
00286     
00287     *fltempscrap = true; /*usually we be the case*/
00288     
00289     switch (totype) {
00290         
00291         case hashscraptype:
00292             /*
00293             *** major problem: our refcons are not contiguous data. they 
00294             are pointers into the odb structure. currently, oppack doesn't 
00295             have a callback mechanism for packing refcon data. so we can't
00296             export a self-contained table scrap
00297             */
00298             
00299             return (false);
00300         
00301         case textscraptype:
00302             return (tableexporttextscrap (scrapval, hexport));
00303         
00304         case opscraptype:
00305         case scriptscraptype:
00306         case menuscraptype:
00307             return (tableexportoutlinescrap (scrapval, hexport));
00308         
00309         case wpscraptype:
00310             return (tableexportwpscrap (scrapval, hexport));
00311         
00312         default:
00313             return (false);
00314         }
00315     } /*tableexportscrapvalue*/
00316 
00317 
00318 static boolean tablegetvaluescrap (Handle hscrap, tyscraptype scraptype, tyvaluerecord *val) {
00319     
00320     Handle x;
00321     tyvaluetype valuetype = langgetvaluetype (scraptype);
00322     
00323     if (!copyhandle (hscrap, &x))
00324         return (false);
00325     
00326     if (!setbinaryvalue (x, scraptype, val))
00327         return (false);
00328     
00329     if (langgoodbinarytype (valuetype)) { /*unpack-able*/
00330         
00331         if (!coercevalue (val, valuetype))
00332             return (false);
00333         }
00334     
00335     return (true);
00336     } /*tablegetvaluescrap*/
00337 
00338 
00339 static boolean tableexportvaluescrap (Handle hscrap, tyscraptype totype, Handle *hexport, boolean *fltempscrap) {
00340     
00341     /*
00342     3.0.2 dmb: new routine. if a foreign value is on the clipboard we 
00343     convert it to text
00344     */
00345     
00346     tyscraptype scraptype;
00347     tyvaluerecord val;
00348     register boolean fl;
00349     
00350     if (totype != textscraptype)
00351         return (false);
00352     
00353     shellgetscrap (&hscrap, &scraptype); /*should be same value for hscrap*/
00354     
00355     disablelangerror ();
00356     
00357     fl = tablegetvaluescrap (hscrap, scraptype, &val);
00358     
00359     if (fl)
00360         fl = copyvaluerecord (val, &val) && coercetostring (&val);
00361     
00362     if (fl) {
00363         
00364         exemptfromtmpstack (&val);
00365         
00366         *fltempscrap = true;
00367             
00368         *hexport = val.data.stringvalue;
00369         }
00370     
00371     enablelangerror ();
00372     
00373     return (fl);
00374     } /*tableexportvaluescrap*/
00375 
00376 
00377 #ifndef odbbrowser
00378 
00379 static void tabledisposescrap (hdltablescrap hscrap) {
00380     
00381     disposehandle ((Handle) hscrap);
00382     } /*tabledisposescrap*/
00383 
00384 #endif
00385 
00386 
00387 boolean tablescraphook (Handle hscrap) {
00388     
00389     /*
00390     if our private type is on the external clipboard, set the internal 
00391     scrap to it.
00392     
00393     10/22/91 dmb: import any language value scrap type
00394     
00395     3.0.2 dmb: use new tableexportvaluescrap so we can paste foreign values 
00396     as text
00397     
00398     4.1b7 dmb: don't choose langvalue scrap types over text unless the 
00399     option key is down.
00400     */
00401     
00402     tyvaluetype type;
00403     
00404     if (getscrap (hashscraptype, hscrap)) {
00405         
00406         hdloutlinerecord houtline;
00407         
00408         if (opunpackoutline (hscrap, &houtline))
00409             browsersetscrap (houtline);
00410         
00411         return (false); /*don't call any more hooks*/
00412         }
00413     
00414     if (!getscrap (textscraptype, nil) || keyboardstatus.floptionkey) { /*4.1b7 dmb*/
00415     
00416         for (type = charvaluetype; type < ctvaluetypes; ++type) {
00417             
00418             if (type != stringvaluetype) { /*leave TEXT for someone else*/
00419                 
00420                 OSType scraptype = langgettypeid (type);
00421                 
00422                 if (getscrap (scraptype, hscrap)) {
00423                     
00424                     shellsetscrap (hscrap, scraptype,
00425                         (shelldisposescrapcallback) &disposehandle,
00426                         (shellexportscrapcallback) &tableexportvaluescrap);
00427                     
00428                     return (false); /*don't call any more hooks*/
00429                     }
00430                 }
00431             }
00432         }
00433     
00434     return (true); /*keep going*/
00435     } /*tablescraphook*/
00436 
00437 
00438 #ifndef odbbrowser
00439 
00440 boolean tablecopyroutine (void) {
00441     
00442     hdlhashtable htable;
00443     tyvaluerecord val;
00444     bigstring bsname;
00445     bigstring bspath;
00446     Handle hscrap;
00447     boolean fl;
00448     hdlhashnode hnode;
00449     
00450     if (tableeditsetglobals ())
00451         return (wpcopy ());
00452     
00453     if (!tablegetcursorinfo (&htable, bsname, &val, &hnode))
00454         return (false);
00455     
00456     langexternalgetquotedpath (htable, emptystring, bspath);
00457     
00458     pushchar ('.', bspath);
00459     
00460     langexternalbracketname (bsname);
00461     
00462     pushstring (bsname, bspath);
00463     
00464     langpusherrorcallback (nil, 0L);
00465     
00466     fl = langpackvalue (val, &hscrap, hnode);
00467     
00468     langpoperrorcallback ();
00469     
00470     if (!fl)
00471         return (false);
00472     
00473     if (!insertinhandle (hscrap, 0L, bspath, stringlength (bspath) + 1)) {
00474         
00475         disposehandle (hscrap);
00476         
00477         return (false);
00478         }
00479     
00480     shellsetscrap (hscrap, hashscraptype, &tabledisposescrap, &tableexportscrap);
00481     
00482     return (true);
00483     } /*tablecopyroutine*/
00484 
00485 #endif
00486 
00487 boolean tableredoclear (hdlhashnode hnode, boolean flundo) {
00488     
00489     bigstring bsname;
00490     
00491     if (flundo) {
00492         
00493         hdlhashtable htable = tablegetlinkedhashtable ();
00494         
00495         tableexiteditmode ();
00496         
00497         if (!tablemovetonode (hnode)) /*error selecting node*/
00498             return (false);
00499         
00500         gethashkey (hnode, bsname);
00501         
00502         pushhashtable (htable);
00503         
00504         if (hashunlink (bsname, &hnode))
00505             pushundostep ((undocallback) tableundoclear, (Handle) hnode);
00506         
00507         pophashtable ();
00508         
00509         if (htable == agentstable)
00510             scriptremoveagent (hnode);
00511         }
00512     
00513     return (true);
00514     } /*tableredoclear*/
00515 
00516 
00517 boolean tableundoclear (hdlhashnode hnode, boolean flundo) {
00518     
00519     hdlhashtable htable = tablegetlinkedhashtable ();
00520     
00521     if (flundo) {
00522         
00523         tableexiteditmode ();
00524         
00525         tableoverridesort ((**hnode).sortedlink); /*retain original sort position*/
00526         
00527         hashinsertnode (hnode, htable);
00528         
00529         tablerestoresort ();
00530         
00531         tablemovetonode (hnode); /*select it*/
00532         
00533         if (htable == agentstable)
00534             scriptinstallagent (hnode);
00535         
00536         pushundostep ((undocallback) tableredoclear, (Handle) hnode);
00537         }
00538     else
00539         disposehashnode (htable, hnode, true, true);
00540     
00541     return (true);
00542     } /*tableundoclear*/
00543 
00544 
00545 static boolean tableclosewindows (hdlhashnode hnode, ptrvoid refcon) {
00546 #pragma unused (refcon)
00547 
00548     /*
00549     the indicated external value is being deleted.  close any windows 
00550     that contain descendants of the table
00551     */
00552     
00553     hdlhashtable htable;
00554     tyvaluerecord val;
00555     hdlwindowinfo hinfo;
00556     
00557     val = (**hnode).val;
00558     
00559     if (val.valuetype != externalvaluetype) /*can't be in a window -- unwind recursion*/
00560         return (true);
00561     
00562     if (langexternalwindowopen (val, &hinfo))
00563         shellclosewindow ((**hinfo).macwindow);
00564     
00565     if (langexternalvaltotable (val, &htable, hnode))
00566         hashtablevisit (htable, &tableclosewindows, nil); /*daisy chain recursion*/
00567     
00568     return (true);
00569     } /*tableclosewindows*/
00570     
00571 
00572 #ifndef odbbrowser
00573 
00574 boolean tableclearroutine (void) {
00575     
00576     /*
00577     9/9/91 dmb: move barcursor up when deleting
00578     
00579     5.0a23 dmb: don't ask hashgetiteminfo for the value that we don't use
00580     */
00581     
00582     register hdltableformats hf = tableformatsdata;
00583     bigstring bsname;
00584     hdlhashtable htable;
00585     hdlhashnode hnode;
00586     short row;
00587     
00588     if (tableeditsetglobals ()) {
00589         
00590         if (tableeditingemptycell ())
00591             tableeditleavecell ();
00592         else
00593             return (wpclear ());
00594         }
00595     
00596     pushundoaction (undoclearstring);
00597     
00598     htable = tablegetlinkedhashtable ();
00599     
00600     row = (**hf).rowcursor;
00601     
00602     if (!hashgetiteminfo (htable, row, bsname, nil))
00603         return (false);
00604     
00605     pushhashtable (htable);
00606     
00607     if (hashunlink (bsname, &hnode)) {
00608         
00609         pushundostep ((undocallback) tableundoclear, (Handle) hnode);
00610         
00611         tablebarcursoron (max (0, row - 1));
00612         
00613         tableclosewindows (hnode); /*if an external, make sure dependent windows are closed*/
00614         
00615         if (htable == agentstable) /*make sure agent stops running*/
00616             scriptremoveagent (hnode);
00617         
00618         tablevisicursor ();
00619         }
00620     
00621     pophashtable ();
00622     
00623     return (true);
00624     } /*tableclearroutine*/
00625 
00626 
00627 boolean tablecutroutine (void) {
00628     
00629     if (tableeditsetglobals ()) {
00630         
00631         if (tableeditingemptycell ())
00632             tableeditleavecell ();
00633         else
00634             return (wpcut ());
00635         }
00636     
00637     pushundoaction (undocutstring);
00638     
00639     return (tablecopyroutine ()  &&  tableclearroutine ());
00640     } /*tablecutroutine*/
00641 
00642 #endif
00643 
00644 static void tablemakeuniquename (bigstring bsname, boolean *flchanged) {
00645     
00646     bigstring bscopy;
00647     bigstring bsunique;
00648     short n;
00649     
00650     for (n = 0; ; ++n) {
00651         
00652         copystring (bsname, bsunique);
00653         
00654         if (n > 0) {
00655             
00656             tablegetstringlist (copyofstring, bscopy);
00657             
00658             pushstring (bscopy, bsunique);
00659             
00660             *flchanged = true;
00661             }
00662         
00663         if (n > 1)
00664             pushint (n, bsunique);
00665         
00666         if (!hashsymbolexists (bsunique))
00667             break;
00668         }
00669     
00670     copystring (bsunique, bsname);
00671     } /*tablemakeuniquename*/
00672 
00673 
00674 static boolean tableconfirmedinsert (bigstring bsname, tyvaluerecord val, boolean *flduplicate) {
00675     
00676     /*
00677     add the entry specified by [bsname, value] into the current hash table.
00678     
00679     if an entry with the same name already exists, confirm its impending 
00680     destruction with the user.
00681     
00682     5.0.2b12 dmb: use hashassign, not hashinsert. even though we know it 
00683     doesn't exist, we want the extra processing that it does.
00684     */
00685     
00686     *flduplicate = false;
00687     
00688     if (hashsymbolexists (bsname)) {
00689     
00690         switch (replacevariabledialog (bsname)) {
00691             
00692             case 1: /*user clicked on Replace*/
00693                 hashdelete (bsname, true, true);
00694                 
00695                 break;
00696                 
00697             case 2: /*user clicked on Duplicate*/
00698                 
00699                 tablemakeuniquename (bsname, flduplicate);
00700                 
00701                 *flduplicate = true; /*should already be true, but let's be sure*/
00702                 
00703                 break;
00704                 
00705             case 3: /*user clickded on Cancel*/
00706                 return (false);
00707             } /*switch*/
00708         } /*symbol already defined*/
00709     
00710     hashassign (bsname, val);
00711     
00712     return (true);
00713     } /*tableconfirmedinsert*/
00714 
00715 
00716 static boolean pastetobinary (Handle hscrap, OSType scraptype, tyvaluerecord *val) {
00717     
00718     /*
00719     3.0.2 dmb: if we can unpack the value, do so instead of pasting a binary
00720     */
00721     
00722     if (!tablegetvaluescrap (hscrap, scraptype, val))
00723         return (false);
00724 
00725     exemptfromtmpstack (val);
00726     
00727     return (true);
00728     } /*pastetobinary*/
00729 
00730 
00731 static boolean tablepastevalue (hdlhashtable htable, bigstring bsname, tyvaluerecord val, boolean flselectname) {
00732     
00733     /*
00734     6/13/91 dmb: seperated this code out as part of droppaste implementation
00735     */
00736     
00737     register boolean fl;
00738     boolean flduplicate;
00739     
00740     pushhashtable (htable);
00741     
00742     fl = tableconfirmedinsert (bsname, val, &flduplicate);
00743     
00744     assert (tablevalidate (htable, true));
00745     
00746     if (!fl)
00747         disposevaluerecord (val, false);
00748     
00749     else {
00750         
00751         if (tablezoomtoname (htable, bsname)) { /*select newly-pasted cell*/
00752             
00753             if (shellpushfrontglobals ()) {
00754                 
00755                 hdlhashnode hnode;
00756                 
00757                 pushundoaction (undopastestring);
00758                 
00759                 if (hashlookupnode (bsname, &hnode))
00760                     pushundostep ((undocallback) tableredoclear, (Handle) hnode);
00761                 
00762                 if (flselectname || flduplicate) { /*there was another item with the same name*/
00763                 
00764                     if (opsettextmode (true))
00765                         opeditsetselection (0, infinity);
00766                     }
00767                 
00768                 shellpopglobals ();
00769                 }
00770             }
00771         }
00772     
00773     pophashtable ();
00774     
00775     return (fl);
00776     } /*tablepastevalue*/
00777 
00778 
00779 #ifndef xxxodbbrowser
00780 
00781 static boolean iseditscrap (void) {
00782     
00783     /*
00784     return true if the scrap could be pasted in text mode.  to save code, 
00785     we'll use op's test, whose logic will do just fine
00786     
00787     8/10/92 dmb: since table cells can contain more than 255 characters of 
00788     text, using op's logic for table values is too restrictive.  instead, 
00789     we'll say that anything that isn't a table element itself is eligable
00790     */
00791     
00792     Handle hscrap;
00793     tyscraptype type;
00794     
00795     shellgetscrap (&hscrap, &type);
00796     
00797     if (type == hashscraptype)
00798         return (false);
00799     
00800     if ((**tableformatsdata).focuscol == valuecolumn)
00801         return (true);
00802     
00803     return (!isoutlinescrap ());
00804     } /*iseditscrap*/
00805 
00806 
00807 boolean tablepasteroutine (void) {
00808     
00809     /*
00810     12/28/90 dmb: when pasting text, convert to bigstring if short enough
00811     
00812     12/7/91 dmb: now that strings can be huge, always paste text as a string
00813     
00814     12/17/91 dmb: select any made-up name
00815     */
00816     
00817     tyvaluerecord val;
00818     hdlhashtable horigtable;
00819     bigstring bsname;
00820     hdlhashtable htable;
00821     tyscraptype scraptype;
00822     Handle hscrap;
00823     boolean flselectname = false;
00824     
00825     if (opeditsetglobals ()) {
00826         
00827         if (iseditscrap ())
00828             return (opeditpaste ());
00829         
00830         if (!tableexiteditmode ())
00831             return (false);
00832         }
00833     
00834     if (!shellgetscrap (&hscrap, &scraptype)) /*try to get the scrap, ignoring type*/
00835         return (false);
00836     
00837     if (!tablegetcursorinfo (&htable, bsname, nil, nil))
00838         return (false);
00839     
00840     setemptystring (bsname);
00841     
00842     switch (scraptype) {
00843         
00844         case hashscraptype:
00845             if (!tablegetscrapvalue (hscrap, &val, &horigtable, bsname))
00846                 return (false);
00847             
00848             if (horigtable == htable) { /*value was copied from here*/
00849                 
00850                 pushhashtable (htable);
00851                 
00852                 tablemakeuniquename (bsname, &flselectname);
00853                 
00854                 pophashtable ();
00855                 }
00856             
00857             break;
00858         
00859         case opscraptype:
00860             if (!langexternalnewvalue (idoutlineprocessor, hscrap, &val))
00861                 return (false);
00862             
00863             break;
00864         
00865         case scriptscraptype:
00866             if (!langexternalnewvalue (idscriptprocessor, hscrap, &val))
00867                 return (false);
00868             
00869             break;
00870         
00871         case menuscraptype:
00872             if (!langexternalnewvalue (idmenuprocessor, hscrap, &val))
00873                 return (false);
00874             
00875             break;
00876         
00877         case wpscraptype:
00878             if (!langexternalnewvalue (idwordprocessor, hscrap, &val))
00879                 return (false);
00880             
00881             break;
00882         
00883         case textscraptype: {
00884             Handle x;
00885             
00886             if (!copyhandle (hscrap, &x))
00887                 return (false);
00888             
00889             if (!setheapvalue (x, stringvaluetype, &val))
00890                 return (false);
00891             
00892             exemptfromtmpstack (&val);
00893             
00894             tablegetstringlist (pastedtextstring, bsname);
00895             
00896             flselectname = true;
00897             
00898             break;
00899             }
00900         
00901         case pictscraptype:
00902             if (!langexternalnewvalue (idpictprocessor, hscrap, &val))
00903                 return (false);
00904             
00905             break;
00906         
00907         default:
00908             if (!pastetobinary (hscrap, scraptype, &val))
00909                 return (false);
00910             
00911             break;
00912         }
00913     
00914     if (isemptystring (bsname)) {
00915         bigstring bspasted;
00916         
00917         hashgettypestring (val, bsname);
00918         
00919         tablegetstringlist (pastedstring, bspasted);
00920         
00921         insertstring (bspasted, bsname);
00922         
00923         flselectname = true;
00924         }
00925     
00926     return (tablepastevalue (htable, bsname, val, flselectname));
00927     } /*tablepasteroutine*/
00928 
00929 #endif
00930 
00931 boolean tabledroppasteroutine (void) {
00932     
00933     /*
00934     6/13/91 dmb: created this routine for pasthing into the main window
00935     
00936     pastes HASH scraps only, in their original database location
00937     
00938     12/5/91 dmb: fixed path construction on paste of new item into existing table
00939     */
00940     
00941     tyvaluerecord val;
00942     bigstring bstable, bsname;
00943     hdlhashtable htable;
00944     tyscraptype scraptype;
00945     Handle hscrap;
00946     bigstring bsprompt;
00947     
00948     if (!shellgetscrap (&hscrap, &scraptype))
00949         return (false);
00950     
00951     if (scraptype != hashscraptype) {
00952         
00953         alertstring (cantpasteherestring);
00954         
00955         return (false);
00956         }
00957     
00958     if (!tablegetscrapvalue (hscrap, &val, &htable, bsname))
00959         return (false);
00960     
00961     langexternalbracketname (bsname);
00962     
00963     insertchar ('.', bsname);
00964     
00965     if (htable == nil) {
00966         
00967         insertstring (nameroottable, bsname);
00968         }
00969     else {
00970         
00971         langexternalgetquotedpath (htable, zerostring, bstable);
00972         
00973         insertstring (bstable, bsname);
00974         }
00975     
00976     tablegetstringlist (pasteasstring, bsprompt);
00977     
00978     if (askdialog (bsprompt, bsname)) {
00979         
00980         if (tableexpandtodotparams (bsname, &htable, bsname))
00981             return (tablepastevalue (htable, bsname, val, false));
00982         }
00983     
00984     disposevaluerecord (val, false);
00985     
00986     return (false);
00987     } /*tabledroppasteroutine*/
00988 
00989 
00990 

Generated on Wed May 31 18:20:03 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6