/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace com::sun::star::uno; using namespace com::sun::star::beans; constexpr OUStringLiteral SYMBOL_LIST = u"SymbolList"; constexpr OUStringLiteral FONT_FORMAT_LIST = u"FontFormatList"; static Sequence< OUString > lcl_GetFontPropertyNames() { return Sequence< OUString > { "Name", "CharSet", "Family", "Pitch", "Weight", "Italic" }; } static Sequence< OUString > lcl_GetSymbolPropertyNames() { return Sequence< OUString > { "Char", "Set", "Predefined", "FontFormatId" }; } static Sequence< OUString > lcl_GetFormatPropertyNames() { //! Beware of order according to *_BEGIN *_END defines in format.hxx ! //! see respective load/save routines here return Sequence< OUString > { "StandardFormat/Textmode", "StandardFormat/GreekCharStyle", "StandardFormat/ScaleNormalBracket", "StandardFormat/HorizontalAlignment", "StandardFormat/BaseSize", "StandardFormat/TextSize", "StandardFormat/IndexSize", "StandardFormat/FunctionSize", "StandardFormat/OperatorSize", "StandardFormat/LimitsSize", "StandardFormat/Distance/Horizontal", "StandardFormat/Distance/Vertical", "StandardFormat/Distance/Root", "StandardFormat/Distance/SuperScript", "StandardFormat/Distance/SubScript", "StandardFormat/Distance/Numerator", "StandardFormat/Distance/Denominator", "StandardFormat/Distance/Fraction", "StandardFormat/Distance/StrokeWidth", "StandardFormat/Distance/UpperLimit", "StandardFormat/Distance/LowerLimit", "StandardFormat/Distance/BracketSize", "StandardFormat/Distance/BracketSpace", "StandardFormat/Distance/MatrixRow", "StandardFormat/Distance/MatrixColumn", "StandardFormat/Distance/OrnamentSize", "StandardFormat/Distance/OrnamentSpace", "StandardFormat/Distance/OperatorSize", "StandardFormat/Distance/OperatorSpace", "StandardFormat/Distance/LeftSpace", "StandardFormat/Distance/RightSpace", "StandardFormat/Distance/TopSpace", "StandardFormat/Distance/BottomSpace", "StandardFormat/Distance/NormalBracketSize", "StandardFormat/VariableFont", "StandardFormat/FunctionFont", "StandardFormat/NumberFont", "StandardFormat/TextFont", "StandardFormat/SerifFont", "StandardFormat/SansFont", "StandardFormat/FixedFont" }; } struct SmCfgOther { SmPrintSize ePrintSize; sal_uInt16 nPrintZoomFactor; sal_uInt16 nSmEditWindowZoomFactor; sal_uInt16 nSmSyntaxVersion; bool bPrintTitle; bool bPrintFormulaText; bool bPrintFrame; bool bIsSaveOnlyUsedSymbols; bool bIsAutoCloseBrackets; bool bIgnoreSpacesRight; bool bToolboxVisible; bool bAutoRedraw; bool bFormulaCursor; SmCfgOther(); }; constexpr sal_uInt16 nDefaultSmSyntaxVersion(5); SmCfgOther::SmCfgOther() : ePrintSize(PRINT_SIZE_NORMAL) , nPrintZoomFactor(100) , nSmEditWindowZoomFactor(100) // Defaulted as 5 so I have time to code the parser 6 , nSmSyntaxVersion(nDefaultSmSyntaxVersion) , bPrintTitle(true) , bPrintFormulaText(true) , bPrintFrame(true) , bIsSaveOnlyUsedSymbols(true) , bIsAutoCloseBrackets(true) , bIgnoreSpacesRight(true) , bToolboxVisible(true) , bAutoRedraw(true) , bFormulaCursor(true) { } SmFontFormat::SmFontFormat() : aName(FONTNAME_MATH) , nCharSet(RTL_TEXTENCODING_UNICODE) , nFamily(FAMILY_DONTKNOW) , nPitch(PITCH_DONTKNOW) , nWeight(WEIGHT_DONTKNOW) , nItalic(ITALIC_NONE) { } SmFontFormat::SmFontFormat( const vcl::Font &rFont ) : aName(rFont.GetFamilyName()) , nCharSet(static_cast(rFont.GetCharSet())) , nFamily(static_cast(rFont.GetFamilyType())) , nPitch(static_cast(rFont.GetPitch())) , nWeight(static_cast(rFont.GetWeight())) , nItalic(static_cast(rFont.GetItalic())) { } vcl::Font SmFontFormat::GetFont() const { vcl::Font aRes; aRes.SetFamilyName( aName ); aRes.SetCharSet( static_cast(nCharSet) ); aRes.SetFamily( static_cast(nFamily) ); aRes.SetPitch( static_cast(nPitch) ); aRes.SetWeight( static_cast(nWeight) ); aRes.SetItalic( static_cast(nItalic) ); return aRes; } bool SmFontFormat::operator == ( const SmFontFormat &rFntFmt ) const { return aName == rFntFmt.aName && nCharSet == rFntFmt.nCharSet && nFamily == rFntFmt.nFamily && nPitch == rFntFmt.nPitch && nWeight == rFntFmt.nWeight && nItalic == rFntFmt.nItalic; } SmFntFmtListEntry::SmFntFmtListEntry( const OUString &rId, const SmFontFormat &rFntFmt ) : aId (rId), aFntFmt (rFntFmt) { } SmFontFormatList::SmFontFormatList() : bModified(false) { } void SmFontFormatList::Clear() { if (!aEntries.empty()) { aEntries.clear(); SetModified( true ); } } void SmFontFormatList::AddFontFormat( const OUString &rFntFmtId, const SmFontFormat &rFntFmt ) { const SmFontFormat *pFntFmt = GetFontFormat( rFntFmtId ); OSL_ENSURE( !pFntFmt, "FontFormatId already exists" ); if (!pFntFmt) { SmFntFmtListEntry aEntry( rFntFmtId, rFntFmt ); aEntries.push_back( aEntry ); SetModified( true ); } } void SmFontFormatList::RemoveFontFormat( std::u16string_view rFntFmtId ) { // search for entry for (size_t i = 0; i < aEntries.size(); ++i) { if (aEntries[i].aId == rFntFmtId) { // remove entry if found aEntries.erase( aEntries.begin() + i ); SetModified( true ); break; } } } const SmFontFormat * SmFontFormatList::GetFontFormat( std::u16string_view rFntFmtId ) const { const SmFontFormat *pRes = nullptr; for (const auto & rEntry : aEntries) { if (rEntry.aId == rFntFmtId) { pRes = &rEntry.aFntFmt; break; } } return pRes; } const SmFontFormat * SmFontFormatList::GetFontFormat( size_t nPos ) const { const SmFontFormat *pRes = nullptr; if (nPos < aEntries.size()) pRes = &aEntries[nPos].aFntFmt; return pRes; } OUString SmFontFormatList::GetFontFormatId( const SmFontFormat &rFntFmt ) const { OUString aRes; for (const auto & rEntry : aEntries) { if (rEntry.aFntFmt == rFntFmt) { aRes = rEntry.aId; break; } } return aRes; } OUString SmFontFormatList::GetFontFormatId( const SmFontFormat &rFntFmt, bool bAdd ) { OUString aRes( GetFontFormatId( rFntFmt) ); if (aRes.isEmpty() && bAdd) { aRes = GetNewFontFormatId(); AddFontFormat( aRes, rFntFmt ); } return aRes; } OUString SmFontFormatList::GetFontFormatId( size_t nPos ) const { OUString aRes; if (nPos < aEntries.size()) aRes = aEntries[nPos].aId; return aRes; } OUString SmFontFormatList::GetNewFontFormatId() const { // returns first unused FormatId sal_Int32 nCnt = GetCount(); for (sal_Int32 i = 1; i <= nCnt + 1; ++i) { OUString aTmpId = "Id" + OUString::number(i); if (!GetFontFormat(aTmpId)) return aTmpId; } OSL_ENSURE( false, "failed to create new FontFormatId" ); return OUString(); } SmMathConfig::SmMathConfig() : ConfigItem("Office.Math") , bIsOtherModified(false) , bIsFormatModified(false) { } SmMathConfig::~SmMathConfig() { Save(); } void SmMathConfig::SetOtherModified( bool bVal ) { bIsOtherModified = bVal; } void SmMathConfig::SetFormatModified( bool bVal ) { bIsFormatModified = bVal; } void SmMathConfig::ReadSymbol( SmSym &rSymbol, const OUString &rSymbolName, std::u16string_view rBaseNode ) const { Sequence< OUString > aNames = lcl_GetSymbolPropertyNames(); sal_Int32 nProps = aNames.getLength(); OUString aDelim( "/" ); for (auto& rName : asNonConstRange(aNames)) rName = rBaseNode + aDelim + rSymbolName + aDelim + rName; const Sequence< Any > aValues = const_cast(this)->GetProperties(aNames); if (!(nProps && aValues.getLength() == nProps)) return; const Any * pValue = aValues.getConstArray(); vcl::Font aFont; sal_UCS4 cChar = '\0'; OUString aSet; bool bPredefined = false; OUString aTmpStr; sal_Int32 nTmp32 = 0; bool bTmp = false; bool bOK = true; if (pValue->hasValue() && (*pValue >>= nTmp32)) cChar = static_cast< sal_UCS4 >( nTmp32 ); else bOK = false; ++pValue; if (pValue->hasValue() && (*pValue >>= aTmpStr)) aSet = aTmpStr; else bOK = false; ++pValue; if (pValue->hasValue() && (*pValue >>= bTmp)) bPredefined = bTmp; else bOK = false; ++pValue; if (pValue->hasValue() && (*pValue >>= aTmpStr)) { const SmFontFormat *pFntFmt = GetFontFormatList().GetFontFormat( aTmpStr ); OSL_ENSURE( pFntFmt, "unknown FontFormat" ); if (pFntFmt) aFont = pFntFmt->GetFont(); } else bOK = false; ++pValue; if (bOK) { OUString aUiName( rSymbolName ); OUString aUiSetName( aSet ); if (bPredefined) { OUString aTmp; aTmp = SmLocalizedSymbolData::GetUiSymbolName( rSymbolName ); OSL_ENSURE( !aTmp.isEmpty(), "localized symbol-name not found" ); if (!aTmp.isEmpty()) aUiName = aTmp; aTmp = SmLocalizedSymbolData::GetUiSymbolSetName( aSet ); OSL_ENSURE( !aTmp.isEmpty(), "localized symbolset-name not found" ); if (!aTmp.isEmpty()) aUiSetName = aTmp; } rSymbol = SmSym( aUiName, aFont, cChar, aUiSetName, bPredefined ); if (aUiName != rSymbolName) rSymbol.SetExportName( rSymbolName ); } else { SAL_WARN("starmath", "symbol read error"); } } SmSymbolManager & SmMathConfig::GetSymbolManager() { if (!pSymbolMgr) { pSymbolMgr.reset(new SmSymbolManager); pSymbolMgr->Load(); } return *pSymbolMgr; } void SmMathConfig::ImplCommit() { Save(); } void SmMathConfig::Save() { SaveOther(); SaveFormat(); SaveFontFormatList(); } void SmMathConfig::GetSymbols( std::vector< SmSym > &rSymbols ) const { Sequence< OUString > aNodes(const_cast(this)->GetNodeNames(SYMBOL_LIST)); const OUString *pNode = aNodes.getConstArray(); sal_Int32 nNodes = aNodes.getLength(); rSymbols.resize( nNodes ); for (auto& rSymbol : rSymbols) { ReadSymbol( rSymbol, *pNode++, SYMBOL_LIST ); } } void SmMathConfig::SetSymbols( const std::vector< SmSym > &rNewSymbols ) { auto nCount = sal::static_int_cast(rNewSymbols.size()); Sequence< OUString > aNames = lcl_GetSymbolPropertyNames(); const OUString *pNames = aNames.getConstArray(); sal_Int32 nSymbolProps = aNames.getLength(); Sequence< PropertyValue > aValues( nCount * nSymbolProps ); PropertyValue *pValues = aValues.getArray(); PropertyValue *pVal = pValues; OUString aDelim( "/" ); for (const SmSym& rSymbol : rNewSymbols) { OUString aNodeNameDelim = SYMBOL_LIST + aDelim + rSymbol.GetExportName() + aDelim; const OUString *pName = pNames; // Char pVal->Name = aNodeNameDelim; pVal->Name += *pName++; pVal->Value <<= rSymbol.GetCharacter(); pVal++; // Set pVal->Name = aNodeNameDelim; pVal->Name += *pName++; OUString aTmp( rSymbol.GetSymbolSetName() ); if (rSymbol.IsPredefined()) aTmp = SmLocalizedSymbolData::GetExportSymbolSetName( aTmp ); pVal->Value <<= aTmp; pVal++; // Predefined pVal->Name = aNodeNameDelim; pVal->Name += *pName++; pVal->Value <<= rSymbol.IsPredefined(); pVal++; // FontFormatId SmFontFormat aFntFmt( rSymbol.GetFace() ); OUString aFntFmtId( GetFontFormatList().GetFontFormatId( aFntFmt, true ) ); OSL_ENSURE( !aFntFmtId.isEmpty(), "FontFormatId not found" ); pVal->Name = aNodeNameDelim; pVal->Name += *pName++; pVal->Value <<= aFntFmtId; pVal++; } OSL_ENSURE( pVal - pValues == sal::static_int_cast< ptrdiff_t >(nCount * nSymbolProps), "properties missing" ); ReplaceSetProperties( SYMBOL_LIST, aValues ); StripFontFormatList( rNewSymbols ); SaveFontFormatList(); } SmFontFormatList & SmMathConfig::GetFontFormatList() { if (!pFontFormatList) { LoadFontFormatList(); } return *pFontFormatList; } void SmMathConfig::LoadFontFormatList() { if (!pFontFormatList) pFontFormatList.reset(new SmFontFormatList); else pFontFormatList->Clear(); const Sequence< OUString > aNodes( GetNodeNames( FONT_FORMAT_LIST ) ); for (const OUString& rNode : aNodes) { SmFontFormat aFntFmt; ReadFontFormat( aFntFmt, rNode, FONT_FORMAT_LIST ); if (!pFontFormatList->GetFontFormat( rNode )) pFontFormatList->AddFontFormat( rNode, aFntFmt ); } pFontFormatList->SetModified( false ); } void SmMathConfig::ReadFontFormat( SmFontFormat &rFontFormat, std::u16string_view rSymbolName, std::u16string_view rBaseNode ) const { Sequence< OUString > aNames = lcl_GetFontPropertyNames(); sal_Int32 nProps = aNames.getLength(); OUString aDelim( "/" ); for (auto& rName : asNonConstRange(aNames)) rName = rBaseNode + aDelim + rSymbolName + aDelim + rName; const Sequence< Any > aValues = const_cast(this)->GetProperties(aNames); if (!(nProps && aValues.getLength() == nProps)) return; const Any * pValue = aValues.getConstArray(); OUString aTmpStr; sal_Int16 nTmp16 = 0; bool bOK = true; if (pValue->hasValue() && (*pValue >>= aTmpStr)) rFontFormat.aName = aTmpStr; else bOK = false; ++pValue; if (pValue->hasValue() && (*pValue >>= nTmp16)) rFontFormat.nCharSet = nTmp16; // 6.0 file-format GetSOLoadTextEncoding not needed else bOK = false; ++pValue; if (pValue->hasValue() && (*pValue >>= nTmp16)) rFontFormat.nFamily = nTmp16; else bOK = false; ++pValue; if (pValue->hasValue() && (*pValue >>= nTmp16)) rFontFormat.nPitch = nTmp16; else bOK = false; ++pValue; if (pValue->hasValue() && (*pValue >>= nTmp16)) rFontFormat.nWeight = nTmp16; else bOK = false; ++pValue; if (pValue->hasValue() && (*pValue >>= nTmp16)) rFontFormat.nItalic = nTmp16; else bOK = false; ++pValue; OSL_ENSURE( bOK, "read FontFormat failed" ); } void SmMathConfig::SaveFontFormatList() { SmFontFormatList &rFntFmtList = GetFontFormatList(); if (!rFntFmtList.IsModified()) return; Sequence< OUString > aNames = lcl_GetFontPropertyNames(); sal_Int32 nSymbolProps = aNames.getLength(); size_t nCount = rFntFmtList.GetCount(); Sequence< PropertyValue > aValues( nCount * nSymbolProps ); PropertyValue *pValues = aValues.getArray(); PropertyValue *pVal = pValues; OUString aDelim( "/" ); for (size_t i = 0; i < nCount; ++i) { OUString aFntFmtId(rFntFmtList.GetFontFormatId(i)); const SmFontFormat *pFntFmt = rFntFmtList.GetFontFormat(i); assert(pFntFmt); const SmFontFormat aFntFmt(*pFntFmt); OUString aNodeNameDelim = FONT_FORMAT_LIST + aDelim + aFntFmtId + aDelim; const OUString *pName = aNames.getConstArray(); // Name pVal->Name = aNodeNameDelim; pVal->Name += *pName++; pVal->Value <<= aFntFmt.aName; pVal++; // CharSet pVal->Name = aNodeNameDelim; pVal->Name += *pName++; pVal->Value <<= aFntFmt.nCharSet; // 6.0 file-format GetSOStoreTextEncoding not needed pVal++; // Family pVal->Name = aNodeNameDelim; pVal->Name += *pName++; pVal->Value <<= aFntFmt.nFamily; pVal++; // Pitch pVal->Name = aNodeNameDelim; pVal->Name += *pName++; pVal->Value <<= aFntFmt.nPitch; pVal++; // Weight pVal->Name = aNodeNameDelim; pVal->Name += *pName++; pVal->Value <<= aFntFmt.nWeight; pVal++; // Italic pVal->Name = aNodeNameDelim; pVal->Name += *pName++; pVal->Value <<= aFntFmt.nItalic; pVal++; } OSL_ENSURE( sal::static_int_cast(pVal - pValues) == nCount * nSymbolProps, "properties missing" ); ReplaceSetProperties( FONT_FORMAT_LIST, aValues ); rFntFmtList.SetModified( false ); } void SmMathConfig::StripFontFormatList( const std::vector< SmSym > &rSymbols ) { size_t i; // build list of used font-formats only //!! font-format IDs may be different !! SmFontFormatList aUsedList; for (i = 0; i < rSymbols.size(); ++i) { OSL_ENSURE( rSymbols[i].GetName().getLength() > 0, "non named symbol" ); aUsedList.GetFontFormatId( SmFontFormat( rSymbols[i].GetFace() ) , true ); } const SmFormat & rStdFmt = GetStandardFormat(); for (i = FNT_BEGIN; i <= FNT_END; ++i) { aUsedList.GetFontFormatId( SmFontFormat( rStdFmt.GetFont( i ) ) , true ); } // remove unused font-formats from list SmFontFormatList &rFntFmtList = GetFontFormatList(); size_t nCnt = rFntFmtList.GetCount(); std::unique_ptr pTmpFormat(new SmFontFormat[ nCnt ]); std::unique_ptr pId(new OUString[ nCnt ]); size_t k; for (k = 0; k < nCnt; ++k) { pTmpFormat[k] = *rFntFmtList.GetFontFormat( k ); pId[k] = rFntFmtList.GetFontFormatId( k ); } for (k = 0; k < nCnt; ++k) { if (aUsedList.GetFontFormatId( pTmpFormat[k] ).isEmpty()) { rFntFmtList.RemoveFontFormat( pId[k] ); } } } void SmMathConfig::LoadOther() { if (!pOther) pOther.reset(new SmCfgOther); pOther->bPrintTitle = officecfg::Office::Math::Print::Title::get(); pOther->bPrintFormulaText = officecfg::Office::Math::Print::FormulaText::get(); pOther->bPrintFrame = officecfg::Office::Math::Print::Frame::get(); pOther->ePrintSize = static_cast(officecfg::Office::Math::Print::Size::get()); pOther->nSmEditWindowZoomFactor = officecfg::Office::Math::Misc::SmEditWindowZoomFactor::get(); pOther->bIsSaveOnlyUsedSymbols = officecfg::Office::Math::LoadSave::IsSaveOnlyUsedSymbols::get(); pOther->nPrintZoomFactor = officecfg::Office::Math::Print::ZoomFactor::get(); pOther->bIsSaveOnlyUsedSymbols = officecfg::Office::Math::LoadSave::IsSaveOnlyUsedSymbols::get(); pOther->bIsAutoCloseBrackets = officecfg::Office::Math::Misc::AutoCloseBrackets::get(); pOther->nSmSyntaxVersion = officecfg::Office::Math::Misc::DefaultSmSyntaxVersion::get(); pOther->bIgnoreSpacesRight = officecfg::Office::Math::Misc::IgnoreSpacesRight::get(); pOther->bToolboxVisible = officecfg::Office::Math::View::ToolboxVisible::get(); pOther->bAutoRedraw = officecfg::Office::Math::View::AutoRedraw::get(); pOther->bFormulaCursor = officecfg::Office::Math::View::FormulaCursor::get(); SetOtherModified( false ); } void SmMathConfig::SaveOther() { if (!pOther || !IsOtherModified()) return; std::shared_ptr batch(comphelper::ConfigurationChanges::create()); officecfg::Office::Math::Print::Title::set(pOther->bPrintTitle, batch); officecfg::Office::Math::Print::FormulaText::set(pOther->bPrintFormulaText, batch); officecfg::Office::Math::Print::Frame::set(pOther->bPrintFrame, batch); officecfg::Office::Math::Print::Size::set(pOther->ePrintSize, batch); officecfg::Office::Math::Print::ZoomFactor::set(pOther->nPrintZoomFactor, batch); officecfg::Office::Math::Misc::SmEditWindowZoomFactor::set(pOther->nSmEditWindowZoomFactor, batch); officecfg::Office::Math::LoadSave::IsSaveOnlyUsedSymbols::set(pOther->bIsSaveOnlyUsedSymbols, batch); officecfg::Office::Math::Misc::AutoCloseBrackets::set(pOther->bIsAutoCloseBrackets, batch); officecfg::Office::Math::Misc::DefaultSmSyntaxVersion::set(pOther->nSmSyntaxVersion, batch); officecfg::Office::Math::Misc::IgnoreSpacesRight::set(pOther->bIgnoreSpacesRight, batch); officecfg::Office::Math::View::ToolboxVisible::set(pOther->bToolboxVisible, batch); officecfg::Office::Math::View::AutoRedraw::set(pOther->bAutoRedraw, batch); officecfg::Office::Math::View::FormulaCursor::set(pOther->bFormulaCursor, batch); batch->commit(); SetOtherModified( false ); } namespace { // Latin default-fonts const DefaultFontType aLatinDefFnts[FNT_END] = { DefaultFontType::SERIF, // FNT_VARIABLE DefaultFontType::SERIF, // FNT_FUNCTION DefaultFontType::SERIF, // FNT_NUMBER DefaultFontType::SERIF, // FNT_TEXT DefaultFontType::SERIF, // FNT_SERIF DefaultFontType::SANS, // FNT_SANS DefaultFontType::FIXED // FNT_FIXED //OpenSymbol, // FNT_MATH }; // CJK default-fonts //! we use non-asian fonts for variables, functions and numbers since they //! look better and even in asia only latin letters will be used for those. //! At least that's what I was told... const DefaultFontType aCJKDefFnts[FNT_END] = { DefaultFontType::SERIF, // FNT_VARIABLE DefaultFontType::SERIF, // FNT_FUNCTION DefaultFontType::SERIF, // FNT_NUMBER DefaultFontType::CJK_TEXT, // FNT_TEXT DefaultFontType::CJK_TEXT, // FNT_SERIF DefaultFontType::CJK_DISPLAY, // FNT_SANS DefaultFontType::CJK_TEXT // FNT_FIXED //OpenSymbol, // FNT_MATH }; // CTL default-fonts const DefaultFontType aCTLDefFnts[FNT_END] = { DefaultFontType::CTL_TEXT, // FNT_VARIABLE DefaultFontType::CTL_TEXT, // FNT_FUNCTION DefaultFontType::CTL_TEXT, // FNT_NUMBER DefaultFontType::CTL_TEXT, // FNT_TEXT DefaultFontType::CTL_TEXT, // FNT_SERIF DefaultFontType::CTL_TEXT, // FNT_SANS DefaultFontType::CTL_TEXT // FNT_FIXED //OpenSymbol, // FNT_MATH }; OUString lcl_GetDefaultFontName( LanguageType nLang, sal_uInt16 nIdent ) { assert(nIdent < FNT_END); const DefaultFontType *pTable; switch ( SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ) ) { case SvtScriptType::LATIN : pTable = aLatinDefFnts; break; case SvtScriptType::ASIAN : pTable = aCJKDefFnts; break; case SvtScriptType::COMPLEX : pTable = aCTLDefFnts; break; default : pTable = aLatinDefFnts; SAL_WARN("starmath", "unknown script-type"); } return OutputDevice::GetDefaultFont(pTable[ nIdent ], nLang, GetDefaultFontFlags::OnlyOne ).GetFamilyName(); } } void SmMathConfig::LoadFormat() { if (!pFormat) pFormat.reset(new SmFormat); Sequence< OUString > aNames = lcl_GetFormatPropertyNames(); sal_Int32 nProps = aNames.getLength(); Sequence< Any > aValues( GetProperties( aNames ) ); if (!(nProps && aValues.getLength() == nProps)) return; const Any *pValues = aValues.getConstArray(); const Any *pVal = pValues; OUString aTmpStr; sal_Int16 nTmp16 = 0; bool bTmp = false; // StandardFormat/Textmode if (pVal->hasValue() && (*pVal >>= bTmp)) pFormat->SetTextmode( bTmp ); ++pVal; // StandardFormat/GreekCharStyle if (pVal->hasValue() && (*pVal >>= nTmp16)) pFormat->SetGreekCharStyle( nTmp16 ); ++pVal; // StandardFormat/ScaleNormalBracket if (pVal->hasValue() && (*pVal >>= bTmp)) pFormat->SetScaleNormalBrackets( bTmp ); ++pVal; // StandardFormat/HorizontalAlignment if (pVal->hasValue() && (*pVal >>= nTmp16)) pFormat->SetHorAlign( static_cast(nTmp16) ); ++pVal; // StandardFormat/BaseSize if (pVal->hasValue() && (*pVal >>= nTmp16)) pFormat->SetBaseSize( Size(0, SmPtsTo100th_mm( nTmp16 )) ); ++pVal; sal_uInt16 i; for (i = SIZ_BEGIN; i <= SIZ_END; ++i) { if (pVal->hasValue() && (*pVal >>= nTmp16)) pFormat->SetRelSize( i, nTmp16 ); ++pVal; } for (i = DIS_BEGIN; i <= DIS_END; ++i) { if (pVal->hasValue() && (*pVal >>= nTmp16)) pFormat->SetDistance( i, nTmp16 ); ++pVal; } LanguageType nLang = Application::GetSettings().GetUILanguageTag().getLanguageType(); for (i = FNT_BEGIN; i < FNT_END; ++i) { vcl::Font aFnt; bool bUseDefaultFont = true; if (pVal->hasValue() && (*pVal >>= aTmpStr)) { bUseDefaultFont = aTmpStr.isEmpty(); if (bUseDefaultFont) { aFnt = pFormat->GetFont( i ); aFnt.SetFamilyName( lcl_GetDefaultFontName( nLang, i ) ); } else { const SmFontFormat *pFntFmt = GetFontFormatList().GetFontFormat( aTmpStr ); OSL_ENSURE( pFntFmt, "unknown FontFormat" ); if (pFntFmt) aFnt = pFntFmt->GetFont(); } } ++pVal; aFnt.SetFontSize( pFormat->GetBaseSize() ); pFormat->SetFont( i, aFnt, bUseDefaultFont ); } OSL_ENSURE( pVal - pValues == nProps, "property mismatch" ); SetFormatModified( false ); } void SmMathConfig::SaveFormat() { if (!pFormat || !IsFormatModified()) return; const Sequence< OUString > aNames = lcl_GetFormatPropertyNames(); sal_Int32 nProps = aNames.getLength(); Sequence< Any > aValues( nProps ); Any *pValues = aValues.getArray(); Any *pValue = pValues; // StandardFormat/Textmode *pValue++ <<= pFormat->IsTextmode(); // StandardFormat/GreekCharStyle *pValue++ <<= pFormat->GetGreekCharStyle(); // StandardFormat/ScaleNormalBracket *pValue++ <<= pFormat->IsScaleNormalBrackets(); // StandardFormat/HorizontalAlignment *pValue++ <<= static_cast(pFormat->GetHorAlign()); // StandardFormat/BaseSize *pValue++ <<= static_cast(SmRoundFraction( Sm100th_mmToPts( pFormat->GetBaseSize().Height() ) )); sal_uInt16 i; for (i = SIZ_BEGIN; i <= SIZ_END; ++i) *pValue++ <<= static_cast(pFormat->GetRelSize( i )); for (i = DIS_BEGIN; i <= DIS_END; ++i) *pValue++ <<= static_cast(pFormat->GetDistance( i )); for (i = FNT_BEGIN; i < FNT_END; ++i) { OUString aFntFmtId; if (!pFormat->IsDefaultFont( i )) { SmFontFormat aFntFmt( pFormat->GetFont( i ) ); aFntFmtId = GetFontFormatList().GetFontFormatId( aFntFmt, true ); OSL_ENSURE( !aFntFmtId.isEmpty(), "FontFormatId not found" ); } *pValue++ <<= aFntFmtId; } OSL_ENSURE( pValue - pValues == nProps, "property mismatch" ); PutProperties( aNames , aValues ); SetFormatModified( false ); } const SmFormat & SmMathConfig::GetStandardFormat() const { if (!pFormat) const_cast(this)->LoadFormat(); return *pFormat; } void SmMathConfig::SetStandardFormat( const SmFormat &rFormat, bool bSaveFontFormatList ) { if (!pFormat) LoadFormat(); if (rFormat == *pFormat) return; *pFormat = rFormat; SetFormatModified( true ); SaveFormat(); if (bSaveFontFormatList) { // needed for SmFontTypeDialog's DefaultButtonClickHdl if (pFontFormatList) pFontFormatList->SetModified( true ); SaveFontFormatList(); } } SmPrintSize SmMathConfig::GetPrintSize() const { if (!pOther) const_cast(this)->LoadOther(); return pOther->ePrintSize; } void SmMathConfig::SetPrintSize( SmPrintSize eSize ) { if (!pOther) LoadOther(); if (eSize != pOther->ePrintSize) { pOther->ePrintSize = eSize; SetOtherModified( true ); } } sal_uInt16 SmMathConfig::GetPrintZoomFactor() const { if (!pOther) const_cast(this)->LoadOther(); return pOther->nPrintZoomFactor; } void SmMathConfig::SetPrintZoomFactor( sal_uInt16 nVal ) { if (!pOther) LoadOther(); if (nVal != pOther->nPrintZoomFactor) { pOther->nPrintZoomFactor = nVal; SetOtherModified( true ); } } sal_uInt16 SmMathConfig::GetSmEditWindowZoomFactor() const { sal_uInt16 smzoomfactor; if (!pOther) const_cast(this)->LoadOther(); smzoomfactor = pOther->nSmEditWindowZoomFactor; return smzoomfactor < 10 || smzoomfactor > 1000 ? 100 : smzoomfactor; } void SmMathConfig::SetSmEditWindowZoomFactor( sal_uInt16 nVal ) { if (!pOther) LoadOther(); if (nVal != pOther->nSmEditWindowZoomFactor) { pOther->nSmEditWindowZoomFactor = nVal; SetOtherModified( true ); } } void SmMathConfig::SetOtherIfNotEqual( bool &rbItem, bool bNewVal ) { if (bNewVal != rbItem) { rbItem = bNewVal; SetOtherModified( true ); } } bool SmMathConfig::IsPrintTitle() const { if (!pOther) const_cast(this)->LoadOther(); return pOther->bPrintTitle; } void SmMathConfig::SetPrintTitle( bool bVal ) { if (!pOther) LoadOther(); SetOtherIfNotEqual( pOther->bPrintTitle, bVal ); } bool SmMathConfig::IsPrintFormulaText() const { if (!pOther) const_cast(this)->LoadOther(); return pOther->bPrintFormulaText; } void SmMathConfig::SetPrintFormulaText( bool bVal ) { if (!pOther) LoadOther(); SetOtherIfNotEqual( pOther->bPrintFormulaText, bVal ); } bool SmMathConfig::IsSaveOnlyUsedSymbols() const { if (!pOther) const_cast(this)->LoadOther(); return pOther->bIsSaveOnlyUsedSymbols; } bool SmMathConfig::IsAutoCloseBrackets() const { if (!pOther) const_cast(this)->LoadOther(); return pOther->bIsAutoCloseBrackets; } sal_uInt16 SmMathConfig::GetDefaultSmSyntaxVersion() const { if (utl::ConfigManager::IsFuzzing()) return nDefaultSmSyntaxVersion; if (!pOther) const_cast(this)->LoadOther(); return pOther->nSmSyntaxVersion; } bool SmMathConfig::IsPrintFrame() const { if (!pOther) const_cast(this)->LoadOther(); return pOther->bPrintFrame; } void SmMathConfig::SetPrintFrame( bool bVal ) { if (!pOther) LoadOther(); SetOtherIfNotEqual( pOther->bPrintFrame, bVal ); } void SmMathConfig::SetSaveOnlyUsedSymbols( bool bVal ) { if (!pOther) LoadOther(); SetOtherIfNotEqual( pOther->bIsSaveOnlyUsedSymbols, bVal ); } void SmMathConfig::SetAutoCloseBrackets( bool bVal ) { if (!pOther) LoadOther(); SetOtherIfNotEqual( pOther->bIsAutoCloseBrackets, bVal ); } void SmMathConfig::SetDefaultSmSyntaxVersion( sal_uInt16 nVal ) { if (!pOther) LoadOther(); if (nVal != pOther->nSmSyntaxVersion) { pOther->nSmSyntaxVersion = nVal; SetOtherModified( true ); } } bool SmMathConfig::IsIgnoreSpacesRight() const { if (utl::ConfigManager::IsFuzzing()) return false; if (!pOther) const_cast(this)->LoadOther(); return pOther->bIgnoreSpacesRight; } void SmMathConfig::SetIgnoreSpacesRight( bool bVal ) { if (!pOther) LoadOther(); SetOtherIfNotEqual( pOther->bIgnoreSpacesRight, bVal ); } bool SmMathConfig::IsAutoRedraw() const { if (!pOther) const_cast(this)->LoadOther(); return pOther->bAutoRedraw; } void SmMathConfig::SetAutoRedraw( bool bVal ) { if (!pOther) LoadOther(); SetOtherIfNotEqual( pOther->bAutoRedraw, bVal ); } bool SmMathConfig::IsShowFormulaCursor() const { if (!pOther) const_cast(this)->LoadOther(); return pOther->bFormulaCursor; } void SmMathConfig::SetShowFormulaCursor( bool bVal ) { if (!pOther) LoadOther(); SetOtherIfNotEqual( pOther->bFormulaCursor, bVal ); } void SmMathConfig::Notify( const css::uno::Sequence< OUString >& ) {} void SmMathConfig::ItemSetToConfig(const SfxItemSet &rSet) { const SfxPoolItem *pItem = nullptr; sal_uInt16 nU16; bool bVal; if (rSet.GetItemState(SID_PRINTSIZE, true, &pItem) == SfxItemState::SET) { nU16 = static_cast(pItem)->GetValue(); SetPrintSize( static_cast(nU16) ); } if (rSet.GetItemState(SID_PRINTZOOM, true, &pItem) == SfxItemState::SET) { nU16 = static_cast(pItem)->GetValue(); SetPrintZoomFactor( nU16 ); } if (rSet.GetItemState(SID_SMEDITWINDOWZOOM, true, &pItem) == SfxItemState::SET) { nU16 = static_cast(pItem)->GetValue(); SetSmEditWindowZoomFactor( nU16 ); } if (rSet.GetItemState(SID_PRINTTITLE, true, &pItem) == SfxItemState::SET) { bVal = static_cast(pItem)->GetValue(); SetPrintTitle( bVal ); } if (rSet.GetItemState(SID_PRINTTEXT, true, &pItem) == SfxItemState::SET) { bVal = static_cast(pItem)->GetValue(); SetPrintFormulaText( bVal ); } if (rSet.GetItemState(SID_PRINTFRAME, true, &pItem) == SfxItemState::SET) { bVal = static_cast(pItem)->GetValue(); SetPrintFrame( bVal ); } if (rSet.GetItemState(SID_AUTOREDRAW, true, &pItem) == SfxItemState::SET) { bVal = static_cast(pItem)->GetValue(); SetAutoRedraw( bVal ); } if (rSet.GetItemState(SID_NO_RIGHT_SPACES, true, &pItem) == SfxItemState::SET) { bVal = static_cast(pItem)->GetValue(); if (IsIgnoreSpacesRight() != bVal) { SetIgnoreSpacesRight( bVal ); // reformat (displayed) formulas accordingly Broadcast(SfxHint(SfxHintId::MathFormatChanged)); } } if (rSet.GetItemState(SID_SAVE_ONLY_USED_SYMBOLS, true, &pItem) == SfxItemState::SET) { bVal = static_cast(pItem)->GetValue(); SetSaveOnlyUsedSymbols( bVal ); } if (rSet.GetItemState(SID_AUTO_CLOSE_BRACKETS, true, &pItem) == SfxItemState::SET) { bVal = static_cast(pItem)->GetValue(); SetAutoCloseBrackets( bVal ); } if (rSet.GetItemState(SID_DEFAULT_SM_SYNTAX_VERSION, true, &pItem) == SfxItemState::SET) { nU16 = static_cast(pItem)->GetValue(); SetDefaultSmSyntaxVersion( nU16 ); } SaveOther(); } void SmMathConfig::ConfigToItemSet(SfxItemSet &rSet) const { const SfxItemPool *pPool = rSet.GetPool(); rSet.Put(SfxUInt16Item(pPool->GetWhich(SID_PRINTSIZE), sal::static_int_cast(GetPrintSize()))); rSet.Put(SfxUInt16Item(pPool->GetWhich(SID_PRINTZOOM), GetPrintZoomFactor())); rSet.Put(SfxUInt16Item(pPool->GetWhich(SID_SMEDITWINDOWZOOM), GetSmEditWindowZoomFactor())); rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTITLE), IsPrintTitle())); rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTTEXT), IsPrintFormulaText())); rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTFRAME), IsPrintFrame())); rSet.Put(SfxBoolItem(pPool->GetWhich(SID_AUTOREDRAW), IsAutoRedraw())); rSet.Put(SfxBoolItem(pPool->GetWhich(SID_NO_RIGHT_SPACES), IsIgnoreSpacesRight())); rSet.Put(SfxBoolItem(pPool->GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), IsSaveOnlyUsedSymbols())); rSet.Put(SfxBoolItem(pPool->GetWhich(SID_AUTO_CLOSE_BRACKETS), IsAutoCloseBrackets())); rSet.Put(SfxBoolItem(pPool->GetWhich(SID_DEFAULT_SM_SYNTAX_VERSION), GetDefaultSmSyntaxVersion())); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ ion> LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-11-12loplugin:reftotemp in svxNoel Grandin
Change-Id: Ie5f9a7f0e6903476bd02391a71c1f3d75afaf09f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176483 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2024-08-29tdf#161826 - Add uniform Glow effect for texts in shapesBalazs Varga
- Add new text Glow effect properties for shapes - Using TextGlowPrimitive for rendering uniform text glow in shapes - Add/allow new UI Glow Effect for texts in shapes on sidebar (Only for Impress/Draw and Calc) - Import/Export ooxml files with Glow effect on texts in shapes (Only PPTX/XLSX) - Import/Export odf files with Glow effect on texts in shapes - Add unit test for glow text attributes in ODF - Add uni tests for OOXML import/export Note: Also this patch effects on tdf#144061 - Effects: Allow GLOW to apply to Text (as we have for shapes) Change-Id: I16586c01654f197f532129e4e06aa2ef9f214395 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172216 Reviewed-by: Balazs Varga <balazs.varga.extern@allotropia.de> Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
2024-06-11annot: new Annotation sdr object, replacing annotation tagsTomaž Vajngerl
Previously the annotations are shown as annotation (smart) tags, which just mark in the document the existence of an annotation at a certain position. For PDF support the annotations can be more complex, so they can show many forms of vector graphic, ink, bitmaps, text boxes,... and for this a normal tag is not enough. This change moves the annotations from simple tag to use the sdr objects, so any SdrObject can be created as an annotation. The previous tag annotations are using SdrObject (actually SdrRect) subclass AnnotationObject and the code that previouslly worked with the tag annotations has been adapted. The (PDFium based) PDF import has been changed to use subclasses of the SdrObjects for the PDF annotations. Change-Id: I4746b85b5b679499e470987e61ed356397e56bf9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168485 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2024-05-11loplugin:ostr in svxNoel Grandin
Change-Id: Ia765a03e033acb82e367873380d289587ea87d6c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167449 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins
2023-12-30tdf#146619 Recheck svx/ with IWYUGabor Kelemen
Change-Id: I99650b50587294c20b1e92270e541140d9ec9cae Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161240 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
2023-10-18Clean up the remaining uses of OUStringConstExpr, and drop itStephan Bergmann
Change-Id: I30b2ac77b58e2ae1d1e997a0c830c513542b973d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158101 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-10-11Drop o3tl::span, can use C++20 std::span directly nowStephan Bergmann
Change-Id: Ic21ff7bf48f07f7277979d52e99d2c5c268de83f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157825 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-10-07loplugin:ostr: automatic rewriteStephan Bergmann
Change-Id: I2d09b2b83e1b50493ec88d0b2c323a83c0c86395 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157647 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Jenkins
2023-07-05tdf#138504 svx,etc.: decorative flag on SdrObject shapesMichael Stahl
* SdrObject new member m_IsDecorative * new Undo SdrUndoObjDecorative * surprising amount of changes in sw including additional SwUndoFlyDecorative * svx API SvxShape property "Decorative" * UI checkbox "Decorative" * ODF import/export as loext:decorative on style:graphic-properties * PDF/UA export: ViewObjectContcat tag shapes with this flag as Artifact Change-Id: I37f7a0597eab92c6c6aff94fad6c16c59b231c80 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154063 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2023-05-12use ComplexColor instead of ThemeColor for better OOXML compat.Tomaž Vajngerl
In OOXML a color definition includes more represenations, one of which is scheme color (which is what is implemented in ThemeColor currently), but it supports other representations too (RGB, HSL, System,..). ComplexColor includes all the representations, so to have a better compatibility with OOXML, this changes all uses of ThemeColor to ComplexColor. In many cases the usage of ComplexColor isn't the same as the usage of ThemeColors, but this cases will need to be changed in a later commit. Change-Id: I9cc8acee2ac0a1998fe9b98247bcf4a96273149a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151492 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2023-04-29use XThemeColor instead of XInterface for *ThemeReference propsTomaž Vajngerl
Change-Id: I23b6a7429bbcf7901f3d817c970ee7ef4a453197 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151184 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2023-03-10simplify initialisation of some pool defaultsNoel Grandin
Change-Id: I794e528a08a5a76cef1955f5c4f3e594f1e90f4a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148537 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-01-13introduce {Char,Fill}ColorThemeReference which uses XThemeColorTomaž Vajngerl
Adds a unified UNO property for theme colors *ColorTheme (CharColorTheme and FillColorTheme) which uses XThemeColor, that replaces the properties *Theme, *TintOrShade, *LumOff, *LumMod. The properties are still present for backwards compatibility and to keep ODF support working in tests as that needs a bigger change. Reactor the code and tests to accomodate for this change. Change-Id: If7983decb4ba528b49fe7b5968aa9efc696a9efc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144783 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
2022-09-09tdf#150732 ReportBuilder: Moving fields from one section to another crashesNoel Grandin
regression from commit 8611f6e259b807b4f19c8dc0eab86ca648891ce3 Author: Noel Grandin <noel.grandin@collabora.co.uk> Date: Thu May 27 10:27:46 2021 +0200 ref-count SdrObject Fixes 2 issues (1) where I removed some code that we need (2) where the OUnoObject constructor was deleting the object is was constructing Note that this only fixes the crash that Julien saw, not the underlying problem that this tdf bug reports. That bug appears to predate my commit. Change-Id: I3878ef460dedc3c2a6c86b88fce9d155e79bc0b8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139714 Tested-by: Julien Nabet <serval2412@yahoo.fr> Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-08-25Related: tdf#149971 avmedia: add doc model and render for crop of media objectsMiklos Vajna
It is possible to provide an explicit preview of media objects since commit 8fa1d453c94cdbb03dac646fb8db2ebd1a0e84bd (Related: tdf#149971 svx: support explicitly provided snapshots for media shapes, 2022-08-24), however they can't be cropped. This means that media shapes from PPTX with cropping show unexpected content and can also have a buggy aspect ratio. Extend avmedia::MediaItem to store cropping and take it into account when returning the preview bitmap in SdrMediaObj::getSnapshot(). PPTX import works out of the box, as oox/ already tried to set a cropping property on the media shape. This is just the preview, the cropping of the video itself is not yet implemented. Change-Id: I8db3e0dcf252613d56eb0e6139adf097e53b15cc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138808 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
2022-07-25use more o3tl::spanNoel Grandin
which means we can reserve precisely the right number of entries when building maps Change-Id: I580414699289369de4730caae09829bbd8759e82 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137292 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-24modernize and improve PropertySetInfoNoel Grandin
(*) use o3tl::span for the array param, which means we don't need a null entry to terminate the array (*) use std::unordered_map to speed things up (*) mark the array as static at a few more call sites Change-Id: I05b6cae7552f44459e183ec05cb94e60edb3bfe0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134832 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-05-01use more string_view in variousNoel Grandin
found by examining uses of OUString::copy() for likely places Change-Id: I6ff20e7b273ad6005410b82719183c1122f8c018 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133617 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-04-13tdf#80633 speed up dialog layoutNoel Grandin
some small speedups when opening Format->Paragraph Change-Id: If97725ecff45b9c2c01b405e153ec05b12882573 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132952 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-04-12loplugin:stringview more o3tl conversionNoel Grandin
look for call sequences that can use string_view and the new o3tl functions in o3tl/string_view.hxx Also add a few more wrappers to said #include file Change-Id: I05d8752cc67a7b55b0b57e8eed803bd06bfcd9ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132840 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-03-03Recheck modules sv* with IWYUGabor Kelemen
See tdf#42949 for motivation Change-Id: I25779cbfb1aa93c31d6e12ac95e136b3bdbbc058 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130403 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2022-01-07remove E3D_INVENTOR_FLAG and convert SdrObjKind to scoped enumNoel Grandin
We don't need E3D_INVENTOR_FLAG, we can just check if the SdrObjKind is in the right range. Which exposes some dodgy code in DrawViewShell::GetMenuStateSel SfxItemState::DEFAULT == rSet.GetItemState( OBJ_TITLETEXT ) || SfxItemState::DEFAULT == rSet.GetItemState( OBJ_OUTLINETEXT ) || which has been there ever since commit f47a9d9db3d06927380bb79b04bb6d4721a92d2b Date: Mon Sep 18 16:07:07 2000 +0000 initial import just remove that. In SwFEShell::ImpEndCreate() move some logic around to avoid using an out-of-range SdrObjKind value Change-Id: I4620bfe61aca8f7415503debe3c84bfe5f4368a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127763 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-11-26use more OUStringLiteral in svxNoel Grandin
Change-Id: Ifdcfa4e1f9a42618061642ffe05eaa2a32e1010e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125882 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-11-26loplugin:stringliteraldefine in svxNoel Grandin
Change-Id: I2375ebfe9791c43063ffbc8ddbe1bd365499a576 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125868 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-11-17expose the SvxColorItem theme related uno for draw/impressSarper Akdemir
[ Miklos: added the missing SvxShapeControlPropertyMapping entries, breaking tests. ] (cherry picked from commit 88b6801ff2aa61ed2f0d64cef94fe6a9c09f3a35, from the feature/themesupport2 branch) Change-Id: Ifdcde6c4643eb9ac1c36040f5ccb490b9d900efd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125394 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2021-11-03Avoid false -Werror=array-boundsStephan Bergmann
...with recent GCC 12 trunk, > svx/source/unodraw/unoprov.cxx:904:28: error: array subscript 25 is above array bounds of ‘const SfxItemPropertyMapEntry* [25]’ [-Werror=array-bounds] > 904 | if(!aMapArr[nPropertyId]) { > | ~~~~~~~~~~~~~~~~~~~^ > In file included from svx/source/unodraw/shapeimpl.hxx:22, > from svx/source/unodraw/unoprov.cxx:45: > include/svx/unoprov.hxx:86:37: note: while referencing ‘SvxUnoPropertyMapProvider::aMapArr’ > 86 | SfxItemPropertyMapEntry const * aMapArr[SVXMAP_END]; > | ^~~~~~~ Change-Id: I60e5352aff0d0aed3056bc484fb1491626761051 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124655 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-08-05Pass context and resource string down to boost::locale separatelyNoel Grandin
because this is often on a hot path, and we can avoid the splitting and joining of strings like this. Change-Id: Ia36047209368ca53431178c2e8723a18cfe8260a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119220 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-07-29rtl::Static -> static localNoel Grandin
Change-Id: Ib8d9a24659a37e6b94237d98f030cd2be00bcb39 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119665 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-06-30tdf#139301 tdf#141933 (related) Translate new preset dash namesGabor Kelemen
Change-Id: I9cd7ad0eca1a6fb471a284fb2828a7ad12816337 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117024 Tested-by: Jenkins Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
2021-05-02throw() -> noexcept, part 2/3: Automatic loplugin:noexcept rewriteStephan Bergmann
Change-Id: I076f16d0536b534abf0ced4d76051eadb4c0e033 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114949 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-01-21avmedia: add doc model for bitmap fill of slide narrationsMiklos Vajna
This allows specifying a custom bitmap for a media shape. It's mostly useful for audio-only streams where the additional bitmap may be e.g. a speaker icon to indicate this a narration. Change-Id: I21c1b492ac09b631cf6e3ec8120be8b82c01c26d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109763 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins