From 936accce7a2b1acb62230d174c1e5413baf499e6 Mon Sep 17 00:00:00 2001 From: Oliver Bolte Date: Fri, 13 Feb 2009 07:10:18 +0000 Subject: [PATCH] CWS-TOOLING: integrate CWS dba31g 2009-02-06 09:31:37 +0100 fs r267443 : line ends 2009-02-06 09:31:16 +0100 fs r267442 : line ends 2009-01-26 09:21:13 +0100 msc r266904 : #i10000# reactive tests 2009-01-21 12:38:53 +0100 msc r266657 : #i98316# add bugid 2009-01-20 14:49:04 +0100 msc r266584 : i97307 2009-01-20 13:43:22 +0100 oj r266572 : #i978i97860# merge changes from dba31h 2009-01-19 12:12:27 +0100 oj r266487 : #i97307# wrong shortcuts 2009-01-12 11:45:03 +0100 fs r266139 : #i97867# ImplPaint: don't paint if there are not items (yet) 2009-01-08 20:34:46 +0100 fs r266039 : ignore output paths 2009-01-08 20:25:45 +0100 fs r266038 : spelling: unxols4 -> unxsols4 2009-01-08 20:16:10 +0100 fs r266037 : BUILD_QADEVOOO 2009-01-08 20:15:35 +0100 fs r266036 : ignore output paths 2009-01-07 22:47:01 +0100 fs r265978 : close the document after the test 2009-01-07 22:40:22 +0100 fs r265977 : tweak the test, some behavior worked in a timing-dependent fashion only 2009-01-07 13:21:48 +0100 lla r265961 : #i96526# need FileAccess instead of File due to URL incompatibity 2009-01-07 12:27:19 +0100 lla r265959 : #i96526# need FileAccess instead of File due to URL incompatibity 2009-01-06 13:30:04 +0100 fs r265917 : #158964# GetFormControl: don't accept requests for model which do not belong to the page displayed in the given view 2009-01-06 13:30:04 +0100 fs r265916 : #158964# GetUnoControl: don't accept requests for a view where a foreign page is displayed 2009-01-06 13:26:37 +0100 fs r265915 : #158964# FmXPageViewWinRec::dispose: catch exceptions (fixes the symptom, the root cause is fixed elsewhere) 2009-01-06 09:52:38 +0100 oj r265897 : #i97307# shortcuts 2009-01-06 09:41:26 +0100 fs r265896 : #i10000# 2009-01-05 13:40:38 +0100 fs r265866 : CWS-TOOLING: rebase CWS dba31g to trunk@265758 (milestone: DEV300:m38) 2008-12-18 11:35:43 +0100 fs r265678 : document the new InputRequired property 2008-12-17 07:25:18 +0100 oj r265578 : #i97307# insert new Accelerators handling in configuration 2008-12-16 09:52:27 +0100 lla r265526 : #i96526# error message is a problem with no existance default.otr occur 2008-12-16 09:33:14 +0100 oj r265525 : #i96948# remove merge conflict with StreamName 2008-12-16 09:22:12 +0100 oj r265524 : #i96935# set reportcomponent for custom shape 2008-12-15 10:32:38 +0100 oj r265463 : #i96965# do not add connection for selfreferencing table 2008-12-12 14:00:56 +0100 fs r265416 : #i97044# EnableFocusSelectionHide=FALSE => don't hide selection when not focused (this is more of a side effect), and preserve the selection when gaining the focus (this is the desired effect) 2008-12-11 15:32:32 +0100 fs r265319 : prevent a deadlock during complex.dbaccess.DatabaseDocument test 2008-12-11 15:31:25 +0100 fs r265317 : prevent a deadlock during complex.dbaccess.DatabaseDocument test 2008-12-11 13:45:06 +0100 fs r265296 : #i97137# 2008-12-11 12:43:00 +0100 fs r265285 : #i97134# 2008-12-10 13:20:28 +0100 lla r265175 : #94067# add (APP|SYS)FONT to XUnitConversion interface implementation 2008-12-10 13:08:22 +0100 lla r265173 : #i94067# add (APP|SYS)FONT 2008-12-10 09:21:39 +0100 fs r265151 : #i95010# implement a non-hacky solution for #i94033#, by making Begin/Do/EndCompleteRedraw virtual 2008-12-09 17:29:32 +0100 fs r265120 : #i96636# --- .../source/commontools/TSkipDeletedSet.cxx | 2 +- .../source/drivers/file/FResultSet.cxx | 1 + connectivity/source/inc/TSkipDeletedSet.hxx | 1 + svx/inc/svx/fmview.hxx | 336 +++-- svx/inc/svx/svdpntv.hxx | 6 +- svx/source/form/fmshell.cxx | 65 +- svx/source/form/fmview.cxx | 1263 +++++++++-------- svx/source/form/fmvwimp.cxx | 38 +- svx/source/svdraw/svdouno.cxx | 4 + svx/source/svdraw/svdpntv.cxx | 15 - 10 files changed, 880 insertions(+), 851 deletions(-) diff --git a/connectivity/source/commontools/TSkipDeletedSet.cxx b/connectivity/source/commontools/TSkipDeletedSet.cxx index 2abd3dee97e0..01783eb9f132 100644 --- a/connectivity/source/commontools/TSkipDeletedSet.cxx +++ b/connectivity/source/commontools/TSkipDeletedSet.cxx @@ -38,9 +38,9 @@ using namespace connectivity; // ----------------------------------------------------------------------------- OSkipDeletedSet::OSkipDeletedSet(IResultSetHelper* _pHelper) : m_pHelper(_pHelper) + ,m_bDeletedVisible(false) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "commontools", "Ocke.Janssen@sun.com", "OSkipDeletedSet::OSkipDeletedSet" ); - m_bDeletedVisible = m_pHelper->deletedVisible(); m_aBookmarksPositions.reserve(256); } // ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx index 96f2767d3a77..f1da3b94ca81 100644 --- a/connectivity/source/drivers/file/FResultSet.cxx +++ b/connectivity/source/drivers/file/FResultSet.cxx @@ -135,6 +135,7 @@ OResultSet::OResultSet(OStatement_Base* pStmt,OSQLParseTreeIterator& _aSQLIte m_nResultSetConcurrency = isCount() ? ResultSetConcurrency::READ_ONLY : ResultSetConcurrency::UPDATABLE; construct(); + m_aSkipDeletedSet.SetDeleted(m_bShowDeleted); osl_decrementInterlockedCount( &m_refCount ); } diff --git a/connectivity/source/inc/TSkipDeletedSet.hxx b/connectivity/source/inc/TSkipDeletedSet.hxx index 4e06e90267a3..80cb771d8739 100644 --- a/connectivity/source/inc/TSkipDeletedSet.hxx +++ b/connectivity/source/inc/TSkipDeletedSet.hxx @@ -101,6 +101,7 @@ namespace connectivity @return the last position */ inline sal_Int32 getLastPosition() const { return m_aBookmarksPositions.size(); } + inline void SetDeleted(bool _bDeletedVisible) { m_bDeletedVisible = _bDeletedVisible; } }; } #endif // CONNECTIVITY_SKIPDELETEDSSET_HXX diff --git a/svx/inc/svx/fmview.hxx b/svx/inc/svx/fmview.hxx index ed100d9cb338..ff4c7f81f6d4 100644 --- a/svx/inc/svx/fmview.hxx +++ b/svx/inc/svx/fmview.hxx @@ -1,169 +1,167 @@ -/************************************************************************* - * - * 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: fmview.hxx,v $ - * $Revision: 1.7 $ - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SVX_FMVIEW_HXX -#define _SVX_FMVIEW_HXX - -#include -#include -#include "svx/svxdllapi.h" - -FORWARD_DECLARE_INTERFACE(util,XNumberFormats) -FORWARD_DECLARE_INTERFACE(beans,XPropertySet) - -class OutputDevice; -class FmFormModel; -class FmPageViewWinRec; -class FmFormObj; -class FmFormPage; -class FmFormShell; -class FmXFormView; - -namespace svx { - class ODataAccessDescriptor; - struct OXFormsDescriptor; -} - -class SdrUnoObj; -namespace com { namespace sun { namespace star { namespace form { - class XForm; - class XFormController; -} } } } - -class SVX_DLLPUBLIC FmFormView : public E3dView -{ - FmXFormView* pImpl; - FmFormShell* pFormShell; - - void Init(); - -public: - TYPEINFO(); - - FmFormView(FmFormModel* pModel, OutputDevice* pOut = 0L); - virtual ~FmFormView(); - - /** create a control pair (label/bound control) for the database field description given. - @param rFieldDesc - description of the field. see clipboard format SBA-FIELDFORMAT - @deprecated - This method is deprecated. Use the version with a ODataAccessDescriptor instead. - */ - SdrObject* CreateFieldControl(const UniString& rFieldDesc) const; - - /** create a control pair (label/bound control) for the database field description given. - */ - SdrObject* CreateFieldControl( const ::svx::ODataAccessDescriptor& _rColumnDescriptor ); - - /** create a control pair (label/bound control) for the xforms description given. - */ - SdrObject* CreateXFormsControl( const ::svx::OXFormsDescriptor &_rDesc ); - - virtual void MarkListHasChanged(); - virtual void AddWindowToPaintView(OutputDevice* pNewWin); - virtual void DeleteWindowFromPaintView(OutputDevice* pOldWin); - - static void createControlLabelPair( - OutputDevice* _pOutDev, - sal_Int32 _nXOffsetMM, - sal_Int32 _nYOffsetMM, - const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField, - const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& _rxNumberFormats, - sal_uInt16 _nControlObjectID, - const ::rtl::OUString& _rFieldPostfix, - UINT32 _nInventor, - UINT16 _nLabelObjectID, - SdrPage* _pLabelPage, - SdrPage* _pControlPage, - SdrModel* _pModel, - SdrUnoObj*& _rpLabel, - SdrUnoObj*& _rpControl - ); - - virtual SdrPageView* ShowSdrPage(SdrPage* pPage); - virtual void HideSdrPage(); - - // for copying complete form structures, not only control models - virtual SdrModel* GetMarkedObjModel() const; - using E3dView::Paste; - virtual sal_Bool Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst=NULL, sal_uInt32 nOptions=0); - - virtual BOOL MouseButtonDown( const MouseEvent& _rMEvt, Window* _pWin ); - - /** grab the focus to the first form control on the view - @param _bForceSync - if the handling should be done synchronously. - */ - SVX_DLLPRIVATE void GrabFirstControlFocus( sal_Bool _bForceSync = sal_False ); - - /** returns the form controller for a given form and a given device - */ - SVX_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > - GetFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const; - - // SdrView - BOOL KeyInput(const KeyEvent& rKEvt, Window* pWin); - - /// shortcut to "GetSdrPageView() ? PTR_CAST( FmFormPage, GetSdrPageView() ) : NULL" - FmFormPage* GetCurPage(); - - SVX_DLLPRIVATE void ActivateControls(SdrPageView*); - SVX_DLLPRIVATE void DeactivateControls(SdrPageView*); - - SVX_DLLPRIVATE void ChangeDesignMode(sal_Bool bDesign); - - SVX_DLLPRIVATE FmXFormView* GetImpl() const { return pImpl; } - SVX_DLLPRIVATE FmFormShell* GetFormShell() const { return pFormShell; } - - struct FormShellAccess { friend class FmFormShell; private: FormShellAccess() { } }; - void SetFormShell( FmFormShell* pShell, FormShellAccess ) { pFormShell = pShell; } - - struct ImplAccess { friend class FmXFormView; private: ImplAccess() { } }; - void SetMoveOutside( bool _bMoveOutside, ImplAccess ) { E3dView::SetMoveOutside( _bMoveOutside ); } - virtual void InsertControlContainer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& xCC); - virtual void RemoveControlContainer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& xCC); - - // the following is a hack, only to be used on the 3.0.1 branch, to prevent becoming - // incompatible there - // #i94033# / 2008-10-16 / frank.schoenheit@sun.com - void onBeginCompleteRedraw(); - void onEndCompleteRedraw(); - SVX_DLLPRIVATE const OutputDevice* GetActualOutDev() const {return pActualOutDev;} - SVX_DLLPRIVATE sal_Bool checkUnMarkAll(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xSource); - -private: - SVX_DLLPRIVATE void AdjustMarks(const SdrMarkList& rMarkList); - SVX_DLLPRIVATE FmFormObj* getMarkedGrid() const; - protected: - using E3dView::SetMoveOutside; -}; - -#endif // _FML_FMVIEW_HXX - +/************************************************************************* + * + * 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: fmview.hxx,v $ + * $Revision: 1.7 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SVX_FMVIEW_HXX +#define _SVX_FMVIEW_HXX + +#include +#include +#include "svx/svxdllapi.h" + +FORWARD_DECLARE_INTERFACE(util,XNumberFormats) +FORWARD_DECLARE_INTERFACE(beans,XPropertySet) + +class OutputDevice; +class FmFormModel; +class FmPageViewWinRec; +class FmFormObj; +class FmFormPage; +class FmFormShell; +class FmXFormView; + +namespace svx { + class ODataAccessDescriptor; + struct OXFormsDescriptor; +} + +class SdrUnoObj; +namespace com { namespace sun { namespace star { namespace form { + class XForm; + class XFormController; +} } } } + +class SVX_DLLPUBLIC FmFormView : public E3dView +{ + FmXFormView* pImpl; + FmFormShell* pFormShell; + + void Init(); + +public: + TYPEINFO(); + + FmFormView(FmFormModel* pModel, OutputDevice* pOut = 0L); + virtual ~FmFormView(); + + /** create a control pair (label/bound control) for the database field description given. + @param rFieldDesc + description of the field. see clipboard format SBA-FIELDFORMAT + @deprecated + This method is deprecated. Use the version with a ODataAccessDescriptor instead. + */ + SdrObject* CreateFieldControl(const UniString& rFieldDesc) const; + + /** create a control pair (label/bound control) for the database field description given. + */ + SdrObject* CreateFieldControl( const ::svx::ODataAccessDescriptor& _rColumnDescriptor ); + + /** create a control pair (label/bound control) for the xforms description given. + */ + SdrObject* CreateXFormsControl( const ::svx::OXFormsDescriptor &_rDesc ); + + virtual void MarkListHasChanged(); + virtual void AddWindowToPaintView(OutputDevice* pNewWin); + virtual void DeleteWindowFromPaintView(OutputDevice* pOldWin); + + static void createControlLabelPair( + OutputDevice* _pOutDev, + sal_Int32 _nXOffsetMM, + sal_Int32 _nYOffsetMM, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField, + const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& _rxNumberFormats, + sal_uInt16 _nControlObjectID, + const ::rtl::OUString& _rFieldPostfix, + UINT32 _nInventor, + UINT16 _nLabelObjectID, + SdrPage* _pLabelPage, + SdrPage* _pControlPage, + SdrModel* _pModel, + SdrUnoObj*& _rpLabel, + SdrUnoObj*& _rpControl + ); + + virtual SdrPageView* ShowSdrPage(SdrPage* pPage); + virtual void HideSdrPage(); + + // for copying complete form structures, not only control models + virtual SdrModel* GetMarkedObjModel() const; + using E3dView::Paste; + virtual sal_Bool Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst=NULL, sal_uInt32 nOptions=0); + + virtual BOOL MouseButtonDown( const MouseEvent& _rMEvt, Window* _pWin ); + + /** grab the focus to the first form control on the view + @param _bForceSync + if the handling should be done synchronously. + */ + SVX_DLLPRIVATE void GrabFirstControlFocus( sal_Bool _bForceSync = sal_False ); + + /** returns the form controller for a given form and a given device + */ + SVX_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > + GetFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const; + + // SdrView + BOOL KeyInput(const KeyEvent& rKEvt, Window* pWin); + + /// shortcut to "GetSdrPageView() ? PTR_CAST( FmFormPage, GetSdrPageView() ) : NULL" + FmFormPage* GetCurPage(); + + SVX_DLLPRIVATE void ActivateControls(SdrPageView*); + SVX_DLLPRIVATE void DeactivateControls(SdrPageView*); + + SVX_DLLPRIVATE void ChangeDesignMode(sal_Bool bDesign); + + SVX_DLLPRIVATE FmXFormView* GetImpl() const { return pImpl; } + SVX_DLLPRIVATE FmFormShell* GetFormShell() const { return pFormShell; } + + struct FormShellAccess { friend class FmFormShell; private: FormShellAccess() { } }; + void SetFormShell( FmFormShell* pShell, FormShellAccess ) { pFormShell = pShell; } + + struct ImplAccess { friend class FmXFormView; private: ImplAccess() { } }; + void SetMoveOutside( bool _bMoveOutside, ImplAccess ) { E3dView::SetMoveOutside( _bMoveOutside ); } + virtual void InsertControlContainer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& xCC); + virtual void RemoveControlContainer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& xCC); + + virtual SdrPaintWindow* BeginCompleteRedraw(OutputDevice* pOut); + virtual void EndCompleteRedraw(SdrPaintWindow& rPaintWindow); + + SVX_DLLPRIVATE const OutputDevice* GetActualOutDev() const {return pActualOutDev;} + SVX_DLLPRIVATE sal_Bool checkUnMarkAll(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xSource); + +private: + SVX_DLLPRIVATE void AdjustMarks(const SdrMarkList& rMarkList); + SVX_DLLPRIVATE FmFormObj* getMarkedGrid() const; + protected: + using E3dView::SetMoveOutside; +}; + +#endif // _FML_FMVIEW_HXX + diff --git a/svx/inc/svx/svdpntv.hxx b/svx/inc/svx/svdpntv.hxx index d9e9d46739d3..dcdbe7fc1c8f 100644 --- a/svx/inc/svx/svdpntv.hxx +++ b/svx/inc/svx/svdpntv.hxx @@ -383,9 +383,9 @@ public: // DoCompleteRedraw draws the DrawingLayer hierarchy then. // EndCompleteRedraw does the necessary refreshes, evtl. paints text edit and overlay and evtl destroys the // SdrPaintWindow again. This means: the SdrPaintWindow is no longer safe after this closing call. - SdrPaintWindow* BeginCompleteRedraw(OutputDevice* pOut); - void DoCompleteRedraw(SdrPaintWindow& rPaintWindow, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector = 0); - void EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer); + virtual SdrPaintWindow* BeginCompleteRedraw(OutputDevice* pOut); + virtual void DoCompleteRedraw(SdrPaintWindow& rPaintWindow, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector = 0); + virtual void EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer); //////////////////////////////////////////////////////////////////////////////////////////////////// // used for the other applications basctl/sc/sw which call DrawLayer at PageViews diff --git a/svx/source/form/fmshell.cxx b/svx/source/form/fmshell.cxx index 738aad42fb2c..529646e2fea1 100644 --- a/svx/source/form/fmshell.cxx +++ b/svx/source/form/fmshell.cxx @@ -1333,25 +1333,11 @@ void FmFormShell::SetControlActivationHandler( const Link& _rHdl ) } //------------------------------------------------------------------------ -SdrUnoObj* FmFormShell::GetFormControl( const Reference< XControlModel >& _rxModel, const SdrView& _rView, const OutputDevice& _rDevice, Reference< XControl >& _out_rxControl ) const +namespace { - if ( !_rxModel.is() ) - return NULL; - - FmFormModel* pModel = GetFormModel(); - OSL_ENSURE( pModel, "FmFormShell::GetFormControl: no model!" ); - if ( !pModel ) - return NULL; - - sal_uInt16 pageCount = pModel->GetPageCount(); - for ( sal_uInt16 page = 0; page < pageCount; ++page ) + SdrUnoObj* lcl_findUnoObject( const SdrObjList& _rObjList, const Reference< XControlModel >& _rxModel ) { - SdrPage* pPage = pModel->GetPage( page ); - OSL_ENSURE( pPage, "FmFormShell::GetFormControl: NULL page encountered!" ); - if ( !pPage ) - continue; - - SdrObjListIter aIter( *pPage ); + SdrObjListIter aIter( _rObjList ); while ( aIter.IsMore() ) { SdrObject* pObject = aIter.Next(); @@ -1364,12 +1350,51 @@ SdrUnoObj* FmFormShell::GetFormControl( const Reference< XControlModel >& _rxMod continue; if ( _rxModel == xControlModel ) - { - _out_rxControl = pUnoObject->GetUnoControl( _rView, _rDevice ); return pUnoObject; - } + } + return NULL; + } +} + +//------------------------------------------------------------------------ +SdrUnoObj* FmFormShell::GetFormControl( const Reference< XControlModel >& _rxModel, const SdrView& _rView, const OutputDevice& _rDevice, Reference< XControl >& _out_rxControl ) const +{ + if ( !_rxModel.is() ) + return NULL; + + // we can only retrieve controls for SdrObjects which belong to page which is actually displayed in the given view + SdrPageView* pPageView = _rView.GetSdrPageView(); + SdrPage* pPage = pPageView ? pPageView->GetPage() : NULL; + OSL_ENSURE( pPage, "FmFormShell::GetFormControl: no page displayed in the given view!" ); + if ( !pPage ) + return NULL; + + SdrUnoObj* pUnoObject = lcl_findUnoObject( *pPage, _rxModel ); + if ( pUnoObject ) + { + _out_rxControl = pUnoObject->GetUnoControl( _rView, _rDevice ); + return pUnoObject; + } + +#if OSL_DEBUG_LEVEL > 0 + // perhaps we are fed with a control model which lives on a page other than the one displayed + // in the given view. This is worth being reported as error, in non-product builds. + FmFormModel* pModel = GetFormModel(); + if ( pModel ) + { + sal_uInt16 pageCount = pModel->GetPageCount(); + for ( sal_uInt16 page = 0; page < pageCount; ++page ) + { + pPage = pModel->GetPage( page ); + OSL_ENSURE( pPage, "FmFormShell::GetFormControl: NULL page encountered!" ); + if ( !pPage ) + continue; + + pUnoObject = lcl_findUnoObject( *pPage, _rxModel ); + OSL_ENSURE( !pUnoObject, "FmFormShell::GetFormControl: the given control model belongs to a wrong page (displayed elsewhere)!" ); } } +#endif return NULL; } diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx index 2b5095473067..de19a3c8de26 100644 --- a/svx/source/form/fmview.cxx +++ b/svx/source/form/fmview.cxx @@ -1,630 +1,633 @@ -/************************************************************************* - * - * 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: fmview.cxx,v $ - * $Revision: 1.55 $ - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svx.hxx" -#include -#ifdef REFERENCE -#undef REFERENCE -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include "fmvwimp.hxx" -#include -#include -#include -#include -#include -#include -#include -#include -#include "fmitems.hxx" -#include "fmobj.hxx" -#include "svditer.hxx" -#include -#include -#include -#include -#include -#include -#include "fmpgeimp.hxx" -#include "fmtools.hxx" -#include "fmshimp.hxx" -#include "fmservs.hxx" -#include "fmprop.hrc" -#include "fmundo.hxx" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "sdrpaintwindow.hxx" - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::sdb; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::form; -using namespace ::com::sun::star::util; -using namespace ::svxform; -using namespace ::svx; - -//======================================================================== -//------------------------------------------------------------------------ -TYPEINIT1(FmFormView, E3dView); - -//------------------------------------------------------------------------ -FmFormView::FmFormView( FmFormModel* pModel, OutputDevice* pOut ) - :E3dView(pModel,pOut) -{ - Init(); -} - -//------------------------------------------------------------------------ -void FmFormView::Init() -{ - pFormShell = NULL; - pImpl = new FmXFormView(::comphelper::getProcessServiceFactory(),this); - pImpl->acquire(); - - ////////////////////////////////////////////////////////////////////// - // Model setzen - SdrModel* pModel = GetModel(); - - DBG_ASSERT( pModel->ISA(FmFormModel), "Falsches Model" ); - if( !pModel->ISA(FmFormModel) ) return; - FmFormModel* pFormModel = (FmFormModel*)pModel; - - ////////////////////////////////////////////////////////////////////// - // DesignMode vom Model holen - sal_Bool bInitDesignMode = pFormModel->GetOpenInDesignMode(); - if ( pFormModel->OpenInDesignModeIsDefaulted( ) ) - { // this means that nobody ever explicitly set this on the model, and the model has never - // been loaded from a stream. - // This means this is a newly created document. This means, we want to have it in design - // mode by default (though a newly created model returns true for GetOpenInDesignMode). - // We _want_ to have this because it makes a lot of hacks following the original fix - // for #94595# unnecessary - // #96399# - 2002-10-11 - fs@openoffice.org - DBG_ASSERT( !bInitDesignMode, "FmFormView::Init: doesn't the model default to FALSE anymore?" ); - // if this asserts, either the on-contruction default in the model has changed (then this here - // may not be necessary anymore), or we're not dealing with a new document .... - bInitDesignMode = sal_True; - } - - SfxObjectShell* pObjShell = pFormModel->GetObjectShell(); - if ( pObjShell && pObjShell->GetMedium() ) - { - const SfxPoolItem *pItem=0; - if ( pObjShell->GetMedium()->GetItemSet()->GetItemState( SID_COMPONENTDATA, sal_False, &pItem ) == SFX_ITEM_SET ) - { - Sequence< PropertyValue > aSeq; - ( ((SfxUnoAnyItem*)pItem)->GetValue() ) >>= aSeq; - ::comphelper::NamedValueCollection aComponentData( aSeq ); - bInitDesignMode = aComponentData.getOrDefault( "ApplyFormDesignMode", bInitDesignMode ); - } - } - - if( pObjShell && pObjShell->IsReadOnly() ) - bInitDesignMode = sal_False; - - // dieses wird in der Shell vorgenommen - // bDesignMode = !bInitDesignMode; // erzwingt, dass SetDesignMode ausgefuehrt wird - SetDesignMode( bInitDesignMode ); -} - -//------------------------------------------------------------------------ -FmFormView::~FmFormView() -{ - if( pFormShell ) - pFormShell->SetView( NULL ); - - pImpl->notifyViewDying(); - pImpl->release(); - pImpl = NULL; -} - -//------------------------------------------------------------------------ -FmFormPage* FmFormView::GetCurPage() -{ - SdrPageView* pPageView = GetSdrPageView(); - FmFormPage* pCurPage = pPageView ? PTR_CAST( FmFormPage, pPageView->GetPage() ) : NULL; - return pCurPage; -} - -//------------------------------------------------------------------------ -void FmFormView::MarkListHasChanged() -{ - E3dView::MarkListHasChanged(); - - if ( pFormShell && IsDesignMode() ) - { - FmFormObj* pObj = getMarkedGrid(); - if ( pImpl->m_pMarkedGrid && pImpl->m_pMarkedGrid != pObj ) - { - pImpl->m_pMarkedGrid = NULL; - if ( pImpl->m_xWindow.is() ) - { - pImpl->m_xWindow->removeFocusListener(pImpl); - pImpl->m_xWindow = NULL; - } - SetMoveOutside(FALSE); - //OLMRefreshAllIAOManagers(); - } - - pFormShell->GetImpl()->SetSelectionDelayed(); - } -} - -namespace -{ - const SdrPageWindow* findPageWindow( const SdrPaintView* _pView, OutputDevice* _pWindow ) - { - SdrPageView* pPageView = _pView->GetSdrPageView(); - if(pPageView) - { - for ( sal_uInt32 window = 0; window < pPageView->PageWindowCount(); ++window ) - { - const SdrPageWindow* pPageWindow = pPageView->GetPageWindow( window ); - if ( !pPageWindow || &pPageWindow->GetPaintWindow().GetOutputDevice() != _pWindow ) - continue; - - return pPageWindow; - } - } - return NULL; - } -} - -//------------------------------------------------------------------------ -void FmFormView::AddWindowToPaintView(OutputDevice* pNewWin) -{ - E3dView::AddWindowToPaintView(pNewWin); - - if ( !pNewWin ) - return; - - // look up the PageViewWindow for the newly inserted window, and care for it - // #i39269# / 2004-12-20 / frank.schoenheit@sun.com - const SdrPageWindow* pPageWindow = findPageWindow( this, pNewWin ); - if ( pPageWindow ) - pImpl->addWindow( *pPageWindow ); -} - -//------------------------------------------------------------------------ -void FmFormView::DeleteWindowFromPaintView(OutputDevice* pNewWin) -{ - const SdrPageWindow* pPageWindow = findPageWindow( this, pNewWin ); - if ( pPageWindow ) - pImpl->removeWindow( pPageWindow->GetControlContainer() ); - - E3dView::DeleteWindowFromPaintView(pNewWin); -} - -//------------------------------------------------------------------------ -void FmFormView::ChangeDesignMode(sal_Bool bDesign) -{ - if (bDesign == IsDesignMode()) - return; - - FmFormModel* pModel = PTR_CAST(FmFormModel, GetModel()); - if (pModel) - { // fuer die Zeit des Uebergangs das Undo-Environment ausschalten, das sichert, dass man dort auch nicht-transiente - // Properties mal eben aendern kann (sollte allerdings mit Vorsicht genossen und beim Rueckschalten des Modes - // auch immer wieder rueckgaegig gemacht werden. Ein Beispiel ist das Setzen der maximalen Text-Laenge durch das - // FmXEditModel an seinem Control.) - pModel->GetUndoEnv().Lock(); - } - - // --- 1. deactivate all controls if we are switching to design mode - if ( bDesign ) - DeactivateControls( GetSdrPageView() ); - - // --- 2. simulate a deactivation (the shell will handle some things there ...?) - if ( pFormShell && pFormShell->GetImpl() ) - pFormShell->GetImpl()->viewDeactivated( *this, sal_True ); - else - pImpl->Deactivate( sal_True ); - - // --- 3. activate all controls, if we're switching to alive mode - if ( !bDesign ) - ActivateControls( GetSdrPageView() ); - - // --- 4. load resp. unload the forms - FmFormPage* pCurPage = GetCurPage(); - if ( pCurPage ) - { - if ( pFormShell && pFormShell->GetImpl() ) - pFormShell->GetImpl()->loadForms( pCurPage, ( bDesign ? FORMS_UNLOAD : FORMS_LOAD ) ); - } - - // --- 5. base class functionality - SetDesignMode( bDesign ); - - // --- 6. simulate a activation (the shell will handle some things there ...?) - OSL_PRECOND( pFormShell && pFormShell->GetImpl(), "FmFormView::ChangeDesignMode: is this really allowed? No shell?" ); - if ( pFormShell && pFormShell->GetImpl() ) - pFormShell->GetImpl()->viewActivated( *this ); - else - pImpl->Activate(); - - if ( pCurPage ) - { - if ( bDesign ) - { - if ( GetActualOutDev() && GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW ) - { - const Window* pWindow = static_cast< const Window* >( GetActualOutDev() ); - const_cast< Window* >( pWindow )->GrabFocus(); - } - - // redraw UNO objects - if ( GetSdrPageView() ) - { - SdrObjListIter aIter(*pCurPage); - while( aIter.IsMore() ) - { - SdrObject* pObj = aIter.Next(); - if (pObj && pObj->IsUnoObj()) - { - // For redraw just use ActionChanged() - // pObj->BroadcastObjectChange(); - pObj->ActionChanged(); - } - } - } - } - else - { - // set the auto focus to the first control (if indicated by the model to do so) - sal_Bool bForceControlFocus = pModel ? pModel->GetAutoControlFocus() : sal_False; - if (bForceControlFocus) - pImpl->AutoFocus(); - } - } - - // und mein Undo-Environment wieder an - if (pModel) - pModel->GetUndoEnv().UnLock(); -} - -//------------------------------------------------------------------------ -void FmFormView::GrabFirstControlFocus( sal_Bool _bForceSync ) -{ - if ( !IsDesignMode() ) - pImpl->AutoFocus( _bForceSync ); -} - -//------------------------------------------------------------------------ -SdrPageView* FmFormView::ShowSdrPage(SdrPage* pPage) -{ - OSL_TRACE( "--- FmFormView::ShowSdrPage : ........, %p, %p\n", this, pPage ); - - SdrPageView* pPV = E3dView::ShowSdrPage(pPage); - - if (pPage) - { - if (!IsDesignMode()) - { - // creating the controllers - ActivateControls(pPV); - - // Alles deselektieren - UnmarkAll(); - } - else if ( pFormShell && pFormShell->IsDesignMode() ) - { - FmXFormShell* pFormShellImpl = pFormShell->GetImpl(); - pFormShellImpl->UpdateForms( sal_True ); - - // damit der Formular-Navigator auf den Seitenwechsel reagieren kann - pFormShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_FMEXPLORER_CONTROL , sal_True, sal_False); - - pFormShellImpl->SetSelection(GetMarkedObjectList()); - } - } - - // notify our shell that we have been activated - if ( pFormShell && pFormShell->GetImpl() ) - pFormShell->GetImpl()->viewActivated( *this ); - else - pImpl->Activate(); - - return pPV; -} - -//------------------------------------------------------------------------ -void FmFormView::HideSdrPage() -{ - OSL_TRACE( "--- FmFormView::HideSdrPage : ........, %p, %p\n", this, GetCurPage() ); - - // --- 1. deactivate controls - if ( !IsDesignMode() ) - DeactivateControls(GetSdrPageView()); - - // --- 2. tell the shell the view is (going to be) deactivated - if ( pFormShell && pFormShell->GetImpl() ) - pFormShell->GetImpl()->viewDeactivated( *this, sal_True ); - else - pImpl->Deactivate( sal_True ); - - // --- 3. base class behavior - E3dView::HideSdrPage(); -} - -//------------------------------------------------------------------------ -SdrModel* FmFormView::GetMarkedObjModel() const -{ - return E3dView::GetMarkedObjModel(); -} - -//------------------------------------------------------------------------ -sal_Bool FmFormView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions) -{ - return E3dView::Paste(rMod, rPos, pLst, nOptions); -} - -//------------------------------------------------------------------------ -void FmFormView::ActivateControls(SdrPageView* pPageView) -{ - if (!pPageView) - return; - - for (sal_uInt32 i = 0L; i < pPageView->PageWindowCount(); ++i) - { - const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i); - pImpl->addWindow(rPageWindow); - } -} - -//------------------------------------------------------------------------ -void FmFormView::DeactivateControls(SdrPageView* pPageView) -{ - if( !pPageView ) - return; - - for (sal_uInt32 i = 0L; i < pPageView->PageWindowCount(); ++i) - { - const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i); - pImpl->removeWindow(rPageWindow.GetControlContainer() ); - } -} - -//------------------------------------------------------------------------ -SdrObject* FmFormView::CreateFieldControl( const ODataAccessDescriptor& _rColumnDescriptor ) -{ - return pImpl->implCreateFieldControl( _rColumnDescriptor ); -} - -//------------------------------------------------------------------------ -SdrObject* FmFormView::CreateXFormsControl( const OXFormsDescriptor &_rDesc ) -{ - return pImpl->implCreateXFormsControl(_rDesc); -} - -//------------------------------------------------------------------------ -SdrObject* FmFormView::CreateFieldControl(const UniString& rFieldDesc) const -{ - ::rtl::OUString sDataSource = rFieldDesc.GetToken(0,sal_Unicode(11)); - ::rtl::OUString sObjectName = rFieldDesc.GetToken(1,sal_Unicode(11)); - sal_uInt16 nObjectType = (sal_uInt16)rFieldDesc.GetToken(2,sal_Unicode(11)).ToInt32(); - ::rtl::OUString sFieldName = rFieldDesc.GetToken(3,sal_Unicode(11)); - - if (!sFieldName.getLength() || !sObjectName.getLength() || !sDataSource.getLength()) - return NULL; - - ODataAccessDescriptor aColumnDescriptor; - aColumnDescriptor.setDataSource(sDataSource); - aColumnDescriptor[ daCommand ] <<= sObjectName; - aColumnDescriptor[ daCommandType ] <<= nObjectType; - aColumnDescriptor[ daColumnName ] <<= sFieldName; - - return pImpl->implCreateFieldControl( aColumnDescriptor ); -} - -//------------------------------------------------------------------------ -void FmFormView::InsertControlContainer(const Reference< ::com::sun::star::awt::XControlContainer > & xCC) -{ - if( !IsDesignMode() ) - { - SdrPageView* pPageView = GetSdrPageView(); - if( pPageView ) - { - for( sal_uInt32 i = 0L; i < pPageView->PageWindowCount(); i++ ) - { - const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i); - - if( rPageWindow.GetControlContainer( false ) == xCC ) - { - pImpl->addWindow(rPageWindow); - break; - } - } - } - } -} - -//------------------------------------------------------------------------ -void FmFormView::RemoveControlContainer(const Reference< ::com::sun::star::awt::XControlContainer > & xCC) -{ - if( !IsDesignMode() ) - { - pImpl->removeWindow( xCC ); - } -} - -// ----------------------------------------------------------------------------- -void FmFormView::onBeginCompleteRedraw() -{ - pImpl->suspendTabOrderUpdate(); -} - -// ----------------------------------------------------------------------------- -void FmFormView::onEndCompleteRedraw() -{ - pImpl->resumeTabOrderUpdate(); -} - -// ----------------------------------------------------------------------------- -BOOL FmFormView::KeyInput(const KeyEvent& rKEvt, Window* pWin) -{ - BOOL bDone = FALSE; - const KeyCode& rKeyCode = rKEvt.GetKeyCode(); - if ( IsDesignMode() - && rKeyCode.GetCode() == KEY_RETURN - ) - { - // RETURN alone enters grid controls, for keyboard accessibility - if ( pWin - && !rKeyCode.IsShift() - && !rKeyCode.IsMod1() - && !rKeyCode.IsMod2() - ) - { - FmFormObj* pObj = getMarkedGrid(); - if ( pObj ) - { - Reference< awt::XWindow > xWindow( pObj->GetUnoControl( *this, *pWin ), UNO_QUERY ); - if ( xWindow.is() ) - { - pImpl->m_pMarkedGrid = pObj; - pImpl->m_xWindow = xWindow; - // add as listener to get notified when ESC will be pressed inside the grid - pImpl->m_xWindow->addFocusListener(pImpl); - SetMoveOutside(TRUE); - //OLMRefreshAllIAOManagers(); - xWindow->setFocus(); - bDone = TRUE; - } - } - } - // Alt-RETURN alone shows the properties of the selection - if ( pFormShell - && pFormShell->GetImpl() - && !rKeyCode.IsShift() - && !rKeyCode.IsMod1() - && rKeyCode.IsMod2() - ) - { - pFormShell->GetImpl()->handleShowPropertiesRequest(); - } - - } - - if ( !bDone ) - bDone = E3dView::KeyInput(rKEvt,pWin); - return bDone; -} -// ----------------------------------------------------------------------------- -sal_Bool FmFormView::checkUnMarkAll(const Reference< XInterface >& _xSource) -{ - Reference< ::com::sun::star::awt::XControl> xControl(pImpl->m_xWindow,UNO_QUERY); - sal_Bool bRet = !xControl.is() || !_xSource.is() || _xSource != xControl->getModel(); - if ( bRet ) - UnmarkAll(); - - return bRet; -} - -// ----------------------------------------------------------------------------- -BOOL FmFormView::MouseButtonDown( const MouseEvent& _rMEvt, Window* _pWin ) -{ - BOOL bReturn = E3dView::MouseButtonDown( _rMEvt, _pWin ); - - if ( pFormShell && pFormShell->GetImpl() ) - { - SdrViewEvent aViewEvent; - PickAnything( _rMEvt, SDRMOUSEBUTTONDOWN, aViewEvent ); - pFormShell->GetImpl()->handleMouseButtonDown( aViewEvent ); - } - - return bReturn; -} - -// ----------------------------------------------------------------------------- -FmFormObj* FmFormView::getMarkedGrid() const -{ - FmFormObj* pFormObject = NULL; - const SdrMarkList& rMarkList = GetMarkedObjectList(); - if ( 1 == rMarkList.GetMarkCount() ) - { - SdrMark* pMark = rMarkList.GetMark(0); - if ( pMark ) - { - pFormObject = FmFormObj::GetFormObject( pMark->GetMarkedSdrObj() ); - if ( pFormObject ) - { - Reference< XServiceInfo > xServInfo( pFormObject->GetUnoControlModel(), UNO_QUERY ); - if ( !xServInfo.is() || !xServInfo->supportsService( FM_SUN_COMPONENT_GRIDCONTROL ) ) - pFormObject = NULL; - } - } - } - return pFormObject; -} - -// ----------------------------------------------------------------------------- -void FmFormView::createControlLabelPair( OutputDevice* _pOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM, - const Reference< XPropertySet >& _rxField, const Reference< XNumberFormats >& _rxNumberFormats, - sal_uInt16 _nControlObjectID, const ::rtl::OUString& _rFieldPostfix, UINT32 _nInventor, UINT16 _nLabelObjectID, - SdrPage* _pLabelPage, SdrPage* _pControlPage, SdrModel* _pModel, SdrUnoObj*& _rpLabel, SdrUnoObj*& _rpControl ) -{ - FmXFormView::createControlLabelPair( - ::comphelper::getProcessServiceFactory(), - *_pOutDev, _nXOffsetMM, _nYOffsetMM, - _rxField, _rxNumberFormats, - _nControlObjectID, _rFieldPostfix, _nInventor, _nLabelObjectID, - _pLabelPage, _pControlPage, _pModel, - _rpLabel, _rpControl - ); -} -// ----------------------------------------------------------------------------- -Reference< XFormController > FmFormView::GetFormController( const Reference< XForm >& _rxForm, const OutputDevice& _rDevice ) const -{ - return pImpl->getFormController( _rxForm, _rDevice ); -} - +/************************************************************************* + * + * 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: fmview.cxx,v $ + * $Revision: 1.55 $ + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" +#include +#ifdef REFERENCE +#undef REFERENCE +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include "fmvwimp.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include "fmitems.hxx" +#include "fmobj.hxx" +#include "svditer.hxx" +#include +#include +#include +#include +#include +#include +#include "fmpgeimp.hxx" +#include "fmtools.hxx" +#include "fmshimp.hxx" +#include "fmservs.hxx" +#include "fmprop.hrc" +#include "fmundo.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "sdrpaintwindow.hxx" + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::sdb; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::form; +using namespace ::com::sun::star::util; +using namespace ::svxform; +using namespace ::svx; + +//======================================================================== +//------------------------------------------------------------------------ +TYPEINIT1(FmFormView, E3dView); + +//------------------------------------------------------------------------ +FmFormView::FmFormView( FmFormModel* pModel, OutputDevice* pOut ) + :E3dView(pModel,pOut) +{ + Init(); +} + +//------------------------------------------------------------------------ +void FmFormView::Init() +{ + pFormShell = NULL; + pImpl = new FmXFormView(::comphelper::getProcessServiceFactory(),this); + pImpl->acquire(); + + ////////////////////////////////////////////////////////////////////// + // Model setzen + SdrModel* pModel = GetModel(); + + DBG_ASSERT( pModel->ISA(FmFormModel), "Falsches Model" ); + if( !pModel->ISA(FmFormModel) ) return; + FmFormModel* pFormModel = (FmFormModel*)pModel; + + ////////////////////////////////////////////////////////////////////// + // DesignMode vom Model holen + sal_Bool bInitDesignMode = pFormModel->GetOpenInDesignMode(); + if ( pFormModel->OpenInDesignModeIsDefaulted( ) ) + { // this means that nobody ever explicitly set this on the model, and the model has never + // been loaded from a stream. + // This means this is a newly created document. This means, we want to have it in design + // mode by default (though a newly created model returns true for GetOpenInDesignMode). + // We _want_ to have this because it makes a lot of hacks following the original fix + // for #94595# unnecessary + // #96399# - 2002-10-11 - fs@openoffice.org + DBG_ASSERT( !bInitDesignMode, "FmFormView::Init: doesn't the model default to FALSE anymore?" ); + // if this asserts, either the on-contruction default in the model has changed (then this here + // may not be necessary anymore), or we're not dealing with a new document .... + bInitDesignMode = sal_True; + } + + SfxObjectShell* pObjShell = pFormModel->GetObjectShell(); + if ( pObjShell && pObjShell->GetMedium() ) + { + const SfxPoolItem *pItem=0; + if ( pObjShell->GetMedium()->GetItemSet()->GetItemState( SID_COMPONENTDATA, sal_False, &pItem ) == SFX_ITEM_SET ) + { + Sequence< PropertyValue > aSeq; + ( ((SfxUnoAnyItem*)pItem)->GetValue() ) >>= aSeq; + ::comphelper::NamedValueCollection aComponentData( aSeq ); + bInitDesignMode = aComponentData.getOrDefault( "ApplyFormDesignMode", bInitDesignMode ); + } + } + + if( pObjShell && pObjShell->IsReadOnly() ) + bInitDesignMode = sal_False; + + // dieses wird in der Shell vorgenommen + // bDesignMode = !bInitDesignMode; // erzwingt, dass SetDesignMode ausgefuehrt wird + SetDesignMode( bInitDesignMode ); +} + +//------------------------------------------------------------------------ +FmFormView::~FmFormView() +{ + if( pFormShell ) + pFormShell->SetView( NULL ); + + pImpl->notifyViewDying(); + pImpl->release(); + pImpl = NULL; +} + +//------------------------------------------------------------------------ +FmFormPage* FmFormView::GetCurPage() +{ + SdrPageView* pPageView = GetSdrPageView(); + FmFormPage* pCurPage = pPageView ? PTR_CAST( FmFormPage, pPageView->GetPage() ) : NULL; + return pCurPage; +} + +//------------------------------------------------------------------------ +void FmFormView::MarkListHasChanged() +{ + E3dView::MarkListHasChanged(); + + if ( pFormShell && IsDesignMode() ) + { + FmFormObj* pObj = getMarkedGrid(); + if ( pImpl->m_pMarkedGrid && pImpl->m_pMarkedGrid != pObj ) + { + pImpl->m_pMarkedGrid = NULL; + if ( pImpl->m_xWindow.is() ) + { + pImpl->m_xWindow->removeFocusListener(pImpl); + pImpl->m_xWindow = NULL; + } + SetMoveOutside(FALSE); + //OLMRefreshAllIAOManagers(); + } + + pFormShell->GetImpl()->SetSelectionDelayed(); + } +} + +namespace +{ + const SdrPageWindow* findPageWindow( const SdrPaintView* _pView, OutputDevice* _pWindow ) + { + SdrPageView* pPageView = _pView->GetSdrPageView(); + if(pPageView) + { + for ( sal_uInt32 window = 0; window < pPageView->PageWindowCount(); ++window ) + { + const SdrPageWindow* pPageWindow = pPageView->GetPageWindow( window ); + if ( !pPageWindow || &pPageWindow->GetPaintWindow().GetOutputDevice() != _pWindow ) + continue; + + return pPageWindow; + } + } + return NULL; + } +} + +//------------------------------------------------------------------------ +void FmFormView::AddWindowToPaintView(OutputDevice* pNewWin) +{ + E3dView::AddWindowToPaintView(pNewWin); + + if ( !pNewWin ) + return; + + // look up the PageViewWindow for the newly inserted window, and care for it + // #i39269# / 2004-12-20 / frank.schoenheit@sun.com + const SdrPageWindow* pPageWindow = findPageWindow( this, pNewWin ); + if ( pPageWindow ) + pImpl->addWindow( *pPageWindow ); +} + +//------------------------------------------------------------------------ +void FmFormView::DeleteWindowFromPaintView(OutputDevice* pNewWin) +{ + const SdrPageWindow* pPageWindow = findPageWindow( this, pNewWin ); + if ( pPageWindow ) + pImpl->removeWindow( pPageWindow->GetControlContainer() ); + + E3dView::DeleteWindowFromPaintView(pNewWin); +} + +//------------------------------------------------------------------------ +void FmFormView::ChangeDesignMode(sal_Bool bDesign) +{ + if (bDesign == IsDesignMode()) + return; + + FmFormModel* pModel = PTR_CAST(FmFormModel, GetModel()); + if (pModel) + { // fuer die Zeit des Uebergangs das Undo-Environment ausschalten, das sichert, dass man dort auch nicht-transiente + // Properties mal eben aendern kann (sollte allerdings mit Vorsicht genossen und beim Rueckschalten des Modes + // auch immer wieder rueckgaegig gemacht werden. Ein Beispiel ist das Setzen der maximalen Text-Laenge durch das + // FmXEditModel an seinem Control.) + pModel->GetUndoEnv().Lock(); + } + + // --- 1. deactivate all controls if we are switching to design mode + if ( bDesign ) + DeactivateControls( GetSdrPageView() ); + + // --- 2. simulate a deactivation (the shell will handle some things there ...?) + if ( pFormShell && pFormShell->GetImpl() ) + pFormShell->GetImpl()->viewDeactivated( *this, sal_True ); + else + pImpl->Deactivate( sal_True ); + + // --- 3. activate all controls, if we're switching to alive mode + if ( !bDesign ) + ActivateControls( GetSdrPageView() ); + + // --- 4. load resp. unload the forms + FmFormPage* pCurPage = GetCurPage(); + if ( pCurPage ) + { + if ( pFormShell && pFormShell->GetImpl() ) + pFormShell->GetImpl()->loadForms( pCurPage, ( bDesign ? FORMS_UNLOAD : FORMS_LOAD ) ); + } + + // --- 5. base class functionality + SetDesignMode( bDesign ); + + // --- 6. simulate a activation (the shell will handle some things there ...?) + OSL_PRECOND( pFormShell && pFormShell->GetImpl(), "FmFormView::ChangeDesignMode: is this really allowed? No shell?" ); + if ( pFormShell && pFormShell->GetImpl() ) + pFormShell->GetImpl()->viewActivated( *this ); + else + pImpl->Activate(); + + if ( pCurPage ) + { + if ( bDesign ) + { + if ( GetActualOutDev() && GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW ) + { + const Window* pWindow = static_cast< const Window* >( GetActualOutDev() ); + const_cast< Window* >( pWindow )->GrabFocus(); + } + + // redraw UNO objects + if ( GetSdrPageView() ) + { + SdrObjListIter aIter(*pCurPage); + while( aIter.IsMore() ) + { + SdrObject* pObj = aIter.Next(); + if (pObj && pObj->IsUnoObj()) + { + // For redraw just use ActionChanged() + // pObj->BroadcastObjectChange(); + pObj->ActionChanged(); + } + } + } + } + else + { + // set the auto focus to the first control (if indicated by the model to do so) + sal_Bool bForceControlFocus = pModel ? pModel->GetAutoControlFocus() : sal_False; + if (bForceControlFocus) + pImpl->AutoFocus(); + } + } + + // und mein Undo-Environment wieder an + if (pModel) + pModel->GetUndoEnv().UnLock(); +} + +//------------------------------------------------------------------------ +void FmFormView::GrabFirstControlFocus( sal_Bool _bForceSync ) +{ + if ( !IsDesignMode() ) + pImpl->AutoFocus( _bForceSync ); +} + +//------------------------------------------------------------------------ +SdrPageView* FmFormView::ShowSdrPage(SdrPage* pPage) +{ + OSL_TRACE( "--- FmFormView::ShowSdrPage : ........, %p, %p\n", this, pPage ); + + SdrPageView* pPV = E3dView::ShowSdrPage(pPage); + + if (pPage) + { + if (!IsDesignMode()) + { + // creating the controllers + ActivateControls(pPV); + + // Alles deselektieren + UnmarkAll(); + } + else if ( pFormShell && pFormShell->IsDesignMode() ) + { + FmXFormShell* pFormShellImpl = pFormShell->GetImpl(); + pFormShellImpl->UpdateForms( sal_True ); + + // damit der Formular-Navigator auf den Seitenwechsel reagieren kann + pFormShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_FMEXPLORER_CONTROL , sal_True, sal_False); + + pFormShellImpl->SetSelection(GetMarkedObjectList()); + } + } + + // notify our shell that we have been activated + if ( pFormShell && pFormShell->GetImpl() ) + pFormShell->GetImpl()->viewActivated( *this ); + else + pImpl->Activate(); + + return pPV; +} + +//------------------------------------------------------------------------ +void FmFormView::HideSdrPage() +{ + OSL_TRACE( "--- FmFormView::HideSdrPage : ........, %p, %p\n", this, GetCurPage() ); + + // --- 1. deactivate controls + if ( !IsDesignMode() ) + DeactivateControls(GetSdrPageView()); + + // --- 2. tell the shell the view is (going to be) deactivated + if ( pFormShell && pFormShell->GetImpl() ) + pFormShell->GetImpl()->viewDeactivated( *this, sal_True ); + else + pImpl->Deactivate( sal_True ); + + // --- 3. base class behavior + E3dView::HideSdrPage(); +} + +//------------------------------------------------------------------------ +SdrModel* FmFormView::GetMarkedObjModel() const +{ + return E3dView::GetMarkedObjModel(); +} + +//------------------------------------------------------------------------ +sal_Bool FmFormView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions) +{ + return E3dView::Paste(rMod, rPos, pLst, nOptions); +} + +//------------------------------------------------------------------------ +void FmFormView::ActivateControls(SdrPageView* pPageView) +{ + if (!pPageView) + return; + + for (sal_uInt32 i = 0L; i < pPageView->PageWindowCount(); ++i) + { + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i); + pImpl->addWindow(rPageWindow); + } +} + +//------------------------------------------------------------------------ +void FmFormView::DeactivateControls(SdrPageView* pPageView) +{ + if( !pPageView ) + return; + + for (sal_uInt32 i = 0L; i < pPageView->PageWindowCount(); ++i) + { + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i); + pImpl->removeWindow(rPageWindow.GetControlContainer() ); + } +} + +//------------------------------------------------------------------------ +SdrObject* FmFormView::CreateFieldControl( const ODataAccessDescriptor& _rColumnDescriptor ) +{ + return pImpl->implCreateFieldControl( _rColumnDescriptor ); +} + +//------------------------------------------------------------------------ +SdrObject* FmFormView::CreateXFormsControl( const OXFormsDescriptor &_rDesc ) +{ + return pImpl->implCreateXFormsControl(_rDesc); +} + +//------------------------------------------------------------------------ +SdrObject* FmFormView::CreateFieldControl(const UniString& rFieldDesc) const +{ + ::rtl::OUString sDataSource = rFieldDesc.GetToken(0,sal_Unicode(11)); + ::rtl::OUString sObjectName = rFieldDesc.GetToken(1,sal_Unicode(11)); + sal_uInt16 nObjectType = (sal_uInt16)rFieldDesc.GetToken(2,sal_Unicode(11)).ToInt32(); + ::rtl::OUString sFieldName = rFieldDesc.GetToken(3,sal_Unicode(11)); + + if (!sFieldName.getLength() || !sObjectName.getLength() || !sDataSource.getLength()) + return NULL; + + ODataAccessDescriptor aColumnDescriptor; + aColumnDescriptor.setDataSource(sDataSource); + aColumnDescriptor[ daCommand ] <<= sObjectName; + aColumnDescriptor[ daCommandType ] <<= nObjectType; + aColumnDescriptor[ daColumnName ] <<= sFieldName; + + return pImpl->implCreateFieldControl( aColumnDescriptor ); +} + +//------------------------------------------------------------------------ +void FmFormView::InsertControlContainer(const Reference< ::com::sun::star::awt::XControlContainer > & xCC) +{ + if( !IsDesignMode() ) + { + SdrPageView* pPageView = GetSdrPageView(); + if( pPageView ) + { + for( sal_uInt32 i = 0L; i < pPageView->PageWindowCount(); i++ ) + { + const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i); + + if( rPageWindow.GetControlContainer( false ) == xCC ) + { + pImpl->addWindow(rPageWindow); + break; + } + } + } + } +} + +//------------------------------------------------------------------------ +void FmFormView::RemoveControlContainer(const Reference< ::com::sun::star::awt::XControlContainer > & xCC) +{ + if( !IsDesignMode() ) + { + pImpl->removeWindow( xCC ); + } +} + +// ----------------------------------------------------------------------------- +SdrPaintWindow* FmFormView::BeginCompleteRedraw(OutputDevice* pOut) +{ + SdrPaintWindow* pPaintWindow = E3dView::BeginCompleteRedraw( pOut ); + pImpl->suspendTabOrderUpdate(); + return pPaintWindow; +} + +// ----------------------------------------------------------------------------- +void FmFormView::EndCompleteRedraw(SdrPaintWindow& rPaintWindow) +{ + E3dView::EndCompleteRedraw( rPaintWindow ); + pImpl->resumeTabOrderUpdate(); +} + +// ----------------------------------------------------------------------------- +BOOL FmFormView::KeyInput(const KeyEvent& rKEvt, Window* pWin) +{ + BOOL bDone = FALSE; + const KeyCode& rKeyCode = rKEvt.GetKeyCode(); + if ( IsDesignMode() + && rKeyCode.GetCode() == KEY_RETURN + ) + { + // RETURN alone enters grid controls, for keyboard accessibility + if ( pWin + && !rKeyCode.IsShift() + && !rKeyCode.IsMod1() + && !rKeyCode.IsMod2() + ) + { + FmFormObj* pObj = getMarkedGrid(); + if ( pObj ) + { + Reference< awt::XWindow > xWindow( pObj->GetUnoControl( *this, *pWin ), UNO_QUERY ); + if ( xWindow.is() ) + { + pImpl->m_pMarkedGrid = pObj; + pImpl->m_xWindow = xWindow; + // add as listener to get notified when ESC will be pressed inside the grid + pImpl->m_xWindow->addFocusListener(pImpl); + SetMoveOutside(TRUE); + //OLMRefreshAllIAOManagers(); + xWindow->setFocus(); + bDone = TRUE; + } + } + } + // Alt-RETURN alone shows the properties of the selection + if ( pFormShell + && pFormShell->GetImpl() + && !rKeyCode.IsShift() + && !rKeyCode.IsMod1() + && rKeyCode.IsMod2() + ) + { + pFormShell->GetImpl()->handleShowPropertiesRequest(); + } + + } + + if ( !bDone ) + bDone = E3dView::KeyInput(rKEvt,pWin); + return bDone; +} +// ----------------------------------------------------------------------------- +sal_Bool FmFormView::checkUnMarkAll(const Reference< XInterface >& _xSource) +{ + Reference< ::com::sun::star::awt::XControl> xControl(pImpl->m_xWindow,UNO_QUERY); + sal_Bool bRet = !xControl.is() || !_xSource.is() || _xSource != xControl->getModel(); + if ( bRet ) + UnmarkAll(); + + return bRet; +} + +// ----------------------------------------------------------------------------- +BOOL FmFormView::MouseButtonDown( const MouseEvent& _rMEvt, Window* _pWin ) +{ + BOOL bReturn = E3dView::MouseButtonDown( _rMEvt, _pWin ); + + if ( pFormShell && pFormShell->GetImpl() ) + { + SdrViewEvent aViewEvent; + PickAnything( _rMEvt, SDRMOUSEBUTTONDOWN, aViewEvent ); + pFormShell->GetImpl()->handleMouseButtonDown( aViewEvent ); + } + + return bReturn; +} + +// ----------------------------------------------------------------------------- +FmFormObj* FmFormView::getMarkedGrid() const +{ + FmFormObj* pFormObject = NULL; + const SdrMarkList& rMarkList = GetMarkedObjectList(); + if ( 1 == rMarkList.GetMarkCount() ) + { + SdrMark* pMark = rMarkList.GetMark(0); + if ( pMark ) + { + pFormObject = FmFormObj::GetFormObject( pMark->GetMarkedSdrObj() ); + if ( pFormObject ) + { + Reference< XServiceInfo > xServInfo( pFormObject->GetUnoControlModel(), UNO_QUERY ); + if ( !xServInfo.is() || !xServInfo->supportsService( FM_SUN_COMPONENT_GRIDCONTROL ) ) + pFormObject = NULL; + } + } + } + return pFormObject; +} + +// ----------------------------------------------------------------------------- +void FmFormView::createControlLabelPair( OutputDevice* _pOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM, + const Reference< XPropertySet >& _rxField, const Reference< XNumberFormats >& _rxNumberFormats, + sal_uInt16 _nControlObjectID, const ::rtl::OUString& _rFieldPostfix, UINT32 _nInventor, UINT16 _nLabelObjectID, + SdrPage* _pLabelPage, SdrPage* _pControlPage, SdrModel* _pModel, SdrUnoObj*& _rpLabel, SdrUnoObj*& _rpControl ) +{ + FmXFormView::createControlLabelPair( + ::comphelper::getProcessServiceFactory(), + *_pOutDev, _nXOffsetMM, _nYOffsetMM, + _rxField, _rxNumberFormats, + _nControlObjectID, _rFieldPostfix, _nInventor, _nLabelObjectID, + _pLabelPage, _pControlPage, _pModel, + _rpLabel, _rpControl + ); +} +// ----------------------------------------------------------------------------- +Reference< XFormController > FmFormView::GetFormController( const Reference< XForm >& _rxForm, const OutputDevice& _rDevice ) const +{ + return pImpl->getFormController( _rxForm, _rDevice ); +} + diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index 4a8d993cf595..d696f84b0b44 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -197,23 +197,35 @@ FmXPageViewWinRec::~FmXPageViewWinRec() //------------------------------------------------------------------ void FmXPageViewWinRec::dispose() { - for (::std::vector< Reference< XFormController > >::const_iterator i = m_aControllerList.begin(); - i != m_aControllerList.end(); i++) + for ( ::std::vector< Reference< XFormController > >::const_iterator i = m_aControllerList.begin(); + i != m_aControllerList.end(); + ++i + ) { - // detaching the events - Reference< XChild > xChild((*i)->getModel(), UNO_QUERY); - if (xChild.is()) + try { - Reference< XEventAttacherManager > xEventManager(xChild->getParent(), UNO_QUERY); - Reference< XInterface > xIfc(*i, UNO_QUERY); - xEventManager->detach( i - m_aControllerList.begin(), xIfc ); - } + Reference< XFormController > xController( *i, UNO_SET_THROW ); - // dispose the formcontroller - Reference< XComponent > xComp(*i, UNO_QUERY); - xComp->dispose(); + // detaching the events + Reference< XChild > xControllerModel( xController->getModel(), UNO_QUERY ); + if ( xControllerModel.is() ) + { + Reference< XEventAttacherManager > xEventManager( xControllerModel->getParent(), UNO_QUERY ); + Reference< XInterface > xControllerNormalized( xController, UNO_QUERY_THROW ); + xEventManager->detach( i - m_aControllerList.begin(), xControllerNormalized ); + } + + // dispose the formcontroller + Reference< XComponent > xComp( xController, UNO_QUERY_THROW ); + xComp->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } - m_aControllerList.clear(); // this call deletes the formcontrollers + + m_aControllerList.clear(); } diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx index cf9476ed2489..d6020908bef0 100644 --- a/svx/source/svdraw/svdouno.cxx +++ b/svx/source/svdraw/svdouno.cxx @@ -623,6 +623,10 @@ uno::Reference< awt::XControl > SdrUnoObj::GetUnoControl(const SdrView& _rView, uno::Reference< awt::XControl > xControl; SdrPageView* pPageView = _rView.GetSdrPageView(); + OSL_ENSURE( GetPage() == pPageView->GetPage(), "SdrUnoObj::GetUnoControl: This object is not displayed in that particular view!" ); + if ( GetPage() != pPageView->GetPage() ) + return NULL; + SdrPageWindow* pPageWindow = pPageView ? pPageView->FindPageWindow( _rOut ) : NULL; OSL_ENSURE( pPageWindow, "SdrUnoObj::GetUnoControl: did not find my SdrPageWindow!" ); if ( !pPageWindow ) diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx index 1bebad93223d..c42497d73507 100644 --- a/svx/source/svdraw/svdpntv.cxx +++ b/svx/source/svdraw/svdpntv.cxx @@ -36,7 +36,6 @@ #include #include #include -#include #ifdef DBG_UTIL #include @@ -868,13 +867,6 @@ SdrPaintWindow* SdrPaintView::BeginCompleteRedraw(OutputDevice* pOut) pPaintWindow->setTemporaryTarget(true); } - // the following is a hack, only to be used on the 3.0.1 branch, to prevent becoming - // incompatible there - // #i94033# / 2008-10-16 / frank.schoenheit@sun.com - FmFormView* pMeAsFormView = dynamic_cast< FmFormView* >( this ); - if ( pMeAsFormView ) - pMeAsFormView->onBeginCompleteRedraw(); - return pPaintWindow; } @@ -938,13 +930,6 @@ void SdrPaintView::EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFo rPaintWindow.OutputPreRenderDevice(rPaintWindow.GetRedrawRegion()); } } - - // the following is a hack, only to be used on the 3.0.1 branch, to prevent becoming - // incompatible there - // #i94033# / 2008-10-16 / frank.schoenheit@sun.com - FmFormView* pMeAsFormView = dynamic_cast< FmFormView* >( this ); - if ( pMeAsFormView ) - pMeAsFormView->onEndCompleteRedraw(); } ////////////////////////////////////////////////////////////////////////////////////////////////////