lib Library API Documentation

KoTextViewIface.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002 Laurent MONTEL <lmontel@mandrakesoft.com>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
00018 */
00019 
00020 #include "KoTextViewIface.h"
00021 #include "kotextview.h"
00022 #include <kapplication.h>
00023 #include <dcopclient.h>
00024 #include <kdebug.h>
00025 #include "koborder.h"
00026 #include <kovariable.h>
00027 #include <kcommand.h>
00028 
00029 
00030 KoTextViewIface::KoTextViewIface( KoTextView *_textview )
00031     : DCOPObject( /*TODO name*/ )
00032 {
00033    m_textView = _textview;
00034 }
00035 
00036 void KoTextViewIface::insertSoftHyphen()
00037 {
00038    m_textView->insertSoftHyphen();
00039 }
00040 
00041 void KoTextViewIface::insertText( const QString &text )
00042 {
00043     m_textView->insertText(text);
00044 }
00045 
00046 void KoTextViewIface::newParagraph()
00047 {
00048     m_textView->newParagraph();
00049 }
00050 
00051 
00052 void KoTextViewIface::setBold(bool b)
00053 {
00054     KCommand *cmd=m_textView->setBoldCommand(b);
00055     delete cmd;
00056 }
00057 
00058 void KoTextViewIface::setItalic(bool on)
00059 {
00060     KCommand *cmd=m_textView->setItalicCommand(on);
00061     delete cmd;
00062 }
00063 
00064 void KoTextViewIface::setUnderline(bool on)
00065 {
00066     KCommand *cmd=m_textView->setUnderlineCommand(on);
00067     delete cmd;
00068 }
00069 
00070 void KoTextViewIface::setDoubleUnderline(bool on)
00071 {
00072     KCommand *cmd=m_textView->setDoubleUnderlineCommand(on);
00073     delete cmd;
00074 }
00075 
00076 
00077 void KoTextViewIface::setStrikeOut(bool on)
00078 {
00079     KCommand *cmd=m_textView->setStrikeOutCommand(on);
00080     delete cmd;
00081 }
00082 
00083 void KoTextViewIface::setPointSize( int s )
00084 {
00085     KCommand *cmd=m_textView->setPointSizeCommand(s);
00086     delete cmd;
00087 }
00088 
00089 void KoTextViewIface::setTextSubScript(bool on)
00090 {
00091     KCommand *cmd=m_textView->setTextSubScriptCommand(on);
00092     delete cmd;
00093 }
00094 
00095 void KoTextViewIface::setTextSuperScript(bool on)
00096 {
00097     KCommand *cmd=m_textView->setTextSuperScriptCommand(on);
00098     delete cmd;
00099 }
00100 
00101 void KoTextViewIface::setLanguage(const QString & _lang)
00102 {
00103     KCommand *cmd=m_textView->setLanguageCommand(_lang);
00104     delete cmd;
00105 }
00106 
00107 QString KoTextViewIface::language() const
00108 {
00109     return m_textView->language();
00110 }
00111 
00112 void KoTextViewIface::setDefaultFormat()
00113 {
00114     KCommand *cmd=m_textView->setDefaultFormatCommand();
00115     delete cmd;
00116 }
00117 
00118 QColor KoTextViewIface::textColor() const
00119 {
00120     return m_textView->textColor();
00121 }
00122 
00123 QString KoTextViewIface::textFontFamily()const
00124 {
00125     return m_textView->textFontFamily();
00126 }
00127 
00128 QColor KoTextViewIface::textBackgroundColor()const
00129 {
00130     return m_textView->textBackgroundColor();
00131 }
00132 
00133 QColor KoTextViewIface::textUnderlineColor() const
00134 {
00135     return m_textView->textUnderlineColor();
00136 }
00137 
00138 double KoTextViewIface::relativeTextSize() const
00139 {
00140     return m_textView->relativeTextSize();
00141 }
00142 
00143 void KoTextViewIface::setRelativeTextSize( double _size)
00144 {
00145     KCommand *cmd=m_textView->setRelativeTextSizeCommand(_size);
00146     delete cmd;
00147 }
00148 
00149 void KoTextViewIface::setUnderlineColor( const QColor & color )
00150 {
00151     KCommand *cmd=m_textView->setUnderlineColorCommand(color);
00152     delete cmd;
00153 }
00154 
00155 void KoTextViewIface::setTextColor(const QColor &color)
00156 {
00157     KCommand *cmd=m_textView->setTextColorCommand(color);
00158     delete cmd;
00159 }
00160 
00161 void KoTextViewIface::setTextBackgroundColor(const QColor &color)
00162 {
00163     KCommand *cmd=m_textView->setTextBackgroundColorCommand(color);
00164     delete cmd;
00165 }
00166 
00167 void KoTextViewIface::setAlign(int align)
00168 {
00169     KCommand *cmd=m_textView->setAlignCommand(align);
00170     delete cmd;
00171 }
00172 
00173 void KoTextViewIface::setAlign(const QString &align)
00174 {
00175     KCommand *cmd=0L;
00176     if( align=="AlignLeft")
00177         cmd=m_textView->setAlignCommand(Qt::AlignLeft);
00178     else if (align=="AlignRight")
00179         cmd=m_textView->setAlignCommand(Qt::AlignRight);
00180     else if (align=="AlignCenter" || align=="AlignHCenter")
00181         cmd=m_textView->setAlignCommand(Qt::AlignHCenter);
00182     else if (align=="AlignJustify")
00183         cmd=m_textView->setAlignCommand(Qt::AlignJustify);
00184     else
00185     {
00186         kdDebug(32500)<<"Align value not recognized...\n";
00187         cmd=m_textView->setAlignCommand(Qt::AlignLeft);
00188     }
00189     delete cmd;
00190 }
00191 
00192 bool KoTextViewIface::textDoubleUnderline() const
00193 {
00194     return m_textView->textDoubleUnderline();
00195 }
00196 
00197 bool KoTextViewIface::textItalic() const
00198 {
00199     return m_textView->textItalic();
00200 }
00201 
00202 bool KoTextViewIface::textBold() const
00203 {
00204     return m_textView->textBold();
00205 }
00206 
00207 bool KoTextViewIface::textUnderline()const
00208 {
00209     return m_textView->textUnderline();
00210 }
00211 
00212 bool KoTextViewIface::textStrikeOut()const
00213 {
00214     return m_textView->textStrikeOut();
00215 }
00216 
00217 bool KoTextViewIface::textSubScript() const
00218 {
00219     return m_textView->textSubScript();
00220 }
00221 
00222 bool KoTextViewIface::textSuperScript() const
00223 {
00224     return m_textView->textSuperScript();
00225 }
00226 
00227 bool KoTextViewIface::isReadWrite() const
00228 {
00229     return m_textView->isReadWrite();
00230 }
00231 
00232 void KoTextViewIface::setReadWrite( bool b )
00233 {
00234     m_textView->setReadWrite(b);
00235 }
00236 
00237 void KoTextViewIface::hideCursor()
00238 {
00239     m_textView->hideCursor();
00240 }
00241 
00242 void KoTextViewIface::showCursor()
00243 {
00244     m_textView->showCursor();
00245 }
00246 
00247 void KoTextViewIface::moveCursorLeft(bool select)
00248 {
00249   m_textView->moveCursor(KoTextView::MoveBackward,select);
00250 }
00251 
00252 void KoTextViewIface::moveCursorRight(bool select)
00253 {
00254   m_textView->moveCursor(KoTextView::MoveForward,select);
00255 }
00256 
00257 void KoTextViewIface::moveCursorUp(bool select)
00258 {
00259   m_textView->moveCursor(KoTextView::MoveUp,select);
00260 }
00261 
00262 void KoTextViewIface::moveCursorDown(bool select)
00263 {
00264   m_textView->moveCursor(KoTextView::MoveDown,select);
00265 }
00266 
00267 void KoTextViewIface::moveCursorHome(bool select)
00268 {
00269   m_textView->moveCursor(KoTextView::MoveHome,select);
00270 }
00271 
00272 void KoTextViewIface::moveCursorEnd(bool select)
00273 {
00274   m_textView->moveCursor(KoTextView::MoveEnd,select);
00275 }
00276 
00277 void KoTextViewIface::moveCursorWordLeft(bool select)
00278 {
00279   m_textView->moveCursor(KoTextView::MoveWordBackward,select);
00280 }
00281 
00282 void KoTextViewIface::moveCursorWordRight(bool select)
00283 {
00284   m_textView->moveCursor(KoTextView::MoveWordForward,select);
00285 }
00286 
00287 void KoTextViewIface::moveCursorLineEnd(bool select)
00288 {
00289   m_textView->moveCursor(KoTextView::MoveLineEnd,select);
00290 }
00291 
00292 void KoTextViewIface::moveCursorLineStart(bool select)
00293 {
00294   m_textView->moveCursor(KoTextView::MoveLineStart,select);
00295 }
00296 
00297 bool KoTextViewIface::paragraphHasBorder() const
00298 {
00299     return m_textView->cursor()->parag()->hasBorder();
00300 }
00301 
00302 double KoTextViewIface::lineSpacing() const
00303 {
00304     return m_textView->cursor()->parag()->kwLineSpacing();
00305 }
00306 
00307 double KoTextViewIface::leftMargin() const
00308 {
00309     return m_textView->cursor()->parag()->margin( QStyleSheetItem::MarginLeft);
00310 }
00311 
00312 double KoTextViewIface::rightMargin() const
00313 {
00314     return m_textView->cursor()->parag()->margin( QStyleSheetItem::MarginRight);
00315 }
00316 
00317 double KoTextViewIface::spaceBeforeParag() const
00318 {
00319     return m_textView->cursor()->parag()->margin( QStyleSheetItem::MarginTop);
00320 }
00321 
00322 double KoTextViewIface::spaceAfterParag() const
00323 {
00324     return m_textView->cursor()->parag()->margin( QStyleSheetItem::MarginBottom);
00325 }
00326 
00327 double KoTextViewIface::marginFirstLine() const
00328 {
00329     return m_textView->cursor()->parag()->margin( QStyleSheetItem::MarginFirstLine);
00330 }
00331 
00332 void KoTextViewIface::setMarginFirstLine(double pt)
00333 {
00334     m_textView->cursor()->parag()->setMargin( QStyleSheetItem::MarginFirstLine,pt);
00335 }
00336 
00337 void KoTextViewIface::setLineSpacing(double pt)
00338 {
00339     m_textView->cursor()->parag()->setLineSpacing(pt);
00340 }
00341 
00342 void KoTextViewIface::setLeftMargin(double pt)
00343 {
00344     m_textView->cursor()->parag()->setMargin( QStyleSheetItem::MarginLeft,pt);
00345 }
00346 
00347 void KoTextViewIface::setRightMargin(double pt)
00348 {
00349     m_textView->cursor()->parag()->setMargin( QStyleSheetItem::MarginRight,pt);
00350 }
00351 
00352 void KoTextViewIface::setSpaceBeforeParag(double pt)
00353 {
00354     m_textView->cursor()->parag()->setMargin( QStyleSheetItem::MarginTop,pt);
00355 }
00356 
00357 void KoTextViewIface::setSpaceAfterParag(double pt)
00358 {
00359     m_textView->cursor()->parag()->setMargin( QStyleSheetItem::MarginBottom,pt);
00360 }
00361 
00362 
00363 void KoTextViewIface::setLeftBorder( const QColor & c,double width )
00364 {
00365     KoTextParag *parag= m_textView->cursor()->parag();
00366     parag->setLeftBorder(KoBorder( c, KoBorder::SOLID, width ));
00367 
00368 }
00369 
00370 void KoTextViewIface::setRightBorder( const QColor & c,double width )
00371 {
00372     KoTextParag *parag= m_textView->cursor()->parag();
00373     parag->setRightBorder(KoBorder( c, KoBorder::SOLID, width ));
00374 }
00375 
00376 void KoTextViewIface::setTopBorder( const QColor & c,double width )
00377 {
00378     KoTextParag *parag= m_textView->cursor()->parag();
00379     parag->setTopBorder(KoBorder( c, KoBorder::SOLID, width ));
00380 }
00381 
00382 void KoTextViewIface::setBottomBorder(const QColor & c,double width )
00383 {
00384     KoTextParag *parag= m_textView->cursor()->parag();
00385     parag->setBottomBorder(KoBorder( c, KoBorder::SOLID, width ));
00386 }
00387 
00388 double KoTextViewIface::leftBorderWidth() const
00389 {
00390     KoTextParag *parag= m_textView->cursor()->parag();
00391     return  parag->leftBorder().width();
00392 }
00393 
00394 double KoTextViewIface::rightBorderWidth() const
00395 {
00396     KoTextParag *parag= m_textView->cursor()->parag();
00397     return parag->rightBorder().width();
00398 
00399 }
00400 double KoTextViewIface::topBorderWidth() const
00401 {
00402     KoTextParag *parag= m_textView->cursor()->parag();
00403     return parag->topBorder().width();
00404 
00405 }
00406 
00407 double KoTextViewIface::bottomBorderWidth() const
00408 {
00409     KoTextParag *parag= m_textView->cursor()->parag();
00410     return parag->bottomBorder().width();
00411 
00412 }
00413 
00414 QColor KoTextViewIface::leftBorderColor() const
00415 {
00416     KoTextParag *parag= m_textView->cursor()->parag();
00417     return parag->leftBorder().color;
00418 }
00419 
00420 QColor KoTextViewIface::rightBorderColor() const
00421 {
00422     KoTextParag *parag= m_textView->cursor()->parag();
00423     return parag->rightBorder().color;
00424 }
00425 
00426 QColor KoTextViewIface::topBorderColor() const
00427 {
00428     KoTextParag *parag= m_textView->cursor()->parag();
00429     return parag->topBorder().color;
00430 }
00431 
00432 QColor KoTextViewIface::bottomBorderColor() const
00433 {
00434     KoTextParag *parag= m_textView->cursor()->parag();
00435     return parag->bottomBorder().color;
00436 }
00437 
00438 void KoTextViewIface::setLeftBorderColor( const QColor & c )
00439 {
00440     KoTextParag *parag= m_textView->cursor()->parag();
00441     parag->leftBorder().color = c ;
00442 }
00443 
00444 void KoTextViewIface::setRightBorderColor( const QColor & c )
00445 {
00446     KoTextParag *parag= m_textView->cursor()->parag();
00447     parag->rightBorder().color = c ;
00448 }
00449 
00450 void KoTextViewIface::setTopBorderColor( const QColor & c )
00451 {
00452     KoTextParag *parag= m_textView->cursor()->parag();
00453     parag->topBorder().color = c ;
00454 }
00455 
00456 void KoTextViewIface::setBottomBorderColor(const QColor & c )
00457 {
00458     KoTextParag *parag= m_textView->cursor()->parag();
00459     parag->bottomBorder().color = c ;
00460 }
00461 
00462 void KoTextViewIface::setLeftBorderWidth( double _witdh )
00463 {
00464     KoTextParag *parag= m_textView->cursor()->parag();
00465     parag->leftBorder().setPenWidth(_witdh) ;
00466 }
00467 
00468 void KoTextViewIface::setRightBorderWidth( double _witdh )
00469 {
00470     KoTextParag *parag= m_textView->cursor()->parag();
00471     parag->rightBorder().setPenWidth(_witdh) ;
00472 }
00473 
00474 void KoTextViewIface::setTopBorderWidth( double _witdh )
00475 {
00476     KoTextParag *parag= m_textView->cursor()->parag();
00477     parag->topBorder().setPenWidth(_witdh) ;
00478 }
00479 
00480 void KoTextViewIface::setBottomBorderWidth( double _witdh )
00481 {
00482     KoTextParag *parag= m_textView->cursor()->parag();
00483     parag->bottomBorder().setPenWidth(_witdh) ;
00484 }
00485 
00486 
00487 void KoTextViewIface::changeCaseOfText( const QString & caseType)
00488 {
00489     KCommand *cmd=0L;
00490     if( caseType.lower() == "uppercase" )
00491     {
00492         cmd=m_textView->setChangeCaseOfTextCommand( KoChangeCaseDia::UpperCase );
00493     }
00494     else if( caseType.lower() =="lowercase" )
00495     {
00496         cmd=m_textView->setChangeCaseOfTextCommand( KoChangeCaseDia::LowerCase );
00497     }
00498     else if( caseType.lower() =="titlecase" )
00499     {
00500         cmd=m_textView->setChangeCaseOfTextCommand( KoChangeCaseDia::TitleCase );
00501     }
00502     else if( caseType.lower() =="togglecase" )
00503     {
00504         cmd=m_textView->setChangeCaseOfTextCommand( KoChangeCaseDia::ToggleCase );
00505     }
00506     else if ( caseType.lower() =="sentencecase" )
00507     {
00508         cmd=m_textView->setChangeCaseOfTextCommand( KoChangeCaseDia::SentenceCase );
00509 
00510     }
00511     else
00512         kdDebug(32500)<<"Error in void KoTextViewIface::changeCaseOfText( const QString & caseType) parameter\n";
00513     delete cmd;
00514 }
00515 
00516 bool KoTextViewIface::isALinkVariable() const
00517 {
00518     return (m_textView->linkVariable()!=0);
00519 }
00520 
00521 QString KoTextViewIface::linkVariableUrl( ) const
00522 {
00523     KoLinkVariable *var=m_textView->linkVariable();
00524     if ( !var)
00525         return QString::null;
00526     else
00527     {
00528         return var->url();
00529     }
00530 }
00531 
00532 QString KoTextViewIface::linkVariableName( ) const
00533 {
00534     KoLinkVariable *var=m_textView->linkVariable();
00535     if ( !var)
00536         return QString::null;
00537     else
00538     {
00539         return var->value();
00540     }
00541 }
00542 
00543 
00544 bool KoTextViewIface::changeLinkVariableUrl( const QString & _url) const
00545 {
00546     KoLinkVariable *var=m_textView->linkVariable();
00547     if ( !var)
00548         return false;
00549     else
00550     {
00551         var->setLink(var->value(), _url);
00552         var->recalc();
00553     }
00554     return true;
00555 }
00556 
00557 bool KoTextViewIface::changeLinkVariableName( const QString & _name) const
00558 {
00559     KoLinkVariable *var=m_textView->linkVariable();
00560     if ( !var)
00561         return false;
00562     else
00563     {
00564         var->setLink(_name, var->url());
00565         var->recalc();
00566     }
00567     return true;
00568 }
00569 
00570 bool KoTextViewIface::isANoteVariable() const
00571 {
00572     KoNoteVariable *var = dynamic_cast<KoNoteVariable *>(m_textView->variable());
00573     return (var!=0);
00574 }
00575 
00576 QString KoTextViewIface::noteVariableText() const
00577 {
00578     KoNoteVariable *var = dynamic_cast<KoNoteVariable *>(m_textView->variable());
00579     if( var )
00580         return var->note();
00581     else
00582         return QString::null;
00583 }
00584 
00585 bool KoTextViewIface::setNoteVariableText(const QString & note) const
00586 {
00587     KoNoteVariable *var = dynamic_cast<KoNoteVariable *>(m_textView->variable());
00588     if( var )
00589     {
00590         var->setNote( note);
00591         return true;
00592     }
00593     else
00594         return false;
00595 }
00596 
00597 void KoTextViewIface::removeComment()
00598 {
00599     removeComment();
00600 }
00601 
00602 QString KoTextViewIface::underlineStyle() const
00603 {
00604     return KoTextFormat::underlineStyleToString( m_textView->underlineStyle() );
00605 }
00606 
00607 QString KoTextViewIface::strikeOutStyle()const
00608 {
00609     return KoTextFormat::strikeOutStyleToString( m_textView->strikeOutStyle() );
00610 }
00611 
00612 void KoTextViewIface::addBookmarks(const QString &url)
00613 {
00614     m_textView->addBookmarks(url);
00615 }
00616 
00617 void KoTextViewIface::copyLink()
00618 {
00619     m_textView->copyLink();
00620 }
00621 
00622 void KoTextViewIface::removeLink()
00623 {
00624     m_textView->removeLink();
00625 }
00626 
00627 bool KoTextViewIface::wordByWord() const
00628 {
00629     return m_textView->wordByWord();
00630 }
00631 
00632 void KoTextViewIface::setWordByWord( bool _b )
00633 {
00634     KCommand *cmd=m_textView->setWordByWordCommand(_b );
00635     delete cmd;
00636 }
00637 
00638 void KoTextViewIface::copyTextOfComment()
00639 {
00640     m_textView->copyTextOfComment();
00641 }
00642 
00643 QString KoTextViewIface::fontAttibute()const
00644 {
00645     return KoTextFormat::attributeFontToString( m_textView->fontAttribute() );
00646 }
00647 
00648 void KoTextViewIface::insertNonbreakingSpace()
00649 {
00650     m_textView->insertNonbreakingSpace();
00651 }
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Nov 17 13:19:26 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2003