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_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 <svtools/colorcfg.hxx>
27 #include <svx/svdedtv.hxx>
28 #include <cppuhelper/basemutex.hxx>
29 #include <rtl/ref.hxx>
30 #include <vcl/dockwin.hxx>
31 #include "MarkedSection.hxx"
32 #include "ReportWindow.hxx"
40 /** This class defines the scrollable area of the report design. It includes
41 the h-ruler and the sections, and end marker. Not the start marker.
43 typedef vcl::Window OScrollWindowHelper_BASE
;
44 class OScrollWindowHelper
: public ::cppu::BaseMutex
45 , public OScrollWindowHelper_BASE
/*TabPage*/
46 , public ::comphelper::OPropertyChangeListener
47 , public IMarkedSection
50 VclPtr
<ScrollBar
> m_aHScroll
;
51 VclPtr
<ScrollBar
> m_aVScroll
;
52 VclPtr
<ScrollBarBox
> m_aCornerWin
; // window in the bottom right corner
53 Size m_aTotalPixelSize
;
54 VclPtr
<ODesignView
> m_pParent
;
55 VclPtr
<OReportWindow
> m_aReportWindow
;
56 ::rtl::Reference
<comphelper::OPropertyChangeMultiplexer
>
57 m_pReportDefinitionMultiPlexer
; // listener for property changes
59 DECL_LINK( ScrollHdl
, ScrollBar
*, void);
60 Size
ResizeScrollBars();
61 void ImplInitSettings();
62 void impl_initScrollBar( ScrollBar
& _rScrollBar
) const;
64 OScrollWindowHelper(OScrollWindowHelper
const &) = delete;
65 void operator =(OScrollWindowHelper
const &) = delete;
67 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
69 virtual void Resize() override
;
70 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
71 // OPropertyChangeListener
72 virtual void _propertyChanged(const css::beans::PropertyChangeEvent
& _rEvent
) override
;
74 OScrollWindowHelper( ODesignView
* _pReportDesignView
);
75 virtual ~OScrollWindowHelper() override
;
76 virtual void dispose() override
;
82 Point
getThumbPos() const { return Point(m_aHScroll
->GetThumbPos(),m_aVScroll
->GetThumbPos())/*m_aScrollOffset*/; }
83 void setTotalSize(sal_Int32 _nWidth
, sal_Int32 _nHeight
);
84 const Size
& getTotalSize() const { return m_aTotalPixelSize
; }
85 ScrollBar
& GetHScroll() { return *m_aHScroll
.get(); }
86 ScrollBar
& GetVScroll() { return *m_aVScroll
.get(); }
89 void SetMode( DlgEdMode _eMode
);
90 void SetInsertObj( sal_uInt16 eObj
,const OUString
& _sShapeType
);
91 OUString
const & GetInsertObjString() const;
92 void setGridSnap(bool bOn
);
93 void setDragStripes(bool bOn
);
94 /** copies the current selection in this section
98 /** returns if paste is allowed
100 * \return <TRUE/> if paste is allowed
102 bool IsPasteAllowed() const;
104 /** paste a new control in this section
108 /** Deletes the current selection in this section
113 /** All objects will be marked.
115 void SelectAll(const sal_uInt16 _nObjectType
);
117 /** returns <TRUE/> when a object is marked
119 bool HasSelection() const;
121 /** removes the section at the given position.
123 * \param _nPosition Zero based.
125 void removeSection(sal_uInt16 _nPosition
);
127 /** adds a new section at position _nPosition.
128 If the section is <NULL/> nothing happens.
129 If the position is grater than the current elements, the section will be appended.
131 void addSection(const css::uno::Reference
< css::report::XSection
>& _xSection
132 ,const OUString
& _sColorEntry
133 ,sal_uInt16 _nPosition
);
135 sal_uInt16
getSectionCount() const;
137 /** turns the grid on or off
141 void toggleGrid(bool _bVisible
);
143 /** unmark all objects on the views.
145 void unmarkAllObjects();
147 /** shows or hides the ruler.
149 void showRuler(bool _bShow
);
151 /** calculate the max width of the markers
153 * The end marker will not be used for calculation.
154 * \return the max width
156 sal_Int32
getMaxMarkerWidth() const;
158 /** checks if the keycode is known by the child windows
159 @param _rCode the keycode
160 @return <TRUE/> if the keycode is handled otherwise <FALSE/>
162 bool handleKeyEvent(const KeyEvent
& _rEvent
);
164 /** the section as marked or not marked
165 @param _pSectionView the section where to set the marked flag
166 @param _bMark the marked flag
168 void setMarked(OSectionView
const * _pSectionView
, bool _bMark
);
169 void setMarked(const css::uno::Reference
< css::report::XSection
>& _xSection
, bool _bMark
);
170 void setMarked(const css::uno::Sequence
< css::uno::Reference
< css::report::XReportComponent
> >& _xShape
, bool _bMark
);
173 OSectionWindow
* getMarkedSection(NearSectionAccess nsa
= CURRENT
) const override
;
174 OSectionWindow
* getSectionWindow(const css::uno::Reference
< css::report::XSection
>& _xSection
) const;
175 virtual void markSection(const sal_uInt16 _nPos
) override
;
178 /** fills the positions of all collapsed sections.
180 * \param _rCollapsedPositions Out parameter which holds afterwards all positions of the collapsed sections.
182 void fillCollapsedSections(::std::vector
<sal_uInt16
>& _rCollapsedPositions
) const;
184 /** collpase all sections given by their position
186 * \param _aCollpasedSections The position of the sections which should be collapsed.
188 void collapseSections(const css::uno::Sequence
< css::beans::PropertyValue
>& _aCollpasedSections
);
190 /** align all marked objects in all sections
192 void alignMarkedObjects(ControlModification _nControlModification
, bool _bAlignAtSection
);
194 sal_uInt32
getMarkedObjectCount() const;
196 /** zoom the ruler and view windows
198 void zoom(const Fraction
& _aZoom
);
200 /** fills the vector with all selected control models
201 /param _rSelection The vector will be filled and will not be cleared before.
203 void fillControlModelSelection(::std::vector
< css::uno::Reference
< css::uno::XInterface
> >& _rSelection
) const;
205 /** calculates the zoom factor.
206 @param _eType which kind of zoom is needed
208 sal_uInt16
getZoomFactor(SvxZoomType _eType
) const;
211 #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_INC_SCROLLHELPER_HXX
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */