diff options
71 files changed, 2763 insertions, 1127 deletions
diff --git a/automation/source/server/statemnt.cxx b/automation/source/server/statemnt.cxx index 17ddbae6f..cdc598721 100644 --- a/automation/source/server/statemnt.cxx +++ b/automation/source/server/statemnt.cxx @@ -91,16 +91,7 @@ #include <svtools/svtdata.hxx> #include <tools/time.hxx> #include <svtools/stringtransfer.hxx> -#ifndef _PRINT_HXX //autogen -#include <vcl/print.hxx> -#endif -#ifndef _PRNDLG_HXX //autogen -#include <vcl/prndlg.hxx> -#endif #include <tools/stream.hxx> -#ifndef _SV_DRAG_HXX //autogen -//#include <vcl/drag.hxx> -#endif #include <tools/fsys.hxx> #include <svl/stritem.hxx> #include <svtools/ttprops.hxx> @@ -4820,37 +4811,49 @@ BOOL StatementControl::Execute() } break; case M_GetPage: - pRet->GenReturn ( RET_Value, aUId, static_cast<comm_ULONG>(((TabControl*)pControl)->GetTabPage(((TabControl*)pControl)->GetCurPageId())->GetSmartUniqueOrHelpId().GetNum())); //GetNum() ULONG != comm_ULONG on 64bit + pRet->GenReturn ( RET_Value, aUId, ((TabControl*)pControl)->GetTabPage(((TabControl*)pControl)->GetCurPageId())->GetSmartUniqueOrHelpId().GetText()); break; case M_SetPage : { // Wegen lokaler Variablen TabControl *pTControl = ((TabControl*)pControl); USHORT nActive = pTControl->GetCurPageId(); USHORT i,anz; - ULONG nID = 0; + SmartId aID; + SmartId aWantedID; + if ( (nParams & PARAM_ULONG_1) ) + { + aWantedID = SmartId( nLNr1 ); + } + else if ( (nParams & PARAM_STR_1) ) + { + aWantedID = SmartId( aString1 ); + } + else + ReportError( aUId, GEN_RES_STR1( S_INTERNAL_ERROR, MethodString( nMethodId ) ) ); + i = pTControl->GetPagePos( pTControl->GetCurPageId() ); - for ( anz=0 ; anz < pTControl->GetPageCount() && nID != nLNr1 ; anz++ ) + for ( anz=0 ; anz < pTControl->GetPageCount() && !aID.Matches( aWantedID ) ; anz++ ) { pTControl->SelectTabPage( pTControl->GetPageId(i) ); /*if (pTControl->GetCurPageId()) pTControl->DeactivatePage(); pTControl->SetCurPageId( pTControl->GetPageId(i) ); pTControl->ActivatePage();*/ - nID = pTControl->GetTabPage(pTControl->GetCurPageId())->GetSmartUniqueOrHelpId().GetNum(); + aID = pTControl->GetTabPage(pTControl->GetCurPageId())->GetSmartUniqueOrHelpId(); i++; if ( i >= pTControl->GetPageCount() ) i = 0; if ( !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) || !MaybeDoTypeKeysDelay( pTControl ) ) // 3 Mal aufrufen break; } - if ( nID != nLNr1 ) + if ( !aID.Matches( aWantedID ) ) { pTControl->SelectTabPage( nActive ); /*if (pTControl->GetCurPageId()) pTControl->DeactivatePage(); pTControl->SetCurPageId( nActive ); pTControl->ActivatePage();*/ - ReportError( SmartId( nLNr1 ), GEN_RES_STR1( S_TABPAGE_NOT_FOUND, MethodString( nMethodId ) ) ); + ReportError( aWantedID, GEN_RES_STR1( S_TABPAGE_NOT_FOUND, MethodString( nMethodId ) ) ); } } break; diff --git a/basctl/inc/basidesh.hrc b/basctl/inc/basidesh.hrc index e49956302..df99862b3 100644 --- a/basctl/inc/basidesh.hrc +++ b/basctl/inc/basidesh.hrc @@ -58,6 +58,7 @@ #define RID_DLG_NEWLIB ( RID_BASICIDE_START + 42 ) #define RID_DLG_EXPORT ( RID_BASICIDE_START + 43 ) #define RID_POPUP_DLGED ( RID_BASICIDE_START + 62 ) +#define RID_PRINTDLG_STRLIST ( RID_BASICIDE_START + 78 ) #define RID_IMG_LOCKED_HC ( RID_BASICIDE_START + 6 ) #define RID_IMGBTN_REMOVEWATCH ( RID_BASICIDE_START + 8 ) diff --git a/basctl/source/basicide/basicprint.src b/basctl/source/basicide/basicprint.src new file mode 100644 index 000000000..4056461cd --- /dev/null +++ b/basctl/source/basicide/basicprint.src @@ -0,0 +1,43 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: basidesh.src,v $ + * $Revision: 1.107 $ + * + * 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. + * + ************************************************************************/ + +#include <basidesh.hrc> + +StringArray RID_PRINTDLG_STRLIST +{ + ItemList [en-US] = + { + < "Print range"; >; + < "All ~Pages"; >; + < "Print all pages of the printable content."; >; + < "Pa~ges"; >; + < "Print only some pages of the printable content."; >; + }; +}; diff --git a/basctl/source/basicide/basicrenderable.cxx b/basctl/source/basicide/basicrenderable.cxx new file mode 100644 index 000000000..0e61b090a --- /dev/null +++ b/basctl/source/basicide/basicrenderable.cxx @@ -0,0 +1,197 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: basidesh.hxx,v $ + * $Revision: 1.10 $ + * + * 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. + * + ************************************************************************/ +#include "precompiled_basctl.hxx" + +#include "basicrenderable.hxx" +#include "bastypes.hxx" +#include "basidesh.hrc" + +#include "com/sun/star/awt/XDevice.hpp" +#include "toolkit/awt/vclxdevice.hxx" +#include "vcl/print.hxx" +#include "tools/multisel.hxx" +#include "tools/resary.hxx" + +using namespace com::sun::star; +using namespace com::sun::star::uno; +using namespace basicide; + +BasicRenderable::BasicRenderable( IDEBaseWindow* pWin ) +: cppu::WeakComponentImplHelper1< com::sun::star::view::XRenderable >( maMutex ) +, mpWindow( pWin ) +{ + ResStringArray aStrings( IDEResId( RID_PRINTDLG_STRLIST ) ); + DBG_ASSERT( aStrings.Count() >= 5, "resource incomplete" ); + if( aStrings.Count() < 5 ) // bad resource ? + return; + + m_aUIProperties.realloc( 3 ); + + // create Subgroup for print range + vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt; + aPrintRangeOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ); + aPrintRangeOpt.mbInternalOnly = sal_True; + m_aUIProperties[0].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 0 ) ), + rtl::OUString(), + aPrintRangeOpt + ); + + // create a choice for the range to print + rtl::OUString aPrintContentName( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ); + Sequence< rtl::OUString > aChoices( 2 ); + Sequence< rtl::OUString > aHelpTexts( 2 ); + aChoices[0] = aStrings.GetString( 1 ); + aHelpTexts[0] = aStrings.GetString( 2 ); + aChoices[1] = aStrings.GetString( 3 ); + aHelpTexts[1] = aStrings.GetString( 4 ); + m_aUIProperties[1].Value = getChoiceControlOpt( rtl::OUString(), + aHelpTexts, + aPrintContentName, + aChoices, + 0 ); + + // create a an Edit dependent on "Pages" selected + vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintContentName, 1, sal_True ); + m_aUIProperties[2].Value = getEditControlOpt( rtl::OUString(), + rtl::OUString(), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), + rtl::OUString(), + aPageRangeOpt + ); +} + +BasicRenderable::~BasicRenderable() +{ +} + +Printer* BasicRenderable::getPrinter() +{ + Printer* pPrinter = NULL; + Any aValue( getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) ) ); + Reference<awt::XDevice> xRenderDevice; + + if( aValue >>= xRenderDevice ) + { + VCLXDevice* pDevice = VCLXDevice::GetImplementation(xRenderDevice); + OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL; + pPrinter = dynamic_cast<Printer*>(pOut); + } + return pPrinter; +} + +sal_Int32 SAL_CALL BasicRenderable::getRendererCount ( + const Any&, const Sequence<beans::PropertyValue >& i_xOptions + ) throw (lang::IllegalArgumentException, RuntimeException) +{ + processProperties( i_xOptions ); + + sal_Int32 nCount = 0; + if( mpWindow ) + { + Printer* pPrinter = getPrinter(); + if( pPrinter ) + { + nCount = mpWindow->countPages( pPrinter ); + sal_Int64 nContent = getIntValue( "PrintContent", -1 ); + if( nContent == 1 ) + { + rtl::OUString aPageRange( getStringValue( "PageRange" ) ); + MultiSelection aSel( aPageRange ); + long nSelCount = aSel.GetSelectCount(); + if( nSelCount >= 0 && nSelCount < nCount ) + nCount = nSelCount; + } + } + else + throw lang::IllegalArgumentException(); + } + + return nCount; +} + +Sequence<beans::PropertyValue> SAL_CALL BasicRenderable::getRenderer ( + sal_Int32, const Any&, const Sequence<beans::PropertyValue>& i_xOptions + ) throw (lang::IllegalArgumentException, RuntimeException) +{ + processProperties( i_xOptions ); + + Sequence< beans::PropertyValue > aVals; + // insert page size here + Printer* pPrinter = getPrinter(); + // no renderdevice is legal; the first call is to get our print ui options + if( pPrinter ) + { + Size aPageSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) ); + + aVals.realloc( 1 ); + aVals[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ); + awt::Size aSize; + aSize.Width = aPageSize.Width(); + aSize.Height = aPageSize.Height(); + aVals[0].Value <<= aSize; + } + + appendPrintUIOptions( aVals ); + + return aVals; +} + +void SAL_CALL BasicRenderable::render ( + sal_Int32 nRenderer, const Any&, + const Sequence<beans::PropertyValue>& i_xOptions + ) throw (lang::IllegalArgumentException, RuntimeException) +{ + processProperties( i_xOptions ); + + if( mpWindow ) + { + Printer* pPrinter = getPrinter(); + if( pPrinter ) + { + sal_Int64 nContent = getIntValue( "PrintContent", -1 ); + if( nContent == 1 ) + { + rtl::OUString aPageRange( getStringValue( "PageRange" ) ); + MultiSelection aSel( aPageRange ); + long nSelect = aSel.FirstSelected(); + while( nSelect != long(SFX_ENDOFSELECTION) && nRenderer-- ) + nSelect = aSel.NextSelected(); + if( nSelect != long(SFX_ENDOFSELECTION) ) + mpWindow->printPage( sal_Int32(nSelect-1), pPrinter ); + } + else + mpWindow->printPage( nRenderer, pPrinter ); + } + else + throw lang::IllegalArgumentException(); + } +} + + diff --git a/basctl/source/basicide/basicrenderable.hxx b/basctl/source/basicide/basicrenderable.hxx new file mode 100644 index 000000000..b4bf72237 --- /dev/null +++ b/basctl/source/basicide/basicrenderable.hxx @@ -0,0 +1,76 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: basidesh.hxx,v $ + * $Revision: 1.10 $ + * + * 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 _BASICRENDERABLE_HXX +#define _BASICRENDERABLE_HXX + +#include "com/sun/star/view/XRenderable.hpp" +#include "cppuhelper/compbase1.hxx" + +#include "vcl/print.hxx" + +class IDEBaseWindow; + +namespace basicide +{ +class BasicRenderable : + public cppu::WeakComponentImplHelper1< com::sun::star::view::XRenderable >, + public vcl::PrinterOptionsHelper +{ + IDEBaseWindow* mpWindow; + osl::Mutex maMutex; + + Printer* getPrinter(); +public: + BasicRenderable( IDEBaseWindow* pWin ); + virtual ~BasicRenderable(); + + // XRenderable + virtual sal_Int32 SAL_CALL getRendererCount ( + const com::sun::star::uno::Any& aSelection, + const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue >& xOptions) + throw (com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException); + + virtual com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> SAL_CALL getRenderer ( + sal_Int32 nRenderer, + const com::sun::star::uno::Any& rSelection, + const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rxOptions) + throw (com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL render ( + sal_Int32 nRenderer, + const com::sun::star::uno::Any& rSelection, + const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rxOptions) + throw (com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException); + +}; + +} // namespace + +#endif diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx index 39396746f..a80c19a9a 100644 --- a/basctl/source/basicide/baside2.cxx +++ b/basctl/source/basicide/baside2.cxx @@ -110,7 +110,7 @@ DBG_NAME( ModulWindow ) TYPEINIT1( ModulWindow , IDEBaseWindow ); -void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const String& rTitle ) +void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const String& rTitle, bool bOutput ) { short nLeftMargin = LMARGPRN; Size aSz = pPrinter->GetOutputSize(); @@ -136,14 +136,16 @@ void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const S long nXLeft = nLeftMargin-nBorder; long nXRight = aSz.Width()-RMARGPRN+nBorder; - pPrinter->DrawRect( Rectangle( - Point( nXLeft, nYTop ), - Size( nXRight-nXLeft, aSz.Height() - nYTop - BMARGPRN + nBorder ) ) ); + if( bOutput ) + pPrinter->DrawRect( Rectangle( + Point( nXLeft, nYTop ), + Size( nXRight-nXLeft, aSz.Height() - nYTop - BMARGPRN + nBorder ) ) ); long nY = TMARGPRN-2*nBorder; Point aPos( nLeftMargin, nY ); - pPrinter->DrawText( aPos, rTitle ); + if( bOutput ) + pPrinter->DrawText( aPos, rTitle ); if ( nPages != 1 ) { aFont.SetWeight( WEIGHT_NORMAL ); @@ -154,13 +156,15 @@ void lcl_PrintHeader( Printer* pPrinter, USHORT nPages, USHORT nCurPage, const S aPageStr += String::CreateFromInt32( nCurPage ); aPageStr += ']'; aPos.X() += pPrinter->GetTextWidth( rTitle ); - pPrinter->DrawText( aPos, aPageStr ); + if( bOutput ) + pPrinter->DrawText( aPos, aPageStr ); } nY = TMARGPRN-nBorder; - pPrinter->DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) ); + if( bOutput ) + pPrinter->DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) ); pPrinter->SetFont( aOldFont ); pPrinter->SetFillColor( aOldFillColor ); @@ -914,13 +918,28 @@ void __EXPORT ModulWindow::UpdateData() } } +sal_Int32 ModulWindow::countPages( Printer* pPrinter ) +{ + return FormatAndPrint( pPrinter, -1 ); +} + +void ModulWindow::printPage( sal_Int32 nPage, Printer* pPrinter ) +{ + FormatAndPrint( pPrinter, nPage ); +} -void __EXPORT ModulWindow::PrintData( Printer* pPrinter ) +/* implementation note: this is totally inefficient for the XRenderable interface + usage since the whole "document" will be format for every page. Should this ever + become a problem we should + - format only once for every new printer + - keep an index list for each page which is the starting paragraph +*/ +sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, sal_Int32 nPrintPage ) { DBG_CHKTHIS( ModulWindow, 0 ); AssertValidEditEngine(); - + MapMode eOldMapMode( pPrinter->GetMapMode() ); Font aOldFont( pPrinter->GetFont() ); @@ -949,10 +968,8 @@ void __EXPORT ModulWindow::PrintData( Printer* pPrinter ) USHORT nPages = (USHORT) (nParas/nLinespPage+1 ); USHORT nCurPage = 1; - pPrinter->StartJob( aTitle ); - pPrinter->StartPage(); // Header drucken... - lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle ); + lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nPrintPage == 0 ); Point aPos( LMARGPRN, TMARGPRN ); for ( ULONG nPara = 0; nPara < nParas; nPara++ ) { @@ -966,20 +983,19 @@ void __EXPORT ModulWindow::PrintData( Printer* pPrinter ) if ( aPos.Y() > ( aPaperSz.Height()+TMARGPRN ) ) { nCurPage++; - pPrinter->EndPage(); - pPrinter->StartPage(); - lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle ); + lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nCurPage-1 == nPrintPage ); aPos = Point( LMARGPRN, TMARGPRN+nLineHeight ); } - pPrinter->DrawText( aPos, aTmpLine ); + if( nCurPage-1 == nPrintPage ) + pPrinter->DrawText( aPos, aTmpLine ); } aPos.Y() += nParaSpace; } - pPrinter->EndPage(); - pPrinter->EndJob(); pPrinter->SetFont( aOldFont ); pPrinter->SetMapMode( eOldMapMode ); + + return sal_Int32(nCurPage); } diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index f2e752bef..3a92d7fdc 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -359,6 +359,7 @@ private: void GoOnTop(); void AssertValidEditEngine(); + sal_Int32 FormatAndPrint( Printer* pPrinter, sal_Int32 nPage = -1 ); protected: virtual void Resize(); virtual void GetFocus(); @@ -380,7 +381,11 @@ public: virtual void StoreData(); virtual void UpdateData(); virtual BOOL CanClose(); - virtual void PrintData( Printer* pPrinter ); + // virtual void PrintData( Printer* pPrinter ); + // return number of pages to be printed + virtual sal_Int32 countPages( Printer* pPrinter ); + // print page + virtual void printPage( sal_Int32 nPage, Printer* pPrinter ); virtual String GetTitle(); virtual BasicEntryDescriptor CreateEntryDescriptor(); virtual BOOL AllowUndo(); diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index 337aaff9a..dbb7ffbcb 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -1368,9 +1368,14 @@ void DialogWindow::Deactivating() BasicIDE::MarkDocumentModified( GetDocument() ); } -void DialogWindow::PrintData( Printer* pPrinter ) +sal_Int32 DialogWindow::countPages( Printer* pPrinter ) { - pEditor->PrintData( pPrinter, CreateQualifiedName() ); + return pEditor->countPages( pPrinter ); +} + +void DialogWindow::printPage( sal_Int32 nPage, Printer* pPrinter ) +{ + pEditor->printPage( nPage, pPrinter, CreateQualifiedName() ); } void DialogWindow::DataChanged( const DataChangedEvent& rDCEvt ) diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx index aa933d800..bed3dcc3f 100644 --- a/basctl/source/basicide/basides2.cxx +++ b/basctl/source/basicide/basides2.cxx @@ -38,8 +38,7 @@ #include <ide_pch.hxx> #include <basic/sbx.hxx> - -#define _SOLAR__PRIVATE 1 +#include "basicrenderable.hxx" #include <com/sun/star/frame/XTitle.hpp> @@ -85,6 +84,12 @@ IMPL_LINK( BasicIDEShell, ObjectDialogInsertHdl, ObjectCatalog *, pObjCat ) } */ +Reference< view::XRenderable > BasicIDEShell::GetRenderable() +{ + return Reference< view::XRenderable >( new basicide::BasicRenderable( pCurWin ) ); +} + +#if 0 USHORT __EXPORT BasicIDEShell::Print( SfxProgress &rProgress, BOOL bIsAPI, PrintDialog *pPrintDialog ) { if ( pCurWin ) @@ -98,6 +103,7 @@ USHORT __EXPORT BasicIDEShell::Print( SfxProgress &rProgress, BOOL bIsAPI, Print } return 0; } +#endif BOOL BasicIDEShell::HasSelection( BOOL /* bText */ ) const { diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx index c3bf36d0b..9fe7b9840 100644 --- a/basctl/source/basicide/bastypes.cxx +++ b/basctl/source/basicide/bastypes.cxx @@ -207,13 +207,6 @@ void __EXPORT IDEBaseWindow::UpdateData() } - -void __EXPORT IDEBaseWindow::PrintData( Printer* ) -{ -} - - - String __EXPORT IDEBaseWindow::GetTitle() { return String(); diff --git a/basctl/source/basicide/makefile.mk b/basctl/source/basicide/makefile.mk index eeba05b2a..46071f14d 100644 --- a/basctl/source/basicide/makefile.mk +++ b/basctl/source/basicide/makefile.mk @@ -51,7 +51,8 @@ CDEFS+=-DBASICDEBUG # --- Allgemein ---------------------------------------------------------- -EXCEPTIONSFILES=$(SLO)$/scriptdocument.obj \ +EXCEPTIONSFILES=$(SLO)$/basicrenderable.obj \ + $(SLO)$/scriptdocument.obj \ $(SLO)$/basidesh.obj \ $(SLO)$/basides1.obj \ $(SLO)$/basides2.obj \ @@ -84,7 +85,7 @@ SLOFILES = $(EXCEPTIONSFILES) \ $(SLO)$/objdlg.obj \ SRS1NAME=$(TARGET) -SRC1FILES= basidesh.src macrodlg.src moptions.src moduldlg.src objdlg.src brkdlg.src tbxctl.src +SRC1FILES= basidesh.src macrodlg.src moptions.src moduldlg.src objdlg.src brkdlg.src tbxctl.src basicprint.src .INCLUDE : target.mk diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx index de913aa2f..3c9ea57d5 100644 --- a/basctl/source/dlged/dlged.cxx +++ b/basctl/source/dlged/dlged.cxx @@ -1283,7 +1283,20 @@ void lcl_PrintHeader( Printer* pPrinter, const String& rTitle ) // not working y //---------------------------------------------------------------------------- -void DlgEditor::PrintData( Printer* pPrinter, const String& rTitle ) // not working yet +sal_Int32 DlgEditor::countPages( Printer* ) +{ + return 1; +} + +void DlgEditor::printPage( sal_Int32 nPage, Printer* pPrinter, const String& rTitle ) +{ + if( nPage == 0 ) + Print( pPrinter, rTitle ); +} + +//---------------------------------------------------------------------------- + +void DlgEditor::Print( Printer* pPrinter, const String& rTitle ) // not working yet { if( pDlgEdView ) { @@ -1304,8 +1317,6 @@ void DlgEditor::PrintData( Printer* pPrinter, const String& rTitle ) // not work aPaperSz.Width() -= (LMARGPRN+RMARGPRN); aPaperSz.Height() -= (TMARGPRN+BMARGPRN); - pPrinter->StartPage(); - lcl_PrintHeader( pPrinter, rTitle ); Bitmap aDlg; @@ -1350,8 +1361,6 @@ void DlgEditor::PrintData( Printer* pPrinter, const String& rTitle ) // not work pPrinter->DrawBitmap( aPosOffs, aOutputSz, aDlg ); - pPrinter->EndPage(); - pPrinter->SetMapMode( aOldMap ); pPrinter->SetFont( aOldFont ); } diff --git a/basctl/source/inc/baside3.hxx b/basctl/source/inc/baside3.hxx index fe95ea6fa..b5eb6dc3b 100644 --- a/basctl/source/inc/baside3.hxx +++ b/basctl/source/inc/baside3.hxx @@ -110,7 +110,10 @@ public: virtual BOOL IsPasteAllowed(); virtual SfxUndoManager* GetUndoManager(); - virtual void PrintData( Printer* pPrinter ); + // return number of pages to be printed + virtual sal_Int32 countPages( Printer* pPrinter ); + // print page + virtual void printPage( sal_Int32 nPage, Printer* pPrinter ); virtual void Deactivating(); virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); diff --git a/basctl/source/inc/basidesh.hxx b/basctl/source/inc/basidesh.hxx index 40f5a0636..8e379c2c0 100644 --- a/basctl/source/inc/basidesh.hxx +++ b/basctl/source/inc/basidesh.hxx @@ -199,7 +199,9 @@ public: SfxUndoManager* GetUndoManager(); - virtual USHORT Print( SfxProgress &rProgress, BOOL bIsAPI, PrintDialog *pPrintDialog = 0 ); + virtual com::sun::star::uno::Reference< com::sun::star::view::XRenderable > GetRenderable(); + + // virtual USHORT Print( SfxProgress &rProgress, BOOL bIsAPI, PrintDialog *pPrintDialog = 0 ); virtual SfxPrinter* GetPrinter( BOOL bCreate ); virtual USHORT SetPrinter( SfxPrinter *pNewPrinter, USHORT nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false ); virtual String GetSelectionText( BOOL bCompleteWords ); diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx index f3bd547f8..c868d67cf 100644 --- a/basctl/source/inc/bastypes.hxx +++ b/basctl/source/inc/bastypes.hxx @@ -205,8 +205,12 @@ public: virtual void StoreData(); virtual void UpdateData(); - virtual void PrintData( Printer* pPrinter ); virtual BOOL CanClose(); + + // return number of pages to be printed + virtual sal_Int32 countPages( Printer* pPrinter ) = 0; + // print page + virtual void printPage( sal_Int32 nPage, Printer* pPrinter ) = 0; virtual String GetTitle(); String CreateQualifiedName(); diff --git a/basctl/source/inc/dlged.hxx b/basctl/source/inc/dlged.hxx index 03f917787..d625c6e7b 100644 --- a/basctl/source/inc/dlged.hxx +++ b/basctl/source/inc/dlged.hxx @@ -102,6 +102,8 @@ private: DECL_LINK( PaintTimeout, Timer * ); DECL_LINK( MarkTimeout, Timer * ); + void Print( Printer* pPrinter, const String& rTitle ); + protected: ScrollBar* pHScroll; ScrollBar* pVScroll; @@ -199,7 +201,8 @@ public: void ShowProperties(); void UpdatePropertyBrowserDelayed(); - void PrintData( Printer*, const String& rTitle ); // not working yet + sal_Int32 countPages( Printer* pPrinter ); + void printPage( sal_Int32 nPage, Printer* pPrinter, const String& ); bool AdjustPageSize(); diff --git a/cui/source/inc/dbregister.hxx b/cui/source/inc/dbregister.hxx index 84c25b204..a3d905ce9 100644 --- a/cui/source/inc/dbregister.hxx +++ b/cui/source/inc/dbregister.hxx @@ -87,7 +87,7 @@ namespace svx @param _sLocation The location of the file. */ - void insertNewEntry(const ::rtl::OUString& _sName,const ::rtl::OUString& _sLocation); + void insertNewEntry( const ::rtl::OUString& _sName,const ::rtl::OUString& _sLocation, const bool bReadOnly ); /** opens the LinkDialog to create a register pair @param _sOldName diff --git a/cui/source/options/dbregister.cxx b/cui/source/options/dbregister.cxx index 159b6137d..fcbd9bf0b 100644 --- a/cui/source/options/dbregister.cxx +++ b/cui/source/options/dbregister.cxx @@ -190,7 +190,7 @@ DbRegistrationOptionsPage::~DbRegistrationOptionsPage() pHeaderBar->Hide(); for ( USHORT i = 0; i < pPathBox->GetEntryCount(); ++i ) - delete static_cast<String*>(pPathBox->GetEntry(i)->GetUserData()); + delete static_cast< DatabaseRegistration* >( pPathBox->GetEntry(i)->GetUserData() ); delete pPathBox; delete pHeaderBar; } @@ -209,21 +209,22 @@ BOOL DbRegistrationOptionsPage::FillItemSet( SfxItemSet& rCoreSet ) { // the settings for the single drivers sal_Bool bModified = sal_False; - TNameLocationMap aMap; + DatabaseRegistrations aRegistrations; ULONG nCount = pPathBox->GetEntryCount(); for ( ULONG i = 0; i < nCount; ++i ) { SvLBoxEntry* pEntry = pPathBox->GetEntry(i); - String* pPath = static_cast<String*>(pEntry->GetUserData()); - if ( pPath && pPath->Len() ) + DatabaseRegistration* pRegistration = static_cast< DatabaseRegistration* >( pEntry->GetUserData() ); + if ( pRegistration && pRegistration->sLocation.getLength() ) { - OFileNotation aTransformer(*pPath); - aMap.insert(TNameLocationMap::value_type(::rtl::OUString(pPathBox->GetEntryText(pEntry,0)),aTransformer.get(OFileNotation::N_URL))); + ::rtl::OUString sName( pPathBox->GetEntryText( pEntry, 0 ) ); + OFileNotation aTransformer( pRegistration->sLocation ); + aRegistrations[ sName ] = DatabaseRegistration( aTransformer.get( OFileNotation::N_URL ), pRegistration->bReadOnly ); } } - if ( m_nOldCount != aMap.size() || m_bModified ) + if ( m_nOldCount != aRegistrations.size() || m_bModified ) { - rCoreSet.Put(DatabaseMapItem(SID_SB_DB_REGISTER, aMap), SID_SB_DB_REGISTER); + rCoreSet.Put(DatabaseMapItem( SID_SB_DB_REGISTER, aRegistrations ), SID_SB_DB_REGISTER); bModified = sal_True; } @@ -235,47 +236,44 @@ BOOL DbRegistrationOptionsPage::FillItemSet( SfxItemSet& rCoreSet ) void DbRegistrationOptionsPage::Reset( const SfxItemSet& rSet ) { // the settings for the single drivers - SFX_ITEMSET_GET( rSet, pSettings, DatabaseMapItem, SID_SB_DB_REGISTER, sal_True ); + SFX_ITEMSET_GET( rSet, pRegistrations, DatabaseMapItem, SID_SB_DB_REGISTER, sal_True ); + if ( !pRegistrations ) + return; - if ( pSettings ) + pPathBox->Clear(); + + const DatabaseRegistrations& rRegistrations = pRegistrations->getRegistrations(); + m_nOldCount = rRegistrations.size(); + DatabaseRegistrations::const_iterator aIter = rRegistrations.begin(); + DatabaseRegistrations::const_iterator aEnd = rRegistrations.end(); + for ( ; aIter != aEnd; ++aIter ) + { + OFileNotation aTransformer( aIter->second.sLocation ); + insertNewEntry( aIter->first, aTransformer.get( OFileNotation::N_SYSTEM ), aIter->second.bReadOnly ); + } + + String aUserData = GetUserData(); + if ( aUserData.Len() ) { - // TabListBox f"ullen - pPathBox->Clear(); - - const TNameLocationMap& rMap = pSettings->getSettings(); - m_nOldCount = rMap.size(); - TNameLocationMap::const_iterator aIter = rMap.begin(); - TNameLocationMap::const_iterator aEnd = rMap.end(); - for (; aIter != aEnd; ++aIter) + // Spaltenbreite restaurieren + pHeaderBar->SetItemSize( ITEMID_TYPE, aUserData.GetToken(0).ToInt32() ); + HeaderEndDrag_Impl( NULL ); + // Sortierrichtung restaurieren + BOOL bUp = (BOOL)(USHORT)aUserData.GetToken(1).ToInt32(); + HeaderBarItemBits nBits = pHeaderBar->GetItemBits(ITEMID_TYPE); + + if ( bUp ) { - OFileNotation aTransformer(aIter->second); - insertNewEntry(aIter->first,aTransformer.get(OFileNotation::N_SYSTEM)); + nBits &= ~HIB_UPARROW; + nBits |= HIB_DOWNARROW; } - - String aUserData = GetUserData(); - - if ( aUserData.Len() ) + else { - // Spaltenbreite restaurieren - pHeaderBar->SetItemSize( ITEMID_TYPE, aUserData.GetToken(0).ToInt32() ); - HeaderEndDrag_Impl( NULL ); - // Sortierrichtung restaurieren - BOOL bUp = (BOOL)(USHORT)aUserData.GetToken(1).ToInt32(); - HeaderBarItemBits nBits = pHeaderBar->GetItemBits(ITEMID_TYPE); - - if ( bUp ) - { - nBits &= ~HIB_UPARROW; - nBits |= HIB_DOWNARROW; - } - else - { - nBits &= ~HIB_DOWNARROW; - nBits |= HIB_UPARROW; - } - pHeaderBar->SetItemBits( ITEMID_TYPE, nBits ); - HeaderSelect_Impl( NULL ); + nBits &= ~HIB_DOWNARROW; + nBits |= HIB_UPARROW; } + pHeaderBar->SetItemBits( ITEMID_TYPE, nBits ); + HeaderSelect_Impl( NULL ); } } @@ -316,16 +314,19 @@ IMPL_LINK( DbRegistrationOptionsPage, NewHdl, void *, EMPTYARG ) IMPL_LINK( DbRegistrationOptionsPage, EditHdl, void *, EMPTYARG ) { SvLBoxEntry* pEntry = pPathBox->GetCurEntry(); - if ( pEntry ) - { - String* pOldLocation = static_cast<String*>(pEntry->GetUserData()); - String sOldName = pPathBox->GetEntryText(pEntry,0); - m_pCurEntry = pEntry; - openLinkDialog(sOldName,*pOldLocation,pEntry); - m_pCurEntry = NULL; - } + if ( !pEntry ) + return 0L; - return 0; + DatabaseRegistration* pOldRegistration = static_cast< DatabaseRegistration* >( pEntry->GetUserData() ); + if ( !pOldRegistration || pOldRegistration->bReadOnly ) + return 0L; + + String sOldName = pPathBox->GetEntryText(pEntry,0); + m_pCurEntry = pEntry; + openLinkDialog( sOldName, pOldRegistration->sLocation, pEntry ); + m_pCurEntry = NULL; + + return 1L; } // ----------------------------------------------------------------------- @@ -390,28 +391,42 @@ IMPL_LINK( DbRegistrationOptionsPage, HeaderEndDrag_Impl, HeaderBar*, pBar ) // ----------------------------------------------------------------------- IMPL_LINK( DbRegistrationOptionsPage, PathSelect_Impl, SvTabListBox *, EMPTYARG ) - -/* [Beschreibung] - -*/ - { SvLBoxEntry* pEntry = pPathBox->FirstSelected(); - m_aEdit.Enable( pEntry != NULL); - m_aDelete.Enable( pEntry != NULL); + bool bReadOnly = true; + if ( pEntry ) + { + DatabaseRegistration* pRegistration = static_cast< DatabaseRegistration* >( pEntry->GetUserData() ); + bReadOnly = pRegistration->bReadOnly; + } + + m_aEdit.Enable( !bReadOnly ); + m_aDelete.Enable( !bReadOnly ); return 0; } // ----------------------------------------------------------------------------- -void DbRegistrationOptionsPage::insertNewEntry(const ::rtl::OUString& _sName,const ::rtl::OUString& _sLocation) +void DbRegistrationOptionsPage::insertNewEntry( const ::rtl::OUString& _sName,const ::rtl::OUString& _sLocation, const bool _bReadOnly ) { String aStr( _sName ); aStr += '\t'; aStr += String(_sLocation); - SvLBoxEntry* pEntry = pPathBox->InsertEntry( aStr ); - String* pLocation = new String( _sLocation ); - pEntry->SetUserData( pLocation ); + + SvLBoxEntry* pEntry = NULL; + if ( _bReadOnly ) + { + sal_Bool bHighContrast = pPathBox->GetDisplayBackground().GetColor().IsDark(); + Image aLocked( CUI_RES( bHighContrast ? RID_SVXBMP_LOCK_HC : RID_SVXBMP_LOCK ) ); + pEntry = pPathBox->InsertEntry( aStr, aLocked, aLocked ); + } + else + { + pEntry = pPathBox->InsertEntry( aStr ); + } + + pEntry->SetUserData( new DatabaseRegistration( _sLocation, _bReadOnly ) ); } + // ----------------------------------------------------------------------------- String DbRegistrationOptionsPage::getFileLocation(const String& _sLocation) { @@ -482,10 +497,10 @@ void DbRegistrationOptionsPage::openLinkDialog(const String& _sOldName,const Str { if ( _pEntry ) { - delete static_cast<String*>(_pEntry->GetUserData()); - pPathBox->GetModel()->Remove(_pEntry); + delete static_cast< DatabaseRegistration* >( _pEntry->GetUserData() ); + pPathBox->GetModel()->Remove( _pEntry ); } - insertNewEntry(sNewName,sNewLocation); + insertNewEntry( sNewName, sNewLocation, false ); m_bModified = sal_True; } } diff --git a/cui/source/options/dbregisterednamesconfig.cxx b/cui/source/options/dbregisterednamesconfig.cxx index c01097aec..d0f85da8d 100644 --- a/cui/source/options/dbregisterednamesconfig.cxx +++ b/cui/source/options/dbregisterednamesconfig.cxx @@ -30,18 +30,19 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_cui.hxx" +#include "connpooloptions.hxx" #include "dbregisterednamesconfig.hxx" +#include "dbregistersettings.hxx" +#include "svx/svxids.hrc" +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/sdb/XDatabaseRegistrations.hpp> +#include <comphelper/componentcontext.hxx> +#include <comphelper/extract.hxx> +#include <comphelper/processfactory.hxx> +#include <svl/eitem.hxx> #include <svl/itemset.hxx> #include <tools/diagnose_ex.h> #include <unotools/confignode.hxx> -#include <comphelper/extract.hxx> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/uno/XNamingService.hpp> -#include <svl/eitem.hxx> -#include <comphelper/processfactory.hxx> -#include <unotools/pathoptions.hxx> -#include "dbregistersettings.hxx" -#include "connpooloptions.hxx" //........................................................................ namespace svx @@ -50,136 +51,92 @@ namespace svx using namespace ::utl; using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::container; - //-------------------------------------------------------------------- - static const ::rtl::OUString& getDbRegisteredNamesNodeName() - { - static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("org.openoffice.Office.DataAccess/RegisteredNames"); - return s_sNodeName; - } - - //-------------------------------------------------------------------- - static const ::rtl::OUString& getDbNameNodeName() - { - static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Name"); - return s_sNodeName; - } - - //-------------------------------------------------------------------- - static const ::rtl::OUString& getDbLocationNodeName() - { - static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Location"); - return s_sNodeName; - } - //==================================================================== //= DbRegisteredNamesConfig //==================================================================== //-------------------------------------------------------------------- - void DbRegisteredNamesConfig::GetOptions(SfxItemSet& _rFillItems) + void DbRegisteredNamesConfig::GetOptions( SfxItemSet& _rFillItems ) { - // the config node where all pooling relevant info are stored under - OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory( - ::comphelper::getProcessServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_READONLY); - - TNameLocationMap aSettings; + DatabaseRegistrations aSettings; - // then look for which of them settings are stored in the configuration - Sequence< ::rtl::OUString > aDriverKeys = aDbRegisteredNamesRoot.getNodeNames(); - const ::rtl::OUString* pDriverKeys = aDriverKeys.getConstArray(); - const ::rtl::OUString* pDriverKeysEnd = pDriverKeys + aDriverKeys.getLength(); - for (;pDriverKeys != pDriverKeysEnd; ++pDriverKeys) + try { - // the name of the driver in this round - OConfigurationNode aThisDriverSettings = aDbRegisteredNamesRoot.openNode(*pDriverKeys); - ::rtl::OUString sName, sLocation; - aThisDriverSettings.getNodeValue(getDbNameNodeName()) >>= sName; - aThisDriverSettings.getNodeValue(getDbLocationNodeName()) >>= sLocation; - sLocation = SvtPathOptions().SubstituteVariable(sLocation); - - aSettings.insert(TNameLocationMap::value_type(sName,sLocation)); + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + Reference< XDatabaseRegistrations > xRegistrations( + aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW ); + + Sequence< ::rtl::OUString > aRegistrationNames( xRegistrations->getRegistrationNames() ); + const ::rtl::OUString* pRegistrationName = aRegistrationNames.getConstArray(); + const ::rtl::OUString* pRegistrationNamesEnd = pRegistrationName + aRegistrationNames.getLength(); + for ( ; pRegistrationName != pRegistrationNamesEnd; ++pRegistrationName ) + { + ::rtl::OUString sLocation( xRegistrations->getDatabaseLocation( *pRegistrationName ) ); + aSettings[ *pRegistrationName ] = + DatabaseRegistration( sLocation, xRegistrations->isDatabaseRegistrationReadOnly( *pRegistrationName ) ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } - _rFillItems.Put(DatabaseMapItem(SID_SB_DB_REGISTER, aSettings)); + _rFillItems.Put( DatabaseMapItem( SID_SB_DB_REGISTER, aSettings ) ); } //-------------------------------------------------------------------- void DbRegisteredNamesConfig::SetOptions(const SfxItemSet& _rSourceItems) { - // the config node where all pooling relevant info are stored under - OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory( - ::comphelper::getProcessServiceFactory(), getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_UPDATABLE); - - if (!aDbRegisteredNamesRoot.isValid()) - // already asserted by the OConfigurationTreeRoot + // the settings for the single drivers + SFX_ITEMSET_GET( _rSourceItems, pRegistrations, DatabaseMapItem, SID_SB_DB_REGISTER, sal_True ); + if ( !pRegistrations ) return; - sal_Bool bNeedCommit = sal_False; - - - // the settings for the single drivers - SFX_ITEMSET_GET( _rSourceItems, pDriverSettings, DatabaseMapItem, SID_SB_DB_REGISTER, sal_True ); - if (pDriverSettings) + try { - Reference< XNameAccess > xDatabaseContext = Reference< XNameAccess >(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DatabaseContext"))), UNO_QUERY); - Reference< XNamingService> xNamingService(xDatabaseContext,UNO_QUERY); - ::rtl::OUString sName, sLocation; - OConfigurationNode aThisDriverSettings; - - const TNameLocationMap& rNewSettings = pDriverSettings->getSettings(); - TNameLocationMap::const_iterator aEnd = rNewSettings.end(); - for ( TNameLocationMap::const_iterator aLoop = rNewSettings.begin(); - aLoop != aEnd; - ++aLoop + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + Reference< XDatabaseRegistrations > xRegistrations( + aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW ); + + const DatabaseRegistrations& rNewRegistrations = pRegistrations->getRegistrations(); + for ( DatabaseRegistrations::const_iterator reg = rNewRegistrations.begin(); + reg != rNewRegistrations.end(); + ++reg ) { - // need the name as ::rtl::OUString - sName = aLoop->first; + const ::rtl::OUString sName = reg->first; + const ::rtl::OUString sLocation = reg->second.sLocation; - // the sub-node for this driver - if (aDbRegisteredNamesRoot.hasByName(sName)) + if ( xRegistrations->hasRegisteredDatabase( sName ) ) { - aThisDriverSettings = aDbRegisteredNamesRoot.openNode(sName); - // set the values - aThisDriverSettings.setNodeValue(getDbNameNodeName(), makeAny(sName)); - aThisDriverSettings.setNodeValue(getDbLocationNodeName(), makeAny(aLoop->second)); - bNeedCommit = sal_True; - } - else - { - try - { - xNamingService->registerObject(sName,Reference< ::com::sun::star::uno::XInterface >(xDatabaseContext->getByName(aLoop->second),UNO_QUERY)); - } - catch( const Exception& ) + if ( !xRegistrations->isDatabaseRegistrationReadOnly( sName ) ) + xRegistrations->changeDatabaseLocation( sName, sLocation ); + else { - DBG_UNHANDLED_EXCEPTION(); + OSL_ENSURE( xRegistrations->getDatabaseLocation( sName ) == sLocation, + "DbRegisteredNamesConfig::SetOptions: somebody changed a read-only registration. How unrespectful." ); } } + else + xRegistrations->registerDatabaseLocation( sName, sLocation ); } - if (bNeedCommit) - aDbRegisteredNamesRoot.commit(); - // delete unused entry - Sequence< ::rtl::OUString > aDriverKeys = xDatabaseContext->getElementNames(); - const ::rtl::OUString* pDriverKeys = aDriverKeys.getConstArray(); - const ::rtl::OUString* pDriverKeysEnd = pDriverKeys + aDriverKeys.getLength(); - for (;pDriverKeys != pDriverKeysEnd; ++pDriverKeys) + // delete unused entries + Sequence< ::rtl::OUString > aRegistrationNames = xRegistrations->getRegistrationNames(); + const ::rtl::OUString* pRegistrationName = aRegistrationNames.getConstArray(); + const ::rtl::OUString* pRegistrationNamesEnd = pRegistrationName + aRegistrationNames.getLength(); + for ( ; pRegistrationName != pRegistrationNamesEnd; ++pRegistrationName ) { - if ( rNewSettings.find(*pDriverKeys) == rNewSettings.end() ) - { - try - { - xNamingService->revokeObject(*pDriverKeys); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - } + if ( rNewRegistrations.find( *pRegistrationName ) == rNewRegistrations.end() ) + xRegistrations->revokeDatabaseLocation( *pRegistrationName ); } } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //........................................................................ diff --git a/cui/source/options/dbregistersettings.cxx b/cui/source/options/dbregistersettings.cxx index 5e3546775..93852148e 100644 --- a/cui/source/options/dbregistersettings.cxx +++ b/cui/source/options/dbregistersettings.cxx @@ -33,6 +33,8 @@ #include "dbregistersettings.hxx" +#include <rtl/ustring.hxx> + //........................................................................ namespace svx { @@ -43,9 +45,9 @@ namespace svx //==================================================================== TYPEINIT1( DatabaseMapItem, SfxPoolItem ) //-------------------------------------------------------------------- - DatabaseMapItem::DatabaseMapItem( sal_uInt16 _nId, const TNameLocationMap& _rSettings ) - :SfxPoolItem(_nId) - ,m_aSettings(_rSettings) + DatabaseMapItem::DatabaseMapItem( sal_uInt16 _nId, const DatabaseRegistrations& _rRegistrations ) + :SfxPoolItem( _nId ) + ,m_aRegistrations( _rRegistrations ) { } @@ -53,19 +55,19 @@ namespace svx int DatabaseMapItem::operator==( const SfxPoolItem& _rCompare ) const { const DatabaseMapItem* pItem = PTR_CAST(DatabaseMapItem, &_rCompare); - if (!pItem) + if ( !pItem ) return sal_False; - if (m_aSettings.size() != pItem->m_aSettings.size()) + if ( m_aRegistrations.size() != pItem->m_aRegistrations.size() ) return sal_False; - return m_aSettings != pItem->m_aSettings; + return m_aRegistrations == pItem->m_aRegistrations; } //-------------------------------------------------------------------- - SfxPoolItem* DatabaseMapItem::Clone( SfxItemPool * ) const + SfxPoolItem* DatabaseMapItem::Clone( SfxItemPool* ) const { - return new DatabaseMapItem(Which(), m_aSettings); + return new DatabaseMapItem( Which(), m_aRegistrations ); } //-------------------------------------------------------------------- diff --git a/cui/source/options/dbregistersettings.hxx b/cui/source/options/dbregistersettings.hxx index ff3f3c6fb..ebbd30257 100644 --- a/cui/source/options/dbregistersettings.hxx +++ b/cui/source/options/dbregistersettings.hxx @@ -39,24 +39,56 @@ namespace svx { //........................................................................ + struct DatabaseRegistration + { + ::rtl::OUString sLocation; + bool bReadOnly; + + DatabaseRegistration() + :sLocation() + ,bReadOnly( true ) + { + } + + DatabaseRegistration( const ::rtl::OUString& _rLocation, const sal_Bool _bReadOnly ) + :sLocation( _rLocation ) + ,bReadOnly( _bReadOnly ) + { + } + + bool operator==( const DatabaseRegistration& _rhs ) const + { + return ( sLocation == _rhs.sLocation ); + // do not take the read-only-ness into account, this is not maintained everywhere, but only + // properly set when filling the struct from the XDatabaseRegistrations data + } + + bool operator!=( const DatabaseRegistration& _rhs ) const + { + return !( this->operator==( _rhs ) ); + } + }; + + typedef ::std::map< ::rtl::OUString, DatabaseRegistration, ::comphelper::UStringLess > DatabaseRegistrations; + //==================================================================== //= DatabaseMapItem //==================================================================== - DECLARE_STL_USTRINGACCESS_MAP(::rtl::OUString,TNameLocationMap); class DatabaseMapItem : public SfxPoolItem { protected: - TNameLocationMap m_aSettings; + DatabaseRegistrations m_aRegistrations; public: TYPEINFO(); - DatabaseMapItem( sal_uInt16 _nId, const TNameLocationMap& _rSettings ); + DatabaseMapItem( sal_uInt16 _nId, const DatabaseRegistrations& _rRegistrations ); virtual int operator==( const SfxPoolItem& ) const; virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; - const TNameLocationMap& getSettings() const { return m_aSettings; } + const DatabaseRegistrations& + getRegistrations() const { return m_aRegistrations; } }; //........................................................................ diff --git a/extensions/source/abpilot/datasourcehandling.cxx b/extensions/source/abpilot/datasourcehandling.cxx index e1f3065dc..76bb4307e 100644 --- a/extensions/source/abpilot/datasourcehandling.cxx +++ b/extensions/source/abpilot/datasourcehandling.cxx @@ -30,30 +30,34 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_extensions.hxx" + +#include "abpresid.hrc" +#include "abptypes.hxx" +#include "componentmodule.hxx" #include "datasourcehandling.hxx" + #include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/sdb/SQLContext.hpp> -#include <com/sun/star/task/XInteractionHandler.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/frame/XStorable.hpp> -#include <com/sun/star/uno/XNamingService.hpp> #include <com/sun/star/lang/XComponent.hpp> -#include <com/sun/star/sdbc/XConnection.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/sdb/SQLContext.hpp> #include <com/sun/star/sdb/XCompletedConnection.hpp> +#include <com/sun/star/sdb/XDatabaseRegistrations.hpp> #include <com/sun/star/sdb/XDocumentDataSource.hpp> +#include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/sdbcx/XTablesSupplier.hpp> -#include <tools/debug.hxx> +#include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/uno/XNamingService.hpp> + #include <comphelper/interaction.hxx> -#include <vcl/stdtext.hxx> -#ifndef EXTENSIONS_ABPRESID_HRC -#include "abpresid.hrc" -#endif -#include "componentmodule.hxx" -#include "abptypes.hxx" +#include <comphelper/componentcontext.hxx> +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> #include <unotools/confignode.hxx> #include <unotools/sharedunocomponent.hxx> +#include <vcl/stdtext.hxx> //......................................................................... namespace abp @@ -76,26 +80,6 @@ namespace abp struct PackageAccessControl { }; //===================================================================== - //-------------------------------------------------------------------- - static const ::rtl::OUString& getDbRegisteredNamesNodeName() - { - static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("org.openoffice.Office.DataAccess/RegisteredNames"); - return s_sNodeName; - } - - //-------------------------------------------------------------------- - static const ::rtl::OUString& getDbNameNodeName() - { - static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Name"); - return s_sNodeName; - } - - //-------------------------------------------------------------------- - static const ::rtl::OUString& getDbLocationNodeName() - { - static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Location"); - return s_sNodeName; - } //--------------------------------------------------------------------- static Reference< XNameAccess > lcl_getDataSourceContext( const Reference< XMultiServiceFactory >& _rxORB ) SAL_THROW (( Exception )) { @@ -173,28 +157,24 @@ namespace abp const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _sName, const ::rtl::OUString& _sURL ) SAL_THROW (( ::com::sun::star::uno::Exception )) { - // the config node where all pooling relevant info are stored under - OConfigurationTreeRoot aDbRegisteredNamesRoot = OConfigurationTreeRoot::createWithServiceFactory( - _rxORB, getDbRegisteredNamesNodeName(), -1, OConfigurationTreeRoot::CM_UPDATABLE); - - if (!aDbRegisteredNamesRoot.isValid()) - // already asserted by the OConfigurationTreeRoot - return; - - OSL_ENSURE(_sName.getLength(),"No Name given!"); - OSL_ENSURE(_sURL.getLength(),"No URL given!"); - - OConfigurationNode aThisDriverSettings; - if ( aDbRegisteredNamesRoot.hasByName(_sName) ) - aThisDriverSettings = aDbRegisteredNamesRoot.openNode(_sName); - else - aThisDriverSettings = aDbRegisteredNamesRoot.createNode(_sName); + OSL_ENSURE( _sName.getLength(), "lcl_registerDataSource: invalid name!" ); + OSL_ENSURE( _sURL.getLength(), "lcl_registerDataSource: invalid URL!" ); + try + { - // set the values - aThisDriverSettings.setNodeValue(getDbNameNodeName(), makeAny(_sName)); - aThisDriverSettings.setNodeValue(getDbLocationNodeName(), makeAny(_sURL)); + ::comphelper::ComponentContext aContext( _rxORB ); + Reference< XDatabaseRegistrations > xRegistrations( + aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW ); - aDbRegisteredNamesRoot.commit(); + if ( xRegistrations->hasRegisteredDatabase( _sName ) ) + xRegistrations->changeDatabaseLocation( _sName, _sURL ); + else + xRegistrations->registerDatabaseLocation( _sName, _sURL ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //===================================================================== diff --git a/extensions/source/bibliography/datman.cxx b/extensions/source/bibliography/datman.cxx index aa31df288..af4369b84 100644 --- a/extensions/source/bibliography/datman.cxx +++ b/extensions/source/bibliography/datman.cxx @@ -31,6 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_extensions.hxx" #include <osl/mutex.hxx> +#include <tools/diagnose_ex.h> #include <tools/urlobj.hxx> #include <comphelper/processfactory.hxx> #include <com/sun/star/io/XPersistObject.hpp> @@ -887,12 +888,14 @@ void BibDataManager::InsertFields(const Reference< XFormComponent > & _rxGrid) case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: sCurrentModelType = C2U("TextField"); break; case DataType::VARCHAR: case DataType::LONGVARCHAR: case DataType::CHAR: + case DataType::CLOB: bFormattedIsNumeric = sal_False; // _NO_ break ! default: @@ -1085,20 +1088,16 @@ void BibDataManager::setFilter(const ::rtl::OUString& rQuery) return; try { - m_xParser->setFilter(rQuery); - ::rtl::OUString aQuery=m_xParser->getFilter(); - Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY ); - Any aVal; aVal <<= aQuery; - aPropertySet->setPropertyValue(C2U("Filter"), aVal); - BOOL bVal = sal_True; - aVal.setValue(&bVal, ::getBooleanCppuType()); - aPropertySet->setPropertyValue(C2U("ApplyFilter"), aVal); + m_xParser->setFilter( rQuery ); + ::rtl::OUString aQuery = m_xParser->getFilter(); + Reference< XPropertySet > xFormProps( m_xForm, UNO_QUERY_THROW ); + xFormProps->setPropertyValue( C2U( "Filter" ), makeAny( aQuery ) ); + xFormProps->setPropertyValue( C2U( "ApplyFilter" ), makeAny( sal_True ) ); reload(); } catch(Exception& e ) { - (void) e; // make compiler happy - DBG_ERROR("::setFilterOnActiveDataSource: something went wrong !"); + DBG_UNHANDLED_EXCEPTION(); } @@ -1110,18 +1109,12 @@ void BibDataManager::setFilter(const ::rtl::OUString& rQuery) ::rtl::OUString aQueryString; try { - Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY ); - Any aQuery=aPropertySet->getPropertyValue(C2U("Filter")); - - if(aQuery.getValueType() == ::getCppuType((::rtl::OUString*)0)) - { - aQueryString=*(::rtl::OUString*)aQuery.getValue(); - } + Reference< XPropertySet > xFormProps( m_xForm, UNO_QUERY_THROW ); + OSL_VERIFY( xFormProps->getPropertyValue( C2U( "Filter" ) ) >>= aQueryString ); } - catch(Exception& e ) + catch( const Exception& ) { - (void) e; // make compiler happy - DBG_ERROR("::getFilterOnActiveDataSource: something went wrong !"); + DBG_UNHANDLED_EXCEPTION(); } @@ -1795,13 +1788,13 @@ void BibDataManager::SetToolbar(BibToolBar* pSet) /* -----------------------------08.05.2002 09:26------------------------------ ---------------------------------------------------------------------------*/ -uno::Reference< form::XFormController > BibDataManager::GetFormController() +uno::Reference< form::runtime::XFormController > BibDataManager::GetFormController() { if(!m_xFormCtrl.is()) { Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory(); - m_xFormCtrl = uno::Reference< form::XFormController > ( - xMgr->createInstance(C2U("com.sun.star.form.FormController")), UNO_QUERY); + m_xFormCtrl = uno::Reference< form::runtime::XFormController > ( + xMgr->createInstance(C2U("com.sun.star.form.runtime.FormController")), UNO_QUERY); m_xFormCtrl->setModel(uno::Reference< awt::XTabControllerModel > (getForm(), UNO_QUERY)); // #100312# ------------- m_xFormDispatch = uno::Reference< frame::XDispatch > ( m_xFormCtrl, UNO_QUERY); diff --git a/extensions/source/bibliography/datman.hxx b/extensions/source/bibliography/datman.hxx index 5dcb96fba..2e6c76d86 100644 --- a/extensions/source/bibliography/datman.hxx +++ b/extensions/source/bibliography/datman.hxx @@ -35,7 +35,7 @@ #include <com/sun/star/form/XForm.hpp> #include <com/sun/star/sdbc/XResultSet.hpp> #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> -#include <com/sun/star/form/XFormController.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> #include <cppuhelper/compbase2.hxx> #include <cppuhelper/interfacecontainer.h> #include <com/sun/star/form/XLoadable.hpp> @@ -98,7 +98,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > m_xGridModel; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xSourceProps; ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xParser; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > m_xFormCtrl; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xFormCtrl; // #100312# ------------------- ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xFormDispatch; BibInterceptorHelper* m_pInterceptorHelper; @@ -191,7 +191,7 @@ public: const rtl::OUString& GetIdentifierMapping(); void ResetIdentifierMapping() {sIdentifierMapping = rtl::OUString();} - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > GetFormController(); + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > GetFormController(); // #100312# ---------- void RegisterInterceptor( ::bib::BibBeamer* pBibBeamer); diff --git a/extensions/source/bibliography/framectr.cxx b/extensions/source/bibliography/framectr.cxx index a5012e0bd..2dd792472 100644 --- a/extensions/source/bibliography/framectr.cxx +++ b/extensions/source/bibliography/framectr.cxx @@ -50,7 +50,7 @@ #include "bibliography.hrc" #include <comphelper/processfactory.hxx> #include <com/sun/star/form/XConfirmDeleteListener.hpp> -#include <com/sun/star/form/XFormController.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> #include <com/sun/star/beans/PropertyState.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> @@ -384,7 +384,7 @@ sal_Bool canInsertRecords(const Reference< beans::XPropertySet>& _rxCursorSet) /* -----------------------------08.05.2002 08:58------------------------------ ---------------------------------------------------------------------------*/ -sal_Bool BibFrameController_Impl::SaveModified(const Reference< form::XFormController>& xController) +sal_Bool BibFrameController_Impl::SaveModified(const Reference< form::runtime::XFormController>& xController) { if (!xController.is()) return sal_False; @@ -592,7 +592,7 @@ void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequen } else if(aCommand.EqualsAscii("Bib/InsertRecord")) { - Reference<form::XFormController > xFormCtrl = pDatMan->GetFormController(); + Reference<form::runtime::XFormController > xFormCtrl = pDatMan->GetFormController(); if(SaveModified(xFormCtrl)) { try diff --git a/extensions/source/bibliography/framectr.hxx b/extensions/source/bibliography/framectr.hxx index 0e0c59e74..81cc44365 100644 --- a/extensions/source/bibliography/framectr.hxx +++ b/extensions/source/bibliography/framectr.hxx @@ -44,9 +44,9 @@ class BibDataManager; class BibFrameCtrl_Impl; namespace com{namespace sun{namespace star{ - namespace form{ + namespace form { namespace runtime { class XFormController; - } + } } }}} class BibStatusDispatch { @@ -83,7 +83,7 @@ friend class BibFrameCtrl_Impl; DECL_STATIC_LINK( BibFrameController_Impl, DisposeHdl, void* ); - sal_Bool SaveModified(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController>& xController); + sal_Bool SaveModified(const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& xController); public: BibFrameController_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > & xComponent, BibDataManager* pDatMan); diff --git a/extensions/source/bibliography/general.cxx b/extensions/source/bibliography/general.cxx index 652dafc1c..babec89c2 100644 --- a/extensions/source/bibliography/general.cxx +++ b/extensions/source/bibliography/general.cxx @@ -417,7 +417,7 @@ BibGeneralPage::BibGeneralPage(Window* pParent, BibDataManager* pMan): uno::Reference< sdbc::XRowSet > xRowSet(pDatMan->getForm(), UNO_QUERY); if(xRowSet.is()) xRowSet->addRowSetListener(xPosListener); - uno::Reference< form::XFormController > xFormCtrl = pDatMan->GetFormController(); + uno::Reference< form::runtime::XFormController > xFormCtrl = pDatMan->GetFormController(); xFormCtrl->setContainer(xCtrlContnr); xFormCtrl->activateTabOrder(); @@ -454,7 +454,7 @@ BibGeneralPage::~BibGeneralPage() ---------------------------------------------------------------------------*/ void BibGeneralPage::CommitActiveControl() { - uno::Reference< form::XFormController > xFormCtrl = pDatMan->GetFormController(); + uno::Reference< form::runtime::XFormController > xFormCtrl = pDatMan->GetFormController(); uno::Reference< awt::XControl > xCurr = xFormCtrl->getCurrentControl(); if(xCurr.is()) { diff --git a/extensions/source/propctrlr/editpropertyhandler.cxx b/extensions/source/propctrlr/editpropertyhandler.cxx index b78ee1355..7e6987494 100644 --- a/extensions/source/propctrlr/editpropertyhandler.cxx +++ b/extensions/source/propctrlr/editpropertyhandler.cxx @@ -298,6 +298,7 @@ namespace pcr _rxInspectorUI->enablePropertyUI( PROPERTY_DEFAULT_TEXT, nTextType != TEXTTYPE_RICHTEXT ); _rxInspectorUI->enablePropertyUI( PROPERTY_SHOW_SCROLLBARS, nTextType != TEXTTYPE_SINGLELINE ); _rxInspectorUI->enablePropertyUI( PROPERTY_LINEEND_FORMAT, nTextType != TEXTTYPE_SINGLELINE ); + _rxInspectorUI->enablePropertyUI( PROPERTY_VERTICAL_ALIGN, nTextType == TEXTTYPE_SINGLELINE ); _rxInspectorUI->showCategory( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) ), nTextType != TEXTTYPE_RICHTEXT ); } diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx index 7e7140772..b7baa76d1 100644 --- a/extensions/source/propctrlr/eventhandler.cxx +++ b/extensions/source/propctrlr/eventhandler.cxx @@ -55,7 +55,7 @@ #include <com/sun/star/container/XNameReplace.hpp> #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/form/XForm.hpp> -#include <com/sun/star/form/XFormController.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> #include <com/sun/star/inspection/PropertyControlType.hpp> #include <com/sun/star/lang/NullPointerException.hpp> #include <com/sun/star/script/XEventAttacherManager.hpp> @@ -118,7 +118,7 @@ namespace pcr using ::com::sun::star::container::XNameContainer; using ::com::sun::star::awt::XTabControllerModel; using ::com::sun::star::form::XForm; - using ::com::sun::star::form::XFormController; + using ::com::sun::star::form::runtime::XFormController; using ::com::sun::star::beans::UnknownPropertyException; using ::com::sun::star::uno::makeAny; using ::com::sun::star::container::NoSuchElementException; @@ -1155,7 +1155,7 @@ namespace pcr m_aContext.createComponent( (const rtl::OUString&)SERVICE_FORMCONTROLLER ), UNO_QUERY_THROW ); xController->setModel( xComponentAsTCModel ); - xReturn = xController.get(); + xReturn = xController; } else { diff --git a/forms/qa/forms_all.sce b/forms/qa/forms_all.sce index 6b5344f60..3aef2c95e 100644 --- a/forms/qa/forms_all.sce +++ b/forms/qa/forms_all.sce @@ -5,3 +5,4 @@ -o integration.forms.ListSelection -o integration.forms.MasterDetailForms -o integration.forms.XMLFormSettings +-o integration.forms.ListBox diff --git a/forms/qa/integration/forms/DocumentViewHelper.java b/forms/qa/integration/forms/DocumentViewHelper.java index f3f94c169..911694882 100644 --- a/forms/qa/integration/forms/DocumentViewHelper.java +++ b/forms/qa/integration/forms/DocumentViewHelper.java @@ -39,7 +39,7 @@ import com.sun.star.beans.XPropertySet; import com.sun.star.container.XIndexContainer; import com.sun.star.form.FormComponentType; import com.sun.star.form.XForm; -import com.sun.star.form.XFormController; +import com.sun.star.form.runtime.XFormController; import com.sun.star.frame.XController; import com.sun.star.frame.XDispatch; import com.sun.star.frame.XDispatchProvider; @@ -190,10 +190,9 @@ public class DocumentViewHelper /* ------------------------------------------------------------------ */ /** retrieves the form controller for a given logical form */ - public XFormController getFormController( XPropertySet _form ) + public XFormController getFormController( Object _form ) { - XFormLayerAccess formLayerAccess = (XFormLayerAccess)query( XFormLayerAccess.class ); - return formLayerAccess.getFormController( (XForm)UnoRuntime.queryInterface( XForm.class, _form ) ); + return getFormController( UnoRuntime.queryInterface( XForm.class, _form )); } /* ------------------------------------------------------------------ */ diff --git a/forms/qa/integration/forms/FormControlTest.java b/forms/qa/integration/forms/FormControlTest.java index 3e9646628..a97ab3ab4 100644 --- a/forms/qa/integration/forms/FormControlTest.java +++ b/forms/qa/integration/forms/FormControlTest.java @@ -33,7 +33,7 @@ import com.sun.star.awt.XImageProducer; import com.sun.star.beans.PropertyValue; import com.sun.star.beans.XPropertySet; import com.sun.star.container.XNameAccess; -import com.sun.star.form.XFormController; +import com.sun.star.form.runtime.XFormController; import com.sun.star.form.XImageProducerSupplier; import com.sun.star.frame.XDispatch; import com.sun.star.lang.EventObject; @@ -52,6 +52,7 @@ import com.sun.star.util.URL; import com.sun.star.util.XCloseable; import com.sun.star.util.XURLTransformer; import connectivity.tools.HsqlDatabase; +import connectivity.tools.sdb.Connection; import java.io.FileOutputStream; @@ -609,8 +610,8 @@ public class FormControlTest extends complexlib.ComplexTestCase implements XSQLE /* ------------------------------------------------------------------ */ private boolean ensureTables() throws com.sun.star.uno.Exception, java.lang.Exception { - XConnection xConn = m_dataSource.getConnection( "", "" ); - assure( "could not connect to the data source", xConn != null ); + Connection connection = new Connection( m_dataSource.getConnection( "", "" ) ); + assure( "could not connect to the data source", connection != null ); // drop the table, if it already exists if ( !implExecuteStatement( "DROP TABLE \"" + s_tableName + "\" IF EXISTS" ) @@ -630,10 +631,10 @@ public class FormControlTest extends complexlib.ComplexTestCase implements XSQLE return false; } - m_databaseDocument.getDataSource().refreshTables( xConn ); + connection.refreshTables(); // do not need the connection anymore - dbfTools.disposeComponent( xConn ); + connection.close(); return true; } diff --git a/forms/qa/integration/forms/FormLayer.java b/forms/qa/integration/forms/FormLayer.java index 962515d92..f241fe338 100644 --- a/forms/qa/integration/forms/FormLayer.java +++ b/forms/qa/integration/forms/FormLayer.java @@ -31,7 +31,6 @@ package integration.forms; import com.sun.star.accessibility.XAccessible; import com.sun.star.accessibility.XAccessibleEditableText; -import com.sun.star.container.XNameAccess; import com.sun.star.uno.UnoRuntime; import com.sun.star.beans.XPropertySet; @@ -42,7 +41,9 @@ import com.sun.star.drawing.XControlShape; import com.sun.star.drawing.XShapes; import com.sun.star.awt.Size; import com.sun.star.awt.Point; +import com.sun.star.awt.VisualEffect; import com.sun.star.awt.XControlModel; +import com.sun.star.container.XNameAccess; import com.sun.star.text.TextContentAnchorType; import com.sun.star.drawing.XDrawPage; @@ -95,12 +96,12 @@ public class FormLayer the property access to the control's model */ public XPropertySet createControlAndShape( String sFormComponentService, int nXPos, - int nYPos, int nWidth, int nHeight, XIndexContainer xParentForm ) throws java.lang.Exception + int nYPos, int nWidth, int nHeight, Object _parentForm ) throws java.lang.Exception { // let the document create a shape - XMultiServiceFactory xDocAsFactory = (XMultiServiceFactory)UnoRuntime.queryInterface( + XMultiServiceFactory xDocAsFactory = UnoRuntime.queryInterface( XMultiServiceFactory.class, m_document.getDocument() ); - XControlShape xShape = (XControlShape)UnoRuntime.queryInterface( XControlShape.class, + XControlShape xShape = UnoRuntime.queryInterface( XControlShape.class, xDocAsFactory.createInstance( "com.sun.star.drawing.ControlShape" ) ); // position and size of the shape @@ -114,13 +115,18 @@ public class FormLayer // create the form component (the model of a form control) String sQualifiedComponentName = "com.sun.star.form.component." + sFormComponentService; - XControlModel xModel = (XControlModel)UnoRuntime.queryInterface( XControlModel.class, + XControlModel xModel = UnoRuntime.queryInterface( XControlModel.class, m_document.getOrb().createInstance( sQualifiedComponentName ) ); // insert the model into the form component hierarchy, if the caller gave us a location - if ( null != xParentForm ) + if ( null != _parentForm ) { - xParentForm.insertByIndex( xParentForm.getCount(), xModel ); + XIndexContainer parentForm = null; + if ( _parentForm instanceof XIndexContainer ) + parentForm = (XIndexContainer)_parentForm; + else + parentForm = UnoRuntime.queryInterface( XIndexContainer.class, _parentForm ); + parentForm.insertByIndex( parentForm.getCount(), xModel ); } // knitt them @@ -129,7 +135,7 @@ public class FormLayer // add the shape to the shapes collection of the document XDrawPage pageWhereToInsert = ( m_page != null ) ? m_page : m_document.getMainDrawPage(); - XShapes xDocShapes = (XShapes)UnoRuntime.queryInterface( XShapes.class, pageWhereToInsert ); + XShapes xDocShapes = UnoRuntime.queryInterface( XShapes.class, pageWhereToInsert ); xDocShapes.add( xShape ); // and outta here with the XPropertySet interface of the model @@ -220,7 +226,7 @@ public class FormLayer @return the control model of the created data input field */ - public XPropertySet insertControlLine( String sControlType, String sFieldName, String sControlNamePostfix, + public XPropertySet insertControlLine( String sControlType, String sFieldName, String _controlNamePostfix, int nXPos, int nYPos, int nHeight ) throws java.lang.Exception { @@ -231,12 +237,20 @@ public class FormLayer // insert the text field control XPropertySet xFieldModel = createControlAndShape( sControlType, nXPos + 26, nYPos, 40, nHeight ); xFieldModel.setPropertyValue( "DataField", sFieldName ); + if ( xFieldModel.getPropertySetInfo().hasPropertyByName( "Border" ) ) + { + xFieldModel.setPropertyValue( "Border", new Short( VisualEffect.FLAT ) ); + if ( xFieldModel.getPropertySetInfo().hasPropertyByName( "BorderColor" ) ) + xFieldModel.setPropertyValue( "BorderColor", new Integer( 0x00C0C0C0 ) ); + } // knit it to it's label component xFieldModel.setPropertyValue( "LabelControl", xLabelModel ); // some names, so later on we can find them - xLabelModel.setPropertyValue( "Name", sFieldName + sControlNamePostfix + "_Label" ); - xFieldModel.setPropertyValue( "Name", sFieldName + sControlNamePostfix ); + if ( _controlNamePostfix == null ) + _controlNamePostfix = ""; + xLabelModel.setPropertyValue( "Name", sFieldName + _controlNamePostfix + "_Label" ); + xFieldModel.setPropertyValue( "Name", sFieldName + _controlNamePostfix ); return xFieldModel; } @@ -256,7 +270,7 @@ public class FormLayer public XPropertySet insertControlLine( String sControlType, String sFieldName, String sControlNamePostfix, int nYPos ) throws java.lang.Exception { - return insertControlLine( sControlType, sFieldName, sControlNamePostfix, 2, nYPos, 6 ); + return insertControlLine( sControlType, sFieldName, sControlNamePostfix, 10, nYPos, 6 ); } /* ------------------------------------------------------------------ */ @@ -270,8 +284,7 @@ public class FormLayer */ public XPropertySet getRadioModelByRefValue( XPropertySet form, String name, String refValue ) throws com.sun.star.uno.Exception, java.lang.Exception { - XIndexAccess indexAccess = (XIndexAccess)UnoRuntime.queryInterface( XIndexAccess.class, - form ); + XIndexAccess indexAccess = UnoRuntime.queryInterface( XIndexAccess.class, form ); for ( int i=0; i<indexAccess.getCount(); ++i ) { @@ -295,8 +308,7 @@ public class FormLayer */ public XPropertySet getRadioModelByTag( XPropertySet form, String name, String tag ) throws com.sun.star.uno.Exception, java.lang.Exception { - XIndexAccess indexAccess = (XIndexAccess)UnoRuntime.queryInterface( XIndexAccess.class, - form ); + XIndexAccess indexAccess = UnoRuntime.queryInterface( XIndexAccess.class, form ); for ( int i=0; i<indexAccess.getCount(); ++i ) { @@ -357,10 +369,10 @@ public class FormLayer // doing a user input, as the latter will trigger a lot of notifications, which the forms runtime environment // (namely the FormController) relies on to notice that the control changed. // Instead, we use the Accessibility interfaces of the control to simulate text input - XAccessible formattedAccessible = (XAccessible)UnoRuntime.queryInterface( XAccessible.class, + XAccessible formattedAccessible = UnoRuntime.queryInterface( XAccessible.class, m_document.getCurrentView().getControl( controlModel ) ); - XAccessibleEditableText textAccess = (XAccessibleEditableText)UnoRuntime.queryInterface( XAccessibleEditableText.class, + XAccessibleEditableText textAccess = UnoRuntime.queryInterface( XAccessibleEditableText.class, formattedAccessible.getAccessibleContext() ); textAccess.setText( text ); } diff --git a/forms/qa/integration/forms/FormPropertyBags.java b/forms/qa/integration/forms/FormPropertyBags.java index 5a0611c2a..c5cac6bef 100644 --- a/forms/qa/integration/forms/FormPropertyBags.java +++ b/forms/qa/integration/forms/FormPropertyBags.java @@ -47,8 +47,6 @@ import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.util.XCloseable; -import integration.forms.DocumentHelper; - public class FormPropertyBags extends complexlib.ComplexTestCase implements XPropertyChangeListener { private DocumentHelper m_document; @@ -90,8 +88,7 @@ public class FormPropertyBags extends complexlib.ComplexTestCase implements XPro { if ( m_document != null ) { - XCloseable closeDoc = (XCloseable)UnoRuntime.queryInterface( XCloseable.class, - m_document.getDocument() ); + XCloseable closeDoc = UnoRuntime.queryInterface( XCloseable.class, m_document.getDocument() ); closeDoc.close( true ); } } @@ -108,7 +105,7 @@ public class FormPropertyBags extends complexlib.ComplexTestCase implements XPro XPropertySet textFieldModel = m_formLayer.createControlAndShape( "DatabaseTextField", 10, 10, 25, 6 ); // check whether adding new properties is successful - XPropertyContainer propContainer = (XPropertyContainer)UnoRuntime.queryInterface( + XPropertyContainer propContainer = UnoRuntime.queryInterface( XPropertyContainer.class, textFieldModel ); assure("XPropertyContainer not supported!", propContainer != null ); @@ -166,8 +163,7 @@ public class FormPropertyBags extends complexlib.ComplexTestCase implements XPro private void impl_checkPropertyPersistence() throws com.sun.star.uno.Exception { // store the document - XStorable store = (XStorable)UnoRuntime.queryInterface( XStorable.class, - m_document.getDocument() ); + XStorable store = UnoRuntime.queryInterface( XStorable.class, m_document.getDocument() ); String documentURL = util.utils.getOfficeTemp( m_orb ) + "document.odt"; PropertyValue[] storeArguments = new PropertyValue[] { new PropertyValue() }; storeArguments[0].Name = "FilterName"; diff --git a/forms/qa/integration/forms/ListBox.java b/forms/qa/integration/forms/ListBox.java new file mode 100644 index 000000000..282d5a539 --- /dev/null +++ b/forms/qa/integration/forms/ListBox.java @@ -0,0 +1,290 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * 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. + * + ************************************************************************/ +package integration.forms; + +import com.sun.star.awt.XListBox; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XChild; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.form.ListSourceType; +import com.sun.star.form.runtime.FormFeature; +import com.sun.star.form.runtime.XFormController; +import com.sun.star.form.runtime.XFormOperations; +import com.sun.star.sdb.CommandType; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XParameters; +import com.sun.star.sdbc.XPreparedStatement; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import connectivity.tools.HsqlColumnDescriptor; +import connectivity.tools.HsqlDatabase; +import connectivity.tools.HsqlTableDescriptor; +import connectivity.tools.sdb.Connection; +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; + +public class ListBox extends TestCase +{ + HsqlDatabase m_database = null; + private final String m_foreignKeyTableName = "foreign_keys"; + + public ListBox() + { + super( DocumentType.WRITER ); + } + + /* ------------------------------------------------------------------ */ + public String[] getTestMethodNames() + { + return new String[] { + "checkForeignKeys" + }; + } + + /* ------------------------------------------------------------------ */ + public void checkForeignKeys() throws com.sun.star.uno.Exception, java.lang.Exception + { + try + { + // create the form document + prepareDocument(); + + final XIndexAccess formsCollection = UnoRuntime.queryInterface( XIndexAccess.class, + m_document.getFormComponentTreeRoot() ); + final XNameAccess form = UnoRuntime.queryInterface( XNameAccess.class, formsCollection.getByIndex(0) ); + + final DocumentViewHelper view = m_document.getCurrentView(); + final XFormController formController = view.getFormController( form ); + final XFormOperations formOperations = formController.getFormOperations(); + + // move through all records, and check that the display values in the list boxes are as expected + final String[][] fieldTypesDefinitions = impl_getFieldTypeDefinitions(); + final String[] fieldTypes = fieldTypesDefinitions[0]; + + final String[] displayValues = impl_getDisplayValues(); + + formOperations.execute( FormFeature.MoveToFirst ); + for ( int row=0; row<2; ++row ) + { + StringBuffer failedFieldTypes = new StringBuffer(); + for ( int i=0; i<fieldTypes.length; ++i ) + { + final String columnFKName = fieldTypes[i] + "_fk"; + Object listBoxModel = form.getByName( columnFKName ); + XListBox listBoxControl = UnoRuntime.queryInterface( XListBox.class, + view.getControl( listBoxModel ) ); + if ( !listBoxControl.getSelectedItem().equals( displayValues[row] ) ) + { + if ( failedFieldTypes.length() > 0 ) + failedFieldTypes.append( ", " ); + failedFieldTypes.append( fieldTypes[i] ); + } + } + /*assure( "The following field types do not work when used as bound list box fields: " + failedFieldTypes.toString() + + " (row " + row + ")", failedFieldTypes.length() == 0 );*/ + + formOperations.execute( FormFeature.MoveToNext ); + } + + } + finally + { + closeDocument(); + } + } + + /* ------------------------------------------------------------------ */ + public void before() throws Exception, java.lang.Exception + { + super.before(); + impl_createDatabase(); + } + + /* ------------------------------------------------------------------ */ + protected void prepareDocument() throws com.sun.star.uno.Exception, java.lang.Exception + { + super.prepareDocument(); + impl_createForm(); + } + + /* ------------------------------------------------------------------ */ + private String[][] impl_getFieldTypeDefinitions() + { + return new String[][] { + new String[] { + "bigint", "boolean", "date", "decimal", "double", "float", "numeric", "time", "timestamp", "tinyint", "varchar" + }, + new String[] { + null, null, null, "(10,2)", null, null, "(10,2)", null, null, null, "(50)" + } + }; + } + + /* ------------------------------------------------------------------ */ + private String[] impl_getTypedValue( final String _asType, final int _rowNum ) throws SQLException + { + Map< String, String[] > valueMap = new HashMap< String, String[] >(); + valueMap.put( "bigint", new String[] { "1111111111", "222222222" } ); + valueMap.put( "boolean", new String[] { "false", "true" } ); + valueMap.put( "date", new String[] { "2001-01-01", "2002-02-02" } ); + valueMap.put( "decimal", new String[] { "1.11", "2.22" } ); + valueMap.put( "double", new String[] { "1.11", "2.22" } ); + valueMap.put( "float", new String[] { "1.11", "2.22" } ); + valueMap.put( "numeric", new String[] { "1.11", "2.22" } ); + valueMap.put( "time", new String[] { "01:01:01", "02:02:02" } ); + valueMap.put( "timestamp", new String[] { "2001-01-01 01:01:01", "2002-02-02 02:02:02" } ); + valueMap.put( "tinyint", new String[] { "1", "2" } ); + valueMap.put( "varchar", new String[] { "first", "second" } ); + + return valueMap.get( _asType ); + } + + /* ------------------------------------------------------------------ */ + private String[] impl_getDisplayValues() + { + return new String[] { "one", "two" }; + } + + /* ------------------------------------------------------------------ */ + private void impl_createDatabase() throws java.lang.Exception + { + try + { + m_database = new HsqlDatabase( m_orb ); + Connection connection = m_database.defaultConnection(); + System.out.println( m_database.getDocumentURL() ); + + final String[][] fieldDefinitions = impl_getFieldTypeDefinitions(); + final String[] keyTypes = fieldDefinitions[0]; + final String[] keyCreationArgs = fieldDefinitions[1]; + + Vector< HsqlColumnDescriptor > foreignKeyColumns = new Vector< HsqlColumnDescriptor >(); + foreignKeyColumns.add( new HsqlColumnDescriptor( "ID", "integer", HsqlColumnDescriptor.PRIMARY ) ); + + Vector< String[] > foreignKeyValues = new Vector< String[] >(); + + StringBuffer foreignKeyInsertSQL = new StringBuffer(); + foreignKeyInsertSQL.append( "INSERT INTO \"" + m_foreignKeyTableName + "\" VALUES (?" ); + + final String[] displayValues = impl_getDisplayValues(); + + for ( int i=0; i<keyTypes.length; ++i ) + { + final String tableName = keyTypes[i] + "_pk"; + final String columnPKName = keyTypes[i] + "_pk"; + final String columnFKName = keyTypes[i] + "_fk"; + final String columnType = keyTypes[i] + ( keyCreationArgs[i] != null ? keyCreationArgs[i] : "" ); + m_database.createTable( new HsqlTableDescriptor( tableName, + new HsqlColumnDescriptor[] { + new HsqlColumnDescriptor( columnPKName, columnType, HsqlColumnDescriptor.PRIMARY ), + new HsqlColumnDescriptor( "content", "varchar(50)" ) + } + ) ); + + // insert a few rows + StringBuffer sql = new StringBuffer(); + sql.append( "INSERT INTO \"" ); + sql.append( tableName ); + sql.append( "\" VALUES (?, ?)"); + XPreparedStatement statement = connection.prepareStatement( sql.toString() ); + XParameters statementParameters = UnoRuntime.queryInterface( XParameters.class, statement ); + + final String[] keyValues = impl_getTypedValue( keyTypes[i], 0 ); + + for ( int row=0; row<displayValues.length; ++row ) + { + statementParameters.setString( 1, keyValues[row] ); + statementParameters.setString( 2, displayValues[row] ); + statement.execute(); + } + + // remember a column descriptor for later creation of the table with the foreign keys + foreignKeyColumns.add( new HsqlColumnDescriptor( columnFKName, columnType, HsqlColumnDescriptor.REQUIRED, + tableName, columnPKName ) ); + + // remember the data to fill into this table + foreignKeyValues.add( keyValues ); + foreignKeyInsertSQL.append( ", ?" ); + } + + // create the table taking all those foreign keys + m_database.createTable( new HsqlTableDescriptor( m_foreignKeyTableName, foreignKeyColumns.toArray( new HsqlColumnDescriptor[0] ) ) ); + // fill in some data + foreignKeyInsertSQL.append( ")" ); + XPreparedStatement statement = connection.prepareStatement( foreignKeyInsertSQL.toString() ); + XParameters statementParameters = UnoRuntime.queryInterface( XParameters.class, statement ); + for ( int row=0; row<2; ++row ) + { + statementParameters.setInt( 1, row ); + for ( int i=0; i<keyTypes.length; ++i ) + { + statementParameters.setString( i+2, foreignKeyValues.get(i)[row] ); + } + statement.execute(); + } + + m_database.defaultConnection().refreshTables(); + } + finally + { + if ( m_database != null ) + m_database.store(); + } + } + + /* ------------------------------------------------------------------ */ + private void impl_createForm() throws java.lang.Exception + { + // a single control for the ID field + XPropertySet controlModel = m_formLayer.insertControlLine( "DatabaseNumericField", "ID", null, 10, 10, 6 ); + // bind the form to the foreign_keys table + XPropertySet form = dbfTools.queryPropertySet( dbfTools.getParent( controlModel, XChild.class ) ); + form.setPropertyValue( "Command", m_foreignKeyTableName ); + form.setPropertyValue( "CommandType", CommandType.TABLE ); + form.setPropertyValue( "DataSourceName", m_database.getDocumentURL() ); + + // create list boxes for the different foreign keys + final String[][] fieldDefinitions = impl_getFieldTypeDefinitions(); + final String[] fieldTypes = fieldDefinitions[0]; + for ( int i=0; i<fieldTypes.length; ++i ) + { + final String tableName = fieldTypes[i] + "_pk"; + final String columnFKName = fieldTypes[i] + "_fk"; + final String columnPKName = fieldTypes[i] + "_pk"; + XPropertySet listBoxModel = m_formLayer.insertControlLine( "DatabaseListBox", columnFKName, null, 10, 20 + 10*i, 6 ); + listBoxModel.setPropertyValue( "Dropdown", new Boolean( true ) ); + listBoxModel.setPropertyValue( "ListSourceType", ListSourceType.SQL ); + listBoxModel.setPropertyValue( "ListSource", new String[] { "SELECT \"content\", \"" + columnPKName + + "\" FROM \"" + tableName + "\"" } ); + listBoxModel.setPropertyValue( "BoundColumn", new Short( (short)1 ) ); + } + + m_document.getCurrentView().toggleFormDesignMode(); + } + } diff --git a/forms/qa/integration/forms/ListSelection.java b/forms/qa/integration/forms/ListSelection.java index 1dd06b356..4aa5221e8 100644 --- a/forms/qa/integration/forms/ListSelection.java +++ b/forms/qa/integration/forms/ListSelection.java @@ -30,7 +30,6 @@ package integration.forms; import com.sun.star.uno.UnoRuntime; -import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.beans.XPropertySet; import com.sun.star.sheet.XSpreadsheet; import com.sun.star.sheet.XSpreadsheets; @@ -48,15 +47,10 @@ import com.sun.star.script.ScriptEventDescriptor; import com.sun.star.accessibility.XAccessible; import com.sun.star.accessibility.XAccessibleContext; import com.sun.star.accessibility.XAccessibleSelection; -import com.sun.star.accessibility.XAccessibleAction; import com.sun.star.frame.XStorable; -import integration.forms.DocumentHelper; - -public class ListSelection extends integration.forms.TestCase implements com.sun.star.awt.XItemListener +public class ListSelection extends integration.forms.TestCase { - private final static boolean m_useJavaCallbacks = false; - /** Creates a new instance of ListSelection */ public ListSelection() { @@ -98,7 +92,7 @@ public class ListSelection extends integration.forms.TestCase implements com.sun { log.println( "Round " + ( i + 1 ) + " of " + runs ); prepareDocument(); - clickTheListBox(); + impl_clickListBox(); synchronized( this ) { this.wait( 1000 ); } closeDocument(); } @@ -106,7 +100,7 @@ public class ListSelection extends integration.forms.TestCase implements com.sun } /* ------------------------------------------------------------------ */ - final protected void clickTheListBox() + final private void impl_clickListBox() { try { @@ -123,13 +117,6 @@ public class ListSelection extends integration.forms.TestCase implements com.sun XAccessible.class, getListBoxControl( activeSheet ) ); XAccessibleContext context = accessibleListBox.getAccessibleContext(); - // open the popup of the list box (not really necessary, but to better - // simlate user action ...) -/* XAccessibleAction listBoxActions = (XAccessibleAction)UnoRuntime.queryInterface( - XAccessibleAction.class, context ); - listBoxActions.doAccessibleAction( 0 ); -*/ - // the first "accessible child" of a list box is its list XAccessibleSelection accessibleList = (XAccessibleSelection)UnoRuntime.queryInterface( XAccessibleSelection.class, context.getAccessibleChild( 1 ) ); @@ -158,7 +145,7 @@ public class ListSelection extends integration.forms.TestCase implements com.sun } /* ------------------------------------------------------------------ */ - final protected void createListenerScript() + final private void impl_setupListenerScript() { try { @@ -203,7 +190,7 @@ public class ListSelection extends integration.forms.TestCase implements com.sun } /* ------------------------------------------------------------------ */ - final protected void assignCallbackScript( XPropertySet controlModel, String interfaceName, String interfaceMethod, String scriptCode ) + final private void impl_assignStarBasicScript( XPropertySet controlModel, String interfaceName, String interfaceMethod, String scriptCode ) { try { @@ -240,8 +227,7 @@ public class ListSelection extends integration.forms.TestCase implements com.sun protected void prepareDocument() throws com.sun.star.uno.Exception, java.lang.Exception { super.prepareDocument(); - if ( !m_useJavaCallbacks ) - createListenerScript(); + impl_setupListenerScript(); SpreadsheetDocument document = (SpreadsheetDocument)m_document; XSpreadsheets sheets = document.getSheets(); @@ -264,7 +250,7 @@ public class ListSelection extends integration.forms.TestCase implements com.sun for ( int i = 0; i < 4; ++i ) { XPropertySet buttonModel = m_formLayer.createControlAndShape( "CommandButton", 10, 10 + i * 10, 30, 8 ); - assignCallbackScript( buttonModel, "XActionListener", "actionPerformed", "document:default.callbacks.onButtonClicked" ); + impl_assignStarBasicScript( buttonModel, "XActionListener", "actionPerformed", "document:default.callbacks.onButtonClicked" ); } // and a list box @@ -273,25 +259,15 @@ public class ListSelection extends integration.forms.TestCase implements com.sun listBox.setPropertyValue( "StringItemList", newSheetNames ); listBox.setPropertyValue( "Name", "ListBox" ); - if ( !m_useJavaCallbacks ) - assignCallbackScript( listBox, "XItemListener", "itemStateChanged", "document:default.callbacks.onListBoxSelected" ); + impl_assignStarBasicScript( listBox, "XItemListener", "itemStateChanged", "document:default.callbacks.onListBoxSelected" ); // clone this sheet for ( short i = 1; i < newSheetNames.length; ++i ) - sheets.copyByName( newSheetNames[0], newSheetNames[i], (short)i ); + sheets.copyByName( newSheetNames[0], newSheetNames[i], i ); // switch the thing to alive mode m_document.getCurrentView().toggleFormDesignMode(); - // add to the list box control as item listener - if ( m_useJavaCallbacks ) - { - XControl control = m_document.getCurrentView().getControl( listBox ); - XListBox listBoxControl = (XListBox)UnoRuntime.queryInterface( - XListBox.class, control ); - listBoxControl.addItemListener( this ); - } - try { XStorable storable = (XStorable)m_document.query( XStorable.class ); @@ -322,48 +298,4 @@ public class ListSelection extends integration.forms.TestCase implements com.sun return (XListBox)UnoRuntime.queryInterface( XListBox.class, m_document.getCurrentView().getControl( getListBoxModel( sheet ) ) ); } - - /* ------------------------------------------------------------------ */ - public void itemStateChanged( com.sun.star.awt.ItemEvent event ) throws com.sun.star.uno.RuntimeException - { - try - { - // get the selected string - XControl control = (XControl)UnoRuntime.queryInterface( XControl.class, - event.Source ); - XPropertySet model = dbfTools.queryPropertySet( control.getModel() ); - String[] entries = (String[])model.getPropertyValue( "StringItemList" ); - String selectedEntry = entries[ event.Selected ]; - - // activate this sheet - SpreadsheetDocument document = (SpreadsheetDocument)m_document; - XSpreadsheet sheet = (XSpreadsheet)UnoRuntime.queryInterface( - XSpreadsheet.class, document.getSheets().getByName( selectedEntry ) ); - XSpreadsheetView view = (XSpreadsheetView)m_document.getCurrentView().query( XSpreadsheetView.class ); - view.setActiveSheet( sheet ); - - if ( m_useJavaCallbacks ) - { - // after we switched to another sheet, we need to register at its list box - // control, again. The reason is that controls exist as long as their sheet is active. - XListBox listBoxControl = getListBoxControl( sheet ); - listBoxControl.addItemListener( this ); - - // in the list box of this new sheet, select its name. Everything else - // is way too confusing - listBoxControl.selectItem( selectedEntry, true ); - // don't do it. It deadlocks :( - } - } - catch( com.sun.star.uno.Exception e ) - { - e.printStackTrace( System.err ); - } - } - - /* ------------------------------------------------------------------ */ - public void disposing( com.sun.star.lang.EventObject rEvent ) throws com.sun.star.uno.RuntimeException - { - // not interested in by now - } } diff --git a/forms/qa/integration/forms/MasterDetailForms.java b/forms/qa/integration/forms/MasterDetailForms.java index 91125ce16..6bb19f5b6 100644 --- a/forms/qa/integration/forms/MasterDetailForms.java +++ b/forms/qa/integration/forms/MasterDetailForms.java @@ -30,67 +30,77 @@ package integration.forms; +import com.sun.star.beans.NamedValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexContainer; import java.lang.reflect.Method; import com.sun.star.uno.UnoRuntime; import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.beans.*; import com.sun.star.container.XNameContainer; +import com.sun.star.embed.XComponentSupplier; +import com.sun.star.form.XGridColumnFactory; +import com.sun.star.form.XGridFieldDataSupplier; import com.sun.star.form.XLoadable; -import com.sun.star.sdbc.*; - -import connectivity.tools.*; +import com.sun.star.lang.XComponent; +import com.sun.star.sdb.CommandType; +import com.sun.star.sdb.XFormDocumentsSupplier; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XColumnLocate; +import com.sun.star.ucb.Command; +import com.sun.star.ucb.OpenMode; +import com.sun.star.ucb.XCommandProcessor; +import com.sun.star.uno.Type; +import com.sun.star.util.XModifiable; +import connectivity.tools.CRMDatabase; +import connectivity.tools.HsqlColumnDescriptor; +import connectivity.tools.HsqlDatabase; +import connectivity.tools.HsqlTableDescriptor; +import org.openoffice.complex.forms.tools.ResultSet; public class MasterDetailForms extends complexlib.ComplexTestCase implements com.sun.star.form.XLoadListener { private XMultiServiceFactory m_orb; - private HsqlDatabase m_databaseDocument; private XPropertySet m_masterForm; private XPropertySet m_detailForm; - private XResultSet m_masterSet; - private XResultSet m_detailSet; - private XRow m_masterRow; - private XRow m_detailRow; + private ResultSet m_masterResult; + private ResultSet m_detailResult; - private Object m_waitForLoad; - private boolean m_loaded; + final private Object m_waitForLoad = new Object(); + private boolean m_loaded = false; - /** Creates a new instance of ValueBinding */ + /** Creates a new instance of MasterDetailForms */ public MasterDetailForms() { - m_loaded = false; - m_waitForLoad = new Object(); } /* ------------------------------------------------------------------ */ public String[] getTestMethodNames() { return new String[] { - "checkMultipleKeys" + "checkMultipleKeys", + "checkDetailFormDefaults" }; } - + /* ------------------------------------------------------------------ */ - public String getTestObjectName() + public void before() { - return "Form Control Spreadsheet Cell Binding Test"; + m_orb = (XMultiServiceFactory)param.getMSF(); } /* ------------------------------------------------------------------ */ - public void before() throws java.lang.Exception + public String getTestObjectName() { - m_orb = (XMultiServiceFactory)param.getMSF(); - m_databaseDocument = new HsqlDatabase( m_orb ); - createTableStructure(); - createForms(); + return "Form Control Spreadsheet Cell Binding Test"; } /* ------------------------------------------------------------------ */ /** creates the table structure needed for the test */ - private void createTableStructure() throws SQLException + private void impl_createTableStructure( final HsqlDatabase _databaseDocument ) throws SQLException { HsqlColumnDescriptor[] masterColumns = { new HsqlColumnDescriptor( "ID1", "INTEGER", HsqlColumnDescriptor.PRIMARY ), @@ -103,46 +113,37 @@ public class MasterDetailForms extends complexlib.ComplexTestCase implements com new HsqlColumnDescriptor( "FK_ID2", "INTEGER", HsqlColumnDescriptor.REQUIRED, "master", "ID2" ), new HsqlColumnDescriptor( "name", "VARCHAR(50)" ), }; - m_databaseDocument.createTable( new HsqlTableDescriptor( "master", masterColumns ) ); - m_databaseDocument.createTable( new HsqlTableDescriptor( "detail", detailColumns ) ); + _databaseDocument.createTable( new HsqlTableDescriptor( "master", masterColumns ) ); + _databaseDocument.createTable( new HsqlTableDescriptor( "detail", detailColumns ) ); - m_databaseDocument.executeSQL( "INSERT INTO \"master\" VALUES ( 1, 1, 'First Record' )" ); - m_databaseDocument.executeSQL( "INSERT INTO \"master\" VALUES ( 1, 2, 'Second Record' )" ); - m_databaseDocument.executeSQL( "INSERT INTO \"detail\" VALUES ( 1, 1, 1, 'record 1.1 (1)')"); - m_databaseDocument.executeSQL( "INSERT INTO \"detail\" VALUES ( 2, 1, 1, 'record 1.1 (2)')"); - m_databaseDocument.executeSQL( "INSERT INTO \"detail\" VALUES ( 3, 1, 2, 'record 1.2 (1)')"); + _databaseDocument.executeSQL( "INSERT INTO \"master\" VALUES ( 1, 1, 'First Record' )" ); + _databaseDocument.executeSQL( "INSERT INTO \"master\" VALUES ( 1, 2, 'Second Record' )" ); + _databaseDocument.executeSQL( "INSERT INTO \"detail\" VALUES ( 1, 1, 1, 'record 1.1 (1)')"); + _databaseDocument.executeSQL( "INSERT INTO \"detail\" VALUES ( 2, 1, 1, 'record 1.1 (2)')"); + _databaseDocument.executeSQL( "INSERT INTO \"detail\" VALUES ( 3, 1, 2, 'record 1.2 (1)')"); - m_databaseDocument.getDataSource().refreshTables( m_databaseDocument.defaultConnection() ); + _databaseDocument.defaultConnection().refreshTables(); } /* ------------------------------------------------------------------ */ - public void createForms() throws com.sun.star.uno.Exception + private void impl_createForms( final HsqlDatabase _databaseDocument ) throws com.sun.star.uno.Exception { m_masterForm = dbfTools.queryPropertySet( m_orb.createInstance( "com.sun.star.form.component.DataForm" ) ); - m_masterRow = (XRow)UnoRuntime.queryInterface( XRow.class, m_masterForm ); - m_masterSet = (XResultSet)UnoRuntime.queryInterface( XResultSet.class, m_masterForm ); - m_masterForm.setPropertyValue( "ActiveConnection", m_databaseDocument.defaultConnection() ); + m_masterForm.setPropertyValue( "ActiveConnection", _databaseDocument.defaultConnection().getXConnection() ); m_masterForm.setPropertyValue( "CommandType", new Integer( com.sun.star.sdb.CommandType.TABLE ) ); m_masterForm.setPropertyValue( "Command", "master" ); + m_masterResult = new ResultSet( m_masterForm ); + m_detailForm = dbfTools.queryPropertySet( m_orb.createInstance( "com.sun.star.form.component.DataForm" ) ); - m_detailRow = (XRow)UnoRuntime.queryInterface( XRow.class, m_detailForm ); - m_detailSet = (XResultSet)UnoRuntime.queryInterface( XResultSet.class, m_detailForm ); - m_detailForm.setPropertyValue( "ActiveConnection", m_databaseDocument.defaultConnection() ); + m_detailForm.setPropertyValue( "ActiveConnection", _databaseDocument.defaultConnection().getXConnection() ); m_detailForm.setPropertyValue( "CommandType", new Integer( com.sun.star.sdb.CommandType.TABLE ) ); m_detailForm.setPropertyValue( "Command", "detail" ); - XNameContainer masterContainer = (XNameContainer)UnoRuntime.queryInterface( XNameContainer.class, - m_masterForm ); - masterContainer.insertByName( "slave", m_detailForm ); - } + m_detailResult = new ResultSet( m_detailForm ); - /* ------------------------------------------------------------------ */ - public void after() throws com.sun.star.uno.Exception, java.lang.Exception - { - m_databaseDocument.closeAndDelete(); - dbfTools.disposeComponent( m_masterForm ); - dbfTools.disposeComponent( m_detailForm ); + XNameContainer masterContainer = UnoRuntime.queryInterface( XNameContainer.class, m_masterForm ); + masterContainer.insertByName( "slave", m_detailForm ); } /* ------------------------------------------------------------------ */ @@ -150,47 +151,211 @@ public class MasterDetailForms extends complexlib.ComplexTestCase implements com */ public void checkMultipleKeys() throws com.sun.star.uno.Exception, java.lang.Exception { - m_detailForm.setPropertyValue( "MasterFields", new String[] { "ID1", "ID2" } ); - m_detailForm.setPropertyValue( "DetailFields", new String[] { "FK_ID1", "FK_ID2" } ); + HsqlDatabase databaseDocument = null; + try + { + databaseDocument = new HsqlDatabase( m_orb ); + impl_createTableStructure( databaseDocument ); + impl_createForms( databaseDocument ); + + m_detailForm.setPropertyValue( "MasterFields", new String[] { "ID1", "ID2" } ); + m_detailForm.setPropertyValue( "DetailFields", new String[] { "FK_ID1", "FK_ID2" } ); + + XLoadable loadMaster = UnoRuntime.queryInterface( XLoadable.class, m_masterForm ); + XLoadable loadDetail = UnoRuntime.queryInterface( XLoadable.class, m_detailForm ); + loadDetail.addLoadListener( this ); + + // wait until the detail form is loaded + operateMasterAndWaitForDetailForm( loadMaster.getClass().getMethod( "load", new Class[] {} ), loadMaster, new Object[] { } ); + + // okay, now the master form should be on the first record + assure( "wrong form state after loading (ID1)", m_masterResult.getInt(1) == 1 ); + assure( "wrong form state after loading (ID2)", m_masterResult.getInt(2) == 1 ); + assure( "wrong form state after loading (value)", m_masterResult.getString(3).equals( "First Record" ) ); - XLoadable loadMaster = (XLoadable)UnoRuntime.queryInterface( XLoadable.class, m_masterForm ); - XLoadable loadDetail = (XLoadable)UnoRuntime.queryInterface( XLoadable.class, m_detailForm ); - loadDetail.addLoadListener( this ); + // the "XResultSet.next" method + Method methodNext = m_masterResult.getClass().getMethod( "next" , new Class[] {} ); - // wait until the detail form is loaded - operateMasterAndWaitForDetailForm( loadMaster.getClass().getMethod( "load", new Class[] {} ), loadMaster, new Object[] { } ); + // the values in the linked fields should be identical + int expectedDetailRowCounts[] = { 2, 1 }; + do + { + verifyColumnValueIdentity( "ID1", "FK_ID1" ); + verifyColumnValueIdentity( "ID2", "FK_ID2" ); + + m_detailResult.last(); + int masterPos = m_masterResult.getRow(); + assure( "wrong number of records in detail form, for master form at pos " + masterPos, + ((Integer)m_detailForm.getPropertyValue( "RowCount" )).intValue() == expectedDetailRowCounts[ masterPos - 1 ] ); - // okay, now the master form should be on the first record - assure( "wrong form state after loading (ID1)", m_masterRow.getInt(1) == 1 ); - assure( "wrong form state after loading (ID2)", m_masterRow.getInt(2) == 1 ); - assure( "wrong form state after loading (value)", m_masterRow.getString(3).equals( "First Record" ) ); + operateMasterAndWaitForDetailForm( methodNext, m_masterResult, new Object[] {} ); + } + while ( !m_masterResult.isAfterLast() ); + assure( "wrong number of records in master form", 2 == ((Integer)m_masterForm.getPropertyValue( "RowCount" )).intValue() ); + } + finally + { + if ( databaseDocument != null ) + databaseDocument.closeAndDelete(); + impl_cleanUpStep(); + } + } - // the "XResultSet.next" method - Method methodNext = m_masterSet.getClass().getMethod( "next" , new Class[] {} ); + /* ------------------------------------------------------------------ */ + private final void impl_cleanUpStep() + { + if ( m_masterForm != null ) + dbfTools.disposeComponent( m_masterForm ); + if ( m_detailForm != null ) + dbfTools.disposeComponent( m_detailForm ); + m_masterForm = m_detailForm = null; + } - // the values in the linked fields should be identical - int expectedDetailRowCounts[] = { 2, 1 }; - do + /* ------------------------------------------------------------------ */ + /** checks whether default values in detail forms work as expected. + * + * Effectively, this test case verifies the issues #i106574# and #i105235# did not creep back in. + */ + public void checkDetailFormDefaults() throws Exception + { + CRMDatabase database = null; + XCommandProcessor subComponentCommands = null; + try { - verifyColumnValueIdentity( "ID1", "FK_ID1" ); - verifyColumnValueIdentity( "ID2", "FK_ID2" ); + // create our standard CRM database document + database = new CRMDatabase( m_orb, true ); + + // create a form document therein + XFormDocumentsSupplier formDocSupp = UnoRuntime.queryInterface( XFormDocumentsSupplier.class, database.getDatabase().getModel() ); + XMultiServiceFactory formFactory = UnoRuntime.queryInterface( XMultiServiceFactory.class, formDocSupp.getFormDocuments() ); + NamedValue[] loadArgs = new NamedValue[] { + new NamedValue( "ActiveConnection", database.getConnection().getXConnection() ), + new NamedValue( "MediaType", "application/vnd.oasis.opendocument.text" ) + }; + + subComponentCommands = UnoRuntime.queryInterface( + XCommandProcessor.class, + formFactory.createInstanceWithArguments( "com.sun.star.sdb.DocumentDefinition", loadArgs ) ); + Command command = new Command(); + command.Name = "openDesign"; + command.Argument = new Short( OpenMode.DOCUMENT ); + + DocumentHelper subDocument = new DocumentHelper( m_orb, + UnoRuntime.queryInterface( XComponent.class, + subComponentCommands.execute( command, subComponentCommands.createCommandIdentifier(), null ) + ) + ); + FormLayer formLayer = new FormLayer( subDocument ); + XPropertySet controlModel = formLayer.insertControlLine( "DatabaseNumericField", "ID", "", 10 ); + formLayer.insertControlLine( "DatabaseTextField", "Name", "", 20 ); + formLayer.insertControlLine( "DatabaseTextField", "Description", "", 30 ); + + m_masterForm = (XPropertySet)dbfTools.getParent( controlModel, XPropertySet.class ); + m_masterForm.setPropertyValue( "Command", "categories" ); + m_masterForm.setPropertyValue( "CommandType", new Integer( CommandType.TABLE ) ); + + // create a detail form + m_detailForm = UnoRuntime.queryInterface( XPropertySet.class, subDocument.createSubForm( m_masterForm, "products" ) ); + m_detailForm.setPropertyValue( "Command", "SELECT \"ID\", \"Name\", \"CategoryID\" FROM \"products\"" ); + m_detailForm.setPropertyValue( "CommandType", new Integer( CommandType.COMMAND ) ); + m_detailForm.setPropertyValue( "MasterFields", new String[] { "ID" } ); + m_detailForm.setPropertyValue( "DetailFields", new String[] { "CategoryID" } ); + + // create a grid control in the detail form, with some columns + XPropertySet gridControlModel = formLayer.createControlAndShape( "GridControl", 20, 40, 130, 50, m_detailForm ); + gridControlModel.setPropertyValue( "Name", "product list" ); + XIndexContainer gridColumns = UnoRuntime.queryInterface( XIndexContainer.class, gridControlModel ); + impl_createGridColumn( gridColumns, "TextField", "ID" ); + XPropertySet nameColumn = impl_createGridColumn( gridColumns, "TextField", "Name" ); + nameColumn.setPropertyValue( "Width", new Integer( 600 ) ); // 6 cm + nameColumn.setPropertyValue( "DefaultText", "default text" ); + + // go live + m_masterResult = new ResultSet( m_masterForm ); + m_detailResult = new ResultSet( m_detailForm ); + + XLoadable loadDetail = UnoRuntime.queryInterface( XLoadable.class, m_detailForm ); + loadDetail.addLoadListener( this ); + + subDocument.getCurrentView().toggleFormDesignMode(); + impl_waitForLoadedEvent(); + + // now that we set up this, do the actual tests + // First, http://www.openoffice.org/issues/show_bug.cgi?id=105235 described the problem + // that default values in the sub form didn't work when the master form was navigated to a row + // for which no detail records were present, and the default of the column/control is the same + // as the last known value. + + // so, take the current value of the "Name" column, and set it as default value ... + String defaultValue = m_detailResult.getString( 2 ); + nameColumn.setPropertyValue( "DefaultText", defaultValue ); + // ... then move to the second main form row ... + m_masterResult.absolute( 2 ); + impl_waitForLoadedEvent(); + // ... which should result in an empty sub form ... + assure( "test precondition not met: The second master form record is expected to have no detail records, " + + "else the test becomes meaningless", impl_isNewRecord( m_detailForm ) ); + // ... and in the "Name" column having the proper text + String actualValue = (String)nameColumn.getPropertyValue( "Text" ); + assureEquals( "#i105235#: default value in sub form not working (not propagated to column model)", defaultValue, actualValue ); + // However, checking the column model's value alone is not enough - we need to ensure it is properly + // propagated to the control. + XGridFieldDataSupplier gridData = (XGridFieldDataSupplier)subDocument.getCurrentView().getControl( + gridControlModel, XGridFieldDataSupplier.class ); + actualValue = (String)(gridData.queryFieldData( 0, Type.STRING )[1]); + assureEquals( "#i105235#: default value in sub form not working (not propagated to column)", defaultValue, actualValue ); + } + finally + { + if ( subComponentCommands != null ) + { + XComponentSupplier componentSupplier = UnoRuntime.queryInterface( XComponentSupplier.class, subComponentCommands ); + XModifiable modifySubComponent = UnoRuntime.queryInterface( XModifiable.class, componentSupplier.getComponent() ); + modifySubComponent.setModified( false ); + Command command = new Command(); + command.Name = "close"; + subComponentCommands.execute( command, subComponentCommands.createCommandIdentifier(), null ); + } - m_detailSet.last(); - int masterPos = m_masterSet.getRow(); - assure( "wrong number of records in detail form, for master form at pos " + masterPos, - ((Integer)m_detailForm.getPropertyValue( "RowCount" )).intValue() == expectedDetailRowCounts[ masterPos - 1 ] ); + if ( database != null ) + database.saveAndClose(); + + impl_cleanUpStep(); + } + } - operateMasterAndWaitForDetailForm( methodNext, m_masterSet, new Object[] {} ); + /* ------------------------------------------------------------------ */ + private boolean impl_isNewRecord( final XPropertySet _rowSet ) + { + boolean isNew = false; + try + { + isNew = ((Boolean)_rowSet.getPropertyValue( "IsNew" )).booleanValue(); } - while ( !m_masterSet.isAfterLast() ); - assure( "wrong number of records in master form", 2 == ((Integer)m_masterForm.getPropertyValue( "RowCount" )).intValue() ); + catch ( Exception ex ) + { + failed( "obtaining the IsNew property failed" ); + } + return isNew; + } + + /* ------------------------------------------------------------------ */ + private XPropertySet impl_createGridColumn( final XIndexContainer _gridModel, final String _columnType, final String _boundField ) throws Exception + { + final XGridColumnFactory columnFactory = UnoRuntime.queryInterface( XGridColumnFactory.class, _gridModel ); + XPropertySet column = columnFactory.createColumn( _columnType ); + column.setPropertyValue( "DataField", _boundField ); + column.setPropertyValue( "Name", _boundField ); + column.setPropertyValue( "Label", _boundField ); + _gridModel.insertByIndex( _gridModel.getCount(), column ); + return column; } + /* ------------------------------------------------------------------ */ /** executes an operation on the master, and waits until the detail form has been (re)loaded aferwards */ private void operateMasterAndWaitForDetailForm( Method _masterMethod, Object _masterInterface, Object[] _methodParameters ) throws SQLException { - m_loaded = false; Object result; try { @@ -205,28 +370,35 @@ public class MasterDetailForms extends complexlib.ComplexTestCase implements com if ( !((Boolean)result).booleanValue() ) return; + impl_waitForLoadedEvent(); + } + + private void impl_waitForLoadedEvent() + { synchronized( m_waitForLoad ) { - if ( !m_loaded ) + while ( !m_loaded ) { try { m_waitForLoad.wait(); } catch( java.lang.InterruptedException e ) { } } + // reset the flag for the next time + m_loaded = false; } } /** assures that the (integer) values in the given columns of our master and detail forms are identical */ - public void verifyColumnValueIdentity( String masterColName, String detailColName ) throws SQLException + private void verifyColumnValueIdentity( final String masterColName, final String detailColName ) throws SQLException { - XColumnLocate locateMasterCols = (XColumnLocate)UnoRuntime.queryInterface( XColumnLocate.class, m_masterForm ); - XColumnLocate locateDetailCols = (XColumnLocate)UnoRuntime.queryInterface( XColumnLocate.class, m_detailForm ); + XColumnLocate locateMasterCols = UnoRuntime.queryInterface( XColumnLocate.class, m_masterForm ); + XColumnLocate locateDetailCols = UnoRuntime.queryInterface( XColumnLocate.class, m_detailForm ); - int masterValue = m_masterRow.getInt( locateMasterCols.findColumn( masterColName ) ); - int detailValue = m_detailRow.getInt( locateDetailCols.findColumn( detailColName ) ); + int masterValue = m_masterResult.getInt( locateMasterCols.findColumn( masterColName ) ); + int detailValue = m_detailResult.getInt( locateDetailCols.findColumn( detailColName ) ); assure( "values in linked column pair " + detailColName + "->" + masterColName + " (" + - detailValue + "->" + masterValue + ") do not match (master position: " + m_masterSet.getRow() + ")!", + detailValue + "->" + masterValue + ") do not match (master position: " + m_masterResult.getRow() + ")!", masterValue == detailValue ); } diff --git a/forms/qa/integration/forms/TestCase.java b/forms/qa/integration/forms/TestCase.java index ba607e753..b842371e5 100644 --- a/forms/qa/integration/forms/TestCase.java +++ b/forms/qa/integration/forms/TestCase.java @@ -30,11 +30,9 @@ package integration.forms; -import com.sun.star.uno.*; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.util.XCloseable; import com.sun.star.util.XModifiable; -import integration.forms.DocumentType; public abstract class TestCase extends complexlib.ComplexTestCase implements com.sun.star.lang.XEventListener { @@ -50,12 +48,23 @@ public abstract class TestCase extends complexlib.ComplexTestCase implements com } /* ------------------------------------------------------------------ */ + public String getTestObjectName() + { + return this.getClass().getName(); + } + + /* ------------------------------------------------------------------ */ public void before() throws com.sun.star.uno.Exception, java.lang.Exception { m_orb = (XMultiServiceFactory)param.getMSF(); } /* ------------------------------------------------------------------ */ + public void after() throws com.sun.star.uno.Exception, java.lang.Exception + { + } + + /* ------------------------------------------------------------------ */ /** closes our document, if we have an open one, via (simulated) user input */ protected void closeDocumentByUI() diff --git a/forms/qa/integration/forms/dbfTools.java b/forms/qa/integration/forms/dbfTools.java index 2f100a2c2..8588cf8a0 100644 --- a/forms/qa/integration/forms/dbfTools.java +++ b/forms/qa/integration/forms/dbfTools.java @@ -24,7 +24,7 @@ class dbfTools */ static public XPropertySet queryPropertySet( Object aComp ) { - return (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, aComp ); + return UnoRuntime.queryInterface( XPropertySet.class, aComp ); } /* ------------------------------------------------------------------ */ @@ -32,7 +32,7 @@ class dbfTools */ static public XIndexContainer queryIndexContainer( Object aComp ) { - return (XIndexContainer)UnoRuntime.queryInterface( XIndexContainer.class, aComp ); + return UnoRuntime.queryInterface( XIndexContainer.class, aComp ); } /* ------------------------------------------------------------------ */ @@ -40,15 +40,16 @@ class dbfTools */ static public XComponent queryComponent( Object aComp ) { - return (XComponent)UnoRuntime.queryInterface( XComponent.class, aComp ); + return UnoRuntime.queryInterface( XComponent.class, aComp ); } /* ------------------------------------------------------------------ */ /** retrieves the parent of the given object */ + @SuppressWarnings("unchecked") static Object getParent( Object aComponent, Class aInterfaceClass ) { - XChild xAsChild = (XChild)UnoRuntime.queryInterface( XChild.class, aComponent ); + XChild xAsChild = UnoRuntime.queryInterface( XChild.class, aComponent ); return UnoRuntime.queryInterface( aInterfaceClass, xAsChild.getParent() ); } }; diff --git a/forms/qa/org/openoffice/complex/forms/tools/ResultSet.java b/forms/qa/org/openoffice/complex/forms/tools/ResultSet.java new file mode 100644 index 000000000..7763afe6b --- /dev/null +++ b/forms/qa/org/openoffice/complex/forms/tools/ResultSet.java @@ -0,0 +1,264 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package org.openoffice.complex.forms.tools; + +import com.sun.star.container.XNameAccess; +import com.sun.star.io.XInputStream; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XArray; +import com.sun.star.sdbc.XBlob; +import com.sun.star.sdbc.XClob; +import com.sun.star.sdbc.XRef; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbc.XRow; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.Date; +import com.sun.star.util.DateTime; +import com.sun.star.util.Time; + +/** + * + * @author frank.schoenheit@sun.com + */ +public class ResultSet implements XResultSet, XRow +{ + private final XResultSet m_resultSet; + private final XRow m_row; + + public ResultSet( final Object _resultSet ) + { + m_resultSet = (XResultSet)UnoRuntime.queryInterface( XResultSet.class, _resultSet ); + m_row = (XRow)UnoRuntime.queryInterface( XRow.class, _resultSet ); + } + + public + boolean next() throws SQLException + { + return m_resultSet.next(); + } + + public + boolean isBeforeFirst() throws SQLException + { + return m_resultSet.isBeforeFirst(); + } + + public + boolean isAfterLast() throws SQLException + { + return m_resultSet.isAfterLast(); + } + + public + boolean isFirst() throws SQLException + { + return m_resultSet.isFirst(); + } + + public + boolean isLast() throws SQLException + { + return m_resultSet.isLast(); + } + + public + void beforeFirst() throws SQLException + { + m_resultSet.beforeFirst(); + } + + public + void afterLast() throws SQLException + { + m_resultSet.afterLast(); + } + + public + boolean first() throws SQLException + { + return m_resultSet.first(); + } + + public + boolean last() throws SQLException + { + return m_resultSet.last(); + } + + public + int getRow() throws SQLException + { + return m_resultSet.getRow(); + } + + public + boolean absolute( int _row ) throws SQLException + { + return m_resultSet.absolute( _row ); + } + + public + boolean relative( int _offset ) throws SQLException + { + return m_resultSet.relative( _offset ); + } + + public + boolean previous() throws SQLException + { + return m_resultSet.previous(); + } + + public + void refreshRow() throws SQLException + { + m_resultSet.refreshRow(); + } + + public + boolean rowUpdated() throws SQLException + { + return m_resultSet.rowUpdated(); + } + + public + boolean rowInserted() throws SQLException + { + return m_resultSet.rowInserted(); + } + + public + boolean rowDeleted() throws SQLException + { + return m_resultSet.rowDeleted(); + } + + public + Object getStatement() throws SQLException + { + return m_resultSet.getStatement(); + } + + public + boolean wasNull() throws SQLException + { + return m_row.wasNull(); + } + + public + String getString( int _colIndex ) throws SQLException + { + return m_row.getString( _colIndex ); + } + + public + boolean getBoolean( int _colIndex ) throws SQLException + { + return m_row.getBoolean( _colIndex ); + } + + public + byte getByte( int _colIndex ) throws SQLException + { + return m_row.getByte( _colIndex ); + } + + public + short getShort( int _colIndex ) throws SQLException + { + return m_row.getShort( _colIndex ); + } + + public + int getInt( int _colIndex ) throws SQLException + { + return m_row.getInt( _colIndex ); + } + + public + long getLong( int _colIndex ) throws SQLException + { + return m_row.getLong( _colIndex ); + } + + public + float getFloat( int _colIndex ) throws SQLException + { + return m_row.getFloat( _colIndex ); + } + + public + double getDouble( int _colIndex ) throws SQLException + { + return m_row.getDouble( _colIndex ); + } + + public + byte[] getBytes( int _colIndex ) throws SQLException + { + return m_row.getBytes( _colIndex ); + } + + public + Date getDate( int _colIndex ) throws SQLException + { + return m_row.getDate( _colIndex ); + } + + public + Time getTime( int _colIndex ) throws SQLException + { + return m_row.getTime( _colIndex ); + } + + public + DateTime getTimestamp( int _colIndex ) throws SQLException + { + return m_row.getTimestamp( _colIndex ); + } + + public + XInputStream getBinaryStream( int _colIndex ) throws SQLException + { + return m_row.getBinaryStream( _colIndex ); + } + + public + XInputStream getCharacterStream( int _colIndex ) throws SQLException + { + return m_row.getCharacterStream( _colIndex ); + } + + public + Object getObject( int _colIndex, XNameAccess _typeMap ) throws SQLException + { + return m_row.getObject( _colIndex, _typeMap ); + } + + public + XRef getRef( int _colIndex ) throws SQLException + { + return m_row.getRef( _colIndex ); + } + + public + XBlob getBlob( int _colIndex ) throws SQLException + { + return m_row.getBlob( _colIndex ); + } + + public + XClob getClob( int _colIndex ) throws SQLException + { + return m_row.getClob( _colIndex ); + } + + public + XArray getArray( int _colIndex ) throws SQLException + { + return m_row.getArray( _colIndex ); + } +} diff --git a/forms/source/component/Button.cxx b/forms/source/component/Button.cxx index 5045c9fdb..09690f1b7 100644 --- a/forms/source/component/Button.cxx +++ b/forms/source/component/Button.cxx @@ -509,7 +509,7 @@ IMPL_LINK( OButtonControl, OnClick, void*, EMPTYARG ) void OButtonControl::actionPerformed_Impl( sal_Bool _bNotifyListener, const ::com::sun::star::awt::MouseEvent& _rEvt ) { { - sal_Int32 nFeatureId = -1; + sal_Int16 nFeatureId = -1; { ::osl::MutexGuard aGuard( m_aMutex ); nFeatureId = m_nTargetUrlFeatureId; @@ -636,7 +636,7 @@ sal_Bool SAL_CALL OButtonControl::setModel( const Reference< XControlModel >& _r //------------------------------------------------------------------------------ void OButtonControl::modelFeatureUrlPotentiallyChanged( ) { - sal_Int32 nOldUrlFeatureId = m_nTargetUrlFeatureId; + sal_Int16 nOldUrlFeatureId = m_nTargetUrlFeatureId; // doe we have another TargetURL now? If so, we need to update our dispatches m_nTargetUrlFeatureId = getModelUrlFeatureId( ); @@ -675,9 +675,9 @@ namespace } //------------------------------------------------------------------------------ -sal_Int32 OButtonControl::getModelUrlFeatureId( ) const +sal_Int16 OButtonControl::getModelUrlFeatureId( ) const { - sal_Int32 nFeatureId = -1; + sal_Int16 nFeatureId = -1; // some URL related properties of the model ::rtl::OUString sUrl; @@ -717,14 +717,14 @@ void SAL_CALL OButtonControl::setDesignMode( sal_Bool _bOn ) throw( RuntimeExcep } //------------------------------------------------------------------------------ -void OButtonControl::getSupportedFeatures( ::std::vector< sal_Int32 >& /* [out] */ _rFeatureIds ) +void OButtonControl::getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds ) { if ( -1 != m_nTargetUrlFeatureId ) _rFeatureIds.push_back( m_nTargetUrlFeatureId ); } //------------------------------------------------------------------ -void OButtonControl::featureStateChanged( sal_Int32 _nFeatureId, sal_Bool _bEnabled ) +void OButtonControl::featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled ) { if ( _nFeatureId == m_nTargetUrlFeatureId ) { @@ -754,7 +754,7 @@ void OButtonControl::allFeatureStatesChanged( ) } //------------------------------------------------------------------ -bool OButtonControl::isEnabled( sal_Int32 _nFeatureId ) const +bool OButtonControl::isEnabled( sal_Int16 _nFeatureId ) const { if ( const_cast< OButtonControl* >( this )->isDesignMode() ) // TODO: the model property? diff --git a/forms/source/component/Button.hxx b/forms/source/component/Button.hxx index 1f4ed0302..f63b5a2e3 100644 --- a/forms/source/component/Button.hxx +++ b/forms/source/component/Button.hxx @@ -131,7 +131,7 @@ class OButtonControl :public OButtonControl_BASE { private: sal_uInt32 m_nClickEvent; - sal_Int32 m_nTargetUrlFeatureId; + sal_Int16 m_nTargetUrlFeatureId; /// caches the value of the "Enabled" property of our model sal_Bool m_bEnabledByPropertyValue; @@ -176,10 +176,10 @@ public: protected: // OFormNavigationHelper overriables - virtual void getSupportedFeatures( ::std::vector< sal_Int32 >& /* [out] */ _rFeatureIds ); - virtual void featureStateChanged( sal_Int32 _nFeatureId, sal_Bool _bEnabled ); + virtual void getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds ); + virtual void featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled ); virtual void allFeatureStatesChanged( ); - virtual bool isEnabled( sal_Int32 _nFeatureId ) const; + virtual bool isEnabled( sal_Int16 _nFeatureId ) const; // XDispatchProviderInterception disambiguaiton virtual void SAL_CALL registerDispatchProviderInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException); @@ -198,7 +198,7 @@ private: /** retrieves the feature id (see OFormNavigationHelper) of the TargetURL of the model. */ - sal_Int32 getModelUrlFeatureId( ) const; + sal_Int16 getModelUrlFeatureId( ) const; /** starts or stops listening for changes in model properties we're interested in */ diff --git a/forms/source/component/Columns.cxx b/forms/source/component/Columns.cxx index 2c17f67bf..3127f8a68 100644 --- a/forms/source/component/Columns.cxx +++ b/forms/source/component/Columns.cxx @@ -342,7 +342,7 @@ void OGridColumn::clearAggregateProperties( Sequence< Property >& _rProps, sal_B aForbiddenProperties.insert( PROPERTY_VSCROLL ); aForbiddenProperties.insert( PROPERTY_CONTROLLABEL ); aForbiddenProperties.insert( PROPERTY_RICH_TEXT ); - aForbiddenProperties.insert( PROPERTY_VERTICALALIGN ); + aForbiddenProperties.insert( PROPERTY_VERTICAL_ALIGN ); aForbiddenProperties.insert( PROPERTY_IMAGE_URL ); aForbiddenProperties.insert( PROPERTY_IMAGE_POSITION ); aForbiddenProperties.insert( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableVisible" ) ) ); @@ -416,14 +416,14 @@ sal_Bool OGridColumn::convertFastPropertyValue( Any& rConvertedValue, Any& rOldV bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aWidth, ::getCppuType((const sal_Int32*)NULL)); break; case PROPERTY_ID_ALIGN: - try + bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_aAlign, ::getCppuType( (const sal_Int32*)NULL ) ); + // strange enough, css.awt.TextAlign is a 32-bit integer, while the Align property (both here for grid controls + // and for ordinary toolkit controls) is a 16-bit integer. So, allow for 32 bit, but normalize it to 16 bit + if ( bModified ) { - bModified = tryPropertyValue(rConvertedValue, rOldValue, rValue, m_aAlign, ::getCppuType((const sal_Int16*)NULL)); - } - catch(starlang::IllegalArgumentException&) - { - OSL_ENSURE(0,"OGridColumn::convertFastPropertyValue: TextAlign must be casted to sal_Int16!"); - throw; + sal_Int32 nAlign( 0 ); + if ( rConvertedValue >>= nAlign ) + rConvertedValue <<= (sal_Int16)nAlign; } break; case PROPERTY_ID_HIDDEN: diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 4e754854c..43e2fb0ac 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -31,72 +31,71 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_forms.hxx" -#include "componenttools.hxx"
-#include "DatabaseForm.hxx"
-#include "EventThread.hxx"
-#include "frm_module.hxx"
-#include "frm_resource.hrc"
-#include "frm_resource.hxx"
-#include "GroupManager.hxx"
-#include "property.hrc"
-#include "property.hxx"
-#include "services.hxx"
-
-#include <com/sun/star/awt/XControlContainer.hpp>
-#include <com/sun/star/awt/XTextComponent.hpp>
-#include <com/sun/star/form/DataSelectionType.hpp>
-#include <com/sun/star/form/FormComponentType.hpp>
-#include <com/sun/star/form/TabulatorCycle.hpp>
-#include <com/sun/star/frame/FrameSearchFlag.hpp>
-#include <com/sun/star/frame/XDispatch.hpp>
-#include <com/sun/star/frame/XDispatchProvider.hpp>
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/io/XObjectInputStream.hpp>
-#include <com/sun/star/io/XObjectOutputStream.hpp>
-#include <com/sun/star/sdb/CommandType.hpp>
-#include <com/sun/star/sdb/RowSetVetoException.hpp>
-#include <com/sun/star/sdb/SQLContext.hpp>
-#include <com/sun/star/sdb/XColumnUpdate.hpp>
-#include <com/sun/star/sdbc/DataType.hpp>
-#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
-#include <com/sun/star/sdbc/ResultSetType.hpp>
-#include <com/sun/star/sdbc/XRowSet.hpp>
-#include <com/sun/star/sdbcx/Privilege.hpp>
-#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
-#include <com/sun/star/util/XCancellable.hpp>
-#include <com/sun/star/util/XURLTransformer.hpp>
+#include "componenttools.hxx" +#include "DatabaseForm.hxx" +#include "EventThread.hxx" +#include "frm_module.hxx" +#include "frm_resource.hrc" +#include "frm_resource.hxx" +#include "GroupManager.hxx" +#include "property.hrc" +#include "property.hxx" +#include "services.hxx" + +#include <com/sun/star/awt/XControlContainer.hpp> +#include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/form/DataSelectionType.hpp> +#include <com/sun/star/form/FormComponentType.hpp> +#include <com/sun/star/form/TabulatorCycle.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/io/XObjectInputStream.hpp> +#include <com/sun/star/io/XObjectOutputStream.hpp> +#include <com/sun/star/sdb/CommandType.hpp> +#include <com/sun/star/sdb/RowSetVetoException.hpp> +#include <com/sun/star/sdb/SQLContext.hpp> +#include <com/sun/star/sdb/XColumnUpdate.hpp> +#include <com/sun/star/sdbc/DataType.hpp> +#include <com/sun/star/sdbc/ResultSetConcurrency.hpp> +#include <com/sun/star/sdbc/ResultSetType.hpp> +#include <com/sun/star/sdbc/XRowSet.hpp> +#include <com/sun/star/sdbcx/Privilege.hpp> +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <com/sun/star/util/XCancellable.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/util/XModifiable2.hpp> -
-#include <comphelper/basicio.hxx>
-#include <comphelper/container.hxx>
-#include <comphelper/enumhelper.hxx>
-#include <comphelper/extract.hxx>
-#include <comphelper/seqstream.hxx>
-#include <comphelper/sequence.hxx>
-#include <comphelper/stl_types.hxx>
-#include <comphelper/uno3.hxx>
-#include <connectivity/dbtools.hxx>
-#include <cppuhelper/exc_hlp.hxx>
-#include <cppuhelper/implbase2.hxx>
-#include <osl/mutex.hxx>
-#include <rtl/math.hxx>
-#include <rtl/tencinfo.h>
-#include <svl/inetstrm.hxx>
-#include <svl/inettype.hxx>
-#include <tools/debug.hxx>
-#include <tools/diagnose_ex.h>
-#include <tools/fsys.hxx>
-#include <tools/inetmsg.hxx>
-#include <tools/urlobj.hxx>
-#include <unotools/ucblockbytes.hxx>
-#include <unotools/ucbstreamhelper.hxx>
-#include <vcl/svapp.hxx>
-#include <vcl/timer.hxx>
-#include <vos/mutex.hxx>
- -#include <ctype.h>
-#include <hash_map>
-//#include <stdio.h>
+ +#include <comphelper/basicio.hxx> +#include <comphelper/container.hxx> +#include <comphelper/enumhelper.hxx> +#include <comphelper/extract.hxx> +#include <comphelper/seqstream.hxx> +#include <comphelper/sequence.hxx> +#include <comphelper/stl_types.hxx> +#include <comphelper/uno3.hxx> +#include <connectivity/dbtools.hxx> +#include <cppuhelper/exc_hlp.hxx> +#include <cppuhelper/implbase2.hxx> +#include <osl/mutex.hxx> +#include <rtl/math.hxx> +#include <rtl/tencinfo.h> +#include <svl/inetstrm.hxx> +#include <svl/inettype.hxx> +#include <tools/debug.hxx> +#include <tools/diagnose_ex.h> +#include <tools/fsys.hxx> +#include <tools/inetmsg.hxx> +#include <tools/urlobj.hxx> +#include <unotools/ucblockbytes.hxx> +#include <unotools/ucbstreamhelper.hxx> +#include <vcl/svapp.hxx> +#include <vcl/timer.hxx> +#include <vos/mutex.hxx> + +#include <ctype.h> +#include <hash_map> // compatiblity: DatabaseCursorType is dead, but for compatiblity reasons we still have to write it ... namespace com { @@ -2629,16 +2628,15 @@ void ODatabaseForm::impl_createLoadTimer() //------------------------------------------------------------------------------ void SAL_CALL ODatabaseForm::loaded(const EventObject& /*aEvent*/) throw( RuntimeException ) { - // now start the rowset listening to recover cursor events - load_impl(sal_True); { - ::osl::MutexGuard aGuard(m_aMutex); - Reference<XRowSet> xParentRowSet(m_xParent, UNO_QUERY); - if (xParentRowSet.is()) - xParentRowSet->addRowSetListener(this); + ::osl::MutexGuard aGuard( m_aMutex ); + Reference< XRowSet > xParentRowSet( m_xParent, UNO_QUERY_THROW ); + xParentRowSet->addRowSetListener( this ); impl_createLoadTimer(); } + + load_impl( sal_True ); } //------------------------------------------------------------------------------ @@ -2646,12 +2644,14 @@ void SAL_CALL ODatabaseForm::unloading(const EventObject& /*aEvent*/) throw( Run { { // now stop the rowset listening if we are a subform - ::osl::MutexGuard aGuard(m_aMutex); - DELETEZ(m_pLoadTimer); + ::osl::MutexGuard aGuard( m_aMutex ); - Reference<XRowSet> xParentRowSet(m_xParent, UNO_QUERY); - if (xParentRowSet.is()) - xParentRowSet->removeRowSetListener(this); + if ( m_pLoadTimer && m_pLoadTimer->IsActive() ) + m_pLoadTimer->Stop(); + DELETEZ( m_pLoadTimer ); + + Reference< XRowSet > xParentRowSet( m_xParent, UNO_QUERY_THROW ); + xParentRowSet->removeRowSetListener( this ); } unload(); @@ -2879,7 +2879,7 @@ sal_Bool ODatabaseForm::implEnsureConnection() } catch( Exception ) { - DBG_ERROR( "ODatabaseForm::implEnsureConnection: caught an exception which I cannot handle!" ); + DBG_UNHANDLED_EXCEPTION(); } return sal_False; diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index 5c68f203f..b240ca066 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -2216,7 +2216,7 @@ sal_Bool OBoundControlModel::approveDbColumnType(sal_Int32 _nColumnType) || (_nColumnType == DataType::LONGVARBINARY) || (_nColumnType == DataType::OTHER) || (_nColumnType == DataType::OBJECT) || (_nColumnType == DataType::DISTINCT) || (_nColumnType == DataType::STRUCT) || (_nColumnType == DataType::ARRAY) - || (_nColumnType == DataType::BLOB) || (_nColumnType == DataType::CLOB) + || (_nColumnType == DataType::BLOB) /*|| (_nColumnType == DataType::CLOB)*/ || (_nColumnType == DataType::REF) || (_nColumnType == DataType::SQLNULL)) return sal_False; @@ -2551,10 +2551,11 @@ void OBoundControlModel::reset() throw (RuntimeException) || ( nFieldType == DataType::VARBINARY ) || ( nFieldType == DataType::LONGVARBINARY ) || ( nFieldType == DataType::OBJECT ) - || ( nFieldType == DataType::BLOB ) - || ( nFieldType == DataType::CLOB ) + /*|| ( nFieldType == DataType::CLOB )*/ ) m_xColumn->getBinaryStream(); + else if ( nFieldType == DataType::BLOB ) + m_xColumn->getBlob(); else m_xColumn->getString(); @@ -2803,7 +2804,14 @@ void SAL_CALL OBoundControlModel::modified( const EventObject& _rEvent ) throw ( //-------------------------------------------------------------------- void OBoundControlModel::transferDbValueToControl( ) { - setControlValue( translateDbColumnToControlValue(), eDbColumnBinding ); + try + { + setControlValue( translateDbColumnToControlValue(), eDbColumnBinding ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //------------------------------------------------------------------------------ diff --git a/forms/source/component/ImageControl.cxx b/forms/source/component/ImageControl.cxx index cf6bb8843..d9bd0f736 100644 --- a/forms/source/component/ImageControl.cxx +++ b/forms/source/component/ImageControl.cxx @@ -115,6 +115,7 @@ namespace || ( _nFieldType == DataType::OBJECT ) || ( _nFieldType == DataType::BLOB ) || ( _nFieldType == DataType::LONGVARCHAR ) + || ( _nFieldType == DataType::CLOB ) ) return ImageStoreBinary; diff --git a/forms/source/cppugen/makefile.mk b/forms/source/cppugen/makefile.mk deleted file mode 100644 index aa65a7122..000000000 --- a/forms/source/cppugen/makefile.mk +++ /dev/null @@ -1,68 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2008 by Sun Microsystems, Inc. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# $RCSfile: makefile.mk,v $ -# -# $Revision: 1.6 $ -# -# 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$/inc -PRJNAME=forms -TARGET=fm_cppugen - -# --- Settings ---------------------------------- - -.INCLUDE : settings.mk -.INCLUDE: $(PRJ)$/makefile.pmk - -# --- Types ------------------------------------- - - - -# --- Types ------------------------------------- - -UNOTYPES+= \ - com.sun.star.form.binding.XBindableValue \ - com.sun.star.form.binding.XValueBinding \ - com.sun.star.form.binding.XListEntrySink \ - com.sun.star.form.binding.XListEntrySource \ - com.sun.star.form.binding.XListEntryListener \ - com.sun.star.form.validation.XValidator \ - com.sun.star.form.validation.XValidatable \ - com.sun.star.form.validation.XValidityConstraintListener \ - com.sun.star.form.validation.XValidatableFormComponent \ - com.sun.star.form.submission.XSubmissionSupplier \ - com.sun.star.xforms.XModel \ - com.sun.star.xforms.XFormsSupplier \ - com.sun.star.xforms.XSubmission \ - com.sun.star.xsd.WhiteSpaceTreatment \ - com.sun.star.xsd.XDataType \ - -# --- Targets ---------------------------------- - -.INCLUDE : target.mk - diff --git a/forms/source/helper/commanddescriptionprovider.cxx b/forms/source/helper/commanddescriptionprovider.cxx new file mode 100644 index 000000000..2eb79aa17 --- /dev/null +++ b/forms/source/helper/commanddescriptionprovider.cxx @@ -0,0 +1,139 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* 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_forms.hxx" + +#include "commanddescriptionprovider.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/frame/XModuleManager.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +/** === end UNO includes === **/ + +#include <comphelper/namedvaluecollection.hxx> +#include <tools/diagnose_ex.h> + +//........................................................................ +namespace frm +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::frame::XModel; + using ::com::sun::star::container::XNameAccess; + using ::com::sun::star::frame::XModuleManager; + using ::com::sun::star::beans::PropertyValue; + /** === end UNO using === **/ + + //==================================================================== + //= DefaultCommandDescriptionProvider + //==================================================================== + class DefaultCommandDescriptionProvider : public ICommandDescriptionProvider + { + public: + DefaultCommandDescriptionProvider( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument ) + { + impl_init_nothrow( _rContext, _rxDocument ); + } + + ~DefaultCommandDescriptionProvider() + { + } + + // ICommandDescriptionProvider + virtual ::rtl::OUString getCommandDescription( const ::rtl::OUString& _rCommandURL ) const; + + private: + void impl_init_nothrow( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument ); + + private: + Reference< XNameAccess > m_xCommandAccess; + }; + + + //-------------------------------------------------------------------- + void DefaultCommandDescriptionProvider::impl_init_nothrow( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument ) + { + OSL_ENSURE( _rxDocument.is(), "DefaultCommandDescriptionProvider::impl_init_nothrow: no document => no command descriptions!" ); + if ( !_rxDocument.is() ) + return; + + try + { + Reference< XModuleManager > xModuleManager( _rContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW ); + ::rtl::OUString sModuleID = xModuleManager->identify( _rxDocument ); + + Reference< XNameAccess > xUICommandDescriptions( _rContext.createComponent( "com.sun.star.frame.UICommandDescription" ), UNO_QUERY_THROW ); + m_xCommandAccess.set( xUICommandDescriptions->getByName( sModuleID ), UNO_QUERY_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //-------------------------------------------------------------------- + ::rtl::OUString DefaultCommandDescriptionProvider::getCommandDescription( const ::rtl::OUString& _rCommandURL ) const + { + if ( !m_xCommandAccess.is() ) + return ::rtl::OUString(); + + try + { + ::comphelper::NamedValueCollection aCommandProperties( m_xCommandAccess->getByName( _rCommandURL ) ); + return aCommandProperties.getOrDefault( "Name", ::rtl::OUString() ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return ::rtl::OUString(); + } + + //-------------------------------------------------------------------- + PCommandDescriptionProvider createDocumentCommandDescriptionProvider( + const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument ) + { + PCommandDescriptionProvider pDescriptionProvider( new DefaultCommandDescriptionProvider( _rContext, _rxDocument ) ); + return pDescriptionProvider; + } + +//........................................................................ +} // namespace frm +//........................................................................ diff --git a/forms/source/helper/commandimageprovider.cxx b/forms/source/helper/commandimageprovider.cxx new file mode 100644 index 000000000..52ac2d95c --- /dev/null +++ b/forms/source/helper/commandimageprovider.cxx @@ -0,0 +1,180 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* 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_forms.hxx" + +#include "commandimageprovider.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/ui/XImageManager.hpp> +#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> +#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp> +#include <com/sun/star/frame/XModuleManager.hpp> +#include <com/sun/star/ui/ImageType.hpp> +/** === end UNO includes === **/ + +#include <tools/diagnose_ex.h> + +//........................................................................ +namespace frm +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::frame::XModel; + using ::com::sun::star::ui::XImageManager; + using ::com::sun::star::ui::XUIConfigurationManagerSupplier; + using ::com::sun::star::ui::XUIConfigurationManager; + using ::com::sun::star::ui::XModuleUIConfigurationManagerSupplier; + using ::com::sun::star::frame::XModuleManager; + using ::com::sun::star::graphic::XGraphic; + /** === end UNO using === **/ + namespace ImageType = ::com::sun::star::ui::ImageType; + + //==================================================================== + //= DocumentCommandImageProvider + //==================================================================== + class DocumentCommandImageProvider : public ICommandImageProvider + { + public: + DocumentCommandImageProvider( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument ) + { + impl_init_nothrow( _rContext, _rxDocument ); + } + virtual ~DocumentCommandImageProvider() + { + } + + // ICommandImageProvider + virtual CommandImages getCommandImages( const CommandURLs& _rCommandURLs, const bool _bLarge, const bool _bHiContrast ) const; + + private: + void impl_init_nothrow( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument ); + + private: + Reference< XImageManager > m_xDocumentImageManager; + Reference< XImageManager > m_xModuleImageManager; + }; + + //-------------------------------------------------------------------- + void DocumentCommandImageProvider::impl_init_nothrow( const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument ) + { + OSL_ENSURE( _rxDocument.is(), "DocumentCommandImageProvider::impl_init_nothrow: no document => no images!" ); + if ( !_rxDocument.is() ) + return; + + // obtain the image manager of the document + try + { + Reference< XUIConfigurationManagerSupplier > xSuppUIConfig( _rxDocument, UNO_QUERY_THROW ); + Reference< XUIConfigurationManager > xUIConfig( xSuppUIConfig->getUIConfigurationManager(), UNO_QUERY ); + m_xDocumentImageManager.set( xUIConfig->getImageManager(), UNO_QUERY_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + // obtain the image manager or the module + try + { + Reference< XModuleManager > xModuleManager( _rContext.createComponent( "com.sun.star.frame.ModuleManager" ), UNO_QUERY_THROW ); + ::rtl::OUString sModuleID = xModuleManager->identify( _rxDocument ); + + Reference< XModuleUIConfigurationManagerSupplier > xSuppUIConfig( + _rContext.createComponent( "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ), UNO_QUERY_THROW ); + Reference< XUIConfigurationManager > xUIConfig( + xSuppUIConfig->getUIConfigurationManager( sModuleID ), UNO_SET_THROW ); + m_xModuleImageManager.set( xUIConfig->getImageManager(), UNO_QUERY_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + //-------------------------------------------------------------------- + CommandImages DocumentCommandImageProvider::getCommandImages( const CommandURLs& _rCommandURLs, const bool _bLarge, const bool _bHiContrast ) const + { + const size_t nCommandCount = _rCommandURLs.getLength(); + CommandImages aImages( nCommandCount ); + try + { + const sal_Int16 nImageType = + ( _bLarge ? ImageType::SIZE_LARGE : ImageType::SIZE_DEFAULT ) + + ( _bHiContrast ? ImageType::COLOR_HIGHCONTRAST : ImageType::COLOR_NORMAL ); + + Sequence< Reference< XGraphic > > aDocImages( nCommandCount ); + Sequence< Reference< XGraphic > > aModImages( nCommandCount ); + + // first try the document image manager + if ( m_xDocumentImageManager.is() ) + aDocImages = m_xDocumentImageManager->getImages( nImageType, _rCommandURLs ); + + // then the module's image manager + if ( m_xModuleImageManager.is() ) + aModImages = m_xModuleImageManager->getImages( nImageType, _rCommandURLs ); + + ENSURE_OR_THROW( (size_t)aDocImages.getLength() == nCommandCount, "illegal array size returned by getImages (document image manager)" ); + ENSURE_OR_THROW( (size_t)aModImages.getLength() == nCommandCount, "illegal array size returned by getImages (module image manager)" ); + + for ( size_t i=0; i<nCommandCount; ++i ) + { + if ( aDocImages[i].is() ) + aImages[i] = Image( aDocImages[i] ); + else + aImages[i] = Image( aModImages[i] ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return aImages; + } + + //-------------------------------------------------------------------- + PCommandImageProvider createDocumentCommandImageProvider( + const ::comphelper::ComponentContext& _rContext, const Reference< XModel >& _rxDocument ) + { + PCommandImageProvider pImageProvider( new DocumentCommandImageProvider( _rContext, _rxDocument ) ); + return pImageProvider; + } + +//........................................................................ +} // namespace frm +//........................................................................ diff --git a/forms/source/helper/formnavigation.cxx b/forms/source/helper/formnavigation.cxx index 3ddfd89ad..513496e2b 100644 --- a/forms/source/helper/formnavigation.cxx +++ b/forms/source/helper/formnavigation.cxx @@ -33,12 +33,13 @@ #include "formnavigation.hxx" #include "urltransformer.hxx" #include "controlfeatureinterception.hxx" -#include <tools/debug.hxx> -#ifndef _SVX_SVXIDS_HRC -#include <svx/svxids.hrc> -#endif #include "frm_strings.hxx" +#include <com/sun/star/form/runtime/FormFeature.hpp> + +#include <tools/debug.hxx> + + //......................................................................... namespace frm { @@ -49,6 +50,7 @@ namespace frm using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; using namespace ::com::sun::star::frame; + namespace FormFeature = ::com::sun::star::form::runtime::FormFeature; //================================================================== //= OFormNavigationHelper @@ -83,7 +85,7 @@ namespace frm } //------------------------------------------------------------------ - void OFormNavigationHelper::featureStateChanged( sal_Int32 /*_nFeatureId*/, sal_Bool /*_bEnabled*/ ) + void OFormNavigationHelper::featureStateChanged( sal_Int16 /*_nFeatureId*/, sal_Bool /*_bEnabled*/ ) { // not interested in } @@ -270,12 +272,12 @@ namespace frm if ( m_aSupportedFeatures.empty() ) { // ask the derivee which feature ids it wants us to support - ::std::vector< sal_Int32 > aFeatureIds; + ::std::vector< sal_Int16 > aFeatureIds; getSupportedFeatures( aFeatureIds ); OFormNavigationMapper aUrlMapper( m_xORB ); - for ( ::std::vector< sal_Int32 >::const_iterator aLoop = aFeatureIds.begin(); + for ( ::std::vector< sal_Int16 >::const_iterator aLoop = aFeatureIds.begin(); aLoop != aFeatureIds.end(); ++aLoop ) @@ -300,7 +302,7 @@ namespace frm } //------------------------------------------------------------------ - void OFormNavigationHelper::dispatchWithArgument( sal_Int32 _nFeatureId, const sal_Char* _pParamAsciiName, + void OFormNavigationHelper::dispatchWithArgument( sal_Int16 _nFeatureId, const sal_Char* _pParamAsciiName, const Any& _rParamValue ) const { FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId ); @@ -318,7 +320,7 @@ namespace frm } //------------------------------------------------------------------ - void OFormNavigationHelper::dispatch( sal_Int32 _nFeatureId ) const + void OFormNavigationHelper::dispatch( sal_Int16 _nFeatureId ) const { FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId ); if ( m_aSupportedFeatures.end() != aInfo ) @@ -332,7 +334,7 @@ namespace frm } //------------------------------------------------------------------ - bool OFormNavigationHelper::isEnabled( sal_Int32 _nFeatureId ) const + bool OFormNavigationHelper::isEnabled( sal_Int16 _nFeatureId ) const { FeatureMap::const_iterator aInfo = m_aSupportedFeatures.find( _nFeatureId ); if ( m_aSupportedFeatures.end() != aInfo ) @@ -342,7 +344,7 @@ namespace frm } //------------------------------------------------------------------ - bool OFormNavigationHelper::getBooleanState( sal_Int32 _nFeatureId ) const + bool OFormNavigationHelper::getBooleanState( sal_Int16 _nFeatureId ) const { sal_Bool bState = sal_False; @@ -354,7 +356,7 @@ namespace frm } //------------------------------------------------------------------ - ::rtl::OUString OFormNavigationHelper::getStringState( sal_Int32 _nFeatureId ) const + ::rtl::OUString OFormNavigationHelper::getStringState( sal_Int16 _nFeatureId ) const { ::rtl::OUString sState; @@ -366,7 +368,7 @@ namespace frm } //------------------------------------------------------------------ - sal_Int32 OFormNavigationHelper::getIntegerState( sal_Int32 _nFeatureId ) const + sal_Int32 OFormNavigationHelper::getIntegerState( sal_Int16 _nFeatureId ) const { sal_Int32 nState = 0; @@ -382,7 +384,7 @@ namespace frm { disconnectDispatchers( ); // no supported features anymore: - FeatureMap aEmpty; + FeatureMap aEmpty; m_aSupportedFeatures.swap( aEmpty ); } @@ -401,7 +403,7 @@ namespace frm } //------------------------------------------------------------------ - bool OFormNavigationMapper::getFeatureURL( sal_Int32 _nFeatureId, URL& /* [out] */ _rURL ) + bool OFormNavigationMapper::getFeatureURL( sal_Int16 _nFeatureId, URL& /* [out] */ _rURL ) { // get the ascii version of the URL const char* pAsciiURL = getFeatureURLAscii( _nFeatureId ); @@ -412,84 +414,72 @@ namespace frm } //------------------------------------------------------------------ - const char* OFormNavigationMapper::getFeatureURLAscii( sal_Int32 _nFeatureId ) + namespace { - const char* pAsciiURL = NULL; - - switch ( _nFeatureId ) + struct FeatureURL { - case SID_FM_RECORD_ABSOLUTE : pAsciiURL = URL_FORM_POSITION; break; - case SID_FM_RECORD_TOTAL : pAsciiURL = URL_FORM_RECORDCOUNT; break; - case SID_FM_RECORD_FIRST : pAsciiURL = URL_RECORD_FIRST; break; - case SID_FM_RECORD_PREV : pAsciiURL = URL_RECORD_PREV; break; - case SID_FM_RECORD_NEXT : pAsciiURL = URL_RECORD_NEXT; break; - case SID_FM_RECORD_LAST : pAsciiURL = URL_RECORD_LAST; break; - case SID_FM_RECORD_SAVE : pAsciiURL = URL_RECORD_SAVE; break; - case SID_FM_RECORD_UNDO : pAsciiURL = URL_RECORD_UNDO; break; - case SID_FM_RECORD_NEW : pAsciiURL = URL_RECORD_NEW; break; - case SID_FM_RECORD_DELETE : pAsciiURL = URL_RECORD_DELETE; break; - case SID_FM_REFRESH : pAsciiURL = URL_FORM_REFRESH; break; - case SID_FM_REFRESH_FORM_CONTROL: pAsciiURL = URL_FORM_REFRESH_CURRENT_CONTROL; break; - - case SID_FM_SORTUP : pAsciiURL = URL_FORM_SORT_UP; break; - case SID_FM_SORTDOWN : pAsciiURL = URL_FORM_SORT_DOWN; break; - case SID_FM_ORDERCRIT : pAsciiURL = URL_FORM_SORT; break; - case SID_FM_AUTOFILTER : pAsciiURL = URL_FORM_AUTO_FILTER; break; - case SID_FM_FILTERCRIT : pAsciiURL = URL_FORM_FILTER; break; - case SID_FM_FORM_FILTERED : pAsciiURL = URL_FORM_APPLY_FILTER; break; - case SID_FM_REMOVE_FILTER_SORT : pAsciiURL = URL_FORM_REMOVE_FILTER; break; + const sal_Int16 nFormFeature; + const sal_Char* pAsciiURL; + + FeatureURL( const sal_Int16 _nFormFeature, const sal_Char* _pAsciiURL ) + :nFormFeature( _nFormFeature ) + ,pAsciiURL( _pAsciiURL ) + { + } }; - return pAsciiURL; + const FeatureURL* lcl_getFeatureTable() + { + static const FeatureURL s_aFeatureURLs[] = + { + FeatureURL( FormFeature::MoveAbsolute, URL_FORM_POSITION ), + FeatureURL( FormFeature::TotalRecords, URL_FORM_RECORDCOUNT ), + FeatureURL( FormFeature::MoveToFirst, URL_RECORD_FIRST ), + FeatureURL( FormFeature::MoveToPrevious, URL_RECORD_PREV ), + FeatureURL( FormFeature::MoveToNext, URL_RECORD_NEXT ), + FeatureURL( FormFeature::MoveToLast, URL_RECORD_LAST ), + FeatureURL( FormFeature::SaveRecordChanges, URL_RECORD_SAVE ), + FeatureURL( FormFeature::UndoRecordChanges, URL_RECORD_UNDO ), + FeatureURL( FormFeature::MoveToInsertRow, URL_RECORD_NEW ), + FeatureURL( FormFeature::DeleteRecord, URL_RECORD_DELETE ), + FeatureURL( FormFeature::ReloadForm, URL_FORM_REFRESH ), + FeatureURL( FormFeature::RefreshCurrentControl, URL_FORM_REFRESH_CURRENT_CONTROL ), + FeatureURL( FormFeature::SortAscending, URL_FORM_SORT_UP ), + FeatureURL( FormFeature::SortDescending, URL_FORM_SORT_DOWN ), + FeatureURL( FormFeature::InteractiveSort, URL_FORM_SORT ), + FeatureURL( FormFeature::AutoFilter, URL_FORM_AUTO_FILTER ), + FeatureURL( FormFeature::InteractiveFilter, URL_FORM_FILTER ), + FeatureURL( FormFeature::ToggleApplyFilter, URL_FORM_APPLY_FILTER ), + FeatureURL( FormFeature::RemoveFilterAndSort, URL_FORM_REMOVE_FILTER ), + FeatureURL( 0, NULL ) + }; + return s_aFeatureURLs; + } + } + + //------------------------------------------------------------------ + const char* OFormNavigationMapper::getFeatureURLAscii( sal_Int16 _nFeatureId ) + { + const FeatureURL* pFeatures = lcl_getFeatureTable(); + while ( pFeatures->pAsciiURL ) + { + if ( pFeatures->nFormFeature == _nFeatureId ) + return pFeatures->pAsciiURL; + ++pFeatures; + } + return NULL; } //------------------------------------------------------------------ - sal_Int32 OFormNavigationMapper::getFeatureId( const ::rtl::OUString& _rCompleteURL ) + sal_Int16 OFormNavigationMapper::getFeatureId( const ::rtl::OUString& _rCompleteURL ) { - sal_Int32 nFeatureId = -1; - - if ( _rCompleteURL == URL_FORM_POSITION ) - nFeatureId = SID_FM_RECORD_ABSOLUTE; - else if ( _rCompleteURL == URL_FORM_RECORDCOUNT ) - nFeatureId = SID_FM_RECORD_TOTAL; - else if ( _rCompleteURL == URL_RECORD_FIRST ) - nFeatureId = SID_FM_RECORD_FIRST; - else if ( _rCompleteURL == URL_RECORD_PREV ) - nFeatureId = SID_FM_RECORD_PREV; - else if ( _rCompleteURL == URL_RECORD_NEXT ) - nFeatureId = SID_FM_RECORD_NEXT; - else if ( _rCompleteURL == URL_RECORD_LAST ) - nFeatureId = SID_FM_RECORD_LAST; - else if ( _rCompleteURL == URL_RECORD_SAVE ) - nFeatureId = SID_FM_RECORD_SAVE; - else if ( _rCompleteURL == URL_RECORD_UNDO ) - nFeatureId = SID_FM_RECORD_UNDO; - else if ( _rCompleteURL == URL_RECORD_NEW ) - nFeatureId = SID_FM_RECORD_NEW; - else if ( _rCompleteURL == URL_RECORD_DELETE ) - nFeatureId = SID_FM_RECORD_DELETE; - else if ( _rCompleteURL == URL_FORM_REFRESH ) - nFeatureId = SID_FM_REFRESH; - else if ( _rCompleteURL == URL_FORM_REFRESH_CURRENT_CONTROL ) - nFeatureId = SID_FM_REFRESH_FORM_CONTROL; - else if ( _rCompleteURL == URL_FORM_SORT_UP ) - nFeatureId = SID_FM_SORTUP; - else if ( _rCompleteURL == URL_FORM_SORT_DOWN ) - nFeatureId = SID_FM_SORTDOWN; - else if ( _rCompleteURL == URL_FORM_SORT ) - nFeatureId = SID_FM_ORDERCRIT; - else if ( _rCompleteURL == URL_FORM_AUTO_FILTER ) - nFeatureId = SID_FM_AUTOFILTER; - else if ( _rCompleteURL == URL_FORM_FILTER ) - nFeatureId = SID_FM_FILTERCRIT; - else if ( _rCompleteURL == URL_FORM_APPLY_FILTER ) - nFeatureId = SID_FM_FORM_FILTERED; - else if ( _rCompleteURL == URL_FORM_REMOVE_FILTER ) - nFeatureId = SID_FM_REMOVE_FILTER_SORT; - - DBG_ASSERT( ( -1 == nFeatureId ) || _rCompleteURL.equalsAscii( getFeatureURLAscii( nFeatureId ) ), - "OFormNavigationMapper::getFeatureId: inconsistent maps!" ); - - return nFeatureId; + const FeatureURL* pFeatures = lcl_getFeatureTable(); + while ( pFeatures->pAsciiURL ) + { + if ( _rCompleteURL.compareToAscii( pFeatures->pAsciiURL ) == 0 ) + return pFeatures->nFormFeature; + ++pFeatures; + } + return -1; } //......................................................................... diff --git a/forms/source/helper/makefile.mk b/forms/source/helper/makefile.mk index 5739d1fcb..e451048dd 100644 --- a/forms/source/helper/makefile.mk +++ b/forms/source/helper/makefile.mk @@ -53,6 +53,8 @@ SLOFILES= $(SLO)$/formnavigation.obj \ $(SLO)$/urltransformer.obj \ $(SLO)$/windowstateguard.obj \ $(SLO)$/resettable.obj \ + $(SLO)$/commandimageprovider.obj \ + $(SLO)$/commanddescriptionprovider.obj \ # --- Targets ---------------------------------- diff --git a/forms/source/inc/FormComponent.hxx b/forms/source/inc/FormComponent.hxx index 85f3c3e5f..8fbce5b83 100644 --- a/forms/source/inc/FormComponent.hxx +++ b/forms/source/inc/FormComponent.hxx @@ -31,61 +31,61 @@ #ifndef _FORMS_FORMCOMPONENT_HXX_ #define _FORMS_FORMCOMPONENT_HXX_ -#include "cloneable.hxx"
-#include "ids.hxx"
-#include "property.hrc"
-#include "property.hxx"
-#include "propertybaghelper.hxx"
+#include "cloneable.hxx" +#include "ids.hxx" +#include "property.hrc" +#include "property.hxx" +#include "propertybaghelper.hxx" #include "resettable.hxx" -#include "services.hxx"
-#include "windowstateguard.hxx"
-
-/** === begin UNO includes === **/
-#include <com/sun/star/awt/XControl.hpp>
-#include <com/sun/star/beans/XPropertyAccess.hpp>
-#include <com/sun/star/beans/XPropertyContainer.hpp>
-#include <com/sun/star/container/XChild.hpp>
-#include <com/sun/star/container/XNamed.hpp>
-#include <com/sun/star/form/binding/XBindableValue.hpp>
-#include <com/sun/star/form/FormComponentType.hpp>
-#include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
-#include <com/sun/star/form/validation/XValidityConstraintListener.hpp>
-#include <com/sun/star/form/XBoundComponent.hpp>
-#include <com/sun/star/form/XBoundControl.hpp>
-#include <com/sun/star/form/XFormComponent.hpp>
-#include <com/sun/star/form/XLoadListener.hpp>
-#include <com/sun/star/form/XReset.hpp>
-#include <com/sun/star/io/XMarkableStream.hpp>
-#include <com/sun/star/io/XPersistObject.hpp>
-#include <com/sun/star/lang/DisposedException.hpp>
-#include <com/sun/star/lang/XEventListener.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/sdb/XColumn.hpp>
-#include <com/sun/star/sdb/XColumnUpdate.hpp>
-#include <com/sun/star/sdb/XRowSetChangeListener.hpp>
-#include <com/sun/star/sdbc/XRowSet.hpp>
-#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
-#include <com/sun/star/uno/XAggregation.hpp>
-#include <com/sun/star/util/XCloneable.hpp>
+#include "services.hxx" +#include "windowstateguard.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/beans/XPropertyAccess.hpp> +#include <com/sun/star/beans/XPropertyContainer.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/form/binding/XBindableValue.hpp> +#include <com/sun/star/form/FormComponentType.hpp> +#include <com/sun/star/form/validation/XValidatableFormComponent.hpp> +#include <com/sun/star/form/validation/XValidityConstraintListener.hpp> +#include <com/sun/star/form/XBoundComponent.hpp> +#include <com/sun/star/form/XBoundControl.hpp> +#include <com/sun/star/form/XFormComponent.hpp> +#include <com/sun/star/form/XLoadListener.hpp> +#include <com/sun/star/form/XReset.hpp> +#include <com/sun/star/io/XMarkableStream.hpp> +#include <com/sun/star/io/XPersistObject.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/sdb/XColumn.hpp> +#include <com/sun/star/sdb/XColumnUpdate.hpp> +#include <com/sun/star/sdb/XRowSetChangeListener.hpp> +#include <com/sun/star/sdbc/XRowSet.hpp> +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <com/sun/star/uno/XAggregation.hpp> +#include <com/sun/star/util/XCloneable.hpp> #include <com/sun/star/util/XModifyListener.hpp> -#include <com/sun/star/form/XLoadable.hpp>
-/** === end UNO includes === **/
-
-#include <comphelper/componentcontext.hxx>
-#include <comphelper/propagg.hxx>
-#include <comphelper/propertybag.hxx>
-#include <comphelper/propmultiplex.hxx>
-#include <comphelper/sequence.hxx>
-#include <comphelper/uno3.hxx>
-#include <cppuhelper/component.hxx>
-#include <cppuhelper/implbase1.hxx>
-#include <cppuhelper/implbase2.hxx>
-#include <cppuhelper/implbase3.hxx>
-#include <cppuhelper/implbase4.hxx>
-#include <cppuhelper/implbase7.hxx>
-#include <osl/mutex.hxx>
-#include <rtl/ustring.hxx>
+#include <com/sun/star/form/XLoadable.hpp> +/** === end UNO includes === **/ + +#include <comphelper/componentcontext.hxx> +#include <comphelper/propagg.hxx> +#include <comphelper/propertybag.hxx> +#include <comphelper/propmultiplex.hxx> +#include <comphelper/sequence.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/component.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase4.hxx> +#include <cppuhelper/implbase7.hxx> +#include <osl/mutex.hxx> +#include <rtl/ustring.hxx> #include <memory> diff --git a/forms/source/inc/commanddescriptionprovider.hxx b/forms/source/inc/commanddescriptionprovider.hxx new file mode 100644 index 000000000..86b7ad111 --- /dev/null +++ b/forms/source/inc/commanddescriptionprovider.hxx @@ -0,0 +1,68 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* 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 COMMANDDESCRIPTIONPROVIDER_HXX +#define COMMANDDESCRIPTIONPROVIDER_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/frame/XModel.hpp> +/** === end UNO includes === **/ + +#include <comphelper/componentcontext.hxx> + +#include <boost/shared_ptr.hpp> + +//........................................................................ +namespace frm +{ +//........................................................................ + + //==================================================================== + //= ICommandDescriptionProvider + //==================================================================== + class SAL_NO_VTABLE ICommandDescriptionProvider + { + public: + virtual ::rtl::OUString getCommandDescription( const ::rtl::OUString& _rCommandURL ) const = 0; + + virtual ~ICommandDescriptionProvider() { } + }; + + typedef ::boost::shared_ptr< const ICommandDescriptionProvider > PCommandDescriptionProvider; + + //===================================================================== + //= factory + //===================================================================== + PCommandDescriptionProvider + createDocumentCommandDescriptionProvider( + const ::comphelper::ComponentContext& _rContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocument + ); + +//........................................................................ +} // namespace frm +//........................................................................ + +#endif // COMMANDDESCRIPTIONPROVIDER_HXX diff --git a/forms/source/inc/commandimageprovider.hxx b/forms/source/inc/commandimageprovider.hxx new file mode 100644 index 000000000..79aafb977 --- /dev/null +++ b/forms/source/inc/commandimageprovider.hxx @@ -0,0 +1,77 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* 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 COMMANDIMAGEPROVIDER_HXX +#define COMMANDIMAGEPROVIDER_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/frame/XModel.hpp> +/** === end UNO includes === **/ + +#include <comphelper/componentcontext.hxx> +#include <vcl/image.hxx> + +#include <boost/shared_ptr.hpp> + +//........................................................................ +namespace frm +{ +//........................................................................ + + //===================================================================== + //= ICommandImageProvider + //===================================================================== + typedef ::rtl::OUString CommandURL; + typedef ::com::sun::star::uno::Sequence< CommandURL > CommandURLs; + typedef ::std::vector< Image > CommandImages; + + class SAL_NO_VTABLE ICommandImageProvider + { + public: + virtual CommandImages getCommandImages( + const CommandURLs& _rCommandURLs, + const bool _bLarge, + const bool _bHiContrast + ) const = 0; + + virtual ~ICommandImageProvider() { } + }; + + typedef ::boost::shared_ptr< const ICommandImageProvider > PCommandImageProvider; + + //===================================================================== + //= factory + //===================================================================== + PCommandImageProvider + createDocumentCommandImageProvider( + const ::comphelper::ComponentContext& _rContext, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocument + ); + +//........................................................................ +} // namespace frm +//........................................................................ + +#endif // COMMANDIMAGEPROVIDER_HXX diff --git a/forms/source/inc/featuredispatcher.hxx b/forms/source/inc/featuredispatcher.hxx index ebc52f088..64539cff7 100644 --- a/forms/source/inc/featuredispatcher.hxx +++ b/forms/source/inc/featuredispatcher.hxx @@ -49,7 +49,7 @@ namespace frm @param _nFeatureId the id of the feature to dispatch */ - virtual void dispatch( sal_Int32 _nFeatureId ) const = 0; + virtual void dispatch( sal_Int16 _nFeatureId ) const = 0; /** dispatches a feature, with an additional named parameter @@ -63,14 +63,14 @@ namespace frm the value of the parameter of the dispatch call */ virtual void dispatchWithArgument( - sal_Int32 _nFeatureId, + sal_Int16 _nFeatureId, const sal_Char* _pParamName, const ::com::sun::star::uno::Any& _rParamValue ) const = 0; /** checks whether a given feature is enabled */ - virtual bool isEnabled( sal_Int32 _nFeatureId ) const = 0; + virtual bool isEnabled( sal_Int16 _nFeatureId ) const = 0; /** returns the boolean state of a feature @@ -81,7 +81,7 @@ namespace frm This method allows retrieving status information about features which have an additional boolean information associated with it. */ - virtual bool getBooleanState( sal_Int32 _nFeatureId ) const = 0; + virtual bool getBooleanState( sal_Int16 _nFeatureId ) const = 0; /** returns the string state of a feature @@ -92,7 +92,7 @@ namespace frm This method allows retrieving status information about features which have an additional string information associated with it. */ - virtual ::rtl::OUString getStringState( sal_Int32 _nFeatureId ) const = 0; + virtual ::rtl::OUString getStringState( sal_Int16 _nFeatureId ) const = 0; /** returns the integer state of a feature @@ -103,7 +103,7 @@ namespace frm This method allows retrieving status information about features which have an additional integer information associated with it. */ - virtual sal_Int32 getIntegerState( sal_Int32 _nFeatureId ) const = 0; + virtual sal_Int32 getIntegerState( sal_Int16 _nFeatureId ) const = 0; }; //......................................................................... diff --git a/forms/source/inc/formnavigation.hxx b/forms/source/inc/formnavigation.hxx index d0abf0cf8..ae786aefd 100644 --- a/forms/source/inc/formnavigation.hxx +++ b/forms/source/inc/formnavigation.hxx @@ -71,7 +71,7 @@ namespace frm FeatureInfo() : bCachedState( sal_False ) { } }; - typedef ::std::map< sal_Int32, FeatureInfo > FeatureMap; + typedef ::std::map< sal_Int16, FeatureInfo > FeatureMap; private: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > @@ -106,12 +106,12 @@ namespace frm virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); // IFeatureDispatcher - virtual void dispatch( sal_Int32 _nFeatureId ) const; - virtual void dispatchWithArgument( sal_Int32 _nFeatureId, const sal_Char* _pParamName, const ::com::sun::star::uno::Any& _rParamValue ) const; - virtual bool isEnabled( sal_Int32 _nFeatureId ) const; - virtual bool getBooleanState( sal_Int32 _nFeatureId ) const; - virtual ::rtl::OUString getStringState( sal_Int32 _nFeatureId ) const; - virtual sal_Int32 getIntegerState( sal_Int32 _nFeatureId ) const; + virtual void dispatch( sal_Int16 _nFeatureId ) const; + virtual void dispatchWithArgument( sal_Int16 _nFeatureId, const sal_Char* _pParamName, const ::com::sun::star::uno::Any& _rParamValue ) const; + virtual bool isEnabled( sal_Int16 _nFeatureId ) const; + virtual bool getBooleanState( sal_Int16 _nFeatureId ) const; + virtual ::rtl::OUString getStringState( sal_Int16 _nFeatureId ) const; + virtual sal_Int32 getIntegerState( sal_Int16 _nFeatureId ) const; // own overridables /** is called when the interceptors have. @@ -134,7 +134,7 @@ namespace frm determines if the features is enabled or disabled @see getBooleanState */ - virtual void featureStateChanged( sal_Int32 _nFeatureId, sal_Bool _bEnabled ); + virtual void featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled ); /** notification for (potential) changes in the state of all features <p>The base class implementation does nothing. Derived classes could force @@ -149,7 +149,7 @@ namespace frm the array of features to support. Out parameter to fill by the derivee's implementation @pure */ - virtual void getSupportedFeatures( ::std::vector< sal_Int32 >& /* [out] */ _rFeatureIds ) = 0; + virtual void getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds ) = 0; protected: /** update all our dispatches which are controlled by our dispatch interceptors @@ -205,7 +205,7 @@ namespace frm @complexity O(log n) @return NULL if the given id is not a known feature id (which is a valid usage) */ - const char* getFeatureURLAscii( sal_Int32 _nFeatureId ); + const char* getFeatureURLAscii( sal_Int16 _nFeatureId ); /** retrieves the feature URL belonging to an feature id @@ -214,7 +214,7 @@ namespace frm <TRUE/> if and only if the given id is a known feature id (which is a valid usage) */ - bool getFeatureURL( sal_Int32 _nFeatureId, ::com::sun::star::util::URL& /* [out] */ _rURL ); + bool getFeatureURL( sal_Int16 _nFeatureId, ::com::sun::star::util::URL& /* [out] */ _rURL ); /** retrieves the feature id belonging to an feature URL @@ -223,7 +223,7 @@ namespace frm the id of the feature URL, or -1 if the URl is not known (which is a valid usage) */ - sal_Int32 getFeatureId( const ::rtl::OUString& _rCompleteURL ); + sal_Int16 getFeatureId( const ::rtl::OUString& _rCompleteURL ); private: OFormNavigationMapper( ); // never implemented diff --git a/forms/source/inc/frm_strings.hxx b/forms/source/inc/frm_strings.hxx index b153321de..63ad54d56 100644 --- a/forms/source/inc/frm_strings.hxx +++ b/forms/source/inc/frm_strings.hxx @@ -153,7 +153,7 @@ namespace frm FORMS_CONSTASCII_STRING( PROPERTY_DEFAULT_SELECT_SEQ, "DefaultSelection" ); FORMS_CONSTASCII_STRING( PROPERTY_MULTISELECTION, "MultiSelection" ); FORMS_CONSTASCII_STRING( PROPERTY_ALIGN, "Align" ); - FORMS_CONSTASCII_STRING( PROPERTY_VERTICALALIGN, "VerticalAlign" ); + FORMS_CONSTASCII_STRING( PROPERTY_VERTICAL_ALIGN, "VerticalAlign" ); FORMS_CONSTASCII_STRING( PROPERTY_DEFAULT_DATE, "DefaultDate" ); FORMS_CONSTASCII_STRING( PROPERTY_DEFAULT_TIME, "DefaultTime" ); FORMS_CONSTASCII_STRING( PROPERTY_DEFAULT_VALUE, "DefaultValue" ); diff --git a/forms/source/inc/property.hrc b/forms/source/inc/property.hrc index 100a693a9..4d1b5d819 100644 --- a/forms/source/inc/property.hrc +++ b/forms/source/inc/property.hrc @@ -63,7 +63,7 @@ namespace frm #define PROPERTY_ID_INPUT_REQUIRED (PROPERTY_ID_START + 19) #define PROPERTY_ID_WRITING_MODE (PROPERTY_ID_START + 20) #define PROPERTY_ID_CONTEXT_WRITING_MODE (PROPERTY_ID_START + 21) - // free +#define PROPERTY_ID_VERTICAL_ALIGN (PROPERTY_ID_START + 22) // free // free // free diff --git a/forms/source/richtext/richtextmodel.cxx b/forms/source/richtext/richtextmodel.cxx index ce0f1c8b9..abe6690a2 100644 --- a/forms/source/richtext/richtextmodel.cxx +++ b/forms/source/richtext/richtextmodel.cxx @@ -40,7 +40,9 @@ /** === begin UNO includes === **/ #include <com/sun/star/awt/LineEndFormat.hpp> #include <com/sun/star/text/WritingMode2.hpp> +#include <com/sun/star/style/VerticalAlignment.hpp> /** === end UNO includes === **/ + #include <cppuhelper/typeprovider.hxx> #include <comphelper/guarding.hxx> #include <toolkit/awt/vclxdevice.hxx> @@ -67,6 +69,7 @@ namespace frm using namespace ::com::sun::star::beans; using namespace ::com::sun::star::form; using namespace ::com::sun::star::util; + using namespace ::com::sun::star::style; namespace WritingMode2 = ::com::sun::star::text::WritingMode2; @@ -120,6 +123,7 @@ namespace frm m_aTabStop = _pOriginal->m_aTabStop; m_aBackgroundColor = _pOriginal->m_aBackgroundColor; m_aBorderColor = _pOriginal->m_aBorderColor; + m_aVerticalAlignment = _pOriginal->m_aVerticalAlignment; m_sDefaultControl = _pOriginal->m_sDefaultControl; m_sHelpText = _pOriginal->m_sHelpText; m_sHelpURL = _pOriginal->m_sHelpURL; @@ -201,9 +205,10 @@ namespace frm REGISTER_PROP_2( RICH_TEXT, m_bReallyActAsRichText, BOUND, MAYBEDEFAULT ); REGISTER_PROP_2( HIDEINACTIVESELECTION, m_bHideInactiveSelection, BOUND, MAYBEDEFAULT ); - REGISTER_VOID_PROP_2( TABSTOP, m_aTabStop, sal_Bool, BOUND, MAYBEDEFAULT ); - REGISTER_VOID_PROP_2( BACKGROUNDCOLOR, m_aBackgroundColor, sal_Int32, BOUND, MAYBEDEFAULT ); - REGISTER_VOID_PROP_2( BORDERCOLOR, m_aBorderColor, sal_Int32, BOUND, MAYBEDEFAULT ); + REGISTER_VOID_PROP_2( TABSTOP, m_aTabStop, sal_Bool, BOUND, MAYBEDEFAULT ); + REGISTER_VOID_PROP_2( BACKGROUNDCOLOR, m_aBackgroundColor, sal_Int32, BOUND, MAYBEDEFAULT ); + REGISTER_VOID_PROP_2( BORDERCOLOR, m_aBorderColor, sal_Int32, BOUND, MAYBEDEFAULT ); + REGISTER_VOID_PROP_2( VERTICAL_ALIGN, m_aVerticalAlignment, VerticalAlignment, BOUND, MAYBEDEFAULT ); // properties which exist only for compatibility with the css.swt.UnoControlEditModel, // since we replace the default implementation for this service @@ -455,6 +460,7 @@ namespace frm case PROPERTY_ID_TABSTOP: case PROPERTY_ID_BACKGROUNDCOLOR: case PROPERTY_ID_BORDERCOLOR: + case PROPERTY_ID_VERTICAL_ALIGN: /* void */ break; diff --git a/forms/source/richtext/richtextmodel.hxx b/forms/source/richtext/richtextmodel.hxx index b6629aea2..e6c1f0a63 100644 --- a/forms/source/richtext/richtextmodel.hxx +++ b/forms/source/richtext/richtextmodel.hxx @@ -74,6 +74,7 @@ namespace frm ::com::sun::star::uno::Any m_aTabStop; ::com::sun::star::uno::Any m_aBackgroundColor; ::com::sun::star::uno::Any m_aBorderColor; + ::com::sun::star::uno::Any m_aVerticalAlignment; ::rtl::OUString m_sDefaultControl; ::rtl::OUString m_sHelpText; ::rtl::OUString m_sHelpURL; @@ -115,7 +116,7 @@ namespace frm DECLARE_DEFAULT_LEAF_XTOR( ORichTextModel ); // UNO - DECLARE_UNO3_AGG_DEFAULTS( ONavigationBarModel, OControlModel ); + DECLARE_UNO3_AGG_DEFAULTS( ORichTextModel, OControlModel ); virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw (::com::sun::star::uno::RuntimeException); // XServiceInfo diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx index 55bccbffe..66e2065a6 100644 --- a/forms/source/runtime/formoperations.cxx +++ b/forms/source/runtime/formoperations.cxx @@ -92,7 +92,7 @@ namespace frm using ::com::sun::star::uno::XInterface; using ::com::sun::star::sdbc::XRowSet; using ::com::sun::star::sdbc::XResultSetUpdate; - using ::com::sun::star::form::XFormController; + using ::com::sun::star::form::runtime::XFormController; using ::com::sun::star::form::runtime::XFeatureInvalidation; using ::com::sun::star::form::runtime::FeatureState; using ::com::sun::star::lang::IllegalArgumentException; diff --git a/forms/source/runtime/formoperations.hxx b/forms/source/runtime/formoperations.hxx index 4f1de98ae..9b3fe559d 100644 --- a/forms/source/runtime/formoperations.hxx +++ b/forms/source/runtime/formoperations.hxx @@ -71,16 +71,16 @@ namespace frm class MethodGuard; private: - ::comphelper::ComponentContext m_aContext; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > m_xController; - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xCursor; - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xUpdateCursor; - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xCursorProperties; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable > m_xLoadableForm; + ::comphelper::ComponentContext m_aContext; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xController; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xCursor; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > m_xUpdateCursor; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xCursorProperties; + ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable > m_xLoadableForm; ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFeatureInvalidation > - m_xFeatureInvalidation; + m_xFeatureInvalidation; mutable ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > - m_xParser; + m_xParser; bool m_bInitializedParser; bool m_bActiveControlModified; @@ -132,7 +132,7 @@ namespace frm // XFormOperations virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > SAL_CALL getCursor() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetUpdate > SAL_CALL getUpdateCursor() throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > SAL_CALL getController() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > SAL_CALL getController() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFeatureInvalidation > SAL_CALL getFeatureInvalidation() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setFeatureInvalidation(const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFeatureInvalidation > & the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::form::runtime::FeatureState SAL_CALL getState(::sal_Int16 Feature) throw (::com::sun::star::uno::RuntimeException); @@ -163,7 +163,7 @@ namespace frm private: // service constructors - void createWithFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController >& _rxController ); + void createWithFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController ); void createWithForm( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm ); /** determines whether or not we're already disposed diff --git a/forms/source/solar/component/navbarcontrol.cxx b/forms/source/solar/component/navbarcontrol.cxx index dac97eda2..e4d93d8c6 100644 --- a/forms/source/solar/component/navbarcontrol.cxx +++ b/forms/source/solar/component/navbarcontrol.cxx @@ -34,17 +34,23 @@ #include "navbarcontrol.hxx" #include "frm_strings.hxx" #include "frm_module.hxx" -#include "navtoolbar.hxx" #include "FormComponent.hxx" +#include "componenttools.hxx" +#include "navtoolbar.hxx" +#include "commandimageprovider.hxx" +#include "commanddescriptionprovider.hxx" /** === begin UNO includes === **/ #include <com/sun/star/awt/XView.hpp> #include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/form/runtime/FormFeature.hpp> +#include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> /** === end UNO includes === **/ #include <tools/debug.hxx> +#include <tools/diagnose_ex.h> #include <vcl/svapp.hxx> -#include <svx/svxids.hrc> //-------------------------------------------------------------------------- extern "C" void SAL_CALL createRegistryInfo_ONavigationBarControl() @@ -62,6 +68,8 @@ namespace frm using namespace ::com::sun::star::awt; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::frame; + using namespace ::com::sun::star::graphic; + namespace FormFeature = ::com::sun::star::form::runtime::FormFeature; #define FORWARD_TO_PEER_1( unoInterface, method, param1 ) \ Reference< unoInterface > xTypedPeer( getPeer(), UNO_QUERY ); \ @@ -129,7 +137,8 @@ namespace frm //------------------------------------------------------------------ namespace { - static WinBits getWinBits( const Reference< XControlModel >& _rxModel ) + //.............................................................. + static WinBits lcl_getWinBits_nothrow( const Reference< XControlModel >& _rxModel ) { WinBits nBits = 0; try @@ -149,7 +158,7 @@ namespace frm } catch( const Exception& ) { - DBG_ERROR( "::getWinBits: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } return nBits; } @@ -175,7 +184,7 @@ namespace frm } // create the peer - ONavigationBarPeer* pPeer = ONavigationBarPeer::Create( m_xORB, pParentWin, getWinBits( getModel() ) ); + ONavigationBarPeer* pPeer = ONavigationBarPeer::Create( m_xORB, pParentWin, getModel() ); DBG_ASSERT( pPeer, "ONavigationBarControl::createPeer: invalid peer returned!" ); if ( pPeer ) // by definition, the returned component is aquired once @@ -267,7 +276,7 @@ namespace frm DBG_NAME( ONavigationBarPeer ) //------------------------------------------------------------------ ONavigationBarPeer* ONavigationBarPeer::Create( const Reference< XMultiServiceFactory >& _rxORB, - Window* _pParentWindow, WinBits _nStyle ) + Window* _pParentWindow, const Reference< XControlModel >& _rxModel ) { DBG_TESTSOLARMUTEX(); @@ -276,7 +285,13 @@ namespace frm pPeer->acquire(); // by definition, the returned object is aquired once // the VCL control for the peer - NavigationToolBar* pNavBar = new NavigationToolBar( _pParentWindow, _nStyle ); + Reference< XModel > xContextDocument( getXModel( _rxModel ) ); + NavigationToolBar* pNavBar = new NavigationToolBar( + _pParentWindow, + lcl_getWinBits_nothrow( _rxModel ), + createDocumentCommandImageProvider( _rxORB, xContextDocument ), + createDocumentCommandDescriptionProvider( _rxORB, xContextDocument ) + ); // some knittings pNavBar->setDispatcher( pPeer ); @@ -456,7 +471,7 @@ namespace frm } //------------------------------------------------------------------ - void ONavigationBarPeer::featureStateChanged( sal_Int32 _nFeatureId, sal_Bool _bEnabled ) + void ONavigationBarPeer::featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled ) { // enable this button on the toolbox NavigationToolBar* pNavBar = static_cast< NavigationToolBar* >( GetWindow() ); @@ -465,15 +480,15 @@ namespace frm pNavBar->enableFeature( _nFeatureId, _bEnabled ); // is it a feature with additional state information? - if ( _nFeatureId == SID_FM_FORM_FILTERED ) + if ( _nFeatureId == FormFeature::ToggleApplyFilter ) { // additional boolean state pNavBar->checkFeature( _nFeatureId, getBooleanState( _nFeatureId ) ); } - else if ( _nFeatureId == SID_FM_RECORD_TOTAL ) + else if ( _nFeatureId == FormFeature::TotalRecords ) { pNavBar->setFeatureText( _nFeatureId, getStringState( _nFeatureId ) ); } - else if ( _nFeatureId == SID_FM_RECORD_ABSOLUTE ) + else if ( _nFeatureId == FormFeature::MoveAbsolute ) { pNavBar->setFeatureText( _nFeatureId, String::CreateFromInt32( getIntegerState( _nFeatureId ) ) ); } @@ -496,7 +511,7 @@ namespace frm } //------------------------------------------------------------------ - bool ONavigationBarPeer::isEnabled( sal_Int32 _nFeatureId ) const + bool ONavigationBarPeer::isEnabled( sal_Int16 _nFeatureId ) const { if ( const_cast< ONavigationBarPeer* >( this )->isDesignMode() ) return false; @@ -524,27 +539,27 @@ namespace frm } //------------------------------------------------------------------ - void ONavigationBarPeer::getSupportedFeatures( ::std::vector< sal_Int32 >& _rFeatureIds ) + void ONavigationBarPeer::getSupportedFeatures( ::std::vector< sal_Int16 >& _rFeatureIds ) { - _rFeatureIds.push_back( SID_FM_RECORD_ABSOLUTE ); - _rFeatureIds.push_back( SID_FM_RECORD_TOTAL ); - _rFeatureIds.push_back( SID_FM_RECORD_FIRST ); - _rFeatureIds.push_back( SID_FM_RECORD_PREV ); - _rFeatureIds.push_back( SID_FM_RECORD_NEXT ); - _rFeatureIds.push_back( SID_FM_RECORD_LAST ); - _rFeatureIds.push_back( SID_FM_RECORD_SAVE ); - _rFeatureIds.push_back( SID_FM_RECORD_UNDO ); - _rFeatureIds.push_back( SID_FM_RECORD_NEW ); - _rFeatureIds.push_back( SID_FM_RECORD_DELETE ); - _rFeatureIds.push_back( SID_FM_REFRESH ); - _rFeatureIds.push_back( SID_FM_REFRESH_FORM_CONTROL ); - _rFeatureIds.push_back( SID_FM_SORTUP ); - _rFeatureIds.push_back( SID_FM_SORTDOWN ); - _rFeatureIds.push_back( SID_FM_ORDERCRIT ); - _rFeatureIds.push_back( SID_FM_AUTOFILTER ); - _rFeatureIds.push_back( SID_FM_FILTERCRIT ); - _rFeatureIds.push_back( SID_FM_FORM_FILTERED ); - _rFeatureIds.push_back( SID_FM_REMOVE_FILTER_SORT ); + _rFeatureIds.push_back( FormFeature::MoveAbsolute ); + _rFeatureIds.push_back( FormFeature::TotalRecords ); + _rFeatureIds.push_back( FormFeature::MoveToFirst ); + _rFeatureIds.push_back( FormFeature::MoveToPrevious ); + _rFeatureIds.push_back( FormFeature::MoveToNext ); + _rFeatureIds.push_back( FormFeature::MoveToLast ); + _rFeatureIds.push_back( FormFeature::SaveRecordChanges ); + _rFeatureIds.push_back( FormFeature::UndoRecordChanges ); + _rFeatureIds.push_back( FormFeature::MoveToInsertRow ); + _rFeatureIds.push_back( FormFeature::DeleteRecord ); + _rFeatureIds.push_back( FormFeature::ReloadForm ); + _rFeatureIds.push_back( FormFeature::RefreshCurrentControl ); + _rFeatureIds.push_back( FormFeature::SortAscending ); + _rFeatureIds.push_back( FormFeature::SortDescending ); + _rFeatureIds.push_back( FormFeature::InteractiveSort ); + _rFeatureIds.push_back( FormFeature::AutoFilter ); + _rFeatureIds.push_back( FormFeature::InteractiveFilter ); + _rFeatureIds.push_back( FormFeature::ToggleApplyFilter ); + _rFeatureIds.push_back( FormFeature::RemoveFilterAndSort ); } //......................................................................... diff --git a/forms/source/solar/component/navbarcontrol.hxx b/forms/source/solar/component/navbarcontrol.hxx index 116684e6a..cda9b2571 100644 --- a/forms/source/solar/component/navbarcontrol.hxx +++ b/forms/source/solar/component/navbarcontrol.hxx @@ -31,14 +31,18 @@ #ifndef FORMS_NAVBARCONTROL_HXX #define FORMS_NAVBARCONTROL_HXX +#include "formnavigation.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/frame/XDispatchProviderInterception.hpp> +#include <com/sun/star/frame/XStatusListener.hpp> +/** === end UNO includes === **/ + #include <toolkit/controls/unocontrol.hxx> #include <toolkit/awt/vclxwindow.hxx> #include <comphelper/uno3.hxx> #include <cppuhelper/implbase1.hxx> #include <vcl/wintypes.hxx> -#include <com/sun/star/frame/XDispatchProviderInterception.hpp> -#include <com/sun/star/frame/XStatusListener.hpp> -#include "formnavigation.hxx" //......................................................................... namespace frm @@ -111,11 +115,13 @@ namespace frm static ONavigationBarPeer* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, Window* _pParentWindow, - WinBits _nStyle + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel ); protected: - ONavigationBarPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB ); + ONavigationBarPeer( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB + ); ~ONavigationBarPeer(); public: @@ -144,12 +150,12 @@ namespace frm // OFormNavigationHelper overriables virtual void interceptorsChanged( ); - virtual void featureStateChanged( sal_Int32 _nFeatureId, sal_Bool _bEnabled ); + virtual void featureStateChanged( sal_Int16 _nFeatureId, sal_Bool _bEnabled ); virtual void allFeatureStatesChanged( ); - virtual void getSupportedFeatures( ::std::vector< sal_Int32 >& /* [out] */ _rFeatureIds ); + virtual void getSupportedFeatures( ::std::vector< sal_Int16 >& /* [out] */ _rFeatureIds ); // IFeatureDispatcher overriables - virtual bool isEnabled( sal_Int32 _nFeatureId ) const; + virtual bool isEnabled( sal_Int16 _nFeatureId ) const; }; //......................................................................... diff --git a/forms/source/solar/control/navtoolbar.cxx b/forms/source/solar/control/navtoolbar.cxx index a79c8af55..a50b17665 100644 --- a/forms/source/solar/control/navtoolbar.cxx +++ b/forms/source/solar/control/navtoolbar.cxx @@ -30,39 +30,41 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_forms.hxx" + #include "navtoolbar.hxx" #include "frm_resource.hxx" -#ifndef _FRM_RESOURCE_HRC_ -#include "frm_resource.hrc" -#endif -#include <vcl/fixed.hxx> -#ifndef _SVX_SVXIDS_HRC -#include <svx/svxids.hrc> -#endif -#include <sfx2/msgpool.hxx> -#include <sfx2/imgmgr.hxx> #include "featuredispatcher.hxx" +#include "frm_resource.hrc" +#include "commandimageprovider.hxx" +#include "commanddescriptionprovider.hxx" + #include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/form/runtime/FormFeature.hpp> + +#include <sfx2/imgmgr.hxx> +#include <vcl/fixed.hxx> #include <memory> -#define LID_RECORD_LABEL 1 -#define LID_RECORD_FILLER 2 +#define LID_RECORD_LABEL 1000 +#define LID_RECORD_FILLER 1001 //......................................................................... namespace frm { //......................................................................... + using ::com::sun::star::uno::makeAny; + namespace FormFeature = ::com::sun::star::form::runtime::FormFeature; + //===================================================================== //..................................................................... namespace { - static bool isSfxSlot( sal_Int32 _nFeatureId ) + static bool isArtificialItem( sal_Int16 _nFeatureId ) { - // everything we use in this class is an SFX-slot - except the LID_* ids - return ( _nFeatureId != LID_RECORD_LABEL ) - && ( _nFeatureId != LID_RECORD_FILLER ); + return ( _nFeatureId == LID_RECORD_LABEL ) + || ( _nFeatureId == LID_RECORD_FILLER ); } static String getLabelString( USHORT _nResId ) @@ -72,6 +74,38 @@ namespace frm sLabel += String::CreateFromAscii( " " ); return sLabel; } + + ::rtl::OUString lcl_getCommandURL( const sal_Int16 _nFormFeature ) + { + const sal_Char* pAsciiCommandName = NULL; + switch ( _nFormFeature ) + { + case FormFeature::MoveAbsolute : pAsciiCommandName = "AbsoluteRecord"; break; + case FormFeature::TotalRecords : pAsciiCommandName = "RecTotal"; break; + case FormFeature::MoveToFirst : pAsciiCommandName = "FirstRecord"; break; + case FormFeature::MoveToPrevious : pAsciiCommandName = "PrevRecord"; break; + case FormFeature::MoveToNext : pAsciiCommandName = "NextRecord"; break; + case FormFeature::MoveToLast : pAsciiCommandName = "LastRecord"; break; + case FormFeature::SaveRecordChanges : pAsciiCommandName = "RecSave"; break; + case FormFeature::UndoRecordChanges : pAsciiCommandName = "RecUndo"; break; + case FormFeature::MoveToInsertRow : pAsciiCommandName = "NewRecord"; break; + case FormFeature::DeleteRecord : pAsciiCommandName = "DeleteRecord"; break; + case FormFeature::ReloadForm : pAsciiCommandName = "Refresh"; break; + case FormFeature::RefreshCurrentControl : pAsciiCommandName = "RefreshFormControl"; break; + case FormFeature::SortAscending : pAsciiCommandName = "Sortup"; break; + case FormFeature::SortDescending : pAsciiCommandName = "SortDown"; break; + case FormFeature::InteractiveSort : pAsciiCommandName = "OrderCrit"; break; + case FormFeature::AutoFilter : pAsciiCommandName = "AutoFilter"; break; + case FormFeature::InteractiveFilter : pAsciiCommandName = "FilterCrit"; break; + case FormFeature::ToggleApplyFilter : pAsciiCommandName = "FormFiltered"; break; + case FormFeature::RemoveFilterAndSort : pAsciiCommandName = "RemoveFilterSort"; break; + } + if ( pAsciiCommandName != NULL ) + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:" ) ) + ::rtl::OUString::createFromAscii( pAsciiCommandName ); + + OSL_ENSURE( false, "lcl_getCommandURL: unknown FormFeature!" ); + return ::rtl::OUString(); + } } //===================================================================== @@ -119,9 +153,12 @@ namespace frm //===================================================================== DBG_NAME( NavigationToolBar ) //--------------------------------------------------------------------- - NavigationToolBar::NavigationToolBar( Window* _pParent, WinBits _nStyle ) + NavigationToolBar::NavigationToolBar( Window* _pParent, WinBits _nStyle, const PCommandImageProvider& _pImageProvider, + const PCommandDescriptionProvider& _pDescriptionProvider ) :Window( _pParent, _nStyle ) ,m_pDispatcher( NULL ) + ,m_pImageProvider( _pImageProvider ) + ,m_pDescriptionProvider( _pDescriptionProvider ) ,m_eImageSize( eSmall ) ,m_pToolbar( NULL ) { @@ -150,7 +187,7 @@ namespace frm m_pToolbar->setDispatcher( _pDispatcher ); - RecordPositionInput* pPositionWindow = static_cast< RecordPositionInput* >( m_pToolbar->GetItemWindow( SID_FM_RECORD_ABSOLUTE ) ); + RecordPositionInput* pPositionWindow = static_cast< RecordPositionInput* >( m_pToolbar->GetItemWindow( FormFeature::MoveAbsolute ) ); OSL_ENSURE( pPositionWindow, "NavigationToolBar::setDispatcher: can't forward the dispatcher to the position window!" ); if ( pPositionWindow ) pPositionWindow->setDispatcher( _pDispatcher ); @@ -179,15 +216,15 @@ namespace frm { m_pToolbar->EnableItem( _nItemId, _bEnabled ); - if ( _nItemId == SID_FM_RECORD_ABSOLUTE ) + if ( _nItemId == FormFeature::MoveAbsolute ) m_pToolbar->EnableItem( LID_RECORD_LABEL, _bEnabled ); - if ( _nItemId == SID_FM_RECORD_TOTAL ) + if ( _nItemId == FormFeature::TotalRecords ) m_pToolbar->EnableItem( LID_RECORD_FILLER, _bEnabled ); } //--------------------------------------------------------------------- - void NavigationToolBar::enableFeature( sal_Int32 _nFeatureId, bool _bEnabled ) + void NavigationToolBar::enableFeature( sal_Int16 _nFeatureId, bool _bEnabled ) { DBG_ASSERT( m_pToolbar->GetItemPos( (USHORT)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND, "NavigationToolBar::enableFeature: invalid id!" ); @@ -196,7 +233,7 @@ namespace frm } //--------------------------------------------------------------------- - void NavigationToolBar::checkFeature( sal_Int32 _nFeatureId, bool _bEnabled ) + void NavigationToolBar::checkFeature( sal_Int16 _nFeatureId, bool _bEnabled ) { DBG_ASSERT( m_pToolbar->GetItemPos( (USHORT)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND, "NavigationToolBar::checkFeature: invalid id!" ); @@ -205,7 +242,7 @@ namespace frm } //--------------------------------------------------------------------- - void NavigationToolBar::setFeatureText( sal_Int32 _nFeatureId, const ::rtl::OUString& _rText ) + void NavigationToolBar::setFeatureText( sal_Int16 _nFeatureId, const ::rtl::OUString& _rText ) { DBG_ASSERT( m_pToolbar->GetItemPos( (USHORT)_nFeatureId ) != TOOLBOX_ITEM_NOTFOUND, "NavigationToolBar::checkFeature: invalid id!" ); @@ -228,71 +265,67 @@ namespace frm // items. We could duplicate all the information here in our lib // (such as the item text and the image), but why should we? - struct SlotDescription + struct FeatureDescription { USHORT nId; bool bRepeat; bool bItemWindow; - } aSupportedSlots[] = + } aSupportedFeatures[] = { - { LID_RECORD_LABEL, false, true }, - { SID_FM_RECORD_ABSOLUTE, false, true }, - { LID_RECORD_FILLER, false, true }, - { SID_FM_RECORD_TOTAL, false, true }, - - { SID_FM_RECORD_FIRST, true, false }, - { SID_FM_RECORD_PREV, true, false }, - { SID_FM_RECORD_NEXT, true, false }, - { SID_FM_RECORD_LAST, true, false }, + { LID_RECORD_LABEL, false, true }, + { FormFeature::MoveAbsolute, false, true }, + { LID_RECORD_FILLER, false, true }, + { FormFeature::TotalRecords, false, true }, + { FormFeature::MoveToFirst, true, false }, + { FormFeature::MoveToPrevious, true, false }, + { FormFeature::MoveToNext, true, false }, + { FormFeature::MoveToLast, true, false }, + { FormFeature::MoveToInsertRow, false, false }, { 0, false, false }, - { SID_FM_RECORD_SAVE, false, false }, - { SID_FM_RECORD_UNDO, false, false }, - { SID_FM_RECORD_NEW, false, false }, - { SID_FM_RECORD_DELETE, false, false }, - { SID_FM_REFRESH, false, false }, - { SID_FM_REFRESH_FORM_CONTROL, false, false }, + { FormFeature::SaveRecordChanges, false, false }, + { FormFeature::UndoRecordChanges, false, false }, + { FormFeature::DeleteRecord, false, false }, + { FormFeature::ReloadForm, false, false }, + { FormFeature::RefreshCurrentControl, false, false }, { 0, false, false }, - { SID_FM_SORTUP, false, false }, - { SID_FM_SORTDOWN, false, false }, - { SID_FM_ORDERCRIT, false, false }, - { SID_FM_AUTOFILTER, false, false }, - { SID_FM_FILTERCRIT, false, false }, - { SID_FM_FORM_FILTERED, false, false }, - { SID_FM_REMOVE_FILTER_SORT, false, false }, + { FormFeature::SortAscending, false, false }, + { FormFeature::SortDescending, false, false }, + { FormFeature::InteractiveSort, false, false }, + { FormFeature::AutoFilter, false, false }, + { FormFeature::InteractiveFilter, false, false }, + { FormFeature::ToggleApplyFilter, false, false }, + { FormFeature::RemoveFilterAndSort, false, false }, }; - size_t nSupportedSlots = sizeof( aSupportedSlots ) / sizeof( aSupportedSlots[0] ); - SlotDescription* pSupportedSlots = aSupportedSlots; - SlotDescription* pSupportedSlotsEnd = aSupportedSlots + nSupportedSlots; - for ( ; pSupportedSlots < pSupportedSlotsEnd; ++pSupportedSlots ) + size_t nSupportedFeatures = sizeof( aSupportedFeatures ) / sizeof( aSupportedFeatures[0] ); + FeatureDescription* pSupportedFeatures = aSupportedFeatures; + FeatureDescription* pSupportedFeaturesEnd = aSupportedFeatures + nSupportedFeatures; + for ( ; pSupportedFeatures < pSupportedFeaturesEnd; ++pSupportedFeatures ) { - if ( pSupportedSlots->nId ) + if ( pSupportedFeatures->nId ) { // it's _not_ a separator - // the text(s) of the item - String sItemText; - String sItemHelpText; - - // TODO/CLEANUP: this code does nothing(!) nowadays - //SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( NULL ); - //sItemText = rSlotPool.GetSlotName( pSupportedSlots->nId, &sItemHelpText ); - // insert the entry - m_pToolbar->InsertItem( pSupportedSlots->nId, sItemText, pSupportedSlots->bRepeat ? TIB_REPEAT : 0 ); - m_pToolbar->SetQuickHelpText( pSupportedSlots->nId, sItemHelpText ); - if ( isSfxSlot( pSupportedSlots->nId ) ) - m_pToolbar->SetHelpId( pSupportedSlots->nId, pSupportedSlots->nId ); + m_pToolbar->InsertItem( pSupportedFeatures->nId, String(), pSupportedFeatures->bRepeat ? TIB_REPEAT : 0 ); + m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, String() ); // TODO + if ( !isArtificialItem( pSupportedFeatures->nId ) ) + { + ::rtl::OUString sCommandURL( lcl_getCommandURL( pSupportedFeatures->nId ) ); + m_pToolbar->SetItemCommand( pSupportedFeatures->nId, sCommandURL ); + if ( m_pDescriptionProvider ) + m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, m_pDescriptionProvider->getCommandDescription( sCommandURL ) ); + } - if ( pSupportedSlots->bItemWindow ) + if ( pSupportedFeatures->bItemWindow ) { Window* pItemWindow = NULL; - if ( SID_FM_RECORD_ABSOLUTE == pSupportedSlots->nId ) + if ( FormFeature::MoveAbsolute == pSupportedFeatures->nId ) { pItemWindow = new RecordPositionInput( m_pToolbar ); static_cast< RecordPositionInput* >( pItemWindow )->setDispatcher( m_pDispatcher ); } - else if ( LID_RECORD_FILLER == pSupportedSlots->nId ) + else if ( LID_RECORD_FILLER == pSupportedFeatures->nId ) { pItemWindow = new FixedText( m_pToolbar, WB_CENTER | WB_VCENTER ); pItemWindow->SetBackground(Wallpaper(Color(COL_TRANSPARENT))); @@ -305,7 +338,7 @@ namespace frm } m_aChildWins.push_back( pItemWindow ); - switch ( pSupportedSlots->nId ) + switch ( pSupportedFeatures->nId ) { case LID_RECORD_LABEL: pItemWindow->SetText( getLabelString( RID_STR_LABEL_RECORD ) ); @@ -316,7 +349,7 @@ namespace frm break; } - m_pToolbar->SetItemWindow( pSupportedSlots->nId, pItemWindow ); + m_pToolbar->SetItemWindow( pSupportedFeatures->nId, pItemWindow ); } } else @@ -327,25 +360,66 @@ namespace frm forEachItemWindow( &NavigationToolBar::adjustItemWindowWidth, NULL ); - // the image of the item - ::std::auto_ptr< SfxImageManager > pImageManager( new SfxImageManager( NULL ) ); - pImageManager->SetImagesForceSize( *m_pToolbar, FALSE, m_eImageSize == eLarge ); + implUpdateImages(); + } + + //--------------------------------------------------------------------- + void NavigationToolBar::implUpdateImages() + { + OSL_ENSURE( m_pImageProvider, "NavigationToolBar::implUpdateImages: no image provider => no images!" ); + if ( !m_pImageProvider ) + return; + + const bool bIsHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); + + const USHORT nItemCount = m_pToolbar->GetItemCount(); + + // collect the FormFeatures in the toolbar + typedef ::std::vector< sal_Int16 > FormFeatures; + FormFeatures aFormFeatures; + aFormFeatures.reserve( nItemCount ); + + for ( USHORT i=0; i<nItemCount; ++i ) + { + USHORT nId = m_pToolbar->GetItemId( i ); + if ( ( TOOLBOXITEM_BUTTON == m_pToolbar->GetItemType( i ) ) && !isArtificialItem( nId ) ) + aFormFeatures.push_back( nId ); + } + + // translate them into command URLs + CommandURLs aCommandURLs( aFormFeatures.size() ); + for ( FormFeatures::const_iterator formFeature = aFormFeatures.begin(); + formFeature != aFormFeatures.end(); + ++formFeature + ) + { + aCommandURLs[ formFeature - aFormFeatures.begin() ] = lcl_getCommandURL( *formFeature ); + } + + // retrieve the images for the command URLs + CommandImages aCommandImages = m_pImageProvider->getCommandImages( aCommandURLs, m_eImageSize == eLarge, bIsHighContrast ); + + // and set them at the toolbar + CommandImages::const_iterator commandImage = aCommandImages.begin(); + for ( FormFeatures::const_iterator formFeature = aFormFeatures.begin(); + formFeature != aFormFeatures.end(); + ++formFeature, ++commandImage + ) + { + m_pToolbar->SetItemImage( *formFeature, *commandImage ); + } // parts of our layout is dependent on the size of our icons Resize(); } //--------------------------------------------------------------------- - void NavigationToolBar::implSetImageSize( ImageSize _eSize, bool _bForce ) + void NavigationToolBar::implSetImageSize( ImageSize _eSize ) { - if ( ( _eSize != m_eImageSize ) || _bForce ) + if ( _eSize != m_eImageSize ) { m_eImageSize = _eSize; - ::std::auto_ptr< SfxImageManager > pImageManager( new SfxImageManager( NULL ) ); - pImageManager->SetImagesForceSize( *m_pToolbar, GetSettings().GetStyleSettings().GetHighContrastMode(), m_eImageSize == eLarge ); - - // parts of our layout is dependent on the size of our icons - Resize(); + implUpdateImages(); } } @@ -365,7 +439,7 @@ namespace frm case ePosition: { static const USHORT aPositionIds[] = { - LID_RECORD_LABEL, SID_FM_RECORD_ABSOLUTE, LID_RECORD_FILLER, SID_FM_RECORD_TOTAL, 0 + LID_RECORD_LABEL, FormFeature::MoveAbsolute, LID_RECORD_FILLER, FormFeature::TotalRecords, 0 }; pGroupIds = aPositionIds; } @@ -373,7 +447,7 @@ namespace frm case eNavigation: { static const USHORT aNavigationIds[] = { - SID_FM_RECORD_FIRST, SID_FM_RECORD_PREV, SID_FM_RECORD_NEXT, SID_FM_RECORD_LAST, 0 + FormFeature::MoveToFirst, FormFeature::MoveToPrevious, FormFeature::MoveToNext, FormFeature::MoveToLast, FormFeature::MoveToInsertRow, 0 }; pGroupIds = aNavigationIds; } @@ -381,7 +455,7 @@ namespace frm case eRecordActions: { static const USHORT aActionIds[] = { - SID_FM_RECORD_SAVE, SID_FM_RECORD_UNDO, SID_FM_RECORD_NEW, SID_FM_RECORD_DELETE, SID_FM_REFRESH, SID_FM_REFRESH_FORM_CONTROL, 0 + FormFeature::SaveRecordChanges, FormFeature::UndoRecordChanges, FormFeature::DeleteRecord, FormFeature::ReloadForm, FormFeature::RefreshCurrentControl, 0 }; pGroupIds = aActionIds; } @@ -389,7 +463,7 @@ namespace frm case eFilterSort: { static const USHORT aFilterSortIds[] = { - SID_FM_SORTUP, SID_FM_SORTDOWN, SID_FM_ORDERCRIT, SID_FM_AUTOFILTER, SID_FM_FILTERCRIT, SID_FM_FORM_FILTERED, SID_FM_REMOVE_FILTER_SORT, 0 + FormFeature::SortAscending, FormFeature::SortDescending, FormFeature::InteractiveSort, FormFeature::AutoFilter, FormFeature::InteractiveFilter, FormFeature::ToggleApplyFilter, FormFeature::RemoveFilterAndSort, 0 }; pGroupIds = aFilterSortIds; } @@ -410,9 +484,9 @@ namespace frm switch ( _eGroup ) { case ePosition : nIndicatorItem = LID_RECORD_LABEL; break; - case eNavigation : nIndicatorItem = SID_FM_RECORD_FIRST; break; - case eRecordActions : nIndicatorItem = SID_FM_RECORD_SAVE; break; - case eFilterSort : nIndicatorItem = SID_FM_SORTUP; break; + case eNavigation : nIndicatorItem = FormFeature::MoveToFirst; break; + case eRecordActions : nIndicatorItem = FormFeature::SaveRecordChanges; break; + case eFilterSort : nIndicatorItem = FormFeature::SortAscending; break; default: OSL_ENSURE( sal_False, "NavigationToolBar::IsFunctionGroupVisible: invalid group id!" ); } @@ -477,7 +551,7 @@ namespace frm // the contrast of the background color may have changed, so force // the images to be rebuild (high contrast requires a possibly different // image set) - implSetImageSize( m_eImageSize, true ); + implUpdateImages(); } //--------------------------------------------------------------------- @@ -490,7 +564,7 @@ namespace frm // the contrast of the background color may have changed, so force // the images to be rebuild (high contrast requires a possibly different // image set) - implSetImageSize( m_eImageSize, true ); + implUpdateImages(); } //--------------------------------------------------------------------- @@ -579,11 +653,11 @@ namespace frm sItemText = getLabelString( RID_STR_LABEL_OF ); break; - case SID_FM_RECORD_ABSOLUTE: + case FormFeature::MoveAbsolute: sItemText = String::CreateFromAscii( "12345678" ); break; - case SID_FM_RECORD_TOTAL: + case FormFeature::TotalRecords: sItemText = String::CreateFromAscii( "123456" ); break; } @@ -638,7 +712,7 @@ namespace frm return; if ( m_pDispatcher ) - m_pDispatcher->dispatchWithArgument( SID_FM_RECORD_ABSOLUTE, "Position", ::com::sun::star::uno::makeAny( (sal_Int32)nRecord ) ); + m_pDispatcher->dispatchWithArgument( FormFeature::MoveAbsolute, "Position", makeAny( (sal_Int32)nRecord ) ); SaveValue(); } diff --git a/forms/source/solar/inc/navtoolbar.hxx b/forms/source/solar/inc/navtoolbar.hxx index 3f55773fd..6e1caea56 100644 --- a/forms/source/solar/inc/navtoolbar.hxx +++ b/forms/source/solar/inc/navtoolbar.hxx @@ -34,14 +34,19 @@ #include <vcl/toolbox.hxx> #include <vcl/field.hxx> +#include <boost/shared_ptr.hpp> + //......................................................................... namespace frm { //......................................................................... class IFeatureDispatcher; + class ICommandImageProvider; + class ICommandDescriptionProvider; class ImplNavToolBar; + //===================================================================== //= NavigationToolBar //===================================================================== @@ -63,13 +68,22 @@ namespace frm }; private: - const IFeatureDispatcher* m_pDispatcher; - ImageSize m_eImageSize; - ImplNavToolBar* m_pToolbar; - ::std::vector< Window* > m_aChildWins; + const IFeatureDispatcher* m_pDispatcher; + const ::boost::shared_ptr< const ICommandImageProvider > + m_pImageProvider; + const ::boost::shared_ptr< const ICommandDescriptionProvider > + m_pDescriptionProvider; + ImageSize m_eImageSize; + ImplNavToolBar* m_pToolbar; + ::std::vector< Window* > m_aChildWins; public: - NavigationToolBar( Window* _pParent, WinBits _nStyle ); + NavigationToolBar( + Window* _pParent, + WinBits _nStyle, + const ::boost::shared_ptr< const ICommandImageProvider >& _pImageProvider, + const ::boost::shared_ptr< const ICommandDescriptionProvider >& _pDescriptionProvider + ); ~NavigationToolBar( ); /** sets the dispatcher which is to be used for the features @@ -82,19 +96,16 @@ namespace frm ensuring the life time of the object does exceed the life time of the tool bar instance. */ - void setDispatcher( const IFeatureDispatcher* _pDispatcher ); + void setDispatcher( const IFeatureDispatcher* _pDispatcher ); - /** enables or disables a given feature - */ - void enableFeature( sal_Int32 _nFeatureId, bool _bEnabled ); + /// enables or disables a given feature + void enableFeature( sal_Int16 _nFeatureId, bool _bEnabled ); - /** checks or unchecks a given feature - */ - void checkFeature( sal_Int32 _nFeatureId, bool _bEnabled ); + /// checks or unchecks a given feature + void checkFeature( sal_Int16 _nFeatureId, bool _bEnabled ); - /** sets the text of a given feature - */ - void setFeatureText( sal_Int32 _nFeatureId, const ::rtl::OUString& _rText ); + /// sets the text of a given feature + void setFeatureText( sal_Int16 _nFeatureId, const ::rtl::OUString& _rText ); /** retrieves the current image size */ @@ -127,7 +138,10 @@ namespace frm void implInit( ); /// impl version of SetImageSize - void implSetImageSize( ImageSize _eSize, bool _bForce = false ); + void implSetImageSize( ImageSize _eSize ); + + /// updates the images of our items + void implUpdateImages(); /// enables or disables an item, plus possible dependent items void implEnableItem( USHORT _nItemId, bool _bEnabled ); diff --git a/setup_native/source/packinfo/packinfo_office.txt b/setup_native/source/packinfo/packinfo_office.txt index b3e68ac17..d4ba6e1be 100755 --- a/setup_native/source/packinfo/packinfo_office.txt +++ b/setup_native/source/packinfo/packinfo_office.txt @@ -508,6 +508,22 @@ packageversion = "%PACKAGEVERSION" End Start +module = "gid_Module_Root_Extension_Dictionary_Ca" +script = "shellscripts_extensions.txt" +solarispackagename = "%PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-ca" +solarisrequires = "%SOLSUREPACKAGEPREFIX-ure, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core01, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core02, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core03, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core04, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core05, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core06, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core07, %PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION" +packagename = "%UNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-ca" +requires = "%UREPACKAGEPREFIX-ure,%BASISPACKAGEPREFIX%OOOBASEVERSION-core01,%BASISPACKAGEPREFIX%OOOBASEVERSION-core02,%BASISPACKAGEPREFIX%OOOBASEVERSION-core03,%BASISPACKAGEPREFIX%OOOBASEVERSION-core04,%BASISPACKAGEPREFIX%OOOBASEVERSION-core05,%BASISPACKAGEPREFIX%OOOBASEVERSION-core06,%BASISPACKAGEPREFIX%OOOBASEVERSION-core07,%UNIXPRODUCTNAME%BRANDPACKAGEVERSION" +linuxpatchrequires = "" +copyright = "1999-2009 by Sun Microsystems" +solariscopyright = "solariscopyrightfile" +vendor = "Sun Microsystems, Inc." +description = "Ca dictionary for %PRODUCTNAME %PRODUCTVERSION" +destpath = "/opt" +packageversion = "%PACKAGEVERSION" +End + +Start module = "gid_Module_Root_Extension_Dictionary_Cs" script = "shellscripts_extensions.txt" solarispackagename = "%PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-cs" @@ -540,17 +556,49 @@ packageversion = "%PACKAGEVERSION" End Start -module = "gid_Module_Root_Extension_Dictionary_De" +module = "gid_Module_Root_Extension_Dictionary_De_AT" +script = "shellscripts_extensions.txt" +solarispackagename = "%PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-de-AT" +solarisrequires = "%SOLSUREPACKAGEPREFIX-ure, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core01, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core02, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core03, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core04, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core05, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core06, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core07, %PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION" +packagename = "%UNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-de-AT" +requires = "%UREPACKAGEPREFIX-ure,%BASISPACKAGEPREFIX%OOOBASEVERSION-core01,%BASISPACKAGEPREFIX%OOOBASEVERSION-core02,%BASISPACKAGEPREFIX%OOOBASEVERSION-core03,%BASISPACKAGEPREFIX%OOOBASEVERSION-core04,%BASISPACKAGEPREFIX%OOOBASEVERSION-core05,%BASISPACKAGEPREFIX%OOOBASEVERSION-core06,%BASISPACKAGEPREFIX%OOOBASEVERSION-core07,%UNIXPRODUCTNAME%BRANDPACKAGEVERSION" +linuxpatchrequires = "" +copyright = "1999-2009 by Sun Microsystems" +solariscopyright = "solariscopyrightfile" +vendor = "Sun Microsystems, Inc." +description = "De-AT dictionary for %PRODUCTNAME %PRODUCTVERSION" +destpath = "/opt" +packageversion = "%PACKAGEVERSION" +End + +Start +module = "gid_Module_Root_Extension_Dictionary_De_CH" +script = "shellscripts_extensions.txt" +solarispackagename = "%PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-de-CH" +solarisrequires = "%SOLSUREPACKAGEPREFIX-ure, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core01, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core02, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core03, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core04, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core05, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core06, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core07, %PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION" +packagename = "%UNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-de-CH" +requires = "%UREPACKAGEPREFIX-ure,%BASISPACKAGEPREFIX%OOOBASEVERSION-core01,%BASISPACKAGEPREFIX%OOOBASEVERSION-core02,%BASISPACKAGEPREFIX%OOOBASEVERSION-core03,%BASISPACKAGEPREFIX%OOOBASEVERSION-core04,%BASISPACKAGEPREFIX%OOOBASEVERSION-core05,%BASISPACKAGEPREFIX%OOOBASEVERSION-core06,%BASISPACKAGEPREFIX%OOOBASEVERSION-core07,%UNIXPRODUCTNAME%BRANDPACKAGEVERSION" +linuxpatchrequires = "" +copyright = "1999-2009 by Sun Microsystems" +solariscopyright = "solariscopyrightfile" +vendor = "Sun Microsystems, Inc." +description = "De-CH dictionary for %PRODUCTNAME %PRODUCTVERSION" +destpath = "/opt" +packageversion = "%PACKAGEVERSION" +End + +Start +module = "gid_Module_Root_Extension_Dictionary_De_DE" script = "shellscripts_extensions.txt" -solarispackagename = "%PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-de" +solarispackagename = "%PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-de-DE" solarisrequires = "%SOLSUREPACKAGEPREFIX-ure, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core01, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core02, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core03, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core04, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core05, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core06, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core07, %PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION" -packagename = "%UNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-de" +packagename = "%UNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-de-DE" requires = "%UREPACKAGEPREFIX-ure,%BASISPACKAGEPREFIX%OOOBASEVERSION-core01,%BASISPACKAGEPREFIX%OOOBASEVERSION-core02,%BASISPACKAGEPREFIX%OOOBASEVERSION-core03,%BASISPACKAGEPREFIX%OOOBASEVERSION-core04,%BASISPACKAGEPREFIX%OOOBASEVERSION-core05,%BASISPACKAGEPREFIX%OOOBASEVERSION-core06,%BASISPACKAGEPREFIX%OOOBASEVERSION-core07,%UNIXPRODUCTNAME%BRANDPACKAGEVERSION" linuxpatchrequires = "" copyright = "1999-2009 by Sun Microsystems" solariscopyright = "solariscopyrightfile" vendor = "Sun Microsystems, Inc." -description = "De dictionary for %PRODUCTNAME %PRODUCTVERSION" +description = "De-DE dictionary for %PRODUCTNAME %PRODUCTVERSION" destpath = "/opt" packageversion = "%PACKAGEVERSION" End @@ -732,6 +780,22 @@ packageversion = "%PACKAGEVERSION" End Start +module = "gid_Module_Root_Extension_Dictionary_No" +script = "shellscripts_extensions.txt" +solarispackagename = "%PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-no" +solarisrequires = "%SOLSUREPACKAGEPREFIX-ure, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core01, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core02, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core03, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core04, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core05, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core06, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core07, %PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION" +packagename = "%UNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-no" +requires = "%UREPACKAGEPREFIX-ure,%BASISPACKAGEPREFIX%OOOBASEVERSION-core01,%BASISPACKAGEPREFIX%OOOBASEVERSION-core02,%BASISPACKAGEPREFIX%OOOBASEVERSION-core03,%BASISPACKAGEPREFIX%OOOBASEVERSION-core04,%BASISPACKAGEPREFIX%OOOBASEVERSION-core05,%BASISPACKAGEPREFIX%OOOBASEVERSION-core06,%BASISPACKAGEPREFIX%OOOBASEVERSION-core07,%UNIXPRODUCTNAME%BRANDPACKAGEVERSION" +linuxpatchrequires = "" +copyright = "1999-2009 by Sun Microsystems" +solariscopyright = "solariscopyrightfile" +vendor = "Sun Microsystems, Inc." +description = "No dictionary for %PRODUCTNAME %PRODUCTVERSION" +destpath = "/opt" +packageversion = "%PACKAGEVERSION" +End + +Start module = "gid_Module_Root_Extension_Dictionary_Pl" script = "shellscripts_extensions.txt" solarispackagename = "%PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-pl" @@ -764,6 +828,22 @@ packageversion = "%PACKAGEVERSION" End Start +module = "gid_Module_Root_Extension_Dictionary_Ro" +script = "shellscripts_extensions.txt" +solarispackagename = "%PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-ro" +solarisrequires = "%SOLSUREPACKAGEPREFIX-ure, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core01, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core02, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core03, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core04, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core05, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core06, %BASISPACKAGEPREFIX%WITHOUTDOTOOOBASEVERSION-core07, %PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION" +packagename = "%UNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-ro" +requires = "%UREPACKAGEPREFIX-ure,%BASISPACKAGEPREFIX%OOOBASEVERSION-core01,%BASISPACKAGEPREFIX%OOOBASEVERSION-core02,%BASISPACKAGEPREFIX%OOOBASEVERSION-core03,%BASISPACKAGEPREFIX%OOOBASEVERSION-core04,%BASISPACKAGEPREFIX%OOOBASEVERSION-core05,%BASISPACKAGEPREFIX%OOOBASEVERSION-core06,%BASISPACKAGEPREFIX%OOOBASEVERSION-core07,%UNIXPRODUCTNAME%BRANDPACKAGEVERSION" +linuxpatchrequires = "" +copyright = "1999-2009 by Sun Microsystems" +solariscopyright = "solariscopyrightfile" +vendor = "Sun Microsystems, Inc." +description = "Ro dictionary for %PRODUCTNAME %PRODUCTVERSION" +destpath = "/opt" +packageversion = "%PACKAGEVERSION" +End + +Start module = "gid_Module_Root_Extension_Dictionary_Ru" script = "shellscripts_extensions.txt" solarispackagename = "%PACKAGEPREFIX%WITHOUTDOTUNIXPRODUCTNAME%BRANDPACKAGEVERSION-dict-ru" diff --git a/setup_native/source/packinfo/spellchecker_selection.txt b/setup_native/source/packinfo/spellchecker_selection.txt index 2abcc10db..03d741b0a 100644 --- a/setup_native/source/packinfo/spellchecker_selection.txt +++ b/setup_native/source/packinfo/spellchecker_selection.txt @@ -4,34 +4,38 @@ # Second column: Assigned spellchecker languages. Comma separated list. af = "af,en-US" -ca = "ca,es,en,fr" +ar = "en-US" +ca = "ca,es,en-US,fr" cs = "cs,en-US" -da = "da,de,en-US" -de = "de,en-US,fr,it" +da = "da,de-DE,en-US" +de = "de-AT,de-CH,de-DE,en-US,fr,it" en-US = "en-US,es,fr" +en-GB = "en-US,es,fr" es = "en-US,es,fr,pt" et = "en-US,et" fr = "en-US,es,fr" gl = "en-US,pt,es,gl" he = "en-US,he" -hu = "de,en-US,hu" -it = "de,en-US,fr,it" +hu = "de-DE,en-US,hu" +it = "de-DE,en-US,fr,it" ja = "en-US" ko = "en-US" lt = "en-US,lt" -nb = "no,en,fr,de,es" +nb = "no,en-US,fr,de-DE,es" ne = "en-US,ne" -nl = "en-US,fr,de,nl" -nn = "no,en,fr,de,es" -pl = "de,en-US,pl,ru" +nl = "en-US,fr,de-DE,nl" +nn = "no,en-US,fr,de-DE,es" +pl = "de-DE,en-US,pl,ru" pt-BR = "en-US,es,pt" -ro = "ro,en,de,hu" -ru = "de,en-US,ru" +pt = "en-US,es,pt" +ro = "ro,en-US,de-DE,hu" +ru = "de-DE,en-US,ru" sk = "en-US,sk" sl = "en-US,sl" -sv = "de,en-US,sv" +sv = "de-DE,en-US,sv" sr = "sr,en-US" -sh = "sh,en-US" +# ! Note the package 'sr' also holds the dictionaries for 'sh' ! +sh = "sr,en-US" sw = "en-US,sw" th = "en-US,th" vi = "en-US,fr,vi" diff --git a/wizards/com/sun/star/wizards/db/CommandMetaData.java b/wizards/com/sun/star/wizards/db/CommandMetaData.java index b9d155290..4b8e1e6f2 100644 --- a/wizards/com/sun/star/wizards/db/CommandMetaData.java +++ b/wizards/com/sun/star/wizards/db/CommandMetaData.java @@ -644,8 +644,8 @@ public class CommandMetaData extends DBMetaData rDispatchArguments[1] = Properties.createProperty("ActiveConnection", this.DBConnection); rDispatchArguments[2] = Properties.createProperty("Command", _commandname); rDispatchArguments[3] = Properties.createProperty("CommandType", new Integer(_commandtype)); - rDispatchArguments[4] = Properties.createProperty("ShowTreeView", Boolean.FALSE); - rDispatchArguments[5] = Properties.createProperty("ShowTreeViewButton", Boolean.FALSE); + rDispatchArguments[4] = Properties.createProperty("ShowBrowser", Boolean.FALSE); + rDispatchArguments[5] = Properties.createProperty("EnableBrowser", Boolean.FALSE); rDispatchArguments[6] = Properties.createProperty("ShowMenu", Boolean.TRUE); return showCommandView(".component:DB/DataSourceBrowser", rDispatchArguments,parentFrame); } diff --git a/wizards/com/sun/star/wizards/db/DBMetaData.java b/wizards/com/sun/star/wizards/db/DBMetaData.java index 6914f2561..ae2590333 100644 --- a/wizards/com/sun/star/wizards/db/DBMetaData.java +++ b/wizards/com/sun/star/wizards/db/DBMetaData.java @@ -32,9 +32,7 @@ package com.sun.star.wizards.db; import com.sun.star.awt.XWindow; import com.sun.star.lang.XInitialization; import com.sun.star.ui.dialogs.XExecutableDialog; -import java.util.*; -// import com.sun.star.io.IOException; import com.sun.star.lang.IllegalArgumentException; import com.sun.star.lang.WrappedTargetException; import com.sun.star.lang.XMultiServiceFactory; @@ -48,7 +46,6 @@ import com.sun.star.container.XHierarchicalNameAccess; import com.sun.star.container.XHierarchicalNameContainer; import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameContainer; -// import com.sun.star.container.XNamed; import com.sun.star.frame.XComponentLoader; import com.sun.star.frame.XModel; import com.sun.star.frame.XStorable; @@ -57,7 +54,6 @@ import com.sun.star.sdbc.DataType; import com.sun.star.sdb.XOfficeDatabaseDocument; import com.sun.star.sdb.XDocumentDataSource; import com.sun.star.sdb.tools.XConnectionTools; -// import com.sun.star.sdbcx.XAppend; import com.sun.star.sdbcx.XColumnsSupplier; import com.sun.star.ucb.XSimpleFileAccess; @@ -67,14 +63,11 @@ import com.sun.star.uno.AnyConverter; import com.sun.star.util.XCloseable; import com.sun.star.util.XNumberFormatsSupplier; -import com.sun.star.wizards.common.Properties; import com.sun.star.wizards.common.*; -// import com.sun.star.wizards.ui.UnoDialog; import com.sun.star.task.XInteractionHandler; import com.sun.star.sdb.XFormDocumentsSupplier; import com.sun.star.sdb.XQueryDefinitionsSupplier; import com.sun.star.sdb.XReportDocumentsSupplier; -// import com.sun.star.sdbc.ColumnValue; import com.sun.star.sdbc.SQLException; import com.sun.star.sdbc.XDatabaseMetaData; import com.sun.star.sdbc.XDataSource; @@ -82,17 +75,22 @@ import com.sun.star.sdbc.XResultSet; import com.sun.star.sdbc.XRow; import com.sun.star.sdb.XCompletedConnection; import com.sun.star.lang.Locale; -// import com.sun.star.util.XFlushable; import com.sun.star.lang.XSingleServiceFactory; import com.sun.star.sdb.XQueriesSupplier; +import com.sun.star.sdbc.XConnection; import com.sun.star.sdbcx.XTablesSupplier; +import com.sun.star.uno.Any; +import java.util.Vector; +import java.util.logging.Level; +import java.util.logging.Logger; public class DBMetaData { private XNameAccess xQueryNames; public XDatabaseMetaData xDBMetaData; - private XDataSource xDataSource; + private XDataSource m_dataSource; + private XPropertySet m_dataSourceSettings; private XOfficeDatabaseDocument xModel; private XPropertySet xDataSourcePropertySet; public String[] DataSourceNames; @@ -150,13 +148,10 @@ public class DBMetaData private int iMaxColumnNameLength = -1; private int iMaxTableNameLength = -1; private boolean bPasswordIsRequired; - // private boolean bFormatKeysareset = false; private final static int NOLIMIT = 9999999; protected final static int RID_DB_COMMON = 1000; private final static int INVALID = 9999999; public TypeInspector oTypeInspector; - private PropertyValue[] aInfoPropertyValues = null; - private boolean bisSQL92CheckEnabled = false; private NumberFormatter oNumberFormatter = null; private long lDateCorrection = INVALID; private boolean bdisposeConnection = false; @@ -219,9 +214,9 @@ public class DBMetaData { this.xMSF = xMSF; xDatabaseContext = (XInterface) xMSF.createInstance("com.sun.star.sdb.DatabaseContext"); - xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xDatabaseContext); + xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, xDatabaseContext); XInterface xInteractionHandler = (XInterface) xMSF.createInstance("com.sun.star.sdb.InteractionHandler"); - oInteractionHandler = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class, xInteractionHandler); + oInteractionHandler = UnoRuntime.queryInterface(XInteractionHandler.class, xInteractionHandler); DataSourceNames = xNameAccess.getElementNames(); } catch (Exception exception) @@ -330,10 +325,10 @@ public class DBMetaData { oCommand = getQueryNamesAsNameAccess().getByName(Name); } - XColumnsSupplier xCommandCols = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, oCommand); - xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oCommand); + XColumnsSupplier xCommandCols = UnoRuntime.queryInterface(XColumnsSupplier.class, oCommand); + xPropertySet = UnoRuntime.queryInterface(XPropertySet.class, oCommand); // TODO: Performance leak getColumns() take very long. - xColumns = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xCommandCols.getColumns()); + xColumns = UnoRuntime.queryInterface(XNameAccess.class, xCommandCols.getColumns()); } catch (Exception exception) { @@ -379,13 +374,13 @@ public class DBMetaData public XNameAccess getQueryNamesAsNameAccess() { XQueriesSupplier xDBQueries = (XQueriesSupplier) UnoRuntime.queryInterface(XQueriesSupplier.class, DBConnection); - xQueryNames = (XNameAccess) xDBQueries.getQueries(); + xQueryNames = xDBQueries.getQueries(); return xQueryNames; } public XNameAccess getTableNamesAsNameAccess() { - XTablesSupplier xDBTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, DBConnection); + XTablesSupplier xDBTables = UnoRuntime.queryInterface(XTablesSupplier.class, DBConnection); XNameAccess xTableNames = xDBTables.getTables(); return xTableNames; } @@ -412,7 +407,7 @@ public class DBMetaData return TableNames; } } - TableNames = (String[]) getTableNamesAsNameAccess().getElementNames(); + TableNames = getTableNamesAsNameAccess().getElementNames(); return TableNames; } @@ -458,7 +453,7 @@ public class DBMetaData int itablecount = xDBMetaData.getMaxTablesInSelect(); if (itablecount == 0) { - return this.NOLIMIT; + return DBMetaData.NOLIMIT; } else { @@ -487,7 +482,7 @@ public class DBMetaData iMaxColumnsInSelect = xDBMetaData.getMaxColumnsInSelect(); if (iMaxColumnsInSelect == 0) { - iMaxColumnsInSelect = this.NOLIMIT; + iMaxColumnsInSelect = DBMetaData.NOLIMIT; } } @@ -496,7 +491,7 @@ public class DBMetaData iMaxColumnsInGroupBy = xDBMetaData.getMaxColumnsInGroupBy(); if (iMaxColumnsInGroupBy == 0) { - iMaxColumnsInGroupBy = this.NOLIMIT; + iMaxColumnsInGroupBy = DBMetaData.NOLIMIT; } } @@ -505,7 +500,7 @@ public class DBMetaData iMaxColumnsInTable = xDBMetaData.getMaxColumnsInTable(); if (iMaxColumnsInTable == 0) { - iMaxColumnsInTable = this.NOLIMIT; + iMaxColumnsInTable = DBMetaData.NOLIMIT; } return iMaxColumnsInTable; } @@ -515,8 +510,7 @@ public class DBMetaData try { xDBMetaData = DBConnection.getMetaData(); - XChild xChild = (XChild) UnoRuntime.queryInterface(XChild.class, DBConnection); - Object oDataSource = xChild.getParent(); + XChild xChild = UnoRuntime.queryInterface( XChild.class, DBConnection ); getDataSourceInterfaces(); setMaxColumnsInGroupBy(); setMaxColumnsInSelect(); @@ -527,24 +521,28 @@ public class DBMetaData } } + private void ensureDataSourceSettings() throws UnknownPropertyException, WrappedTargetException + { + if ( m_dataSourceSettings != null ) + return; + + XPropertySet dataSourceProperties = UnoRuntime.queryInterface( XPropertySet.class, getDataSource() ); + m_dataSourceSettings = UnoRuntime.queryInterface( XPropertySet.class, dataSourceProperties.getPropertyValue( "Settings" ) ); + } + public boolean isSQL92CheckEnabled() { + boolean isSQL92CheckEnabled = false; try { - if (aInfoPropertyValues == null) - { - aInfoPropertyValues = (PropertyValue[]) AnyConverter.toArray(this.xDataSourcePropertySet.getPropertyValue("Info")); - if (Properties.hasPropertyValue(aInfoPropertyValues, "EnableSQL92Check")) - { - bisSQL92CheckEnabled = AnyConverter.toBoolean(Properties.getPropertyValue(aInfoPropertyValues, "EnableSQL92Check")); - } - } + ensureDataSourceSettings(); + isSQL92CheckEnabled = AnyConverter.toBoolean( m_dataSourceSettings.getPropertyValue( "EnableSQL92Check" ) ); } catch (Exception e) { e.printStackTrace(); } - return bisSQL92CheckEnabled; + return isSQL92CheckEnabled; } public String verifyName(String _sname, int _maxlen) @@ -562,12 +560,12 @@ public class DBMetaData public XDataSource getDataSource() { - if (xDataSource == null) + if (m_dataSource == null) { try { Object oDataSource = xNameAccess.getByName(DataSourceName); - xDataSource = (XDataSource) UnoRuntime.queryInterface(XDataSource.class, oDataSource); + m_dataSource = UnoRuntime.queryInterface( XDataSource.class, oDataSource ); } catch (com.sun.star.container.NoSuchElementException e) { @@ -576,7 +574,7 @@ public class DBMetaData { } } - return xDataSource; + return m_dataSource; } private void setDataSourceByName(String _DataSourceName, boolean bgetInterfaces) @@ -585,7 +583,7 @@ public class DBMetaData { this.DataSourceName = _DataSourceName; getDataSourceInterfaces(); - XDocumentDataSource xDocu = (XDocumentDataSource) UnoRuntime.queryInterface(XDocumentDataSource.class, getDataSource()); + XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, getDataSource() ); if (xDocu != null) { xModel = xDocu.getDatabaseDocument(); @@ -599,8 +597,8 @@ public class DBMetaData public void getDataSourceInterfaces() throws Exception { - xCompleted = (XCompletedConnection) UnoRuntime.queryInterface(XCompletedConnection.class, getDataSource()); - xDataSourcePropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, getDataSource()); + xCompleted = UnoRuntime.queryInterface( XCompletedConnection.class, getDataSource() ); + xDataSourcePropertySet = UnoRuntime.queryInterface( XPropertySet.class, getDataSource() ); bPasswordIsRequired = ((Boolean) xDataSourcePropertySet.getPropertyValue("IsPasswordRequired")).booleanValue(); } @@ -608,22 +606,21 @@ public class DBMetaData { try { - com.sun.star.sdbc.XConnection xConnection = null; + XConnection xConnection = null; if (Properties.hasPropertyValue(curproperties, "ActiveConnection")) { - xConnection = (com.sun.star.sdbc.XConnection) AnyConverter.toObject(com.sun.star.sdbc.XConnection.class, - Properties.getPropertyValue(curproperties, "ActiveConnection")); + xConnection = UnoRuntime.queryInterface( XConnection.class, Properties.getPropertyValue( curproperties, "ActiveConnection" ) ); if (xConnection != null) { - com.sun.star.container.XChild child = (com.sun.star.container.XChild) UnoRuntime.queryInterface(com.sun.star.container.XChild.class, xConnection); + com.sun.star.container.XChild child = UnoRuntime.queryInterface( com.sun.star.container.XChild.class, xConnection ); - xDataSource = (XDataSource) UnoRuntime.queryInterface(XDataSource.class, child.getParent()); - XDocumentDataSource xDocu = (XDocumentDataSource) UnoRuntime.queryInterface(XDocumentDataSource.class, this.xDataSource); + m_dataSource = UnoRuntime.queryInterface( XDataSource.class, child.getParent() ); + XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, m_dataSource ); if (xDocu != null) { xModel = xDocu.getDatabaseDocument(); } - XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xDataSource); + XPropertySet xPSet = UnoRuntime.queryInterface( XPropertySet.class, m_dataSource ); if (xPSet != null) { DataSourceName = AnyConverter.toString(xPSet.getPropertyValue("Name")); @@ -646,13 +643,13 @@ public class DBMetaData } else if (Properties.hasPropertyValue(curproperties, "DataSource")) { - xDataSource = (XDataSource) UnoRuntime.queryInterface(XDataSource.class, Properties.getPropertyValue(curproperties, "DataSource")); - XDocumentDataSource xDocu = (XDocumentDataSource) UnoRuntime.queryInterface(XDocumentDataSource.class, this.xDataSource); + m_dataSource = UnoRuntime.queryInterface( XDataSource.class, Properties.getPropertyValue( curproperties, "DataSource" ) ); + XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, this.m_dataSource ); if (xDocu != null) { xModel = xDocu.getDatabaseDocument(); } - return getConnection(xDataSource); + return getConnection(m_dataSource); } if (Properties.hasPropertyValue(curproperties, "DatabaseLocation")) { @@ -692,7 +689,7 @@ public class DBMetaData try { this.DBConnection = _DBConnection; - this.ConnectionTools = (XConnectionTools) UnoRuntime.queryInterface(XConnectionTools.class, this.DBConnection); + this.ConnectionTools = UnoRuntime.queryInterface( XConnectionTools.class, this.DBConnection ); getDataSourceObjects(); return true; } @@ -703,7 +700,7 @@ public class DBMetaData } } - private boolean getConnection(XDataSource xDataSource) + private boolean getConnection(XDataSource _dataSource) { Resource oResource = new Resource(xMSF, "Database", "dbw"); try @@ -717,20 +714,19 @@ public class DBMetaData getDataSourceInterfaces(); if (bPasswordIsRequired == false) { - DBConnection = xDataSource.getConnection("", ""); + DBConnection = _dataSource.getConnection("", ""); bgetConnection = true; } else { - XInterface xInteractionHandler = (XInterface) xMSF.createInstance("com.sun.star.sdb.InteractionHandler"); - XInteractionHandler oInteractionHandler2 = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class, xInteractionHandler); + XInteractionHandler xInteractionHandler = UnoRuntime.queryInterface( XInteractionHandler.class, xMSF.createInstance("com.sun.star.sdb.InteractionHandler") ); boolean bExitLoop = true; do { - XCompletedConnection xCompleted2 = (XCompletedConnection) UnoRuntime.queryInterface(XCompletedConnection.class, xDataSource); + XCompletedConnection xCompleted2 = UnoRuntime.queryInterface( XCompletedConnection.class, _dataSource ); try { - DBConnection = xCompleted2.connectWithCompletion(oInteractionHandler2); + DBConnection = xCompleted2.connectWithCompletion( xInteractionHandler ); bgetConnection = DBConnection != null; if (bgetConnection == false) { @@ -755,8 +751,8 @@ public class DBMetaData } else { - xConnectionComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, DBConnection); - ConnectionTools = (XConnectionTools) UnoRuntime.queryInterface(XConnectionTools.class, DBConnection); + xConnectionComponent = UnoRuntime.queryInterface( XComponent.class, DBConnection ); + ConnectionTools = UnoRuntime.queryInterface( XConnectionTools.class, DBConnection ); getDataSourceObjects(); } return bgetConnection; @@ -804,6 +800,25 @@ public class DBMetaData } } + public boolean supportsPrimaryKeys() + { + boolean supportsPrimaryKeys = false; + try + { + ensureDataSourceSettings(); + Any primaryKeySupport = (Any)m_dataSourceSettings.getPropertyValue( "PrimaryKeySupport" ); + if ( AnyConverter.isVoid( primaryKeySupport ) ) + supportsPrimaryKeys = supportsCoreSQLGrammar(); + else + supportsPrimaryKeys = AnyConverter.toBoolean( primaryKeySupport ); + } + catch ( Exception ex ) + { + Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, ex ); + } + return supportsPrimaryKeys; + } + public boolean supportsCoreSQLGrammar() { try @@ -831,17 +846,17 @@ public class DBMetaData { try { - XQueryDefinitionsSupplier xQueryDefinitionsSuppl = (XQueryDefinitionsSupplier) UnoRuntime.queryInterface(XQueryDefinitionsSupplier.class, xDataSource); + XQueryDefinitionsSupplier xQueryDefinitionsSuppl = UnoRuntime.queryInterface( XQueryDefinitionsSupplier.class, m_dataSource ); XNameAccess xQueryDefs = xQueryDefinitionsSuppl.getQueryDefinitions(); - XSingleServiceFactory xSSFQueryDefs = (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, xQueryDefs); + XSingleServiceFactory xSSFQueryDefs = UnoRuntime.queryInterface( XSingleServiceFactory.class, xQueryDefs ); Object oQuery = xSSFQueryDefs.createInstance(); //"com.sun.star.sdb.QueryDefinition" - XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oQuery); + XPropertySet xPSet = UnoRuntime.queryInterface( XPropertySet.class, oQuery ); String s = _oSQLQueryComposer.m_xQueryAnalyzer.getQuery(); xPSet.setPropertyValue("Command", s); - XNameContainer xNameCont = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xQueryDefs); - XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xQueryDefs); + XNameContainer xNameCont = UnoRuntime.queryInterface( XNameContainer.class, xQueryDefs ); + XNameAccess xNameAccess = UnoRuntime.queryInterface( XNameAccess.class, xQueryDefs ); ConnectionTools.getObjectNames().checkNameForCreate(com.sun.star.sdb.CommandType.QUERY, _QueryName); xNameCont.insertByName(_QueryName, oQuery); return true; @@ -885,23 +900,23 @@ public class DBMetaData public XHierarchicalNameAccess getReportDocuments() { - XReportDocumentsSupplier xReportDocumentSuppl = (XReportDocumentsSupplier) UnoRuntime.queryInterface(XReportDocumentsSupplier.class, this.xModel); + XReportDocumentsSupplier xReportDocumentSuppl = UnoRuntime.queryInterface( XReportDocumentsSupplier.class, this.xModel ); xReportDocumentSuppl.getReportDocuments(); - XHierarchicalNameAccess xReportHier = (XHierarchicalNameAccess) UnoRuntime.queryInterface(XHierarchicalNameAccess.class, xReportDocumentSuppl.getReportDocuments()); + XHierarchicalNameAccess xReportHier = UnoRuntime.queryInterface( XHierarchicalNameAccess.class, xReportDocumentSuppl.getReportDocuments() ); return xReportHier; } public XHierarchicalNameAccess getFormDocuments() { - XFormDocumentsSupplier xFormDocumentSuppl = (XFormDocumentsSupplier) UnoRuntime.queryInterface(XFormDocumentsSupplier.class, xModel); - XHierarchicalNameAccess xFormHier = (XHierarchicalNameAccess) UnoRuntime.queryInterface(XHierarchicalNameAccess.class, xFormDocumentSuppl.getFormDocuments()); + XFormDocumentsSupplier xFormDocumentSuppl = UnoRuntime.queryInterface( XFormDocumentsSupplier.class, xModel ); + XHierarchicalNameAccess xFormHier = UnoRuntime.queryInterface( XHierarchicalNameAccess.class, xFormDocumentSuppl.getFormDocuments() ); return xFormHier; } public boolean hasFormDocumentByName(String _sFormName) { - XFormDocumentsSupplier xFormDocumentSuppl = (XFormDocumentsSupplier) UnoRuntime.queryInterface(XFormDocumentsSupplier.class, xModel); - XNameAccess xFormNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xFormDocumentSuppl.getFormDocuments()); + XFormDocumentsSupplier xFormDocumentSuppl = UnoRuntime.queryInterface( XFormDocumentsSupplier.class, xModel ); + XNameAccess xFormNameAccess = UnoRuntime.queryInterface( XNameAccess.class, xFormDocumentSuppl.getFormDocuments() ); return xFormNameAccess.hasByName(_sFormName); } @@ -929,10 +944,10 @@ public class DBMetaData try { PropertyValue[] aDocProperties; - XModel xDocumentModel = (XModel) UnoRuntime.queryInterface(XModel.class, _xComponent); + XModel xDocumentModel = UnoRuntime.queryInterface( XModel.class, _xComponent ); String sPath = xDocumentModel.getURL(); String basename = FileAccess.getBasename(sPath, "/"); - XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, _xComponent); + XCloseable xCloseable = UnoRuntime.queryInterface( XCloseable.class, _xComponent ); _xComponent.dispose(); xCloseable.close(false); if (_bcreateTemplate) @@ -951,13 +966,13 @@ public class DBMetaData { aDocProperties[4] = Properties.createProperty("AsTemplate", new Boolean(_bcreateTemplate)); } - XMultiServiceFactory xDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, _xDocNameAccess); + XMultiServiceFactory xDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, _xDocNameAccess ); Object oDBDocument = xDocMSF.createInstanceWithArguments("com.sun.star.sdb.DocumentDefinition", aDocProperties); - XHierarchicalNameContainer xHier = (XHierarchicalNameContainer) UnoRuntime.queryInterface(XHierarchicalNameContainer.class, _xDocNameAccess); + XHierarchicalNameContainer xHier = UnoRuntime.queryInterface( XHierarchicalNameContainer.class, _xDocNameAccess ); String sdocname = Desktop.getUniqueName(_xDocNameAccess, basename); xHier.insertByHierarchicalName(sdocname, oDBDocument); XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); - XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface); + XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface ); xSimpleFileAccess.kill(sPath); } catch (Exception e) @@ -971,16 +986,16 @@ public class DBMetaData XComponent[] xRetComponent = new XComponent[2]; try { - XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, _xDocuments); + XComponentLoader xComponentLoader = UnoRuntime.queryInterface( XComponentLoader.class, _xDocuments ); PropertyValue[] aPropertyValues = new PropertyValue[4]; aPropertyValues[0] = Properties.createProperty("OpenMode", _bOpenInDesign ? "openDesign" : "open"); aPropertyValues[1] = Properties.createProperty("ActiveConnection", this.DBConnection); aPropertyValues[2] = Properties.createProperty("DocumentTitle", _docname); aPropertyValues[3] = Properties.createProperty("AsTemplate", new Boolean(_bAsTemplate)); - XHierarchicalNameContainer xHier = (XHierarchicalNameContainer) UnoRuntime.queryInterface(XHierarchicalNameContainer.class, _xDocuments); + XHierarchicalNameContainer xHier = UnoRuntime.queryInterface( XHierarchicalNameContainer.class, _xDocuments ); if (xHier.hasByHierarchicalName(_docname)) { - xRetComponent[0] = (XComponent) UnoRuntime.queryInterface(XComponent.class, xHier.getByHierarchicalName(_docname)); + xRetComponent[0] = UnoRuntime.queryInterface( XComponent.class, xHier.getByHierarchicalName( _docname ) ); xRetComponent[1] = xComponentLoader.loadComponentFromURL(_docname, "", 0, aPropertyValues); } } @@ -1018,7 +1033,7 @@ public class DBMetaData String[] sColValues = null; try { - XRow xRow = (XRow) UnoRuntime.queryInterface(XRow.class, _xResultSet); + XRow xRow = UnoRuntime.queryInterface( XRow.class, _xResultSet ); Vector aColVector = new Vector(); while (_xResultSet.next()) { @@ -1067,9 +1082,9 @@ public class DBMetaData try { XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); - XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface); + XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface ); String storepath = FileAccess.getOfficePath(xMSF, "Temp", xSimpleFileAccess) + "/" + _storename; - XStorable xStoreable = (XStorable) UnoRuntime.queryInterface(XStorable.class, _xcomponent); + XStorable xStoreable = UnoRuntime.queryInterface( XStorable.class, _xcomponent ); PropertyValue[] oStoreProperties = new PropertyValue[1]; oStoreProperties[0] = Properties.createProperty("FilterName", "writer8"); storepath += ".odt"; @@ -1118,12 +1133,12 @@ public class DBMetaData try { Object oDialog = xMSF.createInstance("com.sun.star.sdb.ErrorMessageDialog"); - XInitialization xInitialization = (XInitialization) UnoRuntime.queryInterface(XInitialization.class, oDialog); + XInitialization xInitialization = UnoRuntime.queryInterface( XInitialization.class, oDialog ); PropertyValue[] aPropertyValue = new PropertyValue[2]; aPropertyValue[0] = Properties.createProperty("SQLException", oSQLException); aPropertyValue[1] = Properties.createProperty("ParentWindow", _xWindow); xInitialization.initialize(aPropertyValue); - XExecutableDialog xExecutableDialog = (XExecutableDialog) UnoRuntime.queryInterface(XExecutableDialog.class, oDialog); + XExecutableDialog xExecutableDialog = UnoRuntime.queryInterface( XExecutableDialog.class, oDialog ); xExecutableDialog.execute(); } catch (com.sun.star.uno.Exception ex) @@ -1139,7 +1154,7 @@ public class DBMetaData xNameAccess = null; xDatabaseContext = null; xDBMetaData = null; - xDataSource = null; + m_dataSource = null; xModel = null; xCompleted = null; xDataSourcePropertySet = null; diff --git a/wizards/com/sun/star/wizards/table/TableWizard.java b/wizards/com/sun/star/wizards/table/TableWizard.java index 516387de2..70f59c99e 100644 --- a/wizards/com/sun/star/wizards/table/TableWizard.java +++ b/wizards/com/sun/star/wizards/table/TableWizard.java @@ -251,7 +251,7 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet { curScenarioSelector = new ScenarioSelector(this, this.curTableDescriptor, slblFields, slblSelFields); curFieldFormatter = new FieldFormatter(this, curTableDescriptor); - if (this.curTableDescriptor.supportsCoreSQLGrammar()) + if ( this.curTableDescriptor.supportsPrimaryKeys() ) { curPrimaryKeyHandler = new PrimaryKeyHandler(this, curTableDescriptor); } @@ -265,7 +265,7 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet boolean bTableCreated = false; String schemaname = curFinalizer.getSchemaName(); String catalogname = curFinalizer.getCatalogName(); - if (curTableDescriptor.supportsCoreSQLGrammar()) + if (curTableDescriptor.supportsPrimaryKeys()) { String[] keyfieldnames = curPrimaryKeyHandler.getPrimaryKeyFields(curTableDescriptor); if (keyfieldnames != null) @@ -360,7 +360,7 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet int i = 0; i = insertRoadmapItem(0, true, m_oResource.getResText(UIConsts.RID_TABLE + 2), SOMAINPAGE); i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_TABLE + 3), SOFIELDSFORMATPAGE); - if (this.curTableDescriptor.supportsCoreSQLGrammar()) + if (this.curTableDescriptor.supportsPrimaryKeys()) { i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_TABLE + 4), SOPRIMARYKEYPAGE); } |