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