LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/draw - sdxmlimp_impl.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 14 85.7 %
Date: 2012-12-27 Functions: 12 16 75.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 _SDXMLIMP_IMPL_HXX
      21             : #define _SDXMLIMP_IMPL_HXX
      22             : 
      23             : #include <com/sun/star/drawing/XDrawPage.hpp>
      24             : #include <com/sun/star/frame/XModel.hpp>
      25             : #include <com/sun/star/task/XStatusIndicator.hpp>
      26             : #include <xmloff/xmltkmap.hxx>
      27             : #include <com/sun/star/container/XNameAccess.hpp>
      28             : 
      29             : #include <vector>
      30             : #include <xmloff/xmlimp.hxx>
      31             : 
      32             : //////////////////////////////////////////////////////////////////////////////
      33             : 
      34             : enum SdXMLDocElemTokenMap
      35             : {
      36             :     XML_TOK_DOC_FONTDECLS,
      37             :     XML_TOK_DOC_STYLES,
      38             :     XML_TOK_DOC_AUTOSTYLES,
      39             :     XML_TOK_DOC_MASTERSTYLES,
      40             :     XML_TOK_DOC_META,
      41             :     XML_TOK_DOC_BODY,
      42             :     XML_TOK_DOC_SCRIPT,
      43             :     XML_TOK_DOC_SETTINGS,
      44             :     XML_TOK_OFFICE_END = XML_TOK_UNKNOWN
      45             : };
      46             : 
      47             : enum SdXMLBodyElemTokenMap
      48             : {
      49             :     XML_TOK_BODY_PAGE,
      50             :     XML_TOK_BODY_SETTINGS,
      51             :     XML_TOK_BODY_HEADER_DECL,
      52             :     XML_TOK_BODY_FOOTER_DECL,
      53             :     XML_TOK_BODY_DATE_TIME_DECL
      54             : };
      55             : 
      56             : enum SdXMLStylesElemTokenMap
      57             : {
      58             :     XML_TOK_STYLES_MASTER_PAGE,
      59             :     XML_TOK_STYLES_STYLE,
      60             :     XML_TOK_STYLES_PAGE_MASTER,
      61             :     XML_TOK_STYLES_PRESENTATION_PAGE_LAYOUT
      62             : };
      63             : 
      64             : enum SdXMLAutoStylesElemTokenMap
      65             : {
      66             :     XML_TOK_AUTOSTYLES_STYLE
      67             : };
      68             : 
      69             : enum SdXMLMasterPageElemTokenMap
      70             : {
      71             :     XML_TOK_MASTERPAGE_STYLE,
      72             :     XML_TOK_MASTERPAGE_NOTES
      73             : };
      74             : 
      75             : enum SdXMLMasterPageAttrTokenMap
      76             : {
      77             :     XML_TOK_MASTERPAGE_NAME,
      78             :     XML_TOK_MASTERPAGE_DISPLAY_NAME,
      79             :     XML_TOK_MASTERPAGE_PAGE_MASTER_NAME,
      80             :     XML_TOK_MASTERPAGE_STYLE_NAME,
      81             :     XML_TOK_MASTERPAGE_PAGE_LAYOUT_NAME,
      82             :     XML_TOK_MASTERPAGE_USE_HEADER_NAME,
      83             :     XML_TOK_MASTERPAGE_USE_FOOTER_NAME,
      84             :     XML_TOK_MASTERPAGE_USE_DATE_TIME_NAME
      85             : };
      86             : 
      87             : enum SdXMLPageMasterAttrTokenMap
      88             : {
      89             :     XML_TOK_PAGEMASTER_NAME
      90             : };
      91             : 
      92             : enum SdXMLPageMasterStyleAttrTokenMap
      93             : {
      94             :     XML_TOK_PAGEMASTERSTYLE_MARGIN_TOP,
      95             :     XML_TOK_PAGEMASTERSTYLE_MARGIN_BOTTOM,
      96             :     XML_TOK_PAGEMASTERSTYLE_MARGIN_LEFT,
      97             :     XML_TOK_PAGEMASTERSTYLE_MARGIN_RIGHT,
      98             :     XML_TOK_PAGEMASTERSTYLE_PAGE_WIDTH,
      99             :     XML_TOK_PAGEMASTERSTYLE_PAGE_HEIGHT,
     100             :     XML_TOK_PAGEMASTERSTYLE_PAGE_ORIENTATION
     101             : };
     102             : 
     103             : enum SdXMLDocStyleAttrTokenMap
     104             : {
     105             :     XML_TOK_DOCSTYLE_NAME,
     106             :     XML_TOK_DOCSTYLE_FAMILY,
     107             :     XML_TOK_DOCSTYLE_PARENT_STYLE_NAME,
     108             :     XML_TOK_DOCSTYLE_AUTOMATIC
     109             : };
     110             : 
     111             : enum SdXMLDocStyleElemTokenMap
     112             : {
     113             :     XML_TOK_DOCSTYLE_PROPERTIES,
     114             :     XML_TOK_DOCSTYLE_PRESENTATION_PLACEHOLDER
     115             : };
     116             : 
     117             : enum SdXMLDrawPageAttrTokenMap
     118             : {
     119             :     XML_TOK_DRAWPAGE_NAME,
     120             :     XML_TOK_DRAWPAGE_STYLE_NAME,
     121             :     XML_TOK_DRAWPAGE_MASTER_PAGE_NAME,
     122             :     XML_TOK_DRAWPAGE_PAGE_LAYOUT_NAME,
     123             :     XML_TOK_DRAWPAGE_DRAWID,
     124             :     XML_TOK_DRAWPAGE_XMLID,
     125             :     XML_TOK_DRAWPAGE_HREF,
     126             :     XML_TOK_DRAWPAGE_USE_HEADER_NAME,
     127             :     XML_TOK_DRAWPAGE_USE_FOOTER_NAME,
     128             :     XML_TOK_DRAWPAGE_USE_DATE_TIME_NAME
     129             : };
     130             : 
     131             : enum SdXMLDrawPageElemTokenMap
     132             : {
     133             :     XML_TOK_DRAWPAGE_NOTES,
     134             :     XML_TOK_DRAWPAGE_PAR,
     135             :     XML_TOK_DRAWPAGE_SEQ
     136             : };
     137             : 
     138             : enum SdXMLPresentationPlaceholderAttrTokenMap
     139             : {
     140             :     XML_TOK_PRESENTATIONPLACEHOLDER_OBJECTNAME,
     141             :     XML_TOK_PRESENTATIONPLACEHOLDER_X,
     142             :     XML_TOK_PRESENTATIONPLACEHOLDER_Y,
     143             :     XML_TOK_PRESENTATIONPLACEHOLDER_WIDTH,
     144             :     XML_TOK_PRESENTATIONPLACEHOLDER_HEIGHT
     145             : };
     146             : 
     147             : //////////////////////////////////////////////////////////////////////////////
     148             : 
     149             : struct SdXMLltXDrawPageId
     150             : {
     151             :   bool operator()(sal_Int32 nId1, sal_Int32 nId2 ) const
     152             :   {
     153             :     return nId1 < nId2;
     154             :   }
     155             : };
     156             : 
     157             : typedef std::map< sal_Int32, com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage >, SdXMLltXDrawPageId > DrawPageIdMap;
     158             : 
     159             : //////////////////////////////////////////////////////////////////////////////
     160             : 
     161             : class SvXMLUnitConverter;
     162             : class SvXMLTokenMap;
     163             : class SdXMLMasterStylesContext;
     164             : 
     165             : //////////////////////////////////////////////////////////////////////////////
     166             : 
     167           0 : struct DateTimeDeclContextImpl
     168             : {
     169             :     rtl::OUString maStrText;
     170             :     sal_Bool mbFixed;
     171             :     rtl::OUString maStrDateTimeFormat;
     172             : 
     173           0 :     DateTimeDeclContextImpl() : mbFixed(sal_True) {}
     174             : };
     175             : 
     176             : DECLARE_STL_USTRINGACCESS_MAP( ::rtl::OUString, HeaderFooterDeclMap );
     177             : DECLARE_STL_USTRINGACCESS_MAP( DateTimeDeclContextImpl, DateTimeDeclMap );
     178             : 
     179             : //////////////////////////////////////////////////////////////////////////////
     180             : 
     181             : class SdXMLImport: public SvXMLImport
     182             : {
     183             :     com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > mxDocStyleFamilies;
     184             :     com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > mxDocMasterPages;
     185             :     com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > mxDocDrawPages;
     186             :     com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > mxPageLayouts;
     187             : 
     188             :     // contexts for Style and AutoStyle import
     189             :     SdXMLMasterStylesContext*   mpMasterStylesContext;
     190             : 
     191             :     // token map lists
     192             :     SvXMLTokenMap*              mpDocElemTokenMap;
     193             :     SvXMLTokenMap*              mpBodyElemTokenMap;
     194             :     SvXMLTokenMap*              mpStylesElemTokenMap;
     195             :     SvXMLTokenMap*              mpMasterPageElemTokenMap;
     196             :     SvXMLTokenMap*              mpMasterPageAttrTokenMap;
     197             :     SvXMLTokenMap*              mpPageMasterAttrTokenMap;
     198             :     SvXMLTokenMap*              mpPageMasterStyleAttrTokenMap;
     199             :     SvXMLTokenMap*              mpDrawPageAttrTokenMap;
     200             :     SvXMLTokenMap*              mpDrawPageElemTokenMap;
     201             :     SvXMLTokenMap*              mpPresentationPlaceholderAttrTokenMap;
     202             : 
     203             :     sal_uInt16                  mnStyleFamilyMask;
     204             : 
     205             :     sal_Int32                   mnNewPageCount;
     206             :     sal_Int32                   mnNewMasterPageCount;
     207             : 
     208             :     sal_Bool                    mbIsDraw;
     209             :     sal_Bool                    mbLoadDoc;
     210             :     sal_Bool                    mbPreview;
     211             : 
     212             :     DrawPageIdMap               maDrawPageIds;
     213             : 
     214             :     ::rtl::OUString             msPageLayouts;
     215             :     ::rtl::OUString             msPreview;
     216             : 
     217             :     HeaderFooterDeclMap         maHeaderDeclsMap;
     218             :     HeaderFooterDeclMap         maFooterDeclsMap;
     219             :     DateTimeDeclMap             maDateTimeDeclsMap;
     220             : 
     221             : protected:
     222             :     // This method is called after the namespace map has been updated, but
     223             :     // before a context for the current element has been pushed.
     224             :     virtual SvXMLImportContext *CreateContext(sal_uInt16 nPrefix,
     225             :       const rtl::OUString& rLocalName,
     226             :       const com::sun::star::uno::Reference<
     227             :         com::sun::star::xml::sax::XAttributeList>& xAttrList);
     228             : 
     229             : public:
     230             :     // #110680#
     231             :     SdXMLImport(
     232             :         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,
     233             :         sal_Bool bIsDraw, sal_uInt16 nImportFlags = IMPORT_ALL );
     234             :     ~SdXMLImport() throw ();
     235             : 
     236             :     // XImporter
     237             :     virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
     238             : 
     239             :     // XInitialization
     240             :     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);
     241             : 
     242             :     virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
     243             :     virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps);
     244             : 
     245             :     // namespace office
     246             :     // NB: in contrast to other CreateFooContexts, this particular one handles
     247             :     //     the root element (i.e. office:document-meta)
     248             :     SvXMLImportContext* CreateMetaContext(const rtl::OUString& rLocalName,
     249             :         const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
     250             :     SvXMLImportContext* CreateScriptContext( const ::rtl::OUString& rLocalName );
     251             :     SvXMLImportContext* CreateBodyContext(const rtl::OUString& rLocalName,
     252             :         const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
     253             :     SvXMLStylesContext* CreateStylesContext(const rtl::OUString& rLocalName,
     254             :         const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
     255             :     SvXMLStylesContext* CreateAutoStylesContext(const rtl::OUString& rLocalName,
     256             :         const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
     257             :     SvXMLImportContext* CreateMasterStylesContext(const rtl::OUString& rLocalName,
     258             :         const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
     259             :     SvXMLImportContext *CreateFontDeclsContext(const ::rtl::OUString& rLocalName,
     260             :         const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     261             : 
     262             :     // Styles and AutoStyles contexts
     263             :     const SdXMLMasterStylesContext* GetMasterStylesContext() const { return mpMasterStylesContext; }
     264             : 
     265             :     sal_uInt16 GetStyleFamilyMask() const { return mnStyleFamilyMask; }
     266           2 :     sal_Bool IsStylesOnlyMode() const { return !mbLoadDoc; }
     267             : 
     268             :     const SvXMLTokenMap& GetDocElemTokenMap();
     269             :     const SvXMLTokenMap& GetBodyElemTokenMap();
     270             :     const SvXMLTokenMap& GetStylesElemTokenMap();
     271             :     const SvXMLTokenMap& GetMasterPageElemTokenMap();
     272             :     const SvXMLTokenMap& GetMasterPageAttrTokenMap();
     273             :     const SvXMLTokenMap& GetPageMasterAttrTokenMap();
     274             :     const SvXMLTokenMap& GetPageMasterStyleAttrTokenMap();
     275             :     const SvXMLTokenMap& GetDrawPageAttrTokenMap();
     276             :     const SvXMLTokenMap& GetDrawPageElemTokenMap();
     277             :     const SvXMLTokenMap& GetPresentationPlaceholderAttrTokenMap();
     278             : 
     279             :     // export local parameters concerning page access and similar
     280             :     const com::sun::star::uno::Reference<
     281          10 :         com::sun::star::container::XNameAccess >& GetLocalDocStyleFamilies() const { return mxDocStyleFamilies; }
     282             :     const com::sun::star::uno::Reference<
     283          11 :         com::sun::star::container::XIndexAccess >& GetLocalMasterPages() const { return mxDocMasterPages; }
     284             :     const com::sun::star::uno::Reference<
     285           9 :         com::sun::star::container::XIndexAccess >& GetLocalDrawPages() const { return mxDocDrawPages; }
     286             : 
     287          20 :     sal_Int32 GetNewPageCount() const { return mnNewPageCount; }
     288           9 :     void IncrementNewPageCount() { mnNewPageCount++; }
     289           4 :     sal_Int32 GetNewMasterPageCount() const { return mnNewMasterPageCount; }
     290           2 :     void IncrementNewMasterPageCount() { mnNewMasterPageCount++; }
     291             : 
     292           8 :     com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > getPageLayouts() const { return mxPageLayouts; }
     293             : 
     294           3 :     sal_Bool IsDraw() const { return mbIsDraw; }
     295          21 :     sal_Bool IsImpress() const { return !mbIsDraw; }
     296             : 
     297             :     // #80365#
     298             :     virtual void SetStatistics(
     299             :         const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue> & i_rStats);
     300             : 
     301           7 :     sal_Bool IsPreview() const { return mbPreview; }
     302             : 
     303             :     // XServiceInfo ( : SvXMLExport )
     304             :     virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
     305             : 
     306             :     void AddHeaderDecl( const ::rtl::OUString& rName, const ::rtl::OUString& rText );
     307             :     void AddFooterDecl( const ::rtl::OUString& rName, const ::rtl::OUString& rText );
     308             :     void AddDateTimeDecl( const ::rtl::OUString& rName, const ::rtl::OUString& rText, sal_Bool bFixed, const ::rtl::OUString& rDateTimeFormat );
     309             : 
     310             :     ::rtl::OUString GetHeaderDecl( const ::rtl::OUString& rName ) const;
     311             :     ::rtl::OUString GetFooterDecl( const ::rtl::OUString& rName ) const;
     312             :     ::rtl::OUString GetDateTimeDecl( const ::rtl::OUString& rName, sal_Bool& rbFixed, ::rtl::OUString& rDateTimeFormat );
     313             : 
     314             : };
     315             : 
     316             : #endif  //  _SDXMLIMP_HXX
     317             : 
     318             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10