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 "ReportSection.hxx"
27 #include <cppuhelper/basemutex.hxx>
28 #include <com/sun/star/beans/NamedValue.hpp>
29 #include <svx/svdedtv.hxx>
30 #include "SectionView.hxx"
31 #include <unotools/options.hxx>
35 #include "MarkedSection.hxx"
36 #include "SectionWindow.hxx"
45 enum class ControlModification
;
49 enum CompareMode
{ POS_LEFT
,POS_RIGHT
,POS_UPPER
,POS_DOWN
,POS_CENTER_HORIZONTAL
,POS_CENTER_VERTICAL
};
50 CompareMode
const m_eCompareMode
;
51 Point
const m_aRefPoint
;
52 RectangleLess(CompareMode _eCompareMode
,const Point
& _rRefPoint
) : m_eCompareMode(_eCompareMode
),m_aRefPoint(_rRefPoint
){}
53 bool operator() (const tools::Rectangle
& lhs
, const tools::Rectangle
& rhs
) const
55 switch(m_eCompareMode
)
58 return lhs
.Left() < rhs
.Left();
60 return lhs
.Right() >= rhs
.Right();
62 return lhs
.Top() < rhs
.Top();
64 return lhs
.Bottom() >= rhs
.Bottom();
65 case POS_CENTER_HORIZONTAL
:
66 return std::abs(m_aRefPoint
.X() - lhs
.Center().X()) < std::abs(m_aRefPoint
.X() - rhs
.Center().X());
67 case POS_CENTER_VERTICAL
:
68 return std::abs(lhs
.Center().Y() - m_aRefPoint
.Y()) < std::abs(rhs
.Center().Y() - m_aRefPoint
.Y());
74 class OViewsWindow
: public vcl::Window
75 , public utl::ConfigurationListener
76 , public IMarkedSection
78 typedef ::std::multimap
<tools::Rectangle
,::std::pair
<SdrObject
*,OSectionView
*>,RectangleLess
> TRectangleMap
;
80 typedef ::std::vector
< VclPtr
<OSectionWindow
> > TSectionsMap
;
83 TSectionsMap m_aSections
;
84 svtools::ColorConfig m_aColorConfig
;
85 VclPtr
<OReportWindow
> m_pParent
;
86 OUString m_sShapeType
;
89 void ImplInitSettings();
90 /** returns the iterator at pos _nPos or the end()
92 TSectionsMap::iterator
getIteratorAtPos(sal_uInt16 _nPos
);
93 void collectRectangles(TRectangleMap
& _rMap
);
94 static void collectBoundResizeRect(const TRectangleMap
& _rSortRectangles
, ControlModification _nControlModification
,bool _bAlignAtSection
,tools::Rectangle
& _rBound
,tools::Rectangle
& _rResize
);
95 void impl_resizeSectionWindow(OSectionWindow
& _rSectionWindow
,Point
& _rStartPoint
,bool _bSet
);
97 OViewsWindow(OViewsWindow
const &) = delete;
98 void operator =(OViewsWindow
const &) = delete;
100 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
102 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
103 virtual void MouseButtonUp( const MouseEvent
& rMEvt
) override
;
105 virtual void Paint( vcl::RenderContext
& /*rRenderContext*/, const tools::Rectangle
& rRect
) override
;
106 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster
*, ConfigurationHints
) override
;
109 OReportWindow
* _pReportWindow
);
110 virtual ~OViewsWindow() override
;
111 virtual void dispose() override
;
114 virtual void Resize() override
;
116 void resize(const OSectionWindow
& _rSectionWindow
);
118 OReportWindow
* getView() const { return m_pParent
; }
120 /** removes the section at the given position.
122 * \param _nPosition Zero based.
124 void removeSection(sal_uInt16 _nPosition
);
126 /** adds a new section at position _nPosition.
127 If the section is <NULL/> nothing happens.
128 If the position is grater than the current elements, the section will be appended.
130 void addSection(const css::uno::Reference
< css::report::XSection
>& _xSection
131 ,const OUString
& _sColorEntry
132 ,sal_uInt16 _nPosition
);
134 sal_uInt16
getSectionCount() const;
135 /** return the section at the given position
138 * \return the section at this pos or an empty section
140 OSectionWindow
* getSectionWindow(const sal_uInt16 _nPos
) const;
142 /** turns the grid on or off
146 void toggleGrid(bool _bVisible
);
147 void setGridSnap(bool bOn
);
148 void setDragStripes(bool bOn
);
150 /** returns the total accumulated height of all sections until _pSection is reached
152 sal_Int32
getTotalHeight() const;
154 bool empty() const { return m_aSections
.empty(); }
155 void SetMode( DlgEdMode m_eMode
);
156 void SetInsertObj( sal_uInt16 eObj
,const OUString
& _sShapeType
);
157 const OUString
& GetInsertObjString() const { return m_sShapeType
;}
158 /** copies the current selection in this section
162 /** returns if paste is allowed
164 * \return <TRUE/> if paste is allowed
166 bool IsPasteAllowed() const;
168 /** paste a new control in this section
172 /** Deletes the current selection in this section
177 /** All objects will be marked.
179 void SelectAll(const sal_uInt16 _nObjectType
);
181 /** returns <TRUE/> when a object is marked
183 bool HasSelection() const;
185 /** unmark all objects on the views without the given one.
187 * @param _pSectionView The view where the objects should not be unmarked.
189 void unmarkAllObjects(OSectionView
const * _pSectionView
);
191 /** returns the report section window for the given xsection
192 @param _xSection the section
194 OSectionWindow
* getSectionWindow(const css::uno::Reference
< css::report::XSection
>& _xSection
) const;
196 /** checks if the keycode is known by the child windows
197 @param _rCode the keycode
198 @return <TRUE/> if the keycode is handled otherwise <FALSE/>
200 bool handleKeyEvent(const KeyEvent
& _rEvent
);
202 /** the section as marked or not marked
203 @param _pSectionView the section where to set the marked flag
204 @param _bMark the marked flag
206 void setMarked(OSectionView
const * _pSectionView
, bool _bMark
);
207 void setMarked(const css::uno::Reference
< css::report::XSection
>& _xSection
, bool _bMark
);
208 void setMarked(const css::uno::Sequence
< css::uno::Reference
< css::report::XReportComponent
> >& _xShape
, bool _bMark
);
211 OSectionWindow
* getMarkedSection(NearSectionAccess nsa
= CURRENT
) const override
;
212 virtual void markSection(const sal_uInt16 _nPos
) override
;
214 /** align all marked objects in all sections
216 void alignMarkedObjects(ControlModification _nControlModification
, bool _bAlignAtSection
);
218 /** creates a default object
221 void createDefault();
223 /** shows or hides the ruler.
225 void showRuler(bool _bShow
);
227 /** returns the currently set shape type.
229 * \return \member m_sShapeType
231 const OUString
& getShapeType() const { return m_sShapeType
; }
233 /** returns the current position in the list
235 sal_uInt16
getPosition(const OSectionWindow
* _pSectionWindow
) const;
237 /** calls on every section BrkAction
241 void BegMarkObj(const Point
& _aPnt
,const OSectionView
* _pSection
);
244 void BegDragObj_createInvisibleObjectAtPosition(const tools::Rectangle
& _aRect
, const OSectionView
& _rSection
);
245 void EndDragObj_removeInvisibleObjects();
247 ::std::vector
<SdrObject
*> m_aBegDragTempList
;
249 void BegDragObj(const Point
& _aPnt
, SdrHdl
* _pHdl
,const OSectionView
* _pSection
);
250 void EndDragObj(bool _bDragIntoNewSection
,const OSectionView
* _pSection
,const Point
& _aPnt
);
253 void ForceMarkedToAnotherPage();
254 bool IsAction() const;
255 bool IsDragObj() const;
256 void handleKey(const vcl::KeyCode
& _rCode
);
257 void stopScrollTimer();
259 /** return the section at the given point which is relative to the given section
261 * \param _pSection the section which is used as reference point
262 * \param _rPnt the point, it will be changed that it is inside the section which will be returned
263 * \return the section
265 OSectionView
* getSectionRelativeToPosition(const OSectionView
* _pSection
,Point
& _rPnt
);
267 void MovAction(const Point
& rPnt
,const OSectionView
* _pSection
, bool _bControlKeySet
);
269 sal_uInt32
getMarkedObjectCount() const;
271 /** fills the positions of all collapsed sections.
273 * \param _rCollapsedPositions Out parameter which holds afterwards all positions of the collapsed sections.
275 void fillCollapsedSections(::std::vector
<sal_uInt16
>& _rCollapsedPositions
) const;
277 /** collpase all sections given by their position
279 * \param _aCollpasedSections The position of the sections which should be collapsed.
281 void collapseSections(const css::uno::Sequence
< css::beans::PropertyValue
>& _aCollpasedSections
);
283 /** zoom the ruler and view windows
285 void zoom(const Fraction
& _aZoom
);
287 void scrollChildren(const Point
& _aThumbPos
);
289 /** fills the vector with all selected control models
290 /param _rSelection The vector will be filled and will not be cleared before.
292 void fillControlModelSelection(::std::vector
< css::uno::Reference
< css::uno::XInterface
> >& _rSelection
) const;
297 #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_INC_VIEWSWINDOW_HXX
299 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */