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

Generated by: LCOV version 1.10