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 : #include "GroupsSorting.hxx"
20 : #include "GroupsSorting.hrc"
21 : #include <connectivity/dbtools.hxx>
22 : #include <svtools/editbrowsebox.hxx>
23 : #include <svtools/imgdef.hxx>
24 : #include <com/sun/star/beans/XPropertySet.hpp>
25 : #include <com/sun/star/container/XContainerListener.hpp>
26 : #include <com/sun/star/report/GroupOn.hpp>
27 : #include <com/sun/star/sdbc/DataType.hpp>
28 :
29 : #include <tools/debug.hxx>
30 : #include "RptResId.hrc"
31 : #include "rptui_slotid.hrc"
32 : #include "ModuleHelper.hxx"
33 : #include "helpids.hrc"
34 : #include "GroupExchange.hxx"
35 : #include "UITools.hxx"
36 : #include "UndoActions.hxx"
37 : #include "uistrings.hrc"
38 : #include "ReportController.hxx"
39 : #include "ColumnInfo.hxx"
40 :
41 : #include <cppuhelper/implbase1.hxx>
42 : #include <comphelper/property.hxx>
43 : #include <vcl/mnemonic.hxx>
44 : #include <vcl/msgbox.hxx>
45 : #include <algorithm>
46 :
47 : #include <cppuhelper/bootstrap.hxx>
48 :
49 : #define HANDLE_ID 0
50 : #define FIELD_EXPRESSION 1
51 : #define GROUPS_START_LEN 5
52 : #define NO_GROUP -1
53 :
54 : namespace rptui
55 : {
56 : using namespace ::com::sun::star;
57 : using namespace svt;
58 : using namespace ::comphelper;
59 :
60 0 : void lcl_addToList_throw( ComboBoxControl& _rListBox, ::std::vector<ColumnInfo>& o_aColumnList,const uno::Reference< container::XNameAccess>& i_xColumns )
61 : {
62 0 : uno::Sequence< ::rtl::OUString > aEntries = i_xColumns->getElementNames();
63 0 : const ::rtl::OUString* pEntries = aEntries.getConstArray();
64 0 : sal_Int32 nEntries = aEntries.getLength();
65 0 : for ( sal_Int32 i = 0; i < nEntries; ++i, ++pEntries )
66 : {
67 0 : uno::Reference< beans::XPropertySet> xColumn(i_xColumns->getByName(*pEntries),uno::UNO_QUERY_THROW);
68 0 : ::rtl::OUString sLabel;
69 0 : if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) )
70 0 : xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
71 0 : o_aColumnList.push_back( ColumnInfo(*pEntries,sLabel) );
72 0 : if ( !sLabel.isEmpty() )
73 0 : _rListBox.InsertEntry( sLabel );
74 : else
75 0 : _rListBox.InsertEntry( *pEntries );
76 0 : }
77 0 : }
78 :
79 : typedef ::svt::EditBrowseBox OFieldExpressionControl_Base;
80 : typedef ::cppu::WeakImplHelper1< container::XContainerListener > TContainerListenerBase;
81 : class OFieldExpressionControl : public TContainerListenerBase
82 : ,public OFieldExpressionControl_Base
83 : {
84 : ::osl::Mutex m_aMutex;
85 : ::std::vector<sal_Int32> m_aGroupPositions;
86 : ::std::vector<ColumnInfo> m_aColumnInfo;
87 : ::svt::ComboBoxControl* m_pComboCell;
88 : sal_Int32 m_nDataPos;
89 : sal_Int32 m_nCurrentPos;
90 : sal_uLong m_nPasteEvent;
91 : sal_uLong m_nDeleteEvent;
92 : OGroupsSortingDialog* m_pParent;
93 : bool m_bIgnoreEvent;
94 :
95 : void fillListBox(const uno::Reference< beans::XPropertySet>& _xDest,long nRow,sal_uInt16 nColumnId);
96 : sal_Bool SaveModified(bool _bAppend);
97 :
98 : OFieldExpressionControl(const OFieldExpressionControl&); // NO COPY
99 : void operator =(const OFieldExpressionControl&); // NO ASSIGN
100 : public:
101 : OFieldExpressionControl( OGroupsSortingDialog* _pParent,const ResId& _rResId);
102 : virtual ~OFieldExpressionControl();
103 :
104 : // XEventListener
105 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
106 : // XContainerListener
107 : virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
108 : virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
109 : virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
110 :
111 : void fillColumns(const uno::Reference< container::XNameAccess>& _xColumns);
112 : void lateInit();
113 : sal_Bool IsDeleteAllowed( );
114 : void DeleteRows();
115 : void cut();
116 : void copy();
117 : void paste();
118 :
119 0 : inline sal_Int32 getGroupPosition(sal_Int32 _nRow) const { return _nRow != BROWSER_ENDOFSELECTION ? m_aGroupPositions[_nRow] : sal_Int32(NO_GROUP); }
120 :
121 0 : inline ::svt::ComboBoxControl* getExpressionControl() const { return m_pComboCell; }
122 :
123 : /** returns the sequence with the selected groups
124 : */
125 : uno::Sequence<uno::Any> fillSelectedGroups();
126 :
127 : /** move groups given by _aGroups
128 : */
129 : void moveGroups(const uno::Sequence<uno::Any>& _aGroups,sal_Int32 _nRow,sal_Bool _bSelect = sal_True);
130 :
131 : virtual sal_Bool CursorMoving(long nNewRow, sal_uInt16 nNewCol);
132 : using OFieldExpressionControl_Base::GetRowCount;
133 : protected:
134 : virtual sal_Bool IsTabAllowed(sal_Bool bForward) const;
135 :
136 : virtual void InitController( ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol );
137 : virtual ::svt::CellController* GetController( long nRow, sal_uInt16 nCol );
138 : virtual void PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColId ) const;
139 : virtual sal_Bool SeekRow( long nRow );
140 : virtual sal_Bool SaveModified();
141 : virtual String GetCellText( long nRow, sal_uInt16 nColId ) const;
142 : virtual RowStatus GetRowStatus(long nRow) const;
143 :
144 : virtual void KeyInput(const KeyEvent& rEvt);
145 : virtual void Command( const CommandEvent& rEvt );
146 :
147 : // D&D
148 : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
149 : virtual sal_Int8 AcceptDrop( const BrowserAcceptDropEvent& rEvt );
150 : virtual sal_Int8 ExecuteDrop( const BrowserExecuteDropEvent& rEvt );
151 :
152 : using BrowseBox::AcceptDrop;
153 : using BrowseBox::ExecuteDrop;
154 :
155 : private:
156 :
157 : DECL_LINK( DelayedPaste, void* );
158 : DECL_LINK( CBChangeHdl,ComboBox*);
159 :
160 : void InsertRows( long nRow );
161 :
162 : public:
163 : DECL_LINK( DelayedDelete, void* );
164 :
165 : };
166 : //========================================================================
167 : // class OFieldExpressionControl
168 : //========================================================================
169 : DBG_NAME( rpt_OFieldExpressionControl )
170 : //------------------------------------------------------------------------
171 0 : OFieldExpressionControl::OFieldExpressionControl( OGroupsSortingDialog* _pParent,const ResId& _rResId )
172 : :EditBrowseBox( _pParent, _rResId,EBBF_NONE, WB_TABSTOP | BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION | BROWSER_AUTOSIZE_LASTCOL |
173 : BROWSER_KEEPSELECTION | BROWSER_HLINESFULL | BROWSER_VLINESFULL)
174 : ,m_aGroupPositions(GROUPS_START_LEN,-1)
175 : ,m_pComboCell(NULL)
176 : ,m_nDataPos(-1)
177 : ,m_nCurrentPos(-1)
178 : ,m_nPasteEvent(0)
179 : ,m_nDeleteEvent(0)
180 : ,m_pParent(_pParent)
181 0 : ,m_bIgnoreEvent(false)
182 : {
183 : DBG_CTOR( rpt_OFieldExpressionControl,NULL);
184 0 : SetBorderStyle(WINDOW_BORDER_MONO);
185 0 : }
186 :
187 : //------------------------------------------------------------------------
188 0 : OFieldExpressionControl::~OFieldExpressionControl()
189 : {
190 0 : acquire();
191 0 : uno::Reference< report::XGroups > xGroups = m_pParent->getGroups();
192 0 : xGroups->removeContainerListener(this);
193 : //////////////////////////////////////////////////////////////////////
194 : // delete events from queue
195 0 : if( m_nPasteEvent )
196 0 : Application::RemoveUserEvent( m_nPasteEvent );
197 0 : if( m_nDeleteEvent )
198 0 : Application::RemoveUserEvent( m_nDeleteEvent );
199 :
200 0 : delete m_pComboCell;
201 0 : DBG_DTOR( rpt_OFieldExpressionControl,NULL);
202 0 : }
203 : //------------------------------------------------------------------------------
204 0 : uno::Sequence<uno::Any> OFieldExpressionControl::fillSelectedGroups()
205 : {
206 0 : uno::Sequence<uno::Any> aList;
207 0 : ::std::vector<uno::Any> vClipboardList;
208 0 : vClipboardList.reserve(GetSelectRowCount());
209 :
210 0 : uno::Reference<report::XGroups> xGroups = m_pParent->getGroups();
211 0 : sal_Int32 nCount = xGroups->getCount();
212 0 : if ( nCount >= 1 )
213 : {
214 0 : for( long nIndex=FirstSelectedRow(); nIndex >= 0 ; nIndex=NextSelectedRow() )
215 : {
216 : try
217 : {
218 0 : if ( m_aGroupPositions[nIndex] != NO_GROUP )
219 : {
220 0 : uno::Reference< report::XGroup> xOrgGroup(xGroups->getByIndex(m_aGroupPositions[nIndex]),uno::UNO_QUERY);
221 : /*uno::Reference< report::XGroup> xCopy = xGroups->createGroup();
222 : ::comphelper::copyProperties(xOrgGroup.get(),xCopy.get());*/
223 0 : vClipboardList.push_back( uno::makeAny(xOrgGroup) );
224 : }
225 : }
226 0 : catch(uno::Exception&)
227 : {
228 : OSL_FAIL("Can not access group!");
229 : }
230 : }
231 0 : if ( !vClipboardList.empty() )
232 0 : aList = uno::Sequence< uno::Any >(&vClipboardList[0], vClipboardList.size());
233 : }
234 0 : return aList;
235 : }
236 : //------------------------------------------------------------------------------
237 0 : void OFieldExpressionControl::StartDrag( sal_Int8 /*_nAction*/ , const Point& /*_rPosPixel*/ )
238 : {
239 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
240 0 : if ( m_pParent && !m_pParent->isReadOnly( ) )
241 : {
242 0 : uno::Sequence<uno::Any> aClipboardList = fillSelectedGroups();
243 :
244 0 : if( aClipboardList.getLength() )
245 : {
246 0 : OGroupExchange* pData = new OGroupExchange(aClipboardList);
247 0 : uno::Reference< ::com::sun::star::datatransfer::XTransferable> xRef = pData;
248 0 : pData->StartDrag(this, DND_ACTION_MOVE );
249 0 : }
250 : }
251 0 : }
252 : //------------------------------------------------------------------------------
253 0 : sal_Int8 OFieldExpressionControl::AcceptDrop( const BrowserAcceptDropEvent& rEvt )
254 : {
255 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
256 0 : sal_Int8 nAction = DND_ACTION_NONE;
257 0 : if ( IsEditing() )
258 : {
259 0 : sal_uInt16 nPos = m_pComboCell->GetSelectEntryPos();
260 0 : if ( COMBOBOX_ENTRY_NOTFOUND != nPos || m_pComboCell->GetText().Len() )
261 0 : SaveModified();
262 0 : DeactivateCell();
263 : }
264 0 : if ( IsDropFormatSupported( OGroupExchange::getReportGroupId() ) && m_pParent->getGroups()->getCount() > 1 && rEvt.GetWindow() == &GetDataWindow() )
265 : {
266 0 : nAction = DND_ACTION_MOVE;
267 : }
268 0 : return nAction;
269 : }
270 : //------------------------------------------------------------------------------
271 0 : sal_Int8 OFieldExpressionControl::ExecuteDrop( const BrowserExecuteDropEvent& rEvt )
272 : {
273 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
274 0 : sal_Int8 nAction = DND_ACTION_NONE;
275 0 : if ( IsDropFormatSupported( OGroupExchange::getReportGroupId() ) )
276 : {
277 0 : sal_Int32 nRow = GetRowAtYPosPixel(rEvt.maPosPixel.Y(), sal_False);
278 0 : SetNoSelection();
279 :
280 0 : TransferableDataHelper aDropped( rEvt.maDropEvent.Transferable );
281 0 : uno::Any aDrop = aDropped.GetAny(OGroupExchange::getReportGroupId());
282 0 : uno::Sequence< uno::Any > aGroups;
283 0 : aDrop >>= aGroups;
284 0 : if ( aGroups.getLength() )
285 : {
286 0 : moveGroups(aGroups,nRow);
287 0 : nAction = DND_ACTION_MOVE;
288 0 : }
289 : }
290 0 : return nAction;
291 : }
292 : //------------------------------------------------------------------------------
293 0 : void OFieldExpressionControl::moveGroups(const uno::Sequence<uno::Any>& _aGroups,sal_Int32 _nRow,sal_Bool _bSelect)
294 : {
295 0 : if ( _aGroups.getLength() )
296 : {
297 0 : m_bIgnoreEvent = true;
298 : {
299 0 : sal_Int32 nRow = _nRow;
300 0 : const String sUndoAction(ModuleRes(RID_STR_UNDO_MOVE_GROUP));
301 0 : const UndoContext aUndoContext( m_pParent->m_pController->getUndoManager(), sUndoAction );
302 :
303 0 : uno::Reference< report::XGroups> xGroups = m_pParent->getGroups();
304 0 : const uno::Any* pIter = _aGroups.getConstArray();
305 0 : const uno::Any* pEnd = pIter + _aGroups.getLength();
306 0 : for(;pIter != pEnd;++pIter)
307 : {
308 0 : uno::Reference< report::XGroup> xGroup(*pIter,uno::UNO_QUERY);
309 0 : if ( xGroup.is() )
310 : {
311 0 : uno::Sequence< beans::PropertyValue > aArgs(1);
312 0 : aArgs[0].Name = PROPERTY_GROUP;
313 0 : aArgs[0].Value <<= xGroup;
314 : // we use this way to create undo actions
315 0 : m_pParent->m_pController->executeChecked(SID_GROUP_REMOVE,aArgs);
316 0 : aArgs.realloc(2);
317 0 : if ( nRow > xGroups->getCount() )
318 0 : nRow = xGroups->getCount();
319 0 : if ( _bSelect )
320 0 : SelectRow(nRow);
321 0 : aArgs[1].Name = PROPERTY_POSITIONY;
322 0 : aArgs[1].Value <<= nRow;
323 0 : m_pParent->m_pController->executeChecked(SID_GROUP_APPEND,aArgs);
324 0 : ++nRow;
325 : }
326 0 : }
327 : }
328 0 : m_bIgnoreEvent = false;
329 0 : Invalidate();
330 : }
331 0 : }
332 : // -----------------------------------------------------------------------------
333 0 : void OFieldExpressionControl::fillColumns(const uno::Reference< container::XNameAccess>& _xColumns)
334 : {
335 0 : m_pComboCell->Clear();
336 0 : if ( _xColumns.is() )
337 0 : lcl_addToList_throw(*m_pComboCell,m_aColumnInfo,_xColumns);
338 0 : }
339 : //------------------------------------------------------------------------------
340 0 : void OFieldExpressionControl::lateInit()
341 : {
342 0 : uno::Reference< report::XGroups > xGroups = m_pParent->getGroups();
343 0 : sal_Int32 nGroupsCount = xGroups->getCount();
344 0 : m_aGroupPositions.resize(::std::max<sal_Int32>(nGroupsCount,sal_Int32(GROUPS_START_LEN)),NO_GROUP);
345 0 : ::std::vector<sal_Int32>::iterator aIter = m_aGroupPositions.begin();
346 0 : for (sal_Int32 i = 0; i < nGroupsCount; ++i,++aIter)
347 0 : *aIter = i;
348 :
349 0 : if ( ColCount() == 0 )
350 : {
351 0 : Font aFont( GetDataWindow().GetFont() );
352 0 : aFont.SetWeight( WEIGHT_NORMAL );
353 0 : GetDataWindow().SetFont( aFont );
354 :
355 : // Font fuer die Ueberschriften auf Light setzen
356 0 : aFont = GetFont();
357 0 : aFont.SetWeight( WEIGHT_LIGHT );
358 0 : SetFont(aFont);
359 :
360 0 : InsertHandleColumn(static_cast<sal_uInt16>(GetTextWidth(rtl::OUString('0')) * 4)/*, sal_True */);
361 0 : InsertDataColumn( FIELD_EXPRESSION, String(ModuleRes(STR_RPT_EXPRESSION)), 100);
362 :
363 0 : m_pComboCell = new ComboBoxControl( &GetDataWindow() );
364 0 : m_pComboCell->SetSelectHdl(LINK(this,OFieldExpressionControl,CBChangeHdl));
365 0 : m_pComboCell->SetHelpId(HID_RPT_FIELDEXPRESSION);
366 :
367 0 : Control* pControls[] = {m_pComboCell};
368 0 : for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
369 : {
370 0 : pControls[i]->SetGetFocusHdl(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusGot));
371 0 : pControls[i]->SetLoseFocusHdl(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusLost));
372 : }
373 :
374 : //////////////////////////////////////////////////////////////////////
375 : // set browse mode
376 : BrowserMode nMode(BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION | BROWSER_KEEPSELECTION |
377 0 : BROWSER_HLINESFULL | BROWSER_VLINESFULL | BROWSER_AUTOSIZE_LASTCOL | BROWSER_AUTO_VSCROLL | BROWSER_AUTO_HSCROLL);
378 0 : if( m_pParent->isReadOnly() )
379 0 : nMode |= BROWSER_HIDECURSOR;
380 0 : SetMode(nMode);
381 0 : xGroups->addContainerListener(this);
382 : }
383 : else
384 : // not the first call
385 0 : RowRemoved(0, GetRowCount());
386 :
387 0 : RowInserted(0, m_aGroupPositions.size(), sal_True);
388 0 : }
389 : // -----------------------------------------------------------------------------
390 : // -----------------------------------------------------------------------------
391 0 : IMPL_LINK( OFieldExpressionControl, CBChangeHdl, ComboBox*, /*pComboBox*/ )
392 : {
393 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
394 :
395 0 : SaveModified();
396 0 : return 0L;
397 : }
398 :
399 : //------------------------------------------------------------------------------
400 0 : sal_Bool OFieldExpressionControl::IsTabAllowed(sal_Bool /*bForward*/) const
401 : {
402 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
403 0 : return sal_False;
404 : }
405 :
406 : //------------------------------------------------------------------------------
407 0 : sal_Bool OFieldExpressionControl::SaveModified()
408 : {
409 0 : return SaveModified(true);
410 : }
411 : //------------------------------------------------------------------------------
412 0 : sal_Bool OFieldExpressionControl::SaveModified(bool _bAppendRow)
413 : {
414 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
415 0 : sal_Int32 nRow = GetCurRow();
416 0 : if ( nRow != BROWSER_ENDOFSELECTION )
417 : {
418 0 : sal_Bool bAppend = sal_False;
419 : try
420 : {
421 0 : uno::Reference< report::XGroup> xGroup;
422 0 : if ( m_aGroupPositions[nRow] == NO_GROUP )
423 : {
424 0 : bAppend = sal_True;
425 0 : String sUndoAction(ModuleRes(RID_STR_UNDO_APPEND_GROUP));
426 0 : m_pParent->m_pController->getUndoManager().EnterListAction( sUndoAction, String() );
427 0 : xGroup = m_pParent->getGroups()->createGroup();
428 0 : xGroup->setHeaderOn(sal_True);
429 :
430 0 : uno::Sequence< beans::PropertyValue > aArgs(2);
431 0 : aArgs[0].Name = PROPERTY_GROUP;
432 0 : aArgs[0].Value <<= xGroup;
433 : // find position where to insert the new group
434 0 : sal_Int32 nGroupPos = 0;
435 0 : ::std::vector<sal_Int32>::iterator aIter = m_aGroupPositions.begin();
436 0 : ::std::vector<sal_Int32>::iterator aEnd = m_aGroupPositions.begin() + nRow;
437 0 : for(;aIter != aEnd;++aIter)
438 0 : if ( *aIter != NO_GROUP )
439 0 : nGroupPos = *aIter + 1;
440 0 : aArgs[1].Name = PROPERTY_POSITIONY;
441 0 : aArgs[1].Value <<= nGroupPos;
442 0 : m_bIgnoreEvent = true;
443 0 : m_pParent->m_pController->executeChecked(SID_GROUP_APPEND,aArgs);
444 0 : m_bIgnoreEvent = false;
445 : OSL_ENSURE(*aIter == NO_GROUP ,"Illegal iterator!");
446 0 : *aIter++ = nGroupPos;
447 :
448 0 : aEnd = m_aGroupPositions.end();
449 0 : for(;aIter != aEnd;++aIter)
450 0 : if ( *aIter != NO_GROUP )
451 0 : ++*aIter;
452 : }
453 : else
454 0 : xGroup = m_pParent->getGroup(m_aGroupPositions[nRow]);
455 0 : if ( xGroup.is() )
456 : {
457 0 : sal_uInt16 nPos = m_pComboCell->GetSelectEntryPos();
458 0 : ::rtl::OUString sExpression;
459 0 : if ( COMBOBOX_ENTRY_NOTFOUND == nPos )
460 0 : sExpression = m_pComboCell->GetText();
461 : else
462 : {
463 0 : sExpression = m_aColumnInfo[nPos].sColumnName;
464 : }
465 0 : xGroup->setExpression( sExpression );
466 :
467 0 : ::rptui::adjustSectionName(xGroup,nPos);
468 :
469 0 : if ( bAppend )
470 0 : m_pParent->m_pController->getUndoManager().LeaveListAction();
471 : }
472 :
473 0 : if ( Controller() )
474 0 : Controller()->ClearModified();
475 0 : if ( _bAppendRow && GetRowCount() == m_pParent->getGroups()->getCount() )
476 : {
477 0 : RowInserted( GetRowCount()-1);
478 0 : m_aGroupPositions.push_back(NO_GROUP);
479 : }
480 :
481 0 : GoToRow(nRow);
482 0 : m_pParent->DisplayData(nRow);
483 : }
484 0 : catch(uno::Exception&)
485 : {
486 : OSL_FAIL("OFieldExpressionControl::SaveModified: Exception caught!");
487 : }
488 : }
489 :
490 0 : return sal_True;
491 : }
492 : //------------------------------------------------------------------------------
493 0 : String OFieldExpressionControl::GetCellText( long nRow, sal_uInt16 /*nColId*/ ) const
494 : {
495 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
496 0 : String sText;
497 0 : if ( nRow != BROWSER_ENDOFSELECTION && m_aGroupPositions[nRow] != NO_GROUP )
498 : {
499 : try
500 : {
501 0 : uno::Reference< report::XGroup> xGroup = m_pParent->getGroup(m_aGroupPositions[nRow]);
502 0 : ::rtl::OUString sExpression = xGroup->getExpression();
503 :
504 0 : for(::std::vector<ColumnInfo>::const_iterator aIter = m_aColumnInfo.begin(); aIter != m_aColumnInfo.end();++aIter)
505 : {
506 0 : if ( aIter->sColumnName == sExpression )
507 : {
508 0 : if ( !aIter->sLabel.isEmpty() )
509 0 : sExpression = aIter->sLabel;
510 0 : break;
511 : }
512 : }
513 0 : sText = sExpression;
514 : }
515 0 : catch(uno::Exception&)
516 : {
517 : OSL_FAIL("Exception caught while getting expression value from the group");
518 : }
519 : }
520 0 : return sText;
521 : }
522 :
523 : //------------------------------------------------------------------------------
524 0 : void OFieldExpressionControl::InitController( CellControllerRef& /*rController*/, long nRow, sal_uInt16 nColumnId )
525 : {
526 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
527 :
528 0 : m_pComboCell->SetText( GetCellText( nRow, nColumnId ) );
529 0 : }
530 : //------------------------------------------------------------------------------
531 0 : sal_Bool OFieldExpressionControl::CursorMoving(long nNewRow, sal_uInt16 nNewCol)
532 : {
533 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
534 :
535 0 : if (!EditBrowseBox::CursorMoving(nNewRow, nNewCol))
536 0 : return sal_False;
537 0 : m_nDataPos = nNewRow;
538 0 : long nOldDataPos = GetCurRow();
539 0 : InvalidateStatusCell( m_nDataPos );
540 0 : InvalidateStatusCell( nOldDataPos );
541 :
542 0 : m_pParent->SaveData( nOldDataPos );
543 0 : m_pParent->DisplayData( m_nDataPos );
544 0 : return sal_True;
545 : }
546 : //------------------------------------------------------------------------------
547 0 : CellController* OFieldExpressionControl::GetController( long /*nRow*/, sal_uInt16 /*nColumnId*/ )
548 : {
549 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
550 0 : ComboBoxCellController* pCellController = new ComboBoxCellController( m_pComboCell );
551 0 : pCellController->GetComboBox().SetReadOnly(!m_pParent->m_pController->isEditable());
552 0 : return pCellController;
553 : }
554 :
555 : //------------------------------------------------------------------------------
556 0 : sal_Bool OFieldExpressionControl::SeekRow( long _nRow )
557 : {
558 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
559 : // die Basisklasse braucht den Aufruf, da sie sich dort merkt, welche Zeile gepainted wird
560 0 : EditBrowseBox::SeekRow(_nRow);
561 0 : m_nCurrentPos = _nRow;
562 0 : return sal_True;
563 : }
564 :
565 : //------------------------------------------------------------------------------
566 0 : void OFieldExpressionControl::PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const
567 : {
568 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
569 0 : String aText =const_cast< OFieldExpressionControl*>(this)->GetCellText( m_nCurrentPos, nColumnId );
570 :
571 0 : Point aPos( rRect.TopLeft() );
572 0 : Size aTextSize( GetDataWindow().GetTextHeight(),GetDataWindow().GetTextWidth( aText ));
573 :
574 0 : if( aPos.X() < rRect.Right() || aPos.X() + aTextSize.Width() > rRect.Right() ||
575 0 : aPos.Y() < rRect.Top() || aPos.Y() + aTextSize.Height() > rRect.Bottom() )
576 0 : rDev.SetClipRegion( rRect );
577 :
578 0 : rDev.DrawText( aPos, aText );
579 :
580 0 : if( rDev.IsClipRegion() )
581 0 : rDev.SetClipRegion();
582 0 : }
583 : //------------------------------------------------------------------------------
584 0 : EditBrowseBox::RowStatus OFieldExpressionControl::GetRowStatus(long nRow) const
585 : {
586 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
587 0 : if (nRow >= 0 && nRow == m_nDataPos)
588 0 : return EditBrowseBox::CURRENT;
589 0 : if ( nRow != BROWSER_ENDOFSELECTION && nRow < static_cast<long>(m_aGroupPositions.size()) && m_aGroupPositions[nRow] != NO_GROUP )
590 : {
591 : try
592 : {
593 0 : uno::Reference< report::XGroup> xGroup = m_pParent->getGroup(m_aGroupPositions[nRow]);
594 0 : return (xGroup->getHeaderOn() || xGroup->getFooterOn())? EditBrowseBox::HEADERFOOTER : EditBrowseBox::CLEAN;
595 : }
596 0 : catch(uno::Exception&)
597 : {
598 : OSL_FAIL("Exception cathced while try to get a group!");
599 : }
600 : }
601 0 : return EditBrowseBox::CLEAN;
602 : }
603 : // XEventListener
604 : //------------------------------------------------------------------------------
605 0 : void SAL_CALL OFieldExpressionControl::disposing(const lang::EventObject& /*e*/) throw( uno::RuntimeException )
606 : {
607 0 : }
608 : //------------------------------------------------------------------------------
609 : // XContainerListener
610 : //------------------------------------------------------------------------------
611 0 : void SAL_CALL OFieldExpressionControl::elementInserted(const container::ContainerEvent& evt) throw(uno::RuntimeException)
612 : {
613 0 : if ( m_bIgnoreEvent )
614 0 : return;
615 0 : SolarMutexGuard aSolarGuard;
616 0 : ::osl::MutexGuard aGuard( m_aMutex );
617 0 : sal_Int32 nGroupPos = 0;
618 0 : if ( evt.Accessor >>= nGroupPos )
619 : {
620 0 : if ( nGroupPos >= GetRowCount() )
621 : {
622 0 : sal_Int32 nAddedRows = nGroupPos - GetRowCount();
623 0 : RowInserted(nAddedRows);
624 0 : for (sal_Int32 i = 0; i < nAddedRows; ++i)
625 0 : m_aGroupPositions.push_back(NO_GROUP);
626 0 : m_aGroupPositions[nGroupPos] = nGroupPos;
627 : }
628 : else
629 : {
630 0 : ::std::vector<sal_Int32>::iterator aFind = m_aGroupPositions.begin()+ nGroupPos;
631 0 : if ( aFind == m_aGroupPositions.end() )
632 0 : aFind = ::std::find(m_aGroupPositions.begin(),m_aGroupPositions.end(),NO_GROUP);
633 :
634 0 : if ( aFind != m_aGroupPositions.end() )
635 : {
636 0 : if ( *aFind != NO_GROUP )
637 0 : aFind = m_aGroupPositions.insert(aFind,nGroupPos);
638 : else
639 0 : *aFind = nGroupPos;
640 :
641 0 : ::std::vector<sal_Int32>::iterator aEnd = m_aGroupPositions.end();
642 0 : for(++aFind;aFind != aEnd;++aFind)
643 0 : if ( *aFind != NO_GROUP )
644 0 : ++*aFind;
645 : }
646 : }
647 0 : Invalidate();
648 0 : }
649 : }
650 : //------------------------------------------------------------------------------
651 0 : void SAL_CALL OFieldExpressionControl::elementReplaced(const container::ContainerEvent& /*evt*/) throw(uno::RuntimeException)
652 : {
653 0 : }
654 : //------------------------------------------------------------------------------
655 0 : void SAL_CALL OFieldExpressionControl::elementRemoved(const container::ContainerEvent& evt) throw(uno::RuntimeException)
656 : {
657 0 : SolarMutexGuard aSolarGuard;
658 0 : ::osl::MutexGuard aGuard( m_aMutex );
659 :
660 0 : if ( m_bIgnoreEvent )
661 0 : return;
662 :
663 0 : sal_Int32 nGroupPos = 0;
664 0 : if ( evt.Accessor >>= nGroupPos )
665 : {
666 0 : ::std::vector<sal_Int32>::iterator aFind = ::std::find(m_aGroupPositions.begin(),m_aGroupPositions.end(),nGroupPos);
667 0 : if ( aFind != m_aGroupPositions.end() )
668 : {
669 0 : *aFind = NO_GROUP;
670 0 : ::std::vector<sal_Int32>::iterator aEnd = m_aGroupPositions.end();
671 0 : for(++aFind;aFind != aEnd;++aFind)
672 0 : if ( *aFind != NO_GROUP )
673 0 : --*aFind;
674 0 : Invalidate();
675 : }
676 0 : }
677 : }
678 : //------------------------------------------------------------------------------
679 0 : sal_Bool OFieldExpressionControl::IsDeleteAllowed( )
680 : {
681 0 : return !m_pParent->isReadOnly() && GetSelectRowCount() > 0;
682 : }
683 : //------------------------------------------------------------------------
684 0 : void OFieldExpressionControl::KeyInput( const KeyEvent& rEvt )
685 : {
686 0 : if (IsDeleteAllowed())
687 : {
688 0 : if (rEvt.GetKeyCode().GetCode() == KEY_DELETE && // Delete rows
689 0 : !rEvt.GetKeyCode().IsShift() &&
690 0 : !rEvt.GetKeyCode().IsMod1())
691 : {
692 0 : DeleteRows();
693 0 : return;
694 : }
695 : }
696 0 : EditBrowseBox::KeyInput(rEvt);
697 : }
698 : //------------------------------------------------------------------------
699 0 : void OFieldExpressionControl::Command(const CommandEvent& rEvt)
700 : {
701 0 : switch (rEvt.GetCommand())
702 : {
703 : case COMMAND_CONTEXTMENU:
704 : {
705 0 : if (!rEvt.IsMouseEvent())
706 : {
707 0 : EditBrowseBox::Command(rEvt);
708 0 : return;
709 : }
710 :
711 0 : sal_uInt16 nColId = GetColumnAtXPosPixel(rEvt.GetMousePosPixel().X());
712 :
713 0 : if ( nColId == HANDLE_ID )
714 : {
715 0 : PopupMenu aContextMenu(ModuleRes(RID_GROUPSROWPOPUPMENU));
716 0 : sal_Bool bEnable = sal_False;
717 0 : long nIndex = FirstSelectedRow();
718 0 : while( nIndex >= 0 && !bEnable )
719 : {
720 0 : if ( m_aGroupPositions[nIndex] != NO_GROUP )
721 0 : bEnable = sal_True;
722 0 : nIndex = NextSelectedRow();
723 : }
724 0 : aContextMenu.EnableItem( SID_DELETE, IsDeleteAllowed() && bEnable );
725 0 : switch (aContextMenu.Execute(this, rEvt.GetMousePosPixel()))
726 : {
727 : case SID_CUT:
728 0 : cut();
729 0 : break;
730 : case SID_COPY:
731 0 : copy();
732 0 : break;
733 : case SID_PASTE:
734 0 : paste();
735 0 : break;
736 :
737 : case SID_DELETE:
738 0 : if( m_nDeleteEvent )
739 0 : Application::RemoveUserEvent( m_nDeleteEvent );
740 0 : m_nDeleteEvent = Application::PostUserEvent( LINK(this, OFieldExpressionControl, DelayedDelete) );
741 0 : break;
742 : default:
743 0 : break;
744 0 : }
745 : }
746 : // run through
747 : }
748 : default:
749 0 : EditBrowseBox::Command(rEvt);
750 : }
751 :
752 : }
753 : //------------------------------------------------------------------------------
754 0 : void OFieldExpressionControl::DeleteRows()
755 : {
756 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
757 :
758 0 : sal_Bool bIsEditing = IsEditing();
759 0 : if (bIsEditing)
760 : {
761 0 : DeactivateCell();
762 : }
763 0 : long nIndex = FirstSelectedRow();
764 0 : if (nIndex == -1)
765 : {
766 0 : nIndex = GetCurRow();
767 : }
768 0 : bool bFirstTime = true;
769 :
770 0 : long nOldDataPos = nIndex;
771 0 : uno::Sequence< beans::PropertyValue > aArgs(1);
772 0 : aArgs[0].Name = PROPERTY_GROUP;
773 0 : m_bIgnoreEvent = true;
774 0 : while( nIndex >= 0 )
775 : {
776 0 : if ( m_aGroupPositions[nIndex] != NO_GROUP )
777 : {
778 0 : if ( bFirstTime )
779 : {
780 0 : bFirstTime = false;
781 0 : String sUndoAction(ModuleRes(RID_STR_UNDO_REMOVE_SELECTION));
782 0 : m_pParent->m_pController->getUndoManager().EnterListAction( sUndoAction, String() );
783 : }
784 :
785 0 : sal_Int32 nGroupPos = m_aGroupPositions[nIndex];
786 0 : uno::Reference< report::XGroup> xGroup = m_pParent->getGroup(nGroupPos);
787 0 : aArgs[0].Value <<= xGroup;
788 : // we use this way to create undo actions
789 0 : m_pParent->m_pController->executeChecked(SID_GROUP_REMOVE,aArgs);
790 :
791 0 : ::std::vector<sal_Int32>::iterator aFind = ::std::find(m_aGroupPositions.begin(),m_aGroupPositions.end(),nGroupPos);
792 0 : *aFind = NO_GROUP;
793 0 : ::std::vector<sal_Int32>::iterator aEnd = m_aGroupPositions.end();
794 0 : for(++aFind;aFind != aEnd;++aFind)
795 0 : if ( *aFind != NO_GROUP )
796 0 : --*aFind;
797 : }
798 0 : nIndex = NextSelectedRow();
799 : }
800 :
801 0 : if ( !bFirstTime )
802 0 : m_pParent->m_pController->getUndoManager().LeaveListAction();
803 :
804 0 : m_nDataPos = GetCurRow();
805 0 : InvalidateStatusCell( nOldDataPos );
806 0 : InvalidateStatusCell( m_nDataPos );
807 0 : ActivateCell();
808 0 : m_pParent->DisplayData( m_nDataPos );
809 0 : m_bIgnoreEvent = false;
810 0 : Invalidate();
811 0 : }
812 : //------------------------------------------------------------------------------
813 : //------------------------------------------------------------------------------
814 0 : void OFieldExpressionControl::cut()
815 : {
816 0 : copy();
817 0 : DeleteRows();
818 0 : }
819 :
820 : //------------------------------------------------------------------------------
821 0 : void OFieldExpressionControl::copy()
822 : {
823 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
824 : //////////////////////////////////////////////////////////////////////
825 : // set to the right row and save it
826 0 : m_pParent->SaveData( m_nDataPos );
827 :
828 0 : uno::Sequence<uno::Any> aClipboardList = fillSelectedGroups();
829 :
830 0 : if( aClipboardList.getLength() )
831 : {
832 0 : OGroupExchange* pData = new OGroupExchange(aClipboardList);
833 0 : uno::Reference< ::com::sun::star::datatransfer::XTransferable> xRef = pData;
834 0 : pData->CopyToClipboard(GetParent());
835 0 : }
836 0 : }
837 :
838 : //------------------------------------------------------------------------------
839 0 : void OFieldExpressionControl::paste()
840 : {
841 0 : TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
842 0 : if(aTransferData.HasFormat(OGroupExchange::getReportGroupId()))
843 : {
844 0 : if( m_nPasteEvent )
845 0 : Application::RemoveUserEvent( m_nPasteEvent );
846 0 : m_nPasteEvent = Application::PostUserEvent( LINK(this, OFieldExpressionControl, DelayedPaste) );
847 0 : }
848 0 : }
849 : //------------------------------------------------------------------------------
850 0 : IMPL_LINK( OFieldExpressionControl, DelayedPaste, void*, )
851 : {
852 0 : m_nPasteEvent = 0;
853 :
854 0 : sal_Int32 nPastePosition = GetSelectRowCount() ? FirstSelectedRow() : GetCurRow();
855 :
856 0 : InsertRows( nPastePosition );
857 0 : SetNoSelection();
858 0 : GoToRow( nPastePosition );
859 :
860 0 : return 0;
861 : }
862 : //------------------------------------------------------------------------------
863 0 : IMPL_LINK( OFieldExpressionControl, DelayedDelete, void*, )
864 : {
865 0 : m_nDeleteEvent = 0;
866 0 : DeleteRows();
867 0 : return 0;
868 : }
869 : //------------------------------------------------------------------------------
870 0 : void OFieldExpressionControl::InsertRows( long nRow )
871 : {
872 : DBG_CHKTHIS( rpt_OFieldExpressionControl,NULL);
873 :
874 0 : sal_Int32 nSize = 0;
875 : //////////////////////////////////////////////////////////////////////
876 : // get rows from clipboard
877 0 : TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
878 0 : if(aTransferData.HasFormat(OGroupExchange::getReportGroupId()))
879 : {
880 0 : datatransfer::DataFlavor aFlavor;
881 0 : SotExchange::GetFormatDataFlavor(OGroupExchange::getReportGroupId(), aFlavor);
882 0 : uno::Sequence< uno::Any > aGroups;
883 :
884 0 : if( (aTransferData.GetAny(aFlavor) >>= aGroups) && aGroups.getLength() )
885 : {
886 0 : m_bIgnoreEvent = false;
887 : {
888 0 : const String sUndoAction(ModuleRes(RID_STR_UNDO_APPEND_GROUP));
889 0 : const UndoContext aUndoContext( m_pParent->m_pController->getUndoManager(), sUndoAction );
890 :
891 0 : uno::Reference<report::XGroups> xGroups = m_pParent->getGroups();
892 0 : sal_Int32 nGroupPos = 0;
893 0 : ::std::vector<sal_Int32>::iterator aIter = m_aGroupPositions.begin();
894 0 : ::std::vector<sal_Int32>::size_type nRowPos = static_cast< ::std::vector<sal_Int32>::size_type >(nRow);
895 0 : if ( nRowPos < m_aGroupPositions.size() )
896 : {
897 0 : ::std::vector<sal_Int32>::iterator aEnd = m_aGroupPositions.begin() + nRowPos;
898 0 : for(;aIter != aEnd;++aIter)
899 : {
900 0 : if ( *aIter != NO_GROUP )
901 0 : nGroupPos = *aIter;
902 : }
903 : }
904 0 : for(sal_Int32 i=0;i < aGroups.getLength();++i,++nSize)
905 : {
906 0 : uno::Sequence< beans::PropertyValue > aArgs(2);
907 0 : aArgs[0].Name = PROPERTY_GROUP;
908 0 : aArgs[0].Value = aGroups[i];
909 0 : aArgs[1].Name = PROPERTY_POSITIONY;
910 0 : aArgs[1].Value <<= nGroupPos;
911 0 : m_pParent->m_pController->executeChecked(SID_GROUP_APPEND,aArgs);
912 :
913 0 : ::std::vector<sal_Int32>::iterator aInsertPos = m_aGroupPositions.insert(aIter,nGroupPos);
914 0 : ++aInsertPos;
915 0 : aIter = aInsertPos;
916 0 : ::std::vector<sal_Int32>::iterator aEnd = m_aGroupPositions.end();
917 0 : for(;aInsertPos != aEnd;++aInsertPos)
918 0 : if ( *aInsertPos != NO_GROUP )
919 0 : ++*aInsertPos;
920 0 : }
921 : }
922 0 : m_bIgnoreEvent = true;
923 0 : }
924 : }
925 :
926 0 : RowInserted( nRow,nSize,sal_True );
927 0 : }
928 : //------------------------------------------------------------------------------
929 :
930 : DBG_NAME( rpt_OGroupsSortingDialog )
931 : //========================================================================
932 : // class OGroupsSortingDialog
933 : //========================================================================
934 0 : OGroupsSortingDialog::OGroupsSortingDialog( Window* _pParent
935 : ,sal_Bool _bReadOnly
936 : ,OReportController* _pController)
937 : : FloatingWindow( _pParent, ModuleRes(RID_GROUPS_SORTING) )
938 : ,OPropertyChangeListener(m_aMutex)
939 : ,m_aFL2(this, ModuleRes(FL_SEPARATOR2) )
940 : ,m_aMove(this, ModuleRes(FT_MOVELABEL) )
941 : ,m_aToolBox(this, ModuleRes(TB_TOOLBOX) )
942 :
943 : ,m_aFL3(this, ModuleRes(FL_SEPARATOR3) )
944 : ,m_aOrder(this, ModuleRes(FT_ORDER) )
945 : ,m_aOrderLst(this, ModuleRes(LST_ORDER) )
946 : ,m_aHeader(this, ModuleRes(FT_HEADER) )
947 : ,m_aHeaderLst(this, ModuleRes(LST_HEADERLST) )
948 : ,m_aFooter(this, ModuleRes(FT_FOOTER) )
949 : ,m_aFooterLst(this, ModuleRes(LST_FOOTERLST) )
950 : ,m_aGroupOn(this, ModuleRes(FT_GROUPON) )
951 : ,m_aGroupOnLst(this, ModuleRes(LST_GROUPONLST) )
952 : ,m_aGroupInterval(this, ModuleRes(FT_GROUPINTERVAL) )
953 : ,m_aGroupIntervalEd(this, ModuleRes(ED_GROUPINTERVALLST) )
954 : ,m_aKeepTogether(this, ModuleRes(FT_KEEPTOGETHER) )
955 : ,m_aKeepTogetherLst(this, ModuleRes(LST_KEEPTOGETHERLST) )
956 : ,m_aFL(this, ModuleRes(FL_SEPARATOR1) )
957 : ,m_aHelpWindow(this, ModuleRes(HELP_FIELD) )
958 0 : ,m_pFieldExpression( new OFieldExpressionControl(this,ModuleRes(WND_CONTROL)))
959 : ,m_pController(_pController)
960 : ,m_pCurrentGroupListener(NULL)
961 0 : ,m_xGroups(m_pController->getReportDefinition()->getGroups())
962 0 : ,m_bReadOnly(_bReadOnly)
963 : {
964 : DBG_CTOR( rpt_OGroupsSortingDialog,NULL);
965 :
966 0 : Control* pControlsLst[] = { &m_aHeaderLst, &m_aFooterLst, &m_aGroupOnLst, &m_aKeepTogetherLst, &m_aOrderLst, &m_aGroupIntervalEd};
967 0 : for (size_t i = 0; i < sizeof (pControlsLst) / sizeof (pControlsLst[0]); ++i)
968 : {
969 0 : pControlsLst[i]->SetGetFocusHdl(LINK(this, OGroupsSortingDialog, OnControlFocusGot));
970 0 : pControlsLst[i]->SetLoseFocusHdl(LINK(this, OGroupsSortingDialog, OnControlFocusLost));
971 0 : pControlsLst[i]->Show(sal_True);
972 : }
973 :
974 0 : for (size_t i = 0; i < (sizeof (pControlsLst) / sizeof (pControlsLst[0])) - 1; ++i)
975 0 : static_cast<ListBox*>(pControlsLst[i])->SetSelectHdl(LINK(this,OGroupsSortingDialog,LBChangeHdl));
976 :
977 : Control* pControls[] = { &m_aHeader, &m_aFooter, &m_aGroupOn, &m_aGroupInterval, &m_aKeepTogether, &m_aOrder
978 0 : , &m_aMove,&m_aFL2};
979 0 : sal_Int32 nMaxTextWidth = 0;
980 0 : MnemonicGenerator aMnemonicGenerator;
981 0 : for (size_t i = 0; i < sizeof (pControlsLst) / sizeof (pControlsLst[0]); ++i)
982 0 : aMnemonicGenerator.RegisterMnemonic( pControls[i]->GetText() );
983 :
984 0 : for (size_t i = 0; i < sizeof (pControlsLst) / sizeof (pControlsLst[0]); ++i)
985 : {
986 0 : pControls[i]->Show(sal_True);
987 0 : String sText = pControls[i]->GetText();
988 0 : if ( aMnemonicGenerator.CreateMnemonic(sText) )
989 0 : pControls[i]->SetText(sText);
990 0 : sal_Int32 nTextWidth = GetTextWidth(sText);
991 0 : nMaxTextWidth = ::std::max<sal_Int32>(nTextWidth,nMaxTextWidth);
992 0 : }
993 :
994 0 : Size aSize(UNRELATED_CONTROLS, PAGE_HEIGHT);
995 0 : Size aSpace = LogicToPixel( aSize, MAP_APPFONT );
996 0 : Size aOutSize(nMaxTextWidth + m_aHeader.GetSizePixel().Width() + 3*aSpace.Width(),aSpace.Height());
997 0 : SetMinOutputSizePixel(aOutSize);
998 0 : SetOutputSizePixel(aOutSize);
999 :
1000 0 : m_pReportListener = new OPropertyChangeMultiplexer(this,m_pController->getReportDefinition().get());
1001 0 : m_pReportListener->addProperty(PROPERTY_COMMAND);
1002 0 : m_pReportListener->addProperty(PROPERTY_COMMANDTYPE);
1003 :
1004 0 : m_pFieldExpression->lateInit();
1005 0 : fillColumns();
1006 0 : m_pFieldExpression->Show();
1007 :
1008 0 : m_aHelpWindow.SetControlBackground( GetSettings().GetStyleSettings().GetFaceColor() );
1009 :
1010 0 : m_pFieldExpression->SetZOrder(&m_aFL2, WINDOW_ZORDER_BEHIND);
1011 :
1012 0 : m_aMove.SetZOrder(m_pFieldExpression, WINDOW_ZORDER_BEHIND);
1013 0 : m_aToolBox.SetStyle(m_aToolBox.GetStyle()|WB_LINESPACING);
1014 0 : m_aToolBox.SetSelectHdl(LINK(this, OGroupsSortingDialog, OnFormatAction));
1015 0 : m_aToolBox.SetImageListProvider(this);
1016 0 : setToolBox(&m_aToolBox);
1017 :
1018 0 : checkButtons(0);
1019 0 : Resize();
1020 :
1021 0 : FreeResource();
1022 0 : }
1023 :
1024 : //------------------------------------------------------------------------
1025 0 : OGroupsSortingDialog::~OGroupsSortingDialog()
1026 : {
1027 : DBG_DTOR( rpt_OGroupsSortingDialog,NULL);
1028 0 : delete m_pFieldExpression;
1029 0 : m_xColumns.clear();
1030 0 : m_pReportListener->dispose();
1031 0 : if ( m_pCurrentGroupListener.is() )
1032 0 : m_pCurrentGroupListener->dispose();
1033 0 : }
1034 : // -----------------------------------------------------------------------------
1035 0 : sal_Bool OGroupsSortingDialog::isReadOnly( ) const
1036 : {
1037 0 : return m_bReadOnly;
1038 : }
1039 : //------------------------------------------------------------------------------
1040 0 : void OGroupsSortingDialog::UpdateData( )
1041 : {
1042 0 : m_pFieldExpression->Invalidate();
1043 0 : long nCurRow = m_pFieldExpression->GetCurRow();
1044 0 : m_pFieldExpression->DeactivateCell();
1045 0 : m_pFieldExpression->ActivateCell(nCurRow, m_pFieldExpression->GetCurColumnId());
1046 0 : DisplayData(nCurRow);
1047 0 : }
1048 : //------------------------------------------------------------------------------
1049 0 : void OGroupsSortingDialog::DisplayData( sal_Int32 _nRow )
1050 : {
1051 : DBG_CHKTHIS( rpt_OGroupsSortingDialog,NULL);
1052 0 : sal_Int32 nGroupPos = m_pFieldExpression->getGroupPosition(_nRow);
1053 0 : sal_Bool bEmpty = nGroupPos == NO_GROUP;
1054 0 : m_aHeaderLst.Enable(!bEmpty);
1055 0 : m_aFooterLst.Enable(!bEmpty);
1056 0 : m_aGroupOnLst.Enable(!bEmpty);
1057 0 : m_aGroupIntervalEd.Enable(!bEmpty);
1058 0 : m_aKeepTogetherLst.Enable(!bEmpty);
1059 0 : m_aOrderLst.Enable(!bEmpty);
1060 :
1061 0 : m_aFL3.Enable(!bEmpty);
1062 0 : m_aHeader.Enable(!bEmpty);
1063 0 : m_aFooter.Enable(!bEmpty);
1064 0 : m_aGroupOn.Enable(!bEmpty);
1065 0 : m_aGroupInterval.Enable(!bEmpty);
1066 0 : m_aKeepTogether.Enable(!bEmpty);
1067 0 : m_aOrder.Enable(!bEmpty);
1068 :
1069 0 : checkButtons(_nRow);
1070 :
1071 0 : if ( m_pCurrentGroupListener.is() )
1072 0 : m_pCurrentGroupListener->dispose();
1073 0 : m_pCurrentGroupListener = NULL;
1074 0 : if ( !bEmpty && nGroupPos != NO_GROUP )
1075 : {
1076 0 : uno::Reference< report::XGroup> xGroup = getGroup(nGroupPos);
1077 :
1078 0 : m_pCurrentGroupListener = new OPropertyChangeMultiplexer(this,xGroup.get());
1079 0 : m_pCurrentGroupListener->addProperty(PROPERTY_HEADERON);
1080 0 : m_pCurrentGroupListener->addProperty(PROPERTY_FOOTERON);
1081 :
1082 0 : displayGroup(xGroup);
1083 : }
1084 0 : }
1085 : //------------------------------------------------------------------------------
1086 0 : void OGroupsSortingDialog::SaveData( sal_Int32 _nRow)
1087 : {
1088 : DBG_CHKTHIS( rpt_OGroupsSortingDialog,NULL);
1089 0 : sal_Int32 nGroupPos = m_pFieldExpression->getGroupPosition(_nRow);
1090 0 : if ( nGroupPos == NO_GROUP )
1091 0 : return;
1092 :
1093 0 : uno::Reference< report::XGroup> xGroup = getGroup(nGroupPos);
1094 0 : if ( m_aHeaderLst.GetSavedValue() != m_aHeaderLst.GetSelectEntryPos() )
1095 0 : xGroup->setHeaderOn( m_aHeaderLst.GetSelectEntryPos() == 0 );
1096 0 : if ( m_aFooterLst.GetSavedValue() != m_aFooterLst.GetSelectEntryPos() )
1097 0 : xGroup->setFooterOn( m_aFooterLst.GetSelectEntryPos() == 0 );
1098 0 : if ( m_aKeepTogetherLst.GetSavedValue() != m_aKeepTogetherLst.GetSelectEntryPos() )
1099 0 : xGroup->setKeepTogether( m_aKeepTogetherLst.GetSelectEntryPos() );
1100 0 : if ( m_aGroupOnLst.GetSavedValue() != m_aGroupOnLst.GetSelectEntryPos() )
1101 : {
1102 0 : sal_Int16 nGroupOn = static_cast<sal_Int16>(reinterpret_cast<sal_IntPtr>(m_aGroupOnLst.GetEntryData(m_aGroupOnLst.GetSelectEntryPos())));
1103 0 : xGroup->setGroupOn( nGroupOn );
1104 : }
1105 0 : if ( m_aGroupIntervalEd.GetSavedValue().ToInt32() != m_aGroupIntervalEd.GetValue() )
1106 : {
1107 0 : xGroup->setGroupInterval( static_cast<sal_Int32>(m_aGroupIntervalEd.GetValue()) );
1108 0 : m_aGroupIntervalEd.SaveValue();
1109 : }
1110 0 : if ( m_aOrderLst.GetSavedValue() != m_aOrderLst.GetSelectEntryPos() )
1111 0 : xGroup->setSortAscending( m_aOrderLst.GetSelectEntryPos() == 0 );
1112 :
1113 0 : ListBox* pControls[] = { &m_aHeaderLst,&m_aFooterLst,&m_aGroupOnLst,&m_aKeepTogetherLst,&m_aOrderLst};
1114 0 : for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
1115 0 : pControls[i]->SaveValue();
1116 : }
1117 :
1118 : // -----------------------------------------------------------------------------
1119 0 : sal_Int32 OGroupsSortingDialog::getColumnDataType(const ::rtl::OUString& _sColumnName)
1120 : {
1121 0 : sal_Int32 nDataType = sdbc::DataType::VARCHAR;
1122 : try
1123 : {
1124 0 : if ( !m_xColumns.is() )
1125 0 : fillColumns();
1126 0 : if ( m_xColumns.is() && m_xColumns->hasByName(_sColumnName) )
1127 : {
1128 0 : uno::Reference< beans::XPropertySet> xColumn(m_xColumns->getByName(_sColumnName),uno::UNO_QUERY);
1129 0 : if ( xColumn.is() )
1130 0 : xColumn->getPropertyValue(PROPERTY_TYPE) >>= nDataType;
1131 : }
1132 : }
1133 0 : catch(uno::Exception&)
1134 : {
1135 : OSL_FAIL("Eception caught while getting the type of a column");
1136 : }
1137 :
1138 0 : return nDataType;
1139 : }
1140 : //------------------------------------------------------------------------------
1141 0 : IMPL_LINK(OGroupsSortingDialog, OnControlFocusGot, Control*, pControl )
1142 : {
1143 0 : if ( m_pFieldExpression && m_pFieldExpression->getExpressionControl() )
1144 : {
1145 0 : Control* pControls[] = { m_pFieldExpression->getExpressionControl(),&m_aHeaderLst,&m_aFooterLst,&m_aGroupOnLst,&m_aGroupIntervalEd,&m_aKeepTogetherLst,&m_aOrderLst};
1146 0 : for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
1147 : {
1148 0 : if ( pControl == pControls[i] )
1149 : {
1150 0 : ListBox* pListBox = dynamic_cast< ListBox* >( pControl );
1151 0 : if ( pListBox )
1152 0 : pListBox->SaveValue();
1153 0 : NumericField* pNumericField = dynamic_cast< NumericField* >( pControl );
1154 0 : if ( pNumericField )
1155 0 : pNumericField->SaveValue();
1156 0 : showHelpText(static_cast<sal_uInt16>(i+STR_RPT_HELP_FIELD));
1157 0 : break;
1158 : }
1159 : }
1160 : }
1161 0 : return 0L;
1162 : }
1163 : //------------------------------------------------------------------------------
1164 0 : IMPL_LINK(OGroupsSortingDialog, OnControlFocusLost, Control*, pControl )
1165 : {
1166 0 : if ( m_pFieldExpression && pControl == &m_aGroupIntervalEd )
1167 : {
1168 0 : if ( m_aGroupIntervalEd.IsModified() )
1169 0 : SaveData(m_pFieldExpression->GetCurRow());
1170 : }
1171 0 : return 0L;
1172 : }
1173 : // -----------------------------------------------------------------------------
1174 0 : IMPL_LINK( OGroupsSortingDialog, OnFormatAction, ToolBox*, /*NOTINTERESTEDIN*/ )
1175 : {
1176 : DBG_CHKTHIS( rpt_OGroupsSortingDialog,NULL);
1177 :
1178 0 : sal_uInt16 nCommand = m_aToolBox.GetCurItemId();
1179 :
1180 0 : if ( m_pFieldExpression )
1181 : {
1182 0 : long nIndex = m_pFieldExpression->GetCurrRow();
1183 0 : sal_Int32 nGroupPos = m_pFieldExpression->getGroupPosition(nIndex);
1184 0 : uno::Sequence<uno::Any> aClipboardList;
1185 0 : if ( nIndex >= 0 && nGroupPos != NO_GROUP )
1186 : {
1187 0 : aClipboardList.realloc(1);
1188 0 : aClipboardList[0] = m_xGroups->getByIndex(nGroupPos);
1189 : }
1190 0 : if ( nCommand == SID_RPT_GROUPSORT_MOVE_UP )
1191 : {
1192 0 : --nIndex;
1193 : }
1194 0 : if ( nCommand == SID_RPT_GROUPSORT_MOVE_DOWN )
1195 : {
1196 0 : ++nIndex;
1197 : }
1198 0 : if ( nCommand == SID_RPT_GROUPSORT_DELETE )
1199 : {
1200 0 : Application::PostUserEvent( LINK(m_pFieldExpression, OFieldExpressionControl, DelayedDelete) );
1201 : }
1202 : else
1203 : {
1204 0 : if ( nIndex >= 0 && aClipboardList.getLength() )
1205 : {
1206 0 : m_pFieldExpression->SetNoSelection();
1207 0 : m_pFieldExpression->moveGroups(aClipboardList,nIndex,sal_False);
1208 0 : m_pFieldExpression->DeactivateCell();
1209 0 : m_pFieldExpression->GoToRow(nIndex);
1210 0 : m_pFieldExpression->ActivateCell(nIndex, m_pFieldExpression->GetCurColumnId());
1211 0 : DisplayData(nIndex);
1212 : }
1213 0 : }
1214 : }
1215 0 : return 1L;
1216 : }
1217 : // -----------------------------------------------------------------------------
1218 0 : IMPL_LINK( OGroupsSortingDialog, LBChangeHdl, ListBox*, pListBox )
1219 : {
1220 : DBG_CHKTHIS( rpt_OGroupsSortingDialog,NULL);
1221 0 : if ( pListBox->GetSavedValue() != pListBox->GetSelectEntryPos() )
1222 : {
1223 0 : sal_Int32 nRow = m_pFieldExpression->GetCurRow();
1224 0 : sal_Int32 nGroupPos = m_pFieldExpression->getGroupPosition(nRow);
1225 0 : if ( pListBox != &m_aHeaderLst && pListBox != &m_aFooterLst)
1226 : {
1227 0 : if ( pListBox && pListBox->GetSavedValue() != pListBox->GetSelectEntryPos() )
1228 0 : SaveData(nRow);
1229 0 : if ( pListBox == &m_aGroupOnLst )
1230 0 : m_aGroupIntervalEd.Enable( pListBox->GetSelectEntryPos() != 0 );
1231 : }
1232 0 : else if ( nGroupPos != NO_GROUP )
1233 : {
1234 0 : uno::Reference< report::XGroup> xGroup = getGroup(nGroupPos);
1235 0 : uno::Sequence< beans::PropertyValue > aArgs(2);
1236 0 : aArgs[1].Name = PROPERTY_GROUP;
1237 0 : aArgs[1].Value <<= xGroup;
1238 :
1239 0 : if ( &m_aHeaderLst == pListBox )
1240 0 : aArgs[0].Name = PROPERTY_HEADERON;
1241 : else
1242 0 : aArgs[0].Name = PROPERTY_FOOTERON;
1243 :
1244 0 : aArgs[0].Value <<= pListBox->GetSelectEntryPos() == 0;
1245 0 : m_pController->executeChecked(&m_aHeaderLst == pListBox ? SID_GROUPHEADER : SID_GROUPFOOTER,aArgs);
1246 0 : if ( m_pFieldExpression )
1247 0 : m_pFieldExpression->InvalidateHandleColumn();
1248 : }
1249 : }
1250 0 : return 1L;
1251 : }
1252 : // -----------------------------------------------------------------------------
1253 0 : void OGroupsSortingDialog::showHelpText(sal_uInt16 _nResId)
1254 : {
1255 0 : m_aHelpWindow.SetText(String(ModuleRes(_nResId)));
1256 0 : }
1257 : // -----------------------------------------------------------------------------
1258 0 : void OGroupsSortingDialog::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) throw( uno::RuntimeException)
1259 : {
1260 0 : uno::Reference< report::XGroup > xGroup(_rEvent.Source,uno::UNO_QUERY);
1261 0 : if ( xGroup.is() )
1262 0 : displayGroup(xGroup);
1263 : else
1264 0 : fillColumns();
1265 0 : }
1266 : // -----------------------------------------------------------------------------
1267 0 : void OGroupsSortingDialog::fillColumns()
1268 : {
1269 0 : m_xColumns = m_pController->getColumns();
1270 0 : m_pFieldExpression->fillColumns(m_xColumns);
1271 0 : }
1272 : // -----------------------------------------------------------------------------
1273 0 : void OGroupsSortingDialog::displayGroup(const uno::Reference<report::XGroup>& _xGroup)
1274 : {
1275 0 : m_aHeaderLst.SelectEntryPos(_xGroup->getHeaderOn() ? 0 : 1 );
1276 0 : m_aFooterLst.SelectEntryPos(_xGroup->getFooterOn() ? 0 : 1 );
1277 0 : sal_Int32 nDataType = getColumnDataType(_xGroup->getExpression());
1278 :
1279 : // first clear whole group on list
1280 0 : while(m_aGroupOnLst.GetEntryCount() > 1 )
1281 : {
1282 0 : m_aGroupOnLst.RemoveEntry(1);
1283 : }
1284 :
1285 0 : switch(nDataType)
1286 : {
1287 : case sdbc::DataType::LONGVARCHAR:
1288 : case sdbc::DataType::VARCHAR:
1289 : case sdbc::DataType::CHAR:
1290 0 : m_aGroupOnLst.InsertEntry(String(ModuleRes(STR_RPT_PREFIXCHARS)));
1291 0 : m_aGroupOnLst.SetEntryData(1,reinterpret_cast<void*>(report::GroupOn::PREFIX_CHARACTERS));
1292 0 : break;
1293 : case sdbc::DataType::DATE:
1294 : case sdbc::DataType::TIME:
1295 : case sdbc::DataType::TIMESTAMP:
1296 : {
1297 0 : sal_uInt16 nIds[] = { STR_RPT_YEAR, STR_RPT_QUARTER,STR_RPT_MONTH,STR_RPT_WEEK,STR_RPT_DAY,STR_RPT_HOUR,STR_RPT_MINUTE };
1298 0 : for (sal_uInt16 i = 0; i < sizeof (nIds) / sizeof (nIds[0]); ++i)
1299 : {
1300 0 : m_aGroupOnLst.InsertEntry(String(ModuleRes(nIds[i])));
1301 0 : m_aGroupOnLst.SetEntryData(i+1,reinterpret_cast<void*>(i+2));
1302 : }
1303 : }
1304 0 : break;
1305 : default:
1306 0 : m_aGroupOnLst.InsertEntry(String(ModuleRes(STR_RPT_INTERVAL)));
1307 0 : m_aGroupOnLst.SetEntryData(1,reinterpret_cast<void*>(report::GroupOn::INTERVAL));
1308 0 : break;
1309 : }
1310 0 : sal_uInt16 nPos = 0;
1311 0 : switch(_xGroup->getGroupOn())
1312 : {
1313 : case report::GroupOn::DEFAULT:
1314 0 : nPos = 0;
1315 0 : break;
1316 : case report::GroupOn::PREFIX_CHARACTERS:
1317 0 : nPos = 1;
1318 0 : break;
1319 : case report::GroupOn::YEAR:
1320 0 : nPos = 1;
1321 0 : break;
1322 : case report::GroupOn::QUARTAL:
1323 0 : nPos = 2;
1324 0 : break;
1325 : case report::GroupOn::MONTH:
1326 0 : nPos = 3;
1327 0 : break;
1328 : case report::GroupOn::WEEK:
1329 0 : nPos = 4;
1330 0 : break;
1331 : case report::GroupOn::DAY:
1332 0 : nPos = 5;
1333 0 : break;
1334 : case report::GroupOn::HOUR:
1335 0 : nPos = 6;
1336 0 : break;
1337 : case report::GroupOn::MINUTE:
1338 0 : nPos = 7;
1339 0 : break;
1340 : case report::GroupOn::INTERVAL:
1341 0 : nPos = 1;
1342 0 : break;
1343 : default:
1344 0 : nPos = 0;
1345 : }
1346 0 : m_aGroupOnLst.SelectEntryPos(nPos);
1347 0 : m_aGroupIntervalEd.SetText(rtl::OUString::valueOf(_xGroup->getGroupInterval()));
1348 0 : m_aGroupIntervalEd.SaveValue();
1349 0 : m_aGroupIntervalEd.Enable( nPos != 0 );
1350 0 : m_aKeepTogetherLst.SelectEntryPos(_xGroup->getKeepTogether());
1351 0 : m_aOrderLst.SelectEntryPos(_xGroup->getSortAscending() ? 0 : 1);
1352 :
1353 0 : ListBox* pControls[] = { &m_aHeaderLst,&m_aFooterLst,&m_aGroupOnLst,&m_aKeepTogetherLst,&m_aOrderLst};
1354 0 : for (size_t i = 0; i < sizeof(pControls)/sizeof(pControls[0]); ++i)
1355 0 : pControls[i]->SaveValue();
1356 :
1357 0 : ListBox* pControlsLst2[] = { &m_aHeaderLst, &m_aFooterLst, &m_aGroupOnLst, &m_aKeepTogetherLst,&m_aOrderLst};
1358 0 : sal_Bool bReadOnly = !m_pController->isEditable();
1359 0 : for (size_t i = 0; i < sizeof(pControlsLst2)/sizeof(pControlsLst2[0]); ++i)
1360 0 : pControlsLst2[i]->SetReadOnly(bReadOnly);
1361 0 : m_aGroupIntervalEd.SetReadOnly(bReadOnly);
1362 0 : }
1363 : //------------------------------------------------------------------------------
1364 0 : void OGroupsSortingDialog::Resize()
1365 : {
1366 0 : Window::Resize();
1367 0 : Size aTotalOutputSize = GetOutputSizePixel();
1368 0 : Size aSpace = LogicToPixel( Size( UNRELATED_CONTROLS, UNRELATED_CONTROLS ), MAP_APPFONT );
1369 0 : m_pFieldExpression->SetSizePixel(Size(aTotalOutputSize.Width() - 2*aSpace.Width(),m_pFieldExpression->GetSizePixel().Height()));
1370 :
1371 0 : Control* pControlsLst[] = { &m_aHeaderLst, &m_aFooterLst, &m_aGroupOnLst, &m_aGroupIntervalEd,&m_aKeepTogetherLst,&m_aOrderLst};
1372 0 : Control* pControls[] = { &m_aHeader, &m_aFooter, &m_aGroupOn, &m_aGroupInterval, &m_aKeepTogether, &m_aOrder};
1373 0 : sal_Int32 nMaxTextWidth = 0;
1374 0 : for (size_t i = 0; i < sizeof (pControlsLst) / sizeof (pControlsLst[0]); ++i)
1375 : {
1376 0 : nMaxTextWidth = ::std::max<sal_Int32>(static_cast<sal_Int32>(GetTextWidth(pControls[i]->GetText())),nMaxTextWidth);
1377 : }
1378 :
1379 0 : for (size_t i = 0; i < sizeof (pControlsLst) / sizeof (pControlsLst[0]); ++i)
1380 : {
1381 0 : pControls[i]->SetSizePixel(Size(nMaxTextWidth,pControls[i]->GetSizePixel().Height()));
1382 0 : Point aPos = pControls[i]->GetPosPixel();
1383 0 : aPos.X() += nMaxTextWidth + aSpace.Width();
1384 0 : aPos.Y() = pControlsLst[i]->GetPosPixel().Y();
1385 :
1386 0 : pControlsLst[i]->SetPosSizePixel(aPos,Size(aTotalOutputSize.Width() - aPos.X() - aSpace.Width(),pControlsLst[i]->GetSizePixel().Height()));
1387 : }
1388 :
1389 0 : m_aFL.SetSizePixel(Size(aTotalOutputSize.Width() - aSpace.Width(),m_aFL.GetSizePixel().Height()));
1390 0 : m_aFL2.SetSizePixel(Size(aTotalOutputSize.Width() - aSpace.Width(),m_aFL2.GetSizePixel().Height()));
1391 0 : m_aFL3.SetSizePixel(Size(aTotalOutputSize.Width() - aSpace.Width(),m_aFL3.GetSizePixel().Height()));
1392 0 : sal_Int32 nPos = aTotalOutputSize.Width() - aSpace.Width() - m_aToolBox.GetSizePixel().Width();
1393 0 : m_aToolBox.SetPosPixel(Point(nPos,m_aToolBox.GetPosPixel().Y()));
1394 :
1395 0 : Point aHelpPos = m_aHelpWindow.GetPosPixel();
1396 0 : m_aHelpWindow.SetSizePixel(Size(aTotalOutputSize.Width() - aHelpPos.X(),aTotalOutputSize.Height() - aHelpPos.Y()));
1397 0 : }
1398 : //------------------------------------------------------------------------------
1399 0 : void OGroupsSortingDialog::checkButtons(sal_Int32 _nRow)
1400 : {
1401 0 : sal_Int32 nGroupCount = m_xGroups->getCount();
1402 0 : sal_Int32 nRowCount = m_pFieldExpression->GetRowCount();
1403 0 : sal_Bool bEnabled = nGroupCount > 1;
1404 :
1405 0 : if (bEnabled && _nRow > 0 )
1406 : {
1407 0 : m_aToolBox.EnableItem(SID_RPT_GROUPSORT_MOVE_UP, sal_True);
1408 : }
1409 : else
1410 : {
1411 0 : m_aToolBox.EnableItem(SID_RPT_GROUPSORT_MOVE_UP, sal_False);
1412 : }
1413 0 : if (bEnabled && _nRow < (nRowCount - 1) )
1414 : {
1415 0 : m_aToolBox.EnableItem(SID_RPT_GROUPSORT_MOVE_DOWN, sal_True);
1416 : }
1417 : else
1418 : {
1419 0 : m_aToolBox.EnableItem(SID_RPT_GROUPSORT_MOVE_DOWN, sal_False);
1420 : }
1421 :
1422 0 : sal_Int32 nGroupPos = m_pFieldExpression->getGroupPosition(_nRow);
1423 0 : if ( nGroupPos != NO_GROUP )
1424 : {
1425 0 : sal_Bool bEnableDelete = nGroupCount > 0;
1426 0 : m_aToolBox.EnableItem(SID_RPT_GROUPSORT_DELETE, bEnableDelete);
1427 : }
1428 : else
1429 : {
1430 0 : m_aToolBox.EnableItem(SID_RPT_GROUPSORT_DELETE, sal_False);
1431 : }
1432 0 : }
1433 :
1434 0 : ImageList OGroupsSortingDialog::getImageList(sal_Int16 _eBitmapSet) const
1435 : {
1436 0 : sal_Int16 nN = IMG_CONDFORMAT_DLG_SC;
1437 0 : if ( _eBitmapSet == SFX_SYMBOLS_SIZE_LARGE )
1438 0 : nN = IMG_CONDFORMAT_DLG_LC;
1439 0 : return ImageList(ModuleRes( nN ));
1440 : }
1441 :
1442 : //------------------------------------------------------------------
1443 0 : void OGroupsSortingDialog::resizeControls(const Size& _rDiff)
1444 : {
1445 : // we use large images so we must change them
1446 0 : if ( _rDiff.Width() || _rDiff.Height() )
1447 : {
1448 0 : Invalidate();
1449 : }
1450 0 : }
1451 :
1452 : //------------------------------------------------------------------
1453 : // load the images
1454 0 : ImageList OGroupsSortingDialog::getImageList(vcl::ImageListType) SAL_THROW (( com::sun::star::lang::IllegalArgumentException ))
1455 : {
1456 0 : return ImageList(ModuleRes(IMGLST_GROUPSORT_DLG_SC));
1457 : }
1458 :
1459 : // =============================================================================
1460 : } // rptui
1461 : // =============================================================================
1462 :
1463 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|