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 RPTUI_REPORT_WINDOW_HXX
28 #define RPTUI_REPORT_WINDOW_HXX
29 
30 #include <com/sun/star/report/XSection.hpp>
31 #include "ReportDefines.hxx"
32 #include "StartMarker.hxx"
33 #include <svtools/ruler.hxx>
34 #include <svx/svdedtv.hxx>
35 #include <svx/zoomitem.hxx>
36 
37 #include <vector>
38 #include <boost/shared_ptr.hpp>
39 #include <comphelper/propmultiplex.hxx>
40 
41 #include <MarkedSection.hxx>
42 #include "ViewsWindow.hxx"
43 
44 class Splitter;
45 
46 namespace rptui
47 {
48 	class ODesignView;
49 	class OReportSection;
50 	class OScrollWindowHelper;
51 	class OSectionView;
52 	class OReportModel;
53 	class OEndMarker;
54 	class OReportPage;
55 	class DlgEdFunc;
56 	class DlgEdFactory;
57 
58 	class OReportWindow :	 public Window
59                             , public IMarkedSection
60                             , public ::cppu::BaseMutex
61                             , public ::comphelper::OPropertyChangeListener
62 	{
63 		Ruler					m_aHRuler;
64 		ODesignView*		    m_pView;
65 		OScrollWindowHelper*	m_pParent;
66 		OViewsWindow			m_aViewsWindow;
67         ::rtl::Reference< comphelper::OPropertyChangeMultiplexer>	m_pReportListener;
68         ::std::auto_ptr<DlgEdFactory>
69                                 m_pObjFac;
70 
71 		void ImplInitSettings();
72 
73 		sal_Int32 GetTotalHeight() const;
74         sal_Int32 impl_getRealPixelWidth() const;
75 
76         OReportWindow(OReportWindow&);
77         void operator =(OReportWindow&);
78 	protected:
79 		virtual void DataChanged( const DataChangedEvent& rDCEvt );
80         // OPropertyChangeListener
81 		virtual void	_propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& _rEvent) throw( ::com::sun::star::uno::RuntimeException);
82 	public:
83 		OReportWindow(OScrollWindowHelper* _pParent,ODesignView* _pView);
84 		virtual ~OReportWindow();
85 
86 		/** late ctor
87 		*/
88 		void initialize();
89 		// WINDOW overloads
90 		virtual void Resize();
91 
92 		inline ODesignView*	        getReportView() const { return m_pView; }
93 		inline OScrollWindowHelper*	getScrollWindow() const { return m_pParent; }
94 
95 		void 			SetMode( DlgEdMode m_eMode );
96 		void			SetInsertObj( sal_uInt16 eObj,const ::rtl::OUString& _sShapeType = ::rtl::OUString());
97 		rtl::OUString   GetInsertObjString() const;
98         void            setGridSnap(sal_Bool bOn);
99         void            setDragStripes(sal_Bool bOn);
100 
101         /** copies the current selection in this section
102 		*/
103 		void Copy();
104 
105 		/**	returns if paste is allowed
106 		*
107 		* \return <TRUE/> if paste is allowed
108 		*/
109 		sal_Bool IsPasteAllowed() const;
110 
111 		/** paste a new control in this section
112 		*/
113 		void Paste();
114 
115 		/** Deletes the current selection in this section
116 		*
117 		*/
118 		void Delete();
119 
120 		/** All objects will be marked.
121 		*/
122 		void SelectAll(const sal_uInt16 _nObjectType);
123 
124         /** returns <TRUE/> when a object is marked
125         */
126         sal_Bool HasSelection() const;
127 
128 		Point			getThumbPos() const;
129 
130 		/** removes the section at the given position.
131 		*
132 		* \param _nPosition Zero based.
133 		*/
134 		void			removeSection(sal_uInt16 _nPosition);
135 
136 		/** adds a new section at position _nPosition.
137 			If the section is <NULL/> nothing happens.
138 			If the position is grater than the current elements, the section will be appended.
139 		*/
140 		void			addSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection
141 									,const ::rtl::OUString& _sColorEntry
142 									,sal_uInt16 _nPosition = USHRT_MAX);
143 
144 		sal_uInt16			getSectionCount() const;
145 
146 		/** turns the grid on or off
147 		*
148 		* \param _bVisible
149 		*/
150 		void			toggleGrid(sal_Bool _bVisible);
151 
152 
153 		/** shows the ruler
154 		*/
155 		void			showRuler(sal_Bool _bShow);
156 
157 		inline sal_Int32 getRulerHeight() const { return m_aHRuler.GetSizePixel().Height(); }
158 
159 		/** returns the total width of the first section
160 		*/
161 		sal_Int32		GetTotalWidth() const;
162 
163 		/** calculate the max width of the markers
164 		*
165 		* @param _bWithEnd	if <TRUE/> the end marker will be used for calculation as well otherwise not.
166 		* \return the max width
167 		*/
168 		sal_Int32		getMaxMarkerWidth(sal_Bool _bWithEnd) const;
169 
170 		void			ScrollChildren(const Point& _aThumbPos);
171 
172 		void			notifySizeChanged();
173 
174 		/** unmark all objects on the views without the given one.
175 		*
176 		* @param _pSectionView The view where the objects should not be unmarked.
177 		*/
178 		void			unmarkAllObjects(OSectionView* _pSectionView);
179 
180 		/** triggers the property browser with the report component or section
181 			@param	_xReportComponent
182 		*/
183 		void			showProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xReportComponent);
184 
185 		/** checks if the keycode is known by the child windows
186 			@param	_rCode	the keycode
187 			@return <TRUE/> if the keycode is handled otherwise <FALSE/>
188 		*/
189 		sal_Bool		handleKeyEvent(const KeyEvent& _rEvent);
190 
191 		/** the the section as marked or not marked
192 			@param	_pSectionView	the section where to set the marked flag
193 			@param	_bMark	the marked flag
194 		*/
195 		void			setMarked(OSectionView* _pSectionView,sal_Bool _bMark);
196         void			setMarked(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection,sal_Bool _bMark);
197         void			setMarked(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> >& _xShape,sal_Bool _bMark);
198 
199         // IMarkedSection
200 		::boost::shared_ptr<OSectionWindow> getMarkedSection(NearSectionAccess nsa = CURRENT) const;
201         ::boost::shared_ptr<OSectionWindow> getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const;
202         virtual void markSection(const sal_uInt16 _nPos);
203 
204 
205         /** fills the positions of all collapsed sections.
206         *
207         * \param _rCollapsedPositions Out parameter which holds afterwards all positions of the collapsed sections.
208         */
209         void fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const;
210 
211         /** collpase all sections given by their position
212         *
213         * \param _aCollpasedSections The position of the sections which should be collapsed.
214         */
215         void collapseSections(const com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& _aCollpasedSections);
216 
217         /** align all marked objects in all sections
218         *
219         * \param eHor
220         * \param eVert
221         * \param bBoundRects
222         */
223         void alignMarkedObjects(sal_Int32 _nControlModification, bool _bAlignAtSection, bool bBoundRects = false);
224 
225         sal_uInt32 getMarkedObjectCount() const;
226 
227         /** zoom the ruler and view windows
228         */
229         void zoom(const Fraction& _aZoom);
230 
231         /** fills the vector with all selected control models
232             /param  _rSelection The vector will be filled and will not be cleared before.
233         */
234         void fillControlModelSelection(::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& _rSelection) const;
235 
236         /** calculates the zoom factor.
237             @param  _eType  which kind of zoom is needed
238         */
239         sal_uInt16 getZoomFactor(SvxZoomType _eType) const;
240 	};
241 //==================================================================
242 }	//rptui
243 //==================================================================
244 #endif // RPTUI_REPORT_WINDOW_HXX
245 
246