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