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