xref: /AOO41X/main/reportdesign/source/ui/inc/DesignView.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 RPTUI_DESIGNVIEW_HXX
28*cdf0e10cSrcweir #define RPTUI_DESIGNVIEW_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <dbaccess/dataview.hxx>
31*cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/report/XSection.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/report/XReportComponent.hpp>
34*cdf0e10cSrcweir #include <vcl/split.hxx>
35*cdf0e10cSrcweir #include <vcl/scrbar.hxx>
36*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/datatransfer/DataFlavor.hpp>
38*cdf0e10cSrcweir #include <tools/link.hxx>
39*cdf0e10cSrcweir #include <tools/gen.hxx>
40*cdf0e10cSrcweir #include <vcl/timer.hxx>
41*cdf0e10cSrcweir #include <svl/hint.hxx>
42*cdf0e10cSrcweir #include <svl/brdcst.hxx>
43*cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
44*cdf0e10cSrcweir #include "ReportDefines.hxx"
45*cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
46*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
47*cdf0e10cSrcweir #include <svx/svdedtv.hxx>
48*cdf0e10cSrcweir #include <vcl/tabpage.hxx>
49*cdf0e10cSrcweir #include <vcl/splitwin.hxx>
50*cdf0e10cSrcweir #include <MarkedSection.hxx>
51*cdf0e10cSrcweir #include "ScrollHelper.hxx"
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir class KeyEvent;
54*cdf0e10cSrcweir class MouseEvent;
55*cdf0e10cSrcweir class Timer;
56*cdf0e10cSrcweir class Window;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir namespace rptui
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir 	class OReportSection;
61*cdf0e10cSrcweir 	class OUnoObject;
62*cdf0e10cSrcweir 	class OSectionView;
63*cdf0e10cSrcweir 	class OReportController;
64*cdf0e10cSrcweir 	class PropBrw;
65*cdf0e10cSrcweir     class OAddFieldWindow;
66*cdf0e10cSrcweir     class OReportModel;
67*cdf0e10cSrcweir     class ONavigator;
68*cdf0e10cSrcweir 	//==================================================================
69*cdf0e10cSrcweir 	//==================================================================
70*cdf0e10cSrcweir 	class ODesignView : public dbaui::ODataView, public SfxBroadcaster, public IMarkedSection
71*cdf0e10cSrcweir 	{
72*cdf0e10cSrcweir 	private:
73*cdf0e10cSrcweir         SplitWindow                         m_aSplitWin;
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>		m_xReportComponent;
76*cdf0e10cSrcweir 		OReportController&					m_rReportController;
77*cdf0e10cSrcweir         OScrollWindowHelper                 m_aScrollWindow;
78*cdf0e10cSrcweir 		Window*								m_pTaskPane;
79*cdf0e10cSrcweir 		PropBrw*							m_pPropWin;
80*cdf0e10cSrcweir 		OAddFieldWindow*					m_pAddField;
81*cdf0e10cSrcweir 		OSectionView*						m_pCurrentView;
82*cdf0e10cSrcweir         ONavigator*                         m_pReportExplorer;
83*cdf0e10cSrcweir 		Timer								m_aMarkTimer;
84*cdf0e10cSrcweir 		Point								m_aScrollOffset;
85*cdf0e10cSrcweir 		DlgEdMode							m_eMode;
86*cdf0e10cSrcweir 		sal_uInt16								m_nCurrentPosition;
87*cdf0e10cSrcweir 		sal_uInt16								m_eActObj;
88*cdf0e10cSrcweir 		sal_Bool								m_bFirstDraw;
89*cdf0e10cSrcweir         Size                                m_aGridSizeCoarse;
90*cdf0e10cSrcweir         Size                                m_aGridSizeFine;
91*cdf0e10cSrcweir 		sal_Bool								m_bGridVisible;
92*cdf0e10cSrcweir 		sal_Bool								m_bGridSnap;
93*cdf0e10cSrcweir 		sal_Bool								m_bDeleted;
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 		DECL_LINK( MarkTimeout, Timer * );
97*cdf0e10cSrcweir 		DECL_LINK( SplitHdl, void* );
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir 		void ImplInitSettings();
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir         ODesignView(ODesignView&);
102*cdf0e10cSrcweir         void operator =(ODesignView&);
103*cdf0e10cSrcweir 	protected:
104*cdf0e10cSrcweir         // return the Rectangle where I can paint myself
105*cdf0e10cSrcweir 		virtual void resizeDocumentView(Rectangle& rRect);
106*cdf0e10cSrcweir 		// return the Rectangle where I can paint myself
107*cdf0e10cSrcweir 		virtual void DataChanged( const DataChangedEvent& rDCEvt );
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 	public:
110*cdf0e10cSrcweir 		ODesignView(Window* pParent,
111*cdf0e10cSrcweir 					const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&,
112*cdf0e10cSrcweir 					OReportController& _rController);
113*cdf0e10cSrcweir 		virtual ~ODesignView();
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir 		// window overloads
116*cdf0e10cSrcweir         virtual void MouseButtonDown( const MouseEvent& rMEvt );
117*cdf0e10cSrcweir         virtual long PreNotify( NotifyEvent& rNEvt );
118*cdf0e10cSrcweir         virtual void GetFocus();
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 		// set the view readonly or not
121*cdf0e10cSrcweir 		virtual void setReadOnly(sal_Bool _bReadOnly);
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 		virtual void initialize();
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 		inline OReportController&	getController() const { return m_rReportController; }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 		void 			SetMode( DlgEdMode m_eMode );
128*cdf0e10cSrcweir 		void			SetInsertObj( sal_uInt16 eObj,const ::rtl::OUString& _sShapeType = ::rtl::OUString());
129*cdf0e10cSrcweir 		sal_uInt16    		GetInsertObj() const;
130*cdf0e10cSrcweir 		rtl::OUString   GetInsertObjString() const;
131*cdf0e10cSrcweir 		DlgEdMode   	GetMode() const { return m_eMode; }
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir         /** cuts the current selection in this section
134*cdf0e10cSrcweir 		*/
135*cdf0e10cSrcweir 		void Cut();
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 		/** copies the current selection in this section
138*cdf0e10cSrcweir 		*/
139*cdf0e10cSrcweir 		void Copy();
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir 		/**	returns if paste is allowed
142*cdf0e10cSrcweir 		*
143*cdf0e10cSrcweir 		* \return <TRUE/> if paste is allowed
144*cdf0e10cSrcweir 		*/
145*cdf0e10cSrcweir 		sal_Bool IsPasteAllowed() const;
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 		/** paste a new control in this section
148*cdf0e10cSrcweir 		*/
149*cdf0e10cSrcweir 		void Paste();
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 		/** Deletes the current selection in this section
152*cdf0e10cSrcweir 		*
153*cdf0e10cSrcweir 		*/
154*cdf0e10cSrcweir 		void Delete();
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir         /** align all marked objects in all sections
157*cdf0e10cSrcweir         */
158*cdf0e10cSrcweir         void alignMarkedObjects(sal_Int32 _nControlModification, bool _bAlignAtSection, bool bBoundRects = false);
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir #if 0
161*cdf0e10cSrcweir         /** checks if alignment is possible in the current section
162*cdf0e10cSrcweir         */
163*cdf0e10cSrcweir 	    sal_Bool isAlignPossible() const;
164*cdf0e10cSrcweir #endif
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 		/** All objects will be marked.
167*cdf0e10cSrcweir 		*/
168*cdf0e10cSrcweir 		void            SelectAll(const sal_uInt16 _nObjectType);
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir         /// checks if a selection exists
171*cdf0e10cSrcweir 		sal_Bool			HasSelection() const;
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 		void            UpdatePropertyBrowserDelayed(OSectionView& _rView);
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir 		sal_uInt16			getSectionCount() const;
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 		/** removes the section at the given position.
178*cdf0e10cSrcweir 		*
179*cdf0e10cSrcweir 		* \param _nPosition Zero based.
180*cdf0e10cSrcweir 		*/
181*cdf0e10cSrcweir 		void			removeSection(sal_uInt16 _nPosition);
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 		/** adds a new section at position _nPosition.
184*cdf0e10cSrcweir 			If the section is <NULL/> nothing happens.
185*cdf0e10cSrcweir 			If the position is grater than the current elements, the section will be appended.
186*cdf0e10cSrcweir 		*/
187*cdf0e10cSrcweir 		void			addSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection
188*cdf0e10cSrcweir 									,const ::rtl::OUString& _sColorEntry
189*cdf0e10cSrcweir 									,sal_uInt16 _nPosition = USHRT_MAX);
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir         inline Size     getGridSizeCoarse() const { return m_aGridSizeCoarse; }
192*cdf0e10cSrcweir         inline Size     getGridSizeFine() const { return m_aGridSizeFine; }
193*cdf0e10cSrcweir 		inline sal_Bool		isGridSnap() const { return m_bGridSnap; }
194*cdf0e10cSrcweir         void            setGridSnap(sal_Bool bOn);
195*cdf0e10cSrcweir         void            setDragStripes(sal_Bool bOn);
196*cdf0e10cSrcweir         /** turns the grid on or off
197*cdf0e10cSrcweir 		*
198*cdf0e10cSrcweir 		* \param _bGridVisible
199*cdf0e10cSrcweir 		*/
200*cdf0e10cSrcweir 		void			toggleGrid(sal_Bool _bGridVisible);
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 		void			togglePropertyBrowser(sal_Bool _bToogleOn);
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir 		sal_Bool			isAddFieldVisible() const;
205*cdf0e10cSrcweir 		void			toggleAddField();
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir         sal_Bool			isReportExplorerVisible() const;
208*cdf0e10cSrcweir         void			toggleReportExplorer();
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir 		/** shows or hides the ruler.
211*cdf0e10cSrcweir 		*/
212*cdf0e10cSrcweir 		void			showRuler(sal_Bool _bShow);
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir 		/** unmark all objects on the views without the given one.
215*cdf0e10cSrcweir 		*
216*cdf0e10cSrcweir 		* @param _pSectionView The view where the objects should not be unmarked.
217*cdf0e10cSrcweir 		*/
218*cdf0e10cSrcweir 		void			unmarkAllObjects(OSectionView* _pSectionView);
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 		/** triggers the property browser with the section
221*cdf0e10cSrcweir 			@param	_xReportComponent the report component
222*cdf0e10cSrcweir 		*/
223*cdf0e10cSrcweir 		void			showProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xReportComponent);
224*cdf0e10cSrcweir         ::com::sun::star::uno::Any getCurrentlyShownProperty() const;
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir 		/** returns the current section or the detail section if no section was selected previously
227*cdf0e10cSrcweir 		*/
228*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > getCurrentSection() const;
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir 		/** returns the current control report model or <NULL/>
231*cdf0e10cSrcweir 		*/
232*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent > getCurrentControlModel() const;
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir         // IMarkedSection
235*cdf0e10cSrcweir 		::boost::shared_ptr<OSectionWindow> getMarkedSection(NearSectionAccess nsa = CURRENT) const;
236*cdf0e10cSrcweir         ::boost::shared_ptr<OSectionWindow> getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const;
237*cdf0e10cSrcweir         virtual void markSection(const sal_uInt16 _nPos);
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir         /** fills the positions of all collapsed sections.
240*cdf0e10cSrcweir         *
241*cdf0e10cSrcweir         * \param _rCollapsedPositions Out parameter which holds afterwards all positions of the collapsed sections.
242*cdf0e10cSrcweir         */
243*cdf0e10cSrcweir         void fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const;
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir         /** collpase all sections given by their position
246*cdf0e10cSrcweir         *
247*cdf0e10cSrcweir         * \param _aCollpasedSections The position of the sections which should be collapsed.
248*cdf0e10cSrcweir         */
249*cdf0e10cSrcweir         void collapseSections(const com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& _aCollpasedSections);
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir         ::rtl::OUString  getCurrentPage() const;
252*cdf0e10cSrcweir         void             setCurrentPage(const ::rtl::OUString& _sLastActivePage);
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir         /** checks if the keycode is known by the child windows
255*cdf0e10cSrcweir 			@param	_rCode	the keycode
256*cdf0e10cSrcweir 			@return <TRUE/> if the keycode is handled otherwise <FALSE/>
257*cdf0e10cSrcweir 		*/
258*cdf0e10cSrcweir 		sal_Bool		 handleKeyEvent(const KeyEvent& _rEvent);
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir         /** set the section as marked or not marked
261*cdf0e10cSrcweir 			@param	_pSectionView	the section where to set the marked flag
262*cdf0e10cSrcweir 			@param	_bMark	the marked flag
263*cdf0e10cSrcweir 		*/
264*cdf0e10cSrcweir         void			setMarked(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection,sal_Bool _bMark);
265*cdf0e10cSrcweir         void			setMarked(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> >& _xShape,sal_Bool _bMark);
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir         /** returns if the view handles the event by itself
268*cdf0e10cSrcweir         *
269*cdf0e10cSrcweir         * \param _nId the command id
270*cdf0e10cSrcweir         * \return  <FALSE/> is the event is not handled by the view otherwise <TRUE/>
271*cdf0e10cSrcweir         */
272*cdf0e10cSrcweir         sal_Bool        isHandleEvent(sal_uInt16 _nId) const;
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir         sal_uInt32      getMarkedObjectCount() const;
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir         /** zoom the ruler and view windows
277*cdf0e10cSrcweir         */
278*cdf0e10cSrcweir         void            zoom(const Fraction& _aZoom);
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir         /** fills the vector with all selected control models
281*cdf0e10cSrcweir             /param  _rSelection The vector will be filled and will not be cleared before.
282*cdf0e10cSrcweir         */
283*cdf0e10cSrcweir         void fillControlModelSelection(::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& _rSelection) const;
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir         /** returns the selected field from the add field dialog
286*cdf0e10cSrcweir         */
287*cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > getSelectedFieldDescriptors();
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir         /** calculates the zoom factor.
290*cdf0e10cSrcweir             @param  _eType  which kind of zoom is needed
291*cdf0e10cSrcweir         */
292*cdf0e10cSrcweir         sal_uInt16 getZoomFactor(SvxZoomType _eType) const;
293*cdf0e10cSrcweir 	};
294*cdf0e10cSrcweir //==================================================================
295*cdf0e10cSrcweir }	//rptui
296*cdf0e10cSrcweir //==================================================================
297*cdf0e10cSrcweir #endif // RPTUI_DESIGNVIEW_HXX
298*cdf0e10cSrcweir 
299