Download presentation
Presentation is loading. Please wait.
Published byPierce McGee Modified over 9 years ago
1
Word Processing
2
Word Processing and the WWW Differences –WWW is dynamic Variable window size Possibly non-graphical devices Leave decisions to the browser Simple implementation when building many browsers –Word processing is static Fixed page size Exact layout Target is always paper
3
Word Processing and the WWW Similarities –Text is still text –Basic styling of headers, bold, italic, tables These are inherent in how people communicate with text –Similar underlying algorithms and structures
4
Microsoft Word StyleFontSize Bold, Italic Underline
5
Microsoft Word JustificationListsIndentation Colors Virtually every word processor has these same features
6
Word and HTML
8
<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"> This is some new text Dan R. Olsen Jr. This is some new text Word and HTML
9
HTML in Word Word doesn’t like JavaScript very much
10
HTML –This is some text Word –Use special characters beyond 128 instead of tags Encodings Bold
11
Translating Encodings Word encodes many more kinds of style information than HTML –Paragraph indentation –Superscript and subscript –Embedded EXCEL tables Saving as HTML –Re code similar features (bold, underline) –Simulate the Word feature using HTML features –Throw away the Word feature
12
Translating Encodings MS Word -> WordPerfect WordPerfect -> HTML HTML-> MS Word Each step may modify or discard some features The end result will rarely be the same
13
Algorithms for Basic Word Processing Type a character Delete a character Select some characters Bold some characters Cut / Copy / Paste
14
Cursor Position an index into the string Cursor = 3 Cursor=6
15
Typing a Character Cursor=4 Cursor = 3 Key = ‘p’
16
Typing a Character Cursor = 3 Key = ‘p’ For ( index I starting at Text.length-1 down to Cursor) {Text[I+1]=Text[I] } Text[Cursor] = Key; Cursor = Cursor+1;
17
Typing a Character Cursor = 3 Key = ‘p’ I=8 For ( index I starting at Text.length-1 down to Cursor) {Text[I+1]=Text[I] } move character up one space Text[Cursor] = Key; Cursor = Cursor+1;
18
Typing a Character Cursor = 3 Key = ‘p’ I=7 For ( index I starting at Text.length-1 down to Cursor) {Text[I+1]=Text[I] } move character up one space Text[Cursor] = Key; Cursor = Cursor+1;
19
Typing a Character Cursor = 3 Key = ‘p’ I=6 For ( index I starting at Text.length-1 down to Cursor) {Text[I+1]=Text[I] } move character up one space Text[Cursor] = Key; Cursor = Cursor+1;
20
Typing a Character Cursor = 3 Key = ‘p’ I=5 For ( index I starting at Text.length-1 down to Cursor) {Text[I+1]=Text[I] } move character up one space Text[Cursor] = Key; Cursor = Cursor+1;
21
Typing a Character Cursor = 3 Key = ‘p’ I=4 For ( index I starting at Text.length-1 down to Cursor) {Text[I+1]=Text[I] } move character up one space Text[Cursor] = Key; Cursor = Cursor+1;
22
Typing a Character Cursor = 3 Key = ‘p’ I=3 For ( index I starting at Text.length-1 down to Cursor) {Text[I+1]=Text[I] } Text[Cursor] = Key; add the typed character Cursor = Cursor+1;
23
Typing a Character Cursor = 4 Key = ‘p’ I=3 For ( index I starting at Text.length-1 down to Cursor) {Text[I+1]=Text[I] } Text[Cursor] = Key; Cursor = Cursor+1; move the cursor over
24
Algorithms for Basic Word Processing Type a character Delete a character Select some characters Bold some characters Cut / Copy / Paste
25
Delete a Character Cursor = 4 Key = delete I=? For ( index I starting at Cursor+1 up to Text.length-1) {Text[I-1]=Text[I] } move a character down one space Cursor = Cursor-1; Text[Text.length-1] = “no character”
26
Delete a Character Cursor = 4 Key = delete I=3 For ( index I starting at Cursor+1 up to Text.length-1) {Text[I-1]=Text[I] } move a character down one space Cursor = Cursor-1; Text[Text.length-1] = “no character”
27
Delete a Character Cursor = 4 Key = delete I=4 For ( index I starting at Cursor+1 up to Text.length-1) {Text[I-1]=Text[I] } move a character down one space Cursor = Cursor-1; Text[Text.length-1] = “no character”
28
Delete a Character Cursor = 4 Key = delete I=5 For ( index I starting at Cursor+1 up to Text.length-1) {Text[I-1]=Text[I] } move a character down one space Cursor = Cursor-1; Text[Text.length-1] = “no character”
29
Delete a Character Cursor = 4 Key = delete I=6 For ( index I starting at Cursor+1 up to Text.length-1) {Text[I-1]=Text[I] } move a character down one space Cursor = Cursor-1; Text[Text.length-1] = “no character”
30
Delete a Character Cursor = 4 Key = delete I=7 For ( index I starting at Cursor+1 up to Text.length-1) {Text[I-1]=Text[I] } move a character down one space Cursor = Cursor-1; Text[Text.length-1] = “no character”
31
Delete a Character Cursor = 3 Key = delete I=8 For ( index I starting at Cursor+1 up to Text.length-1) {Text[I-1]=Text[I] } Cursor = Cursor-1;move the cursor over Text[Text.length-1] = “no character”
32
Delete a Character Cursor = 3 Key = delete I=8 For ( index I starting at Cursor+1 up to Text.length-1) {Text[I-1]=Text[I] } Cursor = Cursor-1; Text[Text.length-1] = “no character”; blank out last character
33
A Helpful Function Function moveChars(Text,Start,End,Distance) {if (Distance>0) {for (index I from End down to Start ) { Text[I+Distance]=Text[I];} } Else {for (index I from Start up to End ) { Text[I+Distance]=Text[I] } }
34
Typing a Character Cursor = 3 Key = ‘p’ moveChars(text,Cursor,text.length-1, 1); Text[Cursor]=Key; Cursor=Cursor+1;
35
Delete a Character Cursor = 4 Key = delete I=? moveChars(text,cursor,text.length-1,-1); Cursor=Cursor-1; text[text.length -1]=no character;
36
Algorithms for Basic Word Processing Type a character Delete a character Select some characters Bold some characters Cut / Copy / Paste
37
Selecting Characters Start = 2 End = 7
38
Algorithms for Basic Word Processing Type a character Delete a character Select some characters Bold some characters Cut / Copy / Paste
39
Bolding Characters Start = 2 End = 7 moveChars(text,End,text.length-1,2); moveChars(text,Start,End-1,1); Text[Start]=code for start bold; Text[End+1]=code for end bold; End=End+2;
40
Bolding Characters Start = 2 End = 7 moveChars(text,End,text.length-1,2); -> moveChars(text,7,7,2) moveChars(text,Start,End-1,1); Text[Start]=code for start bold; Text[End+1]=code for end bold; End=End+2;
41
Bolding Characters Start = 2 End = 7 moveChars(text,End,text.length-1,2); moveChars(text,Start,End-1,1); -> moveChars(text,2,6,1) Text[Start]=code for start bold; Text[End+1]=code for end bold; End=End+2;
42
Bolding Characters Start = 2 End = 7 moveChars(text,End,text.length-1,2); moveChars(text,Start,End-1,1); Text[Start]=code for start bold; Text[End+1]=code for end bold; End=End+2;
43
Bolding Characters Start = 2 End = 7 moveChars(text,End,text.length-1,2); moveChars(text,Start,End-1,1); Text[Start]=code for start bold; Text[End+1]=code for end bold; End=End+2;
44
Bolding Characters Start = 2 End = 9 moveChars(text,End,text.length-1,2); moveChars(text,Start,End-1,1); Text[Start]=code for start bold; Text[End+1]=code for end bold; End=End+2;
45
Algorithms for Basic Word Processing Type a character Delete a character Select some characters Bold some characters Cut / Copy / Paste
46
Cut Start = 2 End = 7 ClipBoard= For (each character C with index >= Start and < End) { copy C to the ClipBoard } moveChars(text,End,text.length-1,Start-End); Set the last (End-Start) characters in the array to “no character” End=Start;
47
Cut Start = 2 End = 7 ClipBoard=“strin” For (each character C with index >= Start and < End) { copy C to the ClipBoard } moveChars(text,End,text.length-1,Start-End); Set the last (End-Start) characters in the array to “no character” End=Start;
48
Cut Start = 2 End = 7 ClipBoard =“strin” For (each character C with index >= Start and < End) { copy C to the ClipBoard } moveChars(text,End,text.length-1,Start-End); Set the last (End-Start) characters in the array to “no character” End=Start;
49
Cut Start = 2 End = 7 ClipBoard =“strin” For (each character C with index >= Start and < End) { copy C to the ClipBoard } moveChars(text,End,text.length-1,Start-End); Set the last (End-Start) characters in the array to “no character” End=Start;
50
Cut Start = 2 End = 2 ClipBoard =“strin” For (each character C with index >= Start and < End) { copy C to the ClipBoard } moveChars(text,End,text.length-1,Start-End); Set the last (End-Start) characters in the array to “no character” End=Start;
51
Copy Start = 2 End = 7 ClipBoard =“strin” For (each character C with index >= Start and < End) { copy C to the ClipBoard }
52
Paste Start = 2 End = 2 ClipBoard =“strin” moveChars(text,End,text.length-1, ClipBoard.length); Copy the characters from ClipBoard into the array at index Start
53
Paste Start = 2 End = 2 ClipBoard =“strin” moveChars(text,End,text.length-1, ClipBoard.length); Copy the characters from ClipBoard into the array at index Start
54
Paste Start = 2 End = 2 ClipBoard =“strin” moveChars(text,End,text.length-1, ClipBoard.length); Copy the characters from ClipBoard into the array at index Start
55
Review Other encodings besides Translating between encodings can modify or lose information Text is just an array –Typing a character - move characters right –Deleting a character - move characters left –Selecting - Start and End are array indices –Cut - copy to clip board and move characters left –Copy - copy to clip board –Paste - move characters right and copy from clip board
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.