LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/vcl - texteng.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 15 0.0 %
Date: 2012-12-27 Functions: 0 15 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10