diff options
Diffstat (limited to 'dbaccess/source/ui')
23 files changed, 360 insertions, 482 deletions
diff --git a/dbaccess/source/ui/app/AppControllerGen.cxx b/dbaccess/source/ui/app/AppControllerGen.cxx index 2570822ca6e2..0b1be1189bd4 100644 --- a/dbaccess/source/ui/app/AppControllerGen.cxx +++ b/dbaccess/source/ui/app/AppControllerGen.cxx @@ -619,7 +619,7 @@ void OApplicationController::onDocumentOpened( const ::rtl::OUString& _rName, co try { - m_pSubComponentManager->onSubComponentOpened( _rName, _nType, _eMode, _xDocument ); + m_pSubComponentManager->onSubComponentOpened( _rName, _nType, _eMode, _rxDefinition.is() ? _rxDefinition : _xDocument ); if ( _rxDefinition.is() ) { diff --git a/dbaccess/source/ui/app/subcomponentmanager.cxx b/dbaccess/source/ui/app/subcomponentmanager.cxx index 59a552ffc7cf..8ef4f77f20c7 100644 --- a/dbaccess/source/ui/app/subcomponentmanager.cxx +++ b/dbaccess/source/ui/app/subcomponentmanager.cxx @@ -36,6 +36,8 @@ #include <com/sun/star/frame/XModel2.hpp> #include <com/sun/star/util/XCloseable.hpp> #include <com/sun/star/awt/XTopWindow.hpp> +#include <com/sun/star/embed/XComponentSupplier.hpp> +#include <com/sun/star/ucb/XCommandProcessor.hpp> #include <com/sun/star/document/XDocumentEventBroadcaster.hpp> /** === end UNO includes === **/ @@ -73,6 +75,9 @@ namespace dbaui using ::com::sun::star::container::XEnumeration; using ::com::sun::star::util::XCloseable; using ::com::sun::star::awt::XTopWindow; + using ::com::sun::star::embed::XComponentSupplier; + using ::com::sun::star::ucb::XCommandProcessor; + using ::com::sun::star::ucb::Command; using ::com::sun::star::document::XDocumentEventBroadcaster; /** === end UNO using === **/ @@ -84,11 +89,13 @@ namespace dbaui struct SubComponentDescriptor { /// the frame which the component resides in. Must not be <NULL/> - Reference< XFrame > xFrame; + Reference< XFrame > xFrame; /// the controller of the sub component. Must not be <NULL/> - Reference< XController > xController; + Reference< XController > xController; /// the model of the sub component. Might be <NULL/> - Reference< XModel > xModel; + Reference< XModel > xModel; + /// the document definition which holds the component, if any + Reference< XCommandProcessor > xComponentCommandProcessor; SubComponentDescriptor() :xFrame() @@ -99,28 +106,53 @@ namespace dbaui SubComponentDescriptor( const Reference< XComponent >& _rxComponent ) { - xModel.set( _rxComponent, UNO_QUERY ); + if ( !impl_constructFrom( _rxComponent ) ) + { + Reference< XComponentSupplier > xCompSupp( _rxComponent, UNO_QUERY_THROW ); + Reference< XComponent > xComponent( xCompSupp->getComponent(), UNO_QUERY_THROW ); + if ( !impl_constructFrom( xComponent ) ) + throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Illegal component type." ) ), NULL ); + xComponentCommandProcessor.set( _rxComponent, UNO_QUERY_THROW ); + } + } + + inline bool is() const { return xFrame.is(); } + private: + bool impl_constructFrom( const Reference< XComponent >& _rxComponent ) + { + // is it a model? + xModel.set( _rxComponent, UNO_QUERY ); if ( xModel.is() ) + { xController.set( xModel->getCurrentController(), UNO_SET_THROW ); - else - xController.set( _rxComponent, UNO_QUERY ); - - if ( xController.is() ) xFrame.set( xController->getFrame(), UNO_SET_THROW ); + } else - xFrame.set( _rxComponent, UNO_QUERY_THROW ); + { + // is it a controller? + xController.set( _rxComponent, UNO_QUERY ); + if ( xController.is() ) + { + xFrame.set( xController->getFrame(), UNO_SET_THROW ); + } + else + { + // is it a frame? + xFrame.set( _rxComponent, UNO_QUERY ); + if ( !xFrame.is() ) + return false; - // if the given component was a frame, then ensure we have a controller - if ( xFrame.is() && !xController.is() ) - xController.set( xFrame->getController(), UNO_SET_THROW ); + // ensure we have a controller + xController.set( xFrame->getController(), UNO_SET_THROW ); + } - // if the component was a frame or a controller, then check wether there is a model (not required) - if ( !xModel.is() ) + // check wether there is a model (not required) xModel.set( xController->getModel() ); - } + } - inline bool is() const { return xFrame.is(); } + return true; + } }; struct SelectSubComponent : public ::std::unary_function< SubComponentDescriptor, Reference< XComponent > > @@ -260,8 +292,32 @@ namespace dbaui } //---------------------------------------------------------------- + bool lcl_closeComponent( const Reference< XCommandProcessor >& _rxCommandProcessor ) + { + bool bSuccess = false; + try + { + Reference< XCommandProcessor > xCommandProcessor( _rxCommandProcessor, UNO_SET_THROW ); + sal_Int32 nCommandIdentifier = xCommandProcessor->createCommandIdentifier(); + + Command aCommand; + aCommand.Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "close" ) ); + xCommandProcessor->execute( aCommand, nCommandIdentifier, NULL ); + bSuccess = true; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return bSuccess; + } + + //---------------------------------------------------------------- bool lcl_closeComponent( const SubComponentDescriptor& _rComponent ) { + if ( _rComponent.xComponentCommandProcessor.is() ) + return lcl_closeComponent( _rComponent.xComponentCommandProcessor ); + Reference< XController > xController( _rComponent.xController ); OSL_ENSURE( xController.is(), "lcl_closeComponent: invalid controller!" ); diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx index fad75416bb3c..a9c757a3cf70 100644 --- a/dbaccess/source/ui/control/FieldDescControl.cxx +++ b/dbaccess/source/ui/control/FieldDescControl.cxx @@ -37,111 +37,44 @@ #define ITEMID_LINEBREAK SID_ATTR_ALIGN_LINEBREAK #define ITEMID_MARGIN SID_ATTR_ALIGN_MARGIN -#ifndef DBAUI_FIELDDESCRIPTIONCONTROL_HXX #include "FieldDescControl.hxx" -#endif -#ifndef DBAUI_FIELDCONTROLS_HXX #include "FieldControls.hxx" -#endif -#ifndef _ZFORLIST_HXX //autogen -#define _ZFORLIST_DECLARE_TABLE // ohne das bekomme ich einen Compiler-Fehler in <svtools/zforlist.hxx> -#include <svtools/zforlist.hxx> -#endif -#ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> -#endif -#ifndef DBAUI_TABLEDESIGNHELPBAR_HXX +#include <tools/diagnose_ex.h> #include "TableDesignHelpBar.hxx" -#endif -#ifndef _SV_SCRBAR_HXX #include <vcl/scrbar.hxx> -#endif -#ifndef _SV_BUTTON_HXX #include <vcl/button.hxx> -#endif -#ifndef _SVX_NUMFMTSH_HXX -#include <svx/numfmtsh.hxx> -#endif -#ifndef _DBU_CONTROL_HRC_ -#include "dbu_control.hrc" -#endif -#ifndef _DBU_TBL_HRC_ -#include "dbu_tbl.hrc" -#endif - -#ifndef _SV_SVAPP_HXX #include <vcl/svapp.hxx> -#endif -#ifndef _SV_FIXED_HXX #include <vcl/fixed.hxx> -#endif -#ifndef _SV_MSGBOX_HXX #include <vcl/msgbox.hxx> -#endif -#ifndef _VECTOR_ #include <vector> -#endif -#ifndef DBAUI_FIELDDESCRIPTIONS_HXX #include "FieldDescriptions.hxx" -#endif -#ifndef _SFXITEMPOOL_HXX -#include <svtools/itempool.hxx> -#endif -#ifndef DBAUI_SBATTRDLG_HXX #include "dlgattr.hxx" -#endif -#ifndef _SVX_SVXIDS_HRC +#include <svx/numfmtsh.hxx> #include <svx/svxids.hrc> -#endif -#ifndef _SVX_ALGITEM_HXX #include <svx/algitem.hxx> -#endif -#ifndef _SFXRNGITEM_HXX +#include <svtools/itempool.hxx> +#define _ZFORLIST_DECLARE_TABLE // ohne das bekomme ich einen Compiler-Fehler in <svtools/zforlist.hxx> +#include <svtools/zforlist.hxx> #include <svtools/rngitem.hxx> -#endif -#ifndef _SFXINTITEM_HXX #include <svtools/intitem.hxx> -#endif -#ifndef _COM_SUN_STAR_LANG_XUNOTUNNEL_HPP_ +#include <svtools/numuno.hxx> +#include <svtools/transfer.hxx> #include <com/sun/star/lang/XUnoTunnel.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_ #include <com/sun/star/util/NumberFormat.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATPREVIEWER_HPP_ #include <com/sun/star/util/XNumberFormatPreviewer.hpp> -#endif -#ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_ #include <com/sun/star/util/XNumberFormatTypes.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ #include <com/sun/star/beans/XPropertySet.hpp> -#endif -#ifndef DBAUI_ENUMTYPES_HXX #include "QEnumTypes.hxx" -#endif -#ifndef _DBA_DBACCESS_HELPID_HRC_ #include "dbaccess_helpid.hrc" -#endif -#ifndef _NUMUNO_HXX -#include <svtools/numuno.hxx> -#endif -#ifndef _CONNECTIVITY_DBTOOLS_HXX_ #include <connectivity/dbtools.hxx> -#endif -#ifndef _COMPHELPER_NUMBERS_HXX_ +#include <connectivity/dbconversion.hxx> #include <comphelper/numbers.hxx> -#endif -#ifndef DBAUI_TOOLS_HXX #include "UITools.hxx" -#endif #include <memory> -#ifndef _DBHELPER_DBCONVERSION_HXX_ -#include <connectivity/dbconversion.hxx> -#endif -#ifndef _TRANSFER_HXX -#include <svtools/transfer.hxx> -#endif +#include "dbu_control.hrc" +#include "dbu_tbl.hrc" + using namespace dbaui; using namespace dbtools; @@ -156,7 +89,6 @@ 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_HEIGHT 10 #define CONTROL_WIDTH_1 160 // 100 #define CONTROL_WIDTH_2 100 // 60 #define CONTROL_WIDTH_3 250 @@ -185,6 +117,20 @@ namespace 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; + } + } + } //================================================================== @@ -241,22 +187,7 @@ OFieldDescControl::OFieldDescControl( Window* pParent, const ResId& rResId, OTab { DBG_CTOR(OFieldDescControl,NULL); - 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; + Contruct(); } //------------------------------------------------------------------------------ OFieldDescControl::OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHelpBar ) @@ -305,7 +236,11 @@ OFieldDescControl::OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHel ,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)); @@ -322,7 +257,6 @@ OFieldDescControl::OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHel m_pHorzScroll->SetPageSize(1); m_nOldVThumb = m_nOldHThumb = 0; - } //------------------------------------------------------------------------------ @@ -451,7 +385,7 @@ void OFieldDescControl::CheckScrollBars() sal_uInt16 nActive = CountActiveAggregates(); // welches ist das letzte, was ganz drauf passt ? sal_uInt16 nLastVisible; - const sal_Int32 nControlHeight = LogicToPixel(Size(0, CONTROL_HEIGHT),MAP_APPFONT).Height(); + 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)); @@ -536,7 +470,7 @@ void OFieldDescControl::ScrollAllAggregates() if (m_nOldVThumb != m_pVertScroll->GetThumbPos()) { - const sal_Int32 nControlHeight = LogicToPixel(Size(0, CONTROL_HEIGHT),MAP_APPFONT).Height(); + 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(); @@ -573,7 +507,23 @@ sal_uInt16 OFieldDescControl::CountActiveAggregates() const ++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 ) { @@ -909,7 +859,8 @@ void OFieldDescControl::ArrangeAggregates() // die Z-Order so, dass die Controls auch wirklich in derselben Reihenfolge durchwandert werden koennen, in der sie // hier angeordnet wurden - adAggregates[i].pctrlInputControl->SetZOrder(pZOrderPredecessor, pZOrderPredecessor ? WINDOW_ZORDER_BEHIND : WINDOW_ZORDER_FIRST); + 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) @@ -947,36 +898,18 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) if( pDefault ) return; m_nPos++; - pDefaultText =new FixedText( this ); - pDefaultText->SetText( ModuleRes(STR_DEFAULT_VALUE) ); + pDefaultText = CreateText(STR_DEFAULT_VALUE); pDefault = new OPropEditCtrl( this, STR_HELP_DEFAULT_VALUE, FIELD_PROPERTY_DEFAULT, WB_BORDER ); - pDefault->SetHelpId(HID_TAB_ENT_DEFAULT); - // SetPosSize( (Control**)&pDefaultText, m_nPos, 0 ); - // SetPosSize( (Control**)&pDefault, m_nPos, 3 ); - - pDefault->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pDefault->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pDefaultText->EnableClipSiblings(); - pDefault->EnableClipSiblings(); + InitializeControl(pDefault,HID_TAB_ENT_DEFAULT,false); break; case tpAutoIncrementValue: if( m_pAutoIncrementValue || !isAutoIncrementValueEnabled() ) return; m_nPos++; - m_pAutoIncrementValueText =new FixedText( this ); - m_pAutoIncrementValueText->SetText( ModuleRes(STR_AUTOINCREMENT_VALUE) ); + m_pAutoIncrementValueText = CreateText(STR_AUTOINCREMENT_VALUE); m_pAutoIncrementValue = new OPropEditCtrl( this, STR_HELP_AUTOINCREMENT_VALUE, FIELD_PRPOERTY_AUTOINCREMENT, WB_BORDER ); - m_pAutoIncrementValue->SetHelpId(HID_TAB_AUTOINCREMENTVALUE); - // SetPosSize( (Control**)&m_pAutoIncrementValueText, m_nPos, 0 ); - // SetPosSize( (Control**)&m_pAutoIncrementValue, m_nPos, 3 ); - - m_pAutoIncrementValue->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - m_pAutoIncrementValue->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - m_pAutoIncrementValueText->EnableClipSiblings(); - m_pAutoIncrementValue->EnableClipSiblings(); m_pAutoIncrementValue->SetText( getAutoIncrementValue() ); + InitializeControl(m_pAutoIncrementValue,HID_TAB_AUTOINCREMENTVALUE,false); break; case tpRequired: @@ -988,21 +921,14 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) if(xMetaData.is() && xMetaData->supportsNonNullableColumns()) { m_nPos++; - pRequiredText =new FixedText( this ); - pRequiredText->SetText( ModuleRes(STR_FIELD_REQUIRED) ); + pRequiredText = CreateText(STR_FIELD_REQUIRED); pRequired = new OPropListBoxCtrl( this, STR_HELP_FIELD_REQUIRED, FIELD_PROPERTY_REQUIRED, WB_DROPDOWN); - pRequired->SetHelpId(HID_TAB_ENT_REQUIRED); pRequired->InsertEntry( aYes ); pRequired->InsertEntry( aNo ); pRequired->SelectEntryPos(1); - pRequired->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl)); - - pRequired->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pRequired->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - pRequiredText->EnableClipSiblings(); - pRequired->EnableClipSiblings(); + InitializeControl(pRequired,HID_TAB_ENT_REQUIRED,true); } } break; @@ -1011,53 +937,28 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) if( pAutoIncrement ) return; m_nPos++; - pAutoIncrementText =new FixedText( this ); - pAutoIncrementText->SetText( ModuleRes(STR_FIELD_AUTOINCREMENT) ); + pAutoIncrementText = CreateText(STR_FIELD_AUTOINCREMENT); pAutoIncrement = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PROPERTY_AUTOINC, WB_DROPDOWN ); - pAutoIncrement->SetHelpId(HID_TAB_ENT_AUTOINCREMENT); - pAutoIncrement->InsertEntry( aYes ); pAutoIncrement->InsertEntry( aNo ); pAutoIncrement->SelectEntryPos(0); - pAutoIncrement->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl)); - - pAutoIncrement->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pAutoIncrement->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pAutoIncrementText->EnableClipSiblings(); - pAutoIncrement->EnableClipSiblings(); + InitializeControl(pAutoIncrement,HID_TAB_ENT_AUTOINCREMENT,true); } break; case tpTextLen: if( pTextLen ) return; m_nPos++; - pTextLenText =new FixedText( this ); - pTextLenText->SetText( ModuleRes(STR_TEXT_LENGTH) ); - - pTextLen = new OPropNumericEditCtrl( this, STR_HELP_TEXT_LENGTH, FIELD_PROPERTY_TEXTLEN, WB_BORDER ); - pTextLen->SetDecimalDigits(0); - pTextLen->SetMin(0); - pTextLen->SetMax(0x7FFFFFFF); // soll draussen geaendert werden, wenn noetig - pTextLen->SetStrictFormat(TRUE); - - pTextLen->SetHelpId(HID_TAB_ENT_TEXT_LEN); - - pTextLen->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pTextLen->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pTextLenText->EnableClipSiblings(); - pTextLen->EnableClipSiblings(); + 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 =new FixedText( this ); - m_pTypeText->SetText( ModuleRes(STR_TAB_FIELD_DATATYPE) ); + m_pTypeText = CreateText(STR_TAB_FIELD_DATATYPE); m_pType = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PRPOERTY_TYPE, WB_DROPDOWN ); - m_pType->SetHelpId(HID_TAB_ENT_TYPE); m_pType->SetDropDownLineCount(20); { const OTypeInfoMap* pTypeInfo = getTypeInfo(); @@ -1066,50 +967,48 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) m_pType->InsertEntry( aIter->second->aUIName ); } m_pType->SelectEntryPos(0); - m_pType->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl)); - - m_pType->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - m_pType->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - m_pTypeText->EnableClipSiblings(); - m_pType->EnableClipSiblings(); + InitializeControl(m_pType,HID_TAB_ENT_TYPE,true); break; case tpColumnName: if( m_pColumnName ) return; m_nPos++; { - Reference< XDatabaseMetaData> xMetaData = getMetaData(); - sal_uInt32 nMax = xMetaData.is() ? xMetaData->getMaxColumnNameLength() : EDIT_NOLIMIT; - m_pColumnNameText =new FixedText( this ); - m_pColumnNameText->SetText( ModuleRes(STR_TAB_FIELD_NAME) ); - ::rtl::OUString aTmpString( xMetaData.is() ? xMetaData->getExtraNameCharacters() : ::rtl::OUString() ); + 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->SetHelpId(HID_TAB_ENT_COLUMNNAME); m_pColumnName->SetMaxTextLen(xub_StrLen( nMax ? nMax : EDIT_NOLIMIT)); m_pColumnName->setCheck( isSQL92CheckEnabled(getConnection()) ); } - m_pColumnName->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - m_pColumnName->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - m_pColumnNameText->EnableClipSiblings(); - m_pColumnName->EnableClipSiblings(); + InitializeControl(m_pColumnName,HID_TAB_ENT_COLUMNNAME,false); break; case tpNumType: if( pNumType ) return; m_nPos++; - pNumTypeText =new FixedText( this ); - pNumTypeText->SetText( ModuleRes(STR_NUMERIC_TYPE) ); + pNumTypeText = CreateText(STR_NUMERIC_TYPE); pNumType = new OPropListBoxCtrl( this, STR_HELP_NUMERIC_TYPE, FIELD_PROPERTY_NUMTYPE, WB_DROPDOWN ); pNumType->SetDropDownLineCount(5); - pNumType->SetHelpId(HID_TAB_ENT_NUMTYP); pNumType->InsertEntry( String::CreateFromAscii("Byte") ); pNumType->InsertEntry( String::CreateFromAscii("SmallInt") ); @@ -1117,84 +1016,41 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) pNumType->InsertEntry( String::CreateFromAscii("Single") ); pNumType->InsertEntry( String::CreateFromAscii("Double") ); pNumType->SelectEntryPos(2); - pNumType->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl)); - - pNumType->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pNumType->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pNumTypeText->EnableClipSiblings(); - pNumType->EnableClipSiblings(); + InitializeControl(pNumType,HID_TAB_ENT_NUMTYP,true); break; case tpLength: if( pLength ) return; m_nPos++; - pLengthText =new FixedText( this ); - pLengthText->SetText( ModuleRes(STR_LENGTH) ); - - pLength = new OPropNumericEditCtrl( this, STR_HELP_LENGTH, FIELD_PROPERTY_LENGTH, WB_BORDER ); - pLength->SetDecimalDigits(0); - pLength->SetMin(0); - pLength->SetMax(0x7FFFFFFF); // soll draussen geaendert werden, wenn noetig - pLength->SetStrictFormat(TRUE); - - pLength->SetHelpId(HID_TAB_ENT_LEN); - - pLength->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pLength->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pLengthText->EnableClipSiblings(); - pLength->EnableClipSiblings(); + 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 =new FixedText( this ); - pScaleText->SetText( ModuleRes(STR_SCALE) ); - pScale = new OPropNumericEditCtrl( this, STR_HELP_SCALE, FIELD_PROPERTY_SCALE, WB_BORDER ); - pScale->SetDecimalDigits(0); - pScale->SetMin(0); - pScale->SetMax(0x7FFFFFFF); // soll draussen geaendert werden, wenn noetig - pScale->SetStrictFormat(TRUE); - - pScale->SetHelpId(HID_TAB_ENT_SCALE); - - pScale->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pScale->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pScaleText->EnableClipSiblings(); - pScale->EnableClipSiblings(); + pScaleText = CreateText(STR_SCALE); + pScale = CreateNumericControl(STR_HELP_SCALE, FIELD_PROPERTY_SCALE,HID_TAB_ENT_SCALE); break; case tpFormat: if (!pFormat) { m_nPos++; - pFormatText =new FixedText( this ); - pFormatText->SetText( ModuleRes(STR_FORMAT) ); + pFormatText = CreateText(STR_FORMAT); pFormatSample = new OPropEditCtrl( this, STR_HELP_FORMAT_CODE, -1, WB_BORDER ); - pFormatSample->SetHelpId(HID_TAB_ENT_FORMAT_SAMPLE); pFormatSample->SetReadOnly(sal_True); pFormatSample->Enable(sal_False); + InitializeControl(pFormatSample,HID_TAB_ENT_FORMAT_SAMPLE,false); pFormat = new PushButton( this, ModuleRes(PB_FORMAT) ); - pFormat->SetHelpId(HID_TAB_ENT_FORMAT); - const sal_Int32 nControlHeight = LogicToPixel(Size(0, CONTROL_HEIGHT),MAP_APPFONT).Height(); + const sal_Int32 nControlHeight = GetMaxControlHeight(); pFormat->SetSizePixel(Size(nControlHeight, nControlHeight)); pFormat->SetClickHdl( LINK( this, OFieldDescControl, FormatClickHdl ) ); - - pFormatSample->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pFormatSample->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - pFormat->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pFormat->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pFormatText->EnableClipSiblings(); - pFormatSample->EnableClipSiblings(); - pFormat->EnableClipSiblings(); + InitializeControl(pFormat,HID_TAB_ENT_FORMAT,false); } UpdateFormatSample(pActFieldDescr); @@ -1204,25 +1060,49 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) return; m_nPos++; - pBoolDefaultText =new FixedText(this); - pBoolDefaultText->SetText(ModuleRes(STR_DEFAULT_VALUE)); + 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); - pBoolDefault->SetHelpId(HID_TAB_ENT_BOOL_DEFAULT); - pBoolDefault->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); - pBoolDefault->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); - - pBoolDefaultText->EnableClipSiblings(); - pBoolDefault->EnableClipSiblings(); + 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 ) { @@ -1233,150 +1113,58 @@ void OFieldDescControl::DeactivateAggregate( EControlType eType ) switch( eType ) { case tpDefault: - if( !pDefault ) - return; - m_nPos--; - pDefault->Hide(); - pDefaultText->Hide(); - delete pDefault; - delete pDefaultText; - pDefault = NULL; - pDefaultText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pDefault,&pDefaultText); break; case tpAutoIncrementValue: - if( !m_pAutoIncrementValue ) - return; - m_nPos--; - m_pAutoIncrementValue->Hide(); - m_pAutoIncrementValueText->Hide(); - delete m_pAutoIncrementValue; - delete m_pAutoIncrementValueText; - m_pAutoIncrementValue = NULL; - m_pAutoIncrementValueText =NULL; + lcl_HideAndDeleteControl(m_nPos,&m_pAutoIncrementValue,&m_pAutoIncrementValueText); break; case tpColumnName: - if( !m_pColumnName ) - return; - m_nPos--; - m_pColumnName->Hide(); - m_pColumnNameText->Hide(); - delete m_pColumnName; - delete m_pColumnNameText; - m_pColumnName = NULL; - m_pColumnNameText =NULL; + lcl_HideAndDeleteControl(m_nPos,&m_pColumnName,&m_pColumnNameText); break; case tpType: - if( !m_pType ) - return; - m_nPos--; - m_pType->Hide(); - m_pTypeText->Hide(); - delete m_pType; - delete m_pTypeText; - m_pType = NULL; - m_pTypeText =NULL; + lcl_HideAndDeleteControl(m_nPos,&m_pType,&m_pTypeText); break; case tpAutoIncrement: - if( !pAutoIncrement ) - return; - m_nPos--; - pAutoIncrement->Hide(); - pAutoIncrementText->Hide(); - delete pAutoIncrement; - delete pAutoIncrementText; - pAutoIncrement = NULL; - pAutoIncrementText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pAutoIncrement,&pAutoIncrementText); break; case tpRequired: - if( !pRequired ) - return; - m_nPos--; - pRequired->Hide(); - pRequiredText->Hide(); - delete pRequired; - delete pRequiredText; - pRequired = NULL; - pRequiredText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pRequired,&pRequiredText); break; case tpTextLen: - if( !pTextLen ) - return; - m_nPos--; - pTextLen->Hide(); - pTextLenText->Hide(); - delete pTextLen; - delete pTextLenText; - pTextLen = NULL; - pTextLenText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pTextLen,&pTextLenText); break; case tpNumType: - if( !pNumType ) - return; - m_nPos--; - pNumType->Hide(); - pNumTypeText->Hide(); - delete pNumType; - delete pNumTypeText; - pNumType = NULL; - pNumTypeText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pNumType,&pNumTypeText); break; case tpLength: - if( !pLength ) - return; - m_nPos--; - pLength->Hide(); - pLengthText->Hide(); - delete pLength; - delete pLengthText; - pLength = NULL; - pLengthText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pLength,&pLengthText); break; case tpScale: - if( !pScale ) - return; - m_nPos--; - pScale->Hide(); - pScaleText->Hide(); - delete pScale; - delete pScaleText; - pScale = NULL; - pScaleText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pScale,&pScaleText); break; case tpFormat: - if( !pFormat ) - return; - pFormatText->Hide(); - pFormatSample->Hide(); - pFormat->Hide(); - delete pFormatText; - delete pFormatSample; - delete pFormat; - pFormatText =NULL; - pFormatSample = NULL; - pFormat = NULL; + // 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: - if (!pBoolDefault) - return; - m_nPos--; - pBoolDefault->Hide(); - pBoolDefaultText->Hide(); - delete pBoolDefault; - delete pBoolDefaultText; - pBoolDefault = NULL; - pBoolDefaultText =NULL; + lcl_HideAndDeleteControl(m_nPos,&pBoolDefault,&pBoolDefaultText); break; - } } @@ -1387,48 +1175,28 @@ void OFieldDescControl::SetPosSize( Control** ppControl, long nRow, sal_uInt16 n ////////////////////////////////////////////////////////////////////// // Groesse ermitteln - const sal_Int32 nControlHeight = LogicToPixel(Size(0, CONTROL_HEIGHT),MAP_APPFONT).Height(); - Size aSize; - switch( nCol ) + const sal_Int32 nControlHeight = GetMaxControlHeight(); + Size aSize(0,nControlHeight); + if ( isRightAligned() && nCol ) + aSize.Width() = LogicToPixel(Size(m_nWidth, 0),MAP_APPFONT).Width(); + else { - case 0: - aSize.Width() = CONTROL_WIDTH_1; - aSize.Height() = nControlHeight; - break; - case 1: - if ( isRightAligned() ) - aSize.Width() = LogicToPixel(Size(m_nWidth, 0),MAP_APPFONT).Width(); - else - aSize.Width() = CONTROL_WIDTH_2; - aSize.Height() = nControlHeight; - break; - case 2: - if ( isRightAligned() ) - 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; - aSize.Height() = long(1.5*nControlHeight); - break; - case 3: - if ( isRightAligned() ) - aSize.Width() = LogicToPixel(Size(m_nWidth, 0),MAP_APPFONT).Width(); - else + break; + case 3: aSize.Width() = CONTROL_WIDTH_3; - aSize.Height() = nControlHeight; - break; - case 4: - if ( isRightAligned() ) - aSize.Width() = LogicToPixel(Size(m_nWidth, 0),MAP_APPFONT).Width(); - else + break; + case 4: aSize.Width() = CONTROL_WIDTH_4; - aSize.Height() = nControlHeight; - break; - default: - if ( isRightAligned() ) - aSize.Width() = LogicToPixel(Size(m_nWidth, 0),MAP_APPFONT).Width(); - else - aSize.Width() = CONTROL_WIDTH_1; - aSize.Height() = nControlHeight; + break; + } // switch( nCol ) } @@ -1442,7 +1210,6 @@ void OFieldDescControl::SetPosSize( Control** ppControl, long nRow, sal_uInt16 n aPosition.Y() = 1; break; case 1: - case 2: case 3: case 4: if ( isRightAligned() ) @@ -1965,12 +1732,8 @@ void OFieldDescControl::SaveData( OFieldDescription* pFieldDescr ) //------------------------------------------------------------------------------ void OFieldDescControl::UpdateFormatSample(OFieldDescription* pFieldDescr) { - if(!pFieldDescr) - return; - if(!pFormatSample) - return; - - pFormatSample->SetText(getControlDefault(pFieldDescr,sal_False)); + if ( pFieldDescr && pFormatSample ) + pFormatSample->SetText(getControlDefault(pFieldDescr,sal_False)); } //------------------------------------------------------------------------------ @@ -2169,8 +1932,3 @@ String OFieldDescControl::getControlDefault( const OFieldDescription* _pFieldDes return sDefault; } // ----------------------------------------------------------------------------- - - - - - diff --git a/dbaccess/source/ui/control/opendoccontrols.cxx b/dbaccess/source/ui/control/opendoccontrols.cxx index c65285cf414a..5b089f764337 100644 --- a/dbaccess/source/ui/control/opendoccontrols.cxx +++ b/dbaccess/source/ui/control/opendoccontrols.cxx @@ -300,14 +300,10 @@ namespace dbaui aURL.SetPass( sPassword ); if ( !sTitle.Len() ) - sTitle = aURL.getName(); + sTitle = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_UNAMBIGUOUS ); String sDecodedURL = aURL.GetMainURL( INetURLObject::NO_DECODE ); -// sTitle.AppendAscii( " (" ); -// sTitle += String( ::svt::OFileNotation( sDecodedURL ).get( ::svt::OFileNotation::N_SYSTEM ) ); -// sTitle.AppendAscii( ")" ); - USHORT nPos = InsertEntry( sTitle ); m_aURLs.insert( MapIndexToStringPair::value_type( nPos, StringPair( sDecodedURL, sFilter ) ) ); } diff --git a/dbaccess/source/ui/dlg/UserAdmin.hxx b/dbaccess/source/ui/dlg/UserAdmin.hxx index 57c7a59a140c..b4eae1591b3d 100644 --- a/dbaccess/source/ui/dlg/UserAdmin.hxx +++ b/dbaccess/source/ui/dlg/UserAdmin.hxx @@ -79,7 +79,6 @@ protected: ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xUsers; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_xORB; ::com::sun::star::uno::Sequence< ::rtl::OUString> m_aUserNames; String m_UserName; @@ -93,8 +92,6 @@ protected: OUserAdmin( Window* pParent, const SfxItemSet& _rCoreAttrs); public: - void setServiceFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xORB) { m_xORB = _xORB; } - static SfxTabPage* Create( Window* pParent, const SfxItemSet& _rAttrSet ); ~OUserAdmin(); diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 80b8b389c45a..6df5537544a4 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -316,7 +316,7 @@ ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(Window* _pParent if (pCollectionItem) m_pCollection = pCollectionItem->getCollection(); - DBG_ASSERT(m_pCollection, "OGeneralPage::OGeneralPage : really need a DSN type collection !"); + DBG_ASSERT(m_pCollection, "ODbTypeWizDialogSetup::ODbTypeWizDialogSetup : really need a DSN type collection !"); FreeResource(); diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx index bd5a4c1e6392..cc8f01dd4daf 100644 --- a/dbaccess/source/ui/dlg/sqlmessage.cxx +++ b/dbaccess/source/ui/dlg/sqlmessage.cxx @@ -258,6 +258,14 @@ namespace ExceptionDisplayInfo( SQLExceptionInfo::TYPE _eType ) : eType( _eType ), bSubEntry( false ) { } }; + static bool lcl_hasDetails( const ExceptionDisplayInfo& _displayInfo ) + { + return ( _displayInfo.sErrorCode.Len() ) + || ( _displayInfo.sSQLState.Len() + && !_displayInfo.sSQLState.EqualsAscii( "S1000" ) + ); + } + typedef ::std::vector< ExceptionDisplayInfo > ExceptionDisplayChain; //------------------------------------------------------------------------------ @@ -303,11 +311,19 @@ namespace ExceptionDisplayInfo aDisplayInfo( aCurrentElement.getType() ); - aDisplayInfo.sMessage = pCurrentError->Message; + aDisplayInfo.sMessage = pCurrentError->Message.trim(); aDisplayInfo.sSQLState = pCurrentError->SQLState; if ( pCurrentError->ErrorCode ) aDisplayInfo.sErrorCode = String::CreateFromInt32( pCurrentError->ErrorCode ); + if ( !aDisplayInfo.sMessage.Len() + && !lcl_hasDetails( aDisplayInfo ) + ) + { + OSL_ENSURE( false, "lcl_buildExceptionChain: useles exception: no state, no error code, no message!" ); + continue; + } + aDisplayInfo.pImageProvider = _rFactory.getImageProvider( aCurrentElement.getType() ); aDisplayInfo.pLabelProvider = _rFactory.getLabelProvider( aCurrentElement.getType(), false ); @@ -685,7 +701,25 @@ void OSQLMessageBox::impl_createStandardButtons( WinBits _nStyle ) void OSQLMessageBox::impl_addDetailsButton() { size_t nFirstPageVisible = m_aMessage.IsVisible() ? 2 : 1; + bool bMoreDetailsAvailable = m_pImpl->aDisplayInfo.size() > nFirstPageVisible; + if ( !bMoreDetailsAvailable ) + { + // even if the text fits into what we can display, we might need to details button + // if there is more non-trivial information in the errors than the mere messages + for ( ExceptionDisplayChain::const_iterator error = m_pImpl->aDisplayInfo.begin(); + error != m_pImpl->aDisplayInfo.end(); + ++error + ) + { + if ( lcl_hasDetails( *error ) ) + { + bMoreDetailsAvailable = true; + break; + } + } + } + if ( bMoreDetailsAvailable ) { AddButton( BUTTON_MORE, BUTTONID_MORE, 0 ); diff --git a/dbaccess/source/ui/inc/FieldDescControl.hxx b/dbaccess/source/ui/inc/FieldDescControl.hxx index ca0e411a09cd..c77942cd71c0 100644 --- a/dbaccess/source/ui/inc/FieldDescControl.hxx +++ b/dbaccess/source/ui/inc/FieldDescControl.hxx @@ -160,6 +160,10 @@ namespace dbaui void ScrollAllAggregates(); sal_Bool isTextFormat(const OFieldDescription* _pFieldDescr,sal_uInt32& _nFormatKey) const; + void Contruct(); + OPropNumericEditCtrl* CreateNumericControl(USHORT _nHelpStr,short _nProperty,ULONG _nHelpId); + FixedText* CreateText(USHORT _nTextRes); + void InitializeControl(Control* _pControl,ULONG _nHelpId,bool _bAddChangeHandler); protected: inline void setRightAligned() { m_bRightAligned = true; } @@ -169,7 +173,8 @@ namespace dbaui inline OFieldDescription* getCurrentFieldDescData() { return pActFieldDescr; } inline void setCurrentFieldDescData( OFieldDescription* _pDesc ) { pActFieldDescr = _pDesc; } - USHORT CountActiveAggregates() const; + sal_uInt16 CountActiveAggregates() const; + sal_Int32 GetMaxControlHeight() const; virtual void ActivateAggregate( EControlType eType ); virtual void DeactivateAggregate( EControlType eType ); diff --git a/dbaccess/source/ui/inc/FieldDescriptions.hxx b/dbaccess/source/ui/inc/FieldDescriptions.hxx index 7b54d2617bc3..ee473b032853 100644 --- a/dbaccess/source/ui/inc/FieldDescriptions.hxx +++ b/dbaccess/source/ui/inc/FieldDescriptions.hxx @@ -123,6 +123,7 @@ namespace dbaui sal_Int32 GetFormatKey() const; SvxCellHorJustify GetHorJustify() const; TOTypeInfoSP getTypeInfo() const; + TOTypeInfoSP getSpecialTypeInfo() const; sal_Bool IsAutoIncrement() const; sal_Bool IsPrimaryKey() const; sal_Bool IsCurrency() const; diff --git a/dbaccess/source/ui/inc/dbu_rel.hrc b/dbaccess/source/ui/inc/dbu_rel.hrc index 1e0e2f3423da..c8d224cbdcad 100644 --- a/dbaccess/source/ui/inc/dbu_rel.hrc +++ b/dbaccess/source/ui/inc/dbu_rel.hrc @@ -41,9 +41,10 @@ #define STR_QUERY_REL_DELETE_WINDOW RID_STR_REL_START + 3 #define STR_QUERY_REL_EDIT RID_STR_REL_START + 4 #define STR_QUERY_REL_CREATE RID_STR_REL_START + 5 +#define STR_QUERY_REL_COULD_NOT_CREATE RID_STR_REL_START + 6 // please adjust checking before insert new strings -#if STR_QUERY_REL_DELETE_WINDOW > RID_STR_REL_END +#if STR_QUERY_REL_COULD_NOT_CREATE > RID_STR_REL_END #error Resource-Id Ueberlauf in #file, #line #endif diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx index dc71f6588828..880bb91b3727 100644 --- a/dbaccess/source/ui/misc/DExport.cxx +++ b/dbaccess/source/ui/misc/DExport.cxx @@ -234,7 +234,7 @@ ODatabaseExport::ODatabaseExport(const SharedConnection& _rxConnection, sal_Int32 nType = aValue; ++nPos; - if( nType == DataType::VARCHAR) + if( nType == DataType::VARCHAR ) { m_pTypeInfo = TOTypeInfoSP(new OTypeInfo()); @@ -291,7 +291,9 @@ ODatabaseExport::ODatabaseExport(const SharedConnection& _rxConnection, break; } } - } + } // if(xSet.is()) + if ( !m_pTypeInfo ) + m_pTypeInfo = TOTypeInfoSP(new OTypeInfo()); SetColumnTypes(pList,_pInfoMap); } //--------------------------------------------------------------------------- @@ -432,10 +434,11 @@ sal_Int16 ODatabaseExport::CheckString(const String& aCheckToken, sal_Int16 _nOl if ( m_pFormatter && m_sNumToken.Len() ) { LanguageType eNumLang; - sal_uInt32 nNumberFormat2; - fOutNumber = SfxHTMLParser::GetTableDataOptionsValNum(nNumberFormat2,eNumLang,m_sTextToken,m_sNumToken,*m_pFormatter); + sal_uInt32 nFormatKey; + fOutNumber = SfxHTMLParser::GetTableDataOptionsValNum(nFormatKey,eNumLang,m_sTextToken,m_sNumToken,*m_pFormatter); //double fOutNumber2 = SfxHTMLParser::GetTableDataOptionsValNum(nNumberFormat2,eNumLang,m_sValToken,m_sNumToken,*m_pFormatter); - nNumberFormat = static_cast<sal_Int16>(nNumberFormat2); + Reference<XPropertySet> xProp = xFormats->getByKey(nFormatKey); + xProp->getPropertyValue(PROPERTY_TYPE) >>= nNumberFormat; } else { @@ -559,16 +562,15 @@ void ODatabaseExport::SetColumnTypes(const TColumnVector* _pList,const OTypeInfo DBG_CHKTHIS(ODatabaseExport,NULL); if(_pList && _pInfoMap) { + OSL_ENSURE(m_vNumberFormat.size() == m_vColumnSize.size() && m_vColumnSize.size() == _pList->size(),"Illegal columns in list"); Reference< XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier(); Reference< XNumberFormats > xFormats = xSupplier->getNumberFormats(); TColumnVector::const_iterator aIter = _pList->begin(); TColumnVector::const_iterator aEnd = _pList->end(); - for(sal_Int32 i= 0;aIter != aEnd;++aIter,++i) + for(sal_Int32 i= 0;aIter != aEnd && (i) < static_cast<sal_Int32>(m_vNumberFormat.size()) && (i) < static_cast<sal_Int32>(m_vColumnSize.size()) ;++aIter,++i) { sal_Int32 nDataType; sal_Int32 nLength(0),nScale(0); - OSL_ENSURE((i) < static_cast<sal_Int32>(m_vNumberFormat.size()),"m_vFormatKey: Illegal index for vector"); - OSL_ENSURE((i) < static_cast<sal_Int32>(m_vColumnSize.size()),"m_vColumnSize: Illegal index for vector"); sal_Int16 nType = m_vNumberFormat[i]; switch ( nType ) diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index e38da91c606c..809f9c407e51 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -590,11 +590,11 @@ TOTypeInfoSP getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo, // -> drop the precision and the scale restriction, accept any type with the property // type id (nType) - OSL_ENSURE(sal_False, - ( ::rtl::OString("getTypeInfoFromType: did not find a matching type") - += ::rtl::OString(" (expected type name: ") - += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding()) - += ::rtl::OString(")! Defaulting to the first matching type.")).getStr()); + //OSL_ENSURE(sal_False, + // ( ::rtl::OString("getTypeInfoFromType: did not find a matching type") + // += ::rtl::OString(" (expected type name: ") + // += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding()) + // += ::rtl::OString(")! Defaulting to the first matching type.")).getStr()); for(aIter = aPair.first; aIter != aPair.second; ++aIter) { // search the best matching type (now comparing the local names) @@ -700,6 +700,7 @@ void fillTypeInfo( const Reference< ::com::sun::star::sdbc::XConnection>& _rxCo nCount = 18; aTypes.reserve(nCount+1); aTypes.push_back(-1); + aNullable.push_back(sal_False); for (sal_Int32 j = 1; j <= nCount ; ++j) { aTypes.push_back(xResultSetMetaData->getColumnType(j)); diff --git a/dbaccess/source/ui/misc/WCPage.cxx b/dbaccess/source/ui/misc/WCPage.cxx index 2b4cd971ffa1..a6788ac1926f 100644 --- a/dbaccess/source/ui/misc/WCPage.cxx +++ b/dbaccess/source/ui/misc/WCPage.cxx @@ -216,6 +216,7 @@ sal_Bool OCopyTable::LeavePage() // first check if the table already exists in the database if( m_pParent->getOperation() != CopyTableOperation::AppendData ) { + m_pParent->clearDestColumns(); DynamicTableOrQueryNameCheck aNameCheck( m_pParent->m_xDestConnection, CommandType::TABLE ); SQLExceptionInfo aErrorInfo; if ( !aNameCheck.isNameValid( m_edTableName.GetText(), aErrorInfo ) ) @@ -342,7 +343,7 @@ sal_Bool OCopyTable::checkAppendData() { bNotConvert = sal_True; m_pParent->m_vColumnPos[i] = ODatabaseExport::TPositions::value_type(nPos,nPos); - TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getTypeInfo(),bNotConvert); + TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getSpecialTypeInfo(),bNotConvert); if ( !bNotConvert ) { m_pParent->showColumnTypeNotSupported((*aDestIter)->first); diff --git a/dbaccess/source/ui/misc/WColumnSelect.cxx b/dbaccess/source/ui/misc/WColumnSelect.cxx index 0f3f036102d5..9b4ad13d8dc7 100644 --- a/dbaccess/source/ui/misc/WColumnSelect.cxx +++ b/dbaccess/source/ui/misc/WColumnSelect.cxx @@ -336,7 +336,7 @@ void OWizColumnSelect::createNewColumn( ListBox* _pListbox, OFieldDescription* pNewField = new OFieldDescription(*_pSrcField); pNewField->SetName(sConvertedName); sal_Bool bNotConvert = sal_True; - pNewField->SetType(m_pParent->convertType(_pSrcField->getTypeInfo(),bNotConvert)); + pNewField->SetType(m_pParent->convertType(_pSrcField->getSpecialTypeInfo(),bNotConvert)); if ( !m_pParent->supportsPrimaryKey() ) pNewField->SetPrimaryKey(sal_False); diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx index 0cd8ae2dbeb4..ca9aeacf73e4 100644 --- a/dbaccess/source/ui/misc/WCopyTable.cxx +++ b/dbaccess/source/ui/misc/WCopyTable.cxx @@ -860,7 +860,7 @@ sal_Bool OCopyTableWizard::CheckColumns(sal_Int32& _rnBreakPos) { OFieldDescription* pField = new OFieldDescription(*(*aSrcIter)->second); pField->SetName(convertColumnName(TExportColumnFindFunctor(&m_vDestColumns),(*aSrcIter)->first,sExtraChars,nMaxNameLen)); - TOTypeInfoSP pType = convertType((*aSrcIter)->second->getTypeInfo(),bRet); + TOTypeInfoSP pType = convertType((*aSrcIter)->second->getSpecialTypeInfo(),bRet); pField->SetType(pType); if ( !bPKeyAllowed ) pField->SetPrimaryKey(sal_False); diff --git a/dbaccess/source/ui/misc/WNameMatch.cxx b/dbaccess/source/ui/misc/WNameMatch.cxx index 93feb3aa49b1..5325f0388cfc 100644 --- a/dbaccess/source/ui/misc/WNameMatch.cxx +++ b/dbaccess/source/ui/misc/WNameMatch.cxx @@ -206,7 +206,7 @@ sal_Bool OWizNameMatching::LeavePage() m_pParent->m_vColumnPos[nPos].first = ++nParamPos; m_pParent->m_vColumnPos[nPos].second = ::std::distance(pDestColumns->begin(),aDestIter) + 1; sal_Bool bNotConvert = sal_True; - TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getTypeInfo(),bNotConvert); + TOTypeInfoSP pTypeInfo = m_pParent->convertType((*aDestIter)->second->getSpecialTypeInfo(),bNotConvert); sal_Int32 nType = ::com::sun::star::sdbc::DataType::VARCHAR; if ( pTypeInfo.get() ) nType = pTypeInfo->nType; diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx index 2ae24b6f6423..440be631a3ae 100644 --- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx +++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx @@ -740,6 +740,7 @@ sal_Bool OSelectionBrowseBox::saveField(const String& _sFieldName,OTableFieldDes // second test if the name can be set as select columns in a pseudo statement // we have to look which entries we should quote + const ::rtl::OUString sFieldAlias = _pEntry->GetFieldAlias(); size_t nPass = 4; ::connectivity::OSQLParser& rParser( rController.getParser() ); OSQLParseNode* pParseNode = NULL; @@ -759,6 +760,11 @@ sal_Bool OSelectionBrowseBox::saveField(const String& _sFieldName,OTableFieldDes sSql += ::dbtools::quoteName( xMetaData->getIdentifierQuoteString(), _sFieldName ); else sSql += _sFieldName; + if ( sFieldAlias.getLength() ) + { // always quote the alias name there canbe no function in it + sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ")); + sSql += ::dbtools::quoteName( xMetaData->getIdentifierQuoteString(), sFieldAlias ); + } sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" FROM x")); pParseNode = rParser.parseTree( sErrorMsg, sSql, bInternational ); diff --git a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx index 6e81b8b15088..f052003c2c58 100644 --- a/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx +++ b/dbaccess/source/ui/relationdesign/RTableConnectionData.cxx @@ -30,42 +30,22 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef DBAUI_RTABLECONNECTIONDATA_HXX #include "RTableConnectionData.hxx" -#endif -#ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> -#endif -#ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ #include <com/sun/star/sdbc/KeyRule.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_KEYTYPE_HPP_ #include <com/sun/star/sdbcx/KeyType.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XKEYSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XKeysSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_ #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDATADESCRIPTORFACTORY_HPP_ #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ #include <com/sun/star/sdbcx/XAppend.hpp> -#endif -#ifndef _COM_SUN_STAR_SDBCX_XDROP_HPP_ #include <com/sun/star/sdbcx/XDrop.hpp> -#endif -#ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_ #include <com/sun/star/container/XIndexAccess.hpp> -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" -#endif -#ifndef DBAUI_TOOLS_HXX +#include "dbu_rel.hrc" #include "UITools.hxx" -#endif +#include "moduledbu.hxx" +#include <connectivity/dbexception.hxx> + using namespace dbaui; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdbcx; @@ -382,6 +362,7 @@ BOOL ORelationTableConnectionData::Update() // get the name of foreign key // search for columns m_aConnName = ::rtl::OUString(); xKey = NULL; + bool bDropRelation = false; for(sal_Int32 i=0;i<xKeys->getCount();++i) { xKeys->getByIndex(i) >>= xKey; @@ -426,6 +407,7 @@ BOOL ORelationTableConnectionData::Update() { xKey->getPropertyValue(PROPERTY_NAME) >>= sName; m_aConnName = sName; + bDropRelation = aNames.getLength() == 0; // the key contains no column, so it isn't valid and we have to drop it //here we already know our column structure so we don't have to recreate the table connection data xColSup.clear(); break; @@ -437,15 +419,20 @@ BOOL ORelationTableConnectionData::Update() } } xKey = NULL; + } // for(sal_Int32 i=0;i<xKeys->getCount();++i) + if ( bDropRelation ) + { + DropRelation(); + String sError(ModuleRes(STR_QUERY_REL_COULD_NOT_CREATE)); + ::dbtools::throwGenericSQLException(sError,NULL); } // OSL_ENSURE(xKey.is(),"No key found have insertion!"); + // The fields the relation marks may not be the same as our LineDatas mark after the relation has been updated if ( xColSup.is() ) { - // The fields the relation marks may not be the same as our LineDatas mark after the relation has been updated OConnectionLineDataVec().swap(m_vConnLineData); - Reference<XNameAccess> xColumns = xColSup->getColumns(); Sequence< ::rtl::OUString> aNames = xColumns->getElementNames(); const ::rtl::OUString* pIter = aNames.getConstArray(); @@ -470,7 +457,7 @@ BOOL ORelationTableConnectionData::Update() m_vConnLineData.push_back(pNewData); } } - } + } // if ( xColSup.is() ) // NOTE : the caller is resposible for updating any other objects referencing the old LineDatas (for instance a ConnLine) //////////////////////////////////////////////////////////// diff --git a/dbaccess/source/ui/relationdesign/relation.src b/dbaccess/source/ui/relationdesign/relation.src index e3fe71452fc8..391205223886 100644 --- a/dbaccess/source/ui/relationdesign/relation.src +++ b/dbaccess/source/ui/relationdesign/relation.src @@ -70,15 +70,15 @@ QueryBox RELATION_DESIGN_SAVEMODIFIED Message [ en-US ] = "The relation design has been changed.\nDo you want to save the changes?" ; }; -/* - The menubar resource has become obsolete - you can now find the menubar definition at: <project>/uiconfig/dbrelation/menubar/menubar.xml -*/ - String STR_QUERY_REL_DELETE_WINDOW { Text [ en-US ] = "When you delete this table all corresponding relations will be deleted as well. Continue?"; }; +String STR_QUERY_REL_COULD_NOT_CREATE +{ + Text [ en-US ] = "The datbase could not create the relation. May be foreign keys for this kind of table aren't supported.\nPlease check your documentation of the database."; +}; diff --git a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx index a7ddd801fc51..4ece37f2fa51 100644 --- a/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx +++ b/dbaccess/source/ui/tabledesign/FieldDescriptions.cxx @@ -578,6 +578,15 @@ TOTypeInfoSP OFieldDescription::getTypeInfo() const return m_pType; } // ----------------------------------------------------------------------------- +TOTypeInfoSP OFieldDescription::getSpecialTypeInfo() const +{ + TOTypeInfoSP pSpecialType( new OTypeInfo() ); + *pSpecialType = *m_pType; + pSpecialType->nPrecision = GetPrecision(); + pSpecialType->nMaximumScale = static_cast<sal_Int16>(GetScale()); + return pSpecialType; +} +// ----------------------------------------------------------------------------- sal_Bool OFieldDescription::IsAutoIncrement() const { if ( m_xDest.is() && m_xDestInfo->hasPropertyByName(PROPERTY_ISAUTOINCREMENT) ) diff --git a/dbaccess/source/ui/tabledesign/TEditControl.cxx b/dbaccess/source/ui/tabledesign/TEditControl.cxx index 29a8ca4951b3..353ff0ea11d5 100644 --- a/dbaccess/source/ui/tabledesign/TEditControl.cxx +++ b/dbaccess/source/ui/tabledesign/TEditControl.cxx @@ -349,6 +349,16 @@ void OTableEditorCtrl::InitCellController() pTypeCell->SetHelpId(HID_TABDESIGN_TYPECELL); pDescrCell->SetHelpId(HID_TABDESIGN_COMMENTCELL); + Size aHeight; + const Control* pControls[] = { pTypeCell,pDescrCell,pNameCell}; + for(sal_Size i= 0; i < sizeof(pControls)/sizeof(pControls[0]);++i) + { + const Size aTemp( pControls[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) ); + if ( aTemp.Height() > aHeight.Height() ) + aHeight.Height() = aTemp.Height(); + } // for(int i= 0; i < sizeof(pControls)/sizeof(pControls[0]);++i + SetDataRowHeight(aHeight.Height()); + ClearModified(); } diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index d81cf5f9a5cf..f54c5104c955 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -1482,6 +1482,7 @@ void OTableController::alterColumns() // ----------------------------------------------------------------------------- void OTableController::dropPrimaryKey() { + SQLExceptionInfo aInfo; try { Reference<XKeysSupplier> xKeySup(m_xTable,UNO_QUERY); @@ -1506,11 +1507,24 @@ void OTableController::dropPrimaryKey() } } } + catch(const SQLContext& e) + { + aInfo = SQLExceptionInfo(e); + } + catch(const SQLWarning& e) + { + aInfo = SQLExceptionInfo(e); + } + catch(const SQLException& e) + { + aInfo = SQLExceptionInfo(e); + } catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); } + showError(aInfo); } // ----------------------------------------------------------------------------- void OTableController::assignTable() diff --git a/dbaccess/source/ui/tabledesign/table.src b/dbaccess/source/ui/tabledesign/table.src index c242fcecd3b1..af911ec85c07 100644 --- a/dbaccess/source/ui/tabledesign/table.src +++ b/dbaccess/source/ui/tabledesign/table.src @@ -96,7 +96,7 @@ String STR_TAB_FIELD_COLUMN_NAME }; String STR_TAB_FIELD_DATATYPE { - Text [ en-US ] = "Field type" ; + Text [ en-US ] = "Field ~type" ; }; String STR_TAB_FIELD_COLUMN_DATATYPE { |