LCOV - code coverage report
Current view: top level - writerfilter/source/ooxml - OOXMLFastHelper.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 15 0.0 %
Date: 2014-04-14 Functions: 0 17 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             : #ifndef INCLUDED_FAST_HELPER_HXX
      20             : #define INCLUDED_FAST_HELPER_HXX
      21             : 
      22             : #include <iostream>
      23             : #include <resourcemodel/QNameToString.hxx>
      24             : #include "OOXMLFastContextHandler.hxx"
      25             : #include "ooxmlLoggers.hxx"
      26             : namespace writerfilter {
      27             : 
      28             : namespace ooxml
      29             : {
      30             : using namespace ::std;
      31             : using namespace ::com::sun::star;
      32             : using namespace ::com::sun::star::xml::sax;
      33             : 
      34             : template <class T>
      35             : class OOXMLFastHelper
      36             : {
      37             : public:
      38             :     static uno::Reference<XFastContextHandler> createAndSetParent
      39             :     (OOXMLFastContextHandler * pHandler, sal_uInt32 nToken, Id nId);
      40             : 
      41             :     static uno::Reference<XFastContextHandler> createAndSetParentAndDefine
      42             :     (OOXMLFastContextHandler * pHandler, sal_uInt32 nToken, Id nId, Id nDefine);
      43             : 
      44             :     static uno::Reference<XFastContextHandler> createAndSetParentRef
      45             :     (OOXMLFastContextHandler * pHandler, sal_uInt32 nToken,
      46             :      const uno::Reference < xml::sax::XFastAttributeList > & Attribs);
      47             : 
      48             :     static void newProperty(OOXMLFastContextHandler * pHandler,
      49             :                             Id nId,
      50             :                             const OUString & rValue);
      51             : 
      52             :     static void newProperty(OOXMLFastContextHandler * pHandler,
      53             :                             Id nId, sal_Int32 nValue);
      54             : 
      55             :     static void attributes
      56             :     (OOXMLFastContextHandler * pContext,
      57             :      const uno::Reference < xml::sax::XFastAttributeList > & Attribs);
      58             : };
      59             : 
      60             : template <class T>
      61             : uno::Reference<XFastContextHandler>
      62             : OOXMLFastHelper<T>::createAndSetParent
      63             : (OOXMLFastContextHandler * pHandler, sal_uInt32 nToken, Id nId)
      64             : {
      65             : #ifdef DEBUG_HELPER
      66             :     debug_logger->startElement("helper.createAndSetParent");
      67             :     debug_logger->attribute("context", pHandler->getType());
      68             :     debug_logger->attribute("id", (*QNameToString::Instance())(nId));
      69             : #endif
      70             : 
      71             :     OOXMLFastContextHandler * pTmp = new T(pHandler);
      72             : 
      73             :     pTmp->setToken(nToken);
      74             :     pTmp->setId(nId);
      75             : 
      76             : #ifdef DEBUG_CREATE
      77             :     debug_logger->startElement("createAndSetParent");
      78             :     debug_logger->attribute("context", pHandler->getType());
      79             :     debug_logger->attribute("token", fastTokenToId(pTmp->getToken()));
      80             :     debug_logger->attribute("id", (*QNameToString::Instance())(nId));
      81             : 
      82             :     debug_logger->startElement("created");
      83             :     debug_logger->addTag(pTmp->toTag());
      84             :     debug_logger->endElement("created");
      85             :     debug_logger->endElement("helper.createAndSetParent");
      86             : #endif
      87             : 
      88             :     uno::Reference<XFastContextHandler> aResult(pTmp);
      89             : 
      90             :     return aResult;
      91             : }
      92             : 
      93             : template <class T>
      94             : uno::Reference<XFastContextHandler>
      95           0 : OOXMLFastHelper<T>::createAndSetParentAndDefine
      96             : (OOXMLFastContextHandler * pHandler, sal_uInt32 nToken, Id nId, Id nDefine)
      97             : {
      98             : #ifdef DEBUG_HELPER
      99             :     debug_logger->startElement("helper.createAndSetParentAndDefine");
     100             :     debug_logger->attribute("context", pHandler->getType());
     101             :     debug_logger->attribute("id", (*QNameToString::Instance())(nId));
     102             : 
     103             :     static char buffer[16];
     104             :     snprintf(buffer, sizeof(buffer), "0x%08" SAL_PRIxUINT32, nId);
     105             : 
     106             :     debug_logger->attribute("idnum", buffer);
     107             : #endif
     108             : 
     109           0 :     OOXMLFastContextHandler * pTmp = new T(pHandler);
     110             : 
     111           0 :     pTmp->setToken(nToken);
     112           0 :     pTmp->setId(nId);
     113           0 :     pTmp->setDefine(nDefine);
     114             : 
     115             : 
     116             : #ifdef DEBUG_HELPER
     117             :     debug_logger->startElement("created");
     118             :     debug_logger->addTag(pTmp->toTag());
     119             :     debug_logger->endElement("created");
     120             :     debug_logger->endElement("helper.createAndSetParentAndDefine");
     121             : #endif
     122             : 
     123           0 :     uno::Reference<XFastContextHandler> aResult(pTmp);
     124             : 
     125           0 :     return aResult;
     126             : }
     127             : 
     128             : template <class T>
     129             : uno::Reference<XFastContextHandler>
     130             : OOXMLFastHelper<T>::createAndSetParentRef
     131             : (OOXMLFastContextHandler * pHandler, sal_uInt32 nToken,
     132             :  const uno::Reference < xml::sax::XFastAttributeList > & Attribs)
     133             : {
     134             : #ifdef DEBUG_HELPER
     135             :     debug_logger->startElement("helper.createAndSetParentRef");
     136             :     debug_logger->attribute("context", pHandler->getType());
     137             :     debug_logger->attribute("type", fastTokenToId(nToken));
     138             : #endif
     139             : 
     140             :     boost::shared_ptr<OOXMLFastContextHandler> pTmp(new T(pHandler));
     141             : 
     142             :     uno::Reference<XFastContextHandler> xChild =
     143             :         pTmp->createFastChildContext(nToken, Attribs);
     144             : 
     145             :     if (xChild.is())
     146             :     {
     147             :         OOXMLFastContextHandler* pResult = dynamic_cast<OOXMLFastContextHandler *>(xChild.get());
     148             :         pResult->setToken(nToken);
     149             :         pResult->setParent(pHandler);
     150             :     }
     151             : 
     152             : 
     153             : #ifdef DEBUG_HELPER
     154             :     debug_logger->startElement("created");
     155             :     debug_logger->addTag(pTmp->toTag());
     156             :     debug_logger->endElement("created");
     157             :     debug_logger->endElement("helper.createAndSetParentRef");
     158             : #endif
     159             : 
     160             :     return xChild;
     161             : }
     162             : 
     163             : template <class T>
     164           0 : void OOXMLFastHelper<T>::newProperty(OOXMLFastContextHandler * pHandler,
     165             :                                      Id nId,
     166             :                                      const OUString & rValue)
     167             : {
     168           0 :     OOXMLValue::Pointer_t pVal(new T(rValue));
     169             : 
     170             : #ifdef DEBUG_HELPER
     171             :     string aStr = (*QNameToString::Instance())(nId);
     172             : 
     173             :     debug_logger->startElement("newProperty-from-string");
     174             :     debug_logger->attribute("name", aStr);
     175             :     debug_logger->attribute
     176             :         ("value",
     177             :          OUStringToOString
     178             :          (rValue, RTL_TEXTENCODING_ASCII_US).getStr());
     179             : 
     180             :     if (aStr.empty())
     181             :         debug_logger->element( "unknown-qname" );
     182             : #endif
     183             : 
     184           0 :     pHandler->newProperty(nId, pVal);
     185             : 
     186             : #ifdef DEBUG_HELPER
     187             :     debug_logger->endElement();
     188             : #endif
     189             : 
     190           0 : }
     191             : 
     192             : template <class T>
     193           0 : void OOXMLFastHelper<T>::newProperty(OOXMLFastContextHandler * pHandler,
     194             :                                      Id nId,
     195             :                                      sal_Int32 nVal)
     196             : {
     197           0 :     OOXMLValue::Pointer_t pVal(new T(nVal));
     198             : 
     199             : #ifdef DEBUG_HELPER
     200             :     string aStr = (*QNameToString::Instance())(nId);
     201             : 
     202             :     debug_logger->startElement("helper.newProperty-from-int");
     203             :     debug_logger->attribute("name", aStr);
     204             :     debug_logger->attribute("value", pVal->toString());
     205             : 
     206             :     if (aStr.empty())
     207             :         debug_logger->element("unknown-qname");
     208             : 
     209             :     debug_logger->endElement();
     210             : #endif
     211             : 
     212           0 :     pHandler->newProperty(nId, pVal);
     213           0 : }
     214             : 
     215             : }}
     216             : #endif // INCLUDED_FAST_HELPER_HXX
     217             : 
     218             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10