LCOV - code coverage report
Current view: top level - svx/source/form - fmobjfac.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 23 91 25.3 %
Date: 2015-06-13 12:38:46 Functions: 4 7 57.1 %
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 <config_features.h>
      21             : 
      22             : #include <tools/diagnose_ex.h>
      23             : #include <svx/svdobj.hxx>
      24             : #include "svx/fmtools.hxx"
      25             : #include "fmservs.hxx"
      26             : 
      27             : #include "svx/fmobjfac.hxx"
      28             : 
      29             : #include <svx/fmglob.hxx>
      30             : 
      31             : #include "fmobj.hxx"
      32             : #include "fmshimp.hxx"
      33             : 
      34             : #include <svx/fmshell.hxx>
      35             : 
      36             : #include <svx/svxids.hrc>
      37             : #include "tbxform.hxx"
      38             : #include <tools/resid.hxx>
      39             : 
      40             : #include "svx/fmresids.hrc"
      41             : #include <svx/dialmgr.hxx>
      42             : #include "tabwin.hxx"
      43             : #include "fmexpl.hxx"
      44             : #include "filtnav.hxx"
      45             : 
      46             : #include "fmprop.hrc"
      47             : #include "fmPropBrw.hxx"
      48             : #include "datanavi.hxx"
      49             : 
      50             : using namespace ::com::sun::star::uno;
      51             : using namespace ::com::sun::star::beans;
      52             : using namespace ::svxform;
      53             : 
      54             : static bool bInit = false;
      55             : 
      56         132 : FmFormObjFactory::FmFormObjFactory()
      57             : {
      58         132 :     if ( !bInit )
      59             :     {
      60         114 :         SdrObjFactory::InsertMakeObjectHdl(LINK(this, FmFormObjFactory, MakeObject));
      61             : 
      62             : 
      63             :         // Konfigurations-::com::sun::star::frame::Controller und NavigationBar registrieren
      64         114 :         SvxFmTbxCtlConfig::RegisterControl( SID_FM_CONFIG );
      65         114 :         SvxFmTbxCtlAbsRec::RegisterControl( SID_FM_RECORD_ABSOLUTE );
      66         114 :         SvxFmTbxCtlRecText::RegisterControl( SID_FM_RECORD_TEXT );
      67         114 :         SvxFmTbxCtlRecFromText::RegisterControl( SID_FM_RECORD_FROM_TEXT );
      68         114 :         SvxFmTbxCtlRecTotal::RegisterControl( SID_FM_RECORD_TOTAL );
      69         114 :         SvxFmTbxPrevRec::RegisterControl( SID_FM_RECORD_PREV );
      70         114 :         SvxFmTbxNextRec::RegisterControl( SID_FM_RECORD_NEXT );
      71         114 :         ControlConversionMenuController::RegisterControl(SID_FM_CHANGECONTROLTYPE);
      72             : 
      73             :         // Registrieung von globalen fenstern
      74         114 :         FmFieldWinMgr::RegisterChildWindow();
      75         114 :         FmPropBrwMgr::RegisterChildWindow();
      76         114 :         NavigatorFrameManager::RegisterChildWindow();
      77         114 :         DataNavigatorManager::RegisterChildWindow();
      78             : #if HAVE_FEATURE_DBCONNECTIVITY
      79         114 :         FmFilterNavigatorWinMgr::RegisterChildWindow();
      80             : #endif
      81             : 
      82             :         // Interface fuer die Formshell registrieren
      83         114 :         FmFormShell::RegisterInterface(0);
      84             : 
      85         114 :         ImplSmartRegisterUnoServices();
      86         114 :         bInit = true;
      87             :     }
      88         132 : }
      89             : 
      90         132 : FmFormObjFactory::~FmFormObjFactory()
      91             : {
      92         132 : }
      93             : 
      94             : // ::com::sun::star::form::Form-Objekte erzeugen
      95             : namespace
      96             : {
      97           0 :     void    lcl_initProperty( FmFormObj* _pObject, const OUString& _rPropName, const Any& _rValue )
      98             :     {
      99             :         try
     100             :         {
     101           0 :             Reference< XPropertySet >  xModelSet( _pObject->GetUnoControlModel(), UNO_QUERY );
     102           0 :             if ( xModelSet.is() )
     103           0 :                 xModelSet->setPropertyValue( _rPropName, _rValue );
     104             :         }
     105           0 :         catch( const Exception& )
     106             :         {
     107             :             OSL_FAIL( "lcl_initProperty: caught an exception!" );
     108             :             DBG_UNHANDLED_EXCEPTION();
     109             :         }
     110           0 :     }
     111             : }
     112             : 
     113           0 : IMPL_STATIC_LINK(
     114             :     FmFormObjFactory, MakeObject, SdrObjFactory*, pObjFactory)
     115             : {
     116           0 :     if (pObjFactory->nInventor == FmFormInventor)
     117             :     {
     118           0 :         OUString sServiceSpecifier;
     119             : 
     120             :         typedef ::std::vector< ::std::pair< OUString, Any > > PropertyValueArray;
     121           0 :         PropertyValueArray aInitialProperties;
     122             : 
     123           0 :         switch ( pObjFactory->nIdentifier )
     124             :         {
     125             :             case OBJ_FM_EDIT:
     126           0 :                 sServiceSpecifier = FM_COMPONENT_EDIT;
     127           0 :                 break;
     128             : 
     129             :             case OBJ_FM_BUTTON:
     130           0 :                 sServiceSpecifier = FM_COMPONENT_COMMANDBUTTON;
     131           0 :                 break;
     132             : 
     133             :             case OBJ_FM_FIXEDTEXT:
     134           0 :                 sServiceSpecifier = FM_COMPONENT_FIXEDTEXT;
     135           0 :                 break;
     136             : 
     137             :             case OBJ_FM_LISTBOX:
     138           0 :                 sServiceSpecifier = FM_COMPONENT_LISTBOX;
     139           0 :                 break;
     140             : 
     141             :             case OBJ_FM_CHECKBOX:
     142           0 :                 sServiceSpecifier = FM_COMPONENT_CHECKBOX;
     143           0 :                 break;
     144             : 
     145             :             case OBJ_FM_RADIOBUTTON:
     146           0 :                 sServiceSpecifier = FM_COMPONENT_RADIOBUTTON;
     147           0 :                 break;
     148             : 
     149             :             case OBJ_FM_GROUPBOX:
     150           0 :                 sServiceSpecifier = FM_COMPONENT_GROUPBOX;
     151           0 :                 break;
     152             : 
     153             :             case OBJ_FM_COMBOBOX:
     154           0 :                 sServiceSpecifier = FM_COMPONENT_COMBOBOX;
     155           0 :                 break;
     156             : 
     157             :             case OBJ_FM_GRID:
     158           0 :                 sServiceSpecifier = FM_COMPONENT_GRID;
     159           0 :                 break;
     160             : 
     161             :             case OBJ_FM_IMAGEBUTTON:
     162           0 :                 sServiceSpecifier = FM_COMPONENT_IMAGEBUTTON;
     163           0 :                 break;
     164             : 
     165             :             case OBJ_FM_FILECONTROL:
     166           0 :                 sServiceSpecifier = FM_COMPONENT_FILECONTROL;
     167           0 :                 break;
     168             : 
     169             :             case OBJ_FM_DATEFIELD:
     170           0 :                 sServiceSpecifier = FM_COMPONENT_DATEFIELD;
     171           0 :                 break;
     172             : 
     173             :             case OBJ_FM_TIMEFIELD:
     174           0 :                 sServiceSpecifier = FM_COMPONENT_TIMEFIELD;
     175           0 :                 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_TIMEMAX, makeAny( tools::Time( 23, 59, 59, 999999999 ).GetUNOTime() ) ) );
     176           0 :                 break;
     177             : 
     178             :             case OBJ_FM_NUMERICFIELD:
     179           0 :                 sServiceSpecifier = FM_COMPONENT_NUMERICFIELD;
     180           0 :                 break;
     181             : 
     182             :             case OBJ_FM_CURRENCYFIELD:
     183           0 :                 sServiceSpecifier = FM_COMPONENT_CURRENCYFIELD;
     184           0 :                 break;
     185             : 
     186             :             case OBJ_FM_PATTERNFIELD:
     187           0 :                 sServiceSpecifier = FM_COMPONENT_PATTERNFIELD;
     188           0 :                 break;
     189             : 
     190             :             case OBJ_FM_HIDDEN:
     191           0 :                 sServiceSpecifier = FM_COMPONENT_HIDDEN;
     192           0 :                 break;
     193             : 
     194             :             case OBJ_FM_IMAGECONTROL:
     195           0 :                 sServiceSpecifier = FM_COMPONENT_IMAGECONTROL;
     196           0 :                 break;
     197             : 
     198             :             case OBJ_FM_FORMATTEDFIELD:
     199           0 :                 sServiceSpecifier = FM_COMPONENT_FORMATTEDFIELD;
     200           0 :                 break;
     201             : 
     202             :             case OBJ_FM_NAVIGATIONBAR:
     203           0 :                 sServiceSpecifier = FM_SUN_COMPONENT_NAVIGATIONBAR;
     204           0 :                 break;
     205             : 
     206             :             case OBJ_FM_SCROLLBAR:
     207           0 :                 sServiceSpecifier = FM_SUN_COMPONENT_SCROLLBAR;
     208           0 :                 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
     209           0 :                 break;
     210             : 
     211             :             case OBJ_FM_SPINBUTTON:
     212           0 :                 sServiceSpecifier = FM_SUN_COMPONENT_SPINBUTTON;
     213           0 :                 aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
     214           0 :                 break;
     215             :         }
     216             : 
     217             :         // create the actual object
     218           0 :         if ( !sServiceSpecifier.isEmpty() )
     219           0 :             pObjFactory->pNewObj = new FmFormObj(sServiceSpecifier);
     220             :         else
     221           0 :             pObjFactory->pNewObj = new FmFormObj();
     222             : 
     223             :         // initialize some properties which we want to differ from the defaults
     224           0 :         for (   PropertyValueArray::const_iterator aInitProp = aInitialProperties.begin();
     225           0 :                 aInitProp != aInitialProperties.end();
     226             :                 ++aInitProp
     227             :             )
     228             :         {
     229             :             lcl_initProperty(
     230             :                 static_cast< FmFormObj* >( pObjFactory->pNewObj ),
     231           0 :                 aInitProp->first,
     232           0 :                 aInitProp->second
     233           0 :             );
     234           0 :         }
     235             :     }
     236             : 
     237           0 :     return 0;
     238         390 : }
     239             : 
     240             : 
     241             : 
     242             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11