LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/include/xmloff - xmlstyle.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 13 14 92.9 %
Date: 2013-07-09 Functions: 13 14 92.9 %
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 _XMLOFF_XMLSTYLE_HXX
      21             : #define _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             :     sal_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             :     sal_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             :     sal_Bool            mbNew : 1;  // Set this to false in CreateAnsInsert
      79             :                                     // if the style is already existing.
      80             :     sal_Bool            mbDefaultStyle : 1;
      81             : 
      82             : protected:
      83             : 
      84             :     virtual void SetAttribute( sal_uInt16 nPrefixKey,
      85             :                                const OUString& rLocalName,
      86             :                                const OUString& rValue );
      87             : 
      88          51 :     void SetFamily( sal_uInt16 nSet ) { mnFamily = nSet; }
      89         102 :     void SetAutoName( const OUString& rName ) { maAutoName = rName; }
      90             : 
      91             : public:
      92             : 
      93             :     TYPEINFO();
      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, sal_Bool bDefaultStyle = sal_False );
     100             : 
     101             :     virtual ~SvXMLStyleContext();
     102             : 
     103             :     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
     104             :         const OUString& rLocalName,
     105             :         const ::com::sun::star::uno::Reference<
     106             :             ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     107             : 
     108             :     virtual void StartElement(
     109             :         const ::com::sun::star::uno::Reference<
     110             :             ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     111             : 
     112       21452 :     const OUString&  GetName() const { return maName; }
     113        2940 :     const OUString&  GetDisplayName() const { return maDisplayName.getLength() ? maDisplayName : maName; }
     114         418 :     const OUString&  GetAutoName() const { return maAutoName; }
     115        2529 :     const OUString&  GetParentName() const { return maParentName; }
     116         979 :     const OUString&  GetFollow() const { return maFollow; }
     117             : 
     118             :     const OUString&  GetHelpFile() const { return maHelpFile; }
     119             :     sal_uInt32  GetHelpId() const { return mnHelpId; }
     120             : 
     121       66313 :     sal_uInt16 GetFamily() const { return mnFamily; }
     122             : 
     123        2413 :     sal_Bool IsValid() const { return mbValid; }
     124           0 :     void SetValid( sal_Bool b ) { mbValid = b; }
     125             : 
     126        1211 :     sal_Bool IsNew() const { return mbNew; }
     127        1241 :     void SetNew( sal_Bool b ) { mbNew = b; }
     128             : 
     129        1241 :     sal_Bool IsHidden() const { return mbHidden; }
     130             : 
     131             :     // This method is called for every default style
     132             :     virtual void SetDefaults();
     133             : 
     134             :     // This method is called for every style. It must create it and insert
     135             :     // it into the document.
     136             :     virtual void CreateAndInsert( sal_Bool bOverwrite );
     137             : 
     138             :     // This method is called for every style. It must create it and insert
     139             :     // it into the document if this hasn't happened already in CreateAndInsert().
     140             :     virtual void CreateAndInsertLate( sal_Bool bOverwrite );
     141             : 
     142             :     // This method is called fpr every style after all styles have been
     143             :     // inserted into the document.
     144             :     virtual void Finish( sal_Bool bOverwrite );
     145             : 
     146       14409 :     sal_Bool IsDefaultStyle() const { return mbDefaultStyle; }
     147             : 
     148             :     /** if this method returns true, its parent styles context
     149             :         should not add it to its container.<br>
     150             :         Transient styles can't be accessed from its
     151             :         parent SvXMLStylesContext after theyre imported and
     152             :         the methods CreateAndInsert(), CreateAndInsertLate()
     153             :         and Finish() will not be called.
     154             :         The default return value is false
     155             :     */
     156             :     virtual sal_Bool IsTransient() const;
     157             : };
     158             : 
     159             : class XMLOFF_DLLPUBLIC SvXMLStylesContext : public SvXMLImportContext
     160             : {
     161             :     const OUString msParaStyleServiceName;
     162             :     const OUString msTextStyleServiceName;
     163             : 
     164             :     SvXMLStylesContext_Impl *mpImpl;
     165             :     SvXMLTokenMap           *mpStyleStylesElemTokenMap;
     166             : 
     167             : 
     168             :     ::com::sun::star::uno::Reference <
     169             :                     ::com::sun::star::container::XNameContainer > mxParaStyles;
     170             : 
     171             :     ::com::sun::star::uno::Reference <
     172             :                     ::com::sun::star::container::XNameContainer > mxTextStyles;
     173             : 
     174             :     ::com::sun::star::uno::Reference <
     175             :                     ::com::sun::star::style::XAutoStyleFamily > mxParaAutoStyles;
     176             : 
     177             :     ::com::sun::star::uno::Reference <
     178             :                     ::com::sun::star::style::XAutoStyleFamily > mxTextAutoStyles;
     179             : 
     180             :     UniReference < SvXMLImportPropertyMapper > mxParaImpPropMapper;
     181             :     UniReference < SvXMLImportPropertyMapper > mxTextImpPropMapper;
     182             :     UniReference < SvXMLImportPropertyMapper > mxShapeImpPropMapper;
     183             :     mutable UniReference < SvXMLImportPropertyMapper > mxChartImpPropMapper;
     184             :     mutable UniReference < SvXMLImportPropertyMapper > mxPageImpPropMapper;
     185             : 
     186             :     SAL_DLLPRIVATE const SvXMLTokenMap& GetStyleStylesElemTokenMap();
     187             : 
     188             :     SAL_DLLPRIVATE SvXMLStylesContext(SvXMLStylesContext &); // not defined
     189             :     SAL_DLLPRIVATE void operator =(SvXMLStylesContext &); // not defined
     190             : 
     191             : protected:
     192             : 
     193             :     sal_uInt32 GetStyleCount() const;
     194             :     SvXMLStyleContext *GetStyle( sal_uInt32 i );
     195             :     const SvXMLStyleContext *GetStyle( sal_uInt32 i ) const;
     196             : 
     197             :     virtual SvXMLStyleContext *CreateStyleChildContext( sal_uInt16 nPrefix,
     198             :         const OUString& rLocalName,
     199             :         const ::com::sun::star::uno::Reference<
     200             :             ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     201             : 
     202             :     virtual SvXMLStyleContext *CreateStyleStyleChildContext( sal_uInt16 nFamily,
     203             :         sal_uInt16 nPrefix, const OUString& rLocalName,
     204             :         const ::com::sun::star::uno::Reference<
     205             :             ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     206             : 
     207             :     virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
     208             :         sal_uInt16 nFamily, sal_uInt16 nPrefix,
     209             :         const OUString& rLocalName,
     210             :         const ::com::sun::star::uno::Reference<
     211             :             ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     212             : 
     213             :     virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const;
     214             : 
     215             : public:
     216             :     TYPEINFO();
     217             : 
     218             :     SvXMLStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx,
     219             :         const OUString& rLName,
     220             :         const ::com::sun::star::uno::Reference<
     221             :             ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
     222             :         sal_Bool bAutomatic = sal_False );
     223             : 
     224             :     virtual ~SvXMLStylesContext();
     225             : 
     226             :     // Create child element.
     227             :     virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
     228             :         const OUString& rLocalName,
     229             :         const ::com::sun::star::uno::Reference<
     230             :             ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
     231             : 
     232             :     // This method must be overloaded to insert styles into the document.
     233             :     virtual void EndElement();
     234             : 
     235             :     // This allows to add an SvXMLStyleContext to this context from extern
     236             :     void AddStyle(SvXMLStyleContext& rNew);
     237             : 
     238             :     const SvXMLStyleContext *FindStyleChildContext(
     239             :                                       sal_uInt16 nFamily,
     240             :                                       const OUString& rName,
     241             :                                       sal_Bool bCreateIndex=sal_False ) const;
     242             :     virtual sal_uInt16 GetFamily( const OUString& rFamily ) const;
     243             :     virtual UniReference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
     244             :                         sal_uInt16 nFamily ) const;
     245             : 
     246             :     virtual ::com::sun::star::uno::Reference <
     247             :                     ::com::sun::star::container::XNameContainer >
     248             :         GetStylesContainer( sal_uInt16 nFamily ) const;
     249             :     virtual OUString GetServiceName( sal_uInt16 nFamily ) const;
     250             : 
     251             :        virtual ::com::sun::star::uno::Reference < ::com::sun::star::style::XAutoStyleFamily >
     252             :         GetAutoStyles( sal_uInt16 nFamily ) const;
     253             :     void CopyAutoStylesToDoc();
     254             :     void CopyStylesToDoc( sal_Bool bOverwrite, sal_Bool bFinish=sal_True );
     255             :     void FinishStyles( sal_Bool bOverwrite );
     256             : 
     257             :     // This method must be called to release the references to all styles
     258             :     // that are stored in the context.
     259             :     void Clear();
     260             :     sal_Bool IsAutomaticStyle() const;
     261             : };
     262             : 
     263             : #endif  //  _XMLOFF_XMLSTYLE_HXX
     264             : 
     265             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10