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