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

Generated by: LCOV version 1.10