LibreOffice Module reportdesign (master) 1
SectionView.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 <SectionView.hxx>
20#include <DesignView.hxx>
21#include <RptPage.hxx>
22#include <RptObject.hxx>
23#include <RptDef.hxx>
24#include <svx/svddrgmt.hxx>
25#include <ReportSection.hxx>
26#include <ReportWindow.hxx>
27#include <strings.hxx>
29
30namespace rptui
31{
32 using namespace ::com::sun::star;
33
35 SdrModel& rSdrModel,
36 OReportSection* _pSectionWindow,
37 OReportWindow* pEditor)
38: SdrView(rSdrModel, _pSectionWindow->GetOutDev())
39 ,m_pReportWindow( pEditor )
40 ,m_pSectionWindow(_pSectionWindow)
41{
47}
48
49
51{
52}
53
54
56{
58
59 if ( m_pReportWindow && m_pSectionWindow && !m_pSectionWindow->getPage()->getSpecialMode() )
60 {
62 m_pReportWindow->getReportView()->Broadcast( aHint );
63 m_pReportWindow->getReportView()->UpdatePropertyBrowserDelayed(*this);
64 }
65}
66
67
69{
70 // visible area
71 MapMode aMap( rWin.GetMapMode() );
72 const Point aOrg( aMap.GetOrigin() );
73 const Size aVisSize( rWin.GetOutDev()->GetOutputSize() );
74 const tools::Rectangle aVisRect( Point(-aOrg.X(),-aOrg.Y()), aVisSize );
75
76 // check, if rectangle is inside visible area
77 if ( !aVisRect.Contains( rRect ) )
78 {
79 // calculate scroll distance; the rectangle must be inside the visible area
80 sal_Int32 nScrollX = 0, nScrollY = 0;
81
82 const sal_Int32 nVisLeft = aVisRect.Left();
83 const sal_Int32 nVisRight = aVisRect.Right();
84 const sal_Int32 nVisTop = aVisRect.Top();
85 const sal_Int32 nVisBottom = aVisRect.Bottom();
86
87 // don't scroll beyond the page size
88 Size aPageSize = m_pSectionWindow->getPage()->GetSize();
89 const sal_Int32 nPageWidth = aPageSize.Width();
90 const sal_Int32 nPageHeight = aPageSize.Height();
91
92 if ( nVisRight + nScrollX > nPageWidth )
93 nScrollX = nPageWidth - nVisRight;
94
95 if ( nVisLeft + nScrollX < 0 )
96 nScrollX = -nVisLeft;
97
98 if ( nVisBottom + nScrollY > nPageHeight )
99 nScrollY = nPageHeight - nVisBottom;
100
101 if ( nVisTop + nScrollY < 0 )
102 nScrollY = -nVisTop;
103
104 // scroll window
105 rWin.PaintImmediately();
106 rWin.Scroll( -nScrollX, -nScrollY );
107 aMap.SetOrigin( Point( aOrg.X() - nScrollX, aOrg.Y() - nScrollY ) );
108 rWin.SetMapMode( aMap );
109 rWin.Invalidate();
110
111 if ( m_pReportWindow )
112 {
114 m_pReportWindow->getReportView()->Broadcast( aHint );
115 }
116 }
117 else
118 {
119 rWin.Invalidate(InvalidateFlags::NoErase);
120 }
121}
122
124{
125 SdrView::Notify(rBC,rHint);
126 if (rHint.GetId() != SfxHintId::ThisIsAnSdrHint)
127 return;
128 const SdrHint* pSdrHint = static_cast<const SdrHint*>(&rHint);
129 const SdrObject* pObj = pSdrHint->GetObject();
130 const SdrHintKind eKind = pSdrHint->GetKind();
131 // check for change of selected object
132 if(SdrHintKind::ObjectChange == eKind && pObj && IsObjMarked(pObj))
134 else if ( eKind == SdrHintKind::ObjectRemoved )
136}
137
138
140{
141 const SdrMarkList& rMarkedList = GetMarkedObjectList();
142 const size_t nMark = rMarkedList.GetMarkCount();
143
144 for( size_t i = 0; i < nMark; ++i )
145 {
146 SdrObject* pSdrObj = rMarkedList.GetMark(i)->GetMarkedSdrObj();
147 if (_pObject == pSdrObj)
148 {
149 SdrPageView* pPgView = GetSdrPageView();
150 BrkAction();
151 MarkObj( pSdrObj, pPgView, true );
152 break;
153 }
154 }
155}
156
157
159{
160 if (!AreObjectsMarked())
161 return;
162
163 // #i11702# use SdrUndoObjectLayerChange for undo
164 // STR_UNDO_SELATTR is "Attributes" - should use a different text later
165 BegUndo( );
166
167 const SdrMarkList& rMark = GetMarkedObjectList();
168 const size_t nCount = rMark.GetMarkCount();
169 for (size_t i = 0; i<nCount; ++i)
170 {
171 SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
172 if ( dynamic_cast< const OCustomShape *>( pObj ) != nullptr )
173 {
174 AddUndo( std::make_unique<SdrUndoObjectLayerChange>( *pObj, pObj->GetLayer(), _nLayerNo) );
175 pObj->SetLayer( _nLayerNo );
176 OObjectBase& rBaseObj = dynamic_cast<OObjectBase&>(*pObj);
177 try
178 {
179 rBaseObj.getReportComponent()->setPropertyValue(PROPERTY_OPAQUE,uno::Any(_nLayerNo == RPT_LAYER_FRONT));
180 }
181 catch(const uno::Exception&)
182 {
183 DBG_UNHANDLED_EXCEPTION("reportdesign");
184 }
185 }
186 }
187
188 EndUndo();
189
190 // check mark list now instead of later in a timer
191 CheckMarked();
193}
194
196{
197 const SdrMarkList& rMark = GetMarkedObjectList();
198 const size_t nCount = rMark.GetMarkCount();
199 if ( !nCount )
200 return false;
201 for (size_t i = 0; i<nCount; ++i)
202 {
203 SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
204 if ( dynamic_cast< const OCustomShape *>( pObj ) == nullptr )
205 {
206 return false;
207 }
208 }
209 return true;
210}
211
213{
214 const SdrDragMethod* pDragMethod = GetDragMethod();
215 if (pDragMethod)
216 {
217 bool bMoveOnly = pDragMethod->getMoveOnly();
218 if (!bMoveOnly)
219 {
220 // current marked components will be resized
221 return true;
222 }
223 }
224 return false;
225}
226
227
229{
231 const SdrMarkList &rMrkList = GetMarkedObjectList();
232 for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
233 {
234 const SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
235 if ( nRet == SDRLAYER_NOTFOUND )
236 nRet = pObj->GetLayer();
237 else if ( nRet != pObj->GetLayer() )
238 {
239 break;
240 }
241 }
242 return nRet;
243}
244
245
246} // rptui
247
248
249/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Size GetOutputSize() const
constexpr tools::Long Y() const
constexpr tools::Long X() const
virtual void BrkAction() override
bool getMoveOnly() const
SdrDragMethod * GetDragMethod() const
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
void BegUndo()
void EndUndo()
SdrHintKind GetKind() const
const SdrObject * GetObject() const
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
bool IsObjMarked(SdrObject const *pObj) const
const SdrMarkList & GetMarkedObjectList() const
bool AreObjectsMarked() const
void CheckMarked()
void AdjustMarkHdl(SfxViewShell *pOtherShell=nullptr)
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
SdrObject * GetMarkedSdrObj() const
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
virtual void MarkListHasChanged() override
void SetQuickTextEditMode(bool bOn)
virtual SdrLayerID GetLayer() const
virtual void SetLayer(SdrLayerID nLayer)
void SetBufferedOverlayAllowed(bool bNew)
void SetBordVisible(bool bOn=true)
SdrPageView * GetSdrPageView() const
void SetPageBorderVisible(bool bOn=true)
void SetBufferedOutputAllowed(bool bNew)
SfxHintId GetId() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
VclPtr< OReportSection > m_pSectionWindow
Definition: SectionView.hxx:38
virtual ~OSectionView() override
Definition: SectionView.cxx:50
bool IsDragResize() const
void ObjectRemovedInAliveMode(const SdrObject *pObject)
bool OnlyShapesMarked() const
void SetMarkedToLayer(SdrLayerID nLayerNo)
virtual void MakeVisible(const tools::Rectangle &rRect, vcl::Window &rWin) override
Definition: SectionView.cxx:68
VclPtr< OReportWindow > m_pReportWindow
Definition: SectionView.hxx:37
SdrLayerID GetLayerIdOfMarkedObjects() const
OSectionView(const OSectionView &)=delete
virtual void MarkListHasChanged() override
Definition: SectionView.cxx:55
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
bool Contains(const Point &rPOINT) const
constexpr tools::Long Top() const
constexpr tools::Long Right() const
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
void PaintImmediately()
void SetMapMode()
const MapMode & GetMapMode() const
::OutputDevice const * GetOutDev() const
virtual void Scroll(tools::Long nHorzScroll, tools::Long nVertScroll, ScrollFlags nFlags=ScrollFlags::NONE)
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
int nCount
#define DBG_UNHANDLED_EXCEPTION(...)
int i
@ RPTUI_HINT_WINDOWSCROLLED
Definition: RptObject.hxx:40
@ RPTUI_HINT_SELECTIONCHANGED
Definition: RptObject.hxx:41
constexpr SdrLayerID RPT_LAYER_FRONT(0)
HashMap_OWString_Interface aMap
constexpr OUStringLiteral PROPERTY_OPAQUE
Definition: strings.hxx:201
SdrHintKind
constexpr SdrLayerID SDRLAYER_NOTFOUND(-1)
const tools::Long nScrollX
const tools::Long nScrollY