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

Generated by: LCOV version 1.10