LCOV - code coverage report
Current view: top level - writerperfect/source/common - DocumentHandler.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 29 29 100.0 %
Date: 2014-04-11 Functions: 6 6 100.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 Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       6             :  *
       7             :  * For further information visit http://libwpd.sourceforge.net
       8             :  */
       9             : #include "DocumentHandler.hxx"
      10             : 
      11             : #include <string.h>
      12             : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
      13             : #include <com/sun/star/xml/sax/XAttributeList.hpp>
      14             : 
      15             : #include <xmloff/attrlist.hxx>
      16             : 
      17             : using com::sun::star::xml::sax::XAttributeList;
      18             : 
      19          42 : DocumentHandler::DocumentHandler(Reference < XDocumentHandler > &xHandler) :
      20          42 :     mxHandler(xHandler)
      21             : {
      22          42 : }
      23             : 
      24          42 : void DocumentHandler::startDocument()
      25             : {
      26          42 :     mxHandler->startDocument();
      27          42 : }
      28             : 
      29          40 : void DocumentHandler::endDocument()
      30             : {
      31          40 :     mxHandler->endDocument();
      32          40 : }
      33             : 
      34       11919 : void DocumentHandler::startElement(const char *psName, const WPXPropertyList &xPropList)
      35             : {
      36       11919 :     SvXMLAttributeList *pAttrList = new SvXMLAttributeList();
      37       11919 :     Reference < XAttributeList > xAttrList(pAttrList);
      38       23838 :     WPXPropertyList::Iter i(xPropList);
      39       46466 :     for (i.rewind(); i.next(); )
      40             :     {
      41             :         // filter out libwpd elements
      42       22628 :         if (strncmp(i.key(), "libwpd", 6) != 0)
      43             :         {
      44       22554 :             OUString sName(i.key(), strlen(i.key()),  RTL_TEXTENCODING_UTF8);
      45       45108 :             OUString sValue(i()->getStr().cstr(), strlen(i()->getStr().cstr()), RTL_TEXTENCODING_UTF8);
      46       45108 :             pAttrList->AddAttribute(sName, sValue);
      47             :         }
      48             :     }
      49             : 
      50       23838 :     OUString sElementName(psName, strlen(psName), RTL_TEXTENCODING_UTF8);
      51       23838 :     mxHandler->startElement(sElementName, xAttrList);
      52       11917 : }
      53             : 
      54       11901 : void DocumentHandler::endElement(const char *psName)
      55             : {
      56       11901 :     OUString sElementName(psName, strlen(psName), RTL_TEXTENCODING_UTF8);
      57       11901 :     mxHandler->endElement(sElementName);
      58       11901 : }
      59             : 
      60        2868 : void DocumentHandler::characters(const WPXString &sCharacters)
      61             : {
      62        2868 :     OUString sCharU16(sCharacters.cstr(), strlen(sCharacters.cstr()), RTL_TEXTENCODING_UTF8);
      63        2868 :     mxHandler->characters(sCharU16);
      64        2868 : }
      65             : 
      66             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10