LCOV - code coverage report
Current view: top level - libreoffice/reportdesign/source/ui/dlg - AddField.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 261 0.0 %
Date: 2012-12-27 Functions: 0 31 0.0 %
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 <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/util/URL.hpp>
      27             : #include <com/sun/star/i18n/XCollator.hpp>
      28             : 
      29             : #include <vcl/waitobj.hxx>
      30             : #include <vcl/svapp.hxx>
      31             : #include <tools/diagnose_ex.h>
      32             : #include <comphelper/stl_types.hxx>
      33             : #include "rptui_slotid.hrc"
      34             : 
      35             : #include <connectivity/dbtools.hxx>
      36             : #include "helpids.hrc"
      37             : #include "RptResId.hrc"
      38             : #include "CondFormat.hrc"
      39             : #include "ModuleHelper.hxx"
      40             : #include "uistrings.hrc"
      41             : #include "ColumnInfo.hxx"
      42             : 
      43             : #include <comphelper/property.hxx>
      44             : #include <svtools/imgdef.hxx>
      45             : #include "svtools/treelistentry.hxx"
      46             : 
      47             : namespace rptui
      48             : {
      49             : const long STD_WIN_SIZE_X = 180;
      50             : const long STD_WIN_SIZE_Y = 320;
      51             : 
      52             : const long LISTBOX_BORDER = 2;
      53             : 
      54             : using namespace ::com::sun::star;
      55             : using namespace sdbc;
      56             : using namespace sdb;
      57             : using namespace uno;
      58             : using namespace datatransfer;
      59             : using namespace beans;
      60             : using namespace lang;
      61             : using namespace container;
      62             : using namespace ::svx;
      63             : 
      64             : class OAddFieldWindowListBox    : public SvTreeListBox
      65             : {
      66             :     OAddFieldWindow*                    m_pTabWin;
      67             : 
      68             :     OAddFieldWindowListBox(const OAddFieldWindowListBox&);
      69             :     void operator =(const OAddFieldWindowListBox&);
      70             : 
      71             : public:
      72             :     OAddFieldWindowListBox( OAddFieldWindow* _pParent );
      73             :     virtual ~OAddFieldWindowListBox();
      74             : 
      75             :     sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
      76             :     sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
      77             : 
      78             :     uno::Sequence< beans::PropertyValue > getSelectedFieldDescriptors();
      79             : 
      80             : protected:
      81             :     // DragSourceHelper
      82             :     virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
      83             : 
      84             : private:
      85             :     using SvTreeListBox::ExecuteDrop;
      86             : };
      87             : // -----------------------------------------------------------------------------
      88           0 : uno::Sequence< beans::PropertyValue > OAddFieldWindowListBox::getSelectedFieldDescriptors()
      89             : {
      90           0 :     uno::Sequence< beans::PropertyValue > aArgs(GetSelectionCount());
      91           0 :     sal_Int32 i = 0;
      92           0 :     SvTreeListEntry* pSelected = FirstSelected();
      93           0 :     while( pSelected )
      94             :     {
      95             :         // build a descriptor for the currently selected field
      96           0 :         ::svx::ODataAccessDescriptor aDescriptor;
      97           0 :         m_pTabWin->fillDescriptor(pSelected,aDescriptor);
      98           0 :         aArgs[i++].Value <<= aDescriptor.createPropertyValueSequence();
      99           0 :         pSelected = NextSelected(pSelected);
     100           0 :     }
     101           0 :     return aArgs;
     102             : }
     103             : //==================================================================
     104             : // class OAddFieldWindowListBox
     105             : //==================================================================
     106             : DBG_NAME( rpt_OAddFieldWindowListBox );
     107             : //------------------------------------------------------------------------------
     108           0 : OAddFieldWindowListBox::OAddFieldWindowListBox( OAddFieldWindow* _pParent )
     109             :     :SvTreeListBox( _pParent, WB_TABSTOP|WB_BORDER|WB_SORT )
     110           0 :     ,m_pTabWin( _pParent )
     111             : {
     112             :     DBG_CTOR( rpt_OAddFieldWindowListBox,NULL);
     113           0 :     SetHelpId( HID_RPT_FIELD_SEL );
     114           0 :     SetSelectionMode(MULTIPLE_SELECTION);
     115           0 :     SetDragDropMode( 0xFFFF );
     116           0 :     SetHighlightRange( );
     117           0 : }
     118             : 
     119             : //------------------------------------------------------------------------------
     120           0 : OAddFieldWindowListBox::~OAddFieldWindowListBox()
     121             : {
     122             :     DBG_DTOR( rpt_OAddFieldWindowListBox,NULL);
     123           0 : }
     124             : 
     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             : DBG_NAME( rpt_OAddFieldWindow );
     154             : //-----------------------------------------------------------------------
     155           0 : OAddFieldWindow::OAddFieldWindow(Window* pParent
     156             :                                  ,const uno::Reference< beans::XPropertySet >& _xRowSet
     157             :                                  )
     158             :             :FloatingWindow(pParent, WinBits(WB_STDMODELESS|WB_SIZEABLE))
     159             :             ,::comphelper::OPropertyChangeListener(m_aMutex)
     160             :             ,::comphelper::OContainerListener(m_aMutex)
     161             :             ,m_xRowSet(_xRowSet)
     162             :             ,m_aActions(this,ModuleRes(RID_TB_SORTING))
     163           0 :             ,m_pListBox(new OAddFieldWindowListBox( this ))
     164             :             ,m_aFixedLine(this, ModuleRes(ADDFIELD_FL_HELP_SEPARATOR) )
     165             :             ,m_aHelpText(this, ModuleRes(ADDFIELD_HELP_FIELD) )
     166             :             ,m_aInsertButton(this, WB_TABSTOP|WB_CENTER)
     167             :             ,m_nCommandType(0)
     168             :             ,m_bEscapeProcessing(sal_False)
     169             :             ,m_pChangeListener(NULL)
     170           0 :             ,m_pContainerListener(NULL)
     171             : {
     172             :     DBG_CTOR( rpt_OAddFieldWindow,NULL);
     173           0 :     SetHelpId( HID_RPT_FIELD_SEL_WIN );
     174           0 :     SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor()) );
     175           0 :     SetMinOutputSizePixel(Size(STD_WIN_SIZE_X,STD_WIN_SIZE_Y));
     176             : 
     177           0 :     m_aActions.SetStyle(m_aActions.GetStyle()|WB_LINESPACING);
     178           0 :     m_aActions.SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor()) );
     179             : 
     180           0 :     m_aActions.SetSelectHdl(LINK(this, OAddFieldWindow, OnSortAction));
     181           0 :     setToolBox(&m_aActions);
     182           0 :     m_aActions.CheckItem(SID_FM_SORTUP);
     183           0 :     m_aActions.EnableItem(SID_ADD_CONTROL_PAIR, sal_False);
     184             : 
     185           0 :     m_pListBox->SetDoubleClickHdl(LINK( this, OAddFieldWindow, OnDoubleClickHdl ) );
     186           0 :     m_pListBox->SetSelectHdl(LINK( this, OAddFieldWindow, OnSelectHdl ) );
     187           0 :     m_pListBox->SetDeselectHdl(LINK( this, OAddFieldWindow, OnSelectHdl ) );
     188           0 :     m_pListBox->SetDoubleClickHdl(LINK( this, OAddFieldWindow, OnDoubleClickHdl ) );
     189           0 :     m_pListBox->Show();
     190           0 :     const String sTitle(ModuleRes(RID_STR_INSERT));
     191           0 :     m_aInsertButton.SetText(sTitle);
     192           0 :     m_aInsertButton.SetClickHdl(LINK( this, OAddFieldWindow, OnDoubleClickHdl ) );
     193           0 :     m_aInsertButton.Show();
     194             : 
     195           0 :     m_aFixedLine.SetControlBackground( GetSettings().GetStyleSettings().GetFaceColor() );
     196           0 :     m_aHelpText.SetControlBackground( GetSettings().GetStyleSettings().GetFaceColor() );
     197             : 
     198           0 :     SetSizePixel(Size(STD_WIN_SIZE_X,STD_WIN_SIZE_Y));
     199             : 
     200           0 :     if ( m_xRowSet.is() )
     201             :     {
     202             :         try
     203             :         {
     204             :             // be notified when the settings of report definition change
     205           0 :             m_pChangeListener = new ::comphelper::OPropertyChangeMultiplexer( this, m_xRowSet );
     206           0 :             m_pChangeListener->addProperty( PROPERTY_COMMAND );
     207           0 :             m_pChangeListener->addProperty( PROPERTY_COMMANDTYPE );
     208           0 :             m_pChangeListener->addProperty( PROPERTY_ESCAPEPROCESSING );
     209           0 :             m_pChangeListener->addProperty( PROPERTY_FILTER );
     210             :         }
     211           0 :         catch( const Exception& )
     212             :         {
     213             :             DBG_UNHANDLED_EXCEPTION();
     214             :         }
     215           0 :     }
     216           0 : }
     217             : 
     218             : //-----------------------------------------------------------------------
     219           0 : OAddFieldWindow::~OAddFieldWindow()
     220             : {
     221           0 :     if ( m_pListBox.get() )
     222             :     {
     223           0 :         SvTreeList* pModel = m_pListBox->GetModel();
     224           0 :         sal_uLong nCount = pModel->GetEntryCount();
     225           0 :         for(sal_uLong i = 0; i< nCount;++i)
     226             :         {
     227           0 :             delete static_cast<ColumnInfo*>(pModel->GetEntry(i)->GetUserData());
     228             :         }
     229             :     }
     230           0 :     if (m_pChangeListener.is())
     231           0 :         m_pChangeListener->dispose();
     232           0 :     if ( m_pContainerListener.is() )
     233           0 :         m_pContainerListener->dispose();
     234             :     DBG_DTOR( rpt_OAddFieldWindow,NULL);
     235           0 : }
     236             : 
     237             : //-----------------------------------------------------------------------
     238           0 : void OAddFieldWindow::GetFocus()
     239             : {
     240           0 :     if ( m_pListBox.get() )
     241           0 :         m_pListBox->GrabFocus();
     242             :     else
     243           0 :         FloatingWindow::GetFocus();
     244           0 : }
     245             : //-----------------------------------------------------------------------
     246           0 : uno::Sequence< beans::PropertyValue > OAddFieldWindow::getSelectedFieldDescriptors()
     247             : {
     248           0 :     return m_pListBox->getSelectedFieldDescriptors();
     249             : }
     250             : 
     251             : //-----------------------------------------------------------------------
     252           0 : long OAddFieldWindow::PreNotify( NotifyEvent& _rNEvt )
     253             : {
     254           0 :     if ( EVENT_KEYINPUT == _rNEvt.GetType() )
     255             :     {
     256           0 :         const KeyCode& rKeyCode = _rNEvt.GetKeyEvent()->GetKeyCode();
     257           0 :         if ( ( 0 == rKeyCode.GetModifier() ) && ( KEY_RETURN == rKeyCode.GetCode() ) )
     258             :         {
     259           0 :             if ( m_aCreateLink.IsSet() )
     260             :             {
     261           0 :                 m_aCreateLink.Call(this);
     262           0 :                 return 1;
     263             :             }
     264             :         }
     265             :     }
     266             : 
     267           0 :     return FloatingWindow::PreNotify( _rNEvt );
     268             : }
     269             : //-----------------------------------------------------------------------
     270           0 : void OAddFieldWindow::_propertyChanged( const beans::PropertyChangeEvent& _evt ) throw( uno::RuntimeException )
     271             : {
     272             :     OSL_ENSURE( _evt.Source == m_xRowSet, "OAddFieldWindow::_propertyChanged: where did this come from?" );
     273             :     (void)_evt;
     274           0 :     Update();
     275           0 : }
     276             : 
     277             : //-----------------------------------------------------------------------
     278             : namespace
     279             : {
     280           0 :     void lcl_addToList( OAddFieldWindowListBox& _rListBox, const uno::Sequence< ::rtl::OUString >& _rEntries )
     281             :     {
     282           0 :         const ::rtl::OUString* pEntries = _rEntries.getConstArray();
     283           0 :         sal_Int32 nEntries = _rEntries.getLength();
     284           0 :         for ( sal_Int32 i = 0; i < nEntries; ++i, ++pEntries )
     285           0 :             _rListBox.InsertEntry( *pEntries,NULL,sal_False,LIST_APPEND,new ColumnInfo(*pEntries) );
     286           0 :     }
     287           0 :     void lcl_addToList( OAddFieldWindowListBox& _rListBox, const uno::Reference< container::XNameAccess>& i_xColumns )
     288             :     {
     289           0 :         uno::Sequence< ::rtl::OUString > aEntries = i_xColumns->getElementNames();
     290           0 :         const ::rtl::OUString* pEntries = aEntries.getConstArray();
     291           0 :         sal_Int32 nEntries = aEntries.getLength();
     292           0 :         for ( sal_Int32 i = 0; i < nEntries; ++i, ++pEntries )
     293             :         {
     294           0 :             uno::Reference< beans::XPropertySet> xColumn(i_xColumns->getByName(*pEntries),UNO_QUERY_THROW);
     295           0 :             ::rtl::OUString sLabel;
     296           0 :             if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) )
     297           0 :                 xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
     298           0 :             if ( !sLabel.isEmpty() )
     299           0 :                 _rListBox.InsertEntry( sLabel,NULL,sal_False,LIST_APPEND,new ColumnInfo(*pEntries,sLabel) );
     300             :             else
     301           0 :                 _rListBox.InsertEntry( *pEntries,NULL,sal_False,LIST_APPEND,new ColumnInfo(*pEntries,sLabel) );
     302           0 :         }
     303           0 :     }
     304             : }
     305             : 
     306             : //-----------------------------------------------------------------------
     307           0 : void OAddFieldWindow::Update()
     308             : {
     309           0 :     if ( m_pContainerListener.is() )
     310           0 :         m_pContainerListener->dispose();
     311           0 :     m_pContainerListener = NULL;
     312           0 :     m_xColumns.clear();
     313             : 
     314             :     try
     315             :     {
     316             :         // ListBox loeschen
     317           0 :         m_pListBox->Clear();
     318           0 :         const sal_uInt16 nItemCount = m_aActions.GetItemCount();
     319           0 :         for (sal_uInt16 j = 0; j< nItemCount; ++j)
     320             :         {
     321           0 :             m_aActions.EnableItem(m_aActions.GetItemId(j),sal_False);
     322             :         }
     323             : 
     324           0 :         String aTitle(ModuleRes(RID_STR_FIELDSELECTION));
     325           0 :         SetText(aTitle);
     326           0 :         if ( m_xRowSet.is() )
     327             :         {
     328           0 :             ::rtl::OUString sCommand( m_aCommandName );
     329           0 :             sal_Int32       nCommandType( m_nCommandType );
     330           0 :             sal_Bool        bEscapeProcessing( m_bEscapeProcessing );
     331           0 :             ::rtl::OUString sFilter( m_sFilter );
     332             : 
     333           0 :             OSL_VERIFY( m_xRowSet->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand );
     334           0 :             OSL_VERIFY( m_xRowSet->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType );
     335           0 :             OSL_VERIFY( m_xRowSet->getPropertyValue( PROPERTY_ESCAPEPROCESSING ) >>= bEscapeProcessing );
     336           0 :             OSL_VERIFY( m_xRowSet->getPropertyValue( PROPERTY_FILTER ) >>= sFilter );
     337             : 
     338           0 :             m_aCommandName  = sCommand;
     339           0 :             m_nCommandType  = nCommandType;
     340           0 :             m_bEscapeProcessing = bEscapeProcessing;
     341           0 :             m_sFilter = sFilter;
     342             : 
     343             :             // add the columns to the list
     344           0 :             uno::Reference< sdbc::XConnection> xCon = getConnection();
     345           0 :             if ( xCon.is() && !m_aCommandName.isEmpty() )
     346           0 :                 m_xColumns = dbtools::getFieldsByCommandDescriptor( xCon, GetCommandType(), GetCommand(), m_xHoldAlive );
     347           0 :             if ( m_xColumns.is() )
     348             :             {
     349           0 :                 lcl_addToList( *m_pListBox, m_xColumns );
     350           0 :                 uno::Reference< container::XContainer> xContainer(m_xColumns,uno::UNO_QUERY);
     351           0 :                 if ( xContainer.is() )
     352           0 :                     m_pContainerListener = new ::comphelper::OContainerListenerAdapter(this,xContainer);
     353             :             }
     354             : 
     355             :             // add the parameter columns to the list
     356           0 :             uno::Reference< ::com::sun::star::sdbc::XRowSet > xRowSet(m_xRowSet,uno::UNO_QUERY);
     357           0 :             Sequence< ::rtl::OUString > aParamNames( getParameterNames( xRowSet ) );
     358           0 :             lcl_addToList( *m_pListBox, aParamNames );
     359             : 
     360             :             // set title
     361           0 :             aTitle.AppendAscii(" ");
     362           0 :             aTitle += 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             :     }
     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 :         ::rtl::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 :             ::rtl::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             : } // namespace rptui
     557             : // =============================================================================
     558             : 
     559             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10