summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/control
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/control')
-rw-r--r--dbaccess/source/ui/control/ColumnControlWindow.cxx198
-rw-r--r--dbaccess/source/ui/control/FieldDescControl.cxx1941
-rw-r--r--dbaccess/source/ui/control/RelationControl.cxx751
-rw-r--r--dbaccess/source/ui/control/ScrollHelper.cxx81
-rw-r--r--dbaccess/source/ui/control/SqlNameEdit.cxx100
-rw-r--r--dbaccess/source/ui/control/TableGrantCtrl.cxx516
-rw-r--r--dbaccess/source/ui/control/TableGrantCtrl.src96
-rw-r--r--dbaccess/source/ui/control/VertSplitView.cxx220
-rw-r--r--dbaccess/source/ui/control/charsetlistbox.cxx118
-rw-r--r--dbaccess/source/ui/control/curledit.cxx158
-rw-r--r--dbaccess/source/ui/control/dbtreelistbox.cxx756
-rw-r--r--dbaccess/source/ui/control/listviewitems.cxx84
-rw-r--r--dbaccess/source/ui/control/makefile.mk78
-rw-r--r--dbaccess/source/ui/control/marktree.cxx247
-rw-r--r--dbaccess/source/ui/control/opendoccontrols.cxx363
-rw-r--r--dbaccess/source/ui/control/sqledit.cxx224
-rw-r--r--dbaccess/source/ui/control/statusbarontroller.cxx50
-rw-r--r--dbaccess/source/ui/control/tabletree.cxx738
-rw-r--r--dbaccess/source/ui/control/tabletree.hrc37
-rw-r--r--dbaccess/source/ui/control/tabletree.src88
-rw-r--r--dbaccess/source/ui/control/toolboxcontroller.cxx321
-rw-r--r--dbaccess/source/ui/control/undosqledit.cxx50
-rw-r--r--dbaccess/source/ui/control/undosqledit.src66
23 files changed, 7281 insertions, 0 deletions
diff --git a/dbaccess/source/ui/control/ColumnControlWindow.cxx b/dbaccess/source/ui/control/ColumnControlWindow.cxx
new file mode 100644
index 000000000000..69f31bc1bfc2
--- /dev/null
+++ b/dbaccess/source/ui/control/ColumnControlWindow.cxx
@@ -0,0 +1,198 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_COLUMNCONTROLWINDOW_HXX
+#include "ColumnControlWindow.hxx"
+#endif
+#ifndef DBAUI_FIELDCONTROLS_HXX
+#include "FieldControls.hxx"
+#endif
+#ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX
+#include <unotools/syslocale.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+
+
+using namespace ::dbaui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+
+//========================================================================
+// OColumnControlWindow
+DBG_NAME(OColumnControlWindow)
+//========================================================================
+OColumnControlWindow::OColumnControlWindow(Window* pParent
+ ,const Reference<XMultiServiceFactory>& _rxFactory)
+ : OFieldDescControl(pParent,NULL)
+ , m_xORB(_rxFactory)
+ , m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES))
+ , m_bAutoIncrementEnabled(sal_True)
+{
+ DBG_CTOR(OColumnControlWindow,NULL);
+
+ setRightAligned();
+ m_aLocale = SvtSysLocale().GetLocaleData().getLocale();
+}
+// -----------------------------------------------------------------------------
+OColumnControlWindow::~OColumnControlWindow()
+{
+
+ DBG_DTOR(OColumnControlWindow,NULL);
+}
+// -----------------------------------------------------------------------
+void OColumnControlWindow::ActivateAggregate( EControlType eType )
+{
+ switch(eType )
+ {
+ case tpFormat:
+ case tpDefault:
+// case tpAutoIncrement:
+ case tpColumnName:
+ break;
+ default:
+ OFieldDescControl::ActivateAggregate( eType );
+ }
+}
+// -----------------------------------------------------------------------
+void OColumnControlWindow::DeactivateAggregate( EControlType eType )
+{
+ switch(eType )
+ {
+ case tpFormat:
+ case tpDefault:
+// case tpAutoIncrement:
+ case tpColumnName:
+ break;
+ default:
+ OFieldDescControl::DeactivateAggregate( eType );
+ }
+}
+// -----------------------------------------------------------------------------
+void OColumnControlWindow::CellModified(long /*nRow*/, USHORT /*nColId*/ )
+{
+ saveCurrentFieldDescData();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::lang::Locale OColumnControlWindow::GetLocale() const
+{
+ return m_aLocale;
+}
+// -----------------------------------------------------------------------------
+Reference< XNumberFormatter > OColumnControlWindow::GetFormatter() const
+{
+ if ( !m_xFormatter.is() )
+ try
+ {
+ Reference< XNumberFormatsSupplier > xSupplier(::dbtools::getNumberFormats(m_xConnection, sal_True,m_xORB));
+
+ if ( xSupplier.is() )
+ {
+ // create a new formatter
+ m_xFormatter.set( m_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter"))), UNO_QUERY);
+ if (m_xFormatter.is())
+ m_xFormatter->attachNumberFormatsSupplier(xSupplier);
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ return m_xFormatter;
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OColumnControlWindow::getTypeInfo(sal_Int32 _nPos)
+{
+ return ( _nPos >= 0 && _nPos < static_cast<sal_Int32>(m_aDestTypeInfoIndex.size())) ? m_aDestTypeInfoIndex[_nPos]->second : TOTypeInfoSP();
+}
+// -----------------------------------------------------------------------------
+const OTypeInfoMap* OColumnControlWindow::getTypeInfo() const
+{
+ return &m_aDestTypeInfo;
+}
+// -----------------------------------------------------------------------------
+Reference< XDatabaseMetaData> OColumnControlWindow::getMetaData()
+{
+ if ( m_xConnection.is() )
+ return m_xConnection->getMetaData();
+ return Reference< XDatabaseMetaData>();
+}
+// -----------------------------------------------------------------------------
+Reference< XConnection> OColumnControlWindow::getConnection()
+{
+ return m_xConnection;
+}
+// -----------------------------------------------------------------------------
+void OColumnControlWindow::setConnection(const Reference< XConnection>& _xCon)
+{
+ m_xConnection = _xCon;
+ m_xFormatter = NULL;
+ m_aDestTypeInfoIndex.clear();
+ m_aDestTypeInfo.clear();
+
+ if ( m_xConnection.is() )
+ {
+ Init();
+
+ ::dbaui::fillTypeInfo(m_xConnection,m_sTypeNames,m_aDestTypeInfo,m_aDestTypeInfoIndex);
+ // read autoincrement value set in the datasource
+ ::dbaui::fillAutoIncrementValue(m_xConnection,m_bAutoIncrementEnabled,m_sAutoIncrementValue);
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OColumnControlWindow::isAutoIncrementValueEnabled() const
+{
+ return m_bAutoIncrementEnabled;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OColumnControlWindow::getAutoIncrementValue() const
+{
+ return m_sAutoIncrementValue;
+}
+// -----------------------------------------------------------------------------
+TOTypeInfoSP OColumnControlWindow::getDefaultTyp() const
+{
+ if ( !m_pTypeInfo.get() )
+ {
+ m_pTypeInfo = TOTypeInfoSP(new OTypeInfo());
+ m_pTypeInfo->aUIName = m_sTypeNames.GetToken(TYPE_OTHER);
+ }
+ return m_pTypeInfo;
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx
new file mode 100644
index 000000000000..c2c8affcd4a8
--- /dev/null
+++ b/dbaccess/source/ui/control/FieldDescControl.cxx
@@ -0,0 +1,1941 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#define ITEMID_HORJUSTIFY SID_ATTR_ALIGN_HOR_JUSTIFY
+#define ITEMID_VERJUSTIFY SID_ATTR_ALIGN_VER_JUSTIFY
+//#define ITEMID_ORIENTATION SID_ATTR_ALIGN_ORIENTATION
+#define ITEMID_LINEBREAK SID_ATTR_ALIGN_LINEBREAK
+#define ITEMID_MARGIN SID_ATTR_ALIGN_MARGIN
+
+#include "FieldDescControl.hxx"
+#include "FieldControls.hxx"
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include "TableDesignHelpBar.hxx"
+#include <vcl/scrbar.hxx>
+#include <vcl/button.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/msgbox.hxx>
+#include <vector>
+#include "FieldDescriptions.hxx"
+#include "dlgattr.hxx"
+#include <svx/numfmtsh.hxx>
+#include <svx/svxids.hrc>
+#include <svx/algitem.hxx>
+#include <svl/itempool.hxx>
+#define _ZFORLIST_DECLARE_TABLE // ohne das bekomme ich einen Compiler-Fehler in <svl/zforlist.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/rngitem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/numuno.hxx>
+#include <svtools/transfer.hxx>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatPreviewer.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "QEnumTypes.hxx"
+#include "dbaccess_helpid.hrc"
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbconversion.hxx>
+#include <comphelper/numbers.hxx>
+#include "UITools.hxx"
+#include <memory>
+#include "dbu_control.hrc"
+#include "dbu_tbl.hrc"
+
+
+using namespace dbaui;
+using namespace dbtools;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::util;
+
+//==================================================================
+
+// fuer die Controls auf der OFieldDescGenPage
+#define CONTROL_SPACING_X 18 // 6
+#define CONTROL_SPACING_Y 4
+#define CONTROL_WIDTH_1 160 // 100
+#define CONTROL_WIDTH_2 100 // 60
+#define CONTROL_WIDTH_3 250
+#define CONTROL_WIDTH_4 (CONTROL_WIDTH_3 - 20 - 5)
+
+#define SBA_DEF_RANGEFORMAT (100 + 143) // RangeItem
+#define SBA_DEF_FMTVALUE (100 + 144) // SfxULONG, Format
+#define SBA_ATTR_ALIGN_HOR_JUSTIFY (100 + 145) // SvxHorJustifyItem
+
+#define HSCROLL_STEP 20
+
+
+namespace
+{
+ // -----------------------------------------------------------------------------
+ double checkDoubleForDateFormat(double _nValue,sal_Int32 _nFormatKey,const Reference< ::com::sun::star::util::XNumberFormatter>& _xNumberFormatter)
+ {
+ double nValue = _nValue;
+ sal_Int32 nNumberFormat = ::comphelper::getNumberFormatType(_xNumberFormatter,_nFormatKey);
+ if( (nNumberFormat & ::com::sun::star::util::NumberFormat::DATE) == ::com::sun::star::util::NumberFormat::DATE
+ || (nNumberFormat & ::com::sun::star::util::NumberFormat::DATETIME) == ::com::sun::star::util::NumberFormat::DATETIME )
+ {
+ nValue = DBTypeConversion::toStandardDbDate(DBTypeConversion::getNULLDate(_xNumberFormatter->getNumberFormatsSupplier()),nValue);
+ }
+
+ return nValue;
+ }
+ // -----------------------------------------------------------------------------
+ template< typename T1, typename T2> void lcl_HideAndDeleteControl(short& _nPos,T1** _pControl,T2** _pControlText)
+ {
+ if ( *_pControl )
+ {
+ --_nPos;
+ (*_pControl)->Hide();
+ (*_pControlText)->Hide();
+ delete *_pControl;
+ delete *_pControlText;
+ (*_pControl) = NULL;
+ (*_pControlText) = NULL;
+ }
+ }
+
+}
+
+//==================================================================
+// class OFieldDescControl
+//==================================================================
+
+DBG_NAME(OFieldDescControl)
+
+//==================================================================
+OFieldDescControl::OFieldDescControl( Window* pParent, const ResId& rResId, OTableDesignHelpBar* pHelpBar)
+ :TabPage( pParent, rResId )
+ ,pHelp( pHelpBar )
+ ,pLastFocusWindow(NULL)
+ ,m_pActFocusWindow(NULL)
+ ,pDefaultText(NULL)
+ ,pRequiredText(NULL)
+ ,pAutoIncrementText(NULL)
+ ,pTextLenText(NULL)
+ ,pNumTypeText(NULL)
+ ,pLengthText(NULL)
+ ,pScaleText(NULL)
+ ,pFormatText(NULL)
+ ,pBoolDefaultText(NULL)
+ ,m_pColumnNameText(NULL)
+ ,m_pTypeText(NULL)
+ ,m_pAutoIncrementValueText(NULL)
+ ,pRequired(NULL)
+ ,pNumType(NULL)
+ ,pAutoIncrement(NULL)
+ ,pDefault(NULL)
+ ,pTextLen(NULL)
+ ,pLength(NULL)
+ ,pScale(NULL)
+ ,pFormatSample(NULL)
+ ,pBoolDefault(NULL)
+ ,m_pColumnName(NULL)
+ ,m_pType(NULL)
+ ,m_pAutoIncrementValue(NULL)
+ ,pFormat(NULL)
+ ,m_pVertScroll( NULL )
+ ,m_pHorzScroll( NULL )
+ ,m_pPreviousType()
+ ,nCurChildId(1)
+ ,m_nPos(-1)
+ ,aYes(ModuleRes(STR_VALUE_YES))
+ ,aNo(ModuleRes(STR_VALUE_NO))
+ ,m_nOldVThumb( 0 )
+ ,m_nOldHThumb( 0 )
+ ,m_nWidth(50)
+ ,nDelayedGrabFocusEvent(0)
+ ,m_bAdded(sal_False)
+ ,m_bRightAligned(false)
+ ,pActFieldDescr(NULL)
+{
+ DBG_CTOR(OFieldDescControl,NULL);
+
+ Contruct();
+}
+//------------------------------------------------------------------------------
+OFieldDescControl::OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHelpBar )
+ :TabPage( pParent, WB_3DLOOK | WB_DIALOGCONTROL )
+ ,pHelp( pHelpBar )
+ ,pLastFocusWindow(NULL)
+ ,m_pActFocusWindow(NULL)
+ ,pDefaultText(NULL)
+ ,pRequiredText(NULL)
+ ,pAutoIncrementText(NULL)
+ ,pTextLenText(NULL)
+ ,pNumTypeText(NULL)
+ ,pLengthText(NULL)
+ ,pScaleText(NULL)
+ ,pFormatText(NULL)
+ ,pBoolDefaultText(NULL)
+ ,m_pColumnNameText(NULL)
+ ,m_pTypeText(NULL)
+ ,m_pAutoIncrementValueText(NULL)
+ ,pRequired(NULL)
+ ,pNumType(NULL)
+ ,pAutoIncrement(NULL)
+ ,pDefault(NULL)
+ ,pTextLen(NULL)
+ ,pLength(NULL)
+ ,pScale(NULL)
+ ,pFormatSample(NULL)
+ ,pBoolDefault(NULL)
+ ,m_pColumnName(NULL)
+ ,m_pType(NULL)
+ ,m_pAutoIncrementValue(NULL)
+ ,pFormat(NULL)
+ ,m_pVertScroll( NULL )
+ ,m_pHorzScroll( NULL )
+ ,m_pPreviousType()
+ ,nCurChildId(1)
+ ,m_nPos(-1)
+ ,aYes(ModuleRes(STR_VALUE_YES))
+ ,aNo(ModuleRes(STR_VALUE_NO))
+ ,m_nOldVThumb( 0 )
+ ,m_nOldHThumb( 0 )
+ ,m_nWidth(50)
+ ,nDelayedGrabFocusEvent(0)
+ ,m_bAdded(sal_False)
+ ,m_bRightAligned(false)
+ ,pActFieldDescr(NULL)
+{
+ DBG_CTOR(OFieldDescControl,NULL);
+ Contruct();
+}
+// -----------------------------------------------------------------------------
+void OFieldDescControl::Contruct()
+{
+ m_pVertScroll = new ScrollBar(this, WB_VSCROLL | WB_REPEAT | WB_DRAG);
+ m_pHorzScroll = new ScrollBar(this, WB_HSCROLL | WB_REPEAT | WB_DRAG);
+ m_pVertScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll));
+ m_pHorzScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll));
+ m_pVertScroll->Show();
+ m_pHorzScroll->Show();
+
+ m_pVertScroll->EnableClipSiblings();
+ m_pHorzScroll->EnableClipSiblings();
+
+ m_pVertScroll->SetLineSize(1);
+ m_pVertScroll->SetPageSize(1);
+ m_pHorzScroll->SetLineSize(1);
+ m_pHorzScroll->SetPageSize(1);
+
+ m_nOldVThumb = m_nOldHThumb = 0;
+}
+
+//------------------------------------------------------------------------------
+OFieldDescControl::~OFieldDescControl()
+{
+ DBG_DTOR(OFieldDescControl,NULL);
+
+ {
+ ::std::auto_ptr<Window> aTemp(m_pVertScroll);
+ m_pVertScroll = NULL;
+ }
+ {
+ ::std::auto_ptr<Window> aTemp(m_pHorzScroll);
+ m_pHorzScroll = NULL;
+ }
+ if ( m_bAdded )
+ ::dbaui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
+ pLastFocusWindow = NULL;
+
+ //////////////////////////////////////////////////////////////////////
+ // Childs zerstoeren
+ DeactivateAggregate( tpDefault );
+ DeactivateAggregate( tpRequired );
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpNumType );
+ DeactivateAggregate( tpScale );
+ DeactivateAggregate( tpLength );
+ DeactivateAggregate( tpFormat );
+ DeactivateAggregate( tpAutoIncrement );
+ DeactivateAggregate( tpBoolDefault );
+ DeactivateAggregate( tpColumnName );
+ DeactivateAggregate( tpType );
+ DeactivateAggregate( tpAutoIncrementValue );
+
+ if(nDelayedGrabFocusEvent)
+ Application::RemoveUserEvent(nDelayedGrabFocusEvent);
+}
+
+//------------------------------------------------------------------------------
+String OFieldDescControl::BoolStringPersistent(const String& rUIString) const
+{
+ static String aZero('0');
+ static String aOne('1');
+
+ if (rUIString == aNo)
+ return aZero;
+ if (rUIString == aYes)
+ return aOne;
+ return String();
+}
+
+//------------------------------------------------------------------------------
+String OFieldDescControl::BoolStringUI(const String& rPersistentString) const
+{
+ static String aZero('0');
+ static String aOne('1');
+ static String aNone(ModuleRes(STR_VALUE_NONE));
+
+ // FS - 66161 - 14.05.1999 - aeltere Versionen haben eventuell einen sprachabhaengigen String als Default gespeichert
+ if (rPersistentString.Equals(aYes) || rPersistentString.Equals(aNo))
+ return rPersistentString;
+
+ if (rPersistentString == aZero)
+ return aNo;
+ if (rPersistentString == aOne)
+ return aYes;
+
+ return aNone;
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::Init()
+{
+ Reference< ::com::sun::star::util::XNumberFormatter > xFormatter = GetFormatter();
+ ::dbaui::setEvalDateFormatForFormatter(xFormatter);
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OFieldDescControl, OnScroll, ScrollBar*, /*pBar*/)
+{
+ ScrollAllAggregates();
+ return 0;
+}
+// -----------------------------------------------------------------------------
+namespace
+{
+ void getMaxXPosition(Window* _pWindow,long& _rnMaxXPosition)
+ {
+ if (_pWindow)
+ {
+ long nTemp = _pWindow->GetSizePixel().Width() + _pWindow->GetPosPixel().X();
+ _rnMaxXPosition = ::std::max(_rnMaxXPosition, nTemp);
+ }
+ }
+}
+//------------------------------------------------------------------------------
+void OFieldDescControl::CheckScrollBars()
+{
+ // ein paar Berechnungen zur neuen Position der ScrollBars
+ Size szOverallSize = GetSizePixel();
+ long nHScrollHeight = m_pHorzScroll->GetSizePixel().Height();
+ long nVScrollWidth = m_pVertScroll->GetSizePixel().Width();
+
+ long nNewHWidth = szOverallSize.Width() - nVScrollWidth;
+ long nNewVHeight = szOverallSize.Height() - nHScrollHeight;
+
+ sal_Bool bNeedHScrollBar(sal_False), bNeedVScrollBar(sal_False);
+
+ // die Bereiche anpassen
+ // brauche ich ScrollBars eigentlich ?
+ // horizontal :
+ long lMaxXPosition = 0;
+ Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue};
+ for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
+ getMaxXPosition(ppAggregates[i],lMaxXPosition);
+
+ if (m_pHorzScroll)
+ lMaxXPosition += m_pHorzScroll->GetThumbPos() * HSCROLL_STEP;
+
+ long lMaxXAvailable = szOverallSize.Width();
+ bNeedHScrollBar = lMaxXPosition > lMaxXAvailable;
+ // aendert sich vielleicht noch
+
+ // vertikal
+ // wieviel Controls habe ich
+ sal_uInt16 nActive = CountActiveAggregates();
+ // welches ist das letzte, was ganz drauf passt ?
+ sal_uInt16 nLastVisible;
+ const sal_Int32 nControlHeight = GetMaxControlHeight();
+ const sal_Int32 nControl_Spacing_y = LogicToPixel(Size(0, CONTROL_SPACING_Y),MAP_APPFONT).Height();
+ if (bNeedHScrollBar)
+ nLastVisible = static_cast<sal_uInt16>((szOverallSize.Height() - nControl_Spacing_y - nHScrollHeight) / (nControl_Spacing_y + nControlHeight));
+ else
+ nLastVisible = static_cast<sal_uInt16>((szOverallSize.Height() - nControl_Spacing_y) / (nControl_Spacing_y + nControlHeight));
+ bNeedVScrollBar = nActive>nLastVisible;
+
+ if (bNeedVScrollBar)
+ {
+ // in die urspruengliche Berechnung von lMaxXAvailable ist nicht mit eingegangen, dass ich eine VScrollBar habe, also muss ich
+ // das nachholen
+ lMaxXAvailable -= nVScrollWidth;
+ if (!bNeedHScrollBar && (lMaxXPosition > lMaxXAvailable))
+ {
+ // durch die vertikale brauche ich jetzt ploetzlich doch eine horizontale
+ bNeedHScrollBar = sal_True;
+ // nLastVisible anpassen
+ nLastVisible = static_cast<sal_uInt16>((szOverallSize.Height() - nControl_Spacing_y - nHScrollHeight) / (nControl_Spacing_y + nControlHeight));
+ // bNeedVScrollBar aendert sich nicht : es ist schon auf sal_True und nLastVisible wird hoechstens kleiner
+ }
+ }
+
+ // jetzt kann ich sie wirklich positionieren und ihre Parameter setzen
+ if (bNeedVScrollBar)
+ {
+ m_pVertScroll->Show();
+ m_pVertScroll->SetRangeMax(nActive - nLastVisible);
+// m_pVertScroll->SetThumbPos(0);
+
+ m_pVertScroll->SetPosSizePixel( Point(nNewHWidth, 0), Size(nVScrollWidth, szOverallSize.Height()) );
+ }
+ else
+ {
+ m_pVertScroll->Hide();
+ m_pVertScroll->SetRangeMax(0);
+ m_pVertScroll->SetThumbPos(0);
+ }
+
+ if (bNeedHScrollBar)
+ {
+ m_pHorzScroll->Show();
+ m_pHorzScroll->SetRangeMax((lMaxXPosition - lMaxXAvailable + HSCROLL_STEP - 1 )/HSCROLL_STEP);
+// m_pHorzScroll->SetThumbPos(0);
+
+ m_pHorzScroll->SetPosSizePixel( Point(0, nNewVHeight), Size(bNeedVScrollBar ? nNewHWidth : szOverallSize.Width(), nHScrollHeight) );
+ }
+ else
+ {
+ m_pHorzScroll->Hide();
+ m_pHorzScroll->SetRangeMax(0);
+ m_pHorzScroll->SetThumbPos(0);
+ }
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::Resize()
+{
+ CheckScrollBars();
+ ScrollAllAggregates();
+}
+
+//------------------------------------------------------------------------------
+inline void OFieldDescControl::ScrollAggregate(Control* pText, Control* pInput, Control* pButton, long nDeltaX, long nDeltaY)
+{
+ if (!pText)
+ return;
+ pText->SetPosPixel(pText->GetPosPixel() + Point(nDeltaX, nDeltaY));
+ pInput->SetPosPixel(pInput->GetPosPixel() + Point(nDeltaX, nDeltaY));
+ if (pButton)
+ pButton->SetPosPixel(pButton->GetPosPixel() + Point(nDeltaX, nDeltaY));
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::ScrollAllAggregates()
+{
+ long nDeltaX = 0, nDeltaY = 0;
+ if (m_nOldHThumb != m_pHorzScroll->GetThumbPos())
+ {
+ nDeltaX = (m_nOldHThumb - m_pHorzScroll->GetThumbPos()) * HSCROLL_STEP;
+ m_nOldHThumb = m_pHorzScroll->GetThumbPos();
+ }
+
+ if (m_nOldVThumb != m_pVertScroll->GetThumbPos())
+ {
+ const sal_Int32 nControlHeight = GetMaxControlHeight();
+ const sal_Int32 nControl_Spacing_y = LogicToPixel(Size(0, CONTROL_SPACING_Y),MAP_APPFONT).Height();
+ nDeltaY = (m_nOldVThumb - m_pVertScroll->GetThumbPos()) * (nControl_Spacing_y + nControlHeight);
+ m_nOldVThumb = m_pVertScroll->GetThumbPos();
+ }
+
+ if (nDeltaX || nDeltaY)
+ {
+ Control* ppAggregates[] = { pRequired, pNumType
+ , pAutoIncrement, pDefault
+ , pTextLen, pLength
+ , pScale, m_pColumnName
+ , m_pType, m_pAutoIncrementValue};
+ Control* ppAggregatesText[] = { pRequiredText, pNumTypeText
+ , pAutoIncrementText, pDefaultText
+ , pTextLenText, pLengthText
+ , pScaleText, m_pColumnNameText
+ , m_pTypeText, m_pAutoIncrementValueText};
+ OSL_ENSURE(sizeof(ppAggregates)/sizeof(ppAggregates[0]) == sizeof(ppAggregatesText)/sizeof(ppAggregatesText[0]),"Lists are not identical!");
+
+ for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
+ ScrollAggregate(ppAggregatesText[i],ppAggregates[i],NULL,nDeltaX, nDeltaY);
+
+ ScrollAggregate(pFormatText,pFormatSample,pFormat,nDeltaX, nDeltaY);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_uInt16 OFieldDescControl::CountActiveAggregates() const
+{
+ Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue};
+ sal_uInt16 nVisibleAggregates = 0;
+ for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
+ if (ppAggregates[i])
+ ++nVisibleAggregates;
+ return nVisibleAggregates;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OFieldDescControl::GetMaxControlHeight() const
+{
+ Size aHeight;
+ Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue};
+ for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
+ {
+ if ( ppAggregates[i] )
+ {
+ const Size aTemp( ppAggregates[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) );
+ if ( aTemp.Height() > aHeight.Height() )
+ aHeight.Height() = aTemp.Height();
+ } // if ( ppAggregates[i] )
+ }
+
+ return aHeight.Height();
+}
+//------------------------------------------------------------------------------
+void OFieldDescControl::SetReadOnly( sal_Bool bReadOnly )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Controls enablen/disablen
+ Control* ppAggregates[] = { pRequired, pNumType
+ , pAutoIncrement, pDefault
+ , pTextLen, pLength
+ , pScale, m_pColumnName
+ , m_pType, m_pAutoIncrementValue
+ , pFormat};
+ Control* ppAggregatesText[] = { pRequiredText, pNumTypeText
+ , pAutoIncrementText, pDefaultText
+ , pTextLenText, pLengthText
+ , pScaleText, m_pColumnNameText
+ , m_pTypeText, m_pAutoIncrementValueText
+ , pFormatText};
+
+ OSL_ENSURE(sizeof(ppAggregates)/sizeof(ppAggregates[0]) == sizeof(ppAggregatesText)/sizeof(ppAggregatesText[0]),"Lists are not identical!");
+
+ for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i)
+ {
+ if ( ppAggregatesText[i] )
+ ppAggregatesText[i]->Enable( !bReadOnly );
+ if ( ppAggregates[i] )
+ ppAggregates[i]->Enable( !bReadOnly );
+ }
+}
+
+//------------------------------------------------------------------------------
+String OFieldDescControl::GetControlText( sal_uInt16 nControlId )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Texte der Controls auslesen
+ switch( nControlId )
+ {
+ case FIELD_PROPERTY_BOOL_DEFAULT:
+ if (pBoolDefault)
+ return pBoolDefault->GetSelectEntry();
+ break;
+ case FIELD_PROPERTY_DEFAULT:
+ if (pDefault)
+ return pDefault->GetText();
+ break;
+ case FIELD_PROPERTY_REQUIRED:
+ if (pRequired)
+ return pRequired->GetSelectEntry();
+ break;
+ case FIELD_PROPERTY_TEXTLEN:
+ if (pTextLen)
+ return String::CreateFromInt64(pTextLen->GetValue());
+ case FIELD_PROPERTY_NUMTYPE:
+ if (pNumType)
+ return pNumType->GetSelectEntry();
+ break;
+ case FIELD_PROPERTY_AUTOINC:
+ if (pAutoIncrement)
+ return pAutoIncrement->GetSelectEntry();
+ break;
+ case FIELD_PROPERTY_LENGTH:
+ if (pLength)
+ return pLength->GetText();
+ break;
+ case FIELD_PROPERTY_SCALE:
+ if (pScale)
+ return pScale->GetText();
+ break;
+ case FIELD_PROPERTY_FORMAT:
+ if (pFormatSample)
+ return pFormatSample->GetText();
+ break;
+ case FIELD_PRPOERTY_COLUMNNAME:
+ if(m_pColumnName)
+ return m_pColumnName->GetText();
+ case FIELD_PRPOERTY_TYPE:
+ if(m_pType)
+ return m_pType->GetSelectEntry();
+ break;
+ case FIELD_PRPOERTY_AUTOINCREMENT:
+ if(m_pAutoIncrementValue)
+ return m_pAutoIncrementValue->GetText();
+ }
+
+ return String();
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::SetControlText( sal_uInt16 nControlId, const String& rText )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Texte der Controls setzen
+ switch( nControlId )
+ {
+ case FIELD_PROPERTY_BOOL_DEFAULT:
+ if (pBoolDefault)
+ {
+ String sOld = pBoolDefault->GetSelectEntry();
+ pBoolDefault->SelectEntry(rText);
+ if (!sOld.Equals(rText))
+ LINK(this, OFieldDescControl, ChangeHdl).Call(pBoolDefault);
+ }
+ break;
+ case FIELD_PROPERTY_DEFAULT:
+ if (pDefault)
+ {
+ pDefault->SetText(rText);
+ UpdateFormatSample(pActFieldDescr);
+ }
+ break;
+
+ case FIELD_PROPERTY_REQUIRED:
+ if (pRequired)
+ pRequired->SelectEntry(rText);
+ break;
+
+
+ case FIELD_PROPERTY_TEXTLEN:
+ if (pTextLen)
+ pTextLen->SetText(rText);
+ break;
+
+ case FIELD_PROPERTY_NUMTYPE:
+ if (pNumType)
+ pNumType->SelectEntry(rText);
+ break;
+
+ case FIELD_PROPERTY_AUTOINC:
+ if (pAutoIncrement)
+ {
+ String sOld = pAutoIncrement->GetSelectEntry();
+ pAutoIncrement->SelectEntry(rText);
+ if (!sOld.Equals(rText))
+ LINK(this, OFieldDescControl, ChangeHdl).Call(pAutoIncrement);
+ }
+ break;
+
+ case FIELD_PROPERTY_LENGTH:
+ if (pLength)
+ pLength->SetText(rText);
+ break;
+
+ case FIELD_PROPERTY_SCALE:
+ if (pScale)
+ pScale->SetText(rText);
+ break;
+
+ case FIELD_PROPERTY_FORMAT:
+ if (pActFieldDescr)
+ UpdateFormatSample(pActFieldDescr);
+ break;
+ case FIELD_PRPOERTY_COLUMNNAME:
+ if(m_pColumnName)
+ m_pColumnName->SetText(rText);
+ break;
+ case FIELD_PRPOERTY_TYPE:
+ if(m_pType)
+ m_pType->SelectEntry(rText);
+ break;
+ case FIELD_PRPOERTY_AUTOINCREMENT:
+ if(m_pAutoIncrementValue)
+ m_pAutoIncrementValue->SetText(rText);
+ break;
+ }
+}
+
+//------------------------------------------------------------------------
+IMPL_LINK( OFieldDescControl, FormatClickHdl, Button *, /*pButton*/ )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Temporaere Column erzeugen, mit der Datenaustausch mit Dialog erfolgt
+ if( !pActFieldDescr )
+ return 0;
+
+ sal_Int32 nOldFormatKey(pActFieldDescr->GetFormatKey());
+ SvxCellHorJustify rOldJustify = pActFieldDescr->GetHorJustify();
+ Reference< XNumberFormatsSupplier > xSupplier = GetFormatter()->getNumberFormatsSupplier();
+ SvNumberFormatsSupplierObj* pSupplierImpl = SvNumberFormatsSupplierObj::getImplementation( xSupplier );
+
+ SvNumberFormatter* pFormatter = pSupplierImpl->GetNumberFormatter();
+ sal_uInt16 nFlags;
+ if(::dbaui::callColumnFormatDialog(this,pFormatter,pActFieldDescr->GetType(),nOldFormatKey,rOldJustify,nFlags,sal_True))
+ {
+ sal_Bool bModified = sal_False;
+ if(nOldFormatKey != pActFieldDescr->GetFormatKey())
+ {
+ pActFieldDescr->SetFormatKey( nOldFormatKey );
+ bModified = sal_True;
+ }
+ if(rOldJustify != pActFieldDescr->GetHorJustify())
+ {
+ pActFieldDescr->SetHorJustify( rOldJustify );
+ bModified = sal_True;
+ }
+
+ if(bModified)
+ {
+ SetModified(sal_True);
+ UpdateFormatSample(pActFieldDescr);
+ }
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+void OFieldDescControl::SetModified(sal_Bool /*bModified*/)
+{
+}
+//------------------------------------------------------------------------
+IMPL_LINK( OFieldDescControl, ChangeHdl, ListBox *, pListBox )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ if ( !pActFieldDescr )
+ return 0;
+
+ if ( pListBox->GetSavedValue() != pListBox->GetSelectEntryPos() )
+ SetModified(sal_True);
+
+ // Sonderbehandlund f"ur Bool Felder
+ if(pListBox == pRequired && pBoolDefault )
+ {
+ // wenn pRequired auf sal_True gesetzt ist, dann darf das sal_Bool Feld nicht den Eintrag <<keiner>> besitzen
+ String sDef = BoolStringUI(::comphelper::getString(pActFieldDescr->GetControlDefault()));
+
+ if(pRequired->GetSelectEntryPos() == 0) // JA
+ {
+ pBoolDefault->RemoveEntry(String(ModuleRes(STR_VALUE_NONE)));
+ if (!sDef.Equals(aYes) && !sDef.Equals(aNo))
+ pBoolDefault->SelectEntryPos(1); // nein als Default
+ else
+ pBoolDefault->SelectEntry(sDef);
+ }
+ else if(pBoolDefault->GetEntryCount() < 3)
+ {
+ pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE)));
+ pBoolDefault->SelectEntry(sDef);
+ }
+ }
+
+ // nur fuer AutoIncrement eine Sonderbehandlung
+ if (pListBox == pAutoIncrement)
+ {
+ if(pListBox->GetSelectEntryPos() == 1)
+ { // no
+ DeactivateAggregate( tpAutoIncrementValue );
+ if(pActFieldDescr->IsPrimaryKey())
+ DeactivateAggregate( tpRequired );
+ else if( pActFieldDescr->getTypeInfo()->bNullable )
+ {
+ ActivateAggregate( tpRequired );
+ if(pRequired)
+ {
+ if( pActFieldDescr->IsNullable() )
+ pRequired->SelectEntryPos( 1 ); // no
+ else
+ pRequired->SelectEntryPos( 0 ); // yes
+ }
+ }
+ ActivateAggregate( tpDefault );
+ }
+ else
+ {
+ DeactivateAggregate( tpRequired );
+ DeactivateAggregate( tpDefault );
+ ActivateAggregate( tpAutoIncrementValue );
+ }
+ // und jetzt alle nach oben schieben
+ ArrangeAggregates();
+ }
+
+ if(pListBox == m_pType)
+ {
+ TOTypeInfoSP pTypeInfo = getTypeInfo(m_pType->GetSelectEntryPos());
+ pActFieldDescr->FillFromTypeInfo(pTypeInfo,sal_True,sal_False); // SetType(pTypeInfo);
+
+ DisplayData(pActFieldDescr);
+ CellModified(-1, m_pType->GetPos());
+ }
+
+ return 0;
+}
+//------------------------------------------------------------------------------
+// alle Control neu anordnen, so dass sie in fester Reihenfolge und wirklich
+// OBEN auf der DescriptionPage stehen
+void OFieldDescControl::ArrangeAggregates()
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ // die Beschreibung eines Controls
+ struct AGGREGATE_DESCRIPTION
+ {
+ Control* pctrlInputControl; // das eigentliche Control zur Eingabe
+ Control* pctrlTextControl; // das Label dazu
+ USHORT nPosSizeArgument; // das zweite Argument fuer SetPosSize
+ };
+ AGGREGATE_DESCRIPTION adAggregates[] = {
+ { m_pColumnName, m_pColumnNameText, 1},
+ { m_pType, m_pTypeText, 1},
+ { pAutoIncrement, pAutoIncrementText, 1 },
+ { m_pAutoIncrementValue, m_pAutoIncrementValueText, 3 },
+ { pNumType, pNumTypeText, 1 },
+ { pRequired, pRequiredText, 1 },
+ { pTextLen, pTextLenText, 1 },
+ { pLength, pLengthText, 1 },
+ { pScale, pScaleText, 1 },
+ { pDefault, pDefaultText, 3 },
+ { pFormatSample, pFormatText, 4 },
+ { pBoolDefault, pBoolDefaultText, 1 },
+ };
+
+ long nMaxWidth = 0;
+ for (size_t i=0; i<sizeof(adAggregates)/sizeof(adAggregates[0]); i++)
+ {
+ if (adAggregates[i].pctrlTextControl)
+ {
+ nMaxWidth = ::std::max<long>(OutputDevice::GetTextWidth(adAggregates[i].pctrlTextControl->GetText()),nMaxWidth);
+ }
+ }
+
+ OSL_ENSURE(nMaxWidth != 0,"Invalid width!");
+
+ // und los ...
+ int nCurrentControlPos = 0;
+ Control* pZOrderPredecessor = NULL;
+ for (size_t i=0; i<sizeof(adAggregates)/sizeof(adAggregates[0]); i++)
+ {
+ if (adAggregates[i].pctrlInputControl)
+ {
+ SetPosSize(&adAggregates[i].pctrlTextControl, nCurrentControlPos, 0);
+ SetPosSize(&adAggregates[i].pctrlInputControl, nCurrentControlPos, adAggregates[i].nPosSizeArgument);
+
+ // die Z-Order so, dass die Controls auch wirklich in derselben Reihenfolge durchwandert werden koennen, in der sie
+ // hier angeordnet wurden
+ adAggregates[i].pctrlTextControl->SetZOrder(pZOrderPredecessor, pZOrderPredecessor ? WINDOW_ZORDER_BEHIND : WINDOW_ZORDER_FIRST);
+ adAggregates[i].pctrlInputControl->SetZOrder(adAggregates[i].pctrlTextControl, WINDOW_ZORDER_BEHIND );
+ pZOrderPredecessor = adAggregates[i].pctrlInputControl;
+
+ if (adAggregates[i].pctrlInputControl == pFormatSample)
+ {
+ pFormat->SetZOrder(pZOrderPredecessor, WINDOW_ZORDER_BEHIND);
+ pZOrderPredecessor = pFormat;
+ }
+
+ ++nCurrentControlPos;
+ }
+ }
+
+ // eine Sonderbehandlung fuer die Format-Controls
+ if (pFormat)
+ {
+ Point ptSamplePos(pFormatSample->GetPosPixel());
+ Size szSampleSize(pFormatSample->GetSizePixel());
+ pFormat->SetPosPixel(Point(ptSamplePos.X() + szSampleSize.Width() + 5, ptSamplePos.Y()));
+ }
+
+ // als letztes noch die ScrollBars in der ZOrder ganz nach oben
+ m_pVertScroll->SetZOrder(NULL, WINDOW_ZORDER_FIRST);
+ m_pHorzScroll->SetZOrder(NULL, WINDOW_ZORDER_FIRST);
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::ActivateAggregate( EControlType eType )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Controls erzeugen
+ switch( eType )
+ {
+ case tpDefault:
+ if( pDefault )
+ return;
+ m_nPos++;
+ pDefaultText = CreateText(STR_DEFAULT_VALUE);
+ pDefault = new OPropEditCtrl( this, STR_HELP_DEFAULT_VALUE, FIELD_PROPERTY_DEFAULT, WB_BORDER );
+ InitializeControl(pDefault,HID_TAB_ENT_DEFAULT,false);
+ break;
+ case tpAutoIncrementValue:
+ if( m_pAutoIncrementValue || !isAutoIncrementValueEnabled() )
+ return;
+ m_nPos++;
+ m_pAutoIncrementValueText = CreateText(STR_AUTOINCREMENT_VALUE);
+ m_pAutoIncrementValue = new OPropEditCtrl( this, STR_HELP_AUTOINCREMENT_VALUE, FIELD_PRPOERTY_AUTOINCREMENT, WB_BORDER );
+ m_pAutoIncrementValue->SetText( getAutoIncrementValue() );
+ InitializeControl(m_pAutoIncrementValue,HID_TAB_AUTOINCREMENTVALUE,false);
+ break;
+
+ case tpRequired:
+ {
+ if( pRequired )
+ return;
+ Reference< XDatabaseMetaData> xMetaData = getMetaData();
+
+ if(xMetaData.is() && xMetaData->supportsNonNullableColumns())
+ {
+ m_nPos++;
+ pRequiredText = CreateText(STR_FIELD_REQUIRED);
+ pRequired = new OPropListBoxCtrl( this, STR_HELP_FIELD_REQUIRED, FIELD_PROPERTY_REQUIRED, WB_DROPDOWN);
+
+ pRequired->InsertEntry( aYes );
+ pRequired->InsertEntry( aNo );
+ pRequired->SelectEntryPos(1);
+
+ InitializeControl(pRequired,HID_TAB_ENT_REQUIRED,true);
+ }
+ }
+ break;
+ case tpAutoIncrement:
+ {
+ if( pAutoIncrement )
+ return;
+ m_nPos++;
+ pAutoIncrementText = CreateText(STR_FIELD_AUTOINCREMENT);
+ pAutoIncrement = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PROPERTY_AUTOINC, WB_DROPDOWN );
+ pAutoIncrement->InsertEntry( aYes );
+ pAutoIncrement->InsertEntry( aNo );
+ pAutoIncrement->SelectEntryPos(0);
+ InitializeControl(pAutoIncrement,HID_TAB_ENT_AUTOINCREMENT,true);
+ }
+ break;
+ case tpTextLen:
+ if( pTextLen )
+ return;
+ m_nPos++;
+ pTextLenText = CreateText(STR_TEXT_LENGTH);
+ pTextLen = CreateNumericControl(STR_HELP_TEXT_LENGTH, FIELD_PROPERTY_TEXTLEN,HID_TAB_ENT_TEXT_LEN);
+ break;
+
+ case tpType:
+ if( m_pType)
+ return;
+ m_nPos++;
+ m_pTypeText = CreateText(STR_TAB_FIELD_DATATYPE);
+ m_pType = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PRPOERTY_TYPE, WB_DROPDOWN );
+ m_pType->SetDropDownLineCount(20);
+ {
+ const OTypeInfoMap* pTypeInfo = getTypeInfo();
+ OTypeInfoMap::const_iterator aIter = pTypeInfo->begin();
+ OTypeInfoMap::const_iterator aEnd = pTypeInfo->end();
+ for(;aIter != aEnd;++aIter)
+ m_pType->InsertEntry( aIter->second->aUIName );
+ }
+ m_pType->SelectEntryPos(0);
+ InitializeControl(m_pType,HID_TAB_ENT_TYPE,true);
+ break;
+ case tpColumnName:
+ if( m_pColumnName )
+ return;
+ m_nPos++;
+ {
+ sal_uInt32 nMax = EDIT_NOLIMIT;
+ ::rtl::OUString aTmpString;
+ try
+ {
+ Reference< XDatabaseMetaData> xMetaData = getMetaData();
+ if ( xMetaData.is() )
+ {
+ nMax = xMetaData->getMaxColumnNameLength();
+ aTmpString = xMetaData->getExtraNameCharacters();
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_pColumnNameText = CreateText(STR_TAB_FIELD_NAME);
+ m_pColumnName = new OPropColumnEditCtrl( this,
+ aTmpString,
+ STR_HELP_DEFAULT_VALUE,
+ FIELD_PRPOERTY_COLUMNNAME,
+ WB_BORDER );
+ m_pColumnName->SetMaxTextLen(xub_StrLen( nMax ? nMax : EDIT_NOLIMIT));
+ m_pColumnName->setCheck( isSQL92CheckEnabled(getConnection()) );
+ }
+
+ InitializeControl(m_pColumnName,HID_TAB_ENT_COLUMNNAME,false);
+ break;
+ case tpNumType:
+ if( pNumType )
+ return;
+ m_nPos++;
+ pNumTypeText = CreateText(STR_NUMERIC_TYPE);
+
+ pNumType = new OPropListBoxCtrl( this, STR_HELP_NUMERIC_TYPE, FIELD_PROPERTY_NUMTYPE, WB_DROPDOWN );
+ pNumType->SetDropDownLineCount(5);
+
+ pNumType->InsertEntry( String::CreateFromAscii("Byte") );
+ pNumType->InsertEntry( String::CreateFromAscii("SmallInt") );
+ pNumType->InsertEntry( String::CreateFromAscii("Integer") );
+ pNumType->InsertEntry( String::CreateFromAscii("Single") );
+ pNumType->InsertEntry( String::CreateFromAscii("Double") );
+ pNumType->SelectEntryPos(2);
+ InitializeControl(pNumType,HID_TAB_ENT_NUMTYP,true);
+ break;
+
+ case tpLength:
+ if( pLength )
+ return;
+ m_nPos++;
+ pLengthText = CreateText(STR_LENGTH);
+ pLength = CreateNumericControl(STR_HELP_LENGTH, FIELD_PROPERTY_LENGTH,HID_TAB_ENT_LEN);
+ break;
+
+ case tpScale:
+ if( pScale )
+ return;
+ m_nPos++;
+ pScaleText = CreateText(STR_SCALE);
+ pScale = CreateNumericControl(STR_HELP_SCALE, FIELD_PROPERTY_SCALE,HID_TAB_ENT_SCALE);
+ break;
+
+ case tpFormat:
+ if (!pFormat)
+ {
+ m_nPos++;
+ pFormatText = CreateText(STR_FORMAT);
+
+ pFormatSample = new OPropEditCtrl( this, STR_HELP_FORMAT_CODE, -1, WB_BORDER );
+ pFormatSample->SetReadOnly(sal_True);
+ pFormatSample->Enable(sal_False);
+ InitializeControl(pFormatSample,HID_TAB_ENT_FORMAT_SAMPLE,false);
+
+ pFormat = new PushButton( this, ModuleRes(PB_FORMAT) );
+ const sal_Int32 nControlHeight = GetMaxControlHeight();
+ pFormat->SetSizePixel(Size(nControlHeight, nControlHeight));
+ pFormat->SetClickHdl( LINK( this, OFieldDescControl, FormatClickHdl ) );
+ InitializeControl(pFormat,HID_TAB_ENT_FORMAT,false);
+ }
+
+ UpdateFormatSample(pActFieldDescr);
+ break;
+ case tpBoolDefault:
+ if (pBoolDefault)
+ return;
+
+ m_nPos++;
+ pBoolDefaultText = CreateText(STR_DEFAULT_VALUE);
+ pBoolDefault = new OPropListBoxCtrl( this, STR_HELP_BOOL_DEFAULT, FIELD_PROPERTY_BOOL_DEFAULT, WB_DROPDOWN );
+ pBoolDefault->SetDropDownLineCount(3);
+ pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE)));
+ pBoolDefault->InsertEntry(aYes);
+ pBoolDefault->InsertEntry(aNo);
+
+ InitializeControl(pBoolDefault,HID_TAB_ENT_BOOL_DEFAULT,false);
+ break;
+ }
+}
+// -----------------------------------------------------------------------------
+void OFieldDescControl::InitializeControl(Control* _pControl,ULONG _nHelpId,bool _bAddChangeHandler)
+{
+ _pControl->SetHelpId(_nHelpId);
+ if ( _bAddChangeHandler )
+ ((OPropListBoxCtrl*)_pControl)->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl));
+
+ _pControl->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot));
+ _pControl->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost));
+ _pControl->EnableClipSiblings();
+}
+// -----------------------------------------------------------------------------
+FixedText* OFieldDescControl::CreateText(USHORT _nTextRes)
+{
+ FixedText* pFixedText = new FixedText( this );
+ pFixedText->SetText( ModuleRes(_nTextRes) );
+ pFixedText->EnableClipSiblings();
+ return pFixedText;
+}
+// -----------------------------------------------------------------------------
+OPropNumericEditCtrl* OFieldDescControl::CreateNumericControl(USHORT _nHelpStr,short _nProperty,ULONG _nHelpId)
+{
+ OPropNumericEditCtrl* pControl = new OPropNumericEditCtrl( this, _nHelpStr, _nProperty, WB_BORDER );
+ pControl->SetDecimalDigits(0);
+ pControl->SetMin(0);
+ pControl->SetMax(0x7FFFFFFF); // soll draussen geaendert werden, wenn noetig
+ pControl->SetStrictFormat(TRUE);
+
+ InitializeControl(pControl,_nHelpId,false);
+
+ return pControl;
+}
+//------------------------------------------------------------------------------
+void OFieldDescControl::DeactivateAggregate( EControlType eType )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ pLastFocusWindow = NULL;
+ //////////////////////////////////////////////////////////////////////
+ // Controls zerstoeren
+ switch( eType )
+ {
+ case tpDefault:
+ lcl_HideAndDeleteControl(m_nPos,&pDefault,&pDefaultText);
+ break;
+
+ case tpAutoIncrementValue:
+ lcl_HideAndDeleteControl(m_nPos,&m_pAutoIncrementValue,&m_pAutoIncrementValueText);
+ break;
+
+ case tpColumnName:
+ lcl_HideAndDeleteControl(m_nPos,&m_pColumnName,&m_pColumnNameText);
+ break;
+
+ case tpType:
+ lcl_HideAndDeleteControl(m_nPos,&m_pType,&m_pTypeText);
+ break;
+
+ case tpAutoIncrement:
+ lcl_HideAndDeleteControl(m_nPos,&pAutoIncrement,&pAutoIncrementText);
+ break;
+
+ case tpRequired:
+ lcl_HideAndDeleteControl(m_nPos,&pRequired,&pRequiredText);
+ break;
+
+ case tpTextLen:
+ lcl_HideAndDeleteControl(m_nPos,&pTextLen,&pTextLenText);
+ break;
+
+ case tpNumType:
+ lcl_HideAndDeleteControl(m_nPos,&pNumType,&pNumTypeText);
+ break;
+
+ case tpLength:
+ lcl_HideAndDeleteControl(m_nPos,&pLength,&pLengthText);
+ break;
+
+ case tpScale:
+ lcl_HideAndDeleteControl(m_nPos,&pScale,&pScaleText);
+ break;
+
+ case tpFormat:
+ // TODO: we have to check if we have to increment m_nPos again
+ lcl_HideAndDeleteControl(m_nPos,&pFormat,&pFormatText);
+ if ( pFormatSample )
+ {
+ pFormatSample->Hide();
+ delete pFormatSample;
+ pFormatSample = NULL;
+ }
+ break;
+ case tpBoolDefault:
+ lcl_HideAndDeleteControl(m_nPos,&pBoolDefault,&pBoolDefaultText);
+ break;
+ }
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::SetPosSize( Control** ppControl, long nRow, sal_uInt16 nCol )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+
+ //////////////////////////////////////////////////////////////////////
+ // Groesse ermitteln
+ const sal_Int32 nControlHeight = GetMaxControlHeight();
+ Size aSize(0,nControlHeight);
+ if ( isRightAligned() && nCol )
+ aSize.Width() = LogicToPixel(Size(m_nWidth, 0),MAP_APPFONT).Width();
+ else
+ {
+ switch( nCol )
+ {
+ case 0:
+ default:
+ aSize.Width() = CONTROL_WIDTH_1;
+ break;
+ case 1:
+ aSize.Width() = CONTROL_WIDTH_2;
+ break;
+ case 3:
+ aSize.Width() = CONTROL_WIDTH_3;
+ break;
+ case 4:
+ aSize.Width() = CONTROL_WIDTH_4;
+ break;
+ } // switch( nCol )
+ }
+
+
+ //////////////////////////////////////////////////////////////////////
+ // Position ermitteln
+ Point aPosition;
+ switch( nCol )
+ {
+ case 0:
+ aPosition.X() = 0;
+ aPosition.Y() = 1;
+ break;
+ case 1:
+ case 3:
+ case 4:
+ if ( isRightAligned() )
+ {
+ Size aOwnSize = GetSizePixel();
+ aPosition.X() = aOwnSize.Width() - aSize.Width();
+ }
+ else
+ aPosition.X() = CONTROL_WIDTH_1 + CONTROL_SPACING_X;
+ break;
+ default:
+ aPosition.X() = 0;
+ }
+
+ (*ppControl)->SetSizePixel( aSize );
+ aSize = (*ppControl)->GetSizePixel( );
+
+ const sal_Int32 nControl_Spacing_y = LogicToPixel(Size(0, CONTROL_SPACING_Y),MAP_APPFONT).Height();
+ aPosition.Y() += ((nRow+1)*nControl_Spacing_y) +
+ (nRow*nControlHeight);
+
+ //////////////////////////////////////////////////////////////////////
+ // Control anzeigen
+ (*ppControl)->SetPosSizePixel( aPosition, aSize );
+ aSize = (*ppControl)->GetSizePixel();
+
+ (*ppControl)->Show();
+}
+//------------------------------------------------------------------------------
+void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ pActFieldDescr = pFieldDescr;
+ if(!pFieldDescr)
+ {
+ DeactivateAggregate( tpDefault );
+ DeactivateAggregate( tpRequired );
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpNumType );
+ DeactivateAggregate( tpScale );
+ DeactivateAggregate( tpLength );
+ DeactivateAggregate( tpFormat );
+ DeactivateAggregate( tpAutoIncrement );
+ DeactivateAggregate( tpBoolDefault );
+ DeactivateAggregate( tpColumnName );
+ DeactivateAggregate( tpType );
+ DeactivateAggregate( tpAutoIncrementValue );
+ m_pPreviousType = TOTypeInfoSP();
+ //////////////////////////////////////////////////////////////////////
+ // Zeiger des gespeicherten Focus zuruecksetzen
+ pLastFocusWindow = NULL;
+ if ( m_bAdded )
+ {
+ ::dbaui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
+ m_bAdded = sal_False;
+ }
+ return;
+ }
+
+ if ( !m_bAdded )
+ {
+ ::dbaui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::AddWindow));
+ m_bAdded = sal_True;
+ }
+
+ TOTypeInfoSP pFieldType;
+ if( pFieldDescr )
+ pFieldType = pFieldDescr->getTypeInfo();
+
+ ActivateAggregate( tpColumnName );
+ ActivateAggregate( tpType );
+
+ OSL_ENSURE(pFieldType.get(),"We need a type information here!");
+ //////////////////////////////////////////////////////////////////////
+ // Wenn sich der Typ geaendert hat, Controls austauschen
+ if( m_pPreviousType != pFieldType )
+ {
+ //////////////////////////////////////////////////////////////////////
+ // Zeiger des gespeicherten Focus zuruecksetzen
+ pLastFocusWindow = NULL;
+
+ //////////////////////////////////////////////////////////////////////
+ // Controls, die nicht mehr angezeigt werden duerfen
+ DeactivateAggregate( tpNumType );
+
+ //////////////////////////////////////////////////////////////////////
+ // determine which controls we should show and which not
+
+ // 1. the required control
+ if ( pFieldType->bNullable )
+ ActivateAggregate( tpRequired );
+ else
+ DeactivateAggregate( tpRequired );
+
+ // 2. the autoincrement
+ if ( pFieldType->bAutoIncrement )
+ {
+ DeactivateAggregate( tpRequired );
+ DeactivateAggregate( tpDefault );
+ ActivateAggregate( tpAutoIncrement );
+ ActivateAggregate( tpAutoIncrementValue );
+ }
+ else
+ {
+ DeactivateAggregate( tpAutoIncrement );
+ DeactivateAggregate( tpAutoIncrementValue );
+ if(pFieldType->bNullable)
+ ActivateAggregate( tpRequired );
+ else
+ DeactivateAggregate( tpRequired );
+ ActivateAggregate( tpDefault );
+ }
+ // 3. the scale and precision
+ if (pFieldType->nPrecision)
+ {
+ ActivateAggregate( tpLength );
+ pLength->SetMax(::std::max<sal_Int32>(pFieldType->nPrecision,pFieldDescr->GetPrecision()));
+ pLength->SetSpecialReadOnly(pFieldType->aCreateParams.getLength()==0);
+ }
+ else
+ DeactivateAggregate( tpLength );
+
+ if (pFieldType->nMaximumScale)
+ {
+ ActivateAggregate( tpScale );
+ pScale->SetMax(::std::max<sal_Int32>(pFieldType->nMaximumScale,pFieldDescr->GetScale()));
+ pScale->SetMin(pFieldType->nMinimumScale);
+ static const ::rtl::OUString s_sPRECISION(RTL_CONSTASCII_USTRINGPARAM("PRECISION"));
+ pScale->SetSpecialReadOnly(pFieldType->aCreateParams.getLength() == 0 || pFieldType->aCreateParams == s_sPRECISION);
+ }
+ else
+ DeactivateAggregate( tpScale );
+
+ // and now look for type specific things
+ switch( pFieldType->nType )
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ DeactivateAggregate( tpLength );
+ DeactivateAggregate( tpBoolDefault );
+
+ ActivateAggregate( tpDefault );
+ ActivateAggregate( tpFormat );
+ if (pFieldType->nPrecision)
+ {
+ ActivateAggregate( tpTextLen );
+ pTextLen->SetMax(::std::max<sal_Int32>(pFieldType->nPrecision,pFieldDescr->GetPrecision()));
+ pTextLen->SetSpecialReadOnly(pFieldType->aCreateParams.getLength()==0);
+ }
+ else
+ DeactivateAggregate( tpTextLen );
+ break;
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ DeactivateAggregate( tpLength ); // we don't need a length for date types
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpBoolDefault );
+
+ ActivateAggregate( tpDefault );
+ ActivateAggregate( tpFormat );
+ break;
+ case DataType::BIT:
+ if ( pFieldType->aCreateParams.getLength() )
+ {
+ DeactivateAggregate( tpFormat );
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpBoolDefault );
+ break;
+ }
+ // run through
+ case DataType::BOOLEAN:
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpFormat );
+ DeactivateAggregate( tpDefault );
+
+ ActivateAggregate( tpBoolDefault );
+ break;
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::BIGINT:
+ case DataType::FLOAT:
+ case DataType::DOUBLE:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::REAL:
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpBoolDefault );
+
+ ActivateAggregate( tpFormat );
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ DeactivateAggregate( tpDefault );
+ DeactivateAggregate( tpRequired );
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpBoolDefault );
+
+ ActivateAggregate( tpFormat );
+ break;
+ case DataType::LONGVARBINARY:
+ case DataType::SQLNULL:
+ case DataType::OBJECT:
+ case DataType::DISTINCT:
+ case DataType::STRUCT:
+ case DataType::ARRAY:
+ case DataType::BLOB:
+ case DataType::CLOB:
+ case DataType::REF:
+ case DataType::OTHER:
+ DeactivateAggregate( tpFormat );
+ DeactivateAggregate( tpTextLen );
+ DeactivateAggregate( tpBoolDefault );
+
+ break;
+ default:
+ OSL_ENSURE(0,"Unknown type");
+ }
+ m_pPreviousType = pFieldType;
+ }
+ if(pFieldDescr)
+ {
+ if(pFieldDescr->IsPrimaryKey())
+ {
+ DeactivateAggregate( tpRequired );
+ }
+ else if ( !pAutoIncrement && pFieldType.get() )
+ {
+ if ( pFieldType->bNullable )
+ ActivateAggregate( tpRequired );
+ else
+ DeactivateAggregate( tpRequired );
+ }
+ }
+ //////////////////////////////////////////////////////////////////////
+ // Controls initialisieren
+ if( pAutoIncrement )
+ {
+ if ( pFieldDescr->IsAutoIncrement() )
+ {
+ pAutoIncrement->SelectEntryPos( 0 ); // yes
+ ActivateAggregate( tpAutoIncrementValue );
+ if ( m_pAutoIncrementValue )
+ m_pAutoIncrementValue->SetText(pFieldDescr->GetAutoIncrementValue());
+ DeactivateAggregate( tpRequired );
+ DeactivateAggregate( tpDefault );
+ }
+ else
+ {
+ // disable autoincrement value because it should only be visible when autoincrement is to true
+ DeactivateAggregate( tpAutoIncrementValue );
+ pAutoIncrement->SelectEntryPos( 1 ); // no
+ ActivateAggregate( tpDefault );
+ // hat Auswirkungen auf pRequired
+ if(!pFieldDescr->IsPrimaryKey())
+ ActivateAggregate( tpRequired );
+ }
+ }
+
+ if( pDefault )
+ {
+ pDefault->SetText( getControlDefault(pFieldDescr) );
+ pDefault->ClearModifyFlag();
+ }
+
+ if( pBoolDefault )
+ {
+ // wenn pRequired auf sal_True gesetzt ist, dann darf das sal_Bool Feld nicht den Eintrag <<keiner>> besitzen
+ ::rtl::OUString sValue;
+ pFieldDescr->GetControlDefault() >>= sValue;
+ String sDef = BoolStringUI(sValue);
+
+ // sicher stellen das <<keiner>> nur vorhanden ist, wenn das Feld NULL sein darf
+ if ( ( pFieldType.get() && !pFieldType->bNullable ) || !pFieldDescr->IsNullable() )
+ {
+ pFieldDescr->SetIsNullable(ColumnValue::NO_NULLS); // der Typ sagt das
+
+ pBoolDefault->RemoveEntry(String(ModuleRes(STR_VALUE_NONE)));
+ if ( !sDef.Equals(aYes) && !sDef.Equals(aNo) )
+ pBoolDefault->SelectEntryPos(1); // nein als Default
+ else
+ pBoolDefault->SelectEntry(sDef);
+
+ pFieldDescr->SetControlDefault(makeAny(::rtl::OUString(BoolStringPersistent(pBoolDefault->GetSelectEntry()))));
+ }
+ else if(pBoolDefault->GetEntryCount() < 3)
+ {
+ pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE)));
+ pBoolDefault->SelectEntry(sDef);
+ }
+ else
+ pBoolDefault->SelectEntry(sDef);
+ }
+
+ if( pRequired )
+ {
+ if( pFieldDescr->IsNullable() )
+ pRequired->SelectEntryPos( 1 ); // no
+ else
+ pRequired->SelectEntryPos( 0 ); // yes
+ }
+
+ if( pTextLen )
+ {
+ pTextLen->SetText( String::CreateFromInt32(pFieldDescr->GetPrecision()) );
+ pTextLen->ClearModifyFlag();
+ }
+
+ if( pNumType )
+ {
+ OSL_ENSURE(sal_False, "OFieldDescControl::DisplayData: invalid num type!");
+ }
+
+ if( pLength )
+ pLength->SetText( String::CreateFromInt32(pFieldDescr->GetPrecision()) );
+
+ if( pScale )
+ pScale->SetText( String::CreateFromInt32(pFieldDescr->GetScale()) );
+
+ if( pFormat )
+ UpdateFormatSample(pFieldDescr);
+
+ if(m_pColumnName)
+ m_pColumnName->SetText(pFieldDescr->GetName());
+
+ if(m_pType)
+ {
+ USHORT nPos = pFieldType.get() ? m_pType->GetEntryPos(String(pFieldDescr->getTypeInfo()->aUIName)) : LISTBOX_ENTRY_NOTFOUND;
+ if(nPos == LISTBOX_ENTRY_NOTFOUND)
+ {
+ const OTypeInfoMap* pMap = getTypeInfo();
+ OTypeInfoMap::const_iterator aIter = pMap->find(pFieldType.get() ? pFieldDescr->getTypeInfo()->nType : pFieldDescr->GetType());
+ if(aIter == pMap->end() && !pMap->empty())
+ {
+ aIter = pMap->begin();
+ if(pFieldDescr->GetPrecision() > aIter->second->nPrecision)
+ pFieldDescr->SetPrecision(aIter->second->nPrecision);
+ if(pFieldDescr->GetScale() > aIter->second->nMaximumScale)
+ pFieldDescr->SetScale(0);
+ if(!aIter->second->bNullable && pFieldDescr->IsNullable())
+ pFieldDescr->SetIsNullable(ColumnValue::NO_NULLS);
+ if(!aIter->second->bAutoIncrement && pFieldDescr->IsAutoIncrement())
+ pFieldDescr->SetAutoIncrement(sal_False);
+ }
+ if ( aIter != pMap->end() )
+ {
+ pFieldDescr->SetType(aIter->second);
+ }
+ }
+ m_pType->SelectEntry(pFieldDescr->getTypeInfo()->aUIName);
+ }
+
+
+ //////////////////////////////////////////////////////////////////////
+ // Controls Enablen/Disablen
+ sal_Bool bRead(IsReadOnly());
+
+
+ ArrangeAggregates();
+ CheckScrollBars();
+ ScrollAllAggregates();
+
+ SetReadOnly( bRead );
+}
+//------------------------------------------------------------------------
+IMPL_LINK(OFieldDescControl, DelayedGrabFocus, Control**, ppControl)
+{
+ nDelayedGrabFocusEvent = 0;
+ if (*ppControl)
+ (*ppControl)->GrabFocus();
+
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OFieldDescControl, OnControlFocusGot, Control*, pControl )
+{
+ String strHelpText;
+ OPropNumericEditCtrl* pNumeric = dynamic_cast< OPropNumericEditCtrl* >( pControl );
+ if ( pNumeric )
+ {
+ pNumeric->SaveValue();
+ strHelpText = pNumeric->GetHelp();
+ }
+
+ OPropColumnEditCtrl* pColumn = dynamic_cast< OPropColumnEditCtrl* >( pControl );
+ if ( pColumn )
+ {
+ pColumn->SaveValue();
+ strHelpText = pColumn->GetHelp();
+ }
+
+ OPropEditCtrl* pEdit = dynamic_cast< OPropEditCtrl* >( pControl );
+ if ( pEdit )
+ {
+ pEdit->SaveValue();
+ strHelpText = pEdit->GetHelp();
+ }
+
+ OPropListBoxCtrl* pListBox = dynamic_cast< OPropListBoxCtrl* >( pControl );
+ if ( pListBox )
+ {
+ pListBox->SaveValue();
+ strHelpText = pListBox->GetHelp();
+ }
+
+ if (pControl == pFormat)
+ strHelpText =String(ModuleRes(STR_HELP_FORMAT_BUTTON));
+
+ if (strHelpText.Len() && (pHelp != NULL))
+ pHelp->SetHelpText(strHelpText);
+
+ m_pActFocusWindow = pControl;
+
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OFieldDescControl, OnControlFocusLost, Control*, pControl )
+{
+ if ((pControl == pLength) || (pControl == pTextLen) || (pControl == pScale))
+ {
+ OPropNumericEditCtrl* pConverted = (OPropNumericEditCtrl*)pControl;
+ if (pConverted->IsModified())
+ CellModified(-1, pConverted->GetPos());
+ }
+ if(pControl == m_pColumnName)
+ {
+ OPropColumnEditCtrl* pConverted = (OPropColumnEditCtrl*)pControl;
+ if (pConverted->IsModified())
+ CellModified(-1, pConverted->GetPos());
+ }
+ else if ((pControl == pDefault) || (pControl == pFormatSample) || (pControl == m_pAutoIncrementValue) )
+ {
+ OPropEditCtrl* pConverted = (OPropEditCtrl*)pControl;
+ if (pConverted->IsModified())
+ CellModified(-1, pConverted->GetPos());
+ }
+ else if ((pControl == pRequired) || (pControl == pNumType) || (pControl == pAutoIncrement) || (pControl == pBoolDefault) || (pControl == m_pType))
+ {
+ OPropListBoxCtrl* pConverted = (OPropListBoxCtrl*)pControl;
+ if (pConverted->IsModified())
+ CellModified(-1, pConverted->GetPos());
+ }
+
+ if (pControl == pDefault)
+ UpdateFormatSample(pActFieldDescr);
+
+ implFocusLost(pControl);
+
+ return 0L;
+}
+//------------------------------------------------------------------------------
+void OFieldDescControl::SaveData( OFieldDescription* pFieldDescr )
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ if( !pFieldDescr )
+ return;
+
+ //////////////////////////////////////////////////////////////////////
+ // Controls auslesen
+ ::rtl::OUString sDefault;
+ if (pDefault)
+ {
+ sDefault = pDefault->GetText();
+ }
+ else if (pBoolDefault)
+ {
+ sDefault = BoolStringPersistent(pBoolDefault->GetSelectEntry());
+ }
+
+ if ( sDefault.getLength() )
+ {
+ sal_uInt32 nFormatKey;
+ try
+ {
+ if ( isTextFormat(pFieldDescr,nFormatKey) || pBoolDefault )
+ {
+ pFieldDescr->SetControlDefault(makeAny(sDefault));
+ }
+ else
+ {
+ try
+ {
+ double nValue = GetFormatter()->convertStringToNumber(nFormatKey,sDefault);
+ nValue = checkDoubleForDateFormat(nValue,nFormatKey,GetFormatter());
+ pFieldDescr->SetControlDefault(makeAny(nValue));
+ }
+ catch(const Exception&)
+ {
+ if ( sDefault.getLength() )
+ pFieldDescr->SetControlDefault(makeAny(sDefault));
+ else
+ pFieldDescr->SetControlDefault(Any());
+ }
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+ } // if ( sDefault.getLength() )
+ else
+ pFieldDescr->SetControlDefault(Any());
+
+ if((pRequired && pRequired->GetSelectEntryPos() == 0) || pFieldDescr->IsPrimaryKey() || (pBoolDefault && pBoolDefault->GetEntryCount() == 2)) // yes
+ pFieldDescr->SetIsNullable( ColumnValue::NO_NULLS );
+ else
+ pFieldDescr->SetIsNullable( ColumnValue::NULLABLE );
+
+ if ( pAutoIncrement )
+ pFieldDescr->SetAutoIncrement( pAutoIncrement->GetSelectEntryPos() == 0 );
+
+ if( pTextLen )
+ pFieldDescr->SetPrecision( static_cast<sal_Int32>(pTextLen->GetValue()) );
+ else if( pLength )
+ pFieldDescr->SetPrecision( static_cast<sal_Int32>(pLength->GetValue()) );
+ if( pScale )
+ pFieldDescr->SetScale( static_cast<sal_Int32>(pScale->GetValue()) );
+
+ if(m_pColumnName)
+ pFieldDescr->SetName(m_pColumnName->GetText());
+
+ if ( m_pAutoIncrementValue && isAutoIncrementValueEnabled() )
+ pFieldDescr->SetAutoIncrementValue(m_pAutoIncrementValue->GetText());
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::UpdateFormatSample(OFieldDescription* pFieldDescr)
+{
+ if ( pFieldDescr && pFormatSample )
+ pFormatSample->SetText(getControlDefault(pFieldDescr,sal_False));
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::GetFocus()
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Setzt den Focus auf das zuletzt aktive Control
+ TabPage::GetFocus();
+ if( pLastFocusWindow )
+ {
+ pLastFocusWindow->GrabFocus();
+ pLastFocusWindow = NULL;
+ }
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::implFocusLost(Window* _pWhich)
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+ DBG_ASSERT(!_pWhich || IsChild(_pWhich), "OFieldDescControl::implFocusLost : invalid window !");
+
+ //////////////////////////////////////////////////////////////////////
+ // Das aktive Control merken
+ if (!pLastFocusWindow)
+ pLastFocusWindow = _pWhich;
+
+ //////////////////////////////////////////////////////////////////////
+ // HelpText zuruecksetzen
+ if (pHelp && !pHelp->HasChildPathFocus())
+ pHelp->SetHelpText( String() );
+}
+
+//------------------------------------------------------------------------------
+void OFieldDescControl::LoseFocus()
+{
+ DBG_CHKTHIS(OFieldDescControl,NULL);
+
+ implFocusLost(NULL);
+
+ TabPage::LoseFocus();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescControl::isCopyAllowed()
+{
+ sal_Bool bAllowed = (m_pActFocusWindow != NULL) &&
+ (m_pActFocusWindow == pDefault || m_pActFocusWindow == pFormatSample ||
+ m_pActFocusWindow == pTextLen || m_pActFocusWindow == pLength ||
+ m_pActFocusWindow == pScale || m_pActFocusWindow == m_pColumnName ||
+ m_pActFocusWindow == m_pAutoIncrementValue) &&
+ static_cast<Edit*>(m_pActFocusWindow)->GetSelected().Len() != 0;
+
+ return bAllowed;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescControl::isCutAllowed()
+{
+ sal_Bool bAllowed = (m_pActFocusWindow != NULL) &&
+ (m_pActFocusWindow == pDefault || m_pActFocusWindow == pFormatSample ||
+ m_pActFocusWindow == pTextLen || m_pActFocusWindow == pLength ||
+ m_pActFocusWindow == pScale || m_pActFocusWindow == m_pColumnName ||
+ m_pActFocusWindow == m_pAutoIncrementValue) &&
+ static_cast<Edit*>(m_pActFocusWindow)->GetSelected().Len() != 0;
+ return bAllowed;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescControl::isPasteAllowed()
+{
+ sal_Bool bAllowed = (m_pActFocusWindow != NULL) &&
+ (m_pActFocusWindow == pDefault || m_pActFocusWindow == pFormatSample ||
+ m_pActFocusWindow == pTextLen || m_pActFocusWindow == pLength ||
+ m_pActFocusWindow == pScale || m_pActFocusWindow == m_pColumnName ||
+ m_pActFocusWindow == m_pAutoIncrementValue);
+ if ( bAllowed )
+ {
+ TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
+ bAllowed = aTransferData.HasFormat(SOT_FORMAT_STRING);
+ }
+ return bAllowed;
+}
+// -----------------------------------------------------------------------------
+void OFieldDescControl::cut()
+{
+ if(isCutAllowed())
+ static_cast<Edit*>(m_pActFocusWindow)->Cut();
+}
+// -----------------------------------------------------------------------------
+void OFieldDescControl::copy()
+{
+ if(isCopyAllowed()) // this only checks if the focus window is valid
+ static_cast<Edit*>(m_pActFocusWindow)->Copy();
+}
+// -----------------------------------------------------------------------------
+void OFieldDescControl::paste()
+{
+ if(m_pActFocusWindow) // this only checks if the focus window is valid
+ static_cast<Edit*>(m_pActFocusWindow)->Paste();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFieldDescControl::isTextFormat(const OFieldDescription* _pFieldDescr,sal_uInt32& _nFormatKey) const
+{
+ _nFormatKey = _pFieldDescr->GetFormatKey();
+ sal_Bool bTextFormat = sal_True;
+
+ try
+ {
+ if (!_nFormatKey)
+ {
+ Reference< ::com::sun::star::util::XNumberFormatTypes> xNumberTypes(GetFormatter()->getNumberFormatsSupplier()->getNumberFormats(),UNO_QUERY);
+ OSL_ENSURE(xNumberTypes.is(),"XNumberFormatTypes is null!");
+
+ _nFormatKey = ::dbtools::getDefaultNumberFormat( _pFieldDescr->GetType(),
+ _pFieldDescr->GetScale(),
+ _pFieldDescr->IsCurrency(),
+ xNumberTypes,
+ GetLocale());
+ }
+ sal_Int32 nNumberFormat = ::comphelper::getNumberFormatType(GetFormatter(),_nFormatKey);
+ bTextFormat = (nNumberFormat == ::com::sun::star::util::NumberFormat::TEXT);
+ }
+ catch(const Exception&)
+ {
+
+ }
+
+ return bTextFormat;
+}
+// -----------------------------------------------------------------------------
+String OFieldDescControl::getControlDefault( const OFieldDescription* _pFieldDescr ,sal_Bool _bCheck) const
+{
+ ::rtl::OUString sDefault;
+ sal_Bool bCheck = !_bCheck || _pFieldDescr->GetControlDefault().hasValue();
+ if ( bCheck )
+ {
+ sal_uInt32 nFormatKey;
+ sal_Bool bTextFormat = sal_False;
+ double nValue = 0.0;
+
+ try
+ {
+ bTextFormat = isTextFormat(_pFieldDescr,nFormatKey);
+ if ( _pFieldDescr->GetControlDefault() >>= sDefault )
+ {
+ if ( !bTextFormat )
+ {
+ if ( sDefault.getLength() )
+ {
+ try
+ {
+ nValue = GetFormatter()->convertStringToNumber(nFormatKey,sDefault);
+ }
+ catch(const Exception&)
+ {
+ return ::rtl::OUString(); // return empty string for format example
+ }
+ }
+ }
+ }
+ else
+ _pFieldDescr->GetControlDefault() >>= nValue;
+
+
+ Reference< ::com::sun::star::util::XNumberFormatter> xNumberFormatter = GetFormatter();
+ Reference<XPropertySet> xFormSet = xNumberFormatter->getNumberFormatsSupplier()->getNumberFormats()->getByKey(nFormatKey);
+ OSL_ENSURE(xFormSet.is(),"XPropertySet is null!");
+ ::rtl::OUString sFormat;
+ xFormSet->getPropertyValue(::rtl::OUString::createFromAscii("FormatString")) >>= sFormat;
+
+ if ( !bTextFormat )
+ {
+ Locale aLocale;
+ ::comphelper::getNumberFormatProperty(xNumberFormatter,nFormatKey,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Locale"))) >>= aLocale;
+
+ sal_Int32 nNumberFormat = ::comphelper::getNumberFormatType(xNumberFormatter,nFormatKey);
+ if( (nNumberFormat & ::com::sun::star::util::NumberFormat::DATE) == ::com::sun::star::util::NumberFormat::DATE
+ || (nNumberFormat & ::com::sun::star::util::NumberFormat::DATETIME) == ::com::sun::star::util::NumberFormat::DATETIME )
+ {
+ nValue = DBTypeConversion::toNullDate(DBTypeConversion::getNULLDate(xNumberFormatter->getNumberFormatsSupplier()),nValue);
+ }
+
+
+
+ Reference< ::com::sun::star::util::XNumberFormatPreviewer> xPreViewer(xNumberFormatter,UNO_QUERY);
+ OSL_ENSURE(xPreViewer.is(),"XNumberFormatPreviewer is null!");
+ sDefault = xPreViewer->convertNumberToPreviewString(sFormat,nValue,aLocale,sal_True);
+ }
+ else if ( !_bCheck || (sDefault.getLength() != 0) )
+ sDefault = xNumberFormatter->formatString(nFormatKey,(sDefault.getLength() != 0 )? sDefault : sFormat);
+ }
+ catch(const Exception&)
+ {
+
+ }
+ }
+
+ return sDefault;
+}
+// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/control/RelationControl.cxx b/dbaccess/source/ui/control/RelationControl.cxx
new file mode 100644
index 000000000000..14bbe171c613
--- /dev/null
+++ b/dbaccess/source/ui/control/RelationControl.cxx
@@ -0,0 +1,751 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_RELATIONCONTROL_HXX
+#include "RelationControl.hxx"
+#endif
+#ifndef DBACCESS_SOURCE_UI_INC_RELATIONCONTROL_HRC
+#include "RelationControl.hrc"
+#endif
+
+#ifndef _SVTOOLS_EDITBROWSEBOX_HXX_
+#include <svtools/editbrowsebox.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef DBAUI_TABLECONNECTIONDATA_HXX
+#include "TableConnectionData.hxx"
+#endif
+#ifndef DBAUI_TABLECONNECTION_HXX
+#include "TableConnection.hxx"
+#endif
+#ifndef DBAUI_TABLEWINDOW_HXX
+#include "TableWindow.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef DBAUI_RELCONTROLIFACE_HXX
+#include "RelControliFace.hxx"
+#endif
+#ifndef _DBU_CONTROL_HRC_
+#include "dbu_control.hrc"
+#endif
+#ifndef _DBA_DBACCESS_HELPID_HRC_
+#include "dbaccess_helpid.hrc"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#include <algorithm>
+
+#define SOURCE_COLUMN 1
+#define DEST_COLUMN 2
+
+namespace dbaui
+{
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::container;
+ using namespace svt;
+
+ typedef ::svt::EditBrowseBox ORelationControl_Base;
+ class ORelationControl : public ORelationControl_Base
+ {
+ friend class OTableListBoxControl;
+
+ ::std::auto_ptr< ::svt::ListBoxControl> m_pListCell;
+ TTableConnectionData::value_type m_pConnData;
+ const OJoinTableView::OTableWindowMap* m_pTableMap;
+ OTableListBoxControl* m_pBoxControl;
+ long m_nDataPos;
+ Reference< XPropertySet> m_xSourceDef;
+ Reference< XPropertySet> m_xDestDef;
+
+
+ void fillListBox(const Reference< XPropertySet>& _xDest,long nRow,USHORT nColumnId);
+ /** returns the column id for the editbrowsebox
+ @param _nColId
+ the column id SOURCE_COLUMN or DEST_COLUMN
+
+ @return the current column id eihter SOURCE_COLUMN or DEST_COLUMN depends on the connection data
+ */
+ USHORT getColumnIdent( USHORT _nColId ) const;
+ public:
+ ORelationControl( OTableListBoxControl* pParent,const OJoinTableView::OTableWindowMap* _pTableMap );
+ virtual ~ORelationControl();
+
+ /** searches for a connection between these two tables
+ @param _pSource
+ the left table
+ @param _pDest
+ the right window
+ */
+ void setWindowTables(const OTableWindow* _pSource,const OTableWindow* _pDest);
+
+ /** allows to access the connection data from outside
+
+ @return rthe connection data
+ */
+ inline TTableConnectionData::value_type getData() const { return m_pConnData; }
+
+ void lateInit();
+
+ protected:
+ virtual void Resize();
+
+ virtual long PreNotify(NotifyEvent& rNEvt );
+
+ virtual BOOL IsTabAllowed(BOOL bForward) const;
+
+ virtual void Init(const TTableConnectionData::value_type& _pConnData);
+ virtual void Init() { ORelationControl_Base::Init(); }
+ virtual void InitController( ::svt::CellControllerRef& rController, long nRow, USHORT nCol );
+ virtual ::svt::CellController* GetController( long nRow, USHORT nCol );
+ virtual void PaintCell( OutputDevice& rDev, const Rectangle& rRect, USHORT nColId ) const;
+ virtual BOOL SeekRow( long nRow );
+ virtual BOOL SaveModified();
+ virtual String GetCellText( long nRow, USHORT nColId ) const;
+
+ virtual void CellModified();
+
+ DECL_LINK( AsynchDeactivate, void* );
+ private:
+
+ DECL_LINK( AsynchActivate, void* );
+
+ };
+
+ //========================================================================
+ // class ORelationControl
+ //========================================================================
+ DBG_NAME(ORelationControl)
+ //------------------------------------------------------------------------
+ ORelationControl::ORelationControl( OTableListBoxControl* pParent ,const OJoinTableView::OTableWindowMap* _pTableMap)
+ :EditBrowseBox( pParent, EBBF_SMART_TAB_TRAVEL | EBBF_NOROWPICTURE, WB_TABSTOP | /*WB_3DLOOK | */WB_BORDER | BROWSER_AUTOSIZE_LASTCOL)
+ ,m_pTableMap(_pTableMap)
+ ,m_pBoxControl(pParent)
+ ,m_xSourceDef( NULL )
+ ,m_xDestDef( NULL )
+ {
+ DBG_CTOR(ORelationControl,NULL);
+ }
+
+ //------------------------------------------------------------------------
+ ORelationControl::~ORelationControl()
+ {
+ DBG_DTOR(ORelationControl,NULL);
+ }
+
+ //------------------------------------------------------------------------
+ void ORelationControl::Init(const TTableConnectionData::value_type& _pConnData)
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+
+ m_pConnData = _pConnData;
+ OSL_ENSURE(m_pConnData, "No data supplied!");
+
+ m_pConnData->normalizeLines();
+ }
+ //------------------------------------------------------------------------------
+ void ORelationControl::lateInit()
+ {
+ if ( !m_pConnData.get() )
+ return;
+ m_xSourceDef = m_pConnData->getReferencingTable()->getTable();
+ m_xDestDef = m_pConnData->getReferencedTable()->getTable();
+
+ if ( ColCount() == 0 )
+ {
+ InsertDataColumn( SOURCE_COLUMN, m_pConnData->getReferencingTable()->GetWinName(), 100);
+ InsertDataColumn( DEST_COLUMN, m_pConnData->getReferencedTable()->GetWinName(), 100);
+ // wenn es die Defs noch nicht gibt, dann muessen sie noch mit SetSource-/-DestDef gesetzt werden !
+
+ m_pListCell.reset( new ListBoxControl( &GetDataWindow() ) );
+
+ //////////////////////////////////////////////////////////////////////
+ // set browse mode
+ SetMode( BROWSER_COLUMNSELECTION |
+ BROWSER_HLINESFULL |
+ BROWSER_VLINESFULL |
+ BROWSER_HIDECURSOR |
+ BROWSER_HIDESELECT |
+ BROWSER_AUTO_HSCROLL |
+ BROWSER_AUTO_VSCROLL);
+ }
+ else
+ // not the first call
+ RowRemoved(0, GetRowCount());
+
+ RowInserted(0, m_pConnData->GetConnLineDataList()->size() + 1, TRUE); // add one extra row
+ }
+ //------------------------------------------------------------------------------
+ void ORelationControl::Resize()
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ EditBrowseBox::Resize();
+ long nOutputWidth = GetOutputSizePixel().Width();
+ SetColumnWidth(1, (nOutputWidth / 2));
+ SetColumnWidth(2, (nOutputWidth / 2));
+ }
+
+ //------------------------------------------------------------------------------
+ long ORelationControl::PreNotify(NotifyEvent& rNEvt)
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ if (rNEvt.GetType() == EVENT_LOSEFOCUS && !HasChildPathFocus() )
+ PostUserEvent(LINK(this, ORelationControl, AsynchDeactivate));
+ else if (rNEvt.GetType() == EVENT_GETFOCUS)
+ PostUserEvent(LINK(this, ORelationControl, AsynchActivate));
+
+ return EditBrowseBox::PreNotify(rNEvt);
+ }
+
+ //------------------------------------------------------------------------------
+ IMPL_LINK(ORelationControl, AsynchActivate, void*, EMPTYARG)
+ {
+ ActivateCell();
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------------
+ IMPL_LINK(ORelationControl, AsynchDeactivate, void*, EMPTYARG)
+ {
+ DeactivateCell();
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------------
+ BOOL ORelationControl::IsTabAllowed(BOOL bForward) const
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ long nRow = GetCurRow();
+ USHORT nCol = GetCurColumnId();
+
+ BOOL bRet = !(( ( bForward && (nCol == DEST_COLUMN) && (nRow == GetRowCount() - 1)))
+ || (!bForward && (nCol == SOURCE_COLUMN) && (nRow == 0)));
+
+ return bRet && EditBrowseBox::IsTabAllowed(bForward);
+ }
+
+ //------------------------------------------------------------------------------
+ BOOL ORelationControl::SaveModified()
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ sal_Int32 nRow = GetCurRow();
+ if ( nRow != BROWSER_ENDOFSELECTION )
+ {
+ String sFieldName(m_pListCell->GetSelectEntry());
+ OConnectionLineDataVec* pLines = m_pConnData->GetConnLineDataList();
+ if ( pLines->size() <= static_cast<sal_uInt32>(nRow) )
+ {
+ pLines->push_back(new OConnectionLineData());
+ nRow = pLines->size() - 1;
+ }
+
+ OConnectionLineDataRef pConnLineData = (*pLines)[nRow];
+
+ switch( getColumnIdent( GetCurColumnId() ) )
+ {
+ case SOURCE_COLUMN:
+ pConnLineData->SetSourceFieldName( sFieldName );
+ break;
+ case DEST_COLUMN:
+ pConnLineData->SetDestFieldName( sFieldName );
+ break;
+ }
+ }
+
+ return TRUE;
+ }
+ //------------------------------------------------------------------------------
+ USHORT ORelationControl::getColumnIdent( USHORT _nColId ) const
+ {
+ USHORT nId = _nColId;
+ if ( m_pConnData->getReferencingTable() != m_pBoxControl->getReferencingTable() )
+ nId = ( _nColId == SOURCE_COLUMN) ? DEST_COLUMN : SOURCE_COLUMN;
+ return nId;
+ }
+
+ //------------------------------------------------------------------------------
+ String ORelationControl::GetCellText( long nRow, USHORT nColId ) const
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ String sText;
+ if ( m_pConnData->GetConnLineDataList()->size() > static_cast<size_t>(nRow) )
+ {
+ OConnectionLineDataRef pConnLineData = (*m_pConnData->GetConnLineDataList())[nRow];
+ switch( getColumnIdent( nColId ) )
+ {
+ case SOURCE_COLUMN:
+ sText = pConnLineData->GetSourceFieldName();
+ break;
+ case DEST_COLUMN:
+ sText = pConnLineData->GetDestFieldName();
+ break;
+ }
+ }
+ return sText;
+ }
+
+ //------------------------------------------------------------------------------
+ void ORelationControl::InitController( CellControllerRef& /*rController*/, long nRow, USHORT nColumnId )
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+
+ ULONG nHelpId = HID_RELATIONDIALOG_LEFTFIELDCELL;
+
+ Reference< XPropertySet> xDef;
+ switch ( getColumnIdent(nColumnId) )
+ {
+ case SOURCE_COLUMN:
+ xDef = m_xSourceDef;
+ nHelpId = HID_RELATIONDIALOG_LEFTFIELDCELL;
+ break;
+ case DEST_COLUMN:
+ xDef = m_xDestDef;
+ nHelpId = HID_RELATIONDIALOG_RIGHTFIELDCELL;
+ break;
+ default:
+ // ?????????
+ break;
+ }
+
+ if ( xDef.is() )
+ {
+ fillListBox(xDef,nRow,nColumnId);
+ String sName = GetCellText( nRow, nColumnId );
+ m_pListCell->SelectEntry( sName );
+ if ( m_pListCell->GetSelectEntry() != sName )
+ {
+ m_pListCell->InsertEntry( sName );
+ m_pListCell->SelectEntry( sName );
+ }
+
+ m_pListCell->SetHelpId(nHelpId);
+ }
+ }
+
+ //------------------------------------------------------------------------------
+ CellController* ORelationControl::GetController( long /*nRow*/, USHORT /*nColumnId*/ )
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ return new ListBoxCellController( m_pListCell.get() );
+ }
+
+ //------------------------------------------------------------------------------
+ BOOL ORelationControl::SeekRow( long nRow )
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ m_nDataPos = nRow;
+ return TRUE;
+ }
+
+ //------------------------------------------------------------------------------
+ void ORelationControl::PaintCell( OutputDevice& rDev, const Rectangle& rRect, USHORT nColumnId ) const
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ String aText =const_cast< ORelationControl*>(this)->GetCellText( m_nDataPos, nColumnId );
+
+ Point aPos( rRect.TopLeft() );
+ Size aTextSize( GetDataWindow().GetTextHeight(),GetDataWindow().GetTextWidth( aText ));
+
+ if( aPos.X() < rRect.Right() || aPos.X() + aTextSize.Width() > rRect.Right() ||
+ aPos.Y() < rRect.Top() || aPos.Y() + aTextSize.Height() > rRect.Bottom() )
+ rDev.SetClipRegion( rRect );
+
+ rDev.DrawText( aPos, aText );
+
+ if( rDev.IsClipRegion() )
+ rDev.SetClipRegion();
+ }
+ // -----------------------------------------------------------------------------
+ void ORelationControl::fillListBox(const Reference< XPropertySet>& _xDest,long /*_nRow*/,USHORT /*nColumnId*/)
+ {
+ m_pListCell->Clear();
+ try
+ {
+ if ( _xDest.is() )
+ {
+ //sal_Int32 nRows = GetRowCount();
+ Reference<XColumnsSupplier> xSup(_xDest,UNO_QUERY);
+ Reference<XNameAccess> xColumns = xSup->getColumns();
+ Sequence< ::rtl::OUString> aNames = xColumns->getElementNames();
+ const ::rtl::OUString* pIter = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + aNames.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ m_pListCell->InsertEntry( *pIter );
+ }
+ m_pListCell->InsertEntry(String(), 0);
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ // -----------------------------------------------------------------------------
+ void ORelationControl::setWindowTables(const OTableWindow* _pSource,const OTableWindow* _pDest)
+ {
+ // wenn ich hier gerade editiere, ausblenden
+ BOOL bWasEditing = IsEditing();
+ if ( bWasEditing )
+ DeactivateCell();
+
+ if ( _pSource && _pDest )
+ {
+ m_xSourceDef = _pSource->GetTable();
+ SetColumnTitle(1, _pSource->GetName());
+
+
+ m_xDestDef = _pDest->GetTable();
+ SetColumnTitle(2, _pDest->GetName());
+
+ const OJoinTableView* pView = _pSource->getTableView();
+ OTableConnection* pConn = pView->GetTabConn(_pSource,_pDest);
+ if ( pConn && !m_pConnData->GetConnLineDataList()->empty() )
+ {
+ m_pConnData->CopyFrom(*pConn->GetData());
+ m_pBoxControl->getContainer()->notifyConnectionChange();
+ }
+ else
+ {
+ // no connection found so we clear our data
+ OConnectionLineDataVec* pLines = m_pConnData->GetConnLineDataList();
+ ::std::for_each(pLines->begin(),
+ pLines->end(),
+ OUnaryRefFunctor<OConnectionLineData>( ::std::mem_fun(&OConnectionLineData::Reset))
+ );
+
+ m_pConnData->setReferencingTable(_pSource->GetData());
+ m_pConnData->setReferencedTable(_pDest->GetData());
+ }
+ m_pConnData->normalizeLines();
+
+ }
+ // neu zeichnen
+ Invalidate();
+
+ if ( bWasEditing )
+ {
+ GoToRow(0);
+ ActivateCell();
+ }
+ }
+ //------------------------------------------------------------------------
+ void ORelationControl::CellModified()
+ {
+ DBG_CHKTHIS(ORelationControl,NULL);
+ EditBrowseBox::CellModified();
+ SaveModified();
+ static_cast<OTableListBoxControl*>(GetParent())->NotifyCellChange();
+ }
+ //========================================================================
+ // class OTableListBoxControl
+DBG_NAME(OTableListBoxControl)
+
+//========================================================================
+
+OTableListBoxControl::OTableListBoxControl( Window* _pParent
+ ,const ResId& _rResId
+ ,const OJoinTableView::OTableWindowMap* _pTableMap
+ ,IRelationControlInterface* _pParentDialog)
+ : Window(_pParent,_rResId)
+ , m_aFL_InvolvedTables( this, ResId(FL_INVOLVED_TABLES,*_rResId.GetResMgr()))
+ , m_lmbLeftTable( this, ResId(LB_LEFT_TABLE,*_rResId.GetResMgr()))
+ , m_lmbRightTable( this, ResId(LB_RIGHT_TABLE,*_rResId.GetResMgr()))
+ , m_aFL_InvolvedFields( this, ResId(FL_INVOLVED_FIELDS,*_rResId.GetResMgr()))
+ , m_pTableMap(_pTableMap)
+ , m_pParentDialog(_pParentDialog)
+ {
+ m_pRC_Tables = new ORelationControl( this,m_pTableMap );
+ m_pRC_Tables->SetHelpId(HID_RELDLG_KEYFIELDS);
+ m_pRC_Tables->Init( );
+ m_pRC_Tables->SetZOrder(&m_lmbRightTable, WINDOW_ZORDER_BEHIND);
+
+ lateUIInit();
+
+ Link aLink(LINK(this, OTableListBoxControl, OnTableChanged));
+ m_lmbLeftTable.SetSelectHdl(aLink);
+ m_lmbRightTable.SetSelectHdl(aLink);
+
+ FreeResource();
+ DBG_CTOR(OTableListBoxControl,NULL);
+ }
+ // -----------------------------------------------------------------------------
+ OTableListBoxControl::~OTableListBoxControl()
+ {
+ ORelationControl* pTemp = m_pRC_Tables;
+ m_pRC_Tables = NULL;
+ delete pTemp;
+ DBG_DTOR(OTableListBoxControl,NULL);
+ }
+ // -----------------------------------------------------------------------------
+ void OTableListBoxControl::fillListBoxes()
+ {
+ DBG_ASSERT( !m_pTableMap->empty(), "OTableListBoxControl::fillListBoxes: no table window!");
+ OTableWindow* pInitialLeft = NULL;
+ OTableWindow* pInitialRight = NULL;
+
+ // die Namen aller TabWins einsammeln
+ OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->begin();
+ OJoinTableView::OTableWindowMap::const_iterator aEnd = m_pTableMap->end();
+ for(;aIter != aEnd;++aIter)
+ {
+ m_lmbLeftTable.InsertEntry(aIter->first);
+ m_lmbRightTable.InsertEntry(aIter->first);
+
+ if (!pInitialLeft)
+ {
+ pInitialLeft = aIter->second;
+ m_strCurrentLeft = aIter->first;
+ }
+ else if (!pInitialRight)
+ {
+ pInitialRight = aIter->second;
+ m_strCurrentRight = aIter->first;
+ }
+ } // for(;aIter != m_pTableMap->end();++aIter)
+
+ if ( !pInitialRight )
+ {
+ pInitialRight = pInitialLeft;
+ m_strCurrentRight = m_strCurrentLeft;
+ }
+
+ // die entsprechenden Defs an mein Controls
+ m_pRC_Tables->setWindowTables(pInitialLeft,pInitialRight);
+
+ // die in einer ComboBox ausgewaehlte Tabelle darf nicht in der anderen zur Verfuegung stehen
+
+ if ( m_pTableMap->size() > 2 )
+ {
+ m_lmbLeftTable.RemoveEntry(m_strCurrentRight);
+ m_lmbRightTable.RemoveEntry(m_strCurrentLeft);
+ }
+
+ // links das erste, rechts das zweite selektieren
+ m_lmbLeftTable.SelectEntry(m_strCurrentLeft);
+ m_lmbRightTable.SelectEntry(m_strCurrentRight);
+
+ m_lmbLeftTable.GrabFocus();
+ }
+ // -----------------------------------------------------------------------------
+ IMPL_LINK( OTableListBoxControl, OnTableChanged, ListBox*, pListBox )
+ {
+ String strSelected(pListBox->GetSelectEntry());
+ OTableWindow* pLeft = NULL;
+ OTableWindow* pRight = NULL;
+
+ // eine Sonderbehandlung : wenn es nur zwei Tabellen gibt, muss ich bei Wechsel in einer LB auch in der anderen umschalten
+ if ( m_pTableMap->size() == 2 )
+ {
+ ListBox* pOther;
+ if ( pListBox == &m_lmbLeftTable )
+ pOther = &m_lmbRightTable;
+ else
+ pOther = &m_lmbLeftTable;
+ pOther->SelectEntryPos(1 - pOther->GetSelectEntryPos());
+
+ OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->begin();
+ OTableWindow* pFirst = aIter->second;
+ ++aIter;
+ OTableWindow* pSecond = aIter->second;
+
+ if ( m_lmbLeftTable.GetSelectEntry() == String(pFirst->GetName()) )
+ {
+ pLeft = pFirst;
+ pRight = pSecond;
+ }
+ else
+ {
+ pLeft = pSecond;
+ pRight = pFirst;
+ }
+ }
+ else
+ {
+ // zuerst brauche ich die TableDef zur Tabelle, dazu das TabWin
+ OJoinTableView::OTableWindowMap::const_iterator aFind = m_pTableMap->find(strSelected);
+ OTableWindow* pLoop = NULL;
+ if( aFind != m_pTableMap->end() )
+ pLoop = aFind->second;
+ DBG_ASSERT(pLoop != NULL, "ORelationDialog::OnTableChanged : ungueltiger Eintrag in ListBox !");
+ // da ich die ListBoxen selber mit eben diesen Tabellennamen, mit denen ich sie jetzt vergleiche, gefuellt habe,
+ // MUSS ich strSelected finden
+ if (pListBox == &m_lmbLeftTable)
+ {
+ // den vorher links selektierten Eintrag wieder rein rechts
+ m_lmbRightTable.InsertEntry(m_strCurrentLeft);
+ // und den jetzt selektierten raus
+ m_lmbRightTable.RemoveEntry(strSelected);
+ m_strCurrentLeft = strSelected;
+
+ pLeft = pLoop;
+
+ OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->find(m_lmbRightTable.GetSelectEntry());
+ OSL_ENSURE( aIter != m_pTableMap->end(), "Invalid name");
+ if ( aIter != m_pTableMap->end() )
+ pRight = aIter->second;
+
+ m_lmbLeftTable.GrabFocus();
+ }
+ else
+ {
+ // den vorher rechts selektierten Eintrag wieder rein links
+ m_lmbLeftTable.InsertEntry(m_strCurrentRight);
+ // und den jetzt selektierten raus
+ m_lmbLeftTable.RemoveEntry(strSelected);
+ m_strCurrentRight = strSelected;
+
+ pRight = pLoop;
+ OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->find(m_lmbLeftTable.GetSelectEntry());
+ OSL_ENSURE( aIter != m_pTableMap->end(), "Invalid name");
+ if ( aIter != m_pTableMap->end() )
+ pLeft = aIter->second;
+ }
+ }
+
+ pListBox->GrabFocus();
+
+ m_pRC_Tables->setWindowTables(pLeft,pRight);
+
+ NotifyCellChange();
+ return 0;
+ }
+ // -----------------------------------------------------------------------------
+ void OTableListBoxControl::NotifyCellChange()
+ {
+ // den Ok-Button en- oder disablen, je nachdem, ob ich eine gueltige Situation habe
+ TTableConnectionData::value_type pConnData = m_pRC_Tables->getData();
+ const OConnectionLineDataVec* pLines = pConnData->GetConnLineDataList();
+ m_pParentDialog->setValid(!pLines->empty());
+
+ if ( pLines->size() >= static_cast<sal_uInt32>(m_pRC_Tables->GetRowCount()) )
+ {
+ m_pRC_Tables->DeactivateCell();
+ m_pRC_Tables->RowInserted(m_pRC_Tables->GetRowCount(), pLines->size() - static_cast<sal_uInt32>(m_pRC_Tables->GetRowCount()) + 1, TRUE);
+ m_pRC_Tables->ActivateCell();
+ }
+ }
+ // -----------------------------------------------------------------------------
+ void fillEntryAndDisable(ListBox& _rListBox,const String& _sEntry)
+ {
+ _rListBox.InsertEntry(_sEntry);
+ _rListBox.SelectEntryPos(0);
+ _rListBox.Disable();
+ }
+ // -----------------------------------------------------------------------------
+ void OTableListBoxControl::fillAndDisable(const TTableConnectionData::value_type& _pConnectionData)
+ {
+ fillEntryAndDisable(m_lmbLeftTable,_pConnectionData->getReferencingTable()->GetWinName());
+ fillEntryAndDisable(m_lmbRightTable,_pConnectionData->getReferencedTable()->GetWinName());
+ }
+ // -----------------------------------------------------------------------------
+ void OTableListBoxControl::Init(const TTableConnectionData::value_type& _pConnData)
+ {
+ m_pRC_Tables->Init(_pConnData);
+ }
+ // -----------------------------------------------------------------------------
+ void OTableListBoxControl::lateUIInit(Window* _pTableSeparator)
+ {
+ const sal_Int32 nDiff = LogicToPixel( Point(0,6), MAP_APPFONT ).Y();
+ Point aDlgPoint = LogicToPixel( Point(12,43), MAP_APPFONT );
+ if ( _pTableSeparator )
+ {
+ _pTableSeparator->SetZOrder(&m_lmbRightTable, WINDOW_ZORDER_BEHIND);
+ m_pRC_Tables->SetZOrder(_pTableSeparator, WINDOW_ZORDER_BEHIND);
+ //aDlgPoint = m_pTableSeparator->GetPosPixel() + Point(0,aSize.Height()) + LogicToPixel( Point(0,6), MAP_APPFONT );
+ _pTableSeparator->SetPosPixel(Point(0,m_aFL_InvolvedFields.GetPosPixel().Y()));
+ const Size aSize = _pTableSeparator->GetSizePixel();
+ aDlgPoint.Y() = _pTableSeparator->GetPosPixel().Y() + aSize.Height();
+ m_aFL_InvolvedFields.SetPosPixel(Point(m_aFL_InvolvedFields.GetPosPixel().X(),aDlgPoint.Y()));
+ aDlgPoint.Y() += nDiff + m_aFL_InvolvedFields.GetSizePixel().Height();
+ }
+ //////////////////////////////////////////////////////////////////////
+ // positing BrowseBox control
+ const Size aCurrentSize = GetSizePixel();
+ Size aDlgSize = LogicToPixel( Size(24,0), MAP_APPFONT );
+ aDlgSize.Width() = aCurrentSize.Width() - aDlgSize.Width();
+ aDlgSize.Height() = aCurrentSize.Height() - aDlgPoint.Y() - nDiff;
+
+ m_pRC_Tables->SetPosSizePixel( aDlgPoint, aDlgSize );
+ m_pRC_Tables->Show();
+
+ lateInit();
+ }
+ // -----------------------------------------------------------------------------
+ void OTableListBoxControl::lateInit()
+ {
+ m_pRC_Tables->lateInit();
+ }
+ // -----------------------------------------------------------------------------
+ BOOL OTableListBoxControl::SaveModified()
+ {
+ BOOL bRet = m_pRC_Tables->SaveModified();
+ m_pRC_Tables->getData()->normalizeLines();
+ return bRet;
+ }
+ // -----------------------------------------------------------------------------
+ TTableWindowData::value_type OTableListBoxControl::getReferencingTable() const
+ {
+ return m_pRC_Tables->getData()->getReferencingTable();
+ }
+ // -----------------------------------------------------------------------------
+ void OTableListBoxControl::enableRelation(bool _bEnable)
+ {
+ if ( !_bEnable )
+ PostUserEvent(LINK(m_pRC_Tables, ORelationControl, AsynchDeactivate));
+ m_pRC_Tables->Enable(_bEnable);
+
+ }
+ // -----------------------------------------------------------------------------
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/control/ScrollHelper.cxx b/dbaccess/source/ui/control/ScrollHelper.cxx
new file mode 100644
index 000000000000..c987610b12c8
--- /dev/null
+++ b/dbaccess/source/ui/control/ScrollHelper.cxx
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBAUI_SCROLLHELPER_HXX
+#include "ScrollHelper.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#define LISTBOX_SCROLLING_AREA 12
+namespace dbaui
+{
+DBG_NAME(OScrollHelper)
+
+// -----------------------------------------------------------------------------
+
+
+ OScrollHelper::OScrollHelper()
+ {
+ DBG_CTOR(OScrollHelper,NULL);
+ }
+ // -----------------------------------------------------------------------------
+ OScrollHelper::~OScrollHelper()
+ {
+
+ DBG_DTOR(OScrollHelper,NULL);
+ }
+ // -----------------------------------------------------------------------------
+ void OScrollHelper::scroll(const Point& _rPoint, const Size& _rOutputSize)
+ {
+ // Scrolling Areas
+ Rectangle aScrollArea( Point(0, _rOutputSize.Height() - LISTBOX_SCROLLING_AREA),
+ Size(_rOutputSize.Width(), LISTBOX_SCROLLING_AREA) );
+
+ Link aToCall;
+ // if pointer in bottom area begin scroll
+ if( aScrollArea.IsInside(_rPoint) )
+ aToCall = m_aUpScroll;
+ else
+ {
+ aScrollArea.SetPos(Point(0,0));
+ // if pointer in top area begin scroll
+ if( aScrollArea.IsInside(_rPoint) )
+ aToCall = m_aDownScroll;
+ }
+ if ( aToCall.IsSet() )
+ aToCall.Call( NULL );
+ }
+ // -----------------------------------------------------------------------------
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/dbaccess/source/ui/control/SqlNameEdit.cxx b/dbaccess/source/ui/control/SqlNameEdit.cxx
new file mode 100644
index 000000000000..71c732c569b6
--- /dev/null
+++ b/dbaccess/source/ui/control/SqlNameEdit.cxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_SQLNAMEEDIT_HXX
+#include "SqlNameEdit.hxx"
+#endif
+namespace dbaui
+{
+ //------------------------------------------------------------------
+ sal_Bool isCharOk(sal_Unicode _cChar,sal_Bool _bFirstChar,sal_Bool _bUpperCase,const ::rtl::OUString& _sAllowedChars)
+ {
+ return (
+ (_cChar >= 'A' && _cChar <= 'Z') ||
+ _cChar == '_' ||
+ _sAllowedChars.indexOf(_cChar) != -1 ||
+ (!_bFirstChar && (_cChar >= '0' && _cChar <= '9')) ||
+ (!_bUpperCase && (_cChar >= 'a' && _cChar <= 'z'))
+ );
+ }
+ //------------------------------------------------------------------
+ sal_Bool OSQLNameChecker::checkString( const ::rtl::OUString& _sOldValue,
+ const ::rtl::OUString& _sToCheck,
+ ::rtl::OUString& _rsCorrected)
+ {
+ sal_Bool bCorrected = sal_False;
+ if ( m_bCheck )
+ {
+ XubString sSavedValue = _sOldValue;
+ XubString sText = _sToCheck;
+ xub_StrLen nMatch = 0;
+ for ( xub_StrLen i=nMatch;i < sText.Len(); ++i )
+ {
+ if ( !isCharOk( sText.GetBuffer()[i], i == 0, m_bOnlyUpperCase, m_sAllowedChars ) )
+ {
+ _rsCorrected += sText.Copy( nMatch, i - nMatch );
+ bCorrected = sal_True;
+ nMatch = i + 1;
+ }
+ }
+ _rsCorrected += sText.Copy( nMatch, sText.Len() - nMatch );
+ }
+ return bCorrected;
+ }
+ //------------------------------------------------------------------
+ void OSQLNameEdit::Modify()
+ {
+ ::rtl::OUString sCorrected;
+ if ( checkString( GetSavedValue(),GetText(),sCorrected ) )
+ {
+ Selection aSel = GetSelection();
+ aSel.setMax( aSel.getMin() );
+ SetText( sCorrected, aSel );
+
+ SaveValue();
+ }
+ Edit::Modify();
+ }
+ //------------------------------------------------------------------
+ void OSQLNameComboBox::Modify()
+ {
+ ::rtl::OUString sCorrected;
+ if ( checkString( GetSavedValue(),GetText(),sCorrected ) )
+ {
+ Selection aSel = GetSelection();
+ aSel.setMax( aSel.getMin() );
+ SetText( sCorrected );
+
+ SaveValue();
+ }
+ ComboBox::Modify();
+ }
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/control/TableGrantCtrl.cxx b/dbaccess/source/ui/control/TableGrantCtrl.cxx
new file mode 100644
index 000000000000..679179f3f4ab
--- /dev/null
+++ b/dbaccess/source/ui/control/TableGrantCtrl.cxx
@@ -0,0 +1,516 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_TABLEGRANTCONTROL_HXX
+#include "TableGrantCtrl.hxx"
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGEOBJECT_HPP_
+#include <com/sun/star/sdbcx/PrivilegeObject.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XUSERSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XUsersSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XAUTHORIZABLE_HPP_
+#include <com/sun/star/sdbcx/XAuthorizable.hpp>
+#endif
+#ifndef _DBU_CONTROL_HRC_
+#include "dbu_control.hrc"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+using namespace ::dbaui;
+using namespace ::svt;
+
+const USHORT COL_TABLE_NAME = 1;
+const USHORT COL_SELECT = 2;
+const USHORT COL_INSERT = 3;
+const USHORT COL_DELETE = 4;
+const USHORT COL_UPDATE = 5;
+const USHORT COL_ALTER = 6;
+const USHORT COL_REF = 7;
+const USHORT COL_DROP = 8;
+
+DBG_NAME(OTableGrantControl)
+
+//================================================================================
+// OTableGrantControl
+//================================================================================
+OTableGrantControl::OTableGrantControl( Window* pParent,const ResId& _RsId)
+ :EditBrowseBox( pParent,_RsId, EBBF_SMART_TAB_TRAVEL | EBBF_NOROWPICTURE )
+ ,m_pCheckCell( NULL )
+ ,m_pEdit( NULL )
+ ,m_nDataPos( 0 )
+ ,m_bEnable(TRUE)
+ ,m_nDeactivateEvent(0)
+{
+ DBG_CTOR(OTableGrantControl,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Spalten einfuegen
+ USHORT i=1;
+ InsertDataColumn( i, String(ModuleRes(STR_TABLE_PRIV_NAME) ), 75);
+ FreezeColumn(i++);
+ InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_SELECT)), 75);
+ InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_INSERT)), 75);
+ InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_DELETE)), 75);
+ InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_UPDATE)), 75);
+ InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_ALTER)), 75);
+ InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_REFERENCE)), 75);
+ InsertDataColumn( i++, String(ModuleRes(STR_TABLE_PRIV_DROP)), 75);
+
+ while(--i)
+ SetColumnWidth(i,GetAutoColumnWidth(i));
+}
+
+//------------------------------------------------------------------------
+OTableGrantControl::~OTableGrantControl()
+{
+ DBG_DTOR(OTableGrantControl,NULL);
+ if (m_nDeactivateEvent)
+ {
+ Application::RemoveUserEvent(m_nDeactivateEvent);
+ m_nDeactivateEvent = 0;
+ }
+
+ delete m_pCheckCell;
+ delete m_pEdit;
+
+ m_xTables = NULL;
+}
+// -----------------------------------------------------------------------------
+void OTableGrantControl::setTablesSupplier(const Reference< XTablesSupplier >& _xTablesSup)
+{
+ // first we need the users
+ Reference< XUsersSupplier> xUserSup(_xTablesSup,UNO_QUERY);
+ if(xUserSup.is())
+ m_xUsers = xUserSup->getUsers();
+
+ // second we need the tables to determine which privileges the user has
+ if(_xTablesSup.is())
+ m_xTables = _xTablesSup->getTables();
+
+ if(m_xTables.is())
+ m_aTableNames = m_xTables->getElementNames();
+
+ OSL_ENSURE(m_xUsers.is(),"No user access supported!");
+ OSL_ENSURE(m_xTables.is(),"No tables supported!");
+}
+// -----------------------------------------------------------------------------
+void OTableGrantControl::setORB(const Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xORB)
+{
+ m_xORB = _xORB;
+}
+//------------------------------------------------------------------------
+void OTableGrantControl::UpdateTables()
+{
+ RemoveRows();
+
+ if(m_xTables.is())
+ RowInserted(0, m_aTableNames.getLength());
+ // m_bEnable = m_xDb->GetUser() != ((OUserAdmin*)GetParent())->GetUser();
+}
+//------------------------------------------------------------------------
+void OTableGrantControl::Init()
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ EditBrowseBox::Init();
+
+ //////////////////////////////////////////////////////////////////////
+ // ComboBox instanzieren
+ if(!m_pCheckCell)
+ {
+ m_pCheckCell = new CheckBoxControl( &GetDataWindow() );
+ m_pCheckCell->GetBox().EnableTriState(FALSE);
+
+ m_pEdit = new Edit( &GetDataWindow() );
+ m_pEdit->SetReadOnly();
+ m_pEdit->Enable(FALSE);
+ }
+
+ UpdateTables();
+ //////////////////////////////////////////////////////////////////////
+ // Browser Mode setzen
+ BrowserMode nMode = BROWSER_COLUMNSELECTION | BROWSER_HLINESFULL | BROWSER_VLINESFULL |
+ BROWSER_HIDECURSOR | BROWSER_HIDESELECT;
+
+ SetMode(nMode);
+}
+
+//------------------------------------------------------------------------------
+void OTableGrantControl::Resize()
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ EditBrowseBox::Resize();
+}
+
+//------------------------------------------------------------------------------
+long OTableGrantControl::PreNotify(NotifyEvent& rNEvt)
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ if (rNEvt.GetType() == EVENT_LOSEFOCUS)
+ if (!HasChildPathFocus())
+ {
+ if (m_nDeactivateEvent)
+ Application::RemoveUserEvent(m_nDeactivateEvent);
+ m_nDeactivateEvent = Application::PostUserEvent(LINK(this, OTableGrantControl, AsynchDeactivate));
+ }
+ if (rNEvt.GetType() == EVENT_GETFOCUS)
+ {
+ if (m_nDeactivateEvent)
+ Application::RemoveUserEvent(m_nDeactivateEvent);
+ m_nDeactivateEvent = Application::PostUserEvent(LINK(this, OTableGrantControl, AsynchActivate));
+ }
+ return EditBrowseBox::PreNotify(rNEvt);
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OTableGrantControl, AsynchActivate, void*, EMPTYARG)
+{
+ m_nDeactivateEvent = 0;
+ ActivateCell();
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OTableGrantControl, AsynchDeactivate, void*, EMPTYARG)
+{
+ m_nDeactivateEvent = 0;
+ DeactivateCell();
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+BOOL OTableGrantControl::IsTabAllowed(BOOL bForward) const
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ long nRow = GetCurRow();
+ USHORT nCol = GetCurColumnId();
+
+ if (bForward && (nCol == 2) && (nRow == GetRowCount() - 1))
+ return FALSE;
+
+ if (!bForward && (nCol == 1) && (nRow == 0))
+ return FALSE;
+
+ return EditBrowseBox::IsTabAllowed(bForward);
+}
+//------------------------------------------------------------------------------
+#define GRANT_REVOKE_RIGHT(what) \
+ if(m_pCheckCell->GetBox().IsChecked()) \
+ xAuth->grantPrivileges(sTableName,PrivilegeObject::TABLE,what);\
+ else \
+ xAuth->revokePrivileges(sTableName,PrivilegeObject::TABLE,what)
+
+//------------------------------------------------------------------------------
+BOOL OTableGrantControl::SaveModified()
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+
+ sal_Int32 nRow = GetCurRow();
+ if(nRow == -1 || nRow >= m_aTableNames.getLength())
+ return FALSE;
+
+ ::rtl::OUString sTableName = m_aTableNames[nRow];
+ BOOL bErg = TRUE;
+ try
+ {
+
+ if ( m_xUsers->hasByName(m_sUserName) )
+ {
+ Reference<XAuthorizable> xAuth(m_xUsers->getByName(m_sUserName),UNO_QUERY);
+ if ( xAuth.is() )
+ {
+ switch( GetCurColumnId() )
+ {
+ case COL_INSERT:
+ GRANT_REVOKE_RIGHT(Privilege::INSERT);
+ break;
+ case COL_DELETE:
+ GRANT_REVOKE_RIGHT(Privilege::DELETE);
+ break;
+ case COL_UPDATE:
+ GRANT_REVOKE_RIGHT(Privilege::UPDATE);
+ break;
+ case COL_ALTER:
+ GRANT_REVOKE_RIGHT(Privilege::ALTER);
+ break;
+ case COL_SELECT:
+ GRANT_REVOKE_RIGHT(Privilege::SELECT);
+ break;
+ case COL_REF:
+ GRANT_REVOKE_RIGHT(Privilege::REFERENCE);
+ break;
+ case COL_DROP:
+ GRANT_REVOKE_RIGHT(Privilege::DROP);
+ break;
+ }
+ fillPrivilege(nRow);
+ }
+ }
+ }
+ catch(SQLException& e)
+ {
+ bErg = FALSE;
+ ::dbaui::showError(::dbtools::SQLExceptionInfo(e),GetParent(),m_xORB);
+ }
+ if(bErg && Controller().Is())
+ Controller()->ClearModified();
+ if(!bErg)
+ UpdateTables();
+
+ return bErg;
+}
+
+//------------------------------------------------------------------------------
+String OTableGrantControl::GetCellText( long nRow, USHORT nColId ) const
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ if(COL_TABLE_NAME == nColId)
+ return m_aTableNames[nRow];
+
+ sal_Int32 nPriv = 0;
+ TTablePrivilegeMap::const_iterator aFind = findPrivilege(nRow);
+ if(aFind != m_aPrivMap.end())
+ nPriv = aFind->second.nRights;
+
+ return String::CreateFromInt32(isAllowed(nColId,nPriv) ? 1 :0);
+}
+
+//------------------------------------------------------------------------------
+void OTableGrantControl::InitController( CellControllerRef& /*rController*/, long nRow, USHORT nColumnId )
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ String sTablename = m_aTableNames[nRow];
+ // special case for tablename
+ if(nColumnId == COL_TABLE_NAME)
+ m_pEdit->SetText(sTablename);
+ else
+ {
+ // get the privileges from the user
+ TTablePrivilegeMap::const_iterator aFind = findPrivilege(nRow);
+ m_pCheckCell->GetBox().Check(aFind != m_aPrivMap.end() ? isAllowed(nColumnId,aFind->second.nRights) : FALSE);
+ }
+}
+// -----------------------------------------------------------------------------
+void OTableGrantControl::fillPrivilege(sal_Int32 _nRow) const
+{
+
+ if ( m_xUsers->hasByName(m_sUserName) )
+ {
+ try
+ {
+ Reference<XAuthorizable> xAuth(m_xUsers->getByName(m_sUserName),UNO_QUERY);
+ if ( xAuth.is() )
+ {
+ // get the privileges
+ TPrivileges nRights;
+ nRights.nRights = xAuth->getPrivileges(m_aTableNames[_nRow],PrivilegeObject::TABLE);
+ if(m_xGrantUser.is())
+ nRights.nWithGrant = m_xGrantUser->getGrantablePrivileges(m_aTableNames[_nRow],PrivilegeObject::TABLE);
+ else
+ nRights.nWithGrant = 0;
+
+ m_aPrivMap[m_aTableNames[_nRow]] = nRights;
+ }
+ }
+ catch(SQLException& e)
+ {
+ ::dbaui::showError(::dbtools::SQLExceptionInfo(e),GetParent(),m_xORB);
+ }
+ catch(Exception& )
+ {
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OTableGrantControl::isAllowed(USHORT _nColumnId,sal_Int32 _nPrivilege) const
+{
+ sal_Bool bAllowed = sal_False;
+ switch (_nColumnId)
+ {
+ case COL_INSERT:
+ bAllowed = (Privilege::INSERT & _nPrivilege) == Privilege::INSERT;
+ break;
+ case COL_DELETE:
+ bAllowed = (Privilege::DELETE & _nPrivilege) == Privilege::DELETE;
+ break;
+ case COL_UPDATE:
+ bAllowed = (Privilege::UPDATE & _nPrivilege) == Privilege::UPDATE;
+ break;
+ case COL_ALTER:
+ bAllowed = (Privilege::ALTER & _nPrivilege) == Privilege::ALTER;
+ break;
+ case COL_SELECT:
+ bAllowed = (Privilege::SELECT & _nPrivilege) == Privilege::SELECT;
+ break;
+ case COL_REF:
+ bAllowed = (Privilege::REFERENCE & _nPrivilege) == Privilege::REFERENCE;
+ break;
+ case COL_DROP:
+ bAllowed = (Privilege::DROP & _nPrivilege) == Privilege::DROP;
+ break;
+ }
+ return bAllowed;
+}
+// -----------------------------------------------------------------------------
+void OTableGrantControl::setUserName(const ::rtl::OUString _sUserName)
+{
+ m_sUserName = _sUserName;
+ m_aPrivMap = TTablePrivilegeMap();
+}
+// -----------------------------------------------------------------------------
+void OTableGrantControl::setGrantUser(const Reference< XAuthorizable>& _xGrantUser)
+{
+ OSL_ENSURE(_xGrantUser.is(),"OTableGrantControl::setGrantUser: GrantUser is null!");
+ m_xGrantUser = _xGrantUser;
+}
+//------------------------------------------------------------------------------
+CellController* OTableGrantControl::GetController( long nRow, USHORT nColumnId )
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+
+ CellController* pController = NULL;
+ switch( nColumnId )
+ {
+ case COL_TABLE_NAME:
+ break;
+ case COL_INSERT:
+ case COL_DELETE:
+ case COL_UPDATE:
+ case COL_ALTER:
+ case COL_SELECT:
+ case COL_REF:
+ case COL_DROP:
+ {
+ TTablePrivilegeMap::const_iterator aFind = findPrivilege(nRow);
+ if(aFind != m_aPrivMap.end() && isAllowed(nColumnId,aFind->second.nWithGrant))
+ pController = new CheckBoxCellController( m_pCheckCell );
+ }
+ break;
+ default:
+ ;
+ }
+ return pController;
+}
+//------------------------------------------------------------------------------
+BOOL OTableGrantControl::SeekRow( long nRow )
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ m_nDataPos = nRow;
+
+ return (nRow <= m_aTableNames.getLength());
+}
+
+//------------------------------------------------------------------------------
+void OTableGrantControl::PaintCell( OutputDevice& rDev, const Rectangle& rRect, USHORT nColumnId ) const
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+
+ if(nColumnId != COL_TABLE_NAME)
+ {
+ TTablePrivilegeMap::const_iterator aFind = findPrivilege(m_nDataPos);
+ if(aFind != m_aPrivMap.end())
+ PaintTristate(rDev, rRect, isAllowed(nColumnId,aFind->second.nRights) ? STATE_CHECK : STATE_NOCHECK,isAllowed(nColumnId,aFind->second.nWithGrant));
+ else
+ PaintTristate(rDev, rRect, STATE_NOCHECK,FALSE);
+ }
+ else
+ {
+ String aText(((OTableGrantControl*)this)->GetCellText( m_nDataPos, nColumnId ));
+ Point aPos( rRect.TopLeft() );
+ sal_Int32 nWidth = GetDataWindow().GetTextWidth( aText );
+ sal_Int32 nHeight = GetDataWindow().GetTextHeight();
+
+ if( aPos.X() < rRect.Right() || aPos.X() + nWidth > rRect.Right() ||
+ aPos.Y() < rRect.Top() || aPos.Y() + nHeight > rRect.Bottom() )
+ rDev.SetClipRegion( rRect );
+
+ rDev.DrawText( aPos, aText );
+ }
+
+ if( rDev.IsClipRegion() )
+ rDev.SetClipRegion();
+}
+
+//------------------------------------------------------------------------
+void OTableGrantControl::CellModified()
+{
+ DBG_CHKTHIS(OTableGrantControl,NULL);
+ EditBrowseBox::CellModified();
+ SaveModified();
+}
+// -----------------------------------------------------------------------------
+OTableGrantControl::TTablePrivilegeMap::const_iterator OTableGrantControl::findPrivilege(sal_Int32 _nRow) const
+{
+ TTablePrivilegeMap::const_iterator aFind = m_aPrivMap.find(m_aTableNames[_nRow]);
+ if(aFind == m_aPrivMap.end())
+ {
+ fillPrivilege(_nRow);
+ aFind = m_aPrivMap.find(m_aTableNames[_nRow]);
+ }
+ return aFind;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > OTableGrantControl::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos )
+{
+ USHORT nColumnId = GetColumnId( _nColumnPos );
+ if(nColumnId != COL_TABLE_NAME)
+ {
+ TriState eState = STATE_NOCHECK;
+ BOOL bEnable = FALSE;
+ TTablePrivilegeMap::const_iterator aFind = findPrivilege(_nRow);
+ if(aFind != m_aPrivMap.end())
+ {
+ eState = isAllowed(nColumnId,aFind->second.nRights) ? STATE_CHECK : STATE_NOCHECK;
+ bEnable = isAllowed(nColumnId,aFind->second.nWithGrant);
+ }
+ else
+ eState = STATE_NOCHECK;
+
+ return EditBrowseBox::CreateAccessibleCheckBoxCell( _nRow, _nColumnPos,eState,bEnable );
+ }
+ return EditBrowseBox::CreateAccessibleCell( _nRow, _nColumnPos );
+}
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/control/TableGrantCtrl.src b/dbaccess/source/ui/control/TableGrantCtrl.src
new file mode 100644
index 000000000000..8da72a1f9fe1
--- /dev/null
+++ b/dbaccess/source/ui/control/TableGrantCtrl.src
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBU_CONTROL_HRC_
+#include "dbu_control.hrc"
+#endif
+
+String STR_TABLE_PRIV_NAME
+{
+ Text [ en-US ] = "Table name";
+};
+
+String STR_TABLE_PRIV_INSERT
+{
+ Text [ en-US ] = "Insert data";
+};
+
+String STR_TABLE_PRIV_DELETE
+{
+ Text [ en-US ] = "Delete data";
+};
+
+String STR_TABLE_PRIV_UPDATE
+{
+ Text [ en-US ] = "Modify data";
+};
+
+String STR_TABLE_PRIV_ALTER
+{
+ Text [ en-US ] = "Alter structure";
+};
+String STR_TABLE_PRIV_SELECT
+{
+ Text [ en-US ] = "Read data";
+};
+
+String STR_TABLE_PRIV_REFERENCE
+{
+ Text [ en-US ] = "Modify references";
+};
+
+String STR_TABLE_PRIV_DROP
+{
+ Text [ en-US ] = "Drop structure";
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dbaccess/source/ui/control/VertSplitView.cxx b/dbaccess/source/ui/control/VertSplitView.cxx
new file mode 100644
index 000000000000..f72944848589
--- /dev/null
+++ b/dbaccess/source/ui/control/VertSplitView.cxx
@@ -0,0 +1,220 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBAUI_VERTSPLITVIEW_HXX
+#include "VertSplitView.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
+#define SPLITTER_WIDTH 80
+
+using namespace ::dbaui;
+
+//==================================================================
+// class OSplitterView
+//==================================================================
+DBG_NAME(OSplitterView)
+OSplitterView::OSplitterView(Window* _pParent,sal_Bool _bVertical) : Window(_pParent,WB_DIALOGCONTROL) // ,WB_BORDER
+ ,m_pSplitter( NULL )
+ ,m_pLeft(NULL)
+ ,m_pRight(NULL)
+ ,m_bVertical(_bVertical)
+{
+ DBG_CTOR(OSplitterView,NULL);
+ ImplInitSettings( sal_True, sal_True, sal_True );
+}
+// -----------------------------------------------------------------------------
+OSplitterView::~OSplitterView()
+{
+ DBG_DTOR(OSplitterView,NULL);
+ m_pRight = m_pLeft = NULL;
+}
+//------------------------------------------------------------------------------
+IMPL_LINK( OSplitterView, SplitHdl, Splitter*, /*pSplit*/ )
+{
+ OSL_ENSURE(m_pSplitter, "Splitter is NULL!");
+ if ( m_bVertical )
+ {
+ long nPosY = m_pSplitter->GetPosPixel().Y();
+ m_pSplitter->SetPosPixel( Point( m_pSplitter->GetSplitPosPixel(), nPosY ) );
+ }
+ else
+ m_pSplitter->SetPosPixel( Point( m_pSplitter->GetPosPixel().X(),m_pSplitter->GetSplitPosPixel() ) );
+
+ Resize();
+ return 0L;
+}
+// -----------------------------------------------------------------------------
+void OSplitterView::ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground )
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ if ( bFont )
+ {
+ Font aFont = rStyleSettings.GetAppFont();
+ if ( IsControlFont() )
+ aFont.Merge( GetControlFont() );
+ SetPointFont( aFont );
+// Set/*Zoomed*/PointFont( aFont );
+ }
+
+ if ( bFont || bForeground )
+ {
+ Color aTextColor = rStyleSettings.GetButtonTextColor();
+ if ( IsControlForeground() )
+ aTextColor = GetControlForeground();
+ SetTextColor( aTextColor );
+ }
+
+ if ( bBackground )
+ {
+ if( IsControlBackground() )
+ SetBackground( GetControlBackground() );
+ else
+ SetBackground( rStyleSettings.GetFaceColor() );
+ }
+}
+// -----------------------------------------------------------------------
+void OSplitterView::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ ImplInitSettings( sal_True, sal_True, sal_True );
+ Invalidate();
+ }
+}
+// -----------------------------------------------------------------------------
+void OSplitterView::GetFocus()
+{
+ Window::GetFocus();
+
+ // forward the focus to the current cell of the editor control
+ if ( m_pLeft )
+ m_pLeft->GrabFocus();
+ else if ( m_pRight )
+ m_pRight->GrabFocus();
+}
+
+// -------------------------------------------------------------------------
+void OSplitterView::Resize()
+{
+ Window::Resize();
+ OSL_ENSURE( m_pRight, "No init called!");
+
+ Point aSplitPos;
+ Size aSplitSize;
+ Point aPlaygroundPos( 0,0 );
+ Size aPlaygroundSize( GetOutputSizePixel() );
+
+ if ( m_pLeft && m_pLeft->IsVisible() && m_pSplitter )
+ {
+ aSplitPos = m_pSplitter->GetPosPixel();
+ aSplitSize = m_pSplitter->GetOutputSizePixel();
+ if ( m_bVertical )
+ {
+ // calculate the splitter pos and size
+ aSplitPos.Y() = aPlaygroundPos.Y();
+ aSplitSize.Height() = aPlaygroundSize.Height();
+
+ if( ( aSplitPos.X() + aSplitSize.Width() ) > ( aPlaygroundSize.Width() ))
+ aSplitPos.X() = aPlaygroundSize.Width() - aSplitSize.Width();
+
+ if( aSplitPos.X() <= aPlaygroundPos.X() )
+ aSplitPos.X() = aPlaygroundPos.X() + sal_Int32(aPlaygroundSize.Width() * 0.3);
+
+ // the tree pos and size
+ Point aTreeViewPos( aPlaygroundPos );
+ Size aTreeViewSize( aSplitPos.X(), aPlaygroundSize.Height() );
+
+ // set the size of treelistbox
+ m_pLeft->SetPosSizePixel( aTreeViewPos, aTreeViewSize );
+
+ //set the size of the splitter
+ m_pSplitter->SetPosSizePixel( aSplitPos, Size( aSplitSize.Width(), aPlaygroundSize.Height() ) );
+ m_pSplitter->SetDragRectPixel( Rectangle(aPlaygroundPos,aPlaygroundSize) );
+ }
+ else
+ {
+ aSplitPos.X() = aPlaygroundPos.X();
+ aSplitSize.Width() = aPlaygroundSize.Width();
+
+ if( ( aSplitPos.Y() + aSplitSize.Height() ) > ( aPlaygroundSize.Height() ))
+ aSplitPos.Y() = aPlaygroundSize.Height() - aSplitSize.Height();
+
+ if( aSplitPos.Y() <= aPlaygroundPos.Y() )
+ aSplitPos.Y() = aPlaygroundPos.Y() + sal_Int32(aPlaygroundSize.Height() * 0.3);
+
+ // the tree pos and size
+ Point aTreeViewPos( aPlaygroundPos );
+ Size aTreeViewSize( aPlaygroundSize.Width() ,aSplitPos.Y());
+
+ // set the size of treelistbox
+ m_pLeft->SetPosSizePixel( aTreeViewPos, aTreeViewSize );
+
+ //set the size of the splitter
+ m_pSplitter->SetPosSizePixel( aSplitPos, Size( aPlaygroundSize.Width(), aSplitSize.Height() ) );
+ m_pSplitter->SetDragRectPixel( Rectangle(aPlaygroundPos,aPlaygroundSize) );
+ }
+ }
+
+ if ( m_pRight )
+ {
+ if ( m_bVertical )
+ m_pRight->SetPosSizePixel( aSplitPos.X() + aSplitSize.Width(), aPlaygroundPos.Y(),
+ aPlaygroundSize.Width() - aSplitSize.Width() - aSplitPos.X(), aPlaygroundSize.Height());
+ else
+ m_pRight->SetPosSizePixel( aSplitPos.X(), aPlaygroundPos.Y() + aSplitPos.Y() + aSplitSize.Height(),
+ aPlaygroundSize.Width() , aPlaygroundSize.Height() - aSplitSize.Height() - aSplitPos.Y());
+ }
+
+}
+// -----------------------------------------------------------------------------
+void OSplitterView::set(Window* _pRight,Window* _pLeft)
+{
+ m_pLeft = _pLeft;
+ m_pRight = _pRight;
+}
+// -----------------------------------------------------------------------------
+void OSplitterView::setSplitter(Splitter* _pSplitter)
+{
+ m_pSplitter = _pSplitter;
+ if ( m_pSplitter )
+ {
+ m_pSplitter->SetSplitPosPixel( LogicToPixel( Size( SPLITTER_WIDTH, 0 ), MAP_APPFONT ).Width() );
+ m_pSplitter->SetSplitHdl( LINK(this, OSplitterView, SplitHdl) );
+ m_pSplitter->Show();
+ LINK( this, OSplitterView, SplitHdl ).Call(m_pSplitter);
+ }
+}
diff --git a/dbaccess/source/ui/control/charsetlistbox.cxx b/dbaccess/source/ui/control/charsetlistbox.cxx
new file mode 100644
index 000000000000..89ce1e82e9dd
--- /dev/null
+++ b/dbaccess/source/ui/control/charsetlistbox.cxx
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#include "charsetlistbox.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <svl/itemset.hxx>
+#include <svl/stritem.hxx>
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= CharSetListBox
+ //====================================================================
+ //--------------------------------------------------------------------
+ CharSetListBox::CharSetListBox( Window* _pParent, const ResId& _rResId )
+ :ListBox( _pParent, _rResId )
+ {
+ SetDropDownLineCount( 20 );
+
+ OCharsetDisplay::const_iterator charSet = m_aCharSets.begin();
+ while ( charSet != m_aCharSets.end() )
+ {
+ InsertEntry( (*charSet).getDisplayName() );
+ ++charSet;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ CharSetListBox::~CharSetListBox()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void CharSetListBox::SelectEntryByIanaName( const String& _rIanaName )
+ {
+ OCharsetDisplay::const_iterator aFind = m_aCharSets.findIanaName( _rIanaName );
+ if (aFind == m_aCharSets.end())
+ {
+ DBG_ERROR( "CharSetListBox::SelectEntryByIanaName: unknown charset falling back to system language!" );
+ aFind = m_aCharSets.findEncoding( RTL_TEXTENCODING_DONTKNOW );
+ }
+
+ if ( aFind == m_aCharSets.end() )
+ {
+ SelectEntry( String() );
+ }
+ else
+ {
+ String sDisplayName = (*aFind).getDisplayName();
+ if ( LISTBOX_ENTRY_NOTFOUND == GetEntryPos( sDisplayName ) )
+ {
+ // in our settings, there was an encoding selected which is not valid for the current
+ // data source type
+ // This is worth at least an assertion.
+ DBG_ERROR( "CharSetListBox::SelectEntryByIanaName: invalid character set!" );
+ sDisplayName = String();
+ }
+
+ SelectEntry( sDisplayName );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool CharSetListBox::StoreSelectedCharSet( SfxItemSet& _rSet, const USHORT _nItemId )
+ {
+ bool bChangedSomething = false;
+ if ( GetSelectEntryPos() != GetSavedValue() )
+ {
+ OCharsetDisplay::const_iterator aFind = m_aCharSets.findDisplayName( GetSelectEntry() );
+ DBG_ASSERT( aFind != m_aCharSets.end(), "CharSetListBox::StoreSelectedCharSet: could not translate the selected character set!" );
+ if ( aFind != m_aCharSets.end() )
+ {
+ _rSet.Put( SfxStringItem( _nItemId, (*aFind).getIanaName() ) );
+ bChangedSomething = true;
+ }
+ }
+ return bChangedSomething;
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
diff --git a/dbaccess/source/ui/control/curledit.cxx b/dbaccess/source/ui/control/curledit.cxx
new file mode 100644
index 000000000000..7ef087172807
--- /dev/null
+++ b/dbaccess/source/ui/control/curledit.cxx
@@ -0,0 +1,158 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBAUI_CURLEDIT_HXX_
+#include "curledit.hxx"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+ DBG_NAME(OConnectionURLEdit)
+//=========================================================================
+//= OConnectionURLEdit
+//=========================================================================
+OConnectionURLEdit::OConnectionURLEdit(Window* _pParent, const ResId& _rResId,BOOL _bShowPrefix)
+ :Edit(_pParent, _rResId)
+ ,m_pTypeCollection(NULL)
+ ,m_pForcedPrefix(NULL)
+ ,m_bShowPrefix(_bShowPrefix)
+{
+ DBG_CTOR(OConnectionURLEdit ,NULL);
+}
+
+//-------------------------------------------------------------------------
+OConnectionURLEdit::~OConnectionURLEdit()
+{
+ DBG_DTOR(OConnectionURLEdit ,NULL);
+ // delete my sub controls
+ Edit* pSubEdit = GetSubEdit();
+ SetSubEdit(NULL);
+ delete pSubEdit;
+ delete m_pForcedPrefix;
+}
+
+//-------------------------------------------------------------------------
+void OConnectionURLEdit::SetTextNoPrefix(const String& _rText)
+{
+ DBG_ASSERT(GetSubEdit(), "OConnectionURLEdit::SetTextNoPrefix: have no current type, not changing the text!");
+ if (GetSubEdit())
+ GetSubEdit()->SetText(_rText);
+}
+
+//-------------------------------------------------------------------------
+String OConnectionURLEdit::GetTextNoPrefix() const
+{
+ if (GetSubEdit())
+ return GetSubEdit()->GetText();
+ return GetText();
+}
+
+//-------------------------------------------------------------------------
+void OConnectionURLEdit::SetText(const String& _rStr)
+{
+ Selection aNoSelection(0,0);
+ SetText(_rStr, aNoSelection);
+}
+
+//-------------------------------------------------------------------------
+void OConnectionURLEdit::SetText(const String& _rStr, const Selection& /*_rNewSelection*/)
+{
+ // create new sub controls, if necessary
+ if (!GetSubEdit())
+ SetSubEdit(new Edit(this, 0));
+ if ( !m_pForcedPrefix )
+ {
+ m_pForcedPrefix = new FixedText(this, WB_VCENTER);
+
+ // we use a gray background for the fixed text
+ StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
+ m_pForcedPrefix->SetBackground(Wallpaper(aSystemStyle.GetDialogColor()));
+ }
+
+ m_pForcedPrefix->Show(m_bShowPrefix);
+
+ sal_Bool bIsEmpty = 0 == _rStr.Len();
+ // calc the prefix
+ String sPrefix;
+ if (!bIsEmpty)
+ {
+ // determine the type of the new URL described by the new text
+ sPrefix = m_pTypeCollection->getPrefix(_rStr);
+ }
+
+ // the fixed text gets the prefix
+ if ( m_pForcedPrefix )
+ m_pForcedPrefix->SetText(sPrefix);
+
+ // both subs have to be resized according to the text len of the prefix
+ Size aMySize = GetSizePixel();
+ sal_Int32 nTextWidth = 0;
+ if ( m_pForcedPrefix && m_bShowPrefix)
+ {
+ nTextWidth = m_pForcedPrefix->GetTextWidth(sPrefix) + 2;
+ m_pForcedPrefix->SetPosSizePixel(Point(0, -2), Size(nTextWidth, aMySize.Height()));
+ }
+ GetSubEdit()->SetPosSizePixel(Point(nTextWidth, -2), Size(aMySize.Width() - nTextWidth - 4, aMySize.Height()));
+ // -2 because the edit has a frame which is 2 pixel wide ... should not be necessary, but I don't fully understand this ....
+
+ // show the sub controls (in case they were just created)
+ GetSubEdit()->Show();
+
+ // do the real SetTex
+// Edit::SetText(bIsEmpty ? _rStr : m_pTypeCollection->cutPrefix(_rStr), _rNewSelection);
+ String sNewText( _rStr );
+ if ( !bIsEmpty )
+ sNewText = m_pTypeCollection->cutPrefix( _rStr );
+ Edit::SetText( sNewText );
+}
+
+//-------------------------------------------------------------------------
+String OConnectionURLEdit::GetText() const
+{
+ if ( m_pForcedPrefix )
+ return m_pForcedPrefix->GetText() += Edit::GetText();
+ return Edit::GetText();
+}
+// -----------------------------------------------------------------------------
+void OConnectionURLEdit::ShowPrefix(BOOL _bShowPrefix)
+{
+ m_bShowPrefix = _bShowPrefix;
+ if ( m_pForcedPrefix )
+ m_pForcedPrefix->Show(m_bShowPrefix);
+}
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
diff --git a/dbaccess/source/ui/control/dbtreelistbox.cxx b/dbaccess/source/ui/control/dbtreelistbox.cxx
new file mode 100644
index 000000000000..6664a96e3ec0
--- /dev/null
+++ b/dbaccess/source/ui/control/dbtreelistbox.cxx
@@ -0,0 +1,756 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBAUI_DBTREELISTBOX_HXX
+#include "dbtreelistbox.hxx"
+#endif
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+#ifndef DBACCESS_UI_BROWSER_ID_HXX
+#include "browserids.hxx"
+#endif
+#ifndef _DBAUI_LISTVIEWITEMS_HXX_
+#include "listviewitems.hxx"
+#endif
+#ifndef _DBACCESS_UI_CALLBACKS_HXX_
+#include "callbacks.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDRAGGESTURELISTENER_HDL_
+#include <com/sun/star/datatransfer/dnd/XDragGestureListener.hdl>
+#endif
+#ifndef _COM_SUN_STAR_DATATRANSFER_DND_XDRAGGESTURERECOGNIZER_HPP_
+#include <com/sun/star/datatransfer/dnd/XDragGestureRecognizer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_XCONTEXTMENUINTERCEPTOR_HPP_
+#include <com/sun/star/ui/XContextMenuInterceptor.hpp>
+#endif
+#include <com/sun/star/frame/XFrame.hpp>
+#ifndef _COM_SUN_STAR_UTIL_URL_HPP_
+#include <com/sun/star/util/URL.hpp>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE1_HXX_
+#include <cppuhelper/implbase1.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
+#include <cppuhelper/interfacecontainer.hxx>
+#endif
+#ifndef _SV_HELP_HXX
+#include <vcl/help.hxx>
+#endif
+#ifndef _DBAUI_TABLETREE_HRC_
+#include "tabletree.hrc"
+#endif
+#ifndef DBAUI_ICONTROLLER_HXX
+#include "IController.hxx"
+#endif
+#ifndef __FRAMEWORK_HELPER_ACTIONTRIGGERHELPER_HXX_
+#include <framework/actiontriggerhelper.hxx>
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+#include <framework/imageproducer.hxx>
+#include <vcl/svapp.hxx>
+#include <memory>
+
+// .........................................................................
+namespace dbaui
+{
+// .........................................................................
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::ui;
+using namespace ::com::sun::star::view;
+
+DBG_NAME(DBTreeListBox)
+#define SPACEBETWEENENTRIES 4
+//========================================================================
+// class DBTreeListBox
+//========================================================================
+//------------------------------------------------------------------------
+DBTreeListBox::DBTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, WinBits nWinStyle ,sal_Bool _bHandleEnterKey)
+ :SvTreeListBox(pParent,nWinStyle)
+ ,m_pDragedEntry(NULL)
+ ,m_pActionListener(NULL)
+ ,m_pContextMenuProvider( NULL )
+ ,m_bHandleEnterKey(_bHandleEnterKey)
+ ,m_xORB(_rxORB)
+{
+ DBG_CTOR(DBTreeListBox,NULL);
+ init();
+}
+// -----------------------------------------------------------------------------
+DBTreeListBox::DBTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, const ResId& rResId,sal_Bool _bHandleEnterKey)
+ :SvTreeListBox(pParent,rResId)
+ ,m_pDragedEntry(NULL)
+ ,m_pActionListener(NULL)
+ ,m_pContextMenuProvider( NULL )
+ ,m_bHandleEnterKey(_bHandleEnterKey)
+ ,m_xORB(_rxORB)
+{
+ DBG_CTOR(DBTreeListBox,NULL);
+ init();
+}
+// -----------------------------------------------------------------------------
+void DBTreeListBox::init()
+{
+ USHORT nSize = SPACEBETWEENENTRIES;
+ SetSpaceBetweenEntries(nSize);
+
+ m_aTimer.SetTimeout(900);
+ m_aTimer.SetTimeoutHdl(LINK(this, DBTreeListBox, OnTimeOut));
+
+ m_aScrollHelper.setUpScrollMethod( LINK(this, DBTreeListBox, ScrollUpHdl) );
+ m_aScrollHelper.setDownScrollMethod( LINK(this, DBTreeListBox, ScrollDownHdl) );
+
+ SetNodeDefaultImages( );
+
+ EnableContextMenuHandling();
+}
+//------------------------------------------------------------------------
+DBTreeListBox::~DBTreeListBox()
+{
+ DBG_DTOR(DBTreeListBox,NULL);
+ implStopSelectionTimer();
+}
+//------------------------------------------------------------------------
+SvLBoxEntry* DBTreeListBox::GetEntryPosByName( const String& aName, SvLBoxEntry* pStart, const IEntryFilter* _pFilter ) const
+{
+ SvLBoxTreeList* myModel = GetModel();
+ SvTreeEntryList* pChilds = myModel->GetChildList(pStart);
+ SvLBoxEntry* pEntry = NULL;
+ if ( pChilds )
+ {
+ ULONG nCount = pChilds->Count();
+ for (ULONG i=0; i < nCount; ++i)
+ {
+ pEntry = static_cast<SvLBoxEntry*>(pChilds->GetObject(i));
+ SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ if ( pItem->GetText().Equals(aName) )
+ {
+ if ( !_pFilter || _pFilter->includeEntry( pEntry ) )
+ // found
+ break;
+ }
+ pEntry = NULL;
+ }
+ }
+
+ return pEntry;
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::EnableExpandHandler(SvLBoxEntry* _pEntry)
+{
+ LINK(this, DBTreeListBox, OnResetEntry).Call(_pEntry);
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::RequestingChilds( SvLBoxEntry* pParent )
+{
+ if (m_aPreExpandHandler.IsSet())
+ {
+ if (!m_aPreExpandHandler.Call(pParent))
+ {
+ // an error occured. The method calling us will reset the entry flags, so it can't be expanded again.
+ // But we want that the user may do a second try (i.e. because he misstypes a password in this try), so
+ // we have to reset these flags controlling the expand ability
+ PostUserEvent(LINK(this, DBTreeListBox, OnResetEntry), pParent);
+ }
+ }
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::InitEntry( SvLBoxEntry* _pEntry, const XubString& aStr, const Image& _rCollEntryBmp, const Image& _rExpEntryBmp, SvLBoxButtonKind eButtonKind)
+{
+ SvTreeListBox::InitEntry( _pEntry, aStr, _rCollEntryBmp,_rExpEntryBmp, eButtonKind);
+ SvLBoxItem* pTextItem(_pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ SvLBoxString* pString = new OBoldListboxString( _pEntry, 0, aStr );
+ _pEntry->ReplaceItem( pString,_pEntry->GetPos(pTextItem));
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::implStopSelectionTimer()
+{
+ if ( m_aTimer.IsActive() )
+ m_aTimer.Stop();
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::implStartSelectionTimer()
+{
+ implStopSelectionTimer();
+ m_aTimer.Start();
+}
+
+// -----------------------------------------------------------------------------
+
+void DBTreeListBox::DeselectHdl()
+{
+ m_aSelectedEntries.erase( GetHdlEntry() );
+ SvTreeListBox::DeselectHdl();
+ implStartSelectionTimer();
+}
+// -------------------------------------------------------------------------
+void DBTreeListBox::SelectHdl()
+{
+ m_aSelectedEntries.insert( GetHdlEntry() );
+ SvTreeListBox::SelectHdl();
+ implStartSelectionTimer();
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ sal_Bool bHitEmptySpace = (NULL == GetEntry(rMEvt.GetPosPixel(), sal_True));
+ if (bHitEmptySpace && (rMEvt.GetClicks() == 2) && rMEvt.IsMod1())
+ Control::MouseButtonDown(rMEvt);
+ else
+ SvTreeListBox::MouseButtonDown(rMEvt);
+}
+
+// -------------------------------------------------------------------------
+IMPL_LINK(DBTreeListBox, OnResetEntry, SvLBoxEntry*, pEntry)
+{
+ // set the flag which allows if the entry can be expanded
+ pEntry->SetFlags( (pEntry->GetFlags() & ~(SV_ENTRYFLAG_NO_NODEBMP | SV_ENTRYFLAG_HAD_CHILDREN)) | SV_ENTRYFLAG_CHILDS_ON_DEMAND );
+ // redraw the entry
+ GetModel()->InvalidateEntry( pEntry );
+ return 0L;
+}
+// -----------------------------------------------------------------------------
+void DBTreeListBox::ModelHasEntryInvalidated( SvListEntry* _pEntry )
+{
+ SvTreeListBox::ModelHasEntryInvalidated( _pEntry );
+
+ if ( m_aSelectedEntries.find( _pEntry ) != m_aSelectedEntries.end() )
+ {
+ SvLBoxItem* pTextItem = static_cast< SvLBoxEntry* >( _pEntry )->GetFirstItem( SV_ITEM_ID_BOLDLBSTRING );
+ if ( pTextItem && !static_cast< OBoldListboxString* >( pTextItem )->isEmphasized() )
+ {
+ implStopSelectionTimer();
+ m_aSelectedEntries.erase( _pEntry );
+ // ehm - why?
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void DBTreeListBox::ModelHasRemoved( SvListEntry* _pEntry )
+{
+ SvTreeListBox::ModelHasRemoved(_pEntry);
+ if ( m_aSelectedEntries.find( _pEntry ) != m_aSelectedEntries.end() )
+ {
+ implStopSelectionTimer();
+ m_aSelectedEntries.erase( _pEntry );
+ }
+}
+
+// -------------------------------------------------------------------------
+sal_Int8 DBTreeListBox::AcceptDrop( const AcceptDropEvent& _rEvt )
+{
+ sal_Int8 nDropOption = DND_ACTION_NONE;
+ if ( m_pActionListener )
+ {
+ SvLBoxEntry* pDroppedEntry = GetEntry(_rEvt.maPosPixel);
+ // check if drag is on child entry, which is not allowed
+ SvLBoxEntry* pParent = NULL;
+ if ( _rEvt.mnAction & DND_ACTION_MOVE )
+ {
+ if ( !m_pDragedEntry ) // no entry to move
+ {
+ nDropOption = m_pActionListener->queryDrop( _rEvt, GetDataFlavorExVector() );
+ m_aMousePos = _rEvt.maPosPixel;
+ m_aScrollHelper.scroll(m_aMousePos,GetOutputSizePixel());
+ return nDropOption;
+ }
+
+ pParent = pDroppedEntry ? GetParent(pDroppedEntry) : NULL;
+ while ( pParent && pParent != m_pDragedEntry )
+ pParent = GetParent(pParent);
+ }
+
+ if ( !pParent )
+ {
+ nDropOption = m_pActionListener->queryDrop( _rEvt, GetDataFlavorExVector() );
+ // check if move is allowed
+ if ( nDropOption & DND_ACTION_MOVE )
+ {
+ if ( m_pDragedEntry == pDroppedEntry || GetEntryPosByName(GetEntryText(m_pDragedEntry),pDroppedEntry) )
+ nDropOption = nDropOption & ~DND_ACTION_MOVE;//DND_ACTION_NONE;
+ }
+ m_aMousePos = _rEvt.maPosPixel;
+ m_aScrollHelper.scroll(m_aMousePos,GetOutputSizePixel());
+ }
+ }
+
+ return nDropOption;
+}
+
+// -------------------------------------------------------------------------
+sal_Int8 DBTreeListBox::ExecuteDrop( const ExecuteDropEvent& _rEvt )
+{
+ if ( m_pActionListener )
+ return m_pActionListener->executeDrop( _rEvt );
+
+ return DND_ACTION_NONE;
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::StartDrag( sal_Int8 _nAction, const Point& _rPosPixel )
+{
+ if ( m_pActionListener )
+ {
+ m_pDragedEntry = GetEntry(_rPosPixel);
+ if ( m_pDragedEntry && m_pActionListener->requestDrag( _nAction, _rPosPixel ) )
+ {
+ // if the (asynchronous) drag started, stop the selection timer
+ implStopSelectionTimer();
+ // and stop selecting entries by simply moving the mouse
+ EndSelection();
+ }
+ }
+}
+
+// -------------------------------------------------------------------------
+void DBTreeListBox::RequestHelp( const HelpEvent& rHEvt )
+{
+ if ( !m_pActionListener )
+ {
+ SvTreeListBox::RequestHelp( rHEvt );
+ return;
+ }
+
+ if( rHEvt.GetMode() & HELPMODE_QUICK )
+ {
+ Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
+ SvLBoxEntry* pEntry = GetEntry( aPos );
+ if( pEntry )
+ {
+ String sQuickHelpText;
+ if ( m_pActionListener->requestQuickHelp( pEntry, sQuickHelpText ) )
+ {
+ Size aSize( GetOutputSizePixel().Width(), GetEntryHeight() );
+ Rectangle aScreenRect( OutputToScreenPixel( GetEntryPosition( pEntry ) ), aSize );
+
+ Help::ShowQuickHelp( this, aScreenRect,
+ sQuickHelpText, QUICKHELP_LEFT | QUICKHELP_VCENTER );
+ return;
+ }
+ }
+ }
+
+ SvTreeListBox::RequestHelp( rHEvt );
+}
+
+// -----------------------------------------------------------------------------
+void DBTreeListBox::KeyInput( const KeyEvent& rKEvt )
+{
+ KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction();
+ USHORT nCode = rKEvt.GetKeyCode().GetCode();
+ sal_Bool bHandled = sal_False;
+
+ if(eFunc != KEYFUNC_DONTKNOW)
+ {
+ switch(eFunc)
+ {
+ case KEYFUNC_CUT:
+ bHandled = ( m_aCutHandler.IsSet() && !m_aSelectedEntries.empty() );
+ if ( bHandled )
+ m_aCutHandler.Call( NULL );
+ break;
+ case KEYFUNC_COPY:
+ bHandled = ( m_aCopyHandler.IsSet() && !m_aSelectedEntries.empty() );
+ if ( bHandled )
+ m_aCopyHandler.Call( NULL );
+ break;
+ case KEYFUNC_PASTE:
+ bHandled = ( m_aPasteHandler.IsSet() && !m_aSelectedEntries.empty() );
+ if ( bHandled )
+ m_aPasteHandler.Call( NULL );
+ break;
+ case KEYFUNC_DELETE:
+ bHandled = ( m_aDeleteHandler.IsSet() && !m_aSelectedEntries.empty() );
+ if ( bHandled )
+ m_aDeleteHandler.Call( NULL );
+ break;
+ default:
+ break;
+ }
+ }
+
+ if ( KEY_RETURN == nCode )
+ {
+ bHandled = m_bHandleEnterKey;
+ if ( m_aEnterKeyHdl.IsSet() )
+ m_aEnterKeyHdl.Call(this);
+ // this is a HACK. If the data source browser is opened in the "beamer", while the main frame
+ // contains a writer document, then pressing enter in the DSB would be rerouted to the writer
+ // document if we would not do this hack here.
+ // The problem is that the Writer uses RETURN as _accelerator_ (which is quite weird itself),
+ // so the SFX framework is _obligated_ to pass it to the Writer if nobody else handled it. There
+ // is no chance to distinguish between
+ // "accelerators which are to be executed if the main document has the focus"
+ // and
+ // "accelerators which are always to be executed"
+ //
+ // Thus we cannot prevent the handling of this key in the writer without declaring the key event
+ // as "handled" herein.
+ //
+ // The bad thing about this approach is that it does not scale. Every other accelerator which
+ // is used by the document will raise a similar bug once somebody discovers it.
+ // If this is the case, we should discuss a real solution with the framework (SFX) and the
+ // applications.
+ //
+ // 2002-12-02 - 105831 - fs@openoffice.org
+ }
+
+ if ( !bHandled )
+ SvTreeListBox::KeyInput(rKEvt);
+}
+// -----------------------------------------------------------------------------
+BOOL DBTreeListBox::EditingEntry( SvLBoxEntry* pEntry, Selection& /*_aSelection*/)
+{
+ return m_aEditingHandler.Call(pEntry) != 0;
+}
+// -----------------------------------------------------------------------------
+BOOL DBTreeListBox::EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText )
+{
+ DBTreeEditedEntry aEntry;
+ aEntry.pEntry = pEntry;
+ aEntry.aNewText =rNewText;
+ if(m_aEditedHandler.Call(&aEntry) != 0)
+ {
+ implStopSelectionTimer();
+ m_aSelectedEntries.erase( pEntry );
+ }
+ SetEntryText(pEntry,aEntry.aNewText);
+
+ return FALSE; // we never want that the base change our text
+}
+
+// -----------------------------------------------------------------------------
+BOOL DBTreeListBox::DoubleClickHdl()
+{
+ long nResult = aDoubleClickHdl.Call( this );
+ // continue default processing if the DoubleClickHandler didn't handle it
+ return nResult == 0;
+}
+
+// -----------------------------------------------------------------------------
+void scrollWindow(DBTreeListBox* _pListBox, const Point& _rPos,sal_Bool _bUp)
+{
+ SvLBoxEntry* pEntry = _pListBox->GetEntry( _rPos );
+ if( pEntry && pEntry != _pListBox->Last() )
+ {
+ _pListBox->ScrollOutputArea( _bUp ? -1 : 1 );
+ }
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( DBTreeListBox, ScrollUpHdl, SvTreeListBox*, /*pBox*/ )
+{
+ scrollWindow(this,m_aMousePos,sal_True);
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( DBTreeListBox, ScrollDownHdl, SvTreeListBox*, /*pBox*/ )
+{
+ scrollWindow(this,m_aMousePos,sal_False);
+ return 0;
+}
+// -----------------------------------------------------------------------------
+namespace
+{
+ void lcl_enableEntries( PopupMenu* _pPopup, IController& _rController )
+ {
+ if ( !_pPopup )
+ return;
+
+ USHORT nCount = _pPopup->GetItemCount();
+ for (USHORT i=0; i < nCount; ++i)
+ {
+ if ( _pPopup->GetItemType(i) != MENUITEM_SEPARATOR )
+ {
+ USHORT nId = _pPopup->GetItemId(i);
+ PopupMenu* pSubPopUp = _pPopup->GetPopupMenu(nId);
+ if ( pSubPopUp )
+ {
+ lcl_enableEntries( pSubPopUp, _rController );
+ _pPopup->EnableItem(nId,pSubPopUp->HasValidEntries());
+ }
+ else
+ {
+ ::rtl::OUString sCommandURL( _pPopup->GetItemCommand( nId ) );
+ bool bEnabled = ( sCommandURL.getLength() )
+ ? _rController.isCommandEnabled( sCommandURL )
+ : _rController.isCommandEnabled( nId );
+ _pPopup->EnableItem( nId, bEnabled );
+ }
+ }
+ }
+
+ _pPopup->RemoveDisabledEntries();
+ }
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ void lcl_adjustMenuItemIDs( Menu& _rMenu, IController& _rCommandController )
+ {
+ USHORT nCount = _rMenu.GetItemCount();
+ for ( USHORT pos = 0; pos < nCount; ++pos )
+ {
+ // do not adjust separators
+ if ( _rMenu.GetItemType( pos ) == MENUITEM_SEPARATOR )
+ continue;
+
+ USHORT nId = _rMenu.GetItemId(pos);
+ String aCommand = _rMenu.GetItemCommand( nId );
+ PopupMenu* pPopup = _rMenu.GetPopupMenu( nId );
+ if ( pPopup )
+ {
+ lcl_adjustMenuItemIDs( *pPopup, _rCommandController );
+ continue;
+ } // if ( pPopup )
+
+ const USHORT nCommandId = _rCommandController.registerCommandURL( aCommand );
+ _rMenu.InsertItem( nCommandId, _rMenu.GetItemText( nId ), _rMenu.GetItemImage( nId ),
+ _rMenu.GetItemBits( nId ), pos );
+
+ // more things to preserve:
+ // - the help command
+ ::rtl::OUString sHelpURL = _rMenu.GetHelpCommand( nId );
+ if ( sHelpURL.getLength() )
+ _rMenu.SetHelpCommand( nCommandId, sHelpURL );
+
+ // remove the "old" item
+ _rMenu.RemoveItem( pos+1 );
+ }
+ }
+ void lcl_insertMenuItemImages( Menu& _rMenu, IController& _rCommandController )
+ {
+ const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
+ const BOOL bHiContrast = rSettings.GetHighContrastMode();
+ uno::Reference< frame::XController > xController = _rCommandController.getXController();
+ uno::Reference< frame::XFrame> xFrame;
+ if ( xController.is() )
+ xFrame = xController->getFrame();
+ USHORT nCount = _rMenu.GetItemCount();
+ for ( USHORT pos = 0; pos < nCount; ++pos )
+ {
+ // do not adjust separators
+ if ( _rMenu.GetItemType( pos ) == MENUITEM_SEPARATOR )
+ continue;
+
+ USHORT nId = _rMenu.GetItemId(pos);
+ String aCommand = _rMenu.GetItemCommand( nId );
+ PopupMenu* pPopup = _rMenu.GetPopupMenu( nId );
+ if ( pPopup )
+ {
+ lcl_insertMenuItemImages( *pPopup, _rCommandController );
+ continue;
+ } // if ( pPopup )
+
+ if ( xFrame.is() )
+ _rMenu.SetItemImage(nId,framework::GetImageFromURL(xFrame,aCommand,FALSE,bHiContrast));
+ }
+ }
+ // =========================================================================
+ // = SelectionSupplier
+ // =========================================================================
+ typedef ::cppu::WeakImplHelper1 < XSelectionSupplier
+ > SelectionSupplier_Base;
+ class SelectionSupplier : public SelectionSupplier_Base
+ {
+ public:
+ SelectionSupplier( const Any& _rSelection )
+ :m_aSelection( _rSelection )
+ {
+ }
+
+ virtual ::sal_Bool SAL_CALL select( const Any& xSelection ) throw (IllegalArgumentException, RuntimeException);
+ virtual Any SAL_CALL getSelection( ) throw (RuntimeException);
+ virtual void SAL_CALL addSelectionChangeListener( const Reference< XSelectionChangeListener >& xListener ) throw (RuntimeException);
+ virtual void SAL_CALL removeSelectionChangeListener( const Reference< XSelectionChangeListener >& xListener ) throw (RuntimeException);
+
+ protected:
+ virtual ~SelectionSupplier()
+ {
+ }
+
+ private:
+ Any m_aSelection;
+ };
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL SelectionSupplier::select( const Any& /*_Selection*/ ) throw (IllegalArgumentException, RuntimeException)
+ {
+ throw IllegalArgumentException();
+ // API bug: this should be a NoSupportException
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL SelectionSupplier::getSelection( ) throw (RuntimeException)
+ {
+ return m_aSelection;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SelectionSupplier::addSelectionChangeListener( const Reference< XSelectionChangeListener >& /*_Listener*/ ) throw (RuntimeException)
+ {
+ OSL_ENSURE( false, "SelectionSupplier::removeSelectionChangeListener: no support!" );
+ // API bug: this should be a NoSupportException
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SelectionSupplier::removeSelectionChangeListener( const Reference< XSelectionChangeListener >& /*_Listener*/ ) throw (RuntimeException)
+ {
+ OSL_ENSURE( false, "SelectionSupplier::removeSelectionChangeListener: no support!" );
+ // API bug: this should be a NoSupportException
+ }
+}
+
+// -----------------------------------------------------------------------------
+PopupMenu* DBTreeListBox::CreateContextMenu( void )
+{
+ ::std::auto_ptr< PopupMenu > pContextMenu;
+
+ if ( !m_pContextMenuProvider )
+ return pContextMenu.release();
+
+ // the basic context menu
+ pContextMenu.reset( m_pContextMenuProvider->getContextMenu( *this ) );
+ // disable what is not available currently
+ lcl_enableEntries( pContextMenu.get(), m_pContextMenuProvider->getCommandController() );
+ // set images
+ lcl_insertMenuItemImages( *pContextMenu, m_pContextMenuProvider->getCommandController() );
+ // allow context menu interception
+ ::cppu::OInterfaceContainerHelper* pInterceptors = m_pContextMenuProvider->getContextMenuInterceptors();
+ if ( !pInterceptors || !pInterceptors->getLength() )
+ return pContextMenu.release();
+
+ ContextMenuExecuteEvent aEvent;
+ aEvent.SourceWindow = VCLUnoHelper::GetInterface( this );
+ aEvent.ExecutePosition.X = -1;
+ aEvent.ExecutePosition.Y = -1;
+ aEvent.ActionTriggerContainer = ::framework::ActionTriggerHelper::CreateActionTriggerContainerFromMenu(
+ m_xORB, pContextMenu.get(), 0 );
+ aEvent.Selection = new SelectionSupplier( m_pContextMenuProvider->getCurrentSelection( *this ) );
+
+ ::cppu::OInterfaceIteratorHelper aIter( *pInterceptors );
+ bool bModifiedMenu = false;
+ bool bAskInterceptors = true;
+ while ( aIter.hasMoreElements() && bAskInterceptors )
+ {
+ Reference< XContextMenuInterceptor > xInterceptor( aIter.next(), UNO_QUERY );
+ if ( !xInterceptor.is() )
+ continue;
+
+ try
+ {
+ ContextMenuInterceptorAction eAction = xInterceptor->notifyContextMenuExecute( aEvent );
+ switch ( eAction )
+ {
+ case ContextMenuInterceptorAction_CANCELLED:
+ return NULL;
+
+ case ContextMenuInterceptorAction_EXECUTE_MODIFIED:
+ bModifiedMenu = true;
+ bAskInterceptors = false;
+ break;
+
+ case ContextMenuInterceptorAction_CONTINUE_MODIFIED:
+ bModifiedMenu = true;
+ bAskInterceptors = true;
+ break;
+
+ default:
+ DBG_ERROR( "DBTreeListBox::CreateContextMenu: unexpected return value of the interceptor call!" );
+
+ case ContextMenuInterceptorAction_IGNORED:
+ break;
+ }
+ }
+ catch( const DisposedException& e )
+ {
+ if ( e.Context == xInterceptor )
+ aIter.remove();
+ }
+ }
+
+ if ( bModifiedMenu )
+ {
+ // the interceptor(s) modified the menu description => create a new PopupMenu
+ PopupMenu* pModifiedMenu = new PopupMenu;
+ ::framework::ActionTriggerHelper::CreateMenuFromActionTriggerContainer(
+ pModifiedMenu, aEvent.ActionTriggerContainer );
+ aEvent.ActionTriggerContainer.clear();
+ pContextMenu.reset( pModifiedMenu );
+
+ // the interceptors only know command URLs, but our menus primarily work
+ // with IDs -> we need to translate the commands to IDs
+ lcl_adjustMenuItemIDs( *pModifiedMenu, m_pContextMenuProvider->getCommandController() );
+ } // if ( bModifiedMenu )
+
+ return pContextMenu.release();
+}
+
+// -----------------------------------------------------------------------------
+void DBTreeListBox::ExcecuteContextMenuAction( USHORT _nSelectedPopupEntry )
+{
+ if ( m_pContextMenuProvider && _nSelectedPopupEntry )
+ m_pContextMenuProvider->getCommandController().executeChecked( _nSelectedPopupEntry, Sequence< PropertyValue >() );
+}
+
+// -----------------------------------------------------------------------------
+IMPL_LINK(DBTreeListBox, OnTimeOut, void*, /*EMPTY_ARG*/)
+{
+ implStopSelectionTimer();
+
+ m_aSelChangeHdl.Call( NULL );
+ return 0L;
+}
+// -----------------------------------------------------------------------------
+void DBTreeListBox::StateChanged( StateChangedType nStateChange )
+{
+ if ( nStateChange == STATE_CHANGE_VISIBLE )
+ implStopSelectionTimer();
+}
+// .........................................................................
+} // namespace dbaui
+// .........................................................................
diff --git a/dbaccess/source/ui/control/listviewitems.cxx b/dbaccess/source/ui/control/listviewitems.cxx
new file mode 100644
index 000000000000..51cbd39cbb42
--- /dev/null
+++ b/dbaccess/source/ui/control/listviewitems.cxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBAUI_LISTVIEWITEMS_HXX_
+#include "listviewitems.hxx"
+#endif
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ //========================================================================
+ // class OBoldListboxString
+ //========================================================================
+ //------------------------------------------------------------------------
+ void OBoldListboxString::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* _pViewData)
+ {
+ SvLBoxString::InitViewData( pView, pEntry, _pViewData );
+ if ( !m_bEmphasized )
+ return;
+ if (!_pViewData)
+ _pViewData = pView->GetViewDataItem( pEntry, this );
+ pView->Push(PUSH_ALL);
+ Font aFont( pView->GetFont());
+ aFont.SetWeight(WEIGHT_BOLD);
+ pView->SetFont( aFont );
+ _pViewData->aSize = Size(pView->GetTextWidth(GetText()), pView->GetTextHeight());
+ pView->Pop();
+ }
+
+ //------------------------------------------------------------------------
+ USHORT OBoldListboxString::IsA()
+ {
+ return SV_ITEM_ID_BOLDLBSTRING;
+ }
+
+ //------------------------------------------------------------------------
+ void OBoldListboxString::Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, SvLBoxEntry* pEntry )
+ {
+ if (m_bEmphasized)
+ {
+ rDev.Push(PUSH_ALL);
+ Font aFont( rDev.GetFont());
+ aFont.SetWeight(WEIGHT_BOLD);
+ rDev.SetFont( aFont );
+ Point aPos(rPos);
+ rDev.DrawText( aPos, GetText() );
+ rDev.Pop();
+ }
+ else
+ SvLBoxString::Paint(rPos, rDev, nFlags, pEntry);
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
+
diff --git a/dbaccess/source/ui/control/makefile.mk b/dbaccess/source/ui/control/makefile.mk
new file mode 100644
index 000000000000..76857497cb6b
--- /dev/null
+++ b/dbaccess/source/ui/control/makefile.mk
@@ -0,0 +1,78 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# 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.
+#
+# 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).
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=dbaccess
+TARGET=uicontrols
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files -------------------------------------
+
+# ... resource files ............................
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ TableGrantCtrl.src \
+ undosqledit.src \
+ tabletree.src
+
+# ... exception files .........................
+
+EXCEPTIONSFILES=\
+ $(SLO)$/statusbarontroller.obj \
+ $(SLO)$/RelationControl.obj \
+ $(SLO)$/toolboxcontroller.obj \
+ $(SLO)$/tabletree.obj \
+ $(SLO)$/TableGrantCtrl.obj \
+ $(SLO)$/dbtreelistbox.obj \
+ $(SLO)$/sqledit.obj \
+ $(SLO)$/ColumnControlWindow.obj \
+ $(SLO)$/FieldDescControl.obj \
+ $(SLO)$/opendoccontrols.obj
+
+# ... object files ............................
+
+SLOFILES= \
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/ScrollHelper.obj \
+ $(SLO)$/VertSplitView.obj \
+ $(SLO)$/SqlNameEdit.obj \
+ $(SLO)$/listviewitems.obj \
+ $(SLO)$/undosqledit.obj \
+ $(SLO)$/marktree.obj \
+ $(SLO)$/curledit.obj \
+ $(SLO)$/charsetlistbox.obj
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/dbaccess/source/ui/control/marktree.cxx b/dbaccess/source/ui/control/marktree.cxx
new file mode 100644
index 000000000000..448803ca1e80
--- /dev/null
+++ b/dbaccess/source/ui/control/marktree.cxx
@@ -0,0 +1,247 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBAUI_MARKTREE_HXX_
+#include "marktree.hxx"
+#endif
+#ifndef _DBU_CONTROL_HRC_
+#include "dbu_control.hrc"
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+
+//.........................................................................
+namespace dbaui
+{
+ using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+//.........................................................................
+#define SPACEBETWEENENTRIES 4
+//========================================================================
+//= OMarkableTreeListBox
+//========================================================================
+DBG_NAME(OMarkableTreeListBox)
+//------------------------------------------------------------------------
+OMarkableTreeListBox::OMarkableTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, WinBits nWinStyle )
+ : DBTreeListBox(pParent,_rxORB,nWinStyle)
+{
+ DBG_CTOR(OMarkableTreeListBox,NULL);
+
+ InitButtonData();
+}
+//------------------------------------------------------------------------
+OMarkableTreeListBox::OMarkableTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, const ResId& rResId)
+ : DBTreeListBox(pParent,_rxORB,rResId)
+{
+ DBG_CTOR(OMarkableTreeListBox,NULL);
+
+ InitButtonData();
+}
+//------------------------------------------------------------------------
+OMarkableTreeListBox::~OMarkableTreeListBox()
+{
+ delete m_pCheckButton;
+
+ DBG_DTOR(OMarkableTreeListBox,NULL);
+}
+//------------------------------------------------------------------------
+void OMarkableTreeListBox::Paint(const Rectangle& _rRect)
+{
+ if (!IsEnabled())
+ {
+ Font aOldFont = GetFont();
+ Font aNewFont(aOldFont);
+
+ StyleSettings aSystemStyle = Application::GetSettings().GetStyleSettings();
+ aNewFont.SetColor(aSystemStyle.GetDisableColor());
+
+ SetFont(aNewFont);
+ DBTreeListBox::Paint(_rRect);
+ SetFont(aOldFont);
+ }
+ else
+ DBTreeListBox::Paint(_rRect);
+}
+//------------------------------------------------------------------------
+void OMarkableTreeListBox::InitButtonData()
+{
+ m_pCheckButton = new SvLBoxButtonData( this );
+ EnableCheckButton( m_pCheckButton );
+}
+//------------------------------------------------------------------------
+void OMarkableTreeListBox::KeyInput( const KeyEvent& rKEvt )
+{
+ // nur wenn space
+ if (rKEvt.GetKeyCode().GetCode() == KEY_SPACE && !rKEvt.GetKeyCode().IsShift() && !rKEvt.GetKeyCode().IsMod1())
+ {
+ SvLBoxEntry* pCurrentHandlerEntry = GetHdlEntry();
+ if(pCurrentHandlerEntry)
+ {
+ SvButtonState eState = GetCheckButtonState( pCurrentHandlerEntry);
+ if(eState == SV_BUTTON_CHECKED)
+ SetCheckButtonState( pCurrentHandlerEntry, SV_BUTTON_UNCHECKED);
+ else
+ SetCheckButtonState( pCurrentHandlerEntry, SV_BUTTON_CHECKED);
+
+ CheckButtonHdl();
+ }
+ else
+ DBTreeListBox::KeyInput(rKEvt);
+ }
+ else
+ DBTreeListBox::KeyInput(rKEvt);
+
+}
+//------------------------------------------------------------------------
+SvButtonState OMarkableTreeListBox::implDetermineState(SvLBoxEntry* _pEntry)
+{
+ SvButtonState eState = GetCheckButtonState(_pEntry);
+ if (!GetModel()->HasChilds(_pEntry))
+ // nothing to do in this bottom-up routine if there are no children ...
+ return eState;
+#ifdef DBG_UTIL
+ String sEntryText =GetEntryText(_pEntry);
+#endif
+
+ // loop through the children and check their states
+ sal_uInt16 nCheckedChildren = 0;
+ sal_uInt16 nChildrenOverall = 0;
+
+ SvLBoxEntry* pChildLoop = GetModel()->FirstChild(_pEntry);
+ while (pChildLoop)
+ {
+#ifdef DBG_UTIL
+ String sChildText =GetEntryText(pChildLoop);
+#endif
+ SvButtonState eChildState = implDetermineState(pChildLoop);
+ if (SV_BUTTON_TRISTATE == eChildState)
+ break;
+
+ if (SV_BUTTON_CHECKED == eChildState)
+ ++nCheckedChildren;
+ ++nChildrenOverall;
+
+ pChildLoop = GetModel()->NextSibling(pChildLoop);
+ }
+
+ if (pChildLoop)
+ {
+ // we did not finish the loop because at least one of the children is in tristate
+ eState = SV_BUTTON_TRISTATE;
+
+ // but this means that we did not finish all the siblings of pChildLoop, so their checking may be
+ // incorrect at the moment
+ // -> correct this
+ // 88485 - 20.06.2001 - frank.schoenheit@sun.com
+ while (pChildLoop)
+ {
+ implDetermineState(pChildLoop);
+ pChildLoop = GetModel()->NextSibling(pChildLoop);
+ }
+ }
+ else
+ // none if the children is in tristate
+ if (nCheckedChildren)
+ // we have at least one chil checked
+ if (nCheckedChildren != nChildrenOverall)
+ // not all children are checked
+ eState = SV_BUTTON_TRISTATE;
+ else
+ // all children are checked
+ eState = SV_BUTTON_CHECKED;
+ else
+ // no children are checked
+ eState = SV_BUTTON_UNCHECKED;
+
+ // finally set the entry to the state we just determined
+ SetCheckButtonState(_pEntry, eState);
+
+ // outta here
+ return eState;
+}
+
+//------------------------------------------------------------------------
+void OMarkableTreeListBox::CheckButtons()
+{
+ SvLBoxEntry* pEntry = GetModel()->First();
+ while (pEntry)
+ {
+ implDetermineState(pEntry);
+ pEntry = GetModel()->NextSibling(pEntry);
+ }
+}
+//------------------------------------------------------------------------
+void OMarkableTreeListBox::CheckButtonHdl()
+{
+ checkedButton_noBroadcast(GetHdlEntry());
+ if (m_aCheckButtonHandler.IsSet())
+ m_aCheckButtonHandler.Call(this);
+}
+
+//------------------------------------------------------------------------
+void OMarkableTreeListBox::checkedButton_noBroadcast(SvLBoxEntry* _pEntry)
+{
+ SvButtonState eState = GetCheckButtonState( _pEntry);
+ if (GetModel()->HasChilds(_pEntry)) // Falls Kinder, dann diese auch checken
+ {
+ SvLBoxEntry* pChildEntry = GetModel()->Next(_pEntry);
+ SvLBoxEntry* pSiblingEntry = GetModel()->NextSibling(_pEntry);
+ while(pChildEntry && pChildEntry != pSiblingEntry)
+ {
+ SetCheckButtonState(pChildEntry, eState);
+ pChildEntry = GetModel()->Next(pChildEntry);
+ }
+ }
+
+ SvLBoxEntry* pEntry = IsSelected(_pEntry) ? FirstSelected() : NULL;
+ while(pEntry)
+ {
+ SetCheckButtonState(pEntry,eState);
+ if(GetModel()->HasChilds(pEntry)) // Falls Kinder, dann diese auch checken
+ {
+ SvLBoxEntry* pChildEntry = GetModel()->Next(pEntry);
+ SvLBoxEntry* pSiblingEntry = GetModel()->NextSibling(pEntry);
+ while(pChildEntry && pChildEntry != pSiblingEntry)
+ {
+ SetCheckButtonState(pChildEntry,eState);
+ pChildEntry = GetModel()->Next(pChildEntry);
+ }
+ }
+ pEntry = NextSelected(pEntry);
+ }
+ CheckButtons();
+}
+
+//------------------------------------------------------------------------
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
diff --git a/dbaccess/source/ui/control/opendoccontrols.cxx b/dbaccess/source/ui/control/opendoccontrols.cxx
new file mode 100644
index 000000000000..a97130c74dff
--- /dev/null
+++ b/dbaccess/source/ui/control/opendoccontrols.cxx
@@ -0,0 +1,363 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBACCESS_SOURCE_UI_INC_OPENDOCCONTROLS_HXX
+#include "opendoccontrols.hxx"
+#endif
+
+/** === begin UNO includes === **/
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
+#include <com/sun/star/beans/PropertyValue.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#endif
+#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
+#include <com/sun/star/container/XNameAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_XMODULEUICONFIGURATIONMANAGERSUPPLIER_HPP_
+#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_XUICONFIGURATIONMANAGER_HPP_
+#include <com/sun/star/ui/XUIConfigurationManager.hpp>
+#endif
+#ifndef _COM_SUN_STAR_GRAPHIC_XGRAPHIC_HPP_
+#include <com/sun/star/graphic/XGraphic.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_XIMAGEMANAGER_HPP_
+#include <com/sun/star/ui/XImageManager.hpp>
+#endif
+/** === end UNO includes === **/
+
+#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
+#include <comphelper/processfactory.hxx>
+#endif
+#ifndef _SV_GRAPH_HXX
+#include <vcl/graph.hxx>
+#endif
+#ifndef _SV_HELP_HXX
+#include <vcl/help.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_HISTORYOPTIONS_HXX
+#include <unotools/historyoptions.hxx>
+#endif
+#ifndef _COMPHELPER_SEQUENCEASHASHMAP_HXX_
+#include <comphelper/sequenceashashmap.hxx>
+#endif
+#ifndef _URLOBJ_HXX
+#include <tools/urlobj.hxx>
+#endif
+#ifndef SVTOOLS_FILENOTATION_HXX
+#include <svl/filenotation.hxx>
+#endif
+
+//........................................................................
+namespace dbaui
+{
+//........................................................................
+
+ namespace
+ {
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::ui::XModuleUIConfigurationManagerSupplier;
+ using ::com::sun::star::ui::XUIConfigurationManager;
+ using ::com::sun::star::ui::XImageManager;
+ using ::com::sun::star::graphic::XGraphic;
+
+ String GetCommandText( const sal_Char* _pCommandURL, const ::rtl::OUString& _rModuleName )
+ {
+ ::rtl::OUString sLabel;
+ if ( !_pCommandURL || !*_pCommandURL )
+ return sLabel;
+
+ Reference< XNameAccess > xUICommandLabels;
+ ::rtl::OUString sCommandURL = ::rtl::OUString::createFromAscii( _pCommandURL );
+
+ try
+ {
+ do
+ {
+ // Retrieve popup menu labels
+ Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
+ if ( !xFactory.is() )
+ break;
+
+ Reference< XNameAccess> xNameAccess;
+ xNameAccess = xNameAccess.query( xFactory->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.UICommandDescription" ) )
+ ) );
+ if ( !xNameAccess.is() )
+ break;
+
+ xNameAccess->getByName( _rModuleName ) >>= xUICommandLabels;
+ if ( !xUICommandLabels.is() )
+ break;
+
+ Sequence< PropertyValue > aProperties;
+ if ( !( xUICommandLabels->getByName(sCommandURL) >>= aProperties ) )
+ break;
+
+ sal_Int32 nCount( aProperties.getLength() );
+ for ( sal_Int32 i=0; i<nCount; ++i )
+ {
+ ::rtl::OUString sPropertyName( aProperties[i].Name );
+ if ( sPropertyName.equalsAscii("Label" ) )
+ {
+ aProperties[i].Value >>= sLabel;
+ break;
+ }
+ }
+ }
+ while ( false );
+ }
+ catch( Exception& rException )
+ {
+ (void)rException;
+ }
+
+ return sLabel;
+ }
+
+ Image GetCommandIcon( const sal_Char* _pCommandURL, const ::rtl::OUString& _rModuleName )
+ {
+ Image aIcon;
+ if ( !_pCommandURL || !*_pCommandURL )
+ return aIcon;
+
+ Reference< XNameAccess > xUICommandLabels;
+ ::rtl::OUString sCommandURL = ::rtl::OUString::createFromAscii( _pCommandURL );
+ try
+ {
+ do
+ {
+ // Retrieve popup menu labels
+ Reference< XMultiServiceFactory> xFactory( ::comphelper::getProcessServiceFactory() );
+ if ( !xFactory.is() )
+ break;
+
+ Reference< XModuleUIConfigurationManagerSupplier > xSupplier(
+ xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ) ) ),
+ UNO_QUERY_THROW );
+
+ Reference< XUIConfigurationManager > xManager( xSupplier->getUIConfigurationManager( _rModuleName ) );
+ Reference< XImageManager > xImageManager;
+ if ( xManager.is() )
+ xImageManager = xImageManager.query( xManager->getImageManager() );
+ if ( !xImageManager.is() )
+ break;
+
+ Sequence< ::rtl::OUString > aCommandList( &sCommandURL, 1 );
+ Sequence<Reference< XGraphic> > xIconList( xImageManager->getImages( 0, aCommandList ) );
+ if ( !xIconList.hasElements() )
+ break;
+
+ aIcon = Graphic( xIconList[0] ).GetBitmapEx();
+ }
+ while ( false );
+ }
+ catch ( Exception& rException )
+ {
+ (void)rException;
+ }
+
+ return aIcon;
+ }
+
+
+ }
+
+ //====================================================================
+ //= OpenButton
+ //====================================================================
+ //--------------------------------------------------------------------
+ OpenDocumentButton::OpenDocumentButton( Window* _pParent, const sal_Char* _pAsciiModuleName, const ResId& _rResId )
+ :PushButton( _pParent, _rResId )
+ {
+ impl_init( _pAsciiModuleName );
+ }
+
+ //--------------------------------------------------------------------
+ void OpenDocumentButton::impl_init( const sal_Char* _pAsciiModuleName )
+ {
+ DBG_ASSERT( _pAsciiModuleName, "OpenDocumentButton::impl_init: invalid module name!" );
+ m_sModule = ::rtl::OUString::createFromAscii( _pAsciiModuleName );
+
+ // our label should equal the UI text of the "Open" command
+ String sLabel( GetCommandText( ".uno:Open", m_sModule ) );
+ sLabel.SearchAndReplaceAllAscii( "~", String() );
+ sLabel.Insert( (sal_Unicode)' ', 0 );
+ SetText( sLabel );
+
+ // Place icon left of text and both centered in the button.
+ SetModeImage( GetCommandIcon( ".uno:Open", m_sModule ), BMP_COLOR_NORMAL );
+ EnableImageDisplay( TRUE );
+ EnableTextDisplay( TRUE );
+ SetImageAlign( IMAGEALIGN_LEFT );
+ SetStyle( GetStyle() | WB_CENTER );
+ }
+
+ //====================================================================
+ //= OpenDocumentListBox
+ //====================================================================
+ //--------------------------------------------------------------------
+ OpenDocumentListBox::OpenDocumentListBox( Window* _pParent, const sal_Char* _pAsciiModuleName, const ResId& _rResId )
+ :ListBox( _pParent, _rResId )
+ {
+ impl_init( _pAsciiModuleName );
+ }
+
+ //--------------------------------------------------------------------
+ void OpenDocumentListBox::impl_init( const sal_Char* _pAsciiModuleName )
+ {
+ DBG_ASSERT( _pAsciiModuleName, "OpenDocumentListBox::impl_init: invalid module name!" );
+
+ Sequence< Sequence< PropertyValue> > aHistory = SvtHistoryOptions().GetList( ePICKLIST );
+ Reference< XNameAccess > xFilterFactory;
+ xFilterFactory = xFilterFactory.query( ::comphelper::getProcessServiceFactory()->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.FilterFactory" ) ) ) );
+
+ sal_uInt32 nCount = aHistory.getLength();
+ for ( sal_uInt32 nItem = 0; nItem < nCount; ++nItem )
+ {
+ try
+ {
+ // Get the current history item's properties.
+ ::comphelper::SequenceAsHashMap aItemProperties( aHistory[ nItem ] );
+ ::rtl::OUString sURL = aItemProperties.getUnpackedValueOrDefault( HISTORY_PROPERTYNAME_URL, ::rtl::OUString() );
+ ::rtl::OUString sFilter = aItemProperties.getUnpackedValueOrDefault( HISTORY_PROPERTYNAME_FILTER, ::rtl::OUString() );
+ String sTitle = aItemProperties.getUnpackedValueOrDefault( HISTORY_PROPERTYNAME_TITLE, ::rtl::OUString() );
+ ::rtl::OUString sPassword = aItemProperties.getUnpackedValueOrDefault( HISTORY_PROPERTYNAME_PASSWORD, ::rtl::OUString() );
+
+ // If the entry is an impress file then insert it into the
+ // history list and the list box.
+ Sequence< PropertyValue > aProps;
+ xFilterFactory->getByName( sFilter ) >>= aProps;
+
+ ::comphelper::SequenceAsHashMap aFilterProperties( aProps );
+ ::rtl::OUString sDocumentService = aFilterProperties.getUnpackedValueOrDefault(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DocumentService" ) ), ::rtl::OUString() );
+ if ( sDocumentService.equalsAscii( _pAsciiModuleName ) )
+ {
+ // yes, it's a Base document
+ INetURLObject aURL;
+ aURL.SetSmartURL( sURL );
+ // The password is set only when it is not empty.
+ if ( sPassword.getLength() > 0 )
+ aURL.SetPass( sPassword );
+
+ if ( !sTitle.Len() )
+ sTitle = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_UNAMBIGUOUS );
+
+ String sDecodedURL = aURL.GetMainURL( INetURLObject::NO_DECODE );
+
+ USHORT nPos = InsertEntry( sTitle );
+ m_aURLs.insert( MapIndexToStringPair::value_type( nPos, StringPair( sDecodedURL, sFilter ) ) );
+ }
+ }
+ catch( Exception& rException )
+ {
+ (void)rException;
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ String OpenDocumentListBox::GetSelectedDocumentURL() const
+ {
+ String sURL;
+ USHORT nSelected = GetSelectEntryPos();
+ if ( LISTBOX_ENTRY_NOTFOUND != GetSelectEntryPos() )
+ sURL = impl_getDocumentAtIndex( nSelected ).first;
+ return sURL;
+ }
+
+ //--------------------------------------------------------------------
+ String OpenDocumentListBox::GetSelectedDocumentFilter() const
+ {
+ String sFilter;
+ USHORT nSelected = GetSelectEntryPos();
+ if ( LISTBOX_ENTRY_NOTFOUND != GetSelectEntryPos() )
+ sFilter = impl_getDocumentAtIndex( nSelected ).second;
+ return sFilter;
+ }
+
+ //--------------------------------------------------------------------
+ OpenDocumentListBox::StringPair OpenDocumentListBox::impl_getDocumentAtIndex( USHORT _nListIndex, bool _bSystemNotation ) const
+ {
+ MapIndexToStringPair::const_iterator pos = m_aURLs.find( _nListIndex );
+ DBG_ASSERT( pos != m_aURLs.end(), "OpenDocumentListBox::impl_getDocumentAtIndex: invalid index!" );
+
+ StringPair aDocumentDescriptor;
+ if ( pos != m_aURLs.end() )
+ {
+ aDocumentDescriptor = pos->second;
+ if ( _bSystemNotation && aDocumentDescriptor.first.Len() )
+ {
+ ::svt::OFileNotation aNotation( aDocumentDescriptor.first );
+ aDocumentDescriptor.first = aNotation.get( ::svt::OFileNotation::N_SYSTEM );
+ }
+ }
+ return aDocumentDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ void OpenDocumentListBox::RequestHelp( const HelpEvent& _rHEvt )
+ {
+ if( !( _rHEvt.GetMode() & HELPMODE_QUICK ) )
+ return;
+ if ( !IsEnabled() )
+ return;
+
+ Point aRequestPos( ScreenToOutputPixel( _rHEvt.GetMousePosPixel() ) );
+ USHORT nItemIndex = LISTBOX_ENTRY_NOTFOUND;
+ if ( GetIndexForPoint( aRequestPos, nItemIndex ) != -1 )
+ {
+ Rectangle aItemRect( GetBoundingRectangle( nItemIndex ) );
+ aItemRect = Rectangle(
+ OutputToScreenPixel( aItemRect.TopLeft() ),
+ OutputToScreenPixel( aItemRect.BottomRight() ) );
+ String sHelpText = impl_getDocumentAtIndex( nItemIndex, true ).first;
+ Help::ShowQuickHelp( this, aItemRect, sHelpText, QUICKHELP_LEFT | QUICKHELP_VCENTER );
+ }
+ }
+
+//........................................................................
+} // namespace dbaui
+//........................................................................
diff --git a/dbaccess/source/ui/control/sqledit.cxx b/dbaccess/source/ui/control/sqledit.cxx
new file mode 100644
index 000000000000..89cdc855a0cd
--- /dev/null
+++ b/dbaccess/source/ui/control/sqledit.cxx
@@ -0,0 +1,224 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#include "sqledit.hxx"
+#include "QueryTextView.hxx"
+#include "querycontainerwindow.hxx"
+#include <tools/debug.hxx>
+#include "dbaccess_helpid.hrc"
+#include "browserids.hxx"
+#include "querycontroller.hxx"
+#include "undosqledit.hxx"
+#include "QueryDesignView.hxx"
+
+#include <svl/smplhint.hxx>
+
+//////////////////////////////////////////////////////////////////////////
+// OSqlEdit
+//------------------------------------------------------------------------------
+using namespace dbaui;
+
+DBG_NAME(OSqlEdit)
+OSqlEdit::OSqlEdit( OQueryTextView* pParent, WinBits nWinStyle ) :
+ MultiLineEditSyntaxHighlight( pParent, nWinStyle )
+ ,m_pView(pParent)
+ ,m_bAccelAction( sal_False )
+ ,m_bStopTimer(sal_False )
+{
+ DBG_CTOR(OSqlEdit,NULL);
+ SetHelpId( HID_CTL_QRYSQLEDIT );
+ SetModifyHdl( LINK(this, OSqlEdit, ModifyHdl) );
+
+ m_timerUndoActionCreation.SetTimeout(1000);
+ m_timerUndoActionCreation.SetTimeoutHdl(LINK(this, OSqlEdit, OnUndoActionTimer));
+
+ m_timerInvalidate.SetTimeout(200);
+ m_timerInvalidate.SetTimeoutHdl(LINK(this, OSqlEdit, OnInvalidateTimer));
+ m_timerInvalidate.Start();
+
+ ImplSetFont();
+ // listen for change of Font and Color Settings
+ m_SourceViewConfig.AddListener( this );
+ m_ColorConfig.AddListener(this);
+
+ //#i97044#
+ EnableFocusSelectionHide( FALSE );
+}
+
+//------------------------------------------------------------------------------
+OSqlEdit::~OSqlEdit()
+{
+ DBG_DTOR(OSqlEdit,NULL);
+ if (m_timerUndoActionCreation.IsActive())
+ m_timerUndoActionCreation.Stop();
+ m_SourceViewConfig.RemoveListener(this);
+ m_ColorConfig.RemoveListener(this);
+}
+//------------------------------------------------------------------------------
+void OSqlEdit::KeyInput( const KeyEvent& rKEvt )
+{
+ DBG_CHKTHIS(OSqlEdit,NULL);
+ OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
+ rController.InvalidateFeature(SID_CUT);
+ rController.InvalidateFeature(SID_COPY);
+
+ // Ist dies ein Cut, Copy, Paste Event?
+ KeyFuncType aKeyFunc = rKEvt.GetKeyCode().GetFunction();
+ if( (aKeyFunc==KEYFUNC_CUT)||(aKeyFunc==KEYFUNC_COPY)||(aKeyFunc==KEYFUNC_PASTE) )
+ m_bAccelAction = sal_True;
+
+ MultiLineEditSyntaxHighlight::KeyInput( rKEvt );
+
+ if( m_bAccelAction )
+ m_bAccelAction = sal_False;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool OSqlEdit::IsInAccelAct()
+{
+ DBG_CHKTHIS(OSqlEdit,NULL);
+ // Das Cut, Copy, Paste per Accel. fuehrt neben der Aktion im Edit im View
+ // auch die entsprechenden Slots aus. Die Aktionen finden also zweimal statt.
+ // Um dies zu verhindern, kann im View beim SlotExec diese Funktion
+ // aufgerufen werden.
+
+ return m_bAccelAction;
+}
+
+//------------------------------------------------------------------------------
+void OSqlEdit::GetFocus()
+{
+ DBG_CHKTHIS(OSqlEdit,NULL);
+ m_strOrigText =GetText();
+ MultiLineEditSyntaxHighlight::GetFocus();
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(OSqlEdit, OnUndoActionTimer, void*, EMPTYARG)
+{
+ String aText =GetText();
+ if(aText != m_strOrigText)
+ {
+ OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
+ SfxUndoManager* pUndoMgr = rController.getUndoMgr();
+ OSqlEditUndoAct* pUndoAct = new OSqlEditUndoAct( this );
+
+ pUndoAct->SetOriginalText( m_strOrigText );
+ pUndoMgr->AddUndoAction( pUndoAct );
+
+ rController.InvalidateFeature(SID_UNDO);
+ rController.InvalidateFeature(SID_REDO);
+
+ m_strOrigText =aText;
+ }
+
+ return 0L;
+}
+//------------------------------------------------------------------------------
+IMPL_LINK(OSqlEdit, OnInvalidateTimer, void*, EMPTYARG)
+{
+ OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
+ rController.InvalidateFeature(SID_CUT);
+ rController.InvalidateFeature(SID_COPY);
+ if(!m_bStopTimer)
+ m_timerInvalidate.Start();
+ return 0L;
+}
+//------------------------------------------------------------------------------
+IMPL_LINK(OSqlEdit, ModifyHdl, void*, /*EMPTYTAG*/)
+{
+ if (m_timerUndoActionCreation.IsActive())
+ m_timerUndoActionCreation.Stop();
+ m_timerUndoActionCreation.Start();
+
+ OJoinController& rController = m_pView->getContainerWindow()->getDesignView()->getController();
+ if (!rController.isModified())
+ rController.setModified( sal_True );
+
+ rController.InvalidateFeature(SID_SBA_QRY_EXECUTE);
+ rController.InvalidateFeature(SID_CUT);
+ rController.InvalidateFeature(SID_COPY);
+
+ m_lnkTextModifyHdl.Call(NULL);
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+void OSqlEdit::SetText(const String& rNewText)
+{
+ DBG_CHKTHIS(OSqlEdit,NULL);
+ if (m_timerUndoActionCreation.IsActive())
+ { // die noch anstehenden Undo-Action erzeugen
+ m_timerUndoActionCreation.Stop();
+ LINK(this, OSqlEdit, OnUndoActionTimer).Call(NULL);
+ }
+
+ MultiLineEditSyntaxHighlight::SetText(rNewText);
+ m_strOrigText =rNewText;
+}
+// -----------------------------------------------------------------------------
+void OSqlEdit::stopTimer()
+{
+ m_bStopTimer = sal_True;
+ if (m_timerInvalidate.IsActive())
+ m_timerInvalidate.Stop();
+}
+// -----------------------------------------------------------------------------
+void OSqlEdit::startTimer()
+{
+ m_bStopTimer = sal_False;
+ if (!m_timerInvalidate.IsActive())
+ m_timerInvalidate.Start();
+}
+
+void OSqlEdit::ConfigurationChanged( utl::ConfigurationBroadcaster* pOption, sal_uInt32 )
+{
+ if ( pOption == &m_SourceViewConfig )
+ ImplSetFont();
+ else if ( pOption == &m_ColorConfig )
+ MultiLineEditSyntaxHighlight::UpdateData();
+}
+
+void OSqlEdit::ImplSetFont()
+{
+ AllSettings aSettings = GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ String sFontName = m_SourceViewConfig.GetFontName();
+ if ( !sFontName.Len() )
+ {
+ Font aTmpFont( OutputDevice::GetDefaultFont( DEFAULTFONT_FIXED, Application::GetSettings().GetUILanguage(), 0 , this ) );
+ sFontName = aTmpFont.GetName();
+ }
+ Size aFontSize( 0, m_SourceViewConfig.GetFontHeight() );
+ Font aFont( sFontName, aFontSize );
+ aStyleSettings.SetFieldFont(aFont);
+ aSettings.SetStyleSettings(aStyleSettings);
+ SetSettings(aSettings);
+}
+//==============================================================================
diff --git a/dbaccess/source/ui/control/statusbarontroller.cxx b/dbaccess/source/ui/control/statusbarontroller.cxx
new file mode 100644
index 000000000000..63a7406d436f
--- /dev/null
+++ b/dbaccess/source/ui/control/statusbarontroller.cxx
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#include "statusbarontroller.hxx"
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+
+extern "C" void SAL_CALL createRegistryInfo_OStatusbarController()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OStatusbarController> aAutoRegistration;
+}
+namespace dbaui
+{
+ using namespace svt;
+ using namespace com::sun::star::uno;
+ using namespace com::sun::star::beans;
+ using namespace com::sun::star::lang;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::util;
+
+ IMPLEMENT_SERVICE_INFO1_STATIC(OStatusbarController,"com.sun.star.sdb.ApplicationStatusbarController","com.sun.star.frame.StatusbarController")
+ IMPLEMENT_FORWARD_XINTERFACE2(OStatusbarController,StatusbarController,OStatusbarController_BASE)
+}
diff --git a/dbaccess/source/ui/control/tabletree.cxx b/dbaccess/source/ui/control/tabletree.cxx
new file mode 100644
index 000000000000..72db2ee129df
--- /dev/null
+++ b/dbaccess/source/ui/control/tabletree.cxx
@@ -0,0 +1,738 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef _DBAUI_TABLETREE_HXX_
+#include "tabletree.hxx"
+#endif
+#ifndef _DBAUI_TABLETREE_HRC_
+#include "tabletree.hrc"
+#endif
+#ifndef DBACCESS_IMAGEPROVIDER_HXX
+#include "imageprovider.hxx"
+#endif
+#ifndef _DBAUI_MODULE_DBU_HXX_
+#include "moduledbu.hxx"
+#endif
+#ifndef _DBU_CONTROL_HRC_
+#include "dbu_control.hrc"
+#endif
+#ifndef _SV_MENU_HXX
+#include <vcl/menu.hxx>
+#endif
+#ifndef _CONNECTIVITY_DBTOOLS_HXX_
+#include <connectivity/dbtools.hxx>
+#endif
+#ifndef _COMPHELPER_TYPES_HXX_
+#include <comphelper/types.hxx>
+#endif
+#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
+#include "dbustrings.hrc"
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_DATABASEOBJECT_HPP_
+#include <com/sun/star/sdb/application/DatabaseObject.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_APPLICATION_DATABASEOBJECTFOLDER_HPP_
+#include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XDATADEFINITIONSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XViewsSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_
+#include <com/sun/star/sdb/SQLContext.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SDBC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _DBAUI_COMMON_TYPES_HXX_
+#include "commontypes.hxx"
+#endif
+#ifndef _DBAUI_LISTVIEWITEMS_HXX_
+#include "listviewitems.hxx"
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef _RTL_USTRBUF_HXX_
+#include <rtl/ustrbuf.hxx>
+#endif
+#include <connectivity/dbmetadata.hxx>
+
+#include <algorithm>
+
+//.........................................................................
+namespace dbaui
+{
+//.........................................................................
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb::application;
+
+using namespace ::dbtools;
+using namespace ::comphelper;
+
+namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
+namespace DatabaseObjectContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer;
+
+//========================================================================
+//= OTableTreeListBox
+//========================================================================
+OTableTreeListBox::OTableTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, WinBits nWinStyle,sal_Bool _bVirtualRoot )
+ :OMarkableTreeListBox(pParent,_rxORB,nWinStyle)
+ ,m_pImageProvider( new ImageProvider )
+ ,m_bVirtualRoot(_bVirtualRoot)
+ ,m_bNoEmptyFolders( false )
+{
+ implSetDefaultImages();
+}
+//------------------------------------------------------------------------
+OTableTreeListBox::OTableTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, const ResId& rResId ,sal_Bool _bVirtualRoot)
+ :OMarkableTreeListBox(pParent,_rxORB,rResId)
+ ,m_pImageProvider( new ImageProvider )
+ ,m_bVirtualRoot(_bVirtualRoot)
+ ,m_bNoEmptyFolders( false )
+{
+ implSetDefaultImages();
+}
+
+// -----------------------------------------------------------------------------
+OTableTreeListBox::~OTableTreeListBox()
+{
+}
+
+// -----------------------------------------------------------------------------
+void OTableTreeListBox::implSetDefaultImages()
+{
+ ImageProvider aImageProvider;
+ SetDefaultExpandedEntryBmp( aImageProvider.getFolderImage( DatabaseObject::TABLE, false ), BMP_COLOR_NORMAL );
+ SetDefaultExpandedEntryBmp( aImageProvider.getFolderImage( DatabaseObject::TABLE, true ), BMP_COLOR_HIGHCONTRAST );
+ SetDefaultCollapsedEntryBmp( aImageProvider.getFolderImage( DatabaseObject::TABLE, false ), BMP_COLOR_NORMAL );
+ SetDefaultCollapsedEntryBmp( aImageProvider.getFolderImage( DatabaseObject::TABLE, true ), BMP_COLOR_HIGHCONTRAST );
+}
+
+// -----------------------------------------------------------------------------
+bool OTableTreeListBox::isFolderEntry( const SvLBoxEntry* _pEntry ) const
+{
+ sal_Int32 nEntryType = reinterpret_cast< sal_IntPtr >( _pEntry->GetUserData() );
+ if ( ( nEntryType == DatabaseObjectContainer::TABLES )
+ || ( nEntryType == DatabaseObjectContainer::CATALOG )
+ || ( nEntryType == DatabaseObjectContainer::SCHEMA )
+ )
+ return true;
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+void OTableTreeListBox::notifyHiContrastChanged()
+{
+ implSetDefaultImages();
+
+ SvLBoxEntry* pEntryLoop = First();
+ while (pEntryLoop)
+ {
+ USHORT nCount = pEntryLoop->ItemCount();
+ for (USHORT i=0;i<nCount;++i)
+ {
+ SvLBoxItem* pItem = pEntryLoop->GetItem(i);
+ if ( pItem && pItem->IsA() == SV_ITEM_ID_LBOXCONTEXTBMP)
+ {
+ SvLBoxContextBmp* pContextBitmapItem = static_cast< SvLBoxContextBmp* >( pItem );
+
+ Image aImage, aImageHC;
+ if ( isFolderEntry( pEntryLoop ) )
+ {
+ aImage = m_pImageProvider->getFolderImage( DatabaseObject::TABLE, false );
+ aImageHC = m_pImageProvider->getFolderImage( DatabaseObject::TABLE, true );
+ }
+ else
+ {
+ String sCompleteName( getQualifiedTableName( pEntryLoop ) );
+ m_pImageProvider->getImages( sCompleteName, DatabaseObject::TABLE, aImage, aImageHC );
+ }
+
+ pContextBitmapItem->SetBitmap1( aImage, BMP_COLOR_NORMAL );
+ pContextBitmapItem->SetBitmap2( aImage, BMP_COLOR_NORMAL );
+ pContextBitmapItem->SetBitmap1( aImageHC, BMP_COLOR_HIGHCONTRAST );
+ pContextBitmapItem->SetBitmap2( aImageHC, BMP_COLOR_HIGHCONTRAST );
+ // TODO: Now that we give both images to the entry item, it is not necessary anymore
+ // to do this anytime HC changes - the tree control will do this itself now.
+ // We would only need to properly initialize newly inserted entries.
+ break;
+ }
+ }
+ pEntryLoop = Next(pEntryLoop);
+ }
+}
+
+//------------------------------------------------------------------------
+void OTableTreeListBox::implOnNewConnection( const Reference< XConnection >& _rxConnection )
+{
+ m_xConnection = _rxConnection;
+ m_pImageProvider.reset( new ImageProvider( m_xConnection ) );
+}
+
+//------------------------------------------------------------------------
+void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConnection ) throw(SQLException)
+{
+ Sequence< ::rtl::OUString > sTables, sViews;
+
+ String sCurrentActionError;
+ try
+ {
+ Reference< XTablesSupplier > xTableSupp( _rxConnection, UNO_QUERY_THROW );
+ sCurrentActionError = String(ModuleRes(STR_NOTABLEINFO));
+
+ Reference< XNameAccess > xTables,xViews;
+
+ Reference< XViewsSupplier > xViewSupp( _rxConnection, UNO_QUERY );
+ if ( xViewSupp.is() )
+ {
+ xViews = xViewSupp->getViews();
+ if (xViews.is())
+ sViews = xViews->getElementNames();
+ }
+
+ xTables = xTableSupp->getTables();
+ if (xTables.is())
+ sTables = xTables->getElementNames();
+ }
+ catch(RuntimeException&)
+ {
+ DBG_ERROR("OTableTreeListBox::UpdateTableList : caught an RuntimeException!");
+ }
+ catch ( const SQLException& )
+ {
+ throw;
+ }
+ catch(Exception&)
+ {
+ // a non-SQLException exception occured ... simply throw an SQLException
+ SQLException aInfo;
+ aInfo.Message = sCurrentActionError;
+ throw aInfo;
+ }
+
+ UpdateTableList( _rxConnection, sTables, sViews );
+}
+// -----------------------------------------------------------------------------
+namespace
+{
+ struct OViewSetter : public ::std::unary_function< OTableTreeListBox::TNames::value_type, bool>
+ {
+ const Sequence< ::rtl::OUString> m_aViews;
+ ::comphelper::TStringMixEqualFunctor m_aEqualFunctor;
+
+ OViewSetter(const Sequence< ::rtl::OUString>& _rViews,sal_Bool _bCase) : m_aViews(_rViews),m_aEqualFunctor(_bCase){}
+ OTableTreeListBox::TNames::value_type operator() (const ::rtl::OUString& lhs)
+ {
+ OTableTreeListBox::TNames::value_type aRet;
+ aRet.first = lhs;
+ const ::rtl::OUString* pIter = m_aViews.getConstArray();
+ const ::rtl::OUString* pEnd = m_aViews.getConstArray() + m_aViews.getLength();
+ aRet.second = (::std::find_if(pIter,pEnd,::std::bind2nd(m_aEqualFunctor,lhs)) != pEnd);
+
+ return aRet;
+ }
+ };
+
+}
+// -----------------------------------------------------------------------------
+void OTableTreeListBox::UpdateTableList(
+ const Reference< XConnection >& _rxConnection,
+ const Sequence< ::rtl::OUString>& _rTables,
+ const Sequence< ::rtl::OUString>& _rViews
+ )
+{
+ TNames aTables;
+ aTables.resize(_rTables.getLength());
+ const ::rtl::OUString* pIter = _rTables.getConstArray();
+ const ::rtl::OUString* pEnd = _rTables.getConstArray() + _rTables.getLength();
+ try
+ {
+ Reference< XDatabaseMetaData > xMeta( _rxConnection->getMetaData(), UNO_QUERY_THROW );
+ ::std::transform( pIter, pEnd,
+ aTables.begin(), OViewSetter( _rViews, xMeta->supportsMixedCaseQuotedIdentifiers() ) );
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ UpdateTableList( _rxConnection, aTables );
+}
+
+//------------------------------------------------------------------------
+namespace
+{
+ ::std::vector< ::rtl::OUString > lcl_getMetaDataStrings_throw( const Reference< XResultSet >& _rxMetaDataResult, sal_Int32 _nColumnIndex )
+ {
+ ::std::vector< ::rtl::OUString > aStrings;
+ Reference< XRow > xRow( _rxMetaDataResult, UNO_QUERY_THROW );
+ while ( _rxMetaDataResult->next() )
+ aStrings.push_back( xRow->getString( _nColumnIndex ) );
+ return aStrings;
+ }
+
+ bool lcl_shouldDisplayEmptySchemasAndCatalogs( const Reference< XConnection >& _rxConnection )
+ {
+ ::dbtools::DatabaseMetaData aMetaData( _rxConnection );
+ return aMetaData.displayEmptyTableFolders();
+ }
+}
+
+//------------------------------------------------------------------------
+void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConnection, const TNames& _rTables )
+{
+ implOnNewConnection( _rxConnection );
+
+ // throw away all the old stuff
+ Clear();
+
+ try
+ {
+ // the root entry saying "all objects"
+ SvLBoxEntry* pAllObjects = NULL;
+ if (haveVirtualRoot())
+ {
+ String sRootEntryText;
+ TNames::const_iterator aViews = ::std::find_if(_rTables.begin(),_rTables.end(),
+ ::std::compose1(::std::bind2nd(::std::equal_to<sal_Bool>(),sal_False),::std::select2nd<TNames::value_type>()));
+ TNames::const_iterator aTables = ::std::find_if(_rTables.begin(),_rTables.end(),
+ ::std::compose1(::std::bind2nd(::std::equal_to<sal_Bool>(),sal_True),::std::select2nd<TNames::value_type>()));
+
+ if ( aViews == _rTables.end() )
+ sRootEntryText = String(ModuleRes(STR_ALL_TABLES));
+ else if ( aTables == _rTables.end() )
+ sRootEntryText = String(ModuleRes(STR_ALL_VIEWS));
+ else
+ sRootEntryText = String(ModuleRes(STR_ALL_TABLES_AND_VIEWS));
+ pAllObjects = InsertEntry( sRootEntryText, NULL, FALSE, LIST_APPEND, reinterpret_cast< void* >( DatabaseObjectContainer::TABLES ) );
+ }
+
+ if ( _rTables.empty() )
+ // nothing to do (besides inserting the root entry)
+ return;
+
+ // get the table/view names
+ TNames::const_iterator aIter = _rTables.begin();
+ TNames::const_iterator aEnd = _rTables.end();
+
+ Reference< XDatabaseMetaData > xMeta( _rxConnection->getMetaData(), UNO_QUERY_THROW );
+ for ( ; aIter != aEnd; ++aIter )
+ {
+ // add the entry
+ implAddEntry(
+ xMeta,
+ aIter->first,
+ sal_False
+ );
+ }
+
+ if ( !m_bNoEmptyFolders && lcl_shouldDisplayEmptySchemasAndCatalogs( _rxConnection ) )
+ {
+ sal_Bool bSupportsCatalogs = xMeta->supportsCatalogsInDataManipulation();
+ sal_Bool bSupportsSchemas = xMeta->supportsSchemasInDataManipulation();
+
+ if ( bSupportsCatalogs || bSupportsSchemas )
+ {
+ // we display empty catalogs if the DB supports catalogs, and they're noted at the beginning of a
+ // composed name. Otherwise, we display empty schematas. (also see the tree structure explained in
+ // implAddEntry)
+ bool bCatalogs = bSupportsCatalogs && xMeta->isCatalogAtStart();
+
+ ::std::vector< ::rtl::OUString > aFolderNames( lcl_getMetaDataStrings_throw(
+ bCatalogs ? xMeta->getCatalogs() : xMeta->getSchemas(), 1 ) );
+ sal_Int32 nFolderType = bCatalogs ? DatabaseObjectContainer::CATALOG : DatabaseObjectContainer::SCHEMA;
+
+ SvLBoxEntry* pRootEntry = getAllObjectsEntry();
+ for ( ::std::vector< ::rtl::OUString >::const_iterator folder = aFolderNames.begin();
+ folder != aFolderNames.end();
+ ++folder
+ )
+ {
+ SvLBoxEntry* pFolder = GetEntryPosByName( *folder, pRootEntry );
+ if ( !pFolder )
+ pFolder = InsertEntry( *folder, pRootEntry, FALSE, LIST_APPEND, reinterpret_cast< void* >( nFolderType ) );
+ }
+ }
+ }
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+//------------------------------------------------------------------------
+sal_Bool OTableTreeListBox::isWildcardChecked(SvLBoxEntry* _pEntry) const
+{
+ if (_pEntry)
+ {
+ OBoldListboxString* pTextItem = static_cast<OBoldListboxString*>(_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING));
+ if (pTextItem)
+ return pTextItem->isEmphasized();
+ }
+ return sal_False;
+}
+
+//------------------------------------------------------------------------
+void OTableTreeListBox::checkWildcard(SvLBoxEntry* _pEntry)
+{
+ SetCheckButtonState(_pEntry, SV_BUTTON_CHECKED);
+ checkedButton_noBroadcast(_pEntry);
+}
+
+//------------------------------------------------------------------------
+SvLBoxEntry* OTableTreeListBox::getAllObjectsEntry() const
+{
+ return haveVirtualRoot() ? First() : NULL;
+}
+
+//------------------------------------------------------------------------
+void OTableTreeListBox::checkedButton_noBroadcast(SvLBoxEntry* _pEntry)
+{
+ OMarkableTreeListBox::checkedButton_noBroadcast(_pEntry);
+
+ // if an entry has children, it makes a difference if the entry is checked because alls children are checked
+ // or if the user checked it explicitly.
+ // So we track explicit (un)checking
+
+ SvButtonState eState = GetCheckButtonState(_pEntry);
+ DBG_ASSERT(SV_BUTTON_TRISTATE != eState, "OTableTreeListBox::CheckButtonHdl: user action which lead to TRISTATE?");
+ implEmphasize(_pEntry, SV_BUTTON_CHECKED == eState);
+}
+
+//------------------------------------------------------------------------
+void OTableTreeListBox::implEmphasize(SvLBoxEntry* _pEntry, sal_Bool _bChecked, sal_Bool _bUpdateDescendants, sal_Bool _bUpdateAncestors)
+{
+ DBG_ASSERT(_pEntry, "OTableTreeListBox::implEmphasize: invalid entry (NULL)!");
+
+ // special emphasizing handling for the "all objects" entry
+ // 89709 - 16.07.2001 - frank.schoenheit@sun.com
+ sal_Bool bAllObjectsEntryAffected = haveVirtualRoot() && (getAllObjectsEntry() == _pEntry);
+ if ( GetModel()->HasChilds(_pEntry) // the entry has children
+ || bAllObjectsEntryAffected // or it is the "all objects" entry
+ )
+ {
+ OBoldListboxString* pTextItem = static_cast<OBoldListboxString*>(_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING));
+ if (pTextItem)
+ pTextItem->emphasize(_bChecked);
+
+ if (bAllObjectsEntryAffected)
+ InvalidateEntry(_pEntry);
+ }
+
+ if (_bUpdateDescendants)
+ {
+ // remove the mark for all children of the checked entry
+ SvLBoxEntry* pChildLoop = FirstChild(_pEntry);
+ while (pChildLoop)
+ {
+ if (GetModel()->HasChilds(pChildLoop))
+ implEmphasize(pChildLoop, sal_False, sal_True, sal_False);
+ pChildLoop = NextSibling(pChildLoop);
+ }
+ }
+
+ if (_bUpdateAncestors)
+ {
+ // remove the mark for all ancestors of the entry
+ if (GetModel()->HasParent(_pEntry))
+ implEmphasize(GetParent(_pEntry), sal_False, sal_False, sal_True);
+ }
+}
+
+//------------------------------------------------------------------------
+void OTableTreeListBox::InitEntry(SvLBoxEntry* _pEntry, const XubString& _rString, const Image& _rCollapsedBitmap, const Image& _rExpandedBitmap, SvLBoxButtonKind _eButtonKind)
+{
+ OMarkableTreeListBox::InitEntry(_pEntry, _rString, _rCollapsedBitmap, _rExpandedBitmap, _eButtonKind);
+
+ // replace the text item with our own one
+ SvLBoxItem* pTextItem = _pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING);
+ DBG_ASSERT(pTextItem, "OTableTreeListBox::InitEntry: no text item!?");
+ sal_uInt16 nTextPos = _pEntry->GetPos(pTextItem);
+ DBG_ASSERT(((sal_uInt16)-1) != nTextPos, "OTableTreeListBox::InitEntry: no text item pos!");
+
+ _pEntry->ReplaceItem(new OBoldListboxString(_pEntry, 0, _rString), nTextPos);
+}
+
+//------------------------------------------------------------------------
+SvLBoxEntry* OTableTreeListBox::implAddEntry(
+ const Reference< XDatabaseMetaData >& _rxMeta,
+ const ::rtl::OUString& _rTableName,
+ sal_Bool _bCheckName
+ )
+{
+ OSL_PRECOND( _rxMeta.is(), "OTableTreeListBox::implAddEntry: invalid meta data!" );
+ if ( !_rxMeta.is() )
+ return NULL;
+
+ // split the complete name into it's components
+ ::rtl::OUString sCatalog, sSchema, sName;
+ qualifiedNameComponents( _rxMeta, _rTableName, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
+
+ SvLBoxEntry* pParentEntry = getAllObjectsEntry();
+
+ // if the DB uses catalog at the start of identifiers, then our hierarchy is
+ // catalog
+ // +- schema
+ // +- table
+ // else it is
+ // schema
+ // +- catalog
+ // +- table
+ sal_Bool bCatalogAtStart = _rxMeta->isCatalogAtStart();
+ const ::rtl::OUString& rFirstName = bCatalogAtStart ? sCatalog : sSchema;
+ const sal_Int32 nFirstFolderType = bCatalogAtStart ? DatabaseObjectContainer::CATALOG : DatabaseObjectContainer::SCHEMA;
+ const ::rtl::OUString& rSecondName = bCatalogAtStart ? sSchema : sCatalog;
+ const sal_Int32 nSecondFolderType = bCatalogAtStart ? DatabaseObjectContainer::SCHEMA : DatabaseObjectContainer::CATALOG;
+
+ if ( rFirstName.getLength() )
+ {
+ SvLBoxEntry* pFolder = GetEntryPosByName( rFirstName, pParentEntry );
+ if ( !pFolder )
+ pFolder = InsertEntry( rFirstName, pParentEntry, FALSE, LIST_APPEND, reinterpret_cast< void* >( nFirstFolderType ) );
+ pParentEntry = pFolder;
+ }
+
+ if ( rSecondName.getLength() )
+ {
+ SvLBoxEntry* pFolder = GetEntryPosByName( rSecondName, pParentEntry );
+ if ( !pFolder )
+ pFolder = InsertEntry( rSecondName, pParentEntry, FALSE, LIST_APPEND, reinterpret_cast< void* >( nSecondFolderType ) );
+ pParentEntry = pFolder;
+ }
+
+ SvLBoxEntry* pRet = NULL;
+ if ( !_bCheckName || !GetEntryPosByName( sName, pParentEntry ) )
+ {
+ pRet = InsertEntry( sName, pParentEntry, FALSE, LIST_APPEND );
+
+ Image aImage, aImageHC;
+ m_pImageProvider->getImages( _rTableName, DatabaseObject::TABLE, aImage, aImageHC );
+
+ SetExpandedEntryBmp( pRet, aImage, BMP_COLOR_NORMAL );
+ SetCollapsedEntryBmp( pRet, aImage, BMP_COLOR_NORMAL );
+ SetExpandedEntryBmp( pRet, aImageHC, BMP_COLOR_HIGHCONTRAST );
+ SetCollapsedEntryBmp( pRet, aImageHC, BMP_COLOR_HIGHCONTRAST );
+ }
+ return pRet;
+}
+
+//------------------------------------------------------------------------
+NamedDatabaseObject OTableTreeListBox::describeObject( SvLBoxEntry* _pEntry )
+{
+ NamedDatabaseObject aObject;
+
+ sal_Int32 nEntryType = reinterpret_cast< sal_IntPtr >( _pEntry->GetUserData() );
+
+ if ( nEntryType == DatabaseObjectContainer::TABLES )
+ {
+ aObject.Type = DatabaseObjectContainer::TABLES;
+ }
+ else if ( ( nEntryType == DatabaseObjectContainer::CATALOG )
+ || ( nEntryType == DatabaseObjectContainer::SCHEMA )
+ )
+ {
+ SvLBoxEntry* pParent = GetParent( _pEntry );
+ sal_Int32 nParentEntryType = pParent ? reinterpret_cast< sal_IntPtr >( pParent->GetUserData() ) : -1;
+
+ ::rtl::OUStringBuffer buffer;
+ if ( nEntryType == DatabaseObjectContainer::CATALOG )
+ {
+ if ( nParentEntryType == DatabaseObjectContainer::SCHEMA )
+ {
+ buffer.append( GetEntryText( pParent ) );
+ buffer.append( sal_Unicode( '.' ) );
+ }
+ buffer.append( GetEntryText( _pEntry ) );
+ }
+ else if ( nEntryType == DatabaseObjectContainer::SCHEMA )
+ {
+ if ( nParentEntryType == DatabaseObjectContainer::CATALOG )
+ {
+ buffer.append( GetEntryText( pParent ) );
+ buffer.append( sal_Unicode( '.' ) );
+ }
+ buffer.append( GetEntryText( _pEntry ) );
+ }
+ }
+ else
+ {
+ aObject.Type = DatabaseObject::TABLE;
+ aObject.Name = getQualifiedTableName( _pEntry );
+ }
+
+ return aObject;
+}
+
+//------------------------------------------------------------------------
+SvLBoxEntry* OTableTreeListBox::addedTable( const ::rtl::OUString& _rName )
+{
+ try
+ {
+ Reference< XDatabaseMetaData > xMeta;
+ if ( impl_getAndAssertMetaData( xMeta ) )
+ return implAddEntry( xMeta, _rName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return NULL;
+}
+
+//------------------------------------------------------------------------
+bool OTableTreeListBox::impl_getAndAssertMetaData( Reference< XDatabaseMetaData >& _out_rMetaData ) const
+{
+ if ( m_xConnection.is() )
+ _out_rMetaData = m_xConnection->getMetaData();
+ OSL_PRECOND( _out_rMetaData.is(), "OTableTreeListBox::impl_getAndAssertMetaData: invalid current connection!" );
+ return _out_rMetaData.is();
+}
+
+//------------------------------------------------------------------------
+String OTableTreeListBox::getQualifiedTableName( SvLBoxEntry* _pEntry ) const
+{
+ OSL_PRECOND( !isFolderEntry( _pEntry ), "OTableTreeListBox::getQualifiedTableName: folder entries not allowed here!" );
+
+ try
+ {
+ Reference< XDatabaseMetaData > xMeta;
+ if ( !impl_getAndAssertMetaData( xMeta ) )
+ return String();
+
+ ::rtl::OUString sCatalog;
+ ::rtl::OUString sSchema;
+ ::rtl::OUString sTable;
+
+ SvLBoxEntry* pSchema = GetParent( _pEntry );
+ if ( pSchema )
+ {
+ SvLBoxEntry* pCatalog = GetParent( pSchema );
+ if ( pCatalog
+ || ( xMeta->supportsCatalogsInDataManipulation()
+ && !xMeta->supportsSchemasInDataManipulation()
+ ) // here we support catalog but no schema
+ )
+ {
+ if ( pCatalog == NULL )
+ {
+ pCatalog = pSchema;
+ pSchema = NULL;
+ }
+ sCatalog = GetEntryText( pCatalog );
+ }
+ if ( pSchema )
+ sSchema = GetEntryText(pSchema);
+ }
+ sTable = GetEntryText( _pEntry );
+
+ return ::dbtools::composeTableName( xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return String();
+}
+
+//------------------------------------------------------------------------
+SvLBoxEntry* OTableTreeListBox::getEntryByQualifiedName( const ::rtl::OUString& _rName )
+{
+ try
+ {
+ Reference< XDatabaseMetaData > xMeta;
+ if ( !impl_getAndAssertMetaData( xMeta ) )
+ return NULL;
+
+ // split the complete name into it's components
+ ::rtl::OUString sCatalog, sSchema, sName;
+ qualifiedNameComponents(xMeta, _rName, sCatalog, sSchema, sName,::dbtools::eInDataManipulation);
+
+ SvLBoxEntry* pParent = getAllObjectsEntry();
+ SvLBoxEntry* pCat = NULL;
+ SvLBoxEntry* pSchema = NULL;
+ if ( sCatalog.getLength() )
+ {
+ pCat = GetEntryPosByName(sCatalog, pParent);
+ if ( pCat )
+ pParent = pCat;
+ }
+
+ if ( sSchema.getLength() )
+ {
+ pSchema = GetEntryPosByName(sSchema, pParent);
+ if ( pSchema )
+ pParent = pSchema;
+ }
+
+ return GetEntryPosByName(sName, pParent);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return NULL;
+}
+//------------------------------------------------------------------------
+void OTableTreeListBox::removedTable( const ::rtl::OUString& _rName )
+{
+ try
+ {
+ SvLBoxEntry* pEntry = getEntryByQualifiedName( _rName );
+ if ( pEntry )
+ GetModel()->Remove( pEntry );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//.........................................................................
+} // namespace dbaui
+//.........................................................................
+
diff --git a/dbaccess/source/ui/control/tabletree.hrc b/dbaccess/source/ui/control/tabletree.hrc
new file mode 100644
index 000000000000..1566e1ec10ce
--- /dev/null
+++ b/dbaccess/source/ui/control/tabletree.hrc
@@ -0,0 +1,37 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBAUI_TABLETREE_HRC_
+#define _DBAUI_TABLETREE_HRC_
+
+//------------------------------------------------------------------------
+//- menu ids
+
+#define MID_SORT_ASCENDING 1
+#define MID_SORT_DECENDING 2
+
+#endif // _DBAUI_TABLETREE_HRC_
diff --git a/dbaccess/source/ui/control/tabletree.src b/dbaccess/source/ui/control/tabletree.src
new file mode 100644
index 000000000000..d08535f3e8da
--- /dev/null
+++ b/dbaccess/source/ui/control/tabletree.src
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBU_CONTROL_HRC_
+#include "dbu_control.hrc"
+#endif
+#ifndef _DBAUI_TABLETREE_HRC_
+#include "tabletree.hrc"
+#endif
+#include "browserids.hxx"
+
+
+Menu MENU_TABLETREE_POPUP
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MID_SORT_ASCENDING;
+ Text [ en-US ] = "Sort Ascending";
+ };
+ MenuItem
+ {
+ Identifier = MID_SORT_DECENDING;
+ Text [ en-US ] = "Sort Descending";
+ };
+ };
+};
+
+String STR_COULDNOTCREATE_DRIVERMANAGER
+{
+ Text [ en-US ] = "Cannot connect to the SDBC driver manager (#servicename#).";
+};
+
+String STR_NOREGISTEREDDRIVER
+{
+ Text [ en-US ] = "A driver is not registered for the URL #connurl#.";
+};
+
+String STR_COULDNOTCONNECT
+{
+ Text [ en-US ] = "No connection could be established for the URL #connurl#.";
+};
+String STR_COULDNOTCONNECT_PLEASECHECK
+{
+ Text [ en-US ] = "Please check the current settings, for example user name and password.";
+};
+String STR_NOTABLEINFO
+{
+ Text [ en-US ] = "Successfully connected, but information about database tables is not available.";
+};
+String STR_ALL_TABLES
+{
+ Text [ en-US ] = "All tables";
+};
+String STR_ALL_VIEWS
+{
+ Text [ en-US ] = "All views";
+};
+String STR_ALL_TABLES_AND_VIEWS
+{
+ Text [ en-US ] = "All tables and views";
+};
+
diff --git a/dbaccess/source/ui/control/toolboxcontroller.cxx b/dbaccess/source/ui/control/toolboxcontroller.cxx
new file mode 100644
index 000000000000..4806ca814c0c
--- /dev/null
+++ b/dbaccess/source/ui/control/toolboxcontroller.cxx
@@ -0,0 +1,321 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+#ifndef DBACCESS_TOOLBOXCONTROLLER_HXX
+#include "toolboxcontroller.hxx"
+#endif
+#ifndef _COM_SUN_STAR_UI_IMAGETYPE_HPP_
+#include <com/sun/star/ui/ImageType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#endif
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/helper/vclunohelper.hxx>
+#endif
+#ifndef _SV_MENU_HXX
+#include <vcl/menu.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UI_XUICONFIGURATIONMANAGER_HPP_
+#include <com/sun/star/ui/XUIConfigurationManager.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_XMODULEUICONFIGURATIONMANAGERSUPPLIER_HPP_
+#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_XIMAGEMANAGER_HPP_
+#include <com/sun/star/ui/XImageManager.hpp>
+#endif
+#ifndef _COM_SUN_STAR_UI_IMAGETYPE_HPP_
+#include <com/sun/star/ui/ImageType.hpp>
+#endif
+#ifndef _COM_SUN_STAR_GRAPHIC_XGRAPHIC_HPP_
+#include <com/sun/star/graphic/XGraphic.hpp>
+#endif
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_TOOLBOX_HXX
+#include <vcl/toolbox.hxx>
+#endif
+#ifndef _DBU_RESOURCE_HRC_
+#include "dbu_resource.hrc"
+#endif
+#ifndef INCLUDED_SVTOOLS_MISCOPT_HXX
+#include <svtools/miscopt.hxx>
+#endif
+#ifndef INCLUDED_SVTOOLS_MODULEOPTIONS_HXX
+#include <unotools/moduleoptions.hxx>
+#endif
+#ifndef TOOLS_DIAGNOSE_EX_H
+#include <tools/diagnose_ex.h>
+#endif
+#ifndef INCLUDED_SVTOOLS_MENUOPTIONS_HXX
+#include <svtools/menuoptions.hxx>
+#endif
+#ifndef _VOS_MUTEX_HXX_
+#include <vos/mutex.hxx>
+#endif
+#ifndef _DBU_REGHELPER_HXX_
+#include "dbu_reghelper.hxx"
+#endif
+#ifndef DBAUI_TOOLS_HXX
+#include "UITools.hxx"
+#endif
+
+
+extern "C" void SAL_CALL createRegistryInfo_OToolboxController()
+{
+ static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OToolboxController> aAutoRegistration;
+}
+namespace dbaui
+{
+ using namespace svt;
+ using namespace ::com::sun::star::graphic;
+ using namespace com::sun::star::uno;
+ using namespace com::sun::star::beans;
+ using namespace com::sun::star::lang;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::ui;
+
+ namespace
+ {
+ void lcl_copy(Menu* _pMenu,USHORT _nMenuId,USHORT _nMenuPos,ToolBox* _pToolBox,USHORT _nToolId,const ::rtl::OUString& _sCommand)
+ {
+ if ( _pMenu->GetItemType(_nMenuPos) != MENUITEM_STRING )
+ _pToolBox->SetItemImage(_nToolId, _pMenu->GetItemImage(_nMenuId));
+ _pToolBox->SetItemCommand( _nToolId, _sCommand);
+ _pToolBox->SetHelpId(_nToolId, _pMenu->GetHelpId(_nMenuId));
+ _pToolBox->SetHelpText(_nToolId, _pMenu->GetHelpText(_nMenuId));
+ _pToolBox->SetQuickHelpText(_nToolId, _pMenu->GetTipHelpText(_nMenuId));
+ _pToolBox->SetItemText(_nToolId, _pMenu->GetItemText(_nMenuId));
+ }
+ }
+
+ OToolboxController::OToolboxController(const Reference< XMultiServiceFactory >& _rxORB)
+ : m_nToolBoxId(1)
+ {
+ osl_incrementInterlockedCount(&m_refCount);
+ m_xServiceManager = _rxORB;
+ osl_decrementInterlockedCount(&m_refCount);
+
+ }
+ // -----------------------------------------------------------------------------
+ IMPLEMENT_SERVICE_INFO1_STATIC(OToolboxController,"com.sun.star.sdb.ApplicationToolboxController","com.sun.star.frame.ToolboxController")
+ // -----------------------------------------------------------------------------
+ // XInterface
+ Any SAL_CALL OToolboxController::queryInterface( const Type& _rType ) throw (RuntimeException)
+ {
+ Any aReturn = ToolboxController::queryInterface(_rType);
+ if (!aReturn.hasValue())
+ aReturn = TToolboxController_BASE::queryInterface(_rType);
+ return aReturn;
+ }
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OToolboxController::acquire() throw ()
+ {
+ ToolboxController::acquire();
+ }
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OToolboxController::release() throw ()
+ {
+ ToolboxController::release();
+ }
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OToolboxController::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException)
+ {
+ ToolboxController::initialize(_rArguments);
+ vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if ( m_aCommandURL.equalsAscii(".uno:DBNewForm") )
+ {
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewForm")) ,sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewView")) ,sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewViewSQL")) ,sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewQuery")) ,sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewQuerySql")) ,sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewReport")) ,sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewReportAutoPilot")),sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBNewTable")) ,sal_True));
+ }
+ else
+ {
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:Refresh")) ,sal_True));
+ m_aStates.insert(TCommandState::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:DBRebuildData")) ,sal_True));
+ }
+
+ TCommandState::iterator aIter = m_aStates.begin();
+ TCommandState::iterator aEnd = m_aStates.end();
+ for (; aIter != aEnd; ++aIter)
+ addStatusListener(aIter->first);
+
+ ToolBox* pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+ if ( pToolBox )
+ {
+ USHORT nCount = pToolBox->GetItemCount();
+ for (USHORT nPos = 0; nPos < nCount; ++nPos)
+ {
+ USHORT nItemId = pToolBox->GetItemId(nPos);
+ if ( pToolBox->GetItemCommand(nItemId) == String(m_aCommandURL) )
+ {
+ m_nToolBoxId = nItemId;
+ break;
+ }
+ }
+
+ // check if paste special is allowed, when not don't add DROPDOWN
+ pToolBox->SetItemBits(m_nToolBoxId,pToolBox->GetItemBits(m_nToolBoxId) | TIB_DROPDOWN);
+ }
+ }
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OToolboxController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException )
+ {
+ vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ TCommandState::iterator aFind = m_aStates.find( Event.FeatureURL.Complete );
+ if ( aFind != m_aStates.end() )
+ {
+ aFind->second = Event.IsEnabled;
+ if ( m_aCommandURL == aFind->first && !Event.IsEnabled )
+ {
+ ::std::auto_ptr<PopupMenu> pMenu = getMenu();
+ USHORT nCount = pMenu->GetItemCount();
+ for (USHORT i = 0; i < nCount; ++i)
+ {
+ USHORT nItemId = pMenu->GetItemId(i);
+ aFind = m_aStates.find(pMenu->GetItemCommand(nItemId));
+ if ( aFind != m_aStates.end() && aFind->second )
+ {
+ m_aCommandURL = aFind->first;
+
+ ToolBox* pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+ lcl_copy(pMenu.get(),nItemId,i,pToolBox,m_nToolBoxId, m_aCommandURL);
+ break;
+ }
+ }
+ }
+ }
+ }
+ // -----------------------------------------------------------------------------
+ ::std::auto_ptr<PopupMenu> OToolboxController::getMenu()
+ {
+ ::std::auto_ptr<PopupMenu> pMenu;
+ if ( m_aStates.size() > 2 )
+ {
+ pMenu.reset( new PopupMenu( ModuleRes( RID_MENU_APP_NEW ) ) );
+
+ sal_Bool bHighContrast = isHighContrast();
+
+ try
+ {
+ Reference<XModuleUIConfigurationManagerSupplier> xModuleCfgMgrSupplier(getServiceManager()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.ModuleUIConfigurationManagerSupplier"))),UNO_QUERY);
+ Reference<XUIConfigurationManager> xUIConfigMgr = xModuleCfgMgrSupplier->getUIConfigurationManager(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.OfficeDatabaseDocument")));
+ Reference<XImageManager> xImageMgr(xUIConfigMgr->getImageManager(),UNO_QUERY);
+
+
+ short nImageType = hasBigImages() ? ImageType::SIZE_LARGE : ImageType::SIZE_DEFAULT;
+ if ( bHighContrast )
+ nImageType |= ImageType::COLOR_HIGHCONTRAST;
+
+ Sequence< ::rtl::OUString> aSeq(1);
+ USHORT nCount = pMenu->GetItemCount();
+ for (USHORT nPos = 0; nPos < nCount; ++nPos)
+ {
+ if ( pMenu->GetItemType( nPos ) == MENUITEM_SEPARATOR )
+ continue;
+
+ USHORT nItemId = pMenu->GetItemId(nPos);
+ aSeq[0] = pMenu->GetItemCommand(nItemId);
+ Sequence< Reference<XGraphic> > aImages = xImageMgr->getImages(nImageType,aSeq);
+
+ Image aImage(aImages[0]);
+ pMenu->SetItemImage(nItemId,aImage);
+ TCommandState::iterator aFind = m_aStates.find( aSeq[0] );
+ if ( aFind != m_aStates.end() )
+ {
+ pMenu->EnableItem(nItemId,aFind->second);
+ }
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ else
+ {
+ pMenu.reset( new PopupMenu( ModuleRes( RID_MENU_REFRESH_DATA ) ) );
+ }
+ return pMenu;
+ }
+ // -----------------------------------------------------------------------------
+ Reference< ::com::sun::star::awt::XWindow > SAL_CALL OToolboxController::createPopupWindow() throw (RuntimeException)
+ {
+ // execute the menu
+ vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ ToolBox* pToolBox = static_cast<ToolBox*>(VCLUnoHelper::GetWindow(getParent()));
+ ::std::auto_ptr<PopupMenu> pMenu = getMenu();
+
+ USHORT nSelected = pMenu->Execute(pToolBox, pToolBox->GetItemRect( m_nToolBoxId ),POPUPMENU_EXECUTE_DOWN);
+ // "cleanup" the toolbox state
+ Point aPoint = pToolBox->GetItemRect( m_nToolBoxId ).TopLeft();
+ MouseEvent aLeave( aPoint, 0, MOUSE_LEAVEWINDOW | MOUSE_SYNTHETIC );
+ pToolBox->MouseMove( aLeave );
+ pToolBox->SetItemDown( m_nToolBoxId, sal_False);
+
+ if ( nSelected )
+ {
+ m_aCommandURL = pMenu->GetItemCommand(nSelected);
+ lcl_copy(pMenu.get(),nSelected,pMenu->GetItemPos(nSelected),pToolBox,m_nToolBoxId, m_aCommandURL);
+
+ Reference<XDispatch> xDispatch = m_aListenerMap.find(m_aCommandURL)->second;
+ if ( xDispatch.is() )
+ {
+ URL aUrl;
+ Sequence < PropertyValue > aArgs;
+ aUrl.Complete = m_aCommandURL;
+ OSL_ENSURE(aUrl.Complete.getLength(),"Command is empty!");
+ if ( getURLTransformer().is() )
+ getURLTransformer()->parseStrict(aUrl);
+ xDispatch->dispatch(aUrl,aArgs);
+
+ }
+ }
+ return Reference< ::com::sun::star::awt::XWindow >();
+ }
+ // -----------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------
+//..........................................................................
+} // dbaui
+//..........................................................................
+
+
diff --git a/dbaccess/source/ui/control/undosqledit.cxx b/dbaccess/source/ui/control/undosqledit.cxx
new file mode 100644
index 000000000000..d649220141bd
--- /dev/null
+++ b/dbaccess/source/ui/control/undosqledit.cxx
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_dbaccess.hxx"
+
+#ifndef DBAUI_GENERALUNDO_HXX
+#include "undosqledit.hxx"
+#endif
+#ifndef DBAUI_SQLEDIT_HXX
+#include "sqledit.hxx"
+#endif
+
+namespace dbaui
+{
+//------------------------------------------------------------------------------
+void OSqlEditUndoAct::ToggleText()
+{
+ String strNext = m_pOwner->GetText();
+ m_pOwner->SetText(m_strNextText);
+ m_strNextText =strNext;
+}
+// -----------------------------------------------------------------------------
+} // namespace
+// -----------------------------------------------------------------------------
+
diff --git a/dbaccess/source/ui/control/undosqledit.src b/dbaccess/source/ui/control/undosqledit.src
new file mode 100644
index 000000000000..814a304d18c0
--- /dev/null
+++ b/dbaccess/source/ui/control/undosqledit.src
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * 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.
+ *
+ * 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).
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _DBU_CONTROL_HRC_
+#include "dbu_control.hrc"
+#endif
+
+String STR_QUERY_UNDO_MODIFYSQLEDIT
+{
+ Text [ en-US ] = "Modify SQL statement(s)" ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+