LCOV - code coverage report
Current view: top level - sw/source/filter/xml - xmlimp.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 9 9 100.0 %
Date: 2015-06-13 12:38:46 Functions: 7 7 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             : #ifndef INCLUDED_SW_SOURCE_FILTER_XML_XMLIMP_HXX
      21             : #define INCLUDED_SW_SOURCE_FILTER_XML_XMLIMP_HXX
      22             : 
      23             : #include <com/sun/star/document/XDocumentProperties.hpp>
      24             : 
      25             : #include <sot/storage.hxx>
      26             : 
      27             : #include <xmloff/xmlictxt.hxx>
      28             : #include <xmloff/xmlimp.hxx>
      29             : 
      30             : #include "xmlitmap.hxx"
      31             : 
      32             : class SwDoc;
      33             : class SvXMLUnitConverter;
      34             : class SvXMLTokenMap;
      35             : class SvXMLImportItemMapper;
      36             : class SfxItemSet;
      37             : class SwNodeIndex;
      38             : class XMLTextImportHelper;
      39             : class SvXMLGraphicHelper;
      40             : class SvXMLEmbeddedObjectHelper;
      41             : 
      42             : // define, how many steps ( = paragraphs ) the progress bar should advance
      43             : // for styles, autostyles and settings + meta
      44             : #define PROGRESS_BAR_STEP 20
      45             : 
      46             : namespace SwImport {
      47             :     SwDoc* GetDocFromXMLImport( SvXMLImport& );
      48             : }
      49             : 
      50             : class SwXMLImport: public SvXMLImport
      51             : {
      52             :     SwNodeIndex             *pSttNdIdx;
      53             : 
      54             :     SvXMLUnitConverter      *pTwipUnitConv;
      55             :     SvXMLImportItemMapper   *pTableItemMapper;// paragraph item import
      56             :     SvXMLTokenMap           *pDocElemTokenMap;
      57             :     SvXMLTokenMap           *pTableElemTokenMap;
      58             :     SvXMLTokenMap           *pTableCellAttrTokenMap;
      59             :     SvXMLGraphicHelper      *pGraphicResolver;
      60             :     SvXMLEmbeddedObjectHelper   *pEmbeddedResolver;
      61             : 
      62             :     SvXMLItemMapEntriesRef  xTableItemMap;
      63             :     SvXMLItemMapEntriesRef  xTableColItemMap;
      64             :     SvXMLItemMapEntriesRef  xTableRowItemMap;
      65             :     SvXMLItemMapEntriesRef  xTableCellItemMap;
      66             :     tools::SvRef<SotStorage>            xPackage;
      67             :     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
      68             :                             xLateInitSettings;
      69             : 
      70             :     sal_uInt16              nStyleFamilyMask;// Mask of styles to load
      71             :     bool                bLoadDoc : 1;   // Load doc or styles only
      72             :     bool                bInsert : 1;    // Insert mode. If styles are
      73             :                                             // loaded only false means that
      74             :                                             // existing styles will be
      75             :                                             // overwritten.
      76             :     bool                bBlock : 1;     // Load text block
      77             :     bool                bShowProgress : 1;
      78             :     bool                bOrganizerMode : 1;
      79             :     bool                bInititedXForms : 1;
      80             :     bool                bPreserveRedlineMode;
      81             : 
      82             :     SwDoc*      doc; // cached for getDoc()
      83             : 
      84             :     void                    _InitItemImport();
      85             :     void                    _FinitItemImport();
      86             :     void                    UpdateTextCollConditions( SwDoc *pDoc );
      87             : 
      88             :     void         setTextInsertMode(
      89             :                      const ::com::sun::star::uno::Reference<
      90             :                         ::com::sun::star::text::XTextRange > & rInsertPos );
      91             :     void         setStyleInsertMode( sal_uInt16 nFamilies,
      92             :                                      bool bOverwrite );
      93             :     void         setBlockMode();
      94             :     void         setOrganizerMode();
      95             : 
      96             : protected:
      97             : 
      98             :     // This method is called after the namespace map has been updated, but
      99             :     // before a context for the current element has been pushed.
     100             :     virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
     101             :                   const OUString& rLocalName,
     102             :                   const ::com::sun::star::uno::Reference<
     103             :                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
     104             : 
     105             :     virtual XMLTextImportHelper* CreateTextImport() SAL_OVERRIDE;
     106             : 
     107             :     virtual XMLShapeImportHelper* CreateShapeImport() SAL_OVERRIDE;
     108             : 
     109             : public:
     110             :     SwXMLImport(
     111             :         const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rContext,
     112             :         OUString const & implementationName, SvXMLImportFlags nImportFlags);
     113             : 
     114             :     virtual ~SwXMLImport() throw();
     115             : 
     116             :     // ::com::sun::star::xml::sax::XDocumentHandler
     117             :     virtual void SAL_CALL startDocument()
     118             :         throw (::com::sun::star::xml::sax::SAXException,
     119             :                ::com::sun::star::uno::RuntimeException,
     120             :                std::exception) SAL_OVERRIDE;
     121             :     virtual void SAL_CALL endDocument()
     122             :         throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     123             : 
     124             :     // XUnoTunnel
     125             :     static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
     126             :     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     127             : 
     128             :     // XInitialization
     129             :     virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     130             : 
     131             :     void                    InsertStyles( bool bAuto );
     132             :     void                    FinishStyles();
     133             : 
     134             :     // namespace office
     135             : 
     136             :     // NB: in contrast to other CreateFooContexts, this particular one handles
     137             :     //     the root element (i.e. office:document-meta)
     138             :     SvXMLImportContext *CreateMetaContext( const OUString& rLocalName );
     139             :     SvXMLImportContext *CreateScriptContext( const OUString& rLocalName );
     140             :     SvXMLImportContext *CreateStylesContext(
     141             :                 const OUString& rLocalName,
     142             :                 const ::com::sun::star::uno::Reference<
     143             :                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
     144             :                 bool bAuto );
     145             :     SvXMLImportContext *CreateMasterStylesContext(
     146             :                 const OUString& rLocalName,
     147             :                 const ::com::sun::star::uno::Reference<
     148             :                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     149             :     SvXMLImportContext *CreateFontDeclsContext(
     150             :             const OUString& rLocalName,
     151             :             const ::com::sun::star::uno::Reference<
     152             :                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     153             :     SvXMLImportContext *CreateBodyContentContext( const OUString& rLocalName );
     154       21827 :     sal_uInt16 GetStyleFamilyMask() const { return nStyleFamilyMask; }
     155        8497 :     bool IsInsertMode() const { return bInsert; }
     156        7209 :     bool IsStylesOnlyMode() const { return !bLoadDoc; }
     157        5282 :     bool IsBlockMode() const { return bBlock; }
     158        1850 :     bool IsOrganizerMode() const { return bOrganizerMode; }
     159             : 
     160             :     inline const SvXMLUnitConverter& GetTwipUnitConverter() const;
     161             :     inline const SvXMLImportItemMapper& GetTableItemMapper() const;
     162             :     inline       SvXMLImportItemMapper& GetTableItemMapper();
     163             :     SvXMLImportContext *CreateTableItemImportContext( sal_uInt16 nPrefix,
     164             :                 const OUString& rLocalName,
     165             :                 const ::com::sun::star::uno::Reference<
     166             :                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
     167             :                 sal_uInt16 nSubFamily, SfxItemSet& rItemSet );
     168             : 
     169             :     const SvXMLTokenMap& GetDocElemTokenMap();
     170             :     const SvXMLTokenMap& GetTableElemTokenMap();
     171             :     const SvXMLTokenMap& GetTableCellAttrTokenMap();
     172             : 
     173             :     bool FindAutomaticStyle( sal_uInt16 nFamily,
     174             :                              const OUString& rName,
     175             :                              const SfxItemSet **ppItemSet=0,
     176             :                              OUString *pParent=0 ) const;
     177             : 
     178             :     virtual void SetStatistics(
     179             :         const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue> & i_rStats) SAL_OVERRIDE;
     180             :     virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps) SAL_OVERRIDE;
     181             :     virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps) SAL_OVERRIDE;
     182             :     virtual void SetDocumentSpecificSettings(const OUString& _rSettingsGroupName,
     183             :                     const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& _rSettings) SAL_OVERRIDE;
     184             : 
     185             :     SotStorage *GetPackage() { return &xPackage; }
     186             : 
     187             :     void SetProgressValue( sal_Int32 nValue );
     188             : 
     189             :     // initialize XForms
     190             :     virtual void initXForms() SAL_OVERRIDE;
     191             : 
     192             :     // get the document properties, but only if they actually need importing
     193             :     ::com::sun::star::uno::Reference<
     194             :         ::com::sun::star::document::XDocumentProperties>
     195             :             GetDocumentProperties() const;
     196             : 
     197             :     virtual void NotifyEmbeddedFontRead() SAL_OVERRIDE;
     198             : 
     199             :     const SwDoc* getDoc() const;
     200             :     SwDoc* getDoc();
     201             : };
     202             : 
     203         891 : inline const SvXMLUnitConverter& SwXMLImport::GetTwipUnitConverter() const
     204             : {
     205         891 :     return *pTwipUnitConv;
     206             : }
     207             : 
     208             : inline const SvXMLImportItemMapper& SwXMLImport::GetTableItemMapper() const
     209             : {
     210             :     return *pTableItemMapper;
     211             : }
     212             : 
     213         891 : inline       SvXMLImportItemMapper& SwXMLImport::GetTableItemMapper()
     214             : {
     215         891 :     return *pTableItemMapper;
     216             : }
     217             : 
     218             : inline void SwXMLImport::SetProgressValue( sal_Int32 nValue )
     219             : {
     220             :     if ( bShowProgress )
     221             :         GetProgressBarHelper()->SetValue(nValue);
     222             : }
     223             : 
     224             : #endif  //  _XMLIMP_HXX
     225             : 
     226             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11