Branch data 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 : : #include "SelectionBrowseBox.hxx"
21 : : #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
22 : : #include <com/sun/star/sdbc/DataType.hpp>
23 : : #include "QueryDesignView.hxx"
24 : : #include "querycontroller.hxx"
25 : : #include "QueryTableView.hxx"
26 : : #include "browserids.hxx"
27 : : #include <comphelper/extract.hxx>
28 : : #include <comphelper/stl_types.hxx>
29 : : #include <comphelper/string.hxx>
30 : : #include <comphelper/types.hxx>
31 : : #include "TableFieldInfo.hxx"
32 : : #include "dbu_qry.hrc"
33 : : #include "dbaccess_helpid.hrc"
34 : : #include <com/sun/star/container/XNameAccess.hpp>
35 : : #include "dbustrings.hrc"
36 : : #include "QTableWindow.hxx"
37 : : #include <vcl/msgbox.hxx>
38 : : #include "QueryDesignFieldUndoAct.hxx"
39 : : #include "sqlmessage.hxx"
40 : : #include "UITools.hxx"
41 : : #include <osl/diagnose.h>
42 : :
43 : : using namespace ::svt;
44 : : using namespace ::dbaui;
45 : : using namespace ::connectivity;
46 : : using namespace ::com::sun::star::uno;
47 : : using namespace ::com::sun::star::sdbc;
48 : : using namespace ::com::sun::star::beans;
49 : : using namespace ::com::sun::star::container;
50 : : using namespace ::com::sun::star::util;
51 : : using namespace ::com::sun::star::accessibility;
52 : :
53 : : #define g_strOne rtl::OUString("1")
54 : : #define g_strZero rtl::OUString("0")
55 : :
56 : : #define DEFAULT_QUERY_COLS 20
57 : : #define DEFAULT_SIZE GetTextWidth(g_strZero) * 30
58 : : #define CHECKBOX_SIZE 10
59 : : #define HANDLE_ID 0
60 : : #define HANDLE_COLUMN_WITDH 70
61 : : #define SORT_COLUMN_NONE 0xFFFFFFFF
62 : :
63 : : // -----------------------------------------------------------------------------
64 : : namespace
65 : : {
66 : 0 : sal_Bool isFieldNameAsterix(const ::rtl::OUString& _sFieldName )
67 : : {
68 [ # # ][ # # ]: 0 : sal_Bool bAsterix = !(!_sFieldName.isEmpty() && _sFieldName.toChar() != '*');
69 [ # # ]: 0 : if ( !bAsterix )
70 : : {
71 [ # # ]: 0 : String sName = _sFieldName;
72 [ # # ][ # # ]: 0 : xub_StrLen nTokenCount = comphelper::string::getTokenCount(sName, '.');
73 [ # # ][ # # ]: 0 : if ( (nTokenCount == 2 && sName.GetToken(1,'.').GetChar(0) == '*' )
[ # # # # ]
[ # # ][ # # ]
[ # # # # ]
[ # # ]
74 [ # # ][ # # ]: 0 : || (nTokenCount == 3 && sName.GetToken(2,'.').GetChar(0) == '*' ) )
[ # # ][ # # ]
75 : : {
76 : 0 : bAsterix = sal_True;
77 [ # # ]: 0 : }
78 : : }
79 : 0 : return bAsterix;
80 : : }
81 : : // -----------------------------------------------------------------------------
82 : 0 : sal_Bool lcl_SupportsCoreSQLGrammar(const Reference< XConnection>& _xConnection)
83 : : {
84 : 0 : sal_Bool bSupportsCoreGrammar = sal_False;
85 [ # # ]: 0 : if ( _xConnection.is() )
86 : : {
87 : : try
88 : : {
89 [ # # ][ # # ]: 0 : Reference< XDatabaseMetaData > xMetaData = _xConnection->getMetaData();
90 [ # # ][ # # ]: 0 : bSupportsCoreGrammar = xMetaData.is() && xMetaData->supportsCoreSQLGrammar();
[ # # ][ # # ]
[ # # ]
91 : : }
92 : 0 : catch(Exception&)
93 : : {
94 : : }
95 : : }
96 : 0 : return bSupportsCoreGrammar;
97 : : }
98 : : }
99 : :
100 : : DBG_NAME(OSelectionBrowseBox)
101 : : //------------------------------------------------------------------------------
102 : 0 : OSelectionBrowseBox::OSelectionBrowseBox( Window* pParent )
103 : : :EditBrowseBox( pParent,EBBF_NOROWPICTURE, WB_3DLOOK, BROWSER_COLUMNSELECTION | BROWSER_KEEPSELECTION | BROWSER_HIDESELECT |
104 : : BROWSER_HIDECURSOR | BROWSER_HLINESFULL | BROWSER_VLINESFULL )
105 : : ,m_aFunctionStrings(ModuleRes(STR_QUERY_FUNCTIONS))
106 : : ,m_nVisibleCount(0)
107 : : ,m_nLastSortColumn(SORT_COLUMN_NONE)
108 : : ,m_bOrderByUnRelated(sal_True)
109 : : ,m_bGroupByUnRelated(sal_True)
110 : : ,m_bStopTimer(sal_False)
111 : : ,m_bWasEditing(sal_False)
112 : : ,m_bDisableErrorBox(sal_False)
113 [ # # ][ # # ]: 0 : ,m_bInUndoMode(sal_False)
[ # # ][ # # ]
114 : : {
115 : : DBG_CTOR(OSelectionBrowseBox,NULL);
116 [ # # ]: 0 : SetHelpId(HID_CTL_QRYDGNCRIT);
117 : :
118 : : m_nMode = BROWSER_COLUMNSELECTION | BROWSER_HIDESELECT
119 : : | BROWSER_KEEPSELECTION | BROWSER_HIDECURSOR
120 : : | BROWSER_HLINESFULL | BROWSER_VLINESFULL
121 : 0 : | BROWSER_HEADERBAR_NEW ;
122 : :
123 [ # # ][ # # ]: 0 : m_pTextCell = new Edit(&GetDataWindow(), 0);
124 [ # # ][ # # ]: 0 : m_pVisibleCell = new CheckBoxControl(&GetDataWindow());
125 [ # # ][ # # ]: 0 : m_pTableCell = new ListBoxControl(&GetDataWindow()); m_pTableCell->SetDropDownLineCount( 20 );
[ # # ]
126 [ # # ][ # # ]: 0 : m_pFieldCell = new ComboBoxControl(&GetDataWindow()); m_pFieldCell->SetDropDownLineCount( 20 );
[ # # ]
127 [ # # ][ # # ]: 0 : m_pOrderCell = new ListBoxControl(&GetDataWindow());
128 [ # # ][ # # ]: 0 : m_pFunctionCell = new ListBoxControl(&GetDataWindow()); m_pFunctionCell->SetDropDownLineCount( 20 );
[ # # ]
129 : :
130 [ # # ]: 0 : m_pVisibleCell->SetHelpId(HID_QRYDGN_ROW_VISIBLE);
131 [ # # ]: 0 : m_pTableCell->SetHelpId(HID_QRYDGN_ROW_TABLE);
132 [ # # ]: 0 : m_pFieldCell->SetHelpId(HID_QRYDGN_ROW_FIELD);
133 [ # # ]: 0 : m_pOrderCell->SetHelpId(HID_QRYDGN_ROW_ORDER);
134 [ # # ]: 0 : m_pFunctionCell->SetHelpId(HID_QRYDGN_ROW_FUNCTION);
135 : :
136 : : //////////////////////////////////////////////////////////////////////
137 : : // TriState der ::com::sun::star::form::CheckBox abschalten
138 [ # # ]: 0 : m_pVisibleCell->GetBox().EnableTriState( sal_False );
139 : :
140 [ # # ][ # # ]: 0 : Font aTitleFont = OutputDevice::GetDefaultFont( DEFAULTFONT_SANS_UNICODE,Window::GetSettings().GetLanguage(),DEFAULTFONT_FLAGS_ONLYONE);
141 [ # # ]: 0 : aTitleFont.SetSize(Size(0, 6));
142 [ # # ]: 0 : SetTitleFont(aTitleFont);
143 : :
144 [ # # ][ # # ]: 0 : String aTxt(ModuleRes(STR_QUERY_SORTTEXT));
145 [ # # ][ # # ]: 0 : xub_StrLen nCount = comphelper::string::getTokenCount(aTxt, ';');
146 : 0 : xub_StrLen nIdx = 0;
147 [ # # ]: 0 : for (; nIdx < nCount; nIdx++)
148 [ # # ][ # # ]: 0 : m_pOrderCell->InsertEntry(aTxt.GetToken(nIdx));
[ # # ]
149 : :
150 [ # # ]: 0 : for(long i=0;i < BROW_ROW_CNT;i++)
151 [ # # ]: 0 : m_bVisibleRow.push_back(sal_True);
152 : :
153 [ # # ]: 0 : m_bVisibleRow[BROW_FUNCTION_ROW] = sal_False; // zuerst ausblenden
154 : :
155 [ # # ]: 0 : m_timerInvalidate.SetTimeout(200);
156 [ # # ]: 0 : m_timerInvalidate.SetTimeoutHdl(LINK(this, OSelectionBrowseBox, OnInvalidateTimer));
157 [ # # ][ # # ]: 0 : m_timerInvalidate.Start();
[ # # ]
158 : 0 : }
159 : :
160 : : //------------------------------------------------------------------------------
161 [ # # ][ # # ]: 0 : OSelectionBrowseBox::~OSelectionBrowseBox()
[ # # ]
162 : : {
163 : : DBG_DTOR(OSelectionBrowseBox,NULL);
164 : :
165 [ # # ][ # # ]: 0 : delete m_pTextCell;
166 [ # # ][ # # ]: 0 : delete m_pVisibleCell;
167 [ # # ][ # # ]: 0 : delete m_pFieldCell;
168 [ # # ][ # # ]: 0 : delete m_pTableCell;
169 [ # # ][ # # ]: 0 : delete m_pOrderCell;
170 [ # # ][ # # ]: 0 : delete m_pFunctionCell;
171 [ # # ]: 0 : }
172 : : // -----------------------------------------------------------------------------
173 : 0 : void OSelectionBrowseBox::initialize()
174 : : {
175 [ # # ][ # # ]: 0 : Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection();
176 [ # # ]: 0 : if(xConnection.is())
177 : : {
178 [ # # ]: 0 : const IParseContext& rContext = static_cast<OQueryController&>(getDesignView()->getController()).getParser().getContext();
179 : : IParseContext::InternationalKeyCode eFunctions[] = { IParseContext::KEY_AVG,IParseContext::KEY_COUNT,IParseContext::KEY_MAX
180 : : ,IParseContext::KEY_MIN,IParseContext::KEY_SUM
181 : : ,IParseContext::KEY_EVERY
182 : : ,IParseContext::KEY_ANY
183 : : ,IParseContext::KEY_SOME
184 : : ,IParseContext::KEY_STDDEV_POP
185 : : ,IParseContext::KEY_STDDEV_SAMP
186 : : ,IParseContext::KEY_VAR_SAMP
187 : : ,IParseContext::KEY_VAR_POP
188 : : ,IParseContext::KEY_COLLECT
189 : : ,IParseContext::KEY_FUSION
190 : : ,IParseContext::KEY_INTERSECTION
191 : 0 : };
192 : :
193 [ # # ][ # # ]: 0 : String sGroup = m_aFunctionStrings.GetToken(comphelper::string::getTokenCount(m_aFunctionStrings, ';') - 1);
[ # # ]
194 [ # # ][ # # ]: 0 : m_aFunctionStrings = m_aFunctionStrings.GetToken(0);
[ # # ]
195 : :
196 [ # # ]: 0 : for (size_t i = 0; i < sizeof (eFunctions) / sizeof (eFunctions[0]); ++i)
197 : : {
198 [ # # ][ # # ]: 0 : m_aFunctionStrings += String(RTL_CONSTASCII_USTRINGPARAM(";"));
[ # # ]
199 : 0 : m_aFunctionStrings += rtl::OStringToOUString(rContext.getIntlKeywordAscii(eFunctions[i]),
200 [ # # ][ # # ]: 0 : RTL_TEXTENCODING_UTF8);
[ # # ]
201 : : }
202 [ # # ][ # # ]: 0 : m_aFunctionStrings += String(RTL_CONSTASCII_USTRINGPARAM(";"));
[ # # ]
203 [ # # ]: 0 : m_aFunctionStrings += sGroup;
204 : :
205 : : // Aggregate functions in general available only with Core SQL
206 : : // We slip in a few optionals one, too.
207 [ # # ][ # # ]: 0 : if ( lcl_SupportsCoreSQLGrammar(xConnection) )
208 : : {
209 [ # # ][ # # ]: 0 : xub_StrLen nCount = comphelper::string::getTokenCount(m_aFunctionStrings, ';');
210 [ # # ]: 0 : for (xub_StrLen nIdx = 0; nIdx < nCount; nIdx++)
211 [ # # ][ # # ]: 0 : m_pFunctionCell->InsertEntry(m_aFunctionStrings.GetToken(nIdx));
[ # # ]
212 : : }
213 : : else // else only COUNT(*) and COUNT("table".*)
214 : : {
215 [ # # ][ # # ]: 0 : m_pFunctionCell->InsertEntry(m_aFunctionStrings.GetToken(0));
[ # # ]
216 [ # # ][ # # ]: 0 : m_pFunctionCell->InsertEntry(m_aFunctionStrings.GetToken(2)); // 2 -> COUNT
[ # # ]
217 : : }
218 : : try
219 : : {
220 [ # # ][ # # ]: 0 : Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
221 [ # # ]: 0 : if ( xMetaData.is() )
222 : : {
223 [ # # ][ # # ]: 0 : m_bOrderByUnRelated = xMetaData->supportsOrderByUnrelated();
224 [ # # ][ # # ]: 0 : m_bGroupByUnRelated = xMetaData->supportsGroupByUnrelated();
225 [ # # ]: 0 : }
226 : : }
227 [ # # ]: 0 : catch(Exception&)
228 : : {
229 [ # # ]: 0 : }
230 : : }
231 : :
232 [ # # ]: 0 : Init();
233 : 0 : }
234 : : //==============================================================================
235 : 0 : OQueryDesignView* OSelectionBrowseBox::getDesignView()
236 : : {
237 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
238 : : OSL_ENSURE(static_cast<const OQueryDesignView*>(GetParent()),"Parent isn't an OQueryDesignView!");
239 : 0 : return static_cast<OQueryDesignView*>(GetParent());
240 : : }
241 : : // -----------------------------------------------------------------------------
242 : 0 : OQueryDesignView* OSelectionBrowseBox::getDesignView() const
243 : : {
244 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
245 : : OSL_ENSURE(static_cast<const OQueryDesignView*>(GetParent()),"Parent isn't an OQueryDesignView!");
246 : 0 : return static_cast<OQueryDesignView*>(GetParent());
247 : : }
248 : : namespace
249 : : {
250 [ # # ]: 0 : class OSelectionBrwBoxHeader : public ::svt::EditBrowserHeader
251 : : {
252 : : OSelectionBrowseBox* m_pBrowseBox;
253 : : protected:
254 : : virtual void Select();
255 : : public:
256 : : OSelectionBrwBoxHeader(OSelectionBrowseBox* pParent);
257 : : };
258 : 0 : OSelectionBrwBoxHeader::OSelectionBrwBoxHeader(OSelectionBrowseBox* pParent)
259 : : : ::svt::EditBrowserHeader(pParent,WB_BUTTONSTYLE|WB_DRAG)
260 : 0 : ,m_pBrowseBox(pParent)
261 : : {
262 : 0 : }
263 : :
264 : 0 : void OSelectionBrwBoxHeader::Select()
265 : : {
266 : 0 : EditBrowserHeader::Select();
267 : 0 : m_pBrowseBox->GrabFocus();
268 : :
269 : 0 : BrowserMode nMode = m_pBrowseBox->GetMode();
270 [ # # ]: 0 : if ( 0 == m_pBrowseBox->GetSelectColumnCount() )
271 : : {
272 : 0 : m_pBrowseBox->DeactivateCell();
273 : : // wenn es schon eine selektierte Spalte gibt, bin ich schon im richtigen Modus
274 [ # # ]: 0 : if ( BROWSER_HIDESELECT == ( nMode & BROWSER_HIDESELECT ) )
275 : : {
276 : 0 : nMode &= ~BROWSER_HIDESELECT;
277 : 0 : nMode |= BROWSER_MULTISELECTION;
278 : 0 : m_pBrowseBox->SetMode( nMode );
279 : : }
280 : : }
281 : 0 : m_pBrowseBox->SelectColumnId( GetCurItemId() );
282 : 0 : m_pBrowseBox->DeactivateCell();
283 : 0 : }
284 : : }
285 : :
286 : : // -----------------------------------------------------------------------------
287 : 0 : BrowserHeader* OSelectionBrowseBox::imp_CreateHeaderBar(BrowseBox* /*pParent*/)
288 : : {
289 [ # # ]: 0 : return new OSelectionBrwBoxHeader(this);
290 : : }
291 : : // -----------------------------------------------------------------------------
292 : 0 : void OSelectionBrowseBox::ColumnMoved( sal_uInt16 nColId,sal_Bool _bCreateUndo )
293 : : {
294 : 0 : EditBrowseBox::ColumnMoved( nColId );
295 : : // swap the two columns
296 : 0 : sal_uInt16 nNewPos = GetColumnPos( nColId );
297 : 0 : OTableFields& rFields = getFields();
298 [ # # ]: 0 : if ( rFields.size() > sal_uInt16(nNewPos-1) )
299 : : {
300 : 0 : sal_uInt16 nOldPos = 0;
301 : 0 : OTableFields::iterator aEnd = rFields.end();
302 : 0 : OTableFields::iterator aIter = rFields.begin();
303 [ # # ][ # # ]: 0 : for (; aIter != aEnd && ( (*aIter)->GetColumnId() != nColId ); ++aIter,++nOldPos)
[ # # ][ # # ]
304 : : ;
305 : :
306 : : OSL_ENSURE( (nNewPos-1) != nOldPos && nOldPos < rFields.size(),"Old and new position are equal!");
307 [ # # ][ # # ]: 0 : if ( aIter != aEnd )
308 : : {
309 [ # # ]: 0 : OTableFieldDescRef pOldEntry = rFields[nOldPos];
310 [ # # ][ # # ]: 0 : rFields.erase(rFields.begin() + nOldPos);
311 [ # # ][ # # ]: 0 : rFields.insert(rFields.begin() + nNewPos - 1,pOldEntry);
[ # # ]
312 : :
313 : : // create the undo action
314 [ # # ][ # # ]: 0 : if ( !m_bInUndoMode && _bCreateUndo )
315 : : {
316 [ # # ][ # # ]: 0 : OTabFieldMovedUndoAct* pUndoAct = new OTabFieldMovedUndoAct(this);
317 : 0 : pUndoAct->SetColumnPosition( nOldPos + 1);
318 [ # # ][ # # ]: 0 : pUndoAct->SetTabFieldDescr(pOldEntry);
[ # # ]
319 : :
320 [ # # ][ # # ]: 0 : getDesignView()->getController().addUndoActionAndInvalidate(pUndoAct);
321 [ # # ]: 0 : }
322 : : }
323 : : }
324 : : else
325 : : OSL_FAIL("Invalid column id!");
326 : 0 : }
327 : : //------------------------------------------------------------------------------
328 : 0 : void OSelectionBrowseBox::Init()
329 : : {
330 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
331 : :
332 [ # # ]: 0 : EditBrowseBox::Init();
333 : :
334 : : // set the header bar
335 [ # # ]: 0 : BrowserHeader* pNewHeaderBar = CreateHeaderBar(this);
336 [ # # ]: 0 : pNewHeaderBar->SetMouseTransparent(sal_False);
337 : :
338 [ # # ]: 0 : SetHeaderBar(pNewHeaderBar);
339 [ # # ]: 0 : SetMode(m_nMode);
340 : :
341 [ # # ]: 0 : Font aFont( GetDataWindow().GetFont() );
342 [ # # ]: 0 : aFont.SetWeight( WEIGHT_NORMAL );
343 [ # # ]: 0 : GetDataWindow().SetFont( aFont );
344 : :
345 : 0 : Size aHeight;
346 : 0 : const Control* pControls[] = { m_pTextCell,m_pVisibleCell,m_pTableCell,m_pFieldCell };
347 : :
348 [ # # ]: 0 : for (sal_Size i = 0; i < sizeof (pControls) / sizeof (pControls[0]); ++i)
349 : : {
350 [ # # ]: 0 : const Size aTemp( pControls[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) );
351 [ # # ]: 0 : if ( aTemp.Height() > aHeight.Height() )
352 : 0 : aHeight.Height() = aTemp.Height();
353 : : }
354 [ # # ]: 0 : SetDataRowHeight(aHeight.Height());
355 [ # # ]: 0 : SetTitleLines(1);
356 : : // Anzahl der sichtbaren Zeilen ermitteln
357 [ # # ]: 0 : for(long i=0;i<BROW_ROW_CNT;i++)
358 : : {
359 [ # # ][ # # ]: 0 : if(m_bVisibleRow[i])
360 : 0 : m_nVisibleCount++;
361 : : }
362 [ # # ]: 0 : RowInserted(0, m_nVisibleCount, sal_False);
363 : : try
364 : : {
365 [ # # ][ # # ]: 0 : Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection();
366 [ # # ]: 0 : if(xConnection.is())
367 : : {
368 [ # # ][ # # ]: 0 : Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
369 [ # # ][ # # ]: 0 : m_nMaxColumns = xMetaData.is() ? xMetaData->getMaxColumnsInSelect() : 0;
[ # # ]
370 : :
371 : : }
372 : : else
373 [ # # ]: 0 : m_nMaxColumns = 0;
374 : : }
375 [ # # ]: 0 : catch(const SQLException&)
376 : : {
377 : : OSL_FAIL("Catched Exception when asking for database metadata options!");
378 : 0 : m_nMaxColumns = 0;
379 [ # # ]: 0 : }
380 : 0 : }
381 : :
382 : : //------------------------------------------------------------------------------
383 : 0 : void OSelectionBrowseBox::PreFill()
384 : : {
385 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
386 : 0 : SetUpdateMode(sal_False);
387 : :
388 [ # # ]: 0 : if (GetCurRow() != 0)
389 : 0 : GoToRow(0);
390 : :
391 : :
392 : 0 : static_cast< OQueryController& >( getDesignView()->getController() ).clearFields();
393 : :
394 : 0 : DeactivateCell();
395 : :
396 : 0 : RemoveColumns();
397 : 0 : InsertHandleColumn( HANDLE_COLUMN_WITDH );
398 : 0 : SetUpdateMode(sal_True);
399 : 0 : }
400 : : //------------------------------------------------------------------------------
401 : 0 : void OSelectionBrowseBox::ClearAll()
402 : : {
403 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
404 [ # # ]: 0 : SetUpdateMode(sal_False);
405 : :
406 [ # # ]: 0 : OTableFields::reverse_iterator aIter = getFields().rbegin();
407 [ # # ][ # # ]: 0 : for ( ;aIter != getFields().rend(); ++aIter )
[ # # ][ # # ]
408 : : {
409 [ # # ][ # # ]: 0 : if ( !(*aIter)->IsEmpty() )
[ # # ]
410 : : {
411 [ # # ][ # # ]: 0 : RemoveField( (*aIter)->GetColumnId() );
412 [ # # ]: 0 : aIter = getFields().rbegin();
413 : : }
414 : : }
415 : 0 : m_nLastSortColumn = SORT_COLUMN_NONE;
416 [ # # ]: 0 : SetUpdateMode(sal_True);
417 : 0 : }
418 : : //------------------------------------------------------------------------------
419 : 0 : void OSelectionBrowseBox::SetReadOnly(sal_Bool bRO)
420 : : {
421 [ # # ]: 0 : if (bRO)
422 : : {
423 : 0 : DeactivateCell();
424 : 0 : m_nMode &= ~BROWSER_HIDECURSOR;
425 : 0 : SetMode(m_nMode);
426 : : }
427 : : else
428 : : {
429 : 0 : m_nMode |= BROWSER_HIDECURSOR;
430 : 0 : SetMode(m_nMode);
431 : 0 : ActivateCell();
432 : : }
433 : 0 : }
434 : :
435 : : //------------------------------------------------------------------------------
436 : 0 : CellController* OSelectionBrowseBox::GetController(long nRow, sal_uInt16 nColId)
437 : : {
438 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
439 [ # # ][ # # ]: 0 : if ( nColId > getFields().size() )
440 : 0 : return NULL;
441 [ # # ][ # # ]: 0 : OTableFieldDescRef pEntry = getFields()[nColId-1];
442 : : OSL_ENSURE(pEntry.is(), "OSelectionBrowseBox::GetController : keine FieldDescription !");
443 : :
444 [ # # ]: 0 : if (!pEntry.is())
445 : 0 : return NULL;
446 : :
447 [ # # ][ # # ]: 0 : if (static_cast<OQueryController&>(getDesignView()->getController()).isReadOnly())
[ # # ]
448 : 0 : return NULL;
449 : :
450 [ # # ]: 0 : long nCellIndex = GetRealRow(nRow);
451 [ # # # # : 0 : switch (nCellIndex)
# # ]
452 : : {
453 : : case BROW_FIELD_ROW:
454 [ # # ][ # # ]: 0 : return new ComboBoxCellController(m_pFieldCell);
455 : : case BROW_TABLE_ROW:
456 [ # # ][ # # ]: 0 : return new ListBoxCellController(m_pTableCell);
457 : : case BROW_VIS_ROW:
458 [ # # ][ # # ]: 0 : return new CheckBoxCellController(m_pVisibleCell);
459 : : case BROW_ORDER_ROW:
460 [ # # ][ # # ]: 0 : return new ListBoxCellController(m_pOrderCell);
461 : : case BROW_FUNCTION_ROW:
462 [ # # ][ # # ]: 0 : return new ListBoxCellController(m_pFunctionCell);
463 : : default:
464 [ # # ][ # # ]: 0 : return new EditCellController(m_pTextCell);
465 [ # # ]: 0 : }
466 : : }
467 : :
468 : : //------------------------------------------------------------------------------
469 : 0 : void OSelectionBrowseBox::InitController(CellControllerRef& /*rController*/, long nRow, sal_uInt16 nColId)
470 : : {
471 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
472 : : OSL_ENSURE(nColId != BROWSER_INVALIDID,"An Invalid Id was set!");
473 [ # # ]: 0 : if ( nColId == BROWSER_INVALIDID )
474 : : return;
475 [ # # ]: 0 : sal_uInt16 nPos = GetColumnPos(nColId);
476 [ # # ][ # # ]: 0 : if ( nPos == 0 || nPos == BROWSER_INVALIDID || nPos > getFields().size() )
[ # # ][ # # ]
[ # # ]
477 : : return;
478 [ # # ][ # # ]: 0 : OTableFieldDescRef pEntry = getFields()[nPos-1];
479 : : OSL_ENSURE(pEntry.is(), "OSelectionBrowseBox::InitController : keine FieldDescription !");
480 [ # # ]: 0 : long nCellIndex = GetRealRow(nRow);
481 : :
482 [ # # # # : 0 : switch (nCellIndex)
# # # ]
483 : : {
484 : : case BROW_FIELD_ROW:
485 : : {
486 [ # # ]: 0 : m_pFieldCell->Clear();
487 [ # # ][ # # ]: 0 : m_pFieldCell->SetText(String());
[ # # ]
488 : :
489 [ # # ]: 0 : String aField(pEntry->GetField());
490 [ # # ]: 0 : String aTable(pEntry->GetAlias());
491 : :
492 [ # # ][ # # ]: 0 : getDesignView()->fillValidFields(aTable, m_pFieldCell);
[ # # ]
493 : :
494 : : // * durch alias.* ersetzen
495 [ # # ][ # # ]: 0 : if ((aField.GetChar(0) == '*') && aTable.Len())
[ # # ]
496 : : {
497 [ # # ]: 0 : aField = aTable;
498 [ # # ]: 0 : aField.AppendAscii(".*");
499 : : }
500 [ # # ][ # # ]: 0 : m_pFieldCell->SetText(aField);
[ # # ]
501 : 0 : } break;
502 : : case BROW_TABLE_ROW:
503 : : {
504 [ # # ]: 0 : m_pTableCell->Clear();
505 [ # # ]: 0 : enableControl(pEntry,m_pTableCell);
506 [ # # ]: 0 : if ( !pEntry->isCondition() )
507 : : {
508 [ # # ]: 0 : OJoinTableView::OTableWindowMap* pTabWinList = getDesignView()->getTableView()->GetTabWinMap();
509 [ # # ]: 0 : if (pTabWinList)
510 : : {
511 : 0 : OJoinTableView::OTableWindowMap::iterator aIter = pTabWinList->begin();
512 : 0 : OJoinTableView::OTableWindowMap::iterator aEnd = pTabWinList->end();
513 : :
514 [ # # ]: 0 : for(;aIter != aEnd;++aIter)
515 [ # # ][ # # ]: 0 : m_pTableCell->InsertEntry(static_cast<OQueryTableWindow*>(aIter->second)->GetAliasName());
[ # # ][ # # ]
516 : :
517 [ # # ][ # # ]: 0 : m_pTableCell->InsertEntry(String(ModuleRes(STR_QUERY_NOTABLE)), 0);
[ # # ][ # # ]
518 [ # # ]: 0 : if (!pEntry->GetAlias().isEmpty())
519 [ # # ][ # # ]: 0 : m_pTableCell->SelectEntry(pEntry->GetAlias());
[ # # ]
520 : : else
521 [ # # ][ # # ]: 0 : m_pTableCell->SelectEntry(String(ModuleRes(STR_QUERY_NOTABLE)));
[ # # ][ # # ]
522 : : }
523 : : }
524 : 0 : } break;
525 : : case BROW_VIS_ROW:
526 : : {
527 [ # # ]: 0 : m_pVisibleCell->GetBox().Check(pEntry->IsVisible());
528 : 0 : m_pVisibleCell->GetBox().SaveValue();
529 : :
530 [ # # ]: 0 : enableControl(pEntry,m_pTextCell);
531 : :
532 [ # # ][ # # ]: 0 : if(!pEntry->IsVisible() && pEntry->GetOrderDir() != ORDER_NONE && !m_bOrderByUnRelated)
[ # # ][ # # ]
533 : : {
534 : : // Spalte muss sichtbar sein, um im ORDER BY aufzutauchen
535 : 0 : pEntry->SetVisible(sal_True);
536 [ # # ]: 0 : m_pVisibleCell->GetBox().Check(pEntry->IsVisible());
537 : 0 : m_pVisibleCell->GetBox().SaveValue();
538 [ # # ]: 0 : m_pVisibleCell->GetBox().Disable();
539 [ # # ]: 0 : m_pVisibleCell->GetBox().EnableInput(sal_False);
540 [ # # ][ # # ]: 0 : String aMessage(ModuleRes(STR_QRY_ORDERBY_UNRELATED));
541 [ # # ]: 0 : OQueryDesignView* paDView = getDesignView();
542 [ # # ][ # # ]: 0 : InfoBox(paDView, aMessage).Execute();
[ # # ][ # # ]
543 : : }
544 : 0 : } break;
545 : : case BROW_ORDER_ROW:
546 : : m_pOrderCell->SelectEntryPos(
547 [ # # ]: 0 : sal::static_int_cast< sal_uInt16 >(pEntry->GetOrderDir()));
548 [ # # ]: 0 : enableControl(pEntry,m_pOrderCell);
549 : 0 : break;
550 : : case BROW_COLUMNALIAS_ROW:
551 [ # # ][ # # ]: 0 : setTextCellContext(pEntry,pEntry->GetFieldAlias(),HID_QRYDGN_ROW_ALIAS);
[ # # ]
552 : 0 : break;
553 : : case BROW_FUNCTION_ROW:
554 [ # # ]: 0 : setFunctionCell(pEntry);
555 : 0 : break;
556 : : default:
557 : : {
558 : 0 : sal_uInt16 nIdx = sal_uInt16(nCellIndex - BROW_CRIT1_ROW);
559 [ # # ][ # # ]: 0 : setTextCellContext(pEntry,pEntry->GetCriteria( nIdx ),HID_QRYDGN_ROW_CRIT);
[ # # ][ # # ]
560 : : }
561 : : }
562 [ # # ][ # # ]: 0 : Controller()->ClearModified();
[ # # ][ # # ]
563 : : }
564 : : // -----------------------------------------------------------------------------
565 : 0 : void OSelectionBrowseBox::notifyTableFieldChanged(const String& _sOldAlias,const String& _sAlias,sal_Bool& _bListAction,sal_uInt16 _nColumnId)
566 : : {
567 : 0 : appendUndoAction(_sOldAlias,_sAlias,BROW_TABLE_ROW,_bListAction);
568 [ # # ]: 0 : if ( m_bVisibleRow[BROW_TABLE_ROW] )
569 : 0 : RowModified(GetBrowseRow(BROW_TABLE_ROW), _nColumnId);
570 : 0 : }
571 : : // -----------------------------------------------------------------------------
572 : 0 : void OSelectionBrowseBox::notifyFunctionFieldChanged(const String& _sOldFunctionName,const String& _sFunctionName,sal_Bool& _bListAction,sal_uInt16 _nColumnId)
573 : : {
574 : 0 : appendUndoAction(_sOldFunctionName,_sFunctionName,BROW_FUNCTION_ROW,_bListAction);
575 [ # # ]: 0 : if ( !m_bVisibleRow[BROW_FUNCTION_ROW] )
576 : 0 : SetRowVisible(BROW_FUNCTION_ROW, sal_True);
577 : 0 : RowModified(GetBrowseRow(BROW_FUNCTION_ROW), _nColumnId);
578 : 0 : }
579 : : // -----------------------------------------------------------------------------
580 : 0 : void OSelectionBrowseBox::clearEntryFunctionField(const String& _sFieldName,OTableFieldDescRef& _pEntry,sal_Bool& _bListAction,sal_uInt16 _nColumnId)
581 : : {
582 [ # # ][ # # ]: 0 : if ( isFieldNameAsterix( _sFieldName ) && (!_pEntry->isNoneFunction() || _pEntry->IsGroupBy()) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
583 : : {
584 [ # # ]: 0 : String sFunctionName;
585 [ # # ]: 0 : GetFunctionName(SQL_TOKEN_COUNT,sFunctionName);
586 [ # # ]: 0 : String sOldLocalizedFunctionName = _pEntry->GetFunction();
587 [ # # ][ # # ]: 0 : if ( !sOldLocalizedFunctionName.Equals(sFunctionName) || _pEntry->IsGroupBy() )
[ # # ][ # # ]
588 : : {
589 : : // append undo action for the function field
590 : 0 : _pEntry->SetFunctionType(FKT_NONE);
591 : 0 : _pEntry->SetFunction(::rtl::OUString());
592 : 0 : _pEntry->SetGroupBy(sal_False);
593 [ # # ][ # # ]: 0 : notifyFunctionFieldChanged(sOldLocalizedFunctionName,_pEntry->GetFunction(),_bListAction,_nColumnId);
[ # # ]
594 [ # # ][ # # ]: 0 : }
595 : : }
596 : 0 : }
597 : : // -----------------------------------------------------------------------------
598 : 0 : sal_Bool OSelectionBrowseBox::fillColumnRef(const OSQLParseNode* _pColumnRef, const Reference< XConnection >& _rxConnection, OTableFieldDescRef& _pEntry, sal_Bool& _bListAction )
599 : : {
600 : : OSL_ENSURE(_pColumnRef,"No valid parsenode!");
601 : 0 : ::rtl::OUString sColumnName,sTableRange;
602 [ # # ]: 0 : OSQLParseTreeIterator::getColumnRange(_pColumnRef,_rxConnection,sColumnName,sTableRange);
603 [ # # ][ # # ]: 0 : return fillColumnRef(sColumnName,sTableRange,_rxConnection->getMetaData(),_pEntry,_bListAction);
[ # # ]
604 : : }
605 : : // -----------------------------------------------------------------------------
606 : 0 : sal_Bool OSelectionBrowseBox::fillColumnRef(const ::rtl::OUString& _sColumnName,const ::rtl::OUString& _sTableRange,const Reference<XDatabaseMetaData>& _xMetaData,OTableFieldDescRef& _pEntry,sal_Bool& _bListAction)
607 : : {
608 : 0 : sal_Bool bError = sal_False;
609 [ # # ][ # # ]: 0 : ::comphelper::UStringMixEqual bCase(_xMetaData->supportsMixedCaseQuotedIdentifiers());
610 : : // check if the table name is the same
611 [ # # ][ # # ]: 0 : if ( !_sTableRange.isEmpty() && (bCase(_pEntry->GetTable(),_sTableRange) || bCase(_pEntry->GetAlias(),_sTableRange)) )
[ # # ][ # # ]
[ # # ][ # # ]
612 : : { // a table was already inserted and the tables contains that column name
613 : :
614 [ # # ]: 0 : if ( !_pEntry->GetTabWindow() )
615 : : { // fill tab window
616 : 0 : ::rtl::OUString sOldAlias = _pEntry->GetAlias();
617 [ # # ][ # # ]: 0 : if ( !fillEntryTable(_pEntry,_pEntry->GetTable()) )
618 [ # # ]: 0 : fillEntryTable(_pEntry,_pEntry->GetAlias()); // only when the first failed
619 [ # # ]: 0 : if ( !bCase(sOldAlias,_pEntry->GetAlias()) )
620 [ # # ][ # # ]: 0 : notifyTableFieldChanged(sOldAlias,_pEntry->GetAlias(),_bListAction,GetCurColumnId());
[ # # ][ # # ]
[ # # ]
621 : : }
622 : : }
623 : : // check if the table window
624 [ # # ]: 0 : OQueryTableWindow* pEntryTab = static_cast<OQueryTableWindow*>(_pEntry->GetTabWindow());
625 [ # # ]: 0 : if ( !pEntryTab ) // no table found with this name so we have to travel through all tables
626 : : {
627 [ # # ]: 0 : OJoinTableView::OTableWindowMap* pTabWinList = getDesignView()->getTableView()->GetTabWinMap();
628 [ # # ]: 0 : if ( pTabWinList )
629 : : {
630 : 0 : sal_uInt16 nTabCount = 0;
631 [ # # ][ # # ]: 0 : if ( !static_cast<OQueryTableView*>(getDesignView()->getTableView())->FindTableFromField(_sColumnName,_pEntry,nTabCount) ) // error occurred: column not in table window
[ # # ][ # # ]
[ # # ]
632 : : {
633 [ # # ][ # # ]: 0 : String sErrorMsg(ModuleRes(RID_STR_FIELD_DOESNT_EXIST));
634 [ # # ][ # # ]: 0 : sErrorMsg.SearchAndReplaceAscii("$name$",_sColumnName);
[ # # ]
635 [ # # ][ # # ]: 0 : OSQLWarningBox( this, sErrorMsg ).Execute();
[ # # ]
636 [ # # ]: 0 : bError = sal_True;
637 : : }
638 : : else
639 : : {
640 [ # # ]: 0 : pEntryTab = static_cast<OQueryTableWindow*>(_pEntry->GetTabWindow());
641 [ # # ][ # # ]: 0 : notifyTableFieldChanged(String(),_pEntry->GetAlias(),_bListAction,GetCurColumnId());
[ # # ][ # # ]
[ # # ]
642 : : }
643 : : }
644 : : }
645 [ # # ]: 0 : if ( pEntryTab ) // here we got a valid table
646 : 0 : _pEntry->SetField(_sColumnName);
647 : :
648 : 0 : return bError;
649 : : }
650 : : // -----------------------------------------------------------------------------
651 : 0 : sal_Bool OSelectionBrowseBox::saveField(const String& _sFieldName,OTableFieldDescRef& _pEntry,sal_Bool& _bListAction)
652 : : {
653 : 0 : sal_Bool bError = sal_False;
654 : :
655 [ # # ]: 0 : OQueryController& rController = static_cast<OQueryController&>(getDesignView()->getController());
656 : :
657 : : // first look if the name can be found in our tables
658 : 0 : sal_uInt16 nTabCount = 0;
659 [ # # ]: 0 : String sOldAlias = _pEntry->GetAlias();
660 [ # # ][ # # ]: 0 : if ( static_cast<OQueryTableView*>(getDesignView()->getTableView())->FindTableFromField(_sFieldName,_pEntry,nTabCount) )
[ # # ]
661 : : {
662 : : // append undo action for the alias name
663 [ # # ]: 0 : _pEntry->SetField(_sFieldName);
664 [ # # ][ # # ]: 0 : notifyTableFieldChanged(sOldAlias,_pEntry->GetAlias(),_bListAction,GetCurColumnId());
[ # # ]
665 [ # # ]: 0 : clearEntryFunctionField(_sFieldName,_pEntry,_bListAction,_pEntry->GetColumnId());
666 : 0 : return bError;
667 : : }
668 : :
669 [ # # ]: 0 : Reference<XConnection> xConnection( rController.getConnection() );
670 : 0 : Reference< XDatabaseMetaData > xMetaData;
671 [ # # ]: 0 : if ( xConnection.is() )
672 [ # # ][ # # ]: 0 : xMetaData = xConnection->getMetaData();
[ # # ]
673 : : OSL_ENSURE( xMetaData.is(), "OSelectionBrowseBox::saveField: invalid connection/meta data!" );
674 [ # # ]: 0 : if ( !xMetaData.is() )
675 : 0 : return sal_True;
676 : :
677 : 0 : ::rtl::OUString sErrorMsg;
678 : : // second test if the name can be set as select columns in a pseudo statement
679 : : // we have to look which entries we should quote
680 : :
681 : 0 : const ::rtl::OUString sFieldAlias = _pEntry->GetFieldAlias();
682 : 0 : size_t nPass = 4;
683 : 0 : ::connectivity::OSQLParser& rParser( rController.getParser() );
684 : 0 : OSQLParseNode* pParseNode = NULL;
685 : : // 4 passes in trying to interprete the field name
686 : : // - don't quote the field name, parse internationally
687 : : // - don't quote the field name, parse en-US
688 : : // - quote the field name, parse internationally
689 : : // - quote the field name, parse en-US
690 [ # # ][ # # ]: 0 : do
[ # # ]
691 : : {
692 : 0 : bool bQuote = ( nPass <= 2 );
693 : 0 : bool bInternational = ( nPass % 2 ) == 0;
694 : :
695 : 0 : ::rtl::OUString sSql;
696 [ # # ]: 0 : if ( bQuote )
697 [ # # ][ # # ]: 0 : sSql += ::dbtools::quoteName( xMetaData->getIdentifierQuoteString(), _sFieldName );
[ # # ][ # # ]
698 : : else
699 [ # # ]: 0 : sSql += _sFieldName;
700 : :
701 [ # # ]: 0 : if ( _pEntry->isAggreateFunction() )
702 : : {
703 : : OSL_ENSURE(!_pEntry->GetFunction().isEmpty(),"Functionname darf hier nicht leer sein! ;-(");
704 [ # # ]: 0 : ::rtl::OUStringBuffer aTmpStr2( _pEntry->GetFunction());
705 [ # # ]: 0 : aTmpStr2.appendAscii("(");
706 [ # # ]: 0 : aTmpStr2.append(sSql);
707 [ # # ]: 0 : aTmpStr2.appendAscii(")");
708 [ # # ]: 0 : sSql = aTmpStr2.makeStringAndClear();
709 : : }
710 : :
711 [ # # ]: 0 : sSql = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT ")) + sSql;
712 [ # # ]: 0 : if ( !sFieldAlias.isEmpty() )
713 : : { // always quote the alias name there canbe no function in it
714 [ # # ]: 0 : sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" "));
715 [ # # ][ # # ]: 0 : sSql += ::dbtools::quoteName( xMetaData->getIdentifierQuoteString(), sFieldAlias );
[ # # ]
716 : : }
717 [ # # ]: 0 : sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM x"));
718 : :
719 [ # # ]: 0 : pParseNode = rParser.parseTree( sErrorMsg, sSql, bInternational );
720 : : }
721 : : while ( ( pParseNode == NULL ) && ( --nPass > 0 ) );
722 : :
723 [ # # ]: 0 : if ( pParseNode == NULL )
724 : : {
725 : : // something different which we have to check (may be a select statement)
726 [ # # ][ # # ]: 0 : String sErrorMessage( ModuleRes( STR_QRY_COLUMN_NOT_FOUND ) );
727 [ # # ]: 0 : sErrorMessage.SearchAndReplaceAscii("$name$",_sFieldName);
728 [ # # ][ # # ]: 0 : OSQLWarningBox( this, sErrorMessage ).Execute();
[ # # ]
729 [ # # ]: 0 : return sal_True;
730 : : }
731 : :
732 : : // we got a valid select column
733 : : // find what type of column has be inserted
734 [ # # ]: 0 : ::connectivity::OSQLParseNode* pSelection = pParseNode->getChild(2);
735 [ # # ][ # # ]: 0 : if ( SQL_ISRULE(pSelection,selection) ) // we found the asterix
[ # # ][ # # ]
736 : : {
737 [ # # ]: 0 : _pEntry->SetField(_sFieldName);
738 [ # # ]: 0 : clearEntryFunctionField(_sFieldName,_pEntry,_bListAction,_pEntry->GetColumnId());
739 : : } // travel through the select column parse node
740 : : else
741 : : {
742 [ # # ][ # # ]: 0 : ::comphelper::UStringMixEqual bCase(xMetaData->supportsMixedCaseQuotedIdentifiers());
743 : :
744 [ # # ]: 0 : OTableFieldDescRef aSelEntry = _pEntry;
745 : 0 : sal_uInt16 nColumnId = aSelEntry->GetColumnId();
746 : :
747 : 0 : sal_uInt32 nCount = pSelection->count();
748 [ # # ]: 0 : for (sal_uInt32 i = 0; i < nCount; ++i)
749 : : {
750 [ # # ]: 0 : if ( i > 0 ) // may we have to append more than one field
751 : : {
752 : : sal_uInt16 nColumnPostion;
753 [ # # ][ # # ]: 0 : aSelEntry = FindFirstFreeCol(nColumnPostion);
[ # # ]
754 [ # # ]: 0 : if ( !aSelEntry.is() )
755 : : {
756 [ # # ][ # # ]: 0 : AppendNewCol(1);
757 [ # # ][ # # ]: 0 : aSelEntry = FindFirstFreeCol(nColumnPostion);
[ # # ]
758 : : }
759 : 0 : ++nColumnPostion;
760 [ # # ]: 0 : nColumnId = GetColumnId(nColumnPostion);
761 : : }
762 : :
763 [ # # ]: 0 : ::connectivity::OSQLParseNode* pChild = pSelection->getChild( i );
764 : : OSL_ENSURE(SQL_ISRULE(pChild,derived_column), "No derived column found!");
765 : : // get the column alias
766 [ # # ]: 0 : ::rtl::OUString sColumnAlias = OSQLParseTreeIterator::getColumnAlias(pChild);
767 [ # # ]: 0 : if ( !sColumnAlias.isEmpty() ) // we found an as clause
768 : : {
769 [ # # ]: 0 : String aSelectionAlias = aSelEntry->GetFieldAlias();
770 : 0 : aSelEntry->SetFieldAlias( sColumnAlias );
771 : : // append undo
772 [ # # ][ # # ]: 0 : appendUndoAction(aSelectionAlias,aSelEntry->GetFieldAlias(),BROW_COLUMNALIAS_ROW,_bListAction);
[ # # ]
773 [ # # ][ # # ]: 0 : if ( m_bVisibleRow[BROW_COLUMNALIAS_ROW] )
774 [ # # ][ # # ]: 0 : RowModified(GetBrowseRow(BROW_COLUMNALIAS_ROW), nColumnId);
[ # # ]
775 : : }
776 : :
777 [ # # ]: 0 : ::connectivity::OSQLParseNode* pColumnRef = pChild->getChild(0);
778 [ # # ][ # # : 0 : if (
# # # # #
# # # ]
779 : 0 : pColumnRef->count() == 3 &&
780 [ # # ][ # # ]: 0 : SQL_ISPUNCTUATION(pColumnRef->getChild(0),"(") &&
781 [ # # ][ # # ]: 0 : SQL_ISPUNCTUATION(pColumnRef->getChild(2),")")
782 : : )
783 [ # # ]: 0 : pColumnRef = pColumnRef->getChild(1);
784 : :
785 [ # # ][ # # ]: 0 : if ( SQL_ISRULE(pColumnRef,column_ref) ) // we found a valid column name or more column names
[ # # ][ # # ]
786 : : {
787 : : // look if we can find the corresponding table
788 [ # # ]: 0 : bError = fillColumnRef( pColumnRef, xConnection, aSelEntry, _bListAction );
789 : :
790 : : // we found a simple column so we must clear the function fields but only when the column name is '*'
791 : : // and the function is different to count
792 [ # # ]: 0 : clearEntryFunctionField(_sFieldName,aSelEntry,_bListAction,nColumnId);
793 : : }
794 : : // do we have a aggregate function and only a function?
795 [ # # ][ # # ]: 0 : else if ( SQL_ISRULE(pColumnRef,general_set_fct) )
[ # # ][ # # ]
796 : : {
797 [ # # ]: 0 : String sLocalizedFunctionName;
798 [ # # ][ # # ]: 0 : if ( GetFunctionName(pColumnRef->getChild(0)->getTokenID(),sLocalizedFunctionName) )
[ # # ]
799 : : {
800 [ # # ]: 0 : String sOldLocalizedFunctionName = aSelEntry->GetFunction();
801 [ # # ]: 0 : aSelEntry->SetFunction(sLocalizedFunctionName);
802 : 0 : sal_uInt32 nFunCount = pColumnRef->count() - 1;
803 : 0 : sal_Int32 nFunctionType = FKT_AGGREGATE;
804 : 0 : sal_Bool bQuote = sal_False;
805 : : // may be there exists only one parameter which is a column, fill all information into our fields
806 [ # # ][ # # ]: 0 : if ( nFunCount == 4 && SQL_ISRULE(pColumnRef->getChild(3),column_ref) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
807 [ # # ][ # # ]: 0 : bError = fillColumnRef( pColumnRef->getChild(3), xConnection, aSelEntry, _bListAction );
808 [ # # ]: 0 : else if ( nFunCount == 3 ) // we have a COUNT(*) here, so take the first table
809 [ # # ][ # # ]: 0 : bError = fillColumnRef( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*")), ::rtl::OUString(), xMetaData, aSelEntry, _bListAction );
810 : : else
811 : : {
812 : 0 : nFunctionType |= FKT_NUMERIC;
813 : 0 : bQuote = sal_True;
814 : 0 : aSelEntry->SetDataType(DataType::DOUBLE);
815 : 0 : aSelEntry->SetFieldType(TAB_NORMAL_FIELD);
816 : : }
817 : :
818 : : // now parse the parameters
819 : 0 : ::rtl::OUString sParameters;
820 [ # # ]: 0 : for(sal_uInt32 function = 2; function < nFunCount; ++function) // we only want to parse the parameters of the function
821 [ # # ][ # # ]: 0 : pColumnRef->getChild(function)->parseNodeToStr( sParameters, xConnection, &rParser.getContext(), sal_True, bQuote );
822 : :
823 : 0 : aSelEntry->SetFunctionType(nFunctionType);
824 : 0 : aSelEntry->SetField(sParameters);
825 [ # # ]: 0 : if ( aSelEntry->IsGroupBy() )
826 : : {
827 [ # # ][ # # ]: 0 : sOldLocalizedFunctionName = m_aFunctionStrings.GetToken(comphelper::string::getTokenCount(m_aFunctionStrings, ';')-1);
[ # # ][ # # ]
[ # # ]
828 : 0 : aSelEntry->SetGroupBy(sal_False);
829 : : }
830 : :
831 : : // append undo action
832 [ # # ][ # # ]: 0 : notifyFunctionFieldChanged(sOldLocalizedFunctionName,sLocalizedFunctionName,_bListAction, nColumnId);
833 : : }
834 : : else
835 [ # # ]: 0 : OSL_FAIL("Unsupported function inserted!");
836 : :
837 : : }
838 : : else
839 : : {
840 : : // so we first clear the function field
841 [ # # ]: 0 : clearEntryFunctionField(_sFieldName,aSelEntry,_bListAction,nColumnId);
842 : 0 : ::rtl::OUString sFunction;
843 : : pColumnRef->parseNodeToStr( sFunction,
844 : : xConnection,
845 : 0 : &rController.getParser().getContext(),
846 : : sal_True,
847 [ # # ]: 0 : sal_True); // quote is to true because we need quoted elements inside the function
848 : :
849 [ # # ][ # # ]: 0 : getDesignView()->fillFunctionInfo(pColumnRef,sFunction,aSelEntry);
850 : :
851 [ # # ][ # # ]: 0 : if( SQL_ISRULEOR3(pColumnRef, position_exp, extract_exp, fold) ||
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
[ # # ][ # # ]
[ # # ][ # # ]
852 [ # # ][ # # ]: 0 : SQL_ISRULEOR3(pColumnRef, char_substring_fct, length_exp, char_value_fct) )
[ # # ]
853 : : // a calculation has been found ( can be calc and function )
854 : : {
855 : : // now parse the whole statement
856 : 0 : sal_uInt32 nFunCount = pColumnRef->count();
857 : 0 : ::rtl::OUString sParameters;
858 [ # # ]: 0 : for(sal_uInt32 function = 0; function < nFunCount; ++function)
859 [ # # ][ # # ]: 0 : pColumnRef->getChild(function)->parseNodeToStr( sParameters, xConnection, &rParser.getContext(), sal_True, sal_True );
860 : :
861 [ # # ]: 0 : sOldAlias = aSelEntry->GetAlias();
862 : 0 : sal_Int32 nNewFunctionType = aSelEntry->GetFunctionType() | FKT_NUMERIC | FKT_OTHER;
863 : 0 : aSelEntry->SetFunctionType(nNewFunctionType);
864 : 0 : aSelEntry->SetField(sParameters);
865 : : }
866 : : else
867 : : {
868 : 0 : aSelEntry->SetFieldAlias(sColumnAlias);
869 [ # # ][ # # ]: 0 : if ( SQL_ISRULE(pColumnRef,set_fct_spec) )
[ # # ][ # # ]
870 : 0 : aSelEntry->SetFunctionType(/*FKT_NUMERIC | */FKT_OTHER);
871 : : else
872 : 0 : aSelEntry->SetFunctionType(FKT_NUMERIC | FKT_OTHER);
873 : : }
874 : :
875 : 0 : aSelEntry->SetAlias(::rtl::OUString());
876 [ # # ][ # # ]: 0 : notifyTableFieldChanged(sOldAlias,aSelEntry->GetAlias(),_bListAction, nColumnId);
[ # # ]
877 : : }
878 : :
879 [ # # ][ # # ]: 0 : if ( i > 0 && !InsertField(aSelEntry,BROWSER_INVALIDID,sal_True,sal_False).is() ) // may we have to append more than one field
[ # # ][ # # ]
[ # # ]
[ # # # # ]
880 : : { // the field could not be inserted
881 [ # # ][ # # ]: 0 : String sErrorMessage( ModuleRes( RID_STR_FIELD_DOESNT_EXIST ) );
882 [ # # ][ # # ]: 0 : sErrorMessage.SearchAndReplaceAscii("$name$",aSelEntry->GetField());
[ # # ]
883 [ # # ][ # # ]: 0 : OSQLWarningBox( this, sErrorMessage ).Execute();
[ # # ]
884 [ # # ]: 0 : bError = sal_True;
885 : : }
886 [ # # ]: 0 : }
887 : : }
888 [ # # ][ # # ]: 0 : delete pParseNode;
889 : :
890 [ # # ]: 0 : return bError;
891 : : }
892 : : //------------------------------------------------------------------------------
893 : 0 : sal_Bool OSelectionBrowseBox::SaveModified()
894 : : {
895 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
896 [ # # ]: 0 : OQueryController& rController = static_cast<OQueryController&>(getDesignView()->getController());
897 [ # # ]: 0 : OTableFieldDescRef pEntry = NULL;
898 [ # # ]: 0 : sal_uInt16 nCurrentColumnPos = GetColumnPos(GetCurColumnId());
899 [ # # ][ # # ]: 0 : if(getFields().size() > static_cast<sal_uInt16>(nCurrentColumnPos - 1))
900 [ # # ][ # # ]: 0 : pEntry = getEntry(nCurrentColumnPos - 1);
[ # # ]
901 : :
902 [ # # ][ # # ]: 0 : sal_Bool bWasEmpty = pEntry.is() ? pEntry->IsEmpty() : sal_False;
903 : 0 : sal_Bool bError = sal_False;
904 : 0 : sal_Bool bListAction = sal_False;
905 : :
906 [ # # ][ # # ]: 0 : if (pEntry.is() && Controller().Is() && Controller()->IsModified())
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # ]
907 : : {
908 : : // fuer die Undo-Action
909 [ # # ][ # # ]: 0 : String strOldCellContents,sNewValue;
910 [ # # ]: 0 : long nRow = GetRealRow(GetCurRow());
911 : 0 : sal_Bool bAppendRow = sal_False;
912 [ # # # # : 0 : switch (nRow)
# # # ]
913 : : {
914 : : case BROW_VIS_ROW:
915 : : {
916 : 0 : sal_Bool bOldValue = m_pVisibleCell->GetBox().GetSavedValue() != STATE_NOCHECK;
917 [ # # ][ # # ]: 0 : strOldCellContents = bOldValue ? g_strOne : g_strZero;
[ # # ]
[ # # # # ]
[ # # ]
918 [ # # ][ # # ]: 0 : sNewValue = !bOldValue ? g_strOne : g_strZero;
[ # # ][ # # ]
[ # # # # ]
919 : : }
920 [ # # ][ # # ]: 0 : if((m_bOrderByUnRelated || pEntry->GetOrderDir() == ORDER_NONE) &&
[ # # # # ]
[ # # ]
921 : 0 : (m_bGroupByUnRelated || !pEntry->IsGroupBy()))
922 : : {
923 [ # # ]: 0 : pEntry->SetVisible(m_pVisibleCell->GetBox().IsChecked());
924 : : }
925 : : else
926 : : {
927 : 0 : pEntry->SetVisible(sal_True);
928 [ # # ]: 0 : m_pVisibleCell->GetBox().Check();
929 : : }
930 : 0 : break;
931 : :
932 : : case BROW_FIELD_ROW:
933 : : {
934 [ # # ]: 0 : String aFieldName(m_pFieldCell->GetText());
935 : : try
936 : : {
937 [ # # ]: 0 : if (!aFieldName.Len())
938 : : {
939 [ # # ][ # # ]: 0 : OTableFieldDescRef pNewEntry = new OTableFieldDesc();
[ # # ]
940 : 0 : pNewEntry->SetColumnId( pEntry->GetColumnId() );
941 [ # # ][ # # ]: 0 : ::std::replace(getFields().begin(),getFields().end(),pEntry,pNewEntry);
[ # # ]
942 : 0 : sal_uInt16 nCol = GetCurColumnId();
943 [ # # ]: 0 : for (int i = 0; i < m_nVisibleCount; i++) // Spalte neu zeichnen
944 [ # # ][ # # ]: 0 : RowModified(i,nCol);
945 : : }
946 : : else
947 : : {
948 [ # # ]: 0 : strOldCellContents = pEntry->GetField();
949 : 0 : bListAction = sal_True;
950 [ # # ]: 0 : if ( !m_bInUndoMode )
951 [ # # ][ # # ]: 0 : rController.GetUndoManager().EnterListAction(String(),String());
[ # # ][ # # ]
[ # # ][ # # ]
952 : :
953 [ # # ]: 0 : sal_uInt16 nPos = m_pFieldCell->GetEntryPos(aFieldName);
954 [ # # ]: 0 : String aAliasName = pEntry->GetAlias();
955 [ # # ][ # # ]: 0 : if ( nPos != COMBOBOX_ENTRY_NOTFOUND && !aAliasName.Len() && comphelper::string::getTokenCount(aFieldName, '.') > 1 )
[ # # ][ # # ]
[ # # ]
[ # # # # ]
[ # # ]
956 : : { // special case, we have a table field so we must cut the table name
957 [ # # ]: 0 : String sTableAlias = aFieldName.GetToken(0,'.');
958 [ # # ]: 0 : pEntry->SetAlias(sTableAlias);
959 [ # # ]: 0 : String sColumnName = aFieldName.Copy(sTableAlias.Len()+1,aFieldName.Len() - sTableAlias.Len() -1);
960 [ # # ]: 0 : Reference<XConnection> xConnection = rController.getConnection();
961 [ # # ]: 0 : if ( !xConnection.is() )
962 : 0 : return sal_False;
963 [ # # ][ # # ]: 0 : bError = fillColumnRef( sColumnName, sTableAlias, xConnection->getMetaData(), pEntry, bListAction );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
964 : : }
965 : : else
966 : 0 : bError = sal_True;
967 : :
968 [ # # ]: 0 : if ( bError )
969 [ # # ][ # # ]: 0 : bError = saveField(aFieldName,pEntry,bListAction);
[ # # ][ # # ]
970 : : }
971 : : }
972 [ # # ]: 0 : catch(Exception&)
973 : : {
974 : 0 : bError = sal_True;
975 : : }
976 [ # # ]: 0 : if ( bError )
977 : : {
978 [ # # ]: 0 : sNewValue = aFieldName;
979 [ # # ]: 0 : if ( !m_bInUndoMode )
980 [ # # ][ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).GetUndoManager().LeaveListAction();
[ # # ]
981 : 0 : bListAction = sal_False;
982 : : }
983 : : else
984 [ # # ]: 0 : sNewValue = pEntry->GetField();
985 [ # # ][ # # ]: 0 : rController.InvalidateFeature( ID_BROWSER_QUERY_EXECUTE );
[ # # ][ # # ]
986 : : }
987 : 0 : break;
988 : :
989 : : case BROW_TABLE_ROW:
990 : : {
991 [ # # ]: 0 : String aAliasName = m_pTableCell->GetSelectEntry();
992 [ # # ]: 0 : strOldCellContents = pEntry->GetAlias();
993 [ # # ][ # # ]: 0 : if ( m_pTableCell->GetSelectEntryPos() != 0 )
994 : : {
995 [ # # ]: 0 : pEntry->SetAlias(aAliasName);
996 : : // we have to set the table name as well as the table window
997 [ # # ]: 0 : OJoinTableView::OTableWindowMap* pTabWinList = getDesignView()->getTableView()->GetTabWinMap();
998 [ # # ]: 0 : if (pTabWinList)
999 : : {
1000 [ # # ][ # # ]: 0 : OJoinTableView::OTableWindowMapIterator aIter = pTabWinList->find(aAliasName);
1001 [ # # ]: 0 : if(aIter != pTabWinList->end())
1002 : : {
1003 : 0 : OQueryTableWindow* pEntryTab = static_cast<OQueryTableWindow*>(aIter->second);
1004 [ # # ]: 0 : if (pEntryTab)
1005 : : {
1006 [ # # ]: 0 : pEntry->SetTable(pEntryTab->GetTableName());
1007 [ # # ]: 0 : pEntry->SetTabWindow(pEntryTab);
1008 : : }
1009 : : }
1010 : : }
1011 : : }
1012 : : else
1013 : : {
1014 : 0 : pEntry->SetAlias(::rtl::OUString());
1015 : 0 : pEntry->SetTable(::rtl::OUString());
1016 : 0 : pEntry->SetTabWindow(NULL);
1017 : : }
1018 [ # # ][ # # ]: 0 : sNewValue = pEntry->GetAlias();
1019 : :
1020 : 0 : } break;
1021 : :
1022 : : case BROW_ORDER_ROW:
1023 : : {
1024 [ # # ][ # # ]: 0 : strOldCellContents = String::CreateFromInt32((sal_uInt16)pEntry->GetOrderDir());
[ # # ]
1025 [ # # ]: 0 : sal_uInt16 nIdx = m_pOrderCell->GetSelectEntryPos();
1026 [ # # ]: 0 : if (nIdx == sal_uInt16(-1))
1027 : 0 : nIdx = 0;
1028 : 0 : pEntry->SetOrderDir(EOrderDir(nIdx));
1029 [ # # ]: 0 : if(!m_bOrderByUnRelated)
1030 : : {
1031 : 0 : pEntry->SetVisible(sal_True);
1032 [ # # ]: 0 : m_pVisibleCell->GetBox().Check();
1033 [ # # ][ # # ]: 0 : RowModified(GetBrowseRow(BROW_VIS_ROW), GetCurColumnId());
1034 : : }
1035 [ # # ][ # # ]: 0 : sNewValue = String::CreateFromInt32((sal_uInt16)pEntry->GetOrderDir());
[ # # ]
1036 : 0 : } break;
1037 : :
1038 : : case BROW_COLUMNALIAS_ROW:
1039 [ # # ]: 0 : strOldCellContents = pEntry->GetFieldAlias();
1040 [ # # ][ # # ]: 0 : pEntry->SetFieldAlias(m_pTextCell->GetText());
[ # # ]
1041 [ # # ]: 0 : sNewValue = pEntry->GetFieldAlias();
1042 : 0 : break;
1043 : : case BROW_FUNCTION_ROW:
1044 : : {
1045 [ # # ]: 0 : strOldCellContents = pEntry->GetFunction();
1046 [ # # ]: 0 : sal_uInt16 nPos = m_pFunctionCell->GetSelectEntryPos();
1047 : : // Diese Funktionen stehen nur unter CORE zur Verf�gung
1048 [ # # ]: 0 : String sFunctionName = m_pFunctionCell->GetEntry(nPos);
1049 [ # # ][ # # ]: 0 : String sGroupFunctionName = m_aFunctionStrings.GetToken(comphelper::string::getTokenCount(m_aFunctionStrings, ';')-1);
[ # # ]
1050 : 0 : sal_Bool bGroupBy = sal_False;
1051 [ # # ][ # # ]: 0 : if ( sGroupFunctionName.Equals(sFunctionName) ) // check if the function name is GROUP
1052 : : {
1053 : 0 : bGroupBy = sal_True;
1054 : :
1055 [ # # ][ # # ]: 0 : if ( !m_bGroupByUnRelated && !pEntry->IsVisible() )
[ # # ]
1056 : : {
1057 : : // we have to change the visblie flag, so we must append also an undo action
1058 : 0 : pEntry->SetVisible(sal_True);
1059 [ # # ]: 0 : m_pVisibleCell->GetBox().Check();
1060 [ # # ][ # # ]: 0 : appendUndoAction(g_strZero,g_strOne,BROW_VIS_ROW,bListAction);
[ # # ][ # # ]
[ # # ]
1061 [ # # ][ # # ]: 0 : RowModified(GetBrowseRow(BROW_VIS_ROW), GetCurColumnId());
1062 : : }
1063 : :
1064 [ # # ][ # # ]: 0 : pEntry->SetFunction(String());
[ # # ]
1065 : 0 : pEntry->SetFunctionType(pEntry->GetFunctionType() & ~FKT_AGGREGATE );
1066 : : }
1067 [ # # ]: 0 : else if ( nPos ) // we found an aggregate function
1068 : : {
1069 : 0 : pEntry->SetFunctionType(pEntry->GetFunctionType() | FKT_AGGREGATE );
1070 [ # # ]: 0 : pEntry->SetFunction(sFunctionName);
1071 : : }
1072 : : else
1073 : : {
1074 [ # # ][ # # ]: 0 : sFunctionName = String();
[ # # ]
1075 [ # # ][ # # ]: 0 : pEntry->SetFunction(String());
[ # # ]
1076 : 0 : pEntry->SetFunctionType(pEntry->GetFunctionType() & ~FKT_AGGREGATE );
1077 : : }
1078 : :
1079 : 0 : pEntry->SetGroupBy(bGroupBy);
1080 : :
1081 [ # # ][ # # ]: 0 : sNewValue = sFunctionName;
[ # # ]
1082 : : }
1083 : 0 : break;
1084 : : default:
1085 : : {
1086 [ # # ][ # # ]: 0 : Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection();
1087 [ # # ]: 0 : if(!xConnection.is())
1088 : : break;
1089 : :
1090 : 0 : sal_uInt16 nIdx = sal_uInt16(nRow - BROW_CRIT1_ROW);
1091 [ # # ][ # # ]: 0 : String aText = comphelper::string::stripStart(m_pTextCell->GetText(), ' ');
[ # # ][ # # ]
[ # # ]
1092 : :
1093 : 0 : ::rtl::OUString aCrit;
1094 [ # # ]: 0 : if(aText.Len())
1095 : : {
1096 : 0 : ::rtl::OUString aErrorMsg;
1097 : 0 : Reference<XPropertySet> xColumn;
1098 [ # # ][ # # ]: 0 : OSQLParseNode* pParseNode = getDesignView()->getPredicateTreeFromEntry(pEntry,aText,aErrorMsg,xColumn);
[ # # ][ # # ]
1099 : :
1100 [ # # ]: 0 : if (pParseNode)
1101 : : {
1102 : : pParseNode->parseNodeToPredicateStr(aCrit,
1103 : : xConnection,
1104 [ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).getNumberFormatter(),
1105 : : xColumn,
1106 : : getDesignView()->getLocale(),
1107 [ # # ]: 0 : static_cast<sal_Char>(getDesignView()->getDecimalSeparator().toChar()),
1108 [ # # ][ # # ]: 0 : &(static_cast<OQueryController&>(getDesignView()->getController()).getParser().getContext()));
[ # # ][ # # ]
1109 [ # # ][ # # ]: 0 : delete pParseNode;
1110 : : }
1111 : : else
1112 : : {
1113 [ # # ]: 0 : if(xColumn.is())
1114 : : {
1115 : 0 : sal_Int32 nType = 0;
1116 [ # # ][ # # ]: 0 : xColumn->getPropertyValue(PROPERTY_TYPE) >>= nType;
[ # # ]
1117 [ # # ]: 0 : switch(nType)
1118 : : {
1119 : : case DataType::CHAR:
1120 : : case DataType::VARCHAR:
1121 : : case DataType::LONGVARCHAR:
1122 : : case DataType::CLOB:
1123 [ # # ][ # # ]: 0 : if(aText.GetChar(0) != '\'' || aText.GetChar(aText.Len() -1) != '\'')
[ # # ]
1124 : : {
1125 [ # # ][ # # ]: 0 : aText.SearchAndReplaceAll(rtl::OUString("'"), rtl::OUString("''"));
[ # # ][ # # ]
[ # # ]
1126 [ # # ]: 0 : String aTmp(rtl::OUString("'"));
1127 [ # # ][ # # ]: 0 : (aTmp += aText) += rtl::OUString("'");
1128 [ # # ][ # # ]: 0 : aText = aTmp;
1129 : : }
1130 : 0 : break;
1131 : : default:
1132 : : ;
1133 : : }
1134 [ # # ]: 0 : ::connectivity::OSQLParser& rParser = static_cast<OQueryController&>(getDesignView()->getController()).getParser();
1135 : : pParseNode = rParser.predicateTree(aErrorMsg,
1136 : : aText,
1137 [ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).getNumberFormatter(),
1138 [ # # ][ # # ]: 0 : xColumn);
[ # # ]
1139 [ # # ]: 0 : if (pParseNode)
1140 : : {
1141 : : pParseNode->parseNodeToPredicateStr(aCrit,
1142 : : xConnection,
1143 [ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).getNumberFormatter(),
1144 : : xColumn,
1145 : : getDesignView()->getLocale(),
1146 [ # # ]: 0 : static_cast<sal_Char>(getDesignView()->getDecimalSeparator().toChar()),
1147 [ # # ][ # # ]: 0 : &(static_cast<OQueryController&>(getDesignView()->getController()).getParser().getContext()));
[ # # ][ # # ]
1148 [ # # ][ # # ]: 0 : delete pParseNode;
1149 : : }
1150 : : else
1151 : : {
1152 [ # # ]: 0 : if ( !m_bDisableErrorBox )
1153 : : {
1154 [ # # ][ # # ]: 0 : OSQLWarningBox( this, aErrorMsg ).Execute();
[ # # ][ # # ]
[ # # ]
1155 : : }
1156 : 0 : bError = sal_True;
1157 : : }
1158 : : }
1159 : : else
1160 : : {
1161 [ # # ]: 0 : if ( !m_bDisableErrorBox )
1162 : : {
1163 [ # # ][ # # ]: 0 : OSQLWarningBox( this, aErrorMsg ).Execute();
[ # # ][ # # ]
[ # # ]
1164 : : }
1165 : 0 : bError = sal_True;
1166 : : }
1167 : 0 : }
1168 : : }
1169 [ # # ][ # # ]: 0 : strOldCellContents = pEntry->GetCriteria(nIdx);
1170 [ # # ]: 0 : pEntry->SetCriteria(nIdx, aCrit);
1171 [ # # ][ # # ]: 0 : sNewValue = pEntry->GetCriteria(nIdx);
1172 [ # # ][ # # ]: 0 : if(!aCrit.isEmpty() && nRow >= (GetRowCount()-1))
[ # # ][ # # ]
1173 [ # # ][ # # ]: 0 : bAppendRow = sal_True;
1174 : : }
1175 : : }
1176 [ # # ][ # # ]: 0 : if(!bError && Controller())
[ # # ][ # # ]
[ # # ]
[ # # # # ]
1177 [ # # ][ # # ]: 0 : Controller()->ClearModified();
[ # # ]
1178 : :
1179 [ # # ]: 0 : RowModified(GetCurRow(), GetCurColumnId());
1180 : :
1181 [ # # ]: 0 : if ( bAppendRow )
1182 : : {
1183 [ # # ][ # # ]: 0 : RowInserted( GetRowCount()-1, 1, sal_True );
1184 [ # # ]: 0 : m_bVisibleRow.push_back(sal_True);
1185 : 0 : ++m_nVisibleCount;
1186 : : }
1187 : :
1188 [ # # ]: 0 : if(!bError)
1189 : : {
1190 : : // und noch die Undo-Action fuer das Ganze
1191 [ # # ]: 0 : appendUndoAction(strOldCellContents,sNewValue,nRow);
1192 : :
1193 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
1194 : : }
1195 : :
1196 : : // habe ich Daten in einer FieldDescription gespeichert, die vorher leer war und es nach den Aenderungen nicht mehr ist ?
1197 [ # # ][ # # ]: 0 : if ( pEntry.is() && bWasEmpty && !pEntry->IsEmpty() && !bError )
[ # # ][ # # ]
[ # # ][ # # ]
1198 : : {
1199 : : // Default auf sichtbar
1200 : 0 : pEntry->SetVisible(sal_True);
1201 [ # # ][ # # ]: 0 : appendUndoAction(g_strZero,g_strOne,BROW_VIS_ROW,bListAction);
[ # # ][ # # ]
[ # # ]
1202 [ # # ]: 0 : RowModified(BROW_VIS_ROW, GetCurColumnId());
1203 : :
1204 : : // wenn noetig neue freie Spalten anlegen
1205 : : sal_uInt16 nDummy;
1206 [ # # ]: 0 : CheckFreeColumns(nDummy);
1207 : : }
1208 : :
1209 [ # # ][ # # ]: 0 : if ( bListAction && !m_bInUndoMode )
1210 [ # # ][ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).GetUndoManager().LeaveListAction();
[ # # ]
1211 : :
1212 [ # # ][ # # ]: 0 : return pEntry != NULL && !bError;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1213 : : }
1214 : :
1215 : : //------------------------------------------------------------------------------
1216 : 0 : sal_Bool OSelectionBrowseBox::SeekRow(long nRow)
1217 : : {
1218 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1219 : 0 : sal_Bool bRet = sal_False;
1220 : :
1221 : 0 : m_nSeekRow = nRow;
1222 [ # # ]: 0 : if (nRow < m_nVisibleCount )
1223 : 0 : bRet = sal_True;
1224 : :
1225 : 0 : return bRet;
1226 : : }
1227 : :
1228 : : //------------------------------------------------------------------------------
1229 : 0 : void OSelectionBrowseBox::PaintCell(OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId) const
1230 : : {
1231 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1232 [ # # ][ # # ]: 0 : rDev.SetClipRegion( rRect );
[ # # ]
1233 : :
1234 [ # # ]: 0 : OTableFieldDescRef pEntry = NULL;
1235 [ # # ]: 0 : sal_uInt16 nPos = GetColumnPos(nColumnId);
1236 [ # # ][ # # ]: 0 : if(getFields().size() > sal_uInt16(nPos - 1))
1237 [ # # ][ # # ]: 0 : pEntry = getFields()[nPos - 1];
1238 : :
1239 [ # # ]: 0 : if (!pEntry.is())
1240 : 0 : return;
1241 : :
1242 [ # # ]: 0 : long nRow = GetRealRow(m_nSeekRow);
1243 [ # # ]: 0 : if (nRow == BROW_VIS_ROW)
1244 [ # # ][ # # ]: 0 : PaintTristate(rDev, rRect, pEntry->IsVisible() ? STATE_CHECK : STATE_NOCHECK);
1245 : : else
1246 [ # # ][ # # ]: 0 : rDev.DrawText(rRect, GetCellText(nRow, nColumnId),TEXT_DRAW_VCENTER);
[ # # ]
1247 : :
1248 [ # # ][ # # ]: 0 : rDev.SetClipRegion( );
[ # # ]
1249 : : }
1250 : :
1251 : : //------------------------------------------------------------------------------
1252 : 0 : void OSelectionBrowseBox::PaintStatusCell(OutputDevice& rDev, const Rectangle& rRect) const
1253 : : {
1254 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1255 : 0 : Rectangle aRect(rRect);
1256 : 0 : aRect.TopLeft().Y() -= 2;
1257 [ # # ][ # # ]: 0 : String aLabel(ModuleRes(STR_QUERY_HANDLETEXT));
1258 : :
1259 : : // ab BROW_CRIT2_ROW werden alle Zeilen mit "oder" angegeben
1260 [ # # ]: 0 : xub_StrLen nToken = (xub_StrLen) (m_nSeekRow >= GetBrowseRow(BROW_CRIT2_ROW))
1261 : : ?
1262 [ # # ][ # # ]: 0 : xub_StrLen(BROW_CRIT2_ROW) : xub_StrLen(GetRealRow(m_nSeekRow));
1263 [ # # ][ # # ]: 0 : rDev.DrawText(aRect, aLabel.GetToken(nToken),TEXT_DRAW_VCENTER);
[ # # ][ # # ]
1264 : 0 : }
1265 : :
1266 : : //------------------------------------------------------------------------------
1267 : 0 : void OSelectionBrowseBox::RemoveColumn(sal_uInt16 _nColumnId)
1268 : : {
1269 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1270 [ # # ]: 0 : OQueryController& rController = static_cast<OQueryController&>(getDesignView()->getController());
1271 : :
1272 [ # # ]: 0 : sal_uInt16 nPos = GetColumnPos(_nColumnId);
1273 : : // das Control sollte immer genau eine Spalte mehr haben, naemlich die HandleColumn
1274 : : OSL_ENSURE((nPos == 0) || (nPos <= getFields().size()), "OSelectionBrowseBox::RemoveColumn : invalid parameter nColId");
1275 : : // ColId ist bei mir gleichbedeutend mit Position, und da sollte die Bedingung natuerlich zutreffen
1276 : :
1277 : 0 : sal_uInt16 nCurCol = GetCurColumnId();
1278 : 0 : long nCurrentRow = GetCurRow();
1279 : :
1280 [ # # ]: 0 : DeactivateCell();
1281 : :
1282 [ # # ][ # # ]: 0 : getFields().erase( getFields().begin() + (nPos - 1) );
[ # # ][ # # ]
1283 [ # # ][ # # ]: 0 : OTableFieldDescRef pEntry = new OTableFieldDesc();
[ # # ]
1284 : 0 : pEntry->SetColumnId(_nColumnId);
1285 [ # # ][ # # ]: 0 : getFields().push_back(pEntry);
1286 : :
1287 [ # # ]: 0 : EditBrowseBox::RemoveColumn( _nColumnId );
1288 [ # # ][ # # ]: 0 : InsertDataColumn( _nColumnId , String(), DEFAULT_SIZE, HIB_STDSTYLE, HEADERBAR_APPEND);
[ # # ][ # # ]
[ # # ][ # # ]
1289 : :
1290 : : // Neuzeichnen
1291 [ # # ]: 0 : Rectangle aInvalidRect = GetInvalidRect( _nColumnId );
1292 [ # # ]: 0 : Invalidate( aInvalidRect );
1293 : :
1294 [ # # ]: 0 : ActivateCell( nCurrentRow, nCurCol );
1295 : :
1296 [ # # ]: 0 : rController.setModified( sal_True );
1297 : :
1298 [ # # ][ # # ]: 0 : invalidateUndoRedo();
1299 : 0 : }
1300 : :
1301 : : //------------------------------------------------------------------------------
1302 : 0 : void OSelectionBrowseBox::RemoveField(sal_uInt16 nColumnId )
1303 : : {
1304 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1305 [ # # ]: 0 : OQueryController& rController = static_cast<OQueryController&>(getDesignView()->getController());
1306 : :
1307 [ # # ]: 0 : sal_uInt16 nPos = GetColumnPos(nColumnId);
1308 : : OSL_ENSURE(getFields().size() > sal_uInt16(nPos-1),"ID is to great!");
1309 : :
1310 [ # # ]: 0 : OTableFieldDescRef pDesc = getEntry((sal_uInt32)(nPos - 1)) ;
1311 [ # # ]: 0 : pDesc->SetColWidth( (sal_uInt16)GetColumnWidth(nColumnId) ); // hat er sich vorher leider nicht gemerkt
1312 : :
1313 : : // UndoAction erzeugen
1314 [ # # ]: 0 : if ( !m_bInUndoMode )
1315 : : {
1316 [ # # ][ # # ]: 0 : OTabFieldDelUndoAct* pUndoAction = new OTabFieldDelUndoAct( this );
1317 [ # # ][ # # ]: 0 : pUndoAction->SetTabFieldDescr(pDesc);
[ # # ]
1318 : 0 : pUndoAction->SetColumnPosition(nPos);
1319 [ # # ]: 0 : rController.addUndoActionAndInvalidate( pUndoAction );
1320 : : }
1321 : :
1322 [ # # ]: 0 : RemoveColumn(nColumnId);
1323 : :
1324 [ # # ][ # # ]: 0 : invalidateUndoRedo();
1325 : 0 : }
1326 : :
1327 : : //------------------------------------------------------------------------------
1328 : 0 : void OSelectionBrowseBox::adjustSelectionMode( sal_Bool _bClickedOntoHeader, sal_Bool _bClickedOntoHandleCol )
1329 : : {
1330 : : // wenn ein Header selectiert wird, mu� die selection angezeigt werden, sonst nicht)
1331 [ # # ]: 0 : if ( _bClickedOntoHeader )
1332 : : {
1333 [ # # ]: 0 : if (0 == GetSelectColumnCount() )
1334 : : // wenn es schon eine selektierte Spalte gibt, bin ich schon im richtigen Modus
1335 [ # # ]: 0 : if ( BROWSER_HIDESELECT == ( m_nMode & BROWSER_HIDESELECT ) )
1336 : : {
1337 : 0 : m_nMode &= ~BROWSER_HIDESELECT;
1338 : 0 : m_nMode |= BROWSER_MULTISELECTION;
1339 : 0 : SetMode( m_nMode );
1340 : : }
1341 : : }
1342 [ # # ]: 0 : else if ( BROWSER_HIDESELECT != ( m_nMode & BROWSER_HIDESELECT ) )
1343 : : {
1344 [ # # ]: 0 : if ( GetSelectColumnCount() != 0 )
1345 : 0 : SetNoSelection();
1346 : :
1347 [ # # ]: 0 : if ( _bClickedOntoHandleCol )
1348 : : {
1349 : 0 : m_nMode |= BROWSER_HIDESELECT;
1350 : 0 : m_nMode &= ~BROWSER_MULTISELECTION;
1351 : 0 : SetMode( m_nMode );
1352 : : }
1353 : : }
1354 : 0 : }
1355 : :
1356 : : //------------------------------------------------------------------------------
1357 : 0 : void OSelectionBrowseBox::MouseButtonDown(const BrowserMouseEvent& rEvt)
1358 : : {
1359 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1360 [ # # ]: 0 : if( rEvt.IsLeft() )
1361 : : {
1362 : 0 : sal_Bool bOnHandle = HANDLE_ID == rEvt.GetColumnId();
1363 [ # # ][ # # ]: 0 : sal_Bool bOnHeader = ( rEvt.GetRow() < 0 ) && !bOnHandle;
1364 : 0 : adjustSelectionMode( bOnHeader, bOnHandle );
1365 : : }
1366 : 0 : EditBrowseBox::MouseButtonDown(rEvt);
1367 : 0 : }
1368 : :
1369 : : //------------------------------------------------------------------------------
1370 : 0 : void OSelectionBrowseBox::MouseButtonUp(const BrowserMouseEvent& rEvt)
1371 : : {
1372 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1373 : 0 : EditBrowseBox::MouseButtonUp( rEvt );
1374 [ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature( ID_BROWSER_QUERY_EXECUTE );
1375 : 0 : }
1376 : :
1377 : : //------------------------------------------------------------------------------
1378 : 0 : void OSelectionBrowseBox::KeyInput( const KeyEvent& rEvt )
1379 : : {
1380 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1381 [ # # ]: 0 : if (IsColumnSelected(GetCurColumnId()))
1382 : : {
1383 [ # # # # : 0 : if (rEvt.GetKeyCode().GetCode() == KEY_DELETE && // Delete rows
# # ][ # # ]
1384 : 0 : !rEvt.GetKeyCode().IsShift() &&
1385 : 0 : !rEvt.GetKeyCode().IsMod1())
1386 : : {
1387 : 0 : RemoveField(GetCurColumnId());
1388 : 0 : return;
1389 : : }
1390 : : }
1391 : 0 : EditBrowseBox::KeyInput(rEvt);
1392 : : }
1393 : :
1394 : :
1395 : : //------------------------------------------------------------------------------
1396 : 0 : sal_Int8 OSelectionBrowseBox::AcceptDrop( const BrowserAcceptDropEvent& rEvt )
1397 : : {
1398 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1399 : 0 : sal_Int8 nDropAction = DND_ACTION_NONE;
1400 [ # # ]: 0 : if ( rEvt.GetRow() >= -1 )
1401 : : {
1402 [ # # ]: 0 : if ( IsEditing() )
1403 : : {
1404 : : // allow the asterix again
1405 : 0 : m_bDisableErrorBox = sal_True;
1406 : 0 : SaveModified();
1407 : 0 : m_bDisableErrorBox = sal_False;
1408 : 0 : DeactivateCell();
1409 : : }
1410 : : // check if the format is already supported, if not deactivate the current cell and try again
1411 [ # # ]: 0 : if ( OJoinExchObj::isFormatAvailable(GetDataFlavors()) )
1412 : 0 : nDropAction = DND_ACTION_LINK;
1413 : : }
1414 : :
1415 : 0 : return nDropAction;
1416 : : }
1417 : :
1418 : : //------------------------------------------------------------------------------
1419 : 0 : sal_Int8 OSelectionBrowseBox::ExecuteDrop( const BrowserExecuteDropEvent& _rEvt )
1420 : : {
1421 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1422 : :
1423 [ # # ]: 0 : TransferableDataHelper aDropped(_rEvt.maDropEvent.Transferable);
1424 [ # # ][ # # ]: 0 : if (!OJoinExchObj::isFormatAvailable(aDropped.GetDataFlavorExVector()))
1425 : : {
1426 : : OSL_FAIL("OSelectionBrowseBox::ExecuteDrop: this should never have passed AcceptDrop!");
1427 : 0 : return DND_ACTION_NONE;
1428 : : }
1429 : :
1430 [ # # ]: 0 : OTableFieldDesc aInfo;
1431 : : // Einfuegen des Feldes an der gewuenschten Position
1432 [ # # ]: 0 : OJoinExchangeData jxdSource = OJoinExchObj::GetSourceDescription(_rEvt.maDropEvent.Transferable);
1433 [ # # ][ # # ]: 0 : InsertField(jxdSource);
1434 : :
1435 [ # # ][ # # ]: 0 : return DND_ACTION_LINK;
1436 : : }
1437 : :
1438 : : //------------------------------------------------------------------------------
1439 : 0 : OTableFieldDescRef OSelectionBrowseBox::AppendNewCol( sal_uInt16 nCnt)
1440 : : {
1441 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1442 : : // es koennen mehrere angelegt werden, aber der Erste
1443 : : // wird returnt
1444 : 0 : sal_uInt32 nCount = getFields().size();
1445 [ # # ]: 0 : for (sal_uInt16 i=0 ; i<nCnt ; i++)
1446 : : {
1447 [ # # ][ # # ]: 0 : OTableFieldDescRef pEmptyEntry = new OTableFieldDesc();
[ # # ]
1448 [ # # ][ # # ]: 0 : getFields().push_back(pEmptyEntry);
1449 [ # # ]: 0 : sal_uInt16 nColumnId = sal::static_int_cast< sal_uInt16 >(getFields().size());
1450 : 0 : pEmptyEntry->SetColumnId( nColumnId );
1451 : :
1452 [ # # ][ # # ]: 0 : InsertDataColumn( nColumnId , String(), DEFAULT_SIZE, HIB_STDSTYLE, HEADERBAR_APPEND);
[ # # ][ # # ]
[ # # ][ # # ]
1453 [ # # ]: 0 : }
1454 : :
1455 : 0 : return getFields()[nCount];
1456 : : }
1457 : :
1458 : : //------------------------------------------------------------------------------
1459 : 0 : void OSelectionBrowseBox::DeleteFields(const String& rAliasName)
1460 : : {
1461 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1462 [ # # ]: 0 : if (!getFields().empty())
1463 : : {
1464 : 0 : sal_uInt16 nColId = GetCurColumnId();
1465 : 0 : sal_uInt32 nRow = GetCurRow();
1466 : :
1467 : 0 : sal_Bool bWasEditing = IsEditing();
1468 [ # # ]: 0 : if (bWasEditing)
1469 [ # # ]: 0 : DeactivateCell();
1470 : :
1471 [ # # ]: 0 : OTableFields::reverse_iterator aIter = getFields().rbegin();
1472 [ # # ]: 0 : OTableFieldDescRef pEntry = NULL;
1473 [ # # ][ # # ]: 0 : for(sal_uInt16 nPos=sal::static_int_cast< sal_uInt16 >(getFields().size());aIter != getFields().rend();++aIter,--nPos)
[ # # ][ # # ]
[ # # ]
1474 : : {
1475 [ # # ][ # # ]: 0 : pEntry = *aIter;
1476 [ # # ][ # # ]: 0 : if ( pEntry->GetAlias().equals( rAliasName ) )
1477 : : {
1478 [ # # ][ # # ]: 0 : RemoveField( GetColumnId( nPos ) );
1479 : 0 : break;
1480 : : }
1481 : : }
1482 : :
1483 [ # # ]: 0 : if (bWasEditing)
1484 [ # # ][ # # ]: 0 : ActivateCell(nRow , nColId);
1485 : : }
1486 : 0 : }
1487 : :
1488 : : //------------------------------------------------------------------------------
1489 : 0 : void OSelectionBrowseBox::SetColWidth(sal_uInt16 nColId, long nNewWidth)
1490 : : {
1491 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1492 : 0 : sal_Bool bWasEditing = IsEditing();
1493 [ # # ]: 0 : if (bWasEditing)
1494 [ # # ]: 0 : DeactivateCell();
1495 : :
1496 : : // die Basisklasse machen lassen
1497 [ # # ]: 0 : SetColumnWidth(nColId, nNewWidth);
1498 : :
1499 : : // der FieldDescription Bescheid sagen
1500 [ # # ][ # # ]: 0 : OTableFieldDescRef pEntry = getEntry(GetColumnPos(nColId) - 1);
1501 [ # # ]: 0 : if (pEntry.is())
1502 [ # # ]: 0 : pEntry->SetColWidth(sal_uInt16(GetColumnWidth(nColId)));
1503 : :
1504 [ # # ]: 0 : if (bWasEditing)
1505 [ # # ][ # # ]: 0 : ActivateCell(GetCurRow(), GetCurColumnId());
1506 : 0 : }
1507 : :
1508 : : //------------------------------------------------------------------------------
1509 : 0 : Rectangle OSelectionBrowseBox::GetInvalidRect( sal_uInt16 nColId )
1510 : : {
1511 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1512 : : //////////////////////////////////////////////////////////////////////
1513 : : // Rechteck ist erst einmal der gesamte Outputbereich des Fensters
1514 [ # # ]: 0 : Rectangle aInvalidRect( Point(0,0), GetOutputSizePixel() );
1515 : :
1516 : : //////////////////////////////////////////////////////////////////////
1517 : : // Dann wird die linke Seite angepasst
1518 [ # # ]: 0 : Rectangle aFieldRect(GetCellRect( 0, nColId )); // used instead of GetFieldRectPixel
1519 : 0 : aInvalidRect.Left() = aFieldRect.Left();
1520 : :
1521 : 0 : return aInvalidRect;
1522 : : }
1523 : :
1524 : : //------------------------------------------------------------------------------
1525 : 0 : void OSelectionBrowseBox::InsertColumn(OTableFieldDescRef pEntry, sal_uInt16& _nColumnPosition)
1526 : : {
1527 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1528 : : // das Control sollte immer genau eine Spalte mehr haben, naemlich die HandleColumn
1529 : : OSL_ENSURE(_nColumnPosition == BROWSER_INVALIDID || (_nColumnPosition <= (long)getFields().size()), "OSelectionBrowseBox::InsertColumn : invalid parameter nColId.");
1530 : : // -1 heisst ganz hinten, Count heisst ganz hinten, der Rest bezeichnet eine richtige Position
1531 : :
1532 : 0 : sal_uInt16 nCurCol = GetCurColumnId();
1533 : 0 : long nCurrentRow = GetCurRow();
1534 : :
1535 [ # # ]: 0 : DeactivateCell();
1536 : :
1537 : : // remember the column id of the current positon
1538 [ # # ]: 0 : sal_uInt16 nColumnId = GetColumnId(_nColumnPosition);
1539 : : // Wenn zu klein oder zu gross, auf Ende der Liste setzen
1540 [ # # ][ # # ]: 0 : if ((_nColumnPosition == BROWSER_INVALIDID) || (_nColumnPosition >= getFields().size())) // Anhaengen des Feldes
[ # # ][ # # ]
1541 : : {
1542 [ # # ][ # # ]: 0 : if (FindFirstFreeCol(_nColumnPosition) == NULL) // keine freie Column mehr
[ # # ]
1543 : : {
1544 [ # # ][ # # ]: 0 : AppendNewCol(1);
1545 : : _nColumnPosition = sal::static_int_cast< sal_uInt16 >(
1546 [ # # ]: 0 : getFields().size());
1547 : : }
1548 : : else
1549 : 0 : ++_nColumnPosition; // innerhalb der vorgegebenen Liste
1550 [ # # ]: 0 : nColumnId = GetColumnId(_nColumnPosition);
1551 : 0 : pEntry->SetColumnId( nColumnId );
1552 [ # # ][ # # ]: 0 : getFields()[ _nColumnPosition - 1] = pEntry;
1553 : : }
1554 : :
1555 : : // check if the column ids are identical, if not we have to move
1556 [ # # ]: 0 : if ( pEntry->GetColumnId() != nColumnId )
1557 : : {
1558 [ # # ]: 0 : sal_uInt16 nOldPosition = GetColumnPos(pEntry->GetColumnId());
1559 : : OSL_ENSURE( nOldPosition != 0,"Old position was 0. Not possible!");
1560 [ # # ]: 0 : SetColumnPos(pEntry->GetColumnId(),_nColumnPosition);
1561 : : // we have to delete an empty field for the fields list, because the columns must have equal length
1562 [ # # ][ # # ]: 0 : if ( nOldPosition > 0 && nOldPosition <= getFields().size() )
[ # # ][ # # ]
1563 [ # # ][ # # ]: 0 : getFields()[nOldPosition - 1] = pEntry;
1564 : :
1565 [ # # ]: 0 : ColumnMoved(pEntry->GetColumnId(),sal_False);
1566 : : }
1567 : :
1568 [ # # ]: 0 : if ( pEntry->GetFunctionType() & (FKT_AGGREGATE) )
1569 : : {
1570 [ # # ]: 0 : String sFunctionName = pEntry->GetFunction();
1571 [ # # ][ # # ]: 0 : if ( GetFunctionName(sal_uInt32(-1),sFunctionName) )
1572 [ # # ][ # # ]: 0 : pEntry->SetFunction(sFunctionName);
1573 : : }
1574 : :
1575 : 0 : nColumnId = pEntry->GetColumnId();
1576 : :
1577 [ # # ][ # # ]: 0 : SetColWidth(nColumnId,getDesignView()->getColWidth(GetColumnPos(nColumnId)-1));
[ # # ][ # # ]
1578 : : // Neuzeichnen
1579 [ # # ]: 0 : Rectangle aInvalidRect = GetInvalidRect( nColumnId );
1580 [ # # ]: 0 : Invalidate( aInvalidRect );
1581 : :
1582 [ # # ]: 0 : ActivateCell( nCurrentRow, nCurCol );
1583 [ # # ][ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).setModified( sal_True );
1584 : :
1585 [ # # ]: 0 : invalidateUndoRedo();
1586 : 0 : }
1587 : :
1588 : : //------------------------------------------------------------------------------
1589 : 0 : OTableFieldDescRef OSelectionBrowseBox::InsertField(const OJoinExchangeData& jxdSource, sal_uInt16 _nColumnPosition, sal_Bool bVis, sal_Bool bActivate)
1590 : : {
1591 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1592 : 0 : OQueryTableWindow* pSourceWin = static_cast<OQueryTableWindow*>(jxdSource.pListBox->GetTabWin());
1593 [ # # ]: 0 : if (!pSourceWin)
1594 [ # # ]: 0 : return NULL;
1595 : :
1596 : : // Namen/Position des selektierten Feldes
1597 [ # # ]: 0 : String aFieldName = jxdSource.pListBox->GetEntryText(jxdSource.pEntry);
1598 [ # # ]: 0 : sal_uInt32 nFieldIndex = jxdSource.pListBox->GetModel()->GetAbsPos(jxdSource.pEntry);
1599 : 0 : OTableFieldInfo* pInf = static_cast<OTableFieldInfo*>(jxdSource.pEntry->GetUserData());
1600 : :
1601 : : // eine DragInfo aufbauen, damit ich mich auf das andere InsertField zurueckziehen kann
1602 [ # # ][ # # ]: 0 : OTableFieldDescRef aInfo = new OTableFieldDesc(pSourceWin->GetTableName(),aFieldName);
[ # # ][ # # ]
[ # # ]
1603 [ # # ]: 0 : aInfo->SetTabWindow(pSourceWin);
1604 : 0 : aInfo->SetFieldIndex(nFieldIndex);
1605 : 0 : aInfo->SetFieldType(pInf->GetKeyType());
1606 [ # # ]: 0 : aInfo->SetAlias(pSourceWin->GetAliasName());
1607 : :
1608 : 0 : aInfo->SetDataType(pInf->GetDataType());
1609 : 0 : aInfo->SetVisible(bVis);
1610 : :
1611 [ # # ][ # # ]: 0 : return InsertField(aInfo, _nColumnPosition, bVis, bActivate);
[ # # ]
1612 : : }
1613 : :
1614 : : //------------------------------------------------------------------------------
1615 : 0 : OTableFieldDescRef OSelectionBrowseBox::InsertField(const OTableFieldDescRef& _rInfo, sal_uInt16 _nColumnPosition, sal_Bool bVis, sal_Bool bActivate)
1616 : : {
1617 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1618 : :
1619 [ # # ][ # # ]: 0 : if(m_nMaxColumns && m_nMaxColumns <= FieldsCount())
[ # # ][ # # ]
1620 [ # # ]: 0 : return NULL;
1621 [ # # ]: 0 : if (bActivate)
1622 [ # # ]: 0 : SaveModified();
1623 : :
1624 : : // Neue Spaltenbeschreibung
1625 [ # # ]: 0 : OTableFieldDescRef pEntry = _rInfo;
1626 : 0 : pEntry->SetVisible(bVis);
1627 : :
1628 : : // Spalte einfuegen
1629 [ # # ][ # # ]: 0 : InsertColumn( pEntry, _nColumnPosition );
[ # # ]
1630 : :
1631 [ # # ]: 0 : if ( !m_bInUndoMode )
1632 : : {
1633 : : // UndoAction erzeugen
1634 [ # # ][ # # ]: 0 : OTabFieldCreateUndoAct* pUndoAction = new OTabFieldCreateUndoAct( this );
1635 [ # # ][ # # ]: 0 : pUndoAction->SetTabFieldDescr( pEntry );
[ # # ]
1636 : 0 : pUndoAction->SetColumnPosition(_nColumnPosition);
1637 [ # # ][ # # ]: 0 : getDesignView()->getController().addUndoActionAndInvalidate( pUndoAction );
1638 : : }
1639 : :
1640 [ # # ][ # # ]: 0 : return pEntry;
1641 : : }
1642 : :
1643 : : //------------------------------------------------------------------------------
1644 : 0 : sal_uInt16 OSelectionBrowseBox::FieldsCount()
1645 : : {
1646 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1647 [ # # ]: 0 : OTableFields::iterator aIter = getFields().begin();
1648 : 0 : sal_uInt16 nCount = 0;
1649 : :
1650 [ # # ][ # # ]: 0 : while (aIter != getFields().end())
[ # # ]
1651 : : {
1652 [ # # ][ # # ]: 0 : if ((*aIter).is() && !(*aIter)->IsEmpty())
[ # # ][ # # ]
1653 : 0 : ++nCount;
1654 : 0 : ++aIter;
1655 : : }
1656 : :
1657 : 0 : return nCount;
1658 : : }
1659 : :
1660 : : //------------------------------------------------------------------------------
1661 : 0 : OTableFieldDescRef OSelectionBrowseBox::FindFirstFreeCol(sal_uInt16& _rColumnPosition )
1662 : : {
1663 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1664 [ # # ]: 0 : OTableFields::iterator aIter = getFields().begin();
1665 [ # # ]: 0 : OTableFields::iterator aEnd = getFields().end();
1666 : :
1667 : 0 : _rColumnPosition = BROWSER_INVALIDID;
1668 : :
1669 [ # # ][ # # ]: 0 : while ( aIter != aEnd )
1670 : : {
1671 : 0 : ++_rColumnPosition;
1672 [ # # ]: 0 : OTableFieldDescRef pEntry = (*aIter);
1673 [ # # ][ # # ]: 0 : if ( pEntry.is() && pEntry->IsEmpty() )
[ # # ][ # # ]
1674 [ # # ]: 0 : return pEntry;
1675 [ # # ]: 0 : ++aIter;
1676 [ # # ]: 0 : }
1677 : :
1678 [ # # ]: 0 : return NULL;
1679 : : }
1680 : :
1681 : : //------------------------------------------------------------------------------
1682 : 0 : void OSelectionBrowseBox::CheckFreeColumns(sal_uInt16& _rColumnPosition)
1683 : : {
1684 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1685 [ # # ]: 0 : if (FindFirstFreeCol(_rColumnPosition) == NULL)
1686 : : {
1687 : : // es ist voll, also einen Packen Spalten anhaengen
1688 : 0 : AppendNewCol(DEFAULT_QUERY_COLS);
1689 : 0 : OSL_VERIFY(FindFirstFreeCol(_rColumnPosition).is());
1690 : : }
1691 : 0 : }
1692 : : //------------------------------------------------------------------------------
1693 : 0 : void OSelectionBrowseBox::AddGroupBy( const OTableFieldDescRef& rInfo , sal_uInt32 /*_nCurrentPos*/)
1694 : : {
1695 [ # # ][ # # ]: 0 : Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection();
1696 [ # # ]: 0 : if(!xConnection.is())
1697 : 0 : return;
1698 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1699 : : OSL_ENSURE(!rInfo->IsEmpty(),"AddGroupBy:: OTableFieldDescRef sollte nicht Empty sein!");
1700 : 0 : OTableFieldDescRef pEntry;
1701 [ # # ][ # # ]: 0 : const Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
1702 [ # # ][ # # ]: 0 : const ::comphelper::UStringMixEqual bCase(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers());
[ # # ][ # # ]
1703 : : //sal_Bool bAppend = sal_False;
1704 : :
1705 [ # # ]: 0 : OTableFields& rFields = getFields();
1706 : 0 : OTableFields::iterator aIter = rFields.begin();
1707 : 0 : OTableFields::iterator aEnd = rFields.end();
1708 [ # # ][ # # ]: 0 : for(;aIter != aEnd;++aIter)
1709 : : {
1710 [ # # ]: 0 : pEntry = *aIter;
1711 : : OSL_ENSURE(pEntry.is(),"OTableFieldDescRef was null!");
1712 : :
1713 : 0 : const ::rtl::OUString aField = pEntry->GetField();
1714 : 0 : const ::rtl::OUString aAlias = pEntry->GetAlias();
1715 : :
1716 [ # # ][ # # ]: 0 : if (bCase(aField,rInfo->GetField()) &&
[ # # # #
# # # # ]
1717 [ # # ]: 0 : bCase(aAlias,rInfo->GetAlias()) &&
1718 : 0 : pEntry->GetFunctionType() == rInfo->GetFunctionType() &&
1719 [ # # ][ # # ]: 0 : pEntry->GetFunction() == rInfo->GetFunction())
1720 : : {
1721 [ # # ][ # # ]: 0 : if ( pEntry->isNumericOrAggreateFunction() && rInfo->IsGroupBy() )
[ # # ]
1722 : : {
1723 : 0 : pEntry->SetGroupBy(sal_False);
1724 : 0 : aIter = rFields.end();
1725 : : break;
1726 : : }
1727 : : else
1728 : : {
1729 [ # # ][ # # ]: 0 : if ( !pEntry->IsGroupBy() && !pEntry->HasCriteria() ) // here we have a where condition which is no having clause
[ # # ][ # # ]
1730 : : {
1731 : 0 : pEntry->SetGroupBy(rInfo->IsGroupBy());
1732 [ # # ][ # # ]: 0 : if(!m_bGroupByUnRelated && pEntry->IsGroupBy())
[ # # ]
1733 : 0 : pEntry->SetVisible(sal_True);
1734 : : break;
1735 : : }
1736 : : }
1737 : :
1738 : : }
1739 [ # # ][ # # ]: 0 : }
1740 : :
1741 [ # # ][ # # ]: 0 : if (aIter == rFields.end())
1742 : : {
1743 [ # # ]: 0 : OTableFieldDescRef pTmp = InsertField(rInfo, BROWSER_INVALIDID, sal_False, sal_False );
1744 [ # # ][ # # ]: 0 : if ( (pTmp->isNumericOrAggreateFunction() && rInfo->IsGroupBy()) ) // das GroupBy wird bereits von rInfo "ubernommen
[ # # ]
1745 [ # # ]: 0 : pTmp->SetGroupBy(sal_False);
1746 [ # # ][ # # ]: 0 : }
1747 : : }
1748 : : //------------------------------------------------------------------------------
1749 : 0 : void OSelectionBrowseBox::DuplicateConditionLevel( const sal_uInt16 nLevel)
1750 : : {
1751 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1752 : 0 : const sal_uInt16 nNewLevel = nLevel +1;
1753 [ # # ]: 0 : OTableFields& rFields = getFields();
1754 : 0 : OTableFields::iterator aIter = rFields.begin();
1755 : 0 : OTableFields::iterator aEnd = rFields.end();
1756 [ # # ][ # # ]: 0 : for(;aIter != aEnd;++aIter)
1757 : : {
1758 [ # # ]: 0 : OTableFieldDescRef pEntry = *aIter;
1759 : :
1760 [ # # ]: 0 : ::rtl::OUString sValue = pEntry->GetCriteria(nLevel);
1761 [ # # ]: 0 : if ( !sValue.isEmpty() )
1762 : : {
1763 [ # # ]: 0 : pEntry->SetCriteria( nNewLevel, sValue);
1764 [ # # ]: 0 : if ( nNewLevel == (m_nVisibleCount-BROW_CRIT1_ROW-1) )
1765 : : {
1766 [ # # ][ # # ]: 0 : RowInserted( GetRowCount()-1, 1, sal_True );
1767 [ # # ]: 0 : m_bVisibleRow.push_back(sal_True);
1768 : 0 : ++m_nVisibleCount;
1769 : : }
1770 [ # # ]: 0 : m_bVisibleRow[BROW_CRIT1_ROW + nNewLevel] = sal_True;
1771 : : }
1772 [ # # ]: 0 : }
1773 : 0 : }
1774 : : //------------------------------------------------------------------------------
1775 : 0 : void OSelectionBrowseBox::AddCondition( const OTableFieldDescRef& rInfo, const String& rValue, const sal_uInt16 nLevel,bool _bAddOrOnOneLine )
1776 : : {
1777 [ # # ][ # # ]: 0 : Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection();
1778 [ # # ]: 0 : if(!xConnection.is())
1779 : 0 : return;
1780 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1781 : : OSL_ENSURE(rInfo.is() && !rInfo->IsEmpty(),"AddCondition:: OTableFieldDescRef sollte nicht Empty sein!");
1782 : :
1783 : 0 : OTableFieldDescRef pLastEntry;
1784 [ # # ][ # # ]: 0 : Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
1785 [ # # ][ # # ]: 0 : ::comphelper::UStringMixEqual bCase(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers());
[ # # ][ # # ]
1786 : :
1787 [ # # ]: 0 : OTableFields& rFields = getFields();
1788 : 0 : OTableFields::iterator aIter = rFields.begin();
1789 : 0 : OTableFields::iterator aEnd = rFields.end();
1790 [ # # ][ # # ]: 0 : for(;aIter != aEnd;++aIter)
1791 : : {
1792 [ # # ]: 0 : OTableFieldDescRef pEntry = *aIter;
1793 : 0 : const ::rtl::OUString aField = pEntry->GetField();
1794 : 0 : const ::rtl::OUString aAlias = pEntry->GetAlias();
1795 : :
1796 [ # # ][ # # ]: 0 : if (bCase(aField,rInfo->GetField()) &&
[ # # # #
# # # # #
# ]
1797 [ # # ]: 0 : bCase(aAlias,rInfo->GetAlias()) &&
1798 : 0 : pEntry->GetFunctionType() == rInfo->GetFunctionType() &&
1799 [ # # ][ # # ]: 0 : pEntry->GetFunction() == rInfo->GetFunction() &&
1800 : 0 : pEntry->IsGroupBy() == rInfo->IsGroupBy() )
1801 : : {
1802 [ # # ][ # # ]: 0 : if ( pEntry->isNumericOrAggreateFunction() && rInfo->IsGroupBy() )
[ # # ]
1803 : 0 : pEntry->SetGroupBy(sal_False);
1804 : : else
1805 : : {
1806 [ # # ][ # # ]: 0 : if(!m_bGroupByUnRelated && pEntry->IsGroupBy())
[ # # ]
1807 : 0 : pEntry->SetVisible(sal_True);
1808 : : }
1809 [ # # ][ # # ]: 0 : if (pEntry->GetCriteria(nLevel).isEmpty() )
1810 : : {
1811 [ # # ][ # # ]: 0 : pEntry->SetCriteria( nLevel, rValue);
1812 [ # # ]: 0 : if(nLevel == (m_nVisibleCount-BROW_CRIT1_ROW-1))
1813 : : {
1814 [ # # ][ # # ]: 0 : RowInserted( GetRowCount()-1, 1, sal_True );
1815 [ # # ]: 0 : m_bVisibleRow.push_back(sal_True);
1816 : 0 : ++m_nVisibleCount;
1817 : : }
1818 [ # # ]: 0 : m_bVisibleRow[BROW_CRIT1_ROW + nLevel] = sal_True;
1819 : : break;
1820 : : }
1821 [ # # ]: 0 : if ( _bAddOrOnOneLine )
1822 : : {
1823 [ # # ]: 0 : pLastEntry = pEntry;
1824 : : }
1825 : : }
1826 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
1827 [ # # ]: 0 : if ( pLastEntry.is() )
1828 : : {
1829 [ # # ]: 0 : String sCriteria = rValue;
1830 [ # # ][ # # ]: 0 : String sOldCriteria = pLastEntry->GetCriteria( nLevel );
1831 [ # # ]: 0 : if ( sOldCriteria.Len() )
1832 : : {
1833 [ # # ][ # # ]: 0 : sCriteria = String(RTL_CONSTASCII_USTRINGPARAM("( "));
[ # # ]
1834 [ # # ]: 0 : sCriteria += sOldCriteria;
1835 [ # # ][ # # ]: 0 : sCriteria += String(RTL_CONSTASCII_USTRINGPARAM(" OR "));
[ # # ]
1836 [ # # ]: 0 : sCriteria += rValue;
1837 [ # # ][ # # ]: 0 : sCriteria += String(RTL_CONSTASCII_USTRINGPARAM(" )"));
[ # # ]
1838 : : }
1839 [ # # ][ # # ]: 0 : pLastEntry->SetCriteria( nLevel, sCriteria);
1840 [ # # ]: 0 : if(nLevel == (m_nVisibleCount-BROW_CRIT1_ROW-1))
1841 : : {
1842 [ # # ][ # # ]: 0 : RowInserted( GetRowCount()-1, 1, sal_True );
1843 [ # # ]: 0 : m_bVisibleRow.push_back(sal_True);
1844 : 0 : ++m_nVisibleCount;
1845 : : }
1846 [ # # ][ # # ]: 0 : m_bVisibleRow[BROW_CRIT1_ROW + nLevel] = sal_True;
[ # # ]
1847 : : }
1848 : :
1849 [ # # ][ # # ]: 0 : else if (aIter == getFields().end())
[ # # ]
1850 : : {
1851 [ # # ]: 0 : OTableFieldDescRef pTmp = InsertField(rInfo, BROWSER_INVALIDID, sal_False, sal_False );
1852 [ # # ][ # # ]: 0 : if ( pTmp->isNumericOrAggreateFunction() && rInfo->IsGroupBy() ) // das GroupBy wird bereits von rInfo "ubernommen
[ # # ]
1853 : 0 : pTmp->SetGroupBy(sal_False);
1854 [ # # ]: 0 : if ( pTmp.is() )
1855 : : {
1856 [ # # ][ # # ]: 0 : pTmp->SetCriteria( nLevel, rValue);
1857 [ # # ]: 0 : if(nLevel == (m_nVisibleCount-BROW_CRIT1_ROW-1))
1858 : : {
1859 [ # # ][ # # ]: 0 : RowInserted( GetRowCount()-1, 1, sal_True );
1860 [ # # ]: 0 : m_bVisibleRow.push_back(sal_True);
1861 : 0 : ++m_nVisibleCount;
1862 : : }
1863 [ # # ]: 0 : }
1864 [ # # ][ # # ]: 0 : }
1865 : : }
1866 : :
1867 : : //------------------------------------------------------------------------------
1868 : 0 : void OSelectionBrowseBox::AddOrder( const OTableFieldDescRef& rInfo, const EOrderDir eDir, sal_uInt32 _nCurrentPos)
1869 : : {
1870 [ # # ]: 0 : if (_nCurrentPos == 0)
1871 : 0 : m_nLastSortColumn = SORT_COLUMN_NONE;
1872 : :
1873 [ # # ][ # # ]: 0 : Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection();
1874 [ # # ]: 0 : if(!xConnection.is())
1875 : 0 : return;
1876 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1877 : : OSL_ENSURE(!rInfo->IsEmpty(),"AddOrder:: OTableFieldDescRef should not be Empty!");
1878 : 0 : OTableFieldDescRef pEntry;
1879 [ # # ][ # # ]: 0 : Reference<XDatabaseMetaData> xMeta = xConnection->getMetaData();
1880 [ # # ][ # # ]: 0 : ::comphelper::UStringMixEqual bCase(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers());
[ # # ][ # # ]
1881 : :
1882 : 0 : sal_Bool bAppend = sal_False;
1883 [ # # ]: 0 : OTableFields& rFields = getFields();
1884 : 0 : OTableFields::iterator aIter = rFields.begin();
1885 : 0 : OTableFields::iterator aEnd = rFields.end();
1886 [ # # ][ # # ]: 0 : for(;aIter != aEnd;++aIter)
1887 : : {
1888 [ # # ]: 0 : pEntry = *aIter;
1889 : 0 : ::rtl::OUString aField = pEntry->GetField();
1890 : 0 : ::rtl::OUString aAlias = pEntry->GetAlias();
1891 : :
1892 [ # # ][ # # ]: 0 : if (bCase(aField,rInfo->GetField()) &&
[ # # # # ]
1893 [ # # ]: 0 : bCase(aAlias,rInfo->GetAlias()))
1894 : : {
1895 [ # # ]: 0 : sal_uInt32 nPos = aIter - rFields.begin();
1896 [ # # ][ # # ]: 0 : bAppend = (m_nLastSortColumn != SORT_COLUMN_NONE) && (nPos <= m_nLastSortColumn);
1897 [ # # ]: 0 : if ( bAppend )
1898 : 0 : aIter = rFields.end();
1899 : : else
1900 : : {
1901 [ # # ]: 0 : if ( !m_bOrderByUnRelated )
1902 : 0 : pEntry->SetVisible(sal_True);
1903 : 0 : pEntry->SetOrderDir( eDir );
1904 : 0 : m_nLastSortColumn = nPos;
1905 : : }
1906 : : break;
1907 : : }
1908 [ # # ][ # # ]: 0 : }
1909 : :
1910 [ # # ][ # # ]: 0 : if (aIter == rFields.end())
1911 : : {
1912 [ # # ]: 0 : OTableFieldDescRef pTmp = InsertField(rInfo, BROWSER_INVALIDID, sal_False, sal_False );
1913 [ # # ]: 0 : if(pTmp.is())
1914 : : {
1915 : 0 : m_nLastSortColumn = pTmp->GetColumnId() - 1;
1916 [ # # ][ # # ]: 0 : if ( !m_bOrderByUnRelated && !bAppend )
1917 : 0 : pTmp->SetVisible(sal_True);
1918 : 0 : pTmp->SetOrderDir( eDir );
1919 [ # # ]: 0 : }
1920 [ # # ][ # # ]: 0 : }
1921 : : }
1922 : :
1923 : : //------------------------------------------------------------------------------
1924 : 0 : void OSelectionBrowseBox::ArrangeControls(sal_uInt16& nX, sal_uInt16 nY)
1925 : : {
1926 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1927 : 0 : EditBrowseBox::ArrangeControls(nX, nY);
1928 : 0 : }
1929 : :
1930 : : //------------------------------------------------------------------------------
1931 : 0 : sal_Bool OSelectionBrowseBox::Save()
1932 : : {
1933 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1934 : 0 : sal_Bool bRet = sal_True;
1935 [ # # ]: 0 : if (IsModified())
1936 : 0 : bRet = SaveModified();
1937 : 0 : return bRet;
1938 : : }
1939 : :
1940 : : //------------------------------------------------------------------------------
1941 : 0 : void OSelectionBrowseBox::CellModified()
1942 : : {
1943 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1944 : 0 : long nRow = GetRealRow(GetCurRow());
1945 [ # # ]: 0 : switch (nRow)
1946 : : {
1947 : : case BROW_VIS_ROW:
1948 : : {
1949 [ # # ][ # # ]: 0 : OTableFieldDescRef pEntry = getEntry(GetColumnPos(GetCurColumnId()) - 1);
1950 : :
1951 [ # # ]: 0 : sal_uInt16 nIdx = m_pOrderCell->GetSelectEntryPos();
1952 [ # # ][ # # ]: 0 : if(!m_bOrderByUnRelated && nIdx > 0 &&
[ # # ]
[ # # # # ]
[ # # ]
1953 : : nIdx != sal_uInt16(-1) &&
1954 [ # # ]: 0 : !pEntry->IsEmpty() &&
1955 : 0 : pEntry->GetOrderDir() != ORDER_NONE)
1956 : : {
1957 [ # # ]: 0 : m_pVisibleCell->GetBox().Check();
1958 : 0 : pEntry->SetVisible(sal_True);
1959 : : }
1960 : : else
1961 [ # # ][ # # ]: 0 : pEntry->SetVisible(m_pVisibleCell->GetBox().IsChecked());
1962 : : }
1963 : 0 : break;
1964 : : }
1965 : 0 : static_cast<OQueryController&>(getDesignView()->getController()).setModified( sal_True );
1966 : 0 : }
1967 : :
1968 : : //------------------------------------------------------------------------------
1969 : 0 : void OSelectionBrowseBox::Fill()
1970 : : {
1971 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1972 : : OSL_ENSURE(ColCount() >= 1, "OSelectionBrowseBox::Fill : please call only after inserting the handle column !");
1973 : :
1974 : 0 : sal_uInt16 nColCount = ColCount() - 1;
1975 [ # # ]: 0 : if (nColCount < DEFAULT_QUERY_COLS)
1976 : 0 : AppendNewCol(DEFAULT_QUERY_COLS - nColCount);
1977 : 0 : }
1978 : :
1979 : : //------------------------------------------------------------------------------
1980 : 0 : Size OSelectionBrowseBox::CalcOptimalSize( const Size& _rAvailable )
1981 : : {
1982 : 0 : Size aReturn( _rAvailable.Width(), GetTitleHeight() );
1983 : :
1984 [ # # ]: 0 : aReturn.Height() += ( m_nVisibleCount ? m_nVisibleCount : 15 ) * GetDataRowHeight();
1985 : 0 : aReturn.Height() += 40; // just some space
1986 : :
1987 : 0 : return aReturn;
1988 : : }
1989 : :
1990 : : //------------------------------------------------------------------------------
1991 : 0 : void OSelectionBrowseBox::Command(const CommandEvent& rEvt)
1992 : : {
1993 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
1994 [ # # ]: 0 : switch (rEvt.GetCommand())
1995 : : {
1996 : : case COMMAND_CONTEXTMENU:
1997 : : {
1998 : 0 : Point aMenuPos( rEvt.GetMousePosPixel() );
1999 : :
2000 [ # # ]: 0 : if (!rEvt.IsMouseEvent())
2001 : : {
2002 [ # # ][ # # ]: 0 : if ( 1 == GetSelectColumnCount() )
2003 : : {
2004 : : sal_uInt16 nSelId = GetColumnId(
2005 : : sal::static_int_cast< sal_uInt16 >(
2006 [ # # ][ # # ]: 0 : FirstSelectedColumn() ) );
2007 [ # # ]: 0 : ::Rectangle aColRect( GetFieldRectPixel( 0, nSelId, sal_False ) );
2008 : :
2009 [ # # ]: 0 : aMenuPos = aColRect.TopCenter();
2010 : : }
2011 : : else
2012 : : {
2013 [ # # ]: 0 : EditBrowseBox::Command(rEvt);
2014 : : return;
2015 : : }
2016 : : }
2017 : :
2018 [ # # ][ # # ]: 0 : sal_uInt16 nColId = GetColumnId(GetColumnAtXPosPixel( aMenuPos.X() ));
2019 [ # # ]: 0 : long nRow = GetRowAtYPosPixel( aMenuPos.Y() );
2020 : :
2021 [ # # ][ # # ]: 0 : if (nRow < 0 && nColId > HANDLE_ID )
2022 : : {
2023 [ # # ][ # # ]: 0 : if ( !IsColumnSelected( nColId ) )
2024 : : {
2025 [ # # ]: 0 : adjustSelectionMode( sal_True /* clicked onto a header */ , sal_False /* not onto the handle col */ );
2026 [ # # ]: 0 : SelectColumnId( nColId );
2027 : : }
2028 : :
2029 [ # # ][ # # ]: 0 : if (!static_cast<OQueryController&>(getDesignView()->getController()).isReadOnly())
[ # # ]
2030 : : {
2031 [ # # ][ # # ]: 0 : PopupMenu aContextMenu( ModuleRes( RID_QUERYCOLPOPUPMENU ) );
2032 [ # # ]: 0 : switch (aContextMenu.Execute(this, aMenuPos))
[ # # # ]
2033 : : {
2034 : : case SID_DELETE:
2035 [ # # ]: 0 : RemoveField(nColId);
2036 : 0 : break;
2037 : :
2038 : : case ID_BROWSER_COLWIDTH:
2039 [ # # ]: 0 : adjustBrowseBoxColumnWidth( this, nColId );
2040 : 0 : break;
2041 [ # # ]: 0 : }
2042 : 0 : }
2043 : : }
2044 [ # # ][ # # ]: 0 : else if(nRow >= 0 && nColId <= HANDLE_ID)
2045 : : {
2046 [ # # ][ # # ]: 0 : if (!static_cast<OQueryController&>(getDesignView()->getController()).isReadOnly())
[ # # ]
2047 : : {
2048 [ # # ][ # # ]: 0 : PopupMenu aContextMenu(ModuleRes(RID_QUERYFUNCTION_POPUPMENU));
2049 [ # # ][ # # ]: 0 : aContextMenu.CheckItem( ID_QUERY_FUNCTION, m_bVisibleRow[BROW_FUNCTION_ROW]);
2050 [ # # ][ # # ]: 0 : aContextMenu.CheckItem( ID_QUERY_TABLENAME, m_bVisibleRow[BROW_TABLE_ROW]);
2051 [ # # ][ # # ]: 0 : aContextMenu.CheckItem( ID_QUERY_ALIASNAME, m_bVisibleRow[BROW_COLUMNALIAS_ROW]);
2052 [ # # ][ # # ]: 0 : aContextMenu.CheckItem( ID_QUERY_DISTINCT, static_cast<OQueryController&>(getDesignView()->getController()).isDistinct());
2053 : :
2054 [ # # ][ # # : 0 : switch (aContextMenu.Execute(this, aMenuPos))
# # # ]
2055 : : {
2056 : : case ID_QUERY_FUNCTION:
2057 [ # # ][ # # ]: 0 : SetRowVisible(BROW_FUNCTION_ROW, !IsRowVisible(BROW_FUNCTION_ROW));
2058 [ # # ][ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature( SID_QUERY_VIEW_FUNCTIONS );
[ # # ]
2059 : 0 : break;
2060 : : case ID_QUERY_TABLENAME:
2061 [ # # ][ # # ]: 0 : SetRowVisible(BROW_TABLE_ROW, !IsRowVisible(BROW_TABLE_ROW));
2062 [ # # ][ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature( SID_QUERY_VIEW_TABLES );
[ # # ]
2063 : 0 : break;
2064 : : case ID_QUERY_ALIASNAME:
2065 [ # # ][ # # ]: 0 : SetRowVisible(BROW_COLUMNALIAS_ROW, !IsRowVisible(BROW_COLUMNALIAS_ROW));
2066 [ # # ][ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature( SID_QUERY_VIEW_ALIASES );
[ # # ]
2067 : 0 : break;
2068 : : case ID_QUERY_DISTINCT:
2069 [ # # ][ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).setDistinct(!static_cast<OQueryController&>(getDesignView()->getController()).isDistinct());
2070 [ # # ][ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).setModified( sal_True );
2071 [ # # ][ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature( SID_QUERY_DISTINCT_VALUES );
[ # # ]
2072 : 0 : break;
2073 : : }
2074 : :
2075 [ # # ][ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).setModified( sal_True );
[ # # ]
2076 : 0 : }
2077 : : }
2078 : : else
2079 : : {
2080 [ # # ]: 0 : EditBrowseBox::Command(rEvt);
2081 : : return;
2082 : : }
2083 : : }
2084 : : default:
2085 : 0 : EditBrowseBox::Command(rEvt);
2086 : : }
2087 : : }
2088 : :
2089 : : //------------------------------------------------------------------------------
2090 : 0 : sal_Bool OSelectionBrowseBox::IsRowVisible(sal_uInt16 _nWhich) const
2091 : : {
2092 : : OSL_ENSURE(_nWhich<(m_bVisibleRow.size()), "OSelectionBrowseBox::IsRowVisible : invalid parameter !");
2093 : 0 : return m_bVisibleRow[_nWhich];
2094 : : }
2095 : :
2096 : : //------------------------------------------------------------------------------
2097 : 0 : void OSelectionBrowseBox::SetRowVisible(sal_uInt16 _nWhich, sal_Bool _bVis)
2098 : : {
2099 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
2100 : : OSL_ENSURE(_nWhich<m_bVisibleRow.size(), "OSelectionBrowseBox::SetRowVisible : invalid parameter !");
2101 : :
2102 : 0 : sal_Bool bWasEditing = IsEditing();
2103 [ # # ]: 0 : if (bWasEditing)
2104 : 0 : DeactivateCell();
2105 : :
2106 : : // do this before removing or inserting rows, as this triggers ActivateCell-calls, which rely on m_bVisibleRow
2107 [ # # ]: 0 : m_bVisibleRow[_nWhich] = !m_bVisibleRow[_nWhich];
2108 : :
2109 : 0 : long nId = GetBrowseRow(_nWhich);
2110 [ # # ]: 0 : if (_bVis)
2111 : : {
2112 : 0 : RowInserted(nId,1);
2113 : 0 : ++m_nVisibleCount;
2114 : : }
2115 : : else
2116 : : {
2117 : 0 : RowRemoved(nId,1);
2118 : 0 : --m_nVisibleCount;
2119 : : }
2120 : :
2121 [ # # ]: 0 : if (bWasEditing)
2122 : 0 : ActivateCell();
2123 : 0 : }
2124 : :
2125 : : //------------------------------------------------------------------------------
2126 : 0 : long OSelectionBrowseBox::GetBrowseRow(long nRowId) const
2127 : : {
2128 : 0 : sal_uInt16 nCount(0);
2129 [ # # ]: 0 : for(sal_uInt16 i = 0 ; i < nRowId ; ++i)
2130 : : {
2131 [ # # ]: 0 : if ( m_bVisibleRow[i] )
2132 : 0 : ++nCount;
2133 : : }
2134 : 0 : return nCount;
2135 : : }
2136 : : //------------------------------------------------------------------------------
2137 : 0 : long OSelectionBrowseBox::GetRealRow(long nRowId) const
2138 : : {
2139 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
2140 : 0 : long nErg=0,i;
2141 : 0 : const long nCount = m_bVisibleRow.size();
2142 [ # # ]: 0 : for(i=0;i < nCount; ++i)
2143 : : {
2144 [ # # ]: 0 : if(m_bVisibleRow[i])
2145 : : {
2146 [ # # ]: 0 : if(nErg++ == nRowId)
2147 : 0 : break;
2148 : : }
2149 : : }
2150 : : OSL_ENSURE(nErg <= long(m_bVisibleRow.size()),"nErg kann nicht groesser als BROW_ROW_CNT sein!");
2151 : 0 : return i;
2152 : : }
2153 : : static long nVisibleRowMask[] =
2154 : : {
2155 : : 0x0001,
2156 : : 0x0002,
2157 : : 0x0004,
2158 : : 0x0008,
2159 : : 0x0010,
2160 : : 0x0020,
2161 : : 0x0040,
2162 : : 0x0080,
2163 : : 0x0100,
2164 : : 0x0200,
2165 : : 0x0400,
2166 : : 0x0800
2167 : : };
2168 : : //------------------------------------------------------------------------------
2169 : 0 : sal_Int32 OSelectionBrowseBox::GetNoneVisibleRows() const
2170 : : {
2171 : 0 : sal_Int32 nErg(0);
2172 : : // only the first 11 row are interesting
2173 : 0 : sal_Int32 nSize = sizeof(nVisibleRowMask) / sizeof(nVisibleRowMask[0]);
2174 [ # # ]: 0 : for(sal_Int32 i=0;i<nSize;i++)
2175 : : {
2176 [ # # ]: 0 : if(!m_bVisibleRow[i])
2177 : 0 : nErg |= nVisibleRowMask[i];
2178 : : }
2179 : 0 : return nErg;
2180 : : }
2181 : : //------------------------------------------------------------------------------
2182 : 0 : void OSelectionBrowseBox::SetNoneVisbleRow(long nRows)
2183 : : {
2184 : : // only the first 11 row are interesting
2185 : 0 : sal_Int32 nSize = sizeof(nVisibleRowMask) / sizeof(nVisibleRowMask[0]);
2186 [ # # ]: 0 : for(sal_Int32 i=0;i< nSize;i++)
2187 : 0 : m_bVisibleRow[i] = !(nRows & nVisibleRowMask[i]);
2188 : 0 : }
2189 : : //------------------------------------------------------------------------------
2190 : 0 : String OSelectionBrowseBox::GetCellText(long nRow, sal_uInt16 nColId) const
2191 : : {
2192 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
2193 : :
2194 [ # # ]: 0 : sal_uInt16 nPos = GetColumnPos(nColId);
2195 : :
2196 [ # # ][ # # ]: 0 : OTableFieldDescRef pEntry = getFields()[nPos-1];
2197 : : OSL_ENSURE(pEntry != NULL, "OSelectionBrowseBox::GetCellText : invalid column id, prepare for GPF ... ");
2198 [ # # ][ # # ]: 0 : if ( pEntry->IsEmpty() )
2199 [ # # ]: 0 : return String();
2200 : :
2201 [ # # ]: 0 : String aText;
2202 [ # # # # : 0 : switch (nRow)
# # # ]
2203 : : {
2204 : : case BROW_TABLE_ROW:
2205 [ # # ]: 0 : aText = pEntry->GetAlias();
2206 : 0 : break;
2207 : : case BROW_FIELD_ROW:
2208 : : {
2209 [ # # ]: 0 : String aField = pEntry->GetField();
2210 [ # # ]: 0 : if (aField.GetChar(0) == '*') // * durch alias.* ersetzen
2211 : : {
2212 [ # # ]: 0 : aField = pEntry->GetAlias();
2213 [ # # ]: 0 : if(aField.Len())
2214 [ # # ]: 0 : aField += '.';
2215 [ # # ]: 0 : aField += '*';
2216 : : }
2217 [ # # ][ # # ]: 0 : aText = aField;
2218 : 0 : } break;
2219 : : case BROW_ORDER_ROW:
2220 [ # # ]: 0 : if (pEntry->GetOrderDir() != ORDER_NONE)
2221 [ # # ][ # # ]: 0 : aText = String(ModuleRes(STR_QUERY_SORTTEXT) ).GetToken(sal::static_int_cast< sal_uInt16 >(pEntry->GetOrderDir()));
[ # # ][ # # ]
[ # # ][ # # ]
2222 : 0 : break;
2223 : : case BROW_VIS_ROW:
2224 : 0 : break;
2225 : : case BROW_COLUMNALIAS_ROW:
2226 [ # # ]: 0 : aText = pEntry->GetFieldAlias();
2227 : 0 : break;
2228 : : case BROW_FUNCTION_ROW:
2229 : : // we always show the group function at first
2230 [ # # ]: 0 : if ( pEntry->IsGroupBy() )
2231 [ # # ][ # # ]: 0 : aText = m_aFunctionStrings.GetToken(comphelper::string::getTokenCount(m_aFunctionStrings, ';')-1);
[ # # ][ # # ]
[ # # ]
2232 [ # # ]: 0 : else if ( pEntry->isNumericOrAggreateFunction() )
2233 [ # # ]: 0 : aText = pEntry->GetFunction();
2234 : 0 : break;
2235 : : default:
2236 [ # # ][ # # ]: 0 : aText = pEntry->GetCriteria(sal_uInt16(nRow - BROW_CRIT1_ROW));
2237 : : }
2238 [ # # ][ # # ]: 0 : return aText;
[ # # ]
2239 : : }
2240 : : //------------------------------------------------------------------------------
2241 : 0 : sal_Bool OSelectionBrowseBox::GetFunctionName(sal_uInt32 _nFunctionTokenId,String& rFkt)
2242 : : {
2243 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
2244 : 0 : sal_Bool bErg=sal_True;
2245 [ # # ]: 0 : String aText;
2246 [ # # # # : 0 : switch(_nFunctionTokenId)
# # # # #
# # # # #
# # ]
2247 : : {
2248 : : case SQL_TOKEN_COUNT:
2249 [ # # ][ # # ]: 0 : rFkt = (m_pFunctionCell->GetEntryCount() < 3) ? m_pFunctionCell->GetEntry(1) : m_pFunctionCell->GetEntry(2);
[ # # ][ # # ]
[ # # ][ # # ]
2250 : 0 : break;
2251 : : case SQL_TOKEN_AVG:
2252 [ # # ][ # # ]: 0 : rFkt = m_pFunctionCell->GetEntry(1);
[ # # ]
2253 : 0 : break;
2254 : : case SQL_TOKEN_MAX:
2255 [ # # ][ # # ]: 0 : rFkt = m_pFunctionCell->GetEntry(3);
[ # # ]
2256 : 0 : break;
2257 : : case SQL_TOKEN_MIN:
2258 [ # # ][ # # ]: 0 : rFkt = m_pFunctionCell->GetEntry(4);
[ # # ]
2259 : 0 : break;
2260 : : case SQL_TOKEN_SUM:
2261 [ # # ][ # # ]: 0 : rFkt = m_pFunctionCell->GetEntry(5);
[ # # ]
2262 : 0 : break;
2263 : : case SQL_TOKEN_EVERY:
2264 [ # # ][ # # ]: 0 : rFkt = m_pFunctionCell->GetEntry(6);
[ # # ]
2265 : 0 : break;
2266 : : case SQL_TOKEN_ANY:
2267 [ # # ][ # # ]: 0 : rFkt = m_pFunctionCell->GetEntry(7);
[ # # ]
2268 : 0 : break;
2269 : : case SQL_TOKEN_SOME:
2270 [ # # ][ # # ]: 0 : rFkt = m_pFunctionCell->GetEntry(8);
[ # # ]
2271 : 0 : break;
2272 : : case SQL_TOKEN_STDDEV_POP:
2273 [ # # ][ # # ]: 0 : rFkt = m_pFunctionCell->GetEntry(9);
[ # # ]
2274 : 0 : break;
2275 : : case SQL_TOKEN_STDDEV_SAMP:
2276 [ # # ][ # # ]: 0 : rFkt = m_pFunctionCell->GetEntry(10);
[ # # ]
2277 : 0 : break;
2278 : : case SQL_TOKEN_VAR_SAMP:
2279 [ # # ][ # # ]: 0 : rFkt = m_pFunctionCell->GetEntry(11);
[ # # ]
2280 : 0 : break;
2281 : : case SQL_TOKEN_VAR_POP:
2282 [ # # ][ # # ]: 0 : rFkt = m_pFunctionCell->GetEntry(12);
[ # # ]
2283 : 0 : break;
2284 : : case SQL_TOKEN_COLLECT:
2285 [ # # ][ # # ]: 0 : rFkt = m_pFunctionCell->GetEntry(13);
[ # # ]
2286 : 0 : break;
2287 : : case SQL_TOKEN_FUSION:
2288 [ # # ][ # # ]: 0 : rFkt = m_pFunctionCell->GetEntry(14);
[ # # ]
2289 : 0 : break;
2290 : : case SQL_TOKEN_INTERSECTION:
2291 [ # # ][ # # ]: 0 : rFkt = m_pFunctionCell->GetEntry(15);
[ # # ]
2292 : 0 : break;
2293 : : default:
2294 : : {
2295 [ # # ][ # # ]: 0 : xub_StrLen nCount = comphelper::string::getTokenCount(m_aFunctionStrings, ';');
2296 : : xub_StrLen i;
2297 [ # # ]: 0 : for ( i = 0; i < nCount-1; i++) // Gruppierung wird nicht mit gez"ahlt
2298 : : {
2299 [ # # ][ # # ]: 0 : if(rFkt.EqualsIgnoreCaseAscii(m_aFunctionStrings.GetToken(i)))
[ # # ][ # # ]
2300 : : {
2301 [ # # ][ # # ]: 0 : rFkt = m_aFunctionStrings.GetToken(i);
[ # # ]
2302 : 0 : break;
2303 : : }
2304 : : }
2305 [ # # ]: 0 : if(i == nCount-1)
2306 : 0 : bErg = sal_False;
2307 : : }
2308 : : }
2309 : :
2310 [ # # ]: 0 : return bErg;
2311 : : }
2312 : : //------------------------------------------------------------------------------
2313 : 0 : String OSelectionBrowseBox::GetCellContents(sal_Int32 nCellIndex, sal_uInt16 nColId)
2314 : : {
2315 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
2316 [ # # ][ # # ]: 0 : if ( GetCurColumnId() == nColId && !m_bInUndoMode )
[ # # ]
2317 [ # # ]: 0 : SaveModified();
2318 : :
2319 [ # # ]: 0 : sal_uInt16 nPos = GetColumnPos(nColId);
2320 [ # # ][ # # ]: 0 : OTableFieldDescRef pEntry = getFields()[nPos - 1];
2321 : : OSL_ENSURE(pEntry != NULL, "OSelectionBrowseBox::GetCellContents : invalid column id, prepare for GPF ... ");
2322 : :
2323 [ # # # ]: 0 : switch (nCellIndex)
2324 : : {
2325 : : case BROW_VIS_ROW :
2326 [ # # ][ # # ]: 0 : return pEntry->IsVisible() ? g_strOne : g_strZero;
[ # # ][ # # ]
[ # # # # ]
2327 : : case BROW_ORDER_ROW:
2328 : : {
2329 [ # # ]: 0 : sal_uInt16 nIdx = m_pOrderCell->GetSelectEntryPos();
2330 [ # # ]: 0 : if (nIdx == sal_uInt16(-1))
2331 : 0 : nIdx = 0;
2332 [ # # ]: 0 : return rtl::OUString(nIdx);
2333 : : }
2334 : : default:
2335 [ # # ]: 0 : return GetCellText(nCellIndex, nColId);
2336 [ # # ]: 0 : }
2337 : : }
2338 : :
2339 : : //------------------------------------------------------------------------------
2340 : 0 : void OSelectionBrowseBox::SetCellContents(sal_Int32 nRow, sal_uInt16 nColId, const String& strNewText)
2341 : : {
2342 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
2343 [ # # ][ # # ]: 0 : sal_Bool bWasEditing = IsEditing() && (GetCurColumnId() == nColId) && IsRowVisible(static_cast<sal_uInt16>(nRow)) && (GetCurRow() == static_cast<sal_uInt16>(GetBrowseRow(nRow)));
[ # # ][ # # ]
[ # # ][ # # ]
2344 [ # # ]: 0 : if (bWasEditing)
2345 [ # # ]: 0 : DeactivateCell();
2346 : :
2347 [ # # ]: 0 : sal_uInt16 nPos = GetColumnPos(nColId);
2348 [ # # ]: 0 : OTableFieldDescRef pEntry = getEntry(nPos - 1);
2349 : : OSL_ENSURE(pEntry != NULL, "OSelectionBrowseBox::SetCellContents : invalid column id, prepare for GPF ... ");
2350 : :
2351 : :
2352 [ # # # # : 0 : switch (nRow)
# # # ]
2353 : : {
2354 : : case BROW_VIS_ROW:
2355 [ # # ][ # # ]: 0 : pEntry->SetVisible(strNewText.Equals(g_strOne));
[ # # ]
2356 : 0 : break;
2357 : : case BROW_FIELD_ROW:
2358 [ # # ]: 0 : pEntry->SetField(strNewText);
2359 : 0 : break;
2360 : : case BROW_TABLE_ROW:
2361 [ # # ]: 0 : pEntry->SetAlias(strNewText);
2362 : 0 : break;
2363 : : case BROW_ORDER_ROW:
2364 : : {
2365 [ # # ]: 0 : sal_uInt16 nIdx = (sal_uInt16)strNewText.ToInt32();
2366 : 0 : pEntry->SetOrderDir(EOrderDir(nIdx));
2367 : 0 : } break;
2368 : : case BROW_COLUMNALIAS_ROW:
2369 [ # # ]: 0 : pEntry->SetFieldAlias(strNewText);
2370 : 0 : break;
2371 : : case BROW_FUNCTION_ROW:
2372 : : {
2373 [ # # ]: 0 : String sOldFunctionName = pEntry->GetFunction();
2374 [ # # ][ # # ]: 0 : String sGroupFunctionName = m_aFunctionStrings.GetToken(comphelper::string::getTokenCount(m_aFunctionStrings, ';')-1);
[ # # ]
2375 [ # # ]: 0 : pEntry->SetFunction(strNewText);
2376 : : // first reset this two member
2377 : 0 : sal_Int32 nFunctionType = pEntry->GetFunctionType();
2378 : 0 : nFunctionType &= ~FKT_AGGREGATE;
2379 : 0 : pEntry->SetFunctionType(nFunctionType);
2380 [ # # ][ # # ]: 0 : if ( pEntry->IsGroupBy() && !sGroupFunctionName.EqualsIgnoreCaseAscii(strNewText) )
[ # # ][ # # ]
2381 : 0 : pEntry->SetGroupBy(sal_False);
2382 : :
2383 : :
2384 [ # # ][ # # ]: 0 : if ( sGroupFunctionName.EqualsIgnoreCaseAscii(strNewText) )
2385 : 0 : pEntry->SetGroupBy(sal_True);
2386 [ # # ]: 0 : else if ( strNewText.Len() )
2387 : : {
2388 : 0 : nFunctionType |= FKT_AGGREGATE;
2389 : 0 : pEntry->SetFunctionType(nFunctionType);
2390 [ # # ][ # # ]: 0 : }
2391 : 0 : } break;
2392 : : default:
2393 [ # # ][ # # ]: 0 : pEntry->SetCriteria(sal_uInt16(nRow - BROW_CRIT1_ROW), strNewText);
2394 : : }
2395 : :
2396 [ # # ]: 0 : long nCellIndex = GetRealRow(nRow);
2397 [ # # ][ # # ]: 0 : if(IsRowVisible(static_cast<sal_uInt16>(nRow)))
2398 [ # # ]: 0 : RowModified(nCellIndex, nColId);
2399 : :
2400 : : // die entsprechende Feld-Beschreibung ist jetzt leer -> Visible auf sal_False (damit das konsistent mit normalen leeren Spalten ist)
2401 [ # # ][ # # ]: 0 : if (pEntry->IsEmpty())
2402 : 0 : pEntry->SetVisible(sal_False);
2403 : :
2404 [ # # ]: 0 : if (bWasEditing)
2405 [ # # ]: 0 : ActivateCell(nCellIndex, nColId);
2406 : :
2407 [ # # ][ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).setModified( sal_True );
[ # # ]
2408 : 0 : }
2409 : : //------------------------------------------------------------------------------
2410 : 0 : sal_uInt32 OSelectionBrowseBox::GetTotalCellWidth(long nRow, sal_uInt16 nColId) const
2411 : : {
2412 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
2413 : :
2414 : 0 : long nRowId = GetRealRow(nRow);
2415 [ # # ]: 0 : if (nRowId == BROW_VIS_ROW)
2416 : 0 : return CHECKBOX_SIZE;
2417 : : else
2418 [ # # ]: 0 : return GetDataWindow().GetTextWidth(GetCellText(nRowId, nColId));
2419 : : }
2420 : :
2421 : : //------------------------------------------------------------------------------
2422 : 0 : void OSelectionBrowseBox::ColumnResized(sal_uInt16 nColId)
2423 : : {
2424 [ # # ][ # # ]: 0 : if (static_cast<OQueryController&>(getDesignView()->getController()).isReadOnly())
[ # # ]
2425 : 0 : return;
2426 : : // The resizing of columns can't be suppressed (BrowseBox doesn't support that) so we have to do this
2427 : : // fake. It's not _that_ bad : the user may change column widths while in read-only mode to see all details
2428 : : // but the changes aren't permanent ...
2429 : :
2430 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
2431 [ # # ]: 0 : sal_uInt16 nPos = GetColumnPos(nColId);
2432 : : OSL_ENSURE(nPos <= getFields().size(),"ColumnResized:: nColId sollte nicht groesser als List::count sein!");
2433 [ # # ]: 0 : OTableFieldDescRef pEntry = getEntry(nPos-1);
2434 : : OSL_ENSURE(pEntry.is(), "OSelectionBrowseBox::ColumnResized : keine FieldDescription !");
2435 [ # # ][ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).setModified( sal_True );
2436 [ # # ]: 0 : EditBrowseBox::ColumnResized(nColId);
2437 : :
2438 [ # # ]: 0 : if ( pEntry.is())
2439 : : {
2440 [ # # ]: 0 : if ( !m_bInUndoMode )
2441 : : {
2442 : : // create the undo action
2443 [ # # ][ # # ]: 0 : OTabFieldSizedUndoAct* pUndo = new OTabFieldSizedUndoAct(this);
2444 : 0 : pUndo->SetColumnPosition( nPos );
2445 : 0 : pUndo->SetOriginalWidth(pEntry->GetColWidth());
2446 [ # # ][ # # ]: 0 : getDesignView()->getController().addUndoActionAndInvalidate(pUndo);
2447 : : }
2448 [ # # ]: 0 : pEntry->SetColWidth(sal_uInt16(GetColumnWidth(nColId)));
2449 [ # # ]: 0 : }
2450 : : }
2451 : :
2452 : : //------------------------------------------------------------------------------
2453 : 0 : sal_uInt32 OSelectionBrowseBox::GetTotalCellWidth(long nRowId, sal_uInt16 nColId)
2454 : : {
2455 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
2456 [ # # ]: 0 : sal_uInt16 nPos = GetColumnPos(nColId);
2457 : : OSL_ENSURE((nPos == 0) || (nPos <= getFields().size()), "OSelectionBrowseBox::GetTotalCellWidth : invalid parameter nColId");
2458 : :
2459 [ # # ][ # # ]: 0 : OTableFieldDescRef pEntry = getFields()[nPos-1];
2460 : : OSL_ENSURE(pEntry.is(), "OSelectionBrowseBox::GetTotalCellWidth : invalid FieldDescription !");
2461 : :
2462 [ # # ]: 0 : long nRow = GetRealRow(nRowId);
2463 [ # # ]: 0 : String strText(GetCellText(nRow, nColId));
2464 [ # # ][ # # ]: 0 : return GetDataWindow().LogicToPixel(Size(GetDataWindow().GetTextWidth(strText),0)).Width();
[ # # ][ # # ]
2465 : : }
2466 : :
2467 : : //------------------------------------------------------------------------------
2468 : 0 : sal_uInt16 OSelectionBrowseBox::GetDefaultColumnWidth(const String& /*rName*/) const
2469 : : {
2470 : : DBG_CHKTHIS(OSelectionBrowseBox,NULL);
2471 : : // die Baissklasse macht das von dem Text abhaengig, ich habe aber keine Spaltenueberschriften, daher haette ich
2472 : : // hier gern einen anderen Default-Wert
2473 [ # # ][ # # ]: 0 : return static_cast<sal_uInt16>(DEFAULT_SIZE);
[ # # ]
2474 : : }
2475 : : //------------------------------------------------------------------------------
2476 : 0 : sal_Bool OSelectionBrowseBox::isCutAllowed()
2477 : : {
2478 : 0 : sal_Bool bCutAllowed = sal_False;
2479 : 0 : long nRow = GetRealRow(GetCurRow());
2480 [ # # # ]: 0 : switch (nRow)
2481 : : {
2482 : : case BROW_VIS_ROW:
2483 : : case BROW_ORDER_ROW:
2484 : : case BROW_TABLE_ROW:
2485 : : case BROW_FUNCTION_ROW:
2486 : 0 : break;
2487 : : case BROW_FIELD_ROW:
2488 : 0 : bCutAllowed = m_pFieldCell->GetSelected().Len() != 0;
2489 : 0 : break;
2490 : : default:
2491 : 0 : bCutAllowed = m_pTextCell->GetSelected().Len() != 0;
2492 : 0 : break;
2493 : : }
2494 : 0 : return bCutAllowed;
2495 : : }
2496 : : // -----------------------------------------------------------------------------
2497 : 0 : void OSelectionBrowseBox::cut()
2498 : : {
2499 [ # # ][ # # ]: 0 : String sOldValue = GetCellContents(GetRealRow(GetCurRow()),GetCurColumnId());
2500 [ # # ]: 0 : long nRow = GetRealRow(GetCurRow());
2501 [ # # ]: 0 : switch (nRow)
2502 : : {
2503 : : case BROW_FIELD_ROW:
2504 [ # # ]: 0 : m_pFieldCell->Cut();
2505 [ # # ]: 0 : m_pFieldCell->SetModifyFlag();
2506 : 0 : break;
2507 : : default:
2508 [ # # ]: 0 : m_pTextCell->Cut();
2509 [ # # ]: 0 : m_pTextCell->SetModifyFlag();
2510 : : }
2511 [ # # ]: 0 : SaveModified();
2512 [ # # ][ # # ]: 0 : RowModified(GetBrowseRow(nRow), GetCurColumnId());
2513 : :
2514 [ # # ][ # # ]: 0 : invalidateUndoRedo();
2515 : 0 : }
2516 : : // -----------------------------------------------------------------------------
2517 : 0 : void OSelectionBrowseBox::paste()
2518 : : {
2519 : 0 : long nRow = GetRealRow(GetCurRow());
2520 [ # # ]: 0 : switch (nRow)
2521 : : {
2522 : : case BROW_FIELD_ROW:
2523 : 0 : m_pFieldCell->Paste();
2524 : 0 : m_pFieldCell->SetModifyFlag();
2525 : 0 : break;
2526 : : default:
2527 : 0 : m_pTextCell->Paste();
2528 : 0 : m_pTextCell->SetModifyFlag();
2529 : : }
2530 : 0 : RowModified(GetBrowseRow(nRow), GetCurColumnId());
2531 : 0 : invalidateUndoRedo();
2532 : 0 : }
2533 : : // -----------------------------------------------------------------------------
2534 : 0 : sal_Bool OSelectionBrowseBox::isPasteAllowed()
2535 : : {
2536 : 0 : sal_Bool bPasteAllowed = sal_True;
2537 : 0 : long nRow = GetRealRow(GetCurRow());
2538 [ # # ]: 0 : switch (nRow)
2539 : : {
2540 : : case BROW_VIS_ROW:
2541 : : case BROW_ORDER_ROW:
2542 : : case BROW_TABLE_ROW:
2543 : : case BROW_FUNCTION_ROW:
2544 : 0 : bPasteAllowed = sal_False;
2545 : 0 : break;
2546 : : }
2547 : 0 : return bPasteAllowed;
2548 : : }
2549 : : // -----------------------------------------------------------------------------
2550 : 0 : sal_Bool OSelectionBrowseBox::isCopyAllowed()
2551 : : {
2552 : 0 : return isCutAllowed();
2553 : : }
2554 : : // -----------------------------------------------------------------------------
2555 : 0 : void OSelectionBrowseBox::copy()
2556 : : {
2557 : 0 : long nRow = GetRealRow(GetCurRow());
2558 [ # # ]: 0 : switch (nRow)
2559 : : {
2560 : : case BROW_FIELD_ROW:
2561 : 0 : m_pFieldCell->Copy();
2562 : 0 : break;
2563 : : default:
2564 : 0 : m_pTextCell->Copy();
2565 : : }
2566 : 0 : }
2567 : : // -----------------------------------------------------------------------------
2568 : 0 : void OSelectionBrowseBox::appendUndoAction(const String& _rOldValue,const String& _rNewValue,sal_Int32 _nRow,sal_Bool& _bListAction)
2569 : : {
2570 [ # # ][ # # ]: 0 : if ( !m_bInUndoMode && !_rNewValue.Equals(_rOldValue) )
[ # # ]
2571 : : {
2572 [ # # ]: 0 : if ( !_bListAction )
2573 : : {
2574 : 0 : _bListAction = sal_True;
2575 [ # # ][ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).GetUndoManager().EnterListAction(String(),String());
[ # # ]
2576 : : }
2577 : 0 : appendUndoAction(_rOldValue,_rNewValue,_nRow);
2578 : : }
2579 : 0 : }
2580 : : // -----------------------------------------------------------------------------
2581 : 0 : void OSelectionBrowseBox::appendUndoAction(const String& _rOldValue,const String& _rNewValue,sal_Int32 _nRow)
2582 : : {
2583 [ # # ][ # # ]: 0 : if ( !m_bInUndoMode && !_rNewValue.Equals(_rOldValue) )
[ # # ]
2584 : : {
2585 [ # # ]: 0 : OTabFieldCellModifiedUndoAct* pUndoAct = new OTabFieldCellModifiedUndoAct(this);
2586 : 0 : pUndoAct->SetCellIndex(_nRow);
2587 : : OSL_ENSURE(GetColumnPos(GetCurColumnId()) != BROWSER_INVALIDID,"Current position isn't valid!");
2588 : 0 : pUndoAct->SetColumnPosition( GetColumnPos(GetCurColumnId()) );
2589 : 0 : pUndoAct->SetCellContents(_rOldValue);
2590 : 0 : getDesignView()->getController().addUndoActionAndInvalidate(pUndoAct);
2591 : : }
2592 : 0 : }
2593 : : // -----------------------------------------------------------------------------
2594 : 0 : IMPL_LINK_NOARG(OSelectionBrowseBox, OnInvalidateTimer)
2595 : : {
2596 [ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature(SID_CUT);
2597 [ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature(SID_COPY);
2598 [ # # ]: 0 : static_cast<OQueryController&>(getDesignView()->getController()).InvalidateFeature(SID_PASTE);
2599 [ # # ]: 0 : if(!m_bStopTimer)
2600 : 0 : m_timerInvalidate.Start();
2601 : 0 : return 0L;
2602 : : }
2603 : : // -----------------------------------------------------------------------------
2604 : 0 : void OSelectionBrowseBox::stopTimer()
2605 : : {
2606 : 0 : m_bStopTimer = sal_True;
2607 [ # # ]: 0 : if (m_timerInvalidate.IsActive())
2608 : 0 : m_timerInvalidate.Stop();
2609 : 0 : }
2610 : : // -----------------------------------------------------------------------------
2611 : 0 : void OSelectionBrowseBox::startTimer()
2612 : : {
2613 : 0 : m_bStopTimer = sal_False;
2614 [ # # ]: 0 : if (!m_timerInvalidate.IsActive())
2615 : 0 : m_timerInvalidate.Start();
2616 : 0 : }
2617 : : // -----------------------------------------------------------------------------
2618 : 0 : OTableFields& OSelectionBrowseBox::getFields() const
2619 : : {
2620 : 0 : OQueryController& rController = static_cast<OQueryController&>(getDesignView()->getController());
2621 : 0 : return rController.getTableFieldDesc();
2622 : : }
2623 : : // -----------------------------------------------------------------------------
2624 : 0 : void OSelectionBrowseBox::enableControl(const OTableFieldDescRef& _rEntry,Window* _pControl)
2625 : : {
2626 : 0 : sal_Bool bEnable = !_rEntry->isCondition();
2627 : 0 : _pControl->Enable(bEnable);
2628 : 0 : _pControl->EnableInput(bEnable);
2629 : 0 : }
2630 : : // -----------------------------------------------------------------------------
2631 : 0 : void OSelectionBrowseBox::setTextCellContext(const OTableFieldDescRef& _rEntry,const String& _sText,const rtl::OString& _sHelpId)
2632 : : {
2633 : 0 : m_pTextCell->SetText(_sText);
2634 : 0 : m_pTextCell->ClearModifyFlag();
2635 [ # # ]: 0 : if (!m_pTextCell->HasFocus())
2636 : 0 : m_pTextCell->GrabFocus();
2637 : :
2638 : 0 : enableControl(_rEntry,m_pTextCell);
2639 : :
2640 [ # # ]: 0 : if (m_pTextCell->GetHelpId() != _sHelpId)
2641 : : // da TextCell in verschiedenen Kontexten verwendet wird, muss ich den gecachten HelpText loeschen
2642 [ # # ]: 0 : m_pTextCell->SetHelpText(String());
2643 : 0 : m_pTextCell->SetHelpId(_sHelpId);
2644 : 0 : }
2645 : : // -----------------------------------------------------------------------------
2646 : 0 : void OSelectionBrowseBox::invalidateUndoRedo()
2647 : : {
2648 : 0 : OQueryController& rController = static_cast<OQueryController&>(getDesignView()->getController());
2649 [ # # ]: 0 : rController.InvalidateFeature( ID_BROWSER_UNDO );
2650 [ # # ]: 0 : rController.InvalidateFeature( ID_BROWSER_REDO );
2651 [ # # ]: 0 : rController.InvalidateFeature( ID_BROWSER_QUERY_EXECUTE );
2652 : 0 : }
2653 : : // -----------------------------------------------------------------------------
2654 : 0 : OTableFieldDescRef OSelectionBrowseBox::getEntry(OTableFields::size_type _nPos)
2655 : : {
2656 : : // we have to check if we need a new entry at this position
2657 : 0 : OTableFields& aFields = getFields();
2658 : : OSL_ENSURE(aFields.size() > _nPos,"ColID is to great!");
2659 : :
2660 : 0 : OTableFieldDescRef pEntry = aFields[_nPos];
2661 : : OSL_ENSURE(pEntry.is(),"Invalid entry!");
2662 [ # # ]: 0 : if ( !pEntry.is() )
2663 : : {
2664 [ # # ][ # # ]: 0 : pEntry = new OTableFieldDesc();
[ # # ]
2665 : : pEntry->SetColumnId(
2666 [ # # ]: 0 : GetColumnId(sal::static_int_cast< sal_uInt16 >(_nPos+1)));
2667 [ # # ]: 0 : aFields[_nPos] = pEntry;
2668 : : }
2669 : 0 : return pEntry;
2670 : : }
2671 : : // -----------------------------------------------------------------------------
2672 : 0 : void OSelectionBrowseBox::GetFocus()
2673 : : {
2674 [ # # ][ # # ]: 0 : if(!IsEditing() && !m_bWasEditing)
[ # # ]
2675 : 0 : ActivateCell();
2676 : 0 : EditBrowseBox::GetFocus();
2677 : 0 : }
2678 : : // -----------------------------------------------------------------------------
2679 : 0 : void OSelectionBrowseBox::DeactivateCell(sal_Bool _bUpdate)
2680 : : {
2681 : 0 : m_bWasEditing = sal_True;
2682 : 0 : EditBrowseBox::DeactivateCell(_bUpdate);
2683 : 0 : m_bWasEditing = sal_False;
2684 : 0 : }
2685 : : // -----------------------------------------------------------------------------
2686 : 0 : ::rtl::OUString OSelectionBrowseBox::GetRowDescription( sal_Int32 _nRow ) const
2687 : : {
2688 [ # # ][ # # ]: 0 : String aLabel(ModuleRes(STR_QUERY_HANDLETEXT));
2689 : :
2690 : : // ab BROW_CRIT2_ROW werden alle Zeilen mit "oder" angegeben
2691 [ # # ]: 0 : xub_StrLen nToken = (xub_StrLen) (_nRow >= GetBrowseRow(BROW_CRIT2_ROW))
2692 : : ?
2693 [ # # ][ # # ]: 0 : xub_StrLen(BROW_CRIT2_ROW) : xub_StrLen(GetRealRow(_nRow));
2694 [ # # ][ # # ]: 0 : return ::rtl::OUString(aLabel.GetToken(nToken));
[ # # ][ # # ]
2695 : : }
2696 : : // -----------------------------------------------------------------------------
2697 : 0 : ::rtl::OUString OSelectionBrowseBox::GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType _eObjType,sal_Int32 _nPosition) const
2698 : : {
2699 : 0 : ::rtl::OUString sRetText;
2700 [ # # ]: 0 : switch( _eObjType )
2701 : : {
2702 : : case ::svt::BBTYPE_ROWHEADERCELL:
2703 [ # # ]: 0 : sRetText = GetRowDescription(_nPosition);
2704 : 0 : break;
2705 : : default:
2706 [ # # ]: 0 : sRetText = EditBrowseBox::GetAccessibleObjectDescription(_eObjType,_nPosition);
2707 : : }
2708 : 0 : return sRetText;
2709 : : }
2710 : : // -----------------------------------------------------------------------------
2711 : 0 : sal_Bool OSelectionBrowseBox::fillEntryTable(OTableFieldDescRef& _pEntry,const ::rtl::OUString& _sTableName)
2712 : : {
2713 : 0 : sal_Bool bRet = sal_False;
2714 : 0 : OJoinTableView::OTableWindowMap* pTabWinList = getDesignView()->getTableView()->GetTabWinMap();
2715 [ # # ]: 0 : if (pTabWinList)
2716 : : {
2717 [ # # ]: 0 : OJoinTableView::OTableWindowMapIterator aIter = pTabWinList->find(_sTableName);
2718 [ # # ]: 0 : if(aIter != pTabWinList->end())
2719 : : {
2720 : 0 : OQueryTableWindow* pEntryTab = static_cast<OQueryTableWindow*>(aIter->second);
2721 [ # # ]: 0 : if (pEntryTab)
2722 : : {
2723 [ # # ]: 0 : _pEntry->SetTable(pEntryTab->GetTableName());
2724 [ # # ]: 0 : _pEntry->SetTabWindow(pEntryTab);
2725 : 0 : bRet = sal_True;
2726 : : }
2727 : : }
2728 : : }
2729 : 0 : return bRet;
2730 : : }
2731 : : // -----------------------------------------------------------------------------
2732 : 0 : void OSelectionBrowseBox::setFunctionCell(OTableFieldDescRef& _pEntry)
2733 : : {
2734 [ # # ][ # # ]: 0 : Reference< XConnection> xConnection = static_cast<OQueryController&>(getDesignView()->getController()).getConnection();
2735 [ # # ]: 0 : if ( xConnection.is() )
2736 : : {
2737 : : // Aggregate functions in general only available with Core SQL
2738 [ # # ][ # # ]: 0 : if ( lcl_SupportsCoreSQLGrammar(xConnection) )
2739 : : {
2740 : : // if we have an asterix, no other function than count is allowed
2741 [ # # ]: 0 : m_pFunctionCell->Clear();
2742 [ # # ][ # # ]: 0 : m_pFunctionCell->InsertEntry(m_aFunctionStrings.GetToken(0));
[ # # ]
2743 [ # # ][ # # ]: 0 : if ( isFieldNameAsterix(_pEntry->GetField()) )
2744 [ # # ][ # # ]: 0 : m_pFunctionCell->InsertEntry(m_aFunctionStrings.GetToken(2)); // 2 -> COUNT
[ # # ]
2745 : : else
2746 : : {
2747 [ # # ][ # # ]: 0 : xub_StrLen nCount = comphelper::string::getTokenCount(m_aFunctionStrings, ';');
2748 [ # # ]: 0 : if ( _pEntry->isNumeric() )
2749 : 0 : --nCount;
2750 [ # # ]: 0 : for (xub_StrLen nIdx = 1; nIdx < nCount; nIdx++)
2751 [ # # ][ # # ]: 0 : m_pFunctionCell->InsertEntry(m_aFunctionStrings.GetToken(nIdx));
[ # # ]
2752 : : }
2753 : :
2754 [ # # ]: 0 : if ( _pEntry->IsGroupBy() )
2755 : : {
2756 : : OSL_ENSURE(!_pEntry->isNumeric(),"Not allowed to combine group by and numeric values!");
2757 [ # # ][ # # ]: 0 : m_pFunctionCell->SelectEntry(m_pFunctionCell->GetEntry(m_pFunctionCell->GetEntryCount() - 1));
[ # # ][ # # ]
2758 : : }
2759 [ # # ][ # # ]: 0 : else if ( m_pFunctionCell->GetEntryPos(String(_pEntry->GetFunction())) != COMBOBOX_ENTRY_NOTFOUND )
[ # # ][ # # ]
2760 [ # # ][ # # ]: 0 : m_pFunctionCell->SelectEntry(String(_pEntry->GetFunction()));
[ # # ]
2761 : : else
2762 [ # # ]: 0 : m_pFunctionCell->SelectEntryPos(0);
2763 : :
2764 [ # # ]: 0 : enableControl(_pEntry,m_pFunctionCell);
2765 : : }
2766 : : else
2767 : : {
2768 : : // only COUNT(*) and COUNT("table".*) allowed
2769 [ # # ]: 0 : sal_Bool bCountRemoved = !isFieldNameAsterix(_pEntry->GetField());
2770 [ # # ]: 0 : if ( bCountRemoved )
2771 [ # # ]: 0 : m_pFunctionCell->RemoveEntry(1);
2772 : :
2773 [ # # ][ # # ]: 0 : if ( !bCountRemoved && m_pFunctionCell->GetEntryCount() < 2)
[ # # ][ # # ]
2774 [ # # ][ # # ]: 0 : m_pFunctionCell->InsertEntry(m_aFunctionStrings.GetToken(2)); // 2 -> COUNT
[ # # ]
2775 : :
2776 [ # # ][ # # ]: 0 : if(m_pFunctionCell->GetEntryPos(String(_pEntry->GetFunction())) != COMBOBOX_ENTRY_NOTFOUND)
[ # # ][ # # ]
2777 [ # # ][ # # ]: 0 : m_pFunctionCell->SelectEntry(_pEntry->GetFunction());
[ # # ]
2778 : : else
2779 [ # # ]: 0 : m_pFunctionCell->SelectEntryPos(0);
2780 : : }
2781 : 0 : }
2782 : 0 : }
2783 : : // -----------------------------------------------------------------------------
2784 : 0 : Reference< XAccessible > OSelectionBrowseBox::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos )
2785 : : {
2786 [ # # ]: 0 : OTableFieldDescRef pEntry = NULL;
2787 [ # # ][ # # ]: 0 : if(getFields().size() > sal_uInt16(_nColumnPos - 1))
2788 [ # # ][ # # ]: 0 : pEntry = getFields()[_nColumnPos - 1];
2789 : :
2790 [ # # ][ # # ]: 0 : if ( _nRow == BROW_VIS_ROW && pEntry.is() )
[ # # ]
2791 [ # # ][ # # ]: 0 : return EditBrowseBox::CreateAccessibleCheckBoxCell( _nRow, _nColumnPos,pEntry->IsVisible() ? STATE_CHECK : STATE_NOCHECK );
2792 : :
2793 [ # # ][ # # ]: 0 : return EditBrowseBox::CreateAccessibleCell( _nRow, _nColumnPos );
2794 : : }
2795 : : // -----------------------------------------------------------------------------
2796 : 0 : bool OSelectionBrowseBox::HasFieldByAliasName(const ::rtl::OUString& rFieldName, OTableFieldDescRef& rInfo) const
2797 : : {
2798 [ # # ]: 0 : OTableFields& aFields = getFields();
2799 : 0 : OTableFields::iterator aIter = aFields.begin();
2800 : 0 : OTableFields::iterator aEnd = aFields.end();
2801 : :
2802 [ # # ][ # # ]: 0 : for(;aIter != aEnd;++aIter)
2803 : : {
2804 [ # # ]: 0 : if ( (*aIter)->GetFieldAlias() == rFieldName )
2805 : : {
2806 [ # # ]: 0 : *rInfo = *(*aIter);
2807 : 0 : break;
2808 : : }
2809 : : }
2810 [ # # ]: 0 : return aIter != aEnd;
2811 : : }
2812 : : // -----------------------------------------------------------------------------
2813 : :
2814 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|