LCOV - code coverage report
Current view: top level - sdext/source/presenter - PresenterTextView.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 3 0.0 %
Date: 2014-04-11 Functions: 0 4 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             : 
      20             : #ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERTEXTVIEW_HXX
      21             : #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERTEXTVIEW_HXX
      22             : 
      23             : #include "PresenterTheme.hxx"
      24             : #include <com/sun/star/accessibility/XAccessibleText.hpp>
      25             : #include <com/sun/star/awt/Size.hpp>
      26             : #include <com/sun/star/geometry/RealPoint2D.hpp>
      27             : #include <com/sun/star/geometry/RealSize2D.hpp>
      28             : #include <com/sun/star/i18n/XBreakIterator.hpp>
      29             : #include <com/sun/star/i18n/XScriptTypeDetector.hpp>
      30             : #include <com/sun/star/rendering/XCanvas.hpp>
      31             : #include <com/sun/star/style/ParagraphAdjust.hpp>
      32             : #include <com/sun/star/text/XText.hpp>
      33             : #include <com/sun/star/uno/XComponentContext.hpp>
      34             : #include <cppuhelper/compbase1.hxx>
      35             : #include <cppuhelper/basemutex.hxx>
      36             : 
      37             : namespace cssu = ::com::sun::star::uno;
      38             : namespace cssa = ::com::sun::star::accessibility;
      39             : 
      40             : namespace sdext { namespace presenter {
      41             : 
      42             : class PresenterTextCaret
      43             : {
      44             : public:
      45             :     PresenterTextCaret (
      46             :         const ::boost::function<css::awt::Rectangle(const sal_Int32,const sal_Int32)>&
      47             :             rCharacterBoundsAccess,
      48             :         const ::boost::function<void(const css::awt::Rectangle&)>&
      49             :             rInvalidator);
      50             :     ~PresenterTextCaret (void);
      51             : 
      52             :     void ShowCaret (void);
      53             :     void HideCaret (void);
      54             : 
      55             :     sal_Int32 GetParagraphIndex (void) const;
      56             :     sal_Int32 GetCharacterIndex (void) const;
      57             :     void SetPosition (
      58             :         const sal_Int32 nParagraphIndex,
      59             :         const sal_Int32 nCharacterIndex);
      60             : 
      61             :     bool IsVisible (void) const;
      62             : 
      63             :     /** Set a (possibly empty) functor that broadcasts changes of the caret
      64             :         position.  This is used when a PresenterTextView object is set at
      65             :         the accessibility object so that accessibility events can be sent
      66             :         when the caret changes position.
      67             :     */
      68             :     void SetCaretMotionBroadcaster (
      69             :         const ::boost::function<void(sal_Int32,sal_Int32,sal_Int32,sal_Int32)>& rBroadcaster);
      70             : 
      71             :     css::awt::Rectangle GetBounds (void) const;
      72             : 
      73             : private:
      74             :     sal_Int32 mnParagraphIndex;
      75             :     sal_Int32 mnCharacterIndex;
      76             :     sal_Int32 mnCaretBlinkTaskId;
      77             :     bool mbIsCaretVisible;
      78             :     const ::boost::function<css::awt::Rectangle(const sal_Int32,const sal_Int32)> maCharacterBoundsAccess;
      79             :     const ::boost::function<void(const css::awt::Rectangle&)> maInvalidator;
      80             :     ::boost::function<void(sal_Int32,sal_Int32,sal_Int32,sal_Int32)> maBroadcaster;
      81             :     css::awt::Rectangle maCaretBounds;
      82             : 
      83             :     void InvertCaret (void);
      84             : };
      85             : typedef ::boost::shared_ptr<PresenterTextCaret> SharedPresenterTextCaret;
      86             : 
      87             : //===== PresenterTextParagraph ================================================
      88             : 
      89           0 : class PresenterTextParagraph
      90             : {
      91             : public:
      92             :     PresenterTextParagraph (
      93             :         const sal_Int32 nParagraphIndex,
      94             :         const cssu::Reference<css::i18n::XBreakIterator>& rxBreakIterator,
      95             :         const cssu::Reference<css::i18n::XScriptTypeDetector>& rxScriptTypeDetector,
      96             :         const cssu::Reference<css::text::XTextRange>& rxTextRange,
      97             :         const SharedPresenterTextCaret& rpCaret);
      98             : 
      99             :     void Paint (
     100             :         const cssu::Reference<css::rendering::XCanvas>& rxCanvas,
     101             :         const css::geometry::RealSize2D& rSize,
     102             :         const PresenterTheme::SharedFontDescriptor& rpFont,
     103             :         const css::rendering::ViewState& rViewState,
     104             :         css::rendering::RenderState& rRenderState,
     105             :         const double nTopOffset,
     106             :         const double nClipTop,
     107             :         const double nClipBottom);
     108             : 
     109             :     double GetTotalTextHeight (void);
     110             : 
     111             :     void SetCharacterOffset (const sal_Int32 nCharacterOffset);
     112             :     sal_Int32 GetCharacterCount (void) const;
     113             :     sal_Unicode GetCharacter (const sal_Int32 nGlobalCharacterIndex) const;
     114             :     OUString GetText (void) const;
     115             :     cssa::TextSegment GetTextSegment (
     116             :         const sal_Int32 nOffset,
     117             :         const sal_Int32 nGlobalCharacterIndex,
     118             :         const sal_Int16 nTextType) const;
     119             :     cssa::TextSegment GetWordTextSegment (
     120             :         const sal_Int32 nOffset,
     121             :         const sal_Int32 nIndex) const;
     122             :     cssa::TextSegment CreateTextSegment (
     123             :         sal_Int32 nStartIndex,
     124             :         sal_Int32 nEndIndex) const;
     125             :     css::awt::Rectangle GetCharacterBounds (
     126             :         sal_Int32 nGlobalCharacterIndex,
     127             :         const bool bCaretBox);
     128             :     sal_Int32 GetIndexAtPoint (const css::awt::Point& rPoint) const;
     129             :     void SetupCellArray (
     130             :         const PresenterTheme::SharedFontDescriptor& rpFont);
     131             :     void Format (
     132             :         const double nY,
     133             :         const double nWidth,
     134             :         const PresenterTheme::SharedFontDescriptor& rpFont);
     135             :     sal_Int32 GetWordBoundary(
     136             :         const sal_Int32 nLocalCharacterIndex,
     137             :         const sal_Int32 nDistance);
     138             :     sal_Int32 GetCaretPosition (void) const;
     139             :     void SetCaretPosition (const sal_Int32 nPosition) const;
     140             :     void SetOrigin (const double nXOrigin, const double nYOrigin);
     141             :     css::awt::Point GetRelativeLocation (void) const;
     142             :     css::awt::Size GetSize (void);
     143             : 
     144             : private:
     145             :     OUString msParagraphText;
     146             :     const sal_Int32 mnParagraphIndex;
     147             :     SharedPresenterTextCaret mpCaret;
     148             : 
     149             :     /** A portion of a string that encodes one unicode cell.  It describes
     150             :         number of characters in the unicode string that make up the cell and its
     151             :         width in pixel (with respect to some configuration that is stored
     152             :         externally or implicitly).
     153             :     */
     154             :     class Cell
     155             :     {
     156             :     public:
     157             :         Cell (const sal_Int32 nCharacterIndex, const sal_Int32 nCharacterCount, const double nCellWidth);
     158             :         sal_Int32 mnCharacterIndex;
     159             :         sal_Int32 mnCharacterCount;
     160             :         double mnCellWidth;
     161             :     };
     162             : 
     163           0 :     class Line
     164             :     {
     165             :     public:
     166             :         Line (const sal_Int32 nLineStartCharacterIndex, const sal_Int32 nLineEndCharacterIndex);
     167             :         sal_Int32 mnLineStartCharacterIndex;
     168             :         sal_Int32 mnLineEndCharacterIndex;
     169             :         sal_Int32 mnLineStartCellIndex;
     170             :         sal_Int32 mnLineEndCellIndex;
     171             :         cssu::Reference<css::rendering::XTextLayout> mxLayoutedLine;
     172             :         double mnBaseLine;
     173             :         double mnWidth;
     174             :         cssu::Sequence<css::geometry::RealRectangle2D> maCellBoxes;
     175             : 
     176             :         void ProvideLayoutedLine (
     177             :             const OUString& rsParagraphText,
     178             :             const PresenterTheme::SharedFontDescriptor& rpFont,
     179             :             const sal_Int8 nTextDirection);
     180             :         void ProvideCellBoxes (void);
     181             :         bool IsEmpty (void) const;
     182             :     };
     183             : 
     184             :     cssu::Reference<css::i18n::XBreakIterator> mxBreakIterator;
     185             :     cssu::Reference<css::i18n::XScriptTypeDetector> mxScriptTypeDetector;
     186             :     ::std::vector<Line> maLines;
     187             :     ::std::vector<sal_Int32> maWordBoundaries;
     188             :     // Offset of the top of the paragraph with respect to the origin of the
     189             :     // whole text (specified by mnXOrigin and mnYOrigin).
     190             :     double mnVerticalOffset;
     191             :     double mnXOrigin;
     192             :     double mnYOrigin;
     193             :     double mnWidth;
     194             :     double mnAscent;
     195             :     double mnDescent;
     196             :     double mnLineHeight;
     197             :     css::style::ParagraphAdjust meAdjust;
     198             :     sal_Int8 mnWritingMode;
     199             :     /// The index of the first character in this paragraph with respect to
     200             :     /// the whole text.
     201             :     sal_Int32 mnCharacterOffset;
     202             :     ::std::vector<Cell> maCells;
     203             : 
     204             :     void AddWord (
     205             :         const double nWidth,
     206             :         css::i18n::Boundary& rCurrentLine,
     207             :         const sal_Int32 nWordBoundary,
     208             :         const PresenterTheme::SharedFontDescriptor& rpFont);
     209             :     void AddLine (
     210             :         css::i18n::Boundary& rCurrentLine);
     211             :     sal_Int8 GetTextDirection (void) const;
     212             :     bool IsTextReferencePointLeft (void) const;
     213             : };
     214             : typedef ::boost::shared_ptr<PresenterTextParagraph> SharedPresenterTextParagraph;
     215             : 
     216             : /** A simple text view that paints text onto a given canvas.
     217             : */
     218           0 : class PresenterTextView
     219             : {
     220             : public:
     221             : 
     222             :     PresenterTextView (
     223             :         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
     224             :         const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
     225             :         const ::boost::function<void(const css::awt::Rectangle&)>& rInvalidator);
     226             :     void SetText (const css::uno::Reference<css::text::XText>& rxText);
     227             :     void SetTextChangeBroadcaster (const ::boost::function<void(void)>& rBroadcaster);
     228             : 
     229             :     void SetLocation (const css::geometry::RealPoint2D& rLocation);
     230             :     void SetSize (const css::geometry::RealSize2D& rSize);
     231             :     double GetTotalTextHeight (void);
     232             : 
     233             :     void SetFont (const PresenterTheme::SharedFontDescriptor& rpFont);
     234             : 
     235             :     void SetOffset (
     236             :         const double nLeft,
     237             :         const double nTop);
     238             : 
     239             :     /** Move the caret forward or backward by character or by word.
     240             :         @param nDistance
     241             :             Should be either -1 or +1 to move caret backwards or forwards,
     242             :             respectively.
     243             :         @param nTextType
     244             :             Valid values are the
     245             :             com::sun::star::accessibility::AccessibleTextType constants.
     246             :     */
     247             :     void MoveCaret (
     248             :         const sal_Int32 nDistance,
     249             :         const sal_Int16 nTextType);
     250             : 
     251             :     void Paint (const css::awt::Rectangle& rUpdateBox);
     252             : 
     253             :     SharedPresenterTextCaret GetCaret (void) const;
     254             : 
     255             :     sal_Int32 GetParagraphCount (void) const;
     256             :     SharedPresenterTextParagraph GetParagraph (const sal_Int32 nParagraphIndex) const;
     257             : 
     258             : private:
     259             :     css::uno::Reference<css::rendering::XCanvas> mxCanvas;
     260             :     bool mbDoOuput;
     261             :     css::uno::Reference<css::i18n::XBreakIterator> mxBreakIterator;
     262             :     css::uno::Reference<css::i18n::XScriptTypeDetector> mxScriptTypeDetector;
     263             :     css::geometry::RealPoint2D maLocation;
     264             :     css::geometry::RealSize2D maSize;
     265             :     PresenterTheme::SharedFontDescriptor mpFont;
     266             :     ::std::vector<SharedPresenterTextParagraph> maParagraphs;
     267             :     SharedPresenterTextCaret mpCaret;
     268             :     double mnLeftOffset;
     269             :     double mnTopOffset;
     270             :     const ::boost::function<void(const css::awt::Rectangle&)> maInvalidator;
     271             :     bool mbIsFormatPending;
     272             :     sal_Int32 mnCharacterCount;
     273             :     ::boost::function<void(void)> maTextChangeBroadcaster;
     274             : 
     275             :     void RequestFormat (void);
     276             :     void Format (void);
     277             :     SharedPresenterTextParagraph GetParagraphForCharacterIndex (const sal_Int32 nCharacterIndex) const;
     278             :     css::awt::Rectangle GetCaretBounds (
     279             :         const sal_Int32 nParagraphIndex,
     280             :         const sal_Int32 nCharacterIndex) const;
     281             : };
     282             : 
     283             : } } // end of namespace ::sdext::presenter
     284             : 
     285             : #endif
     286             : 
     287             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10