LibreOffice Module reportdesign (master) 1
ReportSection.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 <memory>
20#include <ReportSection.hxx>
21#include <ReportWindow.hxx>
22#include <DesignView.hxx>
23#include <strings.hxx>
24#include <RptObject.hxx>
25#include <RptModel.hxx>
26#include <SectionView.hxx>
27#include <RptPage.hxx>
28#include <ReportController.hxx>
29#include <UITools.hxx>
30#include <ViewsWindow.hxx>
31
32#include <svx/svdpagv.hxx>
34#include <editeng/eeitem.hxx>
36#include <svx/gallery.hxx>
37#include <svx/svxids.hrc>
38#include <svx/svditer.hxx>
39#include <svx/dbaexchange.hxx>
40#include <svx/sdtagitm.hxx>
41
42#include <com/sun/star/awt/PopupMenuDirection.hpp>
43#include <com/sun/star/frame/XPopupMenuController.hpp>
48#include <RptDef.hxx>
49#include <SectionWindow.hxx>
50#include <helpids.h>
51#include <dlgedclip.hxx>
52#include <rptui_slotid.hrc>
53
54#include <utility>
55#include <vcl/commandevent.hxx>
56#include <o3tl/safeint.hxx>
57
58#include <svl/itempool.hxx>
60
61
62namespace rptui
63{
64
65using namespace ::com::sun::star;
66
67
68static Color lcl_getOverlappedControlColor(/*const uno::Reference <lang::XMultiServiceFactory> _rxFactory*/)
69{
72}
73
74OReportSection::OReportSection(OSectionWindow* _pParent,uno::Reference< report::XSection > _xSection)
75 : Window(_pParent,WB_DIALOGCONTROL)
76 , ::comphelper::OPropertyChangeListener(m_aMutex)
77 , DropTargetHelper(this)
78 , m_pPage(nullptr)
79 , m_pView(nullptr)
80 , m_pParent(_pParent)
81 , m_xSection(std::move(_xSection))
82 , m_nPaintEntranceCount(0)
83 , m_eMode(DlgEdMode::Select)
84{
85 //EnableChildTransparentMode();
87 SetMapMode(MapMode(MapUnit::Map100thMM));
88 SetParentClipMode(ParentClipMode::Clip);
89 EnableChildTransparentMode( false );
90 SetPaintTransparent( false );
91
92 try
93 {
94 fill();
95 }
96 catch(uno::Exception&)
97 {
98 TOOLS_WARN_EXCEPTION( "reportdesign", "");
99 }
100
101 m_pFunc.reset(new DlgEdFuncSelect( this ));
102 m_pFunc->setOverlappedControlColor(lcl_getOverlappedControlColor() );
103}
104
105OReportSection::~OReportSection()
106{
107 disposeOnce();
108}
109
110void OReportSection::dispose()
111{
112 m_pPage = nullptr;
113 if ( m_pMulti.is() )
114 m_pMulti->dispose();
115 m_pMulti.clear();
116
117 if ( m_pReportListener.is() )
118 m_pReportListener->dispose();
119 m_pReportListener.clear();
120 m_pFunc.reset();
121
122 {
123 if ( m_pView )
124 m_pView->EndListening( *m_pModel );
125 delete m_pView;
126 m_pView = nullptr;
127 }
128 m_pParent.clear();
130}
131
132void OReportSection::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect )
133{
134 Window::Paint(rRenderContext, rRect);
135
136 if ( !(m_pView && m_nPaintEntranceCount == 0))
137 return;
138
139 ++m_nPaintEntranceCount;
140 // repaint, get PageView and prepare Region
141 SdrPageView* pPgView = m_pView->GetSdrPageView();
142 const vcl::Region aPaintRectRegion(rRect);
143
144 // #i74769#
145 SdrPaintWindow* pTargetPaintWindow = nullptr;
146
147 // mark repaint start
148 if (pPgView)
149 {
150 pTargetPaintWindow = pPgView->GetView().BeginDrawLayers(GetOutDev(), aPaintRectRegion);
151 OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
152 // draw background self using wallpaper
153 OutputDevice& rTargetOutDev = pTargetPaintWindow->GetTargetOutputDevice();
154 rTargetOutDev.DrawWallpaper(rRect, Wallpaper(pPgView->GetApplicationDocumentColor()));
155
156 // do paint (unbuffered) and mark repaint end
157 pPgView->DrawLayer(RPT_LAYER_FRONT, &rRenderContext);
158 pPgView->GetView().EndDrawLayers(*pTargetPaintWindow, true);
159 }
160
161 m_pView->CompleteRedraw(&rRenderContext, aPaintRectRegion);
162 --m_nPaintEntranceCount;
163}
164
165void OReportSection::fill()
166{
167 if ( !m_xSection.is() )
168 return;
169
170 m_pMulti = new comphelper::OPropertyChangeMultiplexer(this,m_xSection);
171 m_pMulti->addProperty(PROPERTY_BACKCOLOR);
172
173 m_pReportListener = addStyleListener(m_xSection->getReportDefinition(),this);
174
175 m_pModel = m_pParent->getViewsWindow()->getView()->getReportView()->getController().getSdrModel();
176 m_pPage = m_pModel->getPage(m_xSection);
177
178 m_pView = new OSectionView(
179 *m_pModel,
180 this,
181 m_pParent->getViewsWindow()->getView());
182
183 // #i93597# tell SdrPage that only left and right page border is defined
184 // instead of the full rectangle definition
185 m_pPage->setPageBorderOnlyLeftRight(true);
186
187 // without the following call, no grid is painted
188 m_pView->ShowSdrPage( m_pPage );
189
190 m_pView->SetMoveSnapOnlyTopLeft( true );
191 ODesignView* pDesignView = m_pParent->getViewsWindow()->getView()->getReportView();
192
193 // #i93595# Adapted grid to a more coarse grid and subdivisions for better visualisation. This
194 // is only for visualisation and has nothing to do with the actual snap
195 const Size aGridSizeCoarse(pDesignView->getGridSizeCoarse());
196 const Size aGridSizeFine(pDesignView->getGridSizeFine());
197 m_pView->SetGridCoarse(aGridSizeCoarse);
198 m_pView->SetGridFine(aGridSizeFine);
199
200 // #i93595# set snap grid width to snap to all existing subdivisions
201 const Fraction aX(aGridSizeFine.Width());
202 const Fraction aY(aGridSizeFine.Height());
203 m_pView->SetSnapGridWidth(aX, aY);
204
205 m_pView->SetGridSnap( true );
206 m_pView->SetGridFront( false );
207 m_pView->SetDragStripes( true );
208 m_pView->SetPageVisible();
209 sal_Int32 nColor = m_xSection->getBackColor();
210 if ( nColor == static_cast<sal_Int32>(COL_TRANSPARENT) )
211 nColor = getStyleProperty<sal_Int32>(m_xSection->getReportDefinition(),PROPERTY_BACKCOLOR);
212 m_pView->SetApplicationDocumentColor(Color(ColorTransparency, nColor));
213
214 uno::Reference<report::XReportDefinition> xReportDefinition = m_xSection->getReportDefinition();
215 const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN);
216 const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN);
217 m_pPage->SetLeftBorder(nLeftMargin);
218 m_pPage->SetRightBorder(nRightMargin);
219
220// LLA: TODO
221// m_pPage->SetUpperBorder(-10000);
222
223 m_pView->SetDesignMode();
224
225 m_pPage->SetSize( Size( getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width,5*m_xSection->getHeight()) );
226 const Size aPageSize = m_pPage->GetSize();
227 m_pView->SetWorkArea( tools::Rectangle( Point( nLeftMargin, 0), Size(aPageSize.Width() - nLeftMargin - nRightMargin,aPageSize.Height()) ) );
228}
229
230void OReportSection::Paste(const uno::Sequence< beans::NamedValue >& _aAllreadyCopiedObjects,bool _bForce)
231{
232 OSL_ENSURE(m_xSection.is(),"Why is the section here NULL!");
233 if ( !(m_xSection.is() && _aAllreadyCopiedObjects.hasElements()) )
234 return;
235
236 // stop all drawing actions
237 m_pView->BrkAction();
238
239 // unmark all objects
240 m_pView->UnmarkAll();
241 const OUString sSectionName = m_xSection->getName();
242 for(const beans::NamedValue& rObject : _aAllreadyCopiedObjects)
243 {
244 if ( _bForce || rObject.Name == sSectionName)
245 {
246 try
247 {
248 uno::Sequence< uno::Reference<report::XReportComponent> > aCopies;
249 rObject.Value >>= aCopies;
250 for (const uno::Reference<report::XReportComponent>& rCopy : std::as_const(aCopies))
251 {
253 if ( pObject )
254 {
255 // Clone to target SdrModel
256 rtl::Reference<SdrObject> pNewObj(pObject->CloneSdrObject(*m_pModel));
257 m_pPage->InsertObject(pNewObj.get(), SAL_MAX_SIZE);
258 tools::Rectangle aRet(VCLPoint(rCopy->getPosition()),VCLSize(rCopy->getSize()));
259 aRet.setHeight(aRet.getOpenHeight() + 1);
260 aRet.setWidth(aRet.getOpenWidth() + 1);
261 bool bOverlapping = true;
262 while ( bOverlapping )
263 {
264 bOverlapping = isOver(aRet,*m_pPage,*m_pView,true,pNewObj.get()) != nullptr;
265 if ( bOverlapping )
266 {
267 aRet.Move(0,aRet.getOpenHeight()+1);
268 pNewObj->SetLogicRect(aRet);
269 }
270 }
271 m_pView->AddUndo(m_pView->GetModel().GetSdrUndoFactory().CreateUndoNewObject(*pNewObj));
272 m_pView->MarkObj( pNewObj.get(), m_pView->GetSdrPageView() );
273 if ( m_xSection.is() && (o3tl::make_unsigned(aRet.getOpenHeight() + aRet.Top()) > m_xSection->getHeight()) )
274 m_xSection->setHeight(aRet.getOpenHeight() + aRet.Top());
275 }
276 }
277 }
278 catch(uno::Exception&)
279 {
280 TOOLS_WARN_EXCEPTION( "reportdesign", "Exception caught while pasting a new object!");
281 }
282 if ( !_bForce )
283 break;
284 }
285 }
286}
287
288void OReportSection::Delete()
289{
290 if( !m_pView->AreObjectsMarked() )
291 return;
292
293 m_pView->BrkAction();
294 m_pView->DeleteMarked();
295}
296
297void OReportSection::SetMode( DlgEdMode eNewMode )
298{
299 if ( eNewMode == m_eMode )
300 return;
301
302 if ( eNewMode == DlgEdMode::Insert )
303 {
304 m_pFunc.reset(new DlgEdFuncInsert( this ));
305 }
306 else
307 {
308 m_pFunc.reset(new DlgEdFuncSelect( this ));
309 }
310 m_pFunc->setOverlappedControlColor(lcl_getOverlappedControlColor( ) );
311 m_pModel->SetReadOnly(false);
312 m_eMode = eNewMode;
313}
314
315void OReportSection::Copy(uno::Sequence< beans::NamedValue >& _rAllreadyCopiedObjects)
316{
317 Copy(_rAllreadyCopiedObjects,false);
318}
319
320void OReportSection::Copy(uno::Sequence< beans::NamedValue >& _rAllreadyCopiedObjects,bool _bEraseAnddNoClone)
321{
322 OSL_ENSURE(m_xSection.is(),"Why is the section here NULL!");
323 if( !m_pView->AreObjectsMarked() || !m_xSection.is() )
324 return;
325
326 // insert control models of marked objects into clipboard dialog model
327 const SdrMarkList& rMarkedList = m_pView->GetMarkedObjectList();
328 const size_t nMark = rMarkedList.GetMarkCount();
329
330 ::std::vector< uno::Reference<report::XReportComponent> > aCopies;
331 aCopies.reserve(nMark);
332
333 SdrUndoFactory& rUndo = m_pView->GetModel().GetSdrUndoFactory();
334
335 for( size_t i = nMark; i > 0; )
336 {
337 --i;
338 SdrObject* pSdrObject = rMarkedList.GetMark(i)->GetMarkedSdrObj();
339 OObjectBase* pObj = dynamic_cast<OObjectBase*>(pSdrObject);
340 if ( pObj )
341 {
342 try
343 {
344 rtl::Reference<SdrObject> pNewObj(pSdrObject->CloneSdrObject(pSdrObject->getSdrModelFromSdrObject()));
345 aCopies.emplace_back(pNewObj->getUnoShape(),uno::UNO_QUERY);
346 if ( _bEraseAnddNoClone )
347 {
348 m_pView->AddUndo( rUndo.CreateUndoDeleteObject( *pSdrObject ) );
349 m_pPage->RemoveObject(pSdrObject->GetOrdNum());
350 }
351
352 }
353 catch(uno::Exception&)
354 {
355 OSL_FAIL("Can't copy report elements!");
356 }
357 }
358 }
359
360 if ( !aCopies.empty() )
361 {
362 ::std::reverse(aCopies.begin(),aCopies.end());
363 const sal_Int32 nLength = _rAllreadyCopiedObjects.getLength();
364 _rAllreadyCopiedObjects.realloc( nLength + 1);
365 beans::NamedValue* pNewValue = _rAllreadyCopiedObjects.getArray() + nLength;
366 pNewValue->Name = m_xSection->getName();
367 pNewValue->Value <<= uno::Sequence< uno::Reference<report::XReportComponent> >(&(*aCopies.begin()),aCopies.size());
368 }
369}
370
371void OReportSection::MouseButtonDown( const MouseEvent& rMEvt )
372{
373 m_pParent->getViewsWindow()->getView()->setMarked(m_pView, true); // mark the section in which is clicked
374 m_pFunc->MouseButtonDown( rMEvt );
375 Window::MouseButtonDown(rMEvt);
376}
377
378void OReportSection::MouseButtonUp( const MouseEvent& rMEvt )
379{
380 if ( !m_pFunc->MouseButtonUp( rMEvt ) )
381 m_pParent->getViewsWindow()->getView()->getReportView()->getController().executeUnChecked(SID_OBJECT_SELECT,uno::Sequence< beans::PropertyValue>());
382}
383
384
385void OReportSection::MouseMove( const MouseEvent& rMEvt )
386{
387 m_pFunc->MouseMove( rMEvt );
388
389}
390
391void OReportSection::SetGridVisible(bool _bVisible)
392{
393 m_pView->SetGridVisible( _bVisible );
394}
395
396void OReportSection::SelectAll(const SdrObjKind _nObjectType)
397{
398 if ( !m_pView )
399 return;
400
401 if ( _nObjectType == SdrObjKind::NONE )
402 m_pView->MarkAllObj();
403 else
404 {
405 m_pView->UnmarkAll();
406 SdrObjListIter aIter(m_pPage,SdrIterMode::DeepNoGroups);
407 SdrObject* pObjIter = nullptr;
408 while( (pObjIter = aIter.Next()) != nullptr )
409 {
410 if ( pObjIter->GetObjIdentifier() == _nObjectType )
411 m_pView->MarkObj( pObjIter, m_pView->GetSdrPageView() );
412 }
413 }
414}
415
416void OReportSection::Command( const CommandEvent& _rCEvt )
417{
418 Window::Command(_rCEvt);
419 if (_rCEvt.GetCommand() != CommandEventId::ContextMenu)
420 return;
421
422 OReportController& rController = m_pParent->getViewsWindow()->getView()->getReportView()->getController();
423 uno::Reference<frame::XFrame> xFrame = rController.getFrame();
424 css::uno::Sequence<css::uno::Any> aArgs {
425 css::uno::Any(comphelper::makePropertyValue("Value", OUString("report"))),
426 css::uno::Any(comphelper::makePropertyValue("Frame", xFrame)),
427 css::uno::Any(comphelper::makePropertyValue("IsContextMenu", true))
428 };
429
430 css::uno::Reference<css::uno::XComponentContext> xContext(rController.getORB());
431 css::uno::Reference<css::frame::XPopupMenuController> xMenuController(
432 xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
433 "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), css::uno::UNO_QUERY);
434
435 if (!xMenuController.is())
436 return;
437
439
440 if (!xPopupMenu.is())
441 return;
442
443 xMenuController->setPopupMenu(xPopupMenu);
444
445 Point aPos = _rCEvt.GetMousePosPixel();
446 m_pView->EndAction();
447
448 xPopupMenu->execute(GetComponentInterface(),
449 css::awt::Rectangle(aPos.X(), aPos.Y(), 1, 1),
450 css::awt::PopupMenuDirection::EXECUTE_DOWN);
451
452 css::uno::Reference<css::lang::XComponent> xComponent(xMenuController, css::uno::UNO_QUERY);
453 xComponent->dispose();
454}
455
456void OReportSection::_propertyChanged(const beans::PropertyChangeEvent& _rEvent)
457{
458 if ( !m_xSection.is() )
459 return;
460
461 if ( _rEvent.Source == m_xSection || PROPERTY_BACKCOLOR == _rEvent.PropertyName )
462 {
463 sal_Int32 nColor = m_xSection->getBackColor();
464 if ( nColor == static_cast<sal_Int32>(COL_TRANSPARENT) )
465 nColor = getStyleProperty<sal_Int32>(m_xSection->getReportDefinition(),PROPERTY_BACKCOLOR);
466 m_pView->SetApplicationDocumentColor(Color(ColorTransparency, nColor));
467 Invalidate(InvalidateFlags::NoChildren|InvalidateFlags::NoErase);
468 }
469 else
470 {
471 uno::Reference<report::XReportDefinition> xReportDefinition = m_xSection->getReportDefinition();
472 const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN);
473 const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN);
474 const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width;
475
476 if ( _rEvent.PropertyName == PROPERTY_LEFTMARGIN )
477 {
478 m_pPage->SetLeftBorder(nLeftMargin);
479 }
480 else if ( _rEvent.PropertyName == PROPERTY_RIGHTMARGIN )
481 {
482 m_pPage->SetRightBorder(nRightMargin);
483 }
484 const Size aOldPageSize = m_pPage->GetSize();
485 sal_Int32 nNewHeight = 5*m_xSection->getHeight();
486 if ( aOldPageSize.Height() != nNewHeight || nPaperWidth != aOldPageSize.Width() )
487 {
488 m_pPage->SetSize( Size( nPaperWidth,nNewHeight) );
489 const Size aPageSize = m_pPage->GetSize();
490 m_pView->SetWorkArea( tools::Rectangle( Point( nLeftMargin, 0), Size(aPageSize.Width() - nLeftMargin - nRightMargin,aPageSize.Height()) ) );
491 }
492 impl_adjustObjectSizePosition(nPaperWidth,nLeftMargin,nRightMargin);
493 m_pParent->Invalidate(InvalidateFlags::Update | InvalidateFlags::Transparent);
494 }
495}
496void OReportSection::impl_adjustObjectSizePosition(sal_Int32 i_nPaperWidth,sal_Int32 i_nLeftMargin,sal_Int32 i_nRightMargin)
497{
498 try
499 {
500 sal_Int32 nRightBorder = i_nPaperWidth - i_nRightMargin;
501 const sal_Int32 nCount = m_xSection->getCount();
502 for (sal_Int32 i = 0; i < nCount; ++i)
503 {
504 uno::Reference< report::XReportComponent> xReportComponent(m_xSection->getByIndex(i),uno::UNO_QUERY_THROW);
505 awt::Point aPos = xReportComponent->getPosition();
506 awt::Size aSize = xReportComponent->getSize();
508 if ( pObject )
509 {
510 bool bChanged = false;
511
512 OObjectBase& rBase = dynamic_cast<OObjectBase&>(*pObject);
513 rBase.EndListening();
514 if ( aPos.X < i_nLeftMargin )
515 {
516 aPos.X = i_nLeftMargin;
517 bChanged = true;
518 }
519 if ( (aPos.X + aSize.Width) > nRightBorder )
520 {
521 aPos.X = nRightBorder - aSize.Width;
522 if ( aPos.X < i_nLeftMargin )
523 {
524 aSize.Width += aPos.X - i_nLeftMargin;
525 aPos.X = i_nLeftMargin;
526 // add listener around
527 rBase.StartListening();
528 xReportComponent->setSize(aSize);
529 rBase.EndListening();
530 }
531 bChanged = true;
532 }
533 if ( aPos.Y < 0 )
534 aPos.Y = 0;
535 if ( bChanged )
536 {
537 xReportComponent->setPosition(aPos);
538 correctOverlapping(pObject,*this,false);
539 tools::Rectangle aRet(VCLPoint(xReportComponent->getPosition()),VCLSize(xReportComponent->getSize()));
540 aRet.setHeight(aRet.getOpenHeight() + 1);
541 aRet.setWidth(aRet.getOpenWidth() + 1);
542 if ( m_xSection.is() && (o3tl::make_unsigned(aRet.getOpenHeight() + aRet.Top()) > m_xSection->getHeight()) )
543 m_xSection->setHeight(aRet.getOpenHeight() + aRet.Top());
544
545 pObject->RecalcBoundRect();
546 }
547 rBase.StartListening();
548 }
549 }
550 }
551 catch(const uno::Exception &)
552 {
553 TOOLS_WARN_EXCEPTION( "reportdesign", "OReportSection::impl_adjustObjectSizePosition()");
554 }
555}
556
557bool OReportSection::handleKeyEvent(const KeyEvent& _rEvent)
558{
559 return m_pFunc && m_pFunc->handleKeyEvent(_rEvent);
560}
561
562void OReportSection::deactivateOle()
563{
564 if (m_pFunc)
565 m_pFunc->deactivateOle(true);
566}
567
568void OReportSection::createDefault(const OUString& _sType)
569{
570 SdrObject* pObj = m_pView->GetCreateObj();
571 if ( !pObj )
572 return;
573 createDefault(_sType,pObj);
574}
575
576void OReportSection::createDefault(const OUString& _sType,SdrObject* _pObj)
577{
578 bool bAttributesAppliedFromGallery = false;
579
581 {
582 std::vector< OUString > aObjList;
584 {
585 auto aIter = std::find_if(aObjList.begin(), aObjList.end(),
586 [&_sType](const OUString& rObj) { return rObj.equalsIgnoreAsciiCase(_sType); });
587 if (aIter != aObjList.end())
588 {
589 auto i = static_cast<sal_uInt32>(std::distance(aObjList.begin(), aIter));
590 OReportModel aReportModel(nullptr);
591 SfxItemPool& rPool = aReportModel.GetItemPool();
592 rPool.FreezeIdRanges();
594 {
595 const SdrObject* pSourceObj = aReportModel.GetPage( 0 )->GetObj( 0 );
596 if( pSourceObj )
597 {
598 const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
600 // Ranges from SdrAttrObj:
605 // Graphic attributes, 3D properties,
606 // CustomShape properties:
609 // Range from SdrTextObj:
611 aDest( _pObj->getSdrModelFromSdrObject().GetItemPool() );
612 aDest.Set( rSource );
613 _pObj->SetMergedItemSet( aDest );
614 Degree100 nAngle = pSourceObj->GetRotateAngle();
615 if ( nAngle )
616 _pObj->NbcRotate( _pObj->GetSnapRect().Center(), nAngle );
617 bAttributesAppliedFromGallery = true;
618 }
619 }
620 }
621 }
622 }
623 if ( !bAttributesAppliedFromGallery )
624 {
625 _pObj->SetMergedItem( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST) );
629 static_cast<SdrObjCustomShape*>(_pObj)->MergeDefaultAttributes( &_sType );
630 }
631}
632
633uno::Reference< report::XReportComponent > OReportSection::getCurrentControlModel() const
634{
635 uno::Reference< report::XReportComponent > xModel;
636 if ( m_pView )
637 {
638 const SdrMarkList& rMarkList = m_pView->GetMarkedObjectList();
639
640 if ( rMarkList.GetMarkCount() == 1 )
641 {
642 SdrObject* pDlgEdObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
643 OObjectBase* pObj = dynamic_cast<OObjectBase*>(pDlgEdObj);
644 if ( pObj )
645 xModel = pObj->getReportComponent().get();
646 }
647 }
648 return xModel;
649}
650
651void OReportSection::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const
652{
653 if ( !m_pView )
654 return;
655
656 const SdrMarkList& rMarkList = m_pView->GetMarkedObjectList();
657 const size_t nMarkCount = rMarkList.GetMarkCount();
658
659 for (size_t i=0; i < nMarkCount; ++i)
660 {
661 const SdrObject* pDlgEdObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
662 const OObjectBase* pObj = dynamic_cast<const OObjectBase*>(pDlgEdObj);
663 if ( pObj )
664 {
665 uno::Reference<uno::XInterface> xInterface(pObj->getReportComponent());
666 _rSelection.push_back(xInterface);
667 }
668 }
669}
670
671sal_Int8 OReportSection::AcceptDrop( const AcceptDropEvent& _rEvt )
672{
673 ::Point aDropPos(_rEvt.maPosPixel);
674 const MouseEvent aMouseEvt(aDropPos);
675 if ( m_pFunc->isOverlapping(aMouseEvt) )
676 return DND_ACTION_NONE;
677
678 if ( _rEvt.mnAction == DND_ACTION_COPY ||
680 )
681 {
682 if (!m_pParent) return DND_ACTION_NONE;
683 sal_uInt16 nCurrentPosition = m_pParent->getViewsWindow()->getPosition(m_pParent);
684 if (_rEvt.mnAction == DND_ACTION_COPY )
685 {
686 // we must assure, we can't drop in the top section
687 if (nCurrentPosition < 1)
688 {
689 return DND_ACTION_NONE;
690 }
691 return DND_ACTION_LINK;
692 }
693 if (_rEvt.mnAction == DND_ACTION_LINK)
694 {
695 // we must assure, we can't drop in the bottom section
696 if (m_pParent->getViewsWindow()->getSectionCount() > (nCurrentPosition + 1) )
697 {
698 return DND_ACTION_COPY;
699 }
700 return DND_ACTION_NONE;
701 }
702 }
703 else
704 {
705 const DataFlavorExVector& rFlavors = GetDataFlavorExVector();
707 || svx::OColumnTransferable::canExtractColumnDescriptor(rFlavors, ColumnTransferFormatFlags::FIELD_DESCRIPTOR | ColumnTransferFormatFlags::CONTROL_EXCHANGE | ColumnTransferFormatFlags::COLUMN_DESCRIPTOR) )
708 return _rEvt.mnAction;
709
710 const sal_Int8 nDropOption = ( OReportExchange::canExtract(rFlavors) ) ? DND_ACTION_COPYMOVE : DND_ACTION_NONE;
711
712 return nDropOption;
713 }
714 return DND_ACTION_NONE;
715}
716
717
718sal_Int8 OReportSection::ExecuteDrop( const ExecuteDropEvent& _rEvt )
719{
720 ::Point aDropPos(PixelToLogic(_rEvt.maPosPixel));
721 const MouseEvent aMouseEvt(aDropPos);
722 if ( m_pFunc->isOverlapping(aMouseEvt) )
723 return DND_ACTION_NONE;
724
725 sal_Int8 nDropOption = DND_ACTION_NONE;
726 const TransferableDataHelper aDropped(_rEvt.maDropEvent.Transferable);
727 const DataFlavorExVector& rFlavors = aDropped.GetDataFlavorExVector();
728 bool bMultipleFormat = svx::OMultiColumnTransferable::canExtractDescriptor(rFlavors);
729 if ( OReportExchange::canExtract(rFlavors) )
730 {
731 OReportExchange::TSectionElements aCopies = OReportExchange::extractCopies(aDropped);
732 Paste(aCopies,true);
733 nDropOption = DND_ACTION_COPYMOVE;
734 m_pParent->getViewsWindow()->BrkAction();
735 m_pParent->getViewsWindow()->unmarkAllObjects(m_pView);
736 }
737 else if ( bMultipleFormat
738 || svx::OColumnTransferable::canExtractColumnDescriptor(rFlavors, ColumnTransferFormatFlags::FIELD_DESCRIPTOR | ColumnTransferFormatFlags::CONTROL_EXCHANGE | ColumnTransferFormatFlags::COLUMN_DESCRIPTOR) )
739 {
740 m_pParent->getViewsWindow()->getView()->setMarked(m_pView, true);
741 m_pView->UnmarkAll();
742 const tools::Rectangle& rRect = m_pView->GetWorkArea();
743 if ( aDropPos.X() < rRect.Left() )
744 aDropPos.setX( rRect.Left() );
745 else if ( aDropPos.X() > rRect.Right() )
746 aDropPos.setX( rRect.Right() );
747
748 if ( aDropPos.Y() > rRect.Bottom() )
749 aDropPos.setY( rRect.Bottom() );
750
751 uno::Sequence<beans::PropertyValue> aValues;
752 if ( !bMultipleFormat )
753 {
755
756 aValues.realloc(1);
757 aValues.getArray()[0].Value <<= aDescriptor.createPropertyValueSequence();
758 }
759 else
761
762 for(beans::PropertyValue & propVal : asNonConstRange(aValues))
763 {
764 uno::Sequence<beans::PropertyValue> aCurrent;
765 propVal.Value >>= aCurrent;
766 sal_Int32 nLength = aCurrent.getLength();
767 if ( nLength )
768 {
769 aCurrent.realloc(nLength + 3);
770 auto pCurrent = aCurrent.getArray();
771 pCurrent[nLength].Name = PROPERTY_POSITION;
772 pCurrent[nLength++].Value <<= AWTPoint(aDropPos);
773 // give also the DND Action (Shift|Ctrl) Key to really say what we want
774 pCurrent[nLength].Name = "DNDAction";
775 pCurrent[nLength++].Value <<= _rEvt.mnAction;
776
777 pCurrent[nLength].Name = "Section";
778 pCurrent[nLength++].Value <<= getSection();
779 propVal.Value <<= aCurrent;
780 }
781 }
782
783 // we use this way to create undo actions
784 OReportController& rController = m_pParent->getViewsWindow()->getView()->getReportView()->getController();
785 rController.executeChecked(SID_ADD_CONTROL_PAIR,aValues);
786 nDropOption = DND_ACTION_COPY;
787 }
788 return nDropOption;
789}
790
791void OReportSection::stopScrollTimer()
792{
793 m_pFunc->stopScrollTimer();
794}
795
796bool OReportSection::isUiActive() const
797{
798 return m_pFunc->isUiActive();
799}
800
801
802}
803
804
805/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
CommandEventId GetCommand() const
const Point & GetMousePosPixel() const
static sal_uInt32 GetSdrObjCount(std::u16string_view rThemeName)
static bool FillObjListTitle(const sal_uInt32 nThemeId, std::vector< OUString > &rList)
static bool GetSdrObj(std::u16string_view rThemeName, sal_uInt32 nSdrModelPos, SdrModel *pModel, BitmapEx *pThumb=nullptr)
SAL_DLLPRIVATE void DrawWallpaper(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, const Wallpaper &rWallpaper)
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
constexpr tools::Long X() const
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
SdrObject * GetMarkedSdrObj() const
const SfxItemPool & GetItemPool() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
SdrObject * Next()
SdrObject * GetObj(size_t nNum) const
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
virtual Degree100 GetRotateAngle() const
sal_uInt32 GetOrdNum() const
void SetMergedItemSet(const SfxItemSet &rSet, bool bClearAllItems=false)
SdrModel & getSdrModelFromSdrObject() const
virtual const tools::Rectangle & GetSnapRect() const
virtual SdrObjKind GetObjIdentifier() const
virtual rtl::Reference< SdrObject > CloneSdrObject(SdrModel &rTargetModel) const=0
const SfxItemSet & GetMergedItemSet() const
void SetMergedItem(const SfxPoolItem &rItem)
virtual void NbcRotate(const Point &rRef, Degree100 nAngle, double sn, double cs)=0
void DrawLayer(SdrLayerID nID, OutputDevice *pGivenTarget, sdr::contact::ViewObjectContactRedirector *pRedirector=nullptr, const tools::Rectangle &rRect=tools::Rectangle(), basegfx::B2IRectangle const *pPageFrame=nullptr)
SdrView & GetView()
const Color & GetApplicationDocumentColor() const
void EndDrawLayers(SdrPaintWindow &rPaintWindow, bool bPaintFormLayer)
SdrPaintWindow * BeginDrawLayers(OutputDevice *pOut, const vcl::Region &rReg, bool bDisableIntersect=false)
OutputDevice & GetTargetOutputDevice()
virtual std::unique_ptr< SdrUndoAction > CreateUndoDeleteObject(SdrObject &rObject, bool bOrdNumDirect=false)
void FreezeIdRanges()
constexpr tools::Long getHeight() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const DataFlavorExVector & GetDataFlavorExVector() const
const Size & getGridSizeCoarse() const
Definition: DesignView.hxx:157
const Size & getGridSizeFine() const
Definition: DesignView.hxx:158
css::uno::Sequence< css::beans::NamedValue > TSectionElements
Definition: dlgedclip.hxx:39
OReportSection(OReportSection const &)=delete
ExtendedColorConfigValue GetColorValue(const OUString &_sComponentName, const OUString &_sName) const
static bool extractColumnDescriptor(const TransferableDataHelper &_rData, OUString &_rDatasource, OUString &_rDatabaseLocation, OUString &_rConnectionResource, sal_Int32 &_nCommandType, OUString &_rCommand, OUString &_rFieldName)
static bool canExtractColumnDescriptor(const DataFlavorExVector &_rFlavors, ColumnTransferFormatFlags _nFormats)
css::uno::Sequence< css::beans::PropertyValue > const & createPropertyValueSequence()
static css::uno::Sequence< css::beans::PropertyValue > extractDescriptor(const TransferableDataHelper &_rData)
static bool canExtractDescriptor(const DataFlavorExVector &_rFlavors)
constexpr Point Center() const
constexpr tools::Long Top() const
tools::Long getOpenHeight() const
void setWidth(tools::Long n)
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
constexpr tools::Long Right() const
void setHeight(tools::Long n)
tools::Long getOpenWidth() const
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
virtual void dispose() override
ColorTransparency
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
css::awt::Point AWTPoint(const ::Point &rVCLPoint)
inline ::Size VCLSize(const css::awt::Size &rAWTSize)
inline ::Point VCLPoint(const css::awt::Point &rAWTPoint)
int nCount
#define TOOLS_WARN_EXCEPTION(area, stream)
virtual void SetHelpId(const OUString &) override
constexpr TypedWhichId< SvxAdjustItem > EE_PARA_JUST(EE_PARA_START+16)
constexpr sal_uInt16 EE_ITEMS_END(EE_FEATURE_END)
constexpr sal_uInt16 EE_ITEMS_START(OWN_ATTR_VALUE_END+1)
EmbeddedObjectRef * pObject
std::deque< AttachedObject_Impl > aObjList
::std::vector< DataFlavorEx > DataFlavorExVector
#define GALLERY_THEME_POWERPOINT
constexpr OUStringLiteral HID_REPORTSECTION
Definition: helpids.h:31
std::mutex m_aMutex
tools::Long const nRightMargin
tools::Long const nLeftMargin
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
css::uno::Reference< css::uno::XInterface > createDefault(css::uno::Reference< css::uno::XComponentContext > const &context)
int i
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
::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
void correctOverlapping(SdrObject *pControl, OReportSection const &_aReportSection, bool _bInsert=true)
ensures that no control overlaps the given one.
Definition: UITools.cxx:977
SdrObject * isOver(const tools::Rectangle &_rRect, SdrPage const &_rPage, SdrView const &_rView, bool _bAllObjects=false, SdrObject const *_pIgnore=nullptr, sal_Int16 _nIgnoreType=0)
checks whether the given rectangle overlapps another OUnoObject object in that view.
Definition: UITools.cxx:846
constexpr SdrLayerID RPT_LAYER_FRONT(0)
static Color lcl_getOverlappedControlColor()
SdrOnOffItem makeSdrTextAutoGrowHeightItem(bool bAuto)
SDRTEXTVERTADJUST_CENTER
SDRTEXTHORZADJUST_BLOCK
constexpr OUStringLiteral PROPERTY_POSITION
Definition: strings.hxx:257
constexpr OUStringLiteral PROPERTY_RIGHTMARGIN
Definition: strings.hxx:103
constexpr OUStringLiteral DBOVERLAPPEDCONTROL
Definition: strings.hxx:260
constexpr OUStringLiteral PROPERTY_LEFTMARGIN
Definition: strings.hxx:102
constexpr OUStringLiteral CFG_REPORTDESIGNER
Definition: strings.hxx:244
constexpr OUStringLiteral PROPERTY_BACKCOLOR
Definition: strings.hxx:38
constexpr OUStringLiteral PROPERTY_PAPERSIZE
Definition: strings.hxx:62
sal_Int8 mnAction
const css::datatransfer::dnd::DropTargetDropEvent maDropEvent
Reference< XFrame > xFrame
Reference< XModel > xModel
constexpr sal_uInt16 SDRATTR_START(XATTR_START)
constexpr sal_uInt16 SDRATTR_CUSTOMSHAPE_LAST(SDRATTR_CUSTOMSHAPE_GEOMETRY)
constexpr sal_uInt16 SDRATTR_MISC_LAST(SDRATTR_TEXT_CLIPVERTOVERFLOW)
constexpr sal_uInt16 SDRATTR_MISC_FIRST(SDRATTR_CAPTION_LAST+1)
constexpr sal_uInt16 SDRATTR_GRAF_FIRST(SDRATTR_NOTPERSIST_LAST+1)
constexpr sal_uInt16 SDRATTR_SHADOW_LAST(SDRATTR_SHADOWALIGNMENT)
constexpr TypedWhichId< SvxWritingModeItem > SDRATTR_TEXTDIRECTION(SDRATTR_NOTPERSIST_FIRST+34)
SdrObjKind
#define DND_ACTION_COPYMOVE
#define DND_ACTION_COPY
#define DND_ACTION_LINK
#define DND_ACTION_NONE
signed char sal_Int8
WinBits const WB_DIALOGCONTROL
sal_Int32 nLength