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 RPTUI_SCROLLHELPER_HXX
20 #define RPTUI_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 <boost/shared_ptr.hpp>
31 #include <vcl/dockwin.hxx>
32 #include <MarkedSection.hxx>
33 #include "ReportWindow.hxx"
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.
44 typedef Window OScrollWindowHelper_BASE
;
45 class OScrollWindowHelper
: public ::cppu::BaseMutex
46 , public OScrollWindowHelper_BASE
/*TabPage*/
47 , public ::comphelper::OPropertyChangeListener
48 , public IMarkedSection
53 ScrollBarBox m_aCornerWin
; // window in the bottom right corner
54 Size m_aTotalPixelSize
;
55 ODesignView
* m_pParent
;
56 OReportWindow m_aReportWindow
;
57 ::rtl::Reference
<comphelper::OPropertyChangeMultiplexer
>
58 m_pReportDefintionMultiPlexer
; // listener for property changes
60 DECL_LINK( ScrollHdl
, ScrollBar
*);
61 Size
ResizeScrollBars();
62 void ImplInitSettings();
63 void impl_initScrollBar( ScrollBar
& _rScrollBar
) const;
65 OScrollWindowHelper(OScrollWindowHelper
&);
66 void operator =(OScrollWindowHelper
&);
68 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
70 virtual void Resize();
71 virtual long Notify( NotifyEvent
& rNEvt
);
72 // OPropertyChangeListener
73 virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent
& _rEvent
) throw( ::com::sun::star::uno::RuntimeException
);
75 OScrollWindowHelper( ODesignView
* _pReportDesignView
);
76 virtual ~OScrollWindowHelper();
82 inline Point
getThumbPos() const { return Point(m_aHScroll
.GetThumbPos(),m_aVScroll
.GetThumbPos())/*m_aScrollOffset*/; }
83 inline const OReportWindow
& getReportWindow() const { return m_aReportWindow
; }
84 void setTotalSize(sal_Int32 _nWidth
,sal_Int32 _nHeight
);
85 inline Size
getTotalSize() const { return m_aTotalPixelSize
; }
86 inline ScrollBar
* GetHScroll() { return &m_aHScroll
; }
87 inline ScrollBar
* GetVScroll() { return &m_aVScroll
; }
90 void SetMode( DlgEdMode _eMode
);
91 void SetInsertObj( sal_uInt16 eObj
,const OUString
& _sShapeType
= OUString());
92 OUString
GetInsertObjString() const;
93 void setGridSnap(sal_Bool bOn
);
94 void setDragStripes(sal_Bool bOn
);
95 /** copies the current selection in this section
99 /** returns if paste is allowed
101 * \return <TRUE/> if paste is allowed
103 sal_Bool
IsPasteAllowed() const;
105 /** paste a new control in this section
109 /** Deletes the current selection in this section
114 /** All objects will be marked.
116 void SelectAll(const sal_uInt16 _nObjectType
);
118 /** returns <TRUE/> when a object is marked
120 sal_Bool
HasSelection() const;
122 /** removes the section at the given position.
124 * \param _nPosition Zero based.
126 void removeSection(sal_uInt16 _nPosition
);
128 /** adds a new section at position _nPosition.
129 If the section is <NULL/> nothing happens.
130 If the position is grater than the current elements, the section will be appended.
132 void addSection(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>& _xSection
133 ,const OUString
& _sColorEntry
134 ,sal_uInt16 _nPosition
= USHRT_MAX
);
136 sal_uInt16
getSectionCount() const;
138 /** turns the grid on or off
142 void toggleGrid(sal_Bool _bVisible
);
144 /** unmark all objects on the views without the given one.
146 * @param _pSectionView The view where the objects should not be unmarked.
148 void unmarkAllObjects(OSectionView
* _pSectionView
);
150 /** shows or hides the ruler.
152 void showRuler(sal_Bool _bShow
);
154 /** calculate the max width of the markers
156 * @param _bWithEnd if <TRUE/> the end marker will be used for calculation as well otherwise not.
157 * \return the max width
159 sal_Int32
getMaxMarkerWidth(sal_Bool _bWithEnd
) const;
161 /** checks if the keycode is known by the child windows
162 @param _rCode the keycode
163 @return <TRUE/> if the keycode is handled otherwise <FALSE/>
165 sal_Bool
handleKeyEvent(const KeyEvent
& _rEvent
);
167 /** the section as marked or not marked
168 @param _pSectionView the section where to set the marked flag
169 @param _bMark the marked flag
171 void setMarked(OSectionView
* _pSectionView
,sal_Bool _bMark
);
172 void setMarked(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>& _xSection
,sal_Bool _bMark
);
173 void setMarked(const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
> >& _xShape
,sal_Bool _bMark
);
176 ::boost::shared_ptr
<OSectionWindow
> getMarkedSection(NearSectionAccess nsa
= CURRENT
) const;
177 ::boost::shared_ptr
<OSectionWindow
> getSectionWindow(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>& _xSection
) const;
178 virtual void markSection(const sal_uInt16 _nPos
);
181 /** fills the positions of all collapsed sections.
183 * \param _rCollapsedPositions Out parameter which holds afterwards all positions of the collapsed sections.
185 void fillCollapsedSections(::std::vector
<sal_uInt16
>& _rCollapsedPositions
) const;
187 /** collpase all sections given by their position
189 * \param _aCollpasedSections The position of the sections which should be collapsed.
191 void collapseSections(const com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& _aCollpasedSections
);
193 /** align all marked objects in all sections
199 void alignMarkedObjects(sal_Int32 _nControlModification
, bool _bAlignAtSection
, bool bBoundRects
= false);
201 sal_uInt32
getMarkedObjectCount() const;
203 /** zoom the ruler and view windows
205 void zoom(const Fraction
& _aZoom
);
207 /** fills the vector with all selected control models
208 /param _rSelection The vector will be filled and will not be cleared before.
210 void fillControlModelSelection(::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> >& _rSelection
) const;
212 /** calculates the zoom factor.
213 @param _eType which kind of zoom is needed
215 sal_uInt16
getZoomFactor(SvxZoomType _eType
) const;
218 #endif // RPTUI_SCROLLHELPER_HXX
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */