1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef RPTUI_DESIGNVIEW_HXX
20 #define RPTUI_DESIGNVIEW_HXX
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"
53 class OReportController
;
55 class OAddFieldWindow
;
57 //==================================================================
58 //==================================================================
59 class ODesignView
: public dbaui::ODataView
, public SfxBroadcaster
, public IMarkedSection
62 SplitWindow m_aSplitWin
;
64 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> m_xReportComponent
;
65 OReportController
& m_rReportController
;
66 OScrollWindowHelper m_aScrollWindow
;
69 OAddFieldWindow
* m_pAddField
;
70 OSectionView
* m_pCurrentView
;
71 ONavigator
* m_pReportExplorer
;
73 Point m_aScrollOffset
;
75 sal_uInt16 m_nCurrentPosition
;
77 sal_Bool m_bFirstDraw
;
78 Size m_aGridSizeCoarse
;
80 sal_Bool m_bGridVisible
;
85 DECL_LINK(MarkTimeout
, void *);
86 DECL_LINK( SplitHdl
, void* );
88 void ImplInitSettings();
90 ODesignView(ODesignView
&);
91 void operator =(ODesignView
&);
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
);
99 ODesignView(Window
* pParent
,
100 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>&,
101 OReportController
& _rController
);
102 virtual ~ODesignView();
105 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
106 virtual long PreNotify( NotifyEvent
& rNEvt
);
107 virtual void GetFocus();
109 // set the view readonly or not
110 virtual void setReadOnly(sal_Bool _bReadOnly
);
112 virtual void initialize();
114 inline OReportController
& getController() const { return m_rReportController
; }
116 void SetMode( DlgEdMode m_eMode
);
117 void SetInsertObj( sal_uInt16 eObj
,const OUString
& _sShapeType
= OUString());
118 sal_uInt16
GetInsertObj() const;
119 OUString
GetInsertObjString() const;
120 DlgEdMode
GetMode() const { return m_eMode
; }
122 /** cuts the current selection in this section
126 /** copies the current selection in this section
130 /** returns if paste is allowed
132 * \return <TRUE/> if paste is allowed
134 sal_Bool
IsPasteAllowed() const;
136 /** paste a new control in this section
140 /** Deletes the current selection in this section
145 /** align all marked objects in all sections
147 void alignMarkedObjects(sal_Int32 _nControlModification
, bool _bAlignAtSection
, bool bBoundRects
= false);
149 /** All objects will be marked.
151 void SelectAll(const sal_uInt16 _nObjectType
);
153 /// checks if a selection exists
154 sal_Bool
HasSelection() const;
156 void UpdatePropertyBrowserDelayed(OSectionView
& _rView
);
158 sal_uInt16
getSectionCount() const;
160 /** removes the section at the given position.
162 * \param _nPosition Zero based.
164 void removeSection(sal_uInt16 _nPosition
);
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.
170 void addSection(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>& _xSection
171 ,const OUString
& _sColorEntry
172 ,sal_uInt16 _nPosition
= USHRT_MAX
);
174 inline Size
getGridSizeCoarse() const { return m_aGridSizeCoarse
; }
175 inline Size
getGridSizeFine() const { return m_aGridSizeFine
; }
176 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
181 * \param _bGridVisible
183 void toggleGrid(sal_Bool _bGridVisible
);
185 void togglePropertyBrowser(sal_Bool _bToogleOn
);
187 sal_Bool
isAddFieldVisible() const;
188 void toggleAddField();
190 sal_Bool
isReportExplorerVisible() const;
191 void toggleReportExplorer();
193 /** shows or hides the ruler.
195 void showRuler(sal_Bool _bShow
);
197 /** unmark all objects on the views without the given one.
199 * @param _pSectionView The view where the objects should not be unmarked.
201 void unmarkAllObjects(OSectionView
* _pSectionView
);
203 /** triggers the property browser with the section
204 @param _xReportComponent the report component
206 void showProperties( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _xReportComponent
);
207 ::com::sun::star::uno::Any
getCurrentlyShownProperty() const;
209 /** returns the current section or the detail section if no section was selected previously
211 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getCurrentSection() const;
213 /** returns the current control report model or <NULL/>
215 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
> getCurrentControlModel() const;
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
);
222 /** fills the positions of all collapsed sections.
224 * \param _rCollapsedPositions Out parameter which holds afterwards all positions of the collapsed sections.
226 void fillCollapsedSections(::std::vector
<sal_uInt16
>& _rCollapsedPositions
) const;
228 /** collpase all sections given by their position
230 * \param _aCollpasedSections The position of the sections which should be collapsed.
232 void collapseSections(const com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& _aCollpasedSections
);
234 OUString
getCurrentPage() const;
235 void setCurrentPage(const OUString
& _sLastActivePage
);
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/>
241 sal_Bool
handleKeyEvent(const KeyEvent
& _rEvent
);
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
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
);
250 /** returns if the view handles the event by itself
252 * \param _nId the command id
253 * \return <FALSE/> is the event is not handled by the view otherwise <TRUE/>
255 sal_Bool
isHandleEvent(sal_uInt16 _nId
) const;
257 sal_uInt32
getMarkedObjectCount() const;
259 /** zoom the ruler and view windows
261 void zoom(const Fraction
& _aZoom
);
263 /** fills the vector with all selected control models
264 /param _rSelection The vector will be filled and will not be cleared before.
266 void fillControlModelSelection(::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> >& _rSelection
) const;
268 /** returns the selected field from the add field dialog
270 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> getSelectedFieldDescriptors();
272 /** calculates the zoom factor.
273 @param _eType which kind of zoom is needed
275 sal_uInt16
getZoomFactor(SvxZoomType _eType
) const;
277 //==================================================================
279 //==================================================================
280 #endif // RPTUI_DESIGNVIEW_HXX
282 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */