From aad92a7ce2f74782064a69c1f3797544bd3298ee Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 26 May 2015 08:38:37 +0200 Subject: loplugin:unnecessarysuperclass, merge SmMathConfig with SmConfig Change-Id: I2c431e9f72f5dee14cf1b603b11972a2e9d88725 Reviewed-on: https://gerrit.libreoffice.org/15902 Reviewed-by: Noel Grandin Tested-by: Noel Grandin --- starmath/Library_sm.mk | 1 - starmath/inc/config.hxx | 48 ------------ starmath/inc/smmod.hxx | 6 +- starmath/source/ElementsDockingWindow.cxx | 1 - starmath/source/cfgitem.cxx | 70 ++++++++++++++++++ starmath/source/cfgitem.hxx | 13 +++- starmath/source/config.cxx | 119 ------------------------------ starmath/source/dialog.cxx | 2 +- starmath/source/document.cxx | 2 +- starmath/source/edit.cxx | 2 +- starmath/source/mathmlexport.cxx | 4 +- starmath/source/parse.cxx | 2 +- starmath/source/smmod.cxx | 6 +- starmath/source/symbol.cxx | 1 - starmath/source/unomodel.cxx | 4 +- starmath/source/view.cxx | 2 +- 16 files changed, 95 insertions(+), 188 deletions(-) delete mode 100644 starmath/inc/config.hxx delete mode 100644 starmath/source/config.cxx (limited to 'starmath') diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk index 203143f09fe8..a648b8c2bc1e 100644 --- a/starmath/Library_sm.mk +++ b/starmath/Library_sm.mk @@ -65,7 +65,6 @@ $(eval $(call gb_Library_add_exception_objects,sm,\ starmath/source/action \ starmath/source/caret \ starmath/source/cfgitem \ - starmath/source/config \ starmath/source/cursor \ starmath/source/dialog \ starmath/source/document \ diff --git a/starmath/inc/config.hxx b/starmath/inc/config.hxx deleted file mode 100644 index 559545bcec85..000000000000 --- a/starmath/inc/config.hxx +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef INCLUDED_STARMATH_INC_CONFIG_HXX -#define INCLUDED_STARMATH_INC_CONFIG_HXX - -#include -#include -#include "format.hxx" - -#include "cfgitem.hxx" - - -class SfxItemSet; - -class SmConfig : public SmMathConfig, public SfxBroadcaster -{ - SmFontPickList vFontPickList[7]; - -public: - SmConfig(); - virtual ~SmConfig(); - - SmFontPickList & GetFontPickList(sal_uInt16 nIdent) { return vFontPickList[nIdent]; } - - void ItemSetToConfig(const SfxItemSet &rSet); - void ConfigToItemSet(SfxItemSet &rSet) const; -}; - -#endif - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/inc/smmod.hxx b/starmath/inc/smmod.hxx index 59020d815280..9ee0deb9cce8 100644 --- a/starmath/inc/smmod.hxx +++ b/starmath/inc/smmod.hxx @@ -34,9 +34,9 @@ #include class SfxObjectFactory; -class SmConfig; class SmModule; class SmSymbolManager; +class SmMathConfig; /************************************************************************* |* @@ -88,7 +88,7 @@ public: class SmModule : public SfxModule, utl::ConfigurationListener { std::unique_ptr mpColorConfig; - std::unique_ptr mpConfig; + std::unique_ptr mpConfig; std::unique_ptr mpLocSymbolData; std::unique_ptr mpSysLocale; VclPtr mpVirtualDev; @@ -111,7 +111,7 @@ public: svtools::ColorConfig & GetColorConfig(); - SmConfig * GetConfig(); + SmMathConfig * GetConfig(); SmSymbolManager & GetSymbolManager(); SmLocalizedSymbolData & GetLocSymbolData(); diff --git a/starmath/source/ElementsDockingWindow.cxx b/starmath/source/ElementsDockingWindow.cxx index d3fcccb2554c..87680d2ca974 100644 --- a/starmath/source/ElementsDockingWindow.cxx +++ b/starmath/source/ElementsDockingWindow.cxx @@ -21,7 +21,6 @@ #include #include -#include #include #include diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx index 7616043124e8..14029a7c62e8 100644 --- a/starmath/source/cfgitem.cxx +++ b/starmath/source/cfgitem.cxx @@ -19,6 +19,11 @@ #include +#include +#include +#include +#include +#include #include #include @@ -1137,5 +1142,70 @@ void SmMathConfig::Notify( const com::sun::star::uno::Sequence< OUString >& ) {} +void SmMathConfig::ItemSetToConfig(const SfxItemSet &rSet) +{ + const SfxPoolItem *pItem = NULL; + + sal_uInt16 nU16; + bool bVal; + if (rSet.GetItemState(SID_PRINTSIZE, true, &pItem) == SfxItemState::SET) + { nU16 = static_cast(pItem)->GetValue(); + SetPrintSize( (SmPrintSize) nU16 ); + } + if (rSet.GetItemState(SID_PRINTZOOM, true, &pItem) == SfxItemState::SET) + { nU16 = static_cast(pItem)->GetValue(); + SetPrintZoomFactor( nU16 ); + } + if (rSet.GetItemState(SID_PRINTTITLE, true, &pItem) == SfxItemState::SET) + { bVal = static_cast(pItem)->GetValue(); + SetPrintTitle( bVal ); + } + if (rSet.GetItemState(SID_PRINTTEXT, true, &pItem) == SfxItemState::SET) + { bVal = static_cast(pItem)->GetValue(); + SetPrintFormulaText( bVal ); + } + if (rSet.GetItemState(SID_PRINTFRAME, true, &pItem) == SfxItemState::SET) + { bVal = static_cast(pItem)->GetValue(); + SetPrintFrame( bVal ); + } + if (rSet.GetItemState(SID_AUTOREDRAW, true, &pItem) == SfxItemState::SET) + { bVal = static_cast(pItem)->GetValue(); + SetAutoRedraw( bVal ); + } + if (rSet.GetItemState(SID_NO_RIGHT_SPACES, true, &pItem) == SfxItemState::SET) + { bVal = static_cast(pItem)->GetValue(); + if (IsIgnoreSpacesRight() != bVal) + { + SetIgnoreSpacesRight( bVal ); + + // reformat (displayed) formulas accordingly + Broadcast(SfxSimpleHint(HINT_FORMATCHANGED)); + } + } + if (rSet.GetItemState(SID_SAVE_ONLY_USED_SYMBOLS, true, &pItem) == SfxItemState::SET) + { bVal = static_cast(pItem)->GetValue(); + SetSaveOnlyUsedSymbols( bVal ); + } + + SaveOther(); +} + + +void SmMathConfig::ConfigToItemSet(SfxItemSet &rSet) const +{ + const SfxItemPool *pPool = rSet.GetPool(); + + rSet.Put(SfxUInt16Item(pPool->GetWhich(SID_PRINTSIZE), + (sal_uInt16) GetPrintSize())); + rSet.Put(SfxUInt16Item(pPool->GetWhich(SID_PRINTZOOM), + (sal_uInt16) GetPrintZoomFactor())); + + rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTITLE), IsPrintTitle())); + rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTEXT), IsPrintFormulaText())); + rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTFRAME), IsPrintFrame())); + rSet.Put(SfxBoolItem(pPool->GetWhich(SID_AUTOREDRAW), IsAutoRedraw())); + rSet.Put(SfxBoolItem(pPool->GetWhich(SID_NO_RIGHT_SPACES), IsIgnoreSpacesRight())); + rSet.Put(SfxBoolItem(pPool->GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), IsSaveOnlyUsedSymbols())); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/source/cfgitem.hxx b/starmath/source/cfgitem.hxx index 98122903497a..1fe89b424f05 100644 --- a/starmath/source/cfgitem.hxx +++ b/starmath/source/cfgitem.hxx @@ -39,6 +39,7 @@ class SmSym; class SmFormat; namespace vcl { class Font; } struct SmCfgOther; +class SfxItemSet; struct SmFontFormat { @@ -91,14 +92,15 @@ public: void SetModified( bool bVal ) { bModified = bVal; } }; -class SmMathConfig : public utl::ConfigItem +class SmMathConfig : public utl::ConfigItem, public SfxBroadcaster { std::unique_ptr pFormat; std::unique_ptr pOther; std::unique_ptr pFontFormatList; std::unique_ptr pSymbolMgr; - bool bIsOtherModified; - bool bIsFormatModified; + bool bIsOtherModified; + bool bIsFormatModified; + SmFontPickList vFontPickList[7]; SmMathConfig(const SmMathConfig&) SAL_DELETED_FUNCTION; SmMathConfig& operator=(const SmMathConfig&) SAL_DELETED_FUNCTION; @@ -173,6 +175,11 @@ public: void SetAutoRedraw( bool bVal ); bool IsShowFormulaCursor() const; void SetShowFormulaCursor( bool bVal ); + + SmFontPickList & GetFontPickList(sal_uInt16 nIdent) { return vFontPickList[nIdent]; } + + void ItemSetToConfig(const SfxItemSet &rSet); + void ConfigToItemSet(SfxItemSet &rSet) const; }; #endif diff --git a/starmath/source/config.cxx b/starmath/source/config.cxx deleted file mode 100644 index 8b47ce51444a..000000000000 --- a/starmath/source/config.cxx +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include "config.hxx" -#include "format.hxx" -#include "smmod.hxx" -#include "starmath.hrc" - - - -SmConfig::SmConfig() -{ -} - - -SmConfig::~SmConfig() -{ -} - - -void SmConfig::ItemSetToConfig(const SfxItemSet &rSet) -{ - const SfxPoolItem *pItem = NULL; - - sal_uInt16 nU16; - bool bVal; - if (rSet.GetItemState(SID_PRINTSIZE, true, &pItem) == SfxItemState::SET) - { nU16 = static_cast(pItem)->GetValue(); - SetPrintSize( (SmPrintSize) nU16 ); - } - if (rSet.GetItemState(SID_PRINTZOOM, true, &pItem) == SfxItemState::SET) - { nU16 = static_cast(pItem)->GetValue(); - SetPrintZoomFactor( nU16 ); - } - if (rSet.GetItemState(SID_PRINTTITLE, true, &pItem) == SfxItemState::SET) - { bVal = static_cast(pItem)->GetValue(); - SetPrintTitle( bVal ); - } - if (rSet.GetItemState(SID_PRINTTEXT, true, &pItem) == SfxItemState::SET) - { bVal = static_cast(pItem)->GetValue(); - SetPrintFormulaText( bVal ); - } - if (rSet.GetItemState(SID_PRINTFRAME, true, &pItem) == SfxItemState::SET) - { bVal = static_cast(pItem)->GetValue(); - SetPrintFrame( bVal ); - } - if (rSet.GetItemState(SID_AUTOREDRAW, true, &pItem) == SfxItemState::SET) - { bVal = static_cast(pItem)->GetValue(); - SetAutoRedraw( bVal ); - } - if (rSet.GetItemState(SID_NO_RIGHT_SPACES, true, &pItem) == SfxItemState::SET) - { bVal = static_cast(pItem)->GetValue(); - if (IsIgnoreSpacesRight() != bVal) - { - SetIgnoreSpacesRight( bVal ); - - // reformat (displayed) formulas accordingly - Broadcast(SfxSimpleHint(HINT_FORMATCHANGED)); - } - } - if (rSet.GetItemState(SID_SAVE_ONLY_USED_SYMBOLS, true, &pItem) == SfxItemState::SET) - { bVal = static_cast(pItem)->GetValue(); - SetSaveOnlyUsedSymbols( bVal ); - } - - SaveOther(); -} - - -void SmConfig::ConfigToItemSet(SfxItemSet &rSet) const -{ - const SfxItemPool *pPool = rSet.GetPool(); - - rSet.Put(SfxUInt16Item(pPool->GetWhich(SID_PRINTSIZE), - (sal_uInt16) GetPrintSize())); - rSet.Put(SfxUInt16Item(pPool->GetWhich(SID_PRINTZOOM), - (sal_uInt16) GetPrintZoomFactor())); - - rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTITLE), IsPrintTitle())); - rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTEXT), IsPrintFormulaText())); - rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTFRAME), IsPrintFrame())); - rSet.Put(SfxBoolItem(pPool->GetWhich(SID_AUTOREDRAW), IsAutoRedraw())); - rSet.Put(SfxBoolItem(pPool->GetWhich(SID_NO_RIGHT_SPACES), IsIgnoreSpacesRight())); - rSet.Put(SfxBoolItem(pPool->GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), IsSaveOnlyUsedSymbols())); -} - - - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index c305e066ff84..5754b8377bf2 100644 --- a/starmath/source/dialog.cxx +++ b/starmath/source/dialog.cxx @@ -39,7 +39,7 @@ #include "dialog.hxx" #include "starmath.hrc" -#include "config.hxx" +#include "cfgitem.hxx" #include "smmod.hxx" #include "symbol.hxx" #include "view.hxx" diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index 26e95ad24fb9..a9b6d9881b15 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -73,7 +73,6 @@ #include #include #include -#include #include #include #include @@ -94,6 +93,7 @@ #include #include "visitors.hxx" #include "accessibility.hxx" +#include "cfgitem.hxx" #include using namespace ::com::sun::star; diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx index e42749eba4f9..72b7b292d77b 100644 --- a/starmath/source/edit.cxx +++ b/starmath/source/edit.cxx @@ -47,7 +47,7 @@ #include "edit.hxx" #include "view.hxx" #include "document.hxx" -#include "config.hxx" +#include "cfgitem.hxx" #include "accessibility.hxx" #include diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx index 060451bd23a5..af1091c3b400 100644 --- a/starmath/source/mathmlexport.cxx +++ b/starmath/source/mathmlexport.cxx @@ -71,7 +71,7 @@ #include #include #include -#include +#include "cfgitem.hxx" using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; @@ -578,7 +578,7 @@ void SmXMLExport::GetConfigurationSettings( Sequence < PropertyValue > & rProps) PropertyValue* pProps = rProps.getArray(); if (pProps) { - SmConfig *pConfig = SM_MOD()->GetConfig(); + SmMathConfig *pConfig = SM_MOD()->GetConfig(); const bool bUsedSymbolsOnly = pConfig && pConfig->IsSaveOnlyUsedSymbols(); const OUString sFormula ( "Formula" ); diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index cde1214f2072..fb7ac7337f80 100644 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -28,7 +28,7 @@ #include "starmath.hrc" #include "smdll.hxx" #include "smmod.hxx" -#include "config.hxx" +#include "cfgitem.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::i18n; diff --git a/starmath/source/smmod.cxx b/starmath/source/smmod.cxx index a3c9dd478c0d..771528a0552d 100644 --- a/starmath/source/smmod.cxx +++ b/starmath/source/smmod.cxx @@ -33,7 +33,7 @@ #include #include "smmod.hxx" #include "symbol.hxx" -#include "config.hxx" +#include "cfgitem.hxx" #include "dialog.hxx" #include "edit.hxx" #include "view.hxx" @@ -212,10 +212,10 @@ void SmModule::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 ApplyColorConfigValues(*mpColorConfig); } -SmConfig * SmModule::GetConfig() +SmMathConfig * SmModule::GetConfig() { if(!mpConfig) - mpConfig.reset(new SmConfig); + mpConfig.reset(new SmMathConfig); return mpConfig.get(); } diff --git a/starmath/source/symbol.cxx b/starmath/source/symbol.cxx index 899380b7bd8a..52d2a882ea24 100644 --- a/starmath/source/symbol.cxx +++ b/starmath/source/symbol.cxx @@ -32,7 +32,6 @@ #include "view.hxx" #include "utility.hxx" #include "dialog.hxx" -#include "config.hxx" #include "cfgitem.hxx" #include "smmod.hxx" #include "starmath.hrc" diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx index dbebc9b92786..4a6c73d5b0b3 100644 --- a/starmath/source/unomodel.cxx +++ b/starmath/source/unomodel.cxx @@ -44,8 +44,8 @@ #include #include #include -#include #include +#include "cfgitem.hxx" using namespace ::cppu; using namespace ::std; @@ -66,7 +66,7 @@ SmPrintUIOptions::SmPrintUIOptions() return; SmModule *pp = SM_MOD(); - SmConfig *pConfig = pp->GetConfig(); + SmMathConfig *pConfig = pp->GetConfig(); SAL_WARN_IF( !pConfig, "starmath", "SmConfig not found" ); if (!pConfig) return; diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 3633cb6b4fd7..0086cadda2a1 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -64,7 +64,7 @@ #include "unomodel.hxx" #include "view.hxx" -#include "config.hxx" +#include "cfgitem.hxx" #include "dialog.hxx" #include "document.hxx" #include "starmath.hrc" -- cgit