kpresenter

KPrTextObjectIface.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) 2002 Laurent MONTEL <lmontel@mandrakesoft.com>
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 "KPrTextObjectIface.h"
00022 #include "KPrTextObject.h"
00023 #include <KoTextViewIface.h>
00024 #include "KPrDocument.h"
00025 #include "KPrView.h"
00026 #include <KoTextObject.h>
00027 #include <kapplication.h>
00028 #include <dcopclient.h>
00029 #include "KPrCanvas.h"
00030 #include <kdebug.h>
00031 #include <kcommand.h>
00032 
00033 KPrTextObjectIface::KPrTextObjectIface( KPrTextObject *_textobject )
00034     : KPrObject2DIface(_textobject)
00035 {
00036     m_textobject = _textobject;
00037 }
00038 
00039 DCOPRef KPrTextObjectIface::startEditing()
00040 {
00041     KPrDocument *doc=m_textobject->kPresenterDocument();
00042     KPrView *view=doc->firstView();
00043     view->getCanvas()->createEditing( m_textobject);
00044     return DCOPRef( kapp->dcopClient()->appId(),
00045                     view->getCanvas()->currentTextObjectView()->dcopObject()->objId() );
00046 }
00047 
00048 bool KPrTextObjectIface::hasSelection() const
00049 {
00050     return m_textobject->textObject()->hasSelection();
00051 }
00052 
00053 QString KPrTextObjectIface::selectedText() const
00054 {
00055     return m_textobject->textObject()->selectedText();
00056 }
00057 
00058 void KPrTextObjectIface::selectAll( bool select )
00059 {
00060     m_textobject->textObject()->selectAll(select);
00061 }
00062 
00063 void KPrTextObjectIface::recalcPageNum( )
00064 {
00065     //FIXME
00066     //m_textobject->recalcPageNum(m_textobject->kPresenterDocument());
00067 }
00068 
00069 void KPrTextObjectIface::setBoldText( bool b )
00070 {
00071     KCommand *cmd=m_textobject->textObject()->setBoldCommand( b );
00072     delete cmd;
00073 }
00074 
00075 void KPrTextObjectIface::setItalicText( bool b )
00076 {
00077     KCommand *cmd=m_textobject->textObject()->setItalicCommand(b);
00078     delete cmd;
00079 }
00080 
00081 void KPrTextObjectIface::setUnderlineText( bool b )
00082 {
00083     KCommand *cmd=m_textobject->textObject()->setUnderlineCommand(b);
00084     delete cmd;
00085 }
00086 
00087 void KPrTextObjectIface::setDoubleUnderlineText(bool b)
00088 {
00089     KCommand *cmd=m_textobject->textObject()->setDoubleUnderlineCommand(b);
00090     delete cmd;
00091 }
00092 
00093 void KPrTextObjectIface::setUnderlineColor( const QColor & color )
00094 {
00095     KCommand *cmd=m_textobject->textObject()->setUnderlineColorCommand( color );
00096     delete cmd;
00097 }
00098 
00099 void KPrTextObjectIface::setStrikeOutText( bool b )
00100 {
00101     KCommand *cmd=m_textobject->textObject()->setStrikeOutCommand(b);
00102     delete cmd;
00103 }
00104 
00105 void KPrTextObjectIface::setTextColor( const QColor &col )
00106 {
00107     KCommand *cmd=m_textobject->textObject()->setTextColorCommand(col);
00108     delete cmd;
00109 }
00110 
00111 void KPrTextObjectIface::setTextPointSize( int s )
00112 {
00113     KCommand *cmd=m_textobject->textObject()->setPointSizeCommand( s );
00114     delete cmd;
00115 }
00116 
00117 void KPrTextObjectIface::setTextSubScript( bool b )
00118 {
00119     KCommand *cmd=m_textobject->textObject()->setTextSubScriptCommand( b );
00120     delete cmd;
00121 }
00122 
00123 void KPrTextObjectIface::setTextSuperScript( bool b )
00124 {
00125     KCommand *cmd=m_textobject->textObject()->setTextSuperScriptCommand( b );
00126     delete cmd;
00127 }
00128 
00129 void KPrTextObjectIface::setTextDefaultFormat()
00130 {
00131     KCommand *cmd=m_textobject->textObject()->setDefaultFormatCommand();
00132     delete cmd;
00133 }
00134 
00135 void KPrTextObjectIface::setTextBackgroundColor(const QColor & col)
00136 {
00137     KCommand *cmd=m_textobject->textObject()->setTextBackgroundColorCommand(col);
00138     delete cmd;
00139 }
00140 
00141 bool KPrTextObjectIface::textDoubleUnderline()const
00142 {
00143     return m_textobject->textObject()->textDoubleUnderline();
00144 }
00145 
00146 QColor KPrTextObjectIface::textUnderlineColor() const
00147 {
00148     return m_textobject->textObject()->textUnderlineColor();
00149 }
00150 
00151 QColor KPrTextObjectIface::textColor() const
00152 {
00153     return m_textobject->textObject()->textColor();
00154 }
00155 
00156 QFont KPrTextObjectIface::textFont() const
00157 {
00158     return m_textobject->textObject()->textFont();
00159 }
00160 
00161 QString KPrTextObjectIface::textFontFamily()const
00162 {
00163     return m_textobject->textObject()->textFontFamily();
00164 }
00165 
00166 QColor KPrTextObjectIface::textBackgroundColor() const
00167 {
00168     return m_textobject->textObject()->textBackgroundColor();
00169 }
00170 
00171 bool KPrTextObjectIface::textItalic() const
00172 {
00173     return m_textobject->textObject()->textItalic();
00174 }
00175 
00176 bool KPrTextObjectIface::textBold() const
00177 {
00178     return m_textobject->textObject()->textBold();
00179 }
00180 
00181 bool KPrTextObjectIface::textUnderline()const
00182 {
00183     return m_textobject->textObject()->textUnderline();
00184 }
00185 
00186 bool KPrTextObjectIface::textStrikeOut()const
00187 {
00188     return m_textobject->textObject()->textStrikeOut();
00189 }
00190 
00191 bool KPrTextObjectIface::textSubScript() const
00192 {
00193     return m_textobject->textObject()->textSubScript();
00194 }
00195 
00196 bool KPrTextObjectIface::textSuperScript() const
00197 {
00198     return m_textobject->textObject()->textSuperScript();
00199 }
00200 
00201 void KPrTextObjectIface::setTextFamilyFont(const QString &font)
00202 {
00203     KCommand *cmd=m_textobject->textObject()->setFamilyCommand(font);
00204     delete cmd;
00205 }
00206 
00207 void KPrTextObjectIface::changeCaseOfText( const QString & caseType)
00208 {
00209     KCommand *cmd = 0L;
00210     if( caseType.lower() == "uppercase" )
00211         cmd=m_textobject->textObject()->setChangeCaseOfTextCommand( KoChangeCaseDia::UpperCase );
00212     else if( caseType.lower() =="lowercase" )
00213         cmd=m_textobject->textObject()->setChangeCaseOfTextCommand( KoChangeCaseDia::LowerCase );
00214     else if( caseType.lower() =="titlecase" )
00215         cmd=m_textobject->textObject()->setChangeCaseOfTextCommand( KoChangeCaseDia::TitleCase );
00216     else if( caseType.lower() =="togglecase" )
00217         cmd=m_textobject->textObject()->setChangeCaseOfTextCommand( KoChangeCaseDia::ToggleCase );
00218     else if( caseType.lower() =="sentencecase" )
00219         cmd = m_textobject->textObject()->setChangeCaseOfTextCommand( KoChangeCaseDia::SentenceCase );
00220     else
00221         kdDebug(33001)<<"Error in void KWordTextFrameSetIface::changeCaseOfText( const QString & caseType) parameter\n";
00222     delete cmd;
00223 }
00224 
00225 void KPrTextObjectIface::extendTextContentsToHeight()
00226 {
00227     KCommand *cmd=m_textobject->textContentsToHeight();
00228     delete cmd;
00229 }
00230 
00231 void KPrTextObjectIface::extendTextObjectToContents()
00232 {
00233     KCommand *cmd= m_textobject->textObjectToContents();
00234     delete cmd;
00235 }
00236 
00237 void KPrTextObjectIface::setProtectContent ( bool _protect )
00238 {
00239     m_textobject->setProtectContent( _protect );
00240 }
00241 
00242 bool KPrTextObjectIface::isProtectContent() const
00243 {
00244     return m_textobject->isProtectContent();
00245 }
00246 
00247 void KPrTextObjectIface::setPtMarginLeft(double val)
00248 {
00249     m_textobject->setBLeft(val);
00250     m_textobject->kPresenterDocument()->layout( m_textobject );
00251 }
00252 
00253 void KPrTextObjectIface::setPtMarginRight(double val)
00254 {
00255     m_textobject->setBRight(val);
00256     m_textobject->kPresenterDocument()->layout( m_textobject );
00257 }
00258 
00259 void KPrTextObjectIface::setPtMarginTop(double val)
00260 {
00261     m_textobject->setBTop(val);
00262     m_textobject->kPresenterDocument()->layout( m_textobject );
00263 }
00264 
00265 void KPrTextObjectIface::setPtMarginBottom(double val)
00266 {
00267     m_textobject->setBBottom(val);
00268     m_textobject->kPresenterDocument()->layout( m_textobject );
00269 }
00270 
00271 double KPrTextObjectIface::ptMarginLeft()const
00272 {
00273     return m_textobject->bLeft();
00274 }
00275 
00276 double KPrTextObjectIface::ptMarginRight()const
00277 {
00278     return m_textobject->bRight();
00279 }
00280 
00281 double KPrTextObjectIface::ptMarginTop()const
00282 {
00283     return m_textobject->bTop();
00284 }
00285 
00286 double KPrTextObjectIface::ptMarginBottom()const
00287 {
00288     return m_textobject->bBottom();
00289 }
00290 
00291 void KPrTextObjectIface::setVerticalAligment( const QString & type)
00292 {
00293     if ( type.lower() =="center" )
00294         m_textobject->setVerticalAligment( KP_CENTER );
00295     else if ( type.lower() =="top" )
00296         m_textobject->setVerticalAligment( KP_TOP );
00297     else if ( type.lower() =="bottom" )
00298         m_textobject->setVerticalAligment( KP_BOTTOM );
00299 }
00300 
00301 QString KPrTextObjectIface::verticalAlignment() const
00302 {
00303     switch( m_textobject->verticalAlignment() )
00304     {
00305     case KP_CENTER:
00306         return QString("center");
00307         break;
00308     case KP_TOP:
00309         return QString("top");
00310         break;
00311     case KP_BOTTOM:
00312         return QString("bottom");
00313         break;
00314     default:
00315         break;
00316     }
00317     return QString::null;
00318 }
00319 
00320 //bool KPrTextObjectIface::textShadow() const
00321 //{
00322     //return m_textobject->textObject()->textShadow();
00323 //}
00324 
00325 //void KPrTextObjectIface::setTextShadow( bool b )
00326 //{
00327     //KCommand *cmd=m_textobject->textObject()->setShadowTextCommand( b );
00328     //delete cmd;
00329 //}
00330 
00331 double KPrTextObjectIface::relativeTextSize() const
00332 {
00333     return m_textobject->textObject()->relativeTextSize();
00334 }
00335 
00336 void KPrTextObjectIface::setRelativeTextSize( double _size )
00337 {
00338     KCommand *cmd=m_textobject->textObject()->setRelativeTextSizeCommand(_size );
00339     delete cmd;
00340 }
00341 
00342 bool KPrTextObjectIface::wordByWord() const
00343 {
00344     return m_textobject->textObject()->wordByWord();
00345 }
00346 
00347 void KPrTextObjectIface::setWordByWord( bool _b )
00348 {
00349     KCommand *cmd=m_textobject->textObject()->setWordByWordCommand(_b );
00350     delete cmd;
00351 }
00352 
00353 QString KPrTextObjectIface::fontAttribute()const
00354 {
00355     return KoTextFormat::attributeFontToString( m_textobject->textObject()->fontAttribute() );
00356 }
00357 
00358 QString KPrTextObjectIface::underlineLineStyle() const
00359 {
00360     return KoTextFormat::underlineStyleToString( m_textobject->textObject()->underlineStyle() );
00361 }
00362 
00363 QString KPrTextObjectIface::strikeOutLineStyle()const
00364 {
00365     return KoTextFormat::strikeOutStyleToString( m_textobject->textObject()->strikeOutStyle() );
00366 }
KDE Home | KDE Accessibility Home | Description of Access Keys