diff options
-rw-r--r-- | sc/source/ui/docshell/dbdocimp.cxx | 50 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh2.cxx | 75 |
2 files changed, 53 insertions, 72 deletions
diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx index d497a2050770..ca3fcce422d0 100644 --- a/sc/source/ui/docshell/dbdocimp.cxx +++ b/sc/source/ui/docshell/dbdocimp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dbdocimp.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: nn $ $Date: 2001-06-05 14:23:11 $ + * last change: $Author: nn $ $Date: 2001-06-25 15:59:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,6 +71,7 @@ #include <vcl/msgbox.hxx> #include <tools/debug.hxx> #include <offmgr/sbaitems.hxx> // SbaSelectionList +#include <svx/dataaccessdescriptor.hxx> #include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/sdb/XCompletedExecution.hpp> @@ -80,6 +81,8 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> #include "dbdocfun.hxx" #include "docsh.hxx" @@ -111,41 +114,37 @@ using namespace com::sun::star; // static void ScDBDocFunc::ShowInBeamer( const ScImportParam& rParam, SfxViewFrame* pFrame ) { - if (!pFrame) + // called after opening the database beamer + + if ( !pFrame || !rParam.bImport ) return; uno::Reference<frame::XFrame> xFrame = pFrame->GetFrame()->GetFrameInterface(); uno::Reference<frame::XDispatchProvider> xDP(xFrame, uno::UNO_QUERY); - util::URL aURL; - aURL.Complete = rtl::OUString::createFromAscii(".component:DB/DataSourceBrowser"); - uno::Reference<frame::XDispatch> xD = xDP->queryDispatch(aURL, + + uno::Reference<frame::XFrame> xBeamerFrame = xFrame->findFrame( rtl::OUString::createFromAscii("_beamer"), - 0x0C); - if (xD.is()) + frame::FrameSearchFlag::CHILDREN); + if (xBeamerFrame.is()) { - uno::Sequence<beans::PropertyValue> aProperties; - - if (rParam.bImport) // called for a range with imported data? + uno::Reference<frame::XController> xController = xBeamerFrame->getController(); + uno::Reference<view::XSelectionSupplier> xControllerSelection(xController, uno::UNO_QUERY); + if (xControllerSelection.is()) { sal_Int32 nType = rParam.bSql ? sdb::CommandType::COMMAND : ( (rParam.nType == ScDbQuery) ? sdb::CommandType::QUERY : sdb::CommandType::TABLE ); - aProperties.realloc(3); - beans::PropertyValue* pProperties = aProperties.getArray(); - pProperties[0].Name = rtl::OUString::createFromAscii( SC_DBPROP_DATASOURCENAME ); - pProperties[0].Value <<= rtl::OUString( rParam.aDBName ); - pProperties[1].Name = rtl::OUString::createFromAscii( SC_DBPROP_COMMAND ); - pProperties[1].Value <<= rtl::OUString( rParam.aStatement ); - pProperties[2].Name = rtl::OUString::createFromAscii( SC_DBPROP_COMMANDTYPE ); - pProperties[2].Value <<= nType; - } - //! else address book? + ::svx::ODataAccessDescriptor aSelection; + aSelection[svx::daDataSource] <<= rtl::OUString( rParam.aDBName ); + aSelection[svx::daCommand] <<= rtl::OUString( rParam.aStatement ); + aSelection[svx::daCommandType] <<= nType; - xD->dispatch(aURL, aProperties); + xControllerSelection->select(uno::makeAny(aSelection.createPropertyValueSequence())); + } + else + DBG_ERROR("no selection supplier in the beamer!"); } - else - DBG_ERROR("no dispatcher for the database URL!"); } // ----------------------------------------------------------------- @@ -509,7 +508,8 @@ BOOL ScDBDocFunc::DoImport( USHORT nTab, const ScImportParam& rParam, { // old and new range editable? if ( !pDoc->IsBlockEditable(nTab, rParam.nCol1,rParam.nRow1,rParam.nCol2,rParam.nRow2) || - !pDoc->IsBlockEditable(nTab, rParam.nCol1,rParam.nRow1,nEndCol,nEndRow) ) + !pDoc->IsBlockEditable(nTab, rParam.nCol1,rParam.nRow1,nEndCol,nEndRow) || + pDoc->GetChangeTrack() != NULL ) { nErrStringId = STR_PROTECTIONERR; bSuccess = FALSE; diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx index bf47cfd392cf..d2b3de0c8a1d 100644 --- a/sc/source/ui/view/cellsh2.cxx +++ b/sc/source/ui/view/cellsh2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cellsh2.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: nn $ $Date: 2001-02-08 19:34:39 $ + * last change: $Author: nn $ $Date: 2001-06-25 15:57:58 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -166,6 +166,8 @@ #include <offmgr/sbasltid.hrc> #include <vcl/msgbox.hxx> +#include <com/sun/star/frame/FrameSearchFlag.hpp> + #include "cellsh.hxx" #include "tabvwsh.hxx" #include "sc.hrc" @@ -218,52 +220,37 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq ) switch ( nSlotId ) { - case SID_IMPORT_DATA: + case SID_VIEW_DATA_SOURCE_BROWSER: { - //! was wird mit dem Adressbuch? -#if 0 - if( pScApp->GetSbaObject()->IsAddrPIOpen() ) + // check if database beamer is open + + SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame(); + BOOL bWasOpen = FALSE; { - pViewData->GetDispatcher().Execute( SID_SBA_ADDRPI, - SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD ); + uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame()->GetFrameInterface(); + uno::Reference<frame::XFrame> xBeamerFrame = xFrame->findFrame( + rtl::OUString::createFromAscii("_beamer"), + frame::FrameSearchFlag::CHILDREN); + if ( xBeamerFrame.is() ) + bWasOpen = TRUE; } -#endif - if( pReqArgs ) + if ( bWasOpen ) { - const SfxPoolItem* pItem; - if( IS_AVAILABLE( SID_IMPORT_DATA, &pItem ) ) - { - String aDBName, aSQLCommand; + // close database beamer: just forward to SfxViewFrame - aDBName = ((const SfxStringItem*)pItem)->GetValue(); - - if( IS_AVAILABLE( FN_PARAM_1, &pItem ) ) - aSQLCommand = ((const SfxStringItem*)pItem)->GetValue(); + pViewFrame->ExecuteSlot( rReq ); + } + else + { + // show database beamer: SfxViewFrame call must be synchronous + pViewFrame->ExecuteSlot( rReq, (BOOL) FALSE ); // FALSE = synchronous - ScImportParam aImportParam; - ScDBData* pDBData = pTabViewShell->GetDBData(TRUE,SC_DB_IMPORT); // Namen vergeben - pDBData->GetImportParam( aImportParam ); - aImportParam.aDBName = aDBName; - aImportParam.aStatement = aSQLCommand; - aImportParam.bSql = TRUE; // kein Name, sondern Sql - aImportParam.bImport = TRUE; + // select current database in database beamer - pTabViewShell->ImportData( aImportParam ); - pDBData->SetImportParam( aImportParam ); - - rReq.Done(); - } - else - { - rReq.Ignore(); - } - } - else // DB-Browser anzeigen - { ScImportParam aImportParam; - ScDBData* pDBData = pTabViewShell->GetDBData(TRUE,SC_DB_OLD); // nicht neu anlegen + ScDBData* pDBData = pTabViewShell->GetDBData(TRUE,SC_DB_OLD); // don't create if none found if (pDBData) pDBData->GetImportParam( aImportParam ); @@ -1154,17 +1141,11 @@ void __EXPORT ScCellShell::GetDBState( SfxItemSet& rSet ) } break; - case SID_IMPORT_DATA: + case SID_VIEW_DATA_SOURCE_BROWSER: { - if(pDoc->GetChangeTrack()!=NULL) - rSet.DisableItem( nWhich ); -/* Import (F4) ist immer moeglich, Default ist Adressbuch + // get state (BoolItem) from SfxViewFrame - // importierte Daten auch mit Selektion - ScDBData* pDBData = GetDBData(FALSE,SC_DB_OLD); - if (!pDBData || !pDBData->HasImportParam()) - rSet.DisableItem( nWhich ); -*/ + pTabViewShell->GetViewFrame()->GetSlotState( nWhich, NULL, &rSet ); } break; case SID_SBA_BRW_INSERT: |