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

Generated by: LCOV version 1.10