xref: /trunk/main/reportdesign/source/ui/report/DesignView.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #include "precompiled_reportdesign.hxx"
28 
29 #include "DesignView.hxx"
30 #include <tools/debug.hxx>
31 #include "ReportController.hxx"
32 #include <comphelper/types.hxx>
33 #include <unotools/syslocale.hxx>
34 #include <unotools/viewoptions.hxx>
35 #include "RptDef.hxx"
36 #include "UITools.hxx"
37 #include "RptObject.hxx"
38 #include "propbrw.hxx"
39 #include <toolkit/helper/convert.hxx>
40 #include "helpids.hrc"
41 #include "SectionView.hxx"
42 #include "ReportSection.hxx"
43 #include "rptui_slotid.hrc"
44 #include <svx/svxids.hrc>
45 #include "AddField.hxx"
46 #include "ScrollHelper.hxx"
47 #include "Navigator.hxx"
48 #include "SectionWindow.hxx"
49 #include "RptResId.hrc"
50 #include <vcl/svapp.hxx>
51 
52 namespace rptui
53 {
54 using namespace ::dbaui;
55 using namespace ::utl;
56 using namespace ::com::sun::star;
57 using namespace uno;
58 using namespace lang;
59 using namespace beans;
60 using namespace container;
61 
62 #define LINE_SIZE           50
63 #define START_SIZE_TASKPANE 30
64 #define COLSET_ID           1
65 #define REPORT_ID           2
66 #define TASKPANE_ID         3
67 
68 class OTaskWindow : public Window
69 {
70     PropBrw* m_pPropWin;
71 public:
72     OTaskWindow(Window* _pParent) : Window(_pParent),m_pPropWin(NULL){}
73 
74     inline void setPropertyBrowser(PropBrw* _pPropWin)
75     {
76         m_pPropWin = _pPropWin;
77     }
78 
79     virtual void Resize()
80     {
81         const Size aSize = GetOutputSizePixel();
82         if ( m_pPropWin && aSize.Height() && aSize.Width() )
83             m_pPropWin->SetSizePixel(aSize);
84     }
85     long getMinimumWidth() const
86     {
87         long nRet = 0;
88         if ( m_pPropWin )
89             nRet = m_pPropWin->getMinimumSize().Width();
90         return nRet;
91     }
92 };
93 class OwnSplitWindow : public SplitWindow
94 {
95 public:
96     OwnSplitWindow(Window* pParent) : SplitWindow(pParent,WB_DIALOGCONTROL){SetBackground( );}
97 
98     virtual void        Split()
99     {
100         SplitWindow::Split();
101         setItemSizes();
102     }
103     void setItemSizes()
104     {
105         const long nOutWidth = GetOutputSizePixel().Width();
106         long    nTaskPaneMinSplitSize = static_cast<OTaskWindow*>(GetItemWindow(TASKPANE_ID))->getMinimumWidth();
107         nTaskPaneMinSplitSize = static_cast<long>(nTaskPaneMinSplitSize*100/nOutWidth);
108         if ( !nTaskPaneMinSplitSize )
109             nTaskPaneMinSplitSize = START_SIZE_TASKPANE;
110 
111         const long nReportMinSplitSize = static_cast<long>(12000/nOutWidth);
112 
113         long nReportSize = GetItemSize( REPORT_ID );
114         long nTaskPaneSize = GetItemSize( TASKPANE_ID );
115 
116         sal_Bool        bMod = sal_False;
117         if( nReportSize < nReportMinSplitSize )
118         {
119             nReportSize = nReportMinSplitSize;
120             nTaskPaneSize = 99 - nReportMinSplitSize;
121 
122             bMod = sal_True;
123         }
124         else if( nTaskPaneSize < nTaskPaneMinSplitSize )
125         {
126             nTaskPaneSize = nTaskPaneMinSplitSize;
127             nReportSize = 99 - nTaskPaneMinSplitSize;
128 
129             bMod = sal_True;
130         }
131 
132         if( bMod )
133         {
134             SetItemSize( REPORT_ID, nReportSize );
135             SetItemSize( TASKPANE_ID, nTaskPaneSize );
136         }
137     }
138 };
139 //==================================================================
140 // class ODesignView
141 //==================================================================
142 DBG_NAME( rpt_ODesignView )
143 //------------------------------------------------------------------------------
144 ODesignView::ODesignView(   Window* pParent,
145                             const Reference< XMultiServiceFactory >& _rxOrb,
146                             OReportController& _rController) :
147     ODataView( pParent, _rController, _rxOrb, WB_DIALOGCONTROL )
148     ,m_aSplitWin(this)
149     ,m_rReportController( _rController )
150     ,m_aScrollWindow(this)
151     ,m_pPropWin(NULL)
152     ,m_pAddField(NULL)
153     ,m_pCurrentView(NULL)
154     ,m_pReportExplorer(NULL)
155     ,m_eMode( RPTUI_SELECT )
156     ,m_nCurrentPosition(USHRT_MAX)
157     ,m_eActObj( OBJ_NONE )
158     ,m_bFirstDraw(sal_False)
159     ,m_aGridSizeCoarse( 1000, 1000 )    // #i93595# 100TH_MM changed to grid using coarse 1 cm grid
160     ,m_aGridSizeFine( 250, 250 )        // and a 0,25 cm subdivision for better visualisation
161     ,m_bGridVisible(sal_True)
162     ,m_bGridSnap(sal_True)
163     ,m_bDeleted( sal_False )
164 {
165     DBG_CTOR( rpt_ODesignView,NULL);
166     SetHelpId(UID_RPT_RPT_APP_VIEW);
167     ImplInitSettings();
168 
169     SetMapMode( MapMode( MAP_100TH_MM ) );
170 
171     // now create the task pane on the right side :-)
172     m_pTaskPane = new OTaskWindow(this);
173     //m_pTaskPane->Show();
174 
175     m_aSplitWin.InsertItem( COLSET_ID,100,SPLITWINDOW_APPEND, 0, SWIB_PERCENTSIZE | SWIB_COLSET );
176     m_aSplitWin.InsertItem( REPORT_ID, &m_aScrollWindow, 100/*m_aScrollWindow.getMaxMarkerWidth(sal_False)*/, SPLITWINDOW_APPEND, COLSET_ID, SWIB_PERCENTSIZE  /*SWIB_COLSET*/);
177     //m_aSplitWin.InsertItem( TASKPANE_ID, m_pTaskPane, 50, SPLITWINDOW_APPEND, 0, SWIB_PERCENTSIZE );
178 
179     // Splitter einrichten
180     //m_aSplitter.SetSplitHdl(LINK(this, ODesignView,SplitHdl));
181     m_aSplitWin.SetSplitHdl(LINK(this, ODesignView,SplitHdl));
182     m_aSplitWin.ShowAutoHideButton();
183     m_aSplitWin.SetAlign(WINDOWALIGN_LEFT);
184     m_aSplitWin.Show();
185 
186     m_aMarkTimer.SetTimeout( 100 );
187     m_aMarkTimer.SetTimeoutHdl( LINK( this, ODesignView, MarkTimeout ) );
188 }
189 
190 //------------------------------------------------------------------------------
191 ODesignView::~ODesignView()
192 {
193     DBG_DTOR( rpt_ODesignView,NULL);
194     m_bDeleted = sal_True;
195     Hide();
196     m_aScrollWindow.Hide();
197     m_aMarkTimer.Stop();
198     if ( m_pPropWin )
199     {
200         notifySystemWindow(this,m_pPropWin,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
201         ::std::auto_ptr<Window> aTemp2(m_pPropWin);
202         m_pPropWin = NULL;
203     }
204     if ( m_pAddField )
205     {
206         SvtViewOptions aDlgOpt( E_WINDOW, String::CreateFromAscii( UID_RPT_RPT_APP_VIEW ) );
207         aDlgOpt.SetWindowState( ::rtl::OUString::createFromAscii( m_pAddField->GetWindowState(WINDOWSTATE_MASK_ALL).GetBuffer() ) );
208         notifySystemWindow(this,m_pAddField,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
209         ::std::auto_ptr<Window> aTemp2(m_pAddField);
210         m_pAddField = NULL;
211     }
212     if ( m_pReportExplorer )
213     {
214         SvtViewOptions aDlgOpt( E_WINDOW, String::CreateFromInt32( RID_NAVIGATOR ) );
215         aDlgOpt.SetWindowState( ::rtl::OUString::createFromAscii( m_pReportExplorer->GetWindowState(WINDOWSTATE_MASK_ALL).GetBuffer() ) );
216         notifySystemWindow(this,m_pReportExplorer,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
217         ::std::auto_ptr<Window> aTemp2(m_pReportExplorer);
218         m_pReportExplorer = NULL;
219     }
220     {
221         ::std::auto_ptr<Window> aTemp2(m_pTaskPane);
222         m_pTaskPane = NULL;
223     }
224 }
225 // -----------------------------------------------------------------------------
226 void ODesignView::initialize()
227 {
228     SetMapMode( MapMode( MAP_100TH_MM ) );
229     m_aScrollWindow.initialize();
230     m_aScrollWindow.Show();
231 }
232 //-----------------------------------------------------------------------------
233 void ODesignView::DataChanged( const DataChangedEvent& rDCEvt )
234 {
235     ODataView::DataChanged( rDCEvt );
236 
237     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
238          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
239     {
240         ImplInitSettings();
241         Invalidate();
242     }
243 }
244 //------------------------------------------------------------------------------
245 long ODesignView::PreNotify( NotifyEvent& rNEvt )
246 {
247     long nRet = ODataView::PreNotify(rNEvt); // 1 := has to be handled here
248     switch(rNEvt.GetType())
249     {
250         case EVENT_KEYINPUT:
251             if ( (m_pPropWin && m_pPropWin->HasChildPathFocus()) )
252                 return 0L;
253             if ( (m_pAddField && m_pAddField->HasChildPathFocus()) )
254                 return 0L;
255             if ( (m_pReportExplorer && m_pReportExplorer->HasChildPathFocus()) )
256                 return 0L;
257             {
258                 const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
259                 if ( handleKeyEvent(*pKeyEvent) )
260                     nRet = 1L;
261                 else if ( nRet == 1L && m_pAccel.get() )
262                 {
263                     const KeyCode& rCode = pKeyEvent->GetKeyCode();
264                     util::URL aUrl;
265                     aUrl.Complete = m_pAccel->findCommand(svt::AcceleratorExecute::st_VCLKey2AWTKey(rCode));
266                     if ( !aUrl.Complete.getLength() || !m_rController.isCommandEnabled( aUrl.Complete ) )
267                         nRet = 0L;
268                 }
269             }
270             break;
271         default:
272             break;
273     }
274 
275     return nRet;
276 }
277 //------------------------------------------------------------------------------
278 void ODesignView::resizeDocumentView(Rectangle& _rPlayground)
279 {
280     if ( !_rPlayground.IsEmpty() )
281     {
282         const Size aPlaygroundSize( _rPlayground.GetSize() );
283 
284         // calc the split pos, and forward it to the controller
285         sal_Int32 nSplitPos = getController().getSplitPos();
286         if ( 0 != aPlaygroundSize.Width() )
287         {
288             if  (   ( -1 == nSplitPos )
289                 ||  ( nSplitPos >= aPlaygroundSize.Width() )
290                 )
291             {
292                 long nMinWidth = static_cast<long>(0.1*aPlaygroundSize.Width());
293                 if ( m_pPropWin && m_pPropWin->IsVisible() )
294                     nMinWidth = m_pPropWin->GetMinOutputSizePixel().Width();
295                 nSplitPos = static_cast<sal_Int32>(_rPlayground.Right() - nMinWidth);
296                 getController().setSplitPos(nSplitPos);
297             }
298         } // if ( 0 != _rPlaygroundSize.Width() )
299 
300         Size aReportWindowSize(aPlaygroundSize);
301         if ( m_aSplitWin.IsItemValid(TASKPANE_ID) )
302         {
303             // normalize the split pos
304             const long nSplitterWidth = GetSettings().GetStyleSettings().GetSplitSize();
305             Point aTaskPanePos(nSplitPos + nSplitterWidth, _rPlayground.Top());
306             if ( m_pTaskPane && m_pTaskPane->IsVisible() )
307             {
308                 aTaskPanePos.X() = aPlaygroundSize.Width() - m_pTaskPane->GetSizePixel().Width();
309                 sal_Int32 nMinWidth = m_pPropWin->getMinimumSize().Width();
310                 if ( nMinWidth > (aPlaygroundSize.Width() - aTaskPanePos.X()) )
311                 {
312                     aTaskPanePos.X() = aPlaygroundSize.Width() - nMinWidth;
313                 }
314                 nSplitPos = aTaskPanePos.X() - nSplitterWidth;
315                 getController().setSplitPos(nSplitPos);
316 
317                 const long nTaskPaneSize = static_cast<long>((aPlaygroundSize.Width() - aTaskPanePos.X())*100/aPlaygroundSize.Width());
318                 if ( m_aSplitWin.GetItemSize( TASKPANE_ID ) != nTaskPaneSize )
319                 {
320                     m_aSplitWin.SetItemSize( REPORT_ID, 99 - nTaskPaneSize );
321                     m_aSplitWin.SetItemSize( TASKPANE_ID, nTaskPaneSize );
322                 }
323             }
324         }
325         // set the size of the report window
326         m_aSplitWin.SetPosSizePixel( _rPlayground.TopLeft(),aPlaygroundSize );
327     }
328         // just for completeness: there is no space left, we occupied it all ...
329     _rPlayground.SetPos( _rPlayground.BottomRight() );
330     _rPlayground.SetSize( Size( 0, 0 ) );
331 
332 }
333 // -----------------------------------------------------------------------------
334 // set the view readonly or not
335 void ODesignView::setReadOnly(sal_Bool /*_bReadOnly*/)
336 {
337 }
338 //----------------------------------------------------------------------------
339 IMPL_LINK( ODesignView, MarkTimeout, Timer *, EMPTYARG )
340 {
341     if ( m_pPropWin && m_pPropWin->IsVisible() )
342     {
343         m_pPropWin->Update(m_pCurrentView);
344         uno::Reference<beans::XPropertySet> xProp(m_xReportComponent,uno::UNO_QUERY);
345         if ( xProp.is() )
346         {
347             m_pPropWin->Update(xProp);
348             static_cast<OTaskWindow*>(m_pTaskPane)->Resize();
349         }
350         Resize();
351     }
352 
353     return 0;
354 }
355 
356 //----------------------------------------------------------------------------
357 void ODesignView::SetMode( DlgEdMode _eNewMode )
358 {
359     m_eMode = _eNewMode;
360     if ( m_eMode == RPTUI_SELECT )
361         m_eActObj = OBJ_NONE;
362 
363     m_aScrollWindow.SetMode(_eNewMode);
364 }
365 //----------------------------------------------------------------------------
366 void ODesignView::SetInsertObj( sal_uInt16 eObj,const ::rtl::OUString& _sShapeType )
367 {
368     m_eActObj = eObj;
369     m_aScrollWindow.SetInsertObj( eObj,_sShapeType );
370 }
371 //----------------------------------------------------------------------------
372 rtl::OUString ODesignView::GetInsertObjString() const
373 {
374     return m_aScrollWindow.GetInsertObjString();
375 }
376 //----------------------------------------------------------------------------
377 
378 sal_uInt16 ODesignView::GetInsertObj() const
379 {
380     return m_eActObj;
381 }
382 
383 //----------------------------------------------------------------------------
384 void ODesignView::Cut()
385 {
386     Copy();
387     Delete();
388 }
389 
390 //----------------------------------------------------------------------------
391 
392 void ODesignView::Copy()
393 {
394     m_aScrollWindow.Copy();
395 }
396 
397 //----------------------------------------------------------------------------
398 
399 void ODesignView::Paste()
400 {
401     m_aScrollWindow.Paste();
402 }
403 //----------------------------------------------------------------------------
404 void ODesignView::Delete()
405 {
406     m_aScrollWindow.Delete();
407 }
408 //----------------------------------------------------------------------------
409 sal_Bool ODesignView::HasSelection() const
410 {
411     return m_aScrollWindow.HasSelection();
412 }
413 //----------------------------------------------------------------------------
414 
415 sal_Bool ODesignView::IsPasteAllowed() const
416 {
417     return m_aScrollWindow.IsPasteAllowed();
418 }
419 
420 //----------------------------------------------------------------------------
421 void ODesignView::UpdatePropertyBrowserDelayed(OSectionView& _rView)
422 {
423     if ( m_pCurrentView != &_rView )
424     {
425         if ( m_pCurrentView )
426             m_aScrollWindow.setMarked(m_pCurrentView,sal_False);
427         m_pCurrentView = &_rView;
428         if ( m_pCurrentView )
429             m_aScrollWindow.setMarked(m_pCurrentView,sal_True);
430         m_xReportComponent.clear();
431         DlgEdHint aHint( RPTUI_HINT_SELECTIONCHANGED );
432         Broadcast( aHint );
433     }
434     m_aMarkTimer.Start();
435 }
436 
437 //----------------------------------------------------------------------------
438 void ODesignView::toggleGrid(sal_Bool _bGridVisible)
439 {
440      m_aScrollWindow.toggleGrid(_bGridVisible);
441 }
442 //----------------------------------------------------------------------------
443 sal_uInt16 ODesignView::getSectionCount() const
444 {
445     return m_aScrollWindow.getSectionCount();
446 }
447 //----------------------------------------------------------------------------
448 void ODesignView::showRuler(sal_Bool _bShow)
449 {
450      m_aScrollWindow.showRuler(_bShow);
451 }
452 //----------------------------------------------------------------------------
453 void ODesignView::removeSection(sal_uInt16 _nPosition)
454 {
455      m_aScrollWindow.removeSection(_nPosition);
456 }
457 //----------------------------------------------------------------------------
458 void ODesignView::addSection(const uno::Reference< report::XSection >& _xSection,const ::rtl::OUString& _sColorEntry,sal_uInt16 _nPosition)
459 {
460      m_aScrollWindow.addSection(_xSection,_sColorEntry,_nPosition);
461 }
462 // -----------------------------------------------------------------------------
463 void ODesignView::GetFocus()
464 {
465     Window::GetFocus();
466 
467     if ( !m_bDeleted )
468     {
469         ::boost::shared_ptr<OSectionWindow> pSectionWindow = m_aScrollWindow.getMarkedSection();
470         if ( pSectionWindow )
471             pSectionWindow->GrabFocus();
472     }
473 }
474 // -----------------------------------------------------------------------------
475 void ODesignView::ImplInitSettings()
476 {
477 //#if OSL_DEBUG_LEVEL > 0
478 //    SetBackground( Wallpaper( COL_RED ));
479 //#else
480     SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor() ));
481 //#endif
482     SetFillColor( Application::GetSettings().GetStyleSettings().GetFaceColor() );
483     SetTextFillColor( Application::GetSettings().GetStyleSettings().GetFaceColor() );
484 }
485 //-----------------------------------------------------------------------------
486 IMPL_LINK( ODesignView, SplitHdl, void*,  )
487 {
488     const Size aOutputSize = GetOutputSizePixel();
489     const long nTest = aOutputSize.Width() * m_aSplitWin.GetItemSize(TASKPANE_ID) / 100;
490     long nMinWidth = static_cast<long>(0.1*aOutputSize.Width());
491     if ( m_pPropWin && m_pPropWin->IsVisible() )
492         nMinWidth = m_pPropWin->GetMinOutputSizePixel().Width();
493 
494     if ( (aOutputSize.Width() - nTest) >= nMinWidth && nTest > m_aScrollWindow.getMaxMarkerWidth(sal_False) )
495     {
496         long nOldSplitPos = getController().getSplitPos();
497         (void)nOldSplitPos;
498         getController().setSplitPos(nTest);
499     }
500 
501     return 0L;
502 }
503 //-----------------------------------------------------------------------------
504 void ODesignView::SelectAll(const sal_uInt16 _nObjectType)
505 {
506      m_aScrollWindow.SelectAll(_nObjectType);
507 }
508 //-----------------------------------------------------------------------------
509 void ODesignView::unmarkAllObjects(OSectionView* _pSectionView)
510 {
511     m_aScrollWindow.unmarkAllObjects(_pSectionView);
512 }
513 //-----------------------------------------------------------------------------
514 void ODesignView::togglePropertyBrowser(sal_Bool _bToogleOn)
515 {
516     if ( !m_pPropWin && _bToogleOn )
517     {
518         m_pPropWin = new PropBrw(getController().getORB(),m_pTaskPane,this);
519         m_pPropWin->Invalidate();
520         static_cast<OTaskWindow*>(m_pTaskPane)->setPropertyBrowser(m_pPropWin);
521         notifySystemWindow(this,m_pPropWin,::comphelper::mem_fun(&TaskPaneList::AddWindow));
522     }
523     if ( m_pPropWin && _bToogleOn != m_pPropWin->IsVisible() )
524     {
525         if ( !m_pCurrentView && !m_xReportComponent.is() )
526             m_xReportComponent = getController().getReportDefinition();
527 
528         const sal_Bool bWillBeVisible = _bToogleOn;
529         m_pPropWin->Show(bWillBeVisible);
530         m_pTaskPane->Show(bWillBeVisible);
531         m_pTaskPane->Invalidate();
532 
533         if ( bWillBeVisible )
534             m_aSplitWin.InsertItem( TASKPANE_ID, m_pTaskPane,START_SIZE_TASKPANE, SPLITWINDOW_APPEND, COLSET_ID, SWIB_PERCENTSIZE/*|SWIB_COLSET */);
535         else
536             m_aSplitWin.RemoveItem(TASKPANE_ID);
537 
538         // TRY
539         // Invalidate(/*INVALIDATE_NOCHILDREN|INVALIDATE_NOERASE*/);
540         if ( bWillBeVisible )
541             m_aMarkTimer.Start();
542     }
543 }
544 //-----------------------------------------------------------------------------
545 void ODesignView::showProperties(const uno::Reference< uno::XInterface>& _xReportComponent)
546 {
547     if ( m_xReportComponent != _xReportComponent )
548     {
549         m_xReportComponent = _xReportComponent;
550         if ( m_pCurrentView )
551             m_aScrollWindow.setMarked(m_pCurrentView,sal_False);
552         m_pCurrentView = NULL;
553         m_aMarkTimer.Start();
554     }
555 }
556 //-----------------------------------------------------------------------------
557 sal_Bool ODesignView::isReportExplorerVisible() const
558 {
559     return m_pReportExplorer && m_pReportExplorer->IsVisible();
560 }
561 //-----------------------------------------------------------------------------
562 void ODesignView::toggleReportExplorer()
563 {
564     if ( !m_pReportExplorer )
565     {
566         OReportController& rReportController = getController();
567         m_pReportExplorer = new ONavigator(this,rReportController);
568         SvtViewOptions aDlgOpt( E_WINDOW, String::CreateFromInt32( RID_NAVIGATOR ) );
569         if ( aDlgOpt.Exists() )
570             m_pReportExplorer->SetWindowState( ByteString( aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) );
571         m_pReportExplorer->AddEventListener(LINK(&rReportController,OReportController,EventLstHdl));
572         notifySystemWindow(this,m_pReportExplorer,::comphelper::mem_fun(&TaskPaneList::AddWindow));
573     }
574     else
575         m_pReportExplorer->Show(!m_pReportExplorer->IsVisible());
576 }
577 //-----------------------------------------------------------------------------
578 sal_Bool ODesignView::isAddFieldVisible() const
579 {
580     return m_pAddField && m_pAddField->IsVisible();
581 }
582 //-----------------------------------------------------------------------------
583 void ODesignView::toggleAddField()
584 {
585     if ( !m_pAddField )
586     {
587         uno::Reference< report::XReportDefinition > xReport(m_xReportComponent,uno::UNO_QUERY);
588         uno::Reference< report::XReportComponent > xReportComponent(m_xReportComponent,uno::UNO_QUERY);
589         OReportController& rReportController = getController();
590         if ( !m_pCurrentView && !xReport.is() )
591         {
592             if ( xReportComponent.is() )
593                 xReport = xReportComponent->getSection()->getReportDefinition();
594             else
595                 xReport = rReportController.getReportDefinition().get();
596         }
597         else if ( m_pCurrentView )
598         {
599             uno::Reference< report::XSection > xSection = m_pCurrentView->getReportSection()->getSection();
600             xReport = xSection->getReportDefinition();
601         }
602         uno::Reference < beans::XPropertySet > xSet(rReportController.getRowSet(),uno::UNO_QUERY);
603         m_pAddField = new OAddFieldWindow(this,xSet);
604         m_pAddField->SetCreateHdl(LINK( &rReportController, OReportController, OnCreateHdl ) );
605         SvtViewOptions aDlgOpt( E_WINDOW, String::CreateFromAscii( UID_RPT_RPT_APP_VIEW ) );
606         if ( aDlgOpt.Exists() )
607             m_pAddField->SetWindowState( ByteString( aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US ) );
608         m_pAddField->Update();
609         m_pAddField->AddEventListener(LINK(&rReportController,OReportController,EventLstHdl));
610         notifySystemWindow(this,m_pAddField,::comphelper::mem_fun(&TaskPaneList::AddWindow));
611         m_pAddField->Show();
612     }
613     else
614         m_pAddField->Show(!m_pAddField->IsVisible());
615 }
616 // -------------------------------------------------------------------------
617 uno::Reference< report::XSection > ODesignView::getCurrentSection() const
618 {
619     uno::Reference< report::XSection > xSection;
620     if ( m_pCurrentView )
621         xSection = m_pCurrentView->getReportSection()->getSection();
622 
623     // why do we need the code below?
624     //else
625  //   {
626  //       OReportController& rReportController = getController();
627  //       xSection = rReportController.getReportDefinition()->getDetail();
628  //   }
629     return xSection;
630 }
631 // -----------------------------------------------------------------------------
632 uno::Reference< report::XReportComponent > ODesignView::getCurrentControlModel() const
633 {
634     uno::Reference< report::XReportComponent > xModel;
635     if ( m_pCurrentView )
636     {
637         xModel = m_pCurrentView->getReportSection()->getCurrentControlModel();
638     }
639     return xModel;
640 }
641 // -------------------------------------------------------------------------
642 ::boost::shared_ptr<OSectionWindow> ODesignView::getMarkedSection(NearSectionAccess nsa) const
643 {
644     return  m_aScrollWindow.getMarkedSection(nsa);
645 }
646 //-----------------------------------------------------------------------------
647 ::boost::shared_ptr<OSectionWindow> ODesignView::getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const
648 {
649     return  m_aScrollWindow.getSectionWindow(_xSection);
650 }
651 // -------------------------------------------------------------------------
652 void ODesignView::markSection(const sal_uInt16 _nPos)
653 {
654     m_aScrollWindow.markSection(_nPos);
655 }
656 // -----------------------------------------------------------------------------
657 void ODesignView::fillCollapsedSections(::std::vector<sal_uInt16>& _rCollapsedPositions) const
658 {
659     m_aScrollWindow.fillCollapsedSections(_rCollapsedPositions);
660 }
661 // -----------------------------------------------------------------------------
662 void ODesignView::collapseSections(const uno::Sequence< beans::PropertyValue>& _aCollpasedSections)
663 {
664     m_aScrollWindow.collapseSections(_aCollpasedSections);
665 }
666 // -----------------------------------------------------------------------------
667 ::rtl::OUString ODesignView::getCurrentPage() const
668 {
669     return m_pPropWin ? m_pPropWin->getCurrentPage() : ::rtl::OUString();
670 }
671 // -----------------------------------------------------------------------------
672 void ODesignView::setCurrentPage(const ::rtl::OUString& _sLastActivePage)
673 {
674     if ( m_pPropWin )
675         m_pPropWin->setCurrentPage(_sLastActivePage);
676 }
677 // -----------------------------------------------------------------------------
678 void ODesignView::alignMarkedObjects(sal_Int32 _nControlModification,bool _bAlignAtSection, bool bBoundRects)
679 {
680     m_aScrollWindow.alignMarkedObjects(_nControlModification, _bAlignAtSection,bBoundRects);
681 }
682 #if 0
683 // -----------------------------------------------------------------------------
684 sal_Bool ODesignView::isAlignPossible() const
685 {
686     ::boost::shared_ptr<OSectionWindow> pMarkedSection = getMarkedSection();
687     return pMarkedSection.get() && pMarkedSection->getReportSection().getSectionView().IsAlignPossible();
688 }
689 #endif
690 //------------------------------------------------------------------------------
691 sal_Bool ODesignView::handleKeyEvent(const KeyEvent& _rEvent)
692 {
693     if ( (m_pPropWin && m_pPropWin->HasChildPathFocus()) )
694         return sal_False;
695     if ( (m_pAddField && m_pAddField->HasChildPathFocus()) )
696         return sal_False;
697     if ( (m_pReportExplorer && m_pReportExplorer->HasChildPathFocus()) )
698         return sal_False;
699     return m_aScrollWindow.handleKeyEvent(_rEvent);
700 }
701 //------------------------------------------------------------------------
702 void ODesignView::setMarked(const uno::Reference< report::XSection>& _xSection,sal_Bool _bMark)
703 {
704     m_aScrollWindow.setMarked(_xSection,_bMark);
705     if ( _bMark )
706         UpdatePropertyBrowserDelayed(getMarkedSection()->getReportSection().getSectionView());
707     else
708         m_pCurrentView = NULL;
709 }
710 //------------------------------------------------------------------------
711 void ODesignView::setMarked(const uno::Sequence< uno::Reference< report::XReportComponent> >& _aShapes,sal_Bool _bMark)
712 {
713     m_aScrollWindow.setMarked(_aShapes,_bMark);
714     if ( _aShapes.hasElements() && _bMark )
715         showProperties(_aShapes[0]);
716     else
717         m_xReportComponent.clear();
718 }
719 //------------------------------------------------------------------------------
720 void ODesignView::MouseButtonDown( const MouseEvent& rMEvt )
721 {
722     if ( rMEvt.IsLeft() )
723     {
724         const uno::Sequence< beans::PropertyValue> aArgs;
725         getController().executeChecked(SID_SELECT_REPORT,aArgs);
726     }
727     ODataView::MouseButtonDown(rMEvt);
728 }
729 // -----------------------------------------------------------------------------
730 uno::Any ODesignView::getCurrentlyShownProperty() const
731 {
732     uno::Any aRet;
733     ::boost::shared_ptr<OSectionWindow> pSectionWindow = getMarkedSection();
734     if ( pSectionWindow )
735     {
736         ::std::vector< uno::Reference< uno::XInterface > > aSelection;
737         pSectionWindow->getReportSection().fillControlModelSelection(aSelection);
738         if ( !aSelection.empty() )
739         {
740             ::std::vector< uno::Reference< uno::XInterface > >::iterator aIter = aSelection.begin();
741             uno::Sequence< uno::Reference< report::XReportComponent > > aSeq(aSelection.size());
742             for(sal_Int32 i = 0; i < aSeq.getLength(); ++i,++aIter)
743             {
744                 aSeq[i].set(*aIter,uno::UNO_QUERY);
745             }
746             aRet <<= aSeq;
747         }
748     }
749     return aRet;
750 }
751 // -----------------------------------------------------------------------------
752 void ODesignView::fillControlModelSelection(::std::vector< uno::Reference< uno::XInterface > >& _rSelection) const
753 {
754     m_aScrollWindow.fillControlModelSelection(_rSelection);
755 }
756 // -----------------------------------------------------------------------------
757 void ODesignView::setGridSnap(sal_Bool bOn)
758 {
759     m_aScrollWindow.setGridSnap(bOn);
760 
761 }
762 // -----------------------------------------------------------------------------
763 void ODesignView::setDragStripes(sal_Bool bOn)
764 {
765     m_aScrollWindow.setDragStripes(bOn);
766 }
767 // -----------------------------------------------------------------------------
768 sal_Bool ODesignView::isHandleEvent(sal_uInt16 /*_nId*/) const
769 {
770     return m_pPropWin && m_pPropWin->HasChildPathFocus();
771 }
772 // -----------------------------------------------------------------------------
773 sal_uInt32 ODesignView::getMarkedObjectCount() const
774 {
775     return m_aScrollWindow.getMarkedObjectCount();
776 }
777 // -----------------------------------------------------------------------------
778 void ODesignView::zoom(const Fraction& _aZoom)
779 {
780     m_aScrollWindow.zoom(_aZoom);
781 }
782 // -----------------------------------------------------------------------------
783 sal_uInt16 ODesignView::getZoomFactor(SvxZoomType _eType) const
784 {
785     return m_aScrollWindow.getZoomFactor(_eType);
786 }
787 //============================================================================
788 } // rptui
789 //============================================================================
790