LCOV - code coverage report
Current view: top level - xmloff/source/text - XMLAutoTextEventExport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 92 0.0 %
Date: 2012-08-25 Functions: 0 22 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 82 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "XMLAutoTextEventExport.hxx"
      30                 :            : #include <com/sun/star/frame/XModel.hpp>
      31                 :            : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
      32                 :            : #include <com/sun/star/util/MeasureUnit.hpp>
      33                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      34                 :            : #include <com/sun/star/document/XEventsSupplier.hpp>
      35                 :            : #include <com/sun/star/container/XNameReplace.hpp>
      36                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      37                 :            : #include <com/sun/star/uno/Reference.hxx>
      38                 :            : #include <com/sun/star/uno/Sequence.hxx>
      39                 :            : #include <com/sun/star/uno/Exception.hpp>
      40                 :            : #include <rtl/ustrbuf.hxx>
      41                 :            : #include "xmloff/xmlnmspe.hxx"
      42                 :            : #include <xmloff/nmspmap.hxx>
      43                 :            : #include <xmloff/xmltoken.hxx>
      44                 :            : #include <xmloff/XMLEventExport.hxx>
      45                 :            : #include <tools/debug.hxx>
      46                 :            : #include <tools/fldunit.hxx>
      47                 :            : 
      48                 :            : 
      49                 :            : using namespace ::com::sun::star;
      50                 :            : using namespace ::xmloff::token;
      51                 :            : 
      52                 :            : using ::rtl::OUString;
      53                 :            : using ::rtl::OUStringBuffer;
      54                 :            : using ::std::set;
      55                 :            : using ::com::sun::star::beans::XPropertySet;
      56                 :            : using ::com::sun::star::beans::PropertyValue;
      57                 :            : using ::com::sun::star::container::XNameAccess;
      58                 :            : using ::com::sun::star::container::XNameReplace;
      59                 :            : using ::com::sun::star::document::XEventsSupplier;
      60                 :            : using ::com::sun::star::frame::XModel;
      61                 :            : using ::com::sun::star::lang::XMultiServiceFactory;
      62                 :            : using ::com::sun::star::uno::Any;
      63                 :            : using ::com::sun::star::uno::Exception;
      64                 :            : using ::com::sun::star::uno::Reference;
      65                 :            : using ::com::sun::star::uno::Sequence;
      66                 :            : using ::com::sun::star::uno::XInterface;
      67                 :            : using ::com::sun::star::uno::UNO_QUERY;
      68                 :            : using ::com::sun::star::xml::sax::XDocumentHandler;
      69                 :            : 
      70                 :            : 
      71                 :            : const sal_Char sAPI_AutoText[] = "com.sun.star.text.AutoTextContainer";
      72                 :            : 
      73                 :            : 
      74                 :          0 : XMLAutoTextEventExport::XMLAutoTextEventExport(
      75                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
      76                 :            :         sal_uInt16 nFlags
      77                 :            :     )
      78                 :            : :   SvXMLExport(util::MeasureUnit::INCH, xServiceFactory, XML_AUTO_TEXT, nFlags)
      79                 :            : ,
      80                 :            :         sEventType("EventType"),
      81                 :          0 :         sNone("None")
      82                 :            : {
      83                 :          0 : }
      84                 :            : 
      85                 :          0 : XMLAutoTextEventExport::~XMLAutoTextEventExport()
      86                 :            : {
      87         [ #  # ]:          0 : }
      88                 :            : 
      89                 :          0 : void XMLAutoTextEventExport::initialize(
      90                 :            :     const Sequence<Any> & rArguments )
      91                 :            :         throw(uno::Exception, uno::RuntimeException)
      92                 :            : {
      93         [ #  # ]:          0 :     if (rArguments.getLength() > 1)
      94                 :            :     {
      95                 :          0 :         Reference<XEventsSupplier> xSupplier;
      96         [ #  # ]:          0 :         rArguments[1] >>= xSupplier;
      97         [ #  # ]:          0 :         if (xSupplier.is())
      98                 :            :         {
      99 [ #  # ][ #  # ]:          0 :             Reference<XNameAccess> xAccess(xSupplier->getEvents(), UNO_QUERY);
                 [ #  # ]
     100         [ #  # ]:          0 :             xEvents = xAccess;
     101                 :            :         }
     102                 :            :         else
     103                 :            :         {
     104                 :          0 :             Reference<XNameReplace> xReplace;
     105         [ #  # ]:          0 :             rArguments[1] >>= xReplace;
     106         [ #  # ]:          0 :             if (xReplace.is())
     107                 :            :             {
     108         [ #  # ]:          0 :                 Reference<XNameAccess> xAccess(xReplace, UNO_QUERY);
     109         [ #  # ]:          0 :                 xEvents = xAccess;
     110                 :            :             }
     111                 :            :             else
     112                 :            :             {
     113         [ #  # ]:          0 :                 rArguments[1] >>= xEvents;
     114                 :          0 :             }
     115                 :          0 :         }
     116                 :            :     }
     117                 :            : 
     118                 :            :     // call super class (for XHandler)
     119                 :          0 :     SvXMLExport::initialize(rArguments);
     120                 :          0 : }
     121                 :            : 
     122                 :            : 
     123                 :          0 : sal_uInt32 XMLAutoTextEventExport::exportDoc( enum XMLTokenEnum )
     124                 :            : {
     125         [ #  # ]:          0 :     if( (getExportFlags() & EXPORT_OASIS) == 0 )
     126                 :            :     {
     127         [ #  # ]:          0 :         Reference< lang::XMultiServiceFactory > xFactory = getServiceFactory();
     128         [ #  # ]:          0 :         if( xFactory.is() )
     129                 :            :         {
     130                 :            :             try
     131                 :            :             {
     132                 :            : 
     133         [ #  # ]:          0 :                 Sequence<Any> aArgs( 1 );
     134 [ #  # ][ #  # ]:          0 :                 aArgs[0] <<= GetDocHandler();
     135                 :            : 
     136                 :            :                 // get filter component
     137                 :            :                 Reference< xml::sax::XDocumentHandler > xTmpDocHandler(
     138         [ #  # ]:          0 :                     xFactory->createInstanceWithArguments(
     139                 :            :                     OUString("com.sun.star.comp.Oasis2OOoTransformer"),
     140 [ #  # ][ #  # ]:          0 :                                 aArgs), UNO_QUERY);
     141                 :            :                 OSL_ENSURE( xTmpDocHandler.is(),
     142                 :            :                     "can't instantiate OASIS transformer component" );
     143         [ #  # ]:          0 :                 if( xTmpDocHandler.is() )
     144                 :            :                 {
     145         [ #  # ]:          0 :                     SetDocHandler( xTmpDocHandler );
     146 [ #  # ][ #  # ]:          0 :                 }
     147                 :            :             }
     148         [ #  # ]:          0 :             catch( com::sun::star::uno::Exception& )
     149                 :            :             {
     150                 :            :             }
     151                 :          0 :         }
     152                 :            :     }
     153         [ #  # ]:          0 :     if (hasEvents())
     154                 :            :     {
     155                 :          0 :         GetDocHandler()->startDocument();
     156                 :            : 
     157                 :          0 :         addChaffWhenEncryptedStorage();
     158                 :            : 
     159                 :          0 :         addNamespaces();
     160                 :            : 
     161                 :            :         {
     162                 :            :             // container element
     163                 :            :             SvXMLElementExport aContainerElement(
     164                 :            :                 *this, XML_NAMESPACE_OOO, XML_AUTO_TEXT_EVENTS,
     165         [ #  # ]:          0 :                 sal_True, sal_True);
     166                 :            : 
     167 [ #  # ][ #  # ]:          0 :             exportEvents();
     168                 :            :         }
     169                 :            : 
     170                 :            :         // and close document again
     171                 :          0 :         GetDocHandler()->endDocument();
     172                 :            :     }
     173                 :            : 
     174                 :          0 :     return 0;
     175                 :            : }
     176                 :            : 
     177                 :          0 : sal_Bool XMLAutoTextEventExport::hasEvents()
     178                 :            : {
     179                 :            :     // TODO: provide full implementation that check for presence of events
     180                 :          0 :     return xEvents.is();
     181                 :            : }
     182                 :            : 
     183                 :          0 : void XMLAutoTextEventExport::addNamespaces()
     184                 :            : {
     185                 :            :     // namespaces for office:, text: and script:
     186                 :          0 :     GetAttrList().AddAttribute(
     187                 :          0 :         GetNamespaceMap().GetAttrNameByIndex( XML_NAMESPACE_OFFICE ),
     188         [ #  # ]:          0 :         GetNamespaceMap().GetNameByIndex( XML_NAMESPACE_OFFICE ) );
     189                 :          0 :     GetAttrList().AddAttribute(
     190                 :          0 :         GetNamespaceMap().GetAttrNameByIndex( XML_NAMESPACE_TEXT ),
     191         [ #  # ]:          0 :         GetNamespaceMap().GetNameByIndex( XML_NAMESPACE_TEXT ) );
     192                 :          0 :     GetAttrList().AddAttribute(
     193                 :          0 :         GetNamespaceMap().GetAttrNameByIndex( XML_NAMESPACE_SCRIPT ),
     194         [ #  # ]:          0 :         GetNamespaceMap().GetNameByIndex( XML_NAMESPACE_SCRIPT ) );
     195                 :          0 :     GetAttrList().AddAttribute(
     196                 :          0 :         GetNamespaceMap().GetAttrNameByIndex( XML_NAMESPACE_DOM ),
     197         [ #  # ]:          0 :         GetNamespaceMap().GetNameByIndex( XML_NAMESPACE_DOM ) );
     198                 :          0 :     GetAttrList().AddAttribute(
     199                 :          0 :         GetNamespaceMap().GetAttrNameByIndex( XML_NAMESPACE_OOO ),
     200         [ #  # ]:          0 :         GetNamespaceMap().GetNameByIndex( XML_NAMESPACE_OOO ) );
     201                 :          0 :     GetAttrList().AddAttribute(
     202                 :          0 :         GetNamespaceMap().GetAttrNameByIndex( XML_NAMESPACE_XLINK ),
     203         [ #  # ]:          0 :         GetNamespaceMap().GetNameByIndex( XML_NAMESPACE_XLINK ) );
     204                 :          0 : }
     205                 :            : 
     206                 :          0 : void XMLAutoTextEventExport::exportEvents()
     207                 :            : {
     208                 :            :     DBG_ASSERT(hasEvents(), "no events to export!");
     209                 :            : 
     210                 :          0 :     GetEventExport().Export(xEvents, sal_True);
     211                 :          0 : }
     212                 :            : 
     213                 :            : 
     214                 :            : 
     215                 :            : // methods without content:
     216                 :            : 
     217                 :          0 : void XMLAutoTextEventExport::_ExportMeta() {}
     218                 :          0 : void XMLAutoTextEventExport::_ExportScripts() {}
     219                 :          0 : void XMLAutoTextEventExport::_ExportFontDecls() {}
     220                 :          0 : void XMLAutoTextEventExport::_ExportStyles( sal_Bool ) {}
     221                 :          0 : void XMLAutoTextEventExport::_ExportAutoStyles() {}
     222                 :          0 : void XMLAutoTextEventExport::_ExportMasterStyles() {}
     223                 :          0 : void XMLAutoTextEventExport::_ExportChangeTracking() {}
     224                 :          0 : void XMLAutoTextEventExport::_ExportContent() {}
     225                 :            : 
     226                 :            : 
     227                 :            : 
     228                 :            : // methods to support the component registration
     229                 :            : 
     230                 :          0 : Sequence< OUString > SAL_CALL XMLAutoTextEventExport_getSupportedServiceNames()
     231                 :            :     throw()
     232                 :            : {
     233                 :          0 :     Sequence< OUString > aSeq( 1 );
     234         [ #  # ]:          0 :     aSeq[0] = XMLAutoTextEventExport_getImplementationName();
     235                 :          0 :     return aSeq;
     236                 :            : }
     237                 :            : 
     238                 :          0 : OUString SAL_CALL XMLAutoTextEventExport_getImplementationName() throw()
     239                 :            : {
     240                 :          0 :     return OUString( "com.sun.star.comp.Writer.XMLOasisAutotextEventsExporter"  );
     241                 :            : }
     242                 :            : 
     243                 :          0 : Reference< XInterface > SAL_CALL XMLAutoTextEventExport_createInstance(
     244                 :            :         const Reference< XMultiServiceFactory > & rSMgr)
     245                 :            :     throw( Exception )
     246                 :            : {
     247         [ #  # ]:          0 :     return (cppu::OWeakObject*)new XMLAutoTextEventExport(rSMgr, EXPORT_ALL|EXPORT_OASIS);
     248                 :            : }
     249                 :            : 
     250                 :            : // methods to support the component registration
     251                 :            : 
     252                 :          0 : Sequence< OUString > SAL_CALL XMLAutoTextEventExportOOO_getSupportedServiceNames()
     253                 :            :     throw()
     254                 :            : {
     255                 :          0 :     Sequence< OUString > aSeq( 1 );
     256         [ #  # ]:          0 :     aSeq[0] = XMLAutoTextEventExportOOO_getImplementationName();
     257                 :          0 :     return aSeq;
     258                 :            : }
     259                 :            : 
     260                 :          0 : OUString SAL_CALL XMLAutoTextEventExportOOO_getImplementationName() throw()
     261                 :            : {
     262                 :          0 :     return OUString( "com.sun.star.comp.Writer.XMLAutotextEventsExporter"  );
     263                 :            : }
     264                 :            : 
     265                 :          0 : Reference< XInterface > SAL_CALL XMLAutoTextEventExportOOO_createInstance(
     266                 :            :         const Reference< XMultiServiceFactory > & rSMgr)
     267                 :            :     throw( Exception )
     268                 :            : {
     269         [ #  # ]:          0 :     return (cppu::OWeakObject*)new XMLAutoTextEventExport(rSMgr,EXPORT_ALL);
     270                 :            : }
     271                 :            : 
     272                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10