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