LCOV - code coverage report
Current view: top level - include/oox/core - xmlfilterbase.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 3 0.0 %
Date: 2014-04-14 Functions: 0 5 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             : #ifndef INCLUDED_OOX_CORE_XMLFILTERBASE_HXX
      21             : #define INCLUDED_OOX_CORE_XMLFILTERBASE_HXX
      22             : 
      23             : #include <com/sun/star/text/XText.hpp>
      24             : #include <com/sun/star/text/XTextCursor.hpp>
      25             : #include <com/sun/star/text/XTextField.hpp>
      26             : #include <rtl/ref.hxx>
      27             : #include <rtl/string.hxx>
      28             : #include <rtl/ustring.hxx>
      29             : #include <oox/core/filterbase.hxx>
      30             : #include <oox/core/relations.hxx>
      31             : #include <oox/drawingml/table/tablestylelist.hxx>
      32             : #include <oox/dllapi.h>
      33             : 
      34             : namespace com { namespace sun { namespace star {
      35             :     namespace container { class XNameContainer; }
      36             :     namespace document { class XDocumentProperties; }
      37             :     namespace xml { namespace dom { class XDocument; } }
      38             :     namespace xml { namespace sax { class XLocator; } }
      39             :     namespace xml { namespace sax { class XFastDocumentHandler; } }
      40             :     namespace xml { namespace sax { class XFastSAXSerializable; } }
      41             : } } }
      42             : 
      43             : namespace oox {
      44             :     namespace drawingml { class Theme; }
      45             :     namespace drawingml { namespace chart { class ChartConverter; } }
      46             :     namespace vml { class Drawing; }
      47             : }
      48             : 
      49             : namespace sax_fastparser {
      50             :     class FastSerializerHelper;
      51             : 
      52             :     typedef boost::shared_ptr< FastSerializerHelper > FSHelperPtr;
      53             : }
      54             : 
      55             : namespace oox {
      56             : namespace core {
      57             : 
      58             : class FragmentHandler;
      59             : class FastParser;
      60             : 
      61           0 : struct TextField {
      62             :     com::sun::star::uno::Reference< com::sun::star::text::XText > xText;
      63             :     com::sun::star::uno::Reference< com::sun::star::text::XTextCursor > xTextCursor;
      64             :     com::sun::star::uno::Reference< com::sun::star::text::XTextField > xTextField;
      65             : };
      66             : typedef std::vector< TextField > TextFieldStack;
      67             : 
      68             : 
      69             : 
      70             : struct XmlFilterBaseImpl;
      71             : 
      72             : class OOX_DLLPUBLIC XmlFilterBase : public FilterBase
      73             : {
      74             : public:
      75             :     explicit            XmlFilterBase(
      76             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext )
      77             :                             throw( ::com::sun::star::uno::RuntimeException );
      78             : 
      79             :     virtual             ~XmlFilterBase();
      80             : 
      81             :     /** Has to be implemented by each filter, returns the current theme. */
      82             :     virtual const ::oox::drawingml::Theme*
      83             :                         getCurrentTheme() const = 0;
      84             : 
      85             :     /** Has to be implemented by each filter to return the collection of VML shapes. */
      86             :     virtual ::oox::vml::Drawing* getVmlDrawing() = 0;
      87             : 
      88             :     /** Has to be implemented by each filter, returns a filter-specific chart
      89             :         converter object, that should be global per imported document. */
      90             :     virtual ::oox::drawingml::chart::ChartConverter* getChartConverter() = 0;
      91             : 
      92             :     /** Helper to switch chart data table - specifically for xlsx imports */
      93           0 :      virtual void useInternalChartDataTable( bool /*bInternal*/ ) { }
      94             : 
      95             :     /** Has to be implemented by each filter to return the table style list. */
      96             :     virtual const ::oox::drawingml::table::TableStyleListPtr getTableStyles() = 0;
      97             : 
      98             : 
      99             : 
     100             :     OUString     getFragmentPathFromFirstTypeFromOfficeDoc( const OUString& rPart );
     101             : 
     102             :     /** Imports a fragment using the passed fragment handler, which contains
     103             :         the full path to the fragment stream.
     104             : 
     105             :         @return  True, if the fragment could be imported.
     106             :      */
     107             :     bool importFragment( const rtl::Reference<FragmentHandler>& rxHandler );
     108             :     bool importFragment( const rtl::Reference<FragmentHandler>& rxHandler, FastParser& rParser );
     109             : 
     110             :     /** Imports a fragment into an xml::dom::XDocument.
     111             : 
     112             :         @param rFragmentPath path to fragment
     113             : 
     114             :         @return a non-empty reference to the XDocument, if the
     115             :         fragment could be imported.
     116             :      */
     117             :     ::com::sun::star::uno::Reference<
     118             :        ::com::sun::star::xml::dom::XDocument> importFragment( const OUString& rFragmentPath );
     119             : 
     120             :     /** Imports a fragment from an xml::dom::XDocument using the
     121             :         passed fragment handler
     122             : 
     123             :         @param rxHandler fragment handler; path to fragment is
     124             :         ignored, input source is the rxSerializer
     125             : 
     126             :         @param rxSerializer usually retrieved from a
     127             :         xml::dom::XDocument, will get serialized into rxHandler
     128             : 
     129             :         @return true, if the fragment could be imported.
     130             :      */
     131             :     bool importFragment( const ::rtl::Reference< FragmentHandler >& rxHandler,
     132             :                          const ::com::sun::star::uno::Reference<
     133             :                                ::com::sun::star::xml::sax::XFastSAXSerializable >& rxSerializer );
     134             : 
     135             :     /** Imports the relations fragment associated with the specified fragment.
     136             : 
     137             :         @return  The relations collection of the specified fragment.
     138             :      */
     139             :     RelationsRef        importRelations( const OUString& rFragmentPath );
     140             : 
     141             :     /** Adds new relation.
     142             : 
     143             :         @param rType
     144             :             Relation type.
     145             : 
     146             :         @param rTarget
     147             :             Relation target.
     148             : 
     149             :         @return  Added relation Id.
     150             :      */
     151             :     OUString     addRelation( const OUString& rType, const OUString& rTarget, bool bExternal = false );
     152             : 
     153             :     /** Adds new relation to part's relations.
     154             : 
     155             :         @param rPartName
     156             :             Part name the relations are related to. The relations will be stored in <rPartName::path>/_rels/<rPartName::name>.rels.
     157             : 
     158             :         @param rType
     159             :             Relation type.
     160             : 
     161             :         @param rTarget
     162             :             Relation target.
     163             : 
     164             :         @return  Added relation Id.
     165             :      */
     166             :     OUString     addRelation( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xOutputStream, const OUString& rType, const OUString& rTarget, bool bExternal = false );
     167             : 
     168             :     /** Returns a stack of used textfields, used by the pptx importer to replace links to slidepages with rhe real page name */
     169             :     TextFieldStack& getTextFieldStack() const;
     170             : 
     171             :     /** Opens and returns the specified output stream from the base storage with specified media type.
     172             : 
     173             :         @param rStreamName
     174             :             The name of the embedded storage stream. The name may contain
     175             :             slashes to open streams from embedded substorages. If base stream
     176             :             access has been enabled in the storage, the base stream can be
     177             :             accessed by passing an empty string as stream name.
     178             : 
     179             :         @param rMediaType
     180             :             The media type string, used in [Content_Types].xml stream in base
     181             :             storage.
     182             : 
     183             :         @return The opened output stream.
     184             :      */
     185             :     ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
     186             :                         openFragmentStream(
     187             :                             const OUString& rStreamName,
     188             :                             const OUString& rMediaType );
     189             : 
     190             :     /** Opens specified output stream from the base storage with specified
     191             :         media type and returns new fast serializer for that stream.
     192             : 
     193             :         @param rStreamName
     194             :             The name of the embedded storage stream. The name may contain
     195             :             slashes to open streams from embedded substorages. If base stream
     196             :             access has been enabled in the storage, the base stream can be
     197             :             accessed by passing an empty string as stream name.
     198             : 
     199             :         @param rMediaType
     200             :             The media type string, used in [Content_Types].xml stream in base
     201             :             storage.
     202             : 
     203             :         @return newly created serializer helper.
     204             :      */
     205             :     ::sax_fastparser::FSHelperPtr
     206             :                         openFragmentStreamWithSerializer(
     207             :                             const OUString& rStreamName,
     208             :                             const OUString& rMediaType );
     209             : 
     210             :     /** Returns new unique ID for exported document.
     211             : 
     212             :         @return newly created ID.
     213             :      */
     214           0 :     sal_Int32 GetUniqueId() { return mnMaxDocId++; }
     215             :     OString GetUniqueIdOString() { return OString::number( mnMaxDocId++ ); }
     216             :     OUString GetUniqueIdOUString() { return OUString::number( mnMaxDocId++ ); }
     217             : 
     218             :     /** Write the document properties into into the current OPC package.
     219             : 
     220             :         @param xProperties  The document properties to export.
     221             : 
     222             :         @return *this
     223             :      */
     224             :     XmlFilterBase& exportDocumentProperties( ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentProperties > xProperties );
     225             : 
     226             :     OUString getNamespaceURL( const OUString& rPrefix );
     227             : 
     228             :     bool hasNamespaceURL( const OUString& rPrefix ) const;
     229             : 
     230             :     sal_Int32 getNamespaceId( const OUString& rUrl );
     231             : 
     232             :     void importDocumentProperties();
     233             : 
     234             :     FastParser* createParser() const;
     235             : 
     236             : protected:
     237             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
     238             :         implGetInputStream( utl::MediaDescriptor& rMediaDesc ) const SAL_OVERRIDE;
     239             : 
     240             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >
     241             :         implGetOutputStream( utl::MediaDescriptor& rMediaDesc ) const SAL_OVERRIDE;
     242             : 
     243             :     virtual bool implFinalizeExport( utl::MediaDescriptor& rMediaDescriptor ) SAL_OVERRIDE;
     244             : 
     245             : private:
     246             :     virtual StorageRef  implCreateStorage(
     247             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream ) const SAL_OVERRIDE;
     248             :     virtual StorageRef  implCreateStorage(
     249             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream ) const SAL_OVERRIDE;
     250             : 
     251             : private:
     252             :     ::std::auto_ptr< XmlFilterBaseImpl > mxImpl;
     253             :     sal_Int32 mnRelId;
     254             :     sal_Int32 mnMaxDocId;
     255             : };
     256             : 
     257             : typedef ::rtl::Reference< XmlFilterBase > XmlFilterRef;
     258             : 
     259             : 
     260             : 
     261             : } // namespace core
     262             : } // namespace oox
     263             : 
     264             : #endif
     265             : 
     266             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10