LibreOffice Module reportdesign (master) 1
ReportWindow.cxx
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#include <ReportWindow.hxx>
20#include <ReportSection.hxx>
21#include <SectionView.hxx>
22#include <ViewsWindow.hxx>
23#include <DesignView.hxx>
24#include <UITools.hxx>
25
28
29#include <vcl/settings.hxx>
30
31#include <RptDef.hxx>
32#include <strings.hxx>
33#include <ReportController.hxx>
34#include <ScrollHelper.hxx>
35
36#include <helpids.h>
37#include <dlgedfac.hxx>
38
39
40#define SECTION_OFFSET 3
41namespace rptui
42{
43using namespace ::com::sun::star;
44using namespace ::comphelper;
45
46
47
49: Window(_pParent,WB_DIALOGCONTROL)
51,m_aHRuler(VclPtr<Ruler>::Create(this))
52,m_pView(_pView)
53,m_pParent(_pParent)
54,m_aViewsWindow(VclPtr<rptui::OViewsWindow>::Create(this))
55,m_pObjFac( new DlgEdFactory() )
56{
58 SetMapMode( MapMode( MapUnit::Map100thMM ) );
59
60 m_aViewsWindow->Show();
61
62 m_aHRuler->Show();
63 m_aHRuler->Activate();
64 m_aHRuler->SetPagePos();
65 m_aHRuler->SetBorders();
66 m_aHRuler->SetIndents();
67 m_aHRuler->SetMargin1();
68 m_aHRuler->SetMargin2();
70 m_aHRuler->SetUnit(MeasurementSystem::Metric == eSystem ? FieldUnit::CM : FieldUnit::INCH);
71
74}
75
77{
79}
80
82{
83 if ( m_pReportListener.is() )
84 m_pReportListener->dispose();
86 m_aViewsWindow.disposeAndClear();
87 m_pView.clear();
88 m_pParent.clear();
90}
91
92void OReportWindow::SetInsertObj( SdrObjKind eObj,const OUString& _sShapeType )
93{
94 m_aViewsWindow->SetInsertObj( eObj,_sShapeType);
95}
96
97OUString const & OReportWindow::GetInsertObjString() const
98{
99 return m_aViewsWindow->GetInsertObjString();
100}
101
103{
104 m_aViewsWindow->SetMode(eNewMode);
105}
106
107void OReportWindow::removeSection(sal_uInt16 _nPosition)
108{
109 m_aViewsWindow->removeSection(_nPosition);
110 m_pParent->setTotalSize(GetTotalWidth(),GetTotalHeight());
111 m_aViewsWindow->Invalidate(InvalidateFlags::Transparent);
112}
113
114void OReportWindow::addSection(const uno::Reference< report::XSection >& _xSection,const OUString& _sColorEntry,sal_uInt16 _nPosition)
115{
116 if ( !_xSection.is() )
117 return;
118
119 m_aViewsWindow->addSection(_xSection,_sColorEntry,_nPosition);
120
121 m_pParent->setTotalSize(GetTotalWidth(),GetTotalHeight());
122}
123
124void OReportWindow::toggleGrid(bool _bVisible)
125{
126 m_aViewsWindow->toggleGrid(_bVisible);
127}
128
130{
131 m_aHRuler->Show(_bShow);
132
133 m_aViewsWindow->showRuler(_bShow);
134}
135
137{
139 aStartWidth *= m_aViewsWindow->GetMapMode().GetScaleX();
140 return sal_Int32(static_cast<tools::Long>(aStartWidth));
141}
142
144{
145 sal_Int32 nWidth = 0;
146 if ( !m_aViewsWindow->empty() )
147 {
149 const Fraction aZoom(m_pView->getController().getZoomValue(),100);
150 aStartWidth *= aZoom;
151 sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_pView->getController().getReportDefinition(),PROPERTY_PAPERSIZE).Width;
152 nPaperWidth = tools::Long(nPaperWidth * aZoom);
153 const Size aPageSize = LogicToPixel(Size(nPaperWidth,0));
154 nWidth = aPageSize.Width() + tools::Long(aStartWidth);
155 }
156 return nWidth;
157}
158
160{
161 Window::Resize();
162 if ( m_aViewsWindow->empty() )
163 return;
164
165 const Size aTotalOutputSize = GetOutputSizePixel();
166 Fraction aStartWidth(tools::Long(REPORT_STARTMARKER_WIDTH)*m_pView->getController().getZoomValue(),100);
167
168 const Point aOffset = LogicToPixel(Point(SECTION_OFFSET, 0), MapMode(MapUnit::MapAppFont));
169 Point aStartPoint(static_cast<tools::Long>(aStartWidth) + aOffset.X(),0);
170 uno::Reference<report::XReportDefinition> xReportDefinition = getReportView()->getController().getReportDefinition();
171 const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width;
172 sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN);
173 sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN);
174 Size aPageSize = m_aViewsWindow->LogicToPixel(Size(nPaperWidth ,0));
175 nLeftMargin = m_aViewsWindow->LogicToPixel(Size(nLeftMargin,0)).Width();
176 nRightMargin = m_aViewsWindow->LogicToPixel(Size(nRightMargin,0)).Width();
177
178 aPageSize.setHeight( m_aHRuler->GetSizePixel().Height() );
179
180 const tools::Long nTermp(m_aViewsWindow->getTotalHeight() + aPageSize.Height());
181 tools::Long nSectionsHeight = ::std::max<tools::Long>(nTermp,aTotalOutputSize.Height());
182
183 m_aHRuler->SetPosSizePixel(aStartPoint,aPageSize);
184 m_aHRuler->SetNullOffset(nLeftMargin);
185 m_aHRuler->SetMargin1(0);
186 m_aHRuler->SetMargin2(aPageSize.Width() - nLeftMargin - nRightMargin);
187
188 aStartPoint.AdjustY(aPageSize.Height() );
189 nSectionsHeight -= aStartPoint.Y();
190
191 aStartPoint.setX( aOffset.X() );
192
193 m_aViewsWindow->SetPosSizePixel(aStartPoint,Size(aTotalOutputSize.Width(),nSectionsHeight));
194}
195
197{
198 return m_pParent->getThumbPos();
199}
200
202{
203 SetBackground( );
204}
205
207{
208 Window::DataChanged( rDCEvt );
209
210 if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
211 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
212 {
214 Invalidate();
215 }
216}
217
219{
220 return m_aViewsWindow->getTotalHeight();
221}
222
224{
225 MapMode aMap = m_aHRuler->GetMapMode();
226 Point aOrg( aMap.GetOrigin() );
227 if ( aOrg.X() != (-_aThumbPos.X()) )
228 {
229 aMap.SetOrigin( Point(- _aThumbPos.X(), aOrg.Y()));
230 m_aHRuler->SetMapMode( aMap );
231 m_aHRuler->Scroll(-(aOrg.X() + _aThumbPos.X()),0);
232 }
233
234 m_aViewsWindow->scrollChildren(_aThumbPos);
235}
236
238{
239 return m_aViewsWindow->getSectionCount();
240}
241
243{
244 m_pParent->setTotalSize(GetTotalWidth(),GetTotalHeight());
245}
246
248{
249 return m_aViewsWindow->HasSelection();
250}
251
253{
254
255 m_aViewsWindow->Delete();
256}
257
259{
260
261 m_aViewsWindow->Copy();
262}
263
265{
266
267 m_aViewsWindow->Paste();
268}
269
271{
272 return m_aViewsWindow->IsPasteAllowed();
273}
274
275void OReportWindow::SelectAll(const SdrObjKind _nObjectType)
276{
277
278 m_aViewsWindow->SelectAll(_nObjectType);
279}
280
282{
283
284 m_aViewsWindow->unmarkAllObjects(nullptr);
285}
286
287void OReportWindow::showProperties(const uno::Reference< report::XSection>& _xReportComponent)
288{
289 OSectionWindow* pSectionWindow = m_aViewsWindow->getSectionWindow( _xReportComponent );
290 m_pView->UpdatePropertyBrowserDelayed(pSectionWindow->getReportSection().getSectionView());
291}
292
294{
295 return m_aViewsWindow->handleKeyEvent(_rEvent);
296}
297
298void OReportWindow::setMarked(OSectionView const * _pSectionView, bool _bMark)
299{
300 if ( _pSectionView )
301 m_aViewsWindow->setMarked(_pSectionView,_bMark);
302}
303
304void OReportWindow::setMarked(const uno::Reference< report::XSection>& _xSection, bool _bMark)
305{
306
307 m_aViewsWindow->setMarked(_xSection,_bMark);
308}
309
310void OReportWindow::setMarked(const uno::Sequence< uno::Reference< report::XReportComponent> >& _xShape, bool _bMark)
311{
312
313 m_aViewsWindow->setMarked(_xShape,_bMark);
314}
315
317{
318 return m_aViewsWindow->getMarkedSection(nsa);
319}
320
321OSectionWindow* OReportWindow::getSectionWindow(const css::uno::Reference< css::report::XSection>& _xSection) const
322{
323 return m_aViewsWindow->getSectionWindow(_xSection);
324}
325
326void OReportWindow::markSection(const sal_uInt16 _nPos)
327{
328
329 m_aViewsWindow->markSection(_nPos);
330}
331
332void OReportWindow::fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const
333{
334
335 m_aViewsWindow->fillCollapsedSections(_rCollapsedPositions);
336}
337
338void OReportWindow::collapseSections(const uno::Sequence< css::beans::PropertyValue>& _aCollapsedSections)
339{
340
341 m_aViewsWindow->collapseSections(_aCollapsedSections);
342}
343
344void OReportWindow::alignMarkedObjects(ControlModification _nControlModification, bool _bAlignAtSection)
345{
346 m_aViewsWindow->alignMarkedObjects(_nControlModification, _bAlignAtSection);
347}
348
350{
351
352 m_aViewsWindow->setGridSnap(bOn);
353}
354
356{
357 m_aViewsWindow->setDragStripes(bOn);
358}
359
361{
362 return m_aViewsWindow->getMarkedObjectCount();
363}
364
365void OReportWindow::zoom(const Fraction& _aZoom)
366{
367 m_aHRuler->SetZoom(_aZoom);
368 m_aHRuler->Invalidate();
369
370 m_aViewsWindow->zoom(_aZoom);
371
373 const Point aNewThumbPos( m_pParent->getThumbPos() );
374
375 ScrollChildren( aNewThumbPos );
376 Resize();
377
378 Invalidate(InvalidateFlags::NoErase | InvalidateFlags::NoChildren | InvalidateFlags::Transparent);
379}
380
381void OReportWindow::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const
382{
383 m_aViewsWindow->fillControlModelSelection(_rSelection);
384}
385
387{
388 const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(m_pView->getController().getReportDefinition(),PROPERTY_PAPERSIZE).Width;
389 MapMode aMap( MapUnit::Map100thMM );
390 const Size aPageSize = LogicToPixel(Size(nPaperWidth,0),aMap);
392}
393
395{
396 sal_uInt16 nZoom(100);
397 const Size aSize( GetSizePixel() );
398 switch( _eType)
399 {
400 case SvxZoomType::PERCENT:
401 nZoom = m_pView->getController().getZoomValue();
402 break;
403 case SvxZoomType::OPTIMAL:
404 break;
405 case SvxZoomType::WHOLEPAGE:
406 {
407 nZoom = static_cast<sal_uInt16>(static_cast<tools::Long>(Fraction(aSize.Width()*100,impl_getRealPixelWidth())));
408 MapMode aMap( MapUnit::Map100thMM );
409 const Size aHeight = m_aViewsWindow->LogicToPixel(m_aViewsWindow->PixelToLogic(Size(0,GetTotalHeight() + m_aHRuler->GetSizePixel().Height())),aMap);
410 nZoom = ::std::min(nZoom,static_cast<sal_uInt16>(static_cast<tools::Long>(Fraction(aSize.Height()*100,aHeight.Height()))));
411 }
412 break;
413 case SvxZoomType::PAGEWIDTH:
414 nZoom = static_cast<sal_uInt16>(static_cast<tools::Long>(Fraction(aSize.Width()*100,impl_getRealPixelWidth())));
415 break;
416 default:
417 break;
418 }
419
420 return nZoom;
421}
422
423void OReportWindow::_propertyChanged(const beans::PropertyChangeEvent&)
424{
425 Resize();
426 m_aViewsWindow->Resize();
427 Invalidate(InvalidateFlags::Transparent);
428}
429
430} //rptui
431
432
433/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define REPORT_STARTMARKER_WIDTH
#define REPORT_ENDMARKER_WIDTH
#define SECTION_OFFSET
DataChangedEventType GetType() const
AllSettingsFlags GetFlags() const
MeasurementSystem getMeasurementSystemEnum() const
constexpr tools::Long Y() const
void setX(tools::Long nX)
tools::Long AdjustY(tools::Long nVertMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
const LocaleDataWrapper & GetLocaleData() const
void disposeAndClear()
OReportController & getController() const
Definition: DesignView.hxx:97
const css::uno::Reference< css::report::XReportDefinition > & getReportDefinition() const
gives access to the report definition
OSectionView & getSectionView() const
sal_uInt16 getSectionCount() const
VclPtr< ODesignView > m_pView
VclPtr< Ruler > m_aHRuler
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
sal_Int32 GetTotalWidth() const
returns the total width of the first section
void ScrollChildren(const Point &_aThumbPos)
bool handleKeyEvent(const KeyEvent &_rEvent)
checks if the keycode is known by the child windows
rtl::Reference< comphelper::OPropertyChangeMultiplexer > m_pReportListener
virtual void markSection(const sal_uInt16 _nPos) override
mark the section on the given position .
void addSection(const css::uno::Reference< css::report::XSection > &_xSection, const OUString &_sColorEntry, sal_uInt16 _nPosition)
adds a new section at position _nPosition.
bool HasSelection() const
returns <TRUE> when an object is marked
bool IsPasteAllowed() const
returns if paste is allowed
void setMarked(OSectionView const *_pSectionView, bool _bMark)
the section as marked or not marked
void showRuler(bool _bShow)
shows the ruler
void SetMode(DlgEdMode m_eMode)
void zoom(const Fraction &_aZoom)
zoom the ruler and view windows
void SetInsertObj(SdrObjKind eObj, const OUString &_sShapeType)
virtual void Resize() override
void Delete()
Deletes the current selection in this section.
OSectionWindow * getMarkedSection(NearSectionAccess nsa=CURRENT) const override
returns the section which is currently marked.
void Copy()
copies the current selection in this section
virtual ~OReportWindow() override
sal_uInt32 getMarkedObjectCount() const
sal_Int32 getMaxMarkerWidth() const
calculate the max width of the markers The end marker will not be used for calculation.
void unmarkAllObjects()
unmark all objects on the views without the given one.
void SelectAll(const SdrObjKind _nObjectType)
All objects will be marked.
void removeSection(sal_uInt16 _nPosition)
removes the section at the given position.
ODesignView * getReportView() const
VclPtr< OViewsWindow > m_aViewsWindow
VclPtr< OScrollWindowHelper > m_pParent
sal_Int32 GetTotalHeight() const
OSectionWindow * getSectionWindow(const css::uno::Reference< css::report::XSection > &_xSection) const
void showProperties(const css::uno::Reference< css::report::XSection > &_xReportComponent)
triggers the property browser with the report component or section
virtual void dispose() override
void fillCollapsedSections(::std::vector< sal_uInt16 > &_rCollapsedPositions) const
fills the positions of all collapsed sections.
OUString const & GetInsertObjString() const
sal_uInt16 getZoomFactor(SvxZoomType _eType) const
calculates the zoom factor.
Point getThumbPos() const
void alignMarkedObjects(ControlModification _nControlModification, bool _bAlignAtSection)
align all marked objects in all sections
virtual void _propertyChanged(const css::beans::PropertyChangeEvent &_rEvent) override
void setGridSnap(bool bOn)
void Paste()
paste a new control in this section
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...
sal_Int32 impl_getRealPixelWidth() const
void setDragStripes(bool bOn)
void collapseSections(const css::uno::Sequence< css::beans::PropertyValue > &_aCollapsedSections)
collapse all sections given by their position
void toggleGrid(bool _bVisible)
turns the grid on or off
OReportWindow(OReportWindow const &)=delete
OReportSection & getReportSection()
virtual void dispose() override
Point LogicToPixel(const Point &rLogicPt) const
void SetMapMode()
virtual Size GetSizePixel() const
Size GetOutputSizePixel() const
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
void SetHelpId(const OUString &)
void SetBackground()
constexpr OUStringLiteral UID_RPT_REPORTWINDOW
Definition: helpids.h:30
std::mutex m_aMutex
MeasurementSystem
tools::Long const nRightMargin
tools::Long const nLeftMargin
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
::rtl::Reference< comphelper::OPropertyChangeMultiplexer > addStyleListener(const css::uno::Reference< css::report::XReportDefinition > &_xReportDefinition,::comphelper::OPropertyChangeListener *_pListener)
add a listener for the properties size, left margin, right margin to the page style
ControlModification
Definition: RptDef.hxx:49
long Long
HashMap_OWString_Interface aMap
constexpr OUStringLiteral PROPERTY_RIGHTMARGIN
Definition: strings.hxx:103
constexpr OUStringLiteral PROPERTY_LEFTMARGIN
Definition: strings.hxx:102
constexpr OUStringLiteral PROPERTY_PAPERSIZE
Definition: strings.hxx:62
SdrObjKind
WinBits const WB_DIALOGCONTROL
sal_Int32 _nPos
SvxZoomType