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
109e0e4191SAndrew Rist  *
119e0e4191SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
129e0e4191SAndrew Rist  *
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.
199e0e4191SAndrew Rist  *
209e0e4191SAndrew Rist  *************************************************************/
219e0e4191SAndrew Rist 
229e0e4191SAndrew Rist 
23*b63233d8Sdamjan #include "precompiled_rptui.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include "Navigator.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "uistrings.hrc"
28cdf0e10cSrcweir #include "ReportController.hxx"
29cdf0e10cSrcweir #include "UITools.hxx"
30cdf0e10cSrcweir #include "RptUndo.hxx"
31cdf0e10cSrcweir #include "reportformula.hxx"
32cdf0e10cSrcweir #include <com/sun/star/container/XContainerListener.hpp>
33cdf0e10cSrcweir #include <com/sun/star/report/XReportDefinition.hpp>
34cdf0e10cSrcweir #include <com/sun/star/report/XFixedText.hpp>
35cdf0e10cSrcweir #include <com/sun/star/report/XFixedLine.hpp>
36cdf0e10cSrcweir #include <com/sun/star/report/XFormattedField.hpp>
37cdf0e10cSrcweir #include <com/sun/star/report/XImageControl.hpp>
38cdf0e10cSrcweir #include <com/sun/star/report/XShape.hpp>
39cdf0e10cSrcweir #include <svx/globlmn.hrc>
40cdf0e10cSrcweir #include <svx/svxids.hrc>
41cdf0e10cSrcweir #include "helpids.hrc"
42cdf0e10cSrcweir #include "RptResId.hrc"
43cdf0e10cSrcweir #include "rptui_slotid.hrc"
44cdf0e10cSrcweir #include <tools/debug.hxx>
45cdf0e10cSrcweir #include <comphelper/propmultiplex.hxx>
46cdf0e10cSrcweir #include <comphelper/containermultiplexer.hxx>
47cdf0e10cSrcweir #include <comphelper/types.hxx>
48cdf0e10cSrcweir #include "cppuhelper/basemutex.hxx"
49cdf0e10cSrcweir #include "comphelper/SelectionMultiplex.hxx"
50cdf0e10cSrcweir #include <svtools/svtreebx.hxx>
51cdf0e10cSrcweir #include <svl/solar.hrc>
52cdf0e10cSrcweir #include "ReportVisitor.hxx"
53cdf0e10cSrcweir #include "ModuleHelper.hxx"
54cdf0e10cSrcweir #include <rtl/ref.hxx>
55cdf0e10cSrcweir 
56cdf0e10cSrcweir #include <boost/bind.hpp>
57cdf0e10cSrcweir #include <memory>
58cdf0e10cSrcweir #include <algorithm>
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #define RID_SVXIMG_COLLAPSEDNODE			(RID_FORMS_START + 2)
61cdf0e10cSrcweir #define RID_SVXIMG_EXPANDEDNODE				(RID_FORMS_START + 3)
62cdf0e10cSrcweir #define DROP_ACTION_TIMER_INITIAL_TICKS     10
63cdf0e10cSrcweir #define DROP_ACTION_TIMER_SCROLL_TICKS      3
64cdf0e10cSrcweir #define DROP_ACTION_TIMER_TICK_BASE         10
65cdf0e10cSrcweir 
66cdf0e10cSrcweir namespace rptui
67cdf0e10cSrcweir {
68cdf0e10cSrcweir using namespace ::com::sun::star;
69cdf0e10cSrcweir using namespace utl;
70cdf0e10cSrcweir using namespace ::comphelper;
71cdf0e10cSrcweir 
lcl_getImageId(const uno::Reference<report::XReportComponent> & _xElement)72cdf0e10cSrcweir sal_uInt16 lcl_getImageId(const uno::Reference< report::XReportComponent>& _xElement)
73cdf0e10cSrcweir {
74cdf0e10cSrcweir     sal_uInt16 nId = 0;
75cdf0e10cSrcweir     uno::Reference< report::XFixedLine> xFixedLine(_xElement,uno::UNO_QUERY);
76cdf0e10cSrcweir     if ( uno::Reference< report::XFixedText>(_xElement,uno::UNO_QUERY).is() )
77cdf0e10cSrcweir         nId = SID_FM_FIXEDTEXT;
78cdf0e10cSrcweir     else if ( xFixedLine.is() )
79cdf0e10cSrcweir         nId = xFixedLine->getOrientation() ? SID_INSERT_VFIXEDLINE : SID_INSERT_HFIXEDLINE;
80cdf0e10cSrcweir     else if ( uno::Reference< report::XFormattedField>(_xElement,uno::UNO_QUERY).is() )
81cdf0e10cSrcweir         nId = SID_FM_EDIT;
82cdf0e10cSrcweir     else if ( uno::Reference< report::XImageControl>(_xElement,uno::UNO_QUERY).is() )
83cdf0e10cSrcweir         nId = SID_FM_IMAGECONTROL;
84cdf0e10cSrcweir     else if ( uno::Reference< report::XShape>(_xElement,uno::UNO_QUERY).is() )
85cdf0e10cSrcweir         nId = SID_DRAWTBX_CS_BASIC;
86cdf0e10cSrcweir     return nId;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir // -----------------------------------------------------------------------------
lcl_getName(const uno::Reference<beans::XPropertySet> & _xElement)89cdf0e10cSrcweir ::rtl::OUString lcl_getName(const uno::Reference< beans::XPropertySet>& _xElement)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir     OSL_ENSURE(_xElement.is(),"Found report element which is NULL!");
92cdf0e10cSrcweir     ::rtl::OUString sTempName;
93cdf0e10cSrcweir     _xElement->getPropertyValue(PROPERTY_NAME) >>= sTempName;
94cdf0e10cSrcweir     ::rtl::OUStringBuffer sName = sTempName;
95cdf0e10cSrcweir     uno::Reference< report::XFixedText> xFixedText(_xElement,uno::UNO_QUERY);
96cdf0e10cSrcweir     uno::Reference< report::XReportControlModel> xReportModel(_xElement,uno::UNO_QUERY);
97cdf0e10cSrcweir     if ( xFixedText.is() )
98cdf0e10cSrcweir     {
99cdf0e10cSrcweir         sName.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" : ")));
100cdf0e10cSrcweir         sName.append(xFixedText->getLabel());
101cdf0e10cSrcweir     }
102cdf0e10cSrcweir     else if ( xReportModel.is() && _xElement->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATAFIELD) )
103cdf0e10cSrcweir     {
104cdf0e10cSrcweir         ReportFormula aFormula( xReportModel->getDataField() );
105cdf0e10cSrcweir         if ( aFormula.isValid() )
106cdf0e10cSrcweir         {
107cdf0e10cSrcweir             sName.append(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" : ")));
108cdf0e10cSrcweir             sName.append( aFormula.getUndecoratedContent() );
109cdf0e10cSrcweir         }
110cdf0e10cSrcweir     }
111cdf0e10cSrcweir     return sName.makeStringAndClear();
112cdf0e10cSrcweir }
113cdf0e10cSrcweir // -----------------------------------------------------------------------------
114cdf0e10cSrcweir 
115cdf0e10cSrcweir class NavigatorTree :   public ::cppu::BaseMutex
116cdf0e10cSrcweir                     ,   public SvTreeListBox
117cdf0e10cSrcweir                     ,   public reportdesign::ITraverseReport
118cdf0e10cSrcweir                     ,   public comphelper::OSelectionChangeListener
119cdf0e10cSrcweir                     ,	public ::comphelper::OPropertyChangeListener
120cdf0e10cSrcweir {
121cdf0e10cSrcweir     class UserData;
122cdf0e10cSrcweir     friend class UserData;
123cdf0e10cSrcweir     class UserData : public ::cppu::BaseMutex
124cdf0e10cSrcweir                     ,public ::comphelper::OPropertyChangeListener
125cdf0e10cSrcweir                     ,public ::comphelper::OContainerListener
126cdf0e10cSrcweir     {
127cdf0e10cSrcweir         uno::Reference< uno::XInterface >                           m_xContent;
128cdf0e10cSrcweir         ::rtl::Reference< comphelper::OPropertyChangeMultiplexer>   m_pListener;
129cdf0e10cSrcweir         ::rtl::Reference< comphelper::OContainerListenerAdapter>    m_pContainerListener;
130cdf0e10cSrcweir         NavigatorTree*                                              m_pTree;
131cdf0e10cSrcweir     public:
132cdf0e10cSrcweir         UserData(NavigatorTree* _pTree,const uno::Reference<uno::XInterface>& _xContent);
133cdf0e10cSrcweir         ~UserData();
134cdf0e10cSrcweir 
getContent() const135cdf0e10cSrcweir         inline uno::Reference< uno::XInterface > getContent() const { return m_xContent; }
setContent(const uno::Reference<uno::XInterface> & _xContent)136cdf0e10cSrcweir         inline void setContent(const uno::Reference< uno::XInterface >& _xContent) { m_xContent = _xContent; }
137cdf0e10cSrcweir     protected:
138cdf0e10cSrcweir         // OPropertyChangeListener
139cdf0e10cSrcweir 	    virtual void _propertyChanged(const beans::PropertyChangeEvent& _rEvent) throw( uno::RuntimeException);
140cdf0e10cSrcweir 
141cdf0e10cSrcweir         // OContainerListener
142cdf0e10cSrcweir         virtual void _elementInserted( const container::ContainerEvent& _rEvent ) throw(uno::RuntimeException);
143cdf0e10cSrcweir 	    virtual void _elementRemoved( const container::ContainerEvent& _Event ) throw(uno::RuntimeException);
144cdf0e10cSrcweir 	    virtual void _elementReplaced( const container::ContainerEvent& _rEvent ) throw(uno::RuntimeException);
145cdf0e10cSrcweir 	    virtual void _disposing(const lang::EventObject& _rSource) throw( uno::RuntimeException);
146cdf0e10cSrcweir     };
147cdf0e10cSrcweir 
148cdf0e10cSrcweir     enum DROP_ACTION        { DA_SCROLLUP, DA_SCROLLDOWN, DA_EXPANDNODE };
149cdf0e10cSrcweir     AutoTimer                                                                   m_aDropActionTimer;
150cdf0e10cSrcweir     Timer                                                                       m_aSynchronizeTimer;
151cdf0e10cSrcweir     ImageList                                                                   m_aNavigatorImages;
152cdf0e10cSrcweir 	ImageList                                                                   m_aNavigatorImagesHC;
153cdf0e10cSrcweir     Point                                                                       m_aTimerTriggered;      // die Position, an der der DropTimer angeschaltet wurde
154cdf0e10cSrcweir     DROP_ACTION                                                                 m_aDropActionType;
155cdf0e10cSrcweir     OReportController&                                                          m_rController;
156cdf0e10cSrcweir     SvLBoxEntry*                                                                m_pMasterReport;
157cdf0e10cSrcweir     SvLBoxEntry*				                                                m_pDragedEntry;
158cdf0e10cSrcweir     ::rtl::Reference< comphelper::OPropertyChangeMultiplexer>	                m_pReportListener;
159cdf0e10cSrcweir     ::rtl::Reference< comphelper::OSelectionChangeMultiplexer>                  m_pSelectionListener;
160cdf0e10cSrcweir     unsigned short                                                              m_nTimerCounter;
161cdf0e10cSrcweir 
162cdf0e10cSrcweir     SvLBoxEntry* insertEntry(const ::rtl::OUString& _sName,SvLBoxEntry* _pParent,sal_uInt16 _nImageId,sal_uLong _nPosition,UserData* _pData);
163cdf0e10cSrcweir     void traverseSection(const uno::Reference< report::XSection>& _xSection,SvLBoxEntry* _pParent,sal_uInt16 _nImageId,sal_uLong _nPosition = LIST_APPEND);
164cdf0e10cSrcweir     void traverseFunctions(const uno::Reference< report::XFunctions>& _xFunctions,SvLBoxEntry* _pParent);
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     NavigatorTree(const NavigatorTree&);
167cdf0e10cSrcweir     void operator =(const NavigatorTree&);
168cdf0e10cSrcweir protected:
169cdf0e10cSrcweir 	virtual void	    Command( const CommandEvent& rEvt );
170cdf0e10cSrcweir     // DragSourceHelper overridables
171cdf0e10cSrcweir 	virtual void		StartDrag( sal_Int8 nAction, const Point& rPosPixel );
172cdf0e10cSrcweir 	// DropTargetHelper overridables
173cdf0e10cSrcweir 	virtual sal_Int8	AcceptDrop( const AcceptDropEvent& _rEvt );
174cdf0e10cSrcweir 	virtual sal_Int8	ExecuteDrop( const ExecuteDropEvent& _rEvt );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     // OSelectionChangeListener
177cdf0e10cSrcweir 	virtual void _disposing(const lang::EventObject& _rSource) throw( uno::RuntimeException);
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     // OPropertyChangeListener
180cdf0e10cSrcweir 	virtual void _propertyChanged(const beans::PropertyChangeEvent& _rEvent) throw( uno::RuntimeException);
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     // OContainerListener Helper
183cdf0e10cSrcweir     void _elementInserted( const container::ContainerEvent& _rEvent );
184cdf0e10cSrcweir 	void _elementRemoved( const container::ContainerEvent& _Event );
185cdf0e10cSrcweir 	void _elementReplaced( const container::ContainerEvent& _rEvent );
186cdf0e10cSrcweir 
187cdf0e10cSrcweir public:
188cdf0e10cSrcweir     NavigatorTree(Window* pParent,OReportController& _rController );
189cdf0e10cSrcweir 	virtual ~NavigatorTree();
190cdf0e10cSrcweir 
191cdf0e10cSrcweir     DECL_LINK(OnEntrySelDesel, NavigatorTree*);
192cdf0e10cSrcweir     DECL_LINK( OnDropActionTimer, void* );
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     virtual void _selectionChanged( const lang::EventObject& aEvent ) throw (uno::RuntimeException);
195cdf0e10cSrcweir 
196cdf0e10cSrcweir     // ITraverseReport
197cdf0e10cSrcweir     virtual void traverseReport(const uno::Reference< report::XReportDefinition>& _xReport);
198cdf0e10cSrcweir     virtual void traverseReportFunctions(const uno::Reference< report::XFunctions>& _xFunctions);
199cdf0e10cSrcweir     virtual void traverseReportHeader(const uno::Reference< report::XSection>& _xSection);
200cdf0e10cSrcweir     virtual void traverseReportFooter(const uno::Reference< report::XSection>& _xSection);
201cdf0e10cSrcweir     virtual void traversePageHeader(const uno::Reference< report::XSection>& _xSection);
202cdf0e10cSrcweir     virtual void traversePageFooter(const uno::Reference< report::XSection>& _xSection);
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     virtual void traverseGroups(const uno::Reference< report::XGroups>& _xGroups);
205cdf0e10cSrcweir     virtual void traverseGroup(const uno::Reference< report::XGroup>& _xGroup);
206cdf0e10cSrcweir     virtual void traverseGroupFunctions(const uno::Reference< report::XFunctions>& _xFunctions);
207cdf0e10cSrcweir     virtual void traverseGroupHeader(const uno::Reference< report::XSection>& _xSection);
208cdf0e10cSrcweir     virtual void traverseGroupFooter(const uno::Reference< report::XSection>& _xSection);
209cdf0e10cSrcweir 
210cdf0e10cSrcweir     virtual void traverseDetail(const uno::Reference< report::XSection>& _xSection);
211cdf0e10cSrcweir 
212cdf0e10cSrcweir     SvLBoxEntry* find(const uno::Reference< uno::XInterface >& _xContent);
213cdf0e10cSrcweir     void removeEntry(SvLBoxEntry* _pEntry,bool _bRemove = true);
214cdf0e10cSrcweir private:
215cdf0e10cSrcweir     using SvTreeListBox::ExecuteDrop;
216cdf0e10cSrcweir };
DBG_NAME(rpt_NavigatorTree)217cdf0e10cSrcweir DBG_NAME(rpt_NavigatorTree)
218cdf0e10cSrcweir // -----------------------------------------------------------------------------
219cdf0e10cSrcweir NavigatorTree::NavigatorTree( Window* pParent,OReportController& _rController )
220cdf0e10cSrcweir         :SvTreeListBox( pParent, WB_TABSTOP| WB_HASBUTTONS|WB_HASLINES|WB_BORDER|WB_HSCROLL|WB_HASBUTTONSATROOT )
221cdf0e10cSrcweir         ,comphelper::OSelectionChangeListener(m_aMutex)
222cdf0e10cSrcweir         ,OPropertyChangeListener(m_aMutex)
223cdf0e10cSrcweir         ,m_aTimerTriggered(-1,-1)
224cdf0e10cSrcweir         ,m_aDropActionType( DA_SCROLLUP )
225cdf0e10cSrcweir         ,m_rController(_rController)
226cdf0e10cSrcweir         ,m_pMasterReport(NULL)
227cdf0e10cSrcweir         ,m_pDragedEntry(NULL)
228cdf0e10cSrcweir         ,m_nTimerCounter( DROP_ACTION_TIMER_INITIAL_TICKS )
229cdf0e10cSrcweir {
230cdf0e10cSrcweir     DBG_CTOR(rpt_NavigatorTree,NULL);
231cdf0e10cSrcweir     m_pReportListener = new OPropertyChangeMultiplexer(this,m_rController.getReportDefinition().get());
232cdf0e10cSrcweir     m_pReportListener->addProperty(PROPERTY_PAGEHEADERON);
233cdf0e10cSrcweir     m_pReportListener->addProperty(PROPERTY_PAGEFOOTERON);
234cdf0e10cSrcweir     m_pReportListener->addProperty(PROPERTY_REPORTHEADERON);
235cdf0e10cSrcweir     m_pReportListener->addProperty(PROPERTY_REPORTFOOTERON);
236cdf0e10cSrcweir 
237cdf0e10cSrcweir     m_pSelectionListener = new OSelectionChangeMultiplexer(this,&m_rController);
238cdf0e10cSrcweir 
239cdf0e10cSrcweir     SetHelpId( HID_REPORT_NAVIGATOR_TREE );
240cdf0e10cSrcweir 
241cdf0e10cSrcweir     m_aNavigatorImages = ImageList( ModuleRes( RID_SVXIMGLIST_RPTEXPL ) );
242cdf0e10cSrcweir 	m_aNavigatorImagesHC = ImageList( ModuleRes( RID_SVXIMGLIST_RPTEXPL_HC ) );
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 	SetNodeBitmaps(
245cdf0e10cSrcweir 		m_aNavigatorImages.GetImage( RID_SVXIMG_COLLAPSEDNODE ),
246cdf0e10cSrcweir 		m_aNavigatorImages.GetImage( RID_SVXIMG_EXPANDEDNODE ),
247cdf0e10cSrcweir 		BMP_COLOR_NORMAL
248cdf0e10cSrcweir 	);
249cdf0e10cSrcweir 	SetNodeBitmaps(
250cdf0e10cSrcweir 		m_aNavigatorImagesHC.GetImage( RID_SVXIMG_COLLAPSEDNODE ),
251cdf0e10cSrcweir 		m_aNavigatorImagesHC.GetImage( RID_SVXIMG_EXPANDEDNODE ),
252cdf0e10cSrcweir 		BMP_COLOR_HIGHCONTRAST
253cdf0e10cSrcweir 	);
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 	SetDragDropMode(0xFFFF);
256cdf0e10cSrcweir 	EnableInplaceEditing( sal_False );
257cdf0e10cSrcweir 	SetSelectionMode(MULTIPLE_SELECTION);
258cdf0e10cSrcweir     Clear();
259cdf0e10cSrcweir 
260cdf0e10cSrcweir     m_aDropActionTimer.SetTimeoutHdl(LINK(this, NavigatorTree, OnDropActionTimer));
261cdf0e10cSrcweir     SetSelectHdl(LINK(this, NavigatorTree, OnEntrySelDesel));
262cdf0e10cSrcweir 	SetDeselectHdl(LINK(this, NavigatorTree, OnEntrySelDesel));
263cdf0e10cSrcweir }
264cdf0e10cSrcweir // -----------------------------------------------------------------------------
~NavigatorTree()265cdf0e10cSrcweir NavigatorTree::~NavigatorTree()
266cdf0e10cSrcweir {
267cdf0e10cSrcweir     SvLBoxEntry* pCurrent = First();
268cdf0e10cSrcweir     while ( pCurrent )
269cdf0e10cSrcweir     {
270cdf0e10cSrcweir         delete static_cast<UserData*>(pCurrent->GetUserData());
271cdf0e10cSrcweir         pCurrent = Next(pCurrent);
272cdf0e10cSrcweir     }
273cdf0e10cSrcweir     m_pReportListener->dispose();
274cdf0e10cSrcweir     m_pSelectionListener->dispose();
275cdf0e10cSrcweir     DBG_DTOR(rpt_NavigatorTree,NULL);
276cdf0e10cSrcweir }
277cdf0e10cSrcweir //------------------------------------------------------------------------------
Command(const CommandEvent & rEvt)278cdf0e10cSrcweir void NavigatorTree::Command( const CommandEvent& rEvt )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir 	sal_Bool bHandled = sal_False;
281cdf0e10cSrcweir 	switch( rEvt.GetCommand() )
282cdf0e10cSrcweir 	{
283cdf0e10cSrcweir 		case COMMAND_CONTEXTMENU:
284cdf0e10cSrcweir 		{
285cdf0e10cSrcweir 			// die Stelle, an der geklickt wurde
286cdf0e10cSrcweir             SvLBoxEntry* ptClickedOn = NULL;
287cdf0e10cSrcweir 			::Point aWhere;
288cdf0e10cSrcweir 			if (rEvt.IsMouseEvent())
289cdf0e10cSrcweir 			{
290cdf0e10cSrcweir 				aWhere = rEvt.GetMousePosPixel();
291cdf0e10cSrcweir 				ptClickedOn = GetEntry(aWhere);
292cdf0e10cSrcweir 				if (ptClickedOn == NULL)
293cdf0e10cSrcweir 					break;
294cdf0e10cSrcweir 				if ( !IsSelected(ptClickedOn) )
295cdf0e10cSrcweir 				{
296cdf0e10cSrcweir 					SelectAll(sal_False);
297cdf0e10cSrcweir 					Select(ptClickedOn, sal_True);
298cdf0e10cSrcweir 					SetCurEntry(ptClickedOn);
299cdf0e10cSrcweir 				}
300cdf0e10cSrcweir 			}
301cdf0e10cSrcweir 			else
302cdf0e10cSrcweir 			{
303cdf0e10cSrcweir 				ptClickedOn = GetCurEntry();
304cdf0e10cSrcweir 				if ( !ptClickedOn )
305cdf0e10cSrcweir 					break;
306cdf0e10cSrcweir 				aWhere = GetEntryPosition(ptClickedOn);
307cdf0e10cSrcweir 			}
308cdf0e10cSrcweir             UserData* pData = static_cast<UserData*>(ptClickedOn->GetUserData());
309cdf0e10cSrcweir             uno::Reference< report::XFunctionsSupplier> xSupplier(pData->getContent(),uno::UNO_QUERY);
310cdf0e10cSrcweir             uno::Reference< report::XFunctions> xFunctions(pData->getContent(),uno::UNO_QUERY);
311cdf0e10cSrcweir             uno::Reference< report::XGroup> xGroup(pData->getContent(),uno::UNO_QUERY);
312cdf0e10cSrcweir             sal_Bool bDeleteAllowed = m_rController.isEditable() && (xGroup.is() ||
313cdf0e10cSrcweir                                       uno::Reference< report::XFunction>(pData->getContent(),uno::UNO_QUERY).is());
314cdf0e10cSrcweir             PopupMenu aContextMenu( ModuleRes( RID_MENU_NAVIGATOR ) );
315cdf0e10cSrcweir 
316cdf0e10cSrcweir 			sal_uInt16 nCount = aContextMenu.GetItemCount();
317cdf0e10cSrcweir 			for (sal_uInt16 i = 0; i < nCount; ++i)
318cdf0e10cSrcweir 			{
319cdf0e10cSrcweir 				if ( MENUITEM_SEPARATOR != aContextMenu.GetItemType(i))
320cdf0e10cSrcweir 				{
321cdf0e10cSrcweir 					sal_uInt16 nId = aContextMenu.GetItemId(i);
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 					aContextMenu.CheckItem(nId,m_rController.isCommandChecked(nId));
324cdf0e10cSrcweir                     sal_Bool bEnabled = m_rController.isCommandEnabled(nId);
325cdf0e10cSrcweir                     if ( nId == SID_RPT_NEW_FUNCTION )
326cdf0e10cSrcweir                         aContextMenu.EnableItem(nId,m_rController.isEditable() && (xSupplier.is() || xFunctions.is()) );
327cdf0e10cSrcweir                     // special condition, check for function and group
328cdf0e10cSrcweir                     else if ( nId == SID_DELETE )
329cdf0e10cSrcweir                         aContextMenu.EnableItem(SID_DELETE,bDeleteAllowed);
330cdf0e10cSrcweir                     else
331cdf0e10cSrcweir                         aContextMenu.EnableItem(nId,bEnabled);
332cdf0e10cSrcweir 				}
333cdf0e10cSrcweir 			} // for (sal_uInt16 i = 0; i < nCount; ++i)
334cdf0e10cSrcweir 			sal_uInt16 nId = aContextMenu.Execute(this, aWhere);
335cdf0e10cSrcweir 			if ( nId )
336cdf0e10cSrcweir             {
337cdf0e10cSrcweir                 uno::Sequence< beans::PropertyValue> aArgs;
338cdf0e10cSrcweir                 if ( nId == SID_RPT_NEW_FUNCTION )
339cdf0e10cSrcweir                 {
340cdf0e10cSrcweir                     aArgs.realloc(1);
341cdf0e10cSrcweir                     aArgs[0].Value <<= (xFunctions.is() ? xFunctions : xSupplier->getFunctions());
342cdf0e10cSrcweir                 }
343cdf0e10cSrcweir                 else if ( nId == SID_DELETE )
344cdf0e10cSrcweir                 {
345cdf0e10cSrcweir                     if ( xGroup.is() )
346cdf0e10cSrcweir                         nId = SID_GROUP_REMOVE;
347cdf0e10cSrcweir                     aArgs.realloc(1);
348cdf0e10cSrcweir                     aArgs[0].Name = PROPERTY_GROUP;
349cdf0e10cSrcweir                     aArgs[0].Value <<= pData->getContent();
350cdf0e10cSrcweir                 }
351cdf0e10cSrcweir                 m_rController.executeUnChecked(nId,aArgs);
352cdf0e10cSrcweir             }
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 			bHandled = sal_True;
355cdf0e10cSrcweir 		} break;
356cdf0e10cSrcweir 	}
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 	if (!bHandled)
359cdf0e10cSrcweir 		SvTreeListBox::Command( rEvt );
360cdf0e10cSrcweir }
361cdf0e10cSrcweir // -----------------------------------------------------------------------------
AcceptDrop(const AcceptDropEvent & _rEvt)362cdf0e10cSrcweir sal_Int8 NavigatorTree::AcceptDrop( const AcceptDropEvent& _rEvt )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir 	sal_Int8 nDropOption = DND_ACTION_NONE;
365cdf0e10cSrcweir     ::Point aDropPos = _rEvt.maPosPixel;
366cdf0e10cSrcweir     if (_rEvt.mbLeaving)
367cdf0e10cSrcweir 	{
368cdf0e10cSrcweir 		if (m_aDropActionTimer.IsActive())
369cdf0e10cSrcweir 			m_aDropActionTimer.Stop();
370cdf0e10cSrcweir 	}
371cdf0e10cSrcweir     else
372cdf0e10cSrcweir 	{
373cdf0e10cSrcweir         bool bNeedTrigger = false;
374cdf0e10cSrcweir 		// auf dem ersten Eintrag ?
375cdf0e10cSrcweir 		if ((aDropPos.Y() >= 0) && (aDropPos.Y() < GetEntryHeight()))
376cdf0e10cSrcweir 		{
377cdf0e10cSrcweir 			m_aDropActionType = DA_SCROLLUP;
378cdf0e10cSrcweir 			bNeedTrigger = true;
379cdf0e10cSrcweir 		}
380cdf0e10cSrcweir         else if ((aDropPos.Y() < GetSizePixel().Height()) && (aDropPos.Y() >= GetSizePixel().Height() - GetEntryHeight()))
381cdf0e10cSrcweir 		{
382cdf0e10cSrcweir 			m_aDropActionType = DA_SCROLLDOWN;
383cdf0e10cSrcweir 			bNeedTrigger = true;
384cdf0e10cSrcweir 		}
385cdf0e10cSrcweir         else
386cdf0e10cSrcweir 		{
387cdf0e10cSrcweir 			SvLBoxEntry* pDropppedOn = GetEntry(aDropPos);
388cdf0e10cSrcweir 			if (pDropppedOn && (GetChildCount(pDropppedOn) > 0) && !IsExpanded(pDropppedOn))
389cdf0e10cSrcweir 			{
390cdf0e10cSrcweir 				m_aDropActionType = DA_EXPANDNODE;
391cdf0e10cSrcweir 				bNeedTrigger = true;
392cdf0e10cSrcweir 			}
393cdf0e10cSrcweir 		}
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 		if (bNeedTrigger && (m_aTimerTriggered != aDropPos))
396cdf0e10cSrcweir 		{
397cdf0e10cSrcweir 			// neu anfangen zu zaehlen
398cdf0e10cSrcweir 			m_nTimerCounter = DROP_ACTION_TIMER_INITIAL_TICKS;
399cdf0e10cSrcweir 			// die Pos merken, da ich auch AcceptDrops bekomme, wenn sich die Maus gar nicht bewegt hat
400cdf0e10cSrcweir 			m_aTimerTriggered = aDropPos;
401cdf0e10cSrcweir 			// und den Timer los
402cdf0e10cSrcweir 			if (!m_aDropActionTimer.IsActive()) // gibt es den Timer schon ?
403cdf0e10cSrcweir 			{
404cdf0e10cSrcweir 				m_aDropActionTimer.SetTimeout(DROP_ACTION_TIMER_TICK_BASE);
405cdf0e10cSrcweir 				m_aDropActionTimer.Start();
406cdf0e10cSrcweir 			}
407cdf0e10cSrcweir 		}
408cdf0e10cSrcweir         else if (!bNeedTrigger)
409cdf0e10cSrcweir 			m_aDropActionTimer.Stop();
410cdf0e10cSrcweir 	}
411cdf0e10cSrcweir 
412cdf0e10cSrcweir     return nDropOption;
413cdf0e10cSrcweir }
414cdf0e10cSrcweir // -------------------------------------------------------------------------
ExecuteDrop(const ExecuteDropEvent &)415cdf0e10cSrcweir sal_Int8 NavigatorTree::ExecuteDrop( const ExecuteDropEvent& /*_rEvt*/ )
416cdf0e10cSrcweir {
417cdf0e10cSrcweir     // _rEvt.mnAction;
418cdf0e10cSrcweir 	return DND_ACTION_NONE;
419cdf0e10cSrcweir }
420cdf0e10cSrcweir // -------------------------------------------------------------------------
StartDrag(sal_Int8,const Point & _rPosPixel)421cdf0e10cSrcweir void NavigatorTree::StartDrag( sal_Int8 /*_nAction*/, const Point& _rPosPixel )
422cdf0e10cSrcweir {
423cdf0e10cSrcweir     m_pDragedEntry = GetEntry(_rPosPixel);
424cdf0e10cSrcweir     if ( m_pDragedEntry )
425cdf0e10cSrcweir     {
426cdf0e10cSrcweir         EndSelection();
427cdf0e10cSrcweir     }
428cdf0e10cSrcweir }
429cdf0e10cSrcweir //------------------------------------------------------------------------
IMPL_LINK(NavigatorTree,OnDropActionTimer,void *,EMPTYARG)430cdf0e10cSrcweir IMPL_LINK( NavigatorTree, OnDropActionTimer, void*, EMPTYARG )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir 	if (--m_nTimerCounter > 0)
433cdf0e10cSrcweir 		return 0L;
434cdf0e10cSrcweir 
435cdf0e10cSrcweir     switch ( m_aDropActionType )
436cdf0e10cSrcweir     {
437cdf0e10cSrcweir     case DA_EXPANDNODE:
438cdf0e10cSrcweir 	{
439cdf0e10cSrcweir 		SvLBoxEntry* pToExpand = GetEntry(m_aTimerTriggered);
440cdf0e10cSrcweir 		if (pToExpand && (GetChildCount(pToExpand) > 0) &&  !IsExpanded(pToExpand))
441cdf0e10cSrcweir 			// tja, eigentlich muesste ich noch testen, ob die Node nicht schon expandiert ist, aber ich
442cdf0e10cSrcweir 			// habe dazu weder in den Basisklassen noch im Model eine Methode gefunden ...
443cdf0e10cSrcweir 			// aber ich denke, die BK sollte es auch so vertragen
444cdf0e10cSrcweir 			Expand(pToExpand);
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 		// nach dem Expand habe ich im Gegensatz zum Scrollen natuerlich nix mehr zu tun
447cdf0e10cSrcweir 		m_aDropActionTimer.Stop();
448cdf0e10cSrcweir 	}
449cdf0e10cSrcweir     break;
450cdf0e10cSrcweir 
451cdf0e10cSrcweir     case DA_SCROLLUP :
452cdf0e10cSrcweir 		ScrollOutputArea( 1 );
453cdf0e10cSrcweir 		m_nTimerCounter = DROP_ACTION_TIMER_SCROLL_TICKS;
454cdf0e10cSrcweir 		break;
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 	case DA_SCROLLDOWN :
457cdf0e10cSrcweir 		ScrollOutputArea( -1 );
458cdf0e10cSrcweir 		m_nTimerCounter = DROP_ACTION_TIMER_SCROLL_TICKS;
459cdf0e10cSrcweir 		break;
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 	}
462cdf0e10cSrcweir 
463cdf0e10cSrcweir 	return 0L;
464cdf0e10cSrcweir }
465cdf0e10cSrcweir 
466cdf0e10cSrcweir // -----------------------------------------------------------------------------
467cdf0e10cSrcweir IMPL_LINK(NavigatorTree, OnEntrySelDesel, NavigatorTree*, /*pThis*/)
468cdf0e10cSrcweir {
469cdf0e10cSrcweir     if ( !m_pSelectionListener->locked() )
470cdf0e10cSrcweir     {
471cdf0e10cSrcweir         m_pSelectionListener->lock();
472cdf0e10cSrcweir         SvLBoxEntry* pEntry = GetCurEntry();
473cdf0e10cSrcweir         uno::Any aSelection;
474cdf0e10cSrcweir         if ( IsSelected(pEntry) )
475cdf0e10cSrcweir             aSelection <<= static_cast<UserData*>(pEntry->GetUserData())->getContent();
476cdf0e10cSrcweir         m_rController.select(aSelection);
477cdf0e10cSrcweir         m_pSelectionListener->unlock();
478cdf0e10cSrcweir     }
479cdf0e10cSrcweir 
480cdf0e10cSrcweir     return 0L;
481cdf0e10cSrcweir }
482cdf0e10cSrcweir // -----------------------------------------------------------------------------
_selectionChanged(const lang::EventObject & aEvent)483cdf0e10cSrcweir void NavigatorTree::_selectionChanged( const lang::EventObject& aEvent ) throw (uno::RuntimeException)
484cdf0e10cSrcweir {
485cdf0e10cSrcweir     m_pSelectionListener->lock();
486cdf0e10cSrcweir     uno::Reference< view::XSelectionSupplier> xSelectionSupplier(aEvent.Source,uno::UNO_QUERY);
487cdf0e10cSrcweir     uno::Any aSec = xSelectionSupplier->getSelection();
488cdf0e10cSrcweir     uno::Sequence< uno::Reference< report::XReportComponent > > aSelection;
489cdf0e10cSrcweir     aSec >>= aSelection;
490cdf0e10cSrcweir     if ( !aSelection.getLength() )
491cdf0e10cSrcweir     {
492cdf0e10cSrcweir         uno::Reference< uno::XInterface> xSelection(aSec,uno::UNO_QUERY);
493cdf0e10cSrcweir         SvLBoxEntry* pEntry = find(xSelection);
494cdf0e10cSrcweir         if ( pEntry && !IsSelected(pEntry) )
495cdf0e10cSrcweir         {
496cdf0e10cSrcweir             Select(pEntry, sal_True);
497cdf0e10cSrcweir 	        SetCurEntry(pEntry);
498cdf0e10cSrcweir         }
499cdf0e10cSrcweir         else if ( !pEntry )
500cdf0e10cSrcweir             SelectAll(sal_False,sal_False);
501cdf0e10cSrcweir     }
502cdf0e10cSrcweir     else
503cdf0e10cSrcweir     {
504cdf0e10cSrcweir         const uno::Reference< report::XReportComponent >* pIter = aSelection.getConstArray();
505cdf0e10cSrcweir         const uno::Reference< report::XReportComponent >* pEnd  = pIter + aSelection.getLength();
506cdf0e10cSrcweir         for (; pIter != pEnd; ++pIter)
507cdf0e10cSrcweir         {
508cdf0e10cSrcweir             SvLBoxEntry* pEntry = find(*pIter);
509cdf0e10cSrcweir             if ( pEntry && !IsSelected(pEntry) )
510cdf0e10cSrcweir             {
511cdf0e10cSrcweir                 Select(pEntry, sal_True);
512cdf0e10cSrcweir 	            SetCurEntry(pEntry);
513cdf0e10cSrcweir             }
514cdf0e10cSrcweir         }
515cdf0e10cSrcweir     }
516cdf0e10cSrcweir     m_pSelectionListener->unlock();
517cdf0e10cSrcweir }
518cdf0e10cSrcweir // -----------------------------------------------------------------------------
insertEntry(const::rtl::OUString & _sName,SvLBoxEntry * _pParent,sal_uInt16 _nImageId,sal_uLong _nPosition,UserData * _pData)519cdf0e10cSrcweir SvLBoxEntry* NavigatorTree::insertEntry(const ::rtl::OUString& _sName,SvLBoxEntry* _pParent,sal_uInt16 _nImageId,sal_uLong _nPosition,UserData* _pData)
520cdf0e10cSrcweir {
521cdf0e10cSrcweir     SvLBoxEntry* pEntry = NULL;
522cdf0e10cSrcweir     if ( _nImageId )
523cdf0e10cSrcweir     {
524cdf0e10cSrcweir         const Image aImage( m_aNavigatorImages.GetImage( _nImageId ) );
525cdf0e10cSrcweir         pEntry = InsertEntry(_sName,aImage,aImage,_pParent,sal_False,_nPosition,_pData);
526cdf0e10cSrcweir         if ( pEntry )
527cdf0e10cSrcweir 	    {
528cdf0e10cSrcweir             const Image aImageHC( m_aNavigatorImagesHC.GetImage( _nImageId ) );
529cdf0e10cSrcweir 		    SetExpandedEntryBmp( pEntry, aImageHC, BMP_COLOR_HIGHCONTRAST );
530cdf0e10cSrcweir 		    SetCollapsedEntryBmp( pEntry, aImageHC, BMP_COLOR_HIGHCONTRAST );
531cdf0e10cSrcweir 	    }
532cdf0e10cSrcweir     }
533cdf0e10cSrcweir     else
534cdf0e10cSrcweir         pEntry = InsertEntry(_sName,_pParent,sal_False,_nPosition,_pData);
535cdf0e10cSrcweir     return pEntry;
536cdf0e10cSrcweir }
537cdf0e10cSrcweir // -----------------------------------------------------------------------------
traverseSection(const uno::Reference<report::XSection> & _xSection,SvLBoxEntry * _pParent,sal_uInt16 _nImageId,sal_uLong _nPosition)538cdf0e10cSrcweir void NavigatorTree::traverseSection(const uno::Reference< report::XSection>& _xSection,SvLBoxEntry* _pParent,sal_uInt16 _nImageId,sal_uLong _nPosition)
539cdf0e10cSrcweir {
540cdf0e10cSrcweir     SvLBoxEntry* pSection = insertEntry(_xSection->getName(),_pParent,_nImageId,_nPosition,new UserData(this,_xSection));
541cdf0e10cSrcweir     const sal_Int32 nCount = _xSection->getCount();
542cdf0e10cSrcweir     for (sal_Int32 i = 0; i < nCount; ++i)
543cdf0e10cSrcweir     {
544cdf0e10cSrcweir         uno::Reference< report::XReportComponent> xElement(_xSection->getByIndex(i),uno::UNO_QUERY_THROW);
545cdf0e10cSrcweir         OSL_ENSURE(xElement.is(),"Found report element which is NULL!");
546cdf0e10cSrcweir         insertEntry(lcl_getName(xElement.get()),pSection,lcl_getImageId(xElement),LIST_APPEND,new UserData(this,xElement));
547cdf0e10cSrcweir         uno::Reference< report::XReportDefinition> xSubReport(xElement,uno::UNO_QUERY);
548cdf0e10cSrcweir         if ( xSubReport.is() )
549cdf0e10cSrcweir         {
550cdf0e10cSrcweir             m_pMasterReport = find(_xSection->getReportDefinition());
551cdf0e10cSrcweir             reportdesign::OReportVisitor aSubVisitor(this);
552cdf0e10cSrcweir             aSubVisitor.start(xSubReport);
553cdf0e10cSrcweir         }
554cdf0e10cSrcweir     }
555cdf0e10cSrcweir }
556cdf0e10cSrcweir // -----------------------------------------------------------------------------
traverseFunctions(const uno::Reference<report::XFunctions> & _xFunctions,SvLBoxEntry * _pParent)557cdf0e10cSrcweir void NavigatorTree::traverseFunctions(const uno::Reference< report::XFunctions>& _xFunctions,SvLBoxEntry* _pParent)
558cdf0e10cSrcweir {
559cdf0e10cSrcweir     SvLBoxEntry* pFunctions = insertEntry(String(ModuleRes(RID_STR_FUNCTIONS)),_pParent,SID_RPT_NEW_FUNCTION,LIST_APPEND,new UserData(this,_xFunctions));
560cdf0e10cSrcweir     const sal_Int32 nCount = _xFunctions->getCount();
561cdf0e10cSrcweir     for (sal_Int32 i = 0; i< nCount; ++i)
562cdf0e10cSrcweir     {
563cdf0e10cSrcweir         uno::Reference< report::XFunction> xElement(_xFunctions->getByIndex(i),uno::UNO_QUERY);
564cdf0e10cSrcweir         insertEntry(xElement->getName(),pFunctions,SID_RPT_NEW_FUNCTION,LIST_APPEND,new UserData(this,xElement));
565cdf0e10cSrcweir     }
566cdf0e10cSrcweir }
567cdf0e10cSrcweir // -----------------------------------------------------------------------------
find(const uno::Reference<uno::XInterface> & _xContent)568cdf0e10cSrcweir SvLBoxEntry* NavigatorTree::find(const uno::Reference< uno::XInterface >& _xContent)
569cdf0e10cSrcweir {
570cdf0e10cSrcweir     SvLBoxEntry* pRet = NULL;
571cdf0e10cSrcweir     if ( _xContent.is() )
572cdf0e10cSrcweir     {
573cdf0e10cSrcweir         SvLBoxEntry* pCurrent = First();
574cdf0e10cSrcweir         while ( pCurrent )
575cdf0e10cSrcweir         {
576cdf0e10cSrcweir             UserData* pData = static_cast<UserData*>(pCurrent->GetUserData());
577cdf0e10cSrcweir             OSL_ENSURE(pData,"No UserData set an entry!");
578cdf0e10cSrcweir             if ( pData->getContent() == _xContent )
579cdf0e10cSrcweir             {
580cdf0e10cSrcweir                 pRet = pCurrent;
581cdf0e10cSrcweir                 break;
582cdf0e10cSrcweir             }
583cdf0e10cSrcweir             pCurrent = Next(pCurrent);
584cdf0e10cSrcweir         }
585cdf0e10cSrcweir     }
586cdf0e10cSrcweir     return pRet;
587cdf0e10cSrcweir }
588cdf0e10cSrcweir // -----------------------------------------------------------------------------
589cdf0e10cSrcweir // ITraverseReport
590cdf0e10cSrcweir // -----------------------------------------------------------------------------
traverseReport(const uno::Reference<report::XReportDefinition> & _xReport)591cdf0e10cSrcweir void NavigatorTree::traverseReport(const uno::Reference< report::XReportDefinition>& _xReport)
592cdf0e10cSrcweir {
593cdf0e10cSrcweir     insertEntry(_xReport->getName(),m_pMasterReport,SID_SELECT_REPORT,LIST_APPEND,new UserData(this,_xReport));
594cdf0e10cSrcweir }
595cdf0e10cSrcweir // -----------------------------------------------------------------------------
traverseReportFunctions(const uno::Reference<report::XFunctions> & _xFunctions)596cdf0e10cSrcweir void NavigatorTree::traverseReportFunctions(const uno::Reference< report::XFunctions>& _xFunctions)
597cdf0e10cSrcweir {
598cdf0e10cSrcweir     SvLBoxEntry* pReport = find(_xFunctions->getParent());
599cdf0e10cSrcweir     traverseFunctions(_xFunctions,pReport);
600cdf0e10cSrcweir }
601cdf0e10cSrcweir // -----------------------------------------------------------------------------
traverseReportHeader(const uno::Reference<report::XSection> & _xSection)602cdf0e10cSrcweir void NavigatorTree::traverseReportHeader(const uno::Reference< report::XSection>& _xSection)
603cdf0e10cSrcweir {
604cdf0e10cSrcweir     SvLBoxEntry* pReport = find(_xSection->getReportDefinition());
605cdf0e10cSrcweir     traverseSection(_xSection,pReport,SID_REPORTHEADERFOOTER);
606cdf0e10cSrcweir }
607cdf0e10cSrcweir // -----------------------------------------------------------------------------
traverseReportFooter(const uno::Reference<report::XSection> & _xSection)608cdf0e10cSrcweir void NavigatorTree::traverseReportFooter(const uno::Reference< report::XSection>& _xSection)
609cdf0e10cSrcweir {
610cdf0e10cSrcweir     SvLBoxEntry* pReport = find(_xSection->getReportDefinition());
611cdf0e10cSrcweir     traverseSection(_xSection,pReport,SID_REPORTHEADERFOOTER);
612cdf0e10cSrcweir }
613cdf0e10cSrcweir // -----------------------------------------------------------------------------
traversePageHeader(const uno::Reference<report::XSection> & _xSection)614cdf0e10cSrcweir void NavigatorTree::traversePageHeader(const uno::Reference< report::XSection>& _xSection)
615cdf0e10cSrcweir {
616cdf0e10cSrcweir     SvLBoxEntry* pReport = find(_xSection->getReportDefinition());
617cdf0e10cSrcweir     traverseSection(_xSection,pReport,SID_PAGEHEADERFOOTER);
618cdf0e10cSrcweir }
619cdf0e10cSrcweir // -----------------------------------------------------------------------------
traversePageFooter(const uno::Reference<report::XSection> & _xSection)620cdf0e10cSrcweir void NavigatorTree::traversePageFooter(const uno::Reference< report::XSection>& _xSection)
621cdf0e10cSrcweir {
622cdf0e10cSrcweir     SvLBoxEntry* pReport = find(_xSection->getReportDefinition());
623cdf0e10cSrcweir     traverseSection(_xSection,pReport,SID_PAGEHEADERFOOTER);
624cdf0e10cSrcweir }
625cdf0e10cSrcweir // -----------------------------------------------------------------------------
traverseGroups(const uno::Reference<report::XGroups> & _xGroups)626cdf0e10cSrcweir void NavigatorTree::traverseGroups(const uno::Reference< report::XGroups>& _xGroups)
627cdf0e10cSrcweir {
628cdf0e10cSrcweir     SvLBoxEntry* pReport = find(_xGroups->getReportDefinition());
629cdf0e10cSrcweir     insertEntry(String(ModuleRes(RID_STR_GROUPS)),pReport,SID_SORTINGANDGROUPING,LIST_APPEND,new UserData(this,_xGroups));
630cdf0e10cSrcweir }
631cdf0e10cSrcweir // -----------------------------------------------------------------------------
traverseGroup(const uno::Reference<report::XGroup> & _xGroup)632cdf0e10cSrcweir void NavigatorTree::traverseGroup(const uno::Reference< report::XGroup>& _xGroup)
633cdf0e10cSrcweir {
634cdf0e10cSrcweir     uno::Reference< report::XGroups> xGroups(_xGroup->getParent(),uno::UNO_QUERY);
635cdf0e10cSrcweir     SvLBoxEntry* pGroups = find(xGroups);
636cdf0e10cSrcweir     OSL_ENSURE(pGroups,"No Groups inserted so far. Why!");
637cdf0e10cSrcweir     insertEntry(_xGroup->getExpression(),pGroups,SID_GROUP,rptui::getPositionInIndexAccess(xGroups.get(),_xGroup),new UserData(this,_xGroup));
638cdf0e10cSrcweir }
639cdf0e10cSrcweir // -----------------------------------------------------------------------------
traverseGroupFunctions(const uno::Reference<report::XFunctions> & _xFunctions)640cdf0e10cSrcweir void NavigatorTree::traverseGroupFunctions(const uno::Reference< report::XFunctions>& _xFunctions)
641cdf0e10cSrcweir {
642cdf0e10cSrcweir     SvLBoxEntry* pGroup = find(_xFunctions->getParent());
643cdf0e10cSrcweir     traverseFunctions(_xFunctions,pGroup);
644cdf0e10cSrcweir }
645cdf0e10cSrcweir // -----------------------------------------------------------------------------
traverseGroupHeader(const uno::Reference<report::XSection> & _xSection)646cdf0e10cSrcweir void NavigatorTree::traverseGroupHeader(const uno::Reference< report::XSection>& _xSection)
647cdf0e10cSrcweir {
648cdf0e10cSrcweir     SvLBoxEntry* pGroup = find(_xSection->getGroup());
649cdf0e10cSrcweir     OSL_ENSURE(pGroup,"No group found");
650cdf0e10cSrcweir     traverseSection(_xSection,pGroup,SID_GROUPHEADER,1);
651cdf0e10cSrcweir }
652cdf0e10cSrcweir // -----------------------------------------------------------------------------
traverseGroupFooter(const uno::Reference<report::XSection> & _xSection)653cdf0e10cSrcweir void NavigatorTree::traverseGroupFooter(const uno::Reference< report::XSection>& _xSection)
654cdf0e10cSrcweir {
655cdf0e10cSrcweir     SvLBoxEntry* pGroup = find(_xSection->getGroup());
656cdf0e10cSrcweir     OSL_ENSURE(pGroup,"No group found");
657cdf0e10cSrcweir     traverseSection(_xSection,pGroup,SID_GROUPFOOTER);
658cdf0e10cSrcweir }
659cdf0e10cSrcweir // -----------------------------------------------------------------------------
traverseDetail(const uno::Reference<report::XSection> & _xSection)660cdf0e10cSrcweir void NavigatorTree::traverseDetail(const uno::Reference< report::XSection>& _xSection)
661cdf0e10cSrcweir {
662cdf0e10cSrcweir     uno::Reference< report::XReportDefinition> xReport = _xSection->getReportDefinition();
663cdf0e10cSrcweir     SvLBoxEntry* pParent = find(xReport);
664cdf0e10cSrcweir     traverseSection(_xSection,pParent,SID_ICON_DETAIL);
665cdf0e10cSrcweir }
666cdf0e10cSrcweir // -----------------------------------------------------------------------------
_propertyChanged(const beans::PropertyChangeEvent & _rEvent)667cdf0e10cSrcweir void NavigatorTree::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) throw( uno::RuntimeException)
668cdf0e10cSrcweir {
669cdf0e10cSrcweir     uno::Reference< report::XReportDefinition> xReport(_rEvent.Source,uno::UNO_QUERY);
670cdf0e10cSrcweir     if ( xReport.is() )
671cdf0e10cSrcweir     {
672cdf0e10cSrcweir         sal_Bool bEnabled = sal_False;
673cdf0e10cSrcweir         _rEvent.NewValue >>= bEnabled;
674cdf0e10cSrcweir         if ( bEnabled )
675cdf0e10cSrcweir         {
676cdf0e10cSrcweir             SvLBoxEntry* pParent = find(xReport);
677cdf0e10cSrcweir             if ( _rEvent.PropertyName == PROPERTY_REPORTHEADERON )
678cdf0e10cSrcweir             {
679cdf0e10cSrcweir                 sal_uLong nPos = xReport->getReportHeaderOn() ? 2 : 1;
680cdf0e10cSrcweir                 traverseSection(xReport->getReportHeader(),pParent,SID_REPORTHEADERFOOTER,nPos);
681cdf0e10cSrcweir             }
682cdf0e10cSrcweir             else if ( _rEvent.PropertyName == PROPERTY_PAGEHEADERON )
683cdf0e10cSrcweir             {
684cdf0e10cSrcweir                 traverseSection(xReport->getPageHeader(),pParent, SID_PAGEHEADERFOOTER,1);
685cdf0e10cSrcweir             }
686cdf0e10cSrcweir             else if ( _rEvent.PropertyName == PROPERTY_PAGEFOOTERON )
687cdf0e10cSrcweir                 traverseSection(xReport->getPageFooter(),pParent, SID_PAGEHEADERFOOTER);
688cdf0e10cSrcweir             else if ( _rEvent.PropertyName == PROPERTY_REPORTFOOTERON )
689cdf0e10cSrcweir             {
690cdf0e10cSrcweir                 sal_uLong nPos = xReport->getPageFooterOn() ? (GetLevelChildCount(pParent) - 1) : LIST_APPEND;
691cdf0e10cSrcweir                 traverseSection(xReport->getReportFooter(),pParent,SID_REPORTHEADERFOOTER,nPos);
692cdf0e10cSrcweir             }
693cdf0e10cSrcweir         }
694cdf0e10cSrcweir     }
695cdf0e10cSrcweir }
696cdf0e10cSrcweir // -----------------------------------------------------------------------------
_elementInserted(const container::ContainerEvent & _rEvent)697cdf0e10cSrcweir void NavigatorTree::_elementInserted( const container::ContainerEvent& _rEvent )
698cdf0e10cSrcweir {
699cdf0e10cSrcweir     SvLBoxEntry* pEntry = find(_rEvent.Source);
700cdf0e10cSrcweir     uno::Reference<beans::XPropertySet> xProp(_rEvent.Element,uno::UNO_QUERY_THROW);
701cdf0e10cSrcweir     ::rtl::OUString sName;
702cdf0e10cSrcweir     uno::Reference< beans::XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
703cdf0e10cSrcweir     if ( xInfo.is() )
704cdf0e10cSrcweir     {
705cdf0e10cSrcweir         if ( xInfo->hasPropertyByName(PROPERTY_NAME) )
706cdf0e10cSrcweir             xProp->getPropertyValue(PROPERTY_NAME) >>= sName;
707cdf0e10cSrcweir         else if ( xInfo->hasPropertyByName(PROPERTY_EXPRESSION) )
708cdf0e10cSrcweir             xProp->getPropertyValue(PROPERTY_EXPRESSION) >>= sName;
709cdf0e10cSrcweir     }
710cdf0e10cSrcweir     uno::Reference< report::XGroup> xGroup(xProp,uno::UNO_QUERY);
711cdf0e10cSrcweir     if ( xGroup.is() )
712cdf0e10cSrcweir     {
713cdf0e10cSrcweir         reportdesign::OReportVisitor aSubVisitor(this);
714cdf0e10cSrcweir         aSubVisitor.start(xGroup);
715cdf0e10cSrcweir     }
716cdf0e10cSrcweir     else
717cdf0e10cSrcweir     {
718cdf0e10cSrcweir         uno::Reference< report::XReportComponent> xElement(xProp,uno::UNO_QUERY);
719cdf0e10cSrcweir         if ( xProp.is() )
720cdf0e10cSrcweir             sName = lcl_getName(xProp);
721cdf0e10cSrcweir         insertEntry(sName,pEntry,(!xElement.is() ? sal_uInt16(SID_RPT_NEW_FUNCTION) : lcl_getImageId(xElement)),LIST_APPEND,new UserData(this,xProp));
722cdf0e10cSrcweir     }
723cdf0e10cSrcweir     if ( !IsExpanded(pEntry) )
724cdf0e10cSrcweir         Expand(pEntry);
725cdf0e10cSrcweir }
726cdf0e10cSrcweir // -----------------------------------------------------------------------------
_elementRemoved(const container::ContainerEvent & _rEvent)727cdf0e10cSrcweir void NavigatorTree::_elementRemoved( const container::ContainerEvent& _rEvent )
728cdf0e10cSrcweir {
729cdf0e10cSrcweir     uno::Reference<beans::XPropertySet> xProp(_rEvent.Element,uno::UNO_QUERY);
730cdf0e10cSrcweir     SvLBoxEntry* pEntry = find(xProp);
731cdf0e10cSrcweir     OSL_ENSURE(pEntry,"NavigatorTree::_elementRemoved: No Entry found!");
732cdf0e10cSrcweir 
733cdf0e10cSrcweir     if ( pEntry )
734cdf0e10cSrcweir     {
735cdf0e10cSrcweir         SvLBoxEntry* pParent = GetParent(pEntry);
736cdf0e10cSrcweir         removeEntry(pEntry);
737cdf0e10cSrcweir         PaintEntry(pParent);
738cdf0e10cSrcweir     }
739cdf0e10cSrcweir }
740cdf0e10cSrcweir // -----------------------------------------------------------------------------
_elementReplaced(const container::ContainerEvent & _rEvent)741cdf0e10cSrcweir void NavigatorTree::_elementReplaced( const container::ContainerEvent& _rEvent )
742cdf0e10cSrcweir {
743cdf0e10cSrcweir     uno::Reference<beans::XPropertySet> xProp(_rEvent.ReplacedElement,uno::UNO_QUERY);
744cdf0e10cSrcweir     SvLBoxEntry* pEntry = find(xProp);
745cdf0e10cSrcweir     if ( pEntry )
746cdf0e10cSrcweir     {
747cdf0e10cSrcweir         UserData* pData = static_cast<UserData*>(pEntry->GetUserData());
748cdf0e10cSrcweir         xProp.set(_rEvent.Element,uno::UNO_QUERY);
749cdf0e10cSrcweir         pData->setContent(xProp);
750cdf0e10cSrcweir         ::rtl::OUString sName;
751cdf0e10cSrcweir         xProp->getPropertyValue(PROPERTY_NAME) >>= sName;
752cdf0e10cSrcweir         SetEntryText(pEntry,sName);
753cdf0e10cSrcweir     }
754cdf0e10cSrcweir }
755cdf0e10cSrcweir // -----------------------------------------------------------------------------
_disposing(const lang::EventObject & _rSource)756cdf0e10cSrcweir void NavigatorTree::_disposing(const lang::EventObject& _rSource)throw( uno::RuntimeException)
757cdf0e10cSrcweir {
758cdf0e10cSrcweir     removeEntry(find(_rSource.Source));
759cdf0e10cSrcweir }
760cdf0e10cSrcweir // -----------------------------------------------------------------------------
removeEntry(SvLBoxEntry * _pEntry,bool _bRemove)761cdf0e10cSrcweir void NavigatorTree::removeEntry(SvLBoxEntry* _pEntry,bool _bRemove)
762cdf0e10cSrcweir {
763cdf0e10cSrcweir     if ( _pEntry )
764cdf0e10cSrcweir     {
765cdf0e10cSrcweir         SvLBoxEntry* pChild = FirstChild(_pEntry);
766cdf0e10cSrcweir         while( pChild )
767cdf0e10cSrcweir         {
768cdf0e10cSrcweir             removeEntry(pChild,false);
769cdf0e10cSrcweir             pChild = NextSibling(pChild);
770cdf0e10cSrcweir         }
771cdf0e10cSrcweir         delete static_cast<UserData*>(_pEntry->GetUserData());
772cdf0e10cSrcweir         if ( _bRemove )
773cdf0e10cSrcweir             GetModel()->Remove(_pEntry);
774cdf0e10cSrcweir     }
775cdf0e10cSrcweir }
DBG_NAME(rpt_NavigatorTree_UserData)776cdf0e10cSrcweir DBG_NAME(rpt_NavigatorTree_UserData)
777cdf0e10cSrcweir // -----------------------------------------------------------------------------
778cdf0e10cSrcweir NavigatorTree::UserData::UserData(NavigatorTree* _pTree,const uno::Reference<uno::XInterface>& _xContent)
779cdf0e10cSrcweir     : OPropertyChangeListener(m_aMutex)
780cdf0e10cSrcweir     , OContainerListener(m_aMutex)
781cdf0e10cSrcweir     , m_xContent(_xContent)
782cdf0e10cSrcweir     , m_pTree(_pTree)
783cdf0e10cSrcweir {
784cdf0e10cSrcweir     DBG_CTOR(rpt_NavigatorTree_UserData,NULL);
785cdf0e10cSrcweir     uno::Reference<beans::XPropertySet> xProp(m_xContent,uno::UNO_QUERY);
786cdf0e10cSrcweir     if ( xProp.is() )
787cdf0e10cSrcweir     {
788cdf0e10cSrcweir         uno::Reference< beans::XPropertySetInfo> xInfo = xProp->getPropertySetInfo();
789cdf0e10cSrcweir         if ( xInfo.is() )
790cdf0e10cSrcweir         {
791cdf0e10cSrcweir             m_pListener = new ::comphelper::OPropertyChangeMultiplexer(this,xProp);
792cdf0e10cSrcweir             if ( xInfo->hasPropertyByName(PROPERTY_NAME) )
793cdf0e10cSrcweir                 m_pListener->addProperty(PROPERTY_NAME);
794cdf0e10cSrcweir             else if ( xInfo->hasPropertyByName(PROPERTY_EXPRESSION) )
795cdf0e10cSrcweir                 m_pListener->addProperty(PROPERTY_EXPRESSION);
796cdf0e10cSrcweir             if ( xInfo->hasPropertyByName(PROPERTY_DATAFIELD) )
797cdf0e10cSrcweir                 m_pListener->addProperty(PROPERTY_DATAFIELD);
798cdf0e10cSrcweir             if ( xInfo->hasPropertyByName(PROPERTY_LABEL) )
799cdf0e10cSrcweir                 m_pListener->addProperty(PROPERTY_LABEL);
800cdf0e10cSrcweir             if ( xInfo->hasPropertyByName(PROPERTY_HEADERON) )
801cdf0e10cSrcweir                 m_pListener->addProperty(PROPERTY_HEADERON);
802cdf0e10cSrcweir             if ( xInfo->hasPropertyByName(PROPERTY_FOOTERON) )
803cdf0e10cSrcweir                 m_pListener->addProperty(PROPERTY_FOOTERON);
804cdf0e10cSrcweir         }
805cdf0e10cSrcweir     }
806cdf0e10cSrcweir     uno::Reference< container::XContainer> xContainer(m_xContent,uno::UNO_QUERY);
807cdf0e10cSrcweir     if ( xContainer.is() )
808cdf0e10cSrcweir     {
809cdf0e10cSrcweir         m_pContainerListener = new ::comphelper::OContainerListenerAdapter(this,xContainer);
810cdf0e10cSrcweir     }
811cdf0e10cSrcweir }
812cdf0e10cSrcweir // -----------------------------------------------------------------------------
~UserData()813cdf0e10cSrcweir NavigatorTree::UserData::~UserData()
814cdf0e10cSrcweir {
815cdf0e10cSrcweir     DBG_DTOR(rpt_NavigatorTree_UserData,NULL);
816cdf0e10cSrcweir     if ( m_pContainerListener.is() )
817cdf0e10cSrcweir         m_pContainerListener->dispose();
818cdf0e10cSrcweir     if ( m_pListener.is() )
819cdf0e10cSrcweir         m_pListener->dispose();
820cdf0e10cSrcweir }
821cdf0e10cSrcweir // -----------------------------------------------------------------------------
822cdf0e10cSrcweir // OPropertyChangeListener
_propertyChanged(const beans::PropertyChangeEvent & _rEvent)823cdf0e10cSrcweir void NavigatorTree::UserData::_propertyChanged(const beans::PropertyChangeEvent& _rEvent) throw( uno::RuntimeException)
824cdf0e10cSrcweir {
825cdf0e10cSrcweir     SvLBoxEntry* pEntry = m_pTree->find(_rEvent.Source);
826cdf0e10cSrcweir     OSL_ENSURE(pEntry,"No entry could be found! Why not!");
827cdf0e10cSrcweir     const bool bFooterOn = (PROPERTY_FOOTERON == _rEvent.PropertyName);
828cdf0e10cSrcweir     try
829cdf0e10cSrcweir     {
830cdf0e10cSrcweir         if ( bFooterOn || PROPERTY_HEADERON == _rEvent.PropertyName )
831cdf0e10cSrcweir         {
832cdf0e10cSrcweir             sal_Int32 nPos = 1;
833cdf0e10cSrcweir             uno::Reference< report::XGroup> xGroup(_rEvent.Source,uno::UNO_QUERY);
834cdf0e10cSrcweir             ::std::mem_fun_t< sal_Bool,OGroupHelper> pIsOn = ::std::mem_fun(&OGroupHelper::getHeaderOn);
835cdf0e10cSrcweir 	        ::std::mem_fun_t< uno::Reference<report::XSection> ,OGroupHelper> pMemFunSection = ::std::mem_fun(&OGroupHelper::getHeader);
836cdf0e10cSrcweir             if ( bFooterOn )
837cdf0e10cSrcweir             {
838cdf0e10cSrcweir                 pIsOn = ::std::mem_fun(&OGroupHelper::getFooterOn);
839cdf0e10cSrcweir 		        pMemFunSection = ::std::mem_fun(&OGroupHelper::getFooter);
840cdf0e10cSrcweir                 nPos = m_pTree->GetChildCount(pEntry) - 1;
841cdf0e10cSrcweir             }
842cdf0e10cSrcweir 
843cdf0e10cSrcweir             OGroupHelper aGroupHelper(xGroup);
844cdf0e10cSrcweir             if ( pIsOn(&aGroupHelper) )
845cdf0e10cSrcweir             {
846cdf0e10cSrcweir                 if ( bFooterOn )
847cdf0e10cSrcweir                     ++nPos;
848cdf0e10cSrcweir                 m_pTree->traverseSection(pMemFunSection(&aGroupHelper),pEntry,bFooterOn ? SID_GROUPFOOTER : SID_GROUPHEADER,nPos);
849cdf0e10cSrcweir             }
850cdf0e10cSrcweir             //else
851cdf0e10cSrcweir             //    m_pTree->removeEntry(m_pTree->GetEntry(pEntry,nPos));
852cdf0e10cSrcweir         }
853cdf0e10cSrcweir         else if ( PROPERTY_EXPRESSION == _rEvent.PropertyName)
854cdf0e10cSrcweir         {
855cdf0e10cSrcweir             ::rtl::OUString sNewName;
856cdf0e10cSrcweir             _rEvent.NewValue >>= sNewName;
857cdf0e10cSrcweir             m_pTree->SetEntryText(pEntry,sNewName);
858cdf0e10cSrcweir         }
859cdf0e10cSrcweir         else if ( PROPERTY_DATAFIELD == _rEvent.PropertyName || PROPERTY_LABEL == _rEvent.PropertyName || PROPERTY_NAME == _rEvent.PropertyName )
860cdf0e10cSrcweir         {
861cdf0e10cSrcweir             uno::Reference<beans::XPropertySet> xProp(_rEvent.Source,uno::UNO_QUERY);
862cdf0e10cSrcweir             m_pTree->SetEntryText(pEntry,lcl_getName(xProp));
863cdf0e10cSrcweir         }
864cdf0e10cSrcweir     }
865cdf0e10cSrcweir     catch(uno::Exception)
866cdf0e10cSrcweir     {}
867cdf0e10cSrcweir }
868cdf0e10cSrcweir // -----------------------------------------------------------------------------
_elementInserted(const container::ContainerEvent & _rEvent)869cdf0e10cSrcweir void NavigatorTree::UserData::_elementInserted( const container::ContainerEvent& _rEvent ) throw(uno::RuntimeException)
870cdf0e10cSrcweir {
871cdf0e10cSrcweir     m_pTree->_elementInserted( _rEvent );
872cdf0e10cSrcweir }
873cdf0e10cSrcweir // -----------------------------------------------------------------------------
_elementRemoved(const container::ContainerEvent & _rEvent)874cdf0e10cSrcweir void NavigatorTree::UserData::_elementRemoved( const container::ContainerEvent& _rEvent ) throw(uno::RuntimeException)
875cdf0e10cSrcweir {
876cdf0e10cSrcweir     m_pTree->_elementRemoved( _rEvent );
877cdf0e10cSrcweir }
878cdf0e10cSrcweir // -----------------------------------------------------------------------------
_elementReplaced(const container::ContainerEvent & _rEvent)879cdf0e10cSrcweir void NavigatorTree::UserData::_elementReplaced( const container::ContainerEvent& _rEvent ) throw(uno::RuntimeException)
880cdf0e10cSrcweir {
881cdf0e10cSrcweir     m_pTree->_elementReplaced( _rEvent );
882cdf0e10cSrcweir }
883cdf0e10cSrcweir // -----------------------------------------------------------------------------
_disposing(const lang::EventObject & _rSource)884cdf0e10cSrcweir void NavigatorTree::UserData::_disposing(const lang::EventObject& _rSource) throw( uno::RuntimeException)
885cdf0e10cSrcweir {
886cdf0e10cSrcweir     m_pTree->_disposing( _rSource );
887cdf0e10cSrcweir }
888cdf0e10cSrcweir // -----------------------------------------------------------------------------
889cdf0e10cSrcweir // class ONavigatorImpl
890cdf0e10cSrcweir // -----------------------------------------------------------------------------
891cdf0e10cSrcweir class ONavigatorImpl
892cdf0e10cSrcweir {
893cdf0e10cSrcweir     ONavigatorImpl(const ONavigatorImpl&);
894cdf0e10cSrcweir     void operator =(const ONavigatorImpl&);
895cdf0e10cSrcweir public:
896cdf0e10cSrcweir     ONavigatorImpl(OReportController& _rController,ONavigator* _pParent);
897cdf0e10cSrcweir     virtual ~ONavigatorImpl();
898cdf0e10cSrcweir 
899cdf0e10cSrcweir     uno::Reference< report::XReportDefinition>  m_xReport;
900cdf0e10cSrcweir     ::rptui::OReportController&				    m_rController;
901cdf0e10cSrcweir     ::std::auto_ptr<NavigatorTree>              m_pNavigatorTree;
902cdf0e10cSrcweir };
903cdf0e10cSrcweir 
ONavigatorImpl(OReportController & _rController,ONavigator * _pParent)904cdf0e10cSrcweir ONavigatorImpl::ONavigatorImpl(OReportController& _rController,ONavigator* _pParent)
905cdf0e10cSrcweir     :m_xReport(_rController.getReportDefinition())
906cdf0e10cSrcweir     ,m_rController(_rController)
907cdf0e10cSrcweir     ,m_pNavigatorTree(new NavigatorTree(_pParent,_rController))
908cdf0e10cSrcweir {
909cdf0e10cSrcweir     reportdesign::OReportVisitor aVisitor(m_pNavigatorTree.get());
910cdf0e10cSrcweir     aVisitor.start(m_xReport);
911cdf0e10cSrcweir     m_pNavigatorTree->Expand(m_pNavigatorTree->find(m_xReport));
912cdf0e10cSrcweir     lang::EventObject aEvent(m_rController);
913cdf0e10cSrcweir     m_pNavigatorTree->_selectionChanged(aEvent);
914cdf0e10cSrcweir }
915cdf0e10cSrcweir //------------------------------------------------------------------------
~ONavigatorImpl()916cdf0e10cSrcweir ONavigatorImpl::~ONavigatorImpl()
917cdf0e10cSrcweir {
918cdf0e10cSrcweir }
919cdf0e10cSrcweir // -----------------------------------------------------------------------------
920cdf0e10cSrcweir DBG_NAME( rpt_ONavigator )
921cdf0e10cSrcweir const long STD_WIN_SIZE_X = 210;
922cdf0e10cSrcweir const long STD_WIN_SIZE_Y = 280;
923cdf0e10cSrcweir const long LISTBOX_BORDER = 2;
924cdf0e10cSrcweir //========================================================================
925cdf0e10cSrcweir // class ONavigator
926cdf0e10cSrcweir //========================================================================
ONavigator(Window * _pParent,OReportController & _rController)927cdf0e10cSrcweir ONavigator::ONavigator( Window* _pParent
928cdf0e10cSrcweir 						,OReportController& _rController)
929cdf0e10cSrcweir 	: FloatingWindow( _pParent, ModuleRes(RID_NAVIGATOR) )
930cdf0e10cSrcweir {
931cdf0e10cSrcweir 	DBG_CTOR( rpt_ONavigator,NULL);
932cdf0e10cSrcweir 
933cdf0e10cSrcweir     m_pImpl.reset(new ONavigatorImpl(_rController,this));
934cdf0e10cSrcweir 
935cdf0e10cSrcweir 	//Size aSpace = LogicToPixel( Size( 7, 120), MAP_APPFONT );
936cdf0e10cSrcweir 	//Size aOutSize(nMaxTextWidth + m_aHeader.GetSizePixel().Width() + 3*aSpace.Width(),aSpace.Height());
937cdf0e10cSrcweir 	//SetMinOutputSizePixel(aOutSize);
938cdf0e10cSrcweir 	//SetOutputSizePixel(aOutSize);
939cdf0e10cSrcweir     FreeResource();
940cdf0e10cSrcweir     m_pImpl->m_pNavigatorTree->Show();
941cdf0e10cSrcweir     m_pImpl->m_pNavigatorTree->GrabFocus();
942cdf0e10cSrcweir     SetSizePixel(Size(STD_WIN_SIZE_X,STD_WIN_SIZE_Y));
943cdf0e10cSrcweir     Show();
944cdf0e10cSrcweir 
945cdf0e10cSrcweir }
946cdf0e10cSrcweir // -----------------------------------------------------------------------------
947cdf0e10cSrcweir 
948cdf0e10cSrcweir //------------------------------------------------------------------------
~ONavigator()949cdf0e10cSrcweir ONavigator::~ONavigator()
950cdf0e10cSrcweir {
951cdf0e10cSrcweir 	DBG_DTOR( rpt_ONavigator,NULL);
952cdf0e10cSrcweir }
953cdf0e10cSrcweir //------------------------------------------------------------------------------
Resize()954cdf0e10cSrcweir void ONavigator::Resize()
955cdf0e10cSrcweir {
956cdf0e10cSrcweir 	FloatingWindow::Resize();
957cdf0e10cSrcweir 
958cdf0e10cSrcweir 	Point aPos(GetPosPixel());
959cdf0e10cSrcweir 	Size aSize( GetOutputSizePixel() );
960cdf0e10cSrcweir 
961cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
962cdf0e10cSrcweir 
963cdf0e10cSrcweir 	// Groesse der form::ListBox anpassen
964cdf0e10cSrcweir 	Point aLBPos( LISTBOX_BORDER, LISTBOX_BORDER );
965cdf0e10cSrcweir 	Size aLBSize( aSize );
966cdf0e10cSrcweir 	aLBSize.Width() -= (2*LISTBOX_BORDER);
967cdf0e10cSrcweir 	aLBSize.Height() -= (2*LISTBOX_BORDER);
968cdf0e10cSrcweir 
969cdf0e10cSrcweir 	m_pImpl->m_pNavigatorTree->SetPosSizePixel( aLBPos, aLBSize );
970cdf0e10cSrcweir }
971cdf0e10cSrcweir // -----------------------------------------------------------------------------
972cdf0e10cSrcweir // -----------------------------------------------------------------------------
GetFocus()973cdf0e10cSrcweir void ONavigator::GetFocus()
974cdf0e10cSrcweir {
975cdf0e10cSrcweir 	Window::GetFocus();
976cdf0e10cSrcweir 	if ( m_pImpl->m_pNavigatorTree.get() )
977cdf0e10cSrcweir 		m_pImpl->m_pNavigatorTree->GrabFocus();
978cdf0e10cSrcweir }
979cdf0e10cSrcweir // =============================================================================
980cdf0e10cSrcweir } // rptui
981cdf0e10cSrcweir // =============================================================================
982cdf0e10cSrcweir 
983