LCOV - code coverage report
Current view: top level - include/xmloff - xmlstyle.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 14 14 100.0 %
Date: 2014-04-11 Functions: 14 14 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 INCLUDED_XMLOFF_XMLSTYLE_HXX
      21             : #define INCLUDED_XMLOFF_XMLSTYLE_HXX
      22             : 
      23             : #include <sal/config.h>
      24             : #include <xmloff/dllapi.h>
      25             : #include <sal/types.h>
      26             : #include <rsc/rscsfx.hxx>
      27             : #include <tools/rtti.hxx>
      28             : #include <xmloff/uniref.hxx>
      29             : #include <xmloff/xmltkmap.hxx>
      30             : #include <xmloff/xmlictxt.hxx>
      31             : 
      32             : class SvXMLStylesContext_Impl;
      33             : class SvXMLUnitConverter;
      34             : class SvXMLImportPropertyMapper;
      35             : 
      36             : namespace com { namespace sun { namespace star {
      37             : namespace container { class XNameContainer; }
      38             : namespace style { class XAutoStyleFamily; }
      39             : } } }
      40             : 
      41             : enum XMLStyleStylesElemTokens
      42             : {
      43             :     XML_TOK_STYLE_STYLE,
      44             :     XML_TOK_STYLE_PAGE_MASTER,
      45             :     XML_TOK_TEXT_LIST_STYLE,
      46             :     XML_TOK_TEXT_OUTLINE,
      47             :     XML_TOK_STYLES_GRADIENTSTYLES,
      48             :     XML_TOK_STYLES_HATCHSTYLES,
      49             :     XML_TOK_STYLES_BITMAPSTYLES,
      50             :     XML_TOK_STYLES_TRANSGRADIENTSTYLES,
      51             :     XML_TOK_STYLES_MARKERSTYLES,
      52             :     XML_TOK_STYLES_DASHSTYLES,
      53             :     XML_TOK_TEXT_NOTE_CONFIG,
      54             :     XML_TOK_TEXT_BIBLIOGRAPHY_CONFIG,
      55             :     XML_TOK_TEXT_LINENUMBERING_CONFIG,
      56             :     XML_TOK_STYLE_DEFAULT_STYLE,
      57             :     XML_TOK_STYLE_DEFAULT_PAGE_LAYOUT,  //text grid enhancement
      58             :     XML_TOK_STYLE_STYLES_ELEM_END=XML_TOK_UNKNOWN
      59             : };
      60             : 
      61             : class XMLOFF_DLLPUBLIC SvXMLStyleContext : public SvXMLImportContext
      62             : {
      63             :     OUString     maName;
      64             :     OUString     maDisplayName;
      65             :     OUString     maAutoName;
      66             :     OUString     maParentName;// Will be moved to XMLPropStyle soon!!!!
      67             :     OUString     maFollow;    // Will be moved to XMLPropStyle soon!!!!
      68             :     bool         mbHidden;
      69             : 
      70             :     OUString     maHelpFile;  // Will be removed very soon!!!!
      71             : 
      72             :     sal_uInt32   mnHelpId;    // Will be removed very soon!!!!
      73             :     sal_uInt16   mnFamily;
      74             : 
      75             :     bool         mbValid : 1; // Set this to false in CreateAndInsert
      76             :                               // if the style shouldn't be processed
      77             :                               // by Finish() or si somehow invalid.
      78             :     bool         mbNew : 1;   // Set this to false in CreateAnsInsert
      79             :                               // if the style is already existing.
      80             :     bool         mbDefaultStyle : 1;
      81             : 
      82             : protected:
      83             : 
      84             :     virtual void SetAttribute( sal_uInt16 nPrefixKey,
      85             :                                const OUString& rLocalName,
      86             :                                const OUString& rValue );
      87             : 
      88         114 :     void SetFamily( sal_uInt16 nSet ) { mnFamily = nSet; }
      89        1099 :     void SetAutoName( const OUString& rName ) { maAutoName = rName; }
      90             : 
      91             : public:
      92             : 
      93             :     TYPEINFO_OVERRIDE();
      94             : 
      95             :     SvXMLStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
      96             :         const OUString& rLName,
      97             :         const ::com::sun::star::uno::Reference<
      98             :               ::com::sun::star::xml::sax::XAttributeList >& xAttrList,
      99             :               sal_uInt16 nFamily=0,
     100             :               bool bDefaultStyle = false );
     101             : 
     102             :     virtual ~SvXMLStyleContext();
     103             : 
     104             :     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
     105             :         const OUString& rLocalName,
     106             :         const ::com::sun::star::uno::Reference<
     107             :             ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
     108             : 
     109             :     virtual void StartElement(
     110             :         const ::com::sun::star::uno::Reference<
     111             :             ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
     112             : 
     113       50758 :     const OUString&  GetName() const { return maName; }
     114        8423 :     const OUString&  GetDisplayName() const { return maDisplayName.getLength() ? maDisplayName : maName; }
     115       10746 :     const OUString&  GetAutoName() const { return maAutoName; }
     116       10821 :     const OUString&  GetParentName() const { return maParentName; }
     117        2087 :     const OUString&  GetFollow() const { return maFollow; }
     118             : 
     119             :     const OUString&  GetHelpFile() const { return maHelpFile; }
     120             :     sal_uInt32  GetHelpId() const { return mnHelpId; }
     121             : 
     122      153583 :     sal_uInt16 GetFamily() const { return mnFamily; }
     123             : 
     124        5098 :     bool IsValid() const { return mbValid; }
     125          72 :     void SetValid( bool b ) { mbValid = b; }
     126             : 
     127        2837 :     bool IsNew() const { return mbNew; }
     128        2655 :     void SetNew( bool b ) { mbNew = b; }
     129             : 
     130        2583 :     bool IsHidden() const { return mbHidden; }
     131             : 
     132             :     // This method is called for every default style
     133             :     virtual void SetDefaults();
     134             : 
     135             :     // This method is called for every style. It must create it and insert
     136             :     // it into the document.
     137             :     virtual void CreateAndInsert( bool bOverwrite );
     138             : 
     139             :     // This method is called for every style. It must create it and insert
     140             :     // it into the document if this hasn't happened already in CreateAndInsert().
     141             :     virtual void CreateAndInsertLate( bool bOverwrite );
     142             : 
     143             :     // This method is called fpr every style after all styles have been
     144             :     // inserted into the document.
     145             :     virtual void Finish( bool bOverwrite );
     146             : 
     147       37847 :     bool IsDefaultStyle() const { return mbDefaultStyle; }
     148             : 
     149             :     /** if this method returns true, its parent styles context
     150             :         should not add it to its container.<br>
     151             :         Transient styles can't be accessed from its
     152             :         parent SvXMLStylesContext after theyre imported and
     153             :         the methods CreateAndInsert(), CreateAndInsertLate()
     154             :         and Finish() will not be called.
     155             :         The default return value is false
     156             :     */
     157             :     virtual bool IsTransient() const;
     158             : };
     159             : 
     160             : class XMLOFF_DLLPUBLIC SvXMLStylesContext : public SvXMLImportContext
     161             : {
     162             :     const OUString msParaStyleServiceName;
     163             :     const OUString msTextStyleServiceName;
     164             : 
     165             :     SvXMLStylesContext_Impl *mpImpl;
     166             :     SvXMLTokenMap           *mpStyleStylesElemTokenMap;
     167             : 
     168             : 
     169             :     ::com::sun::star::uno::Reference <
     170             :                     ::com::sun::star::container::XNameContainer > mxParaStyles;
     171             : 
     172             :     ::com::sun::star::uno::Reference <
     173             :                     ::com::sun::star::container::XNameContainer > mxTextStyles;
     174             : 
     175             :     ::com::sun::star::uno::Reference <
     176             :                     ::com::sun::star::style::XAutoStyleFamily > mxParaAutoStyles;
     177             : 
     178             :     ::com::sun::star::uno::Reference <
     179             :                     ::com::sun::star::style::XAutoStyleFamily > mxTextAutoStyles;
     180             : 
     181             :     UniReference < SvXMLImportPropertyMapper > mxParaImpPropMapper;
     182             :     UniReference < SvXMLImportPropertyMapper > mxTextImpPropMapper;
     183             :     UniReference < SvXMLImportPropertyMapper > mxShapeImpPropMapper;
     184             :     mutable UniReference < SvXMLImportPropertyMapper > mxChartImpPropMapper;
     185             :     mutable UniReference < SvXMLImportPropertyMapper > mxPageImpPropMapper;
     186             : 
     187             :     SAL_DLLPRIVATE const SvXMLTokenMap& GetStyleStylesElemTokenMap();
     188             : 
     189             :     SAL_DLLPRIVATE SvXMLStylesContext(SvXMLStylesContext &); // not defined
     190             :     SAL_DLLPRIVATE void operator =(SvXMLStylesContext &); // not defined
     191             : 
     192             : protected:
     193             : 
     194             :     sal_uInt32 GetStyleCount() const;
     195             :     SvXMLStyleContext *GetStyle( sal_uInt32 i );
     196             :     const SvXMLStyleContext *GetStyle( sal_uInt32 i ) const;
     197             : 
     198             :     virtual SvXMLStyleContext *CreateStyleChildContext( sal_uInt16 nPrefix,
     199             :         const OUString& rLocalName,
     200             :         const ::com::sun::star::uno::Reference<
     201             :             ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     202             : 
     203             :     virtual SvXMLStyleContext *CreateStyleStyleChildContext( sal_uInt16 nFamily,
     204             :         sal_uInt16 nPrefix, const OUString& rLocalName,
     205             :         const ::com::sun::star::uno::Reference<
     206             :             ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     207             : 
     208             :     virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
     209             :         sal_uInt16 nFamily, sal_uInt16 nPrefix,
     210             :         const OUString& rLocalName,
     211             :         const ::com::sun::star::uno::Reference<
     212             :             ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     213             : 
     214             :     virtual bool InsertStyleFamily( sal_uInt16 nFamily ) const;
     215             : 
     216             : public:
     217             :     TYPEINFO_OVERRIDE();
     218             : 
     219             :     SvXMLStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
     220             :         const OUString& rLName,
     221             :         const ::com::sun::star::uno::Reference<
     222             :             ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
     223             :         bool bAutomatic = false );
     224             : 
     225             :     virtual ~SvXMLStylesContext();
     226             : 
     227             :     // Create child element.
     228             :     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
     229             :         const OUString& rLocalName,
     230             :         const ::com::sun::star::uno::Reference<
     231             :             ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE;
     232             : 
     233             :     // This method must be overloaded to insert styles into the document.
     234             :     virtual void EndElement() SAL_OVERRIDE;
     235             : 
     236             :     // This allows to add an SvXMLStyleContext to this context from extern
     237             :     void AddStyle(SvXMLStyleContext& rNew);
     238             : 
     239             :     const SvXMLStyleContext *FindStyleChildContext(
     240             :                                       sal_uInt16 nFamily,
     241             :                                       const OUString& rName,
     242             :                                       bool bCreateIndex = false ) const;
     243             :     virtual sal_uInt16 GetFamily( const OUString& rFamily ) const;
     244             :     virtual UniReference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
     245             :                         sal_uInt16 nFamily ) const;
     246             : 
     247             :     virtual ::com::sun::star::uno::Reference <
     248             :                     ::com::sun::star::container::XNameContainer >
     249             :         GetStylesContainer( sal_uInt16 nFamily ) const;
     250             :     virtual OUString GetServiceName( sal_uInt16 nFamily ) const;
     251             : 
     252             :        virtual ::com::sun::star::uno::Reference < ::com::sun::star::style::XAutoStyleFamily >
     253             :         GetAutoStyles( sal_uInt16 nFamily ) const;
     254             :     void CopyAutoStylesToDoc();
     255             :     void CopyStylesToDoc( bool bOverwrite, bool bFinish = true );
     256             :     void FinishStyles( bool bOverwrite );
     257             : 
     258             :     // This method must be called to release the references to all styles
     259             :     // that are stored in the context.
     260             :     void Clear();
     261             :     bool IsAutomaticStyle() const;
     262             : };
     263             : 
     264             : #endif // INCLUDED_XMLOFF_XMLSTYLE_HXX
     265             : 
     266             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10