LCOV - code coverage report
Current view: top level - starmath/source - cfgitem.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 9 11 81.8 %
Date: 2015-06-13 12:38:46 Functions: 10 15 66.7 %
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_STARMATH_SOURCE_CFGITEM_HXX
      21             : #define INCLUDED_STARMATH_SOURCE_CFGITEM_HXX
      22             : 
      23             : #include <deque>
      24             : #include <vector>
      25             : 
      26             : #include <com/sun/star/beans/PropertyValues.hpp>
      27             : #include <com/sun/star/uno/Sequence.hxx>
      28             : #include <com/sun/star/uno/Any.h>
      29             : 
      30             : #include <rtl/ustring.hxx>
      31             : #include <unotools/configitem.hxx>
      32             : #include <vcl/timer.hxx>
      33             : 
      34             : #include <symbol.hxx>
      35             : #include <types.hxx>
      36             : #include <memory>
      37             : 
      38             : class SmSym;
      39             : class SmFormat;
      40             : namespace vcl { class Font; }
      41             : struct SmCfgOther;
      42             : class SfxItemSet;
      43             : 
      44         100 : struct SmFontFormat
      45             : {
      46             :     OUString        aName;
      47             :     sal_Int16       nCharSet;
      48             :     sal_Int16       nFamily;
      49             :     sal_Int16       nPitch;
      50             :     sal_Int16       nWeight;
      51             :     sal_Int16       nItalic;
      52             : 
      53             :     SmFontFormat();
      54             :     explicit SmFontFormat( const vcl::Font &rFont );
      55             : 
      56             :     const vcl::Font GetFont() const;
      57             :     bool            operator == ( const SmFontFormat &rFntFmt ) const;
      58             : };
      59             : 
      60          52 : struct SmFntFmtListEntry
      61             : {
      62             :     OUString        aId;
      63             :     SmFontFormat    aFntFmt;
      64             : 
      65             :     SmFntFmtListEntry( const OUString &rId, const SmFontFormat &rFntFmt );
      66             : };
      67             : 
      68           2 : class SmFontFormatList
      69             : {
      70             :     std::deque<SmFntFmtListEntry> aEntries;
      71             :     bool                    bModified;
      72             : 
      73             :     SmFontFormatList(const SmFontFormatList&) SAL_DELETED_FUNCTION;
      74             :     SmFontFormatList& operator=(const SmFontFormatList&) SAL_DELETED_FUNCTION;
      75             : 
      76             : public:
      77             :     SmFontFormatList();
      78             : 
      79             :     void    Clear();
      80             :     void    AddFontFormat( const OUString &rFntFmtId, const SmFontFormat &rFntFmt );
      81             :     void    RemoveFontFormat( const OUString &rFntFmtId );
      82             : 
      83             :     const SmFontFormat *    GetFontFormat( const OUString &rFntFmtId ) const;
      84             :     const SmFontFormat *    GetFontFormat( size_t nPos ) const;
      85             :     const OUString          GetFontFormatId( const SmFontFormat &rFntFmt ) const;
      86             :     const OUString          GetFontFormatId( const SmFontFormat &rFntFmt, bool bAdd );
      87             :     const OUString          GetFontFormatId( size_t nPos ) const;
      88             :     const OUString          GetNewFontFormatId() const;
      89           0 :     size_t                  GetCount() const    { return aEntries.size(); }
      90             : 
      91           2 :     bool    IsModified() const          { return bModified; }
      92          36 :     void    SetModified( bool bVal )    { bModified = bVal; }
      93             : };
      94             : 
      95             : class SmMathConfig : public utl::ConfigItem, public SfxBroadcaster
      96             : {
      97             :     std::unique_ptr<SmFormat>         pFormat;
      98             :     std::unique_ptr<SmCfgOther>       pOther;
      99             :     std::unique_ptr<SmFontFormatList> pFontFormatList;
     100             :     std::unique_ptr<SmSymbolManager>  pSymbolMgr;
     101             :     bool                              bIsOtherModified;
     102             :     bool                              bIsFormatModified;
     103             :     SmFontPickList                    vFontPickList[7];
     104             : 
     105             :     SmMathConfig(const SmMathConfig&) SAL_DELETED_FUNCTION;
     106             :     SmMathConfig& operator=(const SmMathConfig&) SAL_DELETED_FUNCTION;
     107             : 
     108             :     void    StripFontFormatList( const std::vector< SmSym > &rSymbols );
     109             : 
     110             : 
     111             :     void    Save();
     112             : 
     113             :     void    ReadSymbol( SmSym &rSymbol,
     114             :                         const OUString &rSymbolName,
     115             :                         const OUString &rBaseNode ) const;
     116             :     void    ReadFontFormat( SmFontFormat &rFontFormat,
     117             :                         const OUString &rSymbolName,
     118             :                         const OUString &rBaseNode ) const;
     119             : 
     120             :     void            SetOtherIfNotEqual( bool &rbItem, bool bNewVal );
     121             : 
     122             : protected:
     123             :     void    LoadOther();
     124             :     void    SaveOther();
     125             :     void    LoadFormat();
     126             :     void    SaveFormat();
     127             :     void    LoadFontFormatList();
     128             :     void    SaveFontFormatList();
     129             : 
     130             :     void        SetOtherModified( bool bVal );
     131           2 :     inline bool IsOtherModified() const     { return bIsOtherModified; }
     132             :     void        SetFormatModified( bool bVal );
     133           2 :     inline bool IsFormatModified() const    { return bIsFormatModified; }
     134             :     void        SetFontFormatListModified( bool bVal );
     135             :     inline bool IsFontFormatListModified() const    { return pFontFormatList && pFontFormatList->IsModified(); }
     136             : 
     137             :     SmFontFormatList &          GetFontFormatList();
     138         660 :     const SmFontFormatList &    GetFontFormatList() const
     139             :     {
     140         660 :         return const_cast<SmMathConfig*>(this)->GetFontFormatList();
     141             :     }
     142             : 
     143             :     virtual void    ImplCommit() SAL_OVERRIDE;
     144             : 
     145             : public:
     146             :     SmMathConfig();
     147             :     virtual ~SmMathConfig();
     148             : 
     149             :     // utl::ConfigItem
     150             :     virtual void    Notify( const com::sun::star::uno::Sequence< OUString > &rPropertyNames ) SAL_OVERRIDE;
     151             : 
     152             :     SmSymbolManager &   GetSymbolManager();
     153             :     void                GetSymbols( std::vector< SmSym > &rSymbols ) const;
     154             :     void                SetSymbols( const std::vector< SmSym > &rNewSymbols );
     155             : 
     156             :     const SmFormat &    GetStandardFormat() const;
     157             :     void                SetStandardFormat( const SmFormat &rFormat, bool bSaveFontFormatList = false );
     158             : 
     159             :     bool            IsPrintTitle() const;
     160             :     void            SetPrintTitle( bool bVal );
     161             :     bool            IsPrintFormulaText() const;
     162             :     void            SetPrintFormulaText( bool bVal );
     163             :     bool            IsPrintFrame() const;
     164             :     void            SetPrintFrame( bool bVal );
     165             :     SmPrintSize     GetPrintSize() const;
     166             :     void            SetPrintSize( SmPrintSize eSize );
     167             :     sal_uInt16      GetPrintZoomFactor() const;
     168             :     void            SetPrintZoomFactor( sal_uInt16 nVal );
     169             : 
     170             :     bool            IsSaveOnlyUsedSymbols() const;
     171             :     void            SetSaveOnlyUsedSymbols( bool bVal );
     172             :     bool            IsIgnoreSpacesRight() const;
     173             :     void            SetIgnoreSpacesRight( bool bVal );
     174             :     bool            IsAutoRedraw() const;
     175             :     void            SetAutoRedraw( bool bVal );
     176             :     bool            IsShowFormulaCursor() const;
     177             :     void            SetShowFormulaCursor( bool bVal );
     178             : 
     179           0 :     SmFontPickList & GetFontPickList(sal_uInt16 nIdent) { return vFontPickList[nIdent]; }
     180             : 
     181             :     void ItemSetToConfig(const SfxItemSet &rSet);
     182             :     void ConfigToItemSet(SfxItemSet &rSet) const;
     183             : };
     184             : 
     185             : #endif
     186             : 
     187             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11