Word Processing
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
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
Microsoft Word StyleFontSize Bold, Italic Underline
Microsoft Word JustificationListsIndentation Colors Virtually every word processor has these same features
Word and HTML
<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns=" This is some new text Dan R. Olsen Jr. This is some new text Word and HTML
HTML in Word Word doesn’t like JavaScript very much
HTML –This is some text Word –Use special characters beyond 128 instead of tags Encodings Bold
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
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
Algorithms for Basic Word Processing Type a character Delete a character Select some characters Bold some characters Cut / Copy / Paste
Cursor Position an index into the string Cursor = 3 Cursor=6
Typing a Character Cursor=4 Cursor = 3 Key = ‘p’
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;
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;
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;
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;
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;
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;
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;
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
Algorithms for Basic Word Processing Type a character Delete a character Select some characters Bold some characters Cut / Copy / Paste
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”
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”
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”
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”
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”
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”
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”
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
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] } }
Typing a Character Cursor = 3 Key = ‘p’ moveChars(text,Cursor,text.length-1, 1); Text[Cursor]=Key; Cursor=Cursor+1;
Delete a Character Cursor = 4 Key = delete I=? moveChars(text,cursor,text.length-1,-1); Cursor=Cursor-1; text[text.length -1]=no character;
Algorithms for Basic Word Processing Type a character Delete a character Select some characters Bold some characters Cut / Copy / Paste
Selecting Characters Start = 2 End = 7
Algorithms for Basic Word Processing Type a character Delete a character Select some characters Bold some characters Cut / Copy / Paste
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;
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;
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;
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;
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;
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;
Algorithms for Basic Word Processing Type a character Delete a character Select some characters Bold some characters Cut / Copy / Paste
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;
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;
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;
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;
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;
Copy Start = 2 End = 7 ClipBoard =“strin” For (each character C with index >= Start and < End) { copy C to the ClipBoard }
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
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
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
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