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 .
19 #include "ReportSection.hxx"
20 #include "ReportWindow.hxx"
21 #include "DesignView.hxx"
22 #include "uistrings.hrc"
23 #include "RptObject.hxx"
24 #include "RptModel.hxx"
25 #include "SectionView.hxx"
26 #include "RptPage.hxx"
27 #include "ReportController.hxx"
28 #include "UITools.hxx"
29 #include "ViewsWindow.hxx"
31 #include <svx/svdpagv.hxx>
32 #include <editeng/eeitemid.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>
41 #include <vcl/svapp.hxx>
42 #include <vcl/settings.hxx>
44 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
45 #include <toolkit/helper/convert.hxx>
47 #include "SectionWindow.hxx"
48 #include "helpids.hrc"
49 #include "RptResId.hrc"
50 #include "dlgedclip.hxx"
51 #include "UndoActions.hxx"
52 #include "rptui_slotid.hrc"
54 #include <connectivity/dbtools.hxx>
56 #include <vcl/lineinfo.hxx>
57 #include "ColorChanger.hxx"
59 #include <svl/itempool.hxx>
60 #include <svtools/extcolorcfg.hxx>
61 #include <unotools/confignode.hxx>
62 #include <framework/imageproducer.hxx>
68 using namespace ::com::sun::star
;
71 sal_Int32
lcl_getOverlappedControlColor(/*const uno::Reference <lang::XMultiServiceFactory> _rxFactory*/)
73 svtools::ExtendedColorConfig aConfig
;
74 sal_Int32 nColor
= aConfig
.GetColorValue(CFG_REPORTDESIGNER
, DBOVERLAPPEDCONTROL
).getColor();
78 OReportSection::OReportSection(OSectionWindow
* _pParent
,const uno::Reference
< report::XSection
>& _xSection
)
79 : Window(_pParent
,WB_DIALOGCONTROL
)
80 , ::comphelper::OPropertyChangeListener(m_aMutex
)
81 , DropTargetHelper(this)
86 , m_pReportListener(NULL
)
87 , m_xSection(_xSection
)
88 , m_nPaintEntranceCount(0)
89 , m_eMode(RPTUI_SELECT
)
90 , m_bDialogModelChanged(false)
92 //EnableChildTransparentMode();
93 SetHelpId(HID_REPORTSECTION
);
94 SetMapMode(MapMode(MAP_100TH_MM
));
95 SetParentClipMode(PARENTCLIPMODE_CLIP
);
96 EnableChildTransparentMode( false );
97 SetPaintTransparent( false );
103 catch(uno::Exception
&)
105 OSL_FAIL("Exception catched!");
108 m_pFunc
.reset(new DlgEdFuncSelect( this ));
109 m_pFunc
->setOverlappedControlColor(lcl_getOverlappedControlColor() );
112 OReportSection::~OReportSection()
117 void OReportSection::dispose()
123 if ( m_pReportListener
.is() )
124 m_pReportListener
->dispose();
128 ::std::unique_ptr
<OSectionView
> aTemp( m_pView
);
130 m_pView
->EndListening( *m_pModel
);
134 vcl::Window::dispose();
137 void OReportSection::Paint( vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
)
139 Window::Paint(rRenderContext
, rRect
);
141 if ( m_pView
&& m_nPaintEntranceCount
== 0)
143 ++m_nPaintEntranceCount
;
144 // repaint, get PageView and prepare Region
145 SdrPageView
* pPgView
= m_pView
->GetSdrPageView();
146 const vcl::Region
aPaintRectRegion(rRect
);
149 SdrPaintWindow
* pTargetPaintWindow
= 0;
151 // mark repaint start
154 pTargetPaintWindow
= pPgView
->GetView().BeginDrawLayers(this, aPaintRectRegion
);
155 OSL_ENSURE(pTargetPaintWindow
, "BeginDrawLayers: Got no SdrPaintWindow (!)");
156 // draw background self using wallpaper
157 OutputDevice
& rTargetOutDev
= pTargetPaintWindow
->GetTargetOutputDevice();
158 rTargetOutDev
.DrawWallpaper(rRect
, Wallpaper(pPgView
->GetApplicationDocumentColor()));
161 // do paint (unbuffered) and mark repaint end
164 pPgView
->DrawLayer(0, &rRenderContext
);
165 pPgView
->GetView().EndDrawLayers(*pTargetPaintWindow
, true);
168 m_pView
->CompleteRedraw(&rRenderContext
, aPaintRectRegion
);
169 --m_nPaintEntranceCount
;
173 void OReportSection::Resize()
178 void OReportSection::fill()
180 if ( !m_xSection
.is() )
183 m_pMulti
= new comphelper::OPropertyChangeMultiplexer(this,m_xSection
.get());
184 m_pMulti
->addProperty(PROPERTY_BACKCOLOR
);
186 m_pReportListener
= addStyleListener(m_xSection
->getReportDefinition(),this);
188 m_pModel
= m_pParent
->getViewsWindow()->getView()->getReportView()->getController().getSdrModel();
189 m_pPage
= m_pModel
->getPage(m_xSection
);
191 m_pView
= new OSectionView( m_pModel
.get(), this, m_pParent
->getViewsWindow()->getView() );
193 // #i93597# tell SdrPage that only left and right page border is defined
194 // instead of the full rectangle definition
195 m_pPage
->setPageBorderOnlyLeftRight(true);
197 // without the following call, no grid is painted
198 m_pView
->ShowSdrPage( m_pPage
);
200 m_pView
->SetMoveSnapOnlyTopLeft( true );
201 ODesignView
* pDesignView
= m_pParent
->getViewsWindow()->getView()->getReportView();
203 // #i93595# Adapted grid to a more coarse grid and subdivisions for better visualisation. This
204 // is only for visualisation and has nothing to do with the actual snap
205 const Size
aGridSizeCoarse(pDesignView
->getGridSizeCoarse());
206 const Size
aGridSizeFine(pDesignView
->getGridSizeFine());
207 m_pView
->SetGridCoarse(aGridSizeCoarse
);
208 m_pView
->SetGridFine(aGridSizeFine
);
210 // #i93595# set snap grid width to snap to all existing subdivisions
211 const Fraction
aX(aGridSizeFine
.A());
212 const Fraction
aY(aGridSizeFine
.B());
213 m_pView
->SetSnapGridWidth(aX
, aY
);
215 m_pView
->SetGridSnap( pDesignView
->isGridSnap() );
216 m_pView
->SetGridFront( false );
217 m_pView
->SetDragStripes( true );
218 m_pView
->SetPageVisible();
219 sal_Int32 nColor
= m_xSection
->getBackColor();
220 if ( nColor
== (sal_Int32
)COL_TRANSPARENT
)
221 nColor
= getStyleProperty
<sal_Int32
>(m_xSection
->getReportDefinition(),PROPERTY_BACKCOLOR
);
222 m_pView
->SetApplicationDocumentColor(nColor
);
224 uno::Reference
<report::XReportDefinition
> xReportDefinition
= m_xSection
->getReportDefinition();
225 const sal_Int32 nLeftMargin
= getStyleProperty
<sal_Int32
>(xReportDefinition
,PROPERTY_LEFTMARGIN
);
226 const sal_Int32 nRightMargin
= getStyleProperty
<sal_Int32
>(xReportDefinition
,PROPERTY_RIGHTMARGIN
);
227 m_pPage
->SetLftBorder(nLeftMargin
);
228 m_pPage
->SetRgtBorder(nRightMargin
);
231 // m_pPage->SetUppBorder(-10000);
233 m_pView
->SetDesignMode( true );
235 m_pView
->StartListening( *m_pModel
);
236 m_pPage
->SetSize( Size( getStyleProperty
<awt::Size
>(xReportDefinition
,PROPERTY_PAPERSIZE
).Width
,5*m_xSection
->getHeight()) );
237 const Size aPageSize
= m_pPage
->GetSize();
238 m_pView
->SetWorkArea( Rectangle( Point( nLeftMargin
, 0), Size(aPageSize
.Width() - nLeftMargin
- nRightMargin
,aPageSize
.Height()) ) );
241 void OReportSection::Paste(const uno::Sequence
< beans::NamedValue
>& _aAllreadyCopiedObjects
,bool _bForce
)
243 OSL_ENSURE(m_xSection
.is(),"Why is the section here NULL!");
244 if ( m_xSection
.is() && _aAllreadyCopiedObjects
.getLength() )
246 // stop all drawing actions
247 m_pView
->BrkAction();
249 // unmark all objects
250 m_pView
->UnmarkAll();
251 const OUString sSectionName
= m_xSection
->getName();
252 const sal_Int32 nLength
= _aAllreadyCopiedObjects
.getLength();
253 const beans::NamedValue
* pIter
= _aAllreadyCopiedObjects
.getConstArray();
254 const beans::NamedValue
* pEnd
= pIter
+ nLength
;
255 for(;pIter
!= pEnd
;++pIter
)
257 if ( _bForce
|| pIter
->Name
== sSectionName
)
261 uno::Sequence
< uno::Reference
<report::XReportComponent
> > aCopies
;
262 pIter
->Value
>>= aCopies
;
263 const uno::Reference
<report::XReportComponent
>* pCopiesIter
= aCopies
.getConstArray();
264 const uno::Reference
<report::XReportComponent
>* pCopiesEnd
= pCopiesIter
+ aCopies
.getLength();
265 for (;pCopiesIter
!= pCopiesEnd
; ++pCopiesIter
)
267 SvxShape
* pShape
= SvxShape::getImplementation( *pCopiesIter
);
268 SdrObject
* pObject
= pShape
? pShape
->GetSdrObject() : NULL
;
271 SdrObject
* pNeuObj
= pObject
->Clone();
273 pNeuObj
->SetPage( m_pPage
);
274 pNeuObj
->SetModel( m_pModel
.get() );
275 SdrInsertReason
aReason(SDRREASON_VIEWCALL
);
276 m_pPage
->InsertObject(pNeuObj
, SAL_MAX_SIZE
, &aReason
);
278 Rectangle
aRet(VCLPoint((*pCopiesIter
)->getPosition()),VCLSize((*pCopiesIter
)->getSize()));
279 aRet
.setHeight(aRet
.getHeight() + 1);
280 aRet
.setWidth(aRet
.getWidth() + 1);
281 bool bOverlapping
= true;
282 while ( bOverlapping
)
284 bOverlapping
= isOver(aRet
,*m_pPage
,*m_pView
,true,pNeuObj
) != NULL
;
287 aRet
.Move(0,aRet
.getHeight()+1);
288 pNeuObj
->SetLogicRect(aRet
);
291 m_pView
->AddUndo( m_pView
->GetModel()->GetSdrUndoFactory().CreateUndoNewObject( *pNeuObj
) );
292 m_pView
->MarkObj( pNeuObj
, m_pView
->GetSdrPageView() );
293 if ( m_xSection
.is() && (static_cast<sal_uInt32
>(aRet
.getHeight() + aRet
.Top()) > m_xSection
->getHeight()) )
294 m_xSection
->setHeight(aRet
.getHeight() + aRet
.Top());
298 catch(uno::Exception
&)
300 OSL_FAIL("Exception caught while pasting a new object!");
309 void OReportSection::Delete()
311 if( !m_pView
->AreObjectsMarked() )
314 m_pView
->BrkAction();
315 m_pView
->DeleteMarked();
318 void OReportSection::SetMode( DlgEdMode eNewMode
)
320 if ( eNewMode
!= m_eMode
)
322 if ( eNewMode
== RPTUI_INSERT
)
324 m_pFunc
.reset(new DlgEdFuncInsert( this ));
328 m_pFunc
.reset(new DlgEdFuncSelect( this ));
330 m_pFunc
->setOverlappedControlColor(lcl_getOverlappedControlColor( ) );
331 m_pModel
->SetReadOnly(eNewMode
== RPTUI_READONLY
);
336 void OReportSection::Copy(uno::Sequence
< beans::NamedValue
>& _rAllreadyCopiedObjects
)
338 Copy(_rAllreadyCopiedObjects
,false);
341 void OReportSection::Copy(uno::Sequence
< beans::NamedValue
>& _rAllreadyCopiedObjects
,bool _bEraseAnddNoClone
)
343 OSL_ENSURE(m_xSection
.is(),"Why is the section here NULL!");
344 if( !m_pView
->AreObjectsMarked() || !m_xSection
.is() )
347 // insert control models of marked objects into clipboard dialog model
348 const SdrMarkList
& rMarkedList
= m_pView
->GetMarkedObjectList();
349 const size_t nMark
= rMarkedList
.GetMarkCount();
351 ::std::vector
< uno::Reference
<report::XReportComponent
> > aCopies
;
352 aCopies
.reserve(nMark
);
354 SdrUndoFactory
& rUndo
= m_pView
->GetModel()->GetSdrUndoFactory();
356 for( size_t i
= nMark
; i
> 0; )
359 SdrObject
* pSdrObject
= rMarkedList
.GetMark(i
)->GetMarkedSdrObj();
360 OObjectBase
* pObj
= dynamic_cast<OObjectBase
*>(pSdrObject
);
365 SdrObject
* pNeuObj
= pSdrObject
->Clone();
366 aCopies
.push_back(uno::Reference
<report::XReportComponent
>(pNeuObj
->getUnoShape(),uno::UNO_QUERY
));
367 if ( _bEraseAnddNoClone
)
369 m_pView
->AddUndo( rUndo
.CreateUndoDeleteObject( *pSdrObject
) );
370 m_pPage
->RemoveObject(pSdrObject
->GetOrdNum());
374 catch(uno::Exception
&)
376 OSL_FAIL("Can't copy report elements!");
381 if ( !aCopies
.empty() )
383 ::std::reverse(aCopies
.begin(),aCopies
.end());
384 const sal_Int32 nLength
= _rAllreadyCopiedObjects
.getLength();
385 _rAllreadyCopiedObjects
.realloc( nLength
+ 1);
386 beans::NamedValue
* pNewValue
= _rAllreadyCopiedObjects
.getArray() + nLength
;
387 pNewValue
->Name
= m_xSection
->getName();
388 pNewValue
->Value
<<= uno::Sequence
< uno::Reference
<report::XReportComponent
> >(&(*aCopies
.begin()),aCopies
.size());
392 void OReportSection::MouseButtonDown( const MouseEvent
& rMEvt
)
394 m_pParent
->getViewsWindow()->getView()->setMarked(m_pView
, true); // mark the section in which is clicked
395 m_pFunc
->MouseButtonDown( rMEvt
);
396 Window::MouseButtonDown(rMEvt
);
399 void OReportSection::MouseButtonUp( const MouseEvent
& rMEvt
)
401 if ( !m_pFunc
->MouseButtonUp( rMEvt
) )
402 m_pParent
->getViewsWindow()->getView()->getReportView()->getController().executeUnChecked(SID_OBJECT_SELECT
,uno::Sequence
< beans::PropertyValue
>());
407 void OReportSection::MouseMove( const MouseEvent
& rMEvt
)
409 m_pFunc
->MouseMove( rMEvt
);
413 void OReportSection::SetGridVisible(bool _bVisible
)
415 m_pView
->SetGridVisible( _bVisible
);
418 void OReportSection::SelectAll(const sal_uInt16 _nObjectType
)
422 if ( _nObjectType
== OBJ_NONE
)
423 m_pView
->MarkAllObj();
426 m_pView
->UnmarkAll();
427 SdrObjListIter
aIter(*m_pPage
,IM_DEEPNOGROUPS
);
428 SdrObject
* pObjIter
= NULL
;
429 while( (pObjIter
= aIter
.Next()) != NULL
)
431 if ( pObjIter
->GetObjIdentifier() == _nObjectType
)
432 m_pView
->MarkObj( pObjIter
, m_pView
->GetSdrPageView() );
437 void lcl_insertMenuItemImages(
438 PopupMenu
& rContextMenu
,
439 OReportController
& rController
,
440 const uno::Reference
< report::XReportDefinition
>& _xReportDefinition
,uno::Reference
<frame::XFrame
>& _rFrame
443 const sal_uInt16 nCount
= rContextMenu
.GetItemCount();
444 for (sal_uInt16 i
= 0; i
< nCount
; ++i
)
446 if ( MenuItemType::SEPARATOR
!= rContextMenu
.GetItemType(i
))
448 const sal_uInt16 nId
= rContextMenu
.GetItemId(i
);
449 PopupMenu
* pPopupMenu
= rContextMenu
.GetPopupMenu( nId
);
452 lcl_insertMenuItemImages(*pPopupMenu
,rController
,_xReportDefinition
,_rFrame
);
456 const OUString sCommand
= rContextMenu
.GetItemCommand(nId
);
457 rContextMenu
.SetItemImage(nId
,framework::GetImageFromURL(_rFrame
,sCommand
,false));
458 if ( nId
== SID_PAGEHEADERFOOTER
)
460 OUString sText
= ModuleRes((_xReportDefinition
.is() && _xReportDefinition
->getPageHeaderOn()) ? RID_STR_PAGEHEADERFOOTER_DELETE
: RID_STR_PAGEHEADERFOOTER_INSERT
);
461 rContextMenu
.SetItemText(nId
,sText
);
463 else if ( nId
== SID_REPORTHEADERFOOTER
)
465 OUString sText
= ModuleRes((_xReportDefinition
.is() && _xReportDefinition
->getReportHeaderOn()) ? RID_STR_REPORTHEADERFOOTER_DELETE
: RID_STR_REPORTHEADERFOOTER_INSERT
);
466 rContextMenu
.SetItemText(nId
,sText
);
469 rContextMenu
.CheckItem(nId
,rController
.isCommandChecked(nId
));
470 rContextMenu
.EnableItem(nId
,rController
.isCommandEnabled(nId
));
475 void OReportSection::Command( const CommandEvent
& _rCEvt
)
477 Window::Command(_rCEvt
);
478 if (_rCEvt
.GetCommand() == CommandEventId::ContextMenu
)
480 OReportController
& rController
= m_pParent
->getViewsWindow()->getView()->getReportView()->getController();
481 uno::Reference
<frame::XFrame
> xFrame
= rController
.getFrame();
482 PopupMenu
aContextMenu( ModuleRes( RID_MENU_REPORT
) );
483 uno::Reference
< report::XReportDefinition
> xReportDefinition
= getSection()->getReportDefinition();
485 lcl_insertMenuItemImages(aContextMenu
,rController
,xReportDefinition
,xFrame
);
487 Point aPos
= _rCEvt
.GetMousePosPixel();
488 m_pView
->EndAction();
489 const sal_uInt16 nId
= aContextMenu
.Execute(this, aPos
);
492 uno::Sequence
< beans::PropertyValue
> aArgs
;
493 if ( nId
== SID_ATTR_CHAR_COLOR_BACKGROUND
)
496 aArgs
[0].Name
= "Selection";
497 aArgs
[0].Value
<<= m_xSection
;
499 rController
.executeChecked(nId
,aArgs
);
504 void OReportSection::_propertyChanged(const beans::PropertyChangeEvent
& _rEvent
) throw( uno::RuntimeException
)
506 if ( m_xSection
.is() )
508 if ( _rEvent
.Source
== m_xSection
|| PROPERTY_BACKCOLOR
== _rEvent
.PropertyName
)
510 sal_Int32 nColor
= m_xSection
->getBackColor();
511 if ( nColor
== (sal_Int32
)COL_TRANSPARENT
)
512 nColor
= getStyleProperty
<sal_Int32
>(m_xSection
->getReportDefinition(),PROPERTY_BACKCOLOR
);
513 m_pView
->SetApplicationDocumentColor(nColor
);
514 Invalidate(INVALIDATE_NOCHILDREN
|INVALIDATE_NOERASE
);
518 uno::Reference
<report::XReportDefinition
> xReportDefinition
= m_xSection
->getReportDefinition();
519 const sal_Int32 nLeftMargin
= getStyleProperty
<sal_Int32
>(xReportDefinition
,PROPERTY_LEFTMARGIN
);
520 const sal_Int32 nRightMargin
= getStyleProperty
<sal_Int32
>(xReportDefinition
,PROPERTY_RIGHTMARGIN
);
521 const sal_Int32 nPaperWidth
= getStyleProperty
<awt::Size
>(xReportDefinition
,PROPERTY_PAPERSIZE
).Width
;
523 if ( _rEvent
.PropertyName
== PROPERTY_LEFTMARGIN
)
525 m_pPage
->SetLftBorder(nLeftMargin
);
527 else if ( _rEvent
.PropertyName
== PROPERTY_RIGHTMARGIN
)
529 m_pPage
->SetRgtBorder(nRightMargin
);
531 const Size aOldPageSize
= m_pPage
->GetSize();
532 sal_Int32 nNewHeight
= 5*m_xSection
->getHeight();
533 if ( aOldPageSize
.Height() != nNewHeight
|| nPaperWidth
!= aOldPageSize
.Width() )
535 m_pPage
->SetSize( Size( nPaperWidth
,nNewHeight
) );
536 const Size aPageSize
= m_pPage
->GetSize();
537 m_pView
->SetWorkArea( Rectangle( Point( nLeftMargin
, 0), Size(aPageSize
.Width() - nLeftMargin
- nRightMargin
,aPageSize
.Height()) ) );
539 impl_adjustObjectSizePosition(nPaperWidth
,nLeftMargin
,nRightMargin
);
540 m_pParent
->Invalidate(INVALIDATE_UPDATE
| INVALIDATE_TRANSPARENT
);
544 void OReportSection::impl_adjustObjectSizePosition(sal_Int32 i_nPaperWidth
,sal_Int32 i_nLeftMargin
,sal_Int32 i_nRightMargin
)
548 sal_Int32 nRightBorder
= i_nPaperWidth
- i_nRightMargin
;
549 const sal_Int32 nCount
= m_xSection
->getCount();
550 for (sal_Int32 i
= 0; i
< nCount
; ++i
)
552 uno::Reference
< report::XReportComponent
> xReportComponent(m_xSection
->getByIndex(i
),uno::UNO_QUERY_THROW
);
553 awt::Point aPos
= xReportComponent
->getPosition();
554 awt::Size aSize
= xReportComponent
->getSize();
555 SvxShape
* pShape
= SvxShape::getImplementation( xReportComponent
);
556 SdrObject
* pObject
= pShape
? pShape
->GetSdrObject() : NULL
;
559 bool bChanged
= false;
561 OObjectBase
& rBase
= dynamic_cast<OObjectBase
&>(*pObject
);
562 rBase
.EndListening(false);
563 if ( aPos
.X
< i_nLeftMargin
)
565 aPos
.X
= i_nLeftMargin
;
568 if ( (aPos
.X
+ aSize
.Width
) > nRightBorder
)
570 aPos
.X
= nRightBorder
- aSize
.Width
;
571 if ( aPos
.X
< i_nLeftMargin
)
573 aSize
.Width
+= aPos
.X
- i_nLeftMargin
;
574 aPos
.X
= i_nLeftMargin
;
575 // add listener around
576 rBase
.StartListening();
577 xReportComponent
->setSize(aSize
);
578 rBase
.EndListening(false);
586 xReportComponent
->setPosition(aPos
);
587 correctOverlapping(pObject
,*this,false);
588 Rectangle
aRet(VCLPoint(xReportComponent
->getPosition()),VCLSize(xReportComponent
->getSize()));
589 aRet
.setHeight(aRet
.getHeight() + 1);
590 aRet
.setWidth(aRet
.getWidth() + 1);
591 if ( m_xSection
.is() && (static_cast<sal_uInt32
>(aRet
.getHeight() + aRet
.Top()) > m_xSection
->getHeight()) )
592 m_xSection
->setHeight(aRet
.getHeight() + aRet
.Top());
594 pObject
->RecalcBoundRect();
596 rBase
.StartListening();
600 catch(const uno::Exception
&)
602 OSL_FAIL("Exception caught: OReportSection::impl_adjustObjectSizePosition()");
606 bool OReportSection::handleKeyEvent(const KeyEvent
& _rEvent
)
608 return m_pFunc
.get() && m_pFunc
->handleKeyEvent(_rEvent
);
611 void OReportSection::deactivateOle()
614 m_pFunc
->deactivateOle(true);
617 void OReportSection::createDefault(const OUString
& _sType
)
619 SdrObject
* pObj
= m_pView
->GetCreateObj();
622 createDefault(_sType
,pObj
);
625 void OReportSection::createDefault(const OUString
& _sType
,SdrObject
* _pObj
)
627 bool bAttributesAppliedFromGallery
= false;
629 if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT
) )
631 std::vector
< OUString
> aObjList
;
632 if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT
, aObjList
) )
634 std::vector
< OUString
>::iterator aIter
= aObjList
.begin();
635 std::vector
< OUString
>::iterator aEnd
= aObjList
.end();
636 for (sal_uInt32 i
=0 ; aIter
!= aEnd
; ++aIter
,++i
)
638 if ( aIter
->equalsIgnoreAsciiCase( _sType
) )
640 OReportModel
aReportModel(NULL
);
641 SfxItemPool
& rPool
= aReportModel
.GetItemPool();
642 rPool
.FreezeIdRanges();
643 if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT
, i
, &aReportModel
) )
645 const SdrObject
* pSourceObj
= aReportModel
.GetPage( 0 )->GetObj( 0 );
648 const SfxItemSet
& rSource
= pSourceObj
->GetMergedItemSet();
649 SfxItemSet
aDest( _pObj
->GetModel()->GetItemPool(), // ranges from SdrAttrObj
650 SDRATTR_START
, SDRATTR_SHADOW_LAST
,
651 SDRATTR_MISC_FIRST
, SDRATTR_MISC_LAST
,
652 SDRATTR_TEXTDIRECTION
, SDRATTR_TEXTDIRECTION
,
653 // Graphic Attributes
654 SDRATTR_GRAF_FIRST
, SDRATTR_GRAF_LAST
,
656 SDRATTR_3D_FIRST
, SDRATTR_3D_LAST
,
657 // CustomShape properties
658 SDRATTR_CUSTOMSHAPE_FIRST
, SDRATTR_CUSTOMSHAPE_LAST
,
659 // range from SdrTextObj
660 EE_ITEMS_START
, EE_ITEMS_END
,
663 aDest
.Set( rSource
);
664 _pObj
->SetMergedItemSet( aDest
);
665 sal_Int32 nAngle
= pSourceObj
->GetRotateAngle();
668 double a
= nAngle
* F_PI18000
;
669 _pObj
->NbcRotate( _pObj
->GetSnapRect().Center(), nAngle
, sin( a
), cos( a
) );
671 bAttributesAppliedFromGallery
= true;
679 if ( !bAttributesAppliedFromGallery
)
681 _pObj
->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER
,ITEMID_ADJUST
) );
682 _pObj
->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER
) );
683 _pObj
->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK
) );
684 _pObj
->SetMergedItem( makeSdrTextAutoGrowHeightItem( false ) );
685 static_cast<SdrObjCustomShape
*>(_pObj
)->MergeDefaultAttributes( &_sType
);
689 uno::Reference
< report::XReportComponent
> OReportSection::getCurrentControlModel() const
691 uno::Reference
< report::XReportComponent
> xModel
;
694 const SdrMarkList
& rMarkList
= m_pView
->GetMarkedObjectList();
696 if ( rMarkList
.GetMarkCount() == 1 )
698 SdrObject
* pDlgEdObj
= rMarkList
.GetMark(0)->GetMarkedSdrObj();
699 OObjectBase
* pObj
= dynamic_cast<OObjectBase
*>(pDlgEdObj
);
701 xModel
= pObj
->getReportComponent().get();
707 void OReportSection::fillControlModelSelection(::std::vector
< uno::Reference
< uno::XInterface
> >& _rSelection
) const
711 const SdrMarkList
& rMarkList
= m_pView
->GetMarkedObjectList();
712 const size_t nMarkCount
= rMarkList
.GetMarkCount();
714 for (size_t i
=0; i
< nMarkCount
; ++i
)
716 const SdrObject
* pDlgEdObj
= rMarkList
.GetMark(i
)->GetMarkedSdrObj();
717 const OObjectBase
* pObj
= dynamic_cast<const OObjectBase
*>(pDlgEdObj
);
720 uno::Reference
<uno::XInterface
> xInterface(pObj
->getReportComponent());
721 _rSelection
.push_back(xInterface
);
727 sal_Int8
OReportSection::AcceptDrop( const AcceptDropEvent
& _rEvt
)
729 OSL_TRACE("AcceptDrop::DropEvent.Action %i", _rEvt
.mnAction
);
731 ::Point
aDropPos(_rEvt
.maPosPixel
);
732 const MouseEvent
aMouseEvt(aDropPos
);
733 if ( m_pFunc
->isOverlapping(aMouseEvt
) )
734 return DND_ACTION_NONE
;
736 if ( _rEvt
.mnAction
== DND_ACTION_COPY
||
737 _rEvt
.mnAction
== DND_ACTION_LINK
740 if (!m_pParent
) return DND_ACTION_NONE
;
741 sal_uInt16 nCurrentPosition
= 0;
742 nCurrentPosition
= m_pParent
->getViewsWindow()->getPosition(m_pParent
);
743 if (_rEvt
.mnAction
== DND_ACTION_COPY
)
745 // we must assure, we can't drop in the top section
746 if (nCurrentPosition
< 1)
748 return DND_ACTION_NONE
;
750 return DND_ACTION_LINK
;
752 if (_rEvt
.mnAction
== DND_ACTION_LINK
)
754 // we must assure, we can't drop in the bottom section
755 if (m_pParent
->getViewsWindow()->getSectionCount() > (nCurrentPosition
+ 1) )
757 return DND_ACTION_COPY
;
759 return DND_ACTION_NONE
;
764 const DataFlavorExVector
& rFlavors
= GetDataFlavorExVector();
765 if ( svx::OMultiColumnTransferable::canExtractDescriptor(rFlavors
)
766 || svx::OColumnTransferable::canExtractColumnDescriptor(rFlavors
, ColumnTransferFormatFlags::FIELD_DESCRIPTOR
| ColumnTransferFormatFlags::CONTROL_EXCHANGE
| ColumnTransferFormatFlags::COLUMN_DESCRIPTOR
) )
767 return _rEvt
.mnAction
;
769 const sal_Int8 nDropOption
= ( OReportExchange::canExtract(rFlavors
) ) ? DND_ACTION_COPYMOVE
: DND_ACTION_NONE
;
773 return DND_ACTION_NONE
;
777 sal_Int8
OReportSection::ExecuteDrop( const ExecuteDropEvent
& _rEvt
)
779 OSL_TRACE("ExecuteDrop::DropEvent.Action %i", _rEvt
.mnAction
);
780 ::Point
aDropPos(PixelToLogic(_rEvt
.maPosPixel
));
781 const MouseEvent
aMouseEvt(aDropPos
);
782 if ( m_pFunc
->isOverlapping(aMouseEvt
) )
783 return DND_ACTION_NONE
;
785 sal_Int8 nDropOption
= DND_ACTION_NONE
;
786 const TransferableDataHelper
aDropped(_rEvt
.maDropEvent
.Transferable
);
787 DataFlavorExVector
& rFlavors
= aDropped
.GetDataFlavorExVector();
788 bool bMultipleFormat
= svx::OMultiColumnTransferable::canExtractDescriptor(rFlavors
);
789 if ( OReportExchange::canExtract(rFlavors
) )
791 OReportExchange::TSectionElements aCopies
= OReportExchange::extractCopies(aDropped
);
793 nDropOption
= DND_ACTION_COPYMOVE
;
794 m_pParent
->getViewsWindow()->BrkAction();
795 m_pParent
->getViewsWindow()->unmarkAllObjects(m_pView
);
797 else if ( bMultipleFormat
798 || svx::OColumnTransferable::canExtractColumnDescriptor(rFlavors
, ColumnTransferFormatFlags::FIELD_DESCRIPTOR
| ColumnTransferFormatFlags::CONTROL_EXCHANGE
| ColumnTransferFormatFlags::COLUMN_DESCRIPTOR
) )
800 m_pParent
->getViewsWindow()->getView()->setMarked(m_pView
, true);
801 m_pView
->UnmarkAll();
802 const Rectangle
& rRect
= m_pView
->GetWorkArea();
803 if ( aDropPos
.X() < rRect
.Left() )
804 aDropPos
.X() = rRect
.Left();
805 else if ( aDropPos
.X() > rRect
.Right() )
806 aDropPos
.X() = rRect
.Right();
808 if ( aDropPos
.Y() > rRect
.Bottom() )
809 aDropPos
.Y() = rRect
.Bottom();
811 uno::Sequence
<beans::PropertyValue
> aValues
;
812 if ( !bMultipleFormat
)
814 svx::ODataAccessDescriptor aDescriptor
= svx::OColumnTransferable::extractColumnDescriptor(aDropped
);
817 aValues
[0].Value
<<= aDescriptor
.createPropertyValueSequence();
820 aValues
= svx::OMultiColumnTransferable::extractDescriptor(aDropped
);
822 beans::PropertyValue
* pIter
= aValues
.getArray();
823 beans::PropertyValue
* pEnd
= pIter
+ aValues
.getLength();
824 for(;pIter
!= pEnd
; ++pIter
)
826 uno::Sequence
<beans::PropertyValue
> aCurrent
;
827 pIter
->Value
>>= aCurrent
;
828 sal_Int32 nLength
= aCurrent
.getLength();
831 aCurrent
.realloc(nLength
+ 3);
832 aCurrent
[nLength
].Name
= PROPERTY_POSITION
;
833 aCurrent
[nLength
++].Value
<<= AWTPoint(aDropPos
);
834 // give also the DND Action (Shift|Ctrl) Key to really say what we want
835 aCurrent
[nLength
].Name
= "DNDAction";
836 aCurrent
[nLength
++].Value
<<= _rEvt
.mnAction
;
838 aCurrent
[nLength
].Name
= "Section";
839 aCurrent
[nLength
++].Value
<<= getSection();
840 pIter
->Value
<<= aCurrent
;
844 // we use this way to create undo actions
845 OReportController
& rController
= m_pParent
->getViewsWindow()->getView()->getReportView()->getController();
846 rController
.executeChecked(SID_ADD_CONTROL_PAIR
,aValues
);
847 nDropOption
= DND_ACTION_COPY
;
852 void OReportSection::stopScrollTimer()
854 m_pFunc
->stopScrollTimer();
857 bool OReportSection::isUiActive() const
859 return m_pFunc
->isUiActive();
866 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */