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 "AddField.hxx"
20 : #include "UITools.hxx"
21 : #include <svx/dbaexchange.hxx>
22 : #include <svx/svdpagv.hxx>
23 : #include <com/sun/star/sdb/CommandType.hpp>
24 : #include <com/sun/star/util/URL.hpp>
25 : #include <com/sun/star/sdb/XDocumentDataSource.hpp>
26 : #include <com/sun/star/i18n/XCollator.hpp>
27 :
28 : #include <vcl/waitobj.hxx>
29 : #include <vcl/svapp.hxx>
30 : #include <vcl/settings.hxx>
31 :
32 : #include <tools/diagnose_ex.h>
33 : #include "rptui_slotid.hrc"
34 :
35 : #include <connectivity/dbtools.hxx>
36 : #include "helpids.hrc"
37 : #include "RptResId.hrc"
38 : #include "CondFormat.hrc"
39 : #include "ModuleHelper.hxx"
40 : #include "uistrings.hrc"
41 : #include "ColumnInfo.hxx"
42 :
43 : #include <comphelper/property.hxx>
44 : #include <svtools/imgdef.hxx>
45 : #include "svtools/treelistentry.hxx"
46 :
47 : namespace rptui
48 : {
49 : const long STD_WIN_SIZE_X = 180;
50 : const long STD_WIN_SIZE_Y = 320;
51 :
52 : using namespace ::com::sun::star;
53 : using namespace sdbc;
54 : using namespace sdb;
55 : using namespace uno;
56 : using namespace datatransfer;
57 : using namespace beans;
58 : using namespace lang;
59 : using namespace container;
60 : using namespace ::svx;
61 :
62 : class OAddFieldWindowListBox : public SvTreeListBox
63 : {
64 : OAddFieldWindow* m_pTabWin;
65 :
66 : OAddFieldWindowListBox(const OAddFieldWindowListBox&);
67 : void operator =(const OAddFieldWindowListBox&);
68 :
69 : public:
70 : OAddFieldWindowListBox( OAddFieldWindow* _pParent );
71 : virtual ~OAddFieldWindowListBox();
72 :
73 : sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
74 : sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
75 :
76 : uno::Sequence< beans::PropertyValue > getSelectedFieldDescriptors();
77 :
78 : protected:
79 : // DragSourceHelper
80 : virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE;
81 :
82 : private:
83 : using SvTreeListBox::ExecuteDrop;
84 : };
85 :
86 0 : uno::Sequence< beans::PropertyValue > OAddFieldWindowListBox::getSelectedFieldDescriptors()
87 : {
88 0 : uno::Sequence< beans::PropertyValue > aArgs(GetSelectionCount());
89 0 : sal_Int32 i = 0;
90 0 : SvTreeListEntry* pSelected = FirstSelected();
91 0 : while( pSelected )
92 : {
93 : // build a descriptor for the currently selected field
94 0 : ::svx::ODataAccessDescriptor aDescriptor;
95 0 : m_pTabWin->fillDescriptor(pSelected,aDescriptor);
96 0 : aArgs[i++].Value <<= aDescriptor.createPropertyValueSequence();
97 0 : pSelected = NextSelected(pSelected);
98 0 : }
99 0 : return aArgs;
100 : }
101 :
102 : // class OAddFieldWindowListBox
103 :
104 :
105 0 : OAddFieldWindowListBox::OAddFieldWindowListBox( OAddFieldWindow* _pParent )
106 : :SvTreeListBox( _pParent, WB_TABSTOP|WB_BORDER|WB_SORT )
107 0 : ,m_pTabWin( _pParent )
108 : {
109 0 : SetHelpId( HID_RPT_FIELD_SEL );
110 0 : SetSelectionMode(MULTIPLE_SELECTION);
111 0 : SetDragDropMode( 0xFFFF );
112 0 : SetHighlightRange( );
113 0 : }
114 :
115 :
116 0 : OAddFieldWindowListBox::~OAddFieldWindowListBox()
117 : {
118 0 : }
119 :
120 :
121 0 : sal_Int8 OAddFieldWindowListBox::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
122 : {
123 0 : return DND_ACTION_NONE;
124 : }
125 :
126 :
127 0 : sal_Int8 OAddFieldWindowListBox::ExecuteDrop( const ExecuteDropEvent& /*rEvt*/ )
128 : {
129 0 : return DND_ACTION_NONE;
130 : }
131 :
132 :
133 0 : void OAddFieldWindowListBox::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ )
134 : {
135 0 : if ( GetSelectionCount() < 1 )
136 : // no drag without a field
137 0 : return;
138 :
139 0 : OMultiColumnTransferable* pDataContainer = new OMultiColumnTransferable(getSelectedFieldDescriptors());
140 0 : Reference< XTransferable> xEnsureDelete = pDataContainer;
141 :
142 0 : EndSelection();
143 0 : pDataContainer->StartDrag( this, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
144 : }
145 :
146 : // class OAddFieldWindow
147 :
148 :
149 0 : OAddFieldWindow::OAddFieldWindow(Window* pParent
150 : ,const uno::Reference< beans::XPropertySet >& _xRowSet
151 : )
152 : :FloatingWindow(pParent, WinBits(WB_STDMODELESS|WB_SIZEABLE))
153 : ,::comphelper::OPropertyChangeListener(m_aMutex)
154 : ,::comphelper::OContainerListener(m_aMutex)
155 : ,m_xRowSet(_xRowSet)
156 : ,m_aActions(this,ModuleRes(RID_TB_SORTING))
157 0 : ,m_pListBox(new OAddFieldWindowListBox( this ))
158 : ,m_aFixedLine(this, ModuleRes(ADDFIELD_FL_HELP_SEPARATOR) )
159 : ,m_aHelpText(this, ModuleRes(ADDFIELD_HELP_FIELD) )
160 : ,m_aInsertButton(this, WB_TABSTOP|WB_CENTER)
161 : ,m_nCommandType(0)
162 : ,m_bEscapeProcessing(sal_False)
163 : ,m_pChangeListener(NULL)
164 0 : ,m_pContainerListener(NULL)
165 : {
166 0 : SetHelpId( HID_RPT_FIELD_SEL_WIN );
167 0 : SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor()) );
168 0 : SetMinOutputSizePixel(Size(STD_WIN_SIZE_X,STD_WIN_SIZE_Y));
169 :
170 0 : m_aActions.SetStyle(m_aActions.GetStyle()|WB_LINESPACING);
171 0 : m_aActions.SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor()) );
172 :
173 0 : m_aActions.SetSelectHdl(LINK(this, OAddFieldWindow, OnSortAction));
174 0 : setToolBox(&m_aActions);
175 0 : m_aActions.CheckItem(SID_FM_SORTUP);
176 0 : m_aActions.EnableItem(SID_ADD_CONTROL_PAIR, false);
177 :
178 0 : m_pListBox->SetDoubleClickHdl(LINK( this, OAddFieldWindow, OnDoubleClickHdl ) );
179 0 : m_pListBox->SetSelectHdl(LINK( this, OAddFieldWindow, OnSelectHdl ) );
180 0 : m_pListBox->SetDeselectHdl(LINK( this, OAddFieldWindow, OnSelectHdl ) );
181 0 : m_pListBox->SetDoubleClickHdl(LINK( this, OAddFieldWindow, OnDoubleClickHdl ) );
182 0 : m_pListBox->Show();
183 0 : const OUString sTitle(ModuleRes(RID_STR_INSERT));
184 0 : m_aInsertButton.SetText(sTitle);
185 0 : m_aInsertButton.SetClickHdl(LINK( this, OAddFieldWindow, OnDoubleClickHdl ) );
186 0 : m_aInsertButton.Show();
187 :
188 0 : m_aFixedLine.SetControlBackground( GetSettings().GetStyleSettings().GetFaceColor() );
189 0 : m_aHelpText.SetControlBackground( GetSettings().GetStyleSettings().GetFaceColor() );
190 :
191 0 : SetSizePixel(Size(STD_WIN_SIZE_X,STD_WIN_SIZE_Y));
192 :
193 0 : if ( m_xRowSet.is() )
194 : {
195 : try
196 : {
197 : // be notified when the settings of report definition change
198 0 : m_pChangeListener = new ::comphelper::OPropertyChangeMultiplexer( this, m_xRowSet );
199 0 : m_pChangeListener->addProperty( PROPERTY_COMMAND );
200 0 : m_pChangeListener->addProperty( PROPERTY_COMMANDTYPE );
201 0 : m_pChangeListener->addProperty( PROPERTY_ESCAPEPROCESSING );
202 0 : m_pChangeListener->addProperty( PROPERTY_FILTER );
203 : }
204 0 : catch( const Exception& )
205 : {
206 : DBG_UNHANDLED_EXCEPTION();
207 : }
208 0 : }
209 0 : }
210 :
211 :
212 0 : OAddFieldWindow::~OAddFieldWindow()
213 : {
214 0 : if ( m_pListBox.get() )
215 : {
216 0 : SvTreeList* pModel = m_pListBox->GetModel();
217 0 : sal_uLong nCount = pModel->GetEntryCount();
218 0 : for(sal_uLong i = 0; i< nCount;++i)
219 : {
220 0 : delete static_cast<ColumnInfo*>(pModel->GetEntry(i)->GetUserData());
221 : }
222 : }
223 0 : if (m_pChangeListener.is())
224 0 : m_pChangeListener->dispose();
225 0 : if ( m_pContainerListener.is() )
226 0 : m_pContainerListener->dispose();
227 0 : }
228 :
229 :
230 0 : void OAddFieldWindow::GetFocus()
231 : {
232 0 : if ( m_pListBox.get() )
233 0 : m_pListBox->GrabFocus();
234 : else
235 0 : FloatingWindow::GetFocus();
236 0 : }
237 :
238 0 : uno::Sequence< beans::PropertyValue > OAddFieldWindow::getSelectedFieldDescriptors()
239 : {
240 0 : return m_pListBox->getSelectedFieldDescriptors();
241 : }
242 :
243 :
244 0 : bool OAddFieldWindow::PreNotify( NotifyEvent& _rNEvt )
245 : {
246 0 : if ( EVENT_KEYINPUT == _rNEvt.GetType() )
247 : {
248 0 : const KeyCode& rKeyCode = _rNEvt.GetKeyEvent()->GetKeyCode();
249 0 : if ( ( 0 == rKeyCode.GetModifier() ) && ( KEY_RETURN == rKeyCode.GetCode() ) )
250 : {
251 0 : if ( m_aCreateLink.IsSet() )
252 : {
253 0 : m_aCreateLink.Call(this);
254 0 : return true;
255 : }
256 : }
257 : }
258 :
259 0 : return FloatingWindow::PreNotify( _rNEvt );
260 : }
261 :
262 0 : void OAddFieldWindow::_propertyChanged( const beans::PropertyChangeEvent& _evt ) throw( uno::RuntimeException )
263 : {
264 : OSL_ENSURE( _evt.Source == m_xRowSet, "OAddFieldWindow::_propertyChanged: where did this come from?" );
265 : (void)_evt;
266 0 : Update();
267 0 : }
268 :
269 :
270 : namespace
271 : {
272 0 : void lcl_addToList( OAddFieldWindowListBox& _rListBox, const uno::Sequence< OUString >& _rEntries )
273 : {
274 0 : const OUString* pEntries = _rEntries.getConstArray();
275 0 : sal_Int32 nEntries = _rEntries.getLength();
276 0 : for ( sal_Int32 i = 0; i < nEntries; ++i, ++pEntries )
277 0 : _rListBox.InsertEntry( *pEntries,NULL,false,TREELIST_APPEND,new ColumnInfo(*pEntries) );
278 0 : }
279 0 : void lcl_addToList( OAddFieldWindowListBox& _rListBox, const uno::Reference< container::XNameAccess>& i_xColumns )
280 : {
281 0 : uno::Sequence< OUString > aEntries = i_xColumns->getElementNames();
282 0 : const OUString* pEntries = aEntries.getConstArray();
283 0 : sal_Int32 nEntries = aEntries.getLength();
284 0 : for ( sal_Int32 i = 0; i < nEntries; ++i, ++pEntries )
285 : {
286 0 : uno::Reference< beans::XPropertySet> xColumn(i_xColumns->getByName(*pEntries),UNO_QUERY_THROW);
287 0 : OUString sLabel;
288 0 : if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) )
289 0 : xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
290 0 : if ( !sLabel.isEmpty() )
291 0 : _rListBox.InsertEntry( sLabel,NULL,false,TREELIST_APPEND,new ColumnInfo(*pEntries,sLabel) );
292 : else
293 0 : _rListBox.InsertEntry( *pEntries,NULL,false,TREELIST_APPEND,new ColumnInfo(*pEntries,sLabel) );
294 0 : }
295 0 : }
296 : }
297 :
298 :
299 0 : void OAddFieldWindow::Update()
300 : {
301 0 : SolarMutexGuard aSolarGuard;
302 :
303 0 : if ( m_pContainerListener.is() )
304 0 : m_pContainerListener->dispose();
305 0 : m_pContainerListener = NULL;
306 0 : m_xColumns.clear();
307 :
308 : try
309 : {
310 : // ListBox loeschen
311 0 : m_pListBox->Clear();
312 0 : const sal_uInt16 nItemCount = m_aActions.GetItemCount();
313 0 : for (sal_uInt16 j = 0; j< nItemCount; ++j)
314 : {
315 0 : m_aActions.EnableItem(m_aActions.GetItemId(j),false);
316 : }
317 :
318 0 : OUString aTitle(ModuleRes(RID_STR_FIELDSELECTION));
319 0 : SetText(aTitle);
320 0 : if ( m_xRowSet.is() )
321 : {
322 0 : OUString sCommand( m_aCommandName );
323 0 : sal_Int32 nCommandType( m_nCommandType );
324 0 : sal_Bool bEscapeProcessing( m_bEscapeProcessing );
325 0 : OUString sFilter( m_sFilter );
326 :
327 0 : OSL_VERIFY( m_xRowSet->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand );
328 0 : OSL_VERIFY( m_xRowSet->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType );
329 0 : OSL_VERIFY( m_xRowSet->getPropertyValue( PROPERTY_ESCAPEPROCESSING ) >>= bEscapeProcessing );
330 0 : OSL_VERIFY( m_xRowSet->getPropertyValue( PROPERTY_FILTER ) >>= sFilter );
331 :
332 0 : m_aCommandName = sCommand;
333 0 : m_nCommandType = nCommandType;
334 0 : m_bEscapeProcessing = bEscapeProcessing;
335 0 : m_sFilter = sFilter;
336 :
337 : // add the columns to the list
338 0 : uno::Reference< sdbc::XConnection> xCon = getConnection();
339 0 : if ( xCon.is() && !m_aCommandName.isEmpty() )
340 0 : m_xColumns = dbtools::getFieldsByCommandDescriptor( xCon, GetCommandType(), GetCommand(), m_xHoldAlive );
341 0 : if ( m_xColumns.is() )
342 : {
343 0 : lcl_addToList( *m_pListBox, m_xColumns );
344 0 : uno::Reference< container::XContainer> xContainer(m_xColumns,uno::UNO_QUERY);
345 0 : if ( xContainer.is() )
346 0 : m_pContainerListener = new ::comphelper::OContainerListenerAdapter(this,xContainer);
347 : }
348 :
349 : // add the parameter columns to the list
350 0 : uno::Reference< ::com::sun::star::sdbc::XRowSet > xRowSet(m_xRowSet,uno::UNO_QUERY);
351 0 : Sequence< OUString > aParamNames( getParameterNames( xRowSet ) );
352 0 : lcl_addToList( *m_pListBox, aParamNames );
353 :
354 : // set title
355 0 : aTitle += " " + OUString( m_aCommandName.getStr() );
356 0 : SetText( aTitle );
357 0 : if ( !m_aCommandName.isEmpty() )
358 : {
359 0 : for (sal_uInt16 i = 0; i < nItemCount; ++i)
360 : {
361 0 : m_aActions.EnableItem(m_aActions.GetItemId(i));
362 : }
363 : }
364 0 : OnSelectHdl(NULL);
365 0 : }
366 : }
367 0 : catch( const Exception& )
368 : {
369 : DBG_UNHANDLED_EXCEPTION();
370 0 : }
371 0 : }
372 :
373 :
374 0 : void OAddFieldWindow::Resize()
375 : {
376 0 : FloatingWindow::Resize();
377 :
378 0 : const Size aWindowSize( GetOutputSizePixel() );
379 :
380 :
381 0 : const Size aRelated(LogicToPixel( Size( RELATED_CONTROLS, RELATED_CONTROLS ), MAP_APPFONT ));
382 0 : const Size aFixedTextSize(LogicToPixel( Size( FIXEDTEXT_WIDTH, FIXEDTEXT_HEIGHT ), MAP_APPFONT ));
383 :
384 : // ToolBar
385 0 : Size aToolbarSize( m_aActions.GetSizePixel() );
386 0 : Point aToolbarPos( aRelated.Width(), aRelated.Height());
387 0 : m_aActions.SetPosPixel(Point(aToolbarPos.X(), aToolbarPos.Y()));
388 :
389 0 : Size aLBSize( aWindowSize );
390 0 : aLBSize.Width() -= ( 2 * aRelated.Width() );
391 :
392 : // help text
393 0 : const Size aHelpTextSize = m_aHelpText.CalcMinimumSize(aLBSize.Width());
394 :
395 : // ListBox
396 0 : Point aLBPos( aRelated.Width(), aRelated.Height() + aToolbarSize.Height() + aRelated.Height() );
397 :
398 0 : aLBSize.Height() -= aToolbarSize.Height(); // Toolbar
399 0 : aLBSize.Height() -= (6*aRelated.Height()); // 6 * gap
400 0 : aLBSize.Height() -= aFixedTextSize.Height(); // fixed line
401 0 : aLBSize.Height() -= aHelpTextSize.Height(); // help text
402 0 : m_pListBox->SetPosSizePixel( aLBPos, aLBSize );
403 :
404 : // FixedLine
405 0 : Size aFLSize( aLBSize.Width(),aFixedTextSize.Height() );
406 0 : Point aFLPos( aRelated.Width(), aLBPos.Y() + aLBSize.Height() + aRelated.Height());
407 0 : m_aFixedLine.SetPosSizePixel( aFLPos, aFLSize );
408 :
409 : // Help text
410 0 : Point aFTPos( aRelated.Width(), aFLPos.Y() + aFLSize.Height() + aRelated.Height() );
411 0 : m_aHelpText.SetPosSizePixel( aFTPos, aHelpTextSize );
412 0 : }
413 :
414 0 : uno::Reference< sdbc::XConnection> OAddFieldWindow::getConnection() const
415 : {
416 0 : return uno::Reference< sdbc::XConnection>(m_xRowSet->getPropertyValue( PROPERTY_ACTIVECONNECTION ),uno::UNO_QUERY);
417 : }
418 :
419 0 : void OAddFieldWindow::fillDescriptor(SvTreeListEntry* _pSelected,::svx::ODataAccessDescriptor& _rDescriptor)
420 : {
421 0 : if ( _pSelected && m_xColumns.is() )
422 : {
423 0 : uno::Reference<container::XChild> xChild(getConnection(),uno::UNO_QUERY);
424 0 : if ( xChild.is( ) )
425 : {
426 0 : uno::Reference<sdb::XDocumentDataSource> xDocument( xChild->getParent(), uno::UNO_QUERY );
427 0 : if ( xDocument.is() )
428 : {
429 0 : uno::Reference<frame::XModel> xModel(xDocument->getDatabaseDocument(),uno::UNO_QUERY);
430 0 : if ( xModel.is() )
431 0 : _rDescriptor[ daDatabaseLocation ] <<= xModel->getURL();
432 0 : }
433 : }
434 :
435 0 : _rDescriptor[ ::svx::daCommand ] <<= GetCommand();
436 0 : _rDescriptor[ ::svx::daCommandType ] <<= GetCommandType();
437 0 : _rDescriptor[ ::svx::daEscapeProcessing ] <<= GetEscapeProcessing();
438 0 : _rDescriptor[ ::svx::daConnection ] <<= getConnection();
439 :
440 0 : ColumnInfo* pInfo = static_cast<ColumnInfo*>(_pSelected->GetUserData());
441 0 : _rDescriptor[ ::svx::daColumnName ] <<= pInfo->sColumnName;
442 0 : if ( m_xColumns->hasByName( pInfo->sColumnName ) )
443 0 : _rDescriptor[ ::svx::daColumnObject ] <<= m_xColumns->getByName(pInfo->sColumnName);
444 : }
445 0 : }
446 :
447 0 : void OAddFieldWindow::_elementInserted( const container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception)
448 : {
449 0 : if ( m_pListBox.get() )
450 : {
451 0 : OUString sName;
452 0 : if ( (_rEvent.Accessor >>= sName) && m_xColumns->hasByName(sName) )
453 : {
454 0 : uno::Reference< beans::XPropertySet> xColumn(m_xColumns->getByName(sName),UNO_QUERY_THROW);
455 0 : OUString sLabel;
456 0 : if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) )
457 0 : xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
458 0 : if ( !sLabel.isEmpty() )
459 0 : m_pListBox->InsertEntry( sLabel,NULL,false,TREELIST_APPEND,new ColumnInfo(sName,sLabel) );
460 : else
461 0 : m_pListBox->InsertEntry( sName,NULL,false,TREELIST_APPEND,new ColumnInfo(sName,sLabel) );
462 0 : }
463 : }
464 0 : }
465 :
466 0 : void OAddFieldWindow::_elementRemoved( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception)
467 : {
468 0 : if ( m_pListBox.get() )
469 : {
470 0 : m_pListBox->Clear();
471 0 : if ( m_xColumns.is() )
472 0 : lcl_addToList( *m_pListBox, m_xColumns );
473 : }
474 0 : }
475 :
476 0 : void OAddFieldWindow::_elementReplaced( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception)
477 : {
478 0 : }
479 :
480 0 : IMPL_LINK( OAddFieldWindow, OnSelectHdl, void* ,/*_pAddFieldDlg*/)
481 : {
482 0 : m_aActions.EnableItem(SID_ADD_CONTROL_PAIR, ( m_pListBox.get() && m_pListBox->GetSelectionCount() > 0 ));
483 :
484 0 : return 0L;
485 : }
486 :
487 0 : IMPL_LINK( OAddFieldWindow, OnDoubleClickHdl, void* ,/*_pAddFieldDlg*/)
488 : {
489 0 : if ( m_aCreateLink.IsSet() )
490 0 : m_aCreateLink.Call(this);
491 :
492 0 : return 0L;
493 : }
494 :
495 0 : ImageList OAddFieldWindow::getImageList(sal_Int16 _eBitmapSet) const
496 : {
497 0 : sal_Int16 nN = IMG_ADDFIELD_DLG_SC;
498 0 : if ( _eBitmapSet == SFX_SYMBOLS_SIZE_LARGE )
499 0 : nN = IMG_ADDFIELD_DLG_LC;
500 0 : return ImageList(ModuleRes(nN));
501 : }
502 :
503 0 : void OAddFieldWindow::resizeControls(const Size& _rDiff)
504 : {
505 : // we use large images so we must change them
506 0 : if ( _rDiff.Width() || _rDiff.Height() )
507 : {
508 0 : Invalidate();
509 : }
510 0 : }
511 :
512 0 : IMPL_LINK( OAddFieldWindow, OnSortAction, ToolBox*, /*NOTINTERESTEDIN*/ )
513 : {
514 0 : const sal_uInt16 nCurItem = m_aActions.GetCurItemId();
515 0 : if ( SID_ADD_CONTROL_PAIR == nCurItem )
516 0 : OnDoubleClickHdl(NULL);
517 : else
518 : {
519 0 : if ( SID_FM_REMOVE_FILTER_SORT == nCurItem || !m_aActions.IsItemChecked(nCurItem) )
520 : {
521 0 : const sal_uInt16 nItemCount = m_aActions.GetItemCount();
522 0 : for (sal_uInt16 j = 0; j< nItemCount; ++j)
523 : {
524 0 : const sal_uInt16 nItemId = m_aActions.GetItemId(j);
525 0 : if ( nCurItem != nItemId )
526 0 : m_aActions.CheckItem(nItemId,false);
527 : }
528 0 : SvSortMode eSortMode = SortNone;
529 0 : if ( SID_FM_REMOVE_FILTER_SORT != nCurItem )
530 : {
531 0 : m_aActions.CheckItem(nCurItem,!m_aActions.IsItemChecked(nCurItem));
532 0 : if ( m_aActions.IsItemChecked(SID_FM_SORTUP) )
533 0 : eSortMode = SortAscending;
534 0 : else if ( m_aActions.IsItemChecked(SID_FM_SORTDOWN) )
535 0 : eSortMode = SortDescending;
536 : }
537 :
538 0 : m_pListBox->GetModel()->SetSortMode(eSortMode);
539 0 : if ( SID_FM_REMOVE_FILTER_SORT == nCurItem )
540 0 : Update();
541 :
542 0 : m_pListBox->GetModel()->Resort();
543 : }
544 : }
545 0 : return 0L;
546 : }
547 :
548 :
549 : } // namespace rptui
550 :
551 :
552 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|