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

Generated by: LCOV version 1.10