LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/filter/xml - xmlColumn.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 73 0.0 %
Date: 2012-12-27 Functions: 0 5 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 "xmlColumn.hxx"
      21             : #include "xmlfilter.hxx"
      22             : #include <xmloff/xmltoken.hxx>
      23             : #include <xmloff/xmluconv.hxx>
      24             : #include <xmloff/xmlnmspe.hxx>
      25             : #include <xmloff/nmspmap.hxx>
      26             : #include "xmlEnums.hxx"
      27             : #include "xmlstrings.hrc"
      28             : #include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
      29             : #include <com/sun/star/sdbcx/XAppend.hpp>
      30             : #include <com/sun/star/beans/PropertyValue.hpp>
      31             : #include <com/sun/star/container/XNameContainer.hpp>
      32             : #include <com/sun/star/container/XChild.hpp>
      33             : #include "xmlStyleImport.hxx"
      34             : #include <tools/debug.hxx>
      35             : 
      36             : namespace dbaxml
      37             : {
      38             :     using namespace ::com::sun::star::uno;
      39             :     using namespace ::com::sun::star::beans;
      40             :     using namespace ::com::sun::star::sdbcx;
      41             :     using namespace ::com::sun::star::container;
      42             :     using namespace ::com::sun::star::xml::sax;
      43             : DBG_NAME(OXMLColumn)
      44             : 
      45           0 : OXMLColumn::OXMLColumn( ODBFilter& rImport
      46             :                 ,sal_uInt16 nPrfx
      47             :                 ,const ::rtl::OUString& _sLocalName
      48             :                 ,const Reference< XAttributeList > & _xAttrList
      49             :                 ,const Reference< XNameAccess >& _xParentContainer
      50             :                 ,const Reference< XPropertySet >& _xTable
      51             :                 ) :
      52             :     SvXMLImportContext( rImport, nPrfx, _sLocalName )
      53             :     ,m_xParentContainer(_xParentContainer)
      54             :     ,m_xTable(_xTable)
      55           0 :     ,m_bHidden(sal_False)
      56             : {
      57             :     DBG_CTOR(OXMLColumn,NULL);
      58             : 
      59             :     OSL_ENSURE(_xAttrList.is(),"Attribute list is NULL!");
      60           0 :     const SvXMLNamespaceMap& rMap = rImport.GetNamespaceMap();
      61           0 :     const SvXMLTokenMap& rTokenMap = rImport.GetColumnElemTokenMap();
      62             : 
      63           0 :     sal_Int16 nLength = (_xAttrList.is()) ? _xAttrList->getLength() : 0;
      64           0 :     ::rtl::OUString sType;
      65           0 :     for(sal_Int16 i = 0; i < nLength; ++i)
      66             :     {
      67           0 :         ::rtl::OUString sLocalName;
      68           0 :         rtl::OUString sAttrName = _xAttrList->getNameByIndex( i );
      69           0 :         sal_uInt16 nPrefix = rMap.GetKeyByAttrName( sAttrName,&sLocalName );
      70           0 :         rtl::OUString sValue = _xAttrList->getValueByIndex( i );
      71             : 
      72           0 :         switch( rTokenMap.Get( nPrefix, sLocalName ) )
      73             :         {
      74             :             case XML_TOK_COLUMN_NAME:
      75           0 :                 m_sName = sValue;
      76           0 :                 break;
      77             :             case XML_TOK_COLUMN_STYLE_NAME:
      78           0 :                 m_sStyleName = sValue;
      79           0 :                 break;
      80             :             case XML_TOK_COLUMN_HELP_MESSAGE:
      81           0 :                 m_sHelpMessage = sValue;
      82           0 :                 break;
      83             :             case XML_TOK_COLUMN_VISIBILITY:
      84           0 :                 m_bHidden = sValue != "visible";
      85           0 :                 break;
      86             :             case XML_TOK_COLUMN_TYPE_NAME:
      87           0 :                 sType = sValue;
      88             :                 OSL_ENSURE(!sType.isEmpty(),"No type name set");
      89           0 :                 break;
      90             :             case XML_TOK_COLUMN_DEFAULT_VALUE:
      91           0 :                 if ( !(sValue.isEmpty() || sType.isEmpty()) )
      92           0 :                     m_aDefaultValue <<= sValue;
      93           0 :                 break;
      94             :             case XML_TOK_COLUMN_VISIBLE:
      95           0 :                 m_bHidden = sValue == "false";
      96           0 :                 break;
      97             :             case XML_TOK_DEFAULT_CELL_STYLE_NAME:
      98           0 :                 m_sCellStyleName = sValue;
      99           0 :                 break;
     100             :         }
     101           0 :     }
     102           0 : }
     103             : // -----------------------------------------------------------------------------
     104             : 
     105           0 : OXMLColumn::~OXMLColumn()
     106             : {
     107             : 
     108             :     DBG_DTOR(OXMLColumn,NULL);
     109           0 : }
     110             : // -----------------------------------------------------------------------------
     111           0 : void OXMLColumn::EndElement()
     112             : {
     113           0 :     Reference<XDataDescriptorFactory> xFac(m_xParentContainer,UNO_QUERY);
     114           0 :     if ( xFac.is() && !m_sName.isEmpty() )
     115             :     {
     116           0 :         Reference<XPropertySet> xProp(xFac->createDataDescriptor());
     117           0 :         if ( xProp.is() )
     118             :         {
     119           0 :             xProp->setPropertyValue(PROPERTY_NAME,makeAny(m_sName));
     120           0 :             xProp->setPropertyValue(PROPERTY_HIDDEN,makeAny(m_bHidden));
     121           0 :             if ( !m_sHelpMessage.isEmpty() )
     122           0 :                 xProp->setPropertyValue(PROPERTY_HELPTEXT,makeAny(m_sHelpMessage));
     123             : 
     124           0 :             if ( m_aDefaultValue.hasValue() )
     125           0 :                 xProp->setPropertyValue(PROPERTY_CONTROLDEFAULT,m_aDefaultValue);
     126             : 
     127           0 :             Reference<XAppend> xAppend(m_xParentContainer,UNO_QUERY);
     128           0 :             if ( xAppend.is() )
     129           0 :                 xAppend->appendByDescriptor(xProp);
     130           0 :             m_xParentContainer->getByName(m_sName) >>= xProp;
     131             : 
     132           0 :             if ( !m_sStyleName.isEmpty() )
     133             :             {
     134           0 :                 const SvXMLStylesContext* pAutoStyles = GetOwnImport().GetAutoStyles();
     135           0 :                 if ( pAutoStyles )
     136             :                 {
     137           0 :                     OTableStyleContext* pAutoStyle = PTR_CAST(OTableStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_COLUMN,m_sStyleName));
     138           0 :                     if ( pAutoStyle )
     139             :                     {
     140           0 :                         pAutoStyle->FillPropertySet(xProp);
     141             :                     }
     142             :                 }
     143             :             }
     144           0 :             if ( !m_sCellStyleName.isEmpty() )
     145             :             {
     146           0 :                 const SvXMLStylesContext* pAutoStyles = GetOwnImport().GetAutoStyles();
     147           0 :                 if ( pAutoStyles )
     148             :                 {
     149           0 :                     OTableStyleContext* pAutoStyle = PTR_CAST(OTableStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_CELL,m_sCellStyleName));
     150           0 :                     if ( pAutoStyle )
     151             :                     {
     152           0 :                         pAutoStyle->FillPropertySet(xProp);
     153             :                         // we also have to do this on the table to import text-properties
     154           0 :                         pAutoStyle->FillPropertySet(m_xTable);
     155             :                     }
     156             :                 }
     157           0 :             }
     158             : 
     159           0 :         }
     160             :     }
     161           0 :     else if ( !m_sCellStyleName.isEmpty() )
     162             :     {
     163           0 :         const SvXMLStylesContext* pAutoStyles = GetOwnImport().GetAutoStyles();
     164           0 :         if ( pAutoStyles )
     165             :         {
     166           0 :             OTableStyleContext* pAutoStyle = PTR_CAST(OTableStyleContext,pAutoStyles->FindStyleChildContext(XML_STYLE_FAMILY_TABLE_CELL,m_sCellStyleName));
     167           0 :             if ( pAutoStyle )
     168             :             {
     169             :                 // we also have to do this on the table to import text-properties
     170           0 :                 pAutoStyle->FillPropertySet(m_xTable);
     171             :             }
     172             :         }
     173           0 :     }
     174           0 : }
     175             : // -----------------------------------------------------------------------------
     176           0 : ODBFilter& OXMLColumn::GetOwnImport()
     177             : {
     178           0 :     return static_cast<ODBFilter&>(GetImport());
     179             : }
     180             : //----------------------------------------------------------------------------
     181             : } // namespace dbaxml
     182             : // -----------------------------------------------------------------------------
     183             : 
     184             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10