LCOV - code coverage report
Current view: top level - reportdesign/source/ui/dlg - Navigator.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 460 0.0 %
Date: 2012-08-25 Functions: 0 54 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10