Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "PresenterTextView.hxx"
31 : :
32 : : #include <i18npool/mslangid.hxx>
33 : : #include <cppcanvas/vclfactory.hxx>
34 : : #include <svl/itempool.hxx>
35 : : #include <svl/itemset.hxx>
36 : : #include <unotools/linguprops.hxx>
37 : : #include <unotools/lingucfg.hxx>
38 : : #include <editeng/colritem.hxx>
39 : : #include <editeng/editeng.hxx>
40 : : #include <editeng/editstat.hxx>
41 : : #include <editeng/eeitem.hxx>
42 : : #include <editeng/fhgtitem.hxx>
43 : : #include <editeng/fontitem.hxx>
44 : : #include <svx/xflclit.hxx>
45 : : #include <vcl/bitmapex.hxx>
46 : : #include <vcl/svapp.hxx>
47 : : #include <vcl/virdev.hxx>
48 : : #include <com/sun/star/awt/FontDescriptor.hpp>
49 : : #include <com/sun/star/awt/Size.hpp>
50 : : #include <com/sun/star/rendering/XSpriteCanvas.hpp>
51 : : #include <com/sun/star/util/Color.hpp>
52 : : #include <com/sun/star/i18n/ScriptType.hpp>
53 : :
54 : :
55 : : using namespace ::com::sun::star;
56 : : using namespace ::com::sun::star::uno;
57 : : using namespace ::com::sun::star::lang;
58 : : using ::rtl::OUString;
59 : :
60 : : namespace sd { namespace presenter {
61 : :
62 : : //===== Service ===============================================================
63 : :
64 : 0 : Reference<XInterface> SAL_CALL PresenterTextViewService_createInstance (
65 : : const Reference<XComponentContext>& rxContext)
66 : : {
67 [ # # ]: 0 : return Reference<XInterface>(static_cast<XWeak*>(new PresenterTextView(rxContext)));
68 : : }
69 : :
70 : :
71 : :
72 : :
73 : 22 : ::rtl::OUString PresenterTextViewService_getImplementationName (void) throw(RuntimeException)
74 : : {
75 : 22 : return OUString("com.sun.star.comp.Draw.PresenterTextView");
76 : : }
77 : :
78 : :
79 : :
80 : :
81 : 0 : Sequence<rtl::OUString> SAL_CALL PresenterTextViewService_getSupportedServiceNames (void)
82 : : throw (RuntimeException)
83 : : {
84 [ # # ][ # # ]: 0 : static const ::rtl::OUString sServiceName("com.sun.star.drawing.PresenterTextView");
85 : 0 : return Sequence<rtl::OUString>(&sServiceName, 1);
86 : : }
87 : :
88 : :
89 : :
90 : : //===== PresenterTextView::Implementation =====================================
91 : :
92 : : class PresenterTextView::Implementation
93 : : {
94 : : public:
95 : : const OUString msTextPropertyName;
96 : : const OUString msBitmapPropertyName;
97 : : const OUString msSizePropertyName;
98 : : const OUString msBackgroundColorPropertyName;
99 : : const OUString msTextColorPropertyName;
100 : : const OUString msFontDescriptorPropertyName;
101 : : const OUString msTopPropertyName;
102 : : const OUString msTopRelativePropertyName;
103 : : const OUString msTotalHeightPropertyName;
104 : :
105 : : Implementation (void);
106 : : ~Implementation (void);
107 : :
108 : : void SetCanvas (const cppcanvas::CanvasSharedPtr& rCanvas);
109 : : void SetSize (const Size aSize);
110 : : void SetBackgroundColor (const Color aColor);
111 : : void SetTextColor (const Color aColor);
112 : : void SetFontDescriptor (const awt::FontDescriptor& rFontDescriptor);
113 : : sal_Int32 GetTop (void) const;
114 : : void SetTop (const sal_Int32 nTop);
115 : : void SetText (const OUString& Text);
116 : : sal_Int32 ParseDistance (const OUString& rsDistance) const;
117 : : Reference<rendering::XBitmap> GetBitmap (void);
118 : : sal_Int32 GetTotalHeight (void);
119 : :
120 : : private:
121 : : Reference<rendering::XBitmap> mxBitmap;
122 : : cppcanvas::CanvasSharedPtr mpCanvas;
123 : : VirtualDevice* mpOutputDevice;
124 : : EditEngine* mpEditEngine;
125 : : SfxItemPool* mpEditEngineItemPool;
126 : : Size maSize;
127 : : Color maBackgroundColor;
128 : : Color maTextColor;
129 : : String msText;
130 : : sal_Int32 mnTop;
131 : : sal_Int32 mnTotalHeight;
132 : :
133 : : EditEngine * GetEditEngine (void);
134 : : EditEngine* CreateEditEngine (void);
135 : : void CheckTop (void);
136 : : };
137 : :
138 : :
139 : :
140 : :
141 : : //===== PresenterTextView =====================================================
142 : :
143 : 0 : PresenterTextView::PresenterTextView (const Reference<XComponentContext>& rxContext)
144 : : : PresenterTextViewInterfaceBase(),
145 [ # # ][ # # ]: 0 : mpImplementation(new Implementation())
[ # # ]
146 : : {
147 : : (void)rxContext;
148 : 0 : }
149 : :
150 : :
151 : :
152 : :
153 [ # # ][ # # ]: 0 : PresenterTextView::~PresenterTextView (void)
154 : : {
155 [ # # ]: 0 : }
156 : :
157 : :
158 : :
159 : :
160 : 0 : void SAL_CALL PresenterTextView::disposing (void)
161 : : {
162 : 0 : mpImplementation.reset();
163 : 0 : }
164 : :
165 : :
166 : :
167 : :
168 : : //----- XInitialization -------------------------------------------------------
169 : :
170 : 0 : void SAL_CALL PresenterTextView::initialize (const Sequence<Any>& rArguments)
171 : : throw (Exception, RuntimeException)
172 : : {
173 : 0 : ThrowIfDisposed();
174 : :
175 [ # # ]: 0 : if (rArguments.getLength() == 1)
176 : : {
177 : : try
178 : : {
179 [ # # ]: 0 : Reference<rendering::XBitmapCanvas> xCanvas (rArguments[0], UNO_QUERY_THROW);
180 [ # # ]: 0 : if (xCanvas.is())
181 : : {
182 : : mpImplementation->SetCanvas(
183 [ # # ][ # # ]: 0 : cppcanvas::VCLFactory::getInstance().createCanvas(xCanvas));
[ # # ][ # # ]
[ # # ][ # # ]
184 : 0 : }
185 : : }
186 [ # # ]: 0 : catch (RuntimeException&)
187 : : {
188 : 0 : throw;
189 : : }
190 : : }
191 : : else
192 : : {
193 : : throw RuntimeException("PresenterTextView: invalid number of arguments",
194 [ # # ][ # # ]: 0 : static_cast<XWeak*>(this));
195 : : }
196 : 0 : }
197 : :
198 : :
199 : :
200 : :
201 : : //-----------------------------------------------------------------------------
202 : :
203 : 0 : Any PresenterTextView::GetPropertyValue (const OUString& rsPropertyName)
204 : : {
205 : 0 : ThrowIfDisposed();
206 : :
207 [ # # ]: 0 : if (rsPropertyName == mpImplementation->msBitmapPropertyName)
208 : : {
209 [ # # ]: 0 : return Any(mpImplementation->GetBitmap());
210 : : }
211 [ # # ]: 0 : else if (rsPropertyName == mpImplementation->msTopPropertyName)
212 : : {
213 [ # # ]: 0 : return Any(mpImplementation->GetTop());
214 : : }
215 [ # # ]: 0 : else if (rsPropertyName == mpImplementation->msTotalHeightPropertyName)
216 : : {
217 [ # # ]: 0 : return Any(mpImplementation->GetTotalHeight());
218 : : }
219 : :
220 : 0 : return Any();
221 : : }
222 : :
223 : :
224 : :
225 : :
226 : 0 : Any PresenterTextView::SetPropertyValue (
227 : : const ::rtl::OUString& rsPropertyName,
228 : : const css::uno::Any& rValue)
229 : : {
230 : 0 : ThrowIfDisposed();
231 : :
232 : 0 : Any aOldValue;
233 [ # # ]: 0 : if (rsPropertyName == mpImplementation->msTextPropertyName)
234 : : {
235 : 0 : OUString sText;
236 [ # # ]: 0 : if (rValue >>= sText)
237 [ # # ]: 0 : mpImplementation->SetText(sText);
238 : : }
239 [ # # ]: 0 : else if (rsPropertyName == mpImplementation->msSizePropertyName)
240 : : {
241 : 0 : awt::Size aSize;
242 [ # # ][ # # ]: 0 : if (rValue >>= aSize)
243 [ # # ]: 0 : mpImplementation->SetSize(Size(aSize.Width,aSize.Height));
244 : : }
245 [ # # ]: 0 : else if (rsPropertyName == mpImplementation->msBackgroundColorPropertyName)
246 : : {
247 : 0 : util::Color aColor = util::Color();
248 [ # # ]: 0 : if (rValue >>= aColor)
249 [ # # ]: 0 : mpImplementation->SetBackgroundColor(Color(aColor));
250 : : }
251 [ # # ]: 0 : else if (rsPropertyName == mpImplementation->msTextColorPropertyName)
252 : : {
253 : 0 : util::Color aColor = util::Color();
254 [ # # ]: 0 : if (rValue >>= aColor)
255 [ # # ]: 0 : mpImplementation->SetTextColor(Color(aColor));
256 : : }
257 [ # # ]: 0 : else if (rsPropertyName == mpImplementation->msFontDescriptorPropertyName)
258 : : {
259 : 0 : awt::FontDescriptor aFontDescriptor;
260 [ # # ][ # # ]: 0 : if (rValue >>= aFontDescriptor)
261 [ # # ]: 0 : mpImplementation->SetFontDescriptor(aFontDescriptor);
262 : : }
263 [ # # ]: 0 : else if (rsPropertyName == mpImplementation->msTopPropertyName)
264 : : {
265 : 0 : sal_Int32 nTop = 0;
266 [ # # ]: 0 : if (rValue >>= nTop)
267 [ # # ]: 0 : mpImplementation->SetTop(nTop);
268 : : }
269 [ # # ]: 0 : else if (rsPropertyName == mpImplementation->msTopRelativePropertyName)
270 : : {
271 : 0 : OUString sDistance;
272 [ # # ]: 0 : if (rValue >>= sDistance)
273 : : mpImplementation->SetTop(
274 : 0 : mpImplementation->GetTop()
275 [ # # ][ # # ]: 0 : + mpImplementation->ParseDistance(sDistance));
276 : : }
277 : 0 : return aOldValue;
278 : : }
279 : :
280 : :
281 : :
282 : :
283 : 0 : void PresenterTextView::ThrowIfDisposed (void)
284 : : throw (::com::sun::star::lang::DisposedException)
285 : : {
286 [ # # ]: 0 : if (PresenterTextViewInterfaceBase::rBHelper.bDisposed
[ # # # # ]
[ # # ]
287 : : || PresenterTextViewInterfaceBase::rBHelper.bInDispose
288 : 0 : || mpImplementation.get()==NULL)
289 : : {
290 : : throw lang::DisposedException ("PresenterTextView object has already been disposed",
291 [ # # ][ # # ]: 0 : static_cast<uno::XWeak*>(this));
292 : : }
293 : 0 : }
294 : :
295 : :
296 : :
297 : :
298 : : //===== PresenterTextView::Implementation =====================================
299 : :
300 : 0 : PresenterTextView::Implementation::Implementation (void)
301 : : : msTextPropertyName("Text"),
302 : : msBitmapPropertyName("Bitmap"),
303 : : msSizePropertyName("Size"),
304 : : msBackgroundColorPropertyName("BackgroundColor"),
305 : : msTextColorPropertyName("TextColor"),
306 : : msFontDescriptorPropertyName("FontDescriptor"),
307 : : msTopPropertyName("Top"),
308 : : msTopRelativePropertyName("RelativeTop"),
309 : : msTotalHeightPropertyName("TotalHeight"),
310 : : mxBitmap(),
311 : : mpCanvas(),
312 [ # # ]: 0 : mpOutputDevice(new VirtualDevice(*Application::GetDefaultDevice(), 0, 0)),
313 : : mpEditEngine(NULL),
314 [ # # ]: 0 : mpEditEngineItemPool(EditEngine::CreatePool()),
315 : : maSize(100,100),
316 : : maBackgroundColor(0xffffffff),
317 : : maTextColor(0x00000000),
318 : : msText(),
319 : : mnTop(0),
320 [ # # ][ # # ]: 0 : mnTotalHeight(-1)
[ # # ][ # # ]
321 : : {
322 [ # # ][ # # ]: 0 : mpOutputDevice->SetMapMode(MAP_PIXEL);
[ # # ]
323 : :
324 [ # # ]: 0 : GetEditEngine();
325 : 0 : }
326 : :
327 : :
328 : :
329 : :
330 [ # # ][ # # ]: 0 : PresenterTextView::Implementation::~Implementation (void)
331 : : {
332 [ # # ][ # # ]: 0 : delete mpEditEngine;
333 [ # # ]: 0 : SfxItemPool::Free(mpEditEngineItemPool);
334 [ # # ][ # # ]: 0 : delete mpOutputDevice;
335 : 0 : }
336 : :
337 : :
338 : :
339 : :
340 : 0 : EditEngine * PresenterTextView::Implementation::GetEditEngine (void)
341 : : {
342 [ # # ]: 0 : if (mpEditEngine == NULL)
343 : 0 : mpEditEngine = CreateEditEngine ();
344 : 0 : return mpEditEngine;
345 : : }
346 : :
347 : :
348 : :
349 : :
350 : 0 : EditEngine* PresenterTextView::Implementation::CreateEditEngine (void)
351 : : {
352 : 0 : EditEngine* pEditEngine = mpEditEngine;
353 [ # # ]: 0 : if (pEditEngine == NULL)
354 : : {
355 : : //
356 : : // set fonts to be used
357 : : //
358 [ # # ]: 0 : SvtLinguOptions aOpt;
359 [ # # ][ # # ]: 0 : SvtLinguConfig().GetOptions( aOpt );
[ # # ]
360 : :
361 : : struct FontDta {
362 : : sal_Int16 nFallbackLang;
363 : : sal_Int16 nLang;
364 : : sal_uInt16 nFontType;
365 : : sal_uInt16 nFontInfoId;
366 : : } aTable[3] =
367 : : {
368 : : // info to get western font to be used
369 : : { LANGUAGE_ENGLISH_US, LANGUAGE_NONE,
370 : : DEFAULTFONT_SERIF, EE_CHAR_FONTINFO },
371 : : // info to get CJK font to be used
372 : : { LANGUAGE_JAPANESE, LANGUAGE_NONE,
373 : : DEFAULTFONT_CJK_TEXT, EE_CHAR_FONTINFO_CJK },
374 : : // info to get CTL font to be used
375 : : { LANGUAGE_ARABIC_SAUDI_ARABIA, LANGUAGE_NONE,
376 : : DEFAULTFONT_CTL_TEXT, EE_CHAR_FONTINFO_CTL }
377 : 0 : };
378 [ # # ]: 0 : aTable[0].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN);
379 [ # # ]: 0 : aTable[1].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN);
380 [ # # ]: 0 : aTable[2].nLang = MsLangId::resolveSystemLanguageByScriptType(aOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX);
381 : :
382 [ # # ]: 0 : for (int i = 0; i < 3; ++i)
383 : : {
384 : 0 : const FontDta &rFntDta = aTable[i];
385 : : LanguageType nLang = (LANGUAGE_NONE == rFntDta.nLang) ?
386 [ # # ]: 0 : rFntDta.nFallbackLang : rFntDta.nLang;
387 [ # # ]: 0 : Font aFont = Application::GetDefaultDevice()->GetDefaultFont(
388 [ # # ][ # # ]: 0 : rFntDta.nFontType, nLang, DEFAULTFONT_FLAGS_ONLYONE);
[ # # ]
389 : : mpEditEngineItemPool->SetPoolDefaultItem(
390 : : SvxFontItem(
391 : : aFont.GetFamily(),
392 [ # # ]: 0 : aFont.GetName(),
393 [ # # ]: 0 : aFont.GetStyleName(),
394 : : aFont.GetPitch(),
395 [ # # ]: 0 : aFont.GetCharSet(),
396 [ # # ][ # # ]: 0 : rFntDta.nFontInfoId));
[ # # ][ # # ]
[ # # ]
397 [ # # ]: 0 : }
398 : :
399 : :
400 [ # # ][ # # ]: 0 : pEditEngine = new EditEngine (mpEditEngineItemPool);
401 : :
402 [ # # ]: 0 : pEditEngine->EnableUndo (sal_True);
403 : : pEditEngine->SetDefTab (sal_uInt16(
404 [ # # ][ # # ]: 0 : Application::GetDefaultDevice()->GetTextWidth(rtl::OUString("XXXX"))));
[ # # ][ # # ]
[ # # ]
405 : :
406 : : pEditEngine->SetControlWord(
407 [ # # ]: 0 : (pEditEngine->GetControlWord()
408 : : | EE_CNTRL_AUTOINDENTING) &
409 : : (~EE_CNTRL_UNDOATTRIBS) &
410 [ # # ]: 0 : (~EE_CNTRL_PASTESPECIAL));
411 : :
412 [ # # ][ # # ]: 0 : pEditEngine->SetWordDelimiters (rtl::OUString(" .=+-*/(){}[];\""));
[ # # ]
413 [ # # ][ # # ]: 0 : pEditEngine->SetRefMapMode (MAP_PIXEL);
[ # # ]
414 [ # # ]: 0 : pEditEngine->SetPaperSize (Size(800, 0));
415 [ # # ]: 0 : pEditEngine->EraseVirtualDevice();
416 [ # # ][ # # ]: 0 : pEditEngine->ClearModifyFlag();
417 : : }
418 : :
419 : 0 : return pEditEngine;
420 : : }
421 : :
422 : :
423 : :
424 : :
425 : 0 : void PresenterTextView::Implementation::SetCanvas (const cppcanvas::CanvasSharedPtr& rpCanvas)
426 : : {
427 : 0 : mpCanvas = rpCanvas;
428 : 0 : mxBitmap = NULL;
429 : 0 : }
430 : :
431 : :
432 : :
433 : :
434 : 0 : void PresenterTextView::Implementation::SetSize (const Size aSize)
435 : : {
436 : : DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
437 : :
438 : 0 : maSize = aSize;
439 : 0 : mpEditEngine->SetPaperSize(maSize);
440 : 0 : mnTotalHeight = -1;
441 : 0 : mxBitmap = NULL;
442 : 0 : }
443 : :
444 : :
445 : :
446 : :
447 : 0 : void PresenterTextView::Implementation::SetBackgroundColor (const Color aColor)
448 : : {
449 : 0 : maBackgroundColor = aColor;
450 : 0 : mxBitmap = NULL;
451 : :
452 : : DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
453 : : DBG_ASSERT(mpEditEngineItemPool!=NULL, "EditEngineItemPool missing");
454 : 0 : mpEditEngine->SetBackgroundColor(aColor);
455 : 0 : mpEditEngine->EnableAutoColor(sal_False);
456 : 0 : mpEditEngine->ForceAutoColor(sal_False);
457 : 0 : }
458 : :
459 : :
460 : :
461 : :
462 : 0 : void PresenterTextView::Implementation::SetTextColor (const Color aColor)
463 : : {
464 : 0 : maTextColor = aColor;
465 : 0 : mxBitmap = NULL;
466 : :
467 : : DBG_ASSERT(mpEditEngineItemPool!=NULL, "EditEngineItemPool missing");
468 [ # # ]: 0 : mpEditEngineItemPool->SetPoolDefaultItem(SvxColorItem(aColor, EE_CHAR_COLOR));
469 : 0 : }
470 : :
471 : :
472 : :
473 : :
474 : 0 : void PresenterTextView::Implementation::SetFontDescriptor (
475 : : const awt::FontDescriptor& rFontDescriptor)
476 : : {
477 [ # # ]: 0 : mxBitmap = NULL;
478 : :
479 : : DBG_ASSERT(mpEditEngineItemPool!=NULL, "EditEngineItemPool missing");
480 : :
481 : 0 : const sal_Int32 nFontHeight = rFontDescriptor.Height;
482 : :
483 : : SvxFontHeightItem aFontHeight(
484 : : Application::GetDefaultDevice()->LogicToPixel(
485 [ # # ][ # # ]: 0 : Size(0, nFontHeight), MapMode (MAP_POINT)).Height(),
[ # # ][ # # ]
486 : : 100,
487 [ # # ]: 0 : EE_CHAR_FONTHEIGHT);
488 [ # # ]: 0 : mpEditEngineItemPool->SetPoolDefaultItem( aFontHeight);
489 : 0 : aFontHeight.SetWhich (EE_CHAR_FONTHEIGHT_CJK);
490 [ # # ]: 0 : mpEditEngineItemPool->SetPoolDefaultItem( aFontHeight);
491 : 0 : aFontHeight.SetWhich (EE_CHAR_FONTHEIGHT_CTL);
492 [ # # ]: 0 : mpEditEngineItemPool->SetPoolDefaultItem( aFontHeight);
493 : :
494 [ # # ]: 0 : SvxFontItem aSvxFontItem (EE_CHAR_FONTINFO);
495 [ # # ][ # # ]: 0 : aSvxFontItem.SetFamilyName( rFontDescriptor.Name );
[ # # ]
496 [ # # ]: 0 : mpEditEngineItemPool->SetPoolDefaultItem(aSvxFontItem);
497 : :
498 : 0 : mnTotalHeight = -1;
499 [ # # ]: 0 : mxBitmap = NULL;
500 : :
501 [ # # ]: 0 : CheckTop();
502 [ # # ][ # # ]: 0 : mnTotalHeight = -1;
503 : 0 : }
504 : :
505 : :
506 : :
507 : :
508 : 0 : sal_Int32 PresenterTextView::Implementation::GetTop (void) const
509 : : {
510 : 0 : return mnTop;
511 : : }
512 : :
513 : :
514 : :
515 : :
516 : 0 : void PresenterTextView::Implementation::SetTop (const sal_Int32 nTop)
517 : : {
518 [ # # ]: 0 : if (nTop == mnTop)
519 : 0 : return;
520 : :
521 : 0 : mnTop = nTop;
522 : 0 : mxBitmap = NULL;
523 : 0 : CheckTop();
524 : : }
525 : :
526 : :
527 : :
528 : :
529 : 0 : void PresenterTextView::Implementation::SetText (const OUString& rText)
530 : : {
531 : : DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
532 : 0 : msText = rText;
533 : 0 : mpEditEngine->SetPaperSize(maSize);
534 : 0 : mnTotalHeight = -1;
535 : 0 : mxBitmap = NULL;
536 : 0 : }
537 : :
538 : :
539 : :
540 : :
541 : 0 : sal_Int32 PresenterTextView::Implementation::ParseDistance (const OUString& rsDistance) const
542 : : {
543 : : DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
544 : 0 : sal_Int32 nDistance (0);
545 [ # # ]: 0 : if (rsDistance.endsWithAsciiL("px", 2))
546 : : {
547 : 0 : nDistance = rsDistance.copy(0,rsDistance.getLength()-2).toInt32();
548 : : }
549 [ # # ]: 0 : else if (rsDistance.endsWithAsciiL("l", 1))
550 : : {
551 : 0 : const sal_Int32 nLines (rsDistance.copy(0,rsDistance.getLength()-1).toInt32());
552 : : // Take the height of the first line as the height of every line.
553 : 0 : const sal_uInt32 nFirstLineHeight (mpEditEngine->GetLineHeight(0,0));
554 : 0 : nDistance = nFirstLineHeight * nLines;
555 : : }
556 : :
557 : 0 : return nDistance;
558 : : }
559 : :
560 : :
561 : :
562 : :
563 : 0 : Reference<rendering::XBitmap> PresenterTextView::Implementation::GetBitmap (void)
564 : : {
565 : : DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
566 : :
567 [ # # ]: 0 : if ( ! mxBitmap.is())
568 : : {
569 [ # # ]: 0 : if (mpOutputDevice != NULL)
570 [ # # ][ # # ]: 0 : delete mpOutputDevice;
571 [ # # ][ # # ]: 0 : mpOutputDevice = new VirtualDevice(*Application::GetDefaultDevice(), 0, 0);
[ # # ]
572 [ # # ][ # # ]: 0 : mpOutputDevice->SetMapMode(MAP_PIXEL);
[ # # ]
573 [ # # ]: 0 : mpOutputDevice->SetOutputSizePixel(maSize, sal_True);
574 [ # # ]: 0 : mpOutputDevice->SetLineColor();
575 [ # # ]: 0 : mpOutputDevice->SetFillColor();
576 [ # # ][ # # ]: 0 : mpOutputDevice->SetBackground(Wallpaper());
[ # # ]
577 [ # # ]: 0 : mpOutputDevice->Erase();
578 : :
579 [ # # ]: 0 : MapMode aMapMode (mpOutputDevice->GetMapMode());
580 [ # # ]: 0 : aMapMode.SetOrigin(Point(0,0));
581 [ # # ]: 0 : mpOutputDevice->SetMapMode(aMapMode);
582 [ # # ]: 0 : const Rectangle aWindowBox (Point(0,0), maSize);
583 [ # # ]: 0 : mpOutputDevice->DrawRect(aWindowBox);
584 : :
585 [ # # ]: 0 : mpEditEngine->Clear();
586 [ # # ]: 0 : mpEditEngine->SetText(msText);
587 [ # # ]: 0 : mpEditEngine->SetPaperSize(maSize);
588 : :
589 [ # # ]: 0 : mpEditEngine->Draw(mpOutputDevice, aWindowBox, Point(0,mnTop));
590 : :
591 [ # # ]: 0 : const BitmapEx aBitmap (mpOutputDevice->GetBitmapEx(Point(0,0), maSize));
592 [ # # ]: 0 : mxBitmap = cppcanvas::VCLFactory::getInstance().createBitmap(
593 : : mpCanvas,
594 : : aBitmap
595 [ # # ][ # # ]: 0 : )->getUNOBitmap();
[ # # ][ # # ]
[ # # ][ # # ]
596 : : }
597 : 0 : return mxBitmap;
598 : : }
599 : :
600 : :
601 : :
602 : :
603 : 0 : sal_Int32 PresenterTextView::Implementation::GetTotalHeight (void)
604 : : {
605 : : DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
606 : :
607 [ # # ]: 0 : if (mnTotalHeight < 0)
608 : : {
609 [ # # ]: 0 : if ( ! mxBitmap.is())
610 : 0 : GetBitmap();
611 : 0 : mnTotalHeight = mpEditEngine->GetTextHeight();
612 : : }
613 : 0 : return mnTotalHeight;
614 : : }
615 : :
616 : :
617 : :
618 : :
619 : 0 : void PresenterTextView::Implementation::CheckTop (void)
620 : : {
621 : : DBG_ASSERT(mpEditEngine!=NULL, "EditEngine missing");
622 : :
623 [ # # ]: 0 : if (mnTotalHeight < 0)
624 : 0 : mnTotalHeight = mpEditEngine->GetTextHeight();
625 [ # # ][ # # ]: 0 : if (mpEditEngine!=NULL && mnTop >= mnTotalHeight)
626 : 0 : mnTop = mnTotalHeight - mpEditEngine->GetLineHeight(0,0);
627 : :
628 [ # # ]: 0 : if (mnTotalHeight < maSize.Height())
629 : 0 : mnTop = 0;
630 : :
631 [ # # ]: 0 : if (mnTotalHeight - mnTop < maSize.Height())
632 : 0 : mnTop = mnTotalHeight - maSize.Height();
633 : :
634 [ # # ]: 0 : if (mnTop < 0)
635 : 0 : mnTop = 0;
636 : 0 : }
637 : :
638 : :
639 : : } } // end of namespace ::sd::presenter
640 : :
641 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|