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