LCOV - code coverage report
Current view: top level - sw/source/core/swg - SwXMLBlockExport.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 58 58 100.0 %
Date: 2014-11-03 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          34 : 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          34 :     rBlockList(rBlocks)
      37             : {
      38          34 :     _GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST ),
      39          34 :                             GetXMLToken ( XML_N_BLOCK_LIST ),
      40          34 :                             XML_NAMESPACE_BLOCKLIST );
      41          34 : }
      42             : 
      43          34 : sal_uInt32 SwXMLBlockListExport::exportDoc(enum XMLTokenEnum )
      44             : {
      45          34 :     GetDocHandler()->startDocument();
      46             : 
      47          34 :     addChaffWhenEncryptedStorage();
      48             : 
      49             :     AddAttribute ( XML_NAMESPACE_NONE,
      50          34 :                    _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST ),
      51          68 :                    _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST ) );
      52             :     AddAttribute( XML_NAMESPACE_BLOCKLIST,
      53             :                   XML_LIST_NAME,
      54          34 :                   OUString (rBlockList.GetName()));
      55             :     {
      56          34 :         SvXMLElementExport pRoot (*this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK_LIST, true, true);
      57          34 :         sal_uInt16 nBlocks= rBlockList.GetCount();
      58          54 :         for ( sal_uInt16 i = 0; i < nBlocks; i++)
      59             :         {
      60             :             AddAttribute( XML_NAMESPACE_BLOCKLIST,
      61             :                           XML_ABBREVIATED_NAME,
      62          20 :                           OUString(rBlockList.GetShortName(i)));
      63             :             AddAttribute( XML_NAMESPACE_BLOCKLIST,
      64             :                           XML_PACKAGE_NAME,
      65          20 :                           OUString(rBlockList.GetPackageName(i)));
      66             :             AddAttribute( XML_NAMESPACE_BLOCKLIST,
      67             :                           XML_NAME,
      68          20 :                           OUString(rBlockList.GetLongName(i)));
      69             :             AddAttribute( XML_NAMESPACE_BLOCKLIST,
      70             :                           XML_UNFORMATTED_TEXT,
      71          20 :                           rBlockList.IsOnlyTextBlock(i) ? XML_TRUE : XML_FALSE );
      72             : 
      73          20 :             SvXMLElementExport aBlock( *this, XML_NAMESPACE_BLOCKLIST, XML_BLOCK, true, true);
      74          54 :         }
      75             :     }
      76          34 :     GetDocHandler()->endDocument();
      77          34 :     return 0;
      78             : }
      79             : 
      80             : // #110680#
      81          12 : 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          12 :     rBlockList(rBlocks)
      88             : {
      89          12 :     _GetNamespaceMap().Add( GetXMLToken ( XML_NP_BLOCK_LIST ),
      90          12 :                             GetXMLToken ( XML_N_BLOCK_LIST ),
      91          12 :                             XML_NAMESPACE_BLOCKLIST );
      92          12 :     _GetNamespaceMap().Add( GetXMLToken ( XML_NP_OFFICE ),
      93          12 :                             GetXMLToken(XML_N_OFFICE_OOO),
      94          12 :                             XML_NAMESPACE_OFFICE );
      95          12 :     _GetNamespaceMap().Add( GetXMLToken ( XML_NP_TEXT ),
      96          12 :                             GetXMLToken(XML_N_TEXT_OOO),
      97          12 :                             XML_NAMESPACE_TEXT );
      98          12 : }
      99             : 
     100          12 : sal_uInt32 SwXMLTextBlockExport::exportDoc(const OUString &rText)
     101             : {
     102          12 :     GetDocHandler()->startDocument();
     103             : 
     104          12 :     addChaffWhenEncryptedStorage();
     105             : 
     106             :     AddAttribute ( XML_NAMESPACE_NONE,
     107          12 :                    _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_BLOCKLIST ),
     108          24 :                    _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_BLOCKLIST ) );
     109             :     AddAttribute ( XML_NAMESPACE_NONE,
     110          12 :                    _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_TEXT ),
     111          24 :                    _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_TEXT ) );
     112             :     AddAttribute ( XML_NAMESPACE_NONE,
     113          12 :                    _GetNamespaceMap().GetAttrNameByKey ( XML_NAMESPACE_OFFICE ),
     114          24 :                    _GetNamespaceMap().GetNameByKey ( XML_NAMESPACE_OFFICE ) );
     115             :     AddAttribute( XML_NAMESPACE_BLOCKLIST,
     116             :                   XML_LIST_NAME,
     117          12 :                   OUString (rBlockList.GetName()));
     118             :     {
     119          12 :         SvXMLElementExport aDocument (*this, XML_NAMESPACE_OFFICE, XML_DOCUMENT, true, true);
     120             :         {
     121          12 :             SvXMLElementExport aBody (*this, XML_NAMESPACE_OFFICE, XML_BODY, true, true);
     122             :             {
     123          12 :                 sal_Int32 nPos = 0;
     124          16 :                 do
     125             :                 {
     126          16 :                     OUString sTemp ( rText.getToken( 0, '\015', nPos ) );
     127          32 :                     SvXMLElementExport aPara (*this, XML_NAMESPACE_TEXT, XML_P, true, false);
     128          32 :                     GetDocHandler()->characters(sTemp);
     129          16 :                 } while (-1 != nPos );
     130          12 :             }
     131             : 
     132          12 :         }
     133             :     }
     134          12 :     GetDocHandler()->endDocument();
     135          12 :     return 0;
     136         270 : }
     137             : 
     138             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10