LCOV - code coverage report
Current view: top level - svx/source/form - fmPropBrw.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 269 0.4 %
Date: 2012-08-25 Functions: 1 21 4.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 631 0.2 %

           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                 :            : 
      30                 :            : #include <sal/macros.h>
      31                 :            : 
      32                 :            : #include "fmhelp.hrc"
      33                 :            : #include "fmprop.hrc"
      34                 :            : #include "fmPropBrw.hxx"
      35                 :            : #include "svx/fmresids.hrc"
      36                 :            : #include "fmservs.hxx"
      37                 :            : #include "fmshimp.hxx"
      38                 :            : #include "fmpgeimp.hxx"
      39                 :            : 
      40                 :            : #include "svx/dialmgr.hxx"
      41                 :            : #include "svx/fmpage.hxx"
      42                 :            : #include "svx/fmshell.hxx"
      43                 :            : #include "svx/sdrpagewindow.hxx"
      44                 :            : #include "svx/svdpagv.hxx"
      45                 :            : #include "svx/svxids.hrc"
      46                 :            : 
      47                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      48                 :            : #include <com/sun/star/awt/PosSize.hpp>
      49                 :            : #include <com/sun/star/form/XForm.hpp>
      50                 :            : #include <com/sun/star/form/FormComponentType.hpp>
      51                 :            : #include <com/sun/star/awt/XLayoutConstrains.hpp>
      52                 :            : #include <com/sun/star/awt/XControlContainer.hpp>
      53                 :            : #include <com/sun/star/container/XChild.hpp>
      54                 :            : #include <com/sun/star/inspection/ObjectInspector.hpp>
      55                 :            : #include <com/sun/star/inspection/ObjectInspectorModel.hpp>
      56                 :            : #include <com/sun/star/form/inspection/DefaultFormComponentInspectorModel.hpp>
      57                 :            : #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
      58                 :            : #include <com/sun/star/inspection/DefaultHelpProvider.hpp>
      59                 :            : 
      60                 :            : #include <comphelper/processfactory.hxx>
      61                 :            : #include <comphelper/property.hxx>
      62                 :            : #include <cppuhelper/component_context.hxx>
      63                 :            : #include <sfx2/bindings.hxx>
      64                 :            : #include <sfx2/childwin.hxx>
      65                 :            : #include <sfx2/dispatch.hxx>
      66                 :            : #include <sfx2/objitem.hxx>
      67                 :            : #include <sfx2/objsh.hxx>
      68                 :            : #include <sfx2/viewfrm.hxx>
      69                 :            : #include <toolkit/unohlp.hxx>
      70                 :            : #include <tools/debug.hxx>
      71                 :            : #include <tools/diagnose_ex.h>
      72                 :            : #include <tools/shl.hxx>
      73                 :            : #include <unotools/confignode.hxx>
      74                 :            : #include <vcl/stdtext.hxx>
      75                 :            : 
      76                 :            : #include <algorithm>
      77                 :            : 
      78                 :            : using namespace ::com::sun::star;
      79                 :            : using namespace ::com::sun::star::uno;
      80                 :            : using namespace ::com::sun::star::util;
      81                 :            : using namespace ::com::sun::star::inspection;
      82                 :            : using namespace ::com::sun::star::form::inspection;
      83                 :            : using ::com::sun::star::awt::XWindow;
      84                 :            : 
      85                 :            : /*************************************************************************/
      86                 :            : //========================================================================
      87                 :            : //= FmPropBrwMgr
      88                 :            : //========================================================================
      89                 :            : //-----------------------------------------------------------------------
      90 [ #  # ][ +  - ]:        135 : SFX_IMPL_FLOATINGWINDOW(FmPropBrwMgr, SID_FM_SHOW_PROPERTIES)
                 [ #  # ]
      91                 :            : 
      92                 :            : //-----------------------------------------------------------------------
      93                 :          0 : FmPropBrwMgr::FmPropBrwMgr( Window* _pParent, sal_uInt16 _nId,
      94                 :            :                             SfxBindings* _pBindings, SfxChildWinInfo* _pInfo)
      95                 :          0 :               :SfxChildWindow(_pParent, _nId)
      96                 :            : {
      97 [ #  # ][ #  # ]:          0 :     pWindow = new FmPropBrw( ::comphelper::getProcessServiceFactory(), _pBindings, this, _pParent, _pInfo );
                 [ #  # ]
      98                 :          0 :     eChildAlignment = SFX_ALIGN_NOALIGNMENT;
      99         [ #  # ]:          0 :     ((SfxFloatingWindow*)pWindow)->Initialize( _pInfo );
     100                 :          0 : }
     101                 :            : 
     102                 :            : //========================================================================
     103                 :            : //========================================================================
     104                 :            : const long STD_WIN_SIZE_X = 300;
     105                 :            : const long STD_WIN_SIZE_Y = 350;
     106                 :            : 
     107                 :            : const long STD_MIN_SIZE_X = 250;
     108                 :            : const long STD_MIN_SIZE_Y = 250;
     109                 :            : 
     110                 :            : using namespace ::com::sun::star::uno;
     111                 :            : using namespace ::com::sun::star::lang;
     112                 :            : using namespace ::com::sun::star::form;
     113                 :            : using namespace ::com::sun::star::frame;
     114                 :            : using namespace ::com::sun::star::beans;
     115                 :            : using namespace ::com::sun::star::container;
     116                 :            : using namespace ::svxform;
     117                 :            : 
     118                 :          0 : ::rtl::OUString GetUIHeadlineName(sal_Int16 nClassId, const Any& aUnoObj)
     119                 :            : {
     120                 :          0 :     sal_uInt16 nClassNameResourceId = 0;
     121                 :            : 
     122   [ #  #  #  #  :          0 :     switch ( nClassId )
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                #  #  # ]
     123                 :            :     {
     124                 :            :         case FormComponentType::TEXTFIELD:
     125                 :            :         {
     126                 :          0 :             Reference< XInterface >  xIFace;
     127         [ #  # ]:          0 :             aUnoObj >>= xIFace;
     128                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_EDIT;
     129         [ #  # ]:          0 :             if (xIFace.is())
     130                 :            :             {   // we have a chance to check if it's a formatted field model
     131         [ #  # ]:          0 :                 Reference< XServiceInfo >  xInfo(xIFace, UNO_QUERY);
     132 [ #  # ][ #  # ]:          0 :                 if (xInfo.is() && (xInfo->supportsService(FM_SUN_COMPONENT_FORMATTEDFIELD)))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     133                 :          0 :                     nClassNameResourceId = RID_STR_PROPTITLE_FORMATTED;
     134         [ #  # ]:          0 :                 else if (!xInfo.is())
     135                 :            :                 {
     136                 :            :                     // couldn't distinguish between formatted and edit with the service name, so try with the properties
     137         [ #  # ]:          0 :                     Reference< XPropertySet >  xProps(xIFace, UNO_QUERY);
     138         [ #  # ]:          0 :                     if (xProps.is())
     139                 :            :                     {
     140 [ #  # ][ #  # ]:          0 :                         Reference< XPropertySetInfo >  xPropsInfo = xProps->getPropertySetInfo();
     141 [ #  # ][ #  # ]:          0 :                         if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(FM_PROP_FORMATSSUPPLIER))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     142                 :          0 :                             nClassNameResourceId = RID_STR_PROPTITLE_FORMATTED;
     143                 :          0 :                     }
     144                 :          0 :                 }
     145                 :          0 :             }
     146                 :            :         }
     147                 :          0 :         break;
     148                 :            : 
     149                 :            :         case FormComponentType::COMMANDBUTTON:
     150                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_PUSHBUTTON; break;
     151                 :            :         case FormComponentType::RADIOBUTTON:
     152                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_RADIOBUTTON; break;
     153                 :            :         case FormComponentType::CHECKBOX:
     154                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_CHECKBOX; break;
     155                 :            :         case FormComponentType::LISTBOX:
     156                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_LISTBOX; break;
     157                 :            :         case FormComponentType::COMBOBOX:
     158                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_COMBOBOX; break;
     159                 :            :         case FormComponentType::GROUPBOX:
     160                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_GROUPBOX; break;
     161                 :            :         case FormComponentType::IMAGEBUTTON:
     162                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_IMAGEBUTTON; break;
     163                 :            :         case FormComponentType::FIXEDTEXT:
     164                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_FIXEDTEXT; break;
     165                 :            :         case FormComponentType::GRIDCONTROL:
     166                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_DBGRID; break;
     167                 :            :         case FormComponentType::FILECONTROL:
     168                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_FILECONTROL; break;
     169                 :            :         case FormComponentType::DATEFIELD:
     170                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_DATEFIELD; break;
     171                 :            :         case FormComponentType::TIMEFIELD:
     172                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_TIMEFIELD; break;
     173                 :            :         case FormComponentType::NUMERICFIELD:
     174                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_NUMERICFIELD; break;
     175                 :            :         case FormComponentType::CURRENCYFIELD:
     176                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_CURRENCYFIELD; break;
     177                 :            :         case FormComponentType::PATTERNFIELD:
     178                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_PATTERNFIELD; break;
     179                 :            :         case FormComponentType::IMAGECONTROL:
     180                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_IMAGECONTROL; break;
     181                 :            :         case FormComponentType::HIDDENCONTROL:
     182                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_HIDDEN; break;
     183                 :            :         case FormComponentType::SCROLLBAR:
     184                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_SCROLLBAR; break;
     185                 :            :         case FormComponentType::SPINBUTTON:
     186                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_SPINBUTTON; break;
     187                 :            :         case FormComponentType::NAVIGATIONBAR:
     188                 :          0 :             nClassNameResourceId = RID_STR_PROPTITLE_NAVBAR; break;
     189                 :            :         case FormComponentType::CONTROL:
     190                 :            :         default:
     191                 :          0 :             nClassNameResourceId = RID_STR_CONTROL; break;
     192                 :            :     }
     193                 :            : 
     194         [ #  # ]:          0 :     if ( !nClassNameResourceId )
     195                 :          0 :         return ::rtl::OUString();
     196                 :            : 
     197 [ #  # ][ #  # ]:          0 :     return ::rtl::OUString( String( SVX_RES( nClassNameResourceId ) ) );
                 [ #  # ]
     198                 :            : }
     199                 :            : 
     200                 :            : //========================================================================
     201                 :            : // class FmPropBrw
     202                 :            : //========================================================================
     203                 :            : DBG_NAME(FmPropBrw);
     204                 :            : //------------------------------------------------------------------------
     205                 :          0 : FmPropBrw::FmPropBrw( const Reference< XMultiServiceFactory >& _xORB, SfxBindings* _pBindings,
     206                 :            :             SfxChildWindow* _pMgr, Window* _pParent, const SfxChildWinInfo* _pInfo )
     207                 :            :     :SfxFloatingWindow(_pBindings, _pMgr, _pParent, WinBits(WB_STDMODELESS|WB_SIZEABLE|WB_3DLOOK|WB_ROLLABLE) )
     208                 :            :     ,SfxControllerItem(SID_FM_PROPERTY_CONTROL, *_pBindings)
     209                 :            :     ,m_bInitialStateChange(sal_True)
     210                 :            :     ,m_bInStateChange( false )
     211         [ #  # ]:          0 :     ,m_xORB(_xORB)
     212                 :            : {
     213                 :            :     DBG_CTOR(FmPropBrw,NULL);
     214                 :            : 
     215                 :          0 :     ::Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y);
     216         [ #  # ]:          0 :     SetMinOutputSizePixel(::Size(STD_MIN_SIZE_X,STD_MIN_SIZE_Y));
     217         [ #  # ]:          0 :     SetOutputSizePixel(aPropWinSize);
     218         [ #  # ]:          0 :     SetUniqueId(UID_FORMPROPBROWSER_FRAME);
     219                 :            : 
     220                 :            :     try
     221                 :            :     {
     222                 :            :         // create a frame wrapper for myself
     223 [ #  # ][ #  # ]:          0 :         m_xMeAsFrame = Reference< XFrame >(m_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Frame")) ), UNO_QUERY);
         [ #  # ][ #  # ]
                 [ #  # ]
     224         [ #  # ]:          0 :         if (m_xMeAsFrame.is())
     225                 :            :         {
     226                 :            :             // create an intermediate window, which is to be the container window of the frame
     227                 :            :             // Do *not* use |this| as container window for the frame, this would result in undefined
     228                 :            :             // responsiblity for this window (as soon as we initialize a frame with a window, the frame
     229                 :            :             // is responsible for it's life time, but |this| is controlled by the belonging SfxChildWindow)
     230                 :            :             // #i34249#
     231 [ #  # ][ #  # ]:          0 :             Window* pContainerWindow = new Window( this );
     232         [ #  # ]:          0 :             pContainerWindow->Show();
     233 [ #  # ][ #  # ]:          0 :             m_xFrameContainerWindow = VCLUnoHelper::GetInterface ( pContainerWindow );
     234                 :            : 
     235 [ #  # ][ #  # ]:          0 :             m_xMeAsFrame->initialize( m_xFrameContainerWindow );
     236 [ #  # ][ #  # ]:          0 :             m_xMeAsFrame->setName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("form property browser")) );
                 [ #  # ]
     237         [ #  # ]:          0 :             if ( _pBindings->GetDispatcher() )
     238                 :            :             {
     239                 :            :                 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFramesSupplier >
     240 [ #  # ][ #  # ]:          0 :                         xSupp ( _pBindings->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY );
         [ #  # ][ #  # ]
                 [ #  # ]
     241                 :            : //                if ( xSupp.is() )
     242                 :            : //                    xSupp->getFrames()->append( m_xMeAsFrame );
     243                 :            :                 // Don't append frame to frame hierachy to prevent UI_DEACTIVATE messages
     244                 :            :                 // #i31834#
     245                 :            :             }
     246                 :            :         }
     247                 :            :     }
     248         [ #  # ]:          0 :     catch (Exception&)
     249                 :            :     {
     250                 :            :         OSL_FAIL("FmPropBrw::FmPropBrw: could not create/initialize my frame!");
     251                 :          0 :         m_xMeAsFrame.clear();
     252                 :            :     }
     253                 :            : 
     254         [ #  # ]:          0 :     if (m_xMeAsFrame.is())
     255         [ #  # ]:          0 :         _pMgr->SetFrame( m_xMeAsFrame );
     256                 :            : 
     257                 :            : 
     258         [ #  # ]:          0 :     if ( m_xBrowserComponentWindow.is() )
     259 [ #  # ][ #  # ]:          0 :         m_xBrowserComponentWindow->setVisible( sal_True );
     260                 :            : 
     261         [ #  # ]:          0 :     if ( _pInfo )
     262         [ #  # ]:          0 :         m_sLastActivePage = _pInfo->aExtraString;
     263                 :          0 : }
     264                 :            : 
     265                 :            : //------------------------------------------------------------------------
     266                 :          0 : void FmPropBrw::Resize()
     267                 :            : {
     268                 :          0 :     SfxFloatingWindow::Resize();
     269                 :            : 
     270         [ #  # ]:          0 :     if ( m_xFrameContainerWindow.is() )
     271                 :            :     {
     272                 :            :         try
     273                 :            :         {
     274                 :          0 :             ::Size aOutputSize( GetOutputSizePixel() );
     275 [ #  # ][ #  # ]:          0 :             m_xFrameContainerWindow->setPosSize( 0, 0, aOutputSize.Width(), aOutputSize.Height(), awt::PosSize::POSSIZE );
     276                 :            :         }
     277                 :          0 :         catch( const Exception& )
     278                 :            :         {
     279                 :            :             OSL_FAIL( "FmPropBrw::Resize: caught an exception!" );
     280                 :            :         }
     281                 :            :     }
     282         [ #  # ]:          0 : }
     283                 :            : 
     284                 :            : //------------------------------------------------------------------------
     285         [ #  # ]:          0 : FmPropBrw::~FmPropBrw()
     286                 :            : {
     287         [ #  # ]:          0 :     if (m_xBrowserController.is())
     288         [ #  # ]:          0 :         implDetachController();
     289                 :            :     try
     290                 :            :     {
     291                 :            :         // remove our own properties from the component context. We cannot ensure that the component context
     292                 :            :         // is freed (there might be refcount problems :-\), so at least ensure the context itself
     293                 :            :         // does hold the objects anymore
     294         [ #  # ]:          0 :         Reference<XNameContainer> xName(m_xInspectorContext,uno::UNO_QUERY);
     295         [ #  # ]:          0 :         if ( xName.is() )
     296                 :            :         {
     297                 :            :             const ::rtl::OUString pProps[] = { ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) )
     298                 :            :                                              , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) )
     299                 :            :                                              , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlContext" ) )
     300 [ #  # ][ #  # ]:          0 :                                              , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlShapeAccess" ) ) };
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     301         [ #  # ]:          0 :             for ( size_t i = 0; i < sizeof(pProps)/sizeof(pProps[0]); ++i )
     302 [ #  # ][ #  # ]:          0 :                 xName->removeByName( pProps[i] );
         [ #  # ][ #  # ]
     303         [ #  # ]:          0 :         }
     304                 :            :     }
     305         [ #  # ]:          0 :     catch (const Exception& )
     306                 :            :     {
     307                 :            :         DBG_UNHANDLED_EXCEPTION();
     308                 :            :     }
     309                 :            :     DBG_DTOR(FmPropBrw,NULL);
     310         [ #  # ]:          0 : }
     311                 :            : 
     312                 :            : //-----------------------------------------------------------------------
     313                 :          0 : ::rtl::OUString FmPropBrw::getCurrentPage() const
     314                 :            : {
     315                 :          0 :     ::rtl::OUString sCurrentPage;
     316                 :            :     try
     317                 :            :     {
     318         [ #  # ]:          0 :         if ( m_xBrowserController.is() )
     319                 :            :         {
     320 [ #  # ][ #  # ]:          0 :             OSL_VERIFY( m_xBrowserController->getViewData() >>= sCurrentPage );
     321                 :            :         }
     322                 :            : 
     323         [ #  # ]:          0 :         if ( sCurrentPage.isEmpty() )
     324                 :          0 :             sCurrentPage = m_sLastActivePage;
     325                 :            :     }
     326         [ #  # ]:          0 :     catch( const Exception& )
     327                 :            :     {
     328                 :            :         OSL_FAIL( "FmPropBrw::getCurrentPage: caught an exception while retrieving the current page!" );
     329                 :            :     }
     330         [ #  # ]:          0 :     return sCurrentPage;
     331                 :            : }
     332                 :            : 
     333                 :            : //-----------------------------------------------------------------------
     334                 :          0 : void FmPropBrw::implDetachController()
     335                 :            : {
     336                 :          0 :     m_sLastActivePage = getCurrentPage();
     337                 :            : 
     338         [ #  # ]:          0 :     implSetNewSelection( InterfaceBag() );
     339                 :            : 
     340         [ #  # ]:          0 :     if ( m_xMeAsFrame.is() )
     341                 :            :     {
     342                 :            :         try
     343                 :            :         {
     344 [ #  # ][ #  # ]:          0 :             m_xMeAsFrame->setComponent(NULL, NULL);
         [ #  # ][ #  # ]
                 [ #  # ]
     345                 :            :         }
     346                 :          0 :         catch( const Exception& )
     347                 :            :         {
     348                 :            :             OSL_FAIL( "FmPropBrw::implDetachController: caught an exception while resetting the component!" );
     349                 :            :         }
     350                 :            :     }
     351                 :            : 
     352                 :            :     // we attached a frame to the controller manually, so we need to manually tell it that it's detached, too
     353         [ #  # ]:          0 :     if ( m_xBrowserController.is() )
     354         [ #  # ]:          0 :         m_xBrowserController->attachFrame( NULL );
     355                 :            : 
     356                 :          0 :     m_xBrowserController.clear();
     357                 :          0 :     m_xInspectorModel.clear();
     358                 :          0 :     m_xMeAsFrame.clear();
     359                 :          0 : }
     360                 :            : 
     361                 :            : //-----------------------------------------------------------------------
     362                 :          0 : sal_Bool FmPropBrw::Close()
     363                 :            : {
     364                 :            :     // suspend the controller (it is allowed to veto)
     365         [ #  # ]:          0 :     if ( m_xMeAsFrame.is() )
     366                 :            :     {
     367                 :            :         try
     368                 :            :         {
     369 [ #  # ][ #  # ]:          0 :             Reference< XController > xController( m_xMeAsFrame->getController() );
     370 [ #  # ][ #  # ]:          0 :             if ( xController.is() && !xController->suspend( sal_True ) )
         [ #  # ][ #  # ]
                 [ #  # ]
     371 [ #  # ][ #  # ]:          0 :                 return sal_False;
     372                 :            :         }
     373                 :          0 :         catch( const Exception& )
     374                 :            :         {
     375                 :            :             OSL_FAIL( "FmPropBrw::Close: caught an exception while asking the controller!" );
     376                 :            :         }
     377                 :            :     }
     378                 :            : 
     379                 :          0 :     implDetachController();
     380                 :            : 
     381         [ #  # ]:          0 :     if( IsRollUp() )
     382                 :          0 :         RollDown();
     383                 :            : 
     384                 :            :     // remember our bindings: while we're closed, we're deleted, too, so accessing the bindings after this
     385                 :            :     // would be deadly
     386                 :            :     // 10/19/00 - 79321 - FS
     387                 :          0 :     SfxBindings& rBindings = SfxControllerItem::GetBindings();
     388                 :            : 
     389                 :          0 :     sal_Bool bClose = SfxFloatingWindow::Close();
     390                 :            : 
     391         [ #  # ]:          0 :     if (bClose)
     392                 :            :     {
     393                 :          0 :         rBindings.Invalidate(SID_FM_CTL_PROPERTIES);
     394                 :          0 :         rBindings.Invalidate(SID_FM_PROPERTIES);
     395                 :            :     }
     396                 :            : 
     397                 :          0 :     return bClose;
     398                 :            : }
     399                 :            : 
     400                 :            : //-----------------------------------------------------------------------
     401                 :          0 : bool FmPropBrw::implIsReadOnlyModel() const
     402                 :            : {
     403                 :            :     try
     404                 :            :     {
     405         [ #  # ]:          0 :         if ( m_xInspectorModel.is() )
     406 [ #  # ][ #  # ]:          0 :             return m_xInspectorModel->getIsReadOnly();
     407         [ #  # ]:          0 :         return false;
     408                 :            :     }
     409                 :          0 :     catch( const Exception& )
     410                 :            :     {
     411                 :            :         DBG_UNHANDLED_EXCEPTION();
     412                 :            :     }
     413                 :          0 :     return true;
     414                 :            : }
     415                 :            : 
     416                 :            : //-----------------------------------------------------------------------
     417                 :          0 : void FmPropBrw::implSetNewSelection( const InterfaceBag& _rSelection )
     418                 :            : {
     419         [ #  # ]:          0 :     if ( m_xBrowserController.is() )
     420                 :            :     {
     421                 :            :         try
     422                 :            :         {
     423         [ #  # ]:          0 :             Reference< XObjectInspector > xInspector( m_xBrowserController, UNO_QUERY_THROW );
     424                 :            : 
     425                 :            :             // tell it the objects to inspect
     426         [ #  # ]:          0 :             Sequence< Reference< XInterface > > aSelection( _rSelection.size() );
     427 [ #  # ][ #  # ]:          0 :             ::std::copy( _rSelection.begin(), _rSelection.end(), aSelection.getArray() );
     428                 :            : 
     429 [ #  # ][ #  # ]:          0 :             xInspector->inspect( aSelection );
                 [ #  # ]
              [ #  #  # ]
     430                 :            :         }
     431         [ #  # ]:          0 :         catch( const VetoException& )
     432                 :            :         {
     433                 :            :             return;
     434                 :            :         }
     435         [ #  # ]:          0 :         catch( const Exception& )
     436                 :            :         {
     437                 :            :             OSL_FAIL( "FmPropBrw::implSetNewSelection: caught an unexpected exception!" );
     438                 :            :             return;
     439                 :            :         }
     440                 :            : 
     441                 :            :         // set the new title according to the selected object
     442         [ #  # ]:          0 :         String sTitle;
     443                 :            : 
     444         [ #  # ]:          0 :         if ( _rSelection.empty() )
     445                 :            :         {
     446 [ #  # ][ #  # ]:          0 :             sTitle = String( SVX_RES( RID_STR_NO_PROPERTIES ) );
         [ #  # ][ #  # ]
     447                 :            :         }
     448         [ #  # ]:          0 :         else if ( _rSelection.size() > 1 )
     449                 :            :         {
     450                 :            :             // no form component and (no form or no name) -> Multiselection
     451 [ #  # ][ #  # ]:          0 :             sTitle = String( SVX_RES( RID_STR_PROPERTIES_CONTROL ) );
         [ #  # ][ #  # ]
     452 [ #  # ][ #  # ]:          0 :             sTitle += String( SVX_RES( RID_STR_PROPTITLE_MULTISELECT ) );
         [ #  # ][ #  # ]
     453                 :            :         }
     454                 :            :         else
     455                 :            :         {
     456         [ #  # ]:          0 :             Reference< XPropertySet > xSingleSelection( *_rSelection.begin(), UNO_QUERY);
     457 [ #  # ][ #  # ]:          0 :             if  ( ::comphelper::hasProperty( FM_PROP_CLASSID, xSingleSelection ) )
                 [ #  # ]
     458                 :            :             {
     459                 :          0 :                 sal_Int16 nClassID = FormComponentType::CONTROL;
     460 [ #  # ][ #  # ]:          0 :                 xSingleSelection->getPropertyValue( FM_PROP_CLASSID ) >>= nClassID;
                 [ #  # ]
     461                 :            : 
     462 [ #  # ][ #  # ]:          0 :                 sTitle = String( SVX_RES( RID_STR_PROPERTIES_CONTROL ) );
         [ #  # ][ #  # ]
     463 [ #  # ][ #  # ]:          0 :                 sTitle += String( GetUIHeadlineName( nClassID, makeAny( xSingleSelection ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     464                 :            :             }
     465 [ #  # ][ #  # ]:          0 :             else if ( Reference< XForm >( xSingleSelection, UNO_QUERY ).is() )
     466 [ #  # ][ #  # ]:          0 :                 sTitle = String( SVX_RES( RID_STR_PROPERTIES_FORM ) );
         [ #  # ][ #  # ]
     467                 :            :         }
     468                 :            : 
     469 [ #  # ][ #  # ]:          0 :         if ( implIsReadOnlyModel() )
     470 [ #  # ][ #  # ]:          0 :             sTitle += String( SVX_RES( RID_STR_READONLY_VIEW ) );
         [ #  # ][ #  # ]
     471                 :            : 
     472         [ #  # ]:          0 :         SetText( sTitle );
     473                 :            : 
     474                 :            :         // #95343# ---------------------------------
     475         [ #  # ]:          0 :         Reference< ::com::sun::star::awt::XLayoutConstrains > xLayoutConstrains( m_xBrowserController, UNO_QUERY );
     476         [ #  # ]:          0 :         if( xLayoutConstrains.is() )
     477                 :            :         {
     478                 :          0 :             ::Size aConstrainedSize;
     479 [ #  # ][ #  # ]:          0 :             ::com::sun::star::awt::Size aMinSize = xLayoutConstrains->getMinimumSize();
     480                 :            : 
     481                 :          0 :             sal_Int32 nLeft(0), nTop(0), nRight(0), nBottom(0);
     482         [ #  # ]:          0 :             GetBorder( nLeft, nTop, nRight, nBottom );
     483                 :          0 :             aMinSize.Width += nLeft + nRight + 8;
     484                 :          0 :             aMinSize.Height += nTop + nBottom + 8;
     485                 :            : 
     486                 :          0 :             aConstrainedSize.setHeight( aMinSize.Height );
     487                 :          0 :             aConstrainedSize.setWidth( aMinSize.Width );
     488         [ #  # ]:          0 :             SetMinOutputSizePixel( aConstrainedSize );
     489                 :          0 :             aConstrainedSize = GetOutputSizePixel();
     490                 :          0 :             sal_Bool bResize = sal_False;
     491         [ #  # ]:          0 :             if( aConstrainedSize.Width() < aMinSize.Width )
     492                 :            :             {
     493                 :          0 :                 aConstrainedSize.setWidth( aMinSize.Width );
     494                 :          0 :                 bResize = sal_True;
     495                 :            :             }
     496         [ #  # ]:          0 :             if( aConstrainedSize.Height() < aMinSize.Height )
     497                 :            :             {
     498                 :          0 :                 aConstrainedSize.setHeight( aMinSize.Height );
     499                 :          0 :                 bResize = sal_True;
     500                 :            :             }
     501         [ #  # ]:          0 :             if( bResize )
     502         [ #  # ]:          0 :                 SetOutputSizePixel( aConstrainedSize );
     503         [ #  # ]:          0 :         }
     504                 :            :     }
     505                 :            : }
     506                 :            : 
     507                 :            : //-----------------------------------------------------------------------
     508                 :          0 : void FmPropBrw::FillInfo( SfxChildWinInfo& rInfo ) const
     509                 :            : {
     510                 :          0 :     rInfo.bVisible = sal_False;
     511         [ #  # ]:          0 :     rInfo.aExtraString = getCurrentPage();
     512                 :          0 : }
     513                 :            : 
     514                 :            : //-----------------------------------------------------------------------
     515                 :          0 : IMPL_LINK( FmPropBrw, OnAsyncGetFocus, void*, /*NOTINTERESTEDIN*/ )
     516                 :            : {
     517         [ #  # ]:          0 :     if (m_xBrowserComponentWindow.is())
     518                 :          0 :         m_xBrowserComponentWindow->setFocus();
     519                 :          0 :     return 0L;
     520                 :            : }
     521                 :            : 
     522                 :            : //-----------------------------------------------------------------------
     523                 :            : namespace
     524                 :            : {
     525                 :          0 :     static bool lcl_shouldEnableHelpSection( const Reference< XMultiServiceFactory >& _rxFactory )
     526                 :            :     {
     527         [ #  # ]:          0 :         const ::rtl::OUString sConfigName( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common/Forms/PropertyBrowser/" ) );
     528         [ #  # ]:          0 :         const ::rtl::OUString sPropertyName( RTL_CONSTASCII_USTRINGPARAM( "DirectHelp" ) );
     529                 :            : 
     530                 :            :         ::utl::OConfigurationTreeRoot aConfiguration(
     531         [ #  # ]:          0 :             ::utl::OConfigurationTreeRoot::createWithServiceFactory( _rxFactory, sConfigName ) );
     532                 :            : 
     533                 :          0 :         bool bEnabled = false;
     534                 :          0 :         OSL_VERIFY( aConfiguration.getNodeValue( sPropertyName ) >>= bEnabled );
     535         [ #  # ]:          0 :         return bEnabled;
     536                 :            :     }
     537                 :            : }
     538                 :            : //-----------------------------------------------------------------------
     539                 :          0 : void FmPropBrw::impl_createPropertyBrowser_throw( FmFormShell* _pFormShell )
     540                 :            : {
     541                 :            :     // the document in which we live
     542                 :          0 :     Reference< XInterface > xDocument;
     543 [ #  # ][ #  # ]:          0 :     if ( _pFormShell && _pFormShell->GetObjectShell() )
         [ #  # ][ #  # ]
     544 [ #  # ][ #  # ]:          0 :         xDocument = _pFormShell->GetObjectShell()->GetModel();
                 [ #  # ]
     545                 :            : 
     546                 :            :     // the context of the controls in our document
     547                 :          0 :     Reference< awt::XControlContainer > xControlContext;
     548 [ #  # ][ #  # ]:          0 :     if ( _pFormShell && _pFormShell->GetFormView() )
                 [ #  # ]
     549                 :            :     {
     550                 :          0 :         SdrPageView* pPageView = _pFormShell->GetFormView()->GetSdrPageView();
     551                 :            : 
     552         [ #  # ]:          0 :         if(pPageView)
     553                 :            :         {
     554         [ #  # ]:          0 :             SdrPageWindow* pPageWindow = pPageView->GetPageWindow(0L);
     555                 :            : 
     556         [ #  # ]:          0 :             if(pPageWindow)
     557                 :            :             {
     558 [ #  # ][ #  # ]:          0 :                 xControlContext = pPageWindow->GetControlContainer();
     559                 :            :             }
     560                 :            :         }
     561                 :            :     }
     562                 :            : 
     563                 :            :     // the default parent window for message boxes
     564         [ #  # ]:          0 :     Reference< XWindow > xParentWindow( VCLUnoHelper::GetInterface ( this ) );
     565                 :            : 
     566                 :            :     // the mapping from control models to control shapes
     567                 :          0 :     Reference< XMap > xControlMap;
     568 [ #  # ][ #  # ]:          0 :     FmFormPage* pFormPage = _pFormShell ? _pFormShell->GetCurPage() : NULL;
     569         [ #  # ]:          0 :     if ( pFormPage )
     570 [ #  # ][ #  # ]:          0 :         xControlMap = pFormPage->GetImpl().getControlToShapeMap();
     571                 :            : 
     572                 :            :     // our own component context
     573         [ #  # ]:          0 :     Reference< XPropertySet > xFactoryProperties( m_xORB, UNO_QUERY_THROW );
     574                 :            :     Reference< XComponentContext > xOwnContext(
     575         [ #  # ]:          0 :         xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
     576 [ #  # ][ #  # ]:          0 :         UNO_QUERY_THROW );
                 [ #  # ]
     577                 :            : 
     578                 :            :     // a ComponentContext for the
     579                 :            :     ::cppu::ContextEntry_Init aHandlerContextInfo[] =
     580                 :            :     {
     581                 :            :         ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ), makeAny( xDocument ) ),
     582                 :            :         ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ), makeAny( xParentWindow ) ),
     583                 :            :         ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlContext" ) ), makeAny( xControlContext ) ),
     584                 :            :         ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlShapeAccess" ) ), makeAny( xControlMap ) )
     585 [ #  # ][ #  # ]:          0 :     };
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     586                 :            :     m_xInspectorContext.set(
     587                 :            :         ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ),
     588 [ #  # ][ #  # ]:          0 :         xOwnContext ) );
     589                 :            : 
     590         [ #  # ]:          0 :     bool bEnableHelpSection = lcl_shouldEnableHelpSection( m_xORB );
     591                 :            : 
     592                 :            :     // an object inspector model
     593                 :            :     m_xInspectorModel =
     594                 :            :             bEnableHelpSection
     595                 :            :         ?   DefaultFormComponentInspectorModel::createWithHelpSection( m_xInspectorContext, 3, 5 )
     596 [ #  # ][ #  # ]:          0 :         :   DefaultFormComponentInspectorModel::createDefault( m_xInspectorContext );
         [ #  # ][ #  # ]
     597                 :            : 
     598                 :            :     // an object inspector
     599                 :            :     m_xBrowserController = m_xBrowserController.query(
     600                 :            :         ObjectInspector::createWithModel(
     601                 :            :             m_xInspectorContext, m_xInspectorModel
     602 [ #  # ][ #  # ]:          0 :         ) );
                 [ #  # ]
     603                 :            : 
     604         [ #  # ]:          0 :     if ( !m_xBrowserController.is() )
     605                 :            :     {
     606         [ #  # ]:          0 :         ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.ObjectInspector" ) );
     607 [ #  # ][ #  # ]:          0 :         ShowServiceNotAvailableError( GetParent(), sServiceName, sal_True );
         [ #  # ][ #  # ]
     608                 :            :     }
     609                 :            :     else
     610                 :            :     {
     611 [ #  # ][ #  # ]:          0 :         m_xBrowserController->attachFrame( m_xMeAsFrame );
     612 [ #  # ][ #  # ]:          0 :         m_xBrowserComponentWindow = m_xMeAsFrame->getComponentWindow();
                 [ #  # ]
     613                 :            :         DBG_ASSERT( m_xBrowserComponentWindow.is(), "FmPropBrw::impl_createPropertyBrowser_throw: attached the controller, but have no component window!" );
     614                 :            :     }
     615                 :            : 
     616         [ #  # ]:          0 :     if ( bEnableHelpSection )
     617                 :            :     {
     618         [ #  # ]:          0 :         Reference< XObjectInspector > xInspector( m_xBrowserController, UNO_QUERY_THROW );
     619 [ #  # ][ #  # ]:          0 :         Reference< XObjectInspectorUI > xInspectorUI( xInspector->getInspectorUI() );
     620         [ #  # ]:          0 :         Reference< XInterface > xDefaultHelpProvider( DefaultHelpProvider::create( m_xInspectorContext, xInspectorUI ) );
     621 [ #  # ][ #  # ]:          0 :     }
     622                 :          0 : }
     623                 :            : 
     624                 :            : //-----------------------------------------------------------------------
     625                 :          0 : void FmPropBrw::impl_ensurePropertyBrowser_nothrow( FmFormShell* _pFormShell )
     626                 :            : {
     627                 :            :     // the document in which we live
     628                 :          0 :     Reference< XInterface > xDocument;
     629 [ #  # ][ #  # ]:          0 :     SfxObjectShell* pObjectShell = _pFormShell ? _pFormShell->GetObjectShell() : NULL;
     630         [ #  # ]:          0 :     if ( pObjectShell )
     631 [ #  # ][ #  # ]:          0 :         xDocument = pObjectShell->GetModel();
     632 [ #  # ][ #  # ]:          0 :     if ( ( xDocument == m_xLastKnownDocument ) && m_xBrowserController.is() )
         [ #  # ][ #  # ]
     633                 :            :         // nothing to do
     634                 :          0 :         return;
     635                 :            : 
     636                 :            :     try
     637                 :            :     {
     638                 :            :         // clean up any previous instances of the object inspector
     639         [ #  # ]:          0 :         if ( m_xMeAsFrame.is() )
     640 [ #  # ][ #  # ]:          0 :             m_xMeAsFrame->setComponent( NULL, NULL );
         [ #  # ][ #  # ]
                 [ #  # ]
     641                 :            :         else
     642         [ #  # ]:          0 :             ::comphelper::disposeComponent( m_xBrowserController );
     643                 :          0 :         m_xBrowserController.clear();
     644                 :          0 :         m_xInspectorModel.clear();
     645                 :          0 :         m_xBrowserComponentWindow.clear();
     646                 :            : 
     647                 :            :         // and create a new one
     648         [ #  # ]:          0 :         impl_createPropertyBrowser_throw( _pFormShell );
     649                 :            :     }
     650         [ #  # ]:          0 :     catch( const Exception& )
     651                 :            :     {
     652                 :            :         DBG_UNHANDLED_EXCEPTION();
     653                 :            :     }
     654 [ #  # ][ #  # ]:          0 :     m_xLastKnownDocument = xDocument;
     655                 :            : }
     656                 :            : 
     657                 :            : //-----------------------------------------------------------------------
     658                 :          0 : void FmPropBrw::StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState)
     659                 :            : {
     660 [ #  # ][ #  # ]:          0 :     if (!pState  || SID_FM_PROPERTY_CONTROL != nSID)
     661                 :          0 :         return;
     662                 :            : 
     663                 :          0 :     m_bInStateChange = true;
     664                 :            :     try
     665                 :            :     {
     666         [ #  # ]:          0 :         if (eState >= SFX_ITEM_AVAILABLE)
     667                 :            :         {
     668 [ #  # ][ #  # ]:          0 :             FmFormShell* pShell = PTR_CAST(FmFormShell,((SfxObjectItem*)pState)->GetShell());
         [ #  # ][ #  # ]
     669         [ #  # ]:          0 :             InterfaceBag aSelection;
     670         [ #  # ]:          0 :             if ( pShell )
     671         [ #  # ]:          0 :                 pShell->GetImpl()->getCurrentSelection( aSelection );
     672                 :            : 
     673         [ #  # ]:          0 :             impl_ensurePropertyBrowser_nothrow( pShell );
     674                 :            : 
     675                 :            :             // set the new object to inspect
     676         [ #  # ]:          0 :             implSetNewSelection( aSelection );
     677                 :            : 
     678                 :            :             // if this is the first time we're here, some additional things need to be done ...
     679         [ #  # ]:          0 :             if ( m_bInitialStateChange )
     680                 :            :             {
     681                 :            :                 // if we're just newly created, we want to have the focus
     682 [ #  # ][ #  # ]:          0 :                 PostUserEvent( LINK( this, FmPropBrw, OnAsyncGetFocus ) );
     683                 :            : 
     684                 :            :                 // and additionally, we want to show the page which was active during
     685                 :            :                 // our previous incarnation
     686         [ #  # ]:          0 :                 if ( !m_sLastActivePage.isEmpty() )
     687                 :            :                 {
     688                 :            :                     try
     689                 :            :                     {
     690         [ #  # ]:          0 :                         if ( m_xBrowserController.is() )
     691 [ #  # ][ #  # ]:          0 :                             m_xBrowserController->restoreViewData( makeAny( m_sLastActivePage ) );
         [ #  # ][ #  # ]
     692                 :            :                     }
     693         [ #  # ]:          0 :                     catch( const Exception& )
     694                 :            :                     {
     695                 :            :                         OSL_FAIL( "FmPropBrw::StateChanged: caught an exception while setting the initial page!" );
     696                 :            :                     }
     697                 :            :                 }
     698                 :            : 
     699                 :          0 :                 m_bInitialStateChange = sal_False;
     700                 :          0 :             }
     701                 :            : 
     702                 :            :         }
     703                 :            :         else
     704                 :            :         {
     705 [ #  # ][ #  # ]:          0 :             implSetNewSelection( InterfaceBag() );
                 [ #  # ]
     706                 :            :         }
     707                 :            :     }
     708                 :          0 :     catch (Exception&)
     709                 :            :     {
     710                 :            :         OSL_FAIL("FmPropBrw::StateChanged: Exception occurred!");
     711                 :            :     }
     712                 :          0 :     m_bInStateChange = false;
     713                 :            : }
     714                 :            : 
     715                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10