1*96de5490SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*96de5490SAndrew Rist * distributed with this work for additional information 6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance 9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*96de5490SAndrew Rist * software distributed under the License is distributed on an 15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the 17*96de5490SAndrew Rist * specific language governing permissions and limitations 18*96de5490SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*96de5490SAndrew Rist *************************************************************/ 21*96de5490SAndrew Rist 22*96de5490SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef DBAUI_DLGSAVE_HXX 28cdf0e10cSrcweir #include "dlgsave.hxx" 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #ifndef DBAUI_DLGSAVE_HRC 31cdf0e10cSrcweir #include "dlgsave.hrc" 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #ifndef _SV_MSGBOX_HXX //autogen 34cdf0e10cSrcweir #include <vcl/msgbox.hxx> 35cdf0e10cSrcweir #endif 36cdf0e10cSrcweir #ifndef _DBU_DLG_HRC_ 37cdf0e10cSrcweir #include "dbu_dlg.hrc" 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ 40cdf0e10cSrcweir #include <com/sun/star/sdb/CommandType.hpp> 41cdf0e10cSrcweir #endif 42cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ 43cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp> 44cdf0e10cSrcweir #endif 45cdf0e10cSrcweir #ifndef _DBAUI_SQLMESSAGE_HXX_ 46cdf0e10cSrcweir #include "sqlmessage.hxx" 47cdf0e10cSrcweir #endif 48cdf0e10cSrcweir #ifndef _CONNECTIVITY_DBTOOLS_HXX_ 49cdf0e10cSrcweir #include <connectivity/dbtools.hxx> 50cdf0e10cSrcweir #endif 51cdf0e10cSrcweir #ifndef DBAUI_TOOLS_HXX 52cdf0e10cSrcweir #include "UITools.hxx" 53cdf0e10cSrcweir #endif 54cdf0e10cSrcweir #ifndef _DBA_DBACCESS_HELPID_HRC_ 55cdf0e10cSrcweir #include "dbaccess_helpid.hrc" 56cdf0e10cSrcweir #endif 57cdf0e10cSrcweir #ifndef DBAUI_SQLNAMEEDIT_HXX 58cdf0e10cSrcweir #include "SqlNameEdit.hxx" 59cdf0e10cSrcweir #endif 60cdf0e10cSrcweir #ifndef _BUTTON_HXX //autogen 61cdf0e10cSrcweir #include <vcl/button.hxx> 62cdf0e10cSrcweir #endif 63cdf0e10cSrcweir #ifndef _FIXED_HXX //autogen 64cdf0e10cSrcweir #include <vcl/fixed.hxx> 65cdf0e10cSrcweir #endif 66cdf0e10cSrcweir #ifndef _EDIT_HXX //autogen 67cdf0e10cSrcweir #include <vcl/edit.hxx> 68cdf0e10cSrcweir #endif 69cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ 70cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 71cdf0e10cSrcweir #endif 72cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HPP_ 73cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp> 74cdf0e10cSrcweir #endif 75cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_ 76cdf0e10cSrcweir #include <com/sun/star/sdbc/XDatabaseMetaData.hpp> 77cdf0e10cSrcweir #endif 78cdf0e10cSrcweir #ifndef _DBAUI_MODULE_DBU_HXX_ 79cdf0e10cSrcweir #include "moduledbu.hxx" 80cdf0e10cSrcweir #endif 81cdf0e10cSrcweir #ifndef DBACCESS_SOURCE_UI_INC_OBJECTNAMECHECK_HXX 82cdf0e10cSrcweir #include "objectnamecheck.hxx" 83cdf0e10cSrcweir #endif 84cdf0e10cSrcweir #ifndef TOOLS_DIAGNOSE_EX_H 85cdf0e10cSrcweir #include <tools/diagnose_ex.h> 86cdf0e10cSrcweir #endif 87cdf0e10cSrcweir 88cdf0e10cSrcweir 89cdf0e10cSrcweir using namespace dbaui; 90cdf0e10cSrcweir using namespace dbtools; 91cdf0e10cSrcweir using namespace ::com::sun::star::uno; 92cdf0e10cSrcweir using namespace ::com::sun::star::container; 93cdf0e10cSrcweir using namespace ::com::sun::star::sdb; 94cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 95cdf0e10cSrcweir namespace dbaui 96cdf0e10cSrcweir { 97cdf0e10cSrcweir class OSaveAsDlgImpl 98cdf0e10cSrcweir { 99cdf0e10cSrcweir public: 100cdf0e10cSrcweir FixedText m_aDescription; 101cdf0e10cSrcweir FixedText m_aCatalogLbl; 102cdf0e10cSrcweir OSQLNameComboBox m_aCatalog; 103cdf0e10cSrcweir FixedText m_aSchemaLbl; 104cdf0e10cSrcweir OSQLNameComboBox m_aSchema; 105cdf0e10cSrcweir FixedText m_aLabel; 106cdf0e10cSrcweir OSQLNameEdit m_aTitle; 107cdf0e10cSrcweir OKButton m_aPB_OK; 108cdf0e10cSrcweir CancelButton m_aPB_CANCEL; 109cdf0e10cSrcweir HelpButton m_aPB_HELP; 110cdf0e10cSrcweir String m_aQryLabel; 111cdf0e10cSrcweir String m_sTblLabel; 112cdf0e10cSrcweir rtl::OUString m_sCatalog; 113cdf0e10cSrcweir rtl::OUString m_sSchema; 114cdf0e10cSrcweir String m_aName; 115cdf0e10cSrcweir const IObjectNameCheck& 116cdf0e10cSrcweir m_rObjectNameCheck; 117cdf0e10cSrcweir String m_sParentURL; 118cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xMetaData; 119cdf0e10cSrcweir sal_Int32 m_nType; 120cdf0e10cSrcweir sal_Int32 m_nFlags; 121cdf0e10cSrcweir 122cdf0e10cSrcweir OSaveAsDlgImpl( Window * pParent,const sal_Int32& _rType, 123cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection, 124cdf0e10cSrcweir const String& rDefault, 125cdf0e10cSrcweir const IObjectNameCheck& _rObjectNameCheck, 126cdf0e10cSrcweir sal_Int32 _nFlags); 127cdf0e10cSrcweir OSaveAsDlgImpl( Window * pParent, 128cdf0e10cSrcweir const String& rDefault, 129cdf0e10cSrcweir const IObjectNameCheck& _rObjectNameCheck, 130cdf0e10cSrcweir sal_Int32 _nFlags); 131cdf0e10cSrcweir }; 132cdf0e10cSrcweir // ----------------------------------------------------------------------------- 133cdf0e10cSrcweir } // dbaui 134cdf0e10cSrcweir // ----------------------------------------------------------------------------- 135cdf0e10cSrcweir OSaveAsDlgImpl::OSaveAsDlgImpl( Window * _pParent, 136cdf0e10cSrcweir const sal_Int32& _rType, 137cdf0e10cSrcweir const Reference< XConnection>& _xConnection, 138cdf0e10cSrcweir const String& rDefault, 139cdf0e10cSrcweir const IObjectNameCheck& _rObjectNameCheck, 140cdf0e10cSrcweir sal_Int32 _nFlags) 141cdf0e10cSrcweir :m_aDescription(_pParent, ModuleRes (FT_DESCRIPTION)) 142cdf0e10cSrcweir ,m_aCatalogLbl(_pParent, ModuleRes (FT_CATALOG)) 143cdf0e10cSrcweir ,m_aCatalog(_pParent, ModuleRes (ET_CATALOG), ::rtl::OUString()) 144cdf0e10cSrcweir ,m_aSchemaLbl(_pParent, ModuleRes (FT_SCHEMA)) 145cdf0e10cSrcweir ,m_aSchema(_pParent, ModuleRes (ET_SCHEMA), ::rtl::OUString()) 146cdf0e10cSrcweir ,m_aLabel(_pParent, ModuleRes (FT_TITLE)) 147cdf0e10cSrcweir ,m_aTitle(_pParent, ModuleRes (ET_TITLE), ::rtl::OUString()) 148cdf0e10cSrcweir ,m_aPB_OK(_pParent, ModuleRes( PB_OK ) ) 149cdf0e10cSrcweir ,m_aPB_CANCEL(_pParent, ModuleRes( PB_CANCEL )) 150cdf0e10cSrcweir ,m_aPB_HELP(_pParent, ModuleRes( PB_HELP)) 151cdf0e10cSrcweir ,m_aQryLabel(ModuleRes(STR_QRY_LABEL)) 152cdf0e10cSrcweir ,m_sTblLabel(ModuleRes(STR_TBL_LABEL)) 153cdf0e10cSrcweir ,m_aName(rDefault) 154cdf0e10cSrcweir ,m_rObjectNameCheck( _rObjectNameCheck ) 155cdf0e10cSrcweir ,m_nType(_rType) 156cdf0e10cSrcweir ,m_nFlags(_nFlags) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir if ( _xConnection.is() ) 159cdf0e10cSrcweir m_xMetaData = _xConnection->getMetaData(); 160cdf0e10cSrcweir 161cdf0e10cSrcweir if ( m_xMetaData.is() ) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir ::rtl::OUString sExtraNameChars( m_xMetaData->getExtraNameCharacters() ); 164cdf0e10cSrcweir m_aCatalog.setAllowedChars( sExtraNameChars ); 165cdf0e10cSrcweir m_aSchema.setAllowedChars( sExtraNameChars ); 166cdf0e10cSrcweir m_aTitle.setAllowedChars( sExtraNameChars ); 167cdf0e10cSrcweir } 168cdf0e10cSrcweir 169cdf0e10cSrcweir m_aCatalog.SetDropDownLineCount( 10 ); 170cdf0e10cSrcweir m_aSchema.SetDropDownLineCount( 10 ); 171cdf0e10cSrcweir } 172cdf0e10cSrcweir // ----------------------------------------------------------------------------- 173cdf0e10cSrcweir OSaveAsDlgImpl::OSaveAsDlgImpl( Window * _pParent, 174cdf0e10cSrcweir const String& rDefault, 175cdf0e10cSrcweir const IObjectNameCheck& _rObjectNameCheck, 176cdf0e10cSrcweir sal_Int32 _nFlags) 177cdf0e10cSrcweir :m_aDescription(_pParent, ModuleRes (FT_DESCRIPTION)) 178cdf0e10cSrcweir ,m_aCatalogLbl(_pParent, ModuleRes (FT_CATALOG)) 179cdf0e10cSrcweir ,m_aCatalog(_pParent, ModuleRes (ET_CATALOG)) 180cdf0e10cSrcweir ,m_aSchemaLbl(_pParent, ModuleRes (FT_SCHEMA)) 181cdf0e10cSrcweir ,m_aSchema(_pParent, ModuleRes (ET_SCHEMA)) 182cdf0e10cSrcweir ,m_aLabel(_pParent, ModuleRes (FT_TITLE)) 183cdf0e10cSrcweir ,m_aTitle(_pParent, ModuleRes (ET_TITLE)) 184cdf0e10cSrcweir ,m_aPB_OK(_pParent, ModuleRes( PB_OK ) ) 185cdf0e10cSrcweir ,m_aPB_CANCEL(_pParent, ModuleRes( PB_CANCEL )) 186cdf0e10cSrcweir ,m_aPB_HELP(_pParent, ModuleRes( PB_HELP)) 187cdf0e10cSrcweir ,m_aQryLabel(ModuleRes(STR_QRY_LABEL)) 188cdf0e10cSrcweir ,m_sTblLabel(ModuleRes(STR_TBL_LABEL)) 189cdf0e10cSrcweir ,m_aName(rDefault) 190cdf0e10cSrcweir ,m_rObjectNameCheck( _rObjectNameCheck ) 191cdf0e10cSrcweir ,m_nType(CommandType::COMMAND) 192cdf0e10cSrcweir ,m_nFlags(_nFlags) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir m_aCatalog.SetDropDownLineCount( 10 ); 195cdf0e10cSrcweir m_aSchema.SetDropDownLineCount( 10 ); 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir // ----------------------------------------------------------------------------- 199cdf0e10cSrcweir using namespace ::com::sun::star::lang; 200cdf0e10cSrcweir 201cdf0e10cSrcweir //================================================================== 202cdf0e10cSrcweir namespace 203cdf0e10cSrcweir { 204cdf0e10cSrcweir typedef Reference< XResultSet > (SAL_CALL XDatabaseMetaData::*FGetMetaStrings)(); 205cdf0e10cSrcweir 206cdf0e10cSrcweir void lcl_fillComboList( ComboBox& _rList, const Reference< XConnection >& _rxConnection, 207cdf0e10cSrcweir FGetMetaStrings _GetAll, const ::rtl::OUString& _rCurrent ) 208cdf0e10cSrcweir { 209cdf0e10cSrcweir try 210cdf0e10cSrcweir { 211cdf0e10cSrcweir Reference< XDatabaseMetaData > xMetaData( _rxConnection->getMetaData(), UNO_QUERY_THROW ); 212cdf0e10cSrcweir 213cdf0e10cSrcweir Reference< XResultSet > xRes = (xMetaData.get()->*_GetAll)(); 214cdf0e10cSrcweir Reference< XRow > xRow( xRes, UNO_QUERY_THROW ); 215cdf0e10cSrcweir ::rtl::OUString sValue; 216cdf0e10cSrcweir while ( xRes->next() ) 217cdf0e10cSrcweir { 218cdf0e10cSrcweir sValue = xRow->getString( 1 ); 219cdf0e10cSrcweir if ( !xRow->wasNull() ) 220cdf0e10cSrcweir _rList.InsertEntry( sValue ); 221cdf0e10cSrcweir } 222cdf0e10cSrcweir 223cdf0e10cSrcweir sal_uInt16 nPos = _rList.GetEntryPos( String( _rCurrent ) ); 224cdf0e10cSrcweir if ( nPos != COMBOBOX_ENTRY_NOTFOUND ) 225cdf0e10cSrcweir _rList.SelectEntryPos( nPos ); 226cdf0e10cSrcweir else 227cdf0e10cSrcweir _rList.SelectEntryPos( 0 ); 228cdf0e10cSrcweir } 229cdf0e10cSrcweir catch( const Exception& ) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 232cdf0e10cSrcweir } 233cdf0e10cSrcweir } 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir //================================================================== 237cdf0e10cSrcweir OSaveAsDlg::OSaveAsDlg( Window * pParent, 238cdf0e10cSrcweir const sal_Int32& _rType, 239cdf0e10cSrcweir const Reference< XMultiServiceFactory >& _rxORB, 240cdf0e10cSrcweir const Reference< XConnection>& _xConnection, 241cdf0e10cSrcweir const String& rDefault, 242cdf0e10cSrcweir const IObjectNameCheck& _rObjectNameCheck, 243cdf0e10cSrcweir sal_Int32 _nFlags) 244cdf0e10cSrcweir :ModalDialog( pParent, ModuleRes(DLG_SAVE_AS)) 245cdf0e10cSrcweir ,m_xORB( _rxORB ) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir m_pImpl = new OSaveAsDlgImpl(this,_rType,_xConnection,rDefault,_rObjectNameCheck,_nFlags); 248cdf0e10cSrcweir 249cdf0e10cSrcweir switch (_rType) 250cdf0e10cSrcweir { 251cdf0e10cSrcweir case CommandType::QUERY: 252cdf0e10cSrcweir implInitOnlyTitle(m_pImpl->m_aQryLabel); 253cdf0e10cSrcweir break; 254cdf0e10cSrcweir 255cdf0e10cSrcweir case CommandType::TABLE: 256cdf0e10cSrcweir OSL_ENSURE( m_pImpl->m_xMetaData.is(), "OSaveAsDlg::OSaveAsDlg: no meta data for entering table names: this will crash!" ); 257cdf0e10cSrcweir { 258cdf0e10cSrcweir m_pImpl->m_aLabel.SetText(m_pImpl->m_sTblLabel); 259cdf0e10cSrcweir Point aPos(m_pImpl->m_aPB_OK.GetPosPixel()); 260cdf0e10cSrcweir if(m_pImpl->m_xMetaData.is() && !m_pImpl->m_xMetaData->supportsCatalogsInTableDefinitions()) 261cdf0e10cSrcweir { 262cdf0e10cSrcweir m_pImpl->m_aCatalogLbl.Hide(); 263cdf0e10cSrcweir m_pImpl->m_aCatalog.Hide(); 264cdf0e10cSrcweir 265cdf0e10cSrcweir aPos = m_pImpl->m_aLabel.GetPosPixel(); 266cdf0e10cSrcweir 267cdf0e10cSrcweir m_pImpl->m_aLabel.SetPosPixel(m_pImpl->m_aSchemaLbl.GetPosPixel()); 268cdf0e10cSrcweir m_pImpl->m_aTitle.SetPosPixel(m_pImpl->m_aSchema.GetPosPixel()); 269cdf0e10cSrcweir 270cdf0e10cSrcweir m_pImpl->m_aSchemaLbl.SetPosPixel(m_pImpl->m_aCatalogLbl.GetPosPixel()); 271cdf0e10cSrcweir m_pImpl->m_aSchema.SetPosPixel(m_pImpl->m_aCatalog.GetPosPixel()); 272cdf0e10cSrcweir } 273cdf0e10cSrcweir else 274cdf0e10cSrcweir { 275cdf0e10cSrcweir // now fill the catalogs 276cdf0e10cSrcweir lcl_fillComboList( m_pImpl->m_aCatalog, _xConnection, 277cdf0e10cSrcweir &XDatabaseMetaData::getCatalogs, _xConnection->getCatalog() ); 278cdf0e10cSrcweir } 279cdf0e10cSrcweir 280cdf0e10cSrcweir if ( !m_pImpl->m_xMetaData->supportsSchemasInTableDefinitions()) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir m_pImpl->m_aSchemaLbl.Hide(); 283cdf0e10cSrcweir m_pImpl->m_aSchema.Hide(); 284cdf0e10cSrcweir 285cdf0e10cSrcweir aPos = m_pImpl->m_aLabel.GetPosPixel(); 286cdf0e10cSrcweir 287cdf0e10cSrcweir m_pImpl->m_aLabel.SetPosPixel(m_pImpl->m_aSchemaLbl.GetPosPixel()); 288cdf0e10cSrcweir m_pImpl->m_aTitle.SetPosPixel(m_pImpl->m_aSchema.GetPosPixel()); 289cdf0e10cSrcweir } 290cdf0e10cSrcweir else 291cdf0e10cSrcweir { 292cdf0e10cSrcweir lcl_fillComboList( m_pImpl->m_aSchema, _xConnection, 293cdf0e10cSrcweir &XDatabaseMetaData::getSchemas, m_pImpl->m_xMetaData->getUserName() ); 294cdf0e10cSrcweir } 295cdf0e10cSrcweir 296cdf0e10cSrcweir OSL_ENSURE(m_pImpl->m_xMetaData.is(),"The metadata can not be null!"); 297cdf0e10cSrcweir if(m_pImpl->m_aName.Search('.') != STRING_NOTFOUND) 298cdf0e10cSrcweir { 299cdf0e10cSrcweir ::rtl::OUString sCatalog,sSchema,sTable; 300cdf0e10cSrcweir ::dbtools::qualifiedNameComponents(m_pImpl->m_xMetaData, 301cdf0e10cSrcweir m_pImpl->m_aName, 302cdf0e10cSrcweir sCatalog, 303cdf0e10cSrcweir sSchema, 304cdf0e10cSrcweir sTable, 305cdf0e10cSrcweir ::dbtools::eInDataManipulation); 306cdf0e10cSrcweir 307cdf0e10cSrcweir sal_uInt16 nPos = m_pImpl->m_aCatalog.GetEntryPos(String(sCatalog)); 308cdf0e10cSrcweir if ( nPos != COMBOBOX_ENTRY_NOTFOUND ) 309cdf0e10cSrcweir m_pImpl->m_aCatalog.SelectEntryPos(nPos); 310cdf0e10cSrcweir 311cdf0e10cSrcweir if ( sSchema.getLength() ) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir nPos = m_pImpl->m_aSchema.GetEntryPos(String(sSchema)); 314cdf0e10cSrcweir if ( nPos != COMBOBOX_ENTRY_NOTFOUND ) 315cdf0e10cSrcweir m_pImpl->m_aSchema.SelectEntryPos(nPos); 316cdf0e10cSrcweir } 317cdf0e10cSrcweir m_pImpl->m_aTitle.SetText(sTable); 318cdf0e10cSrcweir } 319cdf0e10cSrcweir else 320cdf0e10cSrcweir m_pImpl->m_aTitle.SetText(m_pImpl->m_aName); 321cdf0e10cSrcweir m_pImpl->m_aTitle.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) ); 322cdf0e10cSrcweir 323cdf0e10cSrcweir m_pImpl->m_aPB_OK.SetPosPixel(Point(m_pImpl->m_aPB_OK.GetPosPixel().X(),aPos.Y())); 324cdf0e10cSrcweir m_pImpl->m_aPB_CANCEL.SetPosPixel(Point(m_pImpl->m_aPB_CANCEL.GetPosPixel().X(),aPos.Y())); 325cdf0e10cSrcweir m_pImpl->m_aPB_HELP.SetPosPixel(Point(m_pImpl->m_aPB_HELP.GetPosPixel().X(),aPos.Y())); 326cdf0e10cSrcweir 327cdf0e10cSrcweir sal_uInt16 nLength = m_pImpl->m_xMetaData.is() ? static_cast<sal_uInt16>(m_pImpl->m_xMetaData->getMaxTableNameLength()) : 0; 328cdf0e10cSrcweir nLength = nLength ? nLength : EDIT_NOLIMIT; 329cdf0e10cSrcweir 330cdf0e10cSrcweir m_pImpl->m_aTitle.SetMaxTextLen(nLength); 331cdf0e10cSrcweir m_pImpl->m_aSchema.SetMaxTextLen(nLength); 332cdf0e10cSrcweir m_pImpl->m_aCatalog.SetMaxTextLen(nLength); 333cdf0e10cSrcweir 334cdf0e10cSrcweir sal_Bool bCheck = _xConnection.is() && isSQL92CheckEnabled(_xConnection); 335cdf0e10cSrcweir m_pImpl->m_aTitle.setCheck(bCheck); // enable non valid sql chars as well 336cdf0e10cSrcweir m_pImpl->m_aSchema.setCheck(bCheck); // enable non valid sql chars as well 337cdf0e10cSrcweir m_pImpl->m_aCatalog.setCheck(bCheck); // enable non valid sql chars as well 338cdf0e10cSrcweir 339cdf0e10cSrcweir Size aSize = GetSizePixel(); 340cdf0e10cSrcweir aSize.Height() = 341cdf0e10cSrcweir aPos.Y() + m_pImpl->m_aPB_OK.GetSizePixel().Height() + m_pImpl->m_aTitle.GetSizePixel().Height() / 2; 342cdf0e10cSrcweir SetSizePixel(aSize); 343cdf0e10cSrcweir } 344cdf0e10cSrcweir break; 345cdf0e10cSrcweir 346cdf0e10cSrcweir default: 347cdf0e10cSrcweir OSL_ENSURE( false, "OSaveAsDlg::OSaveAsDlg: Type not supported yet!" ); 348cdf0e10cSrcweir } 349cdf0e10cSrcweir 350cdf0e10cSrcweir implInit(); 351cdf0e10cSrcweir } 352cdf0e10cSrcweir // ----------------------------------------------------------------------------- 353cdf0e10cSrcweir OSaveAsDlg::OSaveAsDlg( Window * pParent, 354cdf0e10cSrcweir const Reference< XMultiServiceFactory >& _rxORB, 355cdf0e10cSrcweir const String& rDefault, 356cdf0e10cSrcweir const String& _sLabel, 357cdf0e10cSrcweir const IObjectNameCheck& _rObjectNameCheck, 358cdf0e10cSrcweir sal_Int32 _nFlags) 359cdf0e10cSrcweir :ModalDialog( pParent, ModuleRes(DLG_SAVE_AS)) 360cdf0e10cSrcweir ,m_xORB( _rxORB ) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir m_pImpl = new OSaveAsDlgImpl(this,rDefault,_rObjectNameCheck,_nFlags); 363cdf0e10cSrcweir implInitOnlyTitle(_sLabel); 364cdf0e10cSrcweir implInit(); 365cdf0e10cSrcweir } 366cdf0e10cSrcweir // ----------------------------------------------------------------------------- 367cdf0e10cSrcweir OSaveAsDlg::~OSaveAsDlg() 368cdf0e10cSrcweir { 369cdf0e10cSrcweir DELETEZ(m_pImpl); 370cdf0e10cSrcweir } 371cdf0e10cSrcweir // ----------------------------------------------------------------------------- 372cdf0e10cSrcweir IMPL_LINK(OSaveAsDlg, ButtonClickHdl, Button *, pButton) 373cdf0e10cSrcweir { 374cdf0e10cSrcweir if (pButton == &m_pImpl->m_aPB_OK) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir m_pImpl->m_aName = m_pImpl->m_aTitle.GetText(); 377cdf0e10cSrcweir 378cdf0e10cSrcweir ::rtl::OUString sNameToCheck( m_pImpl->m_aName ); 379cdf0e10cSrcweir 380cdf0e10cSrcweir if ( m_pImpl->m_nType == CommandType::TABLE ) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir sNameToCheck = ::dbtools::composeTableName( 383cdf0e10cSrcweir m_pImpl->m_xMetaData, 384cdf0e10cSrcweir getCatalog(), 385cdf0e10cSrcweir getSchema(), 386cdf0e10cSrcweir sNameToCheck, 387cdf0e10cSrcweir sal_False, // no quoting 388cdf0e10cSrcweir ::dbtools::eInDataManipulation 389cdf0e10cSrcweir ); 390cdf0e10cSrcweir } 391cdf0e10cSrcweir 392cdf0e10cSrcweir SQLExceptionInfo aNameError; 393cdf0e10cSrcweir if ( m_pImpl->m_rObjectNameCheck.isNameValid( sNameToCheck, aNameError ) ) 394cdf0e10cSrcweir EndDialog( RET_OK ); 395cdf0e10cSrcweir 396cdf0e10cSrcweir showError( aNameError, this, m_xORB ); 397cdf0e10cSrcweir m_pImpl->m_aTitle.GrabFocus(); 398cdf0e10cSrcweir } 399cdf0e10cSrcweir return 0; 400cdf0e10cSrcweir } 401cdf0e10cSrcweir // ----------------------------------------------------------------------------- 402cdf0e10cSrcweir 403cdf0e10cSrcweir IMPL_LINK(OSaveAsDlg, EditModifyHdl, Edit *, pEdit ) 404cdf0e10cSrcweir { 405cdf0e10cSrcweir if (pEdit == &m_pImpl->m_aTitle) 406cdf0e10cSrcweir m_pImpl->m_aPB_OK.Enable(0 != m_pImpl->m_aTitle.GetText().Len()); 407cdf0e10cSrcweir return 0; 408cdf0e10cSrcweir } 409cdf0e10cSrcweir // ----------------------------------------------------------------------------- 410cdf0e10cSrcweir void OSaveAsDlg::implInitOnlyTitle(const String& _rLabel) 411cdf0e10cSrcweir { 412cdf0e10cSrcweir m_pImpl->m_aLabel.SetText(_rLabel); 413cdf0e10cSrcweir m_pImpl->m_aCatalogLbl.Hide(); 414cdf0e10cSrcweir m_pImpl->m_aCatalog.Hide(); 415cdf0e10cSrcweir m_pImpl->m_aSchemaLbl.Hide(); 416cdf0e10cSrcweir m_pImpl->m_aSchema.Hide(); 417cdf0e10cSrcweir 418cdf0e10cSrcweir Point aPos(m_pImpl->m_aSchemaLbl.GetPosPixel()); 419cdf0e10cSrcweir m_pImpl->m_aLabel.SetPosPixel(m_pImpl->m_aCatalogLbl.GetPosPixel()); 420cdf0e10cSrcweir m_pImpl->m_aTitle.SetPosPixel(m_pImpl->m_aCatalog.GetPosPixel()); 421cdf0e10cSrcweir 422cdf0e10cSrcweir m_pImpl->m_aPB_OK.SetPosPixel(Point(m_pImpl->m_aPB_OK.GetPosPixel().X(),aPos.Y())); 423cdf0e10cSrcweir m_pImpl->m_aPB_CANCEL.SetPosPixel(Point(m_pImpl->m_aPB_CANCEL.GetPosPixel().X(),aPos.Y())); 424cdf0e10cSrcweir m_pImpl->m_aPB_HELP.SetPosPixel(Point(m_pImpl->m_aPB_HELP.GetPosPixel().X(),aPos.Y())); 425cdf0e10cSrcweir 426cdf0e10cSrcweir sal_Int32 nNewHeight = 427cdf0e10cSrcweir aPos.Y() + m_pImpl->m_aPB_OK.GetSizePixel().Height() + m_pImpl->m_aTitle.GetSizePixel().Height() / 2; 428cdf0e10cSrcweir 429cdf0e10cSrcweir SetSizePixel(Size(GetSizePixel().Width(), nNewHeight)); 430cdf0e10cSrcweir 431cdf0e10cSrcweir m_pImpl->m_aTitle.SetText(m_pImpl->m_aName); 432cdf0e10cSrcweir m_pImpl->m_aTitle.setCheck(sal_False); // enable non valid sql chars as well 433cdf0e10cSrcweir } 434cdf0e10cSrcweir // ----------------------------------------------------------------------------- 435cdf0e10cSrcweir void OSaveAsDlg::implInit() 436cdf0e10cSrcweir { 437cdf0e10cSrcweir if ( 0 == ( m_pImpl->m_nFlags & SAD_ADDITIONAL_DESCRIPTION ) ) 438cdf0e10cSrcweir { 439cdf0e10cSrcweir // hide the description window 440cdf0e10cSrcweir m_pImpl->m_aDescription.Hide(); 441cdf0e10cSrcweir 442cdf0e10cSrcweir // the number of pixels we have to move the other controls 443cdf0e10cSrcweir sal_Int32 nMoveUp = m_pImpl->m_aCatalog.GetPosPixel().Y() - m_pImpl->m_aDescription.GetPosPixel().Y(); 444cdf0e10cSrcweir 445cdf0e10cSrcweir // loop to all controls and move them ... 446cdf0e10cSrcweir for ( Window* pChildControl = GetWindow( WINDOW_FIRSTCHILD ); 447cdf0e10cSrcweir pChildControl; 448cdf0e10cSrcweir pChildControl= pChildControl->GetWindow( WINDOW_NEXT ) 449cdf0e10cSrcweir ) 450cdf0e10cSrcweir { 451cdf0e10cSrcweir if ( &m_pImpl->m_aDescription != pChildControl ) 452cdf0e10cSrcweir { 453cdf0e10cSrcweir Point aPos = pChildControl->GetPosPixel(); 454cdf0e10cSrcweir aPos.Y() -= nMoveUp; 455cdf0e10cSrcweir pChildControl->SetPosPixel(aPos); 456cdf0e10cSrcweir } 457cdf0e10cSrcweir } 458cdf0e10cSrcweir 459cdf0e10cSrcweir // change our own size accordingly 460cdf0e10cSrcweir Size aSize = GetSizePixel(); 461cdf0e10cSrcweir aSize.Height() -= nMoveUp; 462cdf0e10cSrcweir SetSizePixel(aSize); 463cdf0e10cSrcweir } 464cdf0e10cSrcweir 465cdf0e10cSrcweir if ( SAD_TITLE_PASTE_AS == ( m_pImpl->m_nFlags & SAD_TITLE_PASTE_AS ) ) 466cdf0e10cSrcweir SetText( String( ModuleRes( STR_TITLE_PASTE_AS ) ) ); 467cdf0e10cSrcweir else if ( SAD_TITLE_RENAME == ( m_pImpl->m_nFlags & SAD_TITLE_RENAME ) ) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir SetText( String( ModuleRes( STR_TITLE_RENAME ) ) ); 470cdf0e10cSrcweir m_pImpl->m_aTitle.SetHelpId(HID_DLG_RENAME); 471cdf0e10cSrcweir } 472cdf0e10cSrcweir 473cdf0e10cSrcweir m_pImpl->m_aPB_OK.SetClickHdl(LINK(this,OSaveAsDlg,ButtonClickHdl)); 474cdf0e10cSrcweir m_pImpl->m_aTitle.SetModifyHdl(LINK(this,OSaveAsDlg,EditModifyHdl)); 475cdf0e10cSrcweir m_pImpl->m_aTitle.GrabFocus(); 476cdf0e10cSrcweir FreeResource(); 477cdf0e10cSrcweir } 478cdf0e10cSrcweir // ----------------------------------------------------------------------------- 479cdf0e10cSrcweir String OSaveAsDlg::getName() const { return m_pImpl->m_aName; } 480cdf0e10cSrcweir String OSaveAsDlg::getCatalog() const { return m_pImpl->m_aCatalog.IsVisible() ? m_pImpl->m_aCatalog.GetText() : String(); } 481cdf0e10cSrcweir String OSaveAsDlg::getSchema() const { return m_pImpl->m_aSchema.IsVisible() ? m_pImpl->m_aSchema.GetText() : String(); } 482cdf0e10cSrcweir 483