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