kpresenter

KPrDocumentIface.cpp

00001 // -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
00002 /* This file is part of the KDE project
00003    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include "KPrDocumentIface.h"
00022 #include "KPrTextObject.h"
00023 #include "KPrDocument.h"
00024 #include "KPrView.h"
00025 #include "KPrPage.h"
00026 
00027 #include <kapplication.h>
00028 #include <dcopclient.h>
00029 #include <KoVariable.h>
00030 #include "KPrVariableCollection.h"
00031 #include <KoAutoFormat.h>
00032 
00033 KPrDocumentIface::KPrDocumentIface( KPrDocument *doc_ )
00034     : KoDocumentIface( doc_ )
00035 {
00036     doc = doc_;
00037 }
00038 
00039 int KPrDocumentIface::numPages() const
00040 {
00041     return doc->getPageNums();
00042 }
00043 
00044 DCOPRef KPrDocumentIface::page( int num )
00045 {
00046     if( num>= (int )doc->getPageNums())
00047         return DCOPRef();
00048     return DCOPRef( kapp->dcopClient()->appId(),
00049                     doc->pageList().at( num )->dcopObject()->objId() );
00050 }
00051 
00052 DCOPRef KPrDocumentIface::masterPage()
00053 {
00054     return DCOPRef( kapp->dcopClient()->appId(),
00055                     doc->masterPage()->dcopObject()->objId() );
00056 }
00057 
00058 void KPrDocumentIface::setShowRuler(bool b)
00059 {
00060     doc->setShowRuler(b );
00061     doc->reorganizeGUI();
00062 }
00063 
00064 bool KPrDocumentIface::showRuler() const
00065 {
00066     return doc->showRuler();
00067 }
00068 
00069 void KPrDocumentIface::recalcAllVariables()
00070 {
00071     //recalc all variable
00072     doc->recalcVariables(VT_ALL);
00073 }
00074 
00075 void KPrDocumentIface::recalcVariables(int _var)
00076 {
00077     doc->recalcVariables(_var);
00078 }
00079 
00080 void KPrDocumentIface::recalcVariables(const QString &varName)
00081 {
00082     if(varName=="VT_DATE")
00083         doc->recalcVariables(0);
00084     else if(varName=="VT_TIME")
00085         doc->recalcVariables(2);
00086     else if(varName=="VT_PGNUM")
00087         doc->recalcVariables(4);
00088     else if(varName=="VT_CUSTOM")
00089         doc->recalcVariables(6);
00090     else if(varName=="VT_SERIALLETTER")
00091         doc->recalcVariables(7);
00092     else if(varName=="VT_FIELD")
00093         doc->recalcVariables(8);
00094     else if(varName=="VT_LINK")
00095         doc->recalcVariables(9);
00096     else if(varName=="VT_NOTE")
00097         doc->recalcVariables(10);
00098     else if(varName=="VT_ALL")
00099         doc->recalcVariables(256);
00100 }
00101 
00102 int KPrDocumentIface::startingPage()
00103 {
00104     return doc->getVariableCollection()->variableSetting()->startingPageNumber();
00105 }
00106 
00107 void KPrDocumentIface::setStartingPage(int nb)
00108 {
00109     doc->getVariableCollection()->variableSetting()->setStartingPageNumber(nb);
00110     doc->recalcVariables(VT_PGNUM);
00111 }
00112 
00113 bool KPrDocumentIface::displayLink() const
00114 {
00115     return doc->getVariableCollection()->variableSetting()->displayLink();
00116 }
00117 
00118 void KPrDocumentIface::setDisplayLink(bool b)
00119 {
00120     doc->getVariableCollection()->variableSetting()->setDisplayLink(b);
00121     doc->recalcVariables(VT_LINK);
00122 }
00123 
00124 bool KPrDocumentIface::setCustomVariableValue(const QString & varname, const QString & value)
00125 {
00126     bool exist=doc->getVariableCollection()->customVariableExist(varname);
00127     if(exist)
00128     {
00129         doc->getVariableCollection()->setVariableValue( varname, value );
00130         doc->recalcVariables(VT_CUSTOM);
00131     }
00132     else
00133         return false;
00134     return true;
00135 }
00136 
00137 QString KPrDocumentIface::customVariableValue(const QString & varname)const
00138 {
00139     if(doc->getVariableCollection()->customVariableExist(varname))
00140         return doc->getVariableCollection()->getVariableValue( varname );
00141     return QString::null;
00142 }
00143 
00144 bool KPrDocumentIface::insertNewPage(int pos )
00145 {
00146     if( pos < 0 || pos > (int)(doc->getPageNums())-1 )
00147         pos=doc->getPageNums()-1;
00148     int ret= doc->insertNewPage( i18n("Insert New Slide"), pos, IP_AFTER, false, QString::null );
00149     bool state = (ret !=-1);
00150     return state;
00151 }
00152 
00153 //return false if page number doesn't exist
00154 bool KPrDocumentIface::selectPage( int page,bool select)
00155 {
00156     if(page <0 || page> (int)(doc->getPageNums())-1 )
00157         return false;
00158     doc->selectPage( page, select );
00159     return true;
00160 }
00161 
00162 // return false when we can't remove page
00163 bool KPrDocumentIface::deletePage( int _page )
00164 {
00165     if( _page < 0 || _page > (int)(doc->getPageNums())-1 )
00166         return false;
00167     doc->deletePage(_page);
00168     return true;
00169 }
00170 
00171 void KPrDocumentIface::deSelectAllObj()
00172 {
00173     doc->deSelectAllObj();
00174 }
00175 
00176 void KPrDocumentIface::recalcPageNum()
00177 {
00178     doc->recalcPageNum();
00179 }
00180 
00181 
00182 void KPrDocumentIface::initConfig()
00183 {
00184     doc->initConfig();
00185 }
00186 
00187 void KPrDocumentIface::saveConfig()
00188 {
00189     doc->saveConfig();
00190 }
00191 
00192 QString KPrDocumentIface::selectedForPrinting()const
00193 {
00194     return doc->selectedForPrinting();
00195 }
00196 
00197 bool KPrDocumentIface::isSlideSelected( int pgNum)
00198 {
00199     if( pgNum>= (int)doc->getPageNums())
00200         return false;
00201     return doc->isSlideSelected(pgNum);
00202 }
00203 
00204 //Return a reference to header textobj
00205 DCOPRef KPrDocumentIface::header()
00206 {
00207     if(doc->header())
00208         return DCOPRef( kapp->dcopClient()->appId(),
00209                         doc->header()->dcopObject()->objId() );
00210     else
00211         return DCOPRef();
00212 }
00213 
00214 //Return a reference to footer textobj
00215 DCOPRef KPrDocumentIface::footer()
00216 {
00217     if(doc->footer())
00218         return DCOPRef( kapp->dcopClient()->appId(),
00219                         doc->footer()->dcopObject()->objId() );
00220     else
00221         return DCOPRef();
00222 }
00223 
00224 void KPrDocumentIface::startBackgroundSpellCheck()
00225 {
00226     doc->startBackgroundSpellCheck();
00227 }
00228 
00229 void KPrDocumentIface::reactivateBgSpellChecking()
00230 {
00231     doc->reactivateBgSpellChecking();
00232 }
00233 
00234 void KPrDocumentIface::setConfigUpperCase( bool _uc )
00235 {
00236     doc->getAutoFormat()->configUpperCase(_uc);
00237 }
00238 
00239 void KPrDocumentIface::setConfigUpperUpper( bool _uu )
00240 {
00241     doc->getAutoFormat()->configUpperUpper(_uu);
00242 }
00243 
00244 void KPrDocumentIface::setConfigAdvancedAutocorrect( bool _aa )
00245 {
00246     doc->getAutoFormat()->configAdvancedAutocorrect( _aa );
00247 }
00248 
00249 void KPrDocumentIface::setConfigAutoDetectUrl(bool _au)
00250 {
00251     doc->getAutoFormat()->configAutoDetectUrl(_au);
00252 }
00253 
00254 void KPrDocumentIface::setConfigIgnoreDoubleSpace( bool _ids)
00255 {
00256     doc->getAutoFormat()->configIgnoreDoubleSpace(_ids);
00257 }
00258 
00259 void KPrDocumentIface::setConfigRemoveSpaceBeginEndLine( bool _space)
00260 {
00261     doc->getAutoFormat()->configRemoveSpaceBeginEndLine(_space);
00262 }
00263 
00264 void KPrDocumentIface::setConfigUseBulletStyle( bool _ubs)
00265 {
00266     doc->getAutoFormat()->configUseBulletStyle(_ubs);
00267 }
00268 
00269 bool KPrDocumentIface::configUpperCase() const
00270 {
00271     return doc->getAutoFormat()->getConfigUpperCase();
00272 }
00273 
00274 bool KPrDocumentIface::configUpperUpper() const
00275 {
00276     return doc->getAutoFormat()->getConfigUpperUpper();
00277 }
00278 
00279 bool KPrDocumentIface::configAdvancedAutoCorrect() const
00280 {
00281     return doc->getAutoFormat()->getConfigAdvancedAutoCorrect();
00282 }
00283 
00284 bool KPrDocumentIface::configAutoDetectUrl() const
00285 {
00286     return doc->getAutoFormat()->getConfigAutoDetectUrl();
00287 }
00288 
00289 bool KPrDocumentIface::configIgnoreDoubleSpace() const
00290 {
00291     return doc->getAutoFormat()->getConfigIgnoreDoubleSpace();
00292 }
00293 
00294 bool KPrDocumentIface::configRemoveSpaceBeginEndLine() const
00295 {
00296     return doc->getAutoFormat()->getConfigIgnoreDoubleSpace();
00297 }
00298 
00299 bool KPrDocumentIface::configUseBulletSyle() const
00300 {
00301     return doc->getAutoFormat()->getConfigUseBulletSyle();
00302 }
00303 
00304 bool KPrDocumentIface::configAutoChangeFormat() const
00305 {
00306     return doc->getAutoFormat()->getConfigAutoChangeFormat();
00307 }
00308 
00309 void KPrDocumentIface::setConfigAutoChangeFormat( bool _auto)
00310 {
00311     doc->getAutoFormat()->configAutoChangeFormat(_auto);
00312 }
00313 
00314 bool KPrDocumentIface::configAutoReplaceNumber() const
00315 {
00316     return doc->getAutoFormat()->getConfigAutoReplaceNumber();
00317 }
00318 
00319 void KPrDocumentIface::setConfigAutoReplaceNumber( bool b )
00320 {
00321     doc->getAutoFormat()->configAutoReplaceNumber(b);
00322 }
00323 
00324 bool KPrDocumentIface::showStatusBar() const
00325 {
00326     return doc->showStatusBar();
00327 }
00328 
00329 void KPrDocumentIface::setShowStatusBar( bool _status )
00330 {
00331     doc->setShowStatusBar(_status);
00332     doc->reorganizeGUI();
00333 }
00334 
00335 void KPrDocumentIface::setConfigAutoNumberStyle( bool b )
00336 {
00337     doc->getAutoFormat()->configAutoNumberStyle(b);
00338 }
00339 
00340 bool KPrDocumentIface::configAutoNumberStyle() const
00341 {
00342     return doc->getAutoFormat()->getConfigAutoNumberStyle();
00343 }
00344 
00345 void KPrDocumentIface::setConfigCompletion( bool b )
00346 {
00347     doc->getAutoFormat()->configCompletion( b );
00348 }
00349 
00350 bool KPrDocumentIface::configCompletion() const
00351 {
00352     return doc->getAutoFormat()->getConfigCompletion();
00353 }
00354 
00355 void KPrDocumentIface::setConfigAppendSpace( bool b)
00356 {
00357     doc->getAutoFormat()->configAppendSpace( b );
00358 }
00359 
00360 bool KPrDocumentIface::configAppendSpace() const
00361 {
00362     return doc->getAutoFormat()->getConfigAppendSpace();
00363 }
00364 
00365 void KPrDocumentIface::setConfigMinWordLength( uint val )
00366 {
00367     doc->getAutoFormat()->configMinWordLength( val );
00368 }
00369 
00370 uint KPrDocumentIface::configMinWordLength() const
00371 {
00372     return doc->getAutoFormat()->getConfigMinWordLength();
00373 }
00374 
00375 void KPrDocumentIface::setConfigNbMaxCompletionWord( uint val )
00376 {
00377     doc->getAutoFormat()->configNbMaxCompletionWord( val );
00378 }
00379 
00380 uint KPrDocumentIface::configNbMaxCompletionWord() const
00381 {
00382     return doc->getAutoFormat()->getConfigNbMaxCompletionWord();
00383 }
00384 
00385 void KPrDocumentIface::setConfigAddCompletionWord( bool b )
00386 {
00387     doc->getAutoFormat()->configAddCompletionWord( b );
00388 }
00389 
00390 bool KPrDocumentIface::configAddCompletionWord() const
00391 {
00392     return doc->getAutoFormat()->getConfigAddCompletionWord();
00393 }
00394 
00395 bool KPrDocumentIface::configIncludeTwoUpperUpperLetterException() const
00396 {
00397     return doc->getAutoFormat()->getConfigIncludeTwoUpperUpperLetterException();
00398 }
00399 
00400 void KPrDocumentIface::setConfigIncludeTwoUpperUpperLetterException( bool b)
00401 {
00402     doc->getAutoFormat()->configIncludeTwoUpperUpperLetterException( b );
00403 }
00404 
00405 bool KPrDocumentIface::configIncludeAbbreviation() const
00406 {
00407     return doc->getAutoFormat()->getConfigIncludeAbbreviation();
00408 }
00409 
00410 void KPrDocumentIface::setConfigIncludeAbbreviation( bool b)
00411 {
00412     doc->getAutoFormat()->configIncludeAbbreviation( b );
00413 }
00414 
00415 bool KPrDocumentIface::displayComment() const
00416 {
00417     return doc->getVariableCollection()->variableSetting()->displayComment();
00418 }
00419 
00420 void KPrDocumentIface::setDisplayComment( bool b)
00421 {
00422     doc->getVariableCollection()->variableSetting()->setDisplayComment( b );
00423     doc->recalcVariables(VT_NOTE);
00424 }
00425 
00426 bool KPrDocumentIface::showGuideLines() const
00427 {
00428     return doc->showGuideLines();
00429 }
00430 
00431 void KPrDocumentIface::setShowGuideLines( bool b )
00432 {
00433     doc->setShowGuideLines( b );
00434     doc->updateGuideLineButton();
00435     doc->repaint( false );
00436 }
00437 
00438 void KPrDocumentIface::addGuideLine( bool horizontal, double pos )
00439 {
00440     doc->addGuideLine( horizontal ? Qt::Horizontal: Qt::Vertical, pos );
00441     doc->repaint( false );
00442 }
00443 
00444 unsigned int KPrDocumentIface::nbHorizontalHelpLine() const
00445 {
00446     return doc->horizontalGuideLines().count();
00447 }
00448 
00449 unsigned int KPrDocumentIface::nbVerticalHelpLine() const
00450 {
00451     return doc->verticalGuideLines().count();
00452 }
00453 
00454 bool KPrDocumentIface::showGrid() const
00455 {
00456     return doc->showGrid();
00457 }
00458 
00459 void KPrDocumentIface::setShowGrid ( bool _grid )
00460 {
00461     doc->setShowGrid( _grid);
00462     doc->updateGridButton();
00463     doc->repaint( false );
00464 }
00465 
00466 double KPrDocumentIface::gridX() const
00467 {
00468     return doc->getGridX();
00469 }
00470 
00471 void KPrDocumentIface::setGridX(double _x)
00472 {
00473     doc->setGridX( _x );
00474     if( showGrid() )
00475         doc->repaint( false );
00476 }
00477 
00478 double KPrDocumentIface::gridY() const
00479 {
00480     return doc->getGridY();
00481 }
00482 
00483 void KPrDocumentIface::setGridY(double _y)
00484 {
00485     doc->setGridY( _y );
00486     if( showGrid() )
00487         doc->repaint( false );
00488 }
00489 
00490 bool KPrDocumentIface::configAutoSuperScript() const
00491 {
00492     return doc->getAutoFormat()->getConfigAutoSuperScript();
00493 }
00494 
00495 void KPrDocumentIface::setConfigAutoSuperScript( bool b)
00496 {
00497     doc->getAutoFormat()->configAutoSuperScript( b );
00498 }
00499 
00500 void KPrDocumentIface::addIgnoreWordAll( const QString &word)
00501 {
00502     doc->addSpellCheckIgnoreWord( word );
00503 }
00504 
00505 void KPrDocumentIface::clearIgnoreWordAll( )
00506 {
00507     doc->setSpellCheckIgnoreList( QStringList() );
00508 }
00509 
00510 QStringList KPrDocumentIface::spellListIgnoreAll() const
00511 {
00512     return doc->spellCheckIgnoreList();
00513 }
00514 
00515 bool KPrDocumentIface::displayFieldCode()const
00516 {
00517     return doc->getVariableCollection()->variableSetting()->displayFieldCode();
00518 }
00519 
00520 void KPrDocumentIface::setDisplayFieldCode( bool b)
00521 {
00522     doc->getVariableCollection()->variableSetting()->setDisplayFieldCode( b );
00523     doc->recalcVariables(VT_ALL);
00524 }
00525 
00526 QString KPrDocumentIface::configAutoFormatLanguage( )const
00527 {
00528     return doc->getAutoFormat()->getConfigAutoFormatLanguage( );
00529 }
00530 
00531 
00532 bool KPrDocumentIface::configCapitalizeNameOfDays() const
00533 {
00534     return doc->getAutoFormat()->getConfigCapitalizeNameOfDays();
00535 }
00536 
00537 void KPrDocumentIface::setConfigCapitalizeNameOfDays( bool b)
00538 {
00539     doc->getAutoFormat()->configCapitalizeNameOfDays( b );
00540 }
00541 
00542 QString KPrDocumentIface::presentationName() const
00543 {
00544     return doc->presentationName();
00545 }
00546 
00547 void KPrDocumentIface::setPresentationName( const QString &_name )
00548 {
00549     doc->setPresentationName( _name );
00550 }
00551 
00552 
00553 QStringList KPrDocumentIface::presentationList()
00554 {
00555     return doc->presentationList();
00556 }
00557 
00558 void KPrDocumentIface::repaint()
00559 {
00560     doc->repaint( false );
00561 }
00562 
00563 void KPrDocumentIface::setConfigToolTipCompletion( bool b )
00564 {
00565     doc->getAutoFormat()->configToolTipCompletion( b );
00566 }
00567 
00568 bool KPrDocumentIface::configToolTipCompletion() const
00569 {
00570     return doc->getAutoFormat()->getConfigToolTipCompletion();
00571 }
KDE Home | KDE Accessibility Home | Description of Access Keys