bump product version to 4.1.6.2
[LibreOffice.git] / dbaccess / source / ui / querydesign / LimitBox.cxx
blobb2d267e970d59c668a9264c5e83677beddb98407
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include "LimitBox.hxx"
11 #include "dbu_qry.hrc"
12 #include "moduledbu.hxx"
14 #define ALL_STRING ModuleRes(STR_QUERY_LIMIT_ALL).toString()
15 #define ALL_INT -1
17 namespace global{
19 /// Default values
20 sal_Int64 aDefLimitAry[] =
23 10,
24 20,
30 namespace dbaui
34 LimitBox::LimitBox( Window* pParent, WinBits nStyle )
35 : NumericBox( pParent, nStyle )
37 SetShowTrailingZeros( sal_False );
38 SetDecimalDigits( 0 );
39 SetMin( -1 );
40 SetMax( SAL_MAX_INT64 );
41 LoadDefaultLimits();
43 Size aSize(
44 GetSizePixel().Width(),
45 CalcWindowSizePixel(GetEntryCount() + 1) );
46 SetSizePixel(aSize);
49 LimitBox::~LimitBox()
53 OUString LimitBox::CreateFieldText( sal_Int64 nValue ) const
55 if( nValue == ALL_INT )
56 return ALL_STRING;
57 else
58 return NumericBox::CreateFieldText( nValue );
61 void LimitBox::Reformat()
64 if( GetText() == ALL_STRING )
66 SetValue( ALL_INT );
68 ///Reformat only when text is not All
69 else
71 ///Not allow user to type in -1
72 if( GetText() == "-1" )
74 Undo();
76 else
77 NumericBox::Reformat();
81 void LimitBox::ReformatAll()
83 ///First entry is All, which do not need numeric reformat
84 if ( GetEntryCount() > 0 )
86 RemoveEntry( 0 );
87 NumericBox::ReformatAll();
88 InsertValue( ALL_INT, 0);
90 else
92 NumericBox::ReformatAll();
96 Size LimitBox::GetOptimalSize() const
98 return CalcSize(10,1);
101 ///Initialize entries
102 void LimitBox::LoadDefaultLimits()
104 InsertValue( ALL_INT );
106 const unsigned nSize =
107 sizeof(global::aDefLimitAry)/sizeof(global::aDefLimitAry[0]);
108 for( unsigned nIndex = 0; nIndex< nSize; ++nIndex)
110 InsertValue( global::aDefLimitAry[nIndex] );
114 extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeLimitBox( Window *pParent )
116 LimitBox* pBox = new LimitBox( pParent, WB_DROPDOWN | WB_VSCROLL );
117 return pBox;
121 } ///dbaui namespace
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */