LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/vcl - edit.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 5 18 27.8 %
Date: 2012-08-25 Functions: 5 15 33.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 8 12.5 %

           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                 :            : 
      29                 :            : #ifndef _SV_EDIT_HXX
      30                 :            : #define _SV_EDIT_HXX
      31                 :            : 
      32                 :            : #include <tools/solar.h>
      33                 :            : #include <vcl/dllapi.h>
      34                 :            : #include <vcl/timer.hxx>
      35                 :            : #include <vcl/ctrl.hxx>
      36                 :            : #include <vcl/menu.hxx>
      37                 :            : #include <vcl/dndhelp.hxx>
      38                 :            : #include <com/sun/star/uno/Reference.h>
      39                 :            : 
      40                 :            : namespace com {
      41                 :            : namespace sun {
      42                 :            : namespace star {
      43                 :            : namespace i18n {
      44                 :            :     class XBreakIterator;
      45                 :            :     class XExtendedInputSequenceChecker;
      46                 :            : }}}}
      47                 :            : 
      48                 :            : struct DDInfo;
      49                 :            : struct Impl_IMEInfos;
      50                 :            : 
      51                 :            : // --------------
      52                 :            : // - Edit-Types -
      53                 :            : // --------------
      54                 :            : 
      55                 :            : #define EDIT_NOLIMIT                STRING_LEN
      56                 :            : #define EDIT_UPDATEDATA_TIMEOUT     350
      57                 :            : 
      58                 :            : typedef XubString (*FncGetSpecialChars)( Window* pWin, const Font& rFont );
      59                 :            : 
      60                 :            : // --------
      61                 :            : // - Edit -
      62                 :            : // --------
      63                 :            : 
      64                 :            : enum AutocompleteAction{ AUTOCOMPLETE_KEYINPUT, AUTOCOMPLETE_TABFORWARD, AUTOCOMPLETE_TABBACKWARD };
      65                 :            : 
      66                 :            : class VCL_DLLPUBLIC Edit : public Control, public vcl::unohelper::DragAndDropClient
      67                 :            : {
      68                 :            : private:
      69                 :            :     Edit*               mpSubEdit;
      70                 :            :     Timer*              mpUpdateDataTimer;
      71                 :            :     DDInfo*             mpDDInfo;
      72                 :            :     Impl_IMEInfos*      mpIMEInfos;
      73                 :            :     XubString           maText;
      74                 :            :     XubString           maSaveValue;
      75                 :            :     XubString           maUndoText;
      76                 :            :     XubString           maRedoText;
      77                 :            :     long                mnXOffset;
      78                 :            :     Selection           maSelection;
      79                 :            :     sal_uInt16              mnAlign;
      80                 :            :     xub_StrLen          mnMaxTextLen;
      81                 :            :     AutocompleteAction  meAutocompleteAction;
      82                 :            :     xub_Unicode         mcEchoChar;
      83                 :            :     sal_Bool                mbModified:1,
      84                 :            :                         mbInternModified:1,
      85                 :            :                         mbReadOnly:1,
      86                 :            :                         mbInsertMode:1,
      87                 :            :                         mbClickedInSelection:1,
      88                 :            :                         mbIsSubEdit:1,
      89                 :            :                         mbInMBDown:1,
      90                 :            :                         mbActivePopup:1;
      91                 :            :     Link                maModifyHdl;
      92                 :            :     Link                maUpdateDataHdl;
      93                 :            :     Link                maAutocompleteHdl;
      94                 :            : 
      95                 :            :     DECL_DLLPRIVATE_LINK(      ImplUpdateDataHdl, void* );
      96                 :            : 
      97                 :            :     SAL_DLLPRIVATE bool        ImplTruncateToMaxLen( rtl::OUString&, sal_uInt32 nSelectionLen ) const;
      98                 :            :     SAL_DLLPRIVATE void        ImplInitEditData();
      99                 :            :     SAL_DLLPRIVATE void        ImplModified();
     100                 :            :     SAL_DLLPRIVATE XubString   ImplGetText() const;
     101                 :            :     SAL_DLLPRIVATE void        ImplRepaint( xub_StrLen nStart = 0, xub_StrLen nEnd = STRING_LEN, bool bLayout = false );
     102                 :            :     SAL_DLLPRIVATE void        ImplInvalidateOrRepaint( xub_StrLen nStart = 0, xub_StrLen nEnd = STRING_LEN );
     103                 :            :     SAL_DLLPRIVATE void        ImplDelete( const Selection& rSelection, sal_uInt8 nDirection, sal_uInt8 nMode );
     104                 :            :     SAL_DLLPRIVATE void        ImplSetText( const XubString& rStr, const Selection* pNewSelection = 0 );
     105                 :            :     SAL_DLLPRIVATE void        ImplInsertText( const rtl::OUString& rStr, const Selection* pNewSelection = 0, sal_Bool bIsUserInput = sal_False );
     106                 :            :     SAL_DLLPRIVATE String      ImplGetValidString( const String& rString ) const;
     107                 :            :     SAL_DLLPRIVATE void        ImplClearBackground( long nXStart, long nXEnd );
     108                 :            :     SAL_DLLPRIVATE void        ImplPaintBorder( long nXStart, long nXEnd );
     109                 :            :     SAL_DLLPRIVATE void        ImplShowCursor( sal_Bool bOnlyIfVisible = sal_True );
     110                 :            :     SAL_DLLPRIVATE void        ImplAlign();
     111                 :            :     SAL_DLLPRIVATE void        ImplAlignAndPaint();
     112                 :            :     SAL_DLLPRIVATE xub_StrLen  ImplGetCharPos( const Point& rWindowPos ) const;
     113                 :            :     SAL_DLLPRIVATE void        ImplSetCursorPos( xub_StrLen nChar, sal_Bool bSelect );
     114                 :            :     SAL_DLLPRIVATE void        ImplShowDDCursor();
     115                 :            :     SAL_DLLPRIVATE void        ImplHideDDCursor();
     116                 :            :     SAL_DLLPRIVATE sal_Bool        ImplHandleKeyEvent( const KeyEvent& rKEvt );
     117                 :            :     SAL_DLLPRIVATE void        ImplCopyToSelectionClipboard();
     118                 :            :     SAL_DLLPRIVATE void        ImplCopy( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard );
     119                 :            :     SAL_DLLPRIVATE void        ImplPaste( ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& rxClipboard );
     120                 :            :     SAL_DLLPRIVATE long        ImplGetExtraOffset() const;
     121                 :            :     SAL_DLLPRIVATE long        ImplGetTextYPosition() const;
     122                 :            :     SAL_DLLPRIVATE ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XExtendedInputSequenceChecker > ImplGetInputSequenceChecker() const;
     123                 :            :     SAL_DLLPRIVATE ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XBreakIterator > ImplGetBreakIterator() const;
     124                 :            : 
     125                 :            : protected:
     126                 :            :     using Control::ImplInitSettings;
     127                 :            :     using Window::ImplInit;
     128                 :            :     SAL_DLLPRIVATE void        ImplInit( Window* pParent, WinBits nStyle );
     129                 :            :     SAL_DLLPRIVATE WinBits     ImplInitStyle( WinBits nStyle );
     130                 :            :     SAL_DLLPRIVATE void        ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
     131                 :            :     SAL_DLLPRIVATE void        ImplLoadRes( const ResId& rResId );
     132                 :            :     SAL_DLLPRIVATE void        ImplSetSelection( const Selection& rSelection, sal_Bool bPaint = sal_True );
     133                 :            :     SAL_DLLPRIVATE int         ImplGetNativeControlType();
     134                 :            :     static SAL_DLLPRIVATE void ImplInvalidateOutermostBorder( Window* pWin );
     135                 :            : 
     136                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSourceListener > mxDnDListener;
     137                 :            : 
     138                 :            :     // DragAndDropClient
     139                 :            :     using vcl::unohelper::DragAndDropClient::dragEnter;
     140                 :            :     using vcl::unohelper::DragAndDropClient::dragExit;
     141                 :            :     using vcl::unohelper::DragAndDropClient::dragOver;
     142                 :            :     virtual void        dragGestureRecognized( const ::com::sun::star::datatransfer::dnd::DragGestureEvent& dge ) throw (::com::sun::star::uno::RuntimeException);
     143                 :            :     virtual void        dragDropEnd( const ::com::sun::star::datatransfer::dnd::DragSourceDropEvent& dsde ) throw (::com::sun::star::uno::RuntimeException);
     144                 :            :     virtual void        drop( const ::com::sun::star::datatransfer::dnd::DropTargetDropEvent& dtde ) throw (::com::sun::star::uno::RuntimeException);
     145                 :            :     virtual void        dragEnter( const ::com::sun::star::datatransfer::dnd::DropTargetDragEnterEvent& dtdee ) throw (::com::sun::star::uno::RuntimeException);
     146                 :            :     virtual void        dragExit( const ::com::sun::star::datatransfer::dnd::DropTargetEvent& dte ) throw (::com::sun::star::uno::RuntimeException);
     147                 :            :     virtual void        dragOver( const ::com::sun::star::datatransfer::dnd::DropTargetDragEvent& dtde ) throw (::com::sun::star::uno::RuntimeException);
     148                 :            : 
     149                 :            :     protected:
     150                 :            :     virtual void FillLayoutData() const;
     151                 :            : 
     152                 :            :                         Edit( WindowType nType );
     153                 :            : 
     154                 :            : public:
     155                 :            :     // public because needed in button.cxx
     156                 :            :     SAL_DLLPRIVATE bool        ImplUseNativeBorder( WinBits nStyle );
     157                 :            : 
     158                 :            :                         Edit( Window* pParent, WinBits nStyle = WB_BORDER );
     159                 :            :                         Edit( Window* pParent, const ResId& rResId );
     160                 :            :                         Edit( Window* pParent, const ResId& rResId, bool bDisableAccessibleLabeledByRelation );
     161                 :            :                         virtual ~Edit();
     162                 :            : 
     163                 :            :     virtual void        MouseButtonDown( const MouseEvent& rMEvt );
     164                 :            :     virtual void        MouseButtonUp( const MouseEvent& rMEvt );
     165                 :            :     virtual void        KeyInput( const KeyEvent& rKEvt );
     166                 :            :     virtual void        Paint( const Rectangle& rRect );
     167                 :            :     virtual void        Resize();
     168                 :            :     virtual void        Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
     169                 :            :     virtual void        GetFocus();
     170                 :            :     virtual void        LoseFocus();
     171                 :            :     virtual void        Tracking( const TrackingEvent& rTEvt );
     172                 :            :     virtual void        Command( const CommandEvent& rCEvt );
     173                 :            :     virtual void        StateChanged( StateChangedType nType );
     174                 :            :     virtual void        DataChanged( const DataChangedEvent& rDCEvt );
     175                 :            :     virtual Window*     GetPreferredKeyInputWindow();
     176                 :            : 
     177                 :            :     virtual void        Modify();
     178                 :            :     virtual void        UpdateData();
     179                 :            : 
     180                 :            :     static sal_Bool         IsCharInput( const KeyEvent& rKEvt );
     181                 :            : 
     182                 :            :     virtual void        SetModifyFlag();
     183                 :            :     virtual void        ClearModifyFlag();
     184         [ #  # ]:          0 :     virtual sal_Bool        IsModified() const { return mpSubEdit ? mpSubEdit->mbModified : mbModified; }
     185                 :            : 
     186                 :            :     virtual void        EnableUpdateData( sal_uLong nTimeout = EDIT_UPDATEDATA_TIMEOUT );
     187         [ #  # ]:          0 :     virtual void        DisableUpdateData() { delete mpUpdateDataTimer; mpUpdateDataTimer = NULL; }
     188                 :            :     virtual sal_uLong       IsUpdateDataEnabled() const;
     189                 :            : 
     190                 :            :     void                SetEchoChar( xub_Unicode c );
     191                 :         22 :     xub_Unicode         GetEchoChar() const { return mcEchoChar; }
     192                 :            : 
     193                 :            :     virtual void        SetReadOnly( sal_Bool bReadOnly = sal_True );
     194                 :        198 :     virtual sal_Bool        IsReadOnly() const { return mbReadOnly; }
     195                 :            : 
     196                 :            :     void                SetInsertMode( sal_Bool bInsert );
     197                 :            :     sal_Bool                IsInsertMode() const;
     198                 :            : 
     199                 :            :     virtual void        SetMaxTextLen( xub_StrLen nMaxLen = EDIT_NOLIMIT );
     200                 :          0 :     virtual xub_StrLen  GetMaxTextLen() const { return mnMaxTextLen; }
     201                 :            : 
     202                 :            :     virtual void        SetSelection( const Selection& rSelection );
     203                 :            :     virtual const Selection&    GetSelection() const;
     204                 :            : 
     205                 :            :     virtual void        ReplaceSelected( const XubString& rStr );
     206                 :            :     virtual void        DeleteSelected();
     207                 :            :     virtual XubString   GetSelected() const;
     208                 :            : 
     209                 :            :     virtual void        Cut();
     210                 :            :     virtual void        Copy();
     211                 :            :     virtual void        Paste();
     212                 :            :     void                Undo();
     213                 :            : 
     214                 :            :     virtual void        SetText( const XubString& rStr );
     215                 :            :     virtual void        SetText( const XubString& rStr, const Selection& rNewSelection );
     216                 :            :     virtual XubString   GetText() const;
     217                 :            : 
     218         [ +  - ]:      12162 :     void                SaveValue() { maSaveValue = GetText(); }
     219                 :          0 :     const XubString&    GetSavedValue() const { return maSaveValue; }
     220                 :            : 
     221                 :         28 :     virtual void        SetModifyHdl( const Link& rLink ) { maModifyHdl = rLink; }
     222                 :          0 :     virtual const Link& GetModifyHdl() const { return maModifyHdl; }
     223                 :          0 :     virtual void        SetUpdateDataHdl( const Link& rLink ) { maUpdateDataHdl = rLink; }
     224                 :          0 :     virtual const Link& GetUpdateDataHdl() const { return maUpdateDataHdl; }
     225                 :            : 
     226                 :            :     void                SetSubEdit( Edit* pEdit );
     227                 :       5291 :     Edit*               GetSubEdit() const { return mpSubEdit; }
     228                 :            : 
     229                 :            :     void                SetAutocompleteHdl( const Link& rHdl );
     230                 :          0 :     const Link&         GetAutocompleteHdl() const { return maAutocompleteHdl; }
     231                 :          0 :     AutocompleteAction  GetAutocompleteAction() const { return meAutocompleteAction; }
     232                 :            : 
     233                 :            :     virtual Size        CalcMinimumSize() const;
     234                 :            :     virtual Size        GetOptimalSize(WindowSizeType eType) const;
     235                 :            :     virtual Size        CalcSize( sal_uInt16 nChars ) const;
     236                 :            :     virtual xub_StrLen  GetMaxVisChars() const;
     237                 :            : 
     238                 :            :     xub_StrLen          GetCharPos( const Point& rWindowPos ) const;
     239                 :            : 
     240                 :            :     // shows a warning box saying "text too long, truncated"
     241                 :            :     static void         ShowTruncationWarning( Window* pParent );
     242                 :            : 
     243                 :            :     static void                 SetGetSpecialCharsFunction( FncGetSpecialChars fn );
     244                 :            :     static FncGetSpecialChars   GetGetSpecialCharsFunction();
     245                 :            : 
     246                 :            :     static PopupMenu*   CreatePopupMenu();
     247                 :            :     static void         DeletePopupMenu( PopupMenu* pMenu );
     248                 :            : 
     249                 :            :     virtual rtl::OUString GetSurroundingText() const;
     250                 :            :     virtual Selection GetSurroundingTextSelection() const;
     251                 :            : 
     252                 :            :     // returns the minimum size a bordered Edit should have given the current
     253                 :            :     // global style settings (needed by sc's inputwin.cxx)
     254                 :            :     static Size GetMinimumEditSize();
     255                 :            : };
     256                 :            : 
     257                 :          0 : inline sal_uLong Edit::IsUpdateDataEnabled() const
     258                 :            : {
     259         [ #  # ]:          0 :     if ( mpUpdateDataTimer )
     260                 :          0 :         return mpUpdateDataTimer->GetTimeout();
     261                 :            :     else
     262                 :          0 :         return sal_False;
     263                 :            : }
     264                 :            : 
     265                 :            : #endif  // _SV_EDIT_HXX
     266                 :            : 
     267                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10