1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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 <com/sun/star/awt/PopupMenuDirection.hpp>
43 #include <com/sun/star/frame/XPopupMenuController.hpp>
44 #include <comphelper/propertyvalue.hxx>
45 #include <toolkit/helper/convert.hxx>
46 #include <tools/diagnose_ex.h>
48 #include <SectionWindow.hxx>
50 #include <dlgedclip.hxx>
51 #include <rptui_slotid.hrc>
53 #include <vcl/commandevent.hxx>
54 #include <o3tl/safeint.hxx>
56 #include <svl/itempool.hxx>
57 #include <svtools/extcolorcfg.hxx>
63 using namespace ::com::sun::star
;
66 static Color
lcl_getOverlappedControlColor(/*const uno::Reference <lang::XMultiServiceFactory> _rxFactory*/)
68 svtools::ExtendedColorConfig aConfig
;
69 return aConfig
.GetColorValue(CFG_REPORTDESIGNER
, DBOVERLAPPEDCONTROL
).getColor();
72 OReportSection::OReportSection(OSectionWindow
* _pParent
,const uno::Reference
< report::XSection
>& _xSection
)
73 : Window(_pParent
,WB_DIALOGCONTROL
)
74 , ::comphelper::OPropertyChangeListener(m_aMutex
)
75 , DropTargetHelper(this)
79 , m_xSection(_xSection
)
80 , m_nPaintEntranceCount(0)
81 , m_eMode(DlgEdMode::Select
)
83 //EnableChildTransparentMode();
84 SetHelpId(HID_REPORTSECTION
);
85 SetMapMode(MapMode(MapUnit::Map100thMM
));
86 SetParentClipMode(ParentClipMode::Clip
);
87 EnableChildTransparentMode( false );
88 SetPaintTransparent( false );
94 catch(uno::Exception
&)
96 TOOLS_WARN_EXCEPTION( "reportdesign", "");
99 m_pFunc
.reset(new DlgEdFuncSelect( this ));
100 m_pFunc
->setOverlappedControlColor(lcl_getOverlappedControlColor() );
103 OReportSection::~OReportSection()
108 void OReportSection::dispose()
115 if ( m_pReportListener
.is() )
116 m_pReportListener
->dispose();
117 m_pReportListener
.clear();
122 m_pView
->EndListening( *m_pModel
);
127 vcl::Window::dispose();
130 void OReportSection::Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
)
132 Window::Paint(rRenderContext
, rRect
);
134 if ( !(m_pView
&& m_nPaintEntranceCount
== 0))
137 ++m_nPaintEntranceCount
;
138 // repaint, get PageView and prepare Region
139 SdrPageView
* pPgView
= m_pView
->GetSdrPageView();
140 const vcl::Region
aPaintRectRegion(rRect
);
143 SdrPaintWindow
* pTargetPaintWindow
= nullptr;
145 // mark repaint start
148 pTargetPaintWindow
= pPgView
->GetView().BeginDrawLayers(GetOutDev(), aPaintRectRegion
);
149 OSL_ENSURE(pTargetPaintWindow
, "BeginDrawLayers: Got no SdrPaintWindow (!)");
150 // draw background self using wallpaper
151 OutputDevice
& rTargetOutDev
= pTargetPaintWindow
->GetTargetOutputDevice();
152 rTargetOutDev
.DrawWallpaper(rRect
, Wallpaper(pPgView
->GetApplicationDocumentColor()));
154 // do paint (unbuffered) and mark repaint end
155 pPgView
->DrawLayer(RPT_LAYER_FRONT
, &rRenderContext
);
156 pPgView
->GetView().EndDrawLayers(*pTargetPaintWindow
, true);
159 m_pView
->CompleteRedraw(&rRenderContext
, aPaintRectRegion
);
160 --m_nPaintEntranceCount
;
163 void OReportSection::fill()
165 if ( !m_xSection
.is() )
168 m_pMulti
= new comphelper::OPropertyChangeMultiplexer(this,m_xSection
);
169 m_pMulti
->addProperty(PROPERTY_BACKCOLOR
);
171 m_pReportListener
= addStyleListener(m_xSection
->getReportDefinition(),this);
173 m_pModel
= m_pParent
->getViewsWindow()->getView()->getReportView()->getController().getSdrModel();
174 m_pPage
= m_pModel
->getPage(m_xSection
);
176 m_pView
= new OSectionView(
179 m_pParent
->getViewsWindow()->getView());
181 // #i93597# tell SdrPage that only left and right page border is defined
182 // instead of the full rectangle definition
183 m_pPage
->setPageBorderOnlyLeftRight(true);
185 // without the following call, no grid is painted
186 m_pView
->ShowSdrPage( m_pPage
);
188 m_pView
->SetMoveSnapOnlyTopLeft( true );
189 ODesignView
* pDesignView
= m_pParent
->getViewsWindow()->getView()->getReportView();
191 // #i93595# Adapted grid to a more coarse grid and subdivisions for better visualisation. This
192 // is only for visualisation and has nothing to do with the actual snap
193 const Size
aGridSizeCoarse(pDesignView
->getGridSizeCoarse());
194 const Size
aGridSizeFine(pDesignView
->getGridSizeFine());
195 m_pView
->SetGridCoarse(aGridSizeCoarse
);
196 m_pView
->SetGridFine(aGridSizeFine
);
198 // #i93595# set snap grid width to snap to all existing subdivisions
199 const Fraction
aX(aGridSizeFine
.Width());
200 const Fraction
aY(aGridSizeFine
.Height());
201 m_pView
->SetSnapGridWidth(aX
, aY
);
203 m_pView
->SetGridSnap( true );
204 m_pView
->SetGridFront( false );
205 m_pView
->SetDragStripes( true );
206 m_pView
->SetPageVisible();
207 sal_Int32 nColor
= m_xSection
->getBackColor();
208 if ( nColor
== static_cast<sal_Int32
>(COL_TRANSPARENT
) )
209 nColor
= getStyleProperty
<sal_Int32
>(m_xSection
->getReportDefinition(),PROPERTY_BACKCOLOR
);
210 m_pView
->SetApplicationDocumentColor(Color(ColorTransparency
, nColor
));
212 uno::Reference
<report::XReportDefinition
> xReportDefinition
= m_xSection
->getReportDefinition();
213 const sal_Int32 nLeftMargin
= getStyleProperty
<sal_Int32
>(xReportDefinition
,PROPERTY_LEFTMARGIN
);
214 const sal_Int32 nRightMargin
= getStyleProperty
<sal_Int32
>(xReportDefinition
,PROPERTY_RIGHTMARGIN
);
215 m_pPage
->SetLeftBorder(nLeftMargin
);
216 m_pPage
->SetRightBorder(nRightMargin
);
219 // m_pPage->SetUpperBorder(-10000);
221 m_pView
->SetDesignMode();
223 m_pPage
->SetSize( Size( getStyleProperty
<awt::Size
>(xReportDefinition
,PROPERTY_PAPERSIZE
).Width
,5*m_xSection
->getHeight()) );
224 const Size aPageSize
= m_pPage
->GetSize();
225 m_pView
->SetWorkArea( tools::Rectangle( Point( nLeftMargin
, 0), Size(aPageSize
.Width() - nLeftMargin
- nRightMargin
,aPageSize
.Height()) ) );
228 void OReportSection::Paste(const uno::Sequence
< beans::NamedValue
>& _aAllreadyCopiedObjects
,bool _bForce
)
230 OSL_ENSURE(m_xSection
.is(),"Why is the section here NULL!");
231 if ( !(m_xSection
.is() && _aAllreadyCopiedObjects
.hasElements()) )
234 // stop all drawing actions
235 m_pView
->BrkAction();
237 // unmark all objects
238 m_pView
->UnmarkAll();
239 const OUString sSectionName
= m_xSection
->getName();
240 for(const beans::NamedValue
& rObject
: _aAllreadyCopiedObjects
)
242 if ( _bForce
|| rObject
.Name
== sSectionName
)
246 uno::Sequence
< uno::Reference
<report::XReportComponent
> > aCopies
;
247 rObject
.Value
>>= aCopies
;
248 for (const uno::Reference
<report::XReportComponent
>& rCopy
: std::as_const(aCopies
))
250 SdrObject
* pObject
= SdrObject::getSdrObjectFromXShape( rCopy
);
253 // Clone to target SdrModel
254 SdrObject
* pNewObj(pObject
->CloneSdrObject(*m_pModel
));
255 m_pPage
->InsertObject(pNewObj
, SAL_MAX_SIZE
);
256 tools::Rectangle
aRet(VCLPoint(rCopy
->getPosition()),VCLSize(rCopy
->getSize()));
257 aRet
.setHeight(aRet
.getHeight() + 1);
258 aRet
.setWidth(aRet
.getWidth() + 1);
259 bool bOverlapping
= true;
260 while ( bOverlapping
)
262 bOverlapping
= isOver(aRet
,*m_pPage
,*m_pView
,true,pNewObj
) != nullptr;
265 aRet
.Move(0,aRet
.getHeight()+1);
266 pNewObj
->SetLogicRect(aRet
);
269 m_pView
->AddUndo( m_pView
->GetModel()->GetSdrUndoFactory().CreateUndoNewObject( *pNewObj
) );
270 m_pView
->MarkObj( pNewObj
, m_pView
->GetSdrPageView() );
271 if ( m_xSection
.is() && (o3tl::make_unsigned(aRet
.getHeight() + aRet
.Top()) > m_xSection
->getHeight()) )
272 m_xSection
->setHeight(aRet
.getHeight() + aRet
.Top());
276 catch(uno::Exception
&)
278 TOOLS_WARN_EXCEPTION( "reportdesign", "Exception caught while pasting a new object!");
286 void OReportSection::Delete()
288 if( !m_pView
->AreObjectsMarked() )
291 m_pView
->BrkAction();
292 m_pView
->DeleteMarked();
295 void OReportSection::SetMode( DlgEdMode eNewMode
)
297 if ( eNewMode
== m_eMode
)
300 if ( eNewMode
== DlgEdMode::Insert
)
302 m_pFunc
.reset(new DlgEdFuncInsert( this ));
306 m_pFunc
.reset(new DlgEdFuncSelect( this ));
308 m_pFunc
->setOverlappedControlColor(lcl_getOverlappedControlColor( ) );
309 m_pModel
->SetReadOnly(false);
313 void OReportSection::Copy(uno::Sequence
< beans::NamedValue
>& _rAllreadyCopiedObjects
)
315 Copy(_rAllreadyCopiedObjects
,false);
318 void OReportSection::Copy(uno::Sequence
< beans::NamedValue
>& _rAllreadyCopiedObjects
,bool _bEraseAnddNoClone
)
320 OSL_ENSURE(m_xSection
.is(),"Why is the section here NULL!");
321 if( !m_pView
->AreObjectsMarked() || !m_xSection
.is() )
324 // insert control models of marked objects into clipboard dialog model
325 const SdrMarkList
& rMarkedList
= m_pView
->GetMarkedObjectList();
326 const size_t nMark
= rMarkedList
.GetMarkCount();
328 ::std::vector
< uno::Reference
<report::XReportComponent
> > aCopies
;
329 aCopies
.reserve(nMark
);
331 SdrUndoFactory
& rUndo
= m_pView
->GetModel()->GetSdrUndoFactory();
333 for( size_t i
= nMark
; i
> 0; )
336 SdrObject
* pSdrObject
= rMarkedList
.GetMark(i
)->GetMarkedSdrObj();
337 OObjectBase
* pObj
= dynamic_cast<OObjectBase
*>(pSdrObject
);
342 SdrObject
* pNewObj(pSdrObject
->CloneSdrObject(pSdrObject
->getSdrModelFromSdrObject()));
343 aCopies
.emplace_back(pNewObj
->getUnoShape(),uno::UNO_QUERY
);
344 if ( _bEraseAnddNoClone
)
346 m_pView
->AddUndo( rUndo
.CreateUndoDeleteObject( *pSdrObject
) );
347 m_pPage
->RemoveObject(pSdrObject
->GetOrdNum());
351 catch(uno::Exception
&)
353 OSL_FAIL("Can't copy report elements!");
358 if ( !aCopies
.empty() )
360 ::std::reverse(aCopies
.begin(),aCopies
.end());
361 const sal_Int32 nLength
= _rAllreadyCopiedObjects
.getLength();
362 _rAllreadyCopiedObjects
.realloc( nLength
+ 1);
363 beans::NamedValue
* pNewValue
= _rAllreadyCopiedObjects
.getArray() + nLength
;
364 pNewValue
->Name
= m_xSection
->getName();
365 pNewValue
->Value
<<= uno::Sequence
< uno::Reference
<report::XReportComponent
> >(&(*aCopies
.begin()),aCopies
.size());
369 void OReportSection::MouseButtonDown( const MouseEvent
& rMEvt
)
371 m_pParent
->getViewsWindow()->getView()->setMarked(m_pView
, true); // mark the section in which is clicked
372 m_pFunc
->MouseButtonDown( rMEvt
);
373 Window::MouseButtonDown(rMEvt
);
376 void OReportSection::MouseButtonUp( const MouseEvent
& rMEvt
)
378 if ( !m_pFunc
->MouseButtonUp( rMEvt
) )
379 m_pParent
->getViewsWindow()->getView()->getReportView()->getController().executeUnChecked(SID_OBJECT_SELECT
,uno::Sequence
< beans::PropertyValue
>());
383 void OReportSection::MouseMove( const MouseEvent
& rMEvt
)
385 m_pFunc
->MouseMove( rMEvt
);
389 void OReportSection::SetGridVisible(bool _bVisible
)
391 m_pView
->SetGridVisible( _bVisible
);
394 void OReportSection::SelectAll(const sal_uInt16 _nObjectType
)
399 if ( _nObjectType
== OBJ_NONE
)
400 m_pView
->MarkAllObj();
403 m_pView
->UnmarkAll();
404 SdrObjListIter
aIter(m_pPage
,SdrIterMode::DeepNoGroups
);
405 SdrObject
* pObjIter
= nullptr;
406 while( (pObjIter
= aIter
.Next()) != nullptr )
408 if ( pObjIter
->GetObjIdentifier() == _nObjectType
)
409 m_pView
->MarkObj( pObjIter
, m_pView
->GetSdrPageView() );
414 void OReportSection::Command( const CommandEvent
& _rCEvt
)
416 Window::Command(_rCEvt
);
417 if (_rCEvt
.GetCommand() != CommandEventId::ContextMenu
)
420 OReportController
& rController
= m_pParent
->getViewsWindow()->getView()->getReportView()->getController();
421 uno::Reference
<frame::XFrame
> xFrame
= rController
.getFrame();
422 css::uno::Sequence
<css::uno::Any
> aArgs
{
423 css::uno::makeAny(comphelper::makePropertyValue("Value", OUString("report"))),
424 css::uno::makeAny(comphelper::makePropertyValue("Frame", xFrame
)),
425 css::uno::makeAny(comphelper::makePropertyValue("IsContextMenu", true))
428 css::uno::Reference
<css::uno::XComponentContext
> xContext(rController
.getORB());
429 css::uno::Reference
<css::frame::XPopupMenuController
> xMenuController(
430 xContext
->getServiceManager()->createInstanceWithArgumentsAndContext(
431 "com.sun.star.comp.framework.ResourceMenuController", aArgs
, xContext
), css::uno::UNO_QUERY
);
433 if (!xMenuController
.is())
436 css::uno::Reference
<css::awt::XPopupMenu
> xPopupMenu(
437 xContext
->getServiceManager()->createInstanceWithContext(
438 "com.sun.star.awt.PopupMenu", xContext
), css::uno::UNO_QUERY
);
440 if (!xPopupMenu
.is())
443 xMenuController
->setPopupMenu(xPopupMenu
);
445 Point aPos
= _rCEvt
.GetMousePosPixel();
446 m_pView
->EndAction();
448 xPopupMenu
->execute(GetComponentInterface(),
449 css::awt::Rectangle(aPos
.X(), aPos
.Y(), 1, 1),
450 css::awt::PopupMenuDirection::EXECUTE_DOWN
);
452 css::uno::Reference
<css::lang::XComponent
> xComponent(xMenuController
, css::uno::UNO_QUERY
);
453 xComponent
->dispose();
456 void OReportSection::_propertyChanged(const beans::PropertyChangeEvent
& _rEvent
)
458 if ( !m_xSection
.is() )
461 if ( _rEvent
.Source
== m_xSection
|| PROPERTY_BACKCOLOR
== _rEvent
.PropertyName
)
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
);
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
;
476 if ( _rEvent
.PropertyName
== PROPERTY_LEFTMARGIN
)
478 m_pPage
->SetLeftBorder(nLeftMargin
);
480 else if ( _rEvent
.PropertyName
== PROPERTY_RIGHTMARGIN
)
482 m_pPage
->SetRightBorder(nRightMargin
);
484 const Size aOldPageSize
= m_pPage
->GetSize();
485 sal_Int32 nNewHeight
= 5*m_xSection
->getHeight();
486 if ( aOldPageSize
.Height() != nNewHeight
|| nPaperWidth
!= aOldPageSize
.Width() )
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()) ) );
492 impl_adjustObjectSizePosition(nPaperWidth
,nLeftMargin
,nRightMargin
);
493 m_pParent
->Invalidate(InvalidateFlags::Update
| InvalidateFlags::Transparent
);
496 void OReportSection::impl_adjustObjectSizePosition(sal_Int32 i_nPaperWidth
,sal_Int32 i_nLeftMargin
,sal_Int32 i_nRightMargin
)
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
)
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();
507 SdrObject
* pObject
= SdrObject::getSdrObjectFromXShape( xReportComponent
);
510 bool bChanged
= false;
512 OObjectBase
& rBase
= dynamic_cast<OObjectBase
&>(*pObject
);
513 rBase
.EndListening();
514 if ( aPos
.X
< i_nLeftMargin
)
516 aPos
.X
= i_nLeftMargin
;
519 if ( (aPos
.X
+ aSize
.Width
) > nRightBorder
)
521 aPos
.X
= nRightBorder
- aSize
.Width
;
522 if ( aPos
.X
< i_nLeftMargin
)
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();
537 xReportComponent
->setPosition(aPos
);
538 correctOverlapping(pObject
,*this,false);
539 tools::Rectangle
aRet(VCLPoint(xReportComponent
->getPosition()),VCLSize(xReportComponent
->getSize()));
540 aRet
.setHeight(aRet
.getHeight() + 1);
541 aRet
.setWidth(aRet
.getWidth() + 1);
542 if ( m_xSection
.is() && (o3tl::make_unsigned(aRet
.getHeight() + aRet
.Top()) > m_xSection
->getHeight()) )
543 m_xSection
->setHeight(aRet
.getHeight() + aRet
.Top());
545 pObject
->RecalcBoundRect();
547 rBase
.StartListening();
551 catch(const uno::Exception
&)
553 TOOLS_WARN_EXCEPTION( "reportdesign", "OReportSection::impl_adjustObjectSizePosition()");
557 bool OReportSection::handleKeyEvent(const KeyEvent
& _rEvent
)
559 return m_pFunc
&& m_pFunc
->handleKeyEvent(_rEvent
);
562 void OReportSection::deactivateOle()
565 m_pFunc
->deactivateOle(true);
568 void OReportSection::createDefault(const OUString
& _sType
)
570 SdrObject
* pObj
= m_pView
->GetCreateObj();
573 createDefault(_sType
,pObj
);
576 void OReportSection::createDefault(const OUString
& _sType
,SdrObject
* _pObj
)
578 bool bAttributesAppliedFromGallery
= false;
580 if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT
) )
582 std::vector
< OUString
> aObjList
;
583 if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT
, aObjList
) )
585 auto aIter
= std::find_if(aObjList
.begin(), aObjList
.end(),
586 [&_sType
](const OUString
& rObj
) { return rObj
.equalsIgnoreAsciiCase(_sType
); });
587 if (aIter
!= aObjList
.end())
589 auto i
= static_cast<sal_uInt32
>(std::distance(aObjList
.begin(), aIter
));
590 OReportModel
aReportModel(nullptr);
591 SfxItemPool
& rPool
= aReportModel
.GetItemPool();
592 rPool
.FreezeIdRanges();
593 if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT
, i
, &aReportModel
) )
595 const SdrObject
* pSourceObj
= aReportModel
.GetPage( 0 )->GetObj( 0 );
598 const SfxItemSet
& rSource
= pSourceObj
->GetMergedItemSet();
600 // Ranges from SdrAttrObj:
601 SDRATTR_START
, SDRATTR_SHADOW_LAST
,
602 SDRATTR_MISC_FIRST
, SDRATTR_MISC_LAST
,
603 SDRATTR_TEXTDIRECTION
,
604 SDRATTR_TEXTDIRECTION
,
605 // Graphic attributes, 3D properties,
606 // CustomShape properties:
608 SDRATTR_CUSTOMSHAPE_LAST
,
609 // Range from SdrTextObj:
610 EE_ITEMS_START
, EE_ITEMS_END
>
611 aDest( _pObj
->getSdrModelFromSdrObject().GetItemPool() );
612 aDest
.Set( rSource
);
613 _pObj
->SetMergedItemSet( aDest
);
614 Degree100 nAngle
= pSourceObj
->GetRotateAngle();
616 _pObj
->NbcRotate( _pObj
->GetSnapRect().Center(), nAngle
);
617 bAttributesAppliedFromGallery
= true;
623 if ( !bAttributesAppliedFromGallery
)
625 _pObj
->SetMergedItem( SvxAdjustItem( SvxAdjust::Center
, EE_PARA_JUST
) );
626 _pObj
->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER
) );
627 _pObj
->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK
) );
628 _pObj
->SetMergedItem( makeSdrTextAutoGrowHeightItem( false ) );
629 static_cast<SdrObjCustomShape
*>(_pObj
)->MergeDefaultAttributes( &_sType
);
633 uno::Reference
< report::XReportComponent
> OReportSection::getCurrentControlModel() const
635 uno::Reference
< report::XReportComponent
> xModel
;
638 const SdrMarkList
& rMarkList
= m_pView
->GetMarkedObjectList();
640 if ( rMarkList
.GetMarkCount() == 1 )
642 SdrObject
* pDlgEdObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
643 OObjectBase
* pObj
= dynamic_cast<OObjectBase
*>(pDlgEdObj
);
645 xModel
= pObj
->getReportComponent().get();
651 void OReportSection::fillControlModelSelection(::std::vector
< uno::Reference
< uno::XInterface
> >& _rSelection
) const
656 const SdrMarkList
& rMarkList
= m_pView
->GetMarkedObjectList();
657 const size_t nMarkCount
= rMarkList
.GetMarkCount();
659 for (size_t i
=0; i
< nMarkCount
; ++i
)
661 const SdrObject
* pDlgEdObj
= rMarkList
.GetMark(i
)->GetMarkedSdrObj();
662 const OObjectBase
* pObj
= dynamic_cast<const OObjectBase
*>(pDlgEdObj
);
665 uno::Reference
<uno::XInterface
> xInterface(pObj
->getReportComponent());
666 _rSelection
.push_back(xInterface
);
671 sal_Int8
OReportSection::AcceptDrop( const AcceptDropEvent
& _rEvt
)
673 ::Point
aDropPos(_rEvt
.maPosPixel
);
674 const MouseEvent
aMouseEvt(aDropPos
);
675 if ( m_pFunc
->isOverlapping(aMouseEvt
) )
676 return DND_ACTION_NONE
;
678 if ( _rEvt
.mnAction
== DND_ACTION_COPY
||
679 _rEvt
.mnAction
== DND_ACTION_LINK
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
)
686 // we must assure, we can't drop in the top section
687 if (nCurrentPosition
< 1)
689 return DND_ACTION_NONE
;
691 return DND_ACTION_LINK
;
693 if (_rEvt
.mnAction
== DND_ACTION_LINK
)
695 // we must assure, we can't drop in the bottom section
696 if (m_pParent
->getViewsWindow()->getSectionCount() > (nCurrentPosition
+ 1) )
698 return DND_ACTION_COPY
;
700 return DND_ACTION_NONE
;
705 const DataFlavorExVector
& rFlavors
= GetDataFlavorExVector();
706 if ( svx::OMultiColumnTransferable::canExtractDescriptor(rFlavors
)
707 || svx::OColumnTransferable::canExtractColumnDescriptor(rFlavors
, ColumnTransferFormatFlags::FIELD_DESCRIPTOR
| ColumnTransferFormatFlags::CONTROL_EXCHANGE
| ColumnTransferFormatFlags::COLUMN_DESCRIPTOR
) )
708 return _rEvt
.mnAction
;
710 const sal_Int8 nDropOption
= ( OReportExchange::canExtract(rFlavors
) ) ? DND_ACTION_COPYMOVE
: DND_ACTION_NONE
;
714 return DND_ACTION_NONE
;
718 sal_Int8
OReportSection::ExecuteDrop( const ExecuteDropEvent
& _rEvt
)
720 ::Point
aDropPos(PixelToLogic(_rEvt
.maPosPixel
));
721 const MouseEvent
aMouseEvt(aDropPos
);
722 if ( m_pFunc
->isOverlapping(aMouseEvt
) )
723 return DND_ACTION_NONE
;
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
) )
731 OReportExchange::TSectionElements aCopies
= OReportExchange::extractCopies(aDropped
);
733 nDropOption
= DND_ACTION_COPYMOVE
;
734 m_pParent
->getViewsWindow()->BrkAction();
735 m_pParent
->getViewsWindow()->unmarkAllObjects(m_pView
);
737 else if ( bMultipleFormat
738 || svx::OColumnTransferable::canExtractColumnDescriptor(rFlavors
, ColumnTransferFormatFlags::FIELD_DESCRIPTOR
| ColumnTransferFormatFlags::CONTROL_EXCHANGE
| ColumnTransferFormatFlags::COLUMN_DESCRIPTOR
) )
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() );
748 if ( aDropPos
.Y() > rRect
.Bottom() )
749 aDropPos
.setY( rRect
.Bottom() );
751 uno::Sequence
<beans::PropertyValue
> aValues
;
752 if ( !bMultipleFormat
)
754 svx::ODataAccessDescriptor aDescriptor
= svx::OColumnTransferable::extractColumnDescriptor(aDropped
);
757 aValues
.getArray()[0].Value
<<= aDescriptor
.createPropertyValueSequence();
760 aValues
= svx::OMultiColumnTransferable::extractDescriptor(aDropped
);
762 for(beans::PropertyValue
& propVal
: asNonConstRange(aValues
))
764 uno::Sequence
<beans::PropertyValue
> aCurrent
;
765 propVal
.Value
>>= aCurrent
;
766 sal_Int32 nLength
= aCurrent
.getLength();
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
;
777 pCurrent
[nLength
].Name
= "Section";
778 pCurrent
[nLength
++].Value
<<= getSection();
779 propVal
.Value
<<= aCurrent
;
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
;
791 void OReportSection::stopScrollTimer()
793 m_pFunc
->stopScrollTimer();
796 bool OReportSection::isUiActive() const
798 return m_pFunc
->isUiActive();
805 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */