LCOV - code coverage report
Current view: top level - sdext/source/presenter - PresenterTextView.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 3 0.0 %
Date: 2012-08-25 Functions: 0 4 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 14 0.0 %

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

Generated by: LCOV version 1.10