1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifdef _MSC_VER 29 #pragma hdrstop 30 #endif 31 32 #ifndef _MATH_CFGITEM_HXX_ 33 #define _MATH_CFGITEM_HXX_ 34 35 #include <deque> 36 #include <vector> 37 38 #include <com/sun/star/beans/PropertyValues.hpp> 39 #include <com/sun/star/uno/Sequence.hxx> 40 #include <com/sun/star/uno/Any.h> 41 42 #include <tools/solar.h> 43 #include <rtl/ustring.hxx> 44 #include <unotools/configitem.hxx> 45 #include <vcl/timer.hxx> 46 47 #include <symbol.hxx> 48 #include <types.hxx> 49 50 using namespace com::sun::star; 51 52 class SmSym; 53 class SmFormat; 54 class Font; 55 struct SmCfgOther; 56 57 ///////////////////////////////////////////////////////////////// 58 59 60 struct SmFontFormat 61 { 62 String aName; 63 sal_Int16 nCharSet; 64 sal_Int16 nFamily; 65 sal_Int16 nPitch; 66 sal_Int16 nWeight; 67 sal_Int16 nItalic; 68 69 SmFontFormat(); 70 SmFontFormat( const Font &rFont ); 71 72 const Font GetFont() const; 73 sal_Bool operator == ( const SmFontFormat &rFntFmt ) const; 74 }; 75 76 77 struct SmFntFmtListEntry 78 { 79 String aId; 80 SmFontFormat aFntFmt; 81 82 SmFntFmtListEntry( const String &rId, const SmFontFormat &rFntFmt ); 83 }; 84 85 class SmFontFormatList 86 { 87 std::deque<SmFntFmtListEntry> aEntries; 88 sal_Bool bModified; 89 90 // disallow copy-constructor and assignment-operator for now 91 SmFontFormatList( const SmFontFormatList & ); 92 SmFontFormatList & operator = ( const SmFontFormatList & ); 93 94 public: 95 SmFontFormatList(); 96 97 void Clear(); 98 void AddFontFormat( const String &rFntFmtId, const SmFontFormat &rFntFmt ); 99 void RemoveFontFormat( const String &rFntFmtId ); 100 101 const SmFontFormat * GetFontFormat( const String &rFntFmtId ) const; 102 const SmFontFormat * GetFontFormat( size_t nPos ) const; 103 const String GetFontFormatId( const SmFontFormat &rFntFmt ) const; 104 const String GetFontFormatId( const SmFontFormat &rFntFmt, sal_Bool bAdd ); 105 const String GetFontFormatId( size_t nPos ) const; 106 const String GetNewFontFormatId() const; 107 size_t GetCount() const { return aEntries.size(); } 108 109 sal_Bool IsModified() const { return bModified; } 110 void SetModified( sal_Bool bVal ) { bModified = bVal; } 111 }; 112 113 114 ///////////////////////////////////////////////////////////////// 115 116 class SmMathConfig : public utl::ConfigItem 117 { 118 SmFormat * pFormat; 119 SmCfgOther * pOther; 120 SmFontFormatList * pFontFormatList; 121 SmSymbolManager * pSymbolMgr; 122 sal_Bool bIsOtherModified; 123 sal_Bool bIsFormatModified; 124 125 // disallow copy-constructor and assignment-operator for now 126 SmMathConfig( const SmMathConfig & ); 127 SmMathConfig & operator = ( const SmMathConfig & ); 128 129 130 void StripFontFormatList( const std::vector< SmSym > &rSymbols ); 131 132 133 void Save(); 134 135 void ReadSymbol( SmSym &rSymbol, 136 const rtl::OUString &rSymbolName, 137 const rtl::OUString &rBaseNode ) const; 138 void ReadFontFormat( SmFontFormat &rFontFormat, 139 const rtl::OUString &rSymbolName, 140 const rtl::OUString &rBaseNode ) const; 141 142 void SetOtherIfNotEqual( sal_Bool &rbItem, sal_Bool bNewVal ); 143 144 protected: 145 void LoadOther(); 146 void SaveOther(); 147 void LoadFormat(); 148 void SaveFormat(); 149 void LoadFontFormatList(); 150 void SaveFontFormatList(); 151 152 void SetOtherModified( sal_Bool bVal ); 153 inline sal_Bool IsOtherModified() const { return bIsOtherModified; } 154 void SetFormatModified( sal_Bool bVal ); 155 inline sal_Bool IsFormatModified() const { return bIsFormatModified; } 156 void SetFontFormatListModified( sal_Bool bVal ); 157 inline sal_Bool IsFontFormatListModified() const { return pFontFormatList ? pFontFormatList->IsModified(): sal_False; } 158 159 SmFontFormatList & GetFontFormatList(); 160 const SmFontFormatList & GetFontFormatList() const 161 { 162 return ((SmMathConfig *) this)->GetFontFormatList(); 163 } 164 165 public: 166 SmMathConfig(); 167 virtual ~SmMathConfig(); 168 169 // utl::ConfigItem 170 virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString > &rPropertyNames ); 171 virtual void Commit(); 172 173 // make some protected functions of utl::ConfigItem public 174 //using utl::ConfigItem::GetNodeNames; 175 //using utl::ConfigItem::GetProperties; 176 //using utl::ConfigItem::PutProperties; 177 //using utl::ConfigItem::SetSetProperties; 178 //using utl::ConfigItem::ReplaceSetProperties; 179 //using utl::ConfigItem::GetReadOnlyStates; 180 181 SmSymbolManager & GetSymbolManager(); 182 void GetSymbols( std::vector< SmSym > &rSymbols ) const; 183 void SetSymbols( const std::vector< SmSym > &rNewSymbols ); 184 185 const SmFormat & GetStandardFormat() const; 186 void SetStandardFormat( const SmFormat &rFormat, sal_Bool bSaveFontFormatList = sal_False ); 187 188 sal_Bool IsPrintTitle() const; 189 void SetPrintTitle( sal_Bool bVal ); 190 sal_Bool IsPrintFormulaText() const; 191 void SetPrintFormulaText( sal_Bool bVal ); 192 sal_Bool IsPrintFrame() const; 193 void SetPrintFrame( sal_Bool bVal ); 194 SmPrintSize GetPrintSize() const; 195 void SetPrintSize( SmPrintSize eSize ); 196 sal_uInt16 GetPrintZoomFactor() const; 197 void SetPrintZoomFactor( sal_uInt16 nVal ); 198 199 sal_Bool IsSaveOnlyUsedSymbols() const; 200 void SetSaveOnlyUsedSymbols( sal_Bool bVal ); 201 202 sal_Bool IsIgnoreSpacesRight() const; 203 void SetIgnoreSpacesRight( sal_Bool bVal ); 204 sal_Bool IsAutoRedraw() const; 205 void SetAutoRedraw( sal_Bool bVal ); 206 sal_Bool IsShowFormulaCursor() const; 207 void SetShowFormulaCursor( sal_Bool bVal ); 208 }; 209 210 ///////////////////////////////////////////////////////////////// 211 212 #endif 213 214