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