LCOV - code coverage report
Current view: top level - sdext/source/presenter - PresenterNotesView.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 291 0.0 %
Date: 2014-04-14 Functions: 0 31 0.0 %
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             : #include "vcl/svapp.hxx"
      20             : #include "vcl/settings.hxx"
      21             : #include "PresenterNotesView.hxx"
      22             : #include "PresenterButton.hxx"
      23             : #include "PresenterCanvasHelper.hxx"
      24             : #include "PresenterGeometryHelper.hxx"
      25             : #include "PresenterPaintManager.hxx"
      26             : #include "PresenterScrollBar.hxx"
      27             : #include "PresenterTextView.hxx"
      28             : #include <com/sun/star/accessibility/AccessibleTextType.hpp>
      29             : #include <com/sun/star/awt/Key.hpp>
      30             : #include <com/sun/star/awt/KeyModifier.hpp>
      31             : #include <com/sun/star/awt/PosSize.hpp>
      32             : #include <com/sun/star/beans/XPropertySet.hpp>
      33             : #include <com/sun/star/drawing/framework/XControllerManager.hpp>
      34             : #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
      35             : #include <com/sun/star/drawing/framework/XPane.hpp>
      36             : #include <com/sun/star/lang/XServiceName.hpp>
      37             : #include <com/sun/star/presentation/XPresentationPage.hpp>
      38             : #include <com/sun/star/rendering/CompositeOperation.hpp>
      39             : #include <com/sun/star/rendering/XSpriteCanvas.hpp>
      40             : #include <com/sun/star/text/XTextRange.hpp>
      41             : #include <com/sun/star/util/XChangesBatch.hpp>
      42             : #include <com/sun/star/container/XChild.hpp>
      43             : #include <boost/bind.hpp>
      44             : 
      45             : using namespace ::com::sun::star;
      46             : using namespace ::com::sun::star::uno;
      47             : using namespace ::com::sun::star::drawing::framework;
      48             : 
      49             : static const sal_Int32 gnSpaceBelowSeparator (10);
      50             : static const sal_Int32 gnSpaceAboveSeparator (10);
      51             : static const double gnLineScrollFactor (1.2);
      52             : 
      53             : namespace sdext { namespace presenter {
      54             : 
      55             : //===== PresenterNotesView ====================================================
      56             : 
      57           0 : PresenterNotesView::PresenterNotesView (
      58             :     const Reference<XComponentContext>& rxComponentContext,
      59             :     const Reference<XResourceId>& rxViewId,
      60             :     const Reference<frame::XController>& rxController,
      61             :     const ::rtl::Reference<PresenterController>& rpPresenterController)
      62             :     : PresenterNotesViewInterfaceBase(m_aMutex),
      63             :       mxViewId(rxViewId),
      64             :       mpPresenterController(rpPresenterController),
      65             :       mxCanvas(),
      66             :       mxCurrentNotesPage(),
      67             :       mpScrollBar(),
      68             :       mxToolBarWindow(),
      69             :       mxToolBarCanvas(),
      70             :       mpToolBar(),
      71             :       mpCloseButton(),
      72             :       maSeparatorColor(0xffffff),
      73             :       mnSeparatorYLocation(0),
      74             :       maTextBoundingBox(),
      75             :       mpBackground(),
      76             :       mnTop(0),
      77             :       mpFont(),
      78           0 :       mpTextView()
      79             : {
      80             :     try
      81             :     {
      82           0 :         Reference<XControllerManager> xCM (rxController, UNO_QUERY_THROW);
      83           0 :         Reference<XConfigurationController> xCC (xCM->getConfigurationController(), UNO_QUERY_THROW);
      84           0 :         Reference<XPane> xPane (xCC->getResource(rxViewId->getAnchor()), UNO_QUERY_THROW);
      85             : 
      86           0 :         mxParentWindow = xPane->getWindow();
      87           0 :         mxCanvas = xPane->getCanvas();
      88             :         mpTextView.reset(new PresenterTextView(
      89             :             rxComponentContext,
      90             :             mxCanvas,
      91           0 :             mpPresenterController->GetPaintManager()->GetInvalidator(mxParentWindow)));
      92             : 
      93           0 :         const OUString sResourceURL (mxViewId->getResourceURL());
      94             :         mpFont.reset(new PresenterTheme::FontDescriptor(
      95           0 :             rpPresenterController->GetViewFont(sResourceURL)));
      96           0 :         maSeparatorColor = mpFont->mnColor;
      97           0 :         mpTextView->SetFont(mpFont);
      98             : 
      99           0 :         CreateToolBar(rxComponentContext, rpPresenterController);
     100             : 
     101           0 :         mpCloseButton = PresenterButton::Create(
     102             :             rxComponentContext,
     103             :             mpPresenterController,
     104             :             mpPresenterController->GetTheme(),
     105             :             mxParentWindow,
     106             :             mxCanvas,
     107           0 :             "NotesViewCloser");
     108             : 
     109           0 :         if (mxParentWindow.is())
     110             :         {
     111           0 :             mxParentWindow->addWindowListener(this);
     112           0 :             mxParentWindow->addPaintListener(this);
     113           0 :             mxParentWindow->addKeyListener(this);
     114           0 :             mxParentWindow->setVisible(sal_True);
     115             :         }
     116             : 
     117           0 :         mpScrollBar = new PresenterVerticalScrollBar(
     118             :             rxComponentContext,
     119             :             mxParentWindow,
     120             :             mpPresenterController->GetPaintManager(),
     121           0 :             ::boost::bind(&PresenterNotesView::SetTop, this, _1));
     122             :         mpScrollBar->SetBackground(
     123           0 :             mpPresenterController->GetViewBackground(mxViewId->getResourceURL()));
     124             : 
     125           0 :         mpScrollBar->SetCanvas(mxCanvas);
     126             : 
     127           0 :         Layout();
     128             :     }
     129           0 :     catch (RuntimeException&)
     130             :     {
     131           0 :         PresenterNotesView::disposing();
     132           0 :         throw;
     133             :     }
     134           0 : }
     135             : 
     136           0 : PresenterNotesView::~PresenterNotesView (void)
     137             : {
     138           0 : }
     139             : 
     140           0 : void SAL_CALL PresenterNotesView::disposing (void)
     141             : {
     142           0 :     if (mxParentWindow.is())
     143             :     {
     144           0 :         mxParentWindow->removeWindowListener(this);
     145           0 :         mxParentWindow->removePaintListener(this);
     146           0 :         mxParentWindow->removeKeyListener(this);
     147           0 :         mxParentWindow = NULL;
     148             :     }
     149             : 
     150             :     // Dispose tool bar.
     151             :     {
     152           0 :         Reference<XComponent> xComponent (static_cast<XWeak*>(mpToolBar.get()), UNO_QUERY);
     153           0 :         mpToolBar = NULL;
     154           0 :         if (xComponent.is())
     155           0 :             xComponent->dispose();
     156             :     }
     157             :     {
     158           0 :         Reference<XComponent> xComponent (mxToolBarCanvas, UNO_QUERY);
     159           0 :         mxToolBarCanvas = NULL;
     160           0 :         if (xComponent.is())
     161           0 :             xComponent->dispose();
     162             :     }
     163             :     {
     164           0 :         Reference<XComponent> xComponent (mxToolBarWindow, UNO_QUERY);
     165           0 :         mxToolBarWindow = NULL;
     166           0 :         if (xComponent.is())
     167           0 :             xComponent->dispose();
     168             :     }
     169             : 
     170             :     // Dispose close button
     171             :     {
     172           0 :         Reference<XComponent> xComponent (static_cast<XWeak*>(mpCloseButton.get()), UNO_QUERY);
     173           0 :         mpCloseButton = NULL;
     174           0 :         if (xComponent.is())
     175           0 :             xComponent->dispose();
     176             :     }
     177             : 
     178             :     // Create the tool bar.
     179             : 
     180           0 :     mpScrollBar = NULL;
     181             : 
     182           0 :     mxViewId = NULL;
     183           0 : }
     184             : 
     185           0 : void PresenterNotesView::CreateToolBar (
     186             :     const css::uno::Reference<css::uno::XComponentContext>& rxContext,
     187             :     const ::rtl::Reference<PresenterController>& rpPresenterController)
     188             : {
     189           0 :     if (rpPresenterController.get() == NULL)
     190           0 :         return;
     191             : 
     192             :     Reference<drawing::XPresenterHelper> xPresenterHelper (
     193           0 :         rpPresenterController->GetPresenterHelper());
     194           0 :     if ( ! xPresenterHelper.is())
     195           0 :         return;
     196             : 
     197             :     // Create a new window as container of the tool bar.
     198           0 :     mxToolBarWindow = xPresenterHelper->createWindow(
     199             :         mxParentWindow,
     200             :         sal_False,
     201             :         sal_True,
     202             :         sal_False,
     203           0 :         sal_False);
     204           0 :     mxToolBarCanvas = xPresenterHelper->createSharedCanvas (
     205             :         Reference<rendering::XSpriteCanvas>(mxCanvas, UNO_QUERY),
     206             :         mxParentWindow,
     207             :         mxCanvas,
     208             :         mxParentWindow,
     209           0 :         mxToolBarWindow);
     210             : 
     211             :     // Create the tool bar.
     212           0 :     mpToolBar = new PresenterToolBar(
     213             :         rxContext,
     214             :         mxToolBarWindow,
     215             :         mxToolBarCanvas,
     216             :         rpPresenterController,
     217           0 :         PresenterToolBar::Left);
     218             :     mpToolBar->Initialize(
     219           0 :         "PresenterScreenSettings/ToolBars/NotesToolBar");
     220             : }
     221             : 
     222           0 : void PresenterNotesView::SetSlide (const Reference<drawing::XDrawPage>& rxNotesPage)
     223             : {
     224             :     static const OUString sNotesShapeName (
     225           0 :         "com.sun.star.presentation.NotesShape");
     226             :     static const OUString sTextShapeName (
     227           0 :         "com.sun.star.drawing.TextShape");
     228             : 
     229           0 :     Reference<container::XIndexAccess> xIndexAccess (rxNotesPage, UNO_QUERY);
     230           0 :     if (xIndexAccess.is())
     231             :     {
     232           0 :         OUString sText;
     233             : 
     234             :         // Iterate over all shapes and find the one that holds the text.
     235           0 :         sal_Int32 nCount (xIndexAccess->getCount());
     236           0 :         for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
     237             :         {
     238             : 
     239             :             Reference<lang::XServiceName> xServiceName (
     240           0 :                 xIndexAccess->getByIndex(nIndex), UNO_QUERY);
     241           0 :             if (xServiceName.is()
     242           0 :                 && xServiceName->getServiceName().equals(sNotesShapeName))
     243             :             {
     244           0 :                 Reference<text::XTextRange> xText (xServiceName, UNO_QUERY);
     245           0 :                 if (xText.is())
     246             :                 {
     247           0 :                     sText += xText->getString();
     248           0 :                 }
     249             :             }
     250             :             else
     251             :             {
     252             :                 Reference<drawing::XShapeDescriptor> xShapeDescriptor (
     253           0 :                     xIndexAccess->getByIndex(nIndex), UNO_QUERY);
     254           0 :                 if (xShapeDescriptor.is())
     255             :                 {
     256           0 :                     OUString sType (xShapeDescriptor->getShapeType());
     257           0 :                     if (sType.equals(sNotesShapeName) || sType.equals(sTextShapeName))
     258             :                     {
     259             :                         Reference<text::XTextRange> xText (
     260           0 :                             xIndexAccess->getByIndex(nIndex), UNO_QUERY);
     261           0 :                         if (xText.is())
     262             :                         {
     263           0 :                             sText += xText->getString();
     264           0 :                             mpTextView->SetText(Reference<text::XText>(xText, UNO_QUERY));
     265           0 :                         }
     266           0 :                     }
     267           0 :                 }
     268             :             }
     269           0 :         }
     270             : 
     271           0 :         Layout();
     272             : 
     273           0 :         if (mpScrollBar.get() != NULL)
     274             :         {
     275           0 :             mpScrollBar->SetThumbPosition(0, false);
     276           0 :             UpdateScrollBar();
     277             :         }
     278             : 
     279           0 :         Invalidate();
     280           0 :     }
     281           0 : }
     282             : 
     283             : //-----  lang::XEventListener -------------------------------------------------
     284             : 
     285           0 : void SAL_CALL PresenterNotesView::disposing (const lang::EventObject& rEventObject)
     286             :     throw (RuntimeException, std::exception)
     287             : {
     288           0 :     if (rEventObject.Source == mxParentWindow)
     289           0 :         mxParentWindow = NULL;
     290           0 : }
     291             : 
     292             : //----- XWindowListener -------------------------------------------------------
     293             : 
     294           0 : void SAL_CALL PresenterNotesView::windowResized (const awt::WindowEvent& rEvent)
     295             :     throw (RuntimeException, std::exception)
     296             : {
     297             :     (void)rEvent;
     298           0 :     Layout();
     299           0 : }
     300             : 
     301           0 : void SAL_CALL PresenterNotesView::windowMoved (const awt::WindowEvent& rEvent)
     302             :     throw (RuntimeException, std::exception)
     303             : {
     304             :     (void)rEvent;
     305           0 : }
     306             : 
     307           0 : void SAL_CALL PresenterNotesView::windowShown (const lang::EventObject& rEvent)
     308             :     throw (RuntimeException, std::exception)
     309             : {
     310             :     (void)rEvent;
     311           0 : }
     312             : 
     313           0 : void SAL_CALL PresenterNotesView::windowHidden (const lang::EventObject& rEvent)
     314             :     throw (RuntimeException, std::exception)
     315             : {
     316             :     (void)rEvent;
     317           0 : }
     318             : 
     319             : //----- XPaintListener --------------------------------------------------------
     320             : 
     321           0 : void SAL_CALL PresenterNotesView::windowPaint (const awt::PaintEvent& rEvent)
     322             :     throw (RuntimeException, std::exception)
     323             : {
     324           0 :     ThrowIfDisposed();
     325             : 
     326           0 :     if ( ! mbIsPresenterViewActive)
     327           0 :         return;
     328             : 
     329           0 :     ::osl::MutexGuard aSolarGuard (::osl::Mutex::getGlobalMutex());
     330           0 :     Paint(rEvent.UpdateRect);
     331             : }
     332             : 
     333             : //----- XResourceId -----------------------------------------------------------
     334             : 
     335           0 : Reference<XResourceId> SAL_CALL PresenterNotesView::getResourceId (void)
     336             :     throw (RuntimeException, std::exception)
     337             : {
     338           0 :     return mxViewId;
     339             : }
     340             : 
     341           0 : sal_Bool SAL_CALL PresenterNotesView::isAnchorOnly (void)
     342             :     throw (RuntimeException, std::exception)
     343             : {
     344           0 :     return false;
     345             : }
     346             : 
     347             : //----- XDrawView -------------------------------------------------------------
     348             : 
     349           0 : void SAL_CALL PresenterNotesView::setCurrentPage (const Reference<drawing::XDrawPage>& rxSlide)
     350             :     throw (RuntimeException, std::exception)
     351             : {
     352             :     // Get the associated notes page.
     353           0 :     mxCurrentNotesPage = NULL;
     354             :     try
     355             :     {
     356           0 :         Reference<presentation::XPresentationPage> xPresentationPage(rxSlide, UNO_QUERY);
     357           0 :         if (xPresentationPage.is())
     358           0 :             mxCurrentNotesPage = xPresentationPage->getNotesPage();
     359             :     }
     360           0 :     catch (RuntimeException&)
     361             :     {
     362             :     }
     363             : 
     364           0 :     SetSlide(mxCurrentNotesPage);
     365           0 : }
     366             : 
     367           0 : Reference<drawing::XDrawPage> SAL_CALL PresenterNotesView::getCurrentPage (void)
     368             :     throw (RuntimeException, std::exception)
     369             : {
     370           0 :     return NULL;
     371             : }
     372             : 
     373             : //----- XKeyListener ----------------------------------------------------------
     374             : 
     375           0 : void SAL_CALL PresenterNotesView::keyPressed (const awt::KeyEvent& rEvent)
     376             :     throw (RuntimeException, std::exception)
     377             : {
     378           0 :     switch (rEvent.KeyCode)
     379             :     {
     380             :         case awt::Key::A:
     381           0 :             Scroll(-gnLineScrollFactor * mpFont->mnSize);
     382           0 :             break;
     383             : 
     384             :         case awt::Key::Y:
     385             :         case awt::Key::Z:
     386           0 :             Scroll(+gnLineScrollFactor * mpFont->mnSize);
     387           0 :             break;
     388             : 
     389             :         case awt::Key::S:
     390           0 :             ChangeFontSize(-1);
     391           0 :             break;
     392             : 
     393             :         case awt::Key::G:
     394           0 :             ChangeFontSize(+1);
     395           0 :             break;
     396             : 
     397             :         case awt::Key::H:
     398           0 :             if (mpTextView)
     399             :                 mpTextView->MoveCaret(
     400             :                     -1,
     401           0 :                     (rEvent.Modifiers == awt::KeyModifier::SHIFT)
     402             :                         ? cssa::AccessibleTextType::CHARACTER
     403           0 :                         : cssa::AccessibleTextType::WORD);
     404           0 :             break;
     405             : 
     406             :         case awt::Key::L:
     407           0 :             if (mpTextView)
     408             :                 mpTextView->MoveCaret(
     409             :                     +1,
     410           0 :                     (rEvent.Modifiers == awt::KeyModifier::SHIFT)
     411             :                         ? cssa::AccessibleTextType::CHARACTER
     412           0 :                         : cssa::AccessibleTextType::WORD);
     413           0 :             break;
     414             :     }
     415           0 : }
     416             : 
     417           0 : void SAL_CALL PresenterNotesView::keyReleased (const awt::KeyEvent& rEvent)
     418             :     throw (RuntimeException, std::exception)
     419             : {
     420             :     (void)rEvent;
     421           0 : }
     422             : 
     423             : 
     424             : 
     425           0 : void PresenterNotesView::Layout (void)
     426             : {
     427           0 :     if ( ! mxParentWindow.is())
     428           0 :         return;
     429           0 :     awt::Rectangle aWindowBox (mxParentWindow->getPosSize());
     430           0 :     geometry::RealRectangle2D aNewTextBoundingBox (0,0,aWindowBox.Width, aWindowBox.Height);
     431             :     // Size the tool bar and the horizontal separator above it.
     432           0 :     if (mxToolBarWindow.is())
     433             :         {
     434           0 :             const geometry::RealSize2D aToolBarSize (mpToolBar->GetMinimalSize());
     435           0 :             const sal_Int32 nToolBarHeight = sal_Int32(aToolBarSize.Height + 0.5);
     436           0 :             mxToolBarWindow->setPosSize(0, aWindowBox.Height - nToolBarHeight,
     437           0 :                                         sal_Int32(aToolBarSize.Width + 0.5), nToolBarHeight,
     438           0 :                                         awt::PosSize::POSSIZE);
     439           0 :             aNewTextBoundingBox.Y2 -= nToolBarHeight;
     440           0 :             mnSeparatorYLocation = aWindowBox.Height - nToolBarHeight - gnSpaceBelowSeparator;
     441           0 :             aNewTextBoundingBox.Y2 = mnSeparatorYLocation - gnSpaceAboveSeparator;
     442             :             // Place the close button.
     443           0 :             if (mpCloseButton.get() != NULL)
     444             :                 mpCloseButton->SetCenter(geometry::RealPoint2D(
     445           0 :                                                                (aWindowBox.Width +  aToolBarSize.Width) / 2,
     446           0 :                                                                aWindowBox.Height - aToolBarSize.Height/2));
     447             :         }
     448             :     // Check whether the vertical scroll bar is necessary.
     449           0 :     if (mpScrollBar.get() != NULL)
     450             :         {
     451           0 :             bool bShowVerticalScrollbar (false);
     452             :             try
     453             :                 {
     454           0 :                     const double nTextBoxHeight (aNewTextBoundingBox.Y2 - aNewTextBoundingBox.Y1);
     455           0 :                     const double nHeight (mpTextView->GetTotalTextHeight());
     456           0 :                     if (nHeight > nTextBoxHeight)
     457             :                         {
     458           0 :                             bShowVerticalScrollbar = true;
     459           0 :                             if(!Application::GetSettings().GetLayoutRTL())
     460           0 :                                 aNewTextBoundingBox.X2 -= mpScrollBar->GetSize();
     461             :                             else
     462           0 :                                 aNewTextBoundingBox.X1 += mpScrollBar->GetSize();
     463             :                         }
     464           0 :                     mpScrollBar->SetTotalSize(nHeight);
     465             :                 }
     466           0 :             catch(beans::UnknownPropertyException&)
     467             :                 {
     468             :                     OSL_ASSERT(false);
     469             :                 }
     470           0 :             if(Application::GetSettings().GetLayoutRTL())
     471             :                 {
     472           0 :                     mpScrollBar->SetVisible(bShowVerticalScrollbar);
     473             :                     mpScrollBar->SetPosSize(
     474             :                                             geometry::RealRectangle2D(
     475           0 :                                                                       aNewTextBoundingBox.X1 - mpScrollBar->GetSize(),
     476             :                                                                       aNewTextBoundingBox.Y1,
     477             :                                                                       aNewTextBoundingBox.X1,
     478           0 :                                                                       aNewTextBoundingBox.Y2));
     479           0 :                     if( ! bShowVerticalScrollbar)
     480           0 :                         mpScrollBar->SetThumbPosition(0, false);
     481           0 :                     UpdateScrollBar();
     482             :                 }
     483             :             else
     484             :                 {
     485           0 :                     mpScrollBar->SetVisible(bShowVerticalScrollbar);
     486             :                     mpScrollBar->SetPosSize(
     487             :                                             geometry::RealRectangle2D(
     488           0 :                                                                       aWindowBox.Width - mpScrollBar->GetSize(),
     489             :                                                                       aNewTextBoundingBox.Y1,
     490           0 :                                                                       aNewTextBoundingBox.X2 + mpScrollBar->GetSize(),
     491           0 :                                                                       aNewTextBoundingBox.Y2));
     492           0 :                     if( ! bShowVerticalScrollbar)
     493           0 :                         mpScrollBar->SetThumbPosition(0, false);
     494           0 :                     UpdateScrollBar();
     495             :                 }
     496             :         }
     497             :     // Has the text area has changed it position or size?
     498           0 :     if (aNewTextBoundingBox.X1 != maTextBoundingBox.X1
     499           0 :         || aNewTextBoundingBox.Y1 != maTextBoundingBox.Y1
     500           0 :         || aNewTextBoundingBox.X2 != maTextBoundingBox.X2
     501           0 :         || aNewTextBoundingBox.Y2 != maTextBoundingBox.Y2)
     502             :         {
     503           0 :             maTextBoundingBox = aNewTextBoundingBox;
     504             :             mpTextView->SetLocation(
     505             :                                     geometry::RealPoint2D(
     506             :                                                           aNewTextBoundingBox.X1,
     507           0 :                                                           aNewTextBoundingBox.Y1));
     508             :             mpTextView->SetSize(
     509             :                                 geometry::RealSize2D(
     510           0 :                                                      aNewTextBoundingBox.X2 - aNewTextBoundingBox.X1,
     511           0 :                                                      aNewTextBoundingBox.Y2 - aNewTextBoundingBox.Y1));
     512             :         }
     513             : }
     514             : 
     515           0 : void PresenterNotesView::Paint (const awt::Rectangle& rUpdateBox)
     516             : {
     517           0 :     if ( ! mxParentWindow.is())
     518           0 :         return;
     519           0 :     if ( ! mxCanvas.is())
     520           0 :         return;
     521             : 
     522           0 :     if (mpBackground.get() == NULL)
     523           0 :         mpBackground = mpPresenterController->GetViewBackground(mxViewId->getResourceURL());
     524             : 
     525           0 :     if (rUpdateBox.Y < maTextBoundingBox.Y2
     526           0 :         && rUpdateBox.X < maTextBoundingBox.X2)
     527             :     {
     528           0 :         PaintText(rUpdateBox);
     529             :     }
     530             : 
     531           0 :     mpTextView->Paint(rUpdateBox);
     532             : 
     533           0 :     if (rUpdateBox.Y + rUpdateBox.Height > maTextBoundingBox.Y2)
     534             :     {
     535           0 :         PaintToolBar(rUpdateBox);
     536             :     }
     537             : }
     538             : 
     539           0 : void PresenterNotesView::PaintToolBar (const awt::Rectangle& rUpdateBox)
     540             : {
     541           0 :     awt::Rectangle aWindowBox (mxParentWindow->getPosSize());
     542             : 
     543             :     rendering::ViewState aViewState (
     544             :         geometry::AffineMatrix2D(1,0,0, 0,1,0),
     545           0 :         NULL);
     546             :     rendering::RenderState aRenderState(
     547             :         geometry::AffineMatrix2D(1,0,0, 0,1,0),
     548             :         NULL,
     549             :         Sequence<double>(4),
     550           0 :         rendering::CompositeOperation::SOURCE);
     551             : 
     552           0 :     if (mpBackground.get() != NULL)
     553             :     {
     554             :         // Paint the background.
     555             :         mpPresenterController->GetCanvasHelper()->Paint(
     556             :             mpBackground,
     557             :             mxCanvas,
     558             :             rUpdateBox,
     559             :             awt::Rectangle(0,sal_Int32(maTextBoundingBox.Y2),aWindowBox.Width,aWindowBox.Height),
     560           0 :             awt::Rectangle());
     561             :     }
     562             : 
     563             :     // Paint the horizontal separator.
     564             :     OSL_ASSERT(mxViewId.is());
     565           0 :     PresenterCanvasHelper::SetDeviceColor(aRenderState, maSeparatorColor);
     566             : 
     567           0 :     mxCanvas->drawLine(
     568             :         geometry::RealPoint2D(0,mnSeparatorYLocation),
     569             :         geometry::RealPoint2D(aWindowBox.Width,mnSeparatorYLocation),
     570             :         aViewState,
     571           0 :         aRenderState);
     572           0 : }
     573             : 
     574           0 : void PresenterNotesView::PaintText (const awt::Rectangle& rUpdateBox)
     575             : {
     576             :     const awt::Rectangle aBox (PresenterGeometryHelper::Intersection(rUpdateBox,
     577           0 :             PresenterGeometryHelper::ConvertRectangle(maTextBoundingBox)));
     578             : 
     579           0 :     if (aBox.Width <= 0 || aBox.Height <= 0)
     580           0 :         return;
     581             : 
     582             :     rendering::ViewState aViewState (
     583             :         geometry::AffineMatrix2D(1,0,0, 0,1,0),
     584           0 :         PresenterGeometryHelper::CreatePolygon(aBox, mxCanvas->getDevice()));
     585             :     rendering::RenderState aRenderState(
     586             :         geometry::AffineMatrix2D(1,0,0, 0,1,0),
     587             :         NULL,
     588             :         Sequence<double>(3),
     589           0 :         rendering::CompositeOperation::SOURCE);
     590             : 
     591           0 :     if (mpBackground.get() != NULL)
     592             :     {
     593             :         // Paint the background.
     594             :         mpPresenterController->GetCanvasHelper()->Paint(
     595             :             mpBackground,
     596             :             mxCanvas,
     597             :             rUpdateBox,
     598             :             aBox,
     599           0 :             awt::Rectangle());
     600             :     }
     601             : 
     602           0 :     Reference<rendering::XSpriteCanvas> xSpriteCanvas (mxCanvas, UNO_QUERY);
     603           0 :     if (xSpriteCanvas.is())
     604           0 :         xSpriteCanvas->updateScreen(sal_False);
     605             : }
     606             : 
     607           0 : void PresenterNotesView::Invalidate (void)
     608             : {
     609             :     mpPresenterController->GetPaintManager()->Invalidate(
     610             :         mxParentWindow,
     611           0 :         PresenterGeometryHelper::ConvertRectangle(maTextBoundingBox));
     612           0 : }
     613             : 
     614           0 : void PresenterNotesView::Scroll (const double rnDistance)
     615             : {
     616             :     try
     617             :     {
     618           0 :         mnTop += rnDistance;
     619           0 :         mpTextView->SetOffset(0, mnTop);
     620             : 
     621           0 :         UpdateScrollBar();
     622           0 :         Invalidate();
     623             :     }
     624           0 :     catch (beans::UnknownPropertyException&)
     625             :     {}
     626           0 : }
     627             : 
     628           0 : void PresenterNotesView::SetTop (const double nTop)
     629             : {
     630             :     try
     631             :     {
     632           0 :         mnTop = nTop;
     633           0 :         mpTextView->SetOffset(0, mnTop);
     634             : 
     635           0 :         UpdateScrollBar();
     636           0 :         Invalidate();
     637             :     }
     638           0 :     catch (beans::UnknownPropertyException&)
     639             :     {}
     640           0 : }
     641             : 
     642           0 : void PresenterNotesView::ChangeFontSize (const sal_Int32 nSizeChange)
     643             : {
     644           0 :     const sal_Int32 nNewSize (mpFont->mnSize + nSizeChange);
     645           0 :     if (nNewSize > 5)
     646             :     {
     647           0 :         mpFont->mnSize = nNewSize;
     648           0 :         mpFont->mxFont = NULL;
     649           0 :         mpTextView->SetFont(mpFont);
     650             : 
     651           0 :         Layout();
     652           0 :         UpdateScrollBar();
     653           0 :         Invalidate();
     654             : 
     655             :         // Write the new font size to the configuration to make it persistent.
     656             :         try
     657             :         {
     658             :             const OUString sStyleName (mpPresenterController->GetTheme()->GetStyleName(
     659           0 :                 mxViewId->getResourceURL()));
     660             :             ::boost::shared_ptr<PresenterConfigurationAccess> pConfiguration (
     661             :                 mpPresenterController->GetTheme()->GetNodeForViewStyle(
     662           0 :                     sStyleName));
     663           0 :             if (pConfiguration.get()==NULL || ! pConfiguration->IsValid())
     664           0 :                 return;
     665             : 
     666           0 :             pConfiguration->GoToChild(OUString("Font"));
     667           0 :             pConfiguration->SetProperty("Size", Any((sal_Int32)(nNewSize+0.5)));
     668           0 :             pConfiguration->CommitChanges();
     669             :         }
     670           0 :         catch (Exception&)
     671             :         {
     672             :             OSL_ASSERT(false);
     673             :         }
     674             :     }
     675             : }
     676             : 
     677           0 : ::boost::shared_ptr<PresenterTextView> PresenterNotesView::GetTextView (void) const
     678             : {
     679           0 :     return mpTextView;
     680             : }
     681             : 
     682           0 : void PresenterNotesView::UpdateScrollBar (void)
     683             : {
     684           0 :     if (mpScrollBar.get() != NULL)
     685             :     {
     686             :         try
     687             :         {
     688           0 :             mpScrollBar->SetTotalSize(mpTextView->GetTotalTextHeight());
     689             :         }
     690           0 :         catch(beans::UnknownPropertyException&)
     691             :         {
     692             :             OSL_ASSERT(false);
     693             :         }
     694             : 
     695           0 :         mpScrollBar->SetLineHeight(mpFont->mnSize*1.2);
     696           0 :         mpScrollBar->SetThumbPosition(mnTop, false);
     697             : 
     698           0 :         mpScrollBar->SetThumbSize(maTextBoundingBox.Y2 - maTextBoundingBox.Y1);
     699           0 :         mpScrollBar->CheckValues();
     700             :     }
     701           0 : }
     702             : 
     703           0 : void PresenterNotesView::ThrowIfDisposed (void)
     704             :     throw (::com::sun::star::lang::DisposedException)
     705             : {
     706           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     707             :     {
     708             :         throw lang::DisposedException (
     709             :             "PresenterNotesView object has already been disposed",
     710           0 :             static_cast<uno::XWeak*>(this));
     711             :     }
     712           0 : }
     713             : 
     714           0 : } } // end of namespace ::sdext::presenter
     715             : 
     716             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10