LCOV - code coverage report
Current view: top level - basctl/source/dlged - dlgedfac.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 114 0.0 %
Date: 2014-11-03 Functions: 0 6 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< uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
      54           0 :         uno::Reference< container::XNameContainer > xC( xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.awt.UnoControlDialogModel", xContext ), 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           0 :         (pObjFactory->nIdentifier >= OBJ_DLG_PUSHBUTTON) &&
      65           0 :         (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             :                  {
      88           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.CheckBox", xDialogSFact );
      89           0 :                      static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel );
      90             :                  }
      91           0 :                  break;
      92             :             case OBJ_DLG_FORMLIST:
      93             :             case OBJ_DLG_LISTBOX:
      94           0 :                  if ( pObjFactory->nIdentifier == OBJ_DLG_LISTBOX )
      95           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlListBoxModel", xDialogSFact );
      96             :                  else
      97             :                  {
      98           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.ListBox", xDialogSFact );
      99           0 :                      static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel );
     100             :                  }
     101           0 :                  break;
     102             :             case OBJ_DLG_FORMCOMBO:
     103             :             case OBJ_DLG_COMBOBOX:
     104             :             {
     105           0 :                  DlgEdObj* pNew = NULL;
     106           0 :                  if ( pObjFactory->nIdentifier == OBJ_DLG_COMBOBOX )
     107           0 :                      pNew = new DlgEdObj( "com.sun.star.awt.UnoControlComboBoxModel", xDialogSFact );
     108             :                  else
     109             :                  {
     110           0 :                      pNew = new DlgEdObj( "com.sun.star.form.component.ComboBox", xDialogSFact );
     111           0 :                      static_cast< DlgEdObj* >( pNew )->MakeDataAware( mxModel );
     112             :                  }
     113           0 :                  pObjFactory->pNewObj = pNew;
     114             :                  try
     115             :                  {
     116           0 :                     uno::Reference< beans::XPropertySet >  xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
     117           0 :                     if (xPSet.is())
     118             :                     {
     119           0 :                         sal_Bool bB = true;
     120           0 :                         xPSet->setPropertyValue( DLGED_PROP_DROPDOWN, uno::Any(&bB,::getBooleanCppuType()));
     121           0 :                     }
     122             :                  }
     123           0 :                  catch(...)
     124             :                  {
     125             :                  }
     126           0 :             }    break;
     127             :             case OBJ_DLG_GROUPBOX:
     128           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlGroupBoxModel", xDialogSFact );
     129           0 :                  break;
     130             :             case OBJ_DLG_EDIT:
     131           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlEditModel", xDialogSFact );
     132           0 :                  break;
     133             :             case OBJ_DLG_FIXEDTEXT:
     134           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFixedTextModel", xDialogSFact );
     135           0 :                  break;
     136             :             case OBJ_DLG_IMAGECONTROL:
     137           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlImageControlModel", xDialogSFact );
     138           0 :                  break;
     139             :             case OBJ_DLG_PROGRESSBAR:
     140           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlProgressBarModel", xDialogSFact );
     141           0 :                  break;
     142             :             case OBJ_DLG_FORMHSCROLL:
     143             :             case OBJ_DLG_HSCROLLBAR:
     144           0 :                  if ( pObjFactory->nIdentifier == OBJ_DLG_HSCROLLBAR )
     145           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact );
     146             :                  else
     147             :                  {
     148           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.ScrollBar", xDialogSFact );
     149           0 :                      static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel );
     150             :                  }
     151           0 :                  break;
     152             :             case OBJ_DLG_FORMVSCROLL:
     153             :             case OBJ_DLG_VSCROLLBAR:
     154             :             {
     155           0 :                  DlgEdObj* pNew = NULL;
     156           0 :                  if ( pObjFactory->nIdentifier ==  OBJ_DLG_VSCROLLBAR )
     157           0 :                      pNew = new DlgEdObj( "com.sun.star.awt.UnoControlScrollBarModel", xDialogSFact );
     158             :                  else
     159             :                  {
     160           0 :                      pNew = new DlgEdObj( "com.sun.star.form.component.ScrollBar", xDialogSFact );
     161           0 :                      static_cast< DlgEdObj* >( pNew )->MakeDataAware( mxModel );
     162             :                  }
     163           0 :                  pObjFactory->pNewObj = pNew;
     164             :                  // set vertical orientation
     165             :                  try
     166             :                  {
     167           0 :                     uno::Reference< beans::XPropertySet >  xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
     168           0 :                     if (xPSet.is())
     169             :                     {
     170           0 :                         uno::Any aValue;
     171           0 :                         aValue <<= (sal_Int32) ::com::sun::star::awt::ScrollBarOrientation::VERTICAL;
     172           0 :                         xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, aValue );
     173           0 :                     }
     174             :                  }
     175           0 :                  catch(...)
     176             :                  {
     177             :                  }
     178           0 :             }    break;
     179             :             case OBJ_DLG_HFIXEDLINE:
     180           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
     181           0 :                  break;
     182             :             case OBJ_DLG_VFIXEDLINE:
     183             :             {
     184           0 :                  DlgEdObj* pNew = new DlgEdObj( "com.sun.star.awt.UnoControlFixedLineModel", xDialogSFact );
     185           0 :                  pObjFactory->pNewObj = pNew;
     186             :                  // set vertical orientation
     187             :                  try
     188             :                  {
     189           0 :                     uno::Reference< beans::XPropertySet >  xPSet(pNew->GetUnoControlModel(), uno::UNO_QUERY);
     190           0 :                     if (xPSet.is())
     191             :                     {
     192           0 :                         uno::Any aValue;
     193           0 :                         aValue <<= (sal_Int32) 1;
     194           0 :                         xPSet->setPropertyValue( DLGED_PROP_ORIENTATION, aValue );
     195           0 :                     }
     196             :                  }
     197           0 :                  catch(...)
     198             :                  {
     199             :                  }
     200           0 :             }    break;
     201             :             case OBJ_DLG_DATEFIELD:
     202           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlDateFieldModel", xDialogSFact );
     203           0 :                  break;
     204             :             case OBJ_DLG_TIMEFIELD:
     205           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlTimeFieldModel", xDialogSFact );
     206           0 :                  break;
     207             :             case OBJ_DLG_NUMERICFIELD:
     208           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlNumericFieldModel", xDialogSFact );
     209           0 :                  break;
     210             :             case OBJ_DLG_CURRENCYFIELD:
     211           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlCurrencyFieldModel", xDialogSFact );
     212           0 :                  break;
     213             :             case OBJ_DLG_FORMATTEDFIELD:
     214           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFormattedFieldModel", xDialogSFact );
     215           0 :                  break;
     216             :             case OBJ_DLG_PATTERNFIELD:
     217           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlPatternFieldModel", xDialogSFact );
     218           0 :                  break;
     219             :             case OBJ_DLG_FILECONTROL:
     220           0 :                  pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlFileControlModel", xDialogSFact );
     221           0 :                  break;
     222             :             case OBJ_DLG_FORMSPIN:
     223             :             case OBJ_DLG_SPINBUTTON:
     224           0 :                  if ( pObjFactory->nIdentifier == OBJ_DLG_SPINBUTTON )
     225           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.awt.UnoControlSpinButtonModel", xDialogSFact );
     226             :                  else
     227             :                  {
     228           0 :                      pObjFactory->pNewObj = new DlgEdObj( "com.sun.star.form.component.SpinButton", xDialogSFact );
     229           0 :                      static_cast< DlgEdObj* >( pObjFactory->pNewObj )->MakeDataAware( mxModel );
     230             :                  }
     231           0 :                  break;
     232             :             case OBJ_DLG_TREECONTROL:
     233           0 :                  DlgEdObj* pNew = new DlgEdObj( "com.sun.star.awt.tree.TreeControlModel", xDialogSFact );
     234           0 :                  pObjFactory->pNewObj = pNew;
     235           0 :                  break;
     236             :         }
     237             :     }
     238             : 
     239           0 :     return 0;
     240             : }
     241             : 
     242           0 : } // namespace basctl
     243             : 
     244             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10