bump product version to 6.3.0.0.beta1
[LibreOffice.git] / reportdesign / source / ui / report / ReportSection.cxx
blobd064f485f32831b73ffd77e4055d70cdcb45a2bd
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
32 #include <svx/svdpagv.hxx>
33 #include <editeng/adjustitem.hxx>
34 #include <svx/sdrpaintwindow.hxx>
35 #include <svx/unoshape.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>
42 #include <vcl/svapp.hxx>
43 #include <vcl/settings.hxx>
45 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
46 #include <com/sun/star/frame/XPopupMenuController.hpp>
47 #include <comphelper/propertyvalue.hxx>
48 #include <toolkit/awt/vclxmenu.hxx>
49 #include <toolkit/helper/convert.hxx>
50 #include <RptDef.hxx>
51 #include <SectionWindow.hxx>
52 #include <helpids.h>
53 #include <dlgedclip.hxx>
54 #include <UndoActions.hxx>
55 #include <rptui_slotid.hrc>
57 #include <connectivity/dbtools.hxx>
59 #include <vcl/commandevent.hxx>
60 #include <vcl/lineinfo.hxx>
61 #include <ColorChanger.hxx>
63 #include <svl/itempool.hxx>
64 #include <svtools/extcolorcfg.hxx>
65 #include <unotools/confignode.hxx>
68 namespace rptui
71 using namespace ::com::sun::star;
74 static Color lcl_getOverlappedControlColor(/*const uno::Reference <lang::XMultiServiceFactory> _rxFactory*/)
76 svtools::ExtendedColorConfig aConfig;
77 return aConfig.GetColorValue(CFG_REPORTDESIGNER, DBOVERLAPPEDCONTROL).getColor();
80 OReportSection::OReportSection(OSectionWindow* _pParent,const uno::Reference< report::XSection >& _xSection)
81 : Window(_pParent,WB_DIALOGCONTROL)
82 , ::comphelper::OPropertyChangeListener(m_aMutex)
83 , DropTargetHelper(this)
84 , m_pPage(nullptr)
85 , m_pView(nullptr)
86 , m_pParent(_pParent)
87 , m_xSection(_xSection)
88 , m_nPaintEntranceCount(0)
89 , m_eMode(DlgEdMode::Select)
91 //EnableChildTransparentMode();
92 SetHelpId(HID_REPORTSECTION);
93 SetMapMode(MapMode(MapUnit::Map100thMM));
94 SetParentClipMode(ParentClipMode::Clip);
95 EnableChildTransparentMode( false );
96 SetPaintTransparent( false );
98 try
100 fill();
102 catch(uno::Exception&)
104 OSL_FAIL("Exception caught!");
107 m_pFunc.reset(new DlgEdFuncSelect( this ));
108 m_pFunc->setOverlappedControlColor(lcl_getOverlappedControlColor() );
111 OReportSection::~OReportSection()
113 disposeOnce();
116 void OReportSection::dispose()
118 m_pPage = nullptr;
119 if ( m_pMulti.is() )
120 m_pMulti->dispose();
122 if ( m_pReportListener.is() )
123 m_pReportListener->dispose();
124 m_pFunc.reset();
127 ::std::unique_ptr<OSectionView> aTemp( m_pView);
128 if ( m_pView )
129 m_pView->EndListening( *m_pModel );
130 m_pView = nullptr;
132 m_pParent.clear();
133 vcl::Window::dispose();
136 void OReportSection::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect )
138 Window::Paint(rRenderContext, rRect);
140 if ( m_pView && m_nPaintEntranceCount == 0)
142 ++m_nPaintEntranceCount;
143 // repaint, get PageView and prepare Region
144 SdrPageView* pPgView = m_pView->GetSdrPageView();
145 const vcl::Region aPaintRectRegion(rRect);
147 // #i74769#
148 SdrPaintWindow* pTargetPaintWindow = nullptr;
150 // mark repaint start
151 if (pPgView)
153 pTargetPaintWindow = pPgView->GetView().BeginDrawLayers(this, aPaintRectRegion);
154 OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
155 // draw background self using wallpaper
156 OutputDevice& rTargetOutDev = pTargetPaintWindow->GetTargetOutputDevice();
157 rTargetOutDev.DrawWallpaper(rRect, Wallpaper(pPgView->GetApplicationDocumentColor()));
159 // do paint (unbuffered) and mark repaint end
160 pPgView->DrawLayer(RPT_LAYER_FRONT, &rRenderContext);
161 pPgView->GetView().EndDrawLayers(*pTargetPaintWindow, true);
164 m_pView->CompleteRedraw(&rRenderContext, aPaintRectRegion);
165 --m_nPaintEntranceCount;
169 void OReportSection::fill()
171 if ( !m_xSection.is() )
172 return;
174 m_pMulti = new comphelper::OPropertyChangeMultiplexer(this,m_xSection.get());
175 m_pMulti->addProperty(PROPERTY_BACKCOLOR);
177 m_pReportListener = addStyleListener(m_xSection->getReportDefinition(),this);
179 m_pModel = m_pParent->getViewsWindow()->getView()->getReportView()->getController().getSdrModel();
180 m_pPage = m_pModel->getPage(m_xSection);
182 m_pView = new OSectionView(
183 *m_pModel,
184 this,
185 m_pParent->getViewsWindow()->getView());
187 // #i93597# tell SdrPage that only left and right page border is defined
188 // instead of the full rectangle definition
189 m_pPage->setPageBorderOnlyLeftRight(true);
191 // without the following call, no grid is painted
192 m_pView->ShowSdrPage( m_pPage );
194 m_pView->SetMoveSnapOnlyTopLeft( true );
195 ODesignView* pDesignView = m_pParent->getViewsWindow()->getView()->getReportView();
197 // #i93595# Adapted grid to a more coarse grid and subdivisions for better visualisation. This
198 // is only for visualisation and has nothing to do with the actual snap
199 const Size aGridSizeCoarse(pDesignView->getGridSizeCoarse());
200 const Size aGridSizeFine(pDesignView->getGridSizeFine());
201 m_pView->SetGridCoarse(aGridSizeCoarse);
202 m_pView->SetGridFine(aGridSizeFine);
204 // #i93595# set snap grid width to snap to all existing subdivisions
205 const Fraction aX(aGridSizeFine.Width());
206 const Fraction aY(aGridSizeFine.Height());
207 m_pView->SetSnapGridWidth(aX, aY);
209 m_pView->SetGridSnap( true );
210 m_pView->SetGridFront( false );
211 m_pView->SetDragStripes( true );
212 m_pView->SetPageVisible();
213 sal_Int32 nColor = m_xSection->getBackColor();
214 if ( nColor == static_cast<sal_Int32>(COL_TRANSPARENT) )
215 nColor = getStyleProperty<sal_Int32>(m_xSection->getReportDefinition(),PROPERTY_BACKCOLOR);
216 m_pView->SetApplicationDocumentColor(Color(nColor));
218 uno::Reference<report::XReportDefinition> xReportDefinition = m_xSection->getReportDefinition();
219 const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN);
220 const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN);
221 m_pPage->SetLeftBorder(nLeftMargin);
222 m_pPage->SetRightBorder(nRightMargin);
224 // LLA: TODO
225 // m_pPage->SetUpperBorder(-10000);
227 m_pView->SetDesignMode();
229 m_pPage->SetSize( Size( getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width,5*m_xSection->getHeight()) );
230 const Size aPageSize = m_pPage->GetSize();
231 m_pView->SetWorkArea( tools::Rectangle( Point( nLeftMargin, 0), Size(aPageSize.Width() - nLeftMargin - nRightMargin,aPageSize.Height()) ) );
234 void OReportSection::Paste(const uno::Sequence< beans::NamedValue >& _aAllreadyCopiedObjects,bool _bForce)
236 OSL_ENSURE(m_xSection.is(),"Why is the section here NULL!");
237 if ( m_xSection.is() && _aAllreadyCopiedObjects.hasElements() )
239 // stop all drawing actions
240 m_pView->BrkAction();
242 // unmark all objects
243 m_pView->UnmarkAll();
244 const OUString sSectionName = m_xSection->getName();
245 const sal_Int32 nLength = _aAllreadyCopiedObjects.getLength();
246 const beans::NamedValue* pIter = _aAllreadyCopiedObjects.getConstArray();
247 const beans::NamedValue* pEnd = pIter + nLength;
248 for(;pIter != pEnd;++pIter)
250 if ( _bForce || pIter->Name == sSectionName)
254 uno::Sequence< uno::Reference<report::XReportComponent> > aCopies;
255 pIter->Value >>= aCopies;
256 const uno::Reference<report::XReportComponent>* pCopiesIter = aCopies.getConstArray();
257 const uno::Reference<report::XReportComponent>* pCopiesEnd = pCopiesIter + aCopies.getLength();
258 for (;pCopiesIter != pCopiesEnd ; ++pCopiesIter)
260 SvxShape* pShape = SvxShape::getImplementation( *pCopiesIter );
261 SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr;
262 if ( pObject )
264 // Clone to target SdrModel
265 SdrObject* pNewObj(pObject->CloneSdrObject(*m_pModel.get()));
266 m_pPage->InsertObject(pNewObj, SAL_MAX_SIZE);
267 tools::Rectangle aRet(VCLPoint((*pCopiesIter)->getPosition()),VCLSize((*pCopiesIter)->getSize()));
268 aRet.setHeight(aRet.getHeight() + 1);
269 aRet.setWidth(aRet.getWidth() + 1);
270 bool bOverlapping = true;
271 while ( bOverlapping )
273 bOverlapping = isOver(aRet,*m_pPage,*m_pView,true,pNewObj) != nullptr;
274 if ( bOverlapping )
276 aRet.Move(0,aRet.getHeight()+1);
277 pNewObj->SetLogicRect(aRet);
280 m_pView->AddUndo( m_pView->GetModel()->GetSdrUndoFactory().CreateUndoNewObject( *pNewObj ) );
281 m_pView->MarkObj( pNewObj, m_pView->GetSdrPageView() );
282 if ( m_xSection.is() && (static_cast<sal_uInt32>(aRet.getHeight() + aRet.Top()) > m_xSection->getHeight()) )
283 m_xSection->setHeight(aRet.getHeight() + aRet.Top());
287 catch(uno::Exception&)
289 OSL_FAIL("Exception caught while pasting a new object!");
291 if ( !_bForce )
292 break;
298 void OReportSection::Delete()
300 if( !m_pView->AreObjectsMarked() )
301 return;
303 m_pView->BrkAction();
304 m_pView->DeleteMarked();
307 void OReportSection::SetMode( DlgEdMode eNewMode )
309 if ( eNewMode != m_eMode )
311 if ( eNewMode == DlgEdMode::Insert )
313 m_pFunc.reset(new DlgEdFuncInsert( this ));
315 else
317 m_pFunc.reset(new DlgEdFuncSelect( this ));
319 m_pFunc->setOverlappedControlColor(lcl_getOverlappedControlColor( ) );
320 m_pModel->SetReadOnly(false);
321 m_eMode = eNewMode;
325 void OReportSection::Copy(uno::Sequence< beans::NamedValue >& _rAllreadyCopiedObjects)
327 Copy(_rAllreadyCopiedObjects,false);
330 void OReportSection::Copy(uno::Sequence< beans::NamedValue >& _rAllreadyCopiedObjects,bool _bEraseAnddNoClone)
332 OSL_ENSURE(m_xSection.is(),"Why is the section here NULL!");
333 if( !m_pView->AreObjectsMarked() || !m_xSection.is() )
334 return;
336 // insert control models of marked objects into clipboard dialog model
337 const SdrMarkList& rMarkedList = m_pView->GetMarkedObjectList();
338 const size_t nMark = rMarkedList.GetMarkCount();
340 ::std::vector< uno::Reference<report::XReportComponent> > aCopies;
341 aCopies.reserve(nMark);
343 SdrUndoFactory& rUndo = m_pView->GetModel()->GetSdrUndoFactory();
345 for( size_t i = nMark; i > 0; )
347 --i;
348 SdrObject* pSdrObject = rMarkedList.GetMark(i)->GetMarkedSdrObj();
349 OObjectBase* pObj = dynamic_cast<OObjectBase*>(pSdrObject);
350 if ( pObj )
354 SdrObject* pNewObj(pSdrObject->CloneSdrObject(pSdrObject->getSdrModelFromSdrObject()));
355 aCopies.emplace_back(pNewObj->getUnoShape(),uno::UNO_QUERY);
356 if ( _bEraseAnddNoClone )
358 m_pView->AddUndo( rUndo.CreateUndoDeleteObject( *pSdrObject ) );
359 m_pPage->RemoveObject(pSdrObject->GetOrdNum());
363 catch(uno::Exception&)
365 OSL_FAIL("Can't copy report elements!");
370 if ( !aCopies.empty() )
372 ::std::reverse(aCopies.begin(),aCopies.end());
373 const sal_Int32 nLength = _rAllreadyCopiedObjects.getLength();
374 _rAllreadyCopiedObjects.realloc( nLength + 1);
375 beans::NamedValue* pNewValue = _rAllreadyCopiedObjects.getArray() + nLength;
376 pNewValue->Name = m_xSection->getName();
377 pNewValue->Value <<= uno::Sequence< uno::Reference<report::XReportComponent> >(&(*aCopies.begin()),aCopies.size());
381 void OReportSection::MouseButtonDown( const MouseEvent& rMEvt )
383 m_pParent->getViewsWindow()->getView()->setMarked(m_pView, true); // mark the section in which is clicked
384 m_pFunc->MouseButtonDown( rMEvt );
385 Window::MouseButtonDown(rMEvt);
388 void OReportSection::MouseButtonUp( const MouseEvent& rMEvt )
390 if ( !m_pFunc->MouseButtonUp( rMEvt ) )
391 m_pParent->getViewsWindow()->getView()->getReportView()->getController().executeUnChecked(SID_OBJECT_SELECT,uno::Sequence< beans::PropertyValue>());
395 void OReportSection::MouseMove( const MouseEvent& rMEvt )
397 m_pFunc->MouseMove( rMEvt );
401 void OReportSection::SetGridVisible(bool _bVisible)
403 m_pView->SetGridVisible( _bVisible );
406 void OReportSection::SelectAll(const sal_uInt16 _nObjectType)
408 if ( m_pView )
410 if ( _nObjectType == OBJ_NONE )
411 m_pView->MarkAllObj();
412 else
414 m_pView->UnmarkAll();
415 SdrObjListIter aIter(m_pPage,SdrIterMode::DeepNoGroups);
416 SdrObject* pObjIter = nullptr;
417 while( (pObjIter = aIter.Next()) != nullptr )
419 if ( pObjIter->GetObjIdentifier() == _nObjectType )
420 m_pView->MarkObj( pObjIter, m_pView->GetSdrPageView() );
426 void OReportSection::Command( const CommandEvent& _rCEvt )
428 Window::Command(_rCEvt);
429 if (_rCEvt.GetCommand() == CommandEventId::ContextMenu)
431 OReportController& rController = m_pParent->getViewsWindow()->getView()->getReportView()->getController();
432 uno::Reference<frame::XFrame> xFrame = rController.getFrame();
433 css::uno::Sequence<css::uno::Any> aArgs {
434 css::uno::makeAny(comphelper::makePropertyValue("Value", OUString("report"))),
435 css::uno::makeAny(comphelper::makePropertyValue("Frame", xFrame)),
436 css::uno::makeAny(comphelper::makePropertyValue("IsContextMenu", true))
439 css::uno::Reference<css::uno::XComponentContext> xContext(rController.getORB());
440 css::uno::Reference<css::frame::XPopupMenuController> xMenuController(
441 xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
442 "com.sun.star.comp.framework.ResourceMenuController", aArgs, xContext), css::uno::UNO_QUERY);
444 if (!xMenuController.is())
445 return;
447 rtl::Reference<VCLXPopupMenu> xPopupMenu(new VCLXPopupMenu);
448 xMenuController->setPopupMenu(xPopupMenu.get());
450 Point aPos = _rCEvt.GetMousePosPixel();
451 m_pView->EndAction();
452 static_cast<PopupMenu*>(xPopupMenu->GetMenu())->Execute(this, aPos);
454 css::uno::Reference<css::lang::XComponent> xComponent(xMenuController, css::uno::UNO_QUERY);
455 xComponent->dispose();
459 void OReportSection::_propertyChanged(const beans::PropertyChangeEvent& _rEvent)
461 if ( m_xSection.is() )
463 if ( _rEvent.Source == m_xSection || PROPERTY_BACKCOLOR == _rEvent.PropertyName )
465 sal_Int32 nColor = m_xSection->getBackColor();
466 if ( nColor == static_cast<sal_Int32>(COL_TRANSPARENT) )
467 nColor = getStyleProperty<sal_Int32>(m_xSection->getReportDefinition(),PROPERTY_BACKCOLOR);
468 m_pView->SetApplicationDocumentColor(Color(nColor));
469 Invalidate(InvalidateFlags::NoChildren|InvalidateFlags::NoErase);
471 else
473 uno::Reference<report::XReportDefinition> xReportDefinition = m_xSection->getReportDefinition();
474 const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN);
475 const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN);
476 const sal_Int32 nPaperWidth = getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width;
478 if ( _rEvent.PropertyName == PROPERTY_LEFTMARGIN )
480 m_pPage->SetLeftBorder(nLeftMargin);
482 else if ( _rEvent.PropertyName == PROPERTY_RIGHTMARGIN )
484 m_pPage->SetRightBorder(nRightMargin);
486 const Size aOldPageSize = m_pPage->GetSize();
487 sal_Int32 nNewHeight = 5*m_xSection->getHeight();
488 if ( aOldPageSize.Height() != nNewHeight || nPaperWidth != aOldPageSize.Width() )
490 m_pPage->SetSize( Size( nPaperWidth,nNewHeight) );
491 const Size aPageSize = m_pPage->GetSize();
492 m_pView->SetWorkArea( tools::Rectangle( Point( nLeftMargin, 0), Size(aPageSize.Width() - nLeftMargin - nRightMargin,aPageSize.Height()) ) );
494 impl_adjustObjectSizePosition(nPaperWidth,nLeftMargin,nRightMargin);
495 m_pParent->Invalidate(InvalidateFlags::Update | InvalidateFlags::Transparent);
499 void OReportSection::impl_adjustObjectSizePosition(sal_Int32 i_nPaperWidth,sal_Int32 i_nLeftMargin,sal_Int32 i_nRightMargin)
503 sal_Int32 nRightBorder = i_nPaperWidth - i_nRightMargin;
504 const sal_Int32 nCount = m_xSection->getCount();
505 for (sal_Int32 i = 0; i < nCount; ++i)
507 uno::Reference< report::XReportComponent> xReportComponent(m_xSection->getByIndex(i),uno::UNO_QUERY_THROW);
508 awt::Point aPos = xReportComponent->getPosition();
509 awt::Size aSize = xReportComponent->getSize();
510 SvxShape* pShape = SvxShape::getImplementation( xReportComponent );
511 SdrObject* pObject = pShape ? pShape->GetSdrObject() : nullptr;
512 if ( pObject )
514 bool bChanged = false;
516 OObjectBase& rBase = dynamic_cast<OObjectBase&>(*pObject);
517 rBase.EndListening();
518 if ( aPos.X < i_nLeftMargin )
520 aPos.X = i_nLeftMargin;
521 bChanged = true;
523 if ( (aPos.X + aSize.Width) > nRightBorder )
525 aPos.X = nRightBorder - aSize.Width;
526 if ( aPos.X < i_nLeftMargin )
528 aSize.Width += aPos.X - i_nLeftMargin;
529 aPos.X = i_nLeftMargin;
530 // add listener around
531 rBase.StartListening();
532 xReportComponent->setSize(aSize);
533 rBase.EndListening();
535 bChanged = true;
537 if ( aPos.Y < 0 )
538 aPos.Y = 0;
539 if ( bChanged )
541 xReportComponent->setPosition(aPos);
542 correctOverlapping(pObject,*this,false);
543 tools::Rectangle aRet(VCLPoint(xReportComponent->getPosition()),VCLSize(xReportComponent->getSize()));
544 aRet.setHeight(aRet.getHeight() + 1);
545 aRet.setWidth(aRet.getWidth() + 1);
546 if ( m_xSection.is() && (static_cast<sal_uInt32>(aRet.getHeight() + aRet.Top()) > m_xSection->getHeight()) )
547 m_xSection->setHeight(aRet.getHeight() + aRet.Top());
549 pObject->RecalcBoundRect();
551 rBase.StartListening();
555 catch(const uno::Exception &)
557 OSL_FAIL("Exception caught: OReportSection::impl_adjustObjectSizePosition()");
561 bool OReportSection::handleKeyEvent(const KeyEvent& _rEvent)
563 return m_pFunc.get() && m_pFunc->handleKeyEvent(_rEvent);
566 void OReportSection::deactivateOle()
568 if (m_pFunc)
569 m_pFunc->deactivateOle(true);
572 void OReportSection::createDefault(const OUString& _sType)
574 SdrObject* pObj = m_pView->GetCreateObj();
575 if ( !pObj )
576 return;
577 createDefault(_sType,pObj);
580 void OReportSection::createDefault(const OUString& _sType,SdrObject* _pObj)
582 bool bAttributesAppliedFromGallery = false;
584 if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
586 std::vector< OUString > aObjList;
587 if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
589 auto aIter = std::find_if(aObjList.begin(), aObjList.end(),
590 [&_sType](const OUString& rObj) { return rObj.equalsIgnoreAsciiCase(_sType); });
591 if (aIter != aObjList.end())
593 auto i = static_cast<sal_uInt32>(std::distance(aObjList.begin(), aIter));
594 OReportModel aReportModel(nullptr);
595 SfxItemPool& rPool = aReportModel.GetItemPool();
596 rPool.FreezeIdRanges();
597 if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aReportModel ) )
599 const SdrObject* pSourceObj = aReportModel.GetPage( 0 )->GetObj( 0 );
600 if( pSourceObj )
602 const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
603 SfxItemSet aDest(
604 _pObj->getSdrModelFromSdrObject().GetItemPool(),
605 svl::Items<
606 // Ranges from SdrAttrObj:
607 SDRATTR_START, SDRATTR_SHADOW_LAST,
608 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
609 SDRATTR_TEXTDIRECTION,
610 SDRATTR_TEXTDIRECTION,
611 // Graphic attributes, 3D properties,
612 // CustomShape properties:
613 SDRATTR_GRAF_FIRST,
614 SDRATTR_CUSTOMSHAPE_LAST,
615 // Range from SdrTextObj:
616 EE_ITEMS_START, EE_ITEMS_END>{});
617 aDest.Set( rSource );
618 _pObj->SetMergedItemSet( aDest );
619 sal_Int32 nAngle = pSourceObj->GetRotateAngle();
620 if ( nAngle )
622 double a = nAngle * F_PI18000;
623 _pObj->NbcRotate( _pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) );
625 bAttributesAppliedFromGallery = true;
631 if ( !bAttributesAppliedFromGallery )
633 _pObj->SetMergedItem( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST) );
634 _pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
635 _pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
636 _pObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( false ) );
637 static_cast<SdrObjCustomShape*>(_pObj)->MergeDefaultAttributes( &_sType );
641 uno::Reference< report::XReportComponent > OReportSection::getCurrentControlModel() const
643 uno::Reference< report::XReportComponent > xModel;
644 if ( m_pView )
646 const SdrMarkList& rMarkList = m_pView->GetMarkedObjectList();
648 if ( rMarkList.GetMarkCount() == 1 )
650 SdrObject* pDlgEdObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
651 OObjectBase* pObj = dynamic_cast<OObjectBase*>(pDlgEdObj);
652 if ( pObj )
653 xModel = pObj->getReportComponent().get();
656 return xModel;
659 void OReportSection::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const
661 if ( m_pView )
663 const SdrMarkList& rMarkList = m_pView->GetMarkedObjectList();
664 const size_t nMarkCount = rMarkList.GetMarkCount();
666 for (size_t i=0; i < nMarkCount; ++i)
668 const SdrObject* pDlgEdObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
669 const OObjectBase* pObj = dynamic_cast<const OObjectBase*>(pDlgEdObj);
670 if ( pObj )
672 uno::Reference<uno::XInterface> xInterface(pObj->getReportComponent());
673 _rSelection.push_back(xInterface);
679 sal_Int8 OReportSection::AcceptDrop( const AcceptDropEvent& _rEvt )
681 ::Point aDropPos(_rEvt.maPosPixel);
682 const MouseEvent aMouseEvt(aDropPos);
683 if ( m_pFunc->isOverlapping(aMouseEvt) )
684 return DND_ACTION_NONE;
686 if ( _rEvt.mnAction == DND_ACTION_COPY ||
687 _rEvt.mnAction == DND_ACTION_LINK
690 if (!m_pParent) return DND_ACTION_NONE;
691 sal_uInt16 nCurrentPosition = m_pParent->getViewsWindow()->getPosition(m_pParent);
692 if (_rEvt.mnAction == DND_ACTION_COPY )
694 // we must assure, we can't drop in the top section
695 if (nCurrentPosition < 1)
697 return DND_ACTION_NONE;
699 return DND_ACTION_LINK;
701 if (_rEvt.mnAction == DND_ACTION_LINK)
703 // we must assure, we can't drop in the bottom section
704 if (m_pParent->getViewsWindow()->getSectionCount() > (nCurrentPosition + 1) )
706 return DND_ACTION_COPY;
708 return DND_ACTION_NONE;
711 else
713 const DataFlavorExVector& rFlavors = GetDataFlavorExVector();
714 if ( svx::OMultiColumnTransferable::canExtractDescriptor(rFlavors)
715 || svx::OColumnTransferable::canExtractColumnDescriptor(rFlavors, ColumnTransferFormatFlags::FIELD_DESCRIPTOR | ColumnTransferFormatFlags::CONTROL_EXCHANGE | ColumnTransferFormatFlags::COLUMN_DESCRIPTOR) )
716 return _rEvt.mnAction;
718 const sal_Int8 nDropOption = ( OReportExchange::canExtract(rFlavors) ) ? DND_ACTION_COPYMOVE : DND_ACTION_NONE;
720 return nDropOption;
722 return DND_ACTION_NONE;
726 sal_Int8 OReportSection::ExecuteDrop( const ExecuteDropEvent& _rEvt )
728 ::Point aDropPos(PixelToLogic(_rEvt.maPosPixel));
729 const MouseEvent aMouseEvt(aDropPos);
730 if ( m_pFunc->isOverlapping(aMouseEvt) )
731 return DND_ACTION_NONE;
733 sal_Int8 nDropOption = DND_ACTION_NONE;
734 const TransferableDataHelper aDropped(_rEvt.maDropEvent.Transferable);
735 const DataFlavorExVector& rFlavors = aDropped.GetDataFlavorExVector();
736 bool bMultipleFormat = svx::OMultiColumnTransferable::canExtractDescriptor(rFlavors);
737 if ( OReportExchange::canExtract(rFlavors) )
739 OReportExchange::TSectionElements aCopies = OReportExchange::extractCopies(aDropped);
740 Paste(aCopies,true);
741 nDropOption = DND_ACTION_COPYMOVE;
742 m_pParent->getViewsWindow()->BrkAction();
743 m_pParent->getViewsWindow()->unmarkAllObjects(m_pView);
745 else if ( bMultipleFormat
746 || svx::OColumnTransferable::canExtractColumnDescriptor(rFlavors, ColumnTransferFormatFlags::FIELD_DESCRIPTOR | ColumnTransferFormatFlags::CONTROL_EXCHANGE | ColumnTransferFormatFlags::COLUMN_DESCRIPTOR) )
748 m_pParent->getViewsWindow()->getView()->setMarked(m_pView, true);
749 m_pView->UnmarkAll();
750 const tools::Rectangle& rRect = m_pView->GetWorkArea();
751 if ( aDropPos.X() < rRect.Left() )
752 aDropPos.setX( rRect.Left() );
753 else if ( aDropPos.X() > rRect.Right() )
754 aDropPos.setX( rRect.Right() );
756 if ( aDropPos.Y() > rRect.Bottom() )
757 aDropPos.setY( rRect.Bottom() );
759 uno::Sequence<beans::PropertyValue> aValues;
760 if ( !bMultipleFormat )
762 svx::ODataAccessDescriptor aDescriptor = svx::OColumnTransferable::extractColumnDescriptor(aDropped);
764 aValues.realloc(1);
765 aValues[0].Value <<= aDescriptor.createPropertyValueSequence();
767 else
768 aValues = svx::OMultiColumnTransferable::extractDescriptor(aDropped);
770 for(beans::PropertyValue & propVal : aValues)
772 uno::Sequence<beans::PropertyValue> aCurrent;
773 propVal.Value >>= aCurrent;
774 sal_Int32 nLength = aCurrent.getLength();
775 if ( nLength )
777 aCurrent.realloc(nLength + 3);
778 aCurrent[nLength].Name = PROPERTY_POSITION;
779 aCurrent[nLength++].Value <<= AWTPoint(aDropPos);
780 // give also the DND Action (Shift|Ctrl) Key to really say what we want
781 aCurrent[nLength].Name = "DNDAction";
782 aCurrent[nLength++].Value <<= _rEvt.mnAction;
784 aCurrent[nLength].Name = "Section";
785 aCurrent[nLength++].Value <<= getSection();
786 propVal.Value <<= aCurrent;
790 // we use this way to create undo actions
791 OReportController& rController = m_pParent->getViewsWindow()->getView()->getReportView()->getController();
792 rController.executeChecked(SID_ADD_CONTROL_PAIR,aValues);
793 nDropOption = DND_ACTION_COPY;
795 return nDropOption;
798 void OReportSection::stopScrollTimer()
800 m_pFunc->stopScrollTimer();
803 bool OReportSection::isUiActive() const
805 return m_pFunc->isUiActive();
812 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */