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

Generated by: LCOV version 1.10