/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * 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 .
*/
void CommandCategoryListBox::ClearAll()
{ // Clear objects from m_aGroupInfo vector to avoid memory leak for (constauto& It : m_aGroupInfo)
{ if (It->nKind == SfxCfgKind::GROUP_STYLES && It->pObject)
{
SfxStyleInfo_Impl* pStyle = static_cast<SfxStyleInfo_Impl*>(It->pObject); delete pStyle;
} elseif (It->nKind == SfxCfgKind::FUNCTION_SCRIPT && It->pObject)
{
OUString* pScriptURI = static_cast<OUString*>(It->pObject); delete pScriptURI;
} elseif (It->nKind == SfxCfgKind::GROUP_SCRIPTCONTAINER && It->pObject)
{
css::uno::XInterface* xi = static_cast<css::uno::XInterface*>(It->pObject); if (xi != nullptr)
{
xi->release();
}
}
}
m_aGroupInfo.clear();
m_xControl->clear();
}
void CommandCategoryListBox::Init(const css::uno::Reference<css::uno::XComponentContext>& xContext, const css::uno::Reference<css::frame::XFrame>& xFrame, const OUString& sModuleLongName)
{ // User will not see incomplete UI
m_xControl->freeze();
ClearAll();
if (nGroupsLength > 0)
{ // Add the category of "All commands"
m_aGroupInfo.push_back(
std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_ALLFUNCTIONS, 0));
m_xControl->append(weld::toId(m_aGroupInfo.back().get()),
CuiResId(RID_CUISTR_ALLFUNCTIONS));
}
// Separate the "All commands"category from the actual categories
m_xControl->append_separator(u""_ustr);
// Add the actual categories for (sal_Int32 i = 0; i < nGroupsLength; ++i)
{
sal_Int16 nGroupID = lGroups[i];
OUString sGroupID = OUString::number(nGroupID);
OUString sGroupName;
break;
} case SfxCfgKind::GROUP_FUNCTION:
{
sal_uInt16 nGroup = pInfo->nUniqueID;
css::uno::Reference<css::frame::XDispatchInformationProvider> xProvider(
m_xFrame, css::uno::UNO_QUERY_THROW);
css::uno::Sequence<css::frame::DispatchInformation> lCommands
= xProvider->getConfigurableDispatchInformation(nGroup);
FillFunctionsList(lCommands, pFunctionListBox, filterTerm, pCurrentSaveInData); break;
} case SfxCfgKind::GROUP_SCRIPTCONTAINER: //Macros
{
SAL_INFO("cui.customize", "** ** About to initialise SF Scripts"); // Add Scripting Framework entries
css::uno::Reference<css::script::browse::XBrowseNode> rootNode; try
{
css::uno::Reference<css::script::browse::XBrowseNodeFactory> xFac
= css::script::browse::theBrowseNodeFactory::get(m_xContext);
rootNode.set(xFac->createView(
css::script::browse::BrowseNodeFactoryViewTypes::MACROSELECTOR));
} catch (css::uno::Exception const&)
{
TOOLS_WARN_EXCEPTION( "cui.customize", "Caught some exception whilst retrieving browse nodes from factory"); // TODO exception handling
}
if (rootNode.is() && rootNode->hasChildNodes())
{ //We call acquire on the XBrowseNode so that it does not //get autodestructed and become invalid when accessed later.
rootNode->acquire();
{ // tdf#128010: Do not nag user asking to enable JRE: if it's disabled, // simply don't show relevant entries (user chose to not use JRE)
css::uno::ContextLayer layer(
comphelper::NoEnableJavaInteractionContext()); //Add the children and the grand children
addChildren(xMacroGroup.get(), childGroup, pFunctionListBox, filterTerm,
pCurrentSaveInData, aNodesToExpand);
}
// Remove the main group if empty if (!pFunctionListBox->iter_has_child(*xMacroGroup))
{
pFunctionListBox->remove(*xMacroGroup);
} elseif (!filterTerm.isEmpty())
{
aNodesToExpand.emplace_back(std::move(xMacroGroup));
}
}
}
}
break;
} case SfxCfgKind::GROUP_STYLES:
{ const std::vector<SfxStyleInfo_Impl> lStyleFamilies = pStylesInfo->getStyleFamilies();
for (constauto& pIt : lStyleFamilies)
{ if (pIt.sLabel.isEmpty())
{ continue;
}
m_aGroupInfo.push_back(
std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_STYLES, 0)); // pIt.sLabel is Name of the style family
std::unique_ptr<weld::TreeIter> xFuncEntry(pFunctionListBox->tree_append(
weld::toId(m_aGroupInfo.back().get()), pIt.sLabel));
// Remove the style group from the list if no children if (!pFunctionListBox->iter_has_child(*xFuncEntry))
{
pFunctionListBox->remove(*xFuncEntry);
} elseif (!filterTerm.isEmpty())
{
aNodesToExpand.emplace_back(std::move(xFuncEntry));
}
}
break;
} default: // Do nothing, the list box will stay empty
SAL_INFO("cui.customize", "Ignoring unexpected SfxCfgKind: " << static_cast<int>(pInfo->nKind)); break;
}
pFunctionListBox->thaw();
if (pFunctionListBox->n_children())
pFunctionListBox->select(0);
//post freeze for (constauto& it : aNodesToExpand)
pFunctionListBox->expand_row(*it);
}
css::uno::Any value = xPropSet->getPropertyValue(u"URI"_ustr);
value >>= uri;
try
{
value = xPropSet->getPropertyValue(u"Description"_ustr);
value >>= description;
} catch (css::uno::Exception&)
{ // do nothing, the description will be empty
}
if (description.isEmpty())
{
description = CuiResId(RID_CUISTR_NOMACRODESC);
}
OUString* pScriptURI = new OUString(uri);
css::uno::Reference<css::graphic::XGraphic> xImage; if (pCurrentSaveInData)
xImage = pCurrentSaveInData->GetImage(uri);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.