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