LCOV - code coverage report
Current view: top level - libreoffice/sw/source/filter/xml - xmlimp.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 9 9 100.0 %
Date: 2012-12-27 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 SW_XMLIMP_HXX
      21             : #define SW_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             :     SvStorageRef            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             :     sal_Bool                bLoadDoc : 1;   // Load doc or styles only
      72             :     sal_Bool                bInsert : 1;    // Insert mode. If styles are
      73             :                                             // loaded only sal_False means that
      74             :                                             // existing styles will be
      75             :                                             // overwritten.
      76             :     sal_Bool                bBlock : 1;     // Load text block
      77             :     sal_Bool                bAutoStylesValid : 1;
      78             :     sal_Bool                bShowProgress : 1;
      79             :     sal_Bool                bOrganizerMode : 1;
      80             :     sal_Bool                bInititedXForms : 1;
      81             :     sal_Bool                bPreserveRedlineMode;
      82             : 
      83             :     void                    _InitItemImport();
      84             :     void                    _FinitItemImport();
      85             :     void                    UpdateTxtCollConditions( SwDoc *pDoc );
      86             : 
      87             :     void         setTextInsertMode(
      88             :                      const ::com::sun::star::uno::Reference<
      89             :                         ::com::sun::star::text::XTextRange > & rInsertPos );
      90             :     void         setStyleInsertMode( sal_uInt16 nFamilies,
      91             :                                      sal_Bool bOverwrite );
      92             :     void         setBlockMode();
      93             :     void         setOrganizerMode();
      94             : 
      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 ::rtl::OUString& rLocalName,
     102             :                   const ::com::sun::star::uno::Reference<
     103             :                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     104             : 
     105             :     virtual XMLTextImportHelper* CreateTextImport();
     106             : 
     107             :     virtual XMLShapeImportHelper* CreateShapeImport();
     108             : 
     109             : public:
     110             :     SwXMLImport(
     111             :         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
     112             :         sal_uInt16 nImportFlags = IMPORT_ALL);
     113             : 
     114             :     ~SwXMLImport() throw();
     115             : 
     116             :     // ::com::sun::star::xml::sax::XDocumentHandler
     117             :     virtual void SAL_CALL startDocument(void)
     118             :         throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
     119             :     virtual void SAL_CALL endDocument(void)
     120             :         throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException );
     121             : 
     122             :     // XUnoTunnel
     123             :     static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
     124             :     virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
     125             : 
     126             :     // XInitialization
     127             :     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);
     128             : 
     129             :     // XServiceInfo (override parent method)
     130             :     ::rtl::OUString SAL_CALL getImplementationName()
     131             :         throw( ::com::sun::star::uno::RuntimeException );
     132             : 
     133             :     void                    InsertStyles( sal_Bool bAuto );
     134             :     void                    FinishStyles();
     135             : 
     136             :     // namespace office
     137             : 
     138             :     // NB: in contrast to other CreateFooContexts, this particular one handles
     139             :     //     the root element (i.e. office:document-meta)
     140             :     SvXMLImportContext *CreateMetaContext( const ::rtl::OUString& rLocalName );
     141             :     SvXMLImportContext *CreateScriptContext( const ::rtl::OUString& rLocalName );
     142             :     SvXMLImportContext *CreateStylesContext(
     143             :                 const ::rtl::OUString& rLocalName,
     144             :                 const ::com::sun::star::uno::Reference<
     145             :                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
     146             :                 sal_Bool bAuto );
     147             :     SvXMLImportContext *CreateMasterStylesContext(
     148             :                 const ::rtl::OUString& rLocalName,
     149             :                 const ::com::sun::star::uno::Reference<
     150             :                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     151             :     SvXMLImportContext *CreateFontDeclsContext(
     152             :             const ::rtl::OUString& rLocalName,
     153             :             const ::com::sun::star::uno::Reference<
     154             :                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     155             :     SvXMLImportContext *CreateBodyContentContext( const ::rtl::OUString& rLocalName );
     156         850 :     sal_uInt16 GetStyleFamilyMask() const { return nStyleFamilyMask; }
     157         448 :     sal_Bool IsInsertMode() const { return bInsert; }
     158         414 :     sal_Bool IsStylesOnlyMode() const { return !bLoadDoc; }
     159         311 :     sal_Bool IsBlockMode() const { return bBlock; }
     160         107 :     sal_Bool IsOrganizerMode() const { return bOrganizerMode; }
     161             : 
     162             :     inline const SvXMLUnitConverter& GetTwipUnitConverter() const;
     163             :     inline const SvXMLImportItemMapper& GetTableItemMapper() const;
     164             :     inline       SvXMLImportItemMapper& GetTableItemMapper();
     165             :     SvXMLImportContext *CreateTableItemImportContext( sal_uInt16 nPrefix,
     166             :                 const ::rtl::OUString& rLocalName,
     167             :                 const ::com::sun::star::uno::Reference<
     168             :                     ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
     169             :                 sal_uInt16 nSubFamily, SfxItemSet& rItemSet );
     170             : 
     171             :     const SvXMLTokenMap& GetDocElemTokenMap();
     172             :     const SvXMLTokenMap& GetTableElemTokenMap();
     173             :     const SvXMLTokenMap& GetTableCellAttrTokenMap();
     174             : 
     175             :     sal_Bool FindAutomaticStyle( sal_uInt16 nFamily,
     176             :                              const ::rtl::OUString& rName,
     177             :                              const SfxItemSet **ppItemSet=0,
     178             :                              ::rtl::OUString *pParent=0 ) const;
     179             : 
     180             :     virtual void SetStatistics(
     181             :         const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue> & i_rStats);
     182             :     virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
     183             :     virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps);
     184             :     virtual void SetDocumentSpecificSettings(const ::rtl::OUString& _rSettingsGroupName,
     185             :                     const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& _rSettings);
     186             : 
     187             :     SvStorage *GetPackage() { return &xPackage; }
     188             : 
     189             :     void SetProgressValue( sal_Int32 nValue );
     190             : 
     191             :     // initialize XForms
     192             :     virtual void initXForms();
     193             : 
     194             :     // get the document properties, but only if they actually need importing
     195             :     ::com::sun::star::uno::Reference<
     196             :         ::com::sun::star::document::XDocumentProperties>
     197             :             GetDocumentProperties() const;
     198             : };
     199             : 
     200          19 : inline const SvXMLUnitConverter& SwXMLImport::GetTwipUnitConverter() const
     201             : {
     202          19 :     return *pTwipUnitConv;
     203             : }
     204             : 
     205             : inline const SvXMLImportItemMapper& SwXMLImport::GetTableItemMapper() const
     206             : {
     207             :     return *pTableItemMapper;
     208             : }
     209             : 
     210          19 : inline       SvXMLImportItemMapper& SwXMLImport::GetTableItemMapper()
     211             : {
     212          19 :     return *pTableItemMapper;
     213             : }
     214             : 
     215             : inline void SwXMLImport::SetProgressValue( sal_Int32 nValue )
     216             : {
     217             :     if ( bShowProgress )
     218             :         GetProgressBarHelper()->SetValue(nValue);
     219             : }
     220             : 
     221             : #endif  //  _XMLIMP_HXX
     222             : 
     223             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10