sw/qa: warning C6011: Dereferencing NULL pointer
[LibreOffice.git] / starmath / source / cfgitem.cxx
blobd8805f44dfd0bbb9f22c3cc97e4a0d6b57e02a3c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svl/itemset.hxx>
21 #include <svl/intitem.hxx>
22 #include <svl/eitem.hxx>
23 #include <svl/languageoptions.hxx>
24 #include <comphelper/configuration.hxx>
25 #include <utility>
26 #include <vcl/outdev.hxx>
27 #include <vcl/svapp.hxx>
28 #include <vcl/settings.hxx>
29 #include <sal/log.hxx>
30 #include <osl/diagnose.h>
31 #include <i18nlangtag/languagetag.hxx>
33 #include <com/sun/star/beans/PropertyValue.hpp>
35 #include <cfgitem.hxx>
37 #include <starmath.hrc>
38 #include <smmod.hxx>
39 #include <symbol.hxx>
40 #include <format.hxx>
42 using namespace com::sun::star::uno;
43 using namespace com::sun::star::beans;
45 constexpr OUString SYMBOL_LIST = u"SymbolList"_ustr;
46 constexpr OUString FONT_FORMAT_LIST = u"FontFormatList"_ustr;
48 static Sequence< OUString > lcl_GetFontPropertyNames()
50 return Sequence< OUString > {
51 u"Name"_ustr,
52 u"CharSet"_ustr,
53 u"Family"_ustr,
54 u"Pitch"_ustr,
55 u"Weight"_ustr,
56 u"Italic"_ustr
60 static Sequence< OUString > lcl_GetSymbolPropertyNames()
62 return Sequence< OUString > {
63 u"Char"_ustr,
64 u"Set"_ustr,
65 u"Predefined"_ustr,
66 u"FontFormatId"_ustr
70 static Sequence<OUString> lcl_GetOtherPropertyNames()
72 return Sequence<OUString>{ u"LoadSave/IsSaveOnlyUsedSymbols"_ustr,
73 u"Misc/AutoCloseBrackets"_ustr,
74 u"Misc/DefaultSmSyntaxVersion"_ustr,
75 u"Misc/IgnoreSpacesRight"_ustr,
76 u"Misc/InlineEditEnable"_ustr,
77 u"Misc/SmEditWindowZoomFactor"_ustr,
78 u"Print/FormulaText"_ustr,
79 u"Print/Frame"_ustr,
80 u"Print/Size"_ustr,
81 u"Print/Title"_ustr,
82 u"Print/ZoomFactor"_ustr,
83 u"View/AutoRedraw"_ustr,
84 u"View/FormulaCursor"_ustr,
85 u"View/ToolboxVisible"_ustr };
88 static Sequence< OUString > lcl_GetFormatPropertyNames()
90 //! Beware of order according to *_BEGIN *_END defines in format.hxx !
91 //! see respective load/save routines here
92 return Sequence< OUString > {
93 u"StandardFormat/Textmode"_ustr,
94 u"StandardFormat/RightToLeft"_ustr,
95 u"StandardFormat/GreekCharStyle"_ustr,
96 u"StandardFormat/ScaleNormalBracket"_ustr,
97 u"StandardFormat/HorizontalAlignment"_ustr,
98 u"StandardFormat/BaseSize"_ustr,
99 u"StandardFormat/TextSize"_ustr,
100 u"StandardFormat/IndexSize"_ustr,
101 u"StandardFormat/FunctionSize"_ustr,
102 u"StandardFormat/OperatorSize"_ustr,
103 u"StandardFormat/LimitsSize"_ustr,
104 u"StandardFormat/Distance/Horizontal"_ustr,
105 u"StandardFormat/Distance/Vertical"_ustr,
106 u"StandardFormat/Distance/Root"_ustr,
107 u"StandardFormat/Distance/SuperScript"_ustr,
108 u"StandardFormat/Distance/SubScript"_ustr,
109 u"StandardFormat/Distance/Numerator"_ustr,
110 u"StandardFormat/Distance/Denominator"_ustr,
111 u"StandardFormat/Distance/Fraction"_ustr,
112 u"StandardFormat/Distance/StrokeWidth"_ustr,
113 u"StandardFormat/Distance/UpperLimit"_ustr,
114 u"StandardFormat/Distance/LowerLimit"_ustr,
115 u"StandardFormat/Distance/BracketSize"_ustr,
116 u"StandardFormat/Distance/BracketSpace"_ustr,
117 u"StandardFormat/Distance/MatrixRow"_ustr,
118 u"StandardFormat/Distance/MatrixColumn"_ustr,
119 u"StandardFormat/Distance/OrnamentSize"_ustr,
120 u"StandardFormat/Distance/OrnamentSpace"_ustr,
121 u"StandardFormat/Distance/OperatorSize"_ustr,
122 u"StandardFormat/Distance/OperatorSpace"_ustr,
123 u"StandardFormat/Distance/LeftSpace"_ustr,
124 u"StandardFormat/Distance/RightSpace"_ustr,
125 u"StandardFormat/Distance/TopSpace"_ustr,
126 u"StandardFormat/Distance/BottomSpace"_ustr,
127 u"StandardFormat/Distance/NormalBracketSize"_ustr,
128 u"StandardFormat/VariableFont"_ustr,
129 u"StandardFormat/FunctionFont"_ustr,
130 u"StandardFormat/NumberFont"_ustr,
131 u"StandardFormat/TextFont"_ustr,
132 u"StandardFormat/SerifFont"_ustr,
133 u"StandardFormat/SansFont"_ustr,
134 u"StandardFormat/FixedFont"_ustr
138 struct SmCfgOther
140 SmPrintSize ePrintSize;
141 sal_uInt16 nPrintZoomFactor;
142 sal_uInt16 nSmEditWindowZoomFactor;
143 sal_Int16 nSmSyntaxVersion;
144 bool bPrintTitle;
145 bool bPrintFormulaText;
146 bool bPrintFrame;
147 bool bIsSaveOnlyUsedSymbols;
148 bool bIsAutoCloseBrackets;
149 bool bInlineEditEnable;
150 bool bIgnoreSpacesRight;
151 bool bToolboxVisible;
152 bool bAutoRedraw;
153 bool bFormulaCursor;
155 SmCfgOther();
158 constexpr sal_Int16 nDefaultSmSyntaxVersion(5);
160 SmCfgOther::SmCfgOther()
161 : ePrintSize(PRINT_SIZE_NORMAL)
162 , nPrintZoomFactor(100)
163 , nSmEditWindowZoomFactor(100)
164 // Defaulted as 5 so I have time to code the parser 6
165 , nSmSyntaxVersion(nDefaultSmSyntaxVersion)
166 , bPrintTitle(true)
167 , bPrintFormulaText(true)
168 , bPrintFrame(true)
169 , bIsSaveOnlyUsedSymbols(true)
170 , bIsAutoCloseBrackets(true)
171 , bInlineEditEnable(true)
172 , bIgnoreSpacesRight(true)
173 , bToolboxVisible(true)
174 , bAutoRedraw(true)
175 , bFormulaCursor(true)
180 SmFontFormat::SmFontFormat()
181 : aName(FONTNAME_MATH)
182 , nCharSet(RTL_TEXTENCODING_UNICODE)
183 , nFamily(FAMILY_DONTKNOW)
184 , nPitch(PITCH_DONTKNOW)
185 , nWeight(WEIGHT_DONTKNOW)
186 , nItalic(ITALIC_NONE)
191 SmFontFormat::SmFontFormat( const vcl::Font &rFont )
192 : aName(rFont.GetFamilyName())
193 , nCharSet(static_cast<sal_Int16>(rFont.GetCharSet()))
194 , nFamily(static_cast<sal_Int16>(rFont.GetFamilyType()))
195 , nPitch(static_cast<sal_Int16>(rFont.GetPitch()))
196 , nWeight(static_cast<sal_Int16>(rFont.GetWeight()))
197 , nItalic(static_cast<sal_Int16>(rFont.GetItalic()))
202 vcl::Font SmFontFormat::GetFont() const
204 vcl::Font aRes;
205 aRes.SetFamilyName( aName );
206 aRes.SetCharSet( static_cast<rtl_TextEncoding>(nCharSet) );
207 aRes.SetFamily( static_cast<FontFamily>(nFamily) );
208 aRes.SetPitch( static_cast<FontPitch>(nPitch) );
209 aRes.SetWeight( static_cast<FontWeight>(nWeight) );
210 aRes.SetItalic( static_cast<FontItalic>(nItalic) );
211 return aRes;
215 bool SmFontFormat::operator == ( const SmFontFormat &rFntFmt ) const
217 return aName == rFntFmt.aName &&
218 nCharSet == rFntFmt.nCharSet &&
219 nFamily == rFntFmt.nFamily &&
220 nPitch == rFntFmt.nPitch &&
221 nWeight == rFntFmt.nWeight &&
222 nItalic == rFntFmt.nItalic;
226 SmFntFmtListEntry::SmFntFmtListEntry( OUString _aId, SmFontFormat _aFntFmt ) :
227 aId (std::move(_aId)),
228 aFntFmt (std::move(_aFntFmt))
233 SmFontFormatList::SmFontFormatList()
234 : bModified(false)
239 void SmFontFormatList::Clear()
241 if (!aEntries.empty())
243 aEntries.clear();
244 SetModified( true );
249 void SmFontFormatList::AddFontFormat( const OUString &rFntFmtId,
250 const SmFontFormat &rFntFmt )
252 const SmFontFormat *pFntFmt = GetFontFormat( rFntFmtId );
253 OSL_ENSURE( !pFntFmt, "FontFormatId already exists" );
254 if (!pFntFmt)
256 SmFntFmtListEntry aEntry( rFntFmtId, rFntFmt );
257 aEntries.push_back( aEntry );
258 SetModified( true );
263 void SmFontFormatList::RemoveFontFormat( std::u16string_view rFntFmtId )
266 // search for entry
267 for (size_t i = 0; i < aEntries.size(); ++i)
269 if (aEntries[i].aId == rFntFmtId)
271 // remove entry if found
272 aEntries.erase( aEntries.begin() + i );
273 SetModified( true );
274 break;
280 const SmFontFormat * SmFontFormatList::GetFontFormat( std::u16string_view rFntFmtId ) const
282 const SmFontFormat *pRes = nullptr;
284 for (const auto & rEntry : aEntries)
286 if (rEntry.aId == rFntFmtId)
288 pRes = &rEntry.aFntFmt;
289 break;
293 return pRes;
297 const SmFontFormat * SmFontFormatList::GetFontFormat( size_t nPos ) const
299 const SmFontFormat *pRes = nullptr;
300 if (nPos < aEntries.size())
301 pRes = &aEntries[nPos].aFntFmt;
302 return pRes;
306 OUString SmFontFormatList::GetFontFormatId( const SmFontFormat &rFntFmt ) const
308 OUString aRes;
310 for (const auto & rEntry : aEntries)
312 if (rEntry.aFntFmt == rFntFmt)
314 aRes = rEntry.aId;
315 break;
319 return aRes;
323 OUString SmFontFormatList::GetFontFormatId( const SmFontFormat &rFntFmt, bool bAdd )
325 OUString aRes( GetFontFormatId( rFntFmt) );
326 if (aRes.isEmpty() && bAdd)
328 aRes = GetNewFontFormatId();
329 AddFontFormat( aRes, rFntFmt );
331 return aRes;
335 OUString SmFontFormatList::GetFontFormatId( size_t nPos ) const
337 OUString aRes;
338 if (nPos < aEntries.size())
339 aRes = aEntries[nPos].aId;
340 return aRes;
344 OUString SmFontFormatList::GetNewFontFormatId() const
346 // returns first unused FormatId
348 sal_Int32 nCnt = GetCount();
349 for (sal_Int32 i = 1; i <= nCnt + 1; ++i)
351 OUString aTmpId = "Id" + OUString::number(i);
352 if (!GetFontFormat(aTmpId))
353 return aTmpId;
355 OSL_ENSURE( false, "failed to create new FontFormatId" );
357 return OUString();
361 SmMathConfig::SmMathConfig() :
362 ConfigItem(u"Office.Math"_ustr)
363 , bIsOtherModified(false)
364 , bIsFormatModified(false)
366 EnableNotification({ {} }); // Listen to everything under the node
370 SmMathConfig::~SmMathConfig()
372 Save();
376 void SmMathConfig::SetOtherModified( bool bVal )
378 bIsOtherModified = bVal;
382 void SmMathConfig::SetFormatModified( bool bVal )
384 bIsFormatModified = bVal;
388 void SmMathConfig::ReadSymbol( SmSym &rSymbol,
389 const OUString &rSymbolName,
390 std::u16string_view rBaseNode ) const
392 Sequence< OUString > aNames = lcl_GetSymbolPropertyNames();
393 sal_Int32 nProps = aNames.getLength();
395 OUString aDelim( u"/"_ustr );
396 for (auto& rName : asNonConstRange(aNames))
397 rName = rBaseNode + aDelim + rSymbolName + aDelim + rName;
399 const Sequence< Any > aValues = const_cast<SmMathConfig*>(this)->GetProperties(aNames);
401 if (!(nProps && aValues.getLength() == nProps))
402 return;
404 const Any * pValue = aValues.getConstArray();
405 vcl::Font aFont;
406 sal_UCS4 cChar = '\0';
407 OUString aSet;
408 bool bPredefined = false;
410 OUString aTmpStr;
411 sal_Int32 nTmp32 = 0;
412 bool bTmp = false;
414 bool bOK = true;
415 if (pValue->hasValue() && (*pValue >>= nTmp32))
416 cChar = static_cast< sal_UCS4 >( nTmp32 );
417 else
418 bOK = false;
419 ++pValue;
420 if (pValue->hasValue() && (*pValue >>= aTmpStr))
421 aSet = aTmpStr;
422 else
423 bOK = false;
424 ++pValue;
425 if (pValue->hasValue() && (*pValue >>= bTmp))
426 bPredefined = bTmp;
427 else
428 bOK = false;
429 ++pValue;
430 if (pValue->hasValue() && (*pValue >>= aTmpStr))
432 const SmFontFormat *pFntFmt = GetFontFormatList().GetFontFormat( aTmpStr );
433 OSL_ENSURE( pFntFmt, "unknown FontFormat" );
434 if (pFntFmt)
435 aFont = pFntFmt->GetFont();
437 ++pValue;
439 if (bOK)
441 OUString aUiName( rSymbolName );
442 OUString aUiSetName( aSet );
443 if (bPredefined)
445 OUString aTmp;
446 aTmp = SmLocalizedSymbolData::GetUiSymbolName( rSymbolName );
447 OSL_ENSURE( !aTmp.isEmpty(), "localized symbol-name not found" );
448 if (!aTmp.isEmpty())
449 aUiName = aTmp;
450 aTmp = SmLocalizedSymbolData::GetUiSymbolSetName( aSet );
451 OSL_ENSURE( !aTmp.isEmpty(), "localized symbolset-name not found" );
452 if (!aTmp.isEmpty())
453 aUiSetName = aTmp;
456 rSymbol = SmSym( aUiName, aFont, cChar, aUiSetName, bPredefined );
457 if (aUiName != rSymbolName)
458 rSymbol.SetExportName( rSymbolName );
460 else
462 SAL_WARN("starmath", "symbol read error");
467 SmSymbolManager & SmMathConfig::GetSymbolManager()
469 if (!pSymbolMgr)
471 pSymbolMgr.reset(new SmSymbolManager);
472 pSymbolMgr->Load();
474 return *pSymbolMgr;
478 void SmMathConfig::ImplCommit()
480 Save();
484 void SmMathConfig::Save()
486 SaveOther();
487 SaveFormat();
488 SaveFontFormatList();
492 void SmMathConfig::UnlockCommit()
494 if (--m_nCommitLock == 0)
495 Commit();
499 void SmMathConfig::Clear()
501 // Re-read data on next request
502 pOther.reset();
503 pFormat.reset();
504 pFontFormatList.reset();
508 void SmMathConfig::GetSymbols( std::vector< SmSym > &rSymbols ) const
510 Sequence< OUString > aNodes(const_cast<SmMathConfig*>(this)->GetNodeNames(SYMBOL_LIST));
511 const OUString *pNode = aNodes.getConstArray();
512 sal_Int32 nNodes = aNodes.getLength();
514 rSymbols.resize( nNodes );
515 for (auto& rSymbol : rSymbols)
517 ReadSymbol( rSymbol, *pNode++, SYMBOL_LIST );
522 void SmMathConfig::SetSymbols( const std::vector< SmSym > &rNewSymbols )
524 CommitLocker aLock(*this);
525 auto nCount = sal::static_int_cast<sal_Int32>(rNewSymbols.size());
527 Sequence< OUString > aNames = lcl_GetSymbolPropertyNames();
528 const OUString *pNames = aNames.getConstArray();
529 sal_Int32 nSymbolProps = aNames.getLength();
531 Sequence< PropertyValue > aValues( nCount * nSymbolProps );
532 PropertyValue *pValues = aValues.getArray();
534 PropertyValue *pVal = pValues;
535 OUString aDelim( u"/"_ustr );
536 for (const SmSym& rSymbol : rNewSymbols)
538 OUString aNodeNameDelim = SYMBOL_LIST +
539 aDelim +
540 rSymbol.GetExportName() +
541 aDelim;
543 const OUString *pName = pNames;
545 // Char
546 pVal->Name = aNodeNameDelim;
547 pVal->Name += *pName++;
548 pVal->Value <<= rSymbol.GetCharacter();
549 pVal++;
550 // Set
551 pVal->Name = aNodeNameDelim;
552 pVal->Name += *pName++;
553 OUString aTmp( rSymbol.GetSymbolSetName() );
554 if (rSymbol.IsPredefined())
555 aTmp = SmLocalizedSymbolData::GetExportSymbolSetName( aTmp );
556 pVal->Value <<= aTmp;
557 pVal++;
558 // Predefined
559 pVal->Name = aNodeNameDelim;
560 pVal->Name += *pName++;
561 pVal->Value <<= rSymbol.IsPredefined();
562 pVal++;
563 // FontFormatId
564 SmFontFormat aFntFmt( rSymbol.GetFace() );
565 OUString aFntFmtId( GetFontFormatList().GetFontFormatId( aFntFmt, true ) );
566 OSL_ENSURE( !aFntFmtId.isEmpty(), "FontFormatId not found" );
567 pVal->Name = aNodeNameDelim;
568 pVal->Name += *pName++;
569 pVal->Value <<= aFntFmtId;
570 pVal++;
572 OSL_ENSURE( pVal - pValues == sal::static_int_cast< ptrdiff_t >(nCount * nSymbolProps), "properties missing" );
573 ReplaceSetProperties( SYMBOL_LIST, aValues );
575 StripFontFormatList( rNewSymbols );
579 SmFontFormatList & SmMathConfig::GetFontFormatList()
581 if (!pFontFormatList)
583 LoadFontFormatList();
585 return *pFontFormatList;
589 void SmMathConfig::LoadFontFormatList()
591 if (!pFontFormatList)
592 pFontFormatList.reset(new SmFontFormatList);
593 else
594 pFontFormatList->Clear();
596 const Sequence< OUString > aNodes( GetNodeNames( FONT_FORMAT_LIST ) );
598 for (const OUString& rNode : aNodes)
600 SmFontFormat aFntFmt;
601 ReadFontFormat( aFntFmt, rNode, FONT_FORMAT_LIST );
602 if (!pFontFormatList->GetFontFormat( rNode ))
603 pFontFormatList->AddFontFormat( rNode, aFntFmt );
605 pFontFormatList->SetModified( false );
609 void SmMathConfig::ReadFontFormat( SmFontFormat &rFontFormat,
610 std::u16string_view rSymbolName, std::u16string_view rBaseNode ) const
612 Sequence< OUString > aNames = lcl_GetFontPropertyNames();
613 sal_Int32 nProps = aNames.getLength();
615 OUString aDelim( u"/"_ustr );
616 for (auto& rName : asNonConstRange(aNames))
617 rName = rBaseNode + aDelim + rSymbolName + aDelim + rName;
619 const Sequence< Any > aValues = const_cast<SmMathConfig*>(this)->GetProperties(aNames);
621 if (!(nProps && aValues.getLength() == nProps))
622 return;
624 const Any * pValue = aValues.getConstArray();
626 OUString aTmpStr;
627 sal_Int16 nTmp16 = 0;
629 bool bOK = true;
630 if (pValue->hasValue() && (*pValue >>= aTmpStr))
631 rFontFormat.aName = aTmpStr;
632 else
633 bOK = false;
634 ++pValue;
635 if (pValue->hasValue() && (*pValue >>= nTmp16))
636 rFontFormat.nCharSet = nTmp16; // 6.0 file-format GetSOLoadTextEncoding not needed
637 else
638 bOK = false;
639 ++pValue;
640 if (pValue->hasValue() && (*pValue >>= nTmp16))
641 rFontFormat.nFamily = nTmp16;
642 else
643 bOK = false;
644 ++pValue;
645 if (pValue->hasValue() && (*pValue >>= nTmp16))
646 rFontFormat.nPitch = nTmp16;
647 else
648 bOK = false;
649 ++pValue;
650 if (pValue->hasValue() && (*pValue >>= nTmp16))
651 rFontFormat.nWeight = nTmp16;
652 else
653 bOK = false;
654 ++pValue;
655 if (pValue->hasValue() && (*pValue >>= nTmp16))
656 rFontFormat.nItalic = nTmp16;
657 else
658 bOK = false;
659 ++pValue;
661 OSL_ENSURE( bOK, "read FontFormat failed" );
665 void SmMathConfig::SaveFontFormatList()
667 SmFontFormatList &rFntFmtList = GetFontFormatList();
669 if (!rFntFmtList.IsModified())
670 return;
672 Sequence< OUString > aNames = lcl_GetFontPropertyNames();
673 sal_Int32 nSymbolProps = aNames.getLength();
675 size_t nCount = rFntFmtList.GetCount();
677 Sequence< PropertyValue > aValues( nCount * nSymbolProps );
678 PropertyValue *pValues = aValues.getArray();
680 PropertyValue *pVal = pValues;
681 OUString aDelim( u"/"_ustr );
682 for (size_t i = 0; i < nCount; ++i)
684 OUString aFntFmtId(rFntFmtList.GetFontFormatId(i));
685 const SmFontFormat *pFntFmt = rFntFmtList.GetFontFormat(i);
686 assert(pFntFmt);
687 const SmFontFormat aFntFmt(*pFntFmt);
689 OUString aNodeNameDelim = FONT_FORMAT_LIST +
690 aDelim +
691 aFntFmtId +
692 aDelim;
694 const OUString *pName = aNames.getConstArray();
696 // Name
697 pVal->Name = aNodeNameDelim;
698 pVal->Name += *pName++;
699 pVal->Value <<= aFntFmt.aName;
700 pVal++;
701 // CharSet
702 pVal->Name = aNodeNameDelim;
703 pVal->Name += *pName++;
704 pVal->Value <<= aFntFmt.nCharSet; // 6.0 file-format GetSOStoreTextEncoding not needed
705 pVal++;
706 // Family
707 pVal->Name = aNodeNameDelim;
708 pVal->Name += *pName++;
709 pVal->Value <<= aFntFmt.nFamily;
710 pVal++;
711 // Pitch
712 pVal->Name = aNodeNameDelim;
713 pVal->Name += *pName++;
714 pVal->Value <<= aFntFmt.nPitch;
715 pVal++;
716 // Weight
717 pVal->Name = aNodeNameDelim;
718 pVal->Name += *pName++;
719 pVal->Value <<= aFntFmt.nWeight;
720 pVal++;
721 // Italic
722 pVal->Name = aNodeNameDelim;
723 pVal->Name += *pName++;
724 pVal->Value <<= aFntFmt.nItalic;
725 pVal++;
727 OSL_ENSURE( sal::static_int_cast<size_t>(pVal - pValues) == nCount * nSymbolProps, "properties missing" );
728 ReplaceSetProperties( FONT_FORMAT_LIST, aValues );
730 rFntFmtList.SetModified( false );
734 void SmMathConfig::StripFontFormatList( const std::vector< SmSym > &rSymbols )
736 size_t i;
738 // build list of used font-formats only
739 //!! font-format IDs may be different !!
740 SmFontFormatList aUsedList;
741 for (i = 0; i < rSymbols.size(); ++i)
743 OSL_ENSURE( !rSymbols[i].GetUiName().isEmpty(), "non named symbol" );
744 aUsedList.GetFontFormatId( SmFontFormat( rSymbols[i].GetFace() ) , true );
746 const SmFormat & rStdFmt = GetStandardFormat();
747 for (i = FNT_BEGIN; i <= FNT_END; ++i)
749 aUsedList.GetFontFormatId( SmFontFormat( rStdFmt.GetFont( i ) ) , true );
752 // remove unused font-formats from list
753 SmFontFormatList &rFntFmtList = GetFontFormatList();
754 size_t nCnt = rFntFmtList.GetCount();
755 std::unique_ptr<SmFontFormat[]> pTmpFormat(new SmFontFormat[ nCnt ]);
756 std::unique_ptr<OUString[]> pId(new OUString[ nCnt ]);
757 size_t k;
758 for (k = 0; k < nCnt; ++k)
760 pTmpFormat[k] = *rFntFmtList.GetFontFormat( k );
761 pId[k] = rFntFmtList.GetFontFormatId( k );
763 for (k = 0; k < nCnt; ++k)
765 if (aUsedList.GetFontFormatId( pTmpFormat[k] ).isEmpty())
767 rFntFmtList.RemoveFontFormat( pId[k] );
773 void SmMathConfig::LoadOther()
775 if (!pOther)
776 pOther.reset(new SmCfgOther);
778 const Sequence<OUString> aNames(lcl_GetOtherPropertyNames());
779 const Sequence<Any> aValues(GetProperties(aNames));
780 if (aNames.getLength() != aValues.getLength())
781 return;
783 const Any* pValues = aValues.getConstArray();
784 const Any* pVal = pValues;
786 // LoadSave/IsSaveOnlyUsedSymbols
787 if (bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
788 pOther->bIsSaveOnlyUsedSymbols = bTmp;
789 ++pVal;
790 // Misc/AutoCloseBrackets
791 if (bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
792 pOther->bIsAutoCloseBrackets = bTmp;
793 ++pVal;
794 // Misc/DefaultSmSyntaxVersion
795 if (sal_Int16 nTmp; pVal->hasValue() && (*pVal >>= nTmp))
796 pOther->nSmSyntaxVersion = nTmp;
797 ++pVal;
798 // Misc/InlineEditEnable
799 if (bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
800 pOther->bInlineEditEnable = bTmp;
801 ++pVal;
802 // Misc/IgnoreSpacesRight
803 if (bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
804 pOther->bIgnoreSpacesRight = bTmp;
805 ++pVal;
806 // Misc/SmEditWindowZoomFactor
807 if (sal_Int16 nTmp; pVal->hasValue() && (*pVal >>= nTmp))
808 pOther->nSmEditWindowZoomFactor = nTmp;
809 ++pVal;
810 // Print/FormulaText
811 if (bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
812 pOther->bPrintFormulaText = bTmp;
813 ++pVal;
814 // Print/Frame
815 if (bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
816 pOther->bPrintFrame = bTmp;
817 ++pVal;
818 // Print/Size:
819 if (sal_Int16 nTmp; pVal->hasValue() && (*pVal >>= nTmp))
820 pOther->ePrintSize = static_cast<SmPrintSize>(nTmp);
821 ++pVal;
822 // Print/Title
823 if (bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
824 pOther->bPrintTitle = bTmp;
825 ++pVal;
826 // Print/ZoomFactor
827 if (sal_Int16 nTmp; pVal->hasValue() && (*pVal >>= nTmp))
828 pOther->nPrintZoomFactor = nTmp;
829 ++pVal;
830 // View/AutoRedraw
831 if (bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
832 pOther->bAutoRedraw = bTmp;
833 ++pVal;
834 // View/FormulaCursor
835 if (bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
836 pOther->bFormulaCursor = bTmp;
837 ++pVal;
838 // View/ToolboxVisible
839 if (bool bTmp; pVal->hasValue() && (*pVal >>= bTmp))
840 pOther->bToolboxVisible = bTmp;
841 ++pVal;
843 OSL_ENSURE(pVal - pValues == aNames.getLength(), "property mismatch");
844 SetOtherModified( false );
848 void SmMathConfig::SaveOther()
850 if (!pOther || !IsOtherModified())
851 return;
853 const Sequence<OUString> aNames(lcl_GetOtherPropertyNames());
854 Sequence<Any> aValues(aNames.getLength());
856 Any* pValues = aValues.getArray();
857 Any* pVal = pValues;
859 // LoadSave/IsSaveOnlyUsedSymbols
860 *pVal++ <<= pOther->bIsSaveOnlyUsedSymbols;
861 // Misc/AutoCloseBrackets
862 *pVal++ <<= pOther->bIsAutoCloseBrackets;
863 // Misc/DefaultSmSyntaxVersion
864 *pVal++ <<= pOther->nSmSyntaxVersion;
865 // Misc/InlineEditEnable
866 *pVal++ <<= pOther->bInlineEditEnable;
867 // Misc/IgnoreSpacesRight
868 *pVal++ <<= pOther->bIgnoreSpacesRight;
869 // Misc/SmEditWindowZoomFactor
870 *pVal++ <<= pOther->nSmEditWindowZoomFactor;
871 // Print/FormulaText
872 *pVal++ <<= pOther->bPrintFormulaText;
873 // Print/Frame
874 *pVal++ <<= pOther->bPrintFrame;
875 // Print/Size:
876 *pVal++ <<= static_cast<sal_Int16>(pOther->ePrintSize);
877 // Print/Title
878 *pVal++ <<= pOther->bPrintTitle;
879 // Print/ZoomFactor
880 *pVal++ <<= pOther->nPrintZoomFactor;
881 // View/AutoRedraw
882 *pVal++ <<= pOther->bAutoRedraw;
883 // View/FormulaCursor
884 *pVal++ <<= pOther->bFormulaCursor;
885 // View/ToolboxVisible
886 *pVal++ <<= pOther->bToolboxVisible;
888 OSL_ENSURE(pVal - pValues == aNames.getLength(), "property mismatch");
889 PutProperties(aNames, aValues);
891 SetOtherModified( false );
894 namespace {
896 // Latin default-fonts
897 const DefaultFontType aLatinDefFnts[FNT_END] =
899 DefaultFontType::SERIF, // FNT_VARIABLE
900 DefaultFontType::SERIF, // FNT_FUNCTION
901 DefaultFontType::SERIF, // FNT_NUMBER
902 DefaultFontType::SERIF, // FNT_TEXT
903 DefaultFontType::SERIF, // FNT_SERIF
904 DefaultFontType::SANS, // FNT_SANS
905 DefaultFontType::FIXED // FNT_FIXED
906 //OpenSymbol, // FNT_MATH
909 // CJK default-fonts
910 //! we use non-asian fonts for variables, functions and numbers since they
911 //! look better and even in asia only latin letters will be used for those.
912 //! At least that's what I was told...
913 const DefaultFontType aCJKDefFnts[FNT_END] =
915 DefaultFontType::SERIF, // FNT_VARIABLE
916 DefaultFontType::SERIF, // FNT_FUNCTION
917 DefaultFontType::SERIF, // FNT_NUMBER
918 DefaultFontType::CJK_TEXT, // FNT_TEXT
919 DefaultFontType::CJK_TEXT, // FNT_SERIF
920 DefaultFontType::CJK_DISPLAY, // FNT_SANS
921 DefaultFontType::CJK_TEXT // FNT_FIXED
922 //OpenSymbol, // FNT_MATH
925 // CTL default-fonts
926 const DefaultFontType aCTLDefFnts[FNT_END] =
928 DefaultFontType::CTL_TEXT, // FNT_VARIABLE
929 DefaultFontType::CTL_TEXT, // FNT_FUNCTION
930 DefaultFontType::CTL_TEXT, // FNT_NUMBER
931 DefaultFontType::CTL_TEXT, // FNT_TEXT
932 DefaultFontType::CTL_TEXT, // FNT_SERIF
933 DefaultFontType::CTL_TEXT, // FNT_SANS
934 DefaultFontType::CTL_TEXT // FNT_FIXED
935 //OpenSymbol, // FNT_MATH
939 OUString lcl_GetDefaultFontName( LanguageType nLang, sal_uInt16 nIdent )
941 assert(nIdent < FNT_END);
942 const DefaultFontType *pTable;
943 switch ( SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ) )
945 case SvtScriptType::LATIN : pTable = aLatinDefFnts; break;
946 case SvtScriptType::ASIAN : pTable = aCJKDefFnts; break;
947 case SvtScriptType::COMPLEX : pTable = aCTLDefFnts; break;
948 default :
949 pTable = aLatinDefFnts;
950 SAL_WARN("starmath", "unknown script-type");
953 return OutputDevice::GetDefaultFont(pTable[ nIdent ], nLang,
954 GetDefaultFontFlags::OnlyOne ).GetFamilyName();
960 void SmMathConfig::LoadFormat()
962 if (!pFormat)
963 pFormat.reset(new SmFormat);
966 Sequence< OUString > aNames = lcl_GetFormatPropertyNames();
968 sal_Int32 nProps = aNames.getLength();
970 Sequence< Any > aValues( GetProperties( aNames ) );
971 if (!(nProps && aValues.getLength() == nProps))
972 return;
974 const Any *pValues = aValues.getConstArray();
975 const Any *pVal = pValues;
977 OUString aTmpStr;
978 sal_Int16 nTmp16 = 0;
979 bool bTmp = false;
981 // StandardFormat/Textmode
982 if (pVal->hasValue() && (*pVal >>= bTmp))
983 pFormat->SetTextmode( bTmp );
984 ++pVal;
985 // StandardFormat/RightToLeft
986 if (pVal->hasValue() && (*pVal >>= bTmp))
987 pFormat->SetRightToLeft( bTmp );
988 ++pVal;
989 // StandardFormat/GreekCharStyle
990 if (pVal->hasValue() && (*pVal >>= nTmp16))
991 pFormat->SetGreekCharStyle( nTmp16 );
992 ++pVal;
993 // StandardFormat/ScaleNormalBracket
994 if (pVal->hasValue() && (*pVal >>= bTmp))
995 pFormat->SetScaleNormalBrackets( bTmp );
996 ++pVal;
997 // StandardFormat/HorizontalAlignment
998 if (pVal->hasValue() && (*pVal >>= nTmp16))
999 pFormat->SetHorAlign( static_cast<SmHorAlign>(nTmp16) );
1000 ++pVal;
1001 // StandardFormat/BaseSize
1002 if (pVal->hasValue() && (*pVal >>= nTmp16))
1003 pFormat->SetBaseSize(Size(0, o3tl::convert(nTmp16, o3tl::Length::pt, SmO3tlLengthUnit())));
1004 ++pVal;
1006 sal_uInt16 i;
1007 for (i = SIZ_BEGIN; i <= SIZ_END; ++i)
1009 if (pVal->hasValue() && (*pVal >>= nTmp16))
1010 pFormat->SetRelSize( i, nTmp16 );
1011 ++pVal;
1014 for (i = DIS_BEGIN; i <= DIS_END; ++i)
1016 if (pVal->hasValue() && (*pVal >>= nTmp16))
1017 pFormat->SetDistance( i, nTmp16 );
1018 ++pVal;
1021 LanguageType nLang = Application::GetSettings().GetUILanguageTag().getLanguageType();
1022 for (i = FNT_BEGIN; i < FNT_END; ++i)
1024 vcl::Font aFnt;
1025 bool bUseDefaultFont = true;
1026 if (pVal->hasValue() && (*pVal >>= aTmpStr))
1028 bUseDefaultFont = aTmpStr.isEmpty();
1029 if (bUseDefaultFont)
1031 aFnt = pFormat->GetFont( i );
1032 aFnt.SetFamilyName( lcl_GetDefaultFontName( nLang, i ) );
1034 else
1036 const SmFontFormat *pFntFmt = GetFontFormatList().GetFontFormat( aTmpStr );
1037 OSL_ENSURE( pFntFmt, "unknown FontFormat" );
1038 if (pFntFmt)
1039 aFnt = pFntFmt->GetFont();
1042 ++pVal;
1044 aFnt.SetFontSize( pFormat->GetBaseSize() );
1045 pFormat->SetFont( i, aFnt, bUseDefaultFont );
1048 OSL_ENSURE( pVal - pValues == nProps, "property mismatch" );
1049 SetFormatModified( false );
1053 void SmMathConfig::SaveFormat()
1055 if (!pFormat || !IsFormatModified())
1056 return;
1058 const Sequence< OUString > aNames = lcl_GetFormatPropertyNames();
1059 sal_Int32 nProps = aNames.getLength();
1061 Sequence< Any > aValues( nProps );
1062 Any *pValues = aValues.getArray();
1063 Any *pValue = pValues;
1065 // StandardFormat/Textmode
1066 *pValue++ <<= pFormat->IsTextmode();
1067 // StandardFormat/RightToLeft
1068 *pValue++ <<= pFormat->IsRightToLeft();
1069 // StandardFormat/GreekCharStyle
1070 *pValue++ <<= pFormat->GetGreekCharStyle();
1071 // StandardFormat/ScaleNormalBracket
1072 *pValue++ <<= pFormat->IsScaleNormalBrackets();
1073 // StandardFormat/HorizontalAlignment
1074 *pValue++ <<= static_cast<sal_Int16>(pFormat->GetHorAlign());
1075 // StandardFormat/BaseSize
1076 *pValue++ <<= static_cast<sal_Int16>(
1077 o3tl::convert(pFormat->GetBaseSize().Height(), SmO3tlLengthUnit(), o3tl::Length::pt));
1079 sal_uInt16 i;
1080 for (i = SIZ_BEGIN; i <= SIZ_END; ++i)
1081 *pValue++ <<= static_cast<sal_Int16>(pFormat->GetRelSize( i ));
1083 for (i = DIS_BEGIN; i <= DIS_END; ++i)
1084 *pValue++ <<= static_cast<sal_Int16>(pFormat->GetDistance( i ));
1086 for (i = FNT_BEGIN; i < FNT_END; ++i)
1088 OUString aFntFmtId;
1090 if (!pFormat->IsDefaultFont( i ))
1092 SmFontFormat aFntFmt( pFormat->GetFont( i ) );
1093 aFntFmtId = GetFontFormatList().GetFontFormatId( aFntFmt, true );
1094 OSL_ENSURE( !aFntFmtId.isEmpty(), "FontFormatId not found" );
1097 *pValue++ <<= aFntFmtId;
1100 OSL_ENSURE( pValue - pValues == nProps, "property mismatch" );
1101 PutProperties( aNames , aValues );
1103 SetFormatModified( false );
1107 const SmFormat & SmMathConfig::GetStandardFormat() const
1109 if (!pFormat)
1110 const_cast<SmMathConfig*>(this)->LoadFormat();
1111 return *pFormat;
1115 void SmMathConfig::SetStandardFormat( const SmFormat &rFormat, bool bSaveFontFormatList )
1117 if (!pFormat)
1118 LoadFormat();
1119 if (rFormat == *pFormat)
1120 return;
1122 CommitLocker aLock(*this);
1123 *pFormat = rFormat;
1124 SetFormatModified( true );
1126 if (bSaveFontFormatList)
1128 // needed for SmFontTypeDialog's DefaultButtonClickHdl
1129 if (pFontFormatList)
1130 pFontFormatList->SetModified( true );
1135 SmPrintSize SmMathConfig::GetPrintSize() const
1137 if (!pOther)
1138 const_cast<SmMathConfig*>(this)->LoadOther();
1139 return pOther->ePrintSize;
1143 void SmMathConfig::SetPrintSize( SmPrintSize eSize )
1145 if (!pOther)
1146 LoadOther();
1147 if (eSize != pOther->ePrintSize)
1149 CommitLocker aLock(*this);
1150 pOther->ePrintSize = eSize;
1151 SetOtherModified( true );
1156 sal_uInt16 SmMathConfig::GetPrintZoomFactor() const
1158 if (!pOther)
1159 const_cast<SmMathConfig*>(this)->LoadOther();
1160 return pOther->nPrintZoomFactor;
1164 void SmMathConfig::SetPrintZoomFactor( sal_uInt16 nVal )
1166 if (!pOther)
1167 LoadOther();
1168 if (nVal != pOther->nPrintZoomFactor)
1170 CommitLocker aLock(*this);
1171 pOther->nPrintZoomFactor = nVal;
1172 SetOtherModified( true );
1177 sal_uInt16 SmMathConfig::GetSmEditWindowZoomFactor() const
1179 sal_uInt16 smzoomfactor;
1180 if (!pOther)
1181 const_cast<SmMathConfig*>(this)->LoadOther();
1182 smzoomfactor = pOther->nSmEditWindowZoomFactor;
1183 return smzoomfactor < 10 || smzoomfactor > 1000 ? 100 : smzoomfactor;
1187 void SmMathConfig::SetSmEditWindowZoomFactor( sal_uInt16 nVal )
1189 if (!pOther)
1190 LoadOther();
1191 if (nVal != pOther->nSmEditWindowZoomFactor)
1193 CommitLocker aLock(*this);
1194 pOther->nSmEditWindowZoomFactor = nVal;
1195 SetOtherModified( true );
1200 bool SmMathConfig::SetOtherIfNotEqual( bool &rbItem, bool bNewVal )
1202 if (bNewVal != rbItem)
1204 CommitLocker aLock(*this);
1205 rbItem = bNewVal;
1206 SetOtherModified( true );
1207 return true;
1209 return false;
1213 bool SmMathConfig::IsPrintTitle() const
1215 if (!pOther)
1216 const_cast<SmMathConfig*>(this)->LoadOther();
1217 return pOther->bPrintTitle;
1221 void SmMathConfig::SetPrintTitle( bool bVal )
1223 if (!pOther)
1224 LoadOther();
1225 SetOtherIfNotEqual( pOther->bPrintTitle, bVal );
1229 bool SmMathConfig::IsPrintFormulaText() const
1231 if (!pOther)
1232 const_cast<SmMathConfig*>(this)->LoadOther();
1233 return pOther->bPrintFormulaText;
1237 void SmMathConfig::SetPrintFormulaText( bool bVal )
1239 if (!pOther)
1240 LoadOther();
1241 SetOtherIfNotEqual( pOther->bPrintFormulaText, bVal );
1244 bool SmMathConfig::IsSaveOnlyUsedSymbols() const
1246 if (!pOther)
1247 const_cast<SmMathConfig*>(this)->LoadOther();
1248 return pOther->bIsSaveOnlyUsedSymbols;
1251 bool SmMathConfig::IsAutoCloseBrackets() const
1253 if (!pOther)
1254 const_cast<SmMathConfig*>(this)->LoadOther();
1255 return pOther->bIsAutoCloseBrackets;
1258 sal_Int16 SmMathConfig::GetDefaultSmSyntaxVersion() const
1260 if (comphelper::IsFuzzing())
1261 return nDefaultSmSyntaxVersion;
1262 if (!pOther)
1263 const_cast<SmMathConfig*>(this)->LoadOther();
1264 return pOther->nSmSyntaxVersion;
1267 bool SmMathConfig::IsPrintFrame() const
1269 if (!pOther)
1270 const_cast<SmMathConfig*>(this)->LoadOther();
1271 return pOther->bPrintFrame;
1275 void SmMathConfig::SetPrintFrame( bool bVal )
1277 if (!pOther)
1278 LoadOther();
1279 SetOtherIfNotEqual( pOther->bPrintFrame, bVal );
1283 void SmMathConfig::SetSaveOnlyUsedSymbols( bool bVal )
1285 if (!pOther)
1286 LoadOther();
1287 SetOtherIfNotEqual( pOther->bIsSaveOnlyUsedSymbols, bVal );
1291 void SmMathConfig::SetAutoCloseBrackets( bool bVal )
1293 if (!pOther)
1294 LoadOther();
1295 SetOtherIfNotEqual( pOther->bIsAutoCloseBrackets, bVal );
1298 void SmMathConfig::SetDefaultSmSyntaxVersion( sal_Int16 nVal )
1300 if (!pOther)
1301 LoadOther();
1302 if (nVal != pOther->nSmSyntaxVersion)
1304 CommitLocker aLock(*this);
1305 pOther->nSmSyntaxVersion = nVal;
1306 SetOtherModified( true );
1310 bool SmMathConfig::IsInlineEditEnable() const
1312 if (comphelper::IsFuzzing())
1313 return false;
1314 if (!pOther)
1315 const_cast<SmMathConfig*>(this)->LoadOther();
1316 return pOther->bInlineEditEnable;
1320 void SmMathConfig::SetInlineEditEnable( bool bVal )
1322 if (!pOther)
1323 LoadOther();
1324 if (SetOtherIfNotEqual( pOther->bInlineEditEnable, bVal ))
1326 // reformat (displayed) formulas accordingly
1327 Broadcast(SfxHint(SfxHintId::MathFormatChanged));
1331 bool SmMathConfig::IsIgnoreSpacesRight() const
1333 if (comphelper::IsFuzzing())
1334 return false;
1335 if (!pOther)
1336 const_cast<SmMathConfig*>(this)->LoadOther();
1337 return pOther->bIgnoreSpacesRight;
1341 void SmMathConfig::SetIgnoreSpacesRight( bool bVal )
1343 if (!pOther)
1344 LoadOther();
1345 if (SetOtherIfNotEqual( pOther->bIgnoreSpacesRight, bVal ))
1347 // reformat (displayed) formulas accordingly
1348 Broadcast(SfxHint(SfxHintId::MathFormatChanged));
1354 bool SmMathConfig::IsAutoRedraw() const
1356 if (!pOther)
1357 const_cast<SmMathConfig*>(this)->LoadOther();
1358 return pOther->bAutoRedraw;
1362 void SmMathConfig::SetAutoRedraw( bool bVal )
1364 if (!pOther)
1365 LoadOther();
1366 SetOtherIfNotEqual( pOther->bAutoRedraw, bVal );
1370 bool SmMathConfig::IsShowFormulaCursor() const
1372 if (!pOther)
1373 const_cast<SmMathConfig*>(this)->LoadOther();
1374 return pOther->bFormulaCursor;
1378 void SmMathConfig::SetShowFormulaCursor( bool bVal )
1380 if (!pOther)
1381 LoadOther();
1382 SetOtherIfNotEqual( pOther->bFormulaCursor, bVal );
1385 void SmMathConfig::Notify( const css::uno::Sequence< OUString >& rNames )
1387 Clear();
1388 if (std::find(rNames.begin(), rNames.end(), "Misc/IgnoreSpacesRight") != rNames.end())
1389 Broadcast(SfxHint(SfxHintId::MathFormatChanged));
1393 void SmMathConfig::ItemSetToConfig(const SfxItemSet &rSet)
1395 CommitLocker aLock(*this);
1397 sal_uInt16 nU16;
1398 bool bVal;
1399 if (const SfxUInt16Item* pPrintSizeItem = rSet.GetItemIfSet(SID_PRINTSIZE))
1400 { nU16 = pPrintSizeItem->GetValue();
1401 SetPrintSize( static_cast<SmPrintSize>(nU16) );
1403 if (const SfxUInt16Item* pPrintZoomItem = rSet.GetItemIfSet(SID_PRINTZOOM))
1404 { nU16 = pPrintZoomItem->GetValue();
1405 SetPrintZoomFactor( nU16 );
1407 if (const SfxUInt16Item* pPrintZoomItem = rSet.GetItemIfSet(SID_SMEDITWINDOWZOOM))
1408 { nU16 = pPrintZoomItem->GetValue();
1409 SetSmEditWindowZoomFactor( nU16 );
1411 if (const SfxBoolItem* pPrintTitleItem = rSet.GetItemIfSet(SID_PRINTTITLE))
1412 { bVal = pPrintTitleItem->GetValue();
1413 SetPrintTitle( bVal );
1415 if (const SfxBoolItem* pPrintTextItem = rSet.GetItemIfSet(SID_PRINTTEXT))
1416 { bVal = pPrintTextItem->GetValue();
1417 SetPrintFormulaText( bVal );
1419 if (const SfxBoolItem* pPrintZoomItem = rSet.GetItemIfSet(SID_PRINTFRAME))
1420 { bVal = pPrintZoomItem->GetValue();
1421 SetPrintFrame( bVal );
1423 if (const SfxBoolItem* pRedrawItem = rSet.GetItemIfSet(SID_AUTOREDRAW))
1424 { bVal = pRedrawItem->GetValue();
1425 SetAutoRedraw( bVal );
1427 if (const SfxBoolItem* pSpacesItem = rSet.GetItemIfSet(SID_INLINE_EDIT_ENABLE))
1428 { bVal = pSpacesItem->GetValue();
1429 SetInlineEditEnable( bVal );
1431 if (const SfxBoolItem* pSpacesItem = rSet.GetItemIfSet(SID_NO_RIGHT_SPACES))
1432 { bVal = pSpacesItem->GetValue();
1433 SetIgnoreSpacesRight( bVal );
1435 if (const SfxBoolItem* pSymbolsItem = rSet.GetItemIfSet(SID_SAVE_ONLY_USED_SYMBOLS))
1436 { bVal = pSymbolsItem->GetValue();
1437 SetSaveOnlyUsedSymbols( bVal );
1440 if (const SfxBoolItem* pBracketsItem = rSet.GetItemIfSet(SID_AUTO_CLOSE_BRACKETS))
1442 bVal = pBracketsItem->GetValue();
1443 SetAutoCloseBrackets( bVal );
1446 if (const SfxUInt16Item* pSyntaxItem = rSet.GetItemIfSet(SID_DEFAULT_SM_SYNTAX_VERSION))
1448 nU16 = pSyntaxItem->GetValue();
1449 SetDefaultSmSyntaxVersion( nU16 );
1454 void SmMathConfig::ConfigToItemSet(SfxItemSet &rSet) const
1456 rSet.Put(SfxUInt16Item(SID_PRINTSIZE,
1457 sal::static_int_cast<sal_uInt16>(GetPrintSize())));
1458 rSet.Put(SfxUInt16Item(SID_PRINTZOOM,
1459 GetPrintZoomFactor()));
1460 rSet.Put(SfxUInt16Item(SID_SMEDITWINDOWZOOM,
1461 GetSmEditWindowZoomFactor()));
1463 rSet.Put(SfxBoolItem(SID_PRINTTITLE, IsPrintTitle()));
1464 rSet.Put(SfxBoolItem(SID_PRINTTEXT, IsPrintFormulaText()));
1465 rSet.Put(SfxBoolItem(SID_PRINTFRAME, IsPrintFrame()));
1466 rSet.Put(SfxBoolItem(SID_AUTOREDRAW, IsAutoRedraw()));
1467 rSet.Put(SfxBoolItem(SID_INLINE_EDIT_ENABLE, IsInlineEditEnable()));
1468 rSet.Put(SfxBoolItem(SID_NO_RIGHT_SPACES, IsIgnoreSpacesRight()));
1469 rSet.Put(SfxBoolItem(SID_SAVE_ONLY_USED_SYMBOLS, IsSaveOnlyUsedSymbols()));
1470 rSet.Put(SfxBoolItem(SID_AUTO_CLOSE_BRACKETS, IsAutoCloseBrackets()));
1471 rSet.Put(SfxBoolItem(SID_DEFAULT_SM_SYNTAX_VERSION, GetDefaultSmSyntaxVersion()));
1474 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */