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