-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathRoomerHtmlEditor.pas
5854 lines (5084 loc) · 201 KB
/
RoomerHtmlEditor.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{ Open source project MSHTML Editor 16-04-2012 ver. 4.1 for ocx ver. 2.0 and above
This editor is build from a DHTML edit OSP from 16-05-1999 found at:
http://groups.yahoo.com/group/delphi-dhtmledit/files/DHTMLEdit/DHTML.zip
(look in the file section)
This update editor is created by Kurt Senfer
"Copyright (C) 2002-2012 Kurt Senfer <[email protected]>"
The code in this package is released under:
GNU Lesser General Public License - http://www.gnu.org/licenses/lgpl-2.1.html
Except fore the original source as it is implemented in the original OSP,
witch have the same copyright status as found in the original package DHTML.zip.
I have often, in various mails on the delphi-dhtmledit list, pointed out that
The DHTMLEdit component is just a wrapper around the MSHTML engine - the
Wrapper contains coding that enables additional features like:
Table operations (insert row, insert column, merge cells, and so on).
Absolute drop mode.
Source code white space and formatting preservation.
Custom Editing Glyphs.
........
Replacing DHTMLEdit with the MSHTML engine (or as in this case with the
KSDhtmlEdit.OCX component) means that you need to code a few features, like
source code preservation, witch is build in features in DHTMLEdit, yourself.
I chased to create a wrapper around MSHTML and named it:
TEmbeddedED ~ Embedded EDitor
TEmbeddedED implements all the code you need to replace the DHTML Component
(exept for a few seldom needed features) and it offers a lot of features never
found in DHTML Edit. The main reason for encapsulating all that code in a
component is that its easy to update existing editor projects with
new features (in new versions of KSDhtmlEdit).
This is a short listing of the main things you have to do in order to skip
DHTMLEdit in favour of the HMHTML engine in your own DHTMLEdit project.
- Replace TDHTMLEdit with MSHTML
- Call the existing DHTMLEditDisplayChanged from a new "OnUpdateUI function"
- Implement Custom Editing Glyphs
- Implement IHTMLEditDesigner
- Implement IHTMLEditHost
- Implemet code to handle the table stuff
- Implemet code to handle the position stuff
}
unit RoomerHtmlEditor;
{$I KSED.INC} //Compiler version directives
{.$DEFINE AddictSpell}
{$DEFINE NoBOMShow}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, OleCtrls,
StdCtrls, Buttons, ComCtrls, Menus, ExtCtrls, FmxUtils, ImgList,
ToolWin, ActiveX, Db, DbTables,
{$IFDEF AddictSpell}
//if you get a compiler error heir out-comment / remove {$DEFINE AddictSpell} above
ad3Spell, ad3Configuration,
{$ENDIF}
{$IFDEF Mshtml_TLB}
// this compiler directive is out commented {.$DEFINE Mshtml_TLB} in KSED.inc
// if you want to compile with Mshtml_TLB instead of MSHTML then remove the
// dot in front of {.$DEFINE Mshtml_TLB}
MSHTML_TLB,
{$ELSE}
MSHTML,
{$IFDEF OldMSHTML}
KS_Missing_In_MSHTML,
{$ENDIF}
{$ENDIF}
{$IFDEF KSDHTMLEDLib_TLB}
// this compiler directive is out commented {.$DEFINE KSDHTMLEDLib_TLB} in KSED.inc
// if you want to compile with KSDHTMLEDLib_TLB instead of KSDHTMLED_TLB then
// remove the dot in front of {.$DEFINE KSDHTMLEDLib_TLB}
// But only if you are sure what you are doing !!
KSDHTMLEDLib_TLB,
{$ELSE}
KSDHTMLED_TLB,
{$ENDIF}
KS_Procs,
{$IFNDEF D2009UP}
KS_RichEdit,
{$ENDIF}
KSEmbeddedEDx, acCoolBar, sToolBar, cxClasses, cxPropertiesStore;
type
CmdID = TOleEnum;
TGetInputArg = procedure(Sender: TObject; var pVarIn: OleVariant; var FuncResult: boolean) of object;
TClearInputArg = procedure(Sender: TObject; var pVarIn: OleVariant) of object;
TfrmOcxHtmlEditor = class(TForm)
Panel1: TPanel;
StatusBar1: TStatusBar;
MainMenu1: TMainMenu;
mnuFile: TMenuItem;
mnuFileNew: TMenuItem;
mnuFileOpen: TMenuItem;
mnuFileSave: TMenuItem;
mnuFileSaveAs: TMenuItem;
N2: TMenuItem;
mnuFilePrint: TMenuItem;
mnuFilePageSetup: TMenuItem;
N1: TMenuItem;
mnuFileExit: TMenuItem;
mnuInsert: TMenuItem;
mnuTableInsertTable: TMenuItem;
mnuInsertImage: TMenuItem;
PopupMenu1: TPopupMenu;
mnuEdit: TMenuItem;
mnuEditDelete: TMenuItem;
mnuEditCut: TMenuItem;
mnuEditCopy: TMenuItem;
mnuEditPaste: TMenuItem;
mnuInsertHyperlink: TMenuItem;
N3: TMenuItem;
mnuEditUndo: TMenuItem;
mnuEditRedo: TMenuItem;
N4: TMenuItem;
mnuEditSelectAll: TMenuItem;
N5: TMenuItem;
mnuEditUnlink: TMenuItem;
mnuTable: TMenuItem;
mnuTableInsertRow: TMenuItem;
mnuTableInsertCol: TMenuItem;
mnuTableInsetCell: TMenuItem;
mnuTableDeleteRow: TMenuItem;
mnuTableDeleteCol: TMenuItem;
mnuTableDeleteCell: TMenuItem;
N6: TMenuItem;
mnuTableMergeCells: TMenuItem;
mnuTableSplitCells: TMenuItem;
ColorDialog: TColorDialog;
mnuPosition: TMenuItem;
mnuPositionAboveText: TMenuItem;
mnuPositionBringForward: TMenuItem;
mnuPositionBringtoFront: TMenuItem;
mnuPositionBelowText: TMenuItem;
mnuPositionSendtoBack: TMenuItem;
mnuPositionSendBackward: TMenuItem;
N7: TMenuItem;
pmuUndo: TMenuItem;
pmuRedo: TMenuItem;
pmuCopy: TMenuItem;
pmuPaste: TMenuItem;
pmuCut: TMenuItem;
pmuDelete: TMenuItem;
pmuSelectAll: TMenuItem;
pmuUnlink: TMenuItem;
pmuHyperlink: TMenuItem;
mnuPositionMakeAbsolute: TMenuItem;
N8: TMenuItem;
mnuFileProperties: TMenuItem;
mnuHelpAbout: TMenuItem;
N9: TMenuItem;
mnuInsertHTML: TMenuItem;
mnuPositionGridSettings: TMenuItem;
PageControl1: TPageControl;
tabEdit: TTabSheet;
tabHTML: TTabSheet;
tabPreview: TTabSheet;
mnuEditRemoveTags: TMenuItem;
mmoHTML: TMemo;
CoolBar: TsCoolBar;
tlb_Edit: TToolBar;
btnNew: TToolButton;
btnOpen: TToolButton;
btnSave: TToolButton;
ToolButton10: TToolButton;
btnPrint: TToolButton;
ToolButton9: TToolButton;
btnCut: TToolButton;
btnCopy: TToolButton;
btnPaste: TToolButton;
ToolButton1: TToolButton;
btnUndo: TToolButton;
btnRedo: TToolButton;
tlb_Format: TToolBar;
cmbStyles: TComboBox;
ToolButton2: TToolButton;
cmbFontName: TComboBox;
ToolButton4: TToolButton;
cmbFontSize: TComboBox;
ToolButton6: TToolButton;
btnFGColor: TToolButton;
btnBGColor: TToolButton;
ToolButton3: TToolButton;
btnBold: TToolButton;
btnItalic: TToolButton;
btnUnderline: TToolButton;
ToolButton7: TToolButton;
btnAlignLeft: TToolButton;
btnAlignCenter: TToolButton;
btnAlignRight: TToolButton;
ToolButton12: TToolButton;
btnNumberedList: TToolButton;
btnBulletedList: TToolButton;
ToolButton15: TToolButton;
btnIndentLeft: TToolButton;
btnIndentRight: TToolButton;
ImageList1: TImageList;
ImageList2: TImageList;
ToolButton11: TToolButton;
btnInsertTable: TToolButton;
ToolButton5: TToolButton;
btnInsertLink: TToolButton;
ToolButton14: TToolButton;
btnInsertImage: TToolButton;
ToolButton17: TToolButton;
btnFind: TToolButton;
mnuHelp: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
mnuEditFind: TMenuItem;
ToolButton8: TToolButton;
btnMakeAbsolute: TToolButton;
btnPrevInBrowser: TToolButton;
ToolButton13: TToolButton;
ImageList3: TImageList;
ToolBar1: TToolBar;
ToolBar2: TToolBar;
tlb_Table: TToolBar;
btnTableDelCol: TToolButton;
btnTableInsCol: TToolButton;
btnTableInsRow: TToolButton;
btnTableDelRow: TToolButton;
btnTableDelCell: TToolButton;
btnTableInsCell: TToolButton;
ToolButton23: TToolButton;
ToolButton24: TToolButton;
ToolButton25: TToolButton;
btnTableInTable: TToolButton;
btnTableMergeCells: TToolButton;
ToolButton28: TToolButton;
btnTableTableSplitCells: TToolButton;
mnuView: TMenuItem;
mnuToolbar: TMenuItem;
mnuViewtbl_Table: TMenuItem;
mnuViewtbl_Edit: TMenuItem;
mnuViewtbl_Format: TMenuItem;
btnShowDetails: TToolButton;
btnBorders: TToolButton;
btnClearUndoStack: TToolButton;
mnuPrintpreview: TMenuItem;
PrintDialog1: TPrintDialog;
btnFont: TToolButton;
mnuLockElement: TMenuItem;
N10: TMenuItem;
mnuConstrainElement: TMenuItem;
N15: TMenuItem;
Edit: TKSEditX;
N16: TMenuItem;
mnuFormattablegrid: TMenuItem;
btnEdit: TToolButton;
N17: TMenuItem;
mnuRefresh: TMenuItem;
Testing1: TMenuItem;
Assign1: TMenuItem;
Gotowww1: TMenuItem;
gotofile1: TMenuItem;
SetBaseURLbad1: TMenuItem;
SetBaseURLOK1: TMenuItem;
KSTestEdit1: TToolButton;
KSTestPreview: TToolButton;
KSTestEdit2: TToolButton;
Navigate1: TMenuItem;
mnuOCXversion: TMenuItem;
mnuUpdateUI: TMenuItem;
mnuDrawsquare: TMenuItem;
Printwithtemplate1: TMenuItem;
mnuClassicsel: TMenuItem;
tabFly: TTabSheet;
Panel2: TPanel;
CreateFly: TButton;
LoadFile: TButton;
InsImage: TButton;
DestroyFly: TButton;
ToolBar3: TsToolBar;
ToUndo: TToolButton;
ToolButton18: TToolButton;
ToRedo: TToolButton;
Preview: TKSEditX;
Button1: TButton;
mnuLinkto: TMenuItem;
N18: TMenuItem;
mnuKsxloadfromfile: TMenuItem;
mnuKsxloadfromDB: TMenuItem;
mnuhttpstreamingON: TMenuItem;
mnuhttpstreamingOFF: TMenuItem;
ksxinsertpicture1: TMenuItem;
mnuSaveDocToDb: TMenuItem;
N19: TMenuItem;
mnuGetcaretposition: TMenuItem;
mnuRestorecaretposition: TMenuItem;
mnuDontdragme: TMenuItem;
N21: TMenuItem;
mnuLookforPleasedragme: TMenuItem;
mnuLoadstreamtoDOC: TMenuItem;
mnuSpelling: TMenuItem;
mnuSpellSelect: TMenuItem;
mnuSpellCur: TMenuItem;
mnuSpellDoc: TMenuItem;
mnuSpellOption: TMenuItem;
mnuChecklive: TMenuItem;
mnuLivecheckArea: TMenuItem;
mnuGeCelltlist: TMenuItem;
N22: TMenuItem;
mnuTableSelCell: TMenuItem;
mnuTableSelRow: TMenuItem;
mnuTableSelColumn: TMenuItem;
mnuTableSelTable: TMenuItem;
mnuIscellselected: TMenuItem;
mnuHighlightcells: TMenuItem;
Create100: TButton;
TabUniHTML: TTabSheet;
Pagesetup1: TMenuItem;
mnuLoadURL: TMenuItem;
mnuPastepathsabsolute: TMenuItem;
TabSheet1: TTabSheet;
Panel3: TPanel;
Button2: TButton;
TreeView1: TTreeView;
mnuRawHtml: TMenuItem;
filestreamingON: TMenuItem;
filestreamingOFF: TMenuItem;
N23: TMenuItem;
DefaultfiledropON: TMenuItem;
DefaultfiledropOFF: TMenuItem;
Label1: TLabel;
Label2: TLabel;
Button3: TButton;
WatchElementDeletion1: TMenuItem;
N24: TMenuItem;
StopWatching1: TMenuItem;
Stopwatchingallelements1: TMenuItem;
ToolButton16: TToolButton;
btnShowAnchors: TToolButton;
mnuTatablecells: TMenuItem;
InsBookM: TMenuItem;
EditBookM: TMenuItem;
N25: TMenuItem;
EditHTML: TMenuItem;
N26: TMenuItem;
mnuEditHTML: TMenuItem;
mnuSpellDlgModal: TMenuItem;
N27: TMenuItem;
N28: TMenuItem;
mnuEdittableproperties: TMenuItem;
mnuEditCellproperties: TMenuItem;
N29: TMenuItem;
Format1: TMenuItem;
Bullets1: TMenuItem;
Font1: TMenuItem;
Borders1: TMenuItem;
Nudgeelement1: TMenuItem;
Bookmark1: TMenuItem;
HorizontalRule1: TMenuItem;
mnuRevisions: TMenuItem;
mnuShowmarkedRevisions: TMenuItem;
mnuMarkselectionasRevisions: TMenuItem;
mnuClearselectedrvisionmarking: TMenuItem;
Clearallrevisionmarkings1: TMenuItem;
btnShowPagebrk: TToolButton;
btnInsertPagebrk: TToolButton;
btnRemovePagebrk: TToolButton;
ToolButton22: TToolButton;
Aboutnewfeatures1: TMenuItem;
mnuAboutNewfeatures: TMenuItem;
Testbookmarks1: TMenuItem;
Watchforaccidentlydeletion1: TMenuItem;
Managerevisionsmarking1: TMenuItem;
Managepagebreaks1: TMenuItem;
Changelanguage1: TMenuItem;
Download1: TMenuItem;
N30: TMenuItem;
SetdocumenttoUnichar1: TMenuItem;
Setdocumenttoutf81: TMenuItem;
btnSaveToRoomer: TToolButton;
ToolButton20: TToolButton;
S1: TMenuItem;
N31: TMenuItem;
FormStore: TcxPropertiesStore;
procedure EditDisplayChanged(Sender: TObject);
procedure btnBoldClick(Sender: TObject);
procedure btnOpenClick(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
procedure btnInsertImageClick(Sender: TObject);
procedure btnItalicClick(Sender: TObject);
procedure btnUnderlineClick(Sender: TObject);
procedure btnFindClick(Sender: TObject);
procedure cmbFontNameChange(Sender: TObject);
procedure cmbFontSizeChange(Sender: TObject);
procedure cmbStylesChange(Sender: TObject);
procedure mnuFileExitClick(Sender: TObject);
procedure btnInsertTableClick(Sender: TObject);
procedure mnuEditDeleteClick(Sender: TObject);
procedure mnuEditCutClick(Sender: TObject);
procedure mnuEditCopyClick(Sender: TObject);
procedure mnuEditPasteClick(Sender: TObject);
procedure btnInsertLinkClick(Sender: TObject);
procedure btnAlignCenterClick(Sender: TObject);
procedure btnAlignLeftClick(Sender: TObject);
procedure btnAlignRightClick(Sender: TObject);
procedure mnuEditRedoClick(Sender: TObject);
procedure mnuEditUndoClick(Sender: TObject);
procedure mnuEditSelectAllClick(Sender: TObject);
procedure mnuEditUnlinkClick(Sender: TObject);
procedure mnuTableInsertRowClick(Sender: TObject);
procedure mnuTableInsertColClick(Sender: TObject);
procedure mnuTableInsetCellClick(Sender: TObject);
procedure mnuTableDeleteRowClick(Sender: TObject);
procedure mnuTableDeleteColClick(Sender: TObject);
procedure mnuTableDeleteCellClick(Sender: TObject);
procedure btnFGColorClick(Sender: TObject);
procedure mnuTableMergeCellsClick(Sender: TObject);
procedure mnuTableSplitCellsClick(Sender: TObject);
procedure btnIndentRightClick(Sender: TObject);
procedure btnIndentLeftClick(Sender: TObject);
procedure btnBulletedListClick(Sender: TObject);
procedure btnNumberedListClick(Sender: TObject);
procedure mnuPositionAboveTextClick(Sender: TObject);
procedure mnuPositionBringForwardClick(Sender: TObject);
procedure mnuPositionBringtoFrontClick(Sender: TObject);
procedure mnuPositionBelowTextClick(Sender: TObject);
procedure mnuPositionSendtoBackClick(Sender: TObject);
procedure mnuPositionSendBackwardClick(Sender: TObject);
procedure btnBGColorClick(Sender: TObject);
procedure mnuPositionMakeAbsoluteClick(Sender: TObject);
procedure mnuFilePropertiesClick(Sender: TObject);
procedure btnPrintClick(Sender: TObject);
procedure mnuHelpAboutClick(Sender: TObject);
procedure mnuInsertHTMLClick(Sender: TObject);
procedure btnNewClick(Sender: TObject);
procedure mnuPositionGridSettingsClick(Sender: TObject);
procedure mnuFileSaveAsClick(Sender: TObject);
procedure mnuEditRemoveTagsClick(Sender: TObject);
procedure PageControl1Changing(Sender: TObject; var AllowChange: Boolean);
procedure btnPrevInBrowserClick(Sender: TObject);
procedure mmoHTMLChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure mnuViewtbl_TableClick(Sender: TObject);
procedure mnuViewtbl_FormatClick(Sender: TObject);
procedure mnuViewtbl_EditClick(Sender: TObject);
procedure EditDocumentComplete(Sender: TObject);
procedure btnShowDetailsClick(Sender: TObject);
procedure PageControl1Change(Sender: TObject);
function EditQueryService(const rsid, iid: TGUID; out Obj: IUnknown): HRESULT;
procedure btnBordersClick(Sender: TObject);
procedure btnClearUndoStackClick(Sender: TObject);
procedure tlb_FormatMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure cmbDropDown(Sender: TObject);
procedure btnJustifyClick(Sender: TObject);
procedure btnFontClick(Sender: TObject);
procedure mnuEditClick(Sender: TObject);
procedure mnuTableClick(Sender: TObject);
procedure mnuPositionClick(Sender: TObject);
procedure mnuLockElementClick(Sender: TObject);
procedure mnuConstrainElementClick(Sender: TObject);
procedure cmbFontSizeDropDown(Sender: TObject);
procedure EditShowContextMenu(Sender: TObject; xPos, yPos: Integer);
procedure EditPostEditorEventNotify(Sender: TObject; pinEvtDispId: Integer; const pIEventObj: IHTMLEventObj; var aResult: HRESULT);
procedure EditPreHandleEvent(Sender: TObject; inEvtDispId: Integer; const pIEventObj: IHTMLEventObj; var aResult: HRESULT);
procedure EditInitialize(Sender: TObject; var NewFile: WideString);
procedure mnuPrintpreviewClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure mnuFormattablegridClick(Sender: TObject);
procedure btnEditClick(Sender: TObject);
procedure mnuRefreshClick(Sender: TObject);
procedure Assign1Click(Sender: TObject);
procedure Gotowww1Click(Sender: TObject);
procedure SetBaseURLbad1Click(Sender: TObject);
procedure SetBaseURLOK1Click(Sender: TObject);
procedure gotofile1Click(Sender: TObject);
procedure KSTestEdit1Click(Sender: TObject);
procedure KSTestPreviewClick(Sender: TObject);
procedure KSTestEdit2Click(Sender: TObject);
procedure Navigate1Click(Sender: TObject);
procedure EditGetDLControl(Sender: TObject; var varResult: Integer);
procedure EditGetHostInfo(Sender: TObject; var dwFlags, dwDoubleClick: Cardinal; var chHostCss, chHostNS: WideString);
procedure mnuOCXversionClick(Sender: TObject);
procedure mnuUpdateUIClick(Sender: TObject);
procedure Testing1Click(Sender: TObject);
procedure EditTranslateMessageString(Sender: TObject; var MessageString: WideString; out MessageNr: Integer);
procedure mnuDrawsquareClick(Sender: TObject);
procedure EditPostHandleEvent(Sender: TObject; inEvtDispId: Integer; const pIEventObj: IHTMLEventObj; var aResult: HRESULT);
procedure EditShortCut(Sender: TObject; out CmdID: Cardinal; var Cancel: WordBool);
procedure Printwithtemplate1Click(Sender: TObject);
procedure mnuClassicselClick(Sender: TObject);
procedure CreateFlyClick(Sender: TObject);
procedure InsImageClick(Sender: TObject);
procedure LoadFileClick(Sender: TObject);
procedure DestroyFlyClick(Sender: TObject);
procedure ToUndoClick(Sender: TObject);
procedure ToRedoClick(Sender: TObject);
procedure mnuItemClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure mnuLinktoClick(Sender: TObject);
procedure EditMessage(Sender: TObject; var msg: Cardinal; var wParam, lParam, Result: Integer);
procedure mnuKsxloadfromDBClick(Sender: TObject);
procedure mnuKsxloadfromfileClick(Sender: TObject);
procedure mnuhttpstreamingONClick(Sender: TObject);
procedure mnuhttpstreamingOFFClick(Sender: TObject);
procedure EditGetStreamData(Sender: TObject; const Url: WideString; var aStream: IUnknown; var aResult: HRESULT);
procedure ksxinsertpicture1Click(Sender: TObject);
procedure mnuGetcaretpositionClick(Sender: TObject);
procedure mnuRestorecaretpositionClick(Sender: TObject);
procedure mnuDontdragmeClick(Sender: TObject);
procedure EditDragAndPaste(Sender: TObject; EventType: Integer; const DataObject: IUnknown);
procedure mnuLookforPleasedragmeClick(Sender: TObject);
procedure mnuLoadstreamtoDOCClick(Sender: TObject);
procedure mnuSaveDocToDbClick(Sender: TObject);
procedure mnuSpellSelectClick(Sender: TObject);
procedure mnuSpellCurClick(Sender: TObject);
procedure mnuSpellDocClick(Sender: TObject);
procedure mnuSpellOptionClick(Sender: TObject);
procedure EditSpellEvent(Sender: TObject; EventType: Integer; const aWord: WideString; var InOutVar: WideString; var Result: HRESULT);
procedure mnuCheckliveClick(Sender: TObject);
procedure SpellPopClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure mnuLivecheckAreaClick(Sender: TObject);
procedure mnuGeCelltlistClick(Sender: TObject);
procedure mnuTableSelCellClick(Sender: TObject);
procedure mnuTableSelRowClick(Sender: TObject);
procedure mnuTableSelColumnClick(Sender: TObject);
procedure mnuTableSelTableClick(Sender: TObject);
procedure mnuIscellselectedClick(Sender: TObject);
procedure mnuHighlightcellsClick(Sender: TObject);
procedure Create100Click(Sender: TObject);
procedure EditGetParentWindow(Sender: TObject; var ParentHwnd: Cardinal; var Result: HRESULT);
procedure Pagesetup1Click(Sender: TObject);
procedure mnuLoadURLClick(Sender: TObject);
procedure mnuPastepathsabsoluteClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure mnuRawHtmlClick(Sender: TObject);
procedure filestreamingONClick(Sender: TObject);
procedure filestreamingOFFClick(Sender: TObject);
procedure DefaultfiledropONClick(Sender: TObject);
procedure DefaultfiledropOFFClick(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure EditWatchElementDelete(Sender: TObject; const Value: WideString);
procedure WatchElementDeletion1Click(Sender: TObject);
procedure StopWatching1Click(Sender: TObject);
procedure Stopwatchingallelements1Click(Sender: TObject);
procedure btnShowAnchorsClick(Sender: TObject);
procedure mnuTatablecellsClick(Sender: TObject);
procedure EditHTMLClick(Sender: TObject);
procedure mnuEditHTMLClick(Sender: TObject);
procedure EditBookMClick(Sender: TObject);
procedure mnuSpellDlgModalClick(Sender: TObject);
procedure mnuSpellingClick(Sender: TObject);
procedure mnuEdittablepropertiesClick(Sender: TObject);
procedure mnuEditCellpropertiesClick(Sender: TObject);
procedure Font1Click(Sender: TObject);
procedure Borders1Click(Sender: TObject);
procedure Bullets1Click(Sender: TObject);
procedure Nudgeelement1Click(Sender: TObject);
procedure HorizontalRule1Click(Sender: TObject);
procedure mnuShowmarkedRevisionsClick(Sender: TObject);
procedure mnuMarkselectionasRevisionsClick(Sender: TObject);
procedure mnuClearselectedrvisionmarkingClick(Sender: TObject);
procedure Clearallrevisionmarkings1Click(Sender: TObject);
procedure btnShowPagebrkClick(Sender: TObject);
procedure btnInsertPagebrkClick(Sender: TObject);
procedure btnRemovePagebrkClick(Sender: TObject);
procedure mnuAboutNewfeaturesClick(Sender: TObject);
procedure Testbookmarks1Click(Sender: TObject);
procedure Watchforaccidentlydeletion1Click(Sender: TObject);
procedure Managepagebreaks1Click(Sender: TObject);
procedure Managerevisionsmarking1Click(Sender: TObject);
procedure mnuRevisionsClick(Sender: TObject);
procedure Download1Click(Sender: TObject);
procedure Changelanguage1Click(Sender: TObject);
procedure CheckHint(Sender: TObject);
procedure SetUndoHint;
procedure SetRedoHint;
procedure SetdocumenttoUnichar1Click(Sender: TObject);
procedure Setdocumenttoutf81Click(Sender: TObject);
procedure btnSaveToRoomerClick(Sender: TObject);
private
UpdateUI: Boolean;
Changed: boolean;
FFocusObject: TComboBox;
PrintSetUpOK: Boolean;
// PrintTemplate: string;
// DefaultIETemplate: Boolean;
// FPrintSetup: TPrintSetup;
// DoPrintTime: Boolean;
SourceView: Boolean;
TEIgnoreChange: boolean;
_CurrentDocumentPath: string;
FCurrentStatusbarElement: IUnknown;
NoSyncInBrowseModeWarning: Boolean;
FlyEdit: TKSEditX;
FDatatype: Integer;
FSpecialHttpHandling: Boolean;
FTable: TTable;
FCaretPosElement: IHTMLElement;
FCaretPos: TPoint;
FBlockDragText: boolean;
{$IFDEF AddictSpell}
aSpellChecker: TAddictSpell3;
{$ENDIF}
LastPage: TTabSheet;
FBom: Integer; // 0 = Ansi, 1 = Utf8, 2 = Unicode
{$IFNDEF D2009UP} // from D 2009 and up mmoHTML (TMemo) is Unicode so we don't need a
// separate UniHTML (TKSRichEdit) anymore
UniHTML: TKSRichEdit;
ALabel: TLabel;
{$ENDIF}
FEditHelper: TKSEdit_X;
function DoPromtRepeated: Integer;
procedure FlyEditDisplayChanged(Sender: TObject);
procedure LookForObjects;
procedure Print(ShowDlg: boolean = True);
procedure PrintHTMLSource;
procedure UpdateButtons;
// function GetPrintLayout: TPrintSetup;
procedure mnuQueryStatus(cmdID: Cardinal; var amnu: TMenuItem);
procedure CheckEditButton;
procedure GetStyles;
function CheckResult(HR: HResult; AMessage: String; _Preview: boolean = false; FunctionCall: boolean = false): Boolean;
procedure DrawSquare(Tr: TRect; aHandle: HWND);
function ActivateTable: Boolean;
function SaveStreamToDB(aName: String; aStream: IStream): HResult;
function GetStream(aPath: String; var _Stream: IUnknown): HResult;
procedure F7Spelling;
function OpenSpellchecker: Boolean;
{$IFNDEF AddictSpell}
procedure NoSpellChecker;
{$ENDIF}
function SpellSuggestWords(const aWord: WideString; var Suggestions: WideString): HRESULT;
function SpellCheckWord(const aWord: WideString; var aCorrection: WideString): HRESULT;
function GetCurrentCell(var Ov: OleVariant): boolean;
function ModyFycase(aWord: String): String;
procedure VisualizeDOMTree(node: IHTMLDOMNode; treeNode:TTreeNode; treeNodes:TTreeNodes);
function UndoDeleteElement(TagValue: String; WatchID: Integer): Boolean;
procedure UpdatetbtnShowAnchors;
procedure UpdatebtnShowPagebrk;
public
FWatchedBookMarks: Boolean;
FWatchedComments: Boolean;
FShowAnchorGlyphe: Boolean;
FShowPagebrkGlyphe: Boolean;
RoomerFilename : String;
SaveToRoomer : Boolean;
procedure OpenFile(filename : String);
procedure SaveFile(filename : String);
end;
var
frmOcxHtmlEditor: TfrmOcxHtmlEditor;
function EditLocalHtmlFile(filename : String) : boolean;
function GetInitialDoc: string;
implementation
uses axctrls, Printers, {$IFNDEF D4D5} Variants, {$ENDIF}
ShellAPI, StdVCL, ComConst, ComObj,
PrintText, RegisterOCX, RegFuncs, ModalEdOCX, dlgx_grid, uPageProp,
{$IFDEF SHDocVw_TLB}
//if you get compile error heir: open KSED.inc and deactivate {$DEFINE SHDocVw_TLB}
SHDocVw_TLB,
{$ELSE}
SHDocVw,
{$ENDIF}
{$IFDEF AddictSpell}
AddToDictionary,
{$ENDIF}
KSIeconst, IEDispConst, insHTML, dlgx_Bookmark, dlgx_EditHTML, IniFuncs,
dlgx_TableCell, dlgx_Styles, dlgx_Bullets, dlgx_Nudge, dlgx_ALink;
{$R *.DFM}
{$IFNDEF KSEDINC}
The path to KSED.inc cant be found
Set the path to KSED.inc in Delphis "Library Path"
Or this project wont compile correctly
{$ENDIF}
function EditLocalHtmlFile(filename : String) : boolean;
var _frmOcxHtmlEditor: TfrmOcxHtmlEditor;
begin
_frmOcxHtmlEditor := TfrmOcxHtmlEditor.Create(nil);
try
_frmOcxHtmlEditor.RoomerFilename := filename;
_frmOcxHtmlEditor.SaveToRoomer := False;
if FileExists(filename) then
_frmOcxHtmlEditor.OpenFile(filename)
else
begin
_frmOcxHtmlEditor.btnNew.Click;
_frmOcxHtmlEditor.Edit.DocumentHTML := GetInitialDoc;
end;
_frmOcxHtmlEditor.ShowModal;
result := _frmOcxHtmlEditor.SaveToRoomer;
finally
FreeAndNil(_frmOcxHtmlEditor);
end;
end;
//------------------------------------------------------------------------------
function Color2HTML(Color: TColor): string;
var
Step : Integer;
Step2 : String;
begin
//asm int 3 end; //trap
Step := ColorToRGB(Color);
Step2 := IntToHex(Step, 6);
//The result will be BBGGRR but I want it RRGGBB
Result := '#' + Copy(Step2, 5, 2) + Copy(Step2, 3, 2) + Copy(Step2, 1, 2);
end;
//------------------------------------------------------------------------------
procedure TfrmOcxHtmlEditor.SetUndoHint;
begin
//asm int 3 end; //trap
if btnUndo.enabled
then btnUndo.Hint := 'Undo ' + edit.CmdGet(IDM_GetLastUndoDesc) + '|btnUndo'
else btnUndo.Hint := 'Undo' + '|btnUndo';
end;
//------------------------------------------------------------------------------
procedure TfrmOcxHtmlEditor.SetRedoHint;
begin
//asm int 3 end; //trap
if btnRedo.enabled
then btnRedo.Hint := 'Redo ' + edit.CmdGet(IDM_GetLastRedoDesc) + '|btnRedo'
else btnRedo.Hint := 'Redo' + '|btnRedo';
end;
//------------------------------------------------------------------------------
procedure TfrmOcxHtmlEditor.CheckHint(Sender: TObject);
var
S: String;
begin
//asm int 3 end; //trap
// this is called from Application.OnHint whenever a hint is about to be shown
S := GetLongHint(Application.Hint);
{ wee'l only handle hints from the Undo and Redo buttons heir.
The Undo and Redo buttons hint must be set to Short|btnUndo and Short|btnRedo
in the Object inspector (where Short can be any text) }
If S = 'btnUndo'
then SetUndoHint
else if S = 'btnRedo'
then SetRedoHint;
end;
//------------------------------------------------------------------------------
procedure TfrmOcxHtmlEditor.EditDisplayChanged(Sender: TObject);
var
Index: Integer;
S: WideString;
begin
//asm int 3 end; //trap
LookForObjects;
UpdateButtons;
//UpdateFontName
cmbFontName.ItemIndex := Edit.GetFontNameIndex(cmbFontName.Items.Text);
//UpdateFontSize
cmbFontSize.ItemIndex := Edit.GetFontSizeIndex(cmbFontSize.Text, S);
{ this is a little more complex because cmbFontSize.Items[7] can be changed to
any size found in i.e. a style }
if Length(S) > 0
then begin
Index := cmbFontSize.ItemIndex;
cmbFontSize.Items.Text := S;
cmbFontSize.ItemIndex := Index;
end;
//UpdateStylesBox
cmbStyles.ItemIndex := Edit.GetStylesIndex(cmbStyles.Items.Text);
//UpdateStatusLine(Edit.ActualElement);
end;
//------------------------------------------------------------------------------
procedure TfrmOcxHtmlEditor.UpdateButtons;
//---------------------------------------
procedure btnQueryStatus(cmdID: Cardinal; var aButon: TToolButton);
var
dwStatus : OLECMDF;
begin
//even in browse mode MSHTML will accept certain commands
//like IDM_BOLD
if Edit.BrowseMode
then dwStatus := 0
else dwStatus := Edit.QueryStatus(cmdID);
aButon.Enabled := (dwStatus and OLECMDF_ENABLED) <> 0;
aButon.Down := (dwStatus and OLECMDF_LATCHED) <> 0;
end;
//---------------------------------------
begin
//asm int 3 end; //trap
if PageControl1.ActivePage = tabEdit
then begin
btnQueryStatus(IDM_BOLD, btnBold);
btnQueryStatus(IDM_ITALIC, btnItalic);
btnQueryStatus(IDM_UNDERLINE, btnUnderline);
btnQueryStatus(IDM_CUT, btnCut);
btnQueryStatus(IDM_COPY, btnCopy);
btnQueryStatus(IDM_PASTE, btnPaste);
btnQueryStatus(IDM_INDENT, btnIndentRight);
btnQueryStatus(IDM_OUTDENT, btnIndentLeft);
btnQueryStatus(IDM_JUSTIFYLEFT, btnAlignLeft);
btnQueryStatus(IDM_JUSTIFYCENTER, btnAlignCenter);
btnQueryStatus(IDM_JUSTIFYRIGHT, btnAlignRight);
btnQueryStatus(IDM_HYPERLINK, btnInsertLink);
// doesn't work properly - if cursor is inside a link
btnQueryStatus(IDM_BACKCOLOR, btnBGColor);
btnQueryStatus(IDM_FORECOLOR, btnFGColor);
btnQueryStatus(IDM_FONT, btnFont);
if btnFont.enabled and
assigned(Edit.ActualElement) and
SameText(Edit.ActualElement.Get_tagName, 'FONT')
then btnFont.Down := true;
btnQueryStatus(IDM_ABSOLUTE_POSITION, btnMakeAbsolute);
//btnMakeAbsolute.enabled := true;
btnQueryStatus(IDM_ORDERLIST, btnNumberedList);
btnQueryStatus(IDM_UNORDERLIST, btnBulletedList);
btnQueryStatus(IDM_UNDO, btnUndo);
btnQueryStatus(IDM_REDO, btnRedo);
btnQueryStatus(IDM_SHOWZEROBORDERATDESIGNTIME, btnBorders);
btnQueryStatus(IDM_ClearUndoStack, btnClearUndoStack);
btnSave.enabled := edit.IsDirty;
if Coolbar.Bands[2].Visible
then begin
//update the table buttons
if not mnuViewtbl_Table.Enabled
then begin
btnTableInTable.Enabled := False;
btnTableInsRow.Enabled := False;
btnTableDelRow.Enabled := False;
btnTableInsCol.Enabled := False;
btnTableDelCol.Enabled := False;
btnTableInsCell.Enabled := False;
btnTableDelCell.Enabled := False;
btnTableMergeCells.Enabled := False;
btnTableTableSplitCells.Enabled := False;
end
else begin
btnQueryStatus(DECMD_INSERTTABLE, btnTableInTable);
btnQueryStatus(DECMD_INSERTROW, btnTableInsRow);
btnQueryStatus(DECMD_INSERTCOL, btnTableInsCol);
btnQueryStatus(DECMD_INSERTCELL, btnTableInsCell);
btnQueryStatus(DECMD_DELETEROWS, btnTableDelRow);
btnQueryStatus(DECMD_DELETECOLS, btnTableDelCol);
btnQueryStatus(DECMD_DELETECELLS, btnTableDelCell);
btnQueryStatus(DECMD_MERGECELLS, btnTableMergeCells);
btnQueryStatus(DECMD_SPLITCELL, btnTableTableSplitCells);
end;
end;
end
else if (PageControl1.ActivePage = tabHTML) {$IFNDEF D2009UP} or
(PageControl1.ActivePage = TabUniHTML) {$ENDIF}
then begin
//mmoHTML
btnCut.Enabled := mmoHTML.SelLength > 0;
btnCopy.Enabled := mnuEditCut.Enabled;
btnPaste.Enabled := true;
btnPrint.Enabled := true;
btnUndo.Enabled := mmoHTML.CanUndo;
//mnuEditRedo.Enabled := false;
end
else if PageControl1.ActivePage = tabPreview //preview tab
then begin
btnCopy.Enabled := Preview.Selection;
end;
end;
//------------------------------------------------------------------------------
procedure TfrmOcxHtmlEditor.btnBoldClick(Sender: TObject);
begin
//asm int 3 end; //trap
CheckResult(Edit.CmdSet(IDM_BOLD), 'IDM_BOLD');
end;
//------------------------------------------------------------------------------
procedure TfrmOcxHtmlEditor.btnOpenClick(Sender: TObject);
var
aFile: Widestring;
begin
//asm int 3 end; //trap
CheckResult(Edit.LoadFile(aFile, true), 'LoadFile', false, true);
//this command actually returns the loaded file path
end;
//------------------------------------------------------------------------------
procedure TfrmOcxHtmlEditor.btnSaveClick(Sender: TObject);
begin
//asm int 3 end; //trap
CheckResult(Edit.SaveFile, 'SaveFile', false, true);
end;
procedure TfrmOcxHtmlEditor.btnSaveToRoomerClick(Sender: TObject);
begin
SaveFile(RoomerFilename);
Close;
end;
//------------------------------------------------------------------------------
procedure TfrmOcxHtmlEditor.btnInsertImageClick(Sender: TObject);
begin
//asm int 3 end; //trap
CheckResult(Edit.CmdSet(IDM_IMAGE), 'IDM_IMAGE');
end;
//------------------------------------------------------------------------------
procedure TfrmOcxHtmlEditor.btnItalicClick(Sender: TObject);
begin
CheckResult(Edit.CmdSet(IDM_Italic), 'IDM_Italic');
end;
//------------------------------------------------------------------------------
procedure TfrmOcxHtmlEditor.btnUnderlineClick(Sender: TObject);
begin
//asm int 3 end; //trap
CheckResult(Edit.CmdSet(IDM_Underline), 'IDM_Underline');
end;
//------------------------------------------------------------------------------
procedure TfrmOcxHtmlEditor.btnFindClick(Sender: TObject);
begin
//asm int 3 end; //trap
CheckResult(Edit.CmdSet(IDM_FIND), 'IDM_FIND');
end;
//------------------------------------------------------------------------------
procedure TfrmOcxHtmlEditor.cmbFontNameChange(Sender: TObject);
begin
//asm int 3 end; //trap
if not TEIgnoreChange
then CheckResult(Edit.CmdSet_S(IDM_FONTNAME, cmbFontName.Text), 'IDM_FONTNAME');
CheckResult(Edit.SetFocusToDoc, 'SetFocusToDoc', false, true);
end;
//------------------------------------------------------------------------------
procedure TfrmOcxHtmlEditor.cmbFontSizeChange(Sender: TObject);
begin
//asm int 3 end; //trap
if not TEIgnoreChange
then CheckResult(Edit.CmdSet_I(IDM_FONTSIZE, cmbFontSize.ItemIndex + 1), 'IDM_FONTSIZE');
CheckResult(Edit.SetFocusToDoc, 'SetFocusToDoc', false, true);
end;
//------------------------------------------------------------------------------
procedure TfrmOcxHtmlEditor.cmbStylesChange(Sender: TObject);
begin
//asm int 3 end; //trap
if not TEIgnoreChange
then CheckResult(Edit.SetStyle(cmbStyles.Text), 'SetStyle');