LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/swg - SwXMLBlockExport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 58 58 100.0 %
Date: 2013-07-09 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 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 <SwXMLBlockExport.hxx>
      21             : #include <SwXMLTextBlocks.hxx>
      22             : #include <com/sun/star/util/MeasureUnit.hpp>
      23             : #include <xmloff/nmspmap.hxx>
      24             : #include <xmloff/xmlnmspe.hxx>
      25             : using namespace ::com::sun::star::uno;
      26             : using namespace ::com::sun::star;
      27             : using namespace ::xmloff::token;
      28             : 
      29             : // #110680#
      30          17 : SwXMLBlockListExport::SwXMLBlockListExport(
      31             :     const uno::Reference< uno::XComponentContext > xContext,
      32             :     SwXMLTextBlocks & rBlocks,
      33             :     const OUString &rFileName,
      34             :     uno::Reference< xml::sax::XDocumentHandler> &rHandler)
      35             : :   SvXMLExport( xContext, rFileName, util::MeasureUnit::CM, rHandler ),
      36          17 :     rBlockList(rBlocks)
      37             : {
      38          17 :     _GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST ),
      39          17 :                             GetXMLToken ( XML_N_BLOCK_LIST ),
      40          17 :                             XML_NAMESPACE_BLOCKLIST );
      41          17 : }
      42             : 
      43          17 : sal_uInt32 SwXMLBlockListExport::exportDoc(enum XMLTokenEnum )
      44             : {
      45          17 :     GetDocHandler()->startDocument();
      46             : 
      47          17 :     addChaffWhenEncryptedStorage();
      48             : 
      49             :     AddAttribute ( XML_NAMESPACE_NONE,
      50          17 :                    _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST ),
      51          34 :                    _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST ) );
      52             :     AddAttribute( XML_NAMESPACE_BLOCKLIST,
      53             :                   XML_LIST_NAME,
      54          17 :                   OUString (rBlockList.GetName()));
      55             :     {
      56          17 :         SvXMLElementExport pRoot (*this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK_LIST, sal_True, sal_True);
      57          17 :         sal_uInt16 nBlocks= rBlockList.GetCount();
      58          27 :         for ( sal_uInt16 i = 0; i < nBlocks; i++)
      59             :         {
      60             :             AddAttribute( XML_NAMESPACE_BLOCKLIST,
      61             :                           XML_ABBREVIATED_NAME,
      62          10 :                           OUString(rBlockList.GetShortName(i)));
      63             :             AddAttribute( XML_NAMESPACE_BLOCKLIST,
      64             :                           XML_PACKAGE_NAME,
      65          10 :                           OUString(rBlockList.GetPackageName(i)));
      66             :             AddAttribute( XML_NAMESPACE_BLOCKLIST,
      67             :                           XML_NAME,
      68          10 :                           OUString(rBlockList.GetLongName(i)));
      69             :             AddAttribute( XML_NAMESPACE_BLOCKLIST,
      70             :                           XML_UNFORMATTED_TEXT,
      71          10 :                           rBlockList.IsOnlyTextBlock(i) ? XML_TRUE : XML_FALSE );
      72             : 
      73          10 :             SvXMLElementExport aBlock( *this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK, sal_True, sal_True);
      74          27 :         }
      75             :     }
      76          17 :     GetDocHandler()->endDocument();
      77          17 :     return 0;
      78             : }
      79             : 
      80             : // #110680#
      81           6 : SwXMLTextBlockExport::SwXMLTextBlockExport(
      82             :     const uno::Reference< uno::XComponentContext > xContext,
      83             :     SwXMLTextBlocks & rBlocks,
      84             :     const OUString &rFileName,
      85             :     uno::Reference< xml::sax::XDocumentHandler> &rHandler)
      86             : :   SvXMLExport( xContext, rFileName, util::MeasureUnit::CM, rHandler ),
      87           6 :     rBlockList(rBlocks)
      88             : {
      89           6 :     _GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST ),
      90           6 :                             GetXMLToken ( XML_N_BLOCK_LIST ),
      91           6 :                             XML_NAMESPACE_BLOCKLIST );
      92           6 :     _GetNamespaceMap().Add( GetXMLToken ( XML_NP_OFFICE ),
      93           6 :                             GetXMLToken(XML_N_OFFICE_OOO),
      94           6 :                             XML_NAMESPACE_OFFICE );
      95           6 :     _GetNamespaceMap().Add( GetXMLToken ( XML_NP_TEXT ),
      96           6 :                             GetXMLToken(XML_N_TEXT_OOO),
      97           6 :                             XML_NAMESPACE_TEXT );
      98           6 : }
      99             : 
     100           6 : sal_uInt32 SwXMLTextBlockExport::exportDoc(const String &rText)
     101             : {
     102           6 :     GetDocHandler()->startDocument();
     103             : 
     104           6 :     addChaffWhenEncryptedStorage();
     105             : 
     106             :     AddAttribute ( XML_NAMESPACE_NONE,
     107           6 :                    _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST ),
     108          12 :                    _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST ) );
     109             :     AddAttribute ( XML_NAMESPACE_NONE,
     110           6 :                    _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_TEXT ),
     111          12 :                    _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_TEXT ) );
     112             :     AddAttribute ( XML_NAMESPACE_NONE,
     113           6 :                    _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_OFFICE ),
     114          12 :                    _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_OFFICE ) );
     115             :     AddAttribute( XML_NAMESPACE_BLOCKLIST,
     116             :                   XML_LIST_NAME,
     117           6 :                   OUString (rBlockList.GetName()));
     118             :     {
     119           6 :         SvXMLElementExport aDocument (*this, XML_NAMESPACE_OFFICE, XML_DOCUMENT, sal_True, sal_True);
     120             :         {
     121           6 :             SvXMLElementExport aBody (*this, XML_NAMESPACE_OFFICE, XML_BODY, sal_True, sal_True);
     122             :             {
     123           6 :                 sal_Int32 nPos = 0;
     124           8 :                 do
     125             :                 {
     126           8 :                     String sTemp ( rText.GetToken( 0, '\015', nPos ) );
     127          16 :                      SvXMLElementExport aPara (*this, XML_NAMESPACE_TEXT, XML_P, sal_True, sal_False);
     128          16 :                     GetDocHandler()->characters(sTemp);
     129           8 :                 } while (-1 != nPos );
     130           6 :             }
     131             : 
     132           6 :         }
     133             :     }
     134           6 :     GetDocHandler()->endDocument();
     135           6 :     return 0;
     136          99 : }
     137             : 
     138             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10