LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/vcl - field.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 39 66 59.1 %
Date: 2012-08-25 Functions: 38 63 60.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10