Title Banner

Previous Book Contents Book Index Next

Newton Developer Technical Information: Newton Programmer's Guide: 2.1 OS Addendum /
Chapter 3 - Word Processing Views / Using Word Processing Views


Storing Documents In a Soup

After the user has finished modifying a word-processing document, you need to save it in your soup. The TXWord program does this at view closing time, in its implementation of the ViewQuitScript method, which is shown in Listing 3-8.

Listing 3-8 Closing the word-processing view

ViewQuitScript:

func() begin :SetSoupData(); inherited:?ViewQuitScript(); end

The TXWord implementation of the ViewQuitScript method calls the editor:SetSoupData method to store the modified data and then calls the inherited ViewQuitScript method. The editor:SetSoupData method is shown in Listing 3-9.

Listing 3-9 Storing a word-processing document

editor:SetSoupData:

func() begin // only save if something changed if not :IsModified() then return; local externalData := self:Externalize(); // change existing soup entry if there is one if theSoupEntry then begin theSoupEntry.EditorData := externalData; EntryChangeXmit(theSoupEntry, nil); end; else begin local soup := GetUnionSoupAlways(kSoupName); if soup then theSoupEntry := soup:AddToDefaultStoreXmit( {EditorData: externalData}, nil); else begin soup := GetDefaultStore():CreateSoup(kSoupName, []); theSoupEntry := soup:AddXmit( {EditorData: externalData}, nil); end; end; end

The editor:SetSoupData method first determines if the view has been modified by the user by calling the *protoTXView:*IsModified method. If not, SetSoupData simply returns, rather than spending time saving unchanged data.

If the view has been modified, SetSoupData calls the *protoTXView:*Externalize method to convert the word-processing data in the view into a format that can be stored in your soup. SetSoupData then updates the soup as follows:


Previous Book Contents Book Index Next

© Apple Computer, Inc.
26 APR 1997



Navigation graphic, see text links

Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help