LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/editeng - editdata.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 29 50 58.0 %
Date: 2013-07-09 Functions: 10 15 66.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             : 
      20             : // MyEDITDATA, wegen exportiertem EditData
      21             : #ifndef _MyEDITDATA_HXX
      22             : #define _MyEDITDATA_HXX
      23             : 
      24             : #include <tools/string.hxx>
      25             : #include "editeng/editengdllapi.h"
      26             : 
      27             : class SfxItemSet;
      28             : class SfxPoolItem;
      29             : class SvParser;
      30             : class SvxFieldItem;
      31             : 
      32             : enum EETextFormat       { EE_FORMAT_TEXT = 0x20, EE_FORMAT_RTF, EE_FORMAT_BIN = 0x31, EE_FORMAT_HTML, EE_FORMAT_XML };
      33             : enum EEHorizontalTextDirection { EE_HTEXTDIR_DEFAULT, EE_HTEXTDIR_L2R, EE_HTEXTDIR_R2L };
      34             : enum EESelectionMode    { EE_SELMODE_STD, EE_SELMODE_TXTONLY, EE_SELMODE_HIDDEN };
      35             :     // EE_SELMODE_HIDDEN can be used to completely hide the selection. This is useful e.g. when you want show the selection
      36             :     // only as long as your window (which the edit view works on) has the focus
      37             : enum EESpellState       { EE_SPELL_OK, EE_SPELL_NOLANGUAGE, EE_SPELL_LANGUAGENOTINSTALLED, EE_SPELL_NOSPELLER, EE_SPELL_ERRORFOUND };
      38             : enum EVAnchorMode       {
      39             :             ANCHOR_TOP_LEFT,    ANCHOR_VCENTER_LEFT,    ANCHOR_BOTTOM_LEFT,
      40             :             ANCHOR_TOP_HCENTER, ANCHOR_VCENTER_HCENTER, ANCHOR_BOTTOM_HCENTER,
      41             :             ANCHOR_TOP_RIGHT,   ANCHOR_VCENTER_RIGHT,   ANCHOR_BOTTOM_RIGHT };
      42             : 
      43             : #define EE_PARA_NOT_FOUND       SAL_MAX_INT32
      44             : #define EE_PARA_APPEND          SAL_MAX_INT32
      45             : #define EE_PARA_ALL             SAL_MAX_INT32
      46             : #define EE_PARA_MAX_COUNT       SAL_MAX_INT32
      47             : 
      48             : #define EE_INDEX_NOT_FOUND      SAL_MAX_UINT16
      49             : #define EE_TEXTPOS_ALL          SAL_MAX_UINT16
      50             : #define EE_TEXTPOS_MAX_COUNT    SAL_MAX_UINT16
      51             : 
      52             : EDITENG_DLLPUBLIC extern const size_t EE_APPEND;
      53             : 
      54             : // Error messages for Read / Write Method
      55             : #define EE_READWRITE_OK              (SVSTREAM_OK)
      56             : #define EE_READWRITE_WRONGFORMAT     (SVSTREAM_ERRBASE_USER+1)
      57             : #define EE_READWRITE_GENERALERROR    (SVSTREAM_ERRBASE_USER+2)
      58             : 
      59             : #define EDITUNDO_START              100
      60             : #define EDITUNDO_REMOVECHARS        100
      61             : #define EDITUNDO_CONNECTPARAS       101
      62             : #define EDITUNDO_REMOVEFEATURE      102
      63             : #define EDITUNDO_MOVEPARAGRAPHS     103
      64             : #define EDITUNDO_INSERTFEATURE      104
      65             : #define EDITUNDO_SPLITPARA          105
      66             : #define EDITUNDO_INSERTCHARS        106
      67             : #define EDITUNDO_DELCONTENT         107
      68             : #define EDITUNDO_DELETE             108
      69             : #define EDITUNDO_CUT                109
      70             : #define EDITUNDO_PASTE              110
      71             : #define EDITUNDO_INSERT             111
      72             : #define EDITUNDO_SRCHANDREPL        112
      73             : #define EDITUNDO_MOVEPARAS          113
      74             : #define EDITUNDO_PARAATTRIBS        114
      75             : #define EDITUNDO_ATTRIBS            115
      76             : #define EDITUNDO_DRAGANDDROP        116
      77             : #define EDITUNDO_READ               117
      78             : #define EDITUNDO_STYLESHEET         118
      79             : #define EDITUNDO_REPLACEALL         119
      80             : #define EDITUNDO_STRETCH            120
      81             : #define EDITUNDO_RESETATTRIBS       121
      82             : #define EDITUNDO_INDENTBLOCK        122
      83             : #define EDITUNDO_UNINDENTBLOCK      123
      84             : #define EDITUNDO_MARKSELECTION      124
      85             : #define EDITUNDO_TRANSLITERATE      125
      86             : #define EDITUNDO_END                125
      87             : 
      88             : #define EDITUNDO_USER               200
      89             : 
      90             : class EditView;
      91             : class EditEngine;
      92             : class ImpEditView;
      93             : class ImpEditEngine;
      94             : class EditTextObject;
      95             : class SfxStyleSheet;
      96             : 
      97             : #define RGCHK_NONE          0   // No correction of ViusArea when scrolling
      98             : #define RGCHK_NEG           1   // No negative ViusArea when scrolling
      99             : #define RGCHK_PAPERSZ1      2   // VisArea must be within paper width, Text Size
     100             : 
     101             : struct EPosition
     102             : {
     103             :     sal_Int32   nPara;
     104             :     xub_StrLen  nIndex;
     105             : 
     106          41 :     EPosition() :
     107             :         nPara( EE_PARA_NOT_FOUND ),
     108          41 :         nIndex( EE_INDEX_NOT_FOUND )
     109             :     {
     110          41 :     }
     111             : 
     112          51 :     EPosition( sal_Int32 nPara_, xub_StrLen nPos_ ) :
     113             :         nPara( nPara_ ),
     114          51 :         nIndex( nPos_ )
     115             :     {
     116          51 :     }
     117             : };
     118             : 
     119             : struct ESelection
     120             : {
     121             :     sal_Int32   nStartPara;
     122             :     xub_StrLen  nStartPos;
     123             :     sal_Int32   nEndPara;
     124             :     xub_StrLen  nEndPos;
     125             : 
     126      171535 :     ESelection() : nStartPara( 0 ), nStartPos( 0 ), nEndPara( 0 ), nEndPos( 0 ) {}
     127             : 
     128      112217 :     ESelection( sal_Int32 nStPara, xub_StrLen nStPos, sal_Int32 nEPara, xub_StrLen nEPos ) :
     129             :         nStartPara( nStPara ),
     130             :         nStartPos( nStPos ),
     131             :         nEndPara( nEPara ),
     132      112217 :         nEndPos( nEPos )
     133             :     {
     134      112217 :     }
     135             : 
     136          46 :     ESelection( sal_Int32 nPara, xub_StrLen nPos ) :
     137             :         nStartPara( nPara ),
     138             :         nStartPos( nPos ),
     139             :         nEndPara( nPara ),
     140          46 :         nEndPos( nPos )
     141             :     {
     142          46 :     }
     143             : 
     144             :     void    Adjust();
     145             :     sal_Bool    IsEqual( const ESelection& rS ) const;
     146             :     sal_Bool    IsLess( const ESelection& rS ) const;
     147             :     sal_Bool    IsGreater( const ESelection& rS ) const;
     148             :     sal_Bool    IsZero() const;
     149             :     sal_Bool    HasRange() const;
     150             : };
     151             : 
     152          46 : inline sal_Bool ESelection::HasRange() const
     153             : {
     154          46 :     return ( nStartPara != nEndPara ) || ( nStartPos != nEndPos );
     155             : }
     156             : 
     157           0 : inline sal_Bool ESelection::IsZero() const
     158             : {
     159           0 :     return ( ( nStartPara == 0 ) && ( nStartPos == 0 ) &&
     160           0 :              ( nEndPara == 0 ) && ( nEndPos == 0 ) );
     161             : }
     162             : 
     163         514 : inline sal_Bool ESelection::IsEqual( const ESelection& rS ) const
     164             : {
     165        1542 :     return ( ( nStartPara == rS.nStartPara ) && ( nStartPos == rS.nStartPos ) &&
     166        1542 :              ( nEndPara == rS.nEndPara ) && ( nEndPos == rS.nEndPos ) );
     167             : }
     168             : 
     169           0 : inline sal_Bool ESelection::IsLess( const ESelection& rS ) const
     170             : {
     171             :     // The selection must be adjusted.
     172             :     // => Only check if end of 'this' < Start of rS
     173             : 
     174           0 :     if ( ( nEndPara < rS.nStartPara ) ||
     175           0 :          ( ( nEndPara == rS.nStartPara ) && ( nEndPos < rS.nStartPos ) && !IsEqual( rS ) ) )
     176             :     {
     177           0 :         return sal_True;
     178             :     }
     179           0 :     return sal_False;
     180             : }
     181             : 
     182           0 : inline sal_Bool ESelection::IsGreater( const ESelection& rS ) const
     183             : {
     184             :     // The selection must be adjusted.
     185             :     // => Only check if end of 'this' < Start of rS
     186             : 
     187           0 :     if ( ( nStartPara > rS.nEndPara ) ||
     188           0 :          ( ( nStartPara == rS.nEndPara ) && ( nStartPos > rS.nEndPos ) && !IsEqual( rS ) ) )
     189             :     {
     190           0 :         return sal_True;
     191             :     }
     192           0 :     return sal_False;
     193             : }
     194             : 
     195        1338 : inline void ESelection::Adjust()
     196             : {
     197        1338 :     sal_Bool bSwap = sal_False;
     198        1338 :     if ( nStartPara > nEndPara )
     199           0 :         bSwap = sal_True;
     200        1338 :     else if ( ( nStartPara == nEndPara ) && ( nStartPos > nEndPos ) )
     201           0 :         bSwap = sal_True;
     202             : 
     203        1338 :     if ( bSwap )
     204             :     {
     205           0 :         sal_Int32  nSPar = nStartPara; sal_uInt16 nSPos = nStartPos;
     206           0 :         nStartPara = nEndPara; nStartPos = nEndPos;
     207           0 :         nEndPara = nSPar; nEndPos = nSPos;
     208             :     }
     209        1338 : }
     210             : 
     211             : struct EDITENG_DLLPUBLIC EFieldInfo
     212             : {
     213             :     SvxFieldItem*   pFieldItem;
     214             :     String          aCurrentText;
     215             :     EPosition       aPosition;
     216             : 
     217             :     EFieldInfo();
     218             :     EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_uInt16 nPos );
     219             :     ~EFieldInfo();
     220             : 
     221             :     EFieldInfo( const EFieldInfo& );
     222             :     EFieldInfo& operator= ( const EFieldInfo& );
     223             : };
     224             : 
     225             : // -----------------------------------------------------------------------
     226             : 
     227             : enum ImportState {
     228             :                     RTFIMP_START, RTFIMP_END,               // only pParser, nPara, nIndex
     229             :                     RTFIMP_NEXTTOKEN, RTFIMP_UNKNOWNATTR,   // nToken+nTokenValue
     230             :                     RTFIMP_SETATTR,                         // pAttrs
     231             :                     RTFIMP_INSERTTEXT,                      // aText
     232             :                     RTFIMP_INSERTPARA,                      // -
     233             :                     HTMLIMP_START, HTMLIMP_END,             // only pParser, nPara, nIndex
     234             :                     HTMLIMP_NEXTTOKEN, HTMLIMP_UNKNOWNATTR, // nToken
     235             :                     HTMLIMP_SETATTR,                        // pAttrs
     236             :                     HTMLIMP_INSERTTEXT,                     // aText
     237             :                     HTMLIMP_INSERTPARA, HTMLIMP_INSERTFIELD // -
     238             :                     };
     239             : 
     240             : struct ImportInfo
     241             : {
     242             :     SvParser*               pParser;
     243             :     ESelection              aSelection;
     244             :     ImportState             eState;
     245             : 
     246             :     int                     nToken;
     247             :     short                   nTokenValue;
     248             : 
     249             :     String                  aText;
     250             : 
     251             :     void*                   pAttrs; // RTF: SvxRTFItemStackType*, HTML: SfxItemSet*
     252             : 
     253             :     ImportInfo( ImportState eState, SvParser* pPrsrs, const ESelection& rSel );
     254             :     ~ImportInfo();
     255             : };
     256             : 
     257             : struct ParagraphInfos
     258             : {
     259       89619 :     ParagraphInfos()
     260             :         : nParaHeight( 0 )
     261             :         , nLines( 0 )
     262             :         , nFirstLineStartX( 0 )
     263             :         , nFirstLineOffset( 0 )
     264             :         , nFirstLineHeight( 0 )
     265             :         , nFirstLineTextHeight ( 0 )
     266             :         , nFirstLineMaxAscent( 0 )
     267       89619 :         , bValid( 0 )
     268       89619 :         {}
     269             :     sal_uInt16  nParaHeight;
     270             :     sal_uInt16  nLines;
     271             : 
     272             :     sal_uInt16  nFirstLineStartX;
     273             : 
     274             :     sal_uInt16  nFirstLineOffset;
     275             :     sal_uInt16  nFirstLineHeight;
     276             :     sal_uInt16  nFirstLineTextHeight;
     277             :     sal_uInt16  nFirstLineMaxAscent;
     278             : 
     279             :     sal_Bool    bValid; // A query during formatting is not valid!
     280             : };
     281             : 
     282             : struct EECharAttrib
     283             : {
     284             :     const SfxPoolItem*  pAttr;
     285             : 
     286             :     sal_Int32           nPara;
     287             :     xub_StrLen          nStart;
     288             :     xub_StrLen          nEnd;
     289             : };
     290             : 
     291             : struct MoveParagraphsInfo
     292             : {
     293             :     sal_Int32  nStartPara;
     294             :     sal_Int32  nEndPara;
     295             :     sal_Int32  nDestPara;
     296             : 
     297           0 :     MoveParagraphsInfo( sal_Int32 nS, sal_Int32 nE, sal_Int32 nD )
     298           0 :         { nStartPara = nS; nEndPara = nE; nDestPara = nD; }
     299             : };
     300             : 
     301             : #define EE_ACTION_PASTE 1
     302             : #define EE_ACTION_DROP  2
     303             : 
     304             : struct PasteOrDropInfos
     305             : {
     306             :     sal_uInt16  nAction;
     307             :     sal_Int32   nStartPara;
     308             :     sal_Int32   nEndPara;
     309             : 
     310           0 :     PasteOrDropInfos() : nAction(0), nStartPara(0xFFFFFFFF), nEndPara(0xFFFFFFFF)  {}
     311             : };
     312             : 
     313             : enum EENotifyType
     314             : {
     315             :     /// EditEngine text was modified
     316             :     EE_NOTIFY_TEXTMODIFIED,
     317             : 
     318             :     /// A paragraph was inserted into the EditEngine
     319             :     EE_NOTIFY_PARAGRAPHINSERTED,
     320             : 
     321             :     /// A paragraph was removed from the EditEngine
     322             :     EE_NOTIFY_PARAGRAPHREMOVED,
     323             : 
     324             :     /// Multiple paragraphs have been removed from the EditEngine
     325             :     EE_NOTIFY_PARAGRAPHSMOVED,
     326             : 
     327             :     /// The height of at least one paragraph has changed
     328             :     EE_NOTIFY_TEXTHEIGHTCHANGED,
     329             : 
     330             :     /// The view area of the EditEngine scrolled
     331             :     EE_NOTIFY_TEXTVIEWSCROLLED,
     332             : 
     333             :     /// The selection and/or the cursor position has changed
     334             :     EE_NOTIFY_TEXTVIEWSELECTIONCHANGED,
     335             : 
     336             :     /** Denotes the beginning of a collected amount of EditEngine
     337             :         notification events. This event itself is not queued, but sent
     338             :         immediately
     339             :      */
     340             :     EE_NOTIFY_BLOCKNOTIFICATION_START,
     341             : 
     342             :     /** Denotes the end of a collected amount of EditEngine
     343             :         notification events. After this event, the queue is empty, and
     344             :         a high-level operation such as "insert paragraph" is finished
     345             :      */
     346             :     EE_NOTIFY_BLOCKNOTIFICATION_END,
     347             : 
     348             :     /// Denotes the beginning of a high-level action triggered by a key press
     349             :     EE_NOTIFY_INPUT_START,
     350             : 
     351             :     /// Denotes the end of a high-level action triggered by a key press
     352             :     EE_NOTIFY_INPUT_END
     353             : };
     354             : 
     355             : struct EENotify
     356             : {
     357             :     EENotifyType    eNotificationType;
     358             :     EditEngine*     pEditEngine;
     359             :     EditView*       pEditView;
     360             : 
     361             :     sal_Int32       nParagraph; // only valid in PARAGRAPHINSERTED/EE_NOTIFY_PARAGRAPHREMOVED
     362             : 
     363             :     sal_Int32       nParam1;
     364             :     sal_Int32       nParam2;
     365             : 
     366     1335477 :     EENotify( EENotifyType eType )
     367     1335477 :         { eNotificationType = eType; pEditEngine = NULL; pEditView = NULL; nParagraph = EE_PARA_NOT_FOUND; nParam1 = 0; nParam2 = 0; }
     368             : };
     369             : 
     370             : #endif // _MyEDITDATA_HXX
     371             : 
     372             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10