diff options
Diffstat (limited to 'sw/source/uibase/config')
-rw-r--r-- | sw/source/uibase/config/StoredChapterNumbering.cxx | 459 | ||||
-rw-r--r-- | sw/source/uibase/config/barcfg.cxx | 124 | ||||
-rw-r--r-- | sw/source/uibase/config/caption.cxx | 39 | ||||
-rw-r--r-- | sw/source/uibase/config/cfgitems.cxx | 261 | ||||
-rw-r--r-- | sw/source/uibase/config/dbconfig.cxx | 99 | ||||
-rw-r--r-- | sw/source/uibase/config/fontcfg.cxx | 310 | ||||
-rw-r--r-- | sw/source/uibase/config/modcfg.cxx | 1336 | ||||
-rw-r--r-- | sw/source/uibase/config/prtopt.cxx | 168 | ||||
-rw-r--r-- | sw/source/uibase/config/uinums.cxx | 259 | ||||
-rw-r--r-- | sw/source/uibase/config/usrpref.cxx | 618 | ||||
-rw-r--r-- | sw/source/uibase/config/viewopt.cxx | 611 |
11 files changed, 4284 insertions, 0 deletions
diff --git a/sw/source/uibase/config/StoredChapterNumbering.cxx b/sw/source/uibase/config/StoredChapterNumbering.cxx new file mode 100644 index 000000000..43dbde46b --- /dev/null +++ b/sw/source/uibase/config/StoredChapterNumbering.cxx @@ -0,0 +1,459 @@ +/* -*- 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/. + */ + +#include <uinums.hxx> + +#include <cppuhelper/implbase.hxx> + +#include <com/sun/star/container/XIndexReplace.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/lang/IndexOutOfBoundsException.hpp> +#include <com/sun/star/util/MeasureUnit.hpp> +#include <com/sun/star/xml/sax/Writer.hpp> + +#include <comphelper/processfactory.hxx> + +#include <unotools/streamwrap.hxx> + +#include <xmloff/xmlnamespace.hxx> +#include <xmloff/xmltoken.hxx> +#include <xmloff/namespacemap.hxx> +#include <xmloff/xmlexp.hxx> +#include <xmloff/xmlnume.hxx> +#include <xmloff/xmlimp.hxx> +#include <xmloff/xmlictxt.hxx> +#include <xmloff/xmlnumi.hxx> + +#include <vcl/svapp.hxx> +#include <tools/diagnose_ex.h> + +#include <unosett.hxx> + + +using namespace ::com::sun::star; +using namespace ::xmloff::token; + +namespace sw { + +class StoredChapterNumberingRules + : public ::cppu::WeakImplHelper<container::XNamed,container::XIndexReplace> +{ +private: + // TODO in case this ever becomes accessible via API need an invalidate + SwChapterNumRules & m_rNumRules; + sal_uInt16 const m_nIndex; + + SwNumRulesWithName * GetOrCreateRules() + { + SwNumRulesWithName const* pRules(m_rNumRules.GetRules(m_nIndex)); + if (!pRules) + { + m_rNumRules.CreateEmptyNumRule(m_nIndex); + pRules = m_rNumRules.GetRules(m_nIndex); + assert(pRules); + } + return const_cast<SwNumRulesWithName*>(pRules); + } + +public: + StoredChapterNumberingRules( + SwChapterNumRules & rNumRules, sal_uInt16 const nIndex) + : m_rNumRules(rNumRules) + , m_nIndex(nIndex) + { + assert(m_nIndex < SwChapterNumRules::nMaxRules); + } + + // XNamed + virtual OUString SAL_CALL getName() override + { + SolarMutexGuard g; + SwNumRulesWithName const* pRules(m_rNumRules.GetRules(m_nIndex)); + if (!pRules) + { + return OUString(); + } + return pRules->GetName(); + } + + virtual void SAL_CALL setName(OUString const& rName) override + { + SolarMutexGuard g; + SwNumRulesWithName *const pRules(GetOrCreateRules()); + pRules->SetName(rName); + } + + // XElementAccess + virtual uno::Type SAL_CALL getElementType() override + { + return ::cppu::UnoType<uno::Sequence<beans::PropertyValue>>::get(); + } + + virtual ::sal_Bool SAL_CALL hasElements() override + { + return true; + } + + // XIndexAccess + virtual sal_Int32 SAL_CALL getCount() override + { + return MAXLEVEL; + } + + virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override + { + if (nIndex < 0 || MAXLEVEL <= nIndex) + throw lang::IndexOutOfBoundsException(); + + SolarMutexGuard g; + SwNumRulesWithName const* pRules(m_rNumRules.GetRules(m_nIndex)); + if (!pRules) + { + return uno::Any(); + } + SwNumFormat const* pNumFormat(nullptr); + OUString const* pCharStyleName(nullptr); + pRules->GetNumFormat(nIndex, pNumFormat, pCharStyleName); + if (!pNumFormat) + { // the dialog only fills in those levels that are non-default + return uno::Any(); // the export will ignore this level, yay + } + assert(pCharStyleName); + OUString dummy; // pass in empty HeadingStyleName - can't import anyway + uno::Sequence<beans::PropertyValue> const ret( + SwXNumberingRules::GetPropertiesForNumFormat( + *pNumFormat, *pCharStyleName, &dummy, "")); + return uno::Any(ret); + } + + // XIndexReplace + virtual void SAL_CALL replaceByIndex( + sal_Int32 nIndex, uno::Any const& rElement) override + { + if (nIndex < 0 || MAXLEVEL <= nIndex) + throw lang::IndexOutOfBoundsException(); + uno::Sequence<beans::PropertyValue> props; + if (!(rElement >>= props)) + throw lang::IllegalArgumentException("invalid type", + static_cast< ::cppu::OWeakObject*>(this), 1); + + SolarMutexGuard g; + SwNumFormat aNumberFormat; + OUString charStyleName; + SwXNumberingRules::SetPropertiesToNumFormat( + aNumberFormat, + charStyleName, + nullptr, nullptr, nullptr, nullptr, nullptr, + props); + SwNumRulesWithName *const pRules(GetOrCreateRules()); + pRules->SetNumFormat(nIndex, aNumberFormat, charStyleName); + } +}; + +namespace { + +class StoredChapterNumberingExport + : public SvXMLExport +{ +public: + StoredChapterNumberingExport( + uno::Reference<uno::XComponentContext> const& xContext, + OUString const& rFileName, + uno::Reference<xml::sax::XDocumentHandler> const& xHandler) + : SvXMLExport(xContext, "sw::StoredChapterNumberingExport", rFileName, + util::MeasureUnit::CM, xHandler) + { + GetNamespaceMap_().Add(GetXMLToken(XML_NP_OFFICE), + GetXMLToken(XML_N_OFFICE), XML_NAMESPACE_OFFICE); + GetNamespaceMap_().Add(GetXMLToken(XML_NP_TEXT), + GetXMLToken(XML_N_TEXT), XML_NAMESPACE_TEXT); + GetNamespaceMap_().Add(GetXMLToken(XML_NP_STYLE), + GetXMLToken(XML_N_STYLE), XML_NAMESPACE_STYLE); + GetNamespaceMap_().Add(GetXMLToken(XML_NP_FO), + GetXMLToken(XML_N_FO), XML_NAMESPACE_FO); + GetNamespaceMap_().Add(GetXMLToken(XML_NP_SVG), + GetXMLToken(XML_N_SVG), XML_NAMESPACE_SVG); + } + + virtual void ExportAutoStyles_() override {} + virtual void ExportMasterStyles_() override {} + virtual void ExportContent_() override {} + + void ExportRule(SvxXMLNumRuleExport & rExport, + uno::Reference<container::XIndexReplace> const& xRule) + { + uno::Reference<container::XNamed> const xNamed(xRule, uno::UNO_QUERY); + OUString const name(xNamed->getName()); + bool bEncoded(false); + AddAttribute( XML_NAMESPACE_STYLE, XML_NAME, + EncodeStyleName(name, &bEncoded) ); + if (bEncoded) + { + AddAttribute(XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, name); + } + + SvXMLElementExport aElem( *this, XML_NAMESPACE_TEXT, + XML_OUTLINE_STYLE, true, true ); + rExport.exportLevelStyles(xRule, true); + } + + void ExportRules( + std::set<OUString> const& rCharStyles, + std::vector<uno::Reference<container::XIndexReplace>> const& rRules) + { + GetDocHandler()->startDocument(); + + AddAttribute(XML_NAMESPACE_NONE, + GetNamespaceMap_().GetAttrNameByKey(XML_NAMESPACE_OFFICE), + GetNamespaceMap_().GetNameByKey(XML_NAMESPACE_OFFICE)); + AddAttribute(XML_NAMESPACE_NONE, + GetNamespaceMap_().GetAttrNameByKey (XML_NAMESPACE_TEXT), + GetNamespaceMap_().GetNameByKey(XML_NAMESPACE_TEXT)); + AddAttribute(XML_NAMESPACE_NONE, + GetNamespaceMap_().GetAttrNameByKey(XML_NAMESPACE_STYLE), + GetNamespaceMap_().GetNameByKey(XML_NAMESPACE_STYLE)); + AddAttribute(XML_NAMESPACE_NONE, + GetNamespaceMap_().GetAttrNameByKey(XML_NAMESPACE_FO), + GetNamespaceMap_().GetNameByKey(XML_NAMESPACE_FO)); + AddAttribute(XML_NAMESPACE_NONE, + GetNamespaceMap_().GetAttrNameByKey(XML_NAMESPACE_SVG), + GetNamespaceMap_().GetNameByKey(XML_NAMESPACE_SVG)); + + { + // let's just have an office:styles as a dummy root + SvXMLElementExport styles(*this, + XML_NAMESPACE_OFFICE, XML_STYLES, true, true); + + // horrible hack for char styles to get display-name mapping + for (const auto& rCharStyle : rCharStyles) + { + AddAttribute( XML_NAMESPACE_STYLE, XML_FAMILY, XML_TEXT ); + bool bEncoded(false); + AddAttribute( XML_NAMESPACE_STYLE, XML_NAME, + EncodeStyleName(rCharStyle, &bEncoded) ); + if (bEncoded) + { + AddAttribute(XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, rCharStyle); + } + + SvXMLElementExport style(*this, + XML_NAMESPACE_STYLE, XML_STYLE, true, true); + } + + SvxXMLNumRuleExport numRuleExport(*this); + + for (const auto& rRule : rRules) + { + ExportRule(numRuleExport, rRule); + } + } + + GetDocHandler()->endDocument(); + } +}; + +/** Dummy import context for style:style element that can just read the + attributes needed to map name to display-name. + Unfortunately the "real" context for this depends on some other things. + The mapping is necessary to import the text:style-name attribute + of the text:outline-level-style element. + */ +class StoredChapterNumberingDummyStyleContext + : public SvXMLImportContext +{ +public: + StoredChapterNumberingDummyStyleContext( + SvXMLImport & rImport, + uno::Reference<xml::sax::XFastAttributeList> const& xAttrList) + : SvXMLImportContext(rImport) + { + OUString name; + OUString displayName; + XmlStyleFamily nFamily(XmlStyleFamily::DATA_STYLE); + + for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) + if (aIter.getToken() == (XML_NAMESPACE_STYLE | XML_FAMILY)) + { + if (IsXMLToken(aIter, XML_TEXT)) + nFamily = XmlStyleFamily::TEXT_TEXT; + else if (IsXMLToken(aIter, XML_NAME)) + name = aIter.toString(); + else if (IsXMLToken(aIter, XML_DISPLAY_NAME)) + displayName = aIter.toString(); + else + SAL_WARN("xmloff", "unknown value for style:family=" << aIter.toString()); + } + else + XMLOFF_WARN_UNKNOWN("xmloff", aIter); + + if (nFamily != XmlStyleFamily::DATA_STYLE && !name.isEmpty() && !displayName.isEmpty()) + { + rImport.AddStyleDisplayName(nFamily, name, displayName); + } + } +}; + +class StoredChapterNumberingImport; + +class StoredChapterNumberingRootContext + : public SvXMLImportContext +{ +private: + SwChapterNumRules & m_rNumRules; + size_t m_nCounter; + std::vector<rtl::Reference<SvxXMLListStyleContext>> m_Contexts; + +public: + StoredChapterNumberingRootContext( + SwChapterNumRules & rNumRules, SvXMLImport & rImport) + : SvXMLImportContext(rImport) + , m_rNumRules(rNumRules) + , m_nCounter(0) + { + } + + virtual void SAL_CALL endFastElement(sal_Int32 /*Element*/) override + { + assert(m_Contexts.size() <= SwChapterNumRules::nMaxRules); + for (auto iter = m_Contexts.begin(); iter != m_Contexts.end(); ++iter) + { + uno::Reference<container::XIndexReplace> const xRule( + new sw::StoredChapterNumberingRules(m_rNumRules, + iter - m_Contexts.begin())); + (*iter)->FillUnoNumRule(xRule); + // TODO: xmloff's outline-style import seems to ignore this??? + uno::Reference<container::XNamed> const xNamed(xRule, uno::UNO_QUERY); + xNamed->setName((*iter)->GetDisplayName()); + } + } + + virtual css::uno::Reference<XFastContextHandler> SAL_CALL createFastChildContext( + sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override + { + if (Element == XML_ELEMENT(STYLE, XML_STYLE)) + { + return new StoredChapterNumberingDummyStyleContext(GetImport(), xAttrList); + } + else if (Element == XML_ELEMENT(TEXT, XML_OUTLINE_STYLE)) + { + ++m_nCounter; + if (m_nCounter <= SwChapterNumRules::nMaxRules) + { + SvxXMLListStyleContext *const pContext( + new SvxXMLListStyleContext(GetImport(), true)); + m_Contexts.emplace_back(pContext); + return pContext; + } + } + + return nullptr; + } +}; + +class StoredChapterNumberingImport + : public SvXMLImport +{ +private: + SwChapterNumRules & m_rNumRules; + +public: + StoredChapterNumberingImport( + uno::Reference<uno::XComponentContext> const& xContext, + SwChapterNumRules & rNumRules) + : SvXMLImport(xContext, "sw::StoredChapterNumberingImport", SvXMLImportFlags::ALL) + , m_rNumRules(rNumRules) + { + } + + virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList > & /*xAttrList*/ ) override + { + if (Element == XML_ELEMENT(OFFICE, XML_STYLES)) + return new StoredChapterNumberingRootContext(m_rNumRules, *this); + return nullptr; + } +}; + +} + +void ExportStoredChapterNumberingRules(SwChapterNumRules & rRules, + SvStream & rStream, OUString const& rFileName) +{ + uno::Reference<uno::XComponentContext> const xContext( + ::comphelper::getProcessComponentContext()); + + uno::Reference<io::XOutputStream> const xOutStream( + new ::utl::OOutputStreamWrapper(rStream)); + + uno::Reference<xml::sax::XWriter> const xWriter( + xml::sax::Writer::create(xContext)); + + xWriter->setOutputStream(xOutStream); + + rtl::Reference<StoredChapterNumberingExport> exp(new StoredChapterNumberingExport(xContext, rFileName, xWriter)); + + // if style name contains a space then name != display-name + // ... and the import needs to map from name to display-name then! + std::set<OUString> charStyles; + std::vector<uno::Reference<container::XIndexReplace>> numRules; + for (size_t i = 0; i < SwChapterNumRules::nMaxRules; ++i) + { + if (SwNumRulesWithName const* pRule = rRules.GetRules(i)) + { + for (size_t j = 0; j < MAXLEVEL; ++j) + { + SwNumFormat const* pDummy(nullptr); + OUString const* pCharStyleName(nullptr); + pRule->GetNumFormat(j, pDummy, pCharStyleName); + if (pCharStyleName && !pCharStyleName->isEmpty()) + { + charStyles.insert(*pCharStyleName); + } + } + numRules.push_back(new StoredChapterNumberingRules(rRules, i)); + } + } + + try + { + exp->ExportRules(charStyles, numRules); + } + catch (uno::Exception const&) + { + TOOLS_WARN_EXCEPTION("sw.ui", "ExportStoredChapterNumberingRules"); + } +} + +void ImportStoredChapterNumberingRules(SwChapterNumRules & rRules, + SvStream & rStream, OUString const& rFileName) +{ + uno::Reference<uno::XComponentContext> const xContext( + ::comphelper::getProcessComponentContext()); + + uno::Reference<io::XInputStream> const xInStream( + new ::utl::OInputStreamWrapper(rStream)); + + rtl::Reference<StoredChapterNumberingImport> const xImport(new StoredChapterNumberingImport(xContext, rRules)); + + xml::sax::InputSource const source(xInStream, "", "", rFileName); + + try + { + xImport->parseStream(source); + } + catch (uno::Exception const&) + { + TOOLS_WARN_EXCEPTION("sw.ui", "ImportStoredChapterNumberingRules"); + } +} + +} // namespace sw + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/config/barcfg.cxx b/sw/source/uibase/config/barcfg.cxx new file mode 100644 index 000000000..1f54b05cc --- /dev/null +++ b/sw/source/uibase/config/barcfg.cxx @@ -0,0 +1,124 @@ +/* -*- 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 <osl/diagnose.h> +#include <com/sun/star/uno/Sequence.hxx> +#include <wrtsh.hxx> +#include <barcfg.hxx> + +using namespace utl; +using namespace com::sun::star::uno; + +#define SEL_TYPE_TABLE_TEXT 0 +#define SEL_TYPE_LIST_TEXT 1 +#define SEL_TYPE_TABLE_LIST 2 +#define SEL_TYPE_BEZIER 3 +#define SEL_TYPE_GRAPHIC 4 + +SwToolbarConfigItem::SwToolbarConfigItem( bool bWeb ) : + ConfigItem(bWeb ? OUString("Office.WriterWeb/ObjectBar") : OUString("Office.Writer/ObjectBar"), + ConfigItemMode::ReleaseTree) +{ + for(int i = 0; i <= SEL_TYPE_GRAPHIC; ++i) + m_aTbxIdArray[i] = -1; + + Sequence<OUString> aNames = GetPropertyNames(); + Sequence<Any> aValues = GetProperties(aNames); + const Any* pValues = aValues.getConstArray(); + OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); + if(aValues.getLength() == aNames.getLength()) + { + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + if(pValues[nProp].hasValue()) + { + sal_Int32 nVal = 0; + pValues[nProp] >>= nVal; + m_aTbxIdArray[nProp] = nVal; + } + } + } +} + +SwToolbarConfigItem::~SwToolbarConfigItem() +{ +} + +static sal_Int32 lcl_getArrayIndex(SelectionType nSelType) +{ + sal_Int32 nRet = -1; + if(nSelType & SelectionType::NumberList) + { + if(nSelType & SelectionType::Table) + nRet = SEL_TYPE_TABLE_LIST; + else + nRet = SEL_TYPE_LIST_TEXT; + } + else if(nSelType & SelectionType::Table) + nRet = SEL_TYPE_TABLE_TEXT; + else if(nSelType & SelectionType::Ornament) + nRet = SEL_TYPE_BEZIER; + else if(nSelType & SelectionType::Graphic) + nRet = SEL_TYPE_GRAPHIC; + return nRet; +} + +void SwToolbarConfigItem::SetTopToolbar(SelectionType nSelType, ToolbarId eBarId) +{ + sal_Int32 nProp = lcl_getArrayIndex(nSelType); + if(nProp >= 0) + { + m_aTbxIdArray[nProp] = static_cast<sal_Int32>(eBarId); + SetModified(); + } +} + +Sequence<OUString> SwToolbarConfigItem::GetPropertyNames() +{ + static const char* aPropNames[] = + { + "Selection/Table", // SEL_TYPE_TABLE_TEXT + "Selection/NumberedList", // SEL_TYPE_LIST_TEXT + "Selection/NumberedList_InTable", // SEL_TYPE_TABLE_LIST + "Selection/BezierObject", // SEL_TYPE_BEZIER + "Selection/Graphic" //SEL_TYPE_GRAPHIC + }; + const int nCount = 5; + Sequence<OUString> aNames(nCount); + OUString* pNames = aNames.getArray(); + for(int i = 0; i < nCount; i++) + pNames[i] = OUString::createFromAscii(aPropNames[i]); + return aNames; +} + +void SwToolbarConfigItem::ImplCommit() +{ + Sequence<OUString> aNames = GetPropertyNames(); + + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + pValues[nProp] <<= m_aTbxIdArray[nProp]; + PutProperties(aNames, aValues); +} + +void SwToolbarConfigItem::Notify( const css::uno::Sequence< OUString >& ) {} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/config/caption.cxx b/sw/source/uibase/config/caption.cxx new file mode 100644 index 000000000..d023bd836 --- /dev/null +++ b/sw/source/uibase/config/caption.cxx @@ -0,0 +1,39 @@ +/* -*- 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 <editeng/svxenum.hxx> +#include <caption.hxx> + +InsCaptionOpt::InsCaptionOpt(const SwCapObjType eType, const SvGlobalName* pOleId) : + m_bUseCaption(false), + m_eObjType(eType), + m_nNumType(SVX_NUM_ARABIC), + m_sNumberSeparator(". "), + m_nPos(1), + m_nLevel(0), + m_sSeparator( OUString(": ") ), + m_bIgnoreSeqOpts(false), + m_bCopyAttributes(false) +{ + if (pOleId) + m_aOleId = *pOleId; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/config/cfgitems.cxx b/sw/source/uibase/config/cfgitems.cxx new file mode 100644 index 000000000..e32c86e14 --- /dev/null +++ b/sw/source/uibase/config/cfgitems.cxx @@ -0,0 +1,261 @@ +/* -*- 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 <viewopt.hxx> +#include <cmdid.h> +#include <cfgitems.hxx> +#include <crstate.hxx> + + +SwDocDisplayItem::SwDocDisplayItem() : + SfxPoolItem(FN_PARAM_DOCDISP) +{ + m_bParagraphEnd = + m_bTab = + m_bSpace = + m_bNonbreakingSpace = + m_bSoftHyphen = + m_bCharHiddenText = + m_bBookmarks = + m_bManualBreak = true; + m_xDefaultAnchor = 1; //FLY_TO_CHAR +}; + +// Item for the Settings dialog, page document view +SwDocDisplayItem::SwDocDisplayItem(const SwViewOption& rVOpt ) : + SfxPoolItem( FN_PARAM_DOCDISP ) +{ + m_bParagraphEnd = rVOpt.IsParagraph(true); + m_bTab = rVOpt.IsTab(true); + m_bSpace = rVOpt.IsBlank(true); + m_bNonbreakingSpace = rVOpt.IsHardBlank(); + m_bSoftHyphen = rVOpt.IsSoftHyph(); + m_bCharHiddenText = rVOpt.IsShowHiddenChar(true); + m_bBookmarks = rVOpt.IsShowBookmarks(true); + m_bManualBreak = rVOpt.IsLineBreak(true); + m_xDefaultAnchor = rVOpt.GetDefaultAnchor(); +} + +SwDocDisplayItem* SwDocDisplayItem::Clone( SfxItemPool* ) const +{ + return new SwDocDisplayItem( *this ); +} + +bool SwDocDisplayItem::operator==( const SfxPoolItem& rAttr ) const +{ + assert(SfxPoolItem::operator==(rAttr)); + + const SwDocDisplayItem& rItem = static_cast<const SwDocDisplayItem&>(rAttr); + + return ( m_bParagraphEnd == rItem.m_bParagraphEnd && + m_bTab == rItem.m_bTab && + m_bSpace == rItem.m_bSpace && + m_bNonbreakingSpace == rItem.m_bNonbreakingSpace && + m_bSoftHyphen == rItem.m_bSoftHyphen && + m_bCharHiddenText == rItem.m_bCharHiddenText && + m_bBookmarks == rItem.m_bBookmarks && + m_bManualBreak == rItem.m_bManualBreak && + m_xDefaultAnchor == rItem.m_xDefaultAnchor); +} + +void SwDocDisplayItem::FillViewOptions( SwViewOption& rVOpt) const +{ + rVOpt.SetParagraph (m_bParagraphEnd ); + rVOpt.SetTab (m_bTab ); + rVOpt.SetBlank (m_bSpace ); + rVOpt.SetHardBlank (m_bNonbreakingSpace ); + rVOpt.SetSoftHyph (m_bSoftHyphen ); + rVOpt.SetShowHiddenChar(m_bCharHiddenText ); + rVOpt.SetShowBookmarks(m_bBookmarks ); + rVOpt.SetLineBreak (m_bManualBreak ); + rVOpt.SetDefaultAnchor( m_xDefaultAnchor ); +} + +SwElemItem::SwElemItem() : + SfxPoolItem(FN_PARAM_ELEM) +{ + m_bVertRuler = + m_bVertRulerRight= + m_bCrosshair = + m_bSmoothScroll = + m_bTable = + m_bGraphic = + m_bDrawing = + m_bNotes = false; + m_bShowInlineTooltips = true; + m_bShowOutlineContentVisibilityButton = + m_bTreatSubOutlineLevelsAsContent = + m_bShowChangesInMargin = + m_bFieldHiddenText = + m_bShowHiddenPara = false; +} + +SwElemItem::SwElemItem(const SwViewOption& rVOpt) : + SfxPoolItem( FN_PARAM_ELEM ) +{ + m_bVertRuler = rVOpt.IsViewVRuler(true); + m_bVertRulerRight = rVOpt.IsVRulerRight(); + m_bCrosshair = rVOpt.IsCrossHair(); + m_bSmoothScroll = rVOpt.IsSmoothScroll(); + m_bTable = rVOpt.IsTable(); + m_bGraphic = rVOpt.IsGraphic(); + m_bDrawing = rVOpt.IsDraw() && rVOpt.IsControl(); + m_bNotes = rVOpt.IsPostIts(); + m_bShowInlineTooltips = rVOpt.IsShowInlineTooltips(); + m_bShowOutlineContentVisibilityButton = rVOpt.IsShowOutlineContentVisibilityButton(); + m_bTreatSubOutlineLevelsAsContent = rVOpt.IsTreatSubOutlineLevelsAsContent(); + m_bShowChangesInMargin = rVOpt.IsShowChangesInMargin(); + m_bFieldHiddenText = rVOpt.IsShowHiddenField(); + m_bShowHiddenPara = rVOpt.IsShowHiddenPara(); +} + +SwElemItem* SwElemItem::Clone( SfxItemPool* ) const +{ + return new SwElemItem( *this ); +} + +bool SwElemItem::operator==( const SfxPoolItem& rAttr ) const +{ + assert(SfxPoolItem::operator==(rAttr)); + + const SwElemItem& rItem = static_cast<const SwElemItem&>(rAttr); + + return ( m_bVertRuler == rItem.m_bVertRuler && + m_bVertRulerRight == rItem.m_bVertRulerRight&& + m_bCrosshair == rItem.m_bCrosshair && + m_bSmoothScroll == rItem.m_bSmoothScroll && + m_bTable == rItem.m_bTable && + m_bGraphic == rItem.m_bGraphic && + m_bDrawing == rItem.m_bDrawing && + m_bNotes == rItem.m_bNotes && + m_bShowInlineTooltips == rItem.m_bShowInlineTooltips && + m_bShowOutlineContentVisibilityButton == rItem.m_bShowOutlineContentVisibilityButton && + m_bTreatSubOutlineLevelsAsContent == rItem.m_bTreatSubOutlineLevelsAsContent && + m_bShowChangesInMargin == rItem.m_bShowChangesInMargin && + m_bFieldHiddenText == rItem.m_bFieldHiddenText && + m_bShowHiddenPara == rItem.m_bShowHiddenPara); +} + +void SwElemItem::FillViewOptions( SwViewOption& rVOpt) const +{ + rVOpt.SetViewVRuler(m_bVertRuler ); + rVOpt.SetVRulerRight(m_bVertRulerRight ); + rVOpt.SetCrossHair(m_bCrosshair ); + rVOpt.SetSmoothScroll(m_bSmoothScroll); + rVOpt.SetTable (m_bTable ); + rVOpt.SetGraphic (m_bGraphic ); + rVOpt.SetDraw (m_bDrawing ); + rVOpt.SetControl (m_bDrawing ); + rVOpt.SetPostIts (m_bNotes ); + rVOpt.SetShowInlineTooltips( m_bShowInlineTooltips ); + rVOpt.SetShowOutlineContentVisibilityButton(m_bShowOutlineContentVisibilityButton); + rVOpt.SetTreatSubOutlineLevelsAsContent(m_bTreatSubOutlineLevelsAsContent); + rVOpt.SetShowChangesInMargin( m_bShowChangesInMargin ); + rVOpt.SetShowHiddenField(m_bFieldHiddenText ); + rVOpt.SetShowHiddenPara(m_bShowHiddenPara ); +} + +// CTOR for empty Item +SwAddPrinterItem::SwAddPrinterItem(): + SfxPoolItem(FN_PARAM_ADDPRINTER) +{ +} + +// CTOR from SwPrintOptions +SwAddPrinterItem::SwAddPrinterItem( const SwPrintData& rPrtData ) : + SfxPoolItem(FN_PARAM_ADDPRINTER) +{ + SwPrintData::operator=(rPrtData); +} + +SwAddPrinterItem* SwAddPrinterItem::Clone( SfxItemPool* ) const +{ + return new SwAddPrinterItem( *this ); +} + +bool SwAddPrinterItem::operator==( const SfxPoolItem& rAttr ) const +{ + assert(SfxPoolItem::operator==(rAttr)); + + const SwAddPrinterItem& rItem = static_cast<const SwAddPrinterItem&>(rAttr); + + return SwPrintData::operator==(rItem); +} + +// Item for Settings dialog, ShadowCursorPage +SwShadowCursorItem::SwShadowCursorItem() + : SfxPoolItem( FN_PARAM_SHADOWCURSOR ), + m_eMode( SwFillMode::Tab ) + ,m_bOn( false ) +{ +} + +SwShadowCursorItem::SwShadowCursorItem( const SwViewOption& rVOpt ) + : SfxPoolItem( FN_PARAM_SHADOWCURSOR ), + m_eMode( rVOpt.GetShdwCursorFillMode() ) + ,m_bOn( rVOpt.IsShadowCursor() ) + +{ +} + +SwShadowCursorItem* SwShadowCursorItem::Clone( SfxItemPool* ) const +{ + return new SwShadowCursorItem( *this ); +} + +bool SwShadowCursorItem::operator==( const SfxPoolItem& rCmp ) const +{ + return SfxPoolItem::operator==(rCmp) && + IsOn() == static_cast<const SwShadowCursorItem&>(rCmp).IsOn() && + GetMode() == static_cast<const SwShadowCursorItem&>(rCmp).GetMode(); +} + +void SwShadowCursorItem::FillViewOptions( SwViewOption& rVOpt ) const +{ + rVOpt.SetShadowCursor( m_bOn ); + rVOpt.SetShdwCursorFillMode( m_eMode ); +} + +#ifdef DBG_UTIL +SwTestItem* SwTestItem::Clone( SfxItemPool* ) const +{ + return new SwTestItem( *this ); +} + +bool SwTestItem::operator==( const SfxPoolItem& rAttr ) const +{ + assert(SfxPoolItem::operator==(rAttr)); + + const SwTestItem& rItem = static_cast<const SwTestItem&>( rAttr); + + return ( m_bTest1==rItem.m_bTest1&& + m_bTest2==rItem.m_bTest2&& + m_bTest3==rItem.m_bTest3&& + m_bTest4==rItem.m_bTest4&& + m_bTest5==rItem.m_bTest5&& + m_bTest6==rItem.m_bTest6&& + m_bTest7==rItem.m_bTest7&& + m_bTest8==rItem.m_bTest8&& + m_bTest9==rItem.m_bTest9&& + m_bTest10==rItem.m_bTest10); +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/config/dbconfig.cxx b/sw/source/uibase/config/dbconfig.cxx new file mode 100644 index 000000000..863593163 --- /dev/null +++ b/sw/source/uibase/config/dbconfig.cxx @@ -0,0 +1,99 @@ +/* -*- 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 <dbconfig.hxx> +#include <osl/diagnose.h> +#include <com/sun/star/uno/Sequence.hxx> +#include <swdbdata.hxx> + +using namespace utl; +using namespace com::sun::star::uno; + +const Sequence<OUString>& SwDBConfig::GetPropertyNames() +{ + static Sequence<OUString> aNames { + "AddressBook/DataSourceName", // 0 + "AddressBook/Command", // 1 + "AddressBook/CommandType", // 2 + "Bibliography/CurrentDataSource/DataSourceName", // 4 + "Bibliography/CurrentDataSource/Command", // 5 + "Bibliography/CurrentDataSource/CommandType" // 6 + }; + return aNames; +} + +SwDBConfig::SwDBConfig() : + ConfigItem("Office.DataAccess", ConfigItemMode::ReleaseTree) +{ +}; + +SwDBConfig::~SwDBConfig() +{ + m_pAdrImpl.reset(); + m_pBibImpl.reset(); +} + +void SwDBConfig::Load() +{ + const Sequence<OUString>& rNames = GetPropertyNames(); + if(!m_pAdrImpl) + { + m_pAdrImpl.reset(new SwDBData); + m_pAdrImpl->nCommandType = 0; + m_pBibImpl.reset(new SwDBData); + m_pBibImpl->nCommandType = 0; + } + Sequence<Any> aValues = GetProperties(rNames); + const Any* pValues = aValues.getConstArray(); + OSL_ENSURE(aValues.getLength() == rNames.getLength(), "GetProperties failed"); + if(aValues.getLength() != rNames.getLength()) + return; + + for(int nProp = 0; nProp < rNames.getLength(); nProp++) + { + switch(nProp) + { + case 0: pValues[nProp] >>= m_pAdrImpl->sDataSource; break; + case 1: pValues[nProp] >>= m_pAdrImpl->sCommand; break; + case 2: pValues[nProp] >>= m_pAdrImpl->nCommandType; break; + case 3: pValues[nProp] >>= m_pBibImpl->sDataSource; break; + case 4: pValues[nProp] >>= m_pBibImpl->sCommand; break; + case 5: pValues[nProp] >>= m_pBibImpl->nCommandType; break; + } + } +} + +const SwDBData& SwDBConfig::GetAddressSource() +{ + if(!m_pAdrImpl) + Load(); + return *m_pAdrImpl; +} + +const SwDBData& SwDBConfig::GetBibliographySource() +{ + if(!m_pBibImpl) + Load(); + return *m_pBibImpl; +} + +void SwDBConfig::ImplCommit() {} +void SwDBConfig::Notify( const css::uno::Sequence< OUString >& ) {} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/config/fontcfg.cxx b/sw/source/uibase/config/fontcfg.cxx new file mode 100644 index 000000000..bd57d81e9 --- /dev/null +++ b/sw/source/uibase/config/fontcfg.cxx @@ -0,0 +1,310 @@ +/* -*- 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 <fontcfg.hxx> +#include <i18nlangtag/mslangid.hxx> +#include <osl/diagnose.h> +#include <tools/UnitConversion.hxx> +#include <vcl/outdev.hxx> +#include <unotools/configmgr.hxx> +#include <unotools/lingucfg.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/i18n/ScriptType.hpp> + +using namespace utl; +using namespace com::sun::star::uno; + +static LanguageType lcl_LanguageOfType(sal_Int16 nType, LanguageType eWestern, LanguageType eCJK, LanguageType eCTL) +{ + return nType < FONT_STANDARD_CJK + ? eWestern + : nType >= FONT_STANDARD_CTL ? eCTL : eCJK; +} + +Sequence<OUString> const & SwStdFontConfig::GetPropertyNames() +{ + static Sequence<OUString> aNames { + "DefaultFont/Standard", // 0 + "DefaultFont/Heading", // 1 + "DefaultFont/List", // 2 + "DefaultFont/Caption", // 3 + "DefaultFont/Index", // 4 + "DefaultFontCJK/Standard", // 5 + "DefaultFontCJK/Heading", // 6 + "DefaultFontCJK/List", // 7 + "DefaultFontCJK/Caption", // 8 + "DefaultFontCJK/Index", // 9 + "DefaultFontCTL/Standard", // 10 + "DefaultFontCTL/Heading", // 11 + "DefaultFontCTL/List", // 12 + "DefaultFontCTL/Caption", // 13 + "DefaultFontCTL/Index", // 14 + "DefaultFont/StandardHeight", // 15 + "DefaultFont/HeadingHeight", // 16 + "DefaultFont/ListHeight", // 17 + "DefaultFont/CaptionHeight", // 18 + "DefaultFont/IndexHeight", // 19 + "DefaultFontCJK/StandardHeight", // 20 + "DefaultFontCJK/HeadingHeight", // 21 + "DefaultFontCJK/ListHeight", // 22 + "DefaultFontCJK/CaptionHeight", // 23 + "DefaultFontCJK/IndexHeight", // 24 + "DefaultFontCTL/StandardHeight", // 25 + "DefaultFontCTL/HeadingHeight", // 26 + "DefaultFontCTL/ListHeight", // 27 + "DefaultFontCTL/CaptionHeight", // 28 + "DefaultFontCTL/IndexHeight" // 29 + }; + return aNames; +} + +SwStdFontConfig::SwStdFontConfig() : + utl::ConfigItem("Office.Writer") +{ + SvtLinguOptions aLinguOpt; + + if (!utl::ConfigManager::IsFuzzing()) + SvtLinguConfig().GetOptions( aLinguOpt ); + + LanguageType eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, css::i18n::ScriptType::LATIN), + eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, css::i18n::ScriptType::ASIAN), + eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, css::i18n::ScriptType::COMPLEX); + + for(sal_Int16 i = 0; i < DEF_FONT_COUNT; i++) + { + m_sDefaultFonts[i] = GetDefaultFor(i, + lcl_LanguageOfType(i, eWestern, eCJK, eCTL)); + m_nDefaultFontHeight[i] = -1; + } + + Sequence<OUString> aNames = GetPropertyNames(); + Sequence<Any> aValues = GetProperties(aNames); + const Any* pValues = aValues.getConstArray(); + OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); + if(aValues.getLength() != aNames.getLength()) + return; + + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + if(pValues[nProp].hasValue()) + { + if( nProp < DEF_FONT_COUNT) + { + OUString sVal; + pValues[nProp] >>= sVal; + m_sDefaultFonts[nProp] = sVal; + } + else + { + pValues[nProp] >>= m_nDefaultFontHeight[nProp - DEF_FONT_COUNT]; + m_nDefaultFontHeight[nProp - DEF_FONT_COUNT] = o3tl::toTwips(m_nDefaultFontHeight[nProp - DEF_FONT_COUNT], o3tl::Length::mm100); + } + } + } +} + +void SwStdFontConfig::ImplCommit() +{ + Sequence<OUString> aNames = GetPropertyNames(); + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + SvtLinguOptions aLinguOpt; + + SvtLinguConfig().GetOptions( aLinguOpt ); + + LanguageType eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, css::i18n::ScriptType::LATIN), + eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, css::i18n::ScriptType::ASIAN), + eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, css::i18n::ScriptType::COMPLEX); + + for(sal_uInt16 nProp = 0; + nProp < sal::static_int_cast< sal_uInt16, sal_Int32 >( aNames.getLength() ); + nProp++) + { + if( nProp < DEF_FONT_COUNT ) + { + if(GetDefaultFor(nProp, lcl_LanguageOfType(nProp, eWestern, eCJK, eCTL)) != m_sDefaultFonts[nProp]) + pValues[nProp] <<= m_sDefaultFonts[nProp]; + } + else + { + if(m_nDefaultFontHeight[nProp - DEF_FONT_COUNT] > 0) + pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(m_nDefaultFontHeight[nProp - DEF_FONT_COUNT])); + } + } + PutProperties(aNames, aValues); +} + +SwStdFontConfig::~SwStdFontConfig() +{ +} + +bool SwStdFontConfig::IsFontDefault(sal_uInt16 nFontType) const +{ + bool bSame = false; + SvtLinguOptions aLinguOpt; + + if (!utl::ConfigManager::IsFuzzing()) + SvtLinguConfig().GetOptions(aLinguOpt); + + LanguageType eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, css::i18n::ScriptType::LATIN), + eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, css::i18n::ScriptType::ASIAN), + eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, css::i18n::ScriptType::COMPLEX); + + OUString sDefFont(GetDefaultFor(FONT_STANDARD, eWestern)); + OUString sDefFontCJK(GetDefaultFor(FONT_STANDARD_CJK, eCJK)); + OUString sDefFontCTL(GetDefaultFor(FONT_STANDARD_CTL, eCTL)); + LanguageType eLang = lcl_LanguageOfType(nFontType, eWestern, eCJK, eCTL); + switch( nFontType ) + { + case FONT_STANDARD: + bSame = m_sDefaultFonts[nFontType] == sDefFont; + break; + case FONT_STANDARD_CJK: + bSame = m_sDefaultFonts[nFontType] == sDefFontCJK; + break; + case FONT_STANDARD_CTL: + bSame = m_sDefaultFonts[nFontType] == sDefFontCTL; + break; + case FONT_OUTLINE : + case FONT_OUTLINE_CJK : + case FONT_OUTLINE_CTL : + bSame = m_sDefaultFonts[nFontType] == + GetDefaultFor(nFontType, eLang); + break; + case FONT_LIST : + case FONT_CAPTION : + case FONT_INDEX : + bSame = m_sDefaultFonts[nFontType] == sDefFont && + m_sDefaultFonts[FONT_STANDARD] == sDefFont; + break; + case FONT_LIST_CJK : + case FONT_CAPTION_CJK : + case FONT_INDEX_CJK : + { + bool b1 = m_sDefaultFonts[FONT_STANDARD_CJK] == sDefFontCJK; + bSame = b1 && m_sDefaultFonts[nFontType] == sDefFontCJK; + } + break; + case FONT_LIST_CTL : + case FONT_CAPTION_CTL : + case FONT_INDEX_CTL : + { + bool b1 = m_sDefaultFonts[FONT_STANDARD_CJK] == sDefFontCTL; + bSame = b1 && m_sDefaultFonts[nFontType] == sDefFontCTL; + } + break; + } + return bSame; +} + +OUString SwStdFontConfig::GetDefaultFor(sal_uInt16 nFontType, LanguageType eLang) +{ + DefaultFontType nFontId; + switch( nFontType ) + { + case FONT_OUTLINE : + nFontId = DefaultFontType::LATIN_HEADING; + break; + case FONT_OUTLINE_CJK : + nFontId = DefaultFontType::CJK_HEADING; + break; + case FONT_OUTLINE_CTL : + nFontId = DefaultFontType::CTL_HEADING; + break; + case FONT_STANDARD_CJK: + case FONT_LIST_CJK : + case FONT_CAPTION_CJK : + case FONT_INDEX_CJK : + nFontId = DefaultFontType::CJK_TEXT; + break; + case FONT_STANDARD_CTL: + case FONT_LIST_CTL : + case FONT_CAPTION_CTL : + case FONT_INDEX_CTL : + nFontId = DefaultFontType::CTL_TEXT; + break; + default: + nFontId = DefaultFontType::LATIN_TEXT; + } + vcl::Font aFont = OutputDevice::GetDefaultFont(nFontId, eLang, GetDefaultFontFlags::OnlyOne); + return aFont.GetFamilyName(); +} + +sal_Int32 SwStdFontConfig::GetDefaultHeightFor(sal_uInt16 nFontType, LanguageType eLang) +{ + sal_Int32 nRet = FONTSIZE_DEFAULT; + switch( nFontType ) + { + case FONT_OUTLINE: + case FONT_OUTLINE_CJK: + case FONT_OUTLINE_CTL: + nRet = FONTSIZE_OUTLINE; + break; + case FONT_STANDARD_CJK: + nRet = FONTSIZE_CJK_DEFAULT; + break; + } + if( eLang == LANGUAGE_THAI && nFontType >= FONT_STANDARD_CTL ) + { + nRet = nRet * 4 / 3; + } + return nRet; +} + +void SwStdFontConfig::ChangeInt( sal_uInt16 nFontType, sal_Int32 nHeight ) +{ + OSL_ENSURE( nFontType < DEF_FONT_COUNT, "invalid index in SwStdFontConfig::ChangeInt()"); + if( nFontType >= DEF_FONT_COUNT || m_nDefaultFontHeight[nFontType] == nHeight) + return; + + SvtLinguOptions aLinguOpt; + if (!utl::ConfigManager::IsFuzzing()) + SvtLinguConfig().GetOptions( aLinguOpt ); + + LanguageType eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, css::i18n::ScriptType::LATIN), + eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, css::i18n::ScriptType::ASIAN), + eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, css::i18n::ScriptType::COMPLEX); + + // #i92090# default height value sets back to -1 + const sal_Int32 nDefaultHeight = GetDefaultHeightFor(nFontType, lcl_LanguageOfType(nFontType, eWestern, eCJK, eCTL)); + const bool bIsDefaultHeight = nHeight == nDefaultHeight; + if( bIsDefaultHeight && m_nDefaultFontHeight[nFontType] > 0 ) + { + SetModified(); + m_nDefaultFontHeight[nFontType] = -1; + } + else if( !bIsDefaultHeight && nHeight != m_nDefaultFontHeight[nFontType] ) + { + SetModified(); + m_nDefaultFontHeight[nFontType] = nHeight; + } +} + +sal_Int32 SwStdFontConfig::GetFontHeight( sal_uInt8 nFont, sal_uInt8 nScriptType, LanguageType eLang ) +{ + OSL_ENSURE(nFont + FONT_PER_GROUP * nScriptType < DEF_FONT_COUNT, "wrong index in SwStdFontConfig::GetFontHeight()"); + sal_Int32 nRet = m_nDefaultFontHeight[nFont + FONT_PER_GROUP * nScriptType]; + if(nRet <= 0) + return GetDefaultHeightFor(nFont + FONT_PER_GROUP * nScriptType, eLang); + return nRet; +} + +void SwStdFontConfig::Notify( const css::uno::Sequence< OUString >& ) {} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/config/modcfg.cxx b/sw/source/uibase/config/modcfg.cxx new file mode 100644 index 000000000..2b80d8127 --- /dev/null +++ b/sw/source/uibase/config/modcfg.cxx @@ -0,0 +1,1336 @@ +/* -*- 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 <memory> +#include <comphelper/classids.hxx> +#include <o3tl/any.hxx> +#include <tools/fontenum.hxx> +#include <editeng/svxenum.hxx> +#include <editeng/editids.hrc> +#include <osl/diagnose.h> +#include <rtl/ustrbuf.hxx> +#include <svl/typedwhich.hxx> + +#include <tools/globname.hxx> +#include <tools/UnitConversion.hxx> +#include <itabenum.hxx> +#include <modcfg.hxx> +#include <caption.hxx> + +using namespace com::sun::star::uno; + +#define GLOB_NAME_CALC 0 +#define GLOB_NAME_IMPRESS 1 +#define GLOB_NAME_DRAW 2 +#define GLOB_NAME_MATH 3 +#define GLOB_NAME_CHART 4 + +InsCaptionOpt* InsCaptionOptArr::Find(const SwCapObjType eType, const SvGlobalName *pOleId) +{ + for (auto const& it : m_InsCapOptArr) + { + InsCaptionOpt &rObj = *it; + if (rObj.GetObjType() == eType && (eType != OLE_CAP || (pOleId && rObj.GetOleId() == *pOleId))) + return &rObj; + } + + return nullptr; +} + +void InsCaptionOptArr::Insert(InsCaptionOpt* pObj) +{ + m_InsCapOptArr.push_back(std::unique_ptr<InsCaptionOpt>(pObj)); //takes ownership +} + +const InsCaptionOpt* SwModuleOptions::GetCapOption( + bool bHTML, const SwCapObjType eType, const SvGlobalName *pOleId) +{ + if(bHTML) + { + OSL_FAIL("no caption option in sw/web!"); + return nullptr; + } + else + { + if(eType == OLE_CAP && pOleId) + { + bool bFound = false; + for( sal_uInt16 nId = 0; nId <= GLOB_NAME_CHART && !bFound; nId++) + bFound = *pOleId == m_aInsertConfig.m_aGlobalNames[nId ]; + if(!bFound) + return m_aInsertConfig.m_pOLEMiscOpt.get(); + } + return m_aInsertConfig.m_pCapOptions->Find(eType, pOleId); + } +} + +bool SwModuleOptions::SetCapOption(bool bHTML, const InsCaptionOpt* pOpt) +{ + bool bRet = false; + + if(bHTML) + { + OSL_FAIL("no caption option in sw/web!"); + } + else if (pOpt) + { + if(pOpt->GetObjType() == OLE_CAP) + { + bool bFound = false; + for( sal_uInt16 nId = 0; nId <= GLOB_NAME_CHART; nId++) + bFound = pOpt->GetOleId() == m_aInsertConfig.m_aGlobalNames[nId ]; + if(!bFound) + { + if(m_aInsertConfig.m_pOLEMiscOpt) + *m_aInsertConfig.m_pOLEMiscOpt = *pOpt; + else + m_aInsertConfig.m_pOLEMiscOpt.reset(new InsCaptionOpt(*pOpt)); + } + } + + InsCaptionOptArr& rArr = *m_aInsertConfig.m_pCapOptions; + InsCaptionOpt *pObj = rArr.Find(pOpt->GetObjType(), &pOpt->GetOleId()); + + if (pObj) + { + *pObj = *pOpt; + } + else + rArr.Insert(new InsCaptionOpt(*pOpt)); + + m_aInsertConfig.SetModified(); + bRet = true; + } + + return bRet; +} + +SwModuleOptions::SwModuleOptions() : + m_aInsertConfig(false), + m_aWebInsertConfig(true), + m_aTableConfig(false), + m_aWebTableConfig(true), + m_bHideFieldTips(false) +{ +} + +OUString SwModuleOptions::ConvertWordDelimiter(const OUString& rDelim, bool bFromUI) +{ + OUStringBuffer sReturn; + const sal_Int32 nDelimLen = rDelim.getLength(); + if(bFromUI) + { + for (sal_Int32 i = 0; i < nDelimLen; ) + { + const sal_Unicode c = rDelim[i++]; + + if (c == '\\' && i < nDelimLen ) + { + switch (rDelim[i++]) + { + case 'n': sReturn.append("\n"); break; + case 't': sReturn.append("\t"); break; + case '\\': sReturn.append("\\"); break; + + case 'x': + { + sal_Unicode nChar = 0; + bool bValidData = true; + for( sal_Int32 n = 0; n < 2 && i < nDelimLen; ++n, ++i ) + { + sal_Unicode nVal = rDelim[i]; + if( (nVal >= '0') && ( nVal <= '9') ) + nVal -= '0'; + else if( (nVal >= 'A') && (nVal <= 'F') ) + nVal -= 'A' - 10; + else if( (nVal >= 'a') && (nVal <= 'f') ) + nVal -= 'a' - 10; + else + { + OSL_FAIL("wrong hex value" ); + bValidData = false; + break; + } + + nChar <<= 4; + nChar += nVal; + } + if( bValidData ) + sReturn.append(nChar); + break; + } + + default: // Unknown, so insert backslash + sReturn.append("\\"); + i--; + break; + } + } + else + sReturn.append(c); + } + } + else + { + for (sal_Int32 i = 0; i < nDelimLen; ++i) + { + const sal_Unicode c = rDelim[i]; + + switch (c) + { + case '\n': sReturn.append("\\n"); break; + case '\t': sReturn.append("\\t"); break; + case '\\': sReturn.append("\\\\"); break; + + default: + if( c <= 0x1f || c >= 0x7f ) + { + sReturn.append("\\x" + OUString::number( static_cast<sal_Int32>(c), 16 )); + } + else + { + sReturn.append(c); + } + } + } + } + return sReturn.makeStringAndClear(); +} + +const Sequence<OUString>& SwRevisionConfig::GetPropertyNames() +{ + static Sequence<OUString> const aNames + { + "TextDisplay/Insert/Attribute", // 0 + "TextDisplay/Insert/Color", // 1 + "TextDisplay/Delete/Attribute", // 2 + "TextDisplay/Delete/Color", // 3 + "TextDisplay/ChangedAttribute/Attribute", // 4 + "TextDisplay/ChangedAttribute/Color", // 5 + "LinesChanged/Mark", // 6 + "LinesChanged/Color" // 7 + }; + return aNames; +} + +SwRevisionConfig::SwRevisionConfig() + : ConfigItem("Office.Writer/Revision", ConfigItemMode::ReleaseTree) + , m_nMarkAlign(0) +{ + m_aInsertAttr.m_nItemId = SID_ATTR_CHAR_UNDERLINE; + m_aInsertAttr.m_nAttr = LINESTYLE_SINGLE; + m_aInsertAttr.m_nColor = COL_TRANSPARENT; + m_aDeletedAttr.m_nItemId = SID_ATTR_CHAR_STRIKEOUT; + // coverity[mixed_enums : FALSE] - unhelpfully warns different enum than LINESTYLE_SINGLE above + m_aDeletedAttr.m_nAttr = STRIKEOUT_SINGLE; + m_aDeletedAttr.m_nColor = COL_TRANSPARENT; + m_aFormatAttr.m_nItemId = SID_ATTR_CHAR_WEIGHT; + // coverity[mixed_enums : FALSE] - unhelpfully warns different enum than STRIKEOUT_SINGLE above + m_aFormatAttr.m_nAttr = WEIGHT_BOLD; + m_aFormatAttr.m_nColor = COL_BLACK; + Load(); +} + +SwRevisionConfig::~SwRevisionConfig() +{ +} + +static sal_Int32 lcl_ConvertAttrToCfg(const AuthorCharAttr& rAttr) +{ + sal_Int32 nRet = 0; + switch(rAttr.m_nItemId) + { + case SID_ATTR_CHAR_WEIGHT: nRet = 1; break; + case SID_ATTR_CHAR_POSTURE: nRet = 2; break; + case SID_ATTR_CHAR_UNDERLINE: nRet = LINESTYLE_SINGLE == rAttr.m_nAttr ? 3 : 4; break; + case SID_ATTR_CHAR_STRIKEOUT: nRet = 3; break; + case SID_ATTR_CHAR_CASEMAP: + { + switch(static_cast<SvxCaseMap>(rAttr.m_nAttr)) + { + case SvxCaseMap::Uppercase : nRet = 5;break; + case SvxCaseMap::Lowercase : nRet = 6;break; + case SvxCaseMap::SmallCaps : nRet = 7;break; + case SvxCaseMap::Capitalize: nRet = 8;break; + default: break; + } + } + break; + case SID_ATTR_BRUSH : nRet = 9; break; + } + return nRet; +} + +void SwRevisionConfig::Notify( const css::uno::Sequence< OUString >& ) {} + +void SwRevisionConfig::ImplCommit() +{ + const Sequence<OUString>& aNames = GetPropertyNames(); + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + switch(nProp) + { + case 0 : pValues[nProp] <<= lcl_ConvertAttrToCfg(m_aInsertAttr); break; + case 1 : pValues[nProp] <<= m_aInsertAttr.m_nColor; break; + case 2 : pValues[nProp] <<= lcl_ConvertAttrToCfg(m_aDeletedAttr); break; + case 3 : pValues[nProp] <<= m_aDeletedAttr.m_nColor; break; + case 4 : pValues[nProp] <<= lcl_ConvertAttrToCfg(m_aFormatAttr); break; + case 5 : pValues[nProp] <<= m_aFormatAttr.m_nColor; break; + case 6 : pValues[nProp] <<= m_nMarkAlign; break; + case 7 : pValues[nProp] <<= m_aMarkColor; break; + } + } + PutProperties(aNames, aValues); +} + +static void lcl_ConvertCfgToAttr(sal_Int32 nVal, AuthorCharAttr& rAttr, bool bDelete = false) +{ + rAttr.m_nItemId = rAttr.m_nAttr = 0; + switch(nVal) + { + case 1: rAttr.m_nItemId = SID_ATTR_CHAR_WEIGHT; rAttr.m_nAttr = WEIGHT_BOLD ; break; + case 2: rAttr.m_nItemId = SID_ATTR_CHAR_POSTURE; rAttr.m_nAttr = ITALIC_NORMAL ; break; + case 3: if(bDelete) + { + rAttr.m_nItemId = SID_ATTR_CHAR_STRIKEOUT; + rAttr.m_nAttr = STRIKEOUT_SINGLE; + } + else + { + rAttr.m_nItemId = SID_ATTR_CHAR_UNDERLINE; + rAttr.m_nAttr = LINESTYLE_SINGLE; + } + break; + case 4: rAttr.m_nItemId = SID_ATTR_CHAR_UNDERLINE;rAttr.m_nAttr = LINESTYLE_DOUBLE ; break; + case 5: rAttr.m_nItemId = SID_ATTR_CHAR_CASEMAP; rAttr.m_nAttr = sal_uInt16(SvxCaseMap::Uppercase); break; + case 6: rAttr.m_nItemId = SID_ATTR_CHAR_CASEMAP; rAttr.m_nAttr = sal_uInt16(SvxCaseMap::Lowercase); break; + case 7: rAttr.m_nItemId = SID_ATTR_CHAR_CASEMAP; rAttr.m_nAttr = sal_uInt16(SvxCaseMap::SmallCaps); break; + case 8: rAttr.m_nItemId = SID_ATTR_CHAR_CASEMAP; rAttr.m_nAttr = sal_uInt16(SvxCaseMap::Capitalize); break; + case 9: rAttr.m_nItemId = SID_ATTR_BRUSH; break; + } +} +void SwRevisionConfig::Load() +{ + const Sequence<OUString>& aNames = GetPropertyNames(); + Sequence<Any> aValues = GetProperties(aNames); + const Any* pValues = aValues.getConstArray(); + assert(aValues.getLength() == aNames.getLength()); + for (sal_Int32 nProp = 0; nProp < aNames.getLength(); ++nProp) + { + if (pValues[nProp].hasValue()) + { + sal_Int32 nVal = 0; + pValues[nProp] >>= nVal; + switch (nProp) + { + case 0 : lcl_ConvertCfgToAttr(nVal, m_aInsertAttr); break; + case 1 : m_aInsertAttr.m_nColor = Color(ColorTransparency, nVal); break; + case 2 : lcl_ConvertCfgToAttr(nVal, m_aDeletedAttr, true); break; + case 3 : m_aDeletedAttr.m_nColor = Color(ColorTransparency, nVal); break; + case 4 : lcl_ConvertCfgToAttr(nVal, m_aFormatAttr); break; + case 5 : m_aFormatAttr.m_nColor = Color(ColorTransparency, nVal); break; + case 6 : m_nMarkAlign = sal::static_int_cast< sal_uInt16, sal_Int32>(nVal); break; + case 7 : m_aMarkColor = Color(ColorTransparency, nVal); break; + } + } + } +} + +namespace { + +enum InsertConfigProp +{ + INS_PROP_TABLE_HEADER = 0, + INS_PROP_TABLE_REPEATHEADER, // 1 + INS_PROP_TABLE_BORDER, // 2 + INS_PROP_TABLE_SPLIT, // 3 from here not in writer/web + INS_PROP_CAP_AUTOMATIC, // 4 + INS_PROP_CAP_CAPTIONORDERNUMBERINGFIRST, // 5 + INS_PROP_CAP_OBJECT_TABLE_ENABLE, // 6 + INS_PROP_CAP_OBJECT_TABLE_CATEGORY, // 7 + INS_PROP_CAP_OBJECT_TABLE_NUMBERING, // 8 + INS_PROP_CAP_OBJECT_TABLE_NUMBERINGSEPARATOR, // 9 + INS_PROP_CAP_OBJECT_TABLE_CAPTIONTEXT, //10 + INS_PROP_CAP_OBJECT_TABLE_DELIMITER, //11 + INS_PROP_CAP_OBJECT_TABLE_LEVEL, //12 + INS_PROP_CAP_OBJECT_TABLE_POSITION, //13 + INS_PROP_CAP_OBJECT_TABLE_CHARACTERSTYLE, //14 + INS_PROP_CAP_OBJECT_FRAME_ENABLE, //15 + INS_PROP_CAP_OBJECT_FRAME_CATEGORY, //16 + INS_PROP_CAP_OBJECT_FRAME_NUMBERING, //17 + INS_PROP_CAP_OBJECT_FRAME_NUMBERINGSEPARATOR, //18 + INS_PROP_CAP_OBJECT_FRAME_CAPTIONTEXT, //19 + INS_PROP_CAP_OBJECT_FRAME_DELIMITER, //20 + INS_PROP_CAP_OBJECT_FRAME_LEVEL, //21 + INS_PROP_CAP_OBJECT_FRAME_POSITION, //22 + INS_PROP_CAP_OBJECT_FRAME_CHARACTERSTYLE, //23 + INS_PROP_CAP_OBJECT_GRAPHIC_ENABLE, //24 + INS_PROP_CAP_OBJECT_GRAPHIC_CATEGORY, //25 + INS_PROP_CAP_OBJECT_GRAPHIC_NUMBERING, //26 + INS_PROP_CAP_OBJECT_GRAPHIC_NUMBERINGSEPARATOR, //27 + INS_PROP_CAP_OBJECT_GRAPHIC_CAPTIONTEXT, //28 + INS_PROP_CAP_OBJECT_GRAPHIC_DELIMITER, //29 + INS_PROP_CAP_OBJECT_GRAPHIC_LEVEL, //30 + INS_PROP_CAP_OBJECT_GRAPHIC_POSITION, //31 + INS_PROP_CAP_OBJECT_GRAPHIC_CHARACTERSTYLE, //32 + INS_PROP_CAP_OBJECT_GRAPHIC_APPLYATTRIBUTES, //33 + INS_PROP_CAP_OBJECT_CALC_ENABLE, //34 + INS_PROP_CAP_OBJECT_CALC_CATEGORY, //35 + INS_PROP_CAP_OBJECT_CALC_NUMBERING, //36 + INS_PROP_CAP_OBJECT_CALC_NUMBERINGSEPARATOR, //37 + INS_PROP_CAP_OBJECT_CALC_CAPTIONTEXT, //38 + INS_PROP_CAP_OBJECT_CALC_DELIMITER, //39 + INS_PROP_CAP_OBJECT_CALC_LEVEL, //40 + INS_PROP_CAP_OBJECT_CALC_POSITION, //41 + INS_PROP_CAP_OBJECT_CALC_CHARACTERSTYLE, //42 + INS_PROP_CAP_OBJECT_CALC_APPLYATTRIBUTES, //43 + INS_PROP_CAP_OBJECT_IMPRESS_ENABLE, //44 + INS_PROP_CAP_OBJECT_IMPRESS_CATEGORY, //45 + INS_PROP_CAP_OBJECT_IMPRESS_NUMBERING, //46 + INS_PROP_CAP_OBJECT_IMPRESS_NUMBERINGSEPARATOR, //47 + INS_PROP_CAP_OBJECT_IMPRESS_CAPTIONTEXT, //48 + INS_PROP_CAP_OBJECT_IMPRESS_DELIMITER, //49 + INS_PROP_CAP_OBJECT_IMPRESS_LEVEL, //50 + INS_PROP_CAP_OBJECT_IMPRESS_POSITION, //51 + INS_PROP_CAP_OBJECT_IMPRESS_CHARACTERSTYLE, //52 + INS_PROP_CAP_OBJECT_IMPRESS_APPLYATTRIBUTES, //53 + INS_PROP_CAP_OBJECT_CHART_ENABLE, //54 + INS_PROP_CAP_OBJECT_CHART_CATEGORY, //55 + INS_PROP_CAP_OBJECT_CHART_NUMBERING, //56 + INS_PROP_CAP_OBJECT_CHART_NUMBERINGSEPARATOR, //57 + INS_PROP_CAP_OBJECT_CHART_CAPTIONTEXT, //58 + INS_PROP_CAP_OBJECT_CHART_DELIMITER, //59 + INS_PROP_CAP_OBJECT_CHART_LEVEL, //60 + INS_PROP_CAP_OBJECT_CHART_POSITION, //61 + INS_PROP_CAP_OBJECT_CHART_CHARACTERSTYLE, //62 + INS_PROP_CAP_OBJECT_CHART_APPLYATTRIBUTES, //63 + INS_PROP_CAP_OBJECT_FORMULA_ENABLE, //64 + INS_PROP_CAP_OBJECT_FORMULA_CATEGORY, //65 + INS_PROP_CAP_OBJECT_FORMULA_NUMBERING, //66 + INS_PROP_CAP_OBJECT_FORMULA_NUMBERINGSEPARATOR, //67 + INS_PROP_CAP_OBJECT_FORMULA_CAPTIONTEXT, //68 + INS_PROP_CAP_OBJECT_FORMULA_DELIMITER, //69 + INS_PROP_CAP_OBJECT_FORMULA_LEVEL, //70 + INS_PROP_CAP_OBJECT_FORMULA_POSITION, //71 + INS_PROP_CAP_OBJECT_FORMULA_CHARACTERSTYLE, //72 + INS_PROP_CAP_OBJECT_FORMULA_APPLYATTRIBUTES, //73 + INS_PROP_CAP_OBJECT_DRAW_ENABLE, //74 + INS_PROP_CAP_OBJECT_DRAW_CATEGORY, //75 + INS_PROP_CAP_OBJECT_DRAW_NUMBERING, //76 + INS_PROP_CAP_OBJECT_DRAW_NUMBERINGSEPARATOR, //77 + INS_PROP_CAP_OBJECT_DRAW_CAPTIONTEXT, //78 + INS_PROP_CAP_OBJECT_DRAW_DELIMITER, //79 + INS_PROP_CAP_OBJECT_DRAW_LEVEL, //80 + INS_PROP_CAP_OBJECT_DRAW_POSITION, //81 + INS_PROP_CAP_OBJECT_DRAW_CHARACTERSTYLE, //82 + INS_PROP_CAP_OBJECT_DRAW_APPLYATTRIBUTES, //83 + INS_PROP_CAP_OBJECT_OLEMISC_ENABLE, //84 + INS_PROP_CAP_OBJECT_OLEMISC_CATEGORY, //85 + INS_PROP_CAP_OBJECT_OLEMISC_NUMBERING, //86 + INS_PROP_CAP_OBJECT_OLEMISC_NUMBERINGSEPARATOR, //87 + INS_PROP_CAP_OBJECT_OLEMISC_CAPTIONTEXT, //88 + INS_PROP_CAP_OBJECT_OLEMISC_DELIMITER, //89 + INS_PROP_CAP_OBJECT_OLEMISC_LEVEL, //90 + INS_PROP_CAP_OBJECT_OLEMISC_POSITION, //91 + INS_PROP_CAP_OBJECT_OLEMISC_CHARACTERSTYLE, //92 + INS_PROP_CAP_OBJECT_OLEMISC_APPLYATTRIBUTES //93 +}; + +} + +const Sequence<OUString>& SwInsertConfig::GetPropertyNames() const +{ + static Sequence<OUString> aNames + { + "Table/Header", // 0 + "Table/RepeatHeader", // 1 + "Table/Border", // 2 + "Table/Split", // 3 from here not in writer/web + "Caption/Automatic", // 4 + "Caption/CaptionOrderNumberingFirst", // 5 + "Caption/WriterObject/Table/Enable", // 6 + "Caption/WriterObject/Table/Settings/Category", // 7 + "Caption/WriterObject/Table/Settings/Numbering", // 8 + "Caption/WriterObject/Table/Settings/NumberingSeparator", // 9 + "Caption/WriterObject/Table/Settings/CaptionText", //10 + "Caption/WriterObject/Table/Settings/Delimiter", //11 + "Caption/WriterObject/Table/Settings/Level", //12 + "Caption/WriterObject/Table/Settings/Position", //13 + "Caption/WriterObject/Table/Settings/CharacterStyle", //14 + "Caption/WriterObject/Frame/Enable", //15 + "Caption/WriterObject/Frame/Settings/Category", //16 + "Caption/WriterObject/Frame/Settings/Numbering", //17 + "Caption/WriterObject/Frame/Settings/NumberingSeparator", //18 + "Caption/WriterObject/Frame/Settings/CaptionText", //19 + "Caption/WriterObject/Frame/Settings/Delimiter", //20 + "Caption/WriterObject/Frame/Settings/Level", //21 + "Caption/WriterObject/Frame/Settings/Position", //22 + "Caption/WriterObject/Frame/Settings/CharacterStyle", //23 + "Caption/WriterObject/Graphic/Enable", //24 + "Caption/WriterObject/Graphic/Settings/Category", //25 + "Caption/WriterObject/Graphic/Settings/Numbering", //26 + "Caption/WriterObject/Graphic/Settings/NumberingSeparator", //27 + "Caption/WriterObject/Graphic/Settings/CaptionText", //28 + "Caption/WriterObject/Graphic/Settings/Delimiter", //29 + "Caption/WriterObject/Graphic/Settings/Level", //30 + "Caption/WriterObject/Graphic/Settings/Position", //31 + "Caption/WriterObject/Graphic/Settings/CharacterStyle", //32 + "Caption/WriterObject/Graphic/Settings/ApplyAttributes", //33 + "Caption/OfficeObject/Calc/Enable", //34 + "Caption/OfficeObject/Calc/Settings/Category", //35 + "Caption/OfficeObject/Calc/Settings/Numbering", //36 + "Caption/OfficeObject/Calc/Settings/NumberingSeparator", //37 + "Caption/OfficeObject/Calc/Settings/CaptionText", //38 + "Caption/OfficeObject/Calc/Settings/Delimiter", //39 + "Caption/OfficeObject/Calc/Settings/Level", //40 + "Caption/OfficeObject/Calc/Settings/Position", //41 + "Caption/OfficeObject/Calc/Settings/CharacterStyle", //42 + "Caption/OfficeObject/Calc/Settings/ApplyAttributes", //43 + "Caption/OfficeObject/Impress/Enable", //44 + "Caption/OfficeObject/Impress/Settings/Category", //45 + "Caption/OfficeObject/Impress/Settings/Numbering", //46 + "Caption/OfficeObject/Impress/Settings/NumberingSeparator", //47 + "Caption/OfficeObject/Impress/Settings/CaptionText", //48 + "Caption/OfficeObject/Impress/Settings/Delimiter", //49 + "Caption/OfficeObject/Impress/Settings/Level", //50 + "Caption/OfficeObject/Impress/Settings/Position", //51 + "Caption/OfficeObject/Impress/Settings/CharacterStyle", //52 + "Caption/OfficeObject/Impress/Settings/ApplyAttributes", //53 + "Caption/OfficeObject/Chart/Enable", //54 + "Caption/OfficeObject/Chart/Settings/Category", //55 + "Caption/OfficeObject/Chart/Settings/Numbering", //56 + "Caption/OfficeObject/Chart/Settings/NumberingSeparator", //57 + "Caption/OfficeObject/Chart/Settings/CaptionText", //58 + "Caption/OfficeObject/Chart/Settings/Delimiter", //59 + "Caption/OfficeObject/Chart/Settings/Level", //60 + "Caption/OfficeObject/Chart/Settings/Position", //61 + "Caption/OfficeObject/Chart/Settings/CharacterStyle", //62 + "Caption/OfficeObject/Chart/Settings/ApplyAttributes", //63 + "Caption/OfficeObject/Formula/Enable", //64 + "Caption/OfficeObject/Formula/Settings/Category", //65 + "Caption/OfficeObject/Formula/Settings/Numbering", //66 + "Caption/OfficeObject/Formula/Settings/NumberingSeparator", //67 + "Caption/OfficeObject/Formula/Settings/CaptionText", //68 + "Caption/OfficeObject/Formula/Settings/Delimiter", //69 + "Caption/OfficeObject/Formula/Settings/Level", //70 + "Caption/OfficeObject/Formula/Settings/Position", //71 + "Caption/OfficeObject/Formula/Settings/CharacterStyle", //72 + "Caption/OfficeObject/Formula/Settings/ApplyAttributes", //73 + "Caption/OfficeObject/Draw/Enable", //74 + "Caption/OfficeObject/Draw/Settings/Category", //75 + "Caption/OfficeObject/Draw/Settings/Numbering", //76 + "Caption/OfficeObject/Draw/Settings/NumberingSeparator", //77 + "Caption/OfficeObject/Draw/Settings/CaptionText", //78 + "Caption/OfficeObject/Draw/Settings/Delimiter", //79 + "Caption/OfficeObject/Draw/Settings/Level", //80 + "Caption/OfficeObject/Draw/Settings/Position", //81 + "Caption/OfficeObject/Draw/Settings/CharacterStyle", //82 + "Caption/OfficeObject/Draw/Settings/ApplyAttributes", //83 + "Caption/OfficeObject/OLEMisc/Enable", //84 + "Caption/OfficeObject/OLEMisc/Settings/Category", //85 + "Caption/OfficeObject/OLEMisc/Settings/Numbering", //86 + "Caption/OfficeObject/OLEMisc/Settings/NumberingSeparator", //87 + "Caption/OfficeObject/OLEMisc/Settings/CaptionText", //88 + "Caption/OfficeObject/OLEMisc/Settings/Delimiter", //89 + "Caption/OfficeObject/OLEMisc/Settings/Level", //90 + "Caption/OfficeObject/OLEMisc/Settings/Position", //91 + "Caption/OfficeObject/OLEMisc/Settings/CharacterStyle", //92 + "Caption/OfficeObject/OLEMisc/Settings/ApplyAttributes" //93 + }; + static Sequence<OUString> const aWebNames(aNames.getArray(), INS_PROP_TABLE_BORDER + 1); + return m_bIsWeb ? aWebNames : aNames; +} + +SwInsertConfig::SwInsertConfig(bool bWeb) : + ConfigItem(bWeb ? OUString("Office.WriterWeb/Insert") : OUString("Office.Writer/Insert"), + ConfigItemMode::ReleaseTree), + m_bInsWithCaption( false ), + m_bCaptionOrderNumberingFirst( false ), + m_aInsTableOpts(SwInsertTableFlags::NONE,0), + m_bIsWeb(bWeb) +{ + m_aGlobalNames[GLOB_NAME_CALC ] = SvGlobalName(SO3_SC_CLASSID); + m_aGlobalNames[GLOB_NAME_IMPRESS] = SvGlobalName(SO3_SIMPRESS_CLASSID); + m_aGlobalNames[GLOB_NAME_DRAW ] = SvGlobalName(SO3_SDRAW_CLASSID); + m_aGlobalNames[GLOB_NAME_MATH ] = SvGlobalName(SO3_SM_CLASSID); + m_aGlobalNames[GLOB_NAME_CHART ] = SvGlobalName(SO3_SCH_CLASSID); + if(!m_bIsWeb) + m_pCapOptions.reset(new InsCaptionOptArr); + + Load(); +} + +SwInsertConfig::~SwInsertConfig() +{ + m_pCapOptions.reset(); + m_pOLEMiscOpt.reset(); +} + +static void lcl_WriteOpt(const InsCaptionOpt& rOpt, Any* pValues, sal_Int32 nProp, sal_Int32 nOffset) +{ + switch(nOffset) + { + case 0: pValues[nProp] <<= rOpt.UseCaption(); break;//Enable + case 1: pValues[nProp] <<= rOpt.GetCategory(); break;//Category + case 2: pValues[nProp] <<= static_cast<sal_Int32>(rOpt.GetNumType()); break;//Numbering", + case 3: pValues[nProp] <<= rOpt.GetNumSeparator(); break;//NumberingSeparator", + case 4: pValues[nProp] <<= rOpt.GetCaption(); break;//CaptionText", + case 5: pValues[nProp] <<= rOpt.GetSeparator();break;//Delimiter", + case 6: pValues[nProp] <<= static_cast<sal_Int32>(rOpt.GetLevel()); break;//Level", + case 7: pValues[nProp] <<= static_cast<sal_Int32>(rOpt.GetPos()); break;//Position", + case 8: pValues[nProp] <<= rOpt.GetCharacterStyle(); break; //CharacterStyle + case 9: pValues[nProp] <<= rOpt.CopyAttributes(); break; //ApplyAttributes + } +} + +void SwInsertConfig::Notify( const css::uno::Sequence< OUString >& ) {} + +void SwInsertConfig::ImplCommit() +{ + const Sequence<OUString>& aNames = GetPropertyNames(); + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + const InsCaptionOpt* pWriterTableOpt = nullptr; + const InsCaptionOpt* pWriterFrameOpt = nullptr; + const InsCaptionOpt* pWriterGraphicOpt = nullptr; + const InsCaptionOpt* pOLECalcOpt = nullptr; + const InsCaptionOpt* pOLEImpressOpt = nullptr; + const InsCaptionOpt* pOLEChartOpt = nullptr; + const InsCaptionOpt* pOLEFormulaOpt = nullptr; + const InsCaptionOpt* pOLEDrawOpt = nullptr; + if(m_pCapOptions) + { + pWriterTableOpt = m_pCapOptions->Find(TABLE_CAP); + pWriterFrameOpt = m_pCapOptions->Find(FRAME_CAP); + pWriterGraphicOpt = m_pCapOptions->Find(GRAPHIC_CAP); + pOLECalcOpt = m_pCapOptions->Find(OLE_CAP, &m_aGlobalNames[GLOB_NAME_CALC]); + pOLEImpressOpt = m_pCapOptions->Find(OLE_CAP, &m_aGlobalNames[GLOB_NAME_IMPRESS]); + pOLEDrawOpt = m_pCapOptions->Find(OLE_CAP, &m_aGlobalNames[GLOB_NAME_DRAW ]); + pOLEFormulaOpt = m_pCapOptions->Find(OLE_CAP, &m_aGlobalNames[GLOB_NAME_MATH ]); + pOLEChartOpt = m_pCapOptions->Find(OLE_CAP, &m_aGlobalNames[GLOB_NAME_CHART ]); + } + switch(nProp) + { + case INS_PROP_TABLE_HEADER: + pValues[nProp] <<= bool(m_aInsTableOpts.mnInsMode & SwInsertTableFlags::Headline); + break;//"Table/Header", + case INS_PROP_TABLE_REPEATHEADER: + pValues[nProp] <<= m_aInsTableOpts.mnRowsToRepeat > 0; + break;//"Table/RepeatHeader", + case INS_PROP_TABLE_BORDER: + pValues[nProp] <<= bool(m_aInsTableOpts.mnInsMode & SwInsertTableFlags::DefaultBorder); + break;//"Table/Border", + case INS_PROP_TABLE_SPLIT: + pValues[nProp] <<= bool(m_aInsTableOpts.mnInsMode & SwInsertTableFlags::SplitLayout); + break;//"Table/Split", + case INS_PROP_CAP_AUTOMATIC: + pValues[nProp] <<= m_bInsWithCaption; + break;//"Caption/Automatic", + case INS_PROP_CAP_CAPTIONORDERNUMBERINGFIRST: + pValues[nProp] <<= m_bCaptionOrderNumberingFirst; + break;//"Caption/CaptionOrderNumberingFirst" + + case INS_PROP_CAP_OBJECT_TABLE_ENABLE: + case INS_PROP_CAP_OBJECT_TABLE_CATEGORY: + case INS_PROP_CAP_OBJECT_TABLE_NUMBERING: + case INS_PROP_CAP_OBJECT_TABLE_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_TABLE_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_TABLE_DELIMITER: + case INS_PROP_CAP_OBJECT_TABLE_LEVEL: + case INS_PROP_CAP_OBJECT_TABLE_POSITION: + case INS_PROP_CAP_OBJECT_TABLE_CHARACTERSTYLE: + if(pWriterTableOpt) + lcl_WriteOpt(*pWriterTableOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_TABLE_ENABLE); + break; + case INS_PROP_CAP_OBJECT_FRAME_ENABLE: + case INS_PROP_CAP_OBJECT_FRAME_CATEGORY: + case INS_PROP_CAP_OBJECT_FRAME_NUMBERING: + case INS_PROP_CAP_OBJECT_FRAME_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_FRAME_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_FRAME_DELIMITER: + case INS_PROP_CAP_OBJECT_FRAME_LEVEL: + case INS_PROP_CAP_OBJECT_FRAME_POSITION: + case INS_PROP_CAP_OBJECT_FRAME_CHARACTERSTYLE: + if(pWriterFrameOpt) + lcl_WriteOpt(*pWriterFrameOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_FRAME_ENABLE); + break; + case INS_PROP_CAP_OBJECT_GRAPHIC_ENABLE: + case INS_PROP_CAP_OBJECT_GRAPHIC_CATEGORY: + case INS_PROP_CAP_OBJECT_GRAPHIC_NUMBERING: + case INS_PROP_CAP_OBJECT_GRAPHIC_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_GRAPHIC_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_GRAPHIC_DELIMITER: + case INS_PROP_CAP_OBJECT_GRAPHIC_LEVEL: + case INS_PROP_CAP_OBJECT_GRAPHIC_POSITION: + case INS_PROP_CAP_OBJECT_GRAPHIC_CHARACTERSTYLE: + case INS_PROP_CAP_OBJECT_GRAPHIC_APPLYATTRIBUTES: + if(pWriterGraphicOpt) + lcl_WriteOpt(*pWriterGraphicOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_GRAPHIC_ENABLE); + break; + case INS_PROP_CAP_OBJECT_CALC_ENABLE: + case INS_PROP_CAP_OBJECT_CALC_CATEGORY: + case INS_PROP_CAP_OBJECT_CALC_NUMBERING: + case INS_PROP_CAP_OBJECT_CALC_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_CALC_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_CALC_DELIMITER: + case INS_PROP_CAP_OBJECT_CALC_LEVEL: + case INS_PROP_CAP_OBJECT_CALC_POSITION: + case INS_PROP_CAP_OBJECT_CALC_CHARACTERSTYLE: + case INS_PROP_CAP_OBJECT_CALC_APPLYATTRIBUTES: + if(pOLECalcOpt) + lcl_WriteOpt(*pOLECalcOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_CALC_ENABLE); + break; + case INS_PROP_CAP_OBJECT_IMPRESS_ENABLE: + case INS_PROP_CAP_OBJECT_IMPRESS_CATEGORY: + case INS_PROP_CAP_OBJECT_IMPRESS_NUMBERING: + case INS_PROP_CAP_OBJECT_IMPRESS_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_IMPRESS_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_IMPRESS_DELIMITER: + case INS_PROP_CAP_OBJECT_IMPRESS_LEVEL: + case INS_PROP_CAP_OBJECT_IMPRESS_POSITION: + case INS_PROP_CAP_OBJECT_IMPRESS_CHARACTERSTYLE: + case INS_PROP_CAP_OBJECT_IMPRESS_APPLYATTRIBUTES: + if(pOLEImpressOpt) + lcl_WriteOpt(*pOLEImpressOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_IMPRESS_ENABLE); + break; + case INS_PROP_CAP_OBJECT_CHART_ENABLE: + case INS_PROP_CAP_OBJECT_CHART_CATEGORY: + case INS_PROP_CAP_OBJECT_CHART_NUMBERING: + case INS_PROP_CAP_OBJECT_CHART_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_CHART_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_CHART_DELIMITER: + case INS_PROP_CAP_OBJECT_CHART_LEVEL: + case INS_PROP_CAP_OBJECT_CHART_POSITION: + case INS_PROP_CAP_OBJECT_CHART_CHARACTERSTYLE: + case INS_PROP_CAP_OBJECT_CHART_APPLYATTRIBUTES: + if(pOLEChartOpt) + lcl_WriteOpt(*pOLEChartOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_CHART_ENABLE); + break; + case INS_PROP_CAP_OBJECT_FORMULA_ENABLE: + case INS_PROP_CAP_OBJECT_FORMULA_CATEGORY: + case INS_PROP_CAP_OBJECT_FORMULA_NUMBERING: + case INS_PROP_CAP_OBJECT_FORMULA_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_FORMULA_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_FORMULA_DELIMITER: + case INS_PROP_CAP_OBJECT_FORMULA_LEVEL: + case INS_PROP_CAP_OBJECT_FORMULA_POSITION: + case INS_PROP_CAP_OBJECT_FORMULA_CHARACTERSTYLE: + case INS_PROP_CAP_OBJECT_FORMULA_APPLYATTRIBUTES: + if(pOLEFormulaOpt) + lcl_WriteOpt(*pOLEFormulaOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_FORMULA_ENABLE); + break; + case INS_PROP_CAP_OBJECT_DRAW_ENABLE: + case INS_PROP_CAP_OBJECT_DRAW_CATEGORY: + case INS_PROP_CAP_OBJECT_DRAW_NUMBERING: + case INS_PROP_CAP_OBJECT_DRAW_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_DRAW_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_DRAW_DELIMITER: + case INS_PROP_CAP_OBJECT_DRAW_LEVEL: + case INS_PROP_CAP_OBJECT_DRAW_POSITION: + case INS_PROP_CAP_OBJECT_DRAW_CHARACTERSTYLE: + case INS_PROP_CAP_OBJECT_DRAW_APPLYATTRIBUTES: + if(pOLEDrawOpt) + lcl_WriteOpt(*pOLEDrawOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_DRAW_ENABLE); + break; + case INS_PROP_CAP_OBJECT_OLEMISC_ENABLE: + case INS_PROP_CAP_OBJECT_OLEMISC_CATEGORY: + case INS_PROP_CAP_OBJECT_OLEMISC_NUMBERING: + case INS_PROP_CAP_OBJECT_OLEMISC_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_OLEMISC_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_OLEMISC_DELIMITER: + case INS_PROP_CAP_OBJECT_OLEMISC_LEVEL: + case INS_PROP_CAP_OBJECT_OLEMISC_POSITION: + case INS_PROP_CAP_OBJECT_OLEMISC_CHARACTERSTYLE: + case INS_PROP_CAP_OBJECT_OLEMISC_APPLYATTRIBUTES: + if(m_pOLEMiscOpt) + lcl_WriteOpt(*m_pOLEMiscOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_OLEMISC_ENABLE); + break; + + } + } + PutProperties(aNames, aValues); +} + +static void lcl_ReadOpt(InsCaptionOpt& rOpt, const Any* pValues, sal_Int32 nProp, sal_Int32 nOffset) +{ + switch(nOffset) + { + case 0: + rOpt.UseCaption() = *o3tl::doAccess<bool>(pValues[nProp]); + break;//Enable + case 1: + { + OUString sTemp; pValues[nProp] >>= sTemp; + rOpt.SetCategory(sTemp); + } + break;//Category + case 2: + { + sal_Int32 nTemp = 0; + pValues[nProp] >>= nTemp; + rOpt.SetNumType(sal::static_int_cast< sal_uInt16, sal_Int32>(nTemp)); + } + break;//Numbering", + case 3: + { + OUString sTemp; pValues[nProp] >>= sTemp; + rOpt.SetNumSeparator(sTemp); + } + break;//NumberingSeparator", + case 4: + { + OUString sTemp; pValues[nProp] >>= sTemp; + rOpt.SetCaption(sTemp); + } + break;//CaptionText", + case 5: + { + OUString sTemp; + if(pValues[nProp] >>= sTemp) + rOpt.SetSeparator(sTemp); + } + break;//Delimiter", + case 6: + { + sal_Int32 nTemp = 0; + pValues[nProp] >>= nTemp; + rOpt.SetLevel(sal::static_int_cast< sal_uInt16, sal_Int32>(nTemp)); + } + break;//Level", + case 7: + { + sal_Int32 nTemp = 0; + pValues[nProp] >>= nTemp; + rOpt.SetPos(sal::static_int_cast< sal_uInt16, sal_Int32>(nTemp)); + } + break;//Position", + case 8 : //CharacterStyle + { + OUString sTemp; pValues[nProp] >>= sTemp; + rOpt.SetCharacterStyle( sTemp ); + } + break; + case 9 : //ApplyAttributes + { + pValues[nProp] >>= rOpt.CopyAttributes(); + } + break; + } +} + +void SwInsertConfig::Load() +{ + const Sequence<OUString>& aNames = GetPropertyNames(); + Sequence<Any> aValues = GetProperties(aNames); + const Any* pValues = aValues.getConstArray(); + assert(aValues.getLength() == aNames.getLength()); + InsCaptionOpt* pWriterTableOpt = nullptr; + InsCaptionOpt* pWriterFrameOpt = nullptr; + InsCaptionOpt* pWriterGraphicOpt = nullptr; + InsCaptionOpt* pOLECalcOpt = nullptr; + InsCaptionOpt* pOLEImpressOpt = nullptr; + InsCaptionOpt* pOLEChartOpt = nullptr; + InsCaptionOpt* pOLEFormulaOpt = nullptr; + InsCaptionOpt* pOLEDrawOpt = nullptr; + if (m_pCapOptions) + { + pWriterTableOpt = m_pCapOptions->Find(TABLE_CAP); + pWriterFrameOpt = m_pCapOptions->Find(FRAME_CAP); + pWriterGraphicOpt = m_pCapOptions->Find(GRAPHIC_CAP); + pOLECalcOpt = m_pCapOptions->Find(OLE_CAP, &m_aGlobalNames[GLOB_NAME_CALC]); + pOLEImpressOpt = m_pCapOptions->Find(OLE_CAP, &m_aGlobalNames[GLOB_NAME_IMPRESS]); + pOLEDrawOpt = m_pCapOptions->Find(OLE_CAP, &m_aGlobalNames[GLOB_NAME_DRAW ]); + pOLEFormulaOpt = m_pCapOptions->Find(OLE_CAP, &m_aGlobalNames[GLOB_NAME_MATH ]); + pOLEChartOpt = m_pCapOptions->Find(OLE_CAP, &m_aGlobalNames[GLOB_NAME_CHART ]); + } + else if (!m_bIsWeb) + return; + + SwInsertTableFlags nInsTableFlags = SwInsertTableFlags::NONE; + for (sal_Int32 nProp = 0; nProp < aNames.getLength(); ++nProp) + { + if (pValues[nProp].hasValue()) + { + bool bBool = nProp < INS_PROP_CAP_OBJECT_TABLE_ENABLE && *o3tl::doAccess<bool>(pValues[nProp]); + switch (nProp) + { + case INS_PROP_TABLE_HEADER: + { + if(bBool) + nInsTableFlags |= SwInsertTableFlags::Headline; + } + break;//"Table/Header", + case INS_PROP_TABLE_REPEATHEADER: + { + m_aInsTableOpts.mnRowsToRepeat = bBool? 1 : 0; + + } + break;//"Table/RepeatHeader", + case INS_PROP_TABLE_BORDER: + { + if(bBool) + nInsTableFlags |= SwInsertTableFlags::DefaultBorder; + } + break;//"Table/Border", + case INS_PROP_TABLE_SPLIT: + { + if(bBool) + nInsTableFlags |= SwInsertTableFlags::SplitLayout; + } + break;//"Table/Split", + case INS_PROP_CAP_AUTOMATIC: + m_bInsWithCaption = bBool; + break; + case INS_PROP_CAP_CAPTIONORDERNUMBERINGFIRST: m_bCaptionOrderNumberingFirst = bBool; break; + case INS_PROP_CAP_OBJECT_TABLE_ENABLE: + case INS_PROP_CAP_OBJECT_TABLE_CATEGORY: + case INS_PROP_CAP_OBJECT_TABLE_NUMBERING: + case INS_PROP_CAP_OBJECT_TABLE_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_TABLE_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_TABLE_DELIMITER: + case INS_PROP_CAP_OBJECT_TABLE_LEVEL: + case INS_PROP_CAP_OBJECT_TABLE_POSITION: + case INS_PROP_CAP_OBJECT_TABLE_CHARACTERSTYLE: + if(!pWriterTableOpt) + { + pWriterTableOpt = new InsCaptionOpt(TABLE_CAP); + m_pCapOptions->Insert(pWriterTableOpt); + } + lcl_ReadOpt(*pWriterTableOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_TABLE_ENABLE); + break; + case INS_PROP_CAP_OBJECT_FRAME_ENABLE: + case INS_PROP_CAP_OBJECT_FRAME_CATEGORY: + case INS_PROP_CAP_OBJECT_FRAME_NUMBERING: + case INS_PROP_CAP_OBJECT_FRAME_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_FRAME_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_FRAME_DELIMITER: + case INS_PROP_CAP_OBJECT_FRAME_LEVEL: + case INS_PROP_CAP_OBJECT_FRAME_POSITION: + case INS_PROP_CAP_OBJECT_FRAME_CHARACTERSTYLE: + if(!pWriterFrameOpt) + { + pWriterFrameOpt = new InsCaptionOpt(FRAME_CAP); + m_pCapOptions->Insert(pWriterFrameOpt); + } + lcl_ReadOpt(*pWriterFrameOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_FRAME_ENABLE); + break; + case INS_PROP_CAP_OBJECT_GRAPHIC_ENABLE: + case INS_PROP_CAP_OBJECT_GRAPHIC_CATEGORY: + case INS_PROP_CAP_OBJECT_GRAPHIC_NUMBERING: + case INS_PROP_CAP_OBJECT_GRAPHIC_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_GRAPHIC_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_GRAPHIC_DELIMITER: + case INS_PROP_CAP_OBJECT_GRAPHIC_LEVEL: + case INS_PROP_CAP_OBJECT_GRAPHIC_POSITION: + case INS_PROP_CAP_OBJECT_GRAPHIC_CHARACTERSTYLE: + case INS_PROP_CAP_OBJECT_GRAPHIC_APPLYATTRIBUTES: + if(!pWriterGraphicOpt) + { + pWriterGraphicOpt = new InsCaptionOpt(GRAPHIC_CAP); + m_pCapOptions->Insert(pWriterGraphicOpt); + } + lcl_ReadOpt(*pWriterGraphicOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_GRAPHIC_ENABLE); + break; + case INS_PROP_CAP_OBJECT_CALC_ENABLE: + case INS_PROP_CAP_OBJECT_CALC_CATEGORY: + case INS_PROP_CAP_OBJECT_CALC_NUMBERING: + case INS_PROP_CAP_OBJECT_CALC_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_CALC_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_CALC_DELIMITER: + case INS_PROP_CAP_OBJECT_CALC_LEVEL: + case INS_PROP_CAP_OBJECT_CALC_POSITION: + case INS_PROP_CAP_OBJECT_CALC_CHARACTERSTYLE: + case INS_PROP_CAP_OBJECT_CALC_APPLYATTRIBUTES: + if(!pOLECalcOpt) + { + pOLECalcOpt = new InsCaptionOpt(OLE_CAP, &m_aGlobalNames[GLOB_NAME_CALC]); + m_pCapOptions->Insert(pOLECalcOpt); + } + lcl_ReadOpt(*pOLECalcOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_CALC_ENABLE); + break; + case INS_PROP_CAP_OBJECT_IMPRESS_ENABLE: + case INS_PROP_CAP_OBJECT_IMPRESS_CATEGORY: + case INS_PROP_CAP_OBJECT_IMPRESS_NUMBERING: + case INS_PROP_CAP_OBJECT_IMPRESS_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_IMPRESS_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_IMPRESS_DELIMITER: + case INS_PROP_CAP_OBJECT_IMPRESS_LEVEL: + case INS_PROP_CAP_OBJECT_IMPRESS_POSITION: + case INS_PROP_CAP_OBJECT_IMPRESS_CHARACTERSTYLE: + case INS_PROP_CAP_OBJECT_IMPRESS_APPLYATTRIBUTES: + if(!pOLEImpressOpt) + { + pOLEImpressOpt = new InsCaptionOpt(OLE_CAP, &m_aGlobalNames[GLOB_NAME_IMPRESS]); + m_pCapOptions->Insert(pOLEImpressOpt); + } + lcl_ReadOpt(*pOLEImpressOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_IMPRESS_ENABLE); + break; + case INS_PROP_CAP_OBJECT_CHART_ENABLE: + case INS_PROP_CAP_OBJECT_CHART_CATEGORY: + case INS_PROP_CAP_OBJECT_CHART_NUMBERING: + case INS_PROP_CAP_OBJECT_CHART_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_CHART_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_CHART_DELIMITER: + case INS_PROP_CAP_OBJECT_CHART_LEVEL: + case INS_PROP_CAP_OBJECT_CHART_POSITION: + case INS_PROP_CAP_OBJECT_CHART_CHARACTERSTYLE: + case INS_PROP_CAP_OBJECT_CHART_APPLYATTRIBUTES: + if(!pOLEChartOpt) + { + pOLEChartOpt = new InsCaptionOpt(OLE_CAP, &m_aGlobalNames[GLOB_NAME_CHART]); + m_pCapOptions->Insert(pOLEChartOpt); + } + lcl_ReadOpt(*pOLEChartOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_CHART_ENABLE); + break; + case INS_PROP_CAP_OBJECT_FORMULA_ENABLE: + case INS_PROP_CAP_OBJECT_FORMULA_CATEGORY: + case INS_PROP_CAP_OBJECT_FORMULA_NUMBERING: + case INS_PROP_CAP_OBJECT_FORMULA_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_FORMULA_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_FORMULA_DELIMITER: + case INS_PROP_CAP_OBJECT_FORMULA_LEVEL: + case INS_PROP_CAP_OBJECT_FORMULA_POSITION: + case INS_PROP_CAP_OBJECT_FORMULA_CHARACTERSTYLE: + case INS_PROP_CAP_OBJECT_FORMULA_APPLYATTRIBUTES: + if(!pOLEFormulaOpt) + { + pOLEFormulaOpt = new InsCaptionOpt(OLE_CAP, &m_aGlobalNames[GLOB_NAME_MATH]); + m_pCapOptions->Insert(pOLEFormulaOpt); + } + lcl_ReadOpt(*pOLEFormulaOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_FORMULA_ENABLE); + break; + case INS_PROP_CAP_OBJECT_DRAW_ENABLE: + case INS_PROP_CAP_OBJECT_DRAW_CATEGORY: + case INS_PROP_CAP_OBJECT_DRAW_NUMBERING: + case INS_PROP_CAP_OBJECT_DRAW_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_DRAW_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_DRAW_DELIMITER: + case INS_PROP_CAP_OBJECT_DRAW_LEVEL: + case INS_PROP_CAP_OBJECT_DRAW_POSITION: + case INS_PROP_CAP_OBJECT_DRAW_CHARACTERSTYLE: + case INS_PROP_CAP_OBJECT_DRAW_APPLYATTRIBUTES: + if(!pOLEDrawOpt) + { + pOLEDrawOpt = new InsCaptionOpt(OLE_CAP, &m_aGlobalNames[GLOB_NAME_DRAW]); + m_pCapOptions->Insert(pOLEDrawOpt); + } + lcl_ReadOpt(*pOLEDrawOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_DRAW_ENABLE); + break; + case INS_PROP_CAP_OBJECT_OLEMISC_ENABLE: + case INS_PROP_CAP_OBJECT_OLEMISC_CATEGORY: + case INS_PROP_CAP_OBJECT_OLEMISC_NUMBERING: + case INS_PROP_CAP_OBJECT_OLEMISC_NUMBERINGSEPARATOR: + case INS_PROP_CAP_OBJECT_OLEMISC_CAPTIONTEXT: + case INS_PROP_CAP_OBJECT_OLEMISC_DELIMITER: + case INS_PROP_CAP_OBJECT_OLEMISC_LEVEL: + case INS_PROP_CAP_OBJECT_OLEMISC_POSITION: + case INS_PROP_CAP_OBJECT_OLEMISC_CHARACTERSTYLE: + case INS_PROP_CAP_OBJECT_OLEMISC_APPLYATTRIBUTES: + if(!m_pOLEMiscOpt) + { + m_pOLEMiscOpt.reset(new InsCaptionOpt(OLE_CAP)); + } + lcl_ReadOpt(*m_pOLEMiscOpt, pValues, nProp, nProp - INS_PROP_CAP_OBJECT_OLEMISC_ENABLE); + break; + } + } + else if (nProp == INS_PROP_CAP_CAPTIONORDERNUMBERINGFIRST) + { + m_bCaptionOrderNumberingFirst = false; + } + + } + m_aInsTableOpts.mnInsMode = nInsTableFlags; +} + +const Sequence<OUString>& SwTableConfig::GetPropertyNames() +{ + static Sequence<OUString> const aNames + { + "Shift/Row", // 0 + "Shift/Column", // 1 + "Insert/Row", // 2 + "Insert/Column", // 3 + "Change/Effect", // 4 + "Input/NumberRecognition", // 5 + "Input/NumberFormatRecognition",// 6 + "Input/Alignment", // 7 + "Input/SplitVerticalByDefault" // 8 + }; + return aNames; +} + +SwTableConfig::SwTableConfig(bool bWeb) + : ConfigItem(bWeb ? OUString("Office.WriterWeb/Table") : OUString("Office.Writer/Table"), + ConfigItemMode::ReleaseTree) + , m_nTableHMove(0) + , m_nTableVMove(0) + , m_nTableHInsert(0) + , m_nTableVInsert(0) + , m_eTableChgMode(TableChgMode::FixedWidthChangeAbs) + , m_bInsTableFormatNum(false) + , m_bInsTableChangeNumFormat(false) + , m_bInsTableAlignNum(false) + , m_bSplitVerticalByDefault(false) +{ + Load(); +} + +SwTableConfig::~SwTableConfig() +{ +} + +void SwTableConfig::Notify( const css::uno::Sequence< OUString >& ) {} + +void SwTableConfig::ImplCommit() +{ + const Sequence<OUString>& aNames = GetPropertyNames(); + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + switch(nProp) + { + case 0 : pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(m_nTableHMove)); break; //"Shift/Row", + case 1 : pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(m_nTableVMove)); break; //"Shift/Column", + case 2 : pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(m_nTableHInsert)); break; //"Insert/Row", + case 3 : pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(m_nTableVInsert)); break; //"Insert/Column", + case 4 : pValues[nProp] <<= static_cast<sal_Int32>(m_eTableChgMode); break; //"Change/Effect", + case 5 : pValues[nProp] <<= m_bInsTableFormatNum; break; //"Input/NumberRecognition", + case 6 : pValues[nProp] <<= m_bInsTableChangeNumFormat; break; //"Input/NumberFormatRecognition", + case 7 : pValues[nProp] <<= m_bInsTableAlignNum; break; //"Input/Alignment" + case 8 : pValues[nProp] <<= m_bSplitVerticalByDefault; break; //"Input/SplitVerticalByDefault" + } + } + PutProperties(aNames, aValues); +} + +void SwTableConfig::Load() +{ + const Sequence<OUString>& aNames = GetPropertyNames(); + Sequence<Any> aValues = GetProperties(aNames); + const Any* pValues = aValues.getConstArray(); + assert(aValues.getLength() == aNames.getLength()); + for (sal_Int32 nProp = 0; nProp < aNames.getLength(); ++nProp) + { + if (pValues[nProp].hasValue()) + { + sal_Int32 nTemp = 0; + switch (nProp) + { + case 0 : pValues[nProp] >>= nTemp; m_nTableHMove = o3tl::toTwips(nTemp, o3tl::Length::mm100); break; //"Shift/Row", + case 1 : pValues[nProp] >>= nTemp; m_nTableVMove = o3tl::toTwips(nTemp, o3tl::Length::mm100); break; //"Shift/Column", + case 2 : pValues[nProp] >>= nTemp; m_nTableHInsert = o3tl::toTwips(nTemp, o3tl::Length::mm100); break; //"Insert/Row", + case 3 : pValues[nProp] >>= nTemp; m_nTableVInsert = o3tl::toTwips(nTemp, o3tl::Length::mm100); break; //"Insert/Column", + case 4 : pValues[nProp] >>= nTemp; m_eTableChgMode = static_cast<TableChgMode>(nTemp); break; //"Change/Effect", + case 5 : m_bInsTableFormatNum = *o3tl::doAccess<bool>(pValues[nProp]); break; //"Input/NumberRecognition", + case 6 : m_bInsTableChangeNumFormat = *o3tl::doAccess<bool>(pValues[nProp]); break; //"Input/NumberFormatRecognition", + case 7 : m_bInsTableAlignNum = *o3tl::doAccess<bool>(pValues[nProp]); break; //"Input/Alignment" + case 8 : m_bSplitVerticalByDefault = *o3tl::doAccess<bool>(pValues[nProp]); break; //"Input/SplitVerticalByDefault" + } + } + } +} + +SwMiscConfig::SwMiscConfig() : + ConfigItem("Office.Writer", ConfigItemMode::ReleaseTree), + m_bDefaultFontsInCurrDocOnly(false), + m_bShowIndexPreview(false), + m_bGrfToGalleryAsLnk(true), + m_bNumAlignSize(true), + m_bSinglePrintJob(false), + m_bIsNameFromColumn(true), + m_bIsPasswordFromColumn(false), + m_bAskForMailMergeInPrint(true), + m_nMailingFormats(MailTextFormats::NONE) +{ + Load(); +} + +SwMiscConfig::~SwMiscConfig() +{ +} + +const Sequence<OUString>& SwMiscConfig::GetPropertyNames() +{ + static Sequence<OUString> const aNames + { + "Statistics/WordNumber/Delimiter", // 0 + "DefaultFont/Document", // 1 + "Index/ShowPreview", // 2 + "Misc/GraphicToGalleryAsLink", // 3 + "Numbering/Graphic/KeepRatio", // 4 + "FormLetter/PrintOutput/SinglePrintJobs", // 5 + "FormLetter/MailingOutput/Format", // 6 + "FormLetter/FileOutput/FileName/FromDatabaseField", // 7 + "FormLetter/FileOutput/Path", // 8 + "FormLetter/FileOutput/FileName/FromManualSetting", // 9 + "FormLetter/FileOutput/FileName/Generation",//10 + "FormLetter/PrintOutput/AskForMerge", //11 + "FormLetter/FileOutput/FilePassword/FromDatabaseField", // 12 + "FormLetter/FileOutput/FilePassword/Generation" //13 + }; + return aNames; +} + +void SwMiscConfig::Notify( const css::uno::Sequence< OUString >& ) {} + +void SwMiscConfig::ImplCommit() +{ + const Sequence<OUString>& aNames = GetPropertyNames(); + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + switch(nProp) + { + case 0 : + pValues[nProp] <<= + SwModuleOptions::ConvertWordDelimiter(m_sWordDelimiter, false); + break; + case 1 : pValues[nProp] <<= m_bDefaultFontsInCurrDocOnly; break; + case 2 : pValues[nProp] <<= m_bShowIndexPreview; break; + case 3 : pValues[nProp] <<= m_bGrfToGalleryAsLnk; break; + case 4 : pValues[nProp] <<= m_bNumAlignSize; break; + case 5 : pValues[nProp] <<= m_bSinglePrintJob; break; + case 6 : pValues[nProp] <<= static_cast<sal_Int32>(m_nMailingFormats); break; + case 7 : pValues[nProp] <<= m_sNameFromColumn; break; + case 8 : pValues[nProp] <<= m_sMailingPath; break; + case 9 : pValues[nProp] <<= m_sMailName; break; + case 10: pValues[nProp] <<= m_bIsNameFromColumn; break; + case 11: pValues[nProp] <<= m_bAskForMailMergeInPrint; break; + case 12: pValues[nProp] <<= m_sPasswordFromColumn; break; + case 13: pValues[nProp] <<= m_bIsPasswordFromColumn; break; + } + } + PutProperties(aNames, aValues); +} + +void SwMiscConfig::Load() +{ + const Sequence<OUString>& aNames = GetPropertyNames(); + Sequence<Any> aValues = GetProperties(aNames); + const Any* pValues = aValues.getConstArray(); + assert(aValues.getLength() == aNames.getLength()); + OUString sTmp; + for (sal_Int32 nProp = 0; nProp < aNames.getLength(); ++nProp) + { + if (pValues[nProp].hasValue()) + { + switch (nProp) + { + case 0 : pValues[nProp] >>= sTmp; + m_sWordDelimiter = SwModuleOptions::ConvertWordDelimiter(sTmp, true); + break; + case 1 : m_bDefaultFontsInCurrDocOnly = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 2 : m_bShowIndexPreview = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 3 : m_bGrfToGalleryAsLnk = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 4 : m_bNumAlignSize = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 5 : m_bSinglePrintJob = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 6 : m_nMailingFormats = static_cast<MailTextFormats>(*o3tl::doAccess<sal_Int32>(pValues[nProp])); break; + case 7 : pValues[nProp] >>= sTmp; m_sNameFromColumn = sTmp; break; + case 8 : pValues[nProp] >>= sTmp; m_sMailingPath = sTmp; break; + case 9 : pValues[nProp] >>= sTmp; m_sMailName = sTmp; break; + case 10: m_bIsNameFromColumn = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 11: pValues[nProp] >>= m_bAskForMailMergeInPrint; break; + case 12: pValues[nProp] >>= sTmp; m_sPasswordFromColumn = sTmp; break; + case 13: m_bIsPasswordFromColumn = *o3tl::doAccess<bool>(pValues[nProp]); break; + } + } + } +} + +const Sequence<OUString>& SwCompareConfig::GetPropertyNames() +{ + static Sequence<OUString> const aNames + { + "Mode", // 0 + "UseRSID", // 1 + "IgnorePieces", // 2 + "IgnoreLength", // 3 + "StoreRSID" // 4 + }; + return aNames; +} + +SwCompareConfig::SwCompareConfig() : + ConfigItem("Office.Writer/Comparison", ConfigItemMode::ReleaseTree) + ,m_bStoreRsid(true) +{ + m_eCmpMode = SwCompareMode::Auto; + m_bUseRsid = false; + m_bIgnorePieces = false; + m_nPieceLen = 1; + + Load(); +} + +SwCompareConfig::~SwCompareConfig() +{ +} + +void SwCompareConfig::ImplCommit() +{ + const Sequence<OUString>& aNames = GetPropertyNames(); + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + pValues[0] <<= static_cast<sal_Int16>(m_eCmpMode); + pValues[1] <<= m_bUseRsid; + pValues[2] <<= m_bIgnorePieces; + pValues[3] <<= static_cast<sal_Int16>(m_nPieceLen); + pValues[4] <<= m_bStoreRsid; + + PutProperties(aNames, aValues); +} + +void SwCompareConfig::Load() +{ + const Sequence<OUString>& aNames = GetPropertyNames(); + Sequence<Any> aValues = GetProperties(aNames); + const Any* pValues = aValues.getConstArray(); + assert(aValues.getLength() == aNames.getLength()); + for (sal_Int32 nProp = 0; nProp < aNames.getLength(); nProp++) + { + if (pValues[nProp].hasValue()) + { + sal_Int32 nVal = 0; + pValues[nProp] >>= nVal; + + switch(nProp) + { + case 0 : m_eCmpMode = static_cast<SwCompareMode>(nVal); break; + case 1 : m_bUseRsid = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 2 : m_bIgnorePieces = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 3 : m_nPieceLen = nVal; break; + case 4 : m_bStoreRsid = *o3tl::doAccess<bool>(pValues[nProp]); break; + } + } + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/config/prtopt.cxx b/sw/source/uibase/config/prtopt.cxx new file mode 100644 index 000000000..68764fab1 --- /dev/null +++ b/sw/source/uibase/config/prtopt.cxx @@ -0,0 +1,168 @@ +/* -*- 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 <unotools/configmgr.hxx> +#include <prtopt.hxx> +#include <o3tl/any.hxx> +#include <osl/diagnose.h> +#include <com/sun/star/uno/Sequence.hxx> + +using namespace utl; +using namespace com::sun::star::uno; + +// Ctor +Sequence<OUString> SwPrintOptions::GetPropertyNames() const +{ + static const char* aPropNames[] = + { + "Content/Graphic", // 0 + "Content/Table", // 1 + "Content/Control", // 2 + "Content/Background", // 3 + "Content/PrintBlack", // 4 + "Content/Note", // 5 + "Page/Reversed", // 6 + "Page/Brochure", // 7 + "Page/BrochureRightToLeft", // 8 + "Output/SinglePrintJob", // 9 + "Output/Fax", // 10 + "Papertray/FromPrinterSetup", // 11 + "Content/Drawing", // 12 not in SW/Web + "Page/LeftPage", // 13 not in SW/Web + "Page/RightPage", // 14 not in SW/Web + "EmptyPages", // 15 not in SW/Web + "Content/PrintPlaceholders", // 16 not in Sw/Web + "Content/PrintHiddenText" // 17 not in Sw/Web + }; + const int nCount = m_bIsWeb ? 12 : 18; + Sequence<OUString> aNames(nCount); + OUString* pNames = aNames.getArray(); + for(int i = 0; i < nCount; i++) + { + pNames[i] = OUString::createFromAscii(aPropNames[i]); + } + return aNames; +} + +SwPrintOptions::SwPrintOptions(bool bWeb) : + ConfigItem(bWeb ? OUString("Office.WriterWeb/Print") : OUString("Office.Writer/Print"), + ConfigItemMode::ReleaseTree), + m_bIsWeb(bWeb) +{ + m_bPrintPageBackground = !bWeb; + m_bPrintBlackFont = bWeb; + m_bPrintTextPlaceholder = m_bPrintHiddenText = false; + if (bWeb) + m_bPrintEmptyPages = false; + + Sequence<OUString> aNames = GetPropertyNames(); + Sequence<Any> aValues = GetProperties(aNames); + const Any* pValues = aValues.getConstArray(); + OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); + if(aValues.getLength() == aNames.getLength()) + { + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + if(pValues[nProp].hasValue()) + { + switch(nProp) + { + case 0: m_bPrintGraphic = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 1: m_bPrintTable = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 2: m_bPrintControl = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 3: m_bPrintPageBackground= *o3tl::doAccess<bool>(pValues[nProp]); break; + case 4: m_bPrintBlackFont = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 5: + { + sal_Int32 nTmp = 0; + pValues[nProp] >>= nTmp; + m_nPrintPostIts = static_cast<SwPostItMode>(nTmp); + } + break; + case 6: m_bPrintReverse = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 7: m_bPrintProspect = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 8: m_bPrintProspectRTL = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 9: m_bPrintSingleJobs = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 10: pValues[nProp] >>= m_sFaxName; break; + case 11: m_bPaperFromSetup = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 12: m_bPrintDraw = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 13: m_bPrintLeftPages = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 14: m_bPrintRightPages = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 15: m_bPrintEmptyPages = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 16: m_bPrintTextPlaceholder = *o3tl::doAccess<bool>(pValues[nProp]); break; + case 17: m_bPrintHiddenText = *o3tl::doAccess<bool>(pValues[nProp]); break; + } + } + } + } + + // currently there is just one checkbox for print drawings and print graphics + // In the UI. (File/Print dialog and Tools/Options/.../Print) + // And since print graphics is the only available in Writer and WriterWeb... + + m_bPrintDraw = m_bPrintGraphic; +} + +SwPrintOptions::~SwPrintOptions() +{ +} + +void SwPrintOptions::Notify( const css::uno::Sequence< OUString >& ) {} + +void SwPrintOptions::ImplCommit() +{ + Sequence<OUString> aNames = GetPropertyNames(); + + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + switch(nProp) + { + case 0: pValues[nProp] <<= m_bPrintGraphic; break; + case 1: pValues[nProp] <<= m_bPrintTable; break; + case 2: pValues[nProp] <<= m_bPrintControl; break; + case 3: pValues[nProp] <<= m_bPrintPageBackground; break; + case 4: pValues[nProp] <<= m_bPrintBlackFont; break; + case 5: pValues[nProp] <<= static_cast<sal_Int32>(m_nPrintPostIts) ; break; + case 6: pValues[nProp] <<= m_bPrintReverse; break; + case 7: pValues[nProp] <<= m_bPrintProspect; break; + case 8: pValues[nProp] <<= m_bPrintProspectRTL; break; + case 9: pValues[nProp] <<= m_bPrintSingleJobs; break; + case 10: pValues[nProp] <<= m_sFaxName; break; + case 11: pValues[nProp] <<= m_bPaperFromSetup; break; + case 12: pValues[nProp] <<= m_bPrintDraw; break; + case 13: pValues[nProp] <<= m_bPrintLeftPages; break; + case 14: pValues[nProp] <<= m_bPrintRightPages; break; + case 15: pValues[nProp] <<= m_bPrintEmptyPages; break; + case 16: pValues[nProp] <<= m_bPrintTextPlaceholder; break; + case 17: pValues[nProp] <<= m_bPrintHiddenText; break; + } + } + + // currently there is just one checkbox for print drawings and print graphics + // In the UI. (File/Print dialog and Tools/Options/.../Print) + // And since print graphics is the only available in Writer and WriterWeb... + m_bPrintDraw = m_bPrintGraphic; + + PutProperties(aNames, aValues); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/config/uinums.cxx b/sw/source/uibase/config/uinums.cxx new file mode 100644 index 000000000..71e68f558 --- /dev/null +++ b/sw/source/uibase/config/uinums.cxx @@ -0,0 +1,259 @@ +/* -*- 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 <memory> +#include <uinums.hxx> + +#include <unotools/pathoptions.hxx> +#include <tools/stream.hxx> +#include <sfx2/docfile.hxx> +#include <svl/itemiter.hxx> + +#include <swtypes.hxx> +#include <wrtsh.hxx> +#include <poolfmt.hxx> +#include <charfmt.hxx> + +using namespace ::com::sun::star; + +constexpr OUStringLiteral CHAPTER_FILENAME = u"chapter.cfg"; + +/* + Description: Saving a rule + Parameter: rCopy -- the rule to save + nIdx -- position, where the rule is to be saved. + An old rule at that position will be overwritten. +*/ + +SwChapterNumRules::SwChapterNumRules() +{ + Init(); +} + +void SwChapterNumRules::Save() +{ + INetURLObject aURL; + SvtPathOptions aPathOpt; + aURL.SetSmartURL( aPathOpt.GetUserConfigPath() ); + aURL.setFinalSlash(); + aURL.Append(CHAPTER_FILENAME); + + SfxMedium aMedium( aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE), StreamMode::WRITE ); + SvStream* pStream = aMedium.GetOutStream(); + bool bRet = (pStream && pStream->GetError() == ERRCODE_NONE); + if (bRet) + { + sw::ExportStoredChapterNumberingRules(*this, *pStream,CHAPTER_FILENAME); + + pStream->FlushBuffer(); + + aMedium.Commit(); + } +} + +SwChapterNumRules::~SwChapterNumRules() +{ +} + +void SwChapterNumRules::Init() +{ + for(auto & rpNumRule : m_pNumRules) + rpNumRule.reset(); + + OUString sNm(CHAPTER_FILENAME); + SvtPathOptions aOpt; + if( aOpt.SearchFile( sNm )) + { + SfxMedium aStrm( sNm, StreamMode::STD_READ ); + sw::ImportStoredChapterNumberingRules(*this, *aStrm.GetInStream(), + CHAPTER_FILENAME); + } +} + +void SwChapterNumRules::CreateEmptyNumRule(sal_uInt16 const nIndex) +{ + assert(nIndex < nMaxRules); + assert(!m_pNumRules[nIndex]); + m_pNumRules[nIndex].reset(new SwNumRulesWithName); +} + +void SwChapterNumRules::ApplyNumRules(const SwNumRulesWithName &rCopy, sal_uInt16 nIdx) +{ + assert(nIdx < nMaxRules); + if( !m_pNumRules[nIdx] ) + m_pNumRules[nIdx].reset(new SwNumRulesWithName( rCopy )); + else + *m_pNumRules[nIdx] = rCopy; + Save(); // store it immediately +} + +SwNumRulesWithName::SwNumRulesWithName( const SwNumRule &rCopy, + const OUString &rName ) + : maName(rName) +{ + for( sal_uInt16 n = 0; n < MAXLEVEL; ++n ) + { + const SwNumFormat* pFormat = rCopy.GetNumFormat( n ); + if( pFormat ) + m_aFormats[ n ].reset(new SwNumFormatGlobal( *pFormat )); + else + m_aFormats[ n ].reset(); + } +} + +SwNumRulesWithName::SwNumRulesWithName( const SwNumRulesWithName& rCopy ) +{ + *this = rCopy; +} + +SwNumRulesWithName::~SwNumRulesWithName() +{ +} + +SwNumRulesWithName& SwNumRulesWithName::operator=(const SwNumRulesWithName &rCopy) +{ + if( this != &rCopy ) + { + maName = rCopy.maName; + for( int n = 0; n < MAXLEVEL; ++n ) + { + SwNumFormatGlobal* pFormat = rCopy.m_aFormats[ n ].get(); + if( pFormat ) + m_aFormats[ n ].reset(new SwNumFormatGlobal( *pFormat )); + else + m_aFormats[ n ].reset(); + } + } + return *this; +} + +void SwNumRulesWithName::ResetNumRule(SwWrtShell& rSh, SwNumRule& rNumRule) const +{ + // #i89178# + rNumRule.Reset(maName); + rNumRule.SetAutoRule( false ); + for (sal_uInt16 n = 0; n < MAXLEVEL; ++n) + { + SwNumFormatGlobal* pFormat = m_aFormats[ n ].get(); + if (!pFormat) + continue; + rNumRule.Set(n, pFormat->MakeNumFormat(rSh)); + } +} + +void SwNumRulesWithName::GetNumFormat( + size_t const nIndex, SwNumFormat const*& rpNumFormat, OUString const*& rpName) const +{ + rpNumFormat = (m_aFormats[nIndex]) ? &m_aFormats[nIndex]->m_aFormat : nullptr; + rpName = (m_aFormats[nIndex]) ? &m_aFormats[nIndex]->m_sCharFormatName : nullptr; +} + +void SwNumRulesWithName::SetNumFormat( + size_t const nIndex, SwNumFormat const& rNumFormat, OUString const& rName) +{ + m_aFormats[nIndex].reset( new SwNumFormatGlobal(rNumFormat) ); + m_aFormats[nIndex]->m_sCharFormatName = rName; + m_aFormats[nIndex]->m_nCharPoolId = USHRT_MAX; + m_aFormats[nIndex]->m_Items.clear(); +} + +SwNumRulesWithName::SwNumFormatGlobal::SwNumFormatGlobal( const SwNumFormat& rFormat ) + : m_aFormat( rFormat ), m_nCharPoolId( USHRT_MAX ) +{ + // relative gaps????? + + SwCharFormat* pFormat = rFormat.GetCharFormat(); + if( !pFormat ) + return; + + m_sCharFormatName = pFormat->GetName(); + m_nCharPoolId = pFormat->GetPoolFormatId(); + if( pFormat->GetAttrSet().Count() ) + { + SfxItemIter aIter( pFormat->GetAttrSet() ); + const SfxPoolItem *pCurr = aIter.GetCurItem(); + do + { + m_Items.push_back(std::unique_ptr<SfxPoolItem>(pCurr->Clone())); + pCurr = aIter.NextItem(); + } while (pCurr); + } + + m_aFormat.SetCharFormat( nullptr ); +} + +SwNumRulesWithName::SwNumFormatGlobal::SwNumFormatGlobal( const SwNumFormatGlobal& rFormat ) + : + m_aFormat( rFormat.m_aFormat ), + m_sCharFormatName( rFormat.m_sCharFormatName ), + m_nCharPoolId( rFormat.m_nCharPoolId ) +{ + for (size_t n = rFormat.m_Items.size(); n; ) + { + m_Items.push_back(std::unique_ptr<SfxPoolItem>(rFormat.m_Items[ --n ]->Clone())); + } +} + +SwNumRulesWithName::SwNumFormatGlobal::~SwNumFormatGlobal() +{ +} + +SwNumFormat SwNumRulesWithName::SwNumFormatGlobal::MakeNumFormat(SwWrtShell& rSh) const +{ + SwCharFormat* pFormat = nullptr; + if( !m_sCharFormatName.isEmpty() ) + { + // at first, look for the name + sal_uInt16 nArrLen = rSh.GetCharFormatCount(); + for( sal_uInt16 i = 1; i < nArrLen; ++i ) + { + pFormat = &rSh.GetCharFormat( i ); + if (pFormat->GetName()==m_sCharFormatName) + // exists, so leave attributes as they are! + break; + pFormat = nullptr; + } + + if( !pFormat ) + { + if( IsPoolUserFormat( m_nCharPoolId ) ) + { + pFormat = rSh.MakeCharFormat( m_sCharFormatName ); + pFormat->SetAuto(false); + } + else + pFormat = rSh.GetCharFormatFromPool( m_nCharPoolId ); + + if( !pFormat->HasWriterListeners() ) // set attributes + { + for (size_t n = m_Items.size(); n; ) + { + pFormat->SetFormatAttr( *m_Items[ --n ] ); + } + } + } + } + const_cast<SwNumFormat&>(m_aFormat).SetCharFormat(pFormat); + SwNumFormat aNew = m_aFormat; + if (pFormat) + const_cast<SwNumFormat&>(m_aFormat).SetCharFormat(nullptr); + return aNew; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/config/usrpref.cxx b/sw/source/uibase/config/usrpref.cxx new file mode 100644 index 000000000..e2599f409 --- /dev/null +++ b/sw/source/uibase/config/usrpref.cxx @@ -0,0 +1,618 @@ +/* -*- 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 <sal/config.h> + +#include <osl/diagnose.h> +#include <o3tl/any.hxx> +#include <tools/UnitConversion.hxx> +#include <unotools/configmgr.hxx> +#include <unotools/syslocale.hxx> + +#include <usrpref.hxx> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <unotools/localedatawrapper.hxx> + +using namespace utl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +void SwMasterUsrPref::SetUsrPref(const SwViewOption &rCopy) +{ + *static_cast<SwViewOption*>(this) = rCopy; +} + +SwMasterUsrPref::SwMasterUsrPref(bool bWeb) : + m_eFieldUpdateFlags(AUTOUPD_OFF), + m_nLinkUpdateMode(0), + m_bIsHScrollMetricSet(false), + m_bIsVScrollMetricSet(false), + m_nDefTabInMm100( 2000 ), // 2 cm + m_bIsSquaredPageMode(false), + m_bIsAlignMathObjectsToBaseline(false), + m_aContentConfig(bWeb, *this), + m_aLayoutConfig(bWeb, *this), + m_aGridConfig(bWeb, *this), + m_aCursorConfig(*this), + m_pWebColorConfig(bWeb ? new SwWebColorConfig(*this) : nullptr), + m_bApplyCharUnit(false) +{ + if (utl::ConfigManager::IsFuzzing()) + { + m_eHScrollMetric = m_eVScrollMetric = m_eUserMetric = FieldUnit::CM; + return; + } + MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum(); + m_eUserMetric = MeasurementSystem::Metric == eSystem ? FieldUnit::CM : FieldUnit::INCH; + m_eHScrollMetric = m_eVScrollMetric = m_eUserMetric; + + m_aContentConfig.Load(); + m_aLayoutConfig.Load(); + m_aGridConfig.Load(); + m_aCursorConfig.Load(); + if(m_pWebColorConfig) + m_pWebColorConfig->Load(); +} + +SwMasterUsrPref::~SwMasterUsrPref() +{ +} + +const auto g_UpdateLinkIndex = 17; +const auto g_DefaultAnchor = 25; + +Sequence<OUString> SwContentViewConfig::GetPropertyNames() const +{ + static constexpr const char*const aPropNames[] = + { + "Display/GraphicObject", // 0 + "Display/Table", // 1 + "Display/DrawingControl", // 2 + "Display/FieldCode", // 3 + "Display/Note", // 4 + "Display/ShowContentTips", // 5 + "NonprintingCharacter/MetaCharacters", // 6 + "NonprintingCharacter/ParagraphEnd", // 7 + "NonprintingCharacter/OptionalHyphen", // 8 + "NonprintingCharacter/Space", // 9 + "NonprintingCharacter/Break", // 10 + "NonprintingCharacter/ProtectedSpace", // 11 + "NonprintingCharacter/Tab", // 12 //not in Writer/Web + "NonprintingCharacter/HiddenText", // 13 + "NonprintingCharacter/HiddenParagraph", // 14 + "NonprintingCharacter/HiddenCharacter", // 15 + "NonprintingCharacter/Bookmarks", // 16 + "Update/Link", // 17 + "Update/Field", // 18 + "Update/Chart", // 19 + "Display/ShowInlineTooltips", // 20 + "Display/UseHeaderFooterMenu", // 21 + "Display/ShowOutlineContentVisibilityButton", // 22 + "Display/TreatSubOutlineLevelsAsContent", // 23 + "Display/ShowChangesInMargin", // 24 + "Display/DefaultAnchor" // 25 + }; +#if defined(__GNUC__) && !defined(__clang__) + // clang 8.0.0 says strcmp isn't constexpr + static_assert(std::strcmp("Update/Link", aPropNames[g_UpdateLinkIndex]) == 0); + static_assert(std::strcmp("Display/DefaultAnchor", aPropNames[g_DefaultAnchor]) == 0); +#endif + const int nCount = m_bWeb ? 12 : SAL_N_ELEMENTS(aPropNames); + Sequence<OUString> aNames(nCount); + OUString* pNames = aNames.getArray(); + for(int i = 0; i < nCount; i++) + { + pNames[i] = OUString::createFromAscii(aPropNames[i]); + } + return aNames; +} + +SwContentViewConfig::SwContentViewConfig(bool bIsWeb, SwMasterUsrPref& rPar) : + ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Content") : OUString("Office.Writer/Content")), + m_rParent(rPar), + m_bWeb(bIsWeb) +{ + Load(); + EnableNotification( GetPropertyNames() ); +} + +SwContentViewConfig::~SwContentViewConfig() +{ +} + +void SwContentViewConfig::Notify( const Sequence< OUString > & /*rPropertyNames*/ ) +{ + Load(); +} + +void SwContentViewConfig::ImplCommit() +{ + Sequence<OUString> aNames = GetPropertyNames(); + + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + bool bVal = false; + switch(nProp) + { + case 0: bVal = m_rParent.IsGraphic(); break;// "Display/GraphicObject", + case 1: bVal = m_rParent.IsTable(); break;// "Display/Table", + case 2: bVal = m_rParent.IsDraw(); break;// "Display/DrawingControl", + case 3: bVal = m_rParent.IsFieldName(); break;// "Display/FieldCode", + case 4: bVal = m_rParent.IsPostIts(); break;// "Display/Note", + case 5: bVal = m_rParent.IsShowContentTips(); break; // "Display/ShowContentTips" + case 6: bVal = m_rParent.IsViewMetaChars(); break; //"NonprintingCharacter/MetaCharacters" + case 7: bVal = m_rParent.IsParagraph(true); break;// "NonprintingCharacter/ParagraphEnd", + case 8: bVal = m_rParent.IsSoftHyph(); break;// "NonprintingCharacter/OptionalHyphen", + case 9: bVal = m_rParent.IsBlank(true); break;// "NonprintingCharacter/Space", + case 10: bVal = m_rParent.IsLineBreak(true);break;// "NonprintingCharacter/Break", + case 11: bVal = m_rParent.IsHardBlank(); break;// "NonprintingCharacter/ProtectedSpace", + case 12: bVal = m_rParent.IsTab(true); break;// "NonprintingCharacter/Tab", + case 13: bVal = m_rParent.IsShowHiddenField(); break;// "NonprintingCharacter/Fields: HiddenText", + case 14: bVal = m_rParent.IsShowHiddenPara(); break;// "NonprintingCharacter/Fields: HiddenParagraph", + case 15: bVal = m_rParent.IsShowHiddenChar(true); break;// "NonprintingCharacter/HiddenCharacter", + case 16: bVal = m_rParent.IsShowBookmarks(true); break;// "NonprintingCharacter/Bookmarks", + case 17: pValues[nProp] <<= m_rParent.GetUpdateLinkMode(); break;// "Update/Link", + case 18: bVal = m_rParent.IsUpdateFields(); break;// "Update/Field", + case 19: bVal = m_rParent.IsUpdateCharts(); break;// "Update/Chart" + case 20: bVal = m_rParent.IsShowInlineTooltips(); break;// "Display/ShowInlineTooltips" + case 21: bVal = m_rParent.IsUseHeaderFooterMenu(); break;// "Display/UseHeaderFooterMenu" + case 22: bVal = m_rParent.IsShowOutlineContentVisibilityButton(); break;// "Display/ShowOutlineContentVisibilityButton" + case 23: bVal = m_rParent.IsTreatSubOutlineLevelsAsContent(); break;// "Display/TreatSubOutlineLevelsAsContent" + case 24: bVal = m_rParent.IsShowChangesInMargin(); break;// "Display/ShowChangesInMargin" + case 25: pValues[nProp] <<= m_rParent.GetDefaultAnchor(); break;// "Display/DefaultAnchor" + } + if ((nProp != g_UpdateLinkIndex) && (nProp != g_DefaultAnchor)) + pValues[nProp] <<= bVal; + } + PutProperties(aNames, aValues); +} + +void SwContentViewConfig::Load() +{ + Sequence<OUString> aNames = GetPropertyNames(); + Sequence<Any> aValues = GetProperties(aNames); + const Any* pValues = aValues.getConstArray(); + OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); + if(aValues.getLength() != aNames.getLength()) + return; + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + if(pValues[nProp].hasValue()) + { + bool bSet = ((nProp != g_UpdateLinkIndex) && (nProp != g_DefaultAnchor)) + && *o3tl::doAccess<bool>(pValues[nProp]); + switch(nProp) + { + case 0: m_rParent.SetGraphic(bSet); break;// "Display/GraphicObject", + case 1: m_rParent.SetTable(bSet); break;// "Display/Table", + case 2: m_rParent.SetDraw(bSet); break;// "Display/DrawingControl", + case 3: m_rParent.SetFieldName(bSet); break;// "Display/FieldCode", + case 4: m_rParent.SetPostIts(bSet); break;// "Display/Note", + case 5: m_rParent.SetShowContentTips(bSet); break;// "Display/ShowContentTips", + case 6: m_rParent.SetViewMetaChars(bSet); break; //"NonprintingCharacter/MetaCharacters" + case 7: m_rParent.SetParagraph(bSet); break;// "NonprintingCharacter/ParagraphEnd", + case 8: m_rParent.SetSoftHyph(bSet); break;// "NonprintingCharacter/OptionalHyphen", + case 9: m_rParent.SetBlank(bSet); break;// "NonprintingCharacter/Space", + case 10: m_rParent.SetLineBreak(bSet);break;// "NonprintingCharacter/Break", + case 11: m_rParent.SetHardBlank(bSet); break;// "NonprintingCharacter/ProtectedSpace", + case 12: m_rParent.SetTab(bSet); break;// "NonprintingCharacter/Tab", + case 13: m_rParent.SetShowHiddenField(bSet); break;// "NonprintingCharacter/Fields: HiddenText", + case 14: m_rParent.SetShowHiddenPara(bSet); break;// "NonprintingCharacter/Fields: HiddenParagraph", + case 15: m_rParent.SetShowHiddenChar(bSet); break;// "NonprintingCharacter/HiddenCharacter", + case 16: m_rParent.SetShowBookmarks(bSet); break;// "NonprintingCharacter/Bookmarks", + case 17: + { + sal_Int32 nSet = 0; + pValues[nProp] >>= nSet; + m_rParent.SetUpdateLinkMode(nSet, true); + } + break;// "Update/Link", + case 18: m_rParent.SetUpdateFields(bSet); break;// "Update/Field", + case 19: m_rParent.SetUpdateCharts(bSet); break;// "Update/Chart" + case 20: m_rParent.SetShowInlineTooltips(bSet); break;// "Display/ShowInlineTooltips" + case 21: m_rParent.SetUseHeaderFooterMenu(bSet); break;// "Display/UseHeaderFooterMenu" + case 22: m_rParent.SetShowOutlineContentVisibilityButton(bSet); break;// "Display/ShowOutlineContententVisibilityButton" + case 23: m_rParent.SetTreatSubOutlineLevelsAsContent(bSet); break;// "Display/TreatSubOutlineLevelsAsContent" + case 24: m_rParent.SetShowChangesInMargin(bSet); break;// "Display/ShowChangesInMargin" + case 25: + { + sal_Int32 nSet = 0; + pValues[nProp] >>= nSet; + m_rParent.SetDefaultAnchor(nSet); + } + break; // "Display/DefaultAnchor" + } + } + } +} + +Sequence<OUString> SwLayoutViewConfig::GetPropertyNames() const +{ + static const char* aPropNames[] = + { + "Line/Guide", // 0 + "Window/HorizontalScroll", // 1 + "Window/VerticalScroll", // 2 + "Window/ShowRulers", // 3 + "Window/HorizontalRuler", // 4 + "Window/VerticalRuler", // 5 + "Window/HorizontalRulerUnit", // 6 + "Window/VerticalRulerUnit", // 7 + "Window/SmoothScroll", // 8 + "Zoom/Value", // 9 + "Zoom/Type", //10 + "Other/IsAlignMathObjectsToBaseline", //11 + "Other/MeasureUnit", //12 + // below properties are not available in WriterWeb + "Other/TabStop", //13 + "Window/IsVerticalRulerRight", //14 + "ViewLayout/Columns", //15 + "ViewLayout/BookMode", //16 + "Other/IsSquaredPageMode", //17 + "Other/ApplyCharUnit", //18 + "Window/ShowScrollBarTips", //19 + }; + const int nCount = m_bWeb ? 13 : 20; + Sequence<OUString> aNames(nCount); + OUString* pNames = aNames.getArray(); + for(int i = 0; i < nCount; i++) + { + pNames[i] = OUString::createFromAscii(aPropNames[i]); + } + return aNames; +} + +SwLayoutViewConfig::SwLayoutViewConfig(bool bIsWeb, SwMasterUsrPref& rPar) : + ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Layout") : OUString("Office.Writer/Layout"), + ConfigItemMode::ReleaseTree), + m_rParent(rPar), + m_bWeb(bIsWeb) +{ +} + +SwLayoutViewConfig::~SwLayoutViewConfig() +{ +} + +void SwLayoutViewConfig::ImplCommit() +{ + Sequence<OUString> aNames = GetPropertyNames(); + + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + Any &rVal = pValues[nProp]; + switch(nProp) + { + case 0: rVal <<= m_rParent.IsCrossHair(); break; // "Line/Guide", + case 1: rVal <<= m_rParent.IsViewHScrollBar(); break; // "Window/HorizontalScroll", + case 2: rVal <<= m_rParent.IsViewVScrollBar(); break; // "Window/VerticalScroll", + case 3: rVal <<= m_rParent.IsViewAnyRuler(); break; // "Window/ShowRulers" + // #i14593# use IsView*Ruler(true) instead of IsView*Ruler() + // this preserves the single ruler states even if "Window/ShowRulers" is off + case 4: rVal <<= m_rParent.IsViewHRuler(true); break; // "Window/HorizontalRuler", + case 5: rVal <<= m_rParent.IsViewVRuler(true); break; // "Window/VerticalRuler", + case 6: + if(m_rParent.m_bIsHScrollMetricSet) + rVal <<= static_cast<sal_Int32>(m_rParent.m_eHScrollMetric); // "Window/HorizontalRulerUnit" + break; + case 7: + if(m_rParent.m_bIsVScrollMetricSet) + rVal <<= static_cast<sal_Int32>(m_rParent.m_eVScrollMetric); // "Window/VerticalRulerUnit" + break; + case 8: rVal <<= m_rParent.IsSmoothScroll(); break; // "Window/SmoothScroll", + case 9: rVal <<= static_cast<sal_Int32>(m_rParent.GetZoom()); break; // "Zoom/Value", + case 10: rVal <<= static_cast<sal_Int32>(m_rParent.GetZoomType()); break; // "Zoom/Type", + case 11: rVal <<= m_rParent.IsAlignMathObjectsToBaseline(); break; // "Other/IsAlignMathObjectsToBaseline" + case 12: rVal <<= static_cast<sal_Int32>(m_rParent.GetMetric()); break; // "Other/MeasureUnit", + case 13: rVal <<= m_rParent.GetDefTabInMm100(); break;// "Other/TabStop", + case 14: rVal <<= m_rParent.IsVRulerRight(); break; // "Window/IsVerticalRulerRight", + case 15: rVal <<= static_cast<sal_Int32>(m_rParent.GetViewLayoutColumns()); break; // "ViewLayout/Columns", + case 16: rVal <<= m_rParent.IsViewLayoutBookMode(); break; // "ViewLayout/BookMode", + case 17: rVal <<= m_rParent.IsSquaredPageMode(); break; // "Other/IsSquaredPageMode", + case 18: rVal <<= m_rParent.IsApplyCharUnit(); break; // "Other/ApplyCharUnit", + case 19: rVal <<= m_rParent.IsShowScrollBarTips(); break; // "Window/ShowScrollBarTips", + } + } + PutProperties(aNames, aValues); +} + +void SwLayoutViewConfig::Load() +{ + Sequence<OUString> aNames = GetPropertyNames(); + Sequence<Any> aValues = GetProperties(aNames); + const Any* pValues = aValues.getConstArray(); + OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); + if(aValues.getLength() != aNames.getLength()) + return; + + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + if(pValues[nProp].hasValue()) + { + sal_Int32 nInt32Val = 0; + bool bSet = false; + pValues[nProp] >>= nInt32Val; + pValues[nProp] >>= bSet; + + switch(nProp) + { + case 0: m_rParent.SetCrossHair(bSet); break;// "Line/Guide", + case 1: m_rParent.SetViewHScrollBar(bSet); break;// "Window/HorizontalScroll", + case 2: m_rParent.SetViewVScrollBar(bSet); break;// "Window/VerticalScroll", + case 3: m_rParent.SetViewAnyRuler(bSet);break; // "Window/ShowRulers" + case 4: m_rParent.SetViewHRuler(bSet); break;// "Window/HorizontalRuler", + case 5: m_rParent.SetViewVRuler(bSet); break;// "Window/VerticalRuler", + case 6: + { + m_rParent.m_bIsHScrollMetricSet = true; + m_rParent.m_eHScrollMetric = static_cast<FieldUnit>(nInt32Val); // "Window/HorizontalRulerUnit" + } + break; + case 7: + { + m_rParent.m_bIsVScrollMetricSet = true; + m_rParent.m_eVScrollMetric = static_cast<FieldUnit>(nInt32Val); // "Window/VerticalRulerUnit" + } + break; + case 8: m_rParent.SetSmoothScroll(bSet); break;// "Window/SmoothScroll", + case 9: m_rParent.SetZoom( static_cast< sal_uInt16 >(nInt32Val) ); break;// "Zoom/Value", + case 10: m_rParent.SetZoomType( static_cast< SvxZoomType >(nInt32Val) ); break;// "Zoom/Type", + case 11: m_rParent.SetAlignMathObjectsToBaseline(bSet, true); break;// "Other/IsAlignMathObjectsToBaseline" + case 12: m_rParent.SetMetric(static_cast<FieldUnit>(nInt32Val), true); break;// "Other/MeasureUnit", + case 13: m_rParent.SetDefTabInMm100(nInt32Val, true); break;// "Other/TabStop", + case 14: m_rParent.SetVRulerRight(bSet); break;// "Window/IsVerticalRulerRight", + case 15: m_rParent.SetViewLayoutColumns( o3tl::narrowing<sal_uInt16>(nInt32Val) ); break;// "ViewLayout/Columns", + case 16: m_rParent.SetViewLayoutBookMode(bSet); break;// "ViewLayout/BookMode", + case 17: m_rParent.SetDefaultPageMode(bSet,true); break;// "Other/IsSquaredPageMode", + case 18: m_rParent.SetApplyCharUnit(bSet, true); break;// "Other/ApplyUserChar" + case 29: m_rParent.SetShowScrollBarTips(bSet); break;// "Window/ShowScrollBarTips", + } + } + } +} + +void SwLayoutViewConfig::Notify( const css::uno::Sequence< OUString >& ) {} + +Sequence<OUString> SwGridConfig::GetPropertyNames() +{ + static const char* aPropNames[] = + { + "Option/SnapToGrid", // 0 + "Option/VisibleGrid", // 1 + "Option/Synchronize", // 2 + "Resolution/XAxis", // 3 + "Resolution/YAxis", // 4 + "Subdivision/XAxis", // 5 + "Subdivision/YAxis" // 6 + }; + const int nCount = 7; + Sequence<OUString> aNames(nCount); + OUString* pNames = aNames.getArray(); + for(int i = 0; i < nCount; i++) + { + pNames[i] = OUString::createFromAscii(aPropNames[i]); + } + return aNames; +} + +SwGridConfig::SwGridConfig(bool bIsWeb, SwMasterUsrPref& rPar) : + ConfigItem(bIsWeb ? OUString("Office.WriterWeb/Grid") : OUString("Office.Writer/Grid"), + ConfigItemMode::ReleaseTree), + m_rParent(rPar) +{ +} + +SwGridConfig::~SwGridConfig() +{ +} + +void SwGridConfig::ImplCommit() +{ + Sequence<OUString> aNames = GetPropertyNames(); + + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + switch(nProp) + { + case 0: pValues[nProp] <<= m_rParent.IsSnap(); break;// "Option/SnapToGrid", + case 1: pValues[nProp] <<= m_rParent.IsGridVisible(); break;//"Option/VisibleGrid", + case 2: pValues[nProp] <<= m_rParent.IsSynchronize(); break;// "Option/Synchronize", + case 3: pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(m_rParent.GetSnapSize().Width())); break;// "Resolution/XAxis", + case 4: pValues[nProp] <<= static_cast<sal_Int32>(convertTwipToMm100(m_rParent.GetSnapSize().Height())); break;// "Resolution/YAxis", + case 5: pValues[nProp] <<= static_cast<sal_Int16>(m_rParent.GetDivisionX()); break;// "Subdivision/XAxis", + case 6: pValues[nProp] <<= static_cast<sal_Int16>(m_rParent.GetDivisionY()); break;// "Subdivision/YAxis" + } + } + PutProperties(aNames, aValues); +} + +void SwGridConfig::Load() +{ + Sequence<OUString> aNames = GetPropertyNames(); + Sequence<Any> aValues = GetProperties(aNames); + const Any* pValues = aValues.getConstArray(); + OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); + if(aValues.getLength() != aNames.getLength()) + return; + + Size aSnap(m_rParent.GetSnapSize()); + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + if(pValues[nProp].hasValue()) + { + bool bSet = nProp < 3 && *o3tl::doAccess<bool>(pValues[nProp]); + sal_Int32 nSet = 0; + if(nProp >= 3) + pValues[nProp] >>= nSet; + switch(nProp) + { + case 0: m_rParent.SetSnap(bSet); break;// "Option/SnapToGrid", + case 1: m_rParent.SetGridVisible(bSet); break;//"Option/VisibleGrid", + case 2: m_rParent.SetSynchronize(bSet); break;// "Option/Synchronize", + case 3: aSnap.setWidth( o3tl::toTwips(nSet, o3tl::Length::mm100) ); break;// "Resolution/XAxis", + case 4: aSnap.setHeight( o3tl::toTwips(nSet, o3tl::Length::mm100) ); break;// "Resolution/YAxis", + case 5: m_rParent.SetDivisionX(static_cast<short>(nSet)); break;// "Subdivision/XAxis", + case 6: m_rParent.SetDivisionY(static_cast<short>(nSet)); break;// "Subdivision/YAxis" + } + } + } + m_rParent.SetSnapSize(aSnap); +} + +void SwGridConfig::Notify( const css::uno::Sequence< OUString >& ) {} + +Sequence<OUString> SwCursorConfig::GetPropertyNames() +{ + static const char* aPropNames[] = + { + "DirectCursor/UseDirectCursor", // 0 + "DirectCursor/Insert", // 1 + "Option/ProtectedArea", // 2 + }; + const int nCount = SAL_N_ELEMENTS(aPropNames); + Sequence<OUString> aNames(nCount); + OUString* pNames = aNames.getArray(); + for(int i = 0; i < nCount; i++) + pNames[i] = OUString::createFromAscii(aPropNames[i]); + return aNames; +} + +SwCursorConfig::SwCursorConfig(SwMasterUsrPref& rPar) : + ConfigItem("Office.Writer/Cursor", ConfigItemMode::ReleaseTree), + m_rParent(rPar) +{ +} + +SwCursorConfig::~SwCursorConfig() +{ +} + +void SwCursorConfig::ImplCommit() +{ + Sequence<OUString> aNames = GetPropertyNames(); + + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + switch(nProp) + { + case 0: pValues[nProp] <<= m_rParent.IsShadowCursor(); break; // "DirectCursor/UseDirectCursor", + case 1: pValues[nProp] <<= static_cast<sal_Int32>(m_rParent.GetShdwCursorFillMode()); break; // "DirectCursor/Insert", + case 2: pValues[nProp] <<= m_rParent.IsCursorInProtectedArea(); break; // "Option/ProtectedArea" + } + } + PutProperties(aNames, aValues); +} + +void SwCursorConfig::Load() +{ + Sequence<OUString> aNames = GetPropertyNames(); + Sequence<Any> aValues = GetProperties(aNames); + const Any* pValues = aValues.getConstArray(); + OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed"); + if(aValues.getLength() != aNames.getLength()) + return; + + + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + if(pValues[nProp].hasValue()) + { + bool bSet = false; + sal_Int32 nSet = 0; + if(nProp != 1 ) + bSet = *o3tl::doAccess<bool>(pValues[nProp]); + else + pValues[nProp] >>= nSet; + switch(nProp) + { + case 0: m_rParent.SetShadowCursor(bSet); break; // "DirectCursor/UseDirectCursor", + case 1: m_rParent.SetShdwCursorFillMode(static_cast<SwFillMode>(nSet)); break; // "DirectCursor/Insert", + case 2: m_rParent.SetCursorInProtectedArea(bSet); break; // "Option/ProtectedArea" + } + } + } +} + +void SwCursorConfig::Notify( const css::uno::Sequence< OUString >& ) {} + +SwWebColorConfig::SwWebColorConfig(SwMasterUsrPref& rPar) : + ConfigItem("Office.WriterWeb/Background", ConfigItemMode::ReleaseTree), + m_rParent(rPar), + m_aPropNames(1) +{ + m_aPropNames.getArray()[0] = "Color"; +} + +SwWebColorConfig::~SwWebColorConfig() +{ +} + +void SwWebColorConfig::ImplCommit() +{ + Sequence<Any> aValues(m_aPropNames.getLength()); + Any* pValues = aValues.getArray(); + for(int nProp = 0; nProp < m_aPropNames.getLength(); nProp++) + { + switch(nProp) + { + case 0: pValues[nProp] <<= m_rParent.GetRetoucheColor(); break;// "Color", + } + } + PutProperties(m_aPropNames, aValues); +} + +void SwWebColorConfig::Notify( const css::uno::Sequence< OUString >& ) {} + +void SwWebColorConfig::Load() +{ + Sequence<Any> aValues = GetProperties(m_aPropNames); + const Any* pValues = aValues.getConstArray(); + OSL_ENSURE(aValues.getLength() == m_aPropNames.getLength(), "GetProperties failed"); + if(aValues.getLength() != m_aPropNames.getLength()) + return; + + for(int nProp = 0; nProp < m_aPropNames.getLength(); nProp++) + { + if(pValues[nProp].hasValue()) + { + switch(nProp) + { + case 0: + Color nSet; + pValues[nProp] >>= nSet; m_rParent.SetRetoucheColor(nSet); + break;// "Color", + } + } + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/config/viewopt.cxx b/sw/source/uibase/config/viewopt.cxx new file mode 100644 index 000000000..c5e6f3e56 --- /dev/null +++ b/sw/source/uibase/config/viewopt.cxx @@ -0,0 +1,611 @@ +/* -*- 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 <sfx2/htmlmode.hxx> +#include <svtools/htmlcfg.hxx> + +#include <editeng/editids.hrc> +#include <editeng/svxacorr.hxx> +#include <officecfg/Office/Common.hxx> +#include <unotools/localedatawrapper.hxx> +#include <vcl/outdev.hxx> +#include <swmodule.hxx> +#include <viewopt.hxx> +#include <wdocsh.hxx> +#include <swrect.hxx> +#include <crstate.hxx> +#include <authratr.hxx> +#include <svtools/colorcfg.hxx> +#include <svtools/accessibilityoptions.hxx> +#include <unotools/configmgr.hxx> +#include <unotools/syslocale.hxx> + +#include <editeng/acorrcfg.hxx> +#include <comphelper/lok.hxx> +#include <comphelper/configurationlistener.hxx> + +Color SwViewOption::s_aDocBoundColor(COL_LIGHTGRAY); +Color SwViewOption::s_aObjectBoundColor(COL_LIGHTGRAY); +Color SwViewOption::s_aDocColor(COL_LIGHTGRAY); +Color SwViewOption::s_aAppBackgroundColor(COL_LIGHTGRAY); +Color SwViewOption::s_aTableBoundColor(COL_LIGHTGRAY); +Color SwViewOption::s_aIndexShadingsColor(COL_LIGHTGRAY); +Color SwViewOption::s_aLinksColor(COL_BLUE); +Color SwViewOption::s_aVisitedLinksColor(COL_RED); +Color SwViewOption::s_aDirectCursorColor(COL_BLUE); +Color SwViewOption::s_aTextGridColor(COL_LIGHTGRAY); +Color SwViewOption::s_aSpellColor(COL_LIGHTRED); +Color SwViewOption::s_aSmarttagColor(COL_LIGHTMAGENTA); +Color SwViewOption::s_aFontColor(COL_BLACK); +Color SwViewOption::s_aFieldShadingsColor(COL_LIGHTGRAY); +Color SwViewOption::s_aSectionBoundColor(COL_LIGHTGRAY); +Color SwViewOption::s_aPageBreakColor(COL_BLUE); +Color SwViewOption::s_aScriptIndicatorColor(COL_GREEN); +Color SwViewOption::s_aShadowColor(COL_GRAY); +Color SwViewOption::s_aHeaderFooterMarkColor(COL_BLUE); + +ViewOptFlags SwViewOption::s_nAppearanceFlags = ViewOptFlags::DocBoundaries|ViewOptFlags::ObjectBoundaries; +sal_uInt16 SwViewOption::s_nPixelTwips = 0; // one pixel on the screen + +bool SwViewOption::IsEqualFlags( const SwViewOption &rOpt ) const +{ + return m_nCoreOptions == rOpt.m_nCoreOptions + && m_nCore2Options == rOpt.m_nCore2Options + && m_aSnapSize == rOpt.m_aSnapSize + && mnViewLayoutColumns == rOpt.mnViewLayoutColumns + && m_nDivisionX == rOpt.GetDivisionX() + && m_nDivisionY == rOpt.GetDivisionY() + && m_nPagePreviewRow == rOpt.GetPagePrevRow() + && m_nPagePreviewCol == rOpt.GetPagePrevCol() + && m_aRetouchColor == rOpt.GetRetoucheColor() + && mbFormView == rOpt.IsFormView() + && mbBrowseMode == rOpt.getBrowseMode() + && mbViewLayoutBookMode == rOpt.mbViewLayoutBookMode + && mbHideWhitespaceMode == rOpt.mbHideWhitespaceMode + && m_bShowPlaceHolderFields == rOpt.m_bShowPlaceHolderFields + && m_bIdle == rOpt.m_bIdle + && m_nDefaultAnchor == rOpt.m_nDefaultAnchor +#ifdef DBG_UTIL + // correspond to the statements in ui/config/cfgvw.src + && m_bTest1 == rOpt.IsTest1() + && m_bTest2 == rOpt.IsTest2() + && m_bTest3 == rOpt.IsTest3() + && m_bTest4 == rOpt.IsTest4() + && m_bTest5 == rOpt.IsTest5() + && m_bTest6 == rOpt.IsTest6() + && m_bTest7 == rOpt.IsTest7() + && m_bTest8 == rOpt.IsTest8() + && m_bTest10 == rOpt.IsTest10() +#endif + ; +} + +bool SwViewOption::IsShowOutlineContentVisibilityButton() const +{ + return static_cast<bool>(m_nCoreOptions & ViewOptFlags1::ShowOutlineContentVisibilityButton); +} + +bool SwViewOption::IsTreatSubOutlineLevelsAsContent() const +{ + return static_cast<bool>(m_nCoreOptions & ViewOptFlags1::TreatSubOutlineLevelsAsContent); +} + +void SwViewOption::DrawRect( OutputDevice *pOut, + const SwRect &rRect, ::Color nCol ) +{ + if ( pOut->GetOutDevType() != OUTDEV_PRINTER ) + { + const Color aCol( nCol ); + const Color aOldColor( pOut->GetFillColor() ); + pOut->SetFillColor( aCol ); + pOut->DrawRect( rRect.SVRect() ); + pOut->SetFillColor( aOldColor ); + } + else + DrawRectPrinter( pOut, rRect ); +} + +void SwViewOption::DrawRectPrinter( OutputDevice *pOut, + const SwRect &rRect ) +{ + Color aOldColor(pOut->GetLineColor()); + Color aOldFillColor( pOut->GetFillColor() ); + pOut->SetLineColor( COL_BLACK ); + pOut->SetFillColor( COL_TRANSPARENT); + pOut->DrawRect( rRect.SVRect() ); + pOut->SetFillColor( aOldFillColor ); + pOut->SetLineColor( aOldColor ); +} + +sal_uInt16 SwViewOption::GetPostItsWidth( const OutputDevice *pOut ) +{ + assert(pOut && "no Outdev"); + return sal_uInt16(pOut->GetTextWidth(" ")); +} + +void SwViewOption::PaintPostIts( OutputDevice *pOut, const SwRect &rRect, bool bIsScript ) +{ + if( !(pOut && bIsScript) ) + return; + + Color aOldLineColor( pOut->GetLineColor() ); + pOut->SetLineColor( COL_GRAY ); + // to make it look nice, we subtract two pixels everywhere + sal_uInt16 nPix = s_nPixelTwips * 2; + if( rRect.Width() <= 2 * nPix || rRect.Height() <= 2 * nPix ) + nPix = 0; + const Point aTopLeft( rRect.Left() + nPix, rRect.Top() + nPix ); + const Point aBotRight( rRect.Right() - nPix, rRect.Bottom() - nPix ); + const SwRect aRect( aTopLeft, aBotRight ); + DrawRect( pOut, aRect, s_aScriptIndicatorColor ); + pOut->SetLineColor( aOldLineColor ); +} + +SwViewOption::SwViewOption() : + m_sSymbolFont( "symbol" ), + m_aRetouchColor( COL_TRANSPARENT ), + mnViewLayoutColumns( 0 ), + m_nPagePreviewRow( 1 ), + m_nPagePreviewCol( 2 ), + m_nShadowCursorFillMode( SwFillMode::Tab ), + m_bReadonly(false), + m_bStarOneSetting(false), + m_bIsPagePreview(false), + m_bSelectionInReadonly(false), + mbFormView(false), + mbBrowseMode(false), + mbBookView(false), + mbViewLayoutBookMode(false), + mbHideWhitespaceMode(false), + m_bShowPlaceHolderFields( true ), + m_nZoom( 100 ), + m_eZoom( SvxZoomType::PERCENT ), + m_nTableDestination(TBL_DEST_CELL) +{ + // Initialisation is a little simpler now + // all Bits to 0 + m_nCoreOptions = + ViewOptFlags1::HardBlank | + ViewOptFlags1::SoftHyph | + ViewOptFlags1::Ref | + ViewOptFlags1::Graphic | + ViewOptFlags1::Table | + ViewOptFlags1::Draw | + ViewOptFlags1::Control | + ViewOptFlags1::Pageback | + ViewOptFlags1::Postits; + + m_nCore2Options = + ViewOptCoreFlags2::BlackFont | + ViewOptCoreFlags2::HiddenPara; + + m_nUIOptions = + ViewOptFlags2::Modified | + ViewOptFlags2::GrfKeepZoom | + ViewOptFlags2::ResolvedPostits | + ViewOptFlags2::AnyRuler; + + if (!utl::ConfigManager::IsFuzzing() && MeasurementSystem::Metric != SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()) + { + m_aSnapSize.setWidth(720); // 1/2" + m_aSnapSize.setHeight(720); // 1/2" + + } + else + { + m_aSnapSize.setWidth(567); // 1 cm + m_aSnapSize.setHeight(567); // 1 cm + } + m_nDivisionX = m_nDivisionY = 1; + + m_bSelectionInReadonly = !utl::ConfigManager::IsFuzzing() && SW_MOD()->GetAccessibilityOptions().IsSelectionInReadonly(); + + m_bIdle = true; + + m_nDefaultAnchor = 1; //FLY_TO_CHAR + +#ifdef DBG_UTIL + // correspond to the statements in ui/config/cfgvw.src + m_bTest1 = m_bTest2 = m_bTest3 = m_bTest4 = + m_bTest5 = m_bTest6 = m_bTest7 = m_bTest8 = m_bTest10 = false; +#endif + if (comphelper::LibreOfficeKit::isActive()) + s_aAppBackgroundColor = COL_TRANSPARENT; +} + +SwViewOption::SwViewOption(const SwViewOption& rVOpt) +{ + m_bReadonly = false; + m_bSelectionInReadonly = false; + // #114856# Form view + mbFormView = rVOpt.mbFormView; + m_nZoom = rVOpt.m_nZoom ; + m_aSnapSize = rVOpt.m_aSnapSize ; + mnViewLayoutColumns = rVOpt.mnViewLayoutColumns ; + m_nDivisionX = rVOpt.m_nDivisionX ; + m_nDivisionY = rVOpt.m_nDivisionY ; + m_nPagePreviewRow = rVOpt.m_nPagePreviewRow; + m_nPagePreviewCol = rVOpt.m_nPagePreviewCol; + m_bIsPagePreview = rVOpt.m_bIsPagePreview; + m_eZoom = rVOpt.m_eZoom ; + m_nTableDestination = rVOpt.m_nTableDestination ; + m_nUIOptions = rVOpt.m_nUIOptions ; + m_nCoreOptions = rVOpt.m_nCoreOptions ; + m_nCore2Options = rVOpt.m_nCore2Options ; + m_aRetouchColor = rVOpt.GetRetoucheColor(); + m_sSymbolFont = rVOpt.m_sSymbolFont; + m_nShadowCursorFillMode = rVOpt.m_nShadowCursorFillMode; + m_bStarOneSetting = rVOpt.m_bStarOneSetting; + mbBookView = rVOpt.mbBookView; + mbBrowseMode = rVOpt.mbBrowseMode; + mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode; + mbHideWhitespaceMode = rVOpt.mbHideWhitespaceMode; + m_bShowPlaceHolderFields = rVOpt.m_bShowPlaceHolderFields; + m_bIdle = rVOpt.m_bIdle; + m_nDefaultAnchor = rVOpt.m_nDefaultAnchor; + +#ifdef DBG_UTIL + m_bTest1 = rVOpt.m_bTest1; + m_bTest2 = rVOpt.m_bTest2; + m_bTest3 = rVOpt.m_bTest3; + m_bTest4 = rVOpt.m_bTest4; + m_bTest5 = rVOpt.m_bTest5; + m_bTest6 = rVOpt.m_bTest6; + m_bTest7 = rVOpt.m_bTest7; + m_bTest8 = rVOpt.m_bTest8; + m_bTest10 = rVOpt.m_bTest10; +#endif +} + +SwViewOption& SwViewOption::operator=( const SwViewOption &rVOpt ) +{ + // #114856# Form view + mbFormView = rVOpt.mbFormView ; + m_nZoom = rVOpt.m_nZoom ; + m_aSnapSize = rVOpt.m_aSnapSize ; + mnViewLayoutColumns = rVOpt.mnViewLayoutColumns ; + m_nDivisionX = rVOpt.m_nDivisionX ; + m_nDivisionY = rVOpt.m_nDivisionY ; + m_nPagePreviewRow = rVOpt.m_nPagePreviewRow; + m_nPagePreviewCol = rVOpt.m_nPagePreviewCol; + m_bIsPagePreview = rVOpt.m_bIsPagePreview; + m_eZoom = rVOpt.m_eZoom ; + m_nTableDestination = rVOpt.m_nTableDestination ; + m_nUIOptions = rVOpt.m_nUIOptions ; + m_nCoreOptions = rVOpt.m_nCoreOptions; + m_nCore2Options = rVOpt.m_nCore2Options; + m_aRetouchColor = rVOpt.GetRetoucheColor(); + m_sSymbolFont = rVOpt.m_sSymbolFont; + m_nShadowCursorFillMode = rVOpt.m_nShadowCursorFillMode; + m_bStarOneSetting = rVOpt.m_bStarOneSetting; + mbBookView = rVOpt.mbBookView; + mbBrowseMode = rVOpt.mbBrowseMode; + mbViewLayoutBookMode = rVOpt.mbViewLayoutBookMode; + mbHideWhitespaceMode = rVOpt.mbHideWhitespaceMode; + m_bShowPlaceHolderFields = rVOpt.m_bShowPlaceHolderFields; + m_bIdle = rVOpt.m_bIdle; + m_nDefaultAnchor = rVOpt.m_nDefaultAnchor; + +#ifdef DBG_UTIL + m_bTest1 = rVOpt.m_bTest1; + m_bTest2 = rVOpt.m_bTest2; + m_bTest3 = rVOpt.m_bTest3; + m_bTest4 = rVOpt.m_bTest4; + m_bTest5 = rVOpt.m_bTest5; + m_bTest6 = rVOpt.m_bTest6; + m_bTest7 = rVOpt.m_bTest7; + m_bTest8 = rVOpt.m_bTest8; + m_bTest10 = rVOpt.m_bTest10; +#endif + return *this; +} + +SwViewOption::~SwViewOption() +{ +} + +void SwViewOption::Init(const OutputDevice* pWin) +{ + if( !s_nPixelTwips && pWin ) + { + s_nPixelTwips = o3tl::narrowing<sal_uInt16>(pWin->PixelToLogic( Size(1,1) ).Height()); + } +} + +bool SwViewOption::IsAutoCompleteWords() +{ + const SvxSwAutoFormatFlags& rFlags = SvxAutoCorrCfg::Get().GetAutoCorrect()->GetSwFlags(); + return rFlags.bAutoCmpltCollectWords; +} + +void SwViewOption::SetOnlineSpell(bool b) +{ + if (b) + m_nCoreOptions |= ViewOptFlags1::OnlineSpell; + else + m_nCoreOptions &= ~ViewOptFlags1::OnlineSpell; +} + +AuthorCharAttr::AuthorCharAttr() : + m_nItemId (SID_ATTR_CHAR_UNDERLINE), + m_nAttr (LINESTYLE_SINGLE), + m_nColor (COL_TRANSPARENT) +{ +} + +sal_uInt16 GetHtmlMode(const SwDocShell* pShell) +{ + sal_uInt16 nRet = 0; + if(!pShell || dynamic_cast<const SwWebDocShell*>( pShell) ) + { + nRet = HTMLMODE_ON | HTMLMODE_SOME_STYLES; + switch ( SvxHtmlOptions::GetExportMode() ) + { + case HTML_CFG_MSIE: + nRet |= HTMLMODE_FULL_STYLES; + break; + case HTML_CFG_NS40: + // no special features for this browser + break; + case HTML_CFG_WRITER: + nRet |= HTMLMODE_FULL_STYLES; + break; + } + } + return nRet; +} + +RndStdIds SwViewOption::GetDefaultAnchorType() const +{ + switch ( m_nDefaultAnchor ) + { + case 0: + return RndStdIds::FLY_AT_PARA; //0 + case 1: + return RndStdIds::FLY_AT_CHAR; //4 + case 2: + return RndStdIds::FLY_AS_CHAR; //1 + default: + return RndStdIds::FLY_AT_CHAR; //4 + }//switch +} + +Color& SwViewOption::GetDocColor() +{ + return s_aDocColor; +} + +Color& SwViewOption::GetDocBoundariesColor() +{ + return s_aDocBoundColor; +} + +Color& SwViewOption::GetObjectBoundariesColor() +{ + return s_aObjectBoundColor; +} + +Color& SwViewOption::GetAppBackgroundColor() +{ + return s_aAppBackgroundColor; +} + +Color& SwViewOption::GetTableBoundariesColor() +{ + return s_aTableBoundColor; +} + +Color& SwViewOption::GetIndexShadingsColor() +{ + return s_aIndexShadingsColor; +} + +Color& SwViewOption::GetLinksColor() +{ + return s_aLinksColor; +} + +Color& SwViewOption::GetVisitedLinksColor() +{ + return s_aVisitedLinksColor; +} + +Color& SwViewOption::GetDirectCursorColor() +{ + return s_aDirectCursorColor; +} + +Color& SwViewOption::GetTextGridColor() +{ + return s_aTextGridColor; +} + +Color& SwViewOption::GetSpellColor() +{ + return s_aSpellColor; +} + +Color& SwViewOption::GetSmarttagColor() +{ + return s_aSmarttagColor; +} + +Color& SwViewOption::GetShadowColor() +{ + return s_aShadowColor; +} + +Color& SwViewOption::GetFontColor() +{ + return s_aFontColor; +} + +Color& SwViewOption::GetFieldShadingsColor() +{ + return s_aFieldShadingsColor; +} + +Color& SwViewOption::GetSectionBoundColor() +{ + return s_aSectionBoundColor; +} + +Color& SwViewOption::GetPageBreakColor() +{ + return s_aPageBreakColor; +} + +Color& SwViewOption::GetHeaderFooterMarkColor() +{ + return s_aHeaderFooterMarkColor; +} + +void SwViewOption::ApplyColorConfigValues(const svtools::ColorConfig& rConfig ) +{ + s_aDocColor = rConfig.GetColorValue(svtools::DOCCOLOR).nColor; + + svtools::ColorConfigValue aValue = rConfig.GetColorValue(svtools::DOCBOUNDARIES); + s_aDocBoundColor = aValue.nColor; + s_nAppearanceFlags = ViewOptFlags::NONE; + if(aValue.bIsVisible) + s_nAppearanceFlags |= ViewOptFlags::DocBoundaries; + + s_aAppBackgroundColor = rConfig.GetColorValue(svtools::APPBACKGROUND).nColor; + + aValue = rConfig.GetColorValue(svtools::OBJECTBOUNDARIES); + s_aObjectBoundColor = aValue.nColor; + if(aValue.bIsVisible) + s_nAppearanceFlags |= ViewOptFlags::ObjectBoundaries; + + aValue = rConfig.GetColorValue(svtools::TABLEBOUNDARIES); + s_aTableBoundColor = aValue.nColor; + if(aValue.bIsVisible) + s_nAppearanceFlags |= ViewOptFlags::TableBoundaries; + + aValue = rConfig.GetColorValue(svtools::WRITERIDXSHADINGS); + s_aIndexShadingsColor = aValue.nColor; + if(aValue.bIsVisible) + s_nAppearanceFlags |= ViewOptFlags::IndexShadings; + + aValue = rConfig.GetColorValue(svtools::LINKS); + s_aLinksColor = aValue.nColor; + if(aValue.bIsVisible) + s_nAppearanceFlags |= ViewOptFlags::Links; + + aValue = rConfig.GetColorValue(svtools::LINKSVISITED); + s_aVisitedLinksColor = aValue.nColor; + if(aValue.bIsVisible) + s_nAppearanceFlags |= ViewOptFlags::VisitedLinks; + + aValue = rConfig.GetColorValue(svtools::SHADOWCOLOR); + s_aShadowColor = aValue.nColor; + if(aValue.bIsVisible) + s_nAppearanceFlags |= ViewOptFlags::Shadow; + + s_aDirectCursorColor = rConfig.GetColorValue(svtools::WRITERDIRECTCURSOR).nColor; + + s_aTextGridColor = rConfig.GetColorValue(svtools::WRITERTEXTGRID).nColor; + + s_aSpellColor = rConfig.GetColorValue(svtools::SPELL).nColor; + + s_aSmarttagColor = rConfig.GetColorValue(svtools::SMARTTAGS).nColor; + + s_aFontColor = rConfig.GetColorValue(svtools::FONTCOLOR).nColor; + + aValue = rConfig.GetColorValue(svtools::WRITERFIELDSHADINGS); + s_aFieldShadingsColor = aValue.nColor; + if(aValue.bIsVisible) + s_nAppearanceFlags |= ViewOptFlags::FieldShadings; + + aValue = rConfig.GetColorValue(svtools::WRITERSECTIONBOUNDARIES); + s_aSectionBoundColor = aValue.nColor; + if(aValue.bIsVisible) + s_nAppearanceFlags |= ViewOptFlags::SectionBoundaries; + + aValue = rConfig.GetColorValue(svtools::WRITERPAGEBREAKS); + s_aPageBreakColor = aValue.nColor; + + aValue = rConfig.GetColorValue(svtools::WRITERHEADERFOOTERMARK); + s_aHeaderFooterMarkColor = aValue.nColor; + + s_aScriptIndicatorColor = rConfig.GetColorValue(svtools::WRITERSCRIPTINDICATOR).nColor; +} + +void SwViewOption::SetAppearanceFlag(ViewOptFlags nFlag, bool bSet, bool bSaveInConfig ) +{ + if(bSet) + s_nAppearanceFlags |= nFlag; + else + s_nAppearanceFlags &= ~nFlag; + if(!bSaveInConfig) + return; + + //create an editable svtools::ColorConfig and store the change + svtools::EditableColorConfig aEditableConfig; + struct FlagToConfig_Impl + { + ViewOptFlags nFlag; + svtools::ColorConfigEntry eEntry; + }; + static const FlagToConfig_Impl aFlags[] = + { + { ViewOptFlags::DocBoundaries , svtools::DOCBOUNDARIES }, + { ViewOptFlags::ObjectBoundaries , svtools::OBJECTBOUNDARIES }, + { ViewOptFlags::TableBoundaries , svtools::TABLEBOUNDARIES }, + { ViewOptFlags::IndexShadings , svtools::WRITERIDXSHADINGS }, + { ViewOptFlags::Links , svtools::LINKS }, + { ViewOptFlags::VisitedLinks , svtools::LINKSVISITED }, + { ViewOptFlags::FieldShadings , svtools::WRITERFIELDSHADINGS }, + { ViewOptFlags::SectionBoundaries , svtools::WRITERSECTIONBOUNDARIES }, + { ViewOptFlags::Shadow , svtools::SHADOWCOLOR }, + { ViewOptFlags::NONE , svtools::ColorConfigEntryCount } + }; + sal_uInt16 nPos = 0; + while(aFlags[nPos].nFlag != ViewOptFlags::NONE) + { + if(nFlag & aFlags[nPos].nFlag) + { + svtools::ColorConfigValue aValue = aEditableConfig.GetColorValue(aFlags[nPos].eEntry); + aValue.bIsVisible = bSet; + aEditableConfig.SetColorValue(aFlags[nPos].eEntry, aValue); + } + nPos++; + } +} + +bool SwViewOption::IsAppearanceFlag(ViewOptFlags nFlag) +{ + return bool(s_nAppearanceFlags & nFlag); +} + +namespace{ +rtl::Reference<comphelper::ConfigurationListener> const & getWCOptionListener() +{ + static rtl::Reference<comphelper::ConfigurationListener> xListener(new comphelper::ConfigurationListener("/org.openoffice.Office.Writer/Cursor/Option")); + return xListener; +} +} + +bool SwViewOption::IsIgnoreProtectedArea() +{ + static comphelper::ConfigurationListenerProperty<bool> gIgnoreProtectedArea(getWCOptionListener(), "IgnoreProtectedArea"); + return gIgnoreProtectedArea.get(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |