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_SCROLLHELPER_HXX
20 : #define INCLUDED_REPORTDESIGN_SOURCE_UI_INC_SCROLLHELPER_HXX
21 :
22 : #include <vcl/scrbar.hxx>
23 : #include <com/sun/star/report/XSection.hpp>
24 : #include <comphelper/propmultiplex.hxx>
25 : #include "ReportDefines.hxx"
26 : #include <svtools/colorcfg.hxx>
27 : #include <svx/svdedtv.hxx>
28 : #include <cppuhelper/basemutex.hxx>
29 : #include <rtl/ref.hxx>
30 : #include <boost/shared_ptr.hpp>
31 : #include <vcl/dockwin.hxx>
32 : #include "MarkedSection.hxx"
33 : #include "ReportWindow.hxx"
34 :
35 : namespace rptui
36 : {
37 : class ODesignView;
38 : class OReportWindow;
39 : class OSectionView;
40 :
41 : /** This class defines the scrollable area of the report design. It includes
42 : the h-ruler and the sections, and end marker. Not the start marker.
43 : */
44 : typedef vcl::Window OScrollWindowHelper_BASE;
45 : class OScrollWindowHelper : public ::cppu::BaseMutex
46 : , public OScrollWindowHelper_BASE/*TabPage*/
47 : , public ::comphelper::OPropertyChangeListener
48 : , public IMarkedSection
49 : {
50 : private:
51 : VclPtr<ScrollBar> m_aHScroll;
52 : VclPtr<ScrollBar> m_aVScroll;
53 : VclPtr<ScrollBarBox> m_aCornerWin; // window in the bottom right corner
54 : Size m_aTotalPixelSize;
55 : VclPtr<ODesignView> m_pParent;
56 : VclPtr<OReportWindow> m_aReportWindow;
57 : ::rtl::Reference<comphelper::OPropertyChangeMultiplexer >
58 : m_pReportDefinitionMultiPlexer; // listener for property changes
59 :
60 : DECL_LINK( ScrollHdl, ScrollBar*);
61 : Size ResizeScrollBars();
62 : void ImplInitSettings();
63 : void impl_initScrollBar( ScrollBar& _rScrollBar ) const;
64 :
65 : OScrollWindowHelper(OScrollWindowHelper&) SAL_DELETED_FUNCTION;
66 : void operator =(OScrollWindowHelper&) SAL_DELETED_FUNCTION;
67 : protected:
68 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
69 : // window
70 : virtual void Resize() SAL_OVERRIDE;
71 : virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
72 : // OPropertyChangeListener
73 : virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& _rEvent) throw( ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
74 : public:
75 : OScrollWindowHelper( ODesignView* _pReportDesignView);
76 : virtual ~OScrollWindowHelper();
77 : virtual void dispose() SAL_OVERRIDE;
78 :
79 : /** late ctor
80 : */
81 : void initialize();
82 :
83 0 : inline Point getThumbPos() const { return Point(m_aHScroll->GetThumbPos(),m_aVScroll->GetThumbPos())/*m_aScrollOffset*/; }
84 : inline const OReportWindow& getReportWindow() const { return *m_aReportWindow.get(); }
85 : void setTotalSize(sal_Int32 _nWidth, sal_Int32 _nHeight);
86 0 : inline Size getTotalSize() const { return m_aTotalPixelSize; }
87 0 : inline ScrollBar& GetHScroll() { return *m_aHScroll.get(); }
88 0 : inline ScrollBar& GetVScroll() { return *m_aVScroll.get(); }
89 :
90 : // forwards
91 : void SetMode( DlgEdMode _eMode );
92 : void SetInsertObj( sal_uInt16 eObj,const OUString& _sShapeType = OUString());
93 : OUString GetInsertObjString() const;
94 : void setGridSnap(bool bOn);
95 : void setDragStripes(bool bOn);
96 : /** copies the current selection in this section
97 : */
98 : void Copy();
99 :
100 : /** returns if paste is allowed
101 : *
102 : * \return <TRUE/> if paste is allowed
103 : */
104 : bool IsPasteAllowed() const;
105 :
106 : /** paste a new control in this section
107 : */
108 : void Paste();
109 :
110 : /** Deletes the current selection in this section
111 : *
112 : */
113 : void Delete();
114 :
115 : /** All objects will be marked.
116 : */
117 : void SelectAll(const sal_uInt16 _nObjectType);
118 :
119 : /** returns <TRUE/> when a object is marked
120 : */
121 : bool HasSelection() const;
122 :
123 : /** removes the section at the given position.
124 : *
125 : * \param _nPosition Zero based.
126 : */
127 : void removeSection(sal_uInt16 _nPosition);
128 :
129 : /** adds a new section at position _nPosition.
130 : If the section is <NULL/> nothing happens.
131 : If the position is grater than the current elements, the section will be appended.
132 : */
133 : void addSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection
134 : ,const OUString& _sColorEntry
135 : ,sal_uInt16 _nPosition = USHRT_MAX);
136 :
137 : sal_uInt16 getSectionCount() const;
138 :
139 : /** turns the grid on or off
140 : *
141 : * \param _bVisible
142 : */
143 : void toggleGrid(bool _bVisible);
144 :
145 : /** unmark all objects on the views without the given one.
146 : *
147 : * @param _pSectionView The view where the objects should not be unmarked.
148 : */
149 : void unmarkAllObjects(OSectionView* _pSectionView);
150 :
151 : /** shows or hides the ruler.
152 : */
153 : void showRuler(bool _bShow);
154 :
155 : /** calculate the max width of the markers
156 : *
157 : * @param _bWithEnd if <TRUE/> the end marker will be used for calculation as well otherwise not.
158 : * \return the max width
159 : */
160 : sal_Int32 getMaxMarkerWidth(bool _bWithEnd) const;
161 :
162 : /** checks if the keycode is known by the child windows
163 : @param _rCode the keycode
164 : @return <TRUE/> if the keycode is handled otherwise <FALSE/>
165 : */
166 : bool handleKeyEvent(const KeyEvent& _rEvent);
167 :
168 : /** the section as marked or not marked
169 : @param _pSectionView the section where to set the marked flag
170 : @param _bMark the marked flag
171 : */
172 : void setMarked(OSectionView* _pSectionView, bool _bMark);
173 : void setMarked(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection, bool _bMark);
174 : void setMarked(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> >& _xShape, bool _bMark);
175 :
176 : // IMarkedSection
177 : OSectionWindow* getMarkedSection(NearSectionAccess nsa = CURRENT) const SAL_OVERRIDE;
178 : OSectionWindow* getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const;
179 : virtual void markSection(const sal_uInt16 _nPos) SAL_OVERRIDE;
180 :
181 :
182 : /** fills the positions of all collapsed sections.
183 : *
184 : * \param _rCollapsedPositions Out parameter which holds afterwards all positions of the collapsed sections.
185 : */
186 : void fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const;
187 :
188 : /** collpase all sections given by their position
189 : *
190 : * \param _aCollpasedSections The position of the sections which should be collapsed.
191 : */
192 : void collapseSections(const com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& _aCollpasedSections);
193 :
194 : /** align all marked objects in all sections
195 : *
196 : * \param eHor
197 : * \param eVert
198 : * \param bBoundRects
199 : */
200 : void alignMarkedObjects(sal_Int32 _nControlModification, bool _bAlignAtSection, bool bBoundRects = false);
201 :
202 : sal_uInt32 getMarkedObjectCount() const;
203 :
204 : /** zoom the ruler and view windows
205 : */
206 : void zoom(const Fraction& _aZoom);
207 :
208 : /** fills the vector with all selected control models
209 : /param _rSelection The vector will be filled and will not be cleared before.
210 : */
211 : void fillControlModelSelection(::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& _rSelection) const;
212 :
213 : /** calculates the zoom factor.
214 : @param _eType which kind of zoom is needed
215 : */
216 : sal_uInt16 getZoomFactor(SvxZoomType _eType) const;
217 : };
218 : }
219 : #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_INC_SCROLLHELPER_HXX
220 :
221 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|