LCOV - code coverage report
Current view: top level - starmath/source - cfgitem.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 363 664 54.7 %
Date: 2014-04-11 Functions: 40 66 60.6 %
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             : #include <vcl/svapp.hxx>
      21             : #include <vcl/settings.hxx>
      22             : 
      23             : #include <sal/macros.h>
      24             : #include "cfgitem.hxx"
      25             : 
      26             : #include "starmath.hrc"
      27             : #include "smdll.hxx"
      28             : #include "format.hxx"
      29             : 
      30             : using namespace com::sun::star;
      31             : using namespace com::sun::star::uno;
      32             : using namespace com::sun::star::beans;
      33             : 
      34             : 
      35             : 
      36             : static const char aRootName[] = "Office.Math";
      37             : 
      38             : #define SYMBOL_LIST         "SymbolList"
      39             : #define FONT_FORMAT_LIST    "FontFormatList"
      40             : 
      41             : 
      42             : 
      43             : 
      44          18 : static Sequence< OUString > lcl_GetFontPropertyNames()
      45             : {
      46             :     static const char * aPropNames[] =
      47             :     {
      48             :         "Name",
      49             :         "CharSet",
      50             :         "Family",
      51             :         "Pitch",
      52             :         "Weight",
      53             :         "Italic",
      54             :         0
      55             :     };
      56             : 
      57          18 :     const char** ppPropName = aPropNames;
      58             : 
      59          18 :     Sequence< OUString > aNames( 6 );
      60          18 :     OUString *pNames = aNames.getArray();
      61         126 :     for( sal_Int32 i = 0; *ppPropName;  ++i, ++ppPropName )
      62             :     {
      63         108 :         pNames[i] = OUString::createFromAscii( *ppPropName );
      64             :     }
      65          18 :     return aNames;
      66             : }
      67             : 
      68             : 
      69             : 
      70             : 
      71         462 : static Sequence< OUString > lcl_GetSymbolPropertyNames()
      72             : {
      73             :     static const char * aPropNames[] =
      74             :     {
      75             :         "Char",
      76             :         "Set",
      77             :         "Predefined",
      78             :         "FontFormatId",
      79             :         0
      80             :     };
      81             : 
      82         462 :     const char** ppPropName = aPropNames;
      83             : 
      84         462 :     Sequence< OUString > aNames( 4 );
      85         462 :     OUString *pNames = aNames.getArray();
      86        2310 :     for( sal_Int32 i = 0; *ppPropName;  ++i, ++ppPropName )
      87             :     {
      88        1848 :         pNames[i] = OUString::createFromAscii( *ppPropName );
      89             :     }
      90         462 :     return aNames;
      91             : }
      92             : 
      93             : 
      94             : 
      95             : static const char * aMathPropNames[] =
      96             : {
      97             :     "Print/Title",
      98             :     "Print/FormulaText",
      99             :     "Print/Frame",
     100             :     "Print/Size",
     101             :     "Print/ZoomFactor",
     102             :     "LoadSave/IsSaveOnlyUsedSymbols",
     103             :     "Misc/IgnoreSpacesRight",
     104             :     "View/ToolboxVisible",
     105             :     "View/AutoRedraw",
     106             :     "View/FormulaCursor"
     107             : };
     108             : 
     109             : 
     110             : //! Beware of order according to *_BEGIN *_END defines in format.hxx !
     111             : //! see respective load/save routines here
     112             : static const char * aFormatPropNames[] =
     113             : {
     114             :     "StandardFormat/Textmode",
     115             :     "StandardFormat/GreekCharStyle",
     116             :     "StandardFormat/ScaleNormalBracket",
     117             :     "StandardFormat/HorizontalAlignment",
     118             :     "StandardFormat/BaseSize",
     119             :     "StandardFormat/TextSize",
     120             :     "StandardFormat/IndexSize",
     121             :     "StandardFormat/FunctionSize",
     122             :     "StandardFormat/OperatorSize",
     123             :     "StandardFormat/LimitsSize",
     124             :     "StandardFormat/Distance/Horizontal",
     125             :     "StandardFormat/Distance/Vertical",
     126             :     "StandardFormat/Distance/Root",
     127             :     "StandardFormat/Distance/SuperScript",
     128             :     "StandardFormat/Distance/SubScript",
     129             :     "StandardFormat/Distance/Numerator",
     130             :     "StandardFormat/Distance/Denominator",
     131             :     "StandardFormat/Distance/Fraction",
     132             :     "StandardFormat/Distance/StrokeWidth",
     133             :     "StandardFormat/Distance/UpperLimit",
     134             :     "StandardFormat/Distance/LowerLimit",
     135             :     "StandardFormat/Distance/BracketSize",
     136             :     "StandardFormat/Distance/BracketSpace",
     137             :     "StandardFormat/Distance/MatrixRow",
     138             :     "StandardFormat/Distance/MatrixColumn",
     139             :     "StandardFormat/Distance/OrnamentSize",
     140             :     "StandardFormat/Distance/OrnamentSpace",
     141             :     "StandardFormat/Distance/OperatorSize",
     142             :     "StandardFormat/Distance/OperatorSpace",
     143             :     "StandardFormat/Distance/LeftSpace",
     144             :     "StandardFormat/Distance/RightSpace",
     145             :     "StandardFormat/Distance/TopSpace",
     146             :     "StandardFormat/Distance/BottomSpace",
     147             :     "StandardFormat/Distance/NormalBracketSize",
     148             :     "StandardFormat/VariableFont",
     149             :     "StandardFormat/FunctionFont",
     150             :     "StandardFormat/NumberFont",
     151             :     "StandardFormat/TextFont",
     152             :     "StandardFormat/SerifFont",
     153             :     "StandardFormat/SansFont",
     154             :     "StandardFormat/FixedFont"
     155             : };
     156             : 
     157             : 
     158          18 : static Sequence< OUString > lcl_GetPropertyNames(
     159             :         const char * aPropNames[], sal_uInt16 nCount )
     160             : {
     161             : 
     162          18 :     const char** ppPropName = aPropNames;
     163             : 
     164          18 :     Sequence< OUString > aNames( nCount );
     165          18 :     OUString *pNames = aNames.getArray();
     166         477 :     for (sal_Int32 i = 0;  i < nCount;  ++i, ++ppPropName)
     167             :     {
     168         459 :         pNames[i] = OUString::createFromAscii( *ppPropName );
     169             :     }
     170          18 :     return aNames;
     171             : }
     172             : 
     173           9 : static Sequence< OUString > GetFormatPropertyNames()
     174             : {
     175           9 :     return lcl_GetPropertyNames( aFormatPropNames, SAL_N_ELEMENTS( aFormatPropNames ) );
     176             : }
     177             : 
     178           9 : static Sequence< OUString > GetOtherPropertyNames()
     179             : {
     180           9 :     return lcl_GetPropertyNames( aMathPropNames, SAL_N_ELEMENTS( aMathPropNames ) );
     181             : }
     182             : 
     183             : 
     184             : 
     185             : struct SmCfgOther
     186             : {
     187             :     SmPrintSize     ePrintSize;
     188             :     sal_uInt16      nPrintZoomFactor;
     189             :     bool            bPrintTitle;
     190             :     bool            bPrintFormulaText;
     191             :     bool            bPrintFrame;
     192             :     bool            bIsSaveOnlyUsedSymbols;
     193             :     bool            bIgnoreSpacesRight;
     194             :     bool            bToolboxVisible;
     195             :     bool            bAutoRedraw;
     196             :     bool            bFormulaCursor;
     197             : 
     198             :     SmCfgOther();
     199             : };
     200             : 
     201             : 
     202           9 : SmCfgOther::SmCfgOther()
     203             : {
     204           9 :     ePrintSize          = PRINT_SIZE_NORMAL;
     205           9 :     nPrintZoomFactor    = 100;
     206             :     bPrintTitle         = bPrintFormulaText   =
     207             :     bPrintFrame         = bIgnoreSpacesRight  =
     208             :     bToolboxVisible     = bAutoRedraw         =
     209           9 :     bFormulaCursor      = bIsSaveOnlyUsedSymbols = true;
     210           9 : }
     211             : 
     212             : 
     213             : 
     214             : 
     215          18 : SmFontFormat::SmFontFormat()
     216             : {
     217          18 :     aName       = OUString( FONTNAME_MATH );
     218          18 :     nCharSet    = RTL_TEXTENCODING_UNICODE;
     219          18 :     nFamily     = FAMILY_DONTKNOW;
     220          18 :     nPitch      = PITCH_DONTKNOW;
     221          18 :     nWeight     = WEIGHT_DONTKNOW;
     222          18 :     nItalic     = ITALIC_NONE;
     223          18 : }
     224             : 
     225             : 
     226           0 : SmFontFormat::SmFontFormat( const Font &rFont )
     227             : {
     228           0 :     aName       = rFont.GetName();
     229           0 :     nCharSet    = (sal_Int16) rFont.GetCharSet();
     230           0 :     nFamily     = (sal_Int16) rFont.GetFamily();
     231           0 :     nPitch      = (sal_Int16) rFont.GetPitch();
     232           0 :     nWeight     = (sal_Int16) rFont.GetWeight();
     233           0 :     nItalic     = (sal_Int16) rFont.GetItalic();
     234           0 : }
     235             : 
     236             : 
     237         462 : const Font SmFontFormat::GetFont() const
     238             : {
     239         462 :     Font aRes;
     240         462 :     aRes.SetName( aName );
     241         462 :     aRes.SetCharSet( (rtl_TextEncoding) nCharSet );
     242         462 :     aRes.SetFamily( (FontFamily) nFamily );
     243         462 :     aRes.SetPitch( (FontPitch) nPitch );
     244         462 :     aRes.SetWeight( (FontWeight) nWeight );
     245         462 :     aRes.SetItalic( (FontItalic) nItalic );
     246         462 :     return aRes;
     247             : }
     248             : 
     249             : 
     250           0 : bool SmFontFormat::operator == ( const SmFontFormat &rFntFmt ) const
     251             : {
     252           0 :     return  aName    == rFntFmt.aName       &&
     253           0 :             nCharSet == rFntFmt.nCharSet    &&
     254           0 :             nFamily  == rFntFmt.nFamily     &&
     255           0 :             nPitch   == rFntFmt.nPitch      &&
     256           0 :             nWeight  == rFntFmt.nWeight     &&
     257           0 :             nItalic  == rFntFmt.nItalic;
     258             : }
     259             : 
     260             : 
     261             : 
     262             : 
     263          18 : SmFntFmtListEntry::SmFntFmtListEntry( const OUString &rId, const SmFontFormat &rFntFmt ) :
     264             :     aId     (rId),
     265          18 :     aFntFmt (rFntFmt)
     266             : {
     267          18 : }
     268             : 
     269             : 
     270           9 : SmFontFormatList::SmFontFormatList()
     271             : {
     272           9 :     bModified = false;
     273           9 : }
     274             : 
     275             : 
     276           0 : void SmFontFormatList::Clear()
     277             : {
     278           0 :     if (!aEntries.empty())
     279             :     {
     280           0 :         aEntries.clear();
     281           0 :         SetModified( true );
     282             :     }
     283           0 : }
     284             : 
     285             : 
     286          18 : void SmFontFormatList::AddFontFormat( const OUString &rFntFmtId,
     287             :         const SmFontFormat &rFntFmt )
     288             : {
     289          18 :     const SmFontFormat *pFntFmt = GetFontFormat( rFntFmtId );
     290             :     OSL_ENSURE( !pFntFmt, "FontFormatId already exists" );
     291          18 :     if (!pFntFmt)
     292             :     {
     293          18 :         SmFntFmtListEntry aEntry( rFntFmtId, rFntFmt );
     294          18 :         aEntries.push_back( aEntry );
     295          18 :         SetModified( true );
     296             :     }
     297          18 : }
     298             : 
     299             : 
     300           0 : void SmFontFormatList::RemoveFontFormat( const OUString &rFntFmtId )
     301             : {
     302             : 
     303             :     // search for entry
     304           0 :     for (size_t i = 0;  i < aEntries.size();  ++i)
     305             :     {
     306           0 :         if (aEntries[i].aId == rFntFmtId)
     307             :         {
     308             :             // remove entry if found
     309           0 :             aEntries.erase( aEntries.begin() + i );
     310           0 :             SetModified( true );
     311           0 :             break;
     312             :         }
     313             :     }
     314           0 : }
     315             : 
     316             : 
     317         498 : const SmFontFormat * SmFontFormatList::GetFontFormat( const OUString &rFntFmtId ) const
     318             : {
     319         498 :     const SmFontFormat *pRes = 0;
     320             : 
     321         894 :     for (size_t i = 0;  i < aEntries.size();  ++i)
     322             :     {
     323         858 :         if (aEntries[i].aId == rFntFmtId)
     324             :         {
     325         462 :             pRes = &aEntries[i].aFntFmt;
     326         462 :             break;
     327             :         }
     328             :     }
     329             : 
     330         498 :     return pRes;
     331             : }
     332             : 
     333             : 
     334             : 
     335           0 : const SmFontFormat * SmFontFormatList::GetFontFormat( size_t nPos ) const
     336             : {
     337           0 :     const SmFontFormat *pRes = 0;
     338           0 :     if (nPos < aEntries.size())
     339           0 :         pRes = &aEntries[nPos].aFntFmt;
     340           0 :     return pRes;
     341             : }
     342             : 
     343             : 
     344           0 : const OUString SmFontFormatList::GetFontFormatId( const SmFontFormat &rFntFmt ) const
     345             : {
     346           0 :     OUString aRes;
     347             : 
     348           0 :     for (size_t i = 0;  i < aEntries.size();  ++i)
     349             :     {
     350           0 :         if (aEntries[i].aFntFmt == rFntFmt)
     351             :         {
     352           0 :             aRes = aEntries[i].aId;
     353           0 :             break;
     354             :         }
     355             :     }
     356             : 
     357           0 :     return aRes;
     358             : }
     359             : 
     360             : 
     361           0 : const OUString SmFontFormatList::GetFontFormatId( const SmFontFormat &rFntFmt, bool bAdd )
     362             : {
     363           0 :     OUString aRes( GetFontFormatId( rFntFmt) );
     364           0 :     if (aRes.isEmpty()  &&  bAdd)
     365             :     {
     366           0 :         aRes = GetNewFontFormatId();
     367           0 :         AddFontFormat( aRes, rFntFmt );
     368             :     }
     369           0 :     return aRes;
     370             : }
     371             : 
     372             : 
     373           0 : const OUString SmFontFormatList::GetFontFormatId( size_t nPos ) const
     374             : {
     375           0 :     OUString aRes;
     376           0 :     if (nPos < aEntries.size())
     377           0 :         aRes = aEntries[nPos].aId;
     378           0 :     return aRes;
     379             : }
     380             : 
     381             : 
     382           0 : const OUString SmFontFormatList::GetNewFontFormatId() const
     383             : {
     384             :     // returns first unused FormatId
     385             : 
     386           0 :     OUString aPrefix("Id");
     387           0 :     sal_Int32 nCnt = GetCount();
     388           0 :     for (sal_Int32 i = 1;  i <= nCnt + 1;  ++i)
     389             :     {
     390           0 :         OUString aTmpId =  aPrefix + OUString::number(i);
     391           0 :         if (!GetFontFormat(aTmpId))
     392           0 :             return aTmpId;
     393           0 :     }
     394             :     OSL_ENSURE( !this, "failed to create new FontFormatId" );
     395             : 
     396           0 :     return OUString();
     397             : }
     398             : 
     399             : 
     400             : 
     401           9 : SmMathConfig::SmMathConfig() :
     402           9 :     ConfigItem(OUString(aRootName))
     403             : {
     404           9 :     pFormat         = 0;
     405           9 :     pOther          = 0;
     406           9 :     pFontFormatList = 0;
     407           9 :     pSymbolMgr      = 0;
     408             : 
     409           9 :     bIsOtherModified = bIsFormatModified = false;
     410           9 : }
     411             : 
     412             : 
     413           4 : SmMathConfig::~SmMathConfig()
     414             : {
     415           2 :     Save();
     416           2 :     delete pFormat;
     417           2 :     delete pOther;
     418           2 :     delete pFontFormatList;
     419           2 :     delete pSymbolMgr;
     420           2 : }
     421             : 
     422             : 
     423           9 : void SmMathConfig::SetOtherModified( bool bVal )
     424             : {
     425           9 :     bIsOtherModified = bVal;
     426           9 : }
     427             : 
     428             : 
     429           9 : void SmMathConfig::SetFormatModified( bool bVal )
     430             : {
     431           9 :     bIsFormatModified = bVal;
     432           9 : }
     433             : 
     434             : 
     435           0 : void SmMathConfig::SetFontFormatListModified( bool bVal )
     436             : {
     437           0 :     if (pFontFormatList)
     438           0 :         pFontFormatList->SetModified( bVal );
     439           0 : }
     440             : 
     441             : 
     442         462 : void SmMathConfig::ReadSymbol( SmSym &rSymbol,
     443             :                         const OUString &rSymbolName,
     444             :                         const OUString &rBaseNode ) const
     445             : {
     446         462 :     Sequence< OUString > aNames = lcl_GetSymbolPropertyNames();
     447         462 :     sal_Int32 nProps = aNames.getLength();
     448             : 
     449         924 :     OUString aDelim( "/" );
     450         462 :     OUString *pName = aNames.getArray();
     451        2310 :     for (sal_Int32 i = 0;  i < nProps;  ++i)
     452             :     {
     453        1848 :         OUString &rName = pName[i];
     454        1848 :         OUString aTmp( rName );
     455        1848 :         rName = rBaseNode;
     456        1848 :         rName += aDelim;
     457        1848 :         rName += rSymbolName;
     458        1848 :         rName += aDelim;
     459        1848 :         rName += aTmp;
     460        1848 :     }
     461             : 
     462         924 :     const Sequence< Any > aValues = ((SmMathConfig*) this)->GetProperties( aNames );
     463             : 
     464         462 :     if (nProps  &&  aValues.getLength() == nProps)
     465             :     {
     466         462 :         const Any * pValue = aValues.getConstArray();
     467         462 :         Font        aFont;
     468         462 :         sal_UCS4    cChar = '\0';
     469         924 :         OUString    aSet;
     470         462 :         bool        bPredefined = false;
     471             : 
     472         924 :         OUString    aTmpStr;
     473         462 :         sal_Int32       nTmp32 = 0;
     474         462 :         bool        bTmp = false;
     475             : 
     476         462 :         bool bOK = true;
     477         462 :         if (pValue->hasValue()  &&  (*pValue >>= nTmp32))
     478         462 :             cChar = static_cast< sal_UCS4 >( nTmp32 );
     479             :         else
     480           0 :             bOK = false;
     481         462 :         ++pValue;
     482         462 :         if (pValue->hasValue()  &&  (*pValue >>= aTmpStr))
     483         462 :             aSet = aTmpStr;
     484             :         else
     485           0 :             bOK = false;
     486         462 :         ++pValue;
     487         462 :         if (pValue->hasValue()  &&  (*pValue >>= bTmp))
     488         462 :             bPredefined = bTmp;
     489             :         else
     490           0 :             bOK = false;
     491         462 :         ++pValue;
     492         462 :         if (pValue->hasValue()  &&  (*pValue >>= aTmpStr))
     493             :         {
     494         462 :             const SmFontFormat *pFntFmt = GetFontFormatList().GetFontFormat( aTmpStr );
     495             :             OSL_ENSURE( pFntFmt, "unknown FontFormat" );
     496         462 :             if (pFntFmt)
     497         462 :                 aFont = pFntFmt->GetFont();
     498             :         }
     499             :         else
     500           0 :             bOK = false;
     501         462 :         ++pValue;
     502             : 
     503         462 :         if (bOK)
     504             :         {
     505         462 :             OUString aUiName( rSymbolName );
     506         924 :             OUString aUiSetName( aSet );
     507         462 :             if (bPredefined)
     508             :             {
     509         462 :                 OUString aTmp;
     510         462 :                 aTmp = GetUiSymbolName( rSymbolName );
     511             :                 OSL_ENSURE( !aTmp.isEmpty(), "localized symbol-name not found" );
     512         462 :                 if (!aTmp.isEmpty())
     513         462 :                     aUiName = aTmp;
     514         462 :                 aTmp = GetUiSymbolSetName( aSet );
     515             :                 OSL_ENSURE( !aTmp.isEmpty(), "localized symbolset-name not found" );
     516         462 :                 if (!aTmp.isEmpty())
     517         462 :                     aUiSetName = aTmp;
     518             :             }
     519             : 
     520         462 :             rSymbol = SmSym( aUiName, aFont, cChar, aUiSetName, bPredefined );
     521         462 :             if (aUiName != rSymbolName)
     522         462 :                 rSymbol.SetExportName( rSymbolName );
     523             :         }
     524             :         else
     525             :         {
     526             :             SAL_WARN("starmath", "symbol read error");
     527         462 :         }
     528         462 :     }
     529         462 : }
     530             : 
     531             : 
     532        2676 : SmSymbolManager & SmMathConfig::GetSymbolManager()
     533             : {
     534        2676 :     if (!pSymbolMgr)
     535             :     {
     536           7 :         pSymbolMgr = new SmSymbolManager;
     537           7 :         pSymbolMgr->Load();
     538             :     }
     539        2676 :     return *pSymbolMgr;
     540             : }
     541             : 
     542             : 
     543           0 : void SmMathConfig::Commit()
     544             : {
     545           0 :     Save();
     546           0 : }
     547             : 
     548             : 
     549           2 : void SmMathConfig::Save()
     550             : {
     551           2 :     SaveOther();
     552           2 :     SaveFormat();
     553           2 :     SaveFontFormatList();
     554           2 : }
     555             : 
     556             : 
     557           7 : void SmMathConfig::GetSymbols( std::vector< SmSym > &rSymbols ) const
     558             : {
     559           7 :     Sequence< OUString > aNodes( ((SmMathConfig*) this)->GetNodeNames( SYMBOL_LIST ) );
     560           7 :     const OUString *pNode = aNodes.getConstArray();
     561           7 :     sal_Int32 nNodes = aNodes.getLength();
     562             : 
     563           7 :     rSymbols.resize( nNodes );
     564           7 :     std::vector< SmSym >::iterator aIt( rSymbols.begin() );
     565           7 :     std::vector< SmSym >::iterator aEnd( rSymbols.end() );
     566         476 :     while (aIt != aEnd)
     567             :     {
     568         462 :         ReadSymbol( *aIt++, *pNode++, SYMBOL_LIST );
     569           7 :     }
     570           7 : }
     571             : 
     572             : 
     573           0 : void SmMathConfig::SetSymbols( const std::vector< SmSym > &rNewSymbols )
     574             : {
     575           0 :     sal_uIntPtr nCount = rNewSymbols.size();
     576             : 
     577           0 :     Sequence< OUString > aNames = lcl_GetSymbolPropertyNames();
     578           0 :     const OUString *pNames = aNames.getConstArray();
     579           0 :     sal_uIntPtr nSymbolProps = sal::static_int_cast< sal_uInt32 >(aNames.getLength());
     580             : 
     581           0 :     Sequence< PropertyValue > aValues( nCount * nSymbolProps );
     582           0 :     PropertyValue *pValues = aValues.getArray();
     583             : 
     584           0 :     PropertyValue *pVal = pValues;
     585           0 :     OUString aDelim( "/" );
     586           0 :     std::vector< SmSym >::const_iterator aIt( rNewSymbols.begin() );
     587           0 :     std::vector< SmSym >::const_iterator aEnd( rNewSymbols.end() );
     588           0 :     while (aIt != aEnd)
     589             :     {
     590           0 :         const SmSym &rSymbol = *aIt++;
     591           0 :         OUString  aNodeNameDelim( SYMBOL_LIST );
     592           0 :         aNodeNameDelim += aDelim;
     593           0 :         aNodeNameDelim += rSymbol.GetExportName();
     594           0 :         aNodeNameDelim += aDelim;
     595             : 
     596           0 :         const OUString *pName = pNames;
     597             : 
     598             :         // Char
     599           0 :         pVal->Name  = aNodeNameDelim;
     600           0 :         pVal->Name += *pName++;
     601           0 :         pVal->Value <<= static_cast< sal_UCS4 >( rSymbol.GetCharacter() );
     602           0 :         pVal++;
     603             :         // Set
     604           0 :         pVal->Name  = aNodeNameDelim;
     605           0 :         pVal->Name += *pName++;
     606           0 :         OUString aTmp( rSymbol.GetSymbolSetName() );
     607           0 :         if (rSymbol.IsPredefined())
     608           0 :             aTmp = GetExportSymbolSetName( aTmp );
     609           0 :         pVal->Value <<= aTmp;
     610           0 :         pVal++;
     611             :         // Predefined
     612           0 :         pVal->Name  = aNodeNameDelim;
     613           0 :         pVal->Name += *pName++;
     614           0 :         pVal->Value <<= (sal_Bool) rSymbol.IsPredefined();
     615           0 :         pVal++;
     616             :         // FontFormatId
     617           0 :         SmFontFormat aFntFmt( rSymbol.GetFace() );
     618           0 :         OUString aFntFmtId( GetFontFormatList().GetFontFormatId( aFntFmt, true ) );
     619             :         OSL_ENSURE( !aFntFmtId.isEmpty(), "FontFormatId not found" );
     620           0 :         pVal->Name  = aNodeNameDelim;
     621           0 :         pVal->Name += *pName++;
     622           0 :         pVal->Value <<= aFntFmtId;
     623           0 :         pVal++;
     624           0 :     }
     625             :     OSL_ENSURE( pVal - pValues == sal::static_int_cast< ptrdiff_t >(nCount * nSymbolProps), "properties missing" );
     626           0 :     ReplaceSetProperties( SYMBOL_LIST, aValues );
     627             : 
     628           0 :     StripFontFormatList( rNewSymbols );
     629           0 :     SaveFontFormatList();
     630           0 : }
     631             : 
     632             : 
     633         464 : SmFontFormatList & SmMathConfig::GetFontFormatList()
     634             : {
     635         464 :     if (!pFontFormatList)
     636             :     {
     637           9 :         LoadFontFormatList();
     638             :     }
     639         464 :     return *pFontFormatList;
     640             : }
     641             : 
     642             : 
     643           9 : void SmMathConfig::LoadFontFormatList()
     644             : {
     645           9 :     if (!pFontFormatList)
     646           9 :         pFontFormatList = new SmFontFormatList;
     647             :     else
     648           0 :         pFontFormatList->Clear();
     649             : 
     650           9 :     Sequence< OUString > aNodes( GetNodeNames( FONT_FORMAT_LIST ) );
     651           9 :     const OUString *pNode = aNodes.getConstArray();
     652           9 :     sal_Int32 nNodes = aNodes.getLength();
     653             : 
     654          27 :     for (sal_Int32 i = 0;  i < nNodes;  ++i)
     655             :     {
     656          18 :         SmFontFormat aFntFmt;
     657          18 :         ReadFontFormat( aFntFmt, pNode[i], FONT_FORMAT_LIST );
     658          18 :         if (!pFontFormatList->GetFontFormat( pNode[i] ))
     659             :         {
     660             :             OSL_ENSURE( 0 == pFontFormatList->GetFontFormat( pNode[i] ),
     661             :                     "FontFormat ID already exists" );
     662          18 :             pFontFormatList->AddFontFormat( pNode[i], aFntFmt );
     663             :         }
     664          18 :     }
     665           9 :     pFontFormatList->SetModified( false );
     666           9 : }
     667             : 
     668             : 
     669          18 : void SmMathConfig::ReadFontFormat( SmFontFormat &rFontFormat,
     670             :         const OUString &rSymbolName, const OUString &rBaseNode ) const
     671             : {
     672          18 :     Sequence< OUString > aNames = lcl_GetFontPropertyNames();
     673          18 :     sal_Int32 nProps = aNames.getLength();
     674             : 
     675          36 :     OUString aDelim( "/" );
     676          18 :     OUString *pName = aNames.getArray();
     677         126 :     for (sal_Int32 i = 0;  i < nProps;  ++i)
     678             :     {
     679         108 :         OUString &rName = pName[i];
     680         108 :         OUString aTmp( rName );
     681         108 :         rName = rBaseNode;
     682         108 :         rName += aDelim;
     683         108 :         rName += rSymbolName;
     684         108 :         rName += aDelim;
     685         108 :         rName += aTmp;
     686         108 :     }
     687             : 
     688          36 :     const Sequence< Any > aValues = ((SmMathConfig*) this)->GetProperties( aNames );
     689             : 
     690          18 :     if (nProps  &&  aValues.getLength() == nProps)
     691             :     {
     692          18 :         const Any * pValue = aValues.getConstArray();
     693             : 
     694          18 :         OUString    aTmpStr;
     695          18 :         sal_Int16       nTmp16 = 0;
     696             : 
     697          18 :         bool bOK = true;
     698          18 :         if (pValue->hasValue()  &&  (*pValue >>= aTmpStr))
     699          18 :             rFontFormat.aName = aTmpStr;
     700             :         else
     701           0 :             bOK = false;
     702          18 :         ++pValue;
     703          18 :         if (pValue->hasValue()  &&  (*pValue >>= nTmp16))
     704          18 :             rFontFormat.nCharSet = nTmp16; // 6.0 file-format GetSOLoadTextEncoding not needed
     705             :         else
     706           0 :             bOK = false;
     707          18 :         ++pValue;
     708          18 :         if (pValue->hasValue()  &&  (*pValue >>= nTmp16))
     709          18 :             rFontFormat.nFamily = nTmp16;
     710             :         else
     711           0 :             bOK = false;
     712          18 :         ++pValue;
     713          18 :         if (pValue->hasValue()  &&  (*pValue >>= nTmp16))
     714          18 :             rFontFormat.nPitch = nTmp16;
     715             :         else
     716           0 :             bOK = false;
     717          18 :         ++pValue;
     718          18 :         if (pValue->hasValue()  &&  (*pValue >>= nTmp16))
     719          18 :             rFontFormat.nWeight = nTmp16;
     720             :         else
     721           0 :             bOK = false;
     722          18 :         ++pValue;
     723          18 :         if (pValue->hasValue()  &&  (*pValue >>= nTmp16))
     724          18 :             rFontFormat.nItalic = nTmp16;
     725             :         else
     726           0 :             bOK = false;
     727          18 :         ++pValue;
     728             : 
     729             :         OSL_ENSURE( bOK, "read FontFormat failed" );
     730          18 :         (void)bOK;
     731          18 :     }
     732          18 : }
     733             : 
     734             : 
     735           2 : void SmMathConfig::SaveFontFormatList()
     736             : {
     737           2 :     SmFontFormatList &rFntFmtList = GetFontFormatList();
     738             : 
     739           2 :     if (!rFntFmtList.IsModified())
     740           4 :         return;
     741             : 
     742           0 :     Sequence< OUString > aNames = lcl_GetFontPropertyNames();
     743           0 :     sal_Int32 nSymbolProps = aNames.getLength();
     744             : 
     745           0 :     size_t nCount = rFntFmtList.GetCount();
     746             : 
     747           0 :     Sequence< PropertyValue > aValues( nCount * nSymbolProps );
     748           0 :     PropertyValue *pValues = aValues.getArray();
     749             : 
     750           0 :     PropertyValue *pVal = pValues;
     751           0 :     OUString aDelim( "/" );
     752           0 :     for (size_t i = 0;  i < nCount;  ++i)
     753             :     {
     754           0 :         OUString aFntFmtId( rFntFmtList.GetFontFormatId( i ) );
     755           0 :         const SmFontFormat aFntFmt( *rFntFmtList.GetFontFormat( aFntFmtId ) );
     756             : 
     757           0 :         OUString  aNodeNameDelim( FONT_FORMAT_LIST );
     758           0 :         aNodeNameDelim += aDelim;
     759           0 :         aNodeNameDelim += aFntFmtId;
     760           0 :         aNodeNameDelim += aDelim;
     761             : 
     762           0 :         const OUString *pName = aNames.getConstArray();
     763             : 
     764             :         // Name
     765           0 :         pVal->Name  = aNodeNameDelim;
     766           0 :         pVal->Name += *pName++;
     767           0 :         pVal->Value <<= OUString( aFntFmt.aName );
     768           0 :         pVal++;
     769             :         // CharSet
     770           0 :         pVal->Name  = aNodeNameDelim;
     771           0 :         pVal->Name += *pName++;
     772           0 :         pVal->Value <<= (sal_Int16) aFntFmt.nCharSet; // 6.0 file-format GetSOStoreTextEncoding not needed
     773           0 :         pVal++;
     774             :         // Family
     775           0 :         pVal->Name  = aNodeNameDelim;
     776           0 :         pVal->Name += *pName++;
     777           0 :         pVal->Value <<= (sal_Int16) aFntFmt.nFamily;
     778           0 :         pVal++;
     779             :         // Pitch
     780           0 :         pVal->Name  = aNodeNameDelim;
     781           0 :         pVal->Name += *pName++;
     782           0 :         pVal->Value <<= (sal_Int16) aFntFmt.nPitch;
     783           0 :         pVal++;
     784             :         // Weight
     785           0 :         pVal->Name  = aNodeNameDelim;
     786           0 :         pVal->Name += *pName++;
     787           0 :         pVal->Value <<= (sal_Int16) aFntFmt.nWeight;
     788           0 :         pVal++;
     789             :         // Italic
     790           0 :         pVal->Name  = aNodeNameDelim;
     791           0 :         pVal->Name += *pName++;
     792           0 :         pVal->Value <<= (sal_Int16) aFntFmt.nItalic;
     793           0 :         pVal++;
     794           0 :     }
     795             :     OSL_ENSURE( sal::static_int_cast<size_t>(pVal - pValues) == nCount * nSymbolProps, "properties missing" );
     796           0 :     ReplaceSetProperties( FONT_FORMAT_LIST, aValues );
     797             : 
     798           0 :     rFntFmtList.SetModified( false );
     799             : }
     800             : 
     801             : 
     802           0 : void SmMathConfig::StripFontFormatList( const std::vector< SmSym > &rSymbols )
     803             : {
     804             :     size_t i;
     805             : 
     806             :     // build list of used font-formats only
     807             :     //!! font-format IDs may be different !!
     808           0 :     SmFontFormatList aUsedList;
     809           0 :     for (i = 0;  i < rSymbols.size();  ++i)
     810             :     {
     811             :         OSL_ENSURE( rSymbols[i].GetName().getLength() > 0, "non named symbol" );
     812           0 :         aUsedList.GetFontFormatId( SmFontFormat( rSymbols[i].GetFace() ) , true );
     813             :     }
     814           0 :     const SmFormat & rStdFmt = GetStandardFormat();
     815           0 :     for (i = FNT_BEGIN;  i <= FNT_END;  ++i)
     816             :     {
     817           0 :         aUsedList.GetFontFormatId( SmFontFormat( rStdFmt.GetFont( i ) ) , true );
     818             :     }
     819             : 
     820             :     // remove unused font-formats from list
     821           0 :     SmFontFormatList &rFntFmtList = GetFontFormatList();
     822           0 :     size_t nCnt = rFntFmtList.GetCount();
     823           0 :     SmFontFormat *pTmpFormat = new SmFontFormat[ nCnt ];
     824           0 :     OUString     *pId        = new OUString    [ nCnt ];
     825             :     size_t k;
     826           0 :     for (k = 0;  k < nCnt;  ++k)
     827             :     {
     828           0 :         pTmpFormat[k] = *rFntFmtList.GetFontFormat( k );
     829           0 :         pId[k]     = rFntFmtList.GetFontFormatId( k );
     830             :     }
     831           0 :     for (k = 0;  k < nCnt;  ++k)
     832             :     {
     833           0 :         if (aUsedList.GetFontFormatId( pTmpFormat[k] ).isEmpty())
     834             :         {
     835           0 :             rFntFmtList.RemoveFontFormat( pId[k] );
     836             :         }
     837             :     }
     838           0 :     delete [] pId;
     839           0 :     delete [] pTmpFormat;
     840           0 : }
     841             : 
     842             : 
     843           9 : void SmMathConfig::LoadOther()
     844             : {
     845           9 :     if (!pOther)
     846           9 :         pOther = new SmCfgOther;
     847             : 
     848           9 :     Sequence< OUString > aNames( GetOtherPropertyNames() );
     849           9 :     sal_Int32 nProps = aNames.getLength();
     850             : 
     851          18 :     Sequence< Any > aValues( GetProperties( aNames ) );
     852           9 :     if (nProps  &&  aValues.getLength() == nProps)
     853             :     {
     854           9 :         const Any *pValues = aValues.getConstArray();
     855           9 :         const Any *pVal = pValues;
     856             : 
     857           9 :         sal_Int16   nTmp16 = 0;
     858           9 :         bool    bTmp = false;
     859             : 
     860             :         // Print/Title
     861           9 :         if (pVal->hasValue()  &&  (*pVal >>= bTmp))
     862           9 :             pOther->bPrintTitle = bTmp;
     863           9 :         ++pVal;
     864             :         // Print/FormulaText
     865           9 :         if (pVal->hasValue()  &&  (*pVal >>= bTmp))
     866           9 :             pOther->bPrintFormulaText = bTmp;
     867           9 :         ++pVal;
     868             :         // Print/Frame
     869           9 :         if (pVal->hasValue()  &&  (*pVal >>= bTmp))
     870           9 :             pOther->bPrintFrame = bTmp;
     871           9 :         ++pVal;
     872             :         // Print/Size
     873           9 :         if (pVal->hasValue()  &&  (*pVal >>= nTmp16))
     874           9 :             pOther->ePrintSize = (SmPrintSize) nTmp16;
     875           9 :         ++pVal;
     876             :         // Print/ZoomFactor
     877           9 :         if (pVal->hasValue()  &&  (*pVal >>= nTmp16))
     878           9 :             pOther->nPrintZoomFactor = nTmp16;
     879           9 :         ++pVal;
     880             :         // LoadSave/IsSaveOnlyUsedSymbols
     881           9 :         if (pVal->hasValue()  &&  (*pVal >>= bTmp))
     882           9 :             pOther->bIsSaveOnlyUsedSymbols = bTmp;
     883           9 :         ++pVal;
     884             :         // Misc/IgnoreSpacesRight
     885           9 :         if (pVal->hasValue()  &&  (*pVal >>= bTmp))
     886           9 :             pOther->bIgnoreSpacesRight = bTmp;
     887           9 :         ++pVal;
     888             :         // View/ToolboxVisible
     889           9 :         if (pVal->hasValue()  &&  (*pVal >>= bTmp))
     890           9 :             pOther->bToolboxVisible = bTmp;
     891           9 :         ++pVal;
     892             :         // View/AutoRedraw
     893           9 :         if (pVal->hasValue()  &&  (*pVal >>= bTmp))
     894           9 :             pOther->bAutoRedraw = bTmp;
     895           9 :         ++pVal;
     896             :         // View/FormulaCursor
     897           9 :         if (pVal->hasValue()  &&  (*pVal >>= bTmp))
     898           9 :             pOther->bFormulaCursor = bTmp;
     899           9 :         ++pVal;
     900             : 
     901             :         OSL_ENSURE( pVal - pValues == nProps, "property mismatch" );
     902           9 :         SetOtherModified( false );
     903           9 :     }
     904           9 : }
     905             : 
     906             : 
     907           2 : void SmMathConfig::SaveOther()
     908             : {
     909           2 :     if (!pOther || !IsOtherModified())
     910           4 :         return;
     911             : 
     912           0 :     const Sequence< OUString > aNames( GetOtherPropertyNames() );
     913           0 :     sal_Int32 nProps = aNames.getLength();
     914             : 
     915           0 :     Sequence< Any > aValues( nProps );
     916           0 :     Any *pValues = aValues.getArray();
     917           0 :     Any *pValue  = pValues;
     918             : 
     919             :     // Print/Title
     920           0 :     *pValue++ <<= (sal_Bool) pOther->bPrintTitle;
     921             :     // Print/FormulaText
     922           0 :     *pValue++ <<= (sal_Bool) pOther->bPrintFormulaText;
     923             :     // Print/Frame
     924           0 :     *pValue++ <<= (sal_Bool) pOther->bPrintFrame;
     925             :     // Print/Size
     926           0 :     *pValue++ <<= (sal_Int16) pOther->ePrintSize;
     927             :     // Print/ZoomFactor
     928           0 :     *pValue++ <<= (sal_Int16) pOther->nPrintZoomFactor;
     929             :     // LoadSave/IsSaveOnlyUsedSymbols
     930           0 :     *pValue++ <<= (sal_Bool) pOther->bIsSaveOnlyUsedSymbols;
     931             :     // Misc/IgnoreSpacesRight
     932           0 :     *pValue++ <<= (sal_Bool) pOther->bIgnoreSpacesRight;
     933             :     // View/ToolboxVisible
     934           0 :     *pValue++ <<= (sal_Bool) pOther->bToolboxVisible;
     935             :     // View/AutoRedraw
     936           0 :     *pValue++ <<= (sal_Bool) pOther->bAutoRedraw;
     937             :     // View/FormulaCursor
     938           0 :     *pValue++ <<= (sal_Bool) pOther->bFormulaCursor;
     939             : 
     940             :     OSL_ENSURE( pValue - pValues == nProps, "property mismatch" );
     941           0 :     PutProperties( aNames , aValues );
     942             : 
     943           0 :     SetOtherModified( false );
     944             : }
     945             : 
     946           9 : void SmMathConfig::LoadFormat()
     947             : {
     948           9 :     if (!pFormat)
     949           9 :         pFormat = new SmFormat;
     950             : 
     951             : 
     952           9 :     Sequence< OUString > aNames( GetFormatPropertyNames() );
     953           9 :     sal_Int32 nProps = aNames.getLength();
     954             : 
     955          18 :     Sequence< Any > aValues( GetProperties( aNames ) );
     956           9 :     if (nProps  &&  aValues.getLength() == nProps)
     957             :     {
     958           9 :         const Any *pValues = aValues.getConstArray();
     959           9 :         const Any *pVal = pValues;
     960             : 
     961           9 :         OUString    aTmpStr;
     962           9 :         sal_Int16       nTmp16 = 0;
     963           9 :         bool        bTmp = false;
     964             : 
     965             :         // StandardFormat/Textmode
     966           9 :         if (pVal->hasValue()  &&  (*pVal >>= bTmp))
     967           9 :             pFormat->SetTextmode( bTmp );
     968           9 :         ++pVal;
     969             :         // StandardFormat/GreekCharStyle
     970           9 :         if (pVal->hasValue()  &&  (*pVal >>= nTmp16))
     971           9 :             pFormat->SetGreekCharStyle( nTmp16 );
     972           9 :         ++pVal;
     973             :         // StandardFormat/ScaleNormalBracket
     974           9 :         if (pVal->hasValue()  &&  (*pVal >>= bTmp))
     975           9 :             pFormat->SetScaleNormalBrackets( bTmp );
     976           9 :         ++pVal;
     977             :         // StandardFormat/HorizontalAlignment
     978           9 :         if (pVal->hasValue()  &&  (*pVal >>= nTmp16))
     979           9 :             pFormat->SetHorAlign( (SmHorAlign) nTmp16 );
     980           9 :         ++pVal;
     981             :         // StandardFormat/BaseSize
     982           9 :         if (pVal->hasValue()  &&  (*pVal >>= nTmp16))
     983           9 :             pFormat->SetBaseSize( Size(0, SmPtsTo100th_mm( nTmp16 )) );
     984           9 :         ++pVal;
     985             : 
     986             :         sal_uInt16 i;
     987          54 :         for (i = SIZ_BEGIN;  i <= SIZ_END;  ++i)
     988             :         {
     989          45 :             if (pVal->hasValue()  &&  (*pVal >>= nTmp16))
     990          45 :                 pFormat->SetRelSize( i, nTmp16 );
     991          45 :             ++pVal;
     992             :         }
     993             : 
     994         225 :         for (i = DIS_BEGIN;  i <= DIS_END;  ++i)
     995             :         {
     996         216 :             if (pVal->hasValue()  &&  (*pVal >>= nTmp16))
     997         216 :                 pFormat->SetDistance( i, nTmp16 );
     998         216 :             ++pVal;
     999             :         }
    1000             : 
    1001           9 :         LanguageType nLang = Application::GetSettings().GetUILanguageTag().getLanguageType();
    1002          72 :         for (i = FNT_BEGIN;  i < FNT_END;  ++i)
    1003             :         {
    1004          63 :             Font aFnt;
    1005          63 :             bool bUseDefaultFont = true;
    1006          63 :             if (pVal->hasValue()  &&  (*pVal >>= aTmpStr))
    1007             :             {
    1008          63 :                 bUseDefaultFont = aTmpStr.isEmpty();
    1009          63 :                 if (bUseDefaultFont)
    1010             :                 {
    1011          63 :                     aFnt = pFormat->GetFont( i );
    1012          63 :                     aFnt.SetName( GetDefaultFontName( nLang, i ) );
    1013             :                 }
    1014             :                 else
    1015             :                 {
    1016           0 :                     const SmFontFormat *pFntFmt = GetFontFormatList().GetFontFormat( aTmpStr );
    1017             :                     OSL_ENSURE( pFntFmt, "unknown FontFormat" );
    1018           0 :                     if (pFntFmt)
    1019           0 :                         aFnt = pFntFmt->GetFont();
    1020             :                 }
    1021             :             }
    1022          63 :             ++pVal;
    1023             : 
    1024          63 :             aFnt.SetSize( pFormat->GetBaseSize() );
    1025          63 :             pFormat->SetFont( i, aFnt, bUseDefaultFont );
    1026          63 :         }
    1027             : 
    1028             :         OSL_ENSURE( pVal - pValues == nProps, "property mismatch" );
    1029           9 :         SetFormatModified( false );
    1030           9 :     }
    1031           9 : }
    1032             : 
    1033             : 
    1034           2 : void SmMathConfig::SaveFormat()
    1035             : {
    1036           2 :     if (!pFormat || !IsFormatModified())
    1037           4 :         return;
    1038             : 
    1039           0 :     const Sequence< OUString > aNames( GetFormatPropertyNames() );
    1040           0 :     sal_Int32 nProps = aNames.getLength();
    1041             : 
    1042           0 :     Sequence< Any > aValues( nProps );
    1043           0 :     Any *pValues = aValues.getArray();
    1044           0 :     Any *pValue  = pValues;
    1045             : 
    1046             :     // StandardFormat/Textmode
    1047           0 :     *pValue++ <<= (sal_Bool) pFormat->IsTextmode();
    1048             :     // StandardFormat/GreekCharStyle
    1049           0 :     *pValue++ <<= (sal_Int16) pFormat->GetGreekCharStyle();
    1050             :     // StandardFormat/ScaleNormalBracket
    1051           0 :     *pValue++ <<= (sal_Bool) pFormat->IsScaleNormalBrackets();
    1052             :     // StandardFormat/HorizontalAlignment
    1053           0 :     *pValue++ <<= (sal_Int16) pFormat->GetHorAlign();
    1054             :     // StandardFormat/BaseSize
    1055           0 :     *pValue++ <<= (sal_Int16) SmRoundFraction( Sm100th_mmToPts(
    1056           0 :                                     pFormat->GetBaseSize().Height() ) );
    1057             : 
    1058             :     sal_uInt16 i;
    1059           0 :     for (i = SIZ_BEGIN;  i <= SIZ_END;  ++i)
    1060           0 :         *pValue++ <<= (sal_Int16) pFormat->GetRelSize( i );
    1061             : 
    1062           0 :     for (i = DIS_BEGIN;  i <= DIS_END;  ++i)
    1063           0 :         *pValue++ <<= (sal_Int16) pFormat->GetDistance( i );
    1064             : 
    1065           0 :     for (i = FNT_BEGIN;  i < FNT_END;  ++i)
    1066             :     {
    1067           0 :         OUString aFntFmtId;
    1068             : 
    1069           0 :         if (!pFormat->IsDefaultFont( i ))
    1070             :         {
    1071           0 :             SmFontFormat aFntFmt( pFormat->GetFont( i ) );
    1072           0 :             aFntFmtId = GetFontFormatList().GetFontFormatId( aFntFmt, true );
    1073           0 :             OSL_ENSURE( !aFntFmtId.isEmpty(), "FontFormatId not found" );
    1074             :         }
    1075             : 
    1076           0 :         *pValue++ <<= aFntFmtId;
    1077           0 :     }
    1078             : 
    1079             :     OSL_ENSURE( pValue - pValues == nProps, "property mismatch" );
    1080           0 :     PutProperties( aNames , aValues );
    1081             : 
    1082           0 :     SetFormatModified( false );
    1083             : }
    1084             : 
    1085             : 
    1086         333 : const SmFormat & SmMathConfig::GetStandardFormat() const
    1087             : {
    1088         333 :     if (!pFormat)
    1089           9 :         ((SmMathConfig *) this)->LoadFormat();
    1090         333 :     return *pFormat;
    1091             : }
    1092             : 
    1093             : 
    1094           0 : void SmMathConfig::SetStandardFormat( const SmFormat &rFormat, bool bSaveFontFormatList )
    1095             : {
    1096           0 :     if (!pFormat)
    1097           0 :         LoadFormat();
    1098           0 :     if (rFormat != *pFormat)
    1099             :     {
    1100           0 :         *pFormat = rFormat;
    1101           0 :         SetFormatModified( true );
    1102           0 :         SaveFormat();
    1103             : 
    1104           0 :         if (bSaveFontFormatList)
    1105             :         {
    1106             :             // needed for SmFontTypeDialog's DefaultButtonClickHdl
    1107           0 :             SetFontFormatListModified( true );
    1108           0 :             SaveFontFormatList();
    1109             :         }
    1110             :     }
    1111           0 : }
    1112             : 
    1113             : 
    1114          21 : SmPrintSize SmMathConfig::GetPrintSize() const
    1115             : {
    1116          21 :     if (!pOther)
    1117           3 :         ((SmMathConfig *) this)->LoadOther();
    1118          21 :     return pOther->ePrintSize;
    1119             : }
    1120             : 
    1121             : 
    1122           0 : void SmMathConfig::SetPrintSize( SmPrintSize eSize )
    1123             : {
    1124           0 :     if (!pOther)
    1125           0 :         LoadOther();
    1126           0 :     if (eSize != pOther->ePrintSize)
    1127             :     {
    1128           0 :         pOther->ePrintSize = eSize;
    1129           0 :         SetOtherModified( true );
    1130             :     }
    1131           0 : }
    1132             : 
    1133             : 
    1134          21 : sal_uInt16 SmMathConfig::GetPrintZoomFactor() const
    1135             : {
    1136          21 :     if (!pOther)
    1137           0 :         ((SmMathConfig *) this)->LoadOther();
    1138          21 :     return pOther->nPrintZoomFactor;
    1139             : }
    1140             : 
    1141             : 
    1142           0 : void SmMathConfig::SetPrintZoomFactor( sal_uInt16 nVal )
    1143             : {
    1144           0 :     if (!pOther)
    1145           0 :         LoadOther();
    1146           0 :     if (nVal != pOther->nPrintZoomFactor)
    1147             :     {
    1148           0 :         pOther->nPrintZoomFactor = nVal;
    1149           0 :         SetOtherModified( true );
    1150             :     }
    1151           0 : }
    1152             : 
    1153             : 
    1154           0 : void SmMathConfig::SetOtherIfNotEqual( bool &rbItem, bool bNewVal )
    1155             : {
    1156           0 :     if (bNewVal != rbItem)
    1157             :     {
    1158           0 :         rbItem = bNewVal;
    1159           0 :         SetOtherModified( true );
    1160             :     }
    1161           0 : }
    1162             : 
    1163             : 
    1164          21 : bool SmMathConfig::IsPrintTitle() const
    1165             : {
    1166          21 :     if (!pOther)
    1167           0 :         ((SmMathConfig *) this)->LoadOther();
    1168          21 :     return pOther->bPrintTitle;
    1169             : }
    1170             : 
    1171             : 
    1172           0 : void SmMathConfig::SetPrintTitle( bool bVal )
    1173             : {
    1174           0 :     if (!pOther)
    1175           0 :         LoadOther();
    1176           0 :     SetOtherIfNotEqual( pOther->bPrintTitle, bVal );
    1177           0 : }
    1178             : 
    1179             : 
    1180          21 : bool SmMathConfig::IsPrintFormulaText() const
    1181             : {
    1182          21 :     if (!pOther)
    1183           0 :         ((SmMathConfig *) this)->LoadOther();
    1184          21 :     return pOther->bPrintFormulaText;
    1185             : }
    1186             : 
    1187             : 
    1188           0 : void SmMathConfig::SetPrintFormulaText( bool bVal )
    1189             : {
    1190           0 :     if (!pOther)
    1191           0 :         LoadOther();
    1192           0 :     SetOtherIfNotEqual( pOther->bPrintFormulaText, bVal );
    1193           0 : }
    1194             : 
    1195         578 : bool SmMathConfig::IsSaveOnlyUsedSymbols() const
    1196             : {
    1197         578 :     if (!pOther)
    1198           6 :         ((SmMathConfig *) this)->LoadOther();
    1199         578 :     return pOther->bIsSaveOnlyUsedSymbols;
    1200             : }
    1201             : 
    1202          21 : bool SmMathConfig::IsPrintFrame() const
    1203             : {
    1204          21 :     if (!pOther)
    1205           0 :         ((SmMathConfig *) this)->LoadOther();
    1206          21 :     return pOther->bPrintFrame;
    1207             : }
    1208             : 
    1209             : 
    1210           0 : void SmMathConfig::SetPrintFrame( bool bVal )
    1211             : {
    1212           0 :     if (!pOther)
    1213           0 :         LoadOther();
    1214           0 :     SetOtherIfNotEqual( pOther->bPrintFrame, bVal );
    1215           0 : }
    1216             : 
    1217             : 
    1218           0 : void SmMathConfig::SetSaveOnlyUsedSymbols( bool bVal )
    1219             : {
    1220           0 :     if (!pOther)
    1221           0 :         LoadOther();
    1222           0 :     SetOtherIfNotEqual( pOther->bIsSaveOnlyUsedSymbols, bVal );
    1223           0 : }
    1224             : 
    1225             : 
    1226          21 : bool SmMathConfig::IsIgnoreSpacesRight() const
    1227             : {
    1228          21 :     if (!pOther)
    1229           0 :         ((SmMathConfig *) this)->LoadOther();
    1230          21 :     return pOther->bIgnoreSpacesRight;
    1231             : }
    1232             : 
    1233             : 
    1234           0 : void SmMathConfig::SetIgnoreSpacesRight( bool bVal )
    1235             : {
    1236           0 :     if (!pOther)
    1237           0 :         LoadOther();
    1238           0 :     SetOtherIfNotEqual( pOther->bIgnoreSpacesRight, bVal );
    1239           0 : }
    1240             : 
    1241             : 
    1242          26 : bool SmMathConfig::IsAutoRedraw() const
    1243             : {
    1244          26 :     if (!pOther)
    1245           0 :         ((SmMathConfig *) this)->LoadOther();
    1246          26 :     return pOther->bAutoRedraw;
    1247             : }
    1248             : 
    1249             : 
    1250           0 : void SmMathConfig::SetAutoRedraw( bool bVal )
    1251             : {
    1252           0 :     if (!pOther)
    1253           0 :         LoadOther();
    1254           0 :     SetOtherIfNotEqual( pOther->bAutoRedraw, bVal );
    1255           0 : }
    1256             : 
    1257             : 
    1258          41 : bool SmMathConfig::IsShowFormulaCursor() const
    1259             : {
    1260          41 :     if (!pOther)
    1261           0 :         ((SmMathConfig *) this)->LoadOther();
    1262          41 :     return pOther->bFormulaCursor;
    1263             : }
    1264             : 
    1265             : 
    1266           0 : void SmMathConfig::SetShowFormulaCursor( bool bVal )
    1267             : {
    1268           0 :     if (!pOther)
    1269           0 :         LoadOther();
    1270           0 :     SetOtherIfNotEqual( pOther->bFormulaCursor, bVal );
    1271           0 : }
    1272             : 
    1273           0 : void SmMathConfig::Notify( const com::sun::star::uno::Sequence< OUString >& )
    1274          27 : {}
    1275             : 
    1276             : 
    1277             : 
    1278             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10