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
|
// -*- 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 <reggie@kde.org>
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 "KPrDocumentIface.h"
#include "KPrTextObject.h"
#include "KPrDocument.h"
#include "KPrView.h"
#include "KPrPage.h"
#include <kapplication.h>
#include <dcopclient.h>
#include <KoVariable.h>
#include "KPrVariableCollection.h"
#include <KoAutoFormat.h>
KPrDocumentIface::KPrDocumentIface( KPrDocument *doc_ )
: KoDocumentIface( doc_ )
{
doc = doc_;
}
int KPrDocumentIface::numPages() const
{
return doc->getPageNums();
}
DCOPRef KPrDocumentIface::page( int num )
{
if( num>= (int )doc->getPageNums())
return DCOPRef();
return DCOPRef( kapp->dcopClient()->appId(),
doc->pageList().at( num )->dcopObject()->objId() );
}
DCOPRef KPrDocumentIface::masterPage()
{
return DCOPRef( kapp->dcopClient()->appId(),
doc->masterPage()->dcopObject()->objId() );
}
void KPrDocumentIface::setShowRuler(bool b)
{
doc->setShowRuler(b );
doc->reorganizeGUI();
}
bool KPrDocumentIface::showRuler() const
{
return doc->showRuler();
}
void KPrDocumentIface::recalcAllVariables()
{
//recalc all variable
doc->recalcVariables(VT_ALL);
}
void KPrDocumentIface::recalcVariables(int _var)
{
doc->recalcVariables(_var);
}
void KPrDocumentIface::recalcVariables(const QString &varName)
{
if(varName=="VT_DATE")
doc->recalcVariables(0);
else if(varName=="VT_TIME")
doc->recalcVariables(2);
else if(varName=="VT_PGNUM")
doc->recalcVariables(4);
else if(varName=="VT_CUSTOM")
doc->recalcVariables(6);
else if(varName=="VT_SERIALLETTER")
doc->recalcVariables(7);
else if(varName=="VT_FIELD")
doc->recalcVariables(8);
else if(varName=="VT_LINK")
doc->recalcVariables(9);
else if(varName=="VT_NOTE")
doc->recalcVariables(10);
else if(varName=="VT_ALL")
doc->recalcVariables(256);
}
int KPrDocumentIface::startingPage()
{
return doc->getVariableCollection()->variableSetting()->startingPageNumber();
}
void KPrDocumentIface::setStartingPage(int nb)
{
doc->getVariableCollection()->variableSetting()->setStartingPageNumber(nb);
doc->recalcVariables(VT_PGNUM);
}
bool KPrDocumentIface::displayLink() const
{
return doc->getVariableCollection()->variableSetting()->displayLink();
}
void KPrDocumentIface::setDisplayLink(bool b)
{
doc->getVariableCollection()->variableSetting()->setDisplayLink(b);
doc->recalcVariables(VT_LINK);
}
bool KPrDocumentIface::setCustomVariableValue(const QString & varname, const QString & value)
{
bool exist=doc->getVariableCollection()->customVariableExist(varname);
if(exist)
{
doc->getVariableCollection()->setVariableValue( varname, value );
doc->recalcVariables(VT_CUSTOM);
}
else
return false;
return true;
}
QString KPrDocumentIface::customVariableValue(const QString & varname)const
{
if(doc->getVariableCollection()->customVariableExist(varname))
return doc->getVariableCollection()->getVariableValue( varname );
return QString::null;
}
bool KPrDocumentIface::insertNewPage(int pos )
{
if( pos < 0 || pos > (int)(doc->getPageNums())-1 )
pos=doc->getPageNums()-1;
int ret= doc->insertNewPage( i18n("Insert New Slide"), pos, IP_AFTER, false, QString::null );
bool state = (ret !=-1);
return state;
}
//return false if page number doesn't exist
bool KPrDocumentIface::selectPage( int page,bool select)
{
if(page <0 || page> (int)(doc->getPageNums())-1 )
return false;
doc->selectPage( page, select );
return true;
}
// return false when we can't remove page
bool KPrDocumentIface::deletePage( int _page )
{
if( _page < 0 || _page > (int)(doc->getPageNums())-1 )
return false;
doc->deletePage(_page);
return true;
}
void KPrDocumentIface::deSelectAllObj()
{
doc->deSelectAllObj();
}
void KPrDocumentIface::recalcPageNum()
{
doc->recalcPageNum();
}
void KPrDocumentIface::initConfig()
{
doc->initConfig();
}
void KPrDocumentIface::saveConfig()
{
doc->saveConfig();
}
QString KPrDocumentIface::selectedForPrinting()const
{
return doc->selectedForPrinting();
}
bool KPrDocumentIface::isSlideSelected( int pgNum)
{
if( pgNum>= (int)doc->getPageNums())
return false;
return doc->isSlideSelected(pgNum);
}
//Return a reference to header textobj
DCOPRef KPrDocumentIface::header()
{
if(doc->header())
return DCOPRef( kapp->dcopClient()->appId(),
doc->header()->dcopObject()->objId() );
else
return DCOPRef();
}
//Return a reference to footer textobj
DCOPRef KPrDocumentIface::footer()
{
if(doc->footer())
return DCOPRef( kapp->dcopClient()->appId(),
doc->footer()->dcopObject()->objId() );
else
return DCOPRef();
}
void KPrDocumentIface::startBackgroundSpellCheck()
{
doc->startBackgroundSpellCheck();
}
void KPrDocumentIface::reactivateBgSpellChecking()
{
doc->reactivateBgSpellChecking();
}
void KPrDocumentIface::setConfigUpperCase( bool _uc )
{
doc->getAutoFormat()->configUpperCase(_uc);
}
void KPrDocumentIface::setConfigUpperUpper( bool _uu )
{
doc->getAutoFormat()->configUpperUpper(_uu);
}
void KPrDocumentIface::setConfigAdvancedAutocorrect( bool _aa )
{
doc->getAutoFormat()->configAdvancedAutocorrect( _aa );
}
void KPrDocumentIface::setConfigAutoDetectUrl(bool _au)
{
doc->getAutoFormat()->configAutoDetectUrl(_au);
}
void KPrDocumentIface::setConfigIgnoreDoubleSpace( bool _ids)
{
doc->getAutoFormat()->configIgnoreDoubleSpace(_ids);
}
void KPrDocumentIface::setConfigRemoveSpaceBeginEndLine( bool _space)
{
doc->getAutoFormat()->configRemoveSpaceBeginEndLine(_space);
}
void KPrDocumentIface::setConfigUseBulletStyle( bool _ubs)
{
doc->getAutoFormat()->configUseBulletStyle(_ubs);
}
bool KPrDocumentIface::configUpperCase() const
{
return doc->getAutoFormat()->getConfigUpperCase();
}
bool KPrDocumentIface::configUpperUpper() const
{
return doc->getAutoFormat()->getConfigUpperUpper();
}
bool KPrDocumentIface::configAdvancedAutoCorrect() const
{
return doc->getAutoFormat()->getConfigAdvancedAutoCorrect();
}
bool KPrDocumentIface::configAutoDetectUrl() const
{
return doc->getAutoFormat()->getConfigAutoDetectUrl();
}
bool KPrDocumentIface::configIgnoreDoubleSpace() const
{
return doc->getAutoFormat()->getConfigIgnoreDoubleSpace();
}
bool KPrDocumentIface::configRemoveSpaceBeginEndLine() const
{
return doc->getAutoFormat()->getConfigIgnoreDoubleSpace();
}
bool KPrDocumentIface::configUseBulletSyle() const
{
return doc->getAutoFormat()->getConfigUseBulletSyle();
}
bool KPrDocumentIface::configAutoChangeFormat() const
{
return doc->getAutoFormat()->getConfigAutoChangeFormat();
}
void KPrDocumentIface::setConfigAutoChangeFormat( bool _auto)
{
doc->getAutoFormat()->configAutoChangeFormat(_auto);
}
bool KPrDocumentIface::configAutoReplaceNumber() const
{
return doc->getAutoFormat()->getConfigAutoReplaceNumber();
}
void KPrDocumentIface::setConfigAutoReplaceNumber( bool b )
{
doc->getAutoFormat()->configAutoReplaceNumber(b);
}
bool KPrDocumentIface::showStatusBar() const
{
return doc->showStatusBar();
}
void KPrDocumentIface::setShowStatusBar( bool _status )
{
doc->setShowStatusBar(_status);
doc->reorganizeGUI();
}
void KPrDocumentIface::setConfigAutoNumberStyle( bool b )
{
doc->getAutoFormat()->configAutoNumberStyle(b);
}
bool KPrDocumentIface::configAutoNumberStyle() const
{
return doc->getAutoFormat()->getConfigAutoNumberStyle();
}
void KPrDocumentIface::setConfigCompletion( bool b )
{
doc->getAutoFormat()->configCompletion( b );
}
bool KPrDocumentIface::configCompletion() const
{
return doc->getAutoFormat()->getConfigCompletion();
}
void KPrDocumentIface::setConfigAppendSpace( bool b)
{
doc->getAutoFormat()->configAppendSpace( b );
}
bool KPrDocumentIface::configAppendSpace() const
{
return doc->getAutoFormat()->getConfigAppendSpace();
}
void KPrDocumentIface::setConfigMinWordLength( uint val )
{
doc->getAutoFormat()->configMinWordLength( val );
}
uint KPrDocumentIface::configMinWordLength() const
{
return doc->getAutoFormat()->getConfigMinWordLength();
}
void KPrDocumentIface::setConfigNbMaxCompletionWord( uint val )
{
doc->getAutoFormat()->configNbMaxCompletionWord( val );
}
uint KPrDocumentIface::configNbMaxCompletionWord() const
{
return doc->getAutoFormat()->getConfigNbMaxCompletionWord();
}
void KPrDocumentIface::setConfigAddCompletionWord( bool b )
{
doc->getAutoFormat()->configAddCompletionWord( b );
}
bool KPrDocumentIface::configAddCompletionWord() const
{
return doc->getAutoFormat()->getConfigAddCompletionWord();
}
bool KPrDocumentIface::configIncludeTwoUpperUpperLetterException() const
{
return doc->getAutoFormat()->getConfigIncludeTwoUpperUpperLetterException();
}
void KPrDocumentIface::setConfigIncludeTwoUpperUpperLetterException( bool b)
{
doc->getAutoFormat()->configIncludeTwoUpperUpperLetterException( b );
}
bool KPrDocumentIface::configIncludeAbbreviation() const
{
return doc->getAutoFormat()->getConfigIncludeAbbreviation();
}
void KPrDocumentIface::setConfigIncludeAbbreviation( bool b)
{
doc->getAutoFormat()->configIncludeAbbreviation( b );
}
bool KPrDocumentIface::displayComment() const
{
return doc->getVariableCollection()->variableSetting()->displayComment();
}
void KPrDocumentIface::setDisplayComment( bool b)
{
doc->getVariableCollection()->variableSetting()->setDisplayComment( b );
doc->recalcVariables(VT_NOTE);
}
bool KPrDocumentIface::showGuideLines() const
{
return doc->showGuideLines();
}
void KPrDocumentIface::setShowGuideLines( bool b )
{
doc->setShowGuideLines( b );
doc->updateGuideLineButton();
doc->repaint( false );
}
void KPrDocumentIface::addGuideLine( bool horizontal, double pos )
{
doc->addGuideLine( horizontal ? Qt::Horizontal: Qt::Vertical, pos );
doc->repaint( false );
}
unsigned int KPrDocumentIface::nbHorizontalHelpLine() const
{
return doc->horizontalGuideLines().count();
}
unsigned int KPrDocumentIface::nbVerticalHelpLine() const
{
return doc->verticalGuideLines().count();
}
bool KPrDocumentIface::showGrid() const
{
return doc->showGrid();
}
void KPrDocumentIface::setShowGrid ( bool _grid )
{
doc->setShowGrid( _grid);
doc->updateGridButton();
doc->repaint( false );
}
double KPrDocumentIface::gridX() const
{
return doc->getGridX();
}
void KPrDocumentIface::setGridX(double _x)
{
doc->setGridX( _x );
if( showGrid() )
doc->repaint( false );
}
double KPrDocumentIface::gridY() const
{
return doc->getGridY();
}
void KPrDocumentIface::setGridY(double _y)
{
doc->setGridY( _y );
if( showGrid() )
doc->repaint( false );
}
bool KPrDocumentIface::configAutoSuperScript() const
{
return doc->getAutoFormat()->getConfigAutoSuperScript();
}
void KPrDocumentIface::setConfigAutoSuperScript( bool b)
{
doc->getAutoFormat()->configAutoSuperScript( b );
}
void KPrDocumentIface::addIgnoreWordAll( const QString &word)
{
doc->addSpellCheckIgnoreWord( word );
}
void KPrDocumentIface::clearIgnoreWordAll( )
{
doc->setSpellCheckIgnoreList( QStringList() );
}
QStringList KPrDocumentIface::spellListIgnoreAll() const
{
return doc->spellCheckIgnoreList();
}
bool KPrDocumentIface::displayFieldCode()const
{
return doc->getVariableCollection()->variableSetting()->displayFieldCode();
}
void KPrDocumentIface::setDisplayFieldCode( bool b)
{
doc->getVariableCollection()->variableSetting()->setDisplayFieldCode( b );
doc->recalcVariables(VT_ALL);
}
QString KPrDocumentIface::configAutoFormatLanguage( )const
{
return doc->getAutoFormat()->getConfigAutoFormatLanguage( );
}
bool KPrDocumentIface::configCapitalizeNameOfDays() const
{
return doc->getAutoFormat()->getConfigCapitalizeNameOfDays();
}
void KPrDocumentIface::setConfigCapitalizeNameOfDays( bool b)
{
doc->getAutoFormat()->configCapitalizeNameOfDays( b );
}
QString KPrDocumentIface::presentationName() const
{
return doc->presentationName();
}
void KPrDocumentIface::setPresentationName( const QString &_name )
{
doc->setPresentationName( _name );
}
QStringList KPrDocumentIface::presentationList()
{
return doc->presentationList();
}
void KPrDocumentIface::repaint()
{
doc->repaint( false );
}
void KPrDocumentIface::setConfigToolTipCompletion( bool b )
{
doc->getAutoFormat()->configToolTipCompletion( b );
}
bool KPrDocumentIface::configToolTipCompletion() const
{
return doc->getAutoFormat()->getConfigToolTipCompletion();
}
|