LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLSectionSourceDDEImportContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 52 0.0 %
Date: 2012-08-25 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 109 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "XMLSectionSourceDDEImportContext.hxx"
      30                 :            : #include "XMLSectionImportContext.hxx"
      31                 :            : #include <com/sun/star/text/SectionFileLink.hpp>
      32                 :            : #include <xmloff/xmlictxt.hxx>
      33                 :            : #include <xmloff/xmlimp.hxx>
      34                 :            : #include <xmloff/txtimp.hxx>
      35                 :            : #include <xmloff/nmspmap.hxx>
      36                 :            : #include "xmloff/xmlnmspe.hxx"
      37                 :            : #include <xmloff/xmltoken.hxx>
      38                 :            : #include <sax/tools/converter.hxx>
      39                 :            : #include <com/sun/star/uno/Reference.h>
      40                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      41                 :            : #include <com/sun/star/beans/XMultiPropertySet.hpp>
      42                 :            : #include <tools/debug.hxx>
      43                 :            : 
      44                 :            : using ::rtl::OUString;
      45                 :            : using ::com::sun::star::beans::XPropertySet;
      46                 :            : using ::com::sun::star::beans::XMultiPropertySet;
      47                 :            : using ::com::sun::star::uno::Reference;
      48                 :            : using ::com::sun::star::xml::sax::XAttributeList;
      49                 :            : 
      50                 :            : using namespace ::com::sun::star::uno;
      51                 :            : using namespace ::com::sun::star::text;
      52                 :            : using namespace ::xmloff::token;
      53                 :            : 
      54                 :            : const sal_Char sAPI_DDECommandFile[] = "DDECommandFile";
      55                 :            : const sal_Char sAPI_DDECommandType[] = "DDECommandType";
      56                 :            : const sal_Char sAPI_DDECommandElement[] = "DDECommandElement";
      57                 :            : const sal_Char sAPI_IsAutomaticUpdate[] = "IsAutomaticUpdate";
      58                 :            : 
      59                 :            : 
      60 [ #  # ][ #  # ]:          0 : TYPEINIT1(XMLSectionSourceDDEImportContext, SvXMLImportContext);
      61                 :            : 
      62                 :          0 : XMLSectionSourceDDEImportContext::XMLSectionSourceDDEImportContext(
      63                 :            :     SvXMLImport& rImport,
      64                 :            :     sal_uInt16 nPrfx,
      65                 :            :     const OUString& rLocalName,
      66                 :            :     Reference<XPropertySet> & rSectPropSet) :
      67                 :            :         SvXMLImportContext(rImport, nPrfx, rLocalName),
      68                 :            :         rSectionPropertySet(rSectPropSet),
      69                 :            :         sDdeCommandFile(RTL_CONSTASCII_USTRINGPARAM(sAPI_DDECommandFile)),
      70                 :            :         sDdeCommandType(RTL_CONSTASCII_USTRINGPARAM(sAPI_DDECommandType)),
      71                 :            :        sDdeCommandElement(RTL_CONSTASCII_USTRINGPARAM(sAPI_DDECommandElement)),
      72 [ #  # ][ #  # ]:          0 :         sIsAutomaticUpdate(RTL_CONSTASCII_USTRINGPARAM(sAPI_IsAutomaticUpdate))
         [ #  # ][ #  # ]
      73                 :            : {
      74                 :          0 : }
      75                 :            : 
      76                 :          0 : XMLSectionSourceDDEImportContext::~XMLSectionSourceDDEImportContext()
      77                 :            : {
      78         [ #  # ]:          0 : }
      79                 :            : 
      80                 :            : enum XMLSectionSourceDDEToken
      81                 :            : {
      82                 :            :     XML_TOK_SECTION_DDE_APPLICATION,
      83                 :            :     XML_TOK_SECTION_DDE_TOPIC,
      84                 :            :     XML_TOK_SECTION_DDE_ITEM,
      85                 :            :     XML_TOK_SECTION_IS_AUTOMATIC_UPDATE
      86                 :            : };
      87                 :            : 
      88                 :            : static SvXMLTokenMapEntry aSectionSourceDDETokenMap[] =
      89                 :            : {
      90                 :            :     { XML_NAMESPACE_OFFICE, XML_DDE_APPLICATION,
      91                 :            :           XML_TOK_SECTION_DDE_APPLICATION },
      92                 :            :     { XML_NAMESPACE_OFFICE, XML_DDE_TOPIC, XML_TOK_SECTION_DDE_TOPIC },
      93                 :            :     { XML_NAMESPACE_OFFICE, XML_DDE_ITEM, XML_TOK_SECTION_DDE_ITEM },
      94                 :            :     { XML_NAMESPACE_OFFICE, XML_AUTOMATIC_UPDATE,
      95                 :            :           XML_TOK_SECTION_IS_AUTOMATIC_UPDATE },
      96                 :            :     XML_TOKEN_MAP_END
      97                 :            : };
      98                 :            : 
      99                 :            : 
     100                 :          0 : void XMLSectionSourceDDEImportContext::StartElement(
     101                 :            :     const Reference<XAttributeList> & xAttrList)
     102                 :            : {
     103         [ #  # ]:          0 :     SvXMLTokenMap aTokenMap(aSectionSourceDDETokenMap);
     104                 :          0 :     OUString sApplication;
     105                 :          0 :     OUString sTopic;
     106                 :          0 :     OUString sItem;
     107                 :          0 :     sal_Bool bAutomaticUpdate = sal_False;
     108                 :            : 
     109 [ #  # ][ #  # ]:          0 :     sal_Int16 nLength = xAttrList->getLength();
     110         [ #  # ]:          0 :     for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
     111                 :            :     {
     112                 :          0 :         OUString sLocalName;
     113                 :          0 :         sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
     114         [ #  # ]:          0 :             GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
     115   [ #  #  #  # ]:          0 :                               &sLocalName );
     116                 :            : 
     117   [ #  #  #  #  :          0 :         switch (aTokenMap.Get(nPrefix, sLocalName))
              # ][ #  # ]
     118                 :            :         {
     119                 :            :             case XML_TOK_SECTION_DDE_APPLICATION:
     120 [ #  # ][ #  # ]:          0 :                 sApplication = xAttrList->getValueByIndex(nAttr);
     121                 :          0 :                 break;
     122                 :            :             case XML_TOK_SECTION_DDE_TOPIC:
     123 [ #  # ][ #  # ]:          0 :                 sTopic = xAttrList->getValueByIndex(nAttr);
     124                 :          0 :                 break;
     125                 :            :             case XML_TOK_SECTION_DDE_ITEM:
     126 [ #  # ][ #  # ]:          0 :                 sItem = xAttrList->getValueByIndex(nAttr);
     127                 :          0 :                 break;
     128                 :            :             case XML_TOK_SECTION_IS_AUTOMATIC_UPDATE:
     129                 :            :             {
     130                 :          0 :                 bool bTmp(false);
     131   [ #  #  #  # ]:          0 :                 if (::sax::Converter::convertBool(
     132 [ #  # ][ #  # ]:          0 :                     bTmp, xAttrList->getValueByIndex(nAttr)))
     133                 :            :                 {
     134                 :          0 :                     bAutomaticUpdate = bTmp;
     135                 :            :                 }
     136                 :            :                 break;
     137                 :            :             }
     138                 :            :             default:
     139                 :            :                 ; // ignore
     140                 :          0 :                 break;
     141                 :            :         }
     142                 :          0 :     }
     143                 :            : 
     144                 :            :     // DDE not supported on all platforms; query property first
     145 [ #  # ][ #  # ]:          0 :     if (rSectionPropertySet->getPropertySetInfo()->
         [ #  # ][ #  # ]
     146         [ #  # ]:          0 :         hasPropertyByName(sDdeCommandFile))
     147                 :            :     {
     148                 :            :         // use multi property set to force single update of connection #83654#
     149         [ #  # ]:          0 :         Sequence<OUString> aNames(4);
     150         [ #  # ]:          0 :         Sequence<Any> aValues(4);
     151                 :            : 
     152 [ #  # ][ #  # ]:          0 :         aValues[0] <<= sApplication;
     153         [ #  # ]:          0 :         aNames[0] = sDdeCommandFile;
     154                 :            : 
     155 [ #  # ][ #  # ]:          0 :         aValues[1] <<= sTopic;
     156         [ #  # ]:          0 :         aNames[1] = sDdeCommandType;
     157                 :            : 
     158 [ #  # ][ #  # ]:          0 :         aValues[2] <<= sItem;
     159         [ #  # ]:          0 :         aNames[2] = sDdeCommandElement;
     160                 :            : 
     161 [ #  # ][ #  # ]:          0 :         aValues[3].setValue(&bAutomaticUpdate, ::getBooleanCppuType());
     162         [ #  # ]:          0 :         aNames[3] = sIsAutomaticUpdate;
     163                 :            : 
     164                 :            :         Reference<XMultiPropertySet> rMultiPropSet(rSectionPropertySet,
     165         [ #  # ]:          0 :                                                    UNO_QUERY);
     166                 :            :         DBG_ASSERT(rMultiPropSet.is(), "we'd really like a XMultiPropertySet");
     167         [ #  # ]:          0 :         if (rMultiPropSet.is())
     168 [ #  # ][ #  # ]:          0 :             rMultiPropSet->setPropertyValues(aNames, aValues);
         [ #  # ][ #  # ]
     169                 :            :         // else: ignore
     170         [ #  # ]:          0 :     }
     171                 :          0 : }
     172                 :            : 
     173                 :          0 : void XMLSectionSourceDDEImportContext::EndElement()
     174                 :            : {
     175                 :            :     // nothing to be done!
     176                 :          0 : }
     177                 :            : 
     178                 :          0 : SvXMLImportContext* XMLSectionSourceDDEImportContext::CreateChildContext(
     179                 :            :     sal_uInt16 nPrefix,
     180                 :            :     const OUString& rLocalName,
     181                 :            :     const Reference<XAttributeList> & )
     182                 :            : {
     183                 :            :     // ignore -> default context
     184         [ #  # ]:          0 :     return new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
     185                 :            : }
     186                 :            : 
     187                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10