2007-07-09 10:56:41 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 17:50:37 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2007-07-09 10:56:41 +00:00
|
|
|
*
|
2008-04-10 17:50:37 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2007-07-09 10:56:41 +00:00
|
|
|
*
|
2008-04-10 17:50:37 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2007-07-09 10:56:41 +00:00
|
|
|
*
|
2008-04-10 17:50:37 +00:00
|
|
|
* $RCSfile: AddField.cxx,v $
|
|
|
|
* $Revision: 1.5 $
|
2007-07-09 10:56:41 +00:00
|
|
|
*
|
2008-04-10 17:50:37 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2007-07-09 10:56:41 +00:00
|
|
|
*
|
2008-04-10 17:50:37 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2007-07-09 10:56:41 +00:00
|
|
|
*
|
2008-04-10 17:50:37 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2007-07-09 10:56:41 +00:00
|
|
|
*
|
2008-04-10 17:50:37 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2007-07-09 10:56:41 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
#include "precompiled_reportdesign.hxx"
|
|
|
|
#include "AddField.hxx"
|
|
|
|
#include "UITools.hxx"
|
|
|
|
#include <svx/dbaexchange.hxx>
|
2008-12-10 13:41:25 +00:00
|
|
|
#include <svx/svdpagv.hxx>
|
2007-07-09 10:56:41 +00:00
|
|
|
#include <com/sun/star/sdb/CommandType.hpp>
|
|
|
|
#include <com/sun/star/sdb/XDocumentDataSource.hpp>
|
2008-12-10 13:41:25 +00:00
|
|
|
#include <com/sun/star/util/URL.hpp>
|
|
|
|
#include <com/sun/star/i18n/XCollator.hpp>
|
|
|
|
|
2007-07-09 10:56:41 +00:00
|
|
|
#include <vcl/waitobj.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <tools/diagnose_ex.h>
|
|
|
|
#include <comphelper/stl_types.hxx>
|
|
|
|
#include "rptui_slotid.hrc"
|
2008-12-10 13:41:25 +00:00
|
|
|
|
2007-07-09 10:56:41 +00:00
|
|
|
#include <connectivity/dbtools.hxx>
|
|
|
|
#include "helpids.hrc"
|
|
|
|
#include "RptResId.hrc"
|
2008-12-10 13:41:25 +00:00
|
|
|
#include "CondFormat.hrc"
|
2007-07-09 10:56:41 +00:00
|
|
|
#include "ModuleHelper.hxx"
|
|
|
|
#include "uistrings.hrc"
|
|
|
|
#include <comphelper/property.hxx>
|
2008-12-10 13:41:25 +00:00
|
|
|
#include <svtools/imgdef.hxx>
|
2007-07-09 10:56:41 +00:00
|
|
|
|
|
|
|
namespace rptui
|
|
|
|
{
|
2008-12-10 13:41:25 +00:00
|
|
|
const long STD_WIN_SIZE_X = 180;
|
|
|
|
const long STD_WIN_SIZE_Y = 220;
|
2007-07-09 10:56:41 +00:00
|
|
|
|
|
|
|
const long LISTBOX_BORDER = 2;
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace sdbc;
|
|
|
|
using namespace sdb;
|
|
|
|
using namespace uno;
|
|
|
|
using namespace datatransfer;
|
|
|
|
using namespace beans;
|
|
|
|
using namespace lang;
|
|
|
|
using namespace container;
|
|
|
|
using namespace ::svx;
|
|
|
|
class OAddFieldWindowListBox : public SvTreeListBox
|
|
|
|
{
|
2008-12-10 13:41:25 +00:00
|
|
|
OAddFieldWindow* m_pTabWin;
|
2007-07-09 10:56:41 +00:00
|
|
|
|
|
|
|
OAddFieldWindowListBox(const OAddFieldWindowListBox&);
|
|
|
|
void operator =(const OAddFieldWindowListBox&);
|
|
|
|
protected:
|
|
|
|
// virtual void Command( const CommandEvent& rEvt );
|
|
|
|
|
|
|
|
public:
|
2008-12-10 13:41:25 +00:00
|
|
|
OAddFieldWindowListBox( OAddFieldWindow* _pParent );
|
2007-07-09 10:56:41 +00:00
|
|
|
virtual ~OAddFieldWindowListBox();
|
|
|
|
|
|
|
|
sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
|
|
|
|
sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
|
|
|
|
|
2008-12-10 13:41:25 +00:00
|
|
|
uno::Sequence< beans::PropertyValue > getSelectedFieldDescriptors();
|
2007-07-09 10:56:41 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// DragSourceHelper
|
|
|
|
virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
|
|
|
|
|
|
|
|
private:
|
|
|
|
using SvTreeListBox::ExecuteDrop;
|
|
|
|
};
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-12-10 13:41:25 +00:00
|
|
|
uno::Sequence< beans::PropertyValue > OAddFieldWindowListBox::getSelectedFieldDescriptors()
|
2007-07-09 10:56:41 +00:00
|
|
|
{
|
|
|
|
uno::Sequence< beans::PropertyValue > aArgs(GetSelectionCount());
|
|
|
|
sal_Int32 i = 0;
|
|
|
|
SvLBoxEntry* pSelected = FirstSelected();
|
|
|
|
while( pSelected )
|
|
|
|
{
|
|
|
|
// build a descriptor for the currently selected field
|
|
|
|
::svx::ODataAccessDescriptor aDescriptor;
|
|
|
|
m_pTabWin->fillDescriptor(pSelected,aDescriptor);
|
|
|
|
aArgs[i++].Value <<= aDescriptor.createPropertyValueSequence();
|
|
|
|
pSelected = NextSelected(pSelected);
|
|
|
|
}
|
|
|
|
return aArgs;
|
|
|
|
}
|
|
|
|
//==================================================================
|
|
|
|
// class OAddFieldWindowListBox
|
|
|
|
//==================================================================
|
|
|
|
DBG_NAME( rpt_OAddFieldWindowListBox );
|
|
|
|
//------------------------------------------------------------------------------
|
2008-12-10 13:41:25 +00:00
|
|
|
OAddFieldWindowListBox::OAddFieldWindowListBox( OAddFieldWindow* _pParent )
|
|
|
|
:SvTreeListBox( _pParent, WB_BORDER|WB_SORT )
|
|
|
|
,m_pTabWin( _pParent )
|
2007-07-09 10:56:41 +00:00
|
|
|
{
|
|
|
|
DBG_CTOR( rpt_OAddFieldWindowListBox,NULL);
|
2008-01-29 12:46:35 +00:00
|
|
|
SetHelpId( HID_RPT_FIELD_SEL );
|
2007-07-09 10:56:41 +00:00
|
|
|
SetSelectionMode(MULTIPLE_SELECTION);
|
2008-12-10 13:41:25 +00:00
|
|
|
SetDragDropMode( 0xFFFF );
|
2007-07-09 10:56:41 +00:00
|
|
|
SetHighlightRange( );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
OAddFieldWindowListBox::~OAddFieldWindowListBox()
|
|
|
|
{
|
|
|
|
DBG_DTOR( rpt_OAddFieldWindowListBox,NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
sal_Int8 OAddFieldWindowListBox::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
|
|
|
|
{
|
|
|
|
return DND_ACTION_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
sal_Int8 OAddFieldWindowListBox::ExecuteDrop( const ExecuteDropEvent& /*rEvt*/ )
|
|
|
|
{
|
|
|
|
return DND_ACTION_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void OAddFieldWindowListBox::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ )
|
|
|
|
{
|
2008-12-10 13:41:25 +00:00
|
|
|
if ( GetSelectionCount() < 1 )
|
|
|
|
// no drag without a field
|
2007-07-09 10:56:41 +00:00
|
|
|
return;
|
|
|
|
|
2008-12-10 13:41:25 +00:00
|
|
|
OMultiColumnTransferable* pDataContainer = new OMultiColumnTransferable(getSelectedFieldDescriptors());
|
|
|
|
Reference< XTransferable> xEnsureDelete = pDataContainer;
|
2007-07-09 10:56:41 +00:00
|
|
|
|
|
|
|
EndSelection();
|
2008-12-10 13:41:25 +00:00
|
|
|
pDataContainer->StartDrag( this, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
|
2007-07-09 10:56:41 +00:00
|
|
|
}
|
|
|
|
//========================================================================
|
|
|
|
// class OAddFieldWindow
|
|
|
|
//========================================================================
|
|
|
|
DBG_NAME( rpt_OAddFieldWindow );
|
|
|
|
//-----------------------------------------------------------------------
|
2008-12-10 13:41:25 +00:00
|
|
|
OAddFieldWindow::OAddFieldWindow(Window* pParent
|
|
|
|
,const uno::Reference< beans::XPropertySet >& _xRowSet
|
|
|
|
)
|
2007-07-09 10:56:41 +00:00
|
|
|
:FloatingWindow(pParent, WinBits(WB_STDMODELESS|WB_SIZEABLE))
|
|
|
|
,::comphelper::OPropertyChangeListener(m_aMutex)
|
2007-11-20 18:06:05 +00:00
|
|
|
,::comphelper::OContainerListener(m_aMutex)
|
2008-12-10 13:41:25 +00:00
|
|
|
,m_xRowSet(_xRowSet)
|
|
|
|
,m_aActions(this,ModuleRes(RID_TB_SORTING))
|
2007-07-09 10:56:41 +00:00
|
|
|
,m_pListBox(new OAddFieldWindowListBox( this ))
|
|
|
|
,m_nCommandType(0)
|
|
|
|
,m_bEscapeProcessing(sal_False)
|
|
|
|
,m_pChangeListener(NULL)
|
|
|
|
{
|
|
|
|
DBG_CTOR( rpt_OAddFieldWindow,NULL);
|
2008-01-29 12:46:35 +00:00
|
|
|
SetHelpId( HID_RPT_FIELD_SEL_WIN );
|
2007-07-09 10:56:41 +00:00
|
|
|
SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor()) );
|
2008-12-10 13:41:25 +00:00
|
|
|
SetMinOutputSizePixel(Size(STD_WIN_SIZE_X,STD_WIN_SIZE_Y));
|
|
|
|
|
|
|
|
m_aActions.SetStyle(m_aActions.GetStyle()|WB_LINESPACING);
|
|
|
|
m_aActions.SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor()) );
|
|
|
|
|
|
|
|
m_aActions.SetSelectHdl(LINK(this, OAddFieldWindow, OnSortAction));
|
|
|
|
setToolBox(&m_aActions);
|
|
|
|
m_aActions.CheckItem(SID_FM_SORTUP);
|
|
|
|
m_aActions.EnableItem(SID_ADD_CONTROL_PAIR, FALSE);
|
2007-07-09 10:56:41 +00:00
|
|
|
|
2008-12-10 13:41:25 +00:00
|
|
|
m_pListBox->SetDoubleClickHdl(LINK( this, OAddFieldWindow, OnDoubleClickHdl ) );
|
|
|
|
m_pListBox->SetSelectHdl(LINK( this, OAddFieldWindow, OnSelectHdl ) );
|
|
|
|
m_pListBox->SetDeselectHdl(LINK( this, OAddFieldWindow, OnSelectHdl ) );
|
2007-07-09 10:56:41 +00:00
|
|
|
m_pListBox->Show();
|
|
|
|
|
|
|
|
SetSizePixel(Size(STD_WIN_SIZE_X,STD_WIN_SIZE_Y));
|
2008-12-10 13:41:25 +00:00
|
|
|
//Show();
|
2007-07-09 10:56:41 +00:00
|
|
|
|
2008-12-10 13:41:25 +00:00
|
|
|
if ( m_xRowSet.is() )
|
2007-07-09 10:56:41 +00:00
|
|
|
{
|
2008-12-10 13:41:25 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// be notified when the settings of report definition change
|
|
|
|
m_pChangeListener = new ::comphelper::OPropertyChangeMultiplexer( this, m_xRowSet );
|
|
|
|
m_pChangeListener->addProperty( PROPERTY_COMMAND );
|
|
|
|
m_pChangeListener->addProperty( PROPERTY_COMMANDTYPE );
|
|
|
|
m_pChangeListener->addProperty( PROPERTY_ESCAPEPROCESSING );
|
|
|
|
m_pChangeListener->addProperty( PROPERTY_FILTER );
|
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
2007-07-09 10:56:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
OAddFieldWindow::~OAddFieldWindow()
|
|
|
|
{
|
|
|
|
if (m_pChangeListener.is())
|
|
|
|
m_pChangeListener->dispose();
|
2007-11-20 18:06:05 +00:00
|
|
|
if ( m_pContainerListener.is() )
|
|
|
|
m_pContainerListener->dispose();
|
2007-07-09 10:56:41 +00:00
|
|
|
DBG_DTOR( rpt_OAddFieldWindow,NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
void OAddFieldWindow::GetFocus()
|
|
|
|
{
|
|
|
|
if ( m_pListBox.get() )
|
|
|
|
m_pListBox->GrabFocus();
|
|
|
|
else
|
|
|
|
FloatingWindow::GetFocus();
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------
|
2008-12-10 13:41:25 +00:00
|
|
|
uno::Sequence< beans::PropertyValue > OAddFieldWindow::getSelectedFieldDescriptors()
|
2007-07-09 10:56:41 +00:00
|
|
|
{
|
2008-12-10 13:41:25 +00:00
|
|
|
return m_pListBox->getSelectedFieldDescriptors();
|
2007-07-09 10:56:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
long OAddFieldWindow::PreNotify( NotifyEvent& _rNEvt )
|
|
|
|
{
|
|
|
|
if ( EVENT_KEYINPUT == _rNEvt.GetType() )
|
|
|
|
{
|
|
|
|
const KeyCode& rKeyCode = _rNEvt.GetKeyEvent()->GetKeyCode();
|
|
|
|
if ( ( 0 == rKeyCode.GetModifier() ) && ( KEY_RETURN == rKeyCode.GetCode() ) )
|
|
|
|
{
|
2008-12-10 13:41:25 +00:00
|
|
|
if ( m_aCreateLink.IsSet() )
|
|
|
|
{
|
|
|
|
m_aCreateLink.Call(this);
|
2007-07-09 10:56:41 +00:00
|
|
|
return 1;
|
2008-12-10 13:41:25 +00:00
|
|
|
}
|
2007-07-09 10:56:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FloatingWindow::PreNotify( _rNEvt );
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
void OAddFieldWindow::_propertyChanged( const beans::PropertyChangeEvent& _evt ) throw( uno::RuntimeException )
|
|
|
|
{
|
2008-12-10 13:41:25 +00:00
|
|
|
OSL_ENSURE( _evt.Source == m_xRowSet, "OAddFieldWindow::_propertyChanged: where did this come from?" );
|
2007-07-09 10:56:41 +00:00
|
|
|
(void)_evt;
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
void lcl_addToList( OAddFieldWindowListBox& _rListBox, const uno::Sequence< ::rtl::OUString >& _rEntries )
|
|
|
|
{
|
|
|
|
const ::rtl::OUString* pEntries = _rEntries.getConstArray();
|
|
|
|
sal_Int32 nEntries = _rEntries.getLength();
|
|
|
|
for ( sal_Int32 i = 0; i < nEntries; ++i, ++pEntries )
|
|
|
|
_rListBox.InsertEntry( *pEntries );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
void OAddFieldWindow::Update()
|
|
|
|
{
|
2007-11-20 18:06:05 +00:00
|
|
|
if ( m_pContainerListener.is() )
|
|
|
|
m_pContainerListener->dispose();
|
|
|
|
m_pContainerListener = NULL;
|
2007-07-09 10:56:41 +00:00
|
|
|
m_xColumns.clear();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// ListBox loeschen
|
|
|
|
m_pListBox->Clear();
|
2008-12-10 13:41:25 +00:00
|
|
|
const USHORT nItemCount = m_aActions.GetItemCount();
|
|
|
|
for (USHORT j = 0; j< nItemCount; ++j)
|
|
|
|
{
|
|
|
|
m_aActions.EnableItem(m_aActions.GetItemId(j),FALSE);
|
|
|
|
}
|
|
|
|
|
2007-07-09 10:56:41 +00:00
|
|
|
String aTitle(ModuleRes(RID_STR_FIELDSELECTION));
|
|
|
|
SetText(aTitle);
|
2008-12-10 13:41:25 +00:00
|
|
|
if ( m_xRowSet.is() )
|
2007-11-20 18:06:05 +00:00
|
|
|
{
|
2008-12-10 13:41:25 +00:00
|
|
|
::rtl::OUString sCommand( m_aCommandName );
|
|
|
|
sal_Int32 nCommandType( m_nCommandType );
|
|
|
|
sal_Bool bEscapeProcessing( m_bEscapeProcessing );
|
|
|
|
::rtl::OUString sFilter( m_sFilter );
|
|
|
|
|
|
|
|
OSL_VERIFY( m_xRowSet->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand );
|
|
|
|
OSL_VERIFY( m_xRowSet->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType );
|
|
|
|
OSL_VERIFY( m_xRowSet->getPropertyValue( PROPERTY_ESCAPEPROCESSING ) >>= bEscapeProcessing );
|
|
|
|
OSL_VERIFY( m_xRowSet->getPropertyValue( PROPERTY_FILTER ) >>= sFilter );
|
|
|
|
|
|
|
|
m_aCommandName = sCommand;
|
|
|
|
m_nCommandType = nCommandType;
|
|
|
|
m_bEscapeProcessing = bEscapeProcessing;
|
|
|
|
m_sFilter = sFilter;
|
|
|
|
|
|
|
|
// add the columns to the list
|
|
|
|
uno::Reference< sdbc::XConnection> xCon = getConnection();
|
|
|
|
if ( xCon.is() && m_aCommandName.getLength() )
|
|
|
|
m_xColumns = dbtools::getFieldsByCommandDescriptor( xCon, GetCommandType(), GetCommand(), m_xHoldAlive );
|
|
|
|
if ( m_xColumns.is() )
|
|
|
|
{
|
|
|
|
lcl_addToList( *m_pListBox, m_xColumns->getElementNames() );
|
|
|
|
uno::Reference< container::XContainer> xContainer(m_xColumns,uno::UNO_QUERY);
|
|
|
|
if ( xContainer.is() )
|
|
|
|
m_pContainerListener = new ::comphelper::OContainerListenerAdapter(this,xContainer);
|
|
|
|
}
|
|
|
|
|
|
|
|
// add the parameter columns to the list
|
|
|
|
uno::Reference< ::com::sun::star::sdbc::XRowSet > xRowSet(m_xRowSet,uno::UNO_QUERY);
|
|
|
|
Sequence< ::rtl::OUString > aParamNames( getParameterNames( xRowSet ) );
|
|
|
|
lcl_addToList( *m_pListBox, aParamNames );
|
|
|
|
|
|
|
|
// set title
|
|
|
|
aTitle.AppendAscii(" ");
|
|
|
|
aTitle += m_aCommandName.getStr();
|
|
|
|
SetText( aTitle );
|
|
|
|
if ( m_aCommandName.getLength() )
|
|
|
|
{
|
|
|
|
for (USHORT i = 0; i < nItemCount; ++i)
|
|
|
|
{
|
|
|
|
m_aActions.EnableItem(m_aActions.GetItemId(i));
|
|
|
|
}
|
|
|
|
OnSelectHdl(NULL);
|
|
|
|
}
|
2007-11-20 18:06:05 +00:00
|
|
|
}
|
2007-07-09 10:56:41 +00:00
|
|
|
}
|
|
|
|
catch( const Exception& )
|
|
|
|
{
|
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
void OAddFieldWindow::Resize()
|
|
|
|
{
|
|
|
|
FloatingWindow::Resize();
|
|
|
|
|
2008-12-10 13:41:25 +00:00
|
|
|
const Size aSize( GetOutputSizePixel() );
|
2007-07-09 10:56:41 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2008-12-10 13:41:25 +00:00
|
|
|
Size aToolbarSize( m_aActions.GetSizePixel() );
|
2007-07-09 10:56:41 +00:00
|
|
|
|
2008-12-10 13:41:25 +00:00
|
|
|
const Size aRelated(LogicToPixel( Size( RELATED_CONTROLS, RELATED_CONTROLS ), MAP_APPFONT ));
|
|
|
|
Point aPos( aRelated.Width(), aToolbarSize.Height() + 2*aRelated.Height());
|
|
|
|
Point aToolbarPos( aPos.X(),aRelated.Height());
|
2007-07-09 10:56:41 +00:00
|
|
|
Size aLBSize( aSize );
|
2008-12-10 13:41:25 +00:00
|
|
|
aLBSize.Width() -= (2*aRelated.Width());
|
|
|
|
aLBSize.Height() -= (aRelated.Height() + aPos.Y() );
|
2007-07-09 10:56:41 +00:00
|
|
|
|
2008-12-10 13:41:25 +00:00
|
|
|
m_aActions.SetPosPixel(Point(aPos.X(),aToolbarPos.Y()));
|
|
|
|
m_pListBox->SetPosSizePixel( aPos, aLBSize );
|
2007-07-09 10:56:41 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
uno::Reference< sdbc::XConnection> OAddFieldWindow::getConnection() const
|
|
|
|
{
|
2008-12-10 13:41:25 +00:00
|
|
|
return uno::Reference< sdbc::XConnection>(m_xRowSet->getPropertyValue( PROPERTY_ACTIVECONNECTION ),uno::UNO_QUERY);
|
2007-07-09 10:56:41 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OAddFieldWindow::fillDescriptor(SvLBoxEntry* _pSelected,::svx::ODataAccessDescriptor& _rDescriptor)
|
|
|
|
{
|
|
|
|
if ( _pSelected && m_xColumns.is() )
|
|
|
|
{
|
2008-12-10 13:41:25 +00:00
|
|
|
uno::Reference<container::XChild> xChild(getConnection(),uno::UNO_QUERY);
|
|
|
|
if ( xChild.is( ) )
|
2007-07-09 10:56:41 +00:00
|
|
|
{
|
2008-12-10 13:41:25 +00:00
|
|
|
uno::Reference<sdb::XDocumentDataSource> xDocument( xChild->getParent(), uno::UNO_QUERY );
|
|
|
|
if ( xDocument.is() )
|
|
|
|
{
|
|
|
|
uno::Reference<frame::XModel> xModel(xDocument->getDatabaseDocument(),uno::UNO_QUERY);
|
|
|
|
if ( xModel.is() )
|
|
|
|
_rDescriptor[ daDatabaseLocation ] <<= xModel->getURL();
|
|
|
|
} // if ( xDocument.is() )
|
2007-07-09 10:56:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_rDescriptor[ ::svx::daCommand ] <<= GetCommand();
|
|
|
|
_rDescriptor[ ::svx::daCommandType ] <<= GetCommandType();
|
|
|
|
_rDescriptor[ ::svx::daEscapeProcessing ] <<= GetEscapeProcessing();
|
|
|
|
_rDescriptor[ ::svx::daConnection ] <<= getConnection();
|
|
|
|
|
|
|
|
::rtl::OUString sColumnName = m_pListBox->GetEntryText( _pSelected );
|
|
|
|
_rDescriptor[ ::svx::daColumnName ] <<= sColumnName;
|
|
|
|
if ( m_xColumns->hasByName( sColumnName ) )
|
|
|
|
_rDescriptor[ ::svx::daColumnObject ] <<= m_xColumns->getByName(sColumnName);
|
|
|
|
}
|
|
|
|
}
|
2007-11-20 18:06:05 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OAddFieldWindow::_elementInserted( const container::ContainerEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
if ( m_pListBox.get() )
|
|
|
|
{
|
|
|
|
::rtl::OUString sName;
|
|
|
|
if ( _rEvent.Accessor >>= sName )
|
|
|
|
m_pListBox->InsertEntry(sName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OAddFieldWindow::_elementRemoved( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
if ( m_pListBox.get() )
|
|
|
|
{
|
|
|
|
m_pListBox->Clear();
|
|
|
|
if ( m_xColumns.is() )
|
|
|
|
lcl_addToList( *m_pListBox, m_xColumns->getElementNames() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void OAddFieldWindow::_elementReplaced( const container::ContainerEvent& /*_rEvent*/ ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
}
|
2008-12-10 13:41:25 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
IMPL_LINK( OAddFieldWindow, OnSelectHdl, void* ,/*_pAddFieldDlg*/)
|
|
|
|
{
|
|
|
|
m_aActions.EnableItem(SID_ADD_CONTROL_PAIR, ( m_pListBox.get() && m_pListBox->GetSelectionCount() > 0 ));
|
|
|
|
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
IMPL_LINK( OAddFieldWindow, OnDoubleClickHdl, void* ,/*_pAddFieldDlg*/)
|
|
|
|
{
|
|
|
|
if ( m_aCreateLink.IsSet() )
|
|
|
|
m_aCreateLink.Call(this);
|
|
|
|
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
ImageList OAddFieldWindow::getImageList(sal_Int16 _eBitmapSet,sal_Bool _bHiContast) const
|
|
|
|
{
|
|
|
|
sal_Int16 nN = IMG_ADDFIELD_DLG_SC;
|
|
|
|
sal_Int16 nH = IMG_ADDFIELD_DLG_SCH;
|
|
|
|
if ( _eBitmapSet == SFX_SYMBOLS_SIZE_LARGE )
|
|
|
|
{
|
|
|
|
nN = IMG_ADDFIELD_DLG_LC;
|
|
|
|
nH = IMG_ADDFIELD_DLG_LCH;
|
|
|
|
}
|
|
|
|
return ImageList(ModuleRes( _bHiContast ? nH : nN ));
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
void OAddFieldWindow::resizeControls(const Size& _rDiff)
|
|
|
|
{
|
|
|
|
// we use large images so we must change them
|
|
|
|
if ( _rDiff.Width() || _rDiff.Height() )
|
|
|
|
{
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------
|
|
|
|
IMPL_LINK( OAddFieldWindow, OnSortAction, ToolBox*, /*NOTINTERESTEDIN*/ )
|
|
|
|
{
|
|
|
|
const USHORT nCurItem = m_aActions.GetCurItemId();
|
|
|
|
if ( SID_ADD_CONTROL_PAIR == nCurItem )
|
|
|
|
OnDoubleClickHdl(NULL);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( SID_FM_REMOVE_FILTER_SORT == nCurItem || !m_aActions.IsItemChecked(nCurItem) )
|
|
|
|
{
|
|
|
|
const USHORT nItemCount = m_aActions.GetItemCount();
|
|
|
|
for (USHORT j = 0; j< nItemCount; ++j)
|
|
|
|
{
|
|
|
|
const USHORT nItemId = m_aActions.GetItemId(j);
|
|
|
|
if ( nCurItem != nItemId )
|
|
|
|
m_aActions.CheckItem(nItemId,FALSE);
|
|
|
|
}
|
|
|
|
SvSortMode eSortMode = SortNone;
|
|
|
|
if ( SID_FM_REMOVE_FILTER_SORT != nCurItem )
|
|
|
|
{
|
|
|
|
m_aActions.CheckItem(nCurItem,!m_aActions.IsItemChecked(nCurItem));
|
|
|
|
if ( m_aActions.IsItemChecked(SID_FM_SORTUP) )
|
|
|
|
eSortMode = SortAscending;
|
|
|
|
else if ( m_aActions.IsItemChecked(SID_FM_SORTDOWN) )
|
|
|
|
eSortMode = SortDescending;
|
|
|
|
} // if ( SID_FM_REMOVE_FILTER_SORT != nCurItem )
|
|
|
|
|
|
|
|
m_pListBox->GetModel()->SetSortMode(eSortMode);
|
|
|
|
if ( SID_FM_REMOVE_FILTER_SORT == nCurItem )
|
|
|
|
Update();
|
|
|
|
|
|
|
|
m_pListBox->GetModel()->Resort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2007-07-09 10:56:41 +00:00
|
|
|
// =============================================================================
|
|
|
|
} // namespace rptui
|
|
|
|
// =============================================================================
|