forked from teamQPM/qpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
QPM_SHG_SimpleHelpGenerator.prg
2124 lines (1943 loc) · 95.5 KB
/
QPM_SHG_SimpleHelpGenerator.prg
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
/*
* QPM - QAC based Project Manager
*
* Copyright 2011-2021 Fernando Yurisich <[email protected]>
* https://teamqpm.github.io/
*
* Based on QAC - Project Manager for (x)Harbour
* Copyright 2006-2011 Carozo de Quilmes <[email protected]>
* http://www.CarozoDeQuilmes.com.ar
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "minigui.ch"
#include <QPM.ch>
memvar cPTopic
memvar cPNick
memvar cAuxTopic
memvar cAuxNick
memvar vFilesToCompile
#ifdef QPM_SHG
FUNCTION SHG_CreateDatabase( cFile )
LOCAL auxName := US_FileTmp( US_FileNameOnlyPath( cFile ) + DEF_SLASH + "_AddDbf" )
CREATE ( auxName )
APPEND BLANK
REPLACE Field_name WITH "SHG_NEW",;
Field_type WITH "C",;
Field_len WITH 1,;
Field_dec WITH 0
APPEND BLANK
REPLACE Field_name WITH "SHG_DELETE",;
Field_type WITH "C",;
Field_len WITH 1,;
Field_dec WITH 0
APPEND BLANK
REPLACE Field_name WITH "SHG_TYPE",;
Field_type WITH "C",;
Field_len WITH 1,;
Field_dec WITH 0
APPEND BLANK
REPLACE Field_name WITH "SHG_TYPET",;
Field_type WITH "C",;
Field_len WITH 1,;
Field_dec WITH 0
APPEND BLANK
REPLACE Field_name WITH "SHG_IDENT",;
Field_type WITH "N",;
Field_len WITH 2,;
Field_dec WITH 0
APPEND BLANK
REPLACE Field_name WITH "SHG_IDENTT",;
Field_type WITH "N",;
Field_len WITH 2,;
Field_dec WITH 0
APPEND BLANK
REPLACE Field_name WITH "SHG_ORDER",;
Field_type WITH "N",;
Field_len WITH 5,;
Field_dec WITH 0
APPEND BLANK
REPLACE Field_name WITH "SHG_ORDERT",;
Field_type WITH "N",;
Field_len WITH 5,;
Field_dec WITH 0
APPEND BLANK
REPLACE Field_name WITH "SHG_TOPIC",;
Field_type WITH "C",;
Field_len WITH 255,;
Field_dec WITH 0
APPEND BLANK
REPLACE Field_name WITH "SHG_TOPICT",;
Field_type WITH "C",;
Field_len WITH 255,;
Field_dec WITH 0
APPEND BLANK
REPLACE Field_name WITH "SHG_NICK",;
Field_type WITH "C",;
Field_len WITH 255,;
Field_dec WITH 0
APPEND BLANK
REPLACE Field_name WITH "SHG_NICKT",;
Field_type WITH "C",;
Field_len WITH 255,;
Field_dec WITH 0
APPEND BLANK
REPLACE Field_name WITH "SHG_MEMO",;
Field_type WITH "M",;
Field_len WITH 10,;
Field_dec WITH 0
APPEND BLANK
REPLACE Field_name WITH "SHG_MEMOT",;
Field_type WITH "M",;
Field_len WITH 10,;
Field_dec WITH 0
APPEND BLANK
REPLACE Field_name WITH "SHG_KEYS",;
Field_type WITH "M",;
Field_len WITH 10,;
Field_dec WITH 0
APPEND BLANK
REPLACE Field_name WITH "SHG_KEYST",;
Field_type WITH "M",;
Field_len WITH 10,;
Field_dec WITH 0
USE
CREATE ( cFile ) FROM ( auxName )
USE
SHG_Database := cFile
US_Use( .T. , , SHG_Database , "SHG" , DEF_DBF_EXCLUSIVE , DEF_DBF_WRITE )
DbGoTop()
SHG_IndexON( SHG_Database )
DBCloseArea( "SHG" )
SHG_AddRecord( "F" , 1 , "Global Footer" , "" , "This text will be included at the footer of all Help pages" + HB_OsNewLine() )
SHG_AddRecord( "W" , 2 , "Welcome Page" , "" , "Text of Welcome Page" , "Welcome" + HB_OsNewline() + "Bienvenido" )
SHG_AddRecord( "B" , 3 , "Example Book Number 1" , "" , "Text of Book 1" )
SHG_AddRecord( "P" , 4 , "Example Page Number 1 of Book 1" , "" , "Text of Page 1 of Book 1" )
SHG_AddRecord( "P" , 5 , "Example Page Number 2 of Book 1" , "" , "Text of Page 2 of Book 1" )
SHG_AddRecord( "P" , 6 , "Example Page Number 3 of Book 1" , "" , "Text of Page 3 of Book 1" )
SHG_AddRecord( "P" , 7 , "Example Page Number 4 of Book 1" , "" , "Text of Page 4 of Book 1" )
SHG_AddRecord( "B" , 8 , "Example Book Number 2" , "" , "Text of Book 2" )
SHG_AddRecord( "P" , 9 , "Example Page Number 1 of Book 2" , "" , "Text of Page 1 of Book 2" )
ferase( auxName )
Return .T.
Function SHG_Close()
if !( QPM_WAIT( "SHG_CheckSave()" , "Checking for save ..." ) )
Return .F.
endif
if SHG_BaseOk
if MyMsgYesNo( "Confirm Close Help Database ?" )
QPM_Wait( 'DoMethod( "VentanaMain" , "GHlpFiles" , "DeleteAllItems" )' )
if US_FileSize( US_FileNameOnlyPathAndName( SHG_Database ) + ".dbt" ) > SHG_DbSize
QPM_Wait( 'SHG_PackDatabase()' )
endif
SHG_Database := ""
SetProperty( "VentanaMain" , "THlpDataBase" , "Value" , "" )
SHG_BaseOK := .F.
SetProperty( "VentanaMain" , "RichEditHlp" , "value" , "" )
oHlpRichEdit:lChanged := .F.
SetProperty( "VentanaMain" , "RichEditHlp" , "readonly" , .T. )
else
Return .F.
endif
endif
Return .T.
Function SHG_PackDatabase()
Local cTmpDb := US_FileNameOnlyPathAndName( SHG_Database ) + "_" + PUB_cSecu + ".dbf"
if !file( cTmpDb )
US_Use( .T. , , SHG_Database , "SHG" , DEF_DBF_EXCLUSIVE , DEF_DBF_WRITE )
COPY TO ( cTmpDb )
DBClosearea( "SHG" )
if file( cTmpDb )
ferase( SHG_Database )
ferase( US_FileNameOnlyPathAndName( SHG_Database ) + ".dbt" )
endif
if !file( SHG_Database )
US_Use( .T. , , cTmpDb , "SHG" , DEF_DBF_EXCLUSIVE , DEF_DBF_WRITE )
COPY TO ( SHG_Database )
DBClosearea( "SHG" )
endif
if file( SHG_Database )
ferase( cTmpDb )
ferase( US_FileNameOnlyPathAndName( cTmpDb ) + ".dbt" )
endif
endif
Return .T.
Function SHG_GetDatabase()
Local vFiles, cFile
if !( QPM_WAIT( "SHG_CheckSave()" , "Checking for save ..." ) )
Return .F.
endif
/* Get file con multiselect en .F. trae problemas cuando se pone algo nuevo y se presiona enter en lugar de usar el boton */
If ( len( vFiles := US_GetFile( { {'QPM Help Generator Database (*_SHG.DBF)','*_SHG.DBF'} } , "Select QPM Help Generator Database" , if( !empty( US_FileNameOnlyPath( GetProperty( "VentanaMain" , "THlpDataBase" , "Value" ) ) ) , US_FileNameOnlyPath( GetProperty( "VentanaMain" , "THlpDataBase" , "Value" ) ) , PUB_cProjectFolder ) , .T. , .T. ) ) > 0 )
cFile := SHG_StrTran( vFiles[1] )
if upper( right( US_FileNameOnlyName( cFile ) , 4 ) ) != "_SHG"
cFile := US_FileNameOnlyPath( cFile ) + DEF_SLASH + US_FileNameOnlyName( cFile ) + "_SHG.dbf"
endif
if Upper( US_FileNameOnlyExt( cFile ) ) != "DBF"
cFile := US_FileNameOnlyPathAndName( cFile ) + ".dbf"
endif
if !file( cFile )
if MyMsgYesNo( "Help Database '"+cFile+"' not found. Do you want to create an empty database ?" )
SHG_CreateDatabase( cFile )
SetProperty( "VentanaMain" , "THlpDataBase" , "Value" , cFile )
else
Return .F.
endif
else
if US_IsDbf( cFile ) = 21
MyMsgStop( "Help database '" + cFile + "' if open by another process..." + HB_OsNewline() + "Free the database an retry" )
Return .F.
endif
if US_IsDbf( cFile ) != 0
MyMsgStop( "Invalid or corrupted Help database '" + cFile + "'" )
Return .F.
endif
SHG_Database := cFile
SetProperty( "VentanaMain" , "THlpDataBase" , "Value" , cFile )
endif
else
Return .F.
Endif
QPM_WAIT( "SHG_LoadDatabase( SHG_Database )" , "Loading Database ..." )
Return .T.
Function SHG_AddRecord( cType , nSecu , cTopic , cNick , cMemo , cKeys )
DEFAULT cKeys TO ""
// cMemo := "{\rtf1\ansi\ansicpg1252\deff0\deflang3082{\fonttbl{\f0\froman\fcharset0 Arial;}{\f1\fnil\fcharset0 MS Sans Serif;}}" + HB_OsNewline() + ;
// "{\colortbl ;\red0\green0\blue0;}" + HB_OsNewline() + ;
// "\viewkind4\uc1\pard\sb100\sa100\cf1\f0\fs20 " + cMemo + HB_OsNewline() + ;
// "\par \pard\cf0\f1\fs17 " + HB_OsNewline() + ;
// "\par }"
cMemo := "{\rtf1\ansi\ansicpg1252\deff0\deflang3082{\fonttbl{\f0\froman\fcharset0 Arial;}{\f1\fnil\fcharset0 MS Sans Serif;}}" + HB_OsNewline() + ;
"{\colortbl ;\red0\green0\blue0;}" + HB_OsNewline() + ;
"\viewkind4\uc1\cf1\f0\fs20 " + cMemo + HB_OsNewline() + ;
"\par }"
// "\par \cf0\f1\fs17 " + HB_OsNewline() + ;
cMemo := US_RTF2RTF( cMemo )
US_Use( .T. , , SHG_Database , "SHG" , DEF_DBF_EXCLUSIVE , DEF_DBF_WRITE )
DBSetIndex( US_FileNameOnlyPathAndName( SHG_Database ) )
APPEND BLANK
// REPLACE SHG_TYPET WITH cType , SHG_ORDER WITH nSecu , SHG_TOPICT WITH cTopic , SHG_MEMOT WITH cMemo , SHG_KEYST WITH cKeys
REPLACE SHG_TYPE WITH cType , SHG_TYPET WITH cType , SHG_ORDER WITH nSecu
REPLACE SHG_TOPIC WITH cTopic , SHG_TOPICT WITH cTopic , SHG_MEMO WITH cMemo , SHG_MEMOT WITH cMemo
REPLACE SHG_NICK WITH cNick , SHG_NICKT WITH cNick
REPLACE SHG_KEYS WITH cKeys , SHG_KEYST WITH cKeys
DBCloseArea( "SHG" )
Return .T.
Function SHG_DeleteRecord( nRec )
US_Use( .T. , , SHG_Database , "SHG" , DEF_DBF_EXCLUSIVE , DEF_DBF_WRITE )
DBSetIndex( US_FileNameOnlyPathAndName( SHG_Database ) )
DBGoTop()
if !DbSeek( nRec )
MyMsgInfo( "Error locating record number " + US_VarToStr( nRec ) + " in function SHG_DeleteRecord. Please, contact support." )
else
DELETE
endif
DBCloseArea( "SHG" )
SHG_NewSecuence()
Return .T.
Function SHG_GetField( cField , nRow )
Local cAux := "Record " + US_VarToStr( nRow ) + " not found. Contact with QPM Support for Assistance"
US_Use( .T. , , SHG_Database , "SHG" , DEF_DBF_EXCLUSIVE , DEF_DBF_WRITE )
DBSetIndex( US_FileNameOnlyPathAndName( SHG_Database ) )
DBGoTop()
if !DbSeek( nRow )
MyMsgInfo( "Error locating record number " + US_VarToStr( nRow ) + " in function SHG_GetField. Please, contact support." )
else
cAux := &( cField )
endif
DBCloseArea( "SHG" )
Return cAux
Function SHG_SetField( cField , nRow , xValue )
Local bReto := .F.
US_Use( .T. , , SHG_Database , "SHG" , DEF_DBF_EXCLUSIVE , DEF_DBF_WRITE )
DBSetIndex( US_FileNameOnlyPathAndName( SHG_Database ) )
DBGoTop()
if !DbSeek( nRow )
MyMsgInfo( "Error locating record number " + US_VarToStr( nRow ) + " in function SHG_SetField. Please, contact support." )
else
if &cField == xValue
else
REPLACE &cField WITH xValue
endif
bReto := .T.
endif
DBCloseArea( "SHG" )
Return bReto
Function SHG_CheckSave()
Local nActual := GetProperty( "VentanaMain" , "GHlpFiles" , "Value" )
Local nInx , vDiff := {} , rpt
LostRichEdit( "HLP" , nActual )
SetMGWaitTxt( "Checking changes in Hlp Topics..." )
For nInx := 1 to GetProperty( "VentanaMain" , "GHlpFiles" , "ItemCount" )
if GetProperty( "VentanaMain" , "GHlpFiles" , "Cell" , nInx , NCOLHLPEDIT ) == "D"
aadd( vDiff , nInx )
endif
Next
if len( vDiff ) == 0
Return .T.
endif
if len( vDiff ) == 1
if ( rpt := MyMsgYesNoCancel( "Help Topic '" + alltrim( GetProperty( "VentanaMain" , "GHlpFiles" , "Cell" , vDiff[1] , NCOLHLPTOPIC ) ) + "' not saved !!!" + HB_OsNewLine() + "Save it ???" ) ) == 1
SHG_SetField( "SHG_TYPE" , vDiff[1] , SHG_GetField( "SHG_TYPET" , vDiff[1] ) )
// SHG_SetField( "SHG_ORDER" , vDiff[1] , SHG_GetField( "SHG_ORDERT" , vDiff[1] ) )
SHG_SetField( "SHG_TOPIC" , vDiff[1] , SHG_GetField( "SHG_TOPICT" , vDiff[1] ) )
SHG_SetField( "SHG_NICK" , vDiff[1] , SHG_GetField( "SHG_NICKT" , vDiff[1] ) )
SHG_SetField( "SHG_MEMO" , vDiff[1] , SHG_GetField( "SHG_MEMOT" , vDiff[1] ) )
SHG_SetField( "SHG_KEYS" , vDiff[1] , SHG_GetField( "SHG_KEYST" , vDiff[1] ) )
SetProperty( "VentanaMain" , "GHlpFiles" , "Cell" , vDiff[1] , NCOLHLPEDIT , "E" )
endif
// if rpt == 0
// if SHG_GetField( "SHG_ORDER" , vDiff[1] ) == 0
// SHG_DeleteRecord( vDiff[1] )
// endif
// endif
if rpt == -1
Return .F.
endif
Return .T.
endif
if ( rpt := MyMsgYesNoCancel( alltrim( str( len( vDiff ) ) ) + " Help's Topic's not saved !!!" + HB_OsNewLine() + HB_OsNewLine() + "Reply YES for save ALL Topic" + HB_OsNewLine() + "Reply NO for discard ALL changes of Topics" + HB_OsNewLine() + "Reply CANCEL for return to edit HLP Topics" ) ) == 1
SetMGWaitTxt( "Saving Hlp Topics..." )
SHG_SaveAll()
else
// if rpt == 0
// For nInx := 1 to GetProperty( "VentanaMain" , "GHlpFiles" , "ItemCount" )
// DO EVENTS
// if SHG_GetField( "SHG_ORDER" , nInx ) == 0
// SHG_DeleteRecord( nInx )
// endif
// Next
// endif
if rpt == -1
Return .F.
endif
endif
Return .T.
Function SHG_SaveAll()
Local nInx
For nInx := 1 to GetProperty( "VentanaMain" , "GHlpFiles" , "ItemCount" )
if GetProperty( "VentanaMain" , "GHlpFiles" , "Cell" , nInx , NCOLHLPEDIT ) == "D"
SetMGWaitTxt( "Saving: " + alltrim( GetProperty( "VentanaMain" , "GHlpFiles" , "Cell" , nInx , NCOLHLPTOPIC ) ) + " ..." )
SHG_SetField( "SHG_TYPE" , nInx , SHG_GetField( "SHG_TYPET" , nInx ) )
// SHG_SetField( "SHG_ORDER" , nInx , SHG_GetField( "SHG_ORDERT" , nInx ) )
SHG_SetField( "SHG_TOPIC" , nInx , SHG_GetField( "SHG_TOPICT" , nInx ) )
SHG_SetField( "SHG_NICK" , nInx , SHG_GetField( "SHG_NICKT" , nInx ) )
SHG_SetField( "SHG_MEMO" , nInx , SHG_GetField( "SHG_MEMOT" , nInx ) )
SHG_SetField( "SHG_KEYS" , nInx , SHG_GetField( "SHG_KEYST" , nInx ) )
SetProperty( "VentanaMain" , "GHlpFiles" , "Cell" , nInx , NCOLHLPEDIT , "E" )
endif
Next
Return .T.
Function SHG_Generate( cBase , bGenHtml , PUB_cSecu , cWWW )
Local Prefijo // "Hlp"
Local cOldDll
Local Folder
Local cDllWithCancel
Local cName , cPrev := NIL , cTop := NIL , cNext := NIL
Local nCont := 0 , i
Local cDirOutCHM := PUB_cProjectFolder + DEF_SLASH + "_" + PUB_cSecu + "HlpTemp"
Local nRegistros, cMemoHeader , cMemoFooter , cFooterHTML
Local cBackColor := "#FFFCEA"
Local wwwCdQ := "https://teamqpm.github.io/"
Local cWWWDescri := "Powered by QPM"
Local cAux
Local nCinx
Local cClaves := " "
Local cDirOutHTML := PUB_cProjectFolder + DEF_SLASH + "HtmlHelp"
Local vFiles := {}
PRIVATE vFilesToCompile := {}
if Empty( PUB_cProjectFolder ) .or. ! US_IsDirectory( PUB_cProjectFolder )
MyMsgStop( DBLQT + "Project Folder" + DBLQT + " is not a valid folder:" + Hb_OsNewLine() + PUB_cProjectFolder + Hb_OsNewLine() + 'Look at tab ' + DBLQT + PagePRG + DBLQT )
Return .F.
endif
if US_FileInUse( SHG_GetOutputName() )
MyMsgInfo( "Output name '" + SHG_GetOutputName() + "' is in use." + HB_OsNewLine() + "Close the help process an retry." )
Return .F.
endif
if !file( cBase )
MyMsgStop( "Help database not found: " + cBase + HB_OsNewLine() + "Use open button to open or create help database." )
return .F.
endif
// check
if empty( cWWW ) .or. len( cWWW ) < 4
cWWW := wwwCdQ
endif
Prefijo := US_FileNameOnlyName( SHG_GetOutputName() )
US_Use( .T. , , cBase , "SHG" , DEF_DBF_EXCLUSIVE , DEF_DBF_WRITE )
DbGoTo( 2 )
cAux := field->SHG_TYPE
DbGoTop()
if field->SHG_TYPE != "F" .or. ;
cAux != "W" .or. ;
field->SHG_ORDER != 1 .or. ;
field->SHG_TOPIC != "Global Foot"
MyMsgStop( "Help Database is corrupted, records UNKNOWN" )
DBCloseArea( "SHG" )
Return .F.
endif
DBCloseArea( "SHG" )
// end check
if !( cWWW == wwwCdQ )
cWWWDescri := cWWW
endif
if at( "://" , upper( cWWW ) ) == 0
if at( "@" , upper( cWWW ) ) == 0
cWWW := "http://" + cWWW
else
if at( "mailto:" , upper( cWWW ) ) == 0
cWWW := "mailto:" + cWWW
endif
endif
endif
if upper( US_FileNameOnlyName( SHG_GetOutputName() ) ) == "QPM"
// cBackColor := "#e4f3e2" /* verde */
cBackColor := "#FFFCEA" /* amarillo */
// cBackColor := "#ffeee6" /* {255,238,230} rosa */
endif
if !SHG_BaseOK
if empty( SHG_Database )
MyMsgInfo( "QPM Help Generator Database not selected. Use open button for open or create help database" )
else
MyMsgInfo( "Error opening QPM Help Generator Database: " + SHG_Database + HB_OsNewLine() + "Look at " + PageHlp )
endif
Return .F.
endif
if !SHG_CheckSave()
Return .F.
endif
if bGenHtml
if Empty( SHG_HtmlFolder )
SHG_HtmlFolder := cDirOutHTML
Endif
If Empty( Folder := GetFolder( "Select Folder for HTML Output", SHG_HtmlFolder ) )
MyMsgInfo( "Folder required for HTML output." )
Return .F.
Else
SHG_HtmlFolder := Folder
Endif
if ! US_IsDirectory( SHG_HtmlFolder )
if ! US_CreateFolder( SHG_HtmlFolder )
US_Log( "Unable to create HTML folder: " + SHG_HtmlFolder )
return .F.
endif
endif
cDirOutHTML := SHG_HtmlFolder
endif
cDllWithCancel := alltrim( memoline( memoread( PUB_cQPM_Folder + DEF_SLASH + "itcc_dll.tmp" ) , 254 , 1 ) )
cOldDll := SHG_PutDllItcc()
if cOldDll == "*ERROR*"
Return .F.
endif
QPM_MemoWrit( PUB_cQPM_Folder + DEF_SLASH + "itcc_dll.tmp" , cOldDll )
if !empty( cDllWithCancel )
cOldDll := cDllWithCancel
endif
if !( US_IsDirectory( cDirOutCHM ) )
if !US_CreateFolder( cDirOutCHM )
US_Log( "Unable to create folder for CHM output: " + cDirOutCHM )
return .F.
endif
endif
_SaveBitmap( LoadBitmap( "SHG_ARROWPREV" ), cDirOutCHM + DEF_SLASH + "SHG_ArrowPrev.bmp" )
_SaveBitmap( LoadBitmap( "SHG_ARROWNEXT" ), cDirOutCHM + DEF_SLASH + "SHG_ArrowNext.bmp" )
_SaveBitmap( LoadBitmap( "SHG_ARROWTOP" ), cDirOutCHM + DEF_SLASH + "SHG_ArrowTop.bmp" )
_SaveBitmap( LoadBitmap( "SHG_ARROWBOTTOM" ), cDirOutCHM + DEF_SLASH + "SHG_ArrowBottom.bmp" )
if bGenHtml
US_FileCopy( cDirOutCHM + DEF_SLASH + "SHG_ArrowPrev.bmp" , cDirOutHTML + DEF_SLASH + "SHG_ArrowPrev.bmp" )
US_FileCopy( cDirOutCHM + DEF_SLASH + "SHG_ArrowNext.bmp" , cDirOutHTML + DEF_SLASH + "SHG_ArrowNext.bmp" )
US_FileCopy( cDirOutCHM + DEF_SLASH + "SHG_ArrowTop.bmp" , cDirOutHTML + DEF_SLASH + "SHG_ArrowTop.bmp" )
US_FileCopy( cDirOutCHM + DEF_SLASH + "SHG_ArrowBottom.bmp" , cDirOutHTML + DEF_SLASH + "SHG_ArrowBottom.bmp" )
/* Copy extra images for html help */
_SaveBitmap( LoadBitmap( "SHG_WELCOME" ), cDirOutHTML + DEF_SLASH + "SHG_Welcome.bmp" )
_SaveBitmap( LoadBitmap( "SHG_BOOK" ), cDirOutHTML + DEF_SLASH + "SHG_Book.bmp" )
_SaveBitmap( LoadBitmap( "SHG_PAGE" ), cDirOutHTML + DEF_SLASH + "SHG_Page.bmp" )
/* Copy dtree for html help */
US_FileCopy( PUB_cQPM_Folder + DEF_SLASH + "US_dtree.css" , cDirOutHTML + DEF_SLASH + "SHG_dtree.css" )
US_FileCopy( PUB_cQPM_Folder + DEF_SLASH + "US_dtree.js" , cDirOutHTML + DEF_SLASH + "SHG_dtree.js" )
US_FileCopy( PUB_cQPM_Folder + DEF_SLASH + "US_dtree.im" , cDirOutHTML + DEF_SLASH + "SHG_dtree.zip" )
/* HB_UNZIPFILE( <cFile>, <bBlock>, <lWithPath>, <cPassWord>, <cPath>, <cFile> | <aFile>, <pFileProgress> ) ---> lCompress
* $ARGUMENTS$
* <cFile> Name of the zip file to extract
* <bBlock> Code block to execute while extracting
* <lWithPath> Toggle to create directory if needed
* <cPassWord> Password to use to extract files
* <cPath> Path to extract the files to - mandatory
* <cFile> | <aFiles> A File or Array of files to extract - mandatory
* <pFileProgress> Code block for File Progress
*/
if !HB_UNZIPFILE(cDirOutHTML + DEF_SLASH + "SHG_dtree.zip", nil, .T., nil, cDirOutHTML + DEF_SLASH + "SHG_IMG" + DEF_SLASH, "*.*", nil )
MyMsgInfo( "Error decompresing images for index tree of HTML Help (Java Mode)." )
else
ferase( cDirOutHTML + DEF_SLASH + "SHG_dtree.zip" )
endif
endif
US_Use( .T. , , cBase , "HlpAlias" , DEF_DBF_EXCLUSIVE , DEF_DBF_WRITE )
DBSetIndex( US_FileNameOnlyPathAndName( cBase ) )
nRegistros := Reccount()
DbSeek( 1 )
SetMGWaitTxt( "Generating footer..." )
QPM_MemoWrit( cDirOutCHM + DEF_SLASH + "Footer.rtf" , field->SHG_MEMO )
// US_FileChar26Zap( cDirOutCHM + DEF_SLASH + "Footer.rtf" )
SHG_RtfToHtml( cDirOutCHM + DEF_SLASH + "Footer.rtf" , cDirOutCHM + DEF_SLASH + "Footer.htm" , "Global Foot" )
cFooterHTML := SHG_HTML_GetFooter( cDirOutCHM + DEF_SLASH + "Footer.htm" )
DBSeek( 3 )
if !empty( field->SHG_NICK )
cTop := alltrim( field->SHG_NICK )
else
cTop := Prefijo + "_2.htm"
endif
DBSeek( 2 )
Do while !eof()
DO EVENTS
nCont++
if field->SHG_ORDER < 4
cPrev := NIL
else
DBSKIP( -1 )
if empty( field->SHG_NICK )
cPrev := Prefijo + "_" + alltrim( str( nCont - 1 ) ) + ".htm"
else
cPrev := alltrim( field->SHG_NICK )
endif
DBSKIP( +1 )
endif
if field->SHG_ORDER == nRegistros
cNext := NIL
else
DBSKIP( +1 )
if empty( field->SHG_NICK )
cNext := Prefijo + "_" + alltrim( str( nCont + 1 ) ) + ".htm"
else
cNext := alltrim( field->SHG_NICK )
endif
DBSKIP( -1 )
endif
if empty( field->SHG_NICK )
cName := Prefijo + "_" + alltrim( str( nCont ) )
else
cName := US_FileNameOnlyName( field->SHG_NICK )
endif
if !empty( field->SHG_KEYS )
QPM_MemoWrit( cDirOutCHM + DEF_SLASH + cName + ".Inx" , field->SHG_KEYS )
if bGenHtml
for nCinx := 1 to mlcount( field->SHG_KEYS , 254 )
if at( upper( alltrim( memoline( field->SHG_KEYS , 254 , nCinx ) ) + ", " ) , upper( cClaves ) ) == 0
cClaves := cClaves + alltrim( memoline( field->SHG_KEYS , 254 , nCinx ) ) + ", "
endif
next
endif
endif
aadd( vFiles , { alltrim( field->SHG_TYPE ) , strtran( strtran( alltrim( field->SHG_TOPIC ) , "<" , "<" ) , ">" , ">" ) , cName + ".htm" , cDirOutCHM + DEF_SLASH + cName + ".Inx" , cPrev , cTop , cNext } )
QPM_MemoWrit( cDirOutCHM + DEF_SLASH + cName + ".rtf" , field->SHG_Memo )
// US_FileChar26Zap( cDirOutCHM + DEF_SLASH + cName + ".rtf" )
// SetMGWaitTxt( "Generating: " + cName + ".htm ..." )
SetMGWaitTxt( "Generating: " + alltrim( field->SHG_TOPIC ) + " ..." )
SHG_RtfToHtml( cDirOutCHM + DEF_SLASH + cName + ".rtf" , cDirOutCHM + DEF_SLASH + cName + ".htm" , alltrim( field->SHG_TOPIC ) )
if file( cDirOutCHM + DEF_SLASH + cName + ".htm" )
SHG_HTML_ArmoHeader( @cMemoHeader , vFiles , len( vFiles ) , cBackColor , alltrim( field->SHG_TOPIC ) )
SHG_HTML_AddHeader( cDirOutCHM + DEF_SLASH + cName + ".htm" , cMemoHeader )
SHG_HTML_ArmoFooter( @cMemoFooter , vFiles , len( vFiles ) , cFooterHTML , cWWW , cWWWDescri )
SHG_HTML_AddFooter( cDirOutCHM + DEF_SLASH + cName + ".htm" , cMemoFooter )
if bGenHtml
US_FileCopy( cDirOutCHM + DEF_SLASH + cName + ".htm" , cDirOutHTML + DEF_SLASH + cName + ".htm" )
endif
endif
// ferase( cDirOutCHM + DEF_SLASH + cName + ".rtf" )
DBSkip()
enddo
DBCloseArea( "HlpAlias" )
SetMGWaitTxt( "Compiling to make " + SHG_GetOutputName() + "..." )
SHG_HHP_Gener( Prefijo , cDirOutCHM , vFiles, vFilesToCompile )
SHG_HHC_Gener( Prefijo , cDirOutCHM , vFiles )
SHG_HHK_Gener( Prefijo , cDirOutCHM , vFiles )
DO EVENTS
if bGenHtml
SHG_CopyImageToHtmlFolder( vFilesToCompile , cDirOutHTML )
SHG_GenHtmlIndexHTML( US_FileNameOnlyName( SHG_GetOutputName() ) + '.htm' , cDirOutHTML , vFiles , cClaves , cWWW )
SHG_GenHtmlIndexJava( US_FileNameOnlyName( SHG_GetOutputName() ) + '.htm' , cDirOutHTML , vFiles , cClaves , cWWW )
endif
DO EVENTS
SHG_CompileToCHM( US_ShortName( cDirOutCHM + DEF_SLASH + Prefijo + ".hhp" ) , US_ShortName( cDirOutCHM ) )
for i := 1 to len( vFiles )
DO EVENTS
// ferase( cDirOutCHM + DEF_SLASH + vFiles[i][3] )
// ferase( vFiles[i][4] )
next
// ferase( cDirOutCHM + DEF_SLASH + Prefijo + ".hhp" )
// ferase( cDirOutCHM + DEF_SLASH + Prefijo + ".hhc" )
// ferase( cDirOutCHM + DEF_SLASH + Prefijo + ".hhk" )
if !empty( cOldDll )
SHG_RestoreDllItcc( cOldDll )
else
//ferase( PUB_cQPM_Folder + DEF_SLASH + "hha.dll" )
endif
ferase( PUB_cQPM_Folder + DEF_SLASH + "itcc_dll.tmp" )
US_DirRemoveLoop( cDirOutCHM , 5 )
Return .T.
Function SHG_CopyImageToHtmlFolder( vImage , cDirOut )
Local i
for i:=1 to len( vImage )
DO EVENTS
if file( vImage[i] )
if US_FileCopy( vImage[i] , cDirOut + DEF_SLASH + US_FileNameOnlyNameAndExt( vImage[i] ) ) != US_FileSize( vImage[i] )
MyMsgInfo( "Error copying file '" + vImage[i] + "' to folder: " + cDirOut )
else
if US_FileNameOnlyNameAndExt( US_FileNameCase( vImage[i] ) ) != US_FileNameOnlyNameAndExt( US_FileNameCase( cDirOut + DEF_SLASH + US_FileNameOnlyNameAndExt( vImage[i] ) ) )
frename( cDirOut + DEF_SLASH + US_FileNameOnlyNameAndExt( vImage[i] ) , cDirOut + DEF_SLASH + US_FileNameOnlyNameAndExt( vImage[i] ) + "." + PUB_cSecu )
frename( cDirOut + DEF_SLASH + US_FileNameOnlyNameAndExt( vImage[i] ) + "." + PUB_cSecu , cDirOut + DEF_SLASH + US_FileNameOnlyNameAndExt( US_FileNameCase( vImage[i] ) ) )
endif
endif
endif
next
Return .T.
FUNCTION SHG_GetOutputName()
LOCAL cOutputName, cOutputFolder
cOutputName := US_FileNameOnlyName( SHG_Database )
cOutputName := SubStr( cOutputName , 1 , Len( cOutputName ) - 4 )
cOutputFolder := US_FileNameOnlyPath( GetOutputModuleName() )
IF Empty( cOutputFolder )
cOutputFolder := PUB_cProjectFolder
ENDIF
RETURN cOutputFolder + DEF_SLASH + cOutputName + '.chm'
Function SHG_HTML_ArmoHeader( cHeader , vVector , nIndx , cBackColor , cTitle )
cHeader := '<html><head> ' + HB_OsNewLine() + ;
'<title>'+cTitle+'</title> ' + HB_OsNewLine() + ;
'</head> ' + HB_OsNewLine() + ;
'<body bgcolor="'+cBackColor+'" > ' + HB_OsNewLine() + ;
'<DIV></DIV> ' + HB_OsNewLine() + ;
'<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#c0c0c0" >' + HB_OsNewLine() + ;
'<tr> ' + HB_OsNewLine() + ;
' <td align="left" > ' + HB_OsNewLine() + ;
' <div align="left" ><font face="Arial" color="#010101" size="4" ><span style="FONT-SIZE: 14pt"' + HB_OsNewLine() + ;
' >'+vVector[nIndx][2]+'</span></font></div> ' + HB_OsNewLine() + ;
' </td> ' + HB_OsNewLine() + ;
' <td align="right" > ' + HB_OsNewLine() + ;
' <font face="Arial" size="2" > ' + HB_OsNewLine() + ;
if( empty( vVector[nIndx][5]) , '<img src="SHG_ArrowPrev.bmp" alt="Previous topic"> ' , '<A href="'+vVector[nIndx][5]+'"><img src="SHG_ArrowPrev.bmp" alt="Previous topic"></A> ' + HB_OsNewLine() ) + ;
if( nIndx < 3 , '<img src="SHG_ArrowTop.bmp" alt="First topic"> ' , '<A href="'+vVector[nIndx][6]+'"><img src="SHG_ArrowTop.bmp" alt="First topic"></A> ' + HB_OsNewLine() ) + ;
; // if( empty( vVector[nIndx][7]) , '<img src="SHG_ArrowBottom.bmp" alt="Last topic"> ' , '<A href="'+vVector[len(vVector)][6]+'"><img src="SHG_ArrowBottom.bmp" alt="Last topic"></A> ' + HB_OsNewLine() ) + ;
if( empty( vVector[nIndx][7]) , '<img src="SHG_ArrowNext.bmp" alt="Next topic">' , '<A href="'+vVector[nIndx][7]+'"><img src="SHG_ArrowNext.bmp" alt="Next topic"></A>' + HB_OsNewLine() ) + ;
' </font> ' + HB_OsNewLine() + ;
' </td> ' + HB_OsNewLine() + ;
'</tr></table> ' + HB_OsNewLine() + ;
'<hr><br> ' + HB_OsNewLine()
// if( empty( vVector[nIndx][5]) , '<A>Previous</A> ' , '<A href="'+vVector[nIndx][5]+'">Previous</A> ' + HB_OsNewLine() ) + ;
// if( nIndx < 3 , '<A>Top</A> ' , '<A href="'+vVector[nIndx][6]+'">Top</A> ' + HB_OsNewLine() ) + ;
// if( empty( vVector[nIndx][7]) , '<A>Next</A>' , '<A href="'+vVector[nIndx][7]+'">Next</A>' + HB_OsNewLine() ) + ;
Return .T.
// ' >'+strtran(strtran(vVector[nIndx][2],"<","<"),">",">")+'</span></font></div> ' + HB_OsNewLine() + ;
Function SHG_HTML_GetFooter( cHTML )
Local cMemoAux := MemoRead( cHTML )
// cMemoAux := substr( cMemoAux , at( "</head><body>" , cMemoAux ) + 13 , rat( "</body></html>" , cMemoAux ) - 1 )
Return cMemoAux
Function SHG_HTML_ArmoFooter( cFooter , vVector , nIndx , cFooterHTML , cWWW , cWWWDescri )
cFooter := '<p><hr><p> ' + HB_OsNewLine() + ;
cFooterHTML + HB_OsNewLine() + ;
'<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#c0c0c0" > ' + HB_OsNewLine() + ;
' <TBODY> ' + HB_OsNewLine() + ;
' <tr> ' + HB_OsNewLine() + ;
' <td align="left" ><font face="Arial" color="#010101" size="4" ><span style="FONT-SIZE: 14pt"' + HB_OsNewLine() + ;
' > ' + HB_OsNewLine() + ;
' <P> ' + HB_OsNewLine() + ;
' <P align=left><FONT size=2><A href="'+cWWW+'" target=blank>'+cWWWDescri+'</A> </FONT> ' + HB_OsNewLine() + ;
' </P></span></font></td> ' + HB_OsNewLine() + ;
' <td align="right" > ' + HB_OsNewLine() + ;
' <font face="Arial" size="2" > ' + HB_OsNewLine() + ;
if( empty( vVector[nIndx][5]) , '<img src="SHG_ArrowPrev.bmp" alt="Previous topic"> ' , '<A href="'+vVector[nIndx][5]+'"><img src="SHG_ArrowPrev.bmp" alt="Previous topic"></A> ' + HB_OsNewLine() ) + ;
if( nIndx < 3 , '<img src="SHG_ArrowTop.bmp" alt="First topic"> ' , '<A href="'+vVector[nIndx][6]+'"><img src="SHG_ArrowTop.bmp" alt="First topic"></A> ' + HB_OsNewLine() ) + ;
; // if( empty( vVector[nIndx][7]) , '<img src="SHG_ArrowBottom.bmp" alt="Last topic"> ' , '<A href="'+vVector[len(vVector)][6]+'"><img src="SHG_ArrowBottom.bmp" alt="Last topic"></A> ' + HB_OsNewLine() ) + ;
if( empty( vVector[nIndx][7]) , '<img src="SHG_ArrowNext.bmp" alt="Next topic">' , '<A href="'+vVector[nIndx][7]+'"><img src="SHG_ArrowNext.bmp" alt="Next topic"></A>' + HB_OsNewLine() ) + ;
' </font> ' + HB_OsNewLine() + ;
' </td></tr></TBODY></table><hr></body></html> '
// if( empty( vVector[nIndx][5]) , '<A>Previous</A> ' , '<A href="'+vVector[nIndx][5]+'">Previous</A> ' + HB_OsNewLine() ) + ;
// if( nIndx < 3 , '<A>Top</A> ' , '<A href="'+vVector[nIndx][6]+'">Top</A> ' + HB_OsNewLine() ) + ;
// if( empty( vVector[nIndx][7]) , '<A>Next</A>' , '<A href="'+vVector[nIndx][7]+'">Next</A>' + HB_OsNewLine() ) + ;
Return .T.
Function SHG_HTML_AddHeader( cFile , cHeader )
Local MemoAux := MemoRead( cFile )
// MemoAux := cHeader + substr( MemoAux , at( "</head><body>" , MemoAux ) + 13 )
MemoAux := cHeader + MemoAux
QPM_MemoWrit( cFile , MemoAux )
// US_FileChar26Zap( cFile )
Return .T.
Function SHG_HTML_AddFooter( cFile , cFooter )
Local MemoAux := MemoRead( cFile )
// MemoAux := substr( MemoAux , 1 , rat( "</body></html>" , MemoAux ) - 1 ) + cFooter
MemoAux := MemoAux + cFooter
QPM_MemoWrit( cFile , MemoAux )
// US_FileChar26Zap( cFile )
Return .T.
Function SHG_RtfToHtml( cIn , cOut , cTopic )
Local cOldFolder := GetCurrentFolder()
Local ExeConvert := US_ShortName( PUB_cQPM_Folder ) + DEF_SLASH + "US_R2H.exe"
DirChange( PUB_cProjectFolder )
SHG_Commands( cIn , "PRE" )
DirChange( PUB_cQPM_Folder ) && este cambio de directorio es por la tool rtftohtml que no funciona bien sino se hace esto
QPM_Execute( ExeConvert , US_FileNameOnlyPathAndName( cIn ) , DEF_QPM_EXEC_WAIT , DEF_QPM_EXEC_HIDE )
DirChange( PUB_cProjectFolder )
// DirChange( cOldFolder )
SHG_ImageGenerateList( cOut , cTopic )
SHG_LinkGenerateList( cOut , cTopic )
SHG_Commands( cOut , "POS" )
DirChange( cOldFolder )
Return .T.
Function SHG_HHP_Gener( Prefijo , cDirOutCHM , vFiles, vFilesToCompile )
Local cMemo , i
cMemo := '[OPTIONS] ' + HB_OsNewLine() + ;
'Auto Index=No ' + HB_OsNewLine() + ;
'Binary TOC=No ' + HB_OsNewLine() + ;
'Compatibility=1.1 or later ' + HB_OsNewLine() + ;
'Compiled file=' + SHG_GetOutputName() + ' ' + HB_OsNewLine() + ;
'Contents file=' + Prefijo + '.hhc ' + HB_OsNewLine() + ;
'Default topic=' + vFiles[1][3] + HB_OsNewLine() + ;
'Display compile progress=No ' + HB_OsNewLine() + ;
'Full-text search=Yes ' + HB_OsNewLine() + ;
'Index file=' + Prefijo + '.hhk ' + HB_OsNewLine() + ;
'Language=0x409 ' + HB_OsNewLine() + ;
'Title=' + Upper(Prefijo) + ' ' + HB_OsNewLine()
cMemo := cMemo + '[ALIAS] ' + HB_OsNewLine()
for i := 1 to len( vFiles )
DO EVENTS
cMemo := cMemo + 'IDH_MASTER_TEST'+alltrim( str( i ) )+'='+ vFiles[i][3] +' ' + HB_OsNewLine()
next i
cMemo := cMemo + '[MAP] ' + HB_OsNewLine()
for i := 1 to len( vFiles )
DO EVENTS
cMemo := cMemo + '#define IDH_MASTER_TEST'+alltrim( str( i ) )+' '+ alltrim( str( i ) ) +' ' + HB_OsNewLine()
next i
cMemo := cMemo + '[FILES] ' + HB_OsNewLine()
for i := 1 to len( vFilesToCompile )
DO EVENTS
cMemo := cMemo + vFilesToCompile[i] +' ' + HB_OsNewLine()
next i
QPM_MemoWrit( cDirOutCHM + DEF_SLASH + Prefijo + ".hhp" , cMemo )
Return .T.
Function SHG_HHC_Gener( Prefijo , cDirOutCHM , vFiles )
Local cMemo , i , nLevel := 0
cMemo := '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> ' + HB_OsNewLine() + ;
'<HTML> ' + HB_OsNewLine() + ;
'<HEAD> ' + HB_OsNewLine() + ;
'<meta name="GENERATOR" content="QPM® Simple Help Generator"> ' + HB_OsNewLine() + ;
'<!-- Sitemap 1.0 --> ' + HB_OsNewLine() + ;
'</HEAD><BODY> ' + HB_OsNewLine() + ;
'<OBJECT type="text/site properties"> ' + HB_OsNewLine() + ;
' <param name="ImageType" value="Folder"> ' + HB_OsNewLine() + ;
'</OBJECT> ' + HB_OsNewLine() + ;
'<UL> ' + HB_OsNewLine()
for i := 1 to len( vFiles )
DO EVENTS
if i > 1 .and. ( ( vFiles[i-1][1] == "B" .or. vFiles[i-1][1] == "W" ) .and. vFiles[i][1] == "P" )
cMemo := cMemo + ' <UL> ' + HB_OsNewLine()
nLevel++
endif
if i > 1 .and. ( vFiles[i-1][1] == "P" .and. ( vFiles[i][1] == "B" .or. vFiles[i-1][1] == "W" ) )
if nLevel > 0
cMemo := cMemo + ' </UL> ' + HB_OsNewLine()
nLevel--
endif
endif
cMemo := cMemo + ' <LI> <OBJECT type="text/sitemap"> ' + HB_OsNewLine() + ;
' <param name="Name" value="'+ vFiles[i][2] +'"> ' + HB_OsNewLine() + ;
' <param name="Local" value="'+ vFiles[i][3] +'"> ' + HB_OsNewLine() + ;
' <param name="ImageNumber" value="'+ if( vFiles[i][1] == 'B' , '1' , if( vFiles[i][1] == 'W' , '27' , '11' ) ) +'"> ' + HB_OsNewLine() + ;
' </OBJECT> ' + HB_OsNewLine()
next i
cMemo := cMemo + replicate( "</UL>" , nLevel ) + HB_OsNewLine()
cMemo := cMemo + '</UL> ' + HB_OsNewLine() + ;
'</BODY></HTML>'
QPM_MemoWrit( cDirOutCHM + DEF_SLASH + Prefijo + ".hhc" , cMemo )
Return .T.
Function SHG_HHK_Gener( Prefijo , cDirOutCHM , vFiles )
Local cMemo , i , MemoKeys , k
cMemo := '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> ' + HB_OsNewLine() + ;
' <HTML> ' + HB_OsNewLine() + ;
' <HEAD> ' + HB_OsNewLine() + ;
' <meta name="GENERATOR" content="QPM® Simple Help Generator">' + HB_OsNewLine() + ;
' <!-- Sitemap 1.0 --> ' + HB_OsNewLine() + ;
' </HEAD><BODY> ' + HB_OsNewLine() + ;
' <UL> ' + HB_OsNewLine()
for i := 1 to len( vFiles )
DO EVENTS
if file( vFiles[i][4] )
MemoKeys := memoread( vFiles[i][4] )
for k := 1 to MLCount( MemoKeys , 254 )
DO EVENTS
cMemo := cMemo + ' <LI> <OBJECT type="text/sitemap"> ' + HB_OsNewLine() + ;
' <param name="Name" value="'+ alltrim( memoline( MemoKeys , 254 , k ) ) +'"> ' + HB_OsNewLine() + ;
' <param name="Local" value="'+ vFiles[i][3] +'"> ' + HB_OsNewLine() + ;
' </OBJECT> ' + HB_OsNewLine()
Next k
endif
next i
cMemo := cMemo + '</UL> ' + HB_OsNewLine() + ;
'</BODY></HTML> ' + HB_OsNewLine()
QPM_MemoWrit( cDirOutCHM + DEF_SLASH + Prefijo + ".hhk" , cMemo )
Return .T.
// Se requieren dos DLL's : HHA.dll (puede estar en PUB_cQPM_Folder o en Window\System )
// itcc.dll (debe estar en Window\System y debe registrarse: regsvr32 c:\windows\system\itcc.dll )
// si no se registra esta dll da el siguiente error: "HHC6003: The file itircl.dll has not been registered correctly"
Function SHG_CompileToCHM( Proyecto , cDirOutCHM )
Local cOutPut := cDirOutCHM + DEF_SLASH + '_' + PUB_cSecu + 'OutHHC' + US_DateTimeCen() + '.tmp'
Local MemoResu
ferase( SHG_GetOutputName() )
QPM_MemoWrit( US_ShortName( PUB_cProjectFolder ) + DEF_SLASH + '_'+PUB_cSecu+'RunShell.bat' , US_ShortName(PUB_cQPM_Folder) + DEF_SLASH + 'US_hhc.exe ' + Proyecto + ' > ' + cOutput )
QPM_Execute( US_ShortName( PUB_cProjectFolder ) + DEF_SLASH + '_'+PUB_cSecu+'RunShell.bat' , , DEF_QPM_EXEC_WAIT , DEF_QPM_EXEC_HIDE )
ferase( US_ShortName( PUB_cProjectFolder ) + DEF_SLASH + '_'+PUB_cSecu+'RunShell.bat' )
MemoResu := memoread( cOutPut )
if at( "ERROR:" , upper( MemoResu ) ) == 0 .and. ;
at( "WARNING:" , upper( MemoResu ) ) == 0
MyMsgOk( NIL, 'Build Finished' + HB_OsNewLine() + 'OK', 'I', .T. )
SHG_DisplayHelp( SHG_GetOutputName() )
else
MyMsgStop( strtran( MemoResu , chr(13) + HB_OsNewLine() + chr(13) + HB_OsNewLine() , HB_OsNewLine() ) )
endif
ferase( cOutPut )
Return .T.
Function SHG_DisplayHelp( cName )
Local cOldHelp := GetActiveHelpFile()
if !file( cName )
MyMsgInfo( "Help file '" + cName + "' not found !!!" + HB_OsNewLine() + "Run 'Generate Help' process and try again." )
Return .F.
endif
if US_FileInUse( cName )
MyMsgInfo( "Help file '" + cName + "' is in use." + HB_OsNewLine() + "Close the help process an re-open with TEST button." )
Return .F.
endif
SET HELPFILE TO cName
if GetProperty( "VentanaMain" , "GHlpFiles" , "value" ) == 0
SetProperty( "VentanaMain" , "GHlpFiles" , "value" , 1 )
endif
if GetProperty( "VentanaMain" , "GHlpFiles" , "value" ) == 1
DISPLAY HELP MAIN
else
if empty( GetProperty( "VentanaMain" , "GHlpFiles" , "Cell" , GetProperty( "VentanaMain" , "GHlpFiles" , "value" ) , NCOLHLPNICK ) )
SHG_DisplayHelpTopic( US_FileNameOnlyName( SHG_GetOutputName() ) + "_" + alltrim( str( GetProperty( "VentanaMain" , "GHlpFiles" , "value" ) - 1 ) ) )
else
SHG_DisplayHelpTopic( US_FileNameOnlyName( GetProperty( "VentanaMain" , "GHlpFiles" , "Cell" , GetProperty( "VentanaMain" , "GHlpFiles" , "value" ) , NCOLHLPNICK ) ) )
endif
endif
if !empty( cOldHelp )
SET HELPFILE TO cOldHelp
endif
Return .T.
Function SHG_DisplayHelpTopic( xTopic , nMet )
LOCAL LOC_cParam := ""
If empty( GetActiveHelpFile() )
Return .F.
endif
_HMG_nTopic := xTopic
_HMG_nMet := nMet
if valtype(nMet) == 'U'
nMet := 0
endif
If Right( Alltrim( Upper( GetActiveHelpFile() ) ) , 4 ) == '.CHM'
If ValType( xTopic ) == 'N'
LOC_cParam := "-mapid " + LTrim( Str( xTopic )) + " " + GetActiveHelpFile()
ElseIf ValType( xTopic ) == 'C'
LOC_cParam := '"' + GetActiveHelpFile() + "::/" + AllTrim( xTopic ) + '.htm"'
ElseIf ValType( xTopic ) == 'U'
LOC_cParam := '"' + GetActiveHelpFile() + '"'
EndIf
QPM_Execute( "HH.exe" , LOC_cParam )
Else
If ValType( xTopic ) == 'U'
xTopic := 0
EndIf
WinHelp( _HMG_MainHandle , GetActiveHelpFile() , 1 , nMet , xTopic )
EndIf
Return .T.
Function SHG_Toggle()
if GetProperty( "VentanaMain" , "GHlpFiles" , "ItemCount" ) < 1
Return .F.
endif
if GetProperty( "VentanaMain" , "GHlpFiles" , "Value" ) < 1
MyMsgInfo( "Topic not selected." )
Return .F.
endif
if GetProperty( "VentanaMain" , "GHlpFiles" , "Value" ) == 1
MyMsgInfo( "Global footer can't be toggled!" )
Return .F.
endif
if GetProperty( "VentanaMain" , "GHlpFiles" , "Value" ) == 2
MyMsgInfo( "Welcome page can't be toggled!" )
Return .F.
endif
if GridImage( "VentanaMain" , "GHlpFiles" , GetProperty( "VentanaMain" , "GHlpFiles" , "Value" ) , NCOLHLPSTATUS , "?" , PUB_nGridImgHlpBook )
GridImage( "VentanaMain" , "GHlpFiles" , GetProperty( "VentanaMain" , "GHlpFiles" , "Value" ) , NCOLHLPSTATUS , "-" , PUB_nGridImgHlpBook )
GridImage( "VentanaMain" , "GHlpFiles" , GetProperty( "VentanaMain" , "GHlpFiles" , "Value" ) , NCOLHLPSTATUS , "+" , PUB_nGridImgHlpPage )
SHG_SetField( "SHG_TYPET" , GetProperty( "VentanaMain" , "GHlpFiles" , "Value" ) , "P" )
else
GridImage( "VentanaMain" , "GHlpFiles" , GetProperty( "VentanaMain" , "GHlpFiles" , "Value" ) , NCOLHLPSTATUS , "-" , PUB_nGridImgHlpPage )
GridImage( "VentanaMain" , "GHlpFiles" , GetProperty( "VentanaMain" , "GHlpFiles" , "Value" ) , NCOLHLPSTATUS , "+" , PUB_nGridImgHlpBook )
SHG_SetField( "SHG_TYPET" , GetProperty( "VentanaMain" , "GHlpFiles" , "Value" ) , "B" )
endif
// if GetProperty( "VentanaMain" , "GHlpFiles" , "Cell" , GetProperty( "VentanaMain" , "GHlpFiles" , "Value" ) , NCOLHLPSTATUS ) == 1
// SetProperty( "VentanaMain" , "GHlpFiles" , "Cell" , GetProperty( "VentanaMain" , "GHlpFiles" , "Value" ) , NCOLHLPSTATUS , 2 )
// SHG_SetField( "SHG_TYPET" , GetProperty( "VentanaMain" , "GHlpFiles" , "Value" ) , "P" )
// else
// SetProperty( "VentanaMain" , "GHlpFiles" , "Cell" , GetProperty( "VentanaMain" , "GHlpFiles" , "Value" ) , NCOLHLPSTATUS , 1 )
// SHG_SetField( "SHG_TYPET" , GetProperty( "VentanaMain" , "GHlpFiles" , "Value" ) , "B" )
// endif
Return .T.
Function SHG_NewSecuence()
Local nInx := 0
US_Use( .T. , , SHG_Database , "SHG" , DEF_DBF_EXCLUSIVE , DEF_DBF_WRITE )
DBSetIndex( US_FileNameOnlyPathAndName( SHG_Database ) )
DBGoTop()
do while !eof()
nInx++
REPLACE SHG_ORDER WITH nInx
DBSkip()
enddo
DBCloseArea( "SHG" )
DO EVENTS
// US_Use( .T. , , SHG_Database , "SHG" , DEF_DBF_EXCLUSIVE , DEF_DBF_WRITE )
// DBGoTop()
// do while !eof()
// DO EVENTS
// REPLACE SHG_ORDER WITH SHG_ORDERT
// DBSkip()
// enddo
// DBGoTop()
// SHG_IndexON( SHG_Database )
// DBCloseArea( "SHG" )
Return .T.
Function SHG_LoadDatabase( cDataBase )
Local cAux, vStructure
SetMGWaitTxt( "Loading Help Database ..." )
if US_IsDBF( cDataBase ) != 0
MyMsgInfo( "Error open QPM Help Generator Database: " + cDataBase + HB_OsNewLine() + "Look at " + PageHlp )
SHG_BaseOK := .F.
else
if Upper( US_FileNameOnlyExt( cDatabase ) ) != "DBF"
MyMsgInfo( "Error open QPM Help Generator Database: " + cDataBase + HB_OsNewLine() + "Bad extension." )
SHG_BaseOK := .F.
endif
if upper( right( US_FileNameOnlyName( cDatabase ) , 4 ) ) != "_SHG"
MyMsgInfo( "Error open QPM Help Generator Database: " + cDataBase + HB_OsNewLine() + "Bad Name, not _SHG suffix into database name." )
SHG_BaseOK := .F.
endif
if file( US_FileNameOnlyPathAndName( cDatabase ) + ".dbt" )
SetMGWaitTxt( "Converting SHG Database to DBFCDX Driver..." )
if !US_DBConvert( cDatabase , US_FileNameOnlyPathAndName( cDatabase ) + "_" + PUB_cSecu + ".dbf" , "DBFNTX" , "DBFCDX" )
US_Log( "Error converting SHG database to DBFCDX Driver" )
else
ferase( cDatabase )
ferase( US_FileNameOnlyPathAndName( cDatabase ) + ".dbt" )
ferase( US_FileNameOnlyPathAndName( cDatabase ) + ".ntx" )
if frename( US_FileNameOnlyPathAndName( cDatabase ) + "_" + PUB_cSecu + ".dbf" , cDatabase ) < 0
US_Log( "Error renaming SHG Database '"+ US_FileNameOnlyPathAndName( cDatabase ) + "_" + PUB_cSecu + ".dbf" + "' in Migration process, ferror: " + US_VarToStr( fError() ) )
else
if frename( US_FileNameOnlyPathAndName( cDatabase ) + "_" + PUB_cSecu + ".fpt" , US_FileNameOnlyPathAndName( cDatabase ) + ".fpt" ) < 0
US_Log( "Error renaming SHG Database '" + US_FileNameOnlyPathAndName( cDatabase ) + "_" + PUB_cSecu + ".fpt" + "' in Migration process, ferror: " + US_VarToStr( fError() ) )
// else
// SHG_IndexON( cDatabase )
endif
endif
endif
endif
SetMGWaitTxt( "Packing Help Database ..." )
US_Use( .T. , , cDataBase , "SHG" , DEF_DBF_EXCLUSIVE , DEF_DBF_WRITE )
vStructure := DBStruct()
if ascan( vStructure , {|aval| aval[1] == "SHG_NICK" } ) == 0
DBCloseArea( "SHG" )
US_DB_CMP( US_FileNameOnlyPathAndName( cDataBase ) , "ADD" , "SHG_NICK" , "C" , 255 , 0 )
US_DB_CMP( US_FileNameOnlyPathAndName( cDataBase ) , "ADD" , "SHG_NICKT" , "C" , 255 , 0 )
US_Use( .T. , , cDataBase , "SHG" , DEF_DBF_EXCLUSIVE , DEF_DBF_WRITE )