LCOV - code coverage report
Current view: top level - reportdesign/source/ui/dlg - AddField.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 264 0.4 %
Date: 2014-11-03 Functions: 2 33 6.1 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10