Use o3tl::convert in Math
[LibreOffice.git] / reportdesign / source / ui / inc / ScrollHelper.hxx
blobeab5c7dd3b8bd56c091f53bf641011335f0f3acb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_SCROLLHELPER_HXX
20 #define INCLUDED_REPORTDESIGN_SOURCE_UI_INC_SCROLLHELPER_HXX
22 #include <vcl/scrbar.hxx>
23 #include <com/sun/star/report/XSection.hpp>
24 #include <comphelper/propmultiplex.hxx>
25 #include "ReportDefines.hxx"
26 #include <cppuhelper/basemutex.hxx>
27 #include <rtl/ref.hxx>
28 #include "MarkedSection.hxx"
29 #include "ReportWindow.hxx"
31 namespace rptui
33 class ODesignView;
34 class OReportWindow;
35 class OSectionView;
37 /** This class defines the scrollable area of the report design. It includes
38 the h-ruler and the sections, and end marker. Not the start marker.
40 typedef vcl::Window OScrollWindowHelper_BASE;
41 class OScrollWindowHelper : public ::cppu::BaseMutex
42 , public OScrollWindowHelper_BASE/*TabPage*/
43 , public ::comphelper::OPropertyChangeListener
44 , public IMarkedSection
46 private:
47 VclPtr<ScrollBar> m_aHScroll;
48 VclPtr<ScrollBar> m_aVScroll;
49 VclPtr<ScrollBarBox> m_aCornerWin; // window in the bottom right corner
50 Size m_aTotalPixelSize;
51 VclPtr<ODesignView> m_pParent;
52 VclPtr<OReportWindow> m_aReportWindow;
53 ::rtl::Reference<comphelper::OPropertyChangeMultiplexer >
54 m_pReportDefinitionMultiPlexer; // listener for property changes
56 DECL_LINK( ScrollHdl, ScrollBar*, void);
57 Size ResizeScrollBars();
58 void ImplInitSettings();
59 void impl_initScrollBar( ScrollBar& _rScrollBar ) const;
61 OScrollWindowHelper(OScrollWindowHelper const &) = delete;
62 void operator =(OScrollWindowHelper const &) = delete;
63 protected:
64 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
65 // window
66 virtual void Resize() override;
67 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
68 // OPropertyChangeListener
69 virtual void _propertyChanged(const css::beans::PropertyChangeEvent& _rEvent) override;
70 public:
71 OScrollWindowHelper( ODesignView* _pReportDesignView);
72 virtual ~OScrollWindowHelper() override;
73 virtual void dispose() override;
75 /** late ctor
77 void initialize();
79 Point getThumbPos() const { return Point(m_aHScroll->GetThumbPos(),m_aVScroll->GetThumbPos())/*m_aScrollOffset*/; }
80 void setTotalSize(sal_Int32 _nWidth, sal_Int32 _nHeight);
81 const Size& getTotalSize() const { return m_aTotalPixelSize; }
82 ScrollBar& GetHScroll() { return *m_aHScroll; }
83 ScrollBar& GetVScroll() { return *m_aVScroll; }
85 // forwards
86 void SetMode( DlgEdMode _eMode );
87 void SetInsertObj(SdrObjKind eObj, const OUString& _sShapeType);
88 OUString const & GetInsertObjString() const;
89 void setGridSnap(bool bOn);
90 void setDragStripes(bool bOn);
91 /** copies the current selection in this section
93 void Copy();
95 /** returns if paste is allowed
97 * \return <TRUE/> if paste is allowed
99 bool IsPasteAllowed() const;
101 /** paste a new control in this section
103 void Paste();
105 /** Deletes the current selection in this section
108 void Delete();
110 /** All objects will be marked.
112 void SelectAll(const sal_uInt16 _nObjectType);
114 /** returns <TRUE/> when an object is marked
116 bool HasSelection() const;
118 /** removes the section at the given position.
120 * \param _nPosition Zero based.
122 void removeSection(sal_uInt16 _nPosition);
124 /** adds a new section at position _nPosition.
125 If the section is <NULL/> nothing happens.
126 If the position is grater than the current elements, the section will be appended.
128 void addSection(const css::uno::Reference< css::report::XSection >& _xSection
129 ,const OUString& _sColorEntry
130 ,sal_uInt16 _nPosition);
132 sal_uInt16 getSectionCount() const;
134 /** turns the grid on or off
136 * \param _bVisible
138 void toggleGrid(bool _bVisible);
140 /** unmark all objects on the views.
142 void unmarkAllObjects();
144 /** shows or hides the ruler.
146 void showRuler(bool _bShow);
148 /** calculate the max width of the markers
150 * The end marker will not be used for calculation.
151 * \return the max width
153 sal_Int32 getMaxMarkerWidth() const;
155 /** checks if the keycode is known by the child windows
156 @param _rCode the keycode
157 @return <TRUE/> if the keycode is handled otherwise <FALSE/>
159 bool handleKeyEvent(const KeyEvent& _rEvent);
161 /** the section as marked or not marked
162 @param _pSectionView the section where to set the marked flag
163 @param _bMark the marked flag
165 void setMarked(OSectionView const * _pSectionView, bool _bMark);
166 void setMarked(const css::uno::Reference< css::report::XSection>& _xSection, bool _bMark);
167 void setMarked(const css::uno::Sequence< css::uno::Reference< css::report::XReportComponent> >& _xShape, bool _bMark);
169 // IMarkedSection
170 OSectionWindow* getMarkedSection(NearSectionAccess nsa = CURRENT) const override;
171 OSectionWindow* getSectionWindow(const css::uno::Reference< css::report::XSection>& _xSection) const;
172 virtual void markSection(const sal_uInt16 _nPos) override;
175 /** fills the positions of all collapsed sections.
177 * \param _rCollapsedPositions Out parameter which holds afterwards all positions of the collapsed sections.
179 void fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const;
181 /** collapse all sections given by their position
183 * \param _aCollapsedSections The position of the sections which should be collapsed.
185 void collapseSections(const css::uno::Sequence< css::beans::PropertyValue>& _aCollapsedSections);
187 /** align all marked objects in all sections
189 void alignMarkedObjects(ControlModification _nControlModification, bool _bAlignAtSection);
191 sal_uInt32 getMarkedObjectCount() const;
193 /** zoom the ruler and view windows
195 void zoom(const Fraction& _aZoom);
197 /** fills the vector with all selected control models
198 /param _rSelection The vector will be filled and will not be cleared before.
200 void fillControlModelSelection(::std::vector< css::uno::Reference< css::uno::XInterface > >& _rSelection) const;
202 /** calculates the zoom factor.
203 @param _eType which kind of zoom is needed
205 sal_uInt16 getZoomFactor(SvxZoomType _eType) const;
208 #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_INC_SCROLLHELPER_HXX
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */