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_VIEWSWINDOW_HXX
20 #define INCLUDED_REPORTDESIGN_SOURCE_UI_INC_VIEWSWINDOW_HXX
22 #include <com/sun/star/report/XSection.hpp>
23 #include <vcl/window.hxx>
24 #include <svtools/colorcfg.hxx>
25 #include "ReportDefines.hxx"
26 #include "SectionView.hxx"
27 #include <unotools/options.hxx>
30 #include "MarkedSection.hxx"
31 #include "SectionWindow.hxx"
40 enum class ControlModification
;
44 enum CompareMode
{ POS_LEFT
,POS_RIGHT
,POS_UPPER
,POS_DOWN
,POS_CENTER_HORIZONTAL
,POS_CENTER_VERTICAL
};
45 CompareMode m_eCompareMode
;
47 RectangleLess(CompareMode _eCompareMode
,const Point
& _rRefPoint
) : m_eCompareMode(_eCompareMode
),m_aRefPoint(_rRefPoint
){}
48 bool operator() (const tools::Rectangle
& lhs
, const tools::Rectangle
& rhs
) const
50 switch(m_eCompareMode
)
53 return lhs
.Left() < rhs
.Left();
55 return lhs
.Right() >= rhs
.Right();
57 return lhs
.Top() < rhs
.Top();
59 return lhs
.Bottom() >= rhs
.Bottom();
60 case POS_CENTER_HORIZONTAL
:
61 return std::abs(m_aRefPoint
.X() - lhs
.Center().X()) < std::abs(m_aRefPoint
.X() - rhs
.Center().X());
62 case POS_CENTER_VERTICAL
:
63 return std::abs(lhs
.Center().Y() - m_aRefPoint
.Y()) < std::abs(rhs
.Center().Y() - m_aRefPoint
.Y());
69 class OViewsWindow
: public vcl::Window
70 , public utl::ConfigurationListener
71 , public IMarkedSection
73 typedef ::std::multimap
<tools::Rectangle
,::std::pair
<SdrObject
*,OSectionView
*>,RectangleLess
> TRectangleMap
;
75 typedef ::std::vector
< VclPtr
<OSectionWindow
> > TSectionsMap
;
78 TSectionsMap m_aSections
;
79 svtools::ColorConfig m_aColorConfig
;
80 VclPtr
<OReportWindow
> m_pParent
;
81 OUString m_sShapeType
;
84 void ImplInitSettings();
85 /** returns the iterator at pos _nPos or the end()
87 TSectionsMap::iterator
getIteratorAtPos(sal_uInt16 _nPos
);
88 void collectRectangles(TRectangleMap
& _rMap
);
89 static void collectBoundResizeRect(const TRectangleMap
& _rSortRectangles
, ControlModification _nControlModification
,bool _bAlignAtSection
,tools::Rectangle
& _rBound
,tools::Rectangle
& _rResize
);
90 void impl_resizeSectionWindow(OSectionWindow
& _rSectionWindow
,Point
& _rStartPoint
,bool _bSet
);
92 OViewsWindow(OViewsWindow
const &) = delete;
93 void operator =(OViewsWindow
const &) = delete;
95 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
97 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
98 virtual void MouseButtonUp( const MouseEvent
& rMEvt
) override
;
100 virtual void Paint( vcl::RenderContext
& /*rRenderContext*/, const tools::Rectangle
& rRect
) override
;
101 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster
*, ConfigurationHints
) override
;
104 OReportWindow
* _pReportWindow
);
105 virtual ~OViewsWindow() override
;
106 virtual void dispose() override
;
109 virtual void Resize() override
;
111 void resize(const OSectionWindow
& _rSectionWindow
);
113 OReportWindow
* getView() const { return m_pParent
; }
115 /** removes the section at the given position.
117 * \param _nPosition Zero based.
119 void removeSection(sal_uInt16 _nPosition
);
121 /** adds a new section at position _nPosition.
122 If the section is <NULL/> nothing happens.
123 If the position is grater than the current elements, the section will be appended.
125 void addSection(const css::uno::Reference
< css::report::XSection
>& _xSection
126 ,const OUString
& _sColorEntry
127 ,sal_uInt16 _nPosition
);
129 sal_uInt16
getSectionCount() const;
130 /** return the section at the given position
133 * \return the section at this pos or an empty section
135 OSectionWindow
* getSectionWindow(const sal_uInt16 _nPos
) const;
137 /** turns the grid on or off
141 void toggleGrid(bool _bVisible
);
142 void setGridSnap(bool bOn
);
143 void setDragStripes(bool bOn
);
145 /** returns the total accumulated height of all sections until _pSection is reached
147 sal_Int32
getTotalHeight() const;
149 bool empty() const { return m_aSections
.empty(); }
150 void SetMode( DlgEdMode m_eMode
);
151 void SetInsertObj( SdrObjKind eObj
,const OUString
& _sShapeType
);
152 const OUString
& GetInsertObjString() const { return m_sShapeType
;}
153 /** copies the current selection in this section
157 /** returns if paste is allowed
159 * \return <TRUE/> if paste is allowed
161 bool IsPasteAllowed() const;
163 /** paste a new control in this section
167 /** Deletes the current selection in this section
172 /** All objects will be marked.
174 void SelectAll(const SdrObjKind _nObjectType
);
176 /** returns <TRUE/> when an object is marked
178 bool HasSelection() const;
180 /** unmark all objects on the views without the given one.
182 * @param _pSectionView The view where the objects should not be unmarked.
184 void unmarkAllObjects(OSectionView
const * _pSectionView
);
186 /** returns the report section window for the given xsection
187 @param _xSection the section
189 OSectionWindow
* getSectionWindow(const css::uno::Reference
< css::report::XSection
>& _xSection
) const;
191 /** checks if the keycode is known by the child windows
192 @param _rCode the keycode
193 @return <TRUE/> if the keycode is handled otherwise <FALSE/>
195 bool handleKeyEvent(const KeyEvent
& _rEvent
);
197 /** the section as marked or not marked
198 @param _pSectionView the section where to set the marked flag
199 @param _bMark the marked flag
201 void setMarked(OSectionView
const * _pSectionView
, bool _bMark
);
202 void setMarked(const css::uno::Reference
< css::report::XSection
>& _xSection
, bool _bMark
);
203 void setMarked(const css::uno::Sequence
< css::uno::Reference
< css::report::XReportComponent
> >& _xShape
, bool _bMark
);
206 OSectionWindow
* getMarkedSection(NearSectionAccess nsa
= CURRENT
) const override
;
207 virtual void markSection(const sal_uInt16 _nPos
) override
;
209 /** align all marked objects in all sections
211 void alignMarkedObjects(ControlModification _nControlModification
, bool _bAlignAtSection
);
213 /** creates a default object
216 void createDefault();
218 /** shows or hides the ruler.
220 void showRuler(bool _bShow
);
222 /** returns the currently set shape type.
224 * \return \member m_sShapeType
226 const OUString
& getShapeType() const { return m_sShapeType
; }
228 /** returns the current position in the list
230 sal_uInt16
getPosition(const OSectionWindow
* _pSectionWindow
) const;
232 /** calls on every section BrkAction
236 void BegMarkObj(const Point
& _aPnt
,const OSectionView
* _pSection
);
239 void BegDragObj_createInvisibleObjectAtPosition(const tools::Rectangle
& _aRect
, const OSectionView
& _rSection
);
240 void EndDragObj_removeInvisibleObjects();
242 ::std::vector
<SdrObject
*> m_aBegDragTempList
;
244 void BegDragObj(const Point
& _aPnt
, SdrHdl
* _pHdl
,const OSectionView
* _pSection
);
245 void EndDragObj(bool _bDragIntoNewSection
,const OSectionView
* _pSection
,const Point
& _aPnt
);
248 void ForceMarkedToAnotherPage();
249 bool IsAction() const;
250 bool IsDragObj() const;
251 void handleKey(const vcl::KeyCode
& _rCode
);
252 void stopScrollTimer();
254 /** return the section at the given point which is relative to the given section
256 * \param _pSection the section which is used as reference point
257 * \param _rPnt the point, it will be changed that it is inside the section which will be returned
258 * \return the section
260 OSectionView
* getSectionRelativeToPosition(const OSectionView
* _pSection
,Point
& _rPnt
);
262 void MovAction(const Point
& rPnt
,const OSectionView
* _pSection
, bool _bControlKeySet
);
264 sal_uInt32
getMarkedObjectCount() const;
266 /** fills the positions of all collapsed sections.
268 * \param _rCollapsedPositions Out parameter which holds afterwards all positions of the collapsed sections.
270 void fillCollapsedSections(::std::vector
<sal_uInt16
>& _rCollapsedPositions
) const;
272 /** collapse all sections given by their position
274 * \param _aCollapsedSections The position of the sections which should be collapsed.
276 void collapseSections(const css::uno::Sequence
< css::beans::PropertyValue
>& _aCollapsedSections
);
278 /** zoom the ruler and view windows
280 void zoom(const Fraction
& _aZoom
);
282 void scrollChildren(const Point
& _aThumbPos
);
284 /** fills the vector with all selected control models
285 /param _rSelection The vector will be filled and will not be cleared before.
287 void fillControlModelSelection(::std::vector
< css::uno::Reference
< css::uno::XInterface
> >& _rSelection
) const;
292 #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_INC_VIEWSWINDOW_HXX
294 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */