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