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