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

Generated by: LCOV version 1.11