LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/xmloff/source/draw - sdxmlimp_impl.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 14 85.7 %
Date: 2013-07-09 Functions: 12 15 80.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             :     OUString maStrText;
     170             :     sal_Bool mbFixed;
     171             :     OUString maStrDateTimeFormat;
     172             : 
     173           0 :     DateTimeDeclContextImpl() : mbFixed(sal_True) {}
     174             : };
     175             : 
     176             : DECLARE_STL_USTRINGACCESS_MAP( 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             :     OUString             msPageLayouts;
     215             :     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 OUString& rLocalName,
     226             :       const com::sun::star::uno::Reference<
     227             :         com::sun::star::xml::sax::XAttributeList>& xAttrList);
     228             : 
     229             : public:
     230             :     SdXMLImport(
     231             :         const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
     232             :         sal_Bool bIsDraw, sal_uInt16 nImportFlags = IMPORT_ALL );
     233             :     ~SdXMLImport() throw ();
     234             : 
     235             :     // XImporter
     236             :     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);
     237             : 
     238             :     // XInitialization
     239             :     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);
     240             : 
     241             :     virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps);
     242             :     virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aConfigProps);
     243             : 
     244             :     // namespace office
     245             :     // NB: in contrast to other CreateFooContexts, this particular one handles
     246             :     //     the root element (i.e. office:document-meta)
     247             :     SvXMLImportContext* CreateMetaContext(const OUString& rLocalName,
     248             :         const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
     249             :     SvXMLImportContext* CreateScriptContext( const OUString& rLocalName );
     250             :     SvXMLImportContext* CreateBodyContext(const OUString& rLocalName,
     251             :         const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
     252             :     SvXMLStylesContext* CreateStylesContext(const OUString& rLocalName,
     253             :         const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
     254             :     SvXMLStylesContext* CreateAutoStylesContext(const OUString& rLocalName,
     255             :         const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
     256             :     SvXMLImportContext* CreateMasterStylesContext(const OUString& rLocalName,
     257             :         const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList);
     258             :     SvXMLImportContext *CreateFontDeclsContext(const OUString& rLocalName,
     259             :         const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     260             : 
     261             :     // Styles and AutoStyles contexts
     262             :     const SdXMLMasterStylesContext* GetMasterStylesContext() const { return mpMasterStylesContext; }
     263             : 
     264             :     sal_uInt16 GetStyleFamilyMask() const { return mnStyleFamilyMask; }
     265           7 :     sal_Bool IsStylesOnlyMode() const { return !mbLoadDoc; }
     266             : 
     267             :     const SvXMLTokenMap& GetDocElemTokenMap();
     268             :     const SvXMLTokenMap& GetBodyElemTokenMap();
     269             :     const SvXMLTokenMap& GetStylesElemTokenMap();
     270             :     const SvXMLTokenMap& GetMasterPageElemTokenMap();
     271             :     const SvXMLTokenMap& GetMasterPageAttrTokenMap();
     272             :     const SvXMLTokenMap& GetPageMasterAttrTokenMap();
     273             :     const SvXMLTokenMap& GetPageMasterStyleAttrTokenMap();
     274             :     const SvXMLTokenMap& GetDrawPageAttrTokenMap();
     275             :     const SvXMLTokenMap& GetDrawPageElemTokenMap();
     276             :     const SvXMLTokenMap& GetPresentationPlaceholderAttrTokenMap();
     277             : 
     278             :     // export local parameters concerning page access and similar
     279             :     const com::sun::star::uno::Reference<
     280          35 :         com::sun::star::container::XNameAccess >& GetLocalDocStyleFamilies() const { return mxDocStyleFamilies; }
     281             :     const com::sun::star::uno::Reference<
     282          21 :         com::sun::star::container::XIndexAccess >& GetLocalMasterPages() const { return mxDocMasterPages; }
     283             :     const com::sun::star::uno::Reference<
     284          14 :         com::sun::star::container::XIndexAccess >& GetLocalDrawPages() const { return mxDocDrawPages; }
     285             : 
     286          35 :     sal_Int32 GetNewPageCount() const { return mnNewPageCount; }
     287          14 :     void IncrementNewPageCount() { mnNewPageCount++; }
     288          14 :     sal_Int32 GetNewMasterPageCount() const { return mnNewMasterPageCount; }
     289           7 :     void IncrementNewMasterPageCount() { mnNewMasterPageCount++; }
     290             : 
     291          10 :     com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > getPageLayouts() const { return mxPageLayouts; }
     292             : 
     293          11 :     sal_Bool IsDraw() const { return mbIsDraw; }
     294          41 :     sal_Bool IsImpress() const { return !mbIsDraw; }
     295             : 
     296             :     // #80365#
     297             :     virtual void SetStatistics(
     298             :         const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue> & i_rStats);
     299             : 
     300           7 :     sal_Bool IsPreview() const { return mbPreview; }
     301             : 
     302             :     // XServiceInfo ( : SvXMLExport )
     303             :     virtual OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
     304             : 
     305             :     void AddHeaderDecl( const OUString& rName, const OUString& rText );
     306             :     void AddFooterDecl( const OUString& rName, const OUString& rText );
     307             :     void AddDateTimeDecl( const OUString& rName, const OUString& rText, sal_Bool bFixed, const OUString& rDateTimeFormat );
     308             : 
     309             :     OUString GetHeaderDecl( const OUString& rName ) const;
     310             :     OUString GetFooterDecl( const OUString& rName ) const;
     311             :     OUString GetDateTimeDecl( const OUString& rName, sal_Bool& rbFixed, OUString& rDateTimeFormat );
     312             : 
     313             :     virtual void NotifyEmbeddedFontRead() SAL_OVERRIDE;
     314             : };
     315             : 
     316             : #endif  //  _SDXMLIMP_HXX
     317             : 
     318             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10