update emoji autocorrect entries from po-files
[LibreOffice.git] / reportdesign / source / ui / inc / ViewsWindow.hxx
blob00e0ac22d837e5f9ab59ac65dc9d8786c7789dd1
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_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 <comphelper/propmultiplex.hxx>
28 #include <cppuhelper/basemutex.hxx>
29 #include <com/sun/star/beans/NamedValue.hpp>
30 #include <svx/svdedtv.hxx>
31 #include "SectionView.hxx"
32 #include <unotools/options.hxx>
33 #include <list>
34 #include <vector>
36 #include "MarkedSection.hxx"
37 #include "SectionWindow.hxx"
39 class SdrHdl;
40 namespace rptui
42 class OReportWindow;
43 class OReportSection;
44 class OSectionView;
48 struct RectangleLess : public ::std::binary_function< Rectangle, Rectangle, bool>
50 enum CompareMode { POS_LEFT,POS_RIGHT,POS_UPPER,POS_DOWN,POS_CENTER_HORIZONTAL,POS_CENTER_VERTICAL };
51 CompareMode m_eCompareMode;
52 Point m_aRefPoint;
53 RectangleLess(CompareMode _eCompareMode,const Point& _rRefPoint ) : m_eCompareMode(_eCompareMode),m_aRefPoint(_rRefPoint){}
54 bool operator() (const Rectangle& lhs, const Rectangle& rhs) const
56 switch(m_eCompareMode)
58 case POS_LEFT:
59 return lhs.Left() < rhs.Left();
60 case POS_RIGHT:
61 return lhs.Right() >= rhs.Right();
62 case POS_UPPER:
63 return lhs.Top() < rhs.Top();
64 case POS_DOWN:
65 return lhs.Bottom() >= rhs.Bottom();
66 case POS_CENTER_HORIZONTAL:
67 return std::abs(m_aRefPoint.X() - lhs.Center().X()) < std::abs(m_aRefPoint.X() - rhs.Center().X());
68 case POS_CENTER_VERTICAL:
69 return std::abs(lhs.Center().Y() - m_aRefPoint.Y()) < std::abs(rhs.Center().Y() - m_aRefPoint.Y());
71 return false;
75 class OWindowPositionCorrector
77 ::std::vector< ::std::pair<VclPtr<vcl::Window>,Point> > m_aChildren;
78 long m_nDeltaX;
79 long m_nDeltaY;
80 public:
81 OWindowPositionCorrector(vcl::Window* _pWindow,long _nDeltaX, long _nDeltaY) :m_nDeltaX(_nDeltaX), m_nDeltaY(_nDeltaY)
83 sal_uInt16 nCount = _pWindow->GetChildCount();
84 m_aChildren.reserve(nCount);
85 while( nCount )
87 vcl::Window* pChild = _pWindow->GetChild(--nCount);
88 m_aChildren.push_back(::std::pair<vcl::Window*,Point>(pChild,pChild->GetPosPixel()));
91 ~OWindowPositionCorrector()
93 auto aIter = m_aChildren.begin();
94 auto aEnd = m_aChildren.end();
95 for (; aIter != aEnd; ++aIter)
97 const Point aPos = aIter->first->GetPosPixel();
98 if ( aPos == aIter->second )
99 aIter->first->SetPosPixel(Point(m_nDeltaX,m_nDeltaY) + aPos);
104 class OViewsWindow : public vcl::Window
105 , public utl::ConfigurationListener
106 , public IMarkedSection
108 typedef ::std::multimap<Rectangle,::std::pair<SdrObject*,OSectionView*>,RectangleLess> TRectangleMap;
109 public:
110 typedef ::std::vector< VclPtr<OSectionWindow> > TSectionsMap;
112 struct TReportPairHelper : public ::std::unary_function< TSectionsMap::value_type, OReportSection >
114 OReportSection& operator() (const TSectionsMap::value_type& lhs) const
116 return lhs->getReportSection();
119 struct TStartMarkerHelper : public ::std::unary_function< TSectionsMap::value_type, OStartMarker >
121 OStartMarker& operator() (const TSectionsMap::value_type& lhs) const
123 return lhs->getStartMarker();
126 private:
127 TSectionsMap m_aSections;
128 svtools::ColorConfig m_aColorConfig;
129 VclPtr<OReportWindow> m_pParent;
130 OUString m_sShapeType;
131 bool m_bInUnmark;
133 void ImplInitSettings();
134 /** returns the iterator at pos _nPos or the end()
136 TSectionsMap::iterator getIteratorAtPos(sal_uInt16 _nPos);
137 void collectRectangles(TRectangleMap& _rMap,bool _bBoundRects);
138 static void collectBoundResizeRect(const TRectangleMap& _rSortRectangles,sal_Int32 _nControlModification,bool _bAlignAtSection,bool _bBoundRects,Rectangle& _rBound,Rectangle& _rResize);
139 void impl_resizeSectionWindow(OSectionWindow& _rSectionWindow,Point& _rStartPoint,bool _bSet);
141 OViewsWindow(OViewsWindow&) SAL_DELETED_FUNCTION;
142 void operator =(OViewsWindow&) SAL_DELETED_FUNCTION;
143 protected:
144 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
145 // Window overrides
146 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
147 virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
149 virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rRect ) SAL_OVERRIDE;
150 virtual void ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ) SAL_OVERRIDE;
151 public:
152 OViewsWindow(
153 OReportWindow* _pReportWindow);
154 virtual ~OViewsWindow();
155 virtual void dispose() SAL_OVERRIDE;
157 // Window overrides
158 virtual void Resize() SAL_OVERRIDE;
160 void resize(const OSectionWindow& _rSectionWindow);
162 inline OReportWindow* getView() const { return m_pParent; }
164 /** removes the section at the given position.
166 * \param _nPosition Zero based.
168 void removeSection(sal_uInt16 _nPosition);
170 /** adds a new section at position _nPosition.
171 If the section is <NULL/> nothing happens.
172 If the position is grater than the current elements, the section will be appended.
174 void addSection(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection >& _xSection
175 ,const OUString& _sColorEntry
176 ,sal_uInt16 _nPosition = USHRT_MAX);
178 sal_uInt16 getSectionCount() const;
179 /** return the section at the given position
181 * \param _nPos
182 * \return the section at this pos or an empty section
184 OSectionWindow* getSectionWindow(const sal_uInt16 _nPos) const;
186 /** turns the grid on or off
188 * \param _bVisible
190 void toggleGrid(bool _bVisible);
191 void setGridSnap(bool bOn);
192 void setDragStripes(bool bOn);
194 /** returns the total accumulated height of all sections until _pSection is reached
196 sal_Int32 getTotalHeight() const;
198 inline bool empty() const { return m_aSections.empty(); }
199 void SetMode( DlgEdMode m_eMode );
200 void SetInsertObj( sal_uInt16 eObj,const OUString& _sShapeType = OUString());
201 OUString GetInsertObjString() const { return m_sShapeType;}
202 /** copies the current selection in this section
204 void Copy();
206 /** returns if paste is allowed
208 * \return <TRUE/> if paste is allowed
210 bool IsPasteAllowed() const;
212 /** paste a new control in this section
214 void Paste();
216 /** Deletes the current selection in this section
219 void Delete();
221 /** All objects will be marked.
223 void SelectAll(const sal_uInt16 _nObjectType);
225 /** returns <TRUE/> when a object is marked
227 bool HasSelection() const;
229 /** unmark all objects on the views without the given one.
231 * @param _pSectionView The view where the objects should not be unmarked.
233 void unmarkAllObjects(OSectionView* _pSectionView);
235 /** returns the report section window for the given xsection
236 @param _xSection the section
238 OSectionWindow* getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const;
240 /** checks if the keycode is known by the child windows
241 @param _rCode the keycode
242 @return <TRUE/> if the keycode is handled otherwise <FALSE/>
244 bool handleKeyEvent(const KeyEvent& _rEvent);
246 /** the section as marked or not marked
247 @param _pSectionView the section where to set the marked flag
248 @param _bMark the marked flag
250 void setMarked(OSectionView* _pSectionView, bool _bMark);
251 void setMarked(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection, bool _bMark);
252 void setMarked(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> >& _xShape, bool _bMark);
254 // IMarkedSection
255 OSectionWindow* getMarkedSection(NearSectionAccess nsa = CURRENT) const SAL_OVERRIDE;
256 virtual void markSection(const sal_uInt16 _nPos) SAL_OVERRIDE;
258 /** align all marked objects in all sections
260 void alignMarkedObjects(sal_Int32 _nControlModification,bool _bAlignAtSection, bool bBoundRects = false);
262 /** creates a default object
265 void createDefault();
267 /** shows or hides the ruler.
269 void showRuler(bool _bShow);
271 /** returns the currently set shape type.
273 * \return \member m_sShapeType
275 inline OUString getShapeType() const { return m_sShapeType; }
277 /** returns the current position in the list
279 sal_uInt16 getPosition(const OSectionWindow* _pSectionWindow = NULL) const;
281 /** calls on every section BrkAction
284 void BrkAction();
285 void BegMarkObj(const Point& _aPnt,const OSectionView* _pSection);
287 private:
288 void BegDragObj_createInvisibleObjectAtPosition(const Rectangle& _aRect, const OSectionView& _rSection);
289 void EndDragObj_removeInvisibleObjects();
290 Point m_aDragDelta;
291 ::std::vector<SdrObject*> m_aBegDragTempList;
292 bool isObjectInMyTempList(SdrObject *);
293 public:
294 void BegDragObj(const Point& _aPnt, SdrHdl* _pHdl,const OSectionView* _pSection);
295 void EndDragObj(bool _bDragIntoNewSection,const OSectionView* _pSection,const Point& _aPnt);
297 void EndAction();
298 void ForceMarkedToAnotherPage();
299 bool IsAction() const;
300 bool IsDragObj() const;
301 void handleKey(const vcl::KeyCode& _rCode);
302 void stopScrollTimer();
304 /** return the section at the given point which is relative to the given section
306 * \param _pSection the section which is used as reference point
307 * \param _rPnt the point, it will be changed that it is inside the section which will be returned
308 * \return the section
310 OSectionView* getSectionRelativeToPosition(const OSectionView* _pSection,Point& _rPnt);
312 void MovAction(const Point& rPnt,const OSectionView* _pSection,bool _bMove /*= true */, bool _bControlKeySet);
314 sal_uInt32 getMarkedObjectCount() const;
316 /** fills the positions of all collapsed sections.
318 * \param _rCollapsedPositions Out parameter which holds afterwards all positions of the collapsed sections.
320 void fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const;
322 /** collpase all sections given by their position
324 * \param _aCollpasedSections The position of the sections which should be collapsed.
326 void collapseSections(const com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& _aCollpasedSections);
328 /** zoom the ruler and view windows
330 void zoom(const Fraction& _aZoom);
332 void scrollChildren(const Point& _aThumbPos);
334 /** fills the vector with all selected control models
335 /param _rSelection The vector will be filled and will not be cleared before.
337 void fillControlModelSelection(::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& _rSelection) const;
340 } // rptui
342 #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_INC_VIEWSWINDOW_HXX
344 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */