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