LibreOffice Module reportdesign (master)  1
ViewsWindow.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #ifndef INCLUDED_REPORTDESIGN_SOURCE_UI_INC_VIEWSWINDOW_HXX
20 #define INCLUDED_REPORTDESIGN_SOURCE_UI_INC_VIEWSWINDOW_HXX
21 
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>
28 #include <vector>
29 
30 #include "MarkedSection.hxx"
31 #include "SectionWindow.hxx"
32 
33 class SdrHdl;
34 
35 namespace rptui
36 {
37  class OReportWindow;
38  class OReportSection;
39  class OSectionView;
40  enum class ControlModification;
41 
43  {
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
49  {
50  switch(m_eCompareMode)
51  {
52  case POS_LEFT:
53  return lhs.Left() < rhs.Left();
54  case POS_RIGHT:
55  return lhs.Right() >= rhs.Right();
56  case POS_UPPER:
57  return lhs.Top() < rhs.Top();
58  case POS_DOWN:
59  return lhs.Bottom() >= rhs.Bottom();
61  return std::abs(m_aRefPoint.X() - lhs.Center().X()) < std::abs(m_aRefPoint.X() - rhs.Center().X());
63  return std::abs(lhs.Center().Y() - m_aRefPoint.Y()) < std::abs(rhs.Center().Y() - m_aRefPoint.Y());
64  }
65  return false;
66  }
67  };
68 
69  class OViewsWindow : public vcl::Window
71  , public IMarkedSection
72  {
73  typedef ::std::multimap<tools::Rectangle,::std::pair<SdrObject*,OSectionView*>,RectangleLess> TRectangleMap;
74  public:
75  typedef ::std::vector< VclPtr<OSectionWindow> > TSectionsMap;
76 
77  private:
78  TSectionsMap m_aSections;
81  OUString m_sShapeType;
83 
84  void ImplInitSettings();
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);
91 
92  OViewsWindow(OViewsWindow const &) = delete;
93  void operator =(OViewsWindow const &) = delete;
94  protected:
95  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
96  // Window overrides
97  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
98  virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
99 
100  virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle& rRect ) override;
102  public:
103  OViewsWindow(
104  OReportWindow* _pReportWindow);
105  virtual ~OViewsWindow() override;
106  virtual void dispose() override;
107 
108  // Window overrides
109  virtual void Resize() override;
110 
111  void resize(const OSectionWindow& _rSectionWindow);
112 
113  OReportWindow* getView() const { return m_pParent; }
114 
119  void removeSection(sal_uInt16 _nPosition);
120 
125  void addSection(const css::uno::Reference< css::report::XSection >& _xSection
126  ,const OUString& _sColorEntry
127  ,sal_uInt16 _nPosition);
128 
129  sal_uInt16 getSectionCount() const;
135  OSectionWindow* getSectionWindow(const sal_uInt16 _nPos) const;
136 
141  void toggleGrid(bool _bVisible);
142  void setGridSnap(bool bOn);
143  void setDragStripes(bool bOn);
144 
147  sal_Int32 getTotalHeight() const;
148 
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;}
155  void Copy();
156 
161  bool IsPasteAllowed() const;
162 
165  void Paste();
166 
170  void Delete();
171 
174  void SelectAll(const sal_uInt16 _nObjectType);
175 
178  bool HasSelection() const;
179 
184  void unmarkAllObjects(OSectionView const * _pSectionView);
185 
189  OSectionWindow* getSectionWindow(const css::uno::Reference< css::report::XSection>& _xSection) const;
190 
195  bool handleKeyEvent(const KeyEvent& _rEvent);
196 
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);
204 
205  // IMarkedSection
207  virtual void markSection(const sal_uInt16 _nPos) override;
208 
211  void alignMarkedObjects(ControlModification _nControlModification, bool _bAlignAtSection);
212 
216  void createDefault();
217 
220  void showRuler(bool _bShow);
221 
226  const OUString& getShapeType() const { return m_sShapeType; }
227 
230  sal_uInt16 getPosition(const OSectionWindow* _pSectionWindow) const;
231 
235  void BrkAction();
236  void BegMarkObj(const Point& _aPnt,const OSectionView* _pSection);
237 
238  private:
239  void BegDragObj_createInvisibleObjectAtPosition(const tools::Rectangle& _aRect, const OSectionView& _rSection);
242  ::std::vector<SdrObject*> m_aBegDragTempList;
243  public:
244  void BegDragObj(const Point& _aPnt, SdrHdl* _pHdl,const OSectionView* _pSection);
245  void EndDragObj(bool _bDragIntoNewSection,const OSectionView* _pSection,const Point& _aPnt);
246 
247  void EndAction();
249  bool IsAction() const;
250  bool IsDragObj() const;
251  void handleKey(const vcl::KeyCode& _rCode);
252  void stopScrollTimer();
253 
260  OSectionView* getSectionRelativeToPosition(const OSectionView* _pSection,Point& _rPnt);
261 
262  void MovAction(const Point& rPnt,const OSectionView* _pSection, bool _bControlKeySet);
263 
264  sal_uInt32 getMarkedObjectCount() const;
265 
270  void fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const;
271 
276  void collapseSections(const css::uno::Sequence< css::beans::PropertyValue>& _aCollapsedSections);
277 
280  void zoom(const Fraction& _aZoom);
281 
282  void scrollChildren(const Point& _aThumbPos);
283 
287  void fillControlModelSelection(::std::vector< css::uno::Reference< css::uno::XInterface > >& _rSelection) const;
288  };
289 
290 } // rptui
291 
292 #endif // INCLUDED_REPORTDESIGN_SOURCE_UI_INC_VIEWSWINDOW_HXX
293 
294 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void MouseButtonUp(const MouseEvent &rMEvt) override
TSectionsMap m_aSections
Definition: ViewsWindow.hxx:78
ConfigurationHints
bool empty() const
void BrkAction()
calls on every section BrkAction
OSectionWindow * getMarkedSection(NearSectionAccess nsa=CURRENT) const override
returns the section which is currently marked.
void operator=(OViewsWindow const &)=delete
void Delete()
Deletes the current selection in this section.
void scrollChildren(const Point &_aThumbPos)
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
VclPtr< OReportWindow > m_pParent
Definition: ViewsWindow.hxx:80
OSectionWindow * getSectionWindow(const sal_uInt16 _nPos) const
return the section at the given position
void MovAction(const Point &rPnt, const OSectionView *_pSection, bool _bControlKeySet)
bool operator()(const tools::Rectangle &lhs, const tools::Rectangle &rhs) const
Definition: ViewsWindow.hxx:48
void handleKey(const vcl::KeyCode &_rCode)
void collapseSections(const css::uno::Sequence< css::beans::PropertyValue > &_aCollapsedSections)
collapse all sections given by their position
SdrObjKind
void BegDragObj_createInvisibleObjectAtPosition(const tools::Rectangle &_aRect, const OSectionView &_rSection)
virtual void markSection(const sal_uInt16 _nPos) override
mark the section on the given position .
void collectRectangles(TRectangleMap &_rMap)
sal_uInt32 getMarkedObjectCount() const
TSectionsMap::iterator getIteratorAtPos(sal_uInt16 _nPos)
returns the iterator at pos _nPos or the end()
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
bool HasSelection() const
returns when an object is marked
void SetMode(DlgEdMode m_eMode)
bool IsPasteAllowed() const
returns if paste is allowed
CompareMode m_eCompareMode
Definition: ViewsWindow.hxx:45
tools::Long Left() const
void fillCollapsedSections(::std::vector< sal_uInt16 > &_rCollapsedPositions) const
fills the positions of all collapsed sections.
void EndDragObj(bool _bDragIntoNewSection, const OSectionView *_pSection, const Point &_aPnt)
tools::Long Bottom() const
ControlModification
Definition: RptDef.hxx:48
::std::multimap< tools::Rectangle,::std::pair< SdrObject *, OSectionView * >, RectangleLess > TRectangleMap
Definition: ViewsWindow.hxx:73
void impl_resizeSectionWindow(OSectionWindow &_rSectionWindow, Point &_rStartPoint, bool _bSet)
void BegMarkObj(const Point &_aPnt, const OSectionView *_pSection)
void EndDragObj_removeInvisibleObjects()
bool IsDragObj() const
void setMarked(OSectionView const *_pSectionView, bool _bMark)
the section as marked or not marked
virtual void Paint(vcl::RenderContext &, const tools::Rectangle &rRect) override
virtual void Resize() override
bool handleKeyEvent(const KeyEvent &_rEvent)
checks if the keycode is known by the child windows
void showRuler(bool _bShow)
shows or hides the ruler.
void createDefault()
creates a default object
void addSection(const css::uno::Reference< css::report::XSection > &_xSection, const OUString &_sColorEntry, sal_uInt16 _nPosition)
adds a new section at position _nPosition.
RectangleLess(CompareMode _eCompareMode, const Point &_rRefPoint)
Definition: ViewsWindow.hxx:47
sal_Int32 getTotalHeight() const
returns the total accumulated height of all sections until _pSection is reached
void setGridSnap(bool bOn)
void fillControlModelSelection(::std::vector< css::uno::Reference< css::uno::XInterface > > &_rSelection) const
fills the vector with all selected control models /param _rSelection The vector will be filled and wi...
bool IsAction() const
void SelectAll(const sal_uInt16 _nObjectType)
All objects will be marked.
tools::Long Top() const
void toggleGrid(bool _bVisible)
turns the grid on or off
void Paste()
paste a new control in this section
void SetInsertObj(SdrObjKind eObj, const OUString &_sShapeType)
void zoom(const Fraction &_aZoom)
zoom the ruler and view windows
void unmarkAllObjects(OSectionView const *_pSectionView)
unmark all objects on the views without the given one.
virtual void ConfigurationChanged(utl::ConfigurationBroadcaster *, ConfigurationHints) override
void resize(const OSectionWindow &_rSectionWindow)
sal_uInt16 getPosition(const OSectionWindow *_pSectionWindow) const
returns the current position in the list
void setDragStripes(bool bOn)
const OUString & getShapeType() const
returns the currently set shape type.
virtual void dispose() override
void Copy()
copies the current selection in this section
OViewsWindow(OViewsWindow const &)=delete
::std::vector< VclPtr< OSectionWindow > > TSectionsMap
Definition: ViewsWindow.hxx:75
void alignMarkedObjects(ControlModification _nControlModification, bool _bAlignAtSection)
align all marked objects in all sections
const OUString & GetInsertObjString() const
OSectionView * getSectionRelativeToPosition(const OSectionView *_pSection, Point &_rPnt)
return the section at the given point which is relative to the given section
virtual ~OViewsWindow() override
::std::vector< SdrObject * > m_aBegDragTempList
static void collectBoundResizeRect(const TRectangleMap &_rSortRectangles, ControlModification _nControlModification, bool _bAlignAtSection, tools::Rectangle &_rBound, tools::Rectangle &_rResize)
void BegDragObj(const Point &_aPnt, SdrHdl *_pHdl, const OSectionView *_pSection)
OReportWindow * getView() const
void removeSection(sal_uInt16 _nPosition)
removes the section at the given position.
svtools::ColorConfig m_aColorConfig
Definition: ViewsWindow.hxx:79
tools::Long Right() const
Point Center() const
sal_uInt16 getSectionCount() const