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