LCOV - code coverage report
Current view: top level - include/vcl - texteng.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 11 17 64.7 %
Date: 2015-06-13 12:38:46 Functions: 11 17 64.7 %
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             : #ifndef INCLUDED_VCL_TEXTENG_HXX
      20             : #define INCLUDED_VCL_TEXTENG_HXX
      21             : 
      22             : #include <vcl/dllapi.h>
      23             : #include <vcl/vclptr.hxx>
      24             : 
      25             : class TextDoc;
      26             : class TextView;
      27             : class TextPaM;
      28             : class TextSelection;
      29             : class TEParaPortions;
      30             : class TextAttrib;
      31             : class TextCharAttrib;
      32             : class TextUndo;
      33             : class TextUndoManager;
      34             : class EditSelFunctionSet;
      35             : class Idle;
      36             : class IdleFormatter;
      37             : class TextNode;
      38             : class OutputDevice;
      39             : class SfxUndoAction;
      40             : class KeyEvent;
      41             : class Timer;
      42             : 
      43             : namespace svl
      44             : {
      45             :     class IUndoManager;
      46             : }
      47             : 
      48             : class TextLine;
      49             : class TETextPortion;
      50             : #include <rtl/ustring.hxx>
      51             : #include <svl/SfxBroadcaster.hxx>
      52             : #include <tools/lineend.hxx>
      53             : #include <tools/link.hxx>
      54             : #include <tools/gen.hxx>
      55             : #include <vcl/font.hxx>
      56             : 
      57             : #include <com/sun/star/lang/Locale.hpp>
      58             : #include <com/sun/star/uno/Reference.hxx>
      59             : 
      60             : struct TEIMEInfos;
      61             : class SvtCTLOptions;
      62             : 
      63             : namespace com {
      64             : namespace sun {
      65             : namespace star {
      66             : namespace i18n {
      67             :     class XBreakIterator;
      68             :     class XExtendedInputSequenceChecker;
      69             : }}}}
      70             : 
      71             : class LocaleDataWrapper;
      72             : 
      73             : enum TxtAlign { TXTALIGN_LEFT, TXTALIGN_CENTER, TXTALIGN_RIGHT };
      74             : 
      75             : typedef std::vector<TextView*> TextViews;
      76             : 
      77             : class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster
      78             : {
      79             :     friend class        TextView;
      80             :     friend class        TextSelFunctionSet;
      81             :     friend class        ExtTextEngine;
      82             :     friend class        ExtTextView;
      83             : 
      84             :     friend class        TextUndo;
      85             :     friend class        TextUndoManager;
      86             :     friend class        TextUndoDelPara;
      87             :     friend class        TextUndoConnectParas;
      88             :     friend class        TextUndoSplitPara;
      89             :     friend class        TextUndoInsertChars;
      90             :     friend class        TextUndoRemoveChars;
      91             :     friend class        TextUndoSetAttribs;
      92             : 
      93             : private:
      94             :     TextDoc*            mpDoc;
      95             :     TEParaPortions*     mpTEParaPortions;
      96             :     VclPtr<OutputDevice> mpRefDev;
      97             : 
      98             :     TextViews*          mpViews;
      99             :     TextView*           mpActiveView;
     100             : 
     101             :     TextUndoManager*    mpUndoManager;
     102             : 
     103             :     IdleFormatter*      mpIdleFormatter;
     104             : 
     105             :     TEIMEInfos*         mpIMEInfos;
     106             : 
     107             :     ::com::sun::star::lang::Locale maLocale;
     108             :     ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > mxBreakIterator;
     109             :     css::uno::Reference < css::i18n::XExtendedInputSequenceChecker > mxISC;
     110             : 
     111             :     Rectangle           maInvalidRect;
     112             :     Range               maInvalidRange;
     113             : 
     114             :     LocaleDataWrapper*  mpLocaleDataWrapper;
     115             : 
     116             :     vcl::Font           maFont;
     117             :     Color               maTextColor;
     118             :     long                mnCharHeight;
     119             :     sal_uInt16          mnFixCharWidth100;
     120             : 
     121             :     sal_uLong           mnMaxTextLen;
     122             :     sal_uLong           mnMaxTextWidth;
     123             :     sal_uLong           mnCurTextWidth;
     124             :     sal_uLong           mnCurTextHeight;
     125             :     sal_uLong           mnDefTab;
     126             : 
     127             :     TxtAlign            meAlign;
     128             : 
     129             :     bool                mbIsFormatting      : 1;    // semaphore for the Hook's
     130             :     bool                mbFormatted         : 1;
     131             :     bool                mbUpdate            : 1;
     132             :     bool                mbModified          : 1;
     133             :     bool                mbUndoEnabled       : 1;
     134             :     bool                mbIsInUndo          : 1;
     135             :     bool                mbDowning           : 1;
     136             :     bool                mbRightToLeft       : 1;
     137             :     bool                mbHasMultiLineParas : 1;
     138             : 
     139             :                         TextEngine( const TextEngine& ) : SfxBroadcaster()  {}
     140             :     TextEngine&         operator=( const TextEngine& )      { return *this; }
     141             : 
     142             : protected:
     143             : 
     144             :     void                CursorMoved( sal_uLong nNode );
     145             :     void                TextModified();
     146             : 
     147             :     void                ImpInitDoc();
     148             :     void                ImpRemoveText();
     149             :     TextPaM             ImpDeleteText( const TextSelection& rSel );
     150             :     TextPaM             ImpInsertText( const TextSelection& rSel, sal_Unicode c, bool bOverwrite = false );
     151             :     TextPaM             ImpInsertText( const TextSelection& rSel, const OUString& rText );
     152             :     TextPaM             ImpInsertParaBreak( const TextSelection& rTextSelection, bool bKeepEndingAttribs = true );
     153             :     TextPaM             ImpInsertParaBreak( const TextPaM& rPaM, bool bKeepEndingAttribs = true );
     154             :     void                ImpRemoveChars( const TextPaM& rPaM, sal_uInt16 nChars, SfxUndoAction* pCurUndo = 0 );
     155             :     TextPaM             ImpConnectParagraphs( sal_uLong nLeft, sal_uLong nRight );
     156             :     void                ImpRemoveParagraph( sal_uLong nPara );
     157             :     void                ImpInitWritingDirections( sal_uLong nPara );
     158             :     LocaleDataWrapper*  ImpGetLocaleDataWrapper();
     159             : 
     160             :     // to remain compatible in the minor release we copy the above ImpInsertText
     161             :     // function and add the extra parameter we need but make sure this function
     162             :     // gets not exported. First and seconf parameter swapped to have a different signatur.
     163             :     SAL_DLLPRIVATE TextPaM  ImpInsertText( sal_Unicode c, const TextSelection& rSel, bool bOverwrite = false, bool bIsUserInput = false );
     164             :     // some other new functions needed that must not be exported to remain compatible
     165             :     SAL_DLLPRIVATE ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XExtendedInputSequenceChecker > GetInputSequenceChecker();
     166             :     SAL_DLLPRIVATE bool IsInputSequenceCheckingRequired( sal_Unicode c, const TextSelection& rCurSel ) const;
     167             : 
     168             :     // broadcast or adjust selections
     169             :     void                ImpParagraphInserted( sal_uLong nPara );
     170             :     void                ImpParagraphRemoved( sal_uLong nPara );
     171             :     void                ImpCharsRemoved( sal_uLong nPara, sal_uInt16 nPos, sal_uInt16 nChars );
     172             :     void                ImpCharsInserted( sal_uLong nPara, sal_uInt16 nPos, sal_uInt16 nChars );
     173             :     void                ImpFormattingParagraph( sal_uLong nPara );
     174             :     void                ImpTextHeightChanged();
     175             :     void                ImpTextFormatted();
     176             : 
     177             :     DECL_LINK_TYPED(    IdleFormatHdl, Idle *, void );
     178             :     void                CheckIdleFormatter();
     179             :     void                IdleFormatAndUpdate( TextView* pCurView = 0, sal_uInt16 nMaxTimerRestarts = 5 );
     180             : 
     181             :     bool                CreateLines( sal_uLong nPara );
     182             :     void                CreateAndInsertEmptyLine( sal_uLong nPara );
     183             :     void                ImpBreakLine( sal_uLong nPara, TextLine* pLine, TETextPortion* pPortion, sal_uInt16 nPortionStart, long nRemainingWidth );
     184             :     sal_uInt16              SplitTextPortion( sal_uLong nPara, sal_uInt16 nPos );
     185             :     void                CreateTextPortions( sal_uLong nPara, sal_uInt16 nStartPos );
     186             :     void                RecalcTextPortion( sal_uLong nPara, sal_uInt16 nStartPos, short nNewChars );
     187             :     void                SeekCursor( sal_uLong nNode, sal_uInt16 nPos, vcl::Font& rFont, OutputDevice* pOutDev );
     188             : 
     189             :     void                FormatDoc();
     190             :     void                FormatFullDoc();
     191             :     void                FormatAndUpdate( TextView* pCurView = 0 );
     192        1136 :     bool                IsFormatting() const { return mbIsFormatting; }
     193             :     void                UpdateViews( TextView* pCurView = 0 );
     194             : 
     195             :     void                ImpPaint( OutputDevice* pOut, const Point& rStartPos, Rectangle const* pPaintArea, TextSelection const* pPaintRange = 0, TextSelection const* pSelection = 0 );
     196             : 
     197        1432 :     bool                IsFormatted() const { return mbFormatted; }
     198             : 
     199             :     sal_uInt16          GetCharPos( sal_uLong nPara, sal_uInt16 nLine, long nDocPosX, bool bSmart = false );
     200             :     Rectangle           GetEditCursor( const TextPaM& rPaM, bool bSpecial, bool bPreferPortionStart = false );
     201             :     sal_uInt16          ImpFindIndex( sal_uLong nPortion, const Point& rPosInPara, bool bSmart );
     202             :     long                ImpGetPortionXOffset( sal_uLong nPara, TextLine* pLine, sal_uInt16 nTextPortion );
     203             :     long                ImpGetXPos( sal_uLong nPara, TextLine* pLine, sal_uInt16 nIndex, bool bPreferPortionStart = false );
     204             :     long                ImpGetOutputOffset( sal_uLong nPara, TextLine* pLine, sal_uInt16 nIndex, sal_uInt16 nIndex2 );
     205             :     sal_uInt8           ImpGetRightToLeft( sal_uLong nPara, sal_uInt16 nPos, sal_uInt16* pStart = NULL, sal_uInt16* pEnd = NULL );
     206             :     static void         ImpInitLayoutMode( OutputDevice* pOutDev, bool bDrawingR2LPortion = false );
     207             :     TxtAlign            ImpGetAlign() const;
     208             : 
     209             :     sal_uLong           CalcTextHeight();
     210             :     sal_uLong           CalcParaHeight( sal_uLong nParagraph ) const;
     211             :     sal_uLong           CalcTextWidth( sal_uLong nPara );
     212             :     sal_uLong           CalcTextWidth( sal_uLong nPara, sal_uInt16 nPortionStart, sal_uInt16 nPortionLen, const vcl::Font* pFont = 0 );
     213             :     Range               GetInvalidYOffsets( sal_uLong nPortion );
     214             : 
     215             :     // for Undo/Redo
     216             :     void                InsertContent( TextNode* pNode, sal_uLong nPara );
     217             :     TextPaM             SplitContent( sal_uLong nNode, sal_uInt16 nSepPos );
     218             :     TextPaM             ConnectContents( sal_uLong nLeftNode );
     219             : 
     220             :     // adjust PaM's and selections that were transferred to the API to a valid range
     221             :     void                ValidateSelection( TextSelection& rSel ) const;
     222             :     void                ValidatePaM( TextPaM& rPaM ) const;
     223             : 
     224             : public:
     225             :                         TextEngine();
     226             :                         virtual ~TextEngine();
     227             : 
     228             :     void                SetText( const OUString& rStr );
     229             :     OUString            GetText( LineEnd aSeparator = LINEEND_LF ) const;
     230             :     OUString            GetText( const TextSelection& rSel, LineEnd aSeparator = LINEEND_LF ) const;
     231             :     OUString            GetTextLines( LineEnd aSeparator = LINEEND_LF ) const;
     232             :     void                ReplaceText(const TextSelection& rSel, const OUString& rText);
     233             : 
     234             :     sal_uLong           GetTextLen( LineEnd aSeparator = LINEEND_LF ) const;
     235             :     sal_uLong           GetTextLen( const TextSelection& rSel, LineEnd aSeparator = LINEEND_LF ) const;
     236             : 
     237             :     void                SetFont( const vcl::Font& rFont );
     238         400 :     const vcl::Font&    GetFont() const { return maFont; }
     239             : 
     240             :     sal_uInt16          GetDefTab() const;
     241             : 
     242             :     void                SetLeftMargin( sal_uInt16 n );
     243             : 
     244             :     void                SetUpdateMode( bool bUpdate );
     245        1423 :     bool                GetUpdateMode() const { return mbUpdate; }
     246             : 
     247             :     sal_uInt16          GetViewCount() const;
     248             :     TextView*           GetView( sal_uInt16 nView ) const;
     249             :     void                InsertView( TextView* pTextView );
     250             :     void                RemoveView( TextView* pTextView );
     251          52 :     TextView*           GetActiveView() const { return mpActiveView;}
     252             :     void                SetActiveView( TextView* pView );
     253             : 
     254             :     void                SetMaxTextLen( sal_uLong nLen );
     255          17 :     sal_uLong           GetMaxTextLen() const { return mnMaxTextLen; }
     256             : 
     257             :     void                SetMaxTextWidth( sal_uLong nWidth );
     258           0 :     sal_uLong           GetMaxTextWidth() const { return mnMaxTextWidth; }
     259             : 
     260             :     sal_uLong           GetTextHeight() const;
     261             :     sal_uLong           CalcTextWidth();
     262           0 :     long                GetCharHeight() const { return mnCharHeight; }
     263             : 
     264             :     sal_uLong           GetParagraphCount() const;
     265             :     OUString            GetText( sal_uLong nParagraph ) const;
     266             :     sal_uInt16          GetTextLen( sal_uLong nParagraph ) const;
     267             :     sal_uLong           GetTextHeight( sal_uLong nParagraph ) const;
     268             : 
     269             :     sal_uInt16          GetLineCount( sal_uLong nParagraph ) const;
     270             :     sal_uInt16          GetLineLen( sal_uLong nParagraph, sal_uInt16 nLine ) const;
     271             : 
     272             :     void                SetRightToLeft( bool bR2L );
     273        4065 :     bool                IsRightToLeft() const { return mbRightToLeft; }
     274             : 
     275           0 :     bool                HasUndoManager() const { return mpUndoManager != nullptr; }
     276             :     ::svl::IUndoManager&
     277             :                         GetUndoManager();
     278             :     void                UndoActionStart( sal_uInt16 nId = 0 );
     279             :     void                UndoActionEnd();
     280             :     void                InsertUndo( TextUndo* pUndo, bool bTryMerge = false );
     281         479 :     bool                IsInUndo()                  { return mbIsInUndo; }
     282           0 :     void                SetIsInUndo( bool bInUndo ) { mbIsInUndo = bInUndo; }
     283             :     void                ResetUndo();
     284             : 
     285             :     void                EnableUndo( bool bEnable );
     286         565 :     bool                IsUndoEnabled()             { return mbUndoEnabled; }
     287             : 
     288         140 :     void                SetModified( bool bModified )   { mbModified = bModified; }
     289         129 :     bool                IsModified() const              { return mbModified; }
     290             : 
     291             :     bool                Read( SvStream& rInput, const TextSelection* pSel = NULL );
     292             : 
     293             :     bool                Write( SvStream& rOutput, const TextSelection* pSel = NULL, bool bHTML = false );
     294             : 
     295             :     TextPaM             GetPaM( const Point& rDocPos, bool bSmart = true );
     296             :     Rectangle           PaMtoEditCursor( const TextPaM& rPaM, bool bSpecial = false );
     297             :     OUString            GetWord( const TextPaM& rCursorPos, TextPaM* pStartOfWord = 0 );
     298             : 
     299             :     bool                HasAttrib( sal_uInt16 nWhich ) const;
     300             :     const TextAttrib*       FindAttrib( const TextPaM& rPaM, sal_uInt16 nWhich ) const;
     301             :     const TextCharAttrib*   FindCharAttrib( const TextPaM& rPaM, sal_uInt16 nWhich ) const;
     302             : 
     303             :     void                RemoveAttribs( sal_uLong nPara, sal_uInt16 nWhich, bool bIdleFormatAndUpdate );
     304             :     void                RemoveAttrib( sal_uLong nPara, const TextCharAttrib& rAttrib );
     305             :     void                RemoveAttribs( sal_uLong nPara, bool bIdleFormatAndUpdate = true );
     306             :     void                SetAttrib( const TextAttrib& rAttr, sal_uLong nPara, sal_uInt16 nStart, sal_uInt16 nEnd, bool bIdleFormatAndUpdate = true );
     307             : 
     308           0 :     TxtAlign            GetTextAlign() const { return meAlign; }
     309             :     void                SetTextAlign( TxtAlign eAlign );
     310             : 
     311             :     void                Draw( OutputDevice* pDev, const Point& rPos );
     312             : 
     313             :     void                            SetLocale( const ::com::sun::star::lang::Locale& rLocale );
     314             :     ::com::sun::star::lang::Locale  GetLocale();
     315             :     ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > GetBreakIterator();
     316             : 
     317             :     static bool         DoesKeyChangeText( const KeyEvent& rKeyEvent );
     318             :     static bool         IsSimpleCharInput( const KeyEvent& rKeyEvent );
     319             : 
     320           0 :     Color               GetTextColor() const { return maTextColor; }
     321             : };
     322             : 
     323             : #endif // INCLUDED_VCL_TEXTENG_HXX
     324             : 
     325             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11