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