LCOV - code coverage report
Current view: top level - reportdesign/source/ui/report - propbrw.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 253 0.0 %
Date: 2012-08-25 Functions: 0 20 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                 :            : #include "propbrw.hxx"
      29                 :            : #include "RptObject.hxx"
      30                 :            : #include "ReportController.hxx"
      31                 :            : #include <cppuhelper/component_context.hxx>
      32                 :            : #include <RptResId.hrc>
      33                 :            : #include "rptui_slotid.hrc"
      34                 :            : #include <tools/debug.hxx>
      35                 :            : #include <tools/diagnose_ex.h>
      36                 :            : #include <com/sun/star/awt/XLayoutConstrains.hpp>
      37                 :            : #include <com/sun/star/inspection/ObjectInspector.hpp>
      38                 :            : #include <com/sun/star/inspection/DefaultHelpProvider.hpp>
      39                 :            : #include <svx/svxids.hrc>
      40                 :            : #include <vcl/stdtext.hxx>
      41                 :            : #include <svx/svdview.hxx>
      42                 :            : #include <svx/svdogrp.hxx>
      43                 :            : #include <svx/svdpage.hxx>
      44                 :            : #include <svx/svditer.hxx>
      45                 :            : 
      46                 :            : #include <toolkit/unohlp.hxx>
      47                 :            : #include <comphelper/property.hxx>
      48                 :            : #include <comphelper/namecontainer.hxx>
      49                 :            : #include <comphelper/stl_types.hxx>
      50                 :            : #include <comphelper/types.hxx>
      51                 :            : #include <comphelper/sequence.hxx>
      52                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      53                 :            : #include <com/sun/star/awt/PosSize.hpp>
      54                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      55                 :            : #include <com/sun/star/report/inspection/DefaultComponentInspectorModel.hpp>
      56                 :            : #include <comphelper/processfactory.hxx>
      57                 :            : #include "SectionView.hxx"
      58                 :            : #include "ReportSection.hxx"
      59                 :            : #include "uistrings.hrc"
      60                 :            : #include "DesignView.hxx"
      61                 :            : #include "ViewsWindow.hxx"
      62                 :            : #include "UITools.hxx"
      63                 :            : #include <unotools/confignode.hxx>
      64                 :            : 
      65                 :            : namespace rptui
      66                 :            : {
      67                 :            : #define STD_WIN_SIZE_X  300
      68                 :            : #define STD_WIN_SIZE_Y  350
      69                 :            : 
      70                 :            : using namespace ::com::sun::star;
      71                 :            : using namespace uno;
      72                 :            : using namespace lang;
      73                 :            : using namespace frame;
      74                 :            : using namespace beans;
      75                 :            : using namespace container;
      76                 :            : using namespace ::comphelper;
      77                 :            : 
      78                 :            : //----------------------------------------------------------------------------
      79                 :            : //-----------------------------------------------------------------------
      80                 :            : namespace
      81                 :            : {
      82                 :          0 :     static bool lcl_shouldEnableHelpSection( const Reference< XMultiServiceFactory >& _rxFactory )
      83                 :            :     {
      84                 :          0 :         const ::rtl::OUString sConfigName( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.ReportDesign/PropertyBrowser/" ) );
      85                 :          0 :         const ::rtl::OUString sPropertyName( RTL_CONSTASCII_USTRINGPARAM( "DirectHelp" ) );
      86                 :            : 
      87                 :            :         ::utl::OConfigurationTreeRoot aConfiguration(
      88                 :          0 :             ::utl::OConfigurationTreeRoot::createWithServiceFactory( _rxFactory, sConfigName ) );
      89                 :            : 
      90                 :          0 :         bool bEnabled = false;
      91                 :          0 :         OSL_VERIFY( aConfiguration.getNodeValue( sPropertyName ) >>= bEnabled );
      92                 :          0 :         return bEnabled;
      93                 :            :     }
      94                 :            : }
      95                 :            : //-----------------------------------------------------------------------
      96                 :            : //============================================================================
      97                 :            : // PropBrw
      98                 :            : //============================================================================
      99                 :            : 
     100                 :            : DBG_NAME( rpt_PropBrw )
     101                 :            : 
     102                 :            : //----------------------------------------------------------------------------
     103                 :            : 
     104                 :          0 : PropBrw::PropBrw(const Reference< XMultiServiceFactory >&   _xORB,Window* pParent,ODesignView*  _pDesignView)
     105                 :            :           :DockingWindow(pParent,WinBits(WB_STDMODELESS|WB_SIZEABLE|WB_3DLOOK|WB_ROLLABLE))
     106                 :            :           ,m_xORB(_xORB)
     107                 :            :           ,m_pDesignView(_pDesignView)
     108                 :            :           ,m_pView( NULL )
     109                 :          0 :           ,m_bInitialStateChange(sal_True)
     110                 :            : {
     111                 :            :     DBG_CTOR( rpt_PropBrw,NULL);
     112                 :            : 
     113                 :          0 :     Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y);
     114                 :          0 :     SetOutputSizePixel(aPropWinSize);
     115                 :            : 
     116                 :            :     try
     117                 :            :     {
     118                 :            :         // create a frame wrapper for myself
     119                 :          0 :         m_xMeAsFrame = Reference< XFrame >(m_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Frame"))), UNO_QUERY);
     120                 :          0 :         if (m_xMeAsFrame.is())
     121                 :            :         {
     122                 :          0 :             m_xMeAsFrame->initialize( VCLUnoHelper::GetInterface ( this ) );
     123                 :          0 :             m_xMeAsFrame->setName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("report property browser")));  // change name!
     124                 :            :         }
     125                 :            :     }
     126                 :          0 :     catch (Exception&)
     127                 :            :     {
     128                 :            :         OSL_FAIL("PropBrw::PropBrw: could not create/initialize my frame!");
     129                 :            :         DBG_UNHANDLED_EXCEPTION();
     130                 :          0 :         m_xMeAsFrame.clear();
     131                 :            :     }
     132                 :            : 
     133                 :          0 :     if (m_xMeAsFrame.is())
     134                 :            :     {
     135                 :          0 :         Reference< XComponentContext > xOwnContext;
     136                 :            :         try
     137                 :            :         {
     138                 :            :             // our own component context
     139                 :          0 :             Reference< XPropertySet > xFactoryProperties( m_xORB, UNO_QUERY_THROW );
     140                 :            :             xOwnContext.set(
     141                 :          0 :                 xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
     142                 :          0 :                 UNO_QUERY_THROW );
     143                 :            : 
     144                 :            :             // a ComponentContext for the
     145                 :            :             ::cppu::ContextEntry_Init aHandlerContextInfo[] =
     146                 :            :             {
     147                 :          0 :                 ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ), makeAny( m_pDesignView->getController().getModel() )),
     148                 :            :                 ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ), makeAny( VCLUnoHelper::GetInterface ( this ) )),
     149                 :          0 :                 ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) ), makeAny( m_pDesignView->getController().getConnection() ) ),
     150                 :          0 :             };
     151                 :            :             m_xInspectorContext.set(
     152                 :            :                 ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ),
     153                 :          0 :                 xOwnContext ) );
     154                 :            :             // create a property browser controller
     155                 :          0 :             bool bEnableHelpSection = lcl_shouldEnableHelpSection( m_xORB );
     156                 :            :             Reference< inspection::XObjectInspectorModel> xInspectorModel( bEnableHelpSection
     157                 :            :                 ?   report::inspection::DefaultComponentInspectorModel::createWithHelpSection( m_xInspectorContext, 3, 8 )
     158                 :          0 :                 :   report::inspection::DefaultComponentInspectorModel::createDefault( m_xInspectorContext ) );
     159                 :            : 
     160                 :          0 :             m_xBrowserController = inspection::ObjectInspector::createWithModel(m_xInspectorContext, xInspectorModel);
     161                 :          0 :             if ( !m_xBrowserController.is() )
     162                 :            :             {
     163                 :          0 :                 const ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.ObjectInspector" ) );
     164                 :          0 :                 ShowServiceNotAvailableError(pParent, sServiceName, sal_True);
     165                 :            :             }
     166                 :            :             else
     167                 :            :             {
     168                 :          0 :                 m_xBrowserController->attachFrame(m_xMeAsFrame);
     169                 :          0 :                 m_xBrowserComponentWindow = m_xMeAsFrame->getComponentWindow();
     170                 :            :                 OSL_ENSURE(m_xBrowserComponentWindow.is(), "PropBrw::PropBrw: attached the controller, but have no component window!");
     171                 :          0 :                 if ( bEnableHelpSection )
     172                 :            :                 {
     173                 :          0 :                     uno::Reference< inspection::XObjectInspector > xInspector( m_xBrowserController, uno::UNO_QUERY_THROW );
     174                 :          0 :                     uno::Reference< inspection::XObjectInspectorUI > xInspectorUI( xInspector->getInspectorUI() );
     175                 :          0 :                     uno::Reference< uno::XInterface > xDefaultHelpProvider( inspection::DefaultHelpProvider::create( m_xInspectorContext, xInspectorUI ) );
     176                 :            :                 }
     177                 :          0 :             }
     178                 :            :         }
     179                 :          0 :         catch (Exception&)
     180                 :            :         {
     181                 :            :             OSL_FAIL("PropBrw::PropBrw: could not create/initialize the browser controller!");
     182                 :            :             DBG_UNHANDLED_EXCEPTION();
     183                 :            :             try
     184                 :            :             {
     185                 :          0 :                 ::comphelper::disposeComponent(m_xBrowserController);
     186                 :          0 :                 ::comphelper::disposeComponent(m_xBrowserComponentWindow);
     187                 :            :             }
     188                 :          0 :             catch(Exception&) { }
     189                 :          0 :             m_xBrowserController.clear();
     190                 :          0 :             m_xBrowserComponentWindow.clear();
     191                 :          0 :         }
     192                 :            :     }
     193                 :            : 
     194                 :          0 :     if (m_xBrowserComponentWindow.is())
     195                 :            :     {
     196                 :            : 
     197                 :          0 :         m_xBrowserComponentWindow->setPosSize(0, 0, aPropWinSize.Width(), aPropWinSize.Height(),
     198                 :          0 :             awt::PosSize::WIDTH | awt::PosSize::HEIGHT | awt::PosSize::X | awt::PosSize::Y);
     199                 :          0 :         Resize();
     200                 :          0 :         m_xBrowserComponentWindow->setVisible(sal_True);
     201                 :            :     }
     202                 :          0 :     ::rptui::notifySystemWindow(pParent,this,::comphelper::mem_fun(&TaskPaneList::AddWindow));
     203                 :          0 : }
     204                 :            : 
     205                 :            : //----------------------------------------------------------------------------
     206                 :            : 
     207                 :          0 : PropBrw::~PropBrw()
     208                 :            : {
     209                 :          0 :     if (m_xBrowserController.is())
     210                 :          0 :         implDetachController();
     211                 :            : 
     212                 :            :     try
     213                 :            :     {
     214                 :          0 :         uno::Reference<container::XNameContainer> xName(m_xInspectorContext,uno::UNO_QUERY);
     215                 :          0 :         if ( xName.is() )
     216                 :            :         {
     217                 :            :             const ::rtl::OUString pProps[] = { ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) )
     218                 :            :                                             ,  ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) )
     219                 :          0 :                                             , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) )};
     220                 :          0 :             for (size_t i = 0; i < sizeof(pProps)/sizeof(pProps[0]); ++i)
     221                 :          0 :                 xName->removeByName(pProps[i]);
     222                 :          0 :         }
     223                 :            :     }
     224                 :          0 :     catch(Exception&)
     225                 :            :     {}
     226                 :            : 
     227                 :          0 :     ::rptui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
     228                 :            : 
     229                 :            :     DBG_DTOR( rpt_PropBrw,NULL);
     230                 :          0 : }
     231                 :            : // -----------------------------------------------------------------------------
     232                 :          0 : void PropBrw::setCurrentPage(const ::rtl::OUString& _sLastActivePage)
     233                 :            : {
     234                 :          0 :     m_sLastActivePage = _sLastActivePage;
     235                 :          0 : }
     236                 :            : //----------------------------------------------------------------------------
     237                 :            : 
     238                 :          0 : void PropBrw::implDetachController()
     239                 :            : {
     240                 :          0 :     m_sLastActivePage = getCurrentPage();
     241                 :          0 :     implSetNewObject(  );
     242                 :            : 
     243                 :          0 :     if ( m_xMeAsFrame.is() )
     244                 :          0 :         m_xMeAsFrame->setComponent( NULL, NULL );
     245                 :            : 
     246                 :          0 :     if ( m_xBrowserController.is() )
     247                 :          0 :         m_xBrowserController->attachFrame( NULL );
     248                 :            : 
     249                 :          0 :     m_xMeAsFrame.clear();
     250                 :          0 :     m_xBrowserController.clear();
     251                 :          0 :     m_xBrowserComponentWindow.clear();
     252                 :          0 : }
     253                 :            : //-----------------------------------------------------------------------
     254                 :          0 : ::rtl::OUString PropBrw::getCurrentPage() const
     255                 :            : {
     256                 :          0 :     ::rtl::OUString sCurrentPage;
     257                 :            :     try
     258                 :            :     {
     259                 :          0 :         if ( m_xBrowserController.is() )
     260                 :            :         {
     261                 :          0 :             OSL_VERIFY( m_xBrowserController->getViewData() >>= sCurrentPage );
     262                 :            :         }
     263                 :            : 
     264                 :          0 :         if ( sCurrentPage.isEmpty() )
     265                 :          0 :             sCurrentPage = m_sLastActivePage;
     266                 :            :     }
     267                 :          0 :     catch( const Exception& )
     268                 :            :     {
     269                 :            :         OSL_FAIL( "PropBrw::getCurrentPage: caught an exception while retrieving the current page!" );
     270                 :            :     }
     271                 :          0 :     return sCurrentPage;
     272                 :            : }
     273                 :            : //----------------------------------------------------------------------------
     274                 :            : 
     275                 :          0 : sal_Bool PropBrw::Close()
     276                 :            : {
     277                 :          0 :     m_xLastSection.clear();
     278                 :            :     // suspend the controller (it is allowed to veto)
     279                 :          0 :     if ( m_xMeAsFrame.is() )
     280                 :            :     {
     281                 :            :         try
     282                 :            :         {
     283                 :          0 :             Reference< XController > xController( m_xMeAsFrame->getController() );
     284                 :          0 :             if ( xController.is() && !xController->suspend( sal_True ) )
     285                 :          0 :                 return sal_False;
     286                 :            :         }
     287                 :          0 :         catch( const Exception& )
     288                 :            :         {
     289                 :            :             OSL_FAIL( "FmPropBrw::Close: caught an exception while asking the controller!" );
     290                 :            :         }
     291                 :            :     }
     292                 :          0 :     implDetachController();
     293                 :            : 
     294                 :          0 :     if( IsRollUp() )
     295                 :          0 :         RollDown();
     296                 :            : 
     297                 :          0 :     m_pDesignView->getController().executeUnChecked(SID_PROPERTYBROWSER_LAST_PAGE,uno::Sequence< beans::PropertyValue>());
     298                 :            : 
     299                 :          0 :     return sal_True;
     300                 :            : }
     301                 :            : 
     302                 :            : //----------------------------------------------------------------------------
     303                 :            : 
     304                 :          0 : uno::Sequence< Reference<uno::XInterface> > PropBrw::CreateCompPropSet(const SdrMarkList& _rMarkList)
     305                 :            : {
     306                 :          0 :     sal_uInt32 nMarkCount = _rMarkList.GetMarkCount();
     307                 :          0 :     ::std::vector< uno::Reference< uno::XInterface> > aSets;
     308                 :          0 :     aSets.reserve(nMarkCount);
     309                 :            : 
     310                 :          0 :     for(sal_uInt32 i=0;i<nMarkCount;++i)
     311                 :            :     {
     312                 :          0 :         SdrObject* pCurrent = _rMarkList.GetMark(i)->GetMarkedSdrObj();
     313                 :            : 
     314                 :          0 :         ::std::auto_ptr<SdrObjListIter> pGroupIterator;
     315                 :          0 :         if (pCurrent->IsGroupObject())
     316                 :            :         {
     317                 :          0 :             pGroupIterator.reset(new SdrObjListIter(*pCurrent->GetSubList()));
     318                 :          0 :             pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
     319                 :            :         }
     320                 :            : 
     321                 :          0 :         while (pCurrent)
     322                 :            :         {
     323                 :          0 :             OObjectBase* pObj = dynamic_cast<OObjectBase*>(pCurrent);
     324                 :          0 :             if ( pObj )
     325                 :          0 :                 aSets.push_back(CreateComponentPair(pObj));
     326                 :            : 
     327                 :            :             // next element
     328                 :          0 :             pCurrent = pGroupIterator.get() && pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
     329                 :            :         }
     330                 :          0 :     }
     331                 :          0 :     Reference<uno::XInterface> *pSets = aSets.empty() ? NULL : &aSets[0];
     332                 :          0 :     return uno::Sequence< Reference<uno::XInterface> >(pSets, aSets.size());
     333                 :            : }
     334                 :            : //----------------------------------------------------------------------------
     335                 :          0 : void PropBrw::implSetNewObject( const uno::Sequence< Reference<uno::XInterface> >& _aObjects )
     336                 :            : {
     337                 :          0 :     if ( m_xBrowserController.is() )
     338                 :            :     {
     339                 :            :         try
     340                 :            :         {
     341                 :          0 :             m_xBrowserController->inspect(uno::Sequence< Reference<uno::XInterface> >());
     342                 :          0 :             m_xBrowserController->inspect(_aObjects);
     343                 :            :         }
     344                 :          0 :         catch( const Exception& )
     345                 :            :         {
     346                 :            :             OSL_FAIL( "FmPropBrw::StateChanged: caught an exception while setting the initial page!" );
     347                 :            :         }
     348                 :            :     }
     349                 :          0 :     SetText( GetHeadlineName(_aObjects) );
     350                 :          0 : }
     351                 :            : 
     352                 :            : //----------------------------------------------------------------------------
     353                 :            : 
     354                 :          0 : ::rtl::OUString PropBrw::GetHeadlineName( const uno::Sequence< Reference<uno::XInterface> >& _aObjects )
     355                 :            : {
     356                 :          0 :     ::rtl::OUString aName;
     357                 :          0 :     if ( !_aObjects.getLength() )
     358                 :            :     {
     359                 :          0 :         aName = String(ModuleRes(RID_STR_BRWTITLE_NO_PROPERTIES));
     360                 :            :     }
     361                 :          0 :     else if ( _aObjects.getLength() == 1 )    // single selection
     362                 :            :     {
     363                 :          0 :         aName = String(ModuleRes(RID_STR_BRWTITLE_PROPERTIES));
     364                 :            : 
     365                 :          0 :         uno::Reference< container::XNameContainer > xNameCont(_aObjects[0],uno::UNO_QUERY);
     366                 :          0 :         Reference< lang::XServiceInfo > xServiceInfo( xNameCont->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReportComponent"))), UNO_QUERY );
     367                 :          0 :         if ( xServiceInfo.is() )
     368                 :            :         {
     369                 :          0 :             sal_uInt16 nResId = 0;
     370                 :          0 :             if ( xServiceInfo->supportsService( SERVICE_FIXEDTEXT ) )
     371                 :            :             {
     372                 :          0 :                 nResId = RID_STR_PROPTITLE_FIXEDTEXT;
     373                 :            :             }
     374                 :          0 :             else if ( xServiceInfo->supportsService( SERVICE_IMAGECONTROL ) )
     375                 :            :             {
     376                 :          0 :                 nResId = RID_STR_PROPTITLE_IMAGECONTROL;
     377                 :            :             }
     378                 :          0 :             else if ( xServiceInfo->supportsService( SERVICE_FORMATTEDFIELD ) )
     379                 :            :             {
     380                 :          0 :                 nResId = RID_STR_PROPTITLE_FORMATTED;
     381                 :            :             }
     382                 :          0 :             else if ( xServiceInfo->supportsService( SERVICE_SHAPE ) )
     383                 :            :             {
     384                 :          0 :                 nResId = RID_STR_PROPTITLE_SHAPE;
     385                 :            :             }
     386                 :          0 :             else if ( xServiceInfo->supportsService( SERVICE_REPORTDEFINITION ) )
     387                 :            :             {
     388                 :          0 :                 nResId = RID_STR_PROPTITLE_REPORT;
     389                 :            :             }
     390                 :          0 :             else if ( xServiceInfo->supportsService( SERVICE_SECTION ) )
     391                 :            :             {
     392                 :          0 :                 nResId = RID_STR_PROPTITLE_SECTION;
     393                 :            :             }
     394                 :          0 :             else if ( xServiceInfo->supportsService( SERVICE_FUNCTION ) )
     395                 :            :             {
     396                 :          0 :                 nResId = RID_STR_PROPTITLE_FUNCTION;
     397                 :            :             }
     398                 :          0 :             else if ( xServiceInfo->supportsService( SERVICE_GROUP ) )
     399                 :            :             {
     400                 :          0 :                 nResId = RID_STR_PROPTITLE_GROUP;
     401                 :            :             }
     402                 :          0 :             else if ( xServiceInfo->supportsService( SERVICE_FIXEDLINE ) )
     403                 :            :             {
     404                 :          0 :                 nResId = RID_STR_PROPTITLE_FIXEDLINE;
     405                 :            :             }
     406                 :            :             else
     407                 :            :             {
     408                 :            :                 OSL_FAIL("Unknown service name!");
     409                 :          0 :                 nResId = RID_STR_CLASS_FORMATTEDFIELD;
     410                 :            :             }
     411                 :            : 
     412                 :          0 :             if (nResId)
     413                 :            :             {
     414                 :          0 :                 aName += String(ModuleRes(nResId));
     415                 :            :             }
     416                 :          0 :         }
     417                 :            :     }
     418                 :            :     else    // multiselection
     419                 :            :     {
     420                 :          0 :         aName = String(ModuleRes(RID_STR_BRWTITLE_PROPERTIES));
     421                 :          0 :         aName += String(ModuleRes(RID_STR_BRWTITLE_MULTISELECT));
     422                 :            :     }
     423                 :            : 
     424                 :          0 :     return aName;
     425                 :            : }
     426                 :            : // -----------------------------------------------------------------------------
     427                 :          0 : uno::Reference< uno::XInterface> PropBrw::CreateComponentPair(OObjectBase* _pObj)
     428                 :            : {
     429                 :          0 :     _pObj->initializeOle();
     430                 :          0 :     return CreateComponentPair(_pObj->getAwtComponent(),_pObj->getReportComponent());
     431                 :            : }
     432                 :            : //----------------------------------------------------------------------------
     433                 :          0 : uno::Reference< uno::XInterface> PropBrw::CreateComponentPair(const uno::Reference< uno::XInterface>& _xFormComponent
     434                 :            :                                                               ,const uno::Reference< uno::XInterface>& _xReportComponent)
     435                 :            : {
     436                 :          0 :     uno::Reference< container::XNameContainer > xNameCont = ::comphelper::NameContainer_createInstance(::getCppuType(static_cast<Reference<XInterface> * >(NULL)));
     437                 :          0 :     xNameCont->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FormComponent")),uno::makeAny(_xFormComponent));
     438                 :          0 :     xNameCont->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReportComponent")),uno::makeAny(_xReportComponent));
     439                 :          0 :     xNameCont->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RowSet"))
     440                 :          0 :             ,uno::makeAny(uno::Reference< uno::XInterface>(m_pDesignView->getController().getRowSet())));
     441                 :            : 
     442                 :          0 :     return xNameCont.get();
     443                 :            : }
     444                 :            : // -----------------------------------------------------------------------------
     445                 :          0 : ::Size PropBrw::getMinimumSize() const
     446                 :            : {
     447                 :          0 :     ::Size aSize;
     448                 :          0 :     Reference< awt::XLayoutConstrains > xLayoutConstrains( m_xBrowserController, UNO_QUERY );
     449                 :          0 :     if( xLayoutConstrains.is() )
     450                 :            :     {
     451                 :          0 :         awt::Size aMinSize = xLayoutConstrains->getMinimumSize();
     452                 :          0 :         aMinSize.Height += 4;
     453                 :          0 :         aMinSize.Width += 4;
     454                 :          0 :         aSize.setHeight( aMinSize.Height );
     455                 :          0 :         aSize.setWidth( aMinSize.Width );
     456                 :            :     }
     457                 :          0 :     return aSize;
     458                 :            : }
     459                 :            : //----------------------------------------------------------------------------
     460                 :          0 : void PropBrw::Resize()
     461                 :            : {
     462                 :          0 :     Window::Resize();
     463                 :            : 
     464                 :          0 :     Reference< awt::XLayoutConstrains > xLayoutConstrains( m_xBrowserController, UNO_QUERY );
     465                 :          0 :     if( xLayoutConstrains.is() )
     466                 :            :     {
     467                 :          0 :         ::Size aMinSize = getMinimumSize();
     468                 :          0 :         SetMinOutputSizePixel( aMinSize );
     469                 :          0 :         ::Size aSize = GetOutputSizePixel();
     470                 :          0 :         sal_Bool bResize = sal_False;
     471                 :          0 :         if( aSize.Width() < aMinSize.Width() )
     472                 :            :         {
     473                 :          0 :             aSize.setWidth( aMinSize.Width() );
     474                 :          0 :             bResize = sal_True;
     475                 :            :         }
     476                 :          0 :         if( aSize.Height() < aMinSize.Height() )
     477                 :            :         {
     478                 :          0 :             aSize.setHeight( aMinSize.Height() );
     479                 :          0 :             bResize = sal_True;
     480                 :            :         }
     481                 :          0 :         if( bResize )
     482                 :          0 :             SetOutputSizePixel( aSize );
     483                 :            :     }
     484                 :            :     // adjust size
     485                 :          0 :     if (m_xBrowserComponentWindow.is())
     486                 :            :     {
     487                 :          0 :            Size  aSize = GetOutputSizePixel();
     488                 :          0 :         m_xBrowserComponentWindow->setPosSize(0, 0, aSize.Width(), aSize.Height(),
     489                 :          0 :             awt::PosSize::WIDTH | awt::PosSize::HEIGHT);
     490                 :          0 :     }
     491                 :          0 : }
     492                 :            : //----------------------------------------------------------------------------
     493                 :          0 : void PropBrw::Update( OSectionView* pNewView )
     494                 :            : {
     495                 :            :     try
     496                 :            :     {
     497                 :          0 :         if ( m_pView )
     498                 :            :         {
     499                 :          0 :             EndListening( *(m_pView->GetModel()) );
     500                 :          0 :             m_pView = NULL;
     501                 :            :         }
     502                 :            : 
     503                 :            :         // set focus on initialization
     504                 :          0 :         if ( m_bInitialStateChange )
     505                 :            :         {
     506                 :            :             // if we're just newly created, we want to have the focus
     507                 :          0 :             PostUserEvent( LINK( this, PropBrw, OnAsyncGetFocus ) );
     508                 :          0 :             m_bInitialStateChange = sal_False;
     509                 :            :             // and additionally, we want to show the page which was active during
     510                 :            :             // our previous incarnation
     511                 :          0 :             if ( !m_sLastActivePage.isEmpty() && m_xBrowserController.is() )
     512                 :            :             {
     513                 :            :                 try
     514                 :            :                 {
     515                 :          0 :                     m_xBrowserController->restoreViewData( makeAny( m_sLastActivePage ) );
     516                 :            :                 }
     517                 :          0 :                 catch( const Exception& )
     518                 :            :                 {
     519                 :            :                     OSL_FAIL( "FmPropBrw::StateChanged: caught an exception while setting the initial page!" );
     520                 :            :                 }
     521                 :            :             }
     522                 :            :         }
     523                 :            : 
     524                 :          0 :         if ( !pNewView )
     525                 :          0 :             return;
     526                 :            :         else
     527                 :          0 :             m_pView = pNewView;
     528                 :            : 
     529                 :          0 :         uno::Sequence< Reference<uno::XInterface> > aMarkedObjects;
     530                 :          0 :         OViewsWindow* pViews = m_pView->getReportSection()->getSectionWindow()->getViewsWindow();
     531                 :          0 :         const sal_uInt16 nSectionCount = pViews->getSectionCount();
     532                 :          0 :         for (sal_uInt16 i = 0; i < nSectionCount; ++i)
     533                 :            :         {
     534                 :          0 :             ::boost::shared_ptr<OSectionWindow> pSectionWindow = pViews->getSectionWindow(i);
     535                 :          0 :             if ( pSectionWindow )
     536                 :            :             {
     537                 :          0 :                 const SdrMarkList& rMarkList = pSectionWindow->getReportSection().getSectionView().GetMarkedObjectList();
     538                 :          0 :                 aMarkedObjects = ::comphelper::concatSequences(aMarkedObjects,CreateCompPropSet( rMarkList ));
     539                 :            :             }
     540                 :          0 :         }
     541                 :            : 
     542                 :          0 :         if ( aMarkedObjects.getLength() ) // multiple selection
     543                 :            :         {
     544                 :          0 :             m_xLastSection.clear();
     545                 :          0 :             implSetNewObject( aMarkedObjects );
     546                 :            :         }
     547                 :          0 :         else if ( m_xLastSection != m_pView->getReportSection()->getSection() )
     548                 :            :         {
     549                 :          0 :             uno::Reference< uno::XInterface> xTemp(m_pView->getReportSection()->getSection());
     550                 :          0 :             m_xLastSection = xTemp;
     551                 :          0 :             uno::Reference< container::XNameContainer > xNameCont = ::comphelper::NameContainer_createInstance(::getCppuType(static_cast<Reference<XInterface> * >(NULL)));
     552                 :          0 :             xNameCont->insertByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReportComponent")),uno::makeAny(xTemp));
     553                 :          0 :             xTemp = xNameCont;
     554                 :            : 
     555                 :          0 :             implSetNewObject( uno::Sequence< uno::Reference< uno::XInterface> >(&xTemp,1) );
     556                 :            :         }
     557                 :            : 
     558                 :          0 :         StartListening( *(m_pView->GetModel()) );
     559                 :            :     }
     560                 :          0 :     catch ( Exception& )
     561                 :            :     {
     562                 :            :         OSL_FAIL( "PropBrw::Update: Exception occurred!" );
     563                 :            :     }
     564                 :            : }
     565                 :            : //----------------------------------------------------------------------------
     566                 :          0 : void PropBrw::Update( const uno::Reference< uno::XInterface>& _xReportComponent)
     567                 :            : {
     568                 :          0 :     if ( m_xLastSection != _xReportComponent )
     569                 :            :     {
     570                 :          0 :         m_xLastSection = _xReportComponent;
     571                 :            :         try
     572                 :            :         {
     573                 :          0 :             if ( m_pView )
     574                 :            :             {
     575                 :          0 :                 EndListening( *(m_pView->GetModel()) );
     576                 :          0 :                 m_pView = NULL;
     577                 :            :             }
     578                 :            : 
     579                 :          0 :             uno::Reference< uno::XInterface> xTemp(CreateComponentPair(_xReportComponent,_xReportComponent));
     580                 :          0 :             implSetNewObject( uno::Sequence< uno::Reference< uno::XInterface> >(&xTemp,1) );
     581                 :            :         }
     582                 :          0 :         catch ( Exception& )
     583                 :            :         {
     584                 :            :             OSL_FAIL( "PropBrw::Update: Exception occurred!" );
     585                 :            :         }
     586                 :            :     }
     587                 :          0 : }
     588                 :            : //-----------------------------------------------------------------------
     589                 :          0 : IMPL_LINK( PropBrw, OnAsyncGetFocus, void*,  )
     590                 :            : {
     591                 :          0 :     if (m_xBrowserComponentWindow.is())
     592                 :          0 :         m_xBrowserComponentWindow->setFocus();
     593                 :          0 :     return 0L;
     594                 :            : }
     595                 :            : //----------------------------------------------------------------------------
     596                 :          0 : void PropBrw::LoseFocus()
     597                 :            : {
     598                 :          0 :     DockingWindow::LoseFocus();
     599                 :          0 :     m_pDesignView->getController().InvalidateAll();
     600                 :          0 : }
     601                 :            : //----------------------------------------------------------------------------
     602                 :            : }
     603                 :            : 
     604                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10