LCOV - code coverage report
Current view: top level - libreoffice/basctl/source/dlged - dlgedfac.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 111 0.0 %
Date: 2012-12-27 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "dlgedfac.hxx"
      21             : #include "dlgedobj.hxx"
      22             : #include <dlgeddef.hxx>
      23             : #include <com/sun/star/container/XNameContainer.hpp>
      24             : #include <com/sun/star/beans/PropertyValue.hpp>
      25             : #include <com/sun/star/beans/XPropertySet.hpp>
      26             : #include <com/sun/star/awt/ScrollBarOrientation.hpp>
      27             : 
      28             : namespace basctl
      29             : {
      30             : 
      31             : using namespace ::com::sun::star;
      32             : 
      33             : 
      34           0 : DlgEdFactory::DlgEdFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel ) : mxModel( xModel )
      35             : {
      36           0 :     SdrObjFactory::InsertMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
      37           0 : }
      38             : 
      39             : 
      40           0 : DlgEdFactory::~DlgEdFactory()
      41             : {
      42           0 :     SdrObjFactory::RemoveMakeObjectHdl( LINK(this, DlgEdFactory, MakeObject) );
      43           0 : }
      44             : 
      45             : 
      46           0 : IMPL_LINK( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory )
      47             : {
      48             :     static bool bNeedsInit = true;
      49           0 :     static uno::Reference< lang::XMultiServiceFactory > xDialogSFact;
      50             : 
      51           0 :     if( bNeedsInit )
      52             :     {
      53           0 :         uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
      54           0 :         uno::Reference< container::XNameContainer > xC( xMSF->createInstance( "com.sun.star.awt.UnoControlDialogModel" ), uno::UNO_QUERY );
      55           0 :         if( xC.is() )
      56             :         {
      57           0 :             uno::Reference< lang::XMultiServiceFactory > xModFact( xC, uno::UNO_QUERY );
      58           0 :             xDialogSFact = xModFact;
      59             :         }
      60           0 :         bNeedsInit = false;
      61             :     }
      62             : 
      63           0 :     if( (pObjFactory->nInventor == DlgInventor) &&
      64             :         (pObjFactory->nIdentifier >= OBJ_DLG_PUSHBUTTON) &&
      65             :         (pObjFactory->nIdentifier <= OBJ_DLG_FORMHSCROLL)    )
      66             :     {
      67           0 :         switch( pObjFactory->nIdentifier )
      68             :         {
      69             :             case OBJ_DLG_PUSHBUTTON:
      70           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlButtonModel", xDialogSFact );
      71           0 :                   break;
      72             :             case OBJ_DLG_FORMRADIO:
      73             :             case OBJ_DLG_RADIOBUTTON:
      74           0 :                  if ( pObjFactory->nIdentifier == OBJ_DLG_RADIOBUTTON )
      75           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlRadioButtonModel", xDialogSFact );
      76             :                  else
      77             :                  {
      78           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.RadioButton", xDialogSFact );
      79           0 :                      static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel );
      80             :                  }
      81           0 :                  break;
      82             :             case OBJ_DLG_FORMCHECK:
      83             :             case OBJ_DLG_CHECKBOX:
      84           0 :                  if ( pObjFactory->nIdentifier == OBJ_DLG_CHECKBOX )
      85           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlCheckBoxModel", xDialogSFact );
      86             :                  else
      87           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.CheckBox", xDialogSFact );
      88           0 :                      static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel );
      89           0 :                  break;
      90             :             case OBJ_DLG_FORMLIST:
      91             :             case OBJ_DLG_LISTBOX:
      92           0 :                  if ( pObjFactory->nIdentifier == OBJ_DLG_LISTBOX )
      93           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlListBoxModel", xDialogSFact );
      94             :                  else
      95             :                  {
      96           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.ListBox", xDialogSFact );
      97           0 :                      static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel );
      98             :                  }
      99           0 :                  break;
     100             :             case OBJ_DLG_FORMCOMBO:
     101             :             case OBJ_DLG_COMBOBOX:
     102             :             {
     103           0 :                  DlgEdObj* pNew = NULL;
     104           0 :                  if ( pObjFactory->nIdentifier == OBJ_DLG_COMBOBOX )
     105           0 :                      pNew = new DlgEdObj( "com.sun.star.awt.UnoControlComboBoxModel", xDialogSFact );
     106             :                  else
     107             :                  {
     108           0 :                      pNew = new DlgEdObj( "com.sun.star.form.component.ComboBox", xDialogSFact );
     109           0 :                      static_cast< DlgEdObj* >( pNew )->MakeDataAware( mxModel );
     110             :                  }
     111           0 :                  pObjFactory->pNewObj = pNew;
     112             :                  try
     113             :                  {
     114           0 :                     uno::Reference< beans::XPropertySet >  xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
     115           0 :                     if (xPSet.is())
     116             :                     {
     117           0 :                         sal_Bool bB = true;
     118           0 :                         xPSet->setPropertyValue( DLGED_PROP_DROPDOWN, uno::Any(&bB,::getBooleanCppuType()));
     119           0 :                     }
     120             :                  }
     121           0 :                  catch(...)
     122             :                  {
     123             :                  }
     124           0 :             }    break;
     125             :             case OBJ_DLG_GROUPBOX:
     126           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlGroupBoxModel", xDialogSFact );
     127           0 :                  break;
     128             :             case OBJ_DLG_EDIT:
     129           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlEditModel", xDialogSFact );
     130           0 :                  break;
     131             :             case OBJ_DLG_FIXEDTEXT:
     132           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFixedTextModel", xDialogSFact );
     133           0 :                  break;
     134             :             case OBJ_DLG_IMAGECONTROL:
     135           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlImageControlModel", xDialogSFact );
     136           0 :                  break;
     137             :             case OBJ_DLG_PROGRESSBAR:
     138           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlProgressBarModel", xDialogSFact );
     139           0 :                  break;
     140             :             case OBJ_DLG_FORMHSCROLL:
     141             :             case OBJ_DLG_HSCROLLBAR:
     142           0 :                  if ( pObjFactory->nIdentifier == OBJ_DLG_HSCROLLBAR )
     143           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact );
     144             :                  else
     145             :                  {
     146           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.ScrollBar", xDialogSFact );
     147           0 :                      static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel );
     148             :                  }
     149           0 :                  break;
     150             :             case OBJ_DLG_FORMVSCROLL:
     151             :             case OBJ_DLG_VSCROLLBAR:
     152             :             {
     153           0 :                  DlgEdObj* pNew = NULL;
     154           0 :                  if ( pObjFactory->nIdentifier ==  OBJ_DLG_VSCROLLBAR )
     155           0 :                      pNew = new DlgEdObj( "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact );
     156             :                  else
     157             :                  {
     158           0 :                      pNew = new DlgEdObj( "com.sun.star.form.component.ScrollBar", xDialogSFact );
     159           0 :                      static_cast< DlgEdObj* >( pNew )->MakeDataAware( mxModel );
     160             :                  }
     161           0 :                  pObjFactory->pNewObj = pNew;
     162             :                  // set vertical orientation
     163             :                  try
     164             :                  {
     165           0 :                     uno::Reference< beans::XPropertySet >  xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
     166           0 :                     if (xPSet.is())
     167             :                     {
     168           0 :                         uno::Any aValue;
     169           0 :                         aValue <<= (sal_Int32) ::com::sun::star::awt::ScrollBarOrientation::VERTICAL;
     170           0 :                         xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, aValue );
     171           0 :                     }
     172             :                  }
     173           0 :                  catch(...)
     174             :                  {
     175             :                  }
     176           0 :             }    break;
     177             :             case OBJ_DLG_HFIXEDLINE:
     178           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
     179           0 :                  break;
     180             :             case OBJ_DLG_VFIXEDLINE:
     181             :             {
     182           0 :                  DlgEdObj* pNew = new DlgEdObj( "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
     183           0 :                  pObjFactory->pNewObj = pNew;
     184             :                  // set vertical orientation
     185             :                  try
     186             :                  {
     187           0 :                     uno::Reference< beans::XPropertySet >  xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
     188           0 :                     if (xPSet.is())
     189             :                     {
     190           0 :                         uno::Any aValue;
     191           0 :                         aValue <<= (sal_Int32) 1;
     192           0 :                         xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, aValue );
     193           0 :                     }
     194             :                  }
     195           0 :                  catch(...)
     196             :                  {
     197             :                  }
     198           0 :             }    break;
     199             :             case OBJ_DLG_DATEFIELD:
     200           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlDateFieldModel", xDialogSFact );
     201           0 :                  break;
     202             :             case OBJ_DLG_TIMEFIELD:
     203           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlTimeFieldModel", xDialogSFact );
     204           0 :                  break;
     205             :             case OBJ_DLG_NUMERICFIELD:
     206           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlNumericFieldModel", xDialogSFact );
     207           0 :                  break;
     208             :             case OBJ_DLG_CURRENCYFIELD:
     209           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlCurrencyFieldModel", xDialogSFact );
     210           0 :                  break;
     211             :             case OBJ_DLG_FORMATTEDFIELD:
     212           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFormattedFieldModel", xDialogSFact );
     213           0 :                  break;
     214             :             case OBJ_DLG_PATTERNFIELD:
     215           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlPatternFieldModel", xDialogSFact );
     216           0 :                  break;
     217             :             case OBJ_DLG_FILECONTROL:
     218           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFileControlModel", xDialogSFact );
     219           0 :                  break;
     220             :             case OBJ_DLG_FORMSPIN:
     221             :             case OBJ_DLG_SPINBUTTON:
     222           0 :                  if ( pObjFactory->nIdentifier == OBJ_DLG_SPINBUTTON )
     223           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlSpinButtonModel", xDialogSFact );
     224             :                  else
     225             :                  {
     226           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.SpinButton", xDialogSFact );
     227           0 :                      static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel );
     228             :                  }
     229           0 :                  break;
     230             :             case OBJ_DLG_TREECONTROL:
     231           0 :                  DlgEdObj* pNew = new DlgEdObj( "com.sun.star.awt.tree.TreeControlModel", xDialogSFact );
     232           0 :                  pObjFactory->pNewObj = pNew;
     233           0 :                  break;
     234             :         }
     235             :     }
     236             : 
     237           0 :     return 0;
     238             : }
     239             : 
     240             : } // namespace basctl
     241             : 
     242             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10