LCOV - code coverage report
Current view: top level - include/vcl - texteng.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 9 16 56.2 %
Date: 2014-04-11 Functions: 9 16 56.2 %
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             : 
      24             : class TextDoc;
      25             : class TextView;
      26             : class TextPaM;
      27             : class TextSelection;
      28             : class TEParaPortions;
      29             : class TextAttrib;
      30             : class TextCharAttrib;
      31             : class TextUndo;
      32             : class TextUndoManager;
      33             : class EditSelFunctionSet;
      34             : class IdleFormatter;
      35             : class TextNode;
      36             : class OutputDevice;
      37             : class SfxUndoAction;
      38             : class KeyEvent;
      39             : class Timer;
      40             : 
      41             : namespace svl
      42             : {
      43             :     class IUndoManager;
      44             : }
      45             : 
      46             : class TextLine;
      47             : class TETextPortion;
      48             : #include <rtl/ustring.hxx>
      49             : #include <svl/brdcst.hxx>
      50             : #include <tools/lineend.hxx>
      51             : #include <tools/link.hxx>
      52             : #include <tools/gen.hxx>
      53             : #include <vcl/font.hxx>
      54             : 
      55             : #include <com/sun/star/lang/Locale.hpp>
      56             : #include <com/sun/star/uno/Reference.hxx>
      57             : 
      58             : struct TEIMEInfos;
      59             : class SvtCTLOptions;
      60             : 
      61             : namespace com {
      62             : namespace sun {
      63             : namespace star {
      64             : namespace i18n {
      65             :     class XBreakIterator;
      66             :     class XExtendedInputSequenceChecker;
      67             : }}}}
      68             : 
      69             : class LocaleDataWrapper;
      70             : 
      71             : enum TxtAlign { TXTALIGN_LEFT, TXTALIGN_CENTER, TXTALIGN_RIGHT };
      72             : 
      73             : typedef std::vector<TextView*> TextViews;
      74             : 
      75             : class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster
      76             : {
      77             :     friend class        TextView;
      78             :     friend class        TextSelFunctionSet;
      79             :     friend class        ExtTextEngine;
      80             :     friend class        ExtTextView;
      81             : 
      82             :     friend class        TextUndo;
      83             :     friend class        TextUndoManager;
      84             :     friend class        TextUndoDelPara;
      85             :     friend class        TextUndoConnectParas;
      86             :     friend class        TextUndoSplitPara;
      87             :     friend class        TextUndoInsertChars;
      88             :     friend class        TextUndoRemoveChars;
      89             :     friend class        TextUndoSetAttribs;
      90             : 
      91             : private:
      92             :     TextDoc*            mpDoc;
      93             :     TEParaPortions*     mpTEParaPortions;
      94             :     OutputDevice*       mpRefDev;
      95             : 
      96             :     TextViews*          mpViews;
      97             :     TextView*           mpActiveView;
      98             : 
      99             :     TextUndoManager*    mpUndoManager;
     100             : 
     101             :     IdleFormatter*      mpIdleFormatter;
     102             : 
     103             :     TEIMEInfos*         mpIMEInfos;
     104             : 
     105             :     ::com::sun::star::lang::Locale maLocale;
     106             :     ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > mxBreakIterator;
     107             :     css::uno::Reference < css::i18n::XExtendedInputSequenceChecker > mxISC;
     108             : 
     109             :     Rectangle           maInvalidRect;
     110             :     Range               maInvalidRange;
     111             : 
     112             :     LocaleDataWrapper*  mpLocaleDataWrapper;
     113             : 
     114             :     Font                maFont;
     115             :     Color               maTextColor;
     116             :     sal_uInt16              mnCharHeight;
     117             :     sal_uInt16              mnFixCharWidth100;
     118             : 
     119             :     sal_uLong               mnMaxTextLen;
     120             :     sal_uLong               mnMaxTextWidth;
     121             :     sal_uLong               mnCurTextWidth;
     122             :     sal_uLong               mnCurTextHeight;
     123             :     sal_uLong               mnDefTab;
     124             : 
     125             :     TxtAlign            meAlign;
     126             : 
     127             :     bool                mbIsFormatting      : 1;    // semaphore for the Hook's
     128             :     bool                mbFormatted         : 1;
     129             :     bool                mbUpdate            : 1;
     130             :     bool                mbModified          : 1;
     131             :     bool                mbUndoEnabled       : 1;
     132             :     bool                mbIsInUndo          : 1;
     133             :     bool                mbDowning           : 1;
     134             :     bool                mbRightToLeft       : 1;
     135             :     bool                mbHasMultiLineParas : 1;
     136             : 
     137             :                         TextEngine( const TextEngine& ) : SfxBroadcaster()  {}
     138             :     TextEngine&         operator=( const TextEngine& )      { return *this; }
     139             : 
     140             : protected:
     141             : 
     142             :     void                CursorMoved( sal_uLong nNode );
     143             :     void                TextModified();
     144             : 
     145             :     void                ImpInitDoc();
     146             :     void                ImpRemoveText();
     147             :     TextPaM             ImpDeleteText( const TextSelection& rSel );
     148             :     TextPaM             ImpInsertText( const TextSelection& rSel, sal_Unicode c, bool bOverwrite = false );
     149             :     TextPaM             ImpInsertText( const TextSelection& rSel, const OUString& rText );
     150             :     TextPaM             ImpInsertParaBreak( const TextSelection& rTextSelection, bool bKeepEndingAttribs = true );
     151             :     TextPaM             ImpInsertParaBreak( const TextPaM& rPaM, bool bKeepEndingAttribs = true );
     152             :     void                ImpRemoveChars( const TextPaM& rPaM, sal_uInt16 nChars, SfxUndoAction* pCurUndo = 0 );
     153             :     TextPaM             ImpConnectParagraphs( sal_uLong nLeft, sal_uLong nRight );
     154             :     void                ImpRemoveParagraph( sal_uLong nPara );
     155             :     void                ImpInitWritingDirections( sal_uLong nPara );
     156             :     LocaleDataWrapper*  ImpGetLocaleDataWrapper();
     157             : 
     158             :     // to remain compatible in the minor release we copy the above ImpInsertText
     159             :     // function and add the extra parameter we need but make sure this function
     160             :     // gets not exported. First and seconf parameter swapped to have a different signatur.
     161             :     SAL_DLLPRIVATE TextPaM  ImpInsertText( sal_Unicode c, const TextSelection& rSel, bool bOverwrite = false, bool bIsUserInput = false );
     162             :     // some other new functions needed that must not be exported to remain compatible
     163             :     SAL_DLLPRIVATE ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XExtendedInputSequenceChecker > GetInputSequenceChecker();
     164             :     SAL_DLLPRIVATE bool IsInputSequenceCheckingRequired( sal_Unicode c, const TextSelection& rCurSel ) const;
     165             : 
     166             :     // broadcast or adjust selections
     167             :     void                ImpParagraphInserted( sal_uLong nPara );
     168             :     void                ImpParagraphRemoved( sal_uLong nPara );
     169             :     void                ImpCharsRemoved( sal_uLong nPara, sal_uInt16 nPos, sal_uInt16 nChars );
     170             :     void                ImpCharsInserted( sal_uLong nPara, sal_uInt16 nPos, sal_uInt16 nChars );
     171             :     void                ImpFormattingParagraph( sal_uLong nPara );
     172             :     void                ImpTextHeightChanged();
     173             :     void                ImpTextFormatted();
     174             : 
     175             :     DECL_LINK(          IdleFormatHdl, void * );
     176             :     void                CheckIdleFormatter();
     177             :     void                IdleFormatAndUpdate( TextView* pCurView = 0, sal_uInt16 nMaxTimerRestarts = 5 );
     178             : 
     179             :     bool                CreateLines( sal_uLong nPara );
     180             :     void                CreateAndInsertEmptyLine( sal_uLong nPara );
     181             :     void                ImpBreakLine( sal_uLong nPara, TextLine* pLine, TETextPortion* pPortion, sal_uInt16 nPortionStart, long nRemainingWidth );
     182             :     sal_uInt16              SplitTextPortion( sal_uLong nPara, sal_uInt16 nPos );
     183             :     void                CreateTextPortions( sal_uLong nPara, sal_uInt16 nStartPos );
     184             :     void                RecalcTextPortion( sal_uLong nPara, sal_uInt16 nStartPos, short nNewChars );
     185             :     void                SeekCursor( sal_uLong nNode, sal_uInt16 nPos, Font& rFont, OutputDevice* pOutDev );
     186             : 
     187             :     void                FormatDoc();
     188             :     void                FormatFullDoc();
     189             :     void                FormatAndUpdate( TextView* pCurView = 0 );
     190        1044 :     bool                IsFormatting() const { return mbIsFormatting; }
     191             :     void                UpdateViews( TextView* pCurView = 0 );
     192             : 
     193             :     void                ImpPaint( OutputDevice* pOut, const Point& rStartPos, Rectangle const* pPaintArea, TextSelection const* pPaintRange = 0, TextSelection const* pSelection = 0 );
     194             : 
     195             :     void                UpdateSelections();
     196             : 
     197        1296 :     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             :     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 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 transfered 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 Font& rFont );
     238         369 :     const 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        1272 :     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             :     TextView*           GetActiveView() const;
     252             :     void                SetActiveView( TextView* pView );
     253             : 
     254             :     void                SetMaxTextLen( sal_uLong nLen );
     255           0 :     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 :     sal_uInt16          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        3470 :     bool                IsRightToLeft() const { return mbRightToLeft; }
     274             : 
     275           0 :     bool                HasUndoManager() const { return mpUndoManager ? true : false; }
     276             :     ::svl::IUndoManager&
     277             :                         GetUndoManager();
     278             :     void                UndoActionStart( sal_uInt16 nId = 0 );
     279             :     void                UndoActionEnd();
     280             :     void                InsertUndo( TextUndo* pUndo, bool bTryMerge = false );
     281         401 :     bool                IsInUndo()                  { return mbIsInUndo; }
     282           0 :     void                SetIsInUndo( bool bInUndo ) { mbIsInUndo = bInUndo; }
     283             :     void                ResetUndo();
     284             : 
     285             :     void                EnableUndo( bool bEnable );
     286         500 :     bool                IsUndoEnabled()             { return mbUndoEnabled; }
     287             : 
     288         123 :     void                SetModified( bool bModified )   { mbModified = bModified; }
     289         112 :     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.10