LCOV - code coverage report
Current view: top level - include/vcl - field.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 40 66 60.6 %
Date: 2014-04-11 Functions: 39 63 61.9 %
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_FIELD_HXX
      21             : #define INCLUDED_VCL_FIELD_HXX
      22             : 
      23             : #include <vcl/dllapi.h>
      24             : #include <tools/link.hxx>
      25             : #include <tools/date.hxx>
      26             : #include <tools/time.hxx>
      27             : #include <vcl/spinfld.hxx>
      28             : #include <vcl/combobox.hxx>
      29             : #include <tools/fldunit.hxx>
      30             : 
      31             : namespace com { namespace sun { namespace star { namespace lang { struct Locale; } } } }
      32             : 
      33             : class CalendarWrapper;
      34             : class LocaleDataWrapper;
      35             : class LanguageTag;
      36             : 
      37             : 
      38             : // - FormatterBase -
      39             : 
      40             : 
      41             : class VCL_DLLPUBLIC FormatterBase
      42             : {
      43             : private:
      44             :     Edit*                   mpField;
      45             :     LocaleDataWrapper*      mpLocaleDataWrapper;
      46             :     Link                    maErrorLink;
      47             :     bool                    mbReformat;
      48             :     bool                    mbStrictFormat;
      49             :     bool                    mbEmptyFieldValue;
      50             :     bool                    mbEmptyFieldValueEnabled;
      51             :     bool                    mbDefaultLocale;
      52             : 
      53             : protected:
      54             :     SAL_DLLPRIVATE void     ImplSetText( const OUString& rText, Selection* pNewSel = NULL );
      55          58 :     SAL_DLLPRIVATE bool     ImplGetEmptyFieldValue() const  { return mbEmptyFieldValue; }
      56             : 
      57          58 :     void                    SetEmptyFieldValueData( bool bValue ) { mbEmptyFieldValue = bValue; }
      58             : 
      59             :     SAL_DLLPRIVATE LocaleDataWrapper& ImplGetLocaleDataWrapper() const;
      60           0 :     bool                    IsDefaultLocale() const { return mbDefaultLocale; }
      61             : 
      62             : public:
      63             :     explicit                FormatterBase( Edit* pField = NULL );
      64             :     virtual                 ~FormatterBase();
      65             : 
      66             :     const LocaleDataWrapper& GetLocaleDataWrapper() const;
      67             : 
      68         717 :     void                    SetField( Edit* pField )    { mpField = pField; }
      69       18052 :     Edit*                   GetField() const            { return mpField; }
      70             : 
      71          28 :     bool                    MustBeReformatted() const   { return mbReformat; }
      72        6948 :     void                    MarkToBeReformatted( bool b ) { mbReformat = b; }
      73             : 
      74             :     void                    SetStrictFormat( bool bStrict );
      75          34 :     bool                    IsStrictFormat() const { return mbStrictFormat; }
      76             : 
      77             :     virtual void            Reformat();
      78             :     virtual void            ReformatAll();
      79             : 
      80             :     virtual void            SetLocale( const ::com::sun::star::lang::Locale& rLocale );
      81             :     const ::com::sun::star::lang::Locale&   GetLocale() const;
      82             :     const LanguageTag&      GetLanguageTag() const;
      83             : 
      84             :     const AllSettings&      GetFieldSettings() const;
      85             : 
      86             :     void                    SetErrorHdl( const Link& rLink )    { maErrorLink = rLink; }
      87        3354 :     const Link&             GetErrorHdl() const                 { return maErrorLink; }
      88             : 
      89             :     void                    SetEmptyFieldValue();
      90             :     bool                    IsEmptyFieldValue() const;
      91             : 
      92          77 :     void                    EnableEmptyFieldValue( bool bEnable )   { mbEmptyFieldValueEnabled = bEnable; }
      93          56 :     bool                    IsEmptyFieldValueEnabled() const        { return mbEmptyFieldValueEnabled; }
      94             : };
      95             : 
      96             : 
      97             : 
      98             : // - PatternFormatter -
      99             : 
     100             : 
     101             : #define PATTERN_FORMAT_EMPTYLITERALS    ((sal_uInt16)0x0001)
     102             : 
     103             : class VCL_DLLPUBLIC PatternFormatter : public FormatterBase
     104             : {
     105             : private:
     106             :     OString                m_aEditMask;
     107             :     OUString               maFieldString;
     108             :     OUString               maLiteralMask;
     109             :     sal_uInt16             mnFormatFlags;
     110             :     bool                   mbSameMask;
     111             :     bool               mbInPattKeyInput;
     112             : 
     113             : protected:
     114             :                             PatternFormatter();
     115             : 
     116             :     SAL_DLLPRIVATE void ImplSetMask(const OString& rEditMask,
     117             :         const OUString& rLiteralMask);
     118           0 :     SAL_DLLPRIVATE bool     ImplIsSameMask() const { return mbSameMask; }
     119           0 :     SAL_DLLPRIVATE bool&    ImplGetInPattKeyInput() { return mbInPattKeyInput; }
     120             : 
     121             : public:
     122             :     virtual                 ~PatternFormatter();
     123             : 
     124             :     virtual void            Reformat() SAL_OVERRIDE;
     125             : 
     126             :     void SetMask(const OString& rEditMask, const OUString& rLiteralMask );
     127           0 :     const OString& GetEditMask() const { return m_aEditMask; }
     128           0 :     const OUString&        GetLiteralMask() const  { return maLiteralMask; }
     129             : 
     130             :     void                    SetFormatFlags( sal_uInt16 nFlags ) { mnFormatFlags = nFlags; }
     131           0 :     sal_uInt16              GetFormatFlags() const { return mnFormatFlags; }
     132             : 
     133             :     void                    SetString( const OUString& rStr );
     134             :     OUString                GetString() const;
     135             :     bool                IsStringModified() const { return !(GetString() == maFieldString ); }
     136             : };
     137             : 
     138             : 
     139             : // - NumericFormatter -
     140             : 
     141             : 
     142             : class VCL_DLLPUBLIC NumericFormatter : public FormatterBase
     143             : {
     144             : private:
     145             :     SAL_DLLPRIVATE void     ImplInit();
     146             : 
     147             : protected:
     148             :     sal_Int64               mnFieldValue;
     149             :     sal_Int64               mnLastValue;
     150             :     sal_Int64               mnMin;
     151             :     sal_Int64               mnMax;
     152             :     sal_Int64               mnCorrectedValue;
     153             :     sal_uInt16                  mnType;
     154             :     sal_uInt16                  mnDecimalDigits;
     155             :     bool                    mbThousandSep;
     156             :     bool                    mbShowTrailingZeros;
     157             : 
     158             :     // the members below are used in all derivatives of NumericFormatter
     159             :     // not in NumericFormatter itself.
     160             :     sal_Int64               mnSpinSize;
     161             :     sal_Int64               mnFirst;
     162             :     sal_Int64               mnLast;
     163             : 
     164             : protected:
     165             :                             NumericFormatter();
     166             : 
     167             :     void                    FieldUp();
     168             :     void                    FieldDown();
     169             :     void                    FieldFirst();
     170             :     void                    FieldLast();
     171             : 
     172             :     SAL_DLLPRIVATE void     ImplLoadRes( const ResId& rResId );
     173             :     SAL_DLLPRIVATE bool ImplNumericReformat( const OUString& rStr, sal_Int64& rValue, OUString& rOutStr );
     174             :     SAL_DLLPRIVATE void     ImplNewFieldValue( sal_Int64 nNewValue );
     175             :     SAL_DLLPRIVATE void     ImplSetUserValue( sal_Int64 nNewValue, Selection* pNewSelection = NULL );
     176             : 
     177             : public:
     178             :     virtual                 ~NumericFormatter();
     179             : 
     180             :     virtual void            Reformat() SAL_OVERRIDE;
     181             : 
     182             :     void                    SetMin( sal_Int64 nNewMin );
     183        4323 :     sal_Int64               GetMin() const { return mnMin; }
     184             :     void                    SetMax( sal_Int64 nNewMax );
     185        3760 :     sal_Int64               GetMax() const { return mnMax; }
     186             : 
     187          38 :     void                    SetFirst( sal_Int64 nNewFirst )   { mnFirst = nNewFirst; }
     188           0 :     sal_Int64               GetFirst() const                  { return mnFirst; }
     189           0 :     void                    SetLast( sal_Int64 nNewLast )     { mnLast = nNewLast; }
     190           0 :     sal_Int64               GetLast() const                   { return mnLast; }
     191         101 :     void                    SetSpinSize( sal_Int64 nNewSize ) { mnSpinSize = nNewSize; }
     192           0 :     sal_Int64               GetSpinSize() const               { return mnSpinSize; }
     193             : 
     194             :     void                    SetDecimalDigits( sal_uInt16 nDigits );
     195             :     sal_uInt16                  GetDecimalDigits() const;
     196             : 
     197             :     void                    SetUseThousandSep( bool b );
     198       24324 :     bool                    IsUseThousandSep() const { return mbThousandSep; }
     199             : 
     200             :     void                    SetShowTrailingZeros( bool bShowTrailingZeros );
     201       24324 :     bool                    IsShowTrailingZeros() const { return mbShowTrailingZeros; }
     202             : 
     203             : 
     204             :     void                    SetUserValue( sal_Int64 nNewValue );
     205             :     virtual void            SetValue( sal_Int64 nNewValue );
     206             :     virtual sal_Int64       GetValue() const;
     207             :     virtual OUString        CreateFieldText( sal_Int64 nValue ) const;
     208             :     bool                    IsValueModified() const;
     209             :     sal_Int64               GetCorrectedValue() const { return mnCorrectedValue; }
     210             : 
     211             :     sal_Int64               Normalize( sal_Int64 nValue ) const;
     212             :     sal_Int64               Denormalize( sal_Int64 nValue ) const;
     213             : };
     214             : 
     215             : 
     216             : // - MetricFormatter -
     217             : 
     218             : 
     219             : class VCL_DLLPUBLIC MetricFormatter : public NumericFormatter
     220             : {
     221             : private:
     222             :     SAL_DLLPRIVATE  void    ImplInit();
     223             : 
     224             : protected:
     225             :     OUString                maCustomUnitText;
     226             :     OUString                maCurUnitText;
     227             :     sal_Int64               mnBaseValue;
     228             :     FieldUnit               meUnit;
     229             :     Link                    maCustomConvertLink;
     230             : 
     231             : protected:
     232             :                             MetricFormatter();
     233             : 
     234             :     SAL_DLLPRIVATE void     ImplLoadRes( const ResId& rResId );
     235             :     SAL_DLLPRIVATE bool     ImplMetricReformat( const OUString& rStr, double& rValue, OUString& rOutStr );
     236             : 
     237             : public:
     238             :     virtual                 ~MetricFormatter();
     239             : 
     240             :     virtual void            CustomConvert() = 0;
     241             :     virtual void            Reformat() SAL_OVERRIDE;
     242             : 
     243             :     virtual void            SetUnit( FieldUnit meUnit );
     244        2461 :     FieldUnit               GetUnit() const { return meUnit; }
     245             :     void                    SetCustomUnitText( const OUString& rStr );
     246           0 :     const OUString&         GetCustomUnitText() const { return maCustomUnitText; }
     247           0 :     const OUString&         GetCurUnitText() const { return maCurUnitText; }
     248             : 
     249             :     using NumericFormatter::SetMax;
     250             :     void                    SetMax( sal_Int64 nNewMax, FieldUnit eInUnit );
     251             :     using NumericFormatter::GetMax;
     252             :     sal_Int64               GetMax( FieldUnit eOutUnit ) const;
     253             :     using NumericFormatter::SetMin;
     254             :     void                    SetMin( sal_Int64 nNewMin, FieldUnit eInUnit );
     255             :     using NumericFormatter::GetMin;
     256             :     sal_Int64               GetMin( FieldUnit eOutUnit ) const;
     257             :     void                    SetBaseValue( sal_Int64 nNewBase, FieldUnit eInUnit = FUNIT_NONE );
     258             :     sal_Int64               GetBaseValue( FieldUnit eOutUnit = FUNIT_NONE ) const;
     259             : 
     260             :     virtual void            SetValue( sal_Int64 nNewValue, FieldUnit eInUnit );
     261             :     virtual void            SetValue( sal_Int64 nValue ) SAL_OVERRIDE;
     262             :     using NumericFormatter::SetUserValue;
     263             :     void                    SetUserValue( sal_Int64 nNewValue, FieldUnit eInUnit );
     264             :     virtual sal_Int64       GetValue( FieldUnit eOutUnit ) const;
     265             :     virtual sal_Int64       GetValue() const SAL_OVERRIDE;
     266             :     virtual OUString        CreateFieldText( sal_Int64 nValue ) const SAL_OVERRIDE;
     267             :     using NumericFormatter::GetCorrectedValue;
     268             :     sal_Int64               GetCorrectedValue( FieldUnit eOutUnit ) const;
     269             : 
     270           0 :     void                    SetCustomConvertHdl( const Link& rLink ) { maCustomConvertLink = rLink; }
     271             :     const Link&             GetCustomConvertHdl() const { return maCustomConvertLink; }
     272             : };
     273             : 
     274             : 
     275             : 
     276             : // - CurrencyFormatter -
     277             : 
     278             : 
     279             : class VCL_DLLPUBLIC CurrencyFormatter : public NumericFormatter
     280             : {
     281             : private:
     282             :     SAL_DLLPRIVATE void     ImplInit();
     283             : 
     284             : protected:
     285             :                             CurrencyFormatter();
     286             :     SAL_DLLPRIVATE bool     ImplCurrencyReformat( const OUString& rStr, OUString& rOutStr );
     287             : 
     288             : public:
     289             :     virtual                 ~CurrencyFormatter();
     290             : 
     291             :     virtual void            Reformat() SAL_OVERRIDE;
     292             : 
     293             :     OUString                GetCurrencySymbol() const;
     294             : 
     295             :     virtual void            SetValue( sal_Int64 nNewValue ) SAL_OVERRIDE;
     296             :     virtual sal_Int64       GetValue() const SAL_OVERRIDE;
     297             :     virtual OUString        CreateFieldText( sal_Int64 nValue ) const SAL_OVERRIDE;
     298             : };
     299             : 
     300             : 
     301             : 
     302             : // - DateFormatter -
     303             : 
     304             : 
     305             : class VCL_DLLPUBLIC DateFormatter : public FormatterBase
     306             : {
     307             : private:
     308             :     CalendarWrapper*        mpCalendarWrapper;
     309             :     Date                    maFieldDate;
     310             :     Date                    maLastDate;
     311             :     Date                    maMin;
     312             :     Date                    maMax;
     313             :     Date                    maCorrectedDate;
     314             :     bool                    mbLongFormat;
     315             :     bool                    mbShowDateCentury;
     316             :     sal_uInt16                  mnDateFormat;
     317             :     sal_uLong                   mnExtDateFormat;
     318             :     bool                    mbEnforceValidValue;
     319             : 
     320             :     SAL_DLLPRIVATE void     ImplInit();
     321             : 
     322             : protected:
     323             :                             DateFormatter();
     324             : 
     325             :     SAL_DLLPRIVATE void     ImplLoadRes( const ResId& rResId );
     326          28 :     SAL_DLLPRIVATE const Date& ImplGetFieldDate() const    { return maFieldDate; }
     327             :     SAL_DLLPRIVATE bool     ImplDateReformat( const OUString& rStr, OUString& rOutStr,
     328             :                                               const AllSettings& rSettings );
     329             :     SAL_DLLPRIVATE void     ImplSetUserDate( const Date& rNewDate,
     330             :                                              Selection* pNewSelection = NULL );
     331             :     SAL_DLLPRIVATE OUString ImplGetDateAsText( const Date& rDate,
     332             :                                                const AllSettings& rSettings ) const;
     333             :     SAL_DLLPRIVATE void     ImplNewFieldValue( const Date& rDate );
     334             :     CalendarWrapper&        GetCalendarWrapper() const;
     335             : 
     336             :     SAL_DLLPRIVATE bool     ImplAllowMalformedInput() const;
     337             : 
     338             : public:
     339             :     virtual                 ~DateFormatter();
     340             : 
     341             :     virtual void            Reformat() SAL_OVERRIDE;
     342             :     virtual void            ReformatAll() SAL_OVERRIDE;
     343             : 
     344             :     virtual void            SetLocale( const ::com::sun::star::lang::Locale& rLocale ) SAL_OVERRIDE;
     345             : 
     346             : 
     347             :     void                    SetExtDateFormat( ExtDateFieldFormat eFormat );
     348             :     ExtDateFieldFormat      GetExtDateFormat( bool bResolveSystemFormat = false ) const;
     349             : 
     350             :     void                    SetMin( const Date& rNewMin );
     351          89 :     const Date&             GetMin() const { return maMin; }
     352             : 
     353             :     void                    SetMax( const Date& rNewMax );
     354         141 :     const Date&             GetMax() const { return maMax; }
     355             : 
     356             : 
     357             : 
     358             :     // MT: Remove these methods too, ExtDateFormat should be enough!
     359             :     //     What should happen if using DDMMYYYY, but ShowCentury=false?
     360             : 
     361             :     void                    SetLongFormat( bool bLong );
     362           0 :     bool                    IsLongFormat() const { return mbLongFormat; }
     363             :     void                    SetShowDateCentury( bool bShowCentury );
     364           0 :     bool                    IsShowDateCentury() const { return mbShowDateCentury; }
     365             : 
     366             : 
     367             :     void                    SetDate( const Date& rNewDate );
     368             :     void                    SetUserDate( const Date& rNewDate );
     369             :     Date                    GetDate() const;
     370             :     void                    SetEmptyDate();
     371             :     bool                    IsEmptyDate() const;
     372             :     Date                    GetCorrectedDate() const { return maCorrectedDate; }
     373             : 
     374          28 :     void                    ResetLastDate() { maLastDate = Date( 0, 0, 0 ); }
     375             : 
     376             :     static void             ExpandCentury( Date& rDate );
     377             :     static void             ExpandCentury( Date& rDate, sal_uInt16 nTwoDigitYearStart );
     378             : 
     379           6 :     static Date             GetInvalidDate() { return Date( 0, 0, 0 ); }
     380             : 
     381             :     /** enables or disables the enforcement of valid values
     382             : 
     383             :         If this is set to true (which is the default), then GetDate will always return a valid
     384             :         date, no matter whether the current text can really be interpreted as date. (Note: this
     385             :         is the compatible bahavior).
     386             : 
     387             :         If this is set to false, the GetDate will return GetInvalidDate, in case the current text
     388             :         cannot be interpreted as date.
     389             : 
     390             :         In addition, if this is set to false, the text in the field will \em not be corrected
     391             :         when the control loses the focus - instead, the invalid input will be preserved.
     392             :     */
     393          37 :     void                    EnforceValidValue( bool _bEnforce ) { mbEnforceValidValue = _bEnforce; }
     394          54 :     inline bool             IsEnforceValidValue( ) const { return mbEnforceValidValue; }
     395             : };
     396             : 
     397             : 
     398             : 
     399             : // - TimeFormatter -
     400             : 
     401             : 
     402             : class VCL_DLLPUBLIC TimeFormatter : public FormatterBase
     403             : {
     404             : private:
     405             :     Time                    maLastTime;
     406             :     Time                    maMin;
     407             :     Time                    maMax;
     408             :     Time                    maCorrectedTime;
     409             :     TimeFieldFormat         meFormat;
     410             :     sal_uInt16                  mnTimeFormat;
     411             :     bool                    mbDuration;
     412             :     bool                    mbEnforceValidValue;
     413             : 
     414             :     SAL_DLLPRIVATE void     ImplInit();
     415             : 
     416             : protected:
     417             :     Time                    maFieldTime;
     418             : 
     419             :                             TimeFormatter();
     420             : 
     421             :     SAL_DLLPRIVATE void     ImplLoadRes( const ResId& rResId );
     422             :     SAL_DLLPRIVATE bool     ImplTimeReformat( const OUString& rStr, OUString& rOutStr );
     423             :     SAL_DLLPRIVATE void     ImplNewFieldValue( const Time& rTime );
     424             :     SAL_DLLPRIVATE void     ImplSetUserTime( const Time& rNewTime, Selection* pNewSelection = NULL );
     425             :     SAL_DLLPRIVATE bool     ImplAllowMalformedInput() const;
     426             : 
     427             : public:
     428             : 
     429             :                             enum TimeFormat {
     430             :                                 HOUR_12,
     431             :                                 HOUR_24
     432             :                             };
     433             : 
     434             :     virtual                 ~TimeFormatter();
     435             : 
     436             :     virtual void            Reformat() SAL_OVERRIDE;
     437             :     virtual void            ReformatAll() SAL_OVERRIDE;
     438             : 
     439             :     void                    SetMin( const Time& rNewMin );
     440         278 :     const Time&             GetMin() const { return maMin; }
     441             :     void                    SetMax( const Time& rNewMax );
     442         264 :     const Time&             GetMax() const { return maMax; }
     443             : 
     444             :     void                    SetTimeFormat( TimeFormat eNewFormat );
     445             :     TimeFormat              GetTimeFormat() const;
     446             : 
     447             :     void                    SetFormat( TimeFieldFormat eNewFormat );
     448         357 :     TimeFieldFormat         GetFormat() const { return meFormat; }
     449             : 
     450             :     void                    SetDuration( bool mbDuration );
     451         357 :     bool                    IsDuration() const { return mbDuration; }
     452             : 
     453             :     void                    SetTime( const Time& rNewTime );
     454             :     void                    SetUserTime( const Time& rNewTime );
     455             :     Time                    GetTime() const;
     456           2 :     void                    SetEmptyTime() { FormatterBase::SetEmptyFieldValue(); }
     457          22 :     bool                    IsEmptyTime() const { return FormatterBase::IsEmptyFieldValue(); }
     458             :     Time                    GetCorrectedTime() const { return maCorrectedTime; }
     459             : 
     460           0 :     static Time             GetInvalidTime() { return Time( 99, 99, 99 ); }
     461             : 
     462             :     /** enables or disables the enforcement of valid values
     463             : 
     464             :         If this is set to true (which is the default), then GetTime will always return a valid
     465             :         time, no matter whether the current text can really be interpreted as time. (Note: this
     466             :         is the compatible bahavior).
     467             : 
     468             :         If this is set to false, the GetTime will return GetInvalidTime, in case the current text
     469             :         cannot be interpreted as time.
     470             : 
     471             :         In addition, if this is set to false, the text in the field will <em>not</em> be corrected
     472             :         when the control loses the focus - instead, the invalid input will be preserved.
     473             :     */
     474          26 :     void                    EnforceValidValue( bool _bEnforce ) { mbEnforceValidValue = _bEnforce; }
     475          49 :     inline bool             IsEnforceValidValue( ) const { return mbEnforceValidValue; }
     476             : };
     477             : 
     478             : 
     479             : 
     480             : // - PatternField -
     481             : 
     482             : 
     483             : class VCL_DLLPUBLIC PatternField : public SpinField, public PatternFormatter
     484             : {
     485             : public:
     486             :     explicit                PatternField( Window* pParent, WinBits nWinStyle );
     487             :     virtual                 ~PatternField();
     488             : 
     489             :     virtual bool            PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     490             :     virtual bool            Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     491             :     virtual void            Modify() SAL_OVERRIDE;
     492             : };
     493             : 
     494             : 
     495             : 
     496             : // - NumericField -
     497             : 
     498             : 
     499             : class VCL_DLLPUBLIC NumericField : public SpinField, public NumericFormatter
     500             : {
     501             : protected:
     502             :     SAL_DLLPRIVATE void     ImplLoadRes( const ResId& rResId );
     503             : 
     504             : public:
     505             :     explicit                NumericField( Window* pParent, WinBits nWinStyle );
     506             :     explicit                NumericField( Window* pParent, const ResId& );
     507             :     virtual                 ~NumericField();
     508             : 
     509             :     virtual bool            PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     510             :     virtual bool            Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     511             :     virtual void            DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     512             : 
     513             :     virtual Size            CalcMinimumSize() const SAL_OVERRIDE;
     514             : 
     515             :     virtual void            Modify() SAL_OVERRIDE;
     516             : 
     517             :     virtual void            Up() SAL_OVERRIDE;
     518             :     virtual void            Down() SAL_OVERRIDE;
     519             :     virtual void            First() SAL_OVERRIDE;
     520             :     virtual void            Last() SAL_OVERRIDE;
     521             :     virtual bool            set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
     522             : };
     523             : 
     524             : 
     525             : 
     526             : // - MetricField  -
     527             : 
     528             : 
     529             : class VCL_DLLPUBLIC MetricField : public SpinField, public MetricFormatter
     530             : {
     531             : protected:
     532             :     SAL_DLLPRIVATE void     ImplLoadRes( const ResId& rResId );
     533             : 
     534             : public:
     535             :     explicit                MetricField( Window* pParent, WinBits nWinStyle );
     536             :     explicit                MetricField( Window* pParent, const ResId& );
     537             :     virtual                 ~MetricField();
     538             : 
     539             :     virtual bool            PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     540             :     virtual bool            Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     541             :     virtual void            DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     542             : 
     543             :     virtual Size            CalcMinimumSize() const SAL_OVERRIDE;
     544             : 
     545             :     virtual void            Modify() SAL_OVERRIDE;
     546             : 
     547             :     virtual void            Up() SAL_OVERRIDE;
     548             :     virtual void            Down() SAL_OVERRIDE;
     549             :     virtual void            First() SAL_OVERRIDE;
     550             :     virtual void            Last() SAL_OVERRIDE;
     551             :     virtual void            CustomConvert() SAL_OVERRIDE;
     552             : 
     553             :     virtual void            SetUnit( FieldUnit meUnit ) SAL_OVERRIDE;
     554             : 
     555             :     void                    SetFirst( sal_Int64 nNewFirst, FieldUnit eInUnit );
     556          63 :     inline void             SetFirst(sal_Int64 first) { SetFirst(first, FUNIT_NONE); }
     557             :     sal_Int64               GetFirst( FieldUnit eOutUnit ) const;
     558           0 :     inline sal_Int64        GetFirst() const { return GetFirst(FUNIT_NONE); }
     559             :     void                    SetLast( sal_Int64 nNewLast, FieldUnit eInUnit );
     560          63 :     inline void             SetLast(sal_Int64 last) { SetLast(last, FUNIT_NONE); }
     561             :     sal_Int64               GetLast( FieldUnit eOutUnit ) const;
     562           0 :     inline sal_Int64        GetLast() const { return GetLast(FUNIT_NONE); }
     563             : 
     564             :     static void             SetDefaultUnit( FieldUnit eDefaultUnit );
     565             :     static FieldUnit        GetDefaultUnit();
     566             :     static sal_Int64        ConvertValue( sal_Int64 nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits,
     567             :                                           FieldUnit eInUnit, FieldUnit eOutUnit );
     568             :     static sal_Int64        ConvertValue( sal_Int64 nValue, sal_uInt16 nDecDigits,
     569             :                                           MapUnit eInUnit, FieldUnit eOutUnit );
     570             : 
     571             :     // for backwards compatibility
     572             :     // caution: conversion to double loses precision
     573             :     static double           ConvertDoubleValue( double nValue, sal_Int64 mnBaseValue, sal_uInt16 nDecDigits,
     574             :                                                 FieldUnit eInUnit, FieldUnit eOutUnit );
     575             :     static double           ConvertDoubleValue( double nValue, sal_uInt16 nDecDigits,
     576             :                                                 FieldUnit eInUnit, MapUnit eOutUnit );
     577             :     static double           ConvertDoubleValue( double nValue, sal_uInt16 nDecDigits,
     578             :                                                 MapUnit eInUnit, FieldUnit eOutUnit );
     579             : 
     580             :     // for backwards compatibility
     581             :     // caution: conversion to double loses precision
     582        4972 :     static double           ConvertDoubleValue( sal_Int64 nValue, sal_Int64 nBaseValue, sal_uInt16 nDecDigits,
     583             :                                                 FieldUnit eInUnit, FieldUnit eOutUnit )
     584        4972 :     { return ConvertDoubleValue( static_cast<double>(nValue), nBaseValue, nDecDigits, eInUnit, eOutUnit ); }
     585           0 :     static double           ConvertDoubleValue( sal_Int64 nValue, sal_uInt16 nDecDigits,
     586             :                                                 FieldUnit eInUnit, MapUnit eOutUnit )
     587           0 :     { return ConvertDoubleValue( static_cast<double>(nValue), nDecDigits, eInUnit, eOutUnit ); }
     588           0 :     static double           ConvertDoubleValue( sal_Int64 nValue, sal_uInt16 nDecDigits,
     589             :                                                 MapUnit eInUnit, FieldUnit eOutUnit )
     590           0 :     { return ConvertDoubleValue( static_cast<double>(nValue), nDecDigits, eInUnit, eOutUnit ); }
     591             : 
     592             :     virtual bool            set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
     593             : };
     594             : 
     595             : 
     596             : 
     597             : // - CurrencyField -
     598             : 
     599             : 
     600             : class VCL_DLLPUBLIC CurrencyField : public SpinField, public CurrencyFormatter
     601             : {
     602             : public:
     603             :     CurrencyField( Window* pParent, WinBits nWinStyle );
     604             :     virtual ~CurrencyField();
     605             : 
     606             :     virtual bool            PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     607             :     virtual bool            Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     608             :     virtual void            DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     609             : 
     610             :     virtual void            Modify() SAL_OVERRIDE;
     611             : 
     612             :     virtual void            Up() SAL_OVERRIDE;
     613             :     virtual void            Down() SAL_OVERRIDE;
     614             :     virtual void            First() SAL_OVERRIDE;
     615             :     virtual void            Last() SAL_OVERRIDE;
     616             : };
     617             : 
     618             : 
     619             : 
     620             : // - DateField -
     621             : 
     622             : 
     623             : class VCL_DLLPUBLIC DateField : public SpinField, public DateFormatter
     624             : {
     625             : private:
     626             :     Date                    maFirst;
     627             :     Date                    maLast;
     628             : 
     629             : protected:
     630             :     SAL_DLLPRIVATE void     ImplDateSpinArea( bool bUp );
     631             :     SAL_DLLPRIVATE void     ImplLoadRes( const ResId& rResId );
     632             : 
     633             : public:
     634             :     explicit                DateField( Window* pParent, WinBits nWinStyle );
     635             :     explicit                DateField( Window* pParent, const ResId& );
     636             :     virtual                 ~DateField();
     637             : 
     638             :     virtual bool            PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     639             :     virtual bool            Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     640             :     virtual void            DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     641             : 
     642             :     virtual void            Modify() SAL_OVERRIDE;
     643             : 
     644             :     virtual void            Up() SAL_OVERRIDE;
     645             :     virtual void            Down() SAL_OVERRIDE;
     646             :     virtual void            First() SAL_OVERRIDE;
     647             :     virtual void            Last() SAL_OVERRIDE;
     648             : 
     649          32 :     void                    SetFirst( const Date& rNewFirst )   { maFirst = rNewFirst; }
     650           0 :     Date                    GetFirst() const                    { return maFirst; }
     651          32 :     void                    SetLast( const Date& rNewLast )     { maLast = rNewLast; }
     652           0 :     Date                    GetLast() const                     { return maLast; }
     653             : };
     654             : 
     655             : 
     656             : // - TimeField -
     657             : 
     658             : 
     659             : class VCL_DLLPUBLIC TimeField : public SpinField, public TimeFormatter
     660             : {
     661             : private:
     662             :     Time                    maFirst;
     663             :     Time                    maLast;
     664             : 
     665             : protected:
     666             :     SAL_DLLPRIVATE void     ImplTimeSpinArea( bool bUp );
     667             :     SAL_DLLPRIVATE void     ImplLoadRes( const ResId& rResId );
     668             : 
     669             : public:
     670             :     explicit                TimeField( Window* pParent, WinBits nWinStyle );
     671             :     explicit                TimeField( Window* pParent, const ResId& );
     672             :     virtual                 ~TimeField();
     673             : 
     674             :     virtual bool            PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     675             :     virtual bool            Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     676             :     virtual void            DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     677             : 
     678             :     virtual void            Modify() SAL_OVERRIDE;
     679             : 
     680             :     virtual void            Up() SAL_OVERRIDE;
     681             :     virtual void            Down() SAL_OVERRIDE;
     682             :     virtual void            First() SAL_OVERRIDE;
     683             :     virtual void            Last() SAL_OVERRIDE;
     684             : 
     685          23 :     void                    SetFirst( const Time& rNewFirst )   { maFirst = rNewFirst; }
     686           0 :     Time                    GetFirst() const                    { return maFirst; }
     687          19 :     void                    SetLast( const Time& rNewLast )     { maLast = rNewLast; }
     688           0 :     Time                    GetLast() const                     { return maLast; }
     689             : 
     690             :     void                    SetExtFormat( ExtTimeFieldFormat eFormat );
     691             : };
     692             : 
     693             : 
     694             : 
     695             : // - PatternBox -
     696             : 
     697             : 
     698             : class VCL_DLLPUBLIC PatternBox : public ComboBox, public PatternFormatter
     699             : {
     700             : public:
     701             :                             PatternBox( Window* pParent, WinBits nWinStyle );
     702             :                             virtual ~PatternBox();
     703             : 
     704             :     virtual bool            PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     705             :     virtual bool            Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     706             : 
     707             :     virtual void            Modify() SAL_OVERRIDE;
     708             : 
     709             :     virtual void            ReformatAll() SAL_OVERRIDE;
     710             : };
     711             : 
     712             : 
     713             : 
     714             : // - NumericBox -
     715             : 
     716             : 
     717             : class VCL_DLLPUBLIC NumericBox : public ComboBox, public NumericFormatter
     718             : {
     719             : public:
     720             :     explicit                NumericBox( Window* pParent, WinBits nWinStyle );
     721             :     explicit                NumericBox( Window* pParent, const ResId& );
     722             :     virtual                 ~NumericBox();
     723             : 
     724             :     virtual Size            CalcMinimumSize() const SAL_OVERRIDE;
     725             : 
     726             :     virtual bool            PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     727             :     virtual bool            Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     728             :     virtual void            DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     729             : 
     730             :     virtual void            Modify() SAL_OVERRIDE;
     731             : 
     732             :     virtual void            ReformatAll() SAL_OVERRIDE;
     733             : 
     734             :     void                    InsertValue( sal_Int64 nValue, sal_Int32  nPos = COMBOBOX_APPEND );
     735             : };
     736             : 
     737             : 
     738             : 
     739             : // - MetricBox -
     740             : 
     741             : 
     742             : class VCL_DLLPUBLIC MetricBox : public ComboBox, public MetricFormatter
     743             : {
     744             : public:
     745             :     explicit                MetricBox( Window* pParent, WinBits nWinStyle );
     746             :     virtual                 ~MetricBox();
     747             : 
     748             :     virtual bool            PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     749             :     virtual bool            Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     750             :     virtual void            DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     751             : 
     752             :     virtual Size            CalcMinimumSize() const SAL_OVERRIDE;
     753             : 
     754             :     virtual void            Modify() SAL_OVERRIDE;
     755             : 
     756             :     virtual void            CustomConvert() SAL_OVERRIDE;
     757             :     virtual void            ReformatAll() SAL_OVERRIDE;
     758             : 
     759             :     void                    InsertValue( sal_Int64 nValue, FieldUnit eInUnit = FUNIT_NONE,
     760             :                                          sal_Int32  nPos = COMBOBOX_APPEND );
     761             :     sal_Int64               GetValue( sal_Int32  nPos, FieldUnit eOutUnit = FUNIT_NONE ) const;
     762             :     sal_Int32               GetValuePos( sal_Int64 nValue,
     763             :                                          FieldUnit eInUnit = FUNIT_NONE ) const;
     764             : 
     765             :     // Needed, because GetValue() with nPos hide these functions
     766             :     virtual sal_Int64       GetValue( FieldUnit eOutUnit ) const SAL_OVERRIDE;
     767             :     virtual sal_Int64       GetValue() const SAL_OVERRIDE;
     768             : };
     769             : 
     770             : 
     771             : 
     772             : // - CurrencyBox -
     773             : 
     774             : 
     775             : class VCL_DLLPUBLIC CurrencyBox : public ComboBox, public CurrencyFormatter
     776             : {
     777             : public:
     778             :     explicit                CurrencyBox( Window* pParent, WinBits nWinStyle );
     779             :     virtual                 ~CurrencyBox();
     780             : 
     781             :     virtual bool            PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     782             :     virtual bool            Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     783             :     virtual void            DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     784             : 
     785             :     virtual void            Modify() SAL_OVERRIDE;
     786             : 
     787             :     virtual void            ReformatAll() SAL_OVERRIDE;
     788             : 
     789             :     virtual sal_Int64       GetValue() const SAL_OVERRIDE;
     790             : };
     791             : 
     792             : 
     793             : // - DateBox -
     794             : 
     795             : 
     796             : class VCL_DLLPUBLIC DateBox : public ComboBox, public DateFormatter
     797             : {
     798             : public:
     799             :     explicit                DateBox( Window* pParent, WinBits nWinStyle );
     800             :     virtual                 ~DateBox();
     801             : 
     802             :     virtual bool            PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     803             :     virtual bool            Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     804             :     virtual void            DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     805             : 
     806             :     virtual void            Modify() SAL_OVERRIDE;
     807             : 
     808             :     virtual void            ReformatAll() SAL_OVERRIDE;
     809             : };
     810             : 
     811             : 
     812             : 
     813             : // - TimeBox -
     814             : 
     815             : 
     816             : class VCL_DLLPUBLIC TimeBox : public ComboBox, public TimeFormatter
     817             : {
     818             : public:
     819             :     explicit                TimeBox( Window* pParent, WinBits nWinStyle );
     820             :     virtual                 ~TimeBox();
     821             : 
     822             :     virtual bool            PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     823             :     virtual bool            Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
     824             :     virtual void            DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
     825             : 
     826             :     virtual void            Modify() SAL_OVERRIDE;
     827             : 
     828             :     virtual void            ReformatAll() SAL_OVERRIDE;
     829             : };
     830             : 
     831             : #endif // INCLUDED_VCL_FIELD_HXX
     832             : 
     833             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10