LCOV - code coverage report
Current view: top level - libreoffice/reportdesign/source/ui/inspection - metadata.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 61 0.0 %
Date: 2012-12-27 Functions: 0 16 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             : #include "metadata.hxx"
      20             : #include <svtools/localresaccess.hxx>
      21             : #include "com/sun/star/inspection/XPropertyHandler.hpp"
      22             : #include <comphelper/extract.hxx>
      23             : #include "helpids.hrc"
      24             : #include "RptResId.hrc"
      25             : #include "uistrings.hrc"
      26             : 
      27             : #include <functional>
      28             : #include <algorithm>
      29             : 
      30             : //............................................................................
      31             : namespace rptui
      32             : {
      33             : //............................................................................
      34             : 
      35             :     using namespace ::com::sun::star::uno;
      36             :     using namespace ::com::sun::star;
      37             : 
      38             :     //========================================================================
      39             :     //= OPropertyInfoImpl
      40             :     //========================================================================
      41           0 :     struct OPropertyInfoImpl
      42             :     {
      43             :         String          sName;
      44             :         String          sTranslation;
      45             :         rtl::OString    sHelpId;
      46             :         sal_Int32       nId;
      47             :         sal_uInt16      nPos;
      48             :         sal_uInt32      nUIFlags;
      49             : 
      50             :         OPropertyInfoImpl(
      51             :                         const ::rtl::OUString&      rName,
      52             :                         sal_Int32                   _nId,
      53             :                         const String&               aTranslation,
      54             :                         sal_uInt16                  nPosId,
      55             :                         const rtl::OString&         _sHelpId,
      56             :                         sal_uInt32                  _nUIFlags);
      57             :     };
      58             : 
      59             :     //------------------------------------------------------------------------
      60           0 :     OPropertyInfoImpl::OPropertyInfoImpl(const ::rtl::OUString& _rName, sal_Int32 _nId,
      61             :                                    const String& aString, sal_uInt16 nP, const rtl::OString& sHid, sal_uInt32 _nUIFlags)
      62             :        :sName(_rName)
      63             :        ,sTranslation(aString)
      64             :        ,sHelpId(sHid)
      65             :        ,nId(_nId)
      66             :        ,nPos(nP)
      67           0 :        ,nUIFlags(_nUIFlags)
      68             :     {
      69           0 :     }
      70             : 
      71             :     //------------------------------------------------------------------------
      72             :     // Vergleichen von PropertyInfo
      73             :     struct PropertyInfoLessByName : public ::std::binary_function< OPropertyInfoImpl, OPropertyInfoImpl, bool >
      74             :     {
      75           0 :         bool operator()( const OPropertyInfoImpl& _lhs, const OPropertyInfoImpl& _rhs )
      76             :         {
      77           0 :             return _lhs.sName < _rhs.sName;
      78             :         }
      79             :     };
      80             : 
      81             :     //========================================================================
      82             :     //= OPropertyInfoService
      83             :     //========================================================================
      84             : #define DEF_INFO( ident, uinameres, helpid, flags )   \
      85             :     OPropertyInfoImpl( PROPERTY_##ident, PROPERTY_ID_##ident, \
      86             :             String( ModuleRes( RID_STR_##uinameres ) ), nPos++, HID_RPT_PROP_##helpid, flags )
      87             : 
      88             : #define DEF_INFO_1( ident, uinameres, helpid, flag1 ) \
      89             :     DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 )
      90             : 
      91             : #define DEF_INFO_2( ident, uinameres, helpid, flag1, flag2 ) \
      92             :     DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 )
      93             : 
      94             : #define DEF_INFO_3( ident, uinameres, helpid, flag1, flag2, flag3 ) \
      95             :     DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 | PROP_FLAG_##flag3 )
      96             : 
      97             : #define DEF_INFO_4( ident, uinameres, helpid, flag1, flag2, flag3, flag4 ) \
      98             :     DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 | PROP_FLAG_##flag3 | PROP_FLAG_##flag4 )
      99             : 
     100             : #define DEF_INFO_5( ident, uinameres, helpid, flag1, flag2, flag3, flag4, flag5 ) \
     101             :     DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 | PROP_FLAG_##flag3 | PROP_FLAG_##flag4 | PROP_FLAG_##flag5 )
     102             : 
     103             :     sal_uInt16              OPropertyInfoService::s_nCount = 0;
     104             :     OPropertyInfoImpl*      OPropertyInfoService::s_pPropertyInfos = NULL;
     105             :     //------------------------------------------------------------------------
     106           0 :     const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo()
     107             :     {
     108           0 :         if ( s_pPropertyInfos )
     109           0 :             return s_pPropertyInfos;
     110             : 
     111           0 :         OModuleClient aResourceAccess;
     112             :         // this ensures that we have our resource file loaded
     113             : 
     114           0 :         sal_uInt16 nPos = 1;
     115             :         static OPropertyInfoImpl aPropertyInfos[] =
     116             :         {
     117             :         /*
     118             :         DEF_INFO_?( propname and id,   resoure id,         help id,           flags ),
     119             :         */
     120             :              DEF_INFO_1( FORCENEWPAGE,                  FORCENEWPAGE,               FORCENEWPAGE,               COMPOSEABLE )
     121             :             ,DEF_INFO_1( NEWROWORCOL,                   NEWROWORCOL,                NEWROWORCOL,                COMPOSEABLE )
     122             :             ,DEF_INFO_1( KEEPTOGETHER,                  KEEPTOGETHER,               KEEPTOGETHER,               COMPOSEABLE )
     123             :             ,DEF_INFO_1( CANGROW,                       CANGROW,                    CANGROW,                    COMPOSEABLE )
     124             :             ,DEF_INFO_1( CANSHRINK,                     CANSHRINK,                  CANSHRINK,                  COMPOSEABLE )
     125             :             ,DEF_INFO_1( REPEATSECTION,                 REPEATSECTION,              REPEATSECTION,              COMPOSEABLE )
     126             :             ,DEF_INFO_1( PRINTREPEATEDVALUES,           PRINTREPEATEDVALUES,        PRINTREPEATEDVALUES,        COMPOSEABLE )
     127             :             ,DEF_INFO_1( CONDITIONALPRINTEXPRESSION,    CONDITIONALPRINTEXPRESSION, CONDITIONALPRINTEXPRESSION, COMPOSEABLE )
     128             :             ,DEF_INFO_1( STARTNEWCOLUMN,                STARTNEWCOLUMN,             STARTNEWCOLUMN,             COMPOSEABLE )
     129             :             ,DEF_INFO_1( RESETPAGENUMBER,               RESETPAGENUMBER,            RESETPAGENUMBER,            COMPOSEABLE )
     130             :             ,DEF_INFO_1( PRINTWHENGROUPCHANGE,          PRINTWHENGROUPCHANGE,       PRINTWHENGROUPCHANGE,       COMPOSEABLE )
     131             :             ,DEF_INFO_1( VISIBLE,                       VISIBLE,                    VISIBLE,                    COMPOSEABLE )
     132             :             ,DEF_INFO_1( GROUPKEEPTOGETHER,             GROUPKEEPTOGETHER,          GROUPKEEPTOGETHER,          COMPOSEABLE )
     133             :             ,DEF_INFO_1( PAGEHEADEROPTION,              PAGEHEADEROPTION,           PAGEHEADEROPTION,           COMPOSEABLE )
     134             :             ,DEF_INFO_1( PAGEFOOTEROPTION,              PAGEFOOTEROPTION,           PAGEFOOTEROPTION,           COMPOSEABLE )
     135             :             ,DEF_INFO_1( POSITIONX,                     POSITIONX,                  RPT_POSITIONX,              COMPOSEABLE )
     136             :             ,DEF_INFO_1( POSITIONY,                     POSITIONY,                  RPT_POSITIONY,              COMPOSEABLE )
     137             :             ,DEF_INFO_1( WIDTH,                         WIDTH,                      RPT_WIDTH,                  COMPOSEABLE )
     138             :             ,DEF_INFO_1( HEIGHT,                        HEIGHT,                     RPT_HEIGHT,                 COMPOSEABLE )
     139             :             ,DEF_INFO_1( FONT,                          FONT,                       RPT_FONT,                   COMPOSEABLE )
     140             :             ,DEF_INFO_1( PREEVALUATED,                  PREEVALUATED,               PREEVALUATED,               COMPOSEABLE )
     141             :             ,DEF_INFO_1( DEEPTRAVERSING,                DEEPTRAVERSING,             DEEPTRAVERSING,             COMPOSEABLE )
     142             :             ,DEF_INFO_1( FORMULA,                       FORMULA,                    FORMULA,                    COMPOSEABLE )
     143             :             ,DEF_INFO_1( INITIALFORMULA,                INITIALFORMULA,             INITIALFORMULA,             COMPOSEABLE )
     144             :             ,DEF_INFO_2( TYPE,                          TYPE,                       TYPE,                       COMPOSEABLE,DATA_PROPERTY )
     145             :             ,DEF_INFO_2( DATAFIELD,                     DATAFIELD,                  DATAFIELD,                  COMPOSEABLE,DATA_PROPERTY )
     146             :             ,DEF_INFO_2( FORMULALIST,                   FORMULALIST,                FORMULALIST,                COMPOSEABLE,DATA_PROPERTY )
     147             :             ,DEF_INFO_2( SCOPE,                         SCOPE,                      SCOPE,                      COMPOSEABLE,DATA_PROPERTY )
     148             :             ,DEF_INFO_1( PRESERVEIRI,                   PRESERVEIRI,                PRESERVEIRI,                COMPOSEABLE )
     149             :             ,DEF_INFO_1( BACKCOLOR,                     BACKCOLOR,                  BACKCOLOR,                  COMPOSEABLE )
     150             :             ,DEF_INFO_1( CONTROLBACKGROUND,             BACKCOLOR,                  BACKCOLOR,                  COMPOSEABLE )
     151             :             ,DEF_INFO_1( BACKTRANSPARENT,               BACKTRANSPARENT,            BACKTRANSPARENT,            COMPOSEABLE )
     152             :             ,DEF_INFO_1( CONTROLBACKGROUNDTRANSPARENT,  CONTROLBACKGROUNDTRANSPARENT
     153             :                                                                     ,CONTROLBACKGROUNDTRANSPARENT, COMPOSEABLE )
     154             :             ,DEF_INFO_1( CHARTTYPE,                     CHARTTYPE,                  CHARTTYPE,                  COMPOSEABLE )
     155             :             ,DEF_INFO_1( PREVIEW_COUNT,                 PREVIEW_COUNT,              PREVIEW_COUNT,              COMPOSEABLE )
     156             :             ,DEF_INFO_2( MASTERFIELDS,                  MASTERFIELDS,               MASTERFIELDS,               COMPOSEABLE,DATA_PROPERTY )
     157             :             ,DEF_INFO_2( DETAILFIELDS,                  DETAILFIELDS,               DETAILFIELDS,               COMPOSEABLE,DATA_PROPERTY)
     158             :             ,DEF_INFO_1( AREA,                          AREA,                       AREA,                       COMPOSEABLE )
     159             :             ,DEF_INFO_2( MIMETYPE,                      MIMETYPE,                   MIMETYPE,                   COMPOSEABLE,DATA_PROPERTY )
     160             :             ,DEF_INFO_1( PARAADJUST,                    PARAADJUST,                 PARAADJUST,                 COMPOSEABLE )
     161             :             ,DEF_INFO_1( VERTICALALIGN,                 VERTICALALIGN,              VERTICALALIGN,              COMPOSEABLE )
     162           0 :         };
     163             : 
     164           0 :         s_pPropertyInfos = aPropertyInfos;
     165           0 :         s_nCount = SAL_N_ELEMENTS(aPropertyInfos);
     166           0 :         ::std::sort( aPropertyInfos, aPropertyInfos + SAL_N_ELEMENTS(aPropertyInfos), PropertyInfoLessByName() );
     167             : 
     168           0 :         return s_pPropertyInfos;
     169             :     }
     170             : 
     171             :     //------------------------------------------------------------------------
     172           0 :     sal_Int32 OPropertyInfoService::getPropertyId(const String& _rName) const
     173             :     {
     174           0 :         const OPropertyInfoImpl* pInfo = getPropertyInfo(_rName);
     175           0 :         return pInfo ? pInfo->nId : -1;
     176             :     }
     177             : 
     178             :     //------------------------------------------------------------------------
     179           0 :     String OPropertyInfoService::getPropertyTranslation(sal_Int32 _nId) const
     180             :     {
     181           0 :         const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
     182           0 :         return (pInfo) ? pInfo->sTranslation : String();
     183             :     }
     184             : 
     185             :     //------------------------------------------------------------------------
     186           0 :     rtl::OString OPropertyInfoService::getPropertyHelpId(sal_Int32 _nId) const
     187             :     {
     188           0 :         const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
     189           0 :         return (pInfo) ? pInfo->sHelpId : rtl::OString();
     190             :     }
     191             : 
     192             :     //------------------------------------------------------------------------
     193           0 :     sal_uInt32 OPropertyInfoService::getPropertyUIFlags(sal_Int32 _nId) const
     194             :     {
     195           0 :         const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
     196           0 :         return (pInfo) ? pInfo->nUIFlags : 0;
     197             :     }
     198             : 
     199             :     //------------------------------------------------------------------------
     200           0 :     const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo(const String& _rName)
     201             :     {
     202             :         // intialisierung
     203           0 :         if(!s_pPropertyInfos)
     204           0 :             getPropertyInfo();
     205           0 :         OPropertyInfoImpl  aSearch(_rName, 0L, String(), 0, "", 0);
     206             : 
     207             :         const OPropertyInfoImpl* pPropInfo = ::std::lower_bound(
     208           0 :             s_pPropertyInfos, s_pPropertyInfos + s_nCount, aSearch, PropertyInfoLessByName() );
     209             : 
     210           0 :         if ( ( pPropInfo < s_pPropertyInfos + s_nCount ) && pPropInfo->sName == _rName )
     211           0 :             return pPropInfo;
     212             : 
     213           0 :         return NULL;
     214             :     }
     215             : 
     216             : 
     217             :     //------------------------------------------------------------------------
     218           0 :     const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo(sal_Int32 _nId)
     219             :     {
     220             :         // intialisierung
     221           0 :         if(!s_pPropertyInfos)
     222           0 :             getPropertyInfo();
     223             : 
     224             :         // TODO: a real structure which allows quick access by name as well as by id
     225           0 :         for (sal_uInt16 i = 0; i < s_nCount; i++)
     226           0 :             if (s_pPropertyInfos[i].nId == _nId)
     227           0 :                 return &s_pPropertyInfos[i];
     228             : 
     229           0 :         return NULL;
     230             :     }
     231             : 
     232             :     //------------------------------------------------------------------------
     233           0 :     bool OPropertyInfoService::isComposable( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >& _rxFormComponentHandler )
     234             :     {
     235           0 :         sal_Int32 nId = getPropertyId( _rPropertyName );
     236           0 :         if ( nId != -1 )
     237             :         {
     238           0 :             sal_uInt32 nFlags = getPropertyUIFlags( nId );
     239           0 :             return ( nFlags & PROP_FLAG_COMPOSEABLE ) != 0;
     240             :         }
     241             : 
     242           0 :         return _rxFormComponentHandler->isComposable( _rPropertyName );
     243             :     }
     244             : 
     245             :     //------------------------------------------------------------------------
     246           0 :     void OPropertyInfoService::getExcludeProperties(::std::vector< beans::Property >& _rExcludeProperties,const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >& _xFormComponentHandler)
     247             :     {
     248           0 :         uno::Sequence< beans::Property > aProps = _xFormComponentHandler->getSupportedProperties();
     249             :         static const ::rtl::OUString pExcludeProperties[] =
     250             :         {
     251             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Enabled")),
     252             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Printable")),
     253             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WordBreak")),
     254             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MultiLine")),
     255             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Tag")),
     256             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HelpText")),
     257             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HelpURL")),
     258             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MaxTextLen")),
     259             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReadOnly")),
     260             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Tabstop")),
     261             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TabIndex")),
     262             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ValueMin")),
     263             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ValueMax")),
     264             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Spin")),
     265             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SpinValue")),
     266             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SpinValueMin")),
     267             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SpinValueMax")),
     268             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultSpinValue")),
     269             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SpinIncrement")),
     270             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Repeat")),
     271             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RepeatDelay")),
     272             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlLabel")), /// TODO: has to be checked
     273             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LabelControl")),
     274             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title")), // comment this out if you want to have title feature for charts
     275             :                 PROPERTY_MAXTEXTLEN,
     276             :                 PROPERTY_EFFECTIVEDEFAULT,
     277             :                 PROPERTY_EFFECTIVEMAX,
     278             :                 PROPERTY_EFFECTIVEMIN,
     279             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HideInactiveSelection")),
     280             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SubmitAction")),
     281             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InputRequired")),
     282             :                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VerticalAlign")),
     283             :                 PROPERTY_ALIGN,
     284             :                 PROPERTY_EMPTY_IS_NULL,
     285             :                 PROPERTY_FILTERPROPOSAL
     286             :                 ,PROPERTY_POSITIONX
     287             :                 ,PROPERTY_POSITIONY
     288             :                 ,PROPERTY_WIDTH
     289             :                 ,PROPERTY_HEIGHT
     290             :                 ,PROPERTY_FONT
     291             :                 ,PROPERTY_LABEL
     292             :                 ,PROPERTY_LINECOLOR
     293             :                 ,PROPERTY_BORDER
     294             :                 ,PROPERTY_BORDERCOLOR
     295             :                 ,PROPERTY_BACKTRANSPARENT
     296             :                 ,PROPERTY_CONTROLBACKGROUND
     297             :                 ,PROPERTY_BACKGROUNDCOLOR
     298             :                 ,PROPERTY_CONTROLBACKGROUNDTRANSPARENT
     299             :                 ,PROPERTY_FORMULALIST
     300             :                 ,PROPERTY_SCOPE
     301             :                 ,PROPERTY_TYPE
     302             :                 ,PROPERTY_DATASOURCENAME
     303             :                 ,PROPERTY_VERTICALALIGN
     304           0 :         };
     305             : 
     306           0 :         beans::Property* pPropsIter = aProps.getArray();
     307           0 :         beans::Property* pPropsEnd = pPropsIter + aProps.getLength();
     308           0 :         for (; pPropsIter != pPropsEnd; ++pPropsIter)
     309             :         {
     310           0 :             size_t nPos = 0;
     311           0 :             for (; nPos < sizeof(pExcludeProperties)/sizeof(pExcludeProperties[0]) && pExcludeProperties[nPos] != pPropsIter->Name;++nPos )
     312             :                 ;
     313           0 :             if ( nPos == sizeof(pExcludeProperties)/sizeof(pExcludeProperties[0]) )
     314           0 :                 _rExcludeProperties.push_back(*pPropsIter);
     315           0 :         }
     316           0 :     }
     317             : 
     318             : 
     319             : //............................................................................
     320             : } // namespace pcr
     321             : //............................................................................
     322             : 
     323             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10