LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/presenter - PresenterTextView.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 227 1.3 %
Date: 2013-07-09 Functions: 3 29 10.3 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10