LCOV - code coverage report
Current view: top level - xmloff/source/forms - formattributes.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 157 0.0 %
Date: 2014-04-14 Functions: 0 22 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 "formattributes.hxx"
      21             : 
      22             : #include <sax/tools/converter.hxx>
      23             : 
      24             : #include <xmloff/xmlnmspe.hxx>
      25             : #include <xmloff/xmluconv.hxx>
      26             : #include <rtl/ustrbuf.hxx>
      27             : namespace xmloff
      28             : {
      29             : 
      30             :     using namespace ::com::sun::star::uno;
      31             :     using namespace ::com::sun::star::lang;
      32             :     using namespace ::com::sun::star::beans;
      33             : 
      34             :     //= OAttributeMetaData
      35           0 :     const sal_Char* OAttributeMetaData::getCommonControlAttributeName(sal_Int32 _nId)
      36             :     {
      37           0 :         switch (_nId)
      38             :         {
      39           0 :             case CCA_NAME:              return "name";
      40           0 :             case CCA_SERVICE_NAME:      return "control-implementation";
      41           0 :             case CCA_BUTTON_TYPE:       return "button-type";
      42             : // disabled(AddAttributeIdLegacy)   case CCA_CONTROL_ID:        return "id";
      43           0 :             case CCA_CURRENT_SELECTED:  return "current-selected";
      44           0 :             case CCA_CURRENT_VALUE:     return "current-value";
      45           0 :             case CCA_DISABLED:          return "disabled";
      46           0 :             case CCA_ENABLEVISIBLE:     return "visible";
      47           0 :             case CCA_DROPDOWN:          return "dropdown";
      48           0 :             case CCA_FOR:               return "for";
      49           0 :             case CCA_IMAGE_DATA:        return "image-data";
      50           0 :             case CCA_LABEL:             return "label";
      51           0 :             case CCA_MAX_LENGTH:        return "max-length";
      52           0 :             case CCA_PRINTABLE:         return "printable";
      53           0 :             case CCA_READONLY:          return "readonly";
      54           0 :             case CCA_SELECTED:          return "selected";
      55           0 :             case CCA_SIZE:              return "size";
      56           0 :             case CCA_TAB_INDEX:         return "tab-index";
      57           0 :             case CCA_TARGET_FRAME:      return "target-frame";
      58           0 :             case CCA_TARGET_LOCATION:   return "href";      // the only special thing here: TargetLocation is represented by an xlink:href attribute
      59           0 :             case CCA_TAB_STOP:          return "tab-stop";
      60           0 :             case CCA_TITLE:             return "title";
      61           0 :             case CCA_VALUE:             return "value";
      62           0 :             case CCA_ORIENTATION:       return "orientation";
      63           0 :             case CCA_VISUAL_EFFECT:     return "visual-effect";
      64             :             default:
      65             :                 OSL_FAIL("OAttributeMetaData::getCommonControlAttributeName: invalid id (maybe you or-ed two flags?)!");
      66             :         }
      67           0 :         return "";
      68             :     }
      69             : 
      70           0 :     sal_uInt16 OAttributeMetaData::getCommonControlAttributeNamespace(sal_Int32 _nId)
      71             :     {
      72           0 :         if (CCA_TARGET_LOCATION == _nId)
      73           0 :             return XML_NAMESPACE_XLINK;
      74             : 
      75           0 :         if (CCA_TARGET_FRAME == _nId)
      76           0 :             return XML_NAMESPACE_OFFICE;
      77             : 
      78           0 :         return XML_NAMESPACE_FORM;
      79             :     }
      80             : 
      81           0 :     const sal_Char* OAttributeMetaData::getFormAttributeName(FormAttributes _eAttrib)
      82             :     {
      83           0 :         switch (_eAttrib)
      84             :         {
      85           0 :             case faName:                return "name";
      86           0 :             case faServiceName:         return "service-name";
      87           0 :             case faAction:              return "href";      // the only special thing here: Action is represented by an xlink:href attribute
      88           0 :             case faEnctype:             return "enctype";
      89           0 :             case faMethod:              return "method";
      90           0 :             case faTargetFrame:         return "target-frame";
      91           0 :             case faAllowDeletes:        return "allow-deletes";
      92           0 :             case faAllowInserts:        return "allow-inserts";
      93           0 :             case faAllowUpdates:        return "allow-updates";
      94           0 :             case faApplyFilter:         return "apply-filter";
      95           0 :             case faCommand:             return "command";
      96           0 :             case faCommandType:         return "command-type";
      97           0 :             case faEscapeProcessing:    return "escape-processing";
      98           0 :             case faDatasource:          return "datasource";
      99           0 :             case faConnectionResource:  return "connection-resource";
     100           0 :             case faDetailFiels:         return "detail-fields";
     101           0 :             case faFilter:              return "filter";
     102           0 :             case faIgnoreResult:        return "ignore-result";
     103           0 :             case faMasterFields:        return "master-fields";
     104           0 :             case faNavigationMode:      return "navigation-mode";
     105           0 :             case faOrder:               return "order";
     106           0 :             case faTabbingCycle:        return "tab-cycle";
     107             :             default:
     108             :                 OSL_FAIL("OAttributeMetaData::getFormAttributeName: invalid id!");
     109             :         }
     110           0 :         return "";
     111             :     }
     112             : 
     113           0 :     sal_uInt16 OAttributeMetaData::getFormAttributeNamespace(FormAttributes _eAttrib)
     114             :     {
     115           0 :         if (faAction == _eAttrib)
     116           0 :             return XML_NAMESPACE_XLINK;
     117             : 
     118           0 :         if (faTargetFrame == _eAttrib)
     119           0 :             return XML_NAMESPACE_OFFICE;
     120             : 
     121           0 :         return XML_NAMESPACE_FORM;
     122             :     }
     123             : 
     124           0 :     const sal_Char* OAttributeMetaData::getDatabaseAttributeName(sal_Int32 _nId)
     125             :     {
     126           0 :         switch (_nId)
     127             :         {
     128           0 :             case DA_BOUND_COLUMN:       return "bound-column";
     129           0 :             case DA_CONVERT_EMPTY:      return "convert-empty-to-null";
     130           0 :             case DA_DATA_FIELD:         return "data-field";
     131           0 :             case DA_LIST_SOURCE:        return "list-source";
     132           0 :             case DA_LIST_SOURCE_TYPE:   return "list-source-type";
     133           0 :             case DA_INPUT_REQUIRED:     return "input-required";
     134             :             default:
     135             :                 OSL_FAIL("OAttributeMetaData::getDatabaseAttributeName: invalid id (maybe you or-ed two flags?)!");
     136             :         }
     137           0 :         return "";
     138             :     }
     139             : 
     140           0 :     sal_uInt16 OAttributeMetaData::getDatabaseAttributeNamespace(sal_Int32 /*_nId*/)
     141             :     {
     142             :         // nothing special here
     143           0 :         return XML_NAMESPACE_FORM;
     144             :     }
     145             : 
     146           0 :     const sal_Char* OAttributeMetaData::getBindingAttributeName(sal_Int32 _nId)
     147             :     {
     148           0 :         switch (_nId)
     149             :         {
     150           0 :             case BA_LINKED_CELL:       return "linked-cell";
     151           0 :             case BA_LIST_LINKING_TYPE: return "list-linkage-type";
     152           0 :             case BA_LIST_CELL_RANGE:   return "source-cell-range";
     153             :             default:
     154             :                 OSL_FAIL("OAttributeMetaData::getBindingAttributeName: invalid id (maybe you or-ed two flags?)!");
     155             :         }
     156           0 :         return "";
     157             :     }
     158             : 
     159           0 :     sal_uInt16 OAttributeMetaData::getBindingAttributeNamespace(sal_Int32)
     160             :     {
     161             :         // nothing special here
     162           0 :         return XML_NAMESPACE_FORM;
     163             :     }
     164             : 
     165           0 :     const sal_Char* OAttributeMetaData::getSpecialAttributeName(sal_Int32 _nId)
     166             :     {
     167           0 :         switch (_nId)
     168             :         {
     169           0 :             case SCA_ECHO_CHAR:             return "echo-char";
     170           0 :             case SCA_MAX_VALUE:             return "max-value";
     171           0 :             case SCA_MIN_VALUE:             return "min-value";
     172           0 :             case SCA_VALIDATION:            return "validation";
     173           0 :             case SCA_GROUP_NAME:            return "group-name";
     174           0 :             case SCA_MULTI_LINE:            return "multi-line";
     175           0 :             case SCA_AUTOMATIC_COMPLETION:  return "auto-complete";
     176           0 :             case SCA_MULTIPLE:              return "multiple";
     177           0 :             case SCA_DEFAULT_BUTTON:        return "default-button";
     178           0 :             case SCA_CURRENT_STATE:         return "current-state";
     179           0 :             case SCA_IS_TRISTATE:           return "is-tristate";
     180           0 :             case SCA_STATE:                 return "state";
     181           0 :             case SCA_COLUMN_STYLE_NAME:     return "text-style-name";
     182           0 :             case SCA_STEP_SIZE:             return "step-size";
     183           0 :             case SCA_PAGE_STEP_SIZE:        return "page-step-size";
     184           0 :             case SCA_REPEAT_DELAY:          return "delay-for-repeat";
     185           0 :             case SCA_TOGGLE:                return "toggle";
     186           0 :             case SCA_FOCUS_ON_CLICK:        return "focus-on-click";
     187             :             default:
     188             :                 OSL_FAIL("OAttributeMetaData::getSpecialAttributeName: invalid id (maybe you or-ed two flags?)!");
     189             :         }
     190           0 :         return "";
     191             :     }
     192             : 
     193           0 :     sal_uInt16 OAttributeMetaData::getSpecialAttributeNamespace(sal_Int32 _nId)
     194             :     {
     195           0 :         switch( _nId )
     196             :         {
     197           0 :             case SCA_GROUP_NAME:            return XML_NAMESPACE_FORMX;
     198             :         }
     199           0 :         return XML_NAMESPACE_FORM;
     200             :     }
     201             : 
     202           0 :     const sal_Char* OAttributeMetaData::getOfficeFormsAttributeName(OfficeFormsAttributes _eAttrib)
     203             :     {
     204           0 :         switch (_eAttrib)
     205             :         {
     206           0 :             case ofaAutomaticFocus:     return "automatic-focus";
     207           0 :             case ofaApplyDesignMode:    return "apply-design-mode";
     208             :             default:
     209             :                 OSL_FAIL("OAttributeMetaData::getOfficeFormsAttributeName: invalid id!");
     210             :         }
     211           0 :         return "";
     212             :     }
     213             : 
     214           0 :     sal_uInt16 OAttributeMetaData::getOfficeFormsAttributeNamespace(OfficeFormsAttributes /* _eAttrib */)
     215             :     {
     216             :         // nothing special here
     217           0 :         return XML_NAMESPACE_FORM;
     218             :     }
     219             : 
     220             :     //= OAttribute2Property
     221           0 :     OAttribute2Property::OAttribute2Property()
     222             :     {
     223           0 :     }
     224             : 
     225           0 :     OAttribute2Property::~OAttribute2Property()
     226             :     {
     227           0 :     }
     228             : 
     229           0 :     const OAttribute2Property::AttributeAssignment* OAttribute2Property::getAttributeTranslation(
     230             :             const OUString& _rAttribName)
     231             :     {
     232           0 :         AttributeAssignments::const_iterator aPos = m_aKnownProperties.find(_rAttribName);
     233           0 :         if (m_aKnownProperties.end() != aPos)
     234           0 :             return &aPos->second;
     235           0 :         return NULL;
     236             :     }
     237             : 
     238           0 :     void OAttribute2Property::addStringProperty(
     239             :         const sal_Char* _pAttributeName, const OUString& _rPropertyName,
     240             :         const sal_Char* _pAttributeDefault)
     241             :     {
     242           0 :         implAdd(_pAttributeName, _rPropertyName, ::getCppuType( static_cast< OUString* >(NULL) ),
     243           0 :             _pAttributeDefault ? OUString::createFromAscii(_pAttributeDefault) : OUString());
     244           0 :     }
     245             : 
     246           0 :     void OAttribute2Property::addBooleanProperty(
     247             :         const sal_Char* _pAttributeName, const OUString& _rPropertyName,
     248             :         const sal_Bool _bAttributeDefault, const sal_Bool _bInverseSemantics)
     249             :     {
     250           0 :         OUStringBuffer aDefault;
     251           0 :         ::sax::Converter::convertBool(aDefault, _bAttributeDefault);
     252           0 :         AttributeAssignment& aAssignment = implAdd(_pAttributeName, _rPropertyName, ::getBooleanCppuType(), aDefault.makeStringAndClear());
     253           0 :         aAssignment.bInverseSemantics = _bInverseSemantics;
     254           0 :     }
     255             : 
     256           0 :     void OAttribute2Property::addInt16Property(
     257             :         const sal_Char* _pAttributeName, const OUString& _rPropertyName,
     258             :         const sal_Int16 _nAttributeDefault)
     259             :     {
     260           0 :         OUStringBuffer aDefault;
     261           0 :         ::sax::Converter::convertNumber(aDefault, (sal_Int32)_nAttributeDefault);
     262           0 :         implAdd(_pAttributeName, _rPropertyName, ::getCppuType( static_cast< sal_Int16* >(NULL) ), aDefault.makeStringAndClear());
     263           0 :     }
     264             : 
     265           0 :     void OAttribute2Property::addInt32Property(
     266             :         const sal_Char* _pAttributeName, const OUString& _rPropertyName,
     267             :         const sal_Int32 _nAttributeDefault)
     268             :     {
     269           0 :         OUStringBuffer aDefault;
     270           0 :         ::sax::Converter::convertNumber( aDefault, _nAttributeDefault );
     271           0 :         implAdd( _pAttributeName, _rPropertyName, ::getCppuType( static_cast< sal_Int32* >(NULL) ), aDefault.makeStringAndClear() );
     272           0 :     }
     273             : 
     274           0 :     void OAttribute2Property::addEnumProperty(
     275             :             const sal_Char* _pAttributeName, const OUString& _rPropertyName,
     276             :             const sal_uInt16 _nAttributeDefault, const SvXMLEnumMapEntry* _pValueMap,
     277             :             const ::com::sun::star::uno::Type* _pType)
     278             :     {
     279           0 :         OUStringBuffer aDefault;
     280           0 :         SvXMLUnitConverter::convertEnum(aDefault, _nAttributeDefault, _pValueMap);
     281             :         AttributeAssignment& aAssignment = implAdd(_pAttributeName, _rPropertyName,
     282             :             _pType ? *_pType : ::getCppuType( static_cast< sal_Int32* >(NULL) ),
     283             :                 // this assumes that the setPropertyValue for enums can handle int32's ....
     284           0 :             aDefault.makeStringAndClear());
     285           0 :         aAssignment.pEnumMap = _pValueMap;
     286           0 :     }
     287             : 
     288           0 :     OAttribute2Property::AttributeAssignment& OAttribute2Property::implAdd(
     289             :             const sal_Char* _pAttributeName, const OUString& _rPropertyName,
     290             :             const ::com::sun::star::uno::Type& _rType, const OUString& /*_rDefaultString*/)
     291             :     {
     292             :         OSL_ENSURE(m_aKnownProperties.end() == m_aKnownProperties.find(OUString::createFromAscii(_pAttributeName)),
     293             :             "OAttribute2Property::implAdd: already have this attribute!");
     294             : 
     295           0 :         OUString sAttributeName = OUString::createFromAscii(_pAttributeName);
     296             : 
     297           0 :         AttributeAssignment aAssignment;
     298           0 :         aAssignment.sAttributeName = sAttributeName;
     299           0 :         aAssignment.sPropertyName = _rPropertyName;
     300           0 :         aAssignment.aPropertyType = _rType;
     301             : 
     302             :         // redundance, the accessor is stored in aAssignment.sAttributeName, too
     303           0 :         return m_aKnownProperties[sAttributeName] = aAssignment;
     304             :     }
     305             : 
     306             : }   // namespace xmloff
     307             : 
     308             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10