kpresenter

KPrDocumentIface.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include "KPrDocumentIface.h"
21#include "KPrTextObject.h"
22#include "KPrDocument.h"
23#include "KPrView.h"
24#include "KPrPage.h"
25
26#include <tdeapplication.h>
27#include <dcopclient.h>
28#include <KoVariable.h>
29#include "KPrVariableCollection.h"
30#include <KoAutoFormat.h>
31
32KPrDocumentIface::KPrDocumentIface( KPrDocument *doc_ )
33 : KoDocumentIface( doc_ )
34{
35 doc = doc_;
36}
37
38int KPrDocumentIface::numPages() const
39{
40 return doc->getPageNums();
41}
42
43DCOPRef KPrDocumentIface::page( int num )
44{
45 if( num>= (int )doc->getPageNums())
46 return DCOPRef();
47 return DCOPRef( kapp->dcopClient()->appId(),
48 doc->pageList().at( num )->dcopObject()->objId() );
49}
50
51DCOPRef KPrDocumentIface::masterPage()
52{
53 return DCOPRef( kapp->dcopClient()->appId(),
54 doc->masterPage()->dcopObject()->objId() );
55}
56
57void KPrDocumentIface::setShowRuler(bool b)
58{
59 doc->setShowRuler(b );
60 doc->reorganizeGUI();
61}
62
63bool KPrDocumentIface::showRuler() const
64{
65 return doc->showRuler();
66}
67
68void KPrDocumentIface::recalcAllVariables()
69{
70 //recalc all variable
71 doc->recalcVariables(VT_ALL);
72}
73
74void KPrDocumentIface::recalcVariables(int _var)
75{
76 doc->recalcVariables(_var);
77}
78
79void KPrDocumentIface::recalcVariables(const TQString &varName)
80{
81 if(varName=="VT_DATE")
82 doc->recalcVariables(0);
83 else if(varName=="VT_TIME")
84 doc->recalcVariables(2);
85 else if(varName=="VT_PGNUM")
86 doc->recalcVariables(4);
87 else if(varName=="VT_CUSTOM")
88 doc->recalcVariables(6);
89 else if(varName=="VT_SERIALLETTER")
90 doc->recalcVariables(7);
91 else if(varName=="VT_FIELD")
92 doc->recalcVariables(8);
93 else if(varName=="VT_LINK")
94 doc->recalcVariables(9);
95 else if(varName=="VT_NOTE")
96 doc->recalcVariables(10);
97 else if(varName=="VT_ALL")
98 doc->recalcVariables(256);
99}
100
101int KPrDocumentIface::startingPage()
102{
103 return doc->getVariableCollection()->variableSetting()->startingPageNumber();
104}
105
106void KPrDocumentIface::setStartingPage(int nb)
107{
108 doc->getVariableCollection()->variableSetting()->setStartingPageNumber(nb);
109 doc->recalcVariables(VT_PGNUM);
110}
111
112bool KPrDocumentIface::displayLink() const
113{
114 return doc->getVariableCollection()->variableSetting()->displayLink();
115}
116
117void KPrDocumentIface::setDisplayLink(bool b)
118{
119 doc->getVariableCollection()->variableSetting()->setDisplayLink(b);
120 doc->recalcVariables(VT_LINK);
121}
122
123bool KPrDocumentIface::setCustomVariableValue(const TQString & varname, const TQString & value)
124{
125 bool exist=doc->getVariableCollection()->customVariableExist(varname);
126 if(exist)
127 {
128 doc->getVariableCollection()->setVariableValue( varname, value );
129 doc->recalcVariables(VT_CUSTOM);
130 }
131 else
132 return false;
133 return true;
134}
135
136TQString KPrDocumentIface::customVariableValue(const TQString & varname)const
137{
138 if(doc->getVariableCollection()->customVariableExist(varname))
139 return doc->getVariableCollection()->getVariableValue( varname );
140 return TQString();
141}
142
143bool KPrDocumentIface::insertNewPage(int pos )
144{
145 if( pos < 0 || pos > (int)(doc->getPageNums())-1 )
146 pos=doc->getPageNums()-1;
147 int ret= doc->insertNewPage( i18n("Insert New Slide"), pos, IP_AFTER, false, TQString() );
148 bool state = (ret !=-1);
149 return state;
150}
151
152//return false if page number doesn't exist
153bool KPrDocumentIface::selectPage( int page,bool select)
154{
155 if(page <0 || page> (int)(doc->getPageNums())-1 )
156 return false;
157 doc->selectPage( page, select );
158 return true;
159}
160
161// return false when we can't remove page
162bool KPrDocumentIface::deletePage( int _page )
163{
164 if( _page < 0 || _page > (int)(doc->getPageNums())-1 )
165 return false;
166 doc->deletePage(_page);
167 return true;
168}
169
170void KPrDocumentIface::deSelectAllObj()
171{
172 doc->deSelectAllObj();
173}
174
175void KPrDocumentIface::recalcPageNum()
176{
177 doc->recalcPageNum();
178}
179
180
181void KPrDocumentIface::initConfig()
182{
183 doc->initConfig();
184}
185
186void KPrDocumentIface::saveConfig()
187{
188 doc->saveConfig();
189}
190
191TQString KPrDocumentIface::selectedForPrinting()const
192{
193 return doc->selectedForPrinting();
194}
195
196bool KPrDocumentIface::isSlideSelected( int pgNum)
197{
198 if( pgNum>= (int)doc->getPageNums())
199 return false;
200 return doc->isSlideSelected(pgNum);
201}
202
203//Return a reference to header textobj
204DCOPRef KPrDocumentIface::header()
205{
206 if(doc->header())
207 return DCOPRef( kapp->dcopClient()->appId(),
208 doc->header()->dcopObject()->objId() );
209 else
210 return DCOPRef();
211}
212
213//Return a reference to footer textobj
214DCOPRef KPrDocumentIface::footer()
215{
216 if(doc->footer())
217 return DCOPRef( kapp->dcopClient()->appId(),
218 doc->footer()->dcopObject()->objId() );
219 else
220 return DCOPRef();
221}
222
223void KPrDocumentIface::startBackgroundSpellCheck()
224{
225 doc->startBackgroundSpellCheck();
226}
227
228void KPrDocumentIface::reactivateBgSpellChecking()
229{
230 doc->reactivateBgSpellChecking();
231}
232
233void KPrDocumentIface::setConfigUpperCase( bool _uc )
234{
235 doc->getAutoFormat()->configUpperCase(_uc);
236}
237
238void KPrDocumentIface::setConfigUpperUpper( bool _uu )
239{
240 doc->getAutoFormat()->configUpperUpper(_uu);
241}
242
243void KPrDocumentIface::setConfigAdvancedAutocorrect( bool _aa )
244{
245 doc->getAutoFormat()->configAdvancedAutocorrect( _aa );
246}
247
248void KPrDocumentIface::setConfigAutoDetectUrl(bool _au)
249{
250 doc->getAutoFormat()->configAutoDetectUrl(_au);
251}
252
253void KPrDocumentIface::setConfigIgnoreDoubleSpace( bool _ids)
254{
255 doc->getAutoFormat()->configIgnoreDoubleSpace(_ids);
256}
257
258void KPrDocumentIface::setConfigRemoveSpaceBeginEndLine( bool _space)
259{
260 doc->getAutoFormat()->configRemoveSpaceBeginEndLine(_space);
261}
262
263void KPrDocumentIface::setConfigUseBulletStyle( bool _ubs)
264{
265 doc->getAutoFormat()->configUseBulletStyle(_ubs);
266}
267
268bool KPrDocumentIface::configUpperCase() const
269{
270 return doc->getAutoFormat()->getConfigUpperCase();
271}
272
273bool KPrDocumentIface::configUpperUpper() const
274{
275 return doc->getAutoFormat()->getConfigUpperUpper();
276}
277
278bool KPrDocumentIface::configAdvancedAutoCorrect() const
279{
280 return doc->getAutoFormat()->getConfigAdvancedAutoCorrect();
281}
282
283bool KPrDocumentIface::configAutoDetectUrl() const
284{
285 return doc->getAutoFormat()->getConfigAutoDetectUrl();
286}
287
288bool KPrDocumentIface::configIgnoreDoubleSpace() const
289{
290 return doc->getAutoFormat()->getConfigIgnoreDoubleSpace();
291}
292
293bool KPrDocumentIface::configRemoveSpaceBeginEndLine() const
294{
295 return doc->getAutoFormat()->getConfigIgnoreDoubleSpace();
296}
297
298bool KPrDocumentIface::configUseBulletSyle() const
299{
300 return doc->getAutoFormat()->getConfigUseBulletSyle();
301}
302
303bool KPrDocumentIface::configAutoChangeFormat() const
304{
305 return doc->getAutoFormat()->getConfigAutoChangeFormat();
306}
307
308void KPrDocumentIface::setConfigAutoChangeFormat( bool _auto)
309{
310 doc->getAutoFormat()->configAutoChangeFormat(_auto);
311}
312
313bool KPrDocumentIface::configAutoReplaceNumber() const
314{
315 return doc->getAutoFormat()->getConfigAutoReplaceNumber();
316}
317
318void KPrDocumentIface::setConfigAutoReplaceNumber( bool b )
319{
320 doc->getAutoFormat()->configAutoReplaceNumber(b);
321}
322
323bool KPrDocumentIface::showStatusBar() const
324{
325 return doc->showStatusBar();
326}
327
328void KPrDocumentIface::setShowStatusBar( bool _status )
329{
330 doc->setShowStatusBar(_status);
331 doc->reorganizeGUI();
332}
333
334void KPrDocumentIface::setConfigAutoNumberStyle( bool b )
335{
336 doc->getAutoFormat()->configAutoNumberStyle(b);
337}
338
339bool KPrDocumentIface::configAutoNumberStyle() const
340{
341 return doc->getAutoFormat()->getConfigAutoNumberStyle();
342}
343
344void KPrDocumentIface::setConfigCompletion( bool b )
345{
346 doc->getAutoFormat()->configCompletion( b );
347}
348
349bool KPrDocumentIface::configCompletion() const
350{
351 return doc->getAutoFormat()->getConfigCompletion();
352}
353
354void KPrDocumentIface::setConfigAppendSpace( bool b)
355{
356 doc->getAutoFormat()->configAppendSpace( b );
357}
358
359bool KPrDocumentIface::configAppendSpace() const
360{
361 return doc->getAutoFormat()->getConfigAppendSpace();
362}
363
364void KPrDocumentIface::setConfigMinWordLength( uint val )
365{
366 doc->getAutoFormat()->configMinWordLength( val );
367}
368
369uint KPrDocumentIface::configMinWordLength() const
370{
371 return doc->getAutoFormat()->getConfigMinWordLength();
372}
373
374void KPrDocumentIface::setConfigNbMaxCompletionWord( uint val )
375{
376 doc->getAutoFormat()->configNbMaxCompletionWord( val );
377}
378
379uint KPrDocumentIface::configNbMaxCompletionWord() const
380{
381 return doc->getAutoFormat()->getConfigNbMaxCompletionWord();
382}
383
384void KPrDocumentIface::setConfigAddCompletionWord( bool b )
385{
386 doc->getAutoFormat()->configAddCompletionWord( b );
387}
388
389bool KPrDocumentIface::configAddCompletionWord() const
390{
391 return doc->getAutoFormat()->getConfigAddCompletionWord();
392}
393
394bool KPrDocumentIface::configIncludeTwoUpperUpperLetterException() const
395{
396 return doc->getAutoFormat()->getConfigIncludeTwoUpperUpperLetterException();
397}
398
399void KPrDocumentIface::setConfigIncludeTwoUpperUpperLetterException( bool b)
400{
401 doc->getAutoFormat()->configIncludeTwoUpperUpperLetterException( b );
402}
403
404bool KPrDocumentIface::configIncludeAbbreviation() const
405{
406 return doc->getAutoFormat()->getConfigIncludeAbbreviation();
407}
408
409void KPrDocumentIface::setConfigIncludeAbbreviation( bool b)
410{
411 doc->getAutoFormat()->configIncludeAbbreviation( b );
412}
413
414bool KPrDocumentIface::displayComment() const
415{
416 return doc->getVariableCollection()->variableSetting()->displayComment();
417}
418
419void KPrDocumentIface::setDisplayComment( bool b)
420{
421 doc->getVariableCollection()->variableSetting()->setDisplayComment( b );
422 doc->recalcVariables(VT_NOTE);
423}
424
425bool KPrDocumentIface::showGuideLines() const
426{
427 return doc->showGuideLines();
428}
429
430void KPrDocumentIface::setShowGuideLines( bool b )
431{
432 doc->setShowGuideLines( b );
433 doc->updateGuideLineButton();
434 doc->repaint( false );
435}
436
437void KPrDocumentIface::addGuideLine( bool horizontal, double pos )
438{
439 doc->addGuideLine( horizontal ? TQt::Horizontal: TQt::Vertical, pos );
440 doc->repaint( false );
441}
442
443unsigned int KPrDocumentIface::nbHorizontalHelpLine() const
444{
445 return doc->horizontalGuideLines().count();
446}
447
448unsigned int KPrDocumentIface::nbVerticalHelpLine() const
449{
450 return doc->verticalGuideLines().count();
451}
452
453bool KPrDocumentIface::showGrid() const
454{
455 return doc->showGrid();
456}
457
458void KPrDocumentIface::setShowGrid ( bool _grid )
459{
460 doc->setShowGrid( _grid);
461 doc->updateGridButton();
462 doc->repaint( false );
463}
464
465double KPrDocumentIface::gridX() const
466{
467 return doc->getGridX();
468}
469
470void KPrDocumentIface::setGridX(double _x)
471{
472 doc->setGridX( _x );
473 if( showGrid() )
474 doc->repaint( false );
475}
476
477double KPrDocumentIface::gridY() const
478{
479 return doc->getGridY();
480}
481
482void KPrDocumentIface::setGridY(double _y)
483{
484 doc->setGridY( _y );
485 if( showGrid() )
486 doc->repaint( false );
487}
488
489bool KPrDocumentIface::configAutoSuperScript() const
490{
491 return doc->getAutoFormat()->getConfigAutoSuperScript();
492}
493
494void KPrDocumentIface::setConfigAutoSuperScript( bool b)
495{
496 doc->getAutoFormat()->configAutoSuperScript( b );
497}
498
499void KPrDocumentIface::addIgnoreWordAll( const TQString &word)
500{
501 doc->addSpellCheckIgnoreWord( word );
502}
503
504void KPrDocumentIface::clearIgnoreWordAll( )
505{
506 doc->setSpellCheckIgnoreList( TQStringList() );
507}
508
509TQStringList KPrDocumentIface::spellListIgnoreAll() const
510{
511 return doc->spellCheckIgnoreList();
512}
513
514bool KPrDocumentIface::displayFieldCode()const
515{
516 return doc->getVariableCollection()->variableSetting()->displayFieldCode();
517}
518
519void KPrDocumentIface::setDisplayFieldCode( bool b)
520{
521 doc->getVariableCollection()->variableSetting()->setDisplayFieldCode( b );
522 doc->recalcVariables(VT_ALL);
523}
524
525TQString KPrDocumentIface::configAutoFormatLanguage( )const
526{
527 return doc->getAutoFormat()->getConfigAutoFormatLanguage( );
528}
529
530
531bool KPrDocumentIface::configCapitalizeNameOfDays() const
532{
533 return doc->getAutoFormat()->getConfigCapitalizeNameOfDays();
534}
535
536void KPrDocumentIface::setConfigCapitalizeNameOfDays( bool b)
537{
538 doc->getAutoFormat()->configCapitalizeNameOfDays( b );
539}
540
541TQString KPrDocumentIface::presentationName() const
542{
543 return doc->presentationName();
544}
545
546void KPrDocumentIface::setPresentationName( const TQString &_name )
547{
548 doc->setPresentationName( _name );
549}
550
551
552TQStringList KPrDocumentIface::presentationList()
553{
554 return doc->presentationList();
555}
556
557void KPrDocumentIface::repaint()
558{
559 doc->repaint( false );
560}
561
562void KPrDocumentIface::setConfigToolTipCompletion( bool b )
563{
564 doc->getAutoFormat()->configToolTipCompletion( b );
565}
566
567bool KPrDocumentIface::configToolTipCompletion() const
568{
569 return doc->getAutoFormat()->getConfigToolTipCompletion();
570}