sync master with lastest vba changes
[ooovba.git] / reportdesign / source / ui / inc / ScrollHelper.hxx
blob147cc6ca6773b140371f3cc79707ade1b0408e8c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ScrollHelper.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef RPTUI_SCROLLHELPER_HXX
31 #define RPTUI_SCROLLHELPER_HXX
33 #include <vcl/scrbar.hxx>
34 #include <com/sun/star/report/XSection.hpp>
35 #include <comphelper/propmultiplex.hxx>
36 #include "ReportDefines.hxx"
37 #include <svtools/colorcfg.hxx>
38 #include <svx/svdedtv.hxx>
39 #include "cppuhelper/basemutex.hxx"
40 #include <rtl/ref.hxx>
41 #include <boost/shared_ptr.hpp>
42 #include <vcl/dockwin.hxx>
43 #include <MarkedSection.hxx>
44 #include "ReportWindow.hxx"
46 class SdrView;
47 namespace rptui
49 class ODesignView;
50 class OReportWindow;
51 class OSectionView;
52 class OReportSection;
53 class OReportModel;
55 /** This class defines the scrollable area of the report design. It includes
56 the h-ruler and the sections, and end marker. Not the start marker.
58 typedef Window OScrollWindowHelper_BASE;
59 class OScrollWindowHelper : public ::cppu::BaseMutex
60 , public OScrollWindowHelper_BASE/*TabPage*/
61 , public ::comphelper::OPropertyChangeListener
62 , public IMarkedSection
64 private:
65 ScrollBar m_aHScroll;
66 ScrollBar m_aVScroll;
67 ScrollBarBox m_aCornerWin; // window in the bottom right corner
68 Size m_aTotalPixelSize;
69 ODesignView* m_pParent;
70 OReportWindow m_aReportWindow;
71 ::rtl::Reference<comphelper::OPropertyChangeMultiplexer >
72 m_pReportDefintionMultiPlexer; // listener for property changes
74 DECL_LINK( ScrollHdl, ScrollBar*);
75 Size ResizeScrollBars();
76 void ImplInitSettings();
77 void impl_initScrollBar( ScrollBar& _rScrollBar ) const;
79 OScrollWindowHelper(OScrollWindowHelper&);
80 void operator =(OScrollWindowHelper&);
81 protected:
82 virtual void DataChanged( const DataChangedEvent& rDCEvt );
83 // window
84 virtual void Resize();
85 virtual long Notify( NotifyEvent& rNEvt );
86 // OPropertyChangeListener
87 virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& _rEvent) throw( ::com::sun::star::uno::RuntimeException);
88 public:
89 OScrollWindowHelper( ODesignView* _pReportDesignView);
90 virtual ~OScrollWindowHelper();
92 /** late ctor
94 void initialize();
96 inline Point getThumbPos() const { return Point(m_aHScroll.GetThumbPos(),m_aVScroll.GetThumbPos())/*m_aScrollOffset*/; }
97 inline const OReportWindow& getReportWindow() const { return m_aReportWindow; }
98 void setTotalSize(sal_Int32 _nWidth ,sal_Int32 _nHeight);
99 inline Size getTotalSize() const { return m_aTotalPixelSize; }
100 inline ScrollBar* GetHScroll() { return &m_aHScroll; }
101 inline ScrollBar* GetVScroll() { return &m_aVScroll; }
103 // forwards
104 void SetMode( DlgEdMode _eMode );
105 void SetInsertObj( USHORT eObj,const ::rtl::OUString& _sShapeType = ::rtl::OUString());
106 rtl::OUString GetInsertObjString() const;
107 void setGridSnap(BOOL bOn);
108 void setDragStripes(BOOL bOn);
109 BOOL isDragStripes() const;
110 /** copies the current selection in this section
112 void Copy();
114 /** returns if paste is allowed
116 * \return <TRUE/> if paste is allowed
118 BOOL IsPasteAllowed();
120 /** paste a new control in this section
122 void Paste();
124 /** Deletes the current selection in this section
127 void Delete();
129 /** All objects will be marked.
131 void SelectAll(const sal_uInt16 _nObjectType);
133 /** returns <TRUE/> when a object is marked
135 BOOL HasSelection();
137 /** removes the section at the given position.
139 * \param _nPosition Zero based.
141 void removeSection(USHORT _nPosition);
143 /** adds a new section at position _nPosition.
144 If the section is <NULL/> nothing happens.
145 If the position is grater than the current elements, the section will be appended.
147 void addSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection
148 ,const ::rtl::OUString& _sColorEntry
149 ,USHORT _nPosition = USHRT_MAX);
151 USHORT getSectionCount() const;
153 /** turns the grid on or off
155 * \param _bVisible
157 void toggleGrid(sal_Bool _bVisible);
159 /** unmark all objects on the views without the given one.
161 * @param _pSectionView The view where the objects should not be unmarked.
163 void unmarkAllObjects(OSectionView* _pSectionView);
165 /** shows or hides the ruler.
167 void showRuler(sal_Bool _bShow);
169 /** calculate the max width of the markers
171 * @param _bWithEnd if <TRUE/> the end marker will be used for calculation as well otherwise not.
172 * \return the max width
174 sal_Int32 getMaxMarkerWidth(sal_Bool _bWithEnd) const;
176 /** checks if the keycode is known by the child windows
177 @param _rCode the keycode
178 @return <TRUE/> if the keycode is handled otherwise <FALSE/>
180 sal_Bool handleKeyEvent(const KeyEvent& _rEvent);
182 /** the the section as marked or not marked
183 @param _pSectionView the section where to set the marked flag
184 @param _bMark the marked flag
186 void setMarked(OSectionView* _pSectionView,sal_Bool _bMark);
187 void setMarked(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection,sal_Bool _bMark);
188 void setMarked(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> >& _xShape,sal_Bool _bMark);
190 // IMarkedSection
191 ::boost::shared_ptr<OSectionWindow> getMarkedSection(NearSectionAccess nsa = CURRENT) const;
192 virtual void markSection(const sal_uInt16 _nPos);
195 /** fills the positions of all collapsed sections.
197 * \param _rCollapsedPositions Out parameter which holds afterwards all positions of the collapsed sections.
199 void fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const;
201 /** collpase all sections given by their position
203 * \param _aCollpasedSections The position of the sections which should be collapsed.
205 void collapseSections(const com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& _aCollpasedSections);
207 /** align all marked objects in all sections
209 * \param eHor
210 * \param eVert
211 * \param bBoundRects
213 void alignMarkedObjects(sal_Int32 _nControlModification, bool _bAlignAtSection, bool bBoundRects = false);
215 sal_uInt32 getMarkedObjectCount() const;
217 /** zoom the ruler and view windows
219 void zoom(const Fraction& _aZoom);
221 /** fills the vector with all selected control models
222 /param _rSelection The vector will be filled and will not be cleared before.
224 void fillControlModelSelection(::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& _rSelection) const;
226 /** calculates the zoom factor.
227 @param _eType which kind of zoom is needed
229 sal_uInt16 getZoomFactor(SvxZoomType _eType) const;
232 #endif // RPTUI_SCROLLHELPER_HXX