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

Generated by: LCOV version 1.10