kpresenter

KPrTextObjectIface.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2002 Laurent MONTEL <lmontel@mandrakesoft.com>
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 "KPrTextObjectIface.h"
21#include "KPrTextObject.h"
22#include <KoTextViewIface.h>
23#include "KPrDocument.h"
24#include "KPrView.h"
25#include <KoTextObject.h>
26#include <tdeapplication.h>
27#include <dcopclient.h>
28#include "KPrCanvas.h"
29#include <kdebug.h>
30#include <kcommand.h>
31
32KPrTextObjectIface::KPrTextObjectIface( KPrTextObject *_textobject )
33 : KPrObject2DIface(_textobject)
34{
35 m_textobject = _textobject;
36}
37
38DCOPRef KPrTextObjectIface::startEditing()
39{
40 KPrDocument *doc=m_textobject->kPresenterDocument();
41 KPrView *view=doc->firstView();
42 view->getCanvas()->createEditing( m_textobject);
43 return DCOPRef( kapp->dcopClient()->appId(),
44 view->getCanvas()->currentTextObjectView()->dcopObject()->objId() );
45}
46
47bool KPrTextObjectIface::hasSelection() const
48{
49 return m_textobject->textObject()->hasSelection();
50}
51
52TQString KPrTextObjectIface::selectedText() const
53{
54 return m_textobject->textObject()->selectedText();
55}
56
57void KPrTextObjectIface::selectAll( bool select )
58{
59 m_textobject->textObject()->selectAll(select);
60}
61
62void KPrTextObjectIface::recalcPageNum( )
63{
64 //FIXME
65 //m_textobject->recalcPageNum(m_textobject->kPresenterDocument());
66}
67
68void KPrTextObjectIface::setBoldText( bool b )
69{
70 KCommand *cmd=m_textobject->textObject()->setBoldCommand( b );
71 delete cmd;
72}
73
74void KPrTextObjectIface::setItalicText( bool b )
75{
76 KCommand *cmd=m_textobject->textObject()->setItalicCommand(b);
77 delete cmd;
78}
79
80void KPrTextObjectIface::setUnderlineText( bool b )
81{
82 KCommand *cmd=m_textobject->textObject()->setUnderlineCommand(b);
83 delete cmd;
84}
85
86void KPrTextObjectIface::setDoubleUnderlineText(bool b)
87{
88 KCommand *cmd=m_textobject->textObject()->setDoubleUnderlineCommand(b);
89 delete cmd;
90}
91
92void KPrTextObjectIface::setUnderlineColor( const TQColor & color )
93{
94 KCommand *cmd=m_textobject->textObject()->setUnderlineColorCommand( color );
95 delete cmd;
96}
97
98void KPrTextObjectIface::setStrikeOutText( bool b )
99{
100 KCommand *cmd=m_textobject->textObject()->setStrikeOutCommand(b);
101 delete cmd;
102}
103
104void KPrTextObjectIface::setTextColor( const TQColor &col )
105{
106 KCommand *cmd=m_textobject->textObject()->setTextColorCommand(col);
107 delete cmd;
108}
109
110void KPrTextObjectIface::setTextPointSize( int s )
111{
112 KCommand *cmd=m_textobject->textObject()->setPointSizeCommand( s );
113 delete cmd;
114}
115
116void KPrTextObjectIface::setTextSubScript( bool b )
117{
118 KCommand *cmd=m_textobject->textObject()->setTextSubScriptCommand( b );
119 delete cmd;
120}
121
122void KPrTextObjectIface::setTextSuperScript( bool b )
123{
124 KCommand *cmd=m_textobject->textObject()->setTextSuperScriptCommand( b );
125 delete cmd;
126}
127
128void KPrTextObjectIface::setTextDefaultFormat()
129{
130 KCommand *cmd=m_textobject->textObject()->setDefaultFormatCommand();
131 delete cmd;
132}
133
134void KPrTextObjectIface::setTextBackgroundColor(const TQColor & col)
135{
136 KCommand *cmd=m_textobject->textObject()->setTextBackgroundColorCommand(col);
137 delete cmd;
138}
139
140bool KPrTextObjectIface::textDoubleUnderline()const
141{
142 return m_textobject->textObject()->textDoubleUnderline();
143}
144
145TQColor KPrTextObjectIface::textUnderlineColor() const
146{
147 return m_textobject->textObject()->textUnderlineColor();
148}
149
150TQColor KPrTextObjectIface::textColor() const
151{
152 return m_textobject->textObject()->textColor();
153}
154
155TQFont KPrTextObjectIface::textFont() const
156{
157 return m_textobject->textObject()->textFont();
158}
159
160TQString KPrTextObjectIface::textFontFamily()const
161{
162 return m_textobject->textObject()->textFontFamily();
163}
164
165TQColor KPrTextObjectIface::textBackgroundColor() const
166{
167 return m_textobject->textObject()->textBackgroundColor();
168}
169
170bool KPrTextObjectIface::textItalic() const
171{
172 return m_textobject->textObject()->textItalic();
173}
174
175bool KPrTextObjectIface::textBold() const
176{
177 return m_textobject->textObject()->textBold();
178}
179
180bool KPrTextObjectIface::textUnderline()const
181{
182 return m_textobject->textObject()->textUnderline();
183}
184
185bool KPrTextObjectIface::textStrikeOut()const
186{
187 return m_textobject->textObject()->textStrikeOut();
188}
189
190bool KPrTextObjectIface::textSubScript() const
191{
192 return m_textobject->textObject()->textSubScript();
193}
194
195bool KPrTextObjectIface::textSuperScript() const
196{
197 return m_textobject->textObject()->textSuperScript();
198}
199
200void KPrTextObjectIface::setTextFamilyFont(const TQString &font)
201{
202 KCommand *cmd=m_textobject->textObject()->setFamilyCommand(font);
203 delete cmd;
204}
205
206void KPrTextObjectIface::changeCaseOfText( const TQString & caseType)
207{
208 KCommand *cmd = 0L;
209 if( caseType.lower() == "uppercase" )
210 cmd=m_textobject->textObject()->setChangeCaseOfTextCommand( KoChangeCaseDia::UpperCase );
211 else if( caseType.lower() =="lowercase" )
212 cmd=m_textobject->textObject()->setChangeCaseOfTextCommand( KoChangeCaseDia::LowerCase );
213 else if( caseType.lower() =="titlecase" )
214 cmd=m_textobject->textObject()->setChangeCaseOfTextCommand( KoChangeCaseDia::TitleCase );
215 else if( caseType.lower() =="togglecase" )
216 cmd=m_textobject->textObject()->setChangeCaseOfTextCommand( KoChangeCaseDia::ToggleCase );
217 else if( caseType.lower() =="sentencecase" )
218 cmd = m_textobject->textObject()->setChangeCaseOfTextCommand( KoChangeCaseDia::SentenceCase );
219 else
220 kdDebug(33001)<<"Error in void KWordTextFrameSetIface::changeCaseOfText( const TQString & caseType) parameter\n";
221 delete cmd;
222}
223
224void KPrTextObjectIface::extendTextContentsToHeight()
225{
226 KCommand *cmd=m_textobject->textContentsToHeight();
227 delete cmd;
228}
229
230void KPrTextObjectIface::extendTextObjectToContents()
231{
232 KCommand *cmd= m_textobject->textObjectToContents();
233 delete cmd;
234}
235
236void KPrTextObjectIface::setProtectContent ( bool _protect )
237{
238 m_textobject->setProtectContent( _protect );
239}
240
241bool KPrTextObjectIface::isProtectContent() const
242{
243 return m_textobject->isProtectContent();
244}
245
246void KPrTextObjectIface::setPtMarginLeft(double val)
247{
248 m_textobject->setBLeft(val);
249 m_textobject->kPresenterDocument()->layout( m_textobject );
250}
251
252void KPrTextObjectIface::setPtMarginRight(double val)
253{
254 m_textobject->setBRight(val);
255 m_textobject->kPresenterDocument()->layout( m_textobject );
256}
257
258void KPrTextObjectIface::setPtMarginTop(double val)
259{
260 m_textobject->setBTop(val);
261 m_textobject->kPresenterDocument()->layout( m_textobject );
262}
263
264void KPrTextObjectIface::setPtMarginBottom(double val)
265{
266 m_textobject->setBBottom(val);
267 m_textobject->kPresenterDocument()->layout( m_textobject );
268}
269
270double KPrTextObjectIface::ptMarginLeft()const
271{
272 return m_textobject->bLeft();
273}
274
275double KPrTextObjectIface::ptMarginRight()const
276{
277 return m_textobject->bRight();
278}
279
280double KPrTextObjectIface::ptMarginTop()const
281{
282 return m_textobject->bTop();
283}
284
285double KPrTextObjectIface::ptMarginBottom()const
286{
287 return m_textobject->bBottom();
288}
289
290void KPrTextObjectIface::setVerticalAligment( const TQString & type)
291{
292 if ( type.lower() =="center" )
293 m_textobject->setVerticalAligment( KP_CENTER );
294 else if ( type.lower() =="top" )
295 m_textobject->setVerticalAligment( KP_TOP );
296 else if ( type.lower() =="bottom" )
297 m_textobject->setVerticalAligment( KP_BOTTOM );
298}
299
300TQString KPrTextObjectIface::verticalAlignment() const
301{
302 switch( m_textobject->verticalAlignment() )
303 {
304 case KP_CENTER:
305 return TQString("center");
306 break;
307 case KP_TOP:
308 return TQString("top");
309 break;
310 case KP_BOTTOM:
311 return TQString("bottom");
312 break;
313 default:
314 break;
315 }
316 return TQString();
317}
318
319//bool KPrTextObjectIface::textShadow() const
320//{
321 //return m_textobject->textObject()->textShadow();
322//}
323
324//void KPrTextObjectIface::setTextShadow( bool b )
325//{
326 //KCommand *cmd=m_textobject->textObject()->setShadowTextCommand( b );
327 //delete cmd;
328//}
329
330double KPrTextObjectIface::relativeTextSize() const
331{
332 return m_textobject->textObject()->relativeTextSize();
333}
334
335void KPrTextObjectIface::setRelativeTextSize( double _size )
336{
337 KCommand *cmd=m_textobject->textObject()->setRelativeTextSizeCommand(_size );
338 delete cmd;
339}
340
341bool KPrTextObjectIface::wordByWord() const
342{
343 return m_textobject->textObject()->wordByWord();
344}
345
346void KPrTextObjectIface::setWordByWord( bool _b )
347{
348 KCommand *cmd=m_textobject->textObject()->setWordByWordCommand(_b );
349 delete cmd;
350}
351
352TQString KPrTextObjectIface::fontAttribute()const
353{
354 return KoTextFormat::attributeFontToString( m_textobject->textObject()->fontAttribute() );
355}
356
357TQString KPrTextObjectIface::underlineLineStyle() const
358{
359 return KoTextFormat::underlineStyleToString( m_textobject->textObject()->underlineStyle() );
360}
361
362TQString KPrTextObjectIface::strikeOutLineStyle()const
363{
364 return KoTextFormat::strikeOutStyleToString( m_textobject->textObject()->strikeOutStyle() );
365}