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 INCLUDED_REPORTDESIGN_SOURCE_UI_INC_DESIGNVIEW_HXX
20 #define INCLUDED_REPORTDESIGN_SOURCE_UI_INC_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 <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"
48 namespace vcl
{ class Window
; }
53 class OReportController
;
55 class OAddFieldWindow
;
59 class ODesignView
: public dbaui::ODataView
, public SfxBroadcaster
, public IMarkedSection
62 VclPtr
<SplitWindow
> m_aSplitWin
;
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
;
73 Point m_aScrollOffset
;
75 sal_uInt16 m_nCurrentPosition
;
78 Size m_aGridSizeCoarse
;
85 DECL_LINK_TYPED(MarkTimeout
, Idle
*, void);
86 DECL_LINK( SplitHdl
, void* );
88 void ImplInitSettings();
90 ODesignView(ODesignView
&) SAL_DELETED_FUNCTION
;
91 void operator =(ODesignView
&) SAL_DELETED_FUNCTION
;
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
;
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
;
106 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
107 virtual bool PreNotify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
108 virtual void GetFocus() SAL_OVERRIDE
;
110 virtual void initialize() SAL_OVERRIDE
;
112 inline OReportController
& getController() const { return m_rReportController
; }
114 void SetMode( DlgEdMode m_eMode
);
115 void SetInsertObj( sal_uInt16 eObj
,const OUString
& _sShapeType
= OUString());
116 sal_uInt16
GetInsertObj() const { return m_eActObj
;}
117 OUString
GetInsertObjString() const;
118 DlgEdMode
GetMode() const { return m_eMode
; }
120 /** cuts the current selection in this section
124 /** copies the current selection in this section
128 /** returns if paste is allowed
130 * \return <TRUE/> if paste is allowed
132 bool IsPasteAllowed() const;
134 /** paste a new control in this section
138 /** Deletes the current selection in this section
143 /** align all marked objects in all sections
145 void alignMarkedObjects(sal_Int32 _nControlModification
, bool _bAlignAtSection
, bool bBoundRects
= false);
147 /** All objects will be marked.
149 void SelectAll(const sal_uInt16 _nObjectType
);
151 /// checks if a selection exists
152 bool HasSelection() const;
154 void UpdatePropertyBrowserDelayed(OSectionView
& _rView
);
156 sal_uInt16
getSectionCount() const;
158 /** removes the section at the given position.
160 * \param _nPosition Zero based.
162 void removeSection(sal_uInt16 _nPosition
);
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.
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
);
172 inline Size
getGridSizeCoarse() const { return m_aGridSizeCoarse
; }
173 inline Size
getGridSizeFine() const { return m_aGridSizeFine
; }
174 inline bool isGridSnap() const { return m_bGridSnap
; }
175 void setGridSnap(bool bOn
);
176 void setDragStripes(bool bOn
);
177 /** turns the grid on or off
179 * \param _bGridVisible
181 void toggleGrid(bool _bGridVisible
);
183 void togglePropertyBrowser(bool _bToogleOn
);
185 bool isAddFieldVisible() const;
186 void toggleAddField();
188 bool isReportExplorerVisible() const;
189 void toggleReportExplorer();
191 /** shows or hides the ruler.
193 void showRuler(bool _bShow
);
195 /** unmark all objects on the views without the given one.
197 * @param _pSectionView The view where the objects should not be unmarked.
199 void unmarkAllObjects(OSectionView
* _pSectionView
);
201 /** triggers the property browser with the section
202 @param _xReportComponent the report component
204 void showProperties( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _xReportComponent
);
205 ::com::sun::star::uno::Any
getCurrentlyShownProperty() const;
207 /** returns the current section or the detail section if no section was selected previously
209 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getCurrentSection() const;
211 /** returns the current control report model or <NULL/>
213 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
> getCurrentControlModel() const;
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
;
220 /** fills the positions of all collapsed sections.
222 * \param _rCollapsedPositions Out parameter which holds afterwards all positions of the collapsed sections.
224 void fillCollapsedSections(::std::vector
<sal_uInt16
>& _rCollapsedPositions
) const;
226 /** collpase all sections given by their position
228 * \param _aCollpasedSections The position of the sections which should be collapsed.
230 void collapseSections(const com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& _aCollpasedSections
);
232 OUString
getCurrentPage() const;
233 void setCurrentPage(const OUString
& _sLastActivePage
);
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/>
239 bool handleKeyEvent(const KeyEvent
& _rEvent
);
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
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
);
248 /** returns if the view handles the event by itself
250 * \param _nId the command id
251 * \return <FALSE/> is the event is not handled by the view otherwise <TRUE/>
253 bool isHandleEvent(sal_uInt16 _nId
) const;
255 sal_uInt32
getMarkedObjectCount() const;
257 /** zoom the ruler and view windows
259 void zoom(const Fraction
& _aZoom
);
261 /** fills the vector with all selected control models
262 /param _rSelection The vector will be filled and will not be cleared before.
264 void fillControlModelSelection(::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> >& _rSelection
) const;
266 /** returns the selected field from the add field dialog
268 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> getSelectedFieldDescriptors();
270 /** calculates the zoom factor.
271 @param _eType which kind of zoom is needed
273 sal_uInt16
getZoomFactor(SvxZoomType _eType
) const;
278 #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_INC_DESIGNVIEW_HXX
280 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */