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_SCROLLHELPER_HXX
28*cdf0e10cSrcweir #define RPTUI_SCROLLHELPER_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <vcl/scrbar.hxx>
31*cdf0e10cSrcweir #include <com/sun/star/report/XSection.hpp>
32*cdf0e10cSrcweir #include <comphelper/propmultiplex.hxx>
33*cdf0e10cSrcweir #include "ReportDefines.hxx"
34*cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
35*cdf0e10cSrcweir #include <svx/svdedtv.hxx>
36*cdf0e10cSrcweir #include "cppuhelper/basemutex.hxx"
37*cdf0e10cSrcweir #include <rtl/ref.hxx>
38*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
39*cdf0e10cSrcweir #include <vcl/dockwin.hxx>
40*cdf0e10cSrcweir #include <MarkedSection.hxx>
41*cdf0e10cSrcweir #include "ReportWindow.hxx"
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir class SdrView;
44*cdf0e10cSrcweir namespace rptui
45*cdf0e10cSrcweir {
46*cdf0e10cSrcweir 	class ODesignView;
47*cdf0e10cSrcweir 	class OReportWindow;
48*cdf0e10cSrcweir 	class OSectionView;
49*cdf0e10cSrcweir 	class OReportSection;
50*cdf0e10cSrcweir 	class OReportModel;
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir 	/** This class defines the scrollable area of the report design. It includes
53*cdf0e10cSrcweir 		the h-ruler and the sections, and end marker. Not the start marker.
54*cdf0e10cSrcweir 	*/
55*cdf0e10cSrcweir     typedef Window OScrollWindowHelper_BASE;
56*cdf0e10cSrcweir 	class OScrollWindowHelper : 	public ::cppu::BaseMutex
57*cdf0e10cSrcweir                                 ,   public OScrollWindowHelper_BASE/*TabPage*/
58*cdf0e10cSrcweir                                 ,	public ::comphelper::OPropertyChangeListener
59*cdf0e10cSrcweir                                     , public IMarkedSection
60*cdf0e10cSrcweir 	{
61*cdf0e10cSrcweir 	private:
62*cdf0e10cSrcweir 		ScrollBar			m_aHScroll;
63*cdf0e10cSrcweir 		ScrollBar			m_aVScroll;
64*cdf0e10cSrcweir 		ScrollBarBox		m_aCornerWin; 		// window in the bottom right corner
65*cdf0e10cSrcweir 		Size				m_aTotalPixelSize;
66*cdf0e10cSrcweir 		ODesignView*	    m_pParent;
67*cdf0e10cSrcweir 		OReportWindow		m_aReportWindow;
68*cdf0e10cSrcweir         ::rtl::Reference<comphelper::OPropertyChangeMultiplexer >
69*cdf0e10cSrcweir                             m_pReportDefintionMultiPlexer; // listener for property changes
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 		DECL_LINK( ScrollHdl, ScrollBar*);
72*cdf0e10cSrcweir 		Size ResizeScrollBars();
73*cdf0e10cSrcweir 		void ImplInitSettings();
74*cdf0e10cSrcweir         void impl_initScrollBar( ScrollBar& _rScrollBar ) const;
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir         OScrollWindowHelper(OScrollWindowHelper&);
77*cdf0e10cSrcweir         void operator =(OScrollWindowHelper&);
78*cdf0e10cSrcweir     protected:
79*cdf0e10cSrcweir 		virtual void DataChanged( const DataChangedEvent& rDCEvt );
80*cdf0e10cSrcweir         // window
81*cdf0e10cSrcweir 		virtual void			Resize();
82*cdf0e10cSrcweir         virtual long            Notify( NotifyEvent& rNEvt );
83*cdf0e10cSrcweir         // OPropertyChangeListener
84*cdf0e10cSrcweir 		virtual void	        _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& _rEvent) throw( ::com::sun::star::uno::RuntimeException);
85*cdf0e10cSrcweir 	public:
86*cdf0e10cSrcweir 		OScrollWindowHelper( ODesignView* _pReportDesignView);
87*cdf0e10cSrcweir 		virtual ~OScrollWindowHelper();
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 		/** late ctor
90*cdf0e10cSrcweir 		*/
91*cdf0e10cSrcweir 		void					initialize();
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 		inline Point			getThumbPos() const { return Point(m_aHScroll.GetThumbPos(),m_aVScroll.GetThumbPos())/*m_aScrollOffset*/; }
94*cdf0e10cSrcweir 		inline const OReportWindow&	getReportWindow() const { return m_aReportWindow; }
95*cdf0e10cSrcweir 		void					setTotalSize(sal_Int32 _nWidth ,sal_Int32 _nHeight);
96*cdf0e10cSrcweir 		inline Size				getTotalSize() const { return m_aTotalPixelSize; }
97*cdf0e10cSrcweir 		inline ScrollBar*		GetHScroll() { return &m_aHScroll; }
98*cdf0e10cSrcweir 		inline ScrollBar*		GetVScroll() { return &m_aVScroll; }
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir 		// forwards
101*cdf0e10cSrcweir 		void 					SetMode( DlgEdMode _eMode );
102*cdf0e10cSrcweir 		void					SetInsertObj( sal_uInt16 eObj,const ::rtl::OUString& _sShapeType = ::rtl::OUString());
103*cdf0e10cSrcweir 		rtl::OUString           GetInsertObjString() const;
104*cdf0e10cSrcweir         void                    setGridSnap(sal_Bool bOn);
105*cdf0e10cSrcweir         void                    setDragStripes(sal_Bool bOn);
106*cdf0e10cSrcweir 		/** copies the current selection in this section
107*cdf0e10cSrcweir 		*/
108*cdf0e10cSrcweir 		void Copy();
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir 		/**	returns if paste is allowed
111*cdf0e10cSrcweir 		*
112*cdf0e10cSrcweir 		* \return <TRUE/> if paste is allowed
113*cdf0e10cSrcweir 		*/
114*cdf0e10cSrcweir 		sal_Bool IsPasteAllowed() const;
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir 		/** paste a new control in this section
117*cdf0e10cSrcweir 		*/
118*cdf0e10cSrcweir 		void Paste();
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 		/** Deletes the current selection in this section
121*cdf0e10cSrcweir 		*
122*cdf0e10cSrcweir 		*/
123*cdf0e10cSrcweir 		void Delete();
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 		/** All objects will be marked.
126*cdf0e10cSrcweir 		*/
127*cdf0e10cSrcweir 		void SelectAll(const sal_uInt16 _nObjectType);
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir         /** returns <TRUE/> when a object is marked
130*cdf0e10cSrcweir         */
131*cdf0e10cSrcweir         sal_Bool HasSelection() const;
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir 		/** removes the section at the given position.
134*cdf0e10cSrcweir 		*
135*cdf0e10cSrcweir 		* \param _nPosition Zero based.
136*cdf0e10cSrcweir 		*/
137*cdf0e10cSrcweir 		void					removeSection(sal_uInt16 _nPosition);
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 		/** adds a new section at position _nPosition.
140*cdf0e10cSrcweir 			If the section is <NULL/> nothing happens.
141*cdf0e10cSrcweir 			If the position is grater than the current elements, the section will be appended.
142*cdf0e10cSrcweir 		*/
143*cdf0e10cSrcweir 		void					addSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection
144*cdf0e10cSrcweir 									,const ::rtl::OUString& _sColorEntry
145*cdf0e10cSrcweir 									,sal_uInt16 _nPosition = USHRT_MAX);
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 		sal_uInt16					getSectionCount() const;
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 		/** turns the grid on or off
150*cdf0e10cSrcweir 		*
151*cdf0e10cSrcweir 		* \param _bVisible
152*cdf0e10cSrcweir 		*/
153*cdf0e10cSrcweir 		void					toggleGrid(sal_Bool _bVisible);
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 		/** unmark all objects on the views without the given one.
156*cdf0e10cSrcweir 		*
157*cdf0e10cSrcweir 		* @param _pSectionView The view where the objects should not be unmarked.
158*cdf0e10cSrcweir 		*/
159*cdf0e10cSrcweir 		void					unmarkAllObjects(OSectionView* _pSectionView);
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 		/** shows or hides the ruler.
162*cdf0e10cSrcweir 		*/
163*cdf0e10cSrcweir 		void					showRuler(sal_Bool _bShow);
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 		/** calculate the max width of the markers
166*cdf0e10cSrcweir 		*
167*cdf0e10cSrcweir 		* @param _bWithEnd	if <TRUE/> the end marker will be used for calculation as well otherwise not.
168*cdf0e10cSrcweir 		* \return the max width
169*cdf0e10cSrcweir 		*/
170*cdf0e10cSrcweir 		sal_Int32				getMaxMarkerWidth(sal_Bool _bWithEnd) const;
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 		/** checks if the keycode is known by the child windows
173*cdf0e10cSrcweir 			@param	_rCode	the keycode
174*cdf0e10cSrcweir 			@return <TRUE/> if the keycode is handled otherwise <FALSE/>
175*cdf0e10cSrcweir 		*/
176*cdf0e10cSrcweir 		sal_Bool				handleKeyEvent(const KeyEvent& _rEvent);
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 		/** the the section as marked or not marked
179*cdf0e10cSrcweir 			@param	_pSectionView	the section where to set the marked flag
180*cdf0e10cSrcweir 			@param	_bMark	the marked flag
181*cdf0e10cSrcweir 		*/
182*cdf0e10cSrcweir 		void					setMarked(OSectionView* _pSectionView,sal_Bool _bMark);
183*cdf0e10cSrcweir         void			        setMarked(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection,sal_Bool _bMark);
184*cdf0e10cSrcweir         void			        setMarked(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> >& _xShape,sal_Bool _bMark);
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir         // IMarkedSection
187*cdf0e10cSrcweir 		::boost::shared_ptr<OSectionWindow> getMarkedSection(NearSectionAccess nsa = CURRENT) const;
188*cdf0e10cSrcweir         ::boost::shared_ptr<OSectionWindow> getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const;
189*cdf0e10cSrcweir         virtual void markSection(const sal_uInt16 _nPos);
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir         /** fills the positions of all collapsed sections.
193*cdf0e10cSrcweir         *
194*cdf0e10cSrcweir         * \param _rCollapsedPositions Out parameter which holds afterwards all positions of the collapsed sections.
195*cdf0e10cSrcweir         */
196*cdf0e10cSrcweir         void fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const;
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir         /** collpase all sections given by their position
199*cdf0e10cSrcweir         *
200*cdf0e10cSrcweir         * \param _aCollpasedSections The position of the sections which should be collapsed.
201*cdf0e10cSrcweir         */
202*cdf0e10cSrcweir         void collapseSections(const com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& _aCollpasedSections);
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir         /** align all marked objects in all sections
205*cdf0e10cSrcweir         *
206*cdf0e10cSrcweir         * \param eHor
207*cdf0e10cSrcweir         * \param eVert
208*cdf0e10cSrcweir         * \param bBoundRects
209*cdf0e10cSrcweir         */
210*cdf0e10cSrcweir         void alignMarkedObjects(sal_Int32 _nControlModification, bool _bAlignAtSection, bool bBoundRects = false);
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir         sal_uInt32 getMarkedObjectCount() const;
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir         /** zoom the ruler and view windows
215*cdf0e10cSrcweir         */
216*cdf0e10cSrcweir         void zoom(const Fraction& _aZoom);
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir         /** fills the vector with all selected control models
219*cdf0e10cSrcweir             /param  _rSelection The vector will be filled and will not be cleared before.
220*cdf0e10cSrcweir         */
221*cdf0e10cSrcweir         void fillControlModelSelection(::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& _rSelection) const;
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir         /** calculates the zoom factor.
224*cdf0e10cSrcweir             @param  _eType  which kind of zoom is needed
225*cdf0e10cSrcweir         */
226*cdf0e10cSrcweir         sal_uInt16 getZoomFactor(SvxZoomType _eType) const;
227*cdf0e10cSrcweir 	};
228*cdf0e10cSrcweir }
229*cdf0e10cSrcweir #endif // RPTUI_SCROLLHELPER_HXX
230