1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef REPORT_REPORTSECTION_HXX
28*cdf0e10cSrcweir #define REPORT_REPORTSECTION_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <vcl/window.hxx>
31*cdf0e10cSrcweir #include "RptPage.hxx"
32*cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp>
33*cdf0e10cSrcweir #include <comphelper/propmultiplex.hxx>
34*cdf0e10cSrcweir #include "cppuhelper/basemutex.hxx"
35*cdf0e10cSrcweir #include "ReportDefines.hxx"
36*cdf0e10cSrcweir #include "dlgedfunc.hxx"
37*cdf0e10cSrcweir #include <svtools/transfer.hxx>
38*cdf0e10cSrcweir #include <rtl/ref.hxx>
39*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
40*cdf0e10cSrcweir #include <memory>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir namespace rptui
43*cdf0e10cSrcweir {
44*cdf0e10cSrcweir 	class OReportModel;
45*cdf0e10cSrcweir 	class OReportPage;
46*cdf0e10cSrcweir 	class OSectionView;
47*cdf0e10cSrcweir 	class OSectionWindow;
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir 	class OReportSection :	 public Window
50*cdf0e10cSrcweir 						,	public ::cppu::BaseMutex
51*cdf0e10cSrcweir 						,	public ::comphelper::OPropertyChangeListener
52*cdf0e10cSrcweir                         ,   public DropTargetHelper
53*cdf0e10cSrcweir 	{
54*cdf0e10cSrcweir 		OReportPage*				        m_pPage;
55*cdf0e10cSrcweir 		OSectionView*				        m_pView;
56*cdf0e10cSrcweir 		OSectionWindow*				        m_pParent;
57*cdf0e10cSrcweir 		::std::auto_ptr<DlgEdFunc>	        m_pFunc;
58*cdf0e10cSrcweir         ::boost::shared_ptr<OReportModel>   m_pModel;
59*cdf0e10cSrcweir 		::rtl::Reference< comphelper::OPropertyChangeMultiplexer>				            m_pMulti;
60*cdf0e10cSrcweir 		::rtl::Reference< comphelper::OPropertyChangeMultiplexer>				            m_pReportListener;
61*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >              m_xSection;
62*cdf0e10cSrcweir         sal_Int32                   m_nPaintEntranceCount;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir 		DlgEdMode					m_eMode;
65*cdf0e10cSrcweir 		sal_Bool						m_bDialogModelChanged;
66*cdf0e10cSrcweir 		sal_Bool					m_bInDrag;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 		/** fills the section with all control from the report section
69*cdf0e10cSrcweir 		*/
70*cdf0e10cSrcweir 		void fill();
71*cdf0e10cSrcweir         /** checks all objects if they fit in the new paper width.
72*cdf0e10cSrcweir         */
73*cdf0e10cSrcweir         void impl_adjustObjectSizePosition(sal_Int32 i_nPaperWidth,sal_Int32 i_nLeftMargin,sal_Int32 i_nRightMargin);
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir         OReportSection(OReportSection&);
76*cdf0e10cSrcweir         void operator =(OReportSection&);
77*cdf0e10cSrcweir     protected:
78*cdf0e10cSrcweir         // DropTargetHelper overridables
79*cdf0e10cSrcweir 		virtual sal_Int8	AcceptDrop( const AcceptDropEvent& _rEvt );
80*cdf0e10cSrcweir 		virtual sal_Int8	ExecuteDrop( const ExecuteDropEvent& _rEvt );
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 		// window overrides
83*cdf0e10cSrcweir 		virtual void        Paint( const Rectangle& rRect );
84*cdf0e10cSrcweir 		virtual void 		MouseMove( const MouseEvent& rMEvt );
85*cdf0e10cSrcweir 		virtual void		Command( const CommandEvent& rCEvt );
86*cdf0e10cSrcweir 		virtual void		Resize();
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 		// OPropertyChangeListener
89*cdf0e10cSrcweir 		virtual void	_propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& _rEvent) throw( ::com::sun::star::uno::RuntimeException);
90*cdf0e10cSrcweir 	public:
91*cdf0e10cSrcweir 		OReportSection(OSectionWindow* _pParent,const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection);
92*cdf0e10cSrcweir 		virtual ~OReportSection();
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir         // window overrides
95*cdf0e10cSrcweir 		virtual void 		MouseButtonDown( const MouseEvent& rMEvt );
96*cdf0e10cSrcweir         virtual void 		MouseButtonUp( const MouseEvent& rMEvt );
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 		/** copies the current selection in this section
99*cdf0e10cSrcweir             @param  _rAllreadyCopiedObjects This is an out/in put param which contains all already copied objects.
100*cdf0e10cSrcweir 		*/
101*cdf0e10cSrcweir 		void Copy(::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _rAllreadyCopiedObjects);
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir         void Copy(::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _rAllreadyCopiedObjects,bool _bEraseAnddNoClone);
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 		/** paste a new control in this section
106*cdf0e10cSrcweir             @param  _aAllreadyCopiedObjects objects to paste into the section. Only objects are pasted where the name is equal to the section name.
107*cdf0e10cSrcweir             @param  _bForce If set to <TRUE/> than the objects will be copied into this section. The name is not compared in this case.
108*cdf0e10cSrcweir 		*/
109*cdf0e10cSrcweir 		void Paste(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _aAllreadyCopiedObjects,bool _bForce = false);
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 		/** Deletes the current selection in this section
112*cdf0e10cSrcweir 		*
113*cdf0e10cSrcweir 		*/
114*cdf0e10cSrcweir 		void Delete();
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir 		/** All objects will be marked.
117*cdf0e10cSrcweir 		*/
118*cdf0e10cSrcweir 		void SelectAll(const sal_uInt16 _nObjectType);
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 		/** makes the grid visible
121*cdf0e10cSrcweir 		*
122*cdf0e10cSrcweir 		* \param _bVisible when <TRUE/> the grid is made visible
123*cdf0e10cSrcweir 		*/
124*cdf0e10cSrcweir 		void SetGridVisible(sal_Bool _bVisible);
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 		inline OSectionWindow*		getSectionWindow() const { return m_pParent; }
127*cdf0e10cSrcweir 		inline OSectionView&		getSectionView() const { return *m_pView; }
128*cdf0e10cSrcweir 		inline OReportPage*			getPage() const { return m_pPage; }
129*cdf0e10cSrcweir 		inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getSection() const { return m_xSection; }
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 		void			SetDialogModelChanged( sal_Bool bChanged = sal_True ) { m_bDialogModelChanged = bChanged; }
132*cdf0e10cSrcweir 		sal_Bool			IsDialogModelChanged() const { return m_bDialogModelChanged; }
133*cdf0e10cSrcweir 		DlgEdMode   	GetMode() const { return m_eMode; }
134*cdf0e10cSrcweir 		void 			SetMode( DlgEdMode m_eMode );
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir 		/** checks if the keycode is known by the child windows
137*cdf0e10cSrcweir 			@param	_rCode	the keycode
138*cdf0e10cSrcweir 			@return <TRUE/> if the keycode is handled otherwise <FALSE/>
139*cdf0e10cSrcweir 		*/
140*cdf0e10cSrcweir 		sal_Bool		handleKeyEvent(const KeyEvent& _rEvent);
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 		/** returns the current control report model or <NULL/>
143*cdf0e10cSrcweir 		*/
144*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent > getCurrentControlModel() const;
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir         /** fills the vector with all selected control models
147*cdf0e10cSrcweir             /param  _rSelection The vector will be filled and will not be cleared before.
148*cdf0e10cSrcweir         */
149*cdf0e10cSrcweir         void fillControlModelSelection(::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& _rSelection) const;
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir         /** creates a default object (custom shape)
152*cdf0e10cSrcweir         *
153*cdf0e10cSrcweir         * @param _sType
154*cdf0e10cSrcweir         */
155*cdf0e10cSrcweir         void createDefault(const ::rtl::OUString& _sType);
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir         /** creates a new default custom shape
158*cdf0e10cSrcweir         *
159*cdf0e10cSrcweir         * \param _sType
160*cdf0e10cSrcweir         * \param _pObj
161*cdf0e10cSrcweir         */
162*cdf0e10cSrcweir         void createDefault(const ::rtl::OUString& _sType,SdrObject* _pObj);
163*cdf0e10cSrcweir         void stopScrollTimer();
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir         /** deactivate the currect active ole object if any
166*cdf0e10cSrcweir         */
167*cdf0e10cSrcweir         void    deactivateOle();
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir         /** returns true when an ole object is currently active
170*cdf0e10cSrcweir         */
171*cdf0e10cSrcweir         bool isUiActive() const;
172*cdf0e10cSrcweir 	};
173*cdf0e10cSrcweir //==================================================================
174*cdf0e10cSrcweir }	//rptui
175*cdf0e10cSrcweir //==================================================================
176*cdf0e10cSrcweir #endif // REPORT_REPORTSECTION_HXX
177*cdf0e10cSrcweir 
178