xref: /trunk/main/reportdesign/source/ui/report/ReportSection.cxx (revision 093b492c61de4e1fb95c7e65810eaeddbb65f806)
19e0e4191SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
39e0e4191SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
49e0e4191SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
59e0e4191SAndrew Rist  * distributed with this work for additional information
69e0e4191SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
79e0e4191SAndrew Rist  * to you under the Apache License, Version 2.0 (the
89e0e4191SAndrew Rist  * "License"); you may not use this file except in compliance
99e0e4191SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
119e0e4191SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
139e0e4191SAndrew Rist  * Unless required by applicable law or agreed to in writing,
149e0e4191SAndrew Rist  * software distributed under the License is distributed on an
159e0e4191SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169e0e4191SAndrew Rist  * KIND, either express or implied.  See the License for the
179e0e4191SAndrew Rist  * specific language governing permissions and limitations
189e0e4191SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
209e0e4191SAndrew Rist  *************************************************************/
219e0e4191SAndrew Rist 
22b63233d8Sdamjan #include "precompiled_rptui.hxx"
23cdf0e10cSrcweir #include "ReportSection.hxx"
24cdf0e10cSrcweir #include "ReportWindow.hxx"
25cdf0e10cSrcweir #include "DesignView.hxx"
26cdf0e10cSrcweir #include "uistrings.hrc"
27cdf0e10cSrcweir #include "RptObject.hxx"
28cdf0e10cSrcweir #include "RptModel.hxx"
29cdf0e10cSrcweir #include "SectionView.hxx"
30cdf0e10cSrcweir #include "RptPage.hxx"
31cdf0e10cSrcweir #include "ReportController.hxx"
32cdf0e10cSrcweir #include "UITools.hxx"
33cdf0e10cSrcweir #include "ViewsWindow.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <svx/svdpagv.hxx>
36cdf0e10cSrcweir #include <editeng/eeitemid.hxx>
37cdf0e10cSrcweir #include <editeng/adjitem.hxx>
38cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx>
39cdf0e10cSrcweir #include <svx/unoshape.hxx>
40cdf0e10cSrcweir #include <svx/gallery.hxx>
41cdf0e10cSrcweir #include <svx/svxids.hrc>
42cdf0e10cSrcweir #include <svx/svditer.hxx>
43cdf0e10cSrcweir #include <svx/dbaexchange.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <vcl/svapp.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
48cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
49cdf0e10cSrcweir #include "RptDef.hxx"
50cdf0e10cSrcweir #include "SectionWindow.hxx"
51cdf0e10cSrcweir #include "helpids.hrc"
52cdf0e10cSrcweir #include "RptResId.hrc"
53cdf0e10cSrcweir #include "dlgedclip.hxx"
54cdf0e10cSrcweir #include "UndoActions.hxx"
55cdf0e10cSrcweir #include "rptui_slotid.hrc"
56cdf0e10cSrcweir 
57cdf0e10cSrcweir #include <connectivity/dbtools.hxx>
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #include <vcl/lineinfo.hxx>
60cdf0e10cSrcweir #include "ColorChanger.hxx"
61cdf0e10cSrcweir 
62cdf0e10cSrcweir #include <svl/itempool.hxx>
63cdf0e10cSrcweir #include <svtools/extcolorcfg.hxx>
64cdf0e10cSrcweir #include <unotools/confignode.hxx>
65cdf0e10cSrcweir #include <framework/imageproducer.hxx>
66cdf0e10cSrcweir 
67cdf0e10cSrcweir // =============================================================================
68cdf0e10cSrcweir namespace rptui
69cdf0e10cSrcweir {
70cdf0e10cSrcweir // =============================================================================
71cdf0e10cSrcweir using namespace ::com::sun::star;
72cdf0e10cSrcweir // -----------------------------------------------------------------------------
73cdf0e10cSrcweir 
lcl_getOverlappedControlColor()74cdf0e10cSrcweir sal_Int32 lcl_getOverlappedControlColor(/*const uno::Reference <lang::XMultiServiceFactory> _rxFactory*/)
75cdf0e10cSrcweir {
76cdf0e10cSrcweir     svtools::ExtendedColorConfig aConfig;
77cdf0e10cSrcweir     sal_Int32 nColor = aConfig.GetColorValue(CFG_REPORTDESIGNER, DBOVERLAPPEDCONTROL).getColor();
78cdf0e10cSrcweir     return nColor;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir //------------------------------------------------------------------------------
DBG_NAME(rpt_OReportSection)81cdf0e10cSrcweir DBG_NAME( rpt_OReportSection )
82cdf0e10cSrcweir OReportSection::OReportSection(OSectionWindow* _pParent,const uno::Reference< report::XSection >& _xSection)
83cdf0e10cSrcweir : Window(_pParent,WB_DIALOGCONTROL)
84cdf0e10cSrcweir , ::comphelper::OPropertyChangeListener(m_aMutex)
85cdf0e10cSrcweir , DropTargetHelper(this)
86cdf0e10cSrcweir ,m_pPage(NULL)
87cdf0e10cSrcweir ,m_pView(NULL)
88cdf0e10cSrcweir ,m_pParent(_pParent)
89cdf0e10cSrcweir ,m_pFunc(NULL)
90cdf0e10cSrcweir ,m_pMulti(NULL)
91cdf0e10cSrcweir ,m_pReportListener(NULL)
92cdf0e10cSrcweir ,m_xSection(_xSection)
93cdf0e10cSrcweir ,m_nPaintEntranceCount(0)
94cdf0e10cSrcweir ,m_eMode(RPTUI_SELECT)
95cdf0e10cSrcweir ,m_bDialogModelChanged(sal_False)
96cdf0e10cSrcweir ,m_bInDrag(sal_False)
97cdf0e10cSrcweir {
98cdf0e10cSrcweir     DBG_CTOR( rpt_OReportSection,NULL);
99cdf0e10cSrcweir     //EnableChildTransparentMode();
100cdf0e10cSrcweir     SetHelpId(HID_REPORTSECTION);
101cdf0e10cSrcweir     SetMapMode( MapMode( MAP_100TH_MM ) );
102cdf0e10cSrcweir     SetParentClipMode( PARENTCLIPMODE_CLIP );
103cdf0e10cSrcweir     EnableChildTransparentMode( sal_False );
104cdf0e10cSrcweir     SetPaintTransparent( sal_False );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     try
107cdf0e10cSrcweir     {
108cdf0e10cSrcweir         fill();
109cdf0e10cSrcweir     }
110cdf0e10cSrcweir     catch(uno::Exception&)
111cdf0e10cSrcweir     {
112cdf0e10cSrcweir         OSL_ENSURE(0,"Exception catched!");
113cdf0e10cSrcweir     }
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     m_pFunc.reset(new DlgEdFuncSelect( this ));
116cdf0e10cSrcweir     m_pFunc->setOverlappedControlColor(lcl_getOverlappedControlColor( /* m_pParent->getViewsWindow()->getView()->getReportView()->getController().getORB() */ ) );
117cdf0e10cSrcweir }
118cdf0e10cSrcweir //------------------------------------------------------------------------------
~OReportSection()119cdf0e10cSrcweir OReportSection::~OReportSection()
120cdf0e10cSrcweir {
121cdf0e10cSrcweir     DBG_DTOR( rpt_OReportSection,NULL);
122cdf0e10cSrcweir     m_pPage = NULL;
123cdf0e10cSrcweir     //m_pModel->GetUndoEnv().RemoveSection(m_xSection.get());
124cdf0e10cSrcweir     if ( m_pMulti.is() )
125cdf0e10cSrcweir         m_pMulti->dispose();
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     if ( m_pReportListener.is() )
128cdf0e10cSrcweir         m_pReportListener->dispose();
129cdf0e10cSrcweir     m_pFunc = ::std::auto_ptr<DlgEdFunc>();
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     {
132cdf0e10cSrcweir         ::std::auto_ptr<OSectionView> aTemp( m_pView);
133cdf0e10cSrcweir         if ( m_pView )
134cdf0e10cSrcweir             m_pView->EndListening( *m_pModel );
135cdf0e10cSrcweir         m_pView = NULL;
136cdf0e10cSrcweir     }
137cdf0e10cSrcweir     /*m_pModel->DeletePage(m_pPage->GetPageNum());*/
138cdf0e10cSrcweir }
139cdf0e10cSrcweir //------------------------------------------------------------------------------
Paint(const Rectangle & rRect)140cdf0e10cSrcweir void OReportSection::Paint( const Rectangle& rRect )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir     Window::Paint(rRect);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     if ( m_pView && m_nPaintEntranceCount == 0)
145cdf0e10cSrcweir     {
146cdf0e10cSrcweir         ++m_nPaintEntranceCount;
147cdf0e10cSrcweir         // repaint, get PageView and prepare Region
148cdf0e10cSrcweir         SdrPageView* pPgView = m_pView->GetSdrPageView();
149cdf0e10cSrcweir         const Region aPaintRectRegion(rRect);
150cdf0e10cSrcweir 
151cdf0e10cSrcweir         // #i74769#
152cdf0e10cSrcweir         SdrPaintWindow* pTargetPaintWindow = 0;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir         // mark repaint start
155cdf0e10cSrcweir         if(pPgView)
156cdf0e10cSrcweir         {
157cdf0e10cSrcweir             pTargetPaintWindow = pPgView->GetView().BeginDrawLayers(this, aPaintRectRegion);
158cdf0e10cSrcweir             OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
159cdf0e10cSrcweir             // draw background self using wallpaper
160cdf0e10cSrcweir             OutputDevice& rTargetOutDev = pTargetPaintWindow->GetTargetOutputDevice();
161cdf0e10cSrcweir             rTargetOutDev.DrawWallpaper(rRect, Wallpaper(pPgView->GetApplicationDocumentColor()));
162cdf0e10cSrcweir         }
163cdf0e10cSrcweir 
164cdf0e10cSrcweir         // do paint (unbuffered) and mark repaint end
165cdf0e10cSrcweir         if(pPgView)
166cdf0e10cSrcweir         {
167cdf0e10cSrcweir             pPgView->DrawLayer(0, this);
168cdf0e10cSrcweir             pPgView->GetView().EndDrawLayers(*pTargetPaintWindow, true);
169cdf0e10cSrcweir         }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir         m_pView->CompleteRedraw(this,aPaintRectRegion);
172cdf0e10cSrcweir         --m_nPaintEntranceCount;
173cdf0e10cSrcweir     }
174cdf0e10cSrcweir }
175cdf0e10cSrcweir //------------------------------------------------------------------------------
Resize()176cdf0e10cSrcweir void OReportSection::Resize()
177cdf0e10cSrcweir {
178cdf0e10cSrcweir     Window::Resize();
179cdf0e10cSrcweir }
180cdf0e10cSrcweir //------------------------------------------------------------------------------
fill()181cdf0e10cSrcweir void OReportSection::fill()
182cdf0e10cSrcweir {
183cdf0e10cSrcweir     if ( !m_xSection.is() )
184cdf0e10cSrcweir         return;
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     m_pMulti = new comphelper::OPropertyChangeMultiplexer(this,m_xSection.get());
187cdf0e10cSrcweir     m_pMulti->addProperty(PROPERTY_BACKCOLOR);
188cdf0e10cSrcweir 
189cdf0e10cSrcweir     m_pReportListener = addStyleListener(m_xSection->getReportDefinition(),this);
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     m_pModel = m_pParent->getViewsWindow()->getView()->getReportView()->getController().getSdrModel();
192cdf0e10cSrcweir     m_pPage = m_pModel->getPage(m_xSection);
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     m_pView = new OSectionView( m_pModel.get(), this, m_pParent->getViewsWindow()->getView() );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     // #i93597# tell SdrPage that only left and right page border is defined
197cdf0e10cSrcweir     // instead of the full rectangle definition
198cdf0e10cSrcweir     m_pPage->setPageBorderOnlyLeftRight(true);
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     // without the following call, no grid is painted
201cdf0e10cSrcweir     m_pView->ShowSdrPage( m_pPage );
202cdf0e10cSrcweir 
203cdf0e10cSrcweir     m_pView->SetMoveSnapOnlyTopLeft( sal_True );
204cdf0e10cSrcweir     ODesignView* pDesignView = m_pParent->getViewsWindow()->getView()->getReportView();
205cdf0e10cSrcweir 
206cdf0e10cSrcweir     // #i93595# Adapted grid to a more coarse grid and subdivisions for better visualisation. This
207cdf0e10cSrcweir     // is only for visualisation and has nothing to do with the actual snap
208cdf0e10cSrcweir     const Size aGridSizeCoarse(pDesignView->getGridSizeCoarse());
209cdf0e10cSrcweir     const Size aGridSizeFine(pDesignView->getGridSizeFine());
210cdf0e10cSrcweir     m_pView->SetGridCoarse(aGridSizeCoarse);
211cdf0e10cSrcweir     m_pView->SetGridFine(aGridSizeFine);
212cdf0e10cSrcweir 
213cdf0e10cSrcweir     // #i93595# set snap grid width to snap to all existing subdivisions
214cdf0e10cSrcweir     const Fraction aX(aGridSizeFine.A());
215cdf0e10cSrcweir     const Fraction aY(aGridSizeFine.B());
216cdf0e10cSrcweir     m_pView->SetSnapGridWidth(aX, aY);
217cdf0e10cSrcweir 
218cdf0e10cSrcweir     m_pView->SetGridSnap( pDesignView->isGridSnap() );
219cdf0e10cSrcweir     m_pView->SetGridFront( sal_False );
220cdf0e10cSrcweir     m_pView->SetDragStripes( sal_True );
221cdf0e10cSrcweir     m_pView->SetPageVisible();
222cdf0e10cSrcweir     sal_Int32 nColor = m_xSection->getBackColor();
223cdf0e10cSrcweir     if ( nColor == (sal_Int32)COL_TRANSPARENT )
224cdf0e10cSrcweir         nColor = getStyleProperty<sal_Int32>(m_xSection->getReportDefinition(),PROPERTY_BACKCOLOR);
225cdf0e10cSrcweir     m_pView->SetApplicationDocumentColor(nColor);
226cdf0e10cSrcweir 
227cdf0e10cSrcweir     uno::Reference<report::XReportDefinition> xReportDefinition = m_xSection->getReportDefinition();
228cdf0e10cSrcweir     const sal_Int32 nLeftMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN);
229cdf0e10cSrcweir     const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN);
230cdf0e10cSrcweir     m_pPage->SetLftBorder(nLeftMargin);
231cdf0e10cSrcweir     m_pPage->SetRgtBorder(nRightMargin);
232cdf0e10cSrcweir 
233cdf0e10cSrcweir // LLA: TODO
234cdf0e10cSrcweir //  m_pPage->SetUppBorder(-10000);
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     m_pView->SetDesignMode( sal_True );
237cdf0e10cSrcweir 
238cdf0e10cSrcweir     m_pView->StartListening( *m_pModel  );
239cdf0e10cSrcweir     /*Resize();*/
240cdf0e10cSrcweir     m_pPage->SetSize( Size( getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width,5*m_xSection->getHeight()) );
241cdf0e10cSrcweir     const Size aPageSize = m_pPage->GetSize();
242cdf0e10cSrcweir     m_pView->SetWorkArea( Rectangle( Point( nLeftMargin, 0), Size(aPageSize.Width() - nLeftMargin - nRightMargin,aPageSize.Height()) ) );
243cdf0e10cSrcweir 
244cdf0e10cSrcweir     //SetBackground( Wallpaper( COL_BLUE ));
245cdf0e10cSrcweir }
246cdf0e10cSrcweir // -----------------------------------------------------------------------------
Paste(const uno::Sequence<beans::NamedValue> & _aAllreadyCopiedObjects,bool _bForce)247cdf0e10cSrcweir void OReportSection::Paste(const uno::Sequence< beans::NamedValue >& _aAllreadyCopiedObjects,bool _bForce)
248cdf0e10cSrcweir {
249cdf0e10cSrcweir     OSL_ENSURE(m_xSection.is(),"Why is the section here NULL!");
250cdf0e10cSrcweir     if ( m_xSection.is() && _aAllreadyCopiedObjects.getLength() )
251cdf0e10cSrcweir     {
252cdf0e10cSrcweir         // stop all drawing actions
253cdf0e10cSrcweir         m_pView->BrkAction();
254cdf0e10cSrcweir 
255cdf0e10cSrcweir         // unmark all objects
256cdf0e10cSrcweir         m_pView->UnmarkAll();
257cdf0e10cSrcweir         const ::rtl::OUString sSectionName = m_xSection->getName();
258cdf0e10cSrcweir         const sal_Int32 nLength = _aAllreadyCopiedObjects.getLength();
259cdf0e10cSrcweir         const beans::NamedValue* pIter = _aAllreadyCopiedObjects.getConstArray();
260cdf0e10cSrcweir         const beans::NamedValue* pEnd  = pIter + nLength;
261cdf0e10cSrcweir         for(;pIter != pEnd;++pIter)
262cdf0e10cSrcweir         {
263cdf0e10cSrcweir             if ( _bForce || pIter->Name == sSectionName)
264cdf0e10cSrcweir             {
265cdf0e10cSrcweir                 try
266cdf0e10cSrcweir                 {
267cdf0e10cSrcweir                     uno::Sequence< uno::Reference<report::XReportComponent> > aCopies;
268cdf0e10cSrcweir                     pIter->Value >>= aCopies;
269cdf0e10cSrcweir                     const uno::Reference<report::XReportComponent>* pCopiesIter = aCopies.getConstArray();
270cdf0e10cSrcweir                     const uno::Reference<report::XReportComponent>* pCopiesEnd = pCopiesIter + aCopies.getLength();
271cdf0e10cSrcweir                     for (;pCopiesIter != pCopiesEnd ; ++pCopiesIter)
272cdf0e10cSrcweir                     {
273cdf0e10cSrcweir                         SvxShape* pShape = SvxShape::getImplementation( *pCopiesIter );
274cdf0e10cSrcweir                         SdrObject* pObject = pShape ? pShape->GetSdrObject() : NULL;
275cdf0e10cSrcweir                         if ( pObject )
276cdf0e10cSrcweir                         {
277fe9b7f6aSmseidel                             SdrObject* pNewObj = pObject->Clone();
278cdf0e10cSrcweir 
279fe9b7f6aSmseidel                             pNewObj->SetPage( m_pPage );
280fe9b7f6aSmseidel                             pNewObj->SetModel( m_pModel.get() );
281cdf0e10cSrcweir                             SdrInsertReason aReason(SDRREASON_VIEWCALL);
282fe9b7f6aSmseidel                             m_pPage->InsertObject(pNewObj,CONTAINER_APPEND,&aReason);
283cdf0e10cSrcweir 
284cdf0e10cSrcweir                             Rectangle aRet(VCLPoint((*pCopiesIter)->getPosition()),VCLSize((*pCopiesIter)->getSize()));
285cdf0e10cSrcweir                             aRet.setHeight(aRet.getHeight() + 1);
286cdf0e10cSrcweir                             aRet.setWidth(aRet.getWidth() + 1);
287cdf0e10cSrcweir                             bool bOverlapping = true;
288cdf0e10cSrcweir                             while ( bOverlapping )
289cdf0e10cSrcweir                             {
290fe9b7f6aSmseidel                                 bOverlapping = isOver(aRet,*m_pPage,*m_pView,true,pNewObj) != NULL;
291cdf0e10cSrcweir                                 if ( bOverlapping )
292cdf0e10cSrcweir                                 {
293cdf0e10cSrcweir                                     aRet.Move(0,aRet.getHeight()+1);
294fe9b7f6aSmseidel                                     pNewObj->SetLogicRect(aRet);
295cdf0e10cSrcweir                                     //(*pCopiesIter)->setPositionY(aRet.Top());
296cdf0e10cSrcweir                                 }
297cdf0e10cSrcweir                             }
298fe9b7f6aSmseidel                             m_pView->AddUndo( m_pView->GetModel()->GetSdrUndoFactory().CreateUndoNewObject( *pNewObj ) );
299fe9b7f6aSmseidel                             m_pView->MarkObj( pNewObj, m_pView->GetSdrPageView() );
300cdf0e10cSrcweir                             if ( m_xSection.is() && (static_cast<sal_uInt32>(aRet.getHeight() + aRet.Top()) > m_xSection->getHeight()) )
301cdf0e10cSrcweir                                 m_xSection->setHeight(aRet.getHeight() + aRet.Top());
302cdf0e10cSrcweir                         }
303cdf0e10cSrcweir                     }
304cdf0e10cSrcweir                 }
305cdf0e10cSrcweir                 catch(uno::Exception&)
306cdf0e10cSrcweir                 {
307cdf0e10cSrcweir                     OSL_ENSURE(0,"Exception caught while pasting a new object!");
308cdf0e10cSrcweir                 }
309cdf0e10cSrcweir                 if ( !_bForce )
310cdf0e10cSrcweir                     break;
311cdf0e10cSrcweir             }
312cdf0e10cSrcweir         }
313cdf0e10cSrcweir     }
314cdf0e10cSrcweir }
315cdf0e10cSrcweir //----------------------------------------------------------------------------
Delete()316cdf0e10cSrcweir void OReportSection::Delete()
317cdf0e10cSrcweir {
318cdf0e10cSrcweir     if( !m_pView->AreObjectsMarked() )
319cdf0e10cSrcweir         return;
320cdf0e10cSrcweir 
321cdf0e10cSrcweir     m_pView->BrkAction();
322cdf0e10cSrcweir     m_pView->DeleteMarked();
323cdf0e10cSrcweir }
324cdf0e10cSrcweir //----------------------------------------------------------------------------
SetMode(DlgEdMode eNewMode)325cdf0e10cSrcweir void OReportSection::SetMode( DlgEdMode eNewMode )
326cdf0e10cSrcweir {
327cdf0e10cSrcweir     if ( eNewMode != m_eMode )
328cdf0e10cSrcweir     {
329cdf0e10cSrcweir         if ( eNewMode == RPTUI_INSERT )
330cdf0e10cSrcweir         {
331cdf0e10cSrcweir             m_pFunc.reset(new DlgEdFuncInsert( this ));
332cdf0e10cSrcweir         }
333cdf0e10cSrcweir         else
334cdf0e10cSrcweir         {
335cdf0e10cSrcweir             m_pFunc.reset(new DlgEdFuncSelect( this ));
336cdf0e10cSrcweir         }
337cdf0e10cSrcweir         m_pFunc->setOverlappedControlColor(lcl_getOverlappedControlColor( ) );
338cdf0e10cSrcweir         m_pModel->SetReadOnly(eNewMode == RPTUI_READONLY);
339cdf0e10cSrcweir         m_eMode = eNewMode;
340cdf0e10cSrcweir     }
341cdf0e10cSrcweir }
342cdf0e10cSrcweir // -----------------------------------------------------------------------------
Copy(uno::Sequence<beans::NamedValue> & _rAllreadyCopiedObjects)343cdf0e10cSrcweir void OReportSection::Copy(uno::Sequence< beans::NamedValue >& _rAllreadyCopiedObjects)
344cdf0e10cSrcweir {
345cdf0e10cSrcweir     Copy(_rAllreadyCopiedObjects,false);
346cdf0e10cSrcweir }
347cdf0e10cSrcweir //----------------------------------------------------------------------------
Copy(uno::Sequence<beans::NamedValue> & _rAllreadyCopiedObjects,bool _bEraseAnddNoClone)348cdf0e10cSrcweir void OReportSection::Copy(uno::Sequence< beans::NamedValue >& _rAllreadyCopiedObjects,bool _bEraseAnddNoClone)
349cdf0e10cSrcweir {
350cdf0e10cSrcweir     OSL_ENSURE(m_xSection.is(),"Why is the section here NULL!");
351cdf0e10cSrcweir     if( !m_pView->AreObjectsMarked() || !m_xSection.is() )
352cdf0e10cSrcweir         return;
353cdf0e10cSrcweir 
354cdf0e10cSrcweir     // stop all drawing actions
355cdf0e10cSrcweir     //m_pView->BrkAction();
356cdf0e10cSrcweir 
357cdf0e10cSrcweir     // insert control models of marked objects into clipboard dialog model
358cdf0e10cSrcweir     const SdrMarkList& rMarkedList = m_pView->GetMarkedObjectList();
359cdf0e10cSrcweir     const sal_uLong nMark = rMarkedList.GetMarkCount();
360cdf0e10cSrcweir 
361cdf0e10cSrcweir     ::std::vector< uno::Reference<report::XReportComponent> > aCopies;
362cdf0e10cSrcweir     aCopies.reserve(nMark);
363cdf0e10cSrcweir 
364cdf0e10cSrcweir     SdrUndoFactory& rUndo = m_pView->GetModel()->GetSdrUndoFactory();
365cdf0e10cSrcweir 
366cdf0e10cSrcweir     for( sal_uLong i = nMark; i > 0; )
367cdf0e10cSrcweir     {
368cdf0e10cSrcweir         --i;
369cdf0e10cSrcweir         SdrObject* pSdrObject = rMarkedList.GetMark(i)->GetMarkedSdrObj();
370cdf0e10cSrcweir         OObjectBase* pObj = dynamic_cast<OObjectBase*>(pSdrObject);
371cdf0e10cSrcweir         if ( pObj  )
372cdf0e10cSrcweir         {
373cdf0e10cSrcweir             try
374cdf0e10cSrcweir             {
375fe9b7f6aSmseidel                 SdrObject* pNewObj = pSdrObject->Clone();
376fe9b7f6aSmseidel                 aCopies.push_back(uno::Reference<report::XReportComponent>(pNewObj->getUnoShape(),uno::UNO_QUERY));
377cdf0e10cSrcweir                 if ( _bEraseAnddNoClone )
378cdf0e10cSrcweir                 {
379cdf0e10cSrcweir                     m_pView->AddUndo( rUndo.CreateUndoDeleteObject( *pSdrObject ) );
380cdf0e10cSrcweir                     m_pPage->RemoveObject(pSdrObject->GetOrdNum());
381cdf0e10cSrcweir                 }
382cdf0e10cSrcweir 
383cdf0e10cSrcweir             }
384cdf0e10cSrcweir             catch(uno::Exception&)
385cdf0e10cSrcweir             {
386cdf0e10cSrcweir                 OSL_ENSURE(0,"Can't copy report elements!");
387cdf0e10cSrcweir             }
388cdf0e10cSrcweir         }
389cdf0e10cSrcweir     } // for( sal_uLong i = 0; i < nMark; i++ )
390cdf0e10cSrcweir 
391cdf0e10cSrcweir     if ( !aCopies.empty() )
392cdf0e10cSrcweir     {
393cdf0e10cSrcweir         ::std::reverse(aCopies.begin(),aCopies.end());
394cdf0e10cSrcweir         const sal_Int32 nLength = _rAllreadyCopiedObjects.getLength();
395cdf0e10cSrcweir         _rAllreadyCopiedObjects.realloc( nLength + 1);
396cdf0e10cSrcweir         beans::NamedValue* pNewValue = _rAllreadyCopiedObjects.getArray() + nLength;
397cdf0e10cSrcweir         pNewValue->Name = m_xSection->getName();
398cdf0e10cSrcweir         pNewValue->Value <<= uno::Sequence< uno::Reference<report::XReportComponent> >(&(*aCopies.begin()),aCopies.size());
399cdf0e10cSrcweir     }
400cdf0e10cSrcweir }
401cdf0e10cSrcweir //----------------------------------------------------------------------------
MouseButtonDown(const MouseEvent & rMEvt)402cdf0e10cSrcweir void OReportSection::MouseButtonDown( const MouseEvent& rMEvt )
403cdf0e10cSrcweir {
404cdf0e10cSrcweir     m_pParent->getViewsWindow()->getView()->setMarked(m_pView,sal_True); // mark the section in which is clicked
405cdf0e10cSrcweir     m_pFunc->MouseButtonDown( rMEvt );
406cdf0e10cSrcweir     Window::MouseButtonDown(rMEvt);
407cdf0e10cSrcweir }
408cdf0e10cSrcweir //----------------------------------------------------------------------------
MouseButtonUp(const MouseEvent & rMEvt)409cdf0e10cSrcweir void OReportSection::MouseButtonUp( const MouseEvent& rMEvt )
410cdf0e10cSrcweir {
411cdf0e10cSrcweir     if ( !m_pFunc->MouseButtonUp( rMEvt ) )
412cdf0e10cSrcweir         m_pParent->getViewsWindow()->getView()->getReportView()->getController().executeUnChecked(SID_OBJECT_SELECT,uno::Sequence< beans::PropertyValue>());
413cdf0e10cSrcweir }
414cdf0e10cSrcweir 
415cdf0e10cSrcweir //----------------------------------------------------------------------------
416cdf0e10cSrcweir 
MouseMove(const MouseEvent & rMEvt)417cdf0e10cSrcweir void OReportSection::MouseMove( const MouseEvent& rMEvt )
418cdf0e10cSrcweir {
419cdf0e10cSrcweir     m_pFunc->MouseMove( rMEvt );
420cdf0e10cSrcweir 
421cdf0e10cSrcweir }
422cdf0e10cSrcweir //----------------------------------------------------------------------------
SetGridVisible(sal_Bool _bVisible)423cdf0e10cSrcweir void OReportSection::SetGridVisible(sal_Bool _bVisible)
424cdf0e10cSrcweir {
425cdf0e10cSrcweir     m_pView->SetGridVisible( _bVisible );
426cdf0e10cSrcweir }
427cdf0e10cSrcweir //------------------------------------------------------------------------------
SelectAll(const sal_uInt16 _nObjectType)428cdf0e10cSrcweir void OReportSection::SelectAll(const sal_uInt16 _nObjectType)
429cdf0e10cSrcweir {
430cdf0e10cSrcweir     if ( m_pView )
431cdf0e10cSrcweir     {
432cdf0e10cSrcweir         if ( _nObjectType == OBJ_NONE )
433cdf0e10cSrcweir             m_pView->MarkAllObj();
434cdf0e10cSrcweir         else
435cdf0e10cSrcweir         {
436cdf0e10cSrcweir             m_pView->UnmarkAll();
437cdf0e10cSrcweir             SdrObjListIter aIter(*m_pPage,IM_DEEPNOGROUPS);
438cdf0e10cSrcweir             SdrObject* pObjIter = NULL;
439cdf0e10cSrcweir             while( (pObjIter = aIter.Next()) != NULL )
440cdf0e10cSrcweir             {
441cdf0e10cSrcweir                 if ( pObjIter->GetObjIdentifier() == _nObjectType )
442cdf0e10cSrcweir                     m_pView->MarkObj( pObjIter, m_pView->GetSdrPageView() );
443cdf0e10cSrcweir             }
444cdf0e10cSrcweir         }
445cdf0e10cSrcweir     }
446cdf0e10cSrcweir }
lcl_insertMenuItemImages(PopupMenu & rContextMenu,OReportController & rController,const uno::Reference<report::XReportDefinition> & _xReportDefinition,uno::Reference<frame::XFrame> & _rFrame,sal_Bool _bHiContrast)447cdf0e10cSrcweir void lcl_insertMenuItemImages(PopupMenu& rContextMenu,OReportController& rController,const uno::Reference< report::XReportDefinition>& _xReportDefinition,uno::Reference<frame::XFrame>& _rFrame,sal_Bool _bHiContrast)
448cdf0e10cSrcweir {
449cdf0e10cSrcweir     const sal_uInt16 nCount = rContextMenu.GetItemCount();
450cdf0e10cSrcweir     for (sal_uInt16 i = 0; i < nCount; ++i)
451cdf0e10cSrcweir     {
452cdf0e10cSrcweir         if ( MENUITEM_SEPARATOR != rContextMenu.GetItemType(i))
453cdf0e10cSrcweir         {
454cdf0e10cSrcweir             const sal_uInt16 nId = rContextMenu.GetItemId(i);
455cdf0e10cSrcweir             PopupMenu* pPopupMenu = rContextMenu.GetPopupMenu( nId );
456cdf0e10cSrcweir             if ( pPopupMenu )
457cdf0e10cSrcweir             {
458cdf0e10cSrcweir                 lcl_insertMenuItemImages(*pPopupMenu,rController,_xReportDefinition,_rFrame,_bHiContrast);
459cdf0e10cSrcweir             }
460cdf0e10cSrcweir             else
461cdf0e10cSrcweir             {
462cdf0e10cSrcweir                 const ::rtl::OUString sCommand = rContextMenu.GetItemCommand(nId);
463cdf0e10cSrcweir                 rContextMenu.SetItemImage(nId,framework::GetImageFromURL(_rFrame,sCommand,sal_False,_bHiContrast));
464cdf0e10cSrcweir                 if ( nId == SID_PAGEHEADERFOOTER )
465cdf0e10cSrcweir                 {
466cdf0e10cSrcweir                     String sText = String(ModuleRes((_xReportDefinition.is() && _xReportDefinition->getPageHeaderOn()) ? RID_STR_PAGEHEADERFOOTER_DELETE : RID_STR_PAGEHEADERFOOTER_INSERT));
467cdf0e10cSrcweir                     rContextMenu.SetItemText(nId,sText);
468cdf0e10cSrcweir                 }
469cdf0e10cSrcweir                 else if ( nId == SID_REPORTHEADERFOOTER )
470cdf0e10cSrcweir                 {
471cdf0e10cSrcweir                     String sText = String(ModuleRes((_xReportDefinition.is() && _xReportDefinition->getReportHeaderOn()) ? RID_STR_REPORTHEADERFOOTER_DELETE : RID_STR_REPORTHEADERFOOTER_INSERT));
472cdf0e10cSrcweir                     rContextMenu.SetItemText(nId,sText);
473cdf0e10cSrcweir                 }
474cdf0e10cSrcweir             }
475cdf0e10cSrcweir             rContextMenu.CheckItem(nId,rController.isCommandChecked(nId));
476cdf0e10cSrcweir             rContextMenu.EnableItem(nId,rController.isCommandEnabled(nId));
477cdf0e10cSrcweir         }
478cdf0e10cSrcweir     } // for (sal_uInt16 i = 0; i < nCount; ++i)
479cdf0e10cSrcweir }
480cdf0e10cSrcweir //----------------------------------------------------------------------------
Command(const CommandEvent & _rCEvt)481cdf0e10cSrcweir void OReportSection::Command( const CommandEvent& _rCEvt )
482cdf0e10cSrcweir {
483cdf0e10cSrcweir     Window::Command(_rCEvt);
484cdf0e10cSrcweir     switch (_rCEvt.GetCommand())
485cdf0e10cSrcweir     {
486cdf0e10cSrcweir         case COMMAND_CONTEXTMENU:
487cdf0e10cSrcweir         {
488cdf0e10cSrcweir             const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
489cdf0e10cSrcweir             sal_Bool bHiContrast = rSettings.GetHighContrastMode();
490cdf0e10cSrcweir             OReportController& rController = m_pParent->getViewsWindow()->getView()->getReportView()->getController();
491cdf0e10cSrcweir             uno::Reference<frame::XFrame> xFrame = rController.getFrame();
492cdf0e10cSrcweir             PopupMenu aContextMenu( ModuleRes( RID_MENU_REPORT ) );
493cdf0e10cSrcweir             uno::Reference< report::XReportDefinition> xReportDefinition = getSection()->getReportDefinition();
494cdf0e10cSrcweir 
495cdf0e10cSrcweir             lcl_insertMenuItemImages(aContextMenu,rController,xReportDefinition,xFrame,bHiContrast);
496cdf0e10cSrcweir 
497cdf0e10cSrcweir             Point aPos = _rCEvt.GetMousePosPixel();
498cdf0e10cSrcweir             m_pView->EndAction();
499cdf0e10cSrcweir             const sal_uInt16 nId = aContextMenu.Execute(this, aPos);
500cdf0e10cSrcweir             if ( nId )
501cdf0e10cSrcweir             {
502cdf0e10cSrcweir                 uno::Sequence< beans::PropertyValue> aArgs;
503cdf0e10cSrcweir                 if ( nId == SID_ATTR_CHAR_COLOR_BACKGROUND )
504cdf0e10cSrcweir                 {
505cdf0e10cSrcweir                     aArgs.realloc(1);
506cdf0e10cSrcweir                     aArgs[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Selection"));
507cdf0e10cSrcweir                     aArgs[0].Value <<= m_xSection;
508cdf0e10cSrcweir                 }
509cdf0e10cSrcweir                 rController.executeChecked(nId,aArgs);
510cdf0e10cSrcweir             }
511cdf0e10cSrcweir         }
512cdf0e10cSrcweir         break;
513cdf0e10cSrcweir     }
514cdf0e10cSrcweir }
515cdf0e10cSrcweir // -----------------------------------------------------------------------------
_propertyChanged(const beans::PropertyChangeEvent & _rEvent)516cdf0e10cSrcweir void OReportSection::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) throw( uno::RuntimeException)
517cdf0e10cSrcweir {
518cdf0e10cSrcweir     if ( m_xSection.is() )
519cdf0e10cSrcweir     {
520cdf0e10cSrcweir         if ( _rEvent.Source == m_xSection || PROPERTY_BACKCOLOR == _rEvent.PropertyName )
521cdf0e10cSrcweir         {
522cdf0e10cSrcweir             sal_Int32 nColor = m_xSection->getBackColor();
523cdf0e10cSrcweir             if ( nColor == (sal_Int32)COL_TRANSPARENT )
524cdf0e10cSrcweir                 nColor = getStyleProperty<sal_Int32>(m_xSection->getReportDefinition(),PROPERTY_BACKCOLOR);
525cdf0e10cSrcweir             m_pView->SetApplicationDocumentColor(nColor);
526cdf0e10cSrcweir             Invalidate(INVALIDATE_NOCHILDREN|INVALIDATE_NOERASE);
527cdf0e10cSrcweir         }
528cdf0e10cSrcweir         else
529cdf0e10cSrcweir         {
530cdf0e10cSrcweir             uno::Reference<report::XReportDefinition> xReportDefinition = m_xSection->getReportDefinition();
531cdf0e10cSrcweir             const sal_Int32 nLeftMargin  = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_LEFTMARGIN);
532cdf0e10cSrcweir             const sal_Int32 nRightMargin = getStyleProperty<sal_Int32>(xReportDefinition,PROPERTY_RIGHTMARGIN);
533cdf0e10cSrcweir             const sal_Int32 nPaperWidth  = getStyleProperty<awt::Size>(xReportDefinition,PROPERTY_PAPERSIZE).Width;
534cdf0e10cSrcweir 
535cdf0e10cSrcweir             if ( _rEvent.PropertyName == PROPERTY_LEFTMARGIN )
536cdf0e10cSrcweir             {
537cdf0e10cSrcweir                 m_pPage->SetLftBorder(nLeftMargin);
538cdf0e10cSrcweir             }
539cdf0e10cSrcweir             else if ( _rEvent.PropertyName == PROPERTY_RIGHTMARGIN )
540cdf0e10cSrcweir             {
541cdf0e10cSrcweir                 m_pPage->SetRgtBorder(nRightMargin);
542cdf0e10cSrcweir             }
543cdf0e10cSrcweir             const Size aOldPageSize = m_pPage->GetSize();
544cdf0e10cSrcweir             sal_Int32 nNewHeight = 5*m_xSection->getHeight();
545cdf0e10cSrcweir             if ( aOldPageSize.Height() != nNewHeight || nPaperWidth != aOldPageSize.Width() )
546cdf0e10cSrcweir             {
547cdf0e10cSrcweir                 m_pPage->SetSize( Size( nPaperWidth,nNewHeight) );
548cdf0e10cSrcweir                 const Size aPageSize = m_pPage->GetSize();
549cdf0e10cSrcweir                 m_pView->SetWorkArea( Rectangle( Point( nLeftMargin, 0), Size(aPageSize.Width() - nLeftMargin - nRightMargin,aPageSize.Height()) ) );
550cdf0e10cSrcweir             }
551cdf0e10cSrcweir             impl_adjustObjectSizePosition(nPaperWidth,nLeftMargin,nRightMargin);
552cdf0e10cSrcweir             m_pParent->Invalidate(INVALIDATE_UPDATE | INVALIDATE_TRANSPARENT);
553cdf0e10cSrcweir         }
554*093b492cSmseidel     }
555cdf0e10cSrcweir }
impl_adjustObjectSizePosition(sal_Int32 i_nPaperWidth,sal_Int32 i_nLeftMargin,sal_Int32 i_nRightMargin)556cdf0e10cSrcweir void OReportSection::impl_adjustObjectSizePosition(sal_Int32 i_nPaperWidth,sal_Int32 i_nLeftMargin,sal_Int32 i_nRightMargin)
557cdf0e10cSrcweir {
558cdf0e10cSrcweir     try
559cdf0e10cSrcweir     {
560cdf0e10cSrcweir         sal_Int32 nRightBorder = i_nPaperWidth - i_nRightMargin;
561cdf0e10cSrcweir         const sal_Int32 nCount = m_xSection->getCount();
562cdf0e10cSrcweir         for (sal_Int32 i = 0; i < nCount; ++i)
563cdf0e10cSrcweir         {
564cdf0e10cSrcweir             bool bChanged = false;
565cdf0e10cSrcweir             uno::Reference< report::XReportComponent> xReportComponent(m_xSection->getByIndex(i),uno::UNO_QUERY_THROW);
566cdf0e10cSrcweir             awt::Point aPos = xReportComponent->getPosition();
567cdf0e10cSrcweir             awt::Size aSize = xReportComponent->getSize();
568cdf0e10cSrcweir             SvxShape* pShape = SvxShape::getImplementation( xReportComponent );
569cdf0e10cSrcweir             SdrObject* pObject = pShape ? pShape->GetSdrObject() : NULL;
570cdf0e10cSrcweir             if ( pObject )
571cdf0e10cSrcweir             {
572cdf0e10cSrcweir                 OObjectBase* pBase = dynamic_cast<OObjectBase*>(pObject);
573cdf0e10cSrcweir                 pBase->EndListening(sal_False);
574cdf0e10cSrcweir                 if ( aPos.X < i_nLeftMargin )
575cdf0e10cSrcweir                 {
576cdf0e10cSrcweir                     aPos.X = i_nLeftMargin;
577cdf0e10cSrcweir                     bChanged = true;
578cdf0e10cSrcweir                 }
579cdf0e10cSrcweir                 if ( (aPos.X + aSize.Width) > nRightBorder )
580cdf0e10cSrcweir                 {
581cdf0e10cSrcweir                     aPos.X = nRightBorder - aSize.Width;
582cdf0e10cSrcweir                     if ( aPos.X < i_nLeftMargin )
583cdf0e10cSrcweir                     {
584cdf0e10cSrcweir                         aSize.Width += aPos.X - i_nLeftMargin;
585cdf0e10cSrcweir                         aPos.X = i_nLeftMargin;
586cdf0e10cSrcweir                         // add listener around
587cdf0e10cSrcweir                         pBase->StartListening();
588cdf0e10cSrcweir                         xReportComponent->setSize(aSize);
589cdf0e10cSrcweir                         pBase->EndListening(sal_False);
590cdf0e10cSrcweir                     }
591cdf0e10cSrcweir                     bChanged = true;
592cdf0e10cSrcweir                 }
593cdf0e10cSrcweir                 if ( aPos.Y < 0 )
594cdf0e10cSrcweir                     aPos.Y = 0;
595cdf0e10cSrcweir                 if ( bChanged )
596cdf0e10cSrcweir                 {
597cdf0e10cSrcweir                     xReportComponent->setPosition(aPos);
598cdf0e10cSrcweir                     correctOverlapping(pObject,*this,false);
599cdf0e10cSrcweir                     Rectangle aRet(VCLPoint(xReportComponent->getPosition()),VCLSize(xReportComponent->getSize()));
600cdf0e10cSrcweir                     aRet.setHeight(aRet.getHeight() + 1);
601cdf0e10cSrcweir                     aRet.setWidth(aRet.getWidth() + 1);
602cdf0e10cSrcweir                     if ( m_xSection.is() && (static_cast<sal_uInt32>(aRet.getHeight() + aRet.Top()) > m_xSection->getHeight()) )
603cdf0e10cSrcweir                          m_xSection->setHeight(aRet.getHeight() + aRet.Top());
604cdf0e10cSrcweir 
605cdf0e10cSrcweir                     pObject->RecalcBoundRect();
606cdf0e10cSrcweir                 }
607cdf0e10cSrcweir                 pBase->StartListening();
608cdf0e10cSrcweir             }
609cdf0e10cSrcweir         } // for (sal_Int32 i = 0; i < nCount; ++i)
610cdf0e10cSrcweir     }
611cdf0e10cSrcweir     catch(uno::Exception)
612cdf0e10cSrcweir     {
613cdf0e10cSrcweir         OSL_ENSURE(0,"Exception caught: OReportSection::_propertyChanged(");
614cdf0e10cSrcweir     }
615cdf0e10cSrcweir }
616cdf0e10cSrcweir //------------------------------------------------------------------------------
handleKeyEvent(const KeyEvent & _rEvent)617cdf0e10cSrcweir sal_Bool OReportSection::handleKeyEvent(const KeyEvent& _rEvent)
618cdf0e10cSrcweir {
619cdf0e10cSrcweir     return m_pFunc.get() ? m_pFunc->handleKeyEvent(_rEvent) : sal_False;
620cdf0e10cSrcweir }
621cdf0e10cSrcweir // -----------------------------------------------------------------------------
deactivateOle()622cdf0e10cSrcweir void OReportSection::deactivateOle()
623cdf0e10cSrcweir {
624cdf0e10cSrcweir     if ( m_pFunc.get() )
625cdf0e10cSrcweir         m_pFunc->deactivateOle(true);
626cdf0e10cSrcweir }
627cdf0e10cSrcweir // -----------------------------------------------------------------------------
createDefault(const::rtl::OUString & _sType)628cdf0e10cSrcweir void OReportSection::createDefault(const ::rtl::OUString& _sType)
629cdf0e10cSrcweir {
630cdf0e10cSrcweir     SdrObject* pObj = m_pView->GetCreateObj();//rMarkList.GetMark(0)->GetObj();
631cdf0e10cSrcweir     if ( !pObj )
632cdf0e10cSrcweir         return;
633cdf0e10cSrcweir     createDefault(_sType,pObj);
634cdf0e10cSrcweir }
635cdf0e10cSrcweir // -----------------------------------------------------------------------------
createDefault(const::rtl::OUString & _sType,SdrObject * _pObj)636cdf0e10cSrcweir void OReportSection::createDefault(const ::rtl::OUString& _sType,SdrObject* _pObj)
637cdf0e10cSrcweir {
638cdf0e10cSrcweir     sal_Bool bAttributesAppliedFromGallery = sal_False;
639cdf0e10cSrcweir 
640cdf0e10cSrcweir     if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
641cdf0e10cSrcweir     {
642cdf0e10cSrcweir         std::vector< rtl::OUString > aObjList;
643cdf0e10cSrcweir         if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
644cdf0e10cSrcweir         {
645cdf0e10cSrcweir             std::vector< rtl::OUString >::iterator aIter = aObjList.begin();
646cdf0e10cSrcweir             std::vector< rtl::OUString >::iterator aEnd = aObjList.end();
647cdf0e10cSrcweir             for (sal_uInt32 i=0 ; aIter != aEnd; ++aIter,++i)
648cdf0e10cSrcweir             {
649cdf0e10cSrcweir                 if ( aIter->equalsIgnoreAsciiCase( _sType ) )
650cdf0e10cSrcweir                 {
651cdf0e10cSrcweir                     OReportModel aReportModel(NULL);
652cdf0e10cSrcweir                     SfxItemPool& rPool = aReportModel.GetItemPool();
653cdf0e10cSrcweir                     rPool.FreezeIdRanges();
654cdf0e10cSrcweir                     if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aReportModel ) )
655cdf0e10cSrcweir                     {
656cdf0e10cSrcweir                         const SdrObject* pSourceObj = aReportModel.GetPage( 0 )->GetObj( 0 );
657cdf0e10cSrcweir                         if( pSourceObj )
658cdf0e10cSrcweir                         {
659cdf0e10cSrcweir                             const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
660cdf0e10cSrcweir                             SfxItemSet aDest( _pObj->GetModel()->GetItemPool(),                 // ranges from SdrAttrObj
661cdf0e10cSrcweir                             SDRATTR_START, SDRATTR_SHADOW_LAST,
662cdf0e10cSrcweir                             SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
663cdf0e10cSrcweir                             SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
664cdf0e10cSrcweir                             // Graphic Attributes
665cdf0e10cSrcweir                             SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
666cdf0e10cSrcweir                             // 3d Properties
667cdf0e10cSrcweir                             SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
668cdf0e10cSrcweir                             // CustomShape properties
669cdf0e10cSrcweir                             SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
670cdf0e10cSrcweir                             // range from SdrTextObj
671cdf0e10cSrcweir                             EE_ITEMS_START, EE_ITEMS_END,
672cdf0e10cSrcweir                             // end
673cdf0e10cSrcweir                             0, 0);
674cdf0e10cSrcweir                             aDest.Set( rSource );
675cdf0e10cSrcweir                             _pObj->SetMergedItemSet( aDest );
676cdf0e10cSrcweir                             sal_Int32 nAngle = pSourceObj->GetRotateAngle();
677cdf0e10cSrcweir                             if ( nAngle )
678cdf0e10cSrcweir                             {
679cdf0e10cSrcweir                                 double a = nAngle * F_PI18000;
680cdf0e10cSrcweir                                 _pObj->NbcRotate( _pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) );
681cdf0e10cSrcweir                             }
682cdf0e10cSrcweir                             bAttributesAppliedFromGallery = sal_True;
683cdf0e10cSrcweir                         }
684cdf0e10cSrcweir                     }
685cdf0e10cSrcweir                     break;
686cdf0e10cSrcweir                 }
687cdf0e10cSrcweir             }
688cdf0e10cSrcweir         }
689cdf0e10cSrcweir     }
690cdf0e10cSrcweir     if ( !bAttributesAppliedFromGallery )
691cdf0e10cSrcweir     {
692cdf0e10cSrcweir         _pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER ,ITEMID_ADJUST) );
693cdf0e10cSrcweir         _pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
694cdf0e10cSrcweir         _pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
695cdf0e10cSrcweir         _pObj->SetMergedItem( SdrTextAutoGrowHeightItem( sal_False ) );
696cdf0e10cSrcweir         ((SdrObjCustomShape*)_pObj)->MergeDefaultAttributes( &_sType );
697cdf0e10cSrcweir     }
698cdf0e10cSrcweir }
699cdf0e10cSrcweir // -----------------------------------------------------------------------------
getCurrentControlModel() const700cdf0e10cSrcweir uno::Reference< report::XReportComponent > OReportSection::getCurrentControlModel() const
701cdf0e10cSrcweir {
702cdf0e10cSrcweir     uno::Reference< report::XReportComponent > xModel;
703cdf0e10cSrcweir     if ( m_pView )
704cdf0e10cSrcweir     {
705cdf0e10cSrcweir         const SdrMarkList& rMarkList = m_pView->GetMarkedObjectList();
706cdf0e10cSrcweir         sal_uInt32 nMarkCount = rMarkList.GetMarkCount();
707cdf0e10cSrcweir 
708cdf0e10cSrcweir         if ( nMarkCount == 1 )
709cdf0e10cSrcweir         {
710cdf0e10cSrcweir             SdrObject* pDlgEdObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
711cdf0e10cSrcweir             OObjectBase* pObj = dynamic_cast<OObjectBase*>(pDlgEdObj);
712cdf0e10cSrcweir             if ( pObj )
713cdf0e10cSrcweir                 xModel = pObj->getReportComponent().get();
714cdf0e10cSrcweir         }
715cdf0e10cSrcweir     }
716cdf0e10cSrcweir     return xModel;
717cdf0e10cSrcweir }
718cdf0e10cSrcweir // -----------------------------------------------------------------------------
fillControlModelSelection(::std::vector<uno::Reference<uno::XInterface>> & _rSelection) const719cdf0e10cSrcweir void OReportSection::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const
720cdf0e10cSrcweir {
721cdf0e10cSrcweir     if ( m_pView )
722cdf0e10cSrcweir     {
723cdf0e10cSrcweir         const SdrMarkList& rMarkList = m_pView->GetMarkedObjectList();
724cdf0e10cSrcweir         const sal_uInt32 nMarkCount = rMarkList.GetMarkCount();
725cdf0e10cSrcweir 
726cdf0e10cSrcweir         for (sal_uInt32 i=0; i < nMarkCount; ++i)
727cdf0e10cSrcweir         {
728cdf0e10cSrcweir             const SdrObject* pDlgEdObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
729cdf0e10cSrcweir             const OObjectBase* pObj = dynamic_cast<const OObjectBase*>(pDlgEdObj);
730cdf0e10cSrcweir             if ( pObj )
731cdf0e10cSrcweir                 _rSelection.push_back(pObj->getReportComponent());
732cdf0e10cSrcweir         }
733cdf0e10cSrcweir     }
734cdf0e10cSrcweir }
735cdf0e10cSrcweir // -----------------------------------------------------------------------------
AcceptDrop(const AcceptDropEvent & _rEvt)736cdf0e10cSrcweir sal_Int8 OReportSection::AcceptDrop( const AcceptDropEvent& _rEvt )
737cdf0e10cSrcweir {
738cdf0e10cSrcweir     OSL_TRACE("AcceptDrop::DropEvent.Action %i\n", _rEvt.mnAction);
739cdf0e10cSrcweir 
740cdf0e10cSrcweir     ::Point aDropPos(_rEvt.maPosPixel);
741cdf0e10cSrcweir     const MouseEvent aMouseEvt(aDropPos);
742cdf0e10cSrcweir     if ( m_pFunc->isOverlapping(aMouseEvt) )
743cdf0e10cSrcweir         return DND_ACTION_NONE;
744cdf0e10cSrcweir 
745cdf0e10cSrcweir     if ( _rEvt.mnAction == DND_ACTION_COPY ||
746cdf0e10cSrcweir          _rEvt.mnAction == DND_ACTION_LINK
747cdf0e10cSrcweir         )
748cdf0e10cSrcweir     {
749cdf0e10cSrcweir         if (!m_pParent) return DND_ACTION_NONE;
750cdf0e10cSrcweir         sal_uInt16 nCurrentPosition = 0;
751cdf0e10cSrcweir         nCurrentPosition = m_pParent->getViewsWindow()->getPosition(m_pParent);
752cdf0e10cSrcweir         if (_rEvt.mnAction == DND_ACTION_COPY )
753cdf0e10cSrcweir         {
754cdf0e10cSrcweir             // we must assure, we can't drop in the top section
755cdf0e10cSrcweir             if (nCurrentPosition < 1)
756cdf0e10cSrcweir             {
757cdf0e10cSrcweir                 return DND_ACTION_NONE;
758cdf0e10cSrcweir             }
759cdf0e10cSrcweir             return DND_ACTION_LINK;
760cdf0e10cSrcweir         }
761cdf0e10cSrcweir         if (_rEvt.mnAction == DND_ACTION_LINK)
762cdf0e10cSrcweir         {
763cdf0e10cSrcweir             // we must assure, we can't drop in the bottom section
764cdf0e10cSrcweir             if (m_pParent->getViewsWindow()->getSectionCount() > (nCurrentPosition + 1)  )
765cdf0e10cSrcweir             {
766cdf0e10cSrcweir                 return DND_ACTION_COPY;
767cdf0e10cSrcweir             }
768cdf0e10cSrcweir             return DND_ACTION_NONE;
769cdf0e10cSrcweir         }
770cdf0e10cSrcweir     }
771cdf0e10cSrcweir     else
772cdf0e10cSrcweir     {
773cdf0e10cSrcweir         const DataFlavorExVector& rFlavors = GetDataFlavorExVector();
774cdf0e10cSrcweir         if (   ::svx::OMultiColumnTransferable::canExtractDescriptor(rFlavors)
775cdf0e10cSrcweir             || ::svx::OColumnTransferable::canExtractColumnDescriptor(rFlavors, CTF_FIELD_DESCRIPTOR | CTF_CONTROL_EXCHANGE | CTF_COLUMN_DESCRIPTOR) )
776cdf0e10cSrcweir             return _rEvt.mnAction;
777cdf0e10cSrcweir 
778cdf0e10cSrcweir         const sal_Int8 nDropOption = ( OReportExchange::canExtract(rFlavors) ) ? DND_ACTION_COPYMOVE : DND_ACTION_NONE;
779cdf0e10cSrcweir 
780cdf0e10cSrcweir         return nDropOption;
781cdf0e10cSrcweir     }
782cdf0e10cSrcweir     return DND_ACTION_NONE;
783cdf0e10cSrcweir }
784cdf0e10cSrcweir 
785cdf0e10cSrcweir // -----------------------------------------------------------------------------
ExecuteDrop(const ExecuteDropEvent & _rEvt)786cdf0e10cSrcweir sal_Int8 OReportSection::ExecuteDrop( const ExecuteDropEvent& _rEvt )
787cdf0e10cSrcweir {
788cdf0e10cSrcweir     OSL_TRACE("ExecuteDrop::DropEvent.Action %i\n", _rEvt.mnAction);
789cdf0e10cSrcweir     ::Point aDropPos(PixelToLogic(_rEvt.maPosPixel));
790cdf0e10cSrcweir     const MouseEvent aMouseEvt(aDropPos);
791cdf0e10cSrcweir     if ( m_pFunc->isOverlapping(aMouseEvt) )
792cdf0e10cSrcweir         return DND_ACTION_NONE;
793cdf0e10cSrcweir 
794cdf0e10cSrcweir     sal_Int8 nDropOption = DND_ACTION_NONE;
795cdf0e10cSrcweir     const TransferableDataHelper aDropped(_rEvt.maDropEvent.Transferable);
796cdf0e10cSrcweir     DataFlavorExVector& rFlavors = aDropped.GetDataFlavorExVector();
797cdf0e10cSrcweir     bool bMultipleFormat = ::svx::OMultiColumnTransferable::canExtractDescriptor(rFlavors);
798cdf0e10cSrcweir     if ( OReportExchange::canExtract(rFlavors) )
799cdf0e10cSrcweir     {
800cdf0e10cSrcweir         OReportExchange::TSectionElements aCopies = OReportExchange::extractCopies(aDropped);
801cdf0e10cSrcweir         Paste(aCopies,true);
802cdf0e10cSrcweir         nDropOption = DND_ACTION_COPYMOVE;
803cdf0e10cSrcweir         m_pParent->getViewsWindow()->BrkAction();
804cdf0e10cSrcweir         m_pParent->getViewsWindow()->unmarkAllObjects(m_pView);
805cdf0e10cSrcweir         //m_pParent->getViewsWindow()->getView()->setMarked(m_pView,sal_True);
806cdf0e10cSrcweir     } // if ( OReportExchange::canExtract(rFlavors) )
807cdf0e10cSrcweir     else if ( bMultipleFormat
808cdf0e10cSrcweir         || ::svx::OColumnTransferable::canExtractColumnDescriptor(rFlavors, CTF_FIELD_DESCRIPTOR | CTF_CONTROL_EXCHANGE | CTF_COLUMN_DESCRIPTOR) )
809cdf0e10cSrcweir     {
810cdf0e10cSrcweir         m_pParent->getViewsWindow()->getView()->setMarked(m_pView,sal_True);
811cdf0e10cSrcweir         m_pView->UnmarkAll();
812cdf0e10cSrcweir         const Rectangle& rRect = m_pView->GetWorkArea();
813cdf0e10cSrcweir         if ( aDropPos.X() < rRect.Left() )
814cdf0e10cSrcweir             aDropPos.X() = rRect.Left();
815cdf0e10cSrcweir         else if ( aDropPos.X() > rRect.Right() )
816cdf0e10cSrcweir             aDropPos.X() = rRect.Right();
817cdf0e10cSrcweir 
818cdf0e10cSrcweir         if ( aDropPos.Y() > rRect.Bottom() )
819cdf0e10cSrcweir             aDropPos.Y() = rRect.Bottom();
820cdf0e10cSrcweir 
821cdf0e10cSrcweir         uno::Sequence<beans::PropertyValue> aValues;
822cdf0e10cSrcweir         if ( !bMultipleFormat )
823cdf0e10cSrcweir         {
824cdf0e10cSrcweir             ::svx::ODataAccessDescriptor aDescriptor = ::svx::OColumnTransferable::extractColumnDescriptor(aDropped);
825cdf0e10cSrcweir 
826cdf0e10cSrcweir             aValues.realloc(1);
827cdf0e10cSrcweir             aValues[0].Value <<= aDescriptor.createPropertyValueSequence();
828cdf0e10cSrcweir         } // if ( !bMultipleFormat )
829cdf0e10cSrcweir         else
830cdf0e10cSrcweir             aValues = ::svx::OMultiColumnTransferable::extractDescriptor(aDropped);
831cdf0e10cSrcweir 
832cdf0e10cSrcweir         beans::PropertyValue* pIter = aValues.getArray();
833cdf0e10cSrcweir         beans::PropertyValue* pEnd = pIter + aValues.getLength();
834cdf0e10cSrcweir         for(;pIter != pEnd; ++pIter)
835cdf0e10cSrcweir         {
836cdf0e10cSrcweir             uno::Sequence<beans::PropertyValue> aCurrent;
837cdf0e10cSrcweir             pIter->Value >>= aCurrent;
838cdf0e10cSrcweir             sal_Int32 nLength = aCurrent.getLength();
839cdf0e10cSrcweir             if ( nLength )
840cdf0e10cSrcweir             {
841cdf0e10cSrcweir                 aCurrent.realloc(nLength + 3);
842cdf0e10cSrcweir                 aCurrent[nLength].Name = PROPERTY_POSITION;
843cdf0e10cSrcweir                 aCurrent[nLength++].Value <<= AWTPoint(aDropPos);
844cdf0e10cSrcweir                 // give also the DND Action (Shift|Ctrl) Key to really say what we want
845cdf0e10cSrcweir                 aCurrent[nLength].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DNDAction"));
846cdf0e10cSrcweir                 aCurrent[nLength++].Value <<= _rEvt.mnAction;
847cdf0e10cSrcweir 
848cdf0e10cSrcweir                 aCurrent[nLength].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Section"));
849cdf0e10cSrcweir                 aCurrent[nLength++].Value <<= getSection();
850cdf0e10cSrcweir                 pIter->Value <<= aCurrent;
851cdf0e10cSrcweir             }
852cdf0e10cSrcweir         }
853cdf0e10cSrcweir 
854cdf0e10cSrcweir         // we use this way to create undo actions
855cdf0e10cSrcweir         OReportController& rController = m_pParent->getViewsWindow()->getView()->getReportView()->getController();
856cdf0e10cSrcweir         rController.executeChecked(SID_ADD_CONTROL_PAIR,aValues);
857cdf0e10cSrcweir         nDropOption = DND_ACTION_COPY;
858cdf0e10cSrcweir     }
859cdf0e10cSrcweir     return nDropOption;
860cdf0e10cSrcweir }
861cdf0e10cSrcweir // -----------------------------------------------------------------------------
stopScrollTimer()862cdf0e10cSrcweir void OReportSection::stopScrollTimer()
863cdf0e10cSrcweir {
864cdf0e10cSrcweir     m_pFunc->stopScrollTimer();
865cdf0e10cSrcweir }
866cdf0e10cSrcweir // -----------------------------------------------------------------------------
isUiActive() const867cdf0e10cSrcweir bool OReportSection::isUiActive() const
868cdf0e10cSrcweir {
869cdf0e10cSrcweir     return m_pFunc->isUiActive();
870cdf0e10cSrcweir }
871cdf0e10cSrcweir // -----------------------------------------------------------------------------
872cdf0e10cSrcweir // =============================================================================
873cdf0e10cSrcweir }
874fe9b7f6aSmseidel 
875fe9b7f6aSmseidel /* vim: set noet sw=4 ts=4: */
876