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

Generated by: LCOV version 1.11