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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
|
// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
/* This file is part of the KDE project
Copyright (C) 1998, 1999 Reginald Stadlbauer <[email protected]>
Copyright 2001, 2002 Nicolas GOUTTE <[email protected]>
Copyright 2002 Ariya Hidayat <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KPrWebPresentation.h"
#include "KPrView.h"
#include "KPrDocument.h"
#include "KPrCanvas.h"
#include "KPrPage.h"
#include <kstandarddirs.h>
#include <unistd.h>
#include <sys/types.h>
#include <ktempfile.h>
#include <tqfile.h>
#include <tqtextstream.h>
#include <tqvbox.h>
#include <tqhbox.h>
#include <tqlabel.h>
#include <tqpushbutton.h>
#include <tqfileinfo.h>
#include <tqframe.h>
#include <tqfont.h>
#include <tqpixmap.h>
#include <tqdatetime.h>
#include <tqdir.h>
#include <tqheader.h>
#include <tqwmatrix.h>
#include <tqtextcodec.h>
#include <tqregexp.h>
#include <tqimage.h>
#include <tqlayout.h>
#include <tqwhatsthis.h>
#include <tqcheckbox.h>
#include <kdebug.h>
#include <klocale.h>
#include <kcolorbutton.h>
#include <tdefiledialog.h>
#include <kmessagebox.h>
#include <kbuttonbox.h>
#include <ksimpleconfig.h>
#include <kapplication.h>
#include <kprogress.h>
#include <kglobal.h>
#include <kglobalsettings.h>
#include <kcharsets.h>
#include <kurlrequester.h>
#include <klineedit.h>
#include <klistview.h>
#include <knuminput.h>
#include <kcombobox.h>
#include <kurl.h>
#include <tdeio/netaccess.h>
#include <kdialog.h>
#include "KoDocumentInfo.h"
// Comes from koffice/filters/libexport/KWEFUtils.cc
static TQString EscapeSgmlText(const TQTextCodec* codec, const TQString& strIn,
const bool quot = false , const bool apos = false )
{
TQString strReturn;
TQChar ch;
for (uint i=0; i<strIn.length(); i++)
{
ch=strIn[i];
switch (ch.unicode())
{
case 38: // &
{
strReturn+="&";
break;
}
case 60: // <
{
strReturn+="<";
break;
}
case 62: // >
{
strReturn+=">";
break;
}
case 34: // "
{
if (quot)
strReturn+=""";
else
strReturn+=ch;
break;
}
case 39: // '
{
// NOTE: HTML does not define ' by default (only XML/XHTML does)
if (apos)
strReturn+="'";
else
strReturn+=ch;
break;
}
default:
{
// verify that the character ch can be expressed in the
// encoding in which we will write the HTML file.
if (codec)
{
if (!codec->canEncode(ch))
{
strReturn+=TQString("&#%1;").arg(ch.unicode());
break;
}
}
strReturn+=ch;
break;
}
}
}
return strReturn;
}
// Escape only if the encoding do not support the character
// Special SGML characters like < > & are supposed to be already escaped.
static TQString EscapeEncodingOnly(const TQTextCodec* codec, const TQString& strIn)
{
TQString strReturn;
TQChar ch;
for (uint i=0; i<strIn.length(); i++)
{
ch=strIn[i];
if (codec)
{
if (!codec->canEncode(ch))
{
strReturn+=TQString("&#%1;").arg(ch.unicode());
continue;
}
}
strReturn+=ch;
}
return strReturn;
}
KPrWebPresentation::KPrWebPresentation( KPrDocument *_doc, KPrView *_view )
: config( TQString() ), xml( false )
{
doc = _doc;
view = _view;
init();
}
KPrWebPresentation::KPrWebPresentation( const TQString &_config, KPrDocument *_doc, KPrView *_view )
: config( _config ), xml( false ), m_bWriteHeader( true ), m_bWriteFooter( true ), m_bLoopSlides( false )
{
doc = _doc;
view = _view;
init();
loadConfig();
}
KPrWebPresentation::KPrWebPresentation( const KPrWebPresentation &webPres )
: config( webPres.config ), author( webPres.author ), title( webPres.title ), email( webPres.email ),
slideInfos( webPres.slideInfos ), backColor( webPres.backColor ), titleColor( webPres.titleColor ),
textColor( webPres.textColor ), path( webPres.path ), xml( webPres.xml),
m_bWriteHeader( webPres.m_bWriteHeader ),
m_bWriteFooter( webPres.m_bWriteFooter ), m_bLoopSlides( webPres.m_bLoopSlides ),
timeBetweenSlides ( webPres.timeBetweenSlides ), zoom( webPres.zoom ), m_encoding( webPres.m_encoding )
{
doc = webPres.doc;
view = webPres.view;
}
void KPrWebPresentation::loadConfig()
{
if ( config.isEmpty() )
return;
KSimpleConfig cfg( config );
cfg.setGroup( "General" );
author = cfg.readEntry( "Author", author );
title = cfg.readEntry( "Title", title );
email = cfg.readEntry( "EMail", email );
unsigned int num = cfg.readNumEntry( "Slides", slideInfos.count() );
//kdDebug(33001) << "KPrWebPresentation::loadConfig num=" << num << endl;
if ( num <= slideInfos.count() ) {
for ( unsigned int i = 0; i < num; i++ )
{
TQString key = TQString::fromLatin1( "SlideTitle%1" ).arg( i );
if ( cfg.hasKey( key ) )
{
// We'll assume that the selected pages haven't changed... Hmm.
slideInfos[ i ].slideTitle = cfg.readEntry( key );
kdDebug(33001) << "KPrWebPresentation::loadConfig key=" << key << " data=" << slideInfos[i].slideTitle << endl;
} else kdDebug(33001) << " key not found " << key << endl;
}
}
backColor = cfg.readColorEntry( "BackColor", &backColor );
titleColor = cfg.readColorEntry( "TitleColor", &titleColor );
textColor = cfg.readColorEntry( "TextColor", &textColor );
path = cfg.readPathEntry( "Path", path );
xml = cfg.readBoolEntry( "XML", xml );
m_bWriteHeader = cfg.readBoolEntry( "WriteHeader", m_bWriteHeader );
m_bWriteFooter = cfg.readBoolEntry( "WriteFooter", m_bWriteFooter );
m_bLoopSlides = cfg.readBoolEntry( "LoopSlides", m_bLoopSlides );
zoom = cfg.readNumEntry( "Zoom", zoom );
timeBetweenSlides = cfg.readNumEntry("TimeBetweenSlides", timeBetweenSlides );
m_encoding = cfg.readEntry( "Encoding", m_encoding );
}
void KPrWebPresentation::saveConfig()
{
KSimpleConfig cfg( config );
cfg.setGroup( "General" );
cfg.writeEntry( "Author", author );
cfg.writeEntry( "Title", title );
cfg.writeEntry( "EMail", email );
cfg.writeEntry( "Slides", slideInfos.count() );
for ( unsigned int i = 0; i < slideInfos.count(); i++ )
cfg.writeEntry( TQString::fromLatin1( "SlideTitle%1" ).arg( i ), slideInfos[ i ].slideTitle );
cfg.writeEntry( "BackColor", backColor );
cfg.writeEntry( "TitleColor", titleColor );
cfg.writeEntry( "TextColor", textColor );
#if KDE_IS_VERSION(3,1,3)
cfg.writePathEntry( "Path", path );
#else
cfg.writeEntry( "Path", path );
#endif
cfg.writeEntry( "XML", xml );
cfg.writeEntry( "WriteHeader", m_bWriteHeader );
cfg.writeEntry( "WriteFooter", m_bWriteFooter );
cfg.writeEntry( "LoopSlides", m_bLoopSlides );
cfg.writeEntry( "Zoom", zoom );
cfg.writeEntry( "TimeBetweenSlides", timeBetweenSlides );
cfg.writeEntry( "Encoding", m_encoding );
}
void KPrWebPresentation::initCreation( KProgress *progressBar )
{
TQString cmd;
int p;
KURL str( path + "/html" );
TDEIO::NetAccess::mkdir( str,( TQWidget* )0L );
p = progressBar->progress();
progressBar->setProgress( ++p );
kapp->processEvents();
str = path + "/pics";
TDEIO::NetAccess::mkdir( str,( TQWidget* )0L );
p = progressBar->progress();
progressBar->setProgress( ++p );
kapp->processEvents();
const char *pics[] = { "home", "first", "next", "prev", "last", 0 };
KURL srcurl, desturl;
for ( uint index = 0; pics[ index ]; index ++ )
{
TQString filename = pics[ index ];
filename += ".png";
srcurl.setPath( locate( "slideshow", filename, KPrFactory::global() ) );
desturl = path;
desturl.addPath( "/pics/" + filename );
TDEIO::NetAccess::file_copy( srcurl, desturl, -1, true /*overwrite*/);
p = progressBar->progress();
progressBar->setProgress( ++p );
kapp->processEvents();
}
}
void KPrWebPresentation::createSlidesPictures( KProgress *progressBar )
{
if ( slideInfos.isEmpty() )
return;
TQPixmap pix( 10, 10 );
TQString filename;
int p;
for ( unsigned int i = 0; i < slideInfos.count(); i++ ) {
int pgNum = slideInfos[i].pageNumber;
view->getCanvas()->drawPageInPix( pix, pgNum, zoom, true /*force real variable value*/ );
filename = TQString( "%1/pics/slide_%2.png" ).arg( path ).arg( i + 1 );
KTempFile tmp;
pix.save( tmp.name(), "PNG" );
TDEIO::NetAccess::file_move( tmp.name(), filename, -1, true /*overwrite*/);
p = progressBar->progress();
progressBar->setProgress( ++p );
kapp->processEvents();
}
}
TQString KPrWebPresentation::escapeHtmlText( TQTextCodec *codec, const TQString& strText ) const
{
// Escape quotes (needed in attributes)
// Do not escape apostrophs (only allowed in XHTML!)
return EscapeSgmlText( codec, strText, true, false );
}
void KPrWebPresentation::writeStartOfHeader(TQTextStream& streamOut, TQTextCodec *codec, const TQString& subtitle, const TQString& next)
{
TQString mimeName ( codec->mimeName() );
if ( isXML() )
{ //Write out the XML declaration
streamOut << "<?xml version=\"1.0\" encoding=\""
<< mimeName << "\"?>\n";
}
// write <!DOCTYPE
streamOut << "<!DOCTYPE ";
if ( isXML() )
{
streamOut << "html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"";
streamOut << " \"DTD/xhtml1-transitional.dtd\">\n";
}
else
{
streamOut << "HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"";
streamOut << " \"http://www.w3.org/TR/html4/loose.dtd\">\n";
}
streamOut << "<html";
if ( isXML() )
{
// XHTML has an extra attribute defining its namespace (in the <html> opening tag)
streamOut << " xmlns=\"http://www.w3.org/1999/xhtml\"";
}
streamOut << ">\n" << "<head>\n";
// Declare what charset we are using
streamOut << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=";
streamOut << mimeName << '"' << ( isXML() ?" /":"") << ">\n" ;
// Tell who we are (with the CVS revision number) in case we have a bug in our output!
TQString strVersion("$Revision: 508787 $");
// Eliminate the dollar signs
// (We don't want that the version number changes if the HTML file is itself put in a CVS storage.)
streamOut << "<meta name=\"Generator\" content=\"KPresenter's Web Presentation "
<< strVersion.mid(10).replace("$","")
<< "\""<< ( isXML() ?" /":"") // X(HT)ML closes empty elements, HTML not!
<< ">\n";
// Load the next slide after time elapsed
if ( (timeBetweenSlides > 0) && ( ! next.isNull() ) )
{
streamOut << "<meta http-equiv=\"refresh\" content=\""
<< timeBetweenSlides
<< ";url=" << next
<< "\">\n";
}
streamOut << "<title>"<< escapeHtmlText( codec, title ) << " - " << escapeHtmlText( codec, subtitle ) << "</title>\n";
// ### TODO: transform documentinfo.xml into many <META> elements (at least the author!)
}
void KPrWebPresentation::createSlidesHTML( KProgress *progressBar )
{
TQTextCodec *codec = TDEGlobal::charsets()->codecForName( m_encoding );
const TQString brtag ( "<br" + TQString(isXML()?" /":"") + ">" );
for ( unsigned int i = 0; i < slideInfos.count(); i++ ) {
unsigned int pgNum = i + 1; // pgquiles # elpauer . org - I think this is a bug, seems to be an overflow if we have max_unsigned_int slides
KTempFile tmp;
TQString dest= TQString( "%1/html/slide_%2.html" ).arg( path ).arg( pgNum );
TQString next= TQString( "slide_%2.html" ).arg( pgNum<slideInfos.count() ? pgNum+1 : (m_bLoopSlides ? 1 : pgNum ) ); // Ugly, but it works
TQFile file( tmp.name() );
file.open( IO_WriteOnly );
TQTextStream streamOut( &file );
streamOut.setCodec( codec );
writeStartOfHeader( streamOut, codec, slideInfos[ i ].slideTitle, next );
// ### TODO: transform documentinfo.xml into many <META> elements (at least the author!)
if ( i > 0 ) {
streamOut << "<link rel=\"first\" href=\"slide_1.html\"" << ( isXML() ?" /":"") << ">\n";
streamOut << "<link rel=\"prev\" href=\"slide_" << pgNum - 1 << ".html\"" << ( isXML() ?" /":"") << ">\n";
}
if ( i < slideInfos.count() - 1 ) {
streamOut << "<link rel=\"next\" href=\"slide_" << pgNum + 1 << ".html\"" << ( isXML() ?" /":"") << ">\n";
streamOut << "<link rel=\"last\" href=\"slide_" << slideInfos.count() << ".html\"" << ( isXML() ?" /":"") << ">\n";
}
streamOut << "<link rel=\"contents\" href=\"../index.html\"" << ( isXML() ?" /":"") << ">\n";
streamOut << "</head>\n";
streamOut << "<body bgcolor=\"" << backColor.name() << "\" text=\"" << textColor.name() << "\">\n";
if (m_bWriteHeader) {
streamOut << " <center>\n";
if ( i > 0 )
streamOut << " <a href=\"slide_1.html\">";
streamOut << "<img src=\"../pics/first.png\" border=\"0\" alt=\"" << i18n( "First" )
<< "\" title=\"" << i18n( "First" ) << "\"" << ( isXML() ?" /":"") << ">";
if ( i > 0 )
streamOut << "</a>";
streamOut << "\n";
if ( i > 0 )
streamOut << " <a href=\"slide_" << pgNum - 1 << ".html\">";
streamOut << "<img src=\"../pics/prev.png\" border=\"0\" alt=\"" << i18n( "Previous" )
<< "\" title=\"" << i18n( "Previous" ) << "\"" << ( isXML() ?" /":"") << ">";
if ( i > 0 )
streamOut << "</a>";
streamOut << "\n";
if ( (m_bLoopSlides) || (i < slideInfos.count() - 1 ) )
streamOut << " <a href=\"" << next << "\">";
streamOut << "<img src=\"../pics/next.png\" border=\"0\" alt=\"" << i18n( "Next" )
<< "\" title=\"" << i18n( "Next" ) << "\"" << ( isXML() ?" /":"") << ">";
if ( (m_bLoopSlides) || (i < slideInfos.count() - 1 ) )
streamOut << "</a>";
streamOut << "\n";
if ( i < slideInfos.count() - 1 )
streamOut << " <a href=\"slide_" << slideInfos.count() << ".html\">";
streamOut << "<img src=\"../pics/last.png\" border=\"0\" alt=\"" << i18n( "Last" )
<< "\" title=\"" << i18n( "Last" ) << "\"" << ( isXML() ?" /":"") << ">";
if ( i < slideInfos.count() - 1 )
streamOut << "</a>";
streamOut << "\n" << " \n";
streamOut << " <a href=\"../index.html\">";
streamOut << "<img src=\"../pics/home.png\" border=\"0\" alt=\"" << i18n( "Home" )
<< "\" title=\"" << i18n( "Home" ) << "\"" << ( isXML() ?" /":"") << ">";
streamOut << "</a>\n";
streamOut << " </center>" << brtag << "<hr noshade=\"noshade\"" << ( isXML() ?" /":"") << ">\n"; // ### TODO: is noshade W3C?
streamOut << " <center>\n <font color=\"" << escapeHtmlText( codec, titleColor.name() ) << "\">\n";
streamOut << " <b>" << escapeHtmlText( codec, title ) << "</b> - <i>" << escapeHtmlText( codec, slideInfos[ i ].slideTitle ) << "</i>\n";
streamOut << " </font>\n </center>\n";
streamOut << "<hr noshade=\"noshade\"" << ( isXML() ?" /":"") << ">" << brtag << "\n";
}
streamOut << " <center>\n ";
if ( (m_bLoopSlides) || (i < slideInfos.count() - 1) )
streamOut << "<a href=\"" << next << "\">";
streamOut << "<img src=\"../pics/slide_" << pgNum << ".png\" border=\"0\" alt=\""
<< i18n( "Slide %1" ).arg( pgNum ) << "\"" << ( isXML() ?" /":"") << ">";
if ( i < slideInfos.count() - 1 )
streamOut << "</a>";
streamOut << "\n";
streamOut << " </center>\n";
if (m_bWriteFooter) {
streamOut << brtag << "<hr noshade=\"noshade\"" << ( isXML() ?" /":"") << ">\n";
TQPtrList<KPrPage> _tmpList( doc->getPageList() );
TQString note ( escapeHtmlText( codec, _tmpList.at(i)->noteText() ) );
if ( !note.isEmpty() ) {
streamOut << " <b>" << escapeHtmlText( codec, i18n( "Note" ) ) << "</b>\n";
streamOut << " <blockquote>\n";
streamOut << note.replace( "\n", brtag );
streamOut << " </blockquote><hr noshade=\"noshade\"" << ( isXML() ?" /":"") << ">\n";
}
streamOut << " <center>\n";
TQString htmlAuthor;
if (email.isEmpty())
htmlAuthor=escapeHtmlText( codec, author );
else
htmlAuthor=TQString("<a href=\"mailto:%1\">%2</a>").arg( escapeHtmlText( codec, email )).arg( escapeHtmlText( codec, author ));
streamOut << EscapeEncodingOnly ( codec, i18n( "Created on %1 by <i>%2</i> with <a href=\"http://www.koffice.org/kpresenter\">KPresenter</a>" )
.arg( TDEGlobal::locale()->formatDate ( TQDate::currentDate() ) ).arg( htmlAuthor ) );
streamOut << " </center><hr noshade=\"noshade\"" << ( isXML() ?" /":"") << ">\n";
}
streamOut << "</body>\n</html>\n";
file.close();
TDEIO::NetAccess::file_move( tmp.name(), dest, -1, true /*overwrite*/);
int p = progressBar->progress();
progressBar->setProgress( ++p );
kapp->processEvents();
}
}
void KPrWebPresentation::createMainPage( KProgress *progressBar )
{
TQTextCodec *codec = TDEGlobal::charsets()->codecForName( m_encoding );
KTempFile tmp;
TQString dest = TQString( "%1/index.html" ).arg( path );
TQFile file( tmp.name() );
file.open( IO_WriteOnly );
TQTextStream streamOut( &file );
streamOut.setCodec( codec );
writeStartOfHeader( streamOut, codec, i18n("Table of Contents"), TQString() );
streamOut << "</head>\n";
streamOut << "<body bgcolor=\"" << backColor.name() << "\" text=\"" << textColor.name() << "\">\n";
streamOut << "<h1 align=\"center\"><font color=\"" << titleColor.name()
<< "\">" << title << "</font></h1>";
streamOut << "<p align=\"center\"><a href=\"html/slide_1.html\">";
streamOut << i18n("Click here to start the Slideshow");
streamOut << "</a></p>\n";
streamOut << "<p><b>" << i18n("Table of Contents") << "</b></p>\n";
// create list of slides (with proper link)
streamOut << "<ol>\n";
for ( unsigned int i = 0; i < slideInfos.count(); i++ )
streamOut << " <li><a href=\"html/slide_" << i+1 << ".html\">" << slideInfos[ i ].slideTitle << "</a></li>\n";
streamOut << "</ol>\n";
// footer: author name, e-mail
TQString htmlAuthor = email.isEmpty() ? escapeHtmlText( codec, author ) :
TQString("<a href=\"mailto:%1\">%2</a>").arg( escapeHtmlText( codec, email )).arg( escapeHtmlText( codec, author ));
streamOut << EscapeEncodingOnly ( codec, i18n( "Created on %1 by <i>%2</i> with <a href=\"http://www.koffice.org/kpresenter\">KPresenter</a>" )
.arg( TDEGlobal::locale()->formatDate ( TQDate::currentDate() ) ).arg( htmlAuthor ) );
streamOut << "</body>\n</html>\n";
file.close();
TDEIO::NetAccess::file_move( tmp.name(), dest, -1, true /*overwrite*/);
progressBar->setProgress( progressBar->totalSteps() );
kapp->processEvents();
}
void KPrWebPresentation::init()
{
KoDocumentInfo * info = doc->documentInfo();
KoDocumentInfoAuthor * authorPage = static_cast<KoDocumentInfoAuthor *>(info->page( "author" ));
if ( !authorPage )
kdWarning() << "Author information not found in documentInfo !" << endl;
else
{
author = authorPage->fullName();
email = authorPage->email();
}
title = i18n("Slideshow");
kdDebug(33001) << "KPrWebPresentation::init : " << doc->getPageNums() << " pages." << endl;
for ( unsigned int i = 0; i < doc->getPageNums(); i++ )
{
if ( doc->isSlideSelected( i ) )
{
SlideInfo info;
info.pageNumber = i;
info.slideTitle = doc->pageList().at(i)->pageTitle();
slideInfos.append( info );
}
}
if ( slideInfos.isEmpty() )
kdWarning() << "No slides selected!" << endl;
backColor = TQt::white;
textColor = TQt::black;
titleColor = TQt::red;
path = TDEGlobalSettings::documentPath() + "www";
zoom = 100;
timeBetweenSlides = 0;
m_encoding = TQTextCodec::codecForLocale()->name();
}
KPrWebPresentationWizard::KPrWebPresentationWizard( const TQString &_config, KPrDocument *_doc,
KPrView *_view )
: KWizard( 0, "", false ), config( _config ), webPres( config, _doc, _view )
{
doc = _doc;
view = _view;
setupPage1();
setupPage2();
setupPage3();
setupPage4();
setupPage5();
connect( nextButton(), TQT_SIGNAL( clicked() ), this, TQT_SLOT( pageChanged() ) );
connect( backButton(), TQT_SIGNAL( clicked() ), this, TQT_SLOT( pageChanged() ) );
connect( finishButton(), TQT_SIGNAL( clicked() ), this, TQT_SLOT( finish() ) );
}
KPrWebPresentationWizard::~KPrWebPresentationWizard()
{
view->enableWebPres();
}
void KPrWebPresentationWizard::createWebPresentation( const TQString &_config, KPrDocument *_doc,
KPrView *_view )
{
KPrWebPresentationWizard *dlg = new KPrWebPresentationWizard( _config, _doc, _view );
dlg->setCaption( i18n( "Create HTML Slideshow Wizard" ) );
dlg->show();
}
void KPrWebPresentationWizard::setupPage1()
{
page1 = new TQHBox( this );
TQWhatsThis::add( page1, i18n("This page allows you to specify some of the key"
" values for how your presentation will be shown"
" in HTML. Select individual items for more help"
" on what they do.") );
page1->setSpacing( KDialog::spacingHint() );
page1->setMargin( KDialog::marginHint() );
TQLabel* sidebar = new TQLabel( page1 );
sidebar->setMinimumSize( 106, 318 );
sidebar->setMaximumSize( 106, 318 );
sidebar->setFrameShape( TQFrame::Panel );
sidebar->setFrameShadow( TQFrame::Sunken );
sidebar->setPixmap(locate("data", "kpresenter/pics/webslideshow-sidebar.png"));
TQWidget* canvas = new TQWidget( page1 );
TQGridLayout *layout = new TQGridLayout( canvas, 7, 2,
KDialog::marginHint(), KDialog::spacingHint() );
TQLabel *helptext = new TQLabel( canvas );
helptext->setAlignment( TQt::WordBreak | TQt::AlignTop| TQt::AlignLeft );
helptext->setText( i18n( "Enter your name, email address and "
"the title of the web presentation. "
"Also enter the output directory where the "
"web presentation should be saved. " ) );
layout->addMultiCellWidget( helptext, 0, 0, 0, 1 );
layout->addMultiCell( new TQSpacerItem( 1, 50 ), 1, 1, 0, 1 );
TQLabel *label1 = new TQLabel( i18n("Author:"), canvas );
label1->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
TQWhatsThis::add( label1, i18n("This is where you enter the name of the person or "
"organization that should be named as the author of "
"the presentation.") );
layout->addWidget( label1, 2, 0 );
TQLabel *label2 = new TQLabel( i18n("Title:"), canvas );
label2->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
TQWhatsThis::add( label2, i18n("This is where you enter the title of the overall "
"presentation." ) );
layout->addWidget( label2, 3, 0 );
TQLabel *label3 = new TQLabel( i18n("Email address:"), canvas );
label3->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
TQWhatsThis::add( label3, i18n("This is where you enter the email address of the "
"person or organization that is responsible for "
"the presentation.") );
layout->addWidget( label3, 4, 0 );
TQLabel *label4 = new TQLabel( i18n("Path:"), canvas );
label4->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
TQWhatsThis::add( label4, i18n("The value entered for the path is the directory "
"where the presentation will be saved. If it does "
"not exist, you'll be asked if you want to create "
"the directory or abort the creation.") );
layout->addWidget( label4, 5, 0 );
author = new KLineEdit( webPres.getAuthor(), canvas );
TQWhatsThis::add( author, i18n("This is where you enter the name of the person or "
"organization that should be named as the author of "
"the presentation.") );
layout->addWidget( author, 2, 1 );
title = new KLineEdit( webPres.getTitle(), canvas );
TQWhatsThis::add( title, i18n("This is where you enter the title of the overall "
"presentation." ) );
layout->addWidget( title, 3, 1 );
email = new KLineEdit( webPres.getEmail(), canvas );
TQWhatsThis::add( email, i18n("This is where you enter the email address of the "
"person or organization that is responsible for "
"the presentation.") );
layout->addWidget( email, 4, 1 );
path=new KURLRequester( canvas );
path->setMode( KFile::Directory);
path->lineEdit()->setText(webPres.getPath());
TQWhatsThis::add( path, i18n("The value entered for the path is the directory "
"where the presentation will be saved. If it does "
"not exist, you'll be asked if you want to create "
"the directory or abort the creation.") );
layout->addWidget( path, 5, 1 );
TQSpacerItem* spacer = new TQSpacerItem( 1, 10,
TQSizePolicy::Minimum, TQSizePolicy::Expanding );
layout->addMultiCell( spacer, 6, 6, 0, 1 );
connect(path, TQT_SIGNAL(textChanged(const TQString&)),
this,TQT_SLOT(slotChoosePath(const TQString&)));
connect(path, TQT_SIGNAL(urlSelected( const TQString& )),
this,TQT_SLOT(slotChoosePath(const TQString&)));
addPage( page1, i18n( "Step 1: General Information" ) );
setHelpEnabled(page1, false); //doesn't do anything currently
}
void KPrWebPresentationWizard::setupPage2()
{
page2 = new TQHBox( this );
TQWhatsThis::add( page2, i18n("This page allows you to specify how the HTML "
"for your presentation will be displayed. Select "
"individual items for more help on what they do.") );
page2->setSpacing( KDialog::spacingHint() );
page2->setMargin( KDialog::marginHint() );
TQLabel* sidebar = new TQLabel( page2 );
sidebar->setMinimumSize( 106, 318 );
sidebar->setMaximumSize( 106, 318 );
sidebar->setFrameShape( TQFrame::Panel );
sidebar->setFrameShadow( TQFrame::Sunken );
sidebar->setPixmap(locate("data", "kpresenter/pics/webslideshow-sidebar.png"));
TQWidget* canvas = new TQWidget( page2 );
TQGridLayout *layout = new TQGridLayout( canvas, 6, 2,
KDialog::marginHint(), KDialog::spacingHint() );
TQLabel *helptext = new TQLabel( canvas );
helptext->setAlignment( TQt::WordBreak | TQt::AlignVCenter| TQt::AlignLeft );
TQString help = i18n("Here you can configure the style of the web pages.");
help += i18n( "You can also specify the zoom for the slides." );
helptext->setText(help);
layout->addMultiCellWidget( helptext, 0, 0, 0, 1 );
layout->addMultiCell( new TQSpacerItem( 1, 50 ), 1, 1, 0, 1 );
TQLabel *label1 = new TQLabel( i18n("Zoom:"), canvas );
label1->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
TQWhatsThis::add( label1, i18n( "This selection allows you to specify "
"the size of the slide image." ) );
layout->addWidget( label1, 2, 0 );
TQLabel *label2 = new TQLabel( i18n( "Encoding:" ), canvas );
label2->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
layout->addWidget( label2, 3, 0 );
TQLabel *label3 = new TQLabel( i18n( "Document type:" ), canvas );
label3->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
layout->addWidget( label3, 4, 0 );
zoom = new KIntNumInput( webPres.getZoom(), canvas );
TQWhatsThis::add( zoom, i18n( "This selection allows you to specify "
"the size of the slide image." ) );
layout->addWidget( zoom, 2, 1 );
zoom->setSuffix( " %" );
zoom->setRange( 25, 1000, 5 );
encoding = new KComboBox( false, canvas );
layout->addWidget( encoding, 3, 1 );
// Fill encoding combo
// Stolen from tdelibs/kate/part/katedialogs.cpp
TQStringList encodings(TDEGlobal::charsets()->descriptiveEncodingNames());
int idx = 0;
for (uint i = 0; i < encodings.count(); i++)
{
bool found = false;
TQTextCodec *codecForEnc = TDEGlobal::charsets()->codecForName(TDEGlobal::charsets()->encodingForName(encodings[i]), found);
if (found)
{
encoding->insertItem(encodings[i]);
if ( codecForEnc->name() == webPres.getEncoding() )
encoding->setCurrentItem(idx);
idx++;
}
}
doctype = new KComboBox( false, canvas );
layout->addWidget( doctype, 4, 1 );
doctype->insertItem( "HTML 4.01", -1 );
doctype->insertItem( "XHTML 1.0", -1 );
doctype->setCurrentItem( webPres.isXML() ? 1 : 0 );
TQSpacerItem* spacer = new TQSpacerItem( 1, 10,
TQSizePolicy::Minimum, TQSizePolicy::Expanding );
layout->addMultiCell( spacer, 5, 5, 0, 1 );
addPage( page2, i18n( "Step 2: Configure HTML" ) );
setHelpEnabled(page2, false); //doesn't do anything currently
}
void KPrWebPresentationWizard::setupPage3()
{
page3 = new TQHBox( this );
TQWhatsThis::add( page3, i18n("This page allows you to specify the colors for "
"your presentation display. Select individual "
"items for more help on what they do.") );
page3->setSpacing( KDialog::spacingHint() );
page3->setMargin( KDialog::marginHint() );
TQLabel* sidebar = new TQLabel( page3 );
sidebar->setMinimumSize( 106, 318 );
sidebar->setMaximumSize( 106, 318 );
sidebar->setFrameShape( TQFrame::Panel );
sidebar->setFrameShadow( TQFrame::Sunken );
sidebar->setPixmap(locate("data", "kpresenter/pics/webslideshow-sidebar.png"));
TQWidget* canvas = new TQWidget( page3 );
TQGridLayout *layout = new TQGridLayout( canvas, 6, 2,
KDialog::marginHint(), KDialog::spacingHint() );
TQLabel *helptext = new TQLabel( canvas );
helptext->setAlignment( TQt::WordBreak | TQt::AlignVCenter| TQt::AlignLeft );
helptext->setText( i18n( "Now you can customize the colors of the web pages." ) );
layout->addMultiCellWidget( helptext, 0, 0, 0, 1 );
layout->addMultiCell( new TQSpacerItem( 1, 50 ), 1, 1, 0, 1 );
TQLabel *label1 = new TQLabel( i18n("Text color:"), canvas );
label1->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
layout->addWidget( label1, 2, 0 );
TQLabel *label2 = new TQLabel( i18n("Title color:"), canvas );
label2->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
layout->addWidget( label2, 3, 0 );
TQLabel *label3 = new TQLabel( i18n("Background color:"), canvas );
label3->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
layout->addWidget( label3, 4, 0 );
textColor = new KColorButton( webPres.getTextColor(), canvas );
layout->addWidget( textColor, 2, 1 );
titleColor = new KColorButton( webPres.getTitleColor(), canvas );
layout->addWidget( titleColor, 3, 1 );
backColor = new KColorButton( webPres.getBackColor(), canvas );
layout->addWidget( backColor, 4, 1 );
TQSpacerItem* spacer = new TQSpacerItem( 1, 10,
TQSizePolicy::Minimum, TQSizePolicy::Expanding );
layout->addMultiCell( spacer, 5, 5, 0, 1 );
addPage( page3, i18n( "Step 3: Customize Colors" ) );
setHelpEnabled(page3, false); //doesn't do anything currently
}
void KPrWebPresentationWizard::setupPage4()
{
page4 = new TQHBox( this );
TQWhatsThis::add( page4, i18n("This page allows you to modify the titles of "
"each slide, if required. You normally do not need "
"to do this, but it is available if required.") );
page4->setSpacing( KDialog::spacingHint() );
page4->setMargin( KDialog::marginHint() );
TQLabel* sidebar = new TQLabel( page4 );
sidebar->setMinimumSize( 106, 318 );
sidebar->setMaximumSize( 106, 318 );
sidebar->setFrameShape( TQFrame::Panel );
sidebar->setFrameShadow( TQFrame::Sunken );
sidebar->setPixmap(locate("data", "kpresenter/pics/webslideshow-sidebar.png"));
TQWidget* canvas = new TQWidget( page4 );
TQGridLayout *layout = new TQGridLayout( canvas, 3, 2,
KDialog::marginHint(), KDialog::spacingHint() );
TQLabel *helptext = new TQLabel( canvas );
helptext->setAlignment( TQt::WordBreak | TQt::AlignVCenter| TQt::AlignLeft );
helptext->setText( i18n( "Here you can specify titles for "
"each slide. Click on a slide in "
"the list and then enter the title "
"in the textbox below. If you "
"click on a title, KPresenter "
"mainview will display the slide.") );
layout->addMultiCellWidget( helptext, 0, 0, 0, 1 );
TQLabel *label = new TQLabel( i18n( "Slide title:" ), canvas );
label->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
layout->addWidget( label, 1, 0 );
slideTitle = new KLineEdit( canvas );
layout->addWidget( slideTitle, 1, 1 );
connect( slideTitle, TQT_SIGNAL( textChanged( const TQString & ) ), this,
TQT_SLOT( slideTitleChanged( const TQString & ) ) );
slideTitles = new TDEListView( canvas );
layout->addMultiCellWidget( slideTitles, 2, 2, 0, 1 );
slideTitles->addColumn( i18n( "No." ) );
slideTitles->addColumn( i18n( "Slide Title" ) );
connect( slideTitles, TQT_SIGNAL( selectionChanged( TQListViewItem * ) ), this,
TQT_SLOT( slideTitleChanged( TQListViewItem * ) ) );
slideTitles->setSorting( -1 );
slideTitles->setAllColumnsShowFocus( true );
slideTitles->setResizeMode( TQListView::LastColumn );
slideTitles->header()->setMovingEnabled( false );
TQValueList<KPrWebPresentation::SlideInfo> infos = webPres.getSlideInfos();
for ( int i = infos.count() - 1; i >= 0; --i ) {
TDEListViewItem *item = new TDEListViewItem( slideTitles );
item->setText( 0, TQString::number( i + 1 ) );
//kdDebug(33001) << "KPrWebPresentationWizard::setupPage3 " << infos[ i ].slideTitle << endl;
item->setText( 1, infos[ i ].slideTitle );
}
slideTitles->setSelected( slideTitles->firstChild(), true );
addPage( page4, i18n( "Step 4: Customize Slide Titles" ) );
setHelpEnabled(page4, false); //doesn't do anything currently
}
void KPrWebPresentationWizard::setupPage5()
{
page5 = new TQHBox( this );
TQWhatsThis::add( page5, i18n("This page allows you to specify some options for "
"presentations which run unattended, such as time "
"elapsed before advancing to the next slide, looping "
"and the presence of headers. If you do not want "
"an unattended presentation, just leave defaults unchanged.") );
page5->setSpacing( KDialog::spacingHint() );
page5->setMargin( KDialog::marginHint() );
TQLabel* sidebar = new TQLabel( page5 );
sidebar->setMinimumSize( 106, 318 );
sidebar->setMaximumSize( 106, 318 );
sidebar->setFrameShape( TQFrame::Panel );
sidebar->setFrameShadow( TQFrame::Sunken );
sidebar->setPixmap(locate("data", "kpresenter/pics/webslideshow-sidebar.png"));
TQWidget* canvas = new TQWidget( page5 );
TQGridLayout *layout = new TQGridLayout( canvas, 6, 2,
KDialog::marginHint(), KDialog::spacingHint() );
TQLabel *helptext = new TQLabel( canvas );
helptext->setAlignment( TQt::WordBreak | TQt::AlignVCenter| TQt::AlignLeft );
TQString help = i18n("Here you can configure some options for unattended "
"presentations, such as time elapsed before automatically advance to "
"the next slide, looping and the presence of headers.");
helptext->setText(help);
layout->addMultiCellWidget( helptext, 0, 0, 0, 1 );
layout->addMultiCell( new TQSpacerItem( 1, 50 ), 1, 1, 0, 1 );
TQLabel *label1 = new TQLabel( i18n("Advance after:"), canvas );
label1->setAlignment( TQt::AlignVCenter | TQt::AlignRight );
TQWhatsThis::add( label1, i18n( "This selection allows you to specify "
"the time between slides." ) );
layout->addWidget( label1, 2, 0 );
timeBetweenSlides = new KIntNumInput( webPres.getTimeBetweenSlides(), canvas );
timeBetweenSlides->setSpecialValueText(i18n( "Disabled" ));
TQWhatsThis::add( timeBetweenSlides, i18n( "This selection allows you to specify "
"the time between slides." ) );
layout->addWidget( timeBetweenSlides, 2, 1 );
timeBetweenSlides->setSuffix( " seconds" );
timeBetweenSlides->setRange( 0, 900, 1 );
layout->addMultiCell( new TQSpacerItem( 1, 10 ), 1, 1, 0, 1 );
writeHeader=new TQCheckBox( i18n("Write header to the slides"), canvas);
TQWhatsThis::add( writeHeader, i18n( "This checkbox allows you to specify if you "
"want to write the navigation buttons on top "
"of the slide." ) );
writeHeader->setChecked( webPres.wantHeader() );
layout->addWidget( writeHeader, 3, 1);
writeFooter=new TQCheckBox( i18n("Write footer to the slides"), canvas);
TQWhatsThis::add( writeFooter, i18n( "This checkbox allows you to specify if you "
"want to write an imprint consisting on the author "
"and the software used to create these slides." ) );
writeFooter->setChecked( webPres.wantFooter() );
layout->addWidget( writeFooter, 4, 1);
loopSlides=new TQCheckBox( i18n("Loop presentation"), canvas);
TQWhatsThis::add( loopSlides, i18n( "This checkbox allows you to specify if you "
"want the presentation to start again once "
"the latest slide is reached." ) );
loopSlides->setChecked( webPres.wantLoopSlides() );
layout->addWidget( loopSlides, 5, 1);
TQSpacerItem* spacer = new TQSpacerItem( 1, 10,
TQSizePolicy::Minimum, TQSizePolicy::Expanding );
layout->addMultiCell( spacer, 5, 5, 0, 1 );
addPage( page5, i18n( "Step 5: Options for Unattended Presentations" ) );
setHelpEnabled(page5, false); //doesn't do anything currently
setFinish( page5, true );
}
void KPrWebPresentationWizard::finish()
{
webPres.setAuthor( author->text() );
webPres.setEMail( email->text() );
webPres.setTitle( title->text() );
TQListViewItemIterator it( slideTitles );
for ( ; it.current(); ++it )
webPres.setSlideTitle( it.current()->text( 0 ).toInt() - 1, it.current()->text( 1 ) );
webPres.setBackColor( backColor->color() );
webPres.setTitleColor( titleColor->color() );
webPres.setTextColor( textColor->color() );
webPres.setPath( path->lineEdit()->text() );
webPres.setZoom( zoom->value() );
webPres.setTimeBetweenSlides( timeBetweenSlides->value() );
webPres.setWriteHeader( writeHeader->isChecked() );
webPres.setWriteFooter( writeFooter->isChecked() );
webPres.setLoopSlides( loopSlides->isChecked() );
webPres.setXML( doctype->currentItem() != 0 );
bool found = false;
TQTextCodec *codecForEnc = TDEGlobal::charsets()->codecForName(TDEGlobal::charsets()->encodingForName(encoding->currentText()), found);
if ( found )
{
webPres.setEncoding( codecForEnc->name() );
}
close();
KPrWebPresentationCreateDialog::createWebPresentation( doc, view, webPres );
}
void KPrWebPresentationWizard::pageChanged()
{
if ( currentPage() != page5 )
{
TQString pathname = path->lineEdit()->text();
// path doesn't exist. ask user if it should be created.
if ( !TDEIO::NetAccess::exists( pathname, true/*write*/,this ) )
{
TQString msg = i18n( "<qt>The directory <b>%1</b> does not exist.<br>"
"Do you want create it?</qt>" );
if( KMessageBox::questionYesNo( this, msg.arg( pathname ),
i18n( "Directory Not Found" ) )
== KMessageBox::Yes)
{
bool ok = TDEIO::NetAccess::mkdir( pathname, this );
if( !ok )
{
KMessageBox::sorry( this,
i18n( "Cannot create directory." ) );
// go back to first step
showPage( page1 );
path->setFocus();
}
}
else
{
// go back to first step
showPage( page1 );
path->setFocus();
}
}
} else
finishButton()->setEnabled( true );
}
void KPrWebPresentationWizard::slideTitleChanged( const TQString &s )
{
if ( slideTitles->currentItem() )
slideTitles->currentItem()->setText( 1, s );
}
void KPrWebPresentationWizard::slideTitleChanged( TQListViewItem *i )
{
if ( !i ) return;
slideTitle->setText( i->text( 1 ) );
view->skipToPage( i->text( 0 ).toInt() - 1 );
}
void KPrWebPresentationWizard::closeEvent( TQCloseEvent *e )
{
view->enableWebPres();
KWizard::closeEvent( e );
}
void KPrWebPresentationWizard::slotChoosePath(const TQString &text)
{
webPres.setPath(text);
}
KPrWebPresentationCreateDialog::KPrWebPresentationCreateDialog( KPrDocument *_doc, KPrView *_view,
const KPrWebPresentation &_webPres )
: TQDialog( 0, "", false ), webPres( _webPres )
{
doc = _doc;
view = _view;
setupGUI();
}
KPrWebPresentationCreateDialog::~KPrWebPresentationCreateDialog()
{
view->enableWebPres();
}
void KPrWebPresentationCreateDialog::createWebPresentation( KPrDocument *_doc, KPrView *_view,
const KPrWebPresentation &_webPres )
{
KPrWebPresentationCreateDialog *dlg = new KPrWebPresentationCreateDialog( _doc, _view, _webPres );
dlg->setCaption( i18n( "Create HTML Slideshow" ) );
dlg->resize( 400, 300 );
dlg->show();
dlg->start();
}
void KPrWebPresentationCreateDialog::start()
{
setCursor( waitCursor );
initCreation();
createSlidesPictures();
createSlidesHTML();
createMainPage();
setCursor( arrowCursor );
bDone->setEnabled( true );
bSave->setEnabled( true );
}
void KPrWebPresentationCreateDialog::initCreation()
{
TQFont f = step1->font(), f2 = step1->font();
f.setBold( true );
step1->setFont( f );
progressBar->setProgress( 0 );
progressBar->setTotalSteps( webPres.initSteps() );
webPres.initCreation( progressBar );
step1->setFont( f2 );
progressBar->setProgress( progressBar->totalSteps() );
}
void KPrWebPresentationCreateDialog::createSlidesPictures()
{
TQFont f = step2->font(), f2 = f;
f.setBold( true );
step2->setFont( f );
progressBar->setProgress( 0 );
if ( webPres.slides1Steps() > 0 )
{
progressBar->setTotalSteps( webPres.slides1Steps() );
webPres.createSlidesPictures( progressBar );
}
step2->setFont( f2 );
progressBar->setProgress( progressBar->totalSteps() );
}
void KPrWebPresentationCreateDialog::createSlidesHTML()
{
TQFont f = step3->font(), f2 = step3->font();
f.setBold( true );
step3->setFont( f );
progressBar->setProgress( 0 );
if ( webPres.slides1Steps() > 0 )
{
progressBar->setTotalSteps( webPres.slides1Steps() );
webPres.createSlidesHTML( progressBar );
}
step3->setFont( f2 );
progressBar->setProgress( progressBar->totalSteps() );
}
void KPrWebPresentationCreateDialog::createMainPage()
{
TQFont f = step4->font(), f2 = step4->font();
f.setBold( true );
step4->setFont( f );
progressBar->setProgress( 0 );
progressBar->setTotalSteps( webPres.slides1Steps() );
webPres.createMainPage( progressBar );
step4->setFont( f2 );
progressBar->setProgress( progressBar->totalSteps() );
}
void KPrWebPresentationCreateDialog::setupGUI()
{
back = new TQVBox( this );
back->setMargin( KDialog::marginHint() );
TQFrame *line;
line = new TQFrame( back );
line->setFrameStyle( TQFrame::HLine | TQFrame::Sunken );
line->setMaximumHeight( 20 );
step1 = new TQLabel( i18n( "Initialize (create file structure, etc.)" ), back );
step2 = new TQLabel( i18n( "Create Pictures of the Slides" ), back );
step3 = new TQLabel( i18n( "Create HTML Pages for the Slides" ), back );
step4 = new TQLabel( i18n( "Create Main Page (Table of Contents)" ), back );
step5 = new TQLabel( i18n( "Options for Unattended Presentations" ), back);
line = new TQFrame( back );
line->setFrameStyle( TQFrame::HLine | TQFrame::Sunken );
line->setMaximumHeight( 20 );
progressBar = new KProgress( back );
line = new TQFrame( back );
line->setFrameStyle( TQFrame::HLine | TQFrame::Sunken );
line->setMaximumHeight( 20 );
KButtonBox *bb = new KButtonBox( back );
bSave = bb->addButton( i18n( "Save Configuration..." ) );
bb->addStretch();
bDone = bb->addButton( i18n( "Done" ) );
bSave->setEnabled( false );
bDone->setEnabled( false );
connect( bDone, TQT_SIGNAL( clicked() ), this, TQT_SLOT( accept() ) );
connect( bSave, TQT_SIGNAL( clicked() ), this, TQT_SLOT( saveConfig() ) );
}
void KPrWebPresentationCreateDialog::resizeEvent( TQResizeEvent *e )
{
TQDialog::resizeEvent( e );
back->resize( size() );
}
void KPrWebPresentationCreateDialog::saveConfig()
{
TQString filename = webPres.getConfig();
if ( TQFileInfo( filename ).exists() )
filename = TQFileInfo( filename ).absFilePath();
else
filename = TQString();
KFileDialog fd (filename, i18n("*.kpweb|KPresenter Web-Presentation (*.kpweb)"),
0/*parent*/, 0/*name*/, true/*modal*/);
fd.setCaption (i18n ("Save Web Presentation Configuration"));
fd.setOperationMode (KFileDialog::Saving);
fd.setMode (KFile::File | KFile::LocalOnly);
if (fd.exec ())
{
webPres.setConfig( fd.selectedFile () );
webPres.saveConfig();
}
}
#include "KPrGradient.h"
#include "KPrWebPresentation.moc"
|